Edit mode

This commit is contained in:
nds 2016-11-09 13:05:20 +03:00
parent d61dfb05a3
commit 3d5732ec1d
6 changed files with 186 additions and 35 deletions

View File

@ -156,6 +156,78 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex
storeVisibleState( theEntry, theView ); storeVisibleState( theEntry, theView );
} }
void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperty )
{
SUIT_Session* ses = SUIT_Session::session();
SUIT_Application* app = ses->activeApplication();
if ( app )
{
SUIT_Desktop* desk = app->desktop();
QList<SUIT_ViewWindow*> wnds = desk->windows();
SUIT_ViewWindow* wnd;
QListIterator<SUIT_ViewWindow*> it( wnds );
while ( it.hasNext() && (wnd = it.next()) )
{
SUIT_ViewManager* vman = wnd->getViewManager();
if ( vman )
{
SUIT_ViewModel* vmodel = vman->getViewModel();
if ( vmodel )
{
SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
if ( aView )
Redisplay( theEntry, theIndex, theProperty, aView );
}
}
}
}
}
void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperty,
SALOME_View* theView )
{
SALOME_View* aView = viewOrActiveView( theView );
if ( !aView )
return;
if ( !myVisualized.contains( aView ) )
return;
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
if ( !anEntryToAnnotation.contains( theEntry ) )
return;
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
if ( !anAnnotationToPrs.contains( theIndex ) )
return;
GEOMGUI_AnnotationAttrs::Properties aProperty;
GEOM::GEOM_Object_ptr anObject;
getObject( theEntry, theIndex, anObject, aProperty );
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
// erase presentation from the viewer
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
SOCC_Viewer* anOCCViewer = dynamic_cast<SOCC_Viewer*>(theView);
if ( anOCCPrs && anOCCViewer ) {
AIS_ListOfInteractive anIOs;
anOCCPrs->GetObjects( anIOs );
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
for ( ; anIter.More(); anIter.Next() ) {
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
Handle(GEOM_Annotation) aPresentation = Handle(GEOM_Annotation)::DownCast( aPrs );
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
anOCCViewer->getAISContext()->Redisplay(aPresentation);
}
}
}
void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SALOME_View* theView ) void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SALOME_View* theView )
{ {
SALOME_View* aView = viewOrActiveView( theView ); SALOME_View* aView = viewOrActiveView( theView );

View File

@ -59,6 +59,10 @@ public:
bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const; bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const;
void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ); void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 );
void Erase( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ); void Erase( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 );
void Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperties);
void Redisplay( const QString& theEntry, const int theIndex,
const GEOMGUI_AnnotationAttrs::Properties& theProperties, SALOME_View* theView );
void DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); void DisplayVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );
void EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); void EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 );

View File

@ -387,6 +387,15 @@ GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
return myAnnotationMgr; return myAnnotationMgr;
} }
//=======================================================================
// function : GeometryGUI::SetActiveDialogBox()
// purpose : Set active dialog box
//=======================================================================
GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
{
return myTextTreeWdg;
}
//======================================================================= //=======================================================================
// function : GeometryGUI::SetActiveDialogBox() // function : GeometryGUI::SetActiveDialogBox()
// purpose : Set active dialog box // purpose : Set active dialog box

View File

@ -102,6 +102,8 @@ public:
GEOMGUI_AnnotationMgr* GetAnnotationMgr(); GEOMGUI_AnnotationMgr* GetAnnotationMgr();
GEOMGUI_TextTreeWdg* GetTextTreeWdg() const;
// Get active dialog box // Get active dialog box
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; } QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
// Set active dialog box // Set active dialog box

View File

@ -32,6 +32,7 @@
#include <GEOM_Displayer.h> #include <GEOM_Displayer.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMGUI_AnnotationMgr.h> #include <GEOMGUI_AnnotationMgr.h>
#include <GEOMGUI_TextTreeWdg.h>
#include <SOCC_Prs.h> #include <SOCC_Prs.h>
#include <SOCC_ViewModel.h> #include <SOCC_ViewModel.h>
@ -161,6 +162,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI,
QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup ); QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup );
mySubShapeTypeCombo = new QComboBox( propGroup ); mySubShapeTypeCombo = new QComboBox( propGroup );
mySubShapeTypeCombo->setEnabled( myIsCreation );
mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE ); mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE );
mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX ); mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX );
mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE ); mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE );
@ -232,9 +234,10 @@ void MeasureGUI_AnnotationDlg::Init()
// update internal controls and fields following to default values // update internal controls and fields following to default values
activateSelectionArgument( myShapeSelBtn ); activateSelectionArgument( myShapeSelBtn );
myTextEdit->setText( myAnnotationProperties.Text ); myTextEdit->setText( myAnnotationProperties.Text );
myShapeNameModified = false; myShapeNameModified = false;
myTypeCombo->setCurrentIndex( 0 ); myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 );
int aSubShapeTypeIndex = -1; int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count(); int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
@ -261,10 +264,69 @@ void MeasureGUI_AnnotationDlg::Init()
this, SLOT( onSubShapeTypeChange() ) ); this, SLOT( onSubShapeTypeChange() ) );
//SelectionIntoArgument(); //SelectionIntoArgument();
} else { // edition
}
redisplayPreview(); redisplayPreview();
} else { // edition
mySelectionMode = TopAbs_SHAPE;
// find annotation
GEOMGUI_TextTreeWdg* aTextTreeWdg = myGeomGUI->GetTextTreeWdg();
// text tree widget should be not empty
QMap<QString, QList<int> > anAnnotations;
aTextTreeWdg->getSelected( anAnnotations );
// there is only one annotation selected when edit is started
QMap<QString, QList<int> >::const_iterator anIt = anAnnotations.begin();
myEditAnnotationEntry = anIt.key();
myEditAnnotationIndex = anIt.value()[0];
SalomeApp_Study* aStudy = getStudy();
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myEditAnnotationEntry.toStdString() );
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
if ( !aShapeAnnotations.IsNull() ) {
aShapeAnnotations->GetProperties( myEditAnnotationIndex, myAnnotationProperties );
myShape = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
}
/// fill dialog controls
myTextEdit->setText( myAnnotationProperties.Text );
myShapeNameModified = false;
myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 );
int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
int aType = mySubShapeTypeCombo->itemData( i ).toInt();
if ( aType == myAnnotationProperties.ShapeType )
aSubShapeTypeIndex = i;
}
mySubShapeTypeCombo->setCurrentIndex( aSubShapeTypeIndex );
QString aShapeName = "";
_PTR(GenericAttribute) anAttr;
if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
_PTR(AttributeName) aNameAttr( anAttr );
aNameAttr->Value();
aShapeName = aNameAttr->Value().c_str();
}
myShapeName->setText( aShapeName );
QString aSubShapeName = "";
TopAbs_ShapeEnum aShapeType = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
if ( aShapeType != TopAbs_SHAPE ) {
aSubShapeName = QString( "%1:%2_%3" ).arg( aShapeName )
.arg( GEOMBase::TypeName( aShapeType ) )
.arg( myAnnotationProperties.ShapeIndex );
}
mySubShapeName->setText( aSubShapeName );
mySelectionMode = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
//SelectionIntoArgument();
updateSubShapeEnableState();
// connect controls
connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) );
}
} }
//================================================================================= //=================================================================================
@ -693,15 +755,13 @@ bool MeasureGUI_AnnotationDlg::execute()
if ( !isValid( anError ) ) if ( !isValid( anError ) )
return false; return false;
if ( myIsCreation ) {
SalomeApp_Study* aStudy = getStudy(); SalomeApp_Study* aStudy = getStudy();
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() ); _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() );
Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations =
GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy ); GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy );
if ( myIsCreation ) {
myAnnotationProperties.IsVisible = true; // initially created annotation is hidden myAnnotationProperties.IsVisible = true; // initially created annotation is hidden
aShapeAnnotations->Append( myAnnotationProperties ); aShapeAnnotations->Append( myAnnotationProperties );
@ -713,13 +773,8 @@ bool MeasureGUI_AnnotationDlg::execute()
myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 ); myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 );
} }
else { else {
/*SalomeApp_Study* aStudy = getStudy();
myAnnotationProperties = aStudy->getObjectProperty( GEOM::sharedPropertiesId(), aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties );
myShape->GetStudyEntry(),
GEOM::propertyName( GEOM::ShapeAnnotations ),
QVariant() )
.value<GEOMGUI_ShapeAnnotations>();
mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );*/
} }
return true; return true;
} }
@ -765,6 +820,8 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
//================================================================================= //=================================================================================
void MeasureGUI_AnnotationDlg::redisplayPreview() void MeasureGUI_AnnotationDlg::redisplayPreview()
{ {
if ( myIsCreation ) {
QString aMess; QString aMess;
if ( !isValid( aMess ) ) { if ( !isValid( aMess ) ) {
erasePreview( true ); erasePreview( true );
@ -784,6 +841,11 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
} catch ( ... ) { } catch ( ... ) {
} }
} }
else {
myGeomGUI->GetAnnotationMgr()->Redisplay( myEditAnnotationEntry, myEditAnnotationIndex,
myAnnotationProperties );
}
}
//================================================================================= //=================================================================================
// function : getPickedPoint // function : getPickedPoint

View File

@ -101,6 +101,8 @@ private:
private: private:
TopAbs_ShapeEnum mySelectionMode; TopAbs_ShapeEnum mySelectionMode;
QString myEditAnnotationEntry;
int myEditAnnotationIndex;
GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties; GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties;
bool myIsPositionDefined; bool myIsPositionDefined;
/// an index of edited annotation in the list shape annotations, -1 in create operation /// an index of edited annotation in the list shape annotations, -1 in create operation