From: nds Date: Wed, 9 Nov 2016 10:05:20 +0000 (+0300) Subject: Edit mode X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d5732ec1d17b21e8a1517a41d3c370e649acd17;p=modules%2Fgeom.git Edit mode --- diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx index 6ed2039cf..cb682e6c1 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx @@ -156,6 +156,78 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex 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 wnds = desk->windows(); + SUIT_ViewWindow* wnd; + QListIterator 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(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( aPrs ); + SOCC_Viewer* anOCCViewer = dynamic_cast(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 ) { SALOME_View* aView = viewOrActiveView( theView ); diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h index de7cfcc67..995843207 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h @@ -59,7 +59,11 @@ public: 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 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 EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); void UpdateVisibleAnnotations( const QString& theEntry, SALOME_View* theView = 0 ); diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 683722781..ab55900c5 100755 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -387,6 +387,15 @@ GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr() return myAnnotationMgr; } +//======================================================================= +// function : GeometryGUI::SetActiveDialogBox() +// purpose : Set active dialog box +//======================================================================= +GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const +{ + return myTextTreeWdg; +} + //======================================================================= // function : GeometryGUI::SetActiveDialogBox() // purpose : Set active dialog box diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 2481cdfad..0e5257588 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -102,6 +102,8 @@ public: GEOMGUI_AnnotationMgr* GetAnnotationMgr(); + GEOMGUI_TextTreeWdg* GetTextTreeWdg() const; + // Get active dialog box QDialog* GetActiveDialogBox(){ return myActiveDialogBox; } // Set active dialog box diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx index 2d347c99b..a99aab047 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -161,6 +162,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup ); mySubShapeTypeCombo = new QComboBox( propGroup ); + mySubShapeTypeCombo->setEnabled( myIsCreation ); mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE ); mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX ); mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE ); @@ -232,9 +234,10 @@ void MeasureGUI_AnnotationDlg::Init() // update internal controls and fields following to default values activateSelectionArgument( myShapeSelBtn ); + myTextEdit->setText( myAnnotationProperties.Text ); myShapeNameModified = false; - myTypeCombo->setCurrentIndex( 0 ); + myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed ? 0 : 1 ); int aSubShapeTypeIndex = -1; int aTypesCount = aTypesCount = mySubShapeTypeCombo->count(); @@ -261,10 +264,69 @@ void MeasureGUI_AnnotationDlg::Init() this, SLOT( onSubShapeTypeChange() ) ); //SelectionIntoArgument(); + + redisplayPreview(); } else { // edition + mySelectionMode = TopAbs_SHAPE; + // find annotation + GEOMGUI_TextTreeWdg* aTextTreeWdg = myGeomGUI->GetTextTreeWdg(); + // text tree widget should be not empty + QMap > anAnnotations; + aTextTreeWdg->getSelected( anAnnotations ); + // there is only one annotation selected when edit is started + QMap >::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() ) ); } - redisplayPreview(); } //================================================================================= @@ -693,15 +755,13 @@ bool MeasureGUI_AnnotationDlg::execute() if ( !isValid( anError ) ) 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 = - GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy ); + Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = + GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy ); + if ( myIsCreation ) { myAnnotationProperties.IsVisible = true; // initially created annotation is hidden aShapeAnnotations->Append( myAnnotationProperties ); @@ -713,13 +773,8 @@ bool MeasureGUI_AnnotationDlg::execute() myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 ); } else { - /*SalomeApp_Study* aStudy = getStudy(); - myAnnotationProperties = aStudy->getObjectProperty( GEOM::sharedPropertiesId(), - myShape->GetStudyEntry(), - GEOM::propertyName( GEOM::ShapeAnnotations ), - QVariant() ) - .value(); - mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );*/ + + aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties ); } return true; } @@ -765,23 +820,30 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState() //================================================================================= void MeasureGUI_AnnotationDlg::redisplayPreview() { - QString aMess; - if ( !isValid( aMess ) ) { - erasePreview( true ); - return; - } + if ( myIsCreation ) { - erasePreview( false ); + QString aMess; + if ( !isValid( aMess ) ) { + erasePreview( true ); + return; + } - try { - SUIT_OverrideCursor wc; - getDisplayer()->SetToActivate( true ); + erasePreview( false ); - if ( SALOME_Prs* aPrs = buildPrs() ) - displayPreview( aPrs ); - } catch ( const SALOME::SALOME_Exception& e ) { - SalomeApp_Tools::QtCatchCorbaException( e ); - } catch ( ... ) { + try { + SUIT_OverrideCursor wc; + getDisplayer()->SetToActivate( true ); + + if ( SALOME_Prs* aPrs = buildPrs() ) + displayPreview( aPrs ); + } catch ( const SALOME::SALOME_Exception& e ) { + SalomeApp_Tools::QtCatchCorbaException( e ); + } catch ( ... ) { + } + } + else { + myGeomGUI->GetAnnotationMgr()->Redisplay( myEditAnnotationEntry, myEditAnnotationIndex, + myAnnotationProperties ); } } diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h index 4ca12bc0b..a3f0bf04e 100755 --- a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h +++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h @@ -101,6 +101,8 @@ private: private: TopAbs_ShapeEnum mySelectionMode; + QString myEditAnnotationEntry; + int myEditAnnotationIndex; GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties; bool myIsPositionDefined; /// an index of edited annotation in the list shape annotations, -1 in create operation