]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Edit mode
authornds <natalia.ermolaeva@opencascade.com>
Wed, 9 Nov 2016 10:05:20 +0000 (13:05 +0300)
committernds <natalia.ermolaeva@opencascade.com>
Wed, 9 Nov 2016 10:05:20 +0000 (13:05 +0300)
src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
src/GEOMGUI/GEOMGUI_AnnotationMgr.h
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
src/MeasureGUI/MeasureGUI_AnnotationDlg.h

index 6ed2039cfcd863c3fdefe4802c3dcbfe53c99428..cb682e6c11925ed2b553c5b1df31af8a5f65d9be 100755 (executable)
@@ -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<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 )
 {
   SALOME_View* aView = viewOrActiveView( theView );
index de7cfcc676bc2df88386664370147bcf530beac5..9958432073698b87b6ddf13dbe4e9c89bf4af8e8 100755 (executable)
@@ -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 );
index 68372278147e2e726abd16adf7fedad87c0c51c1..ab55900c5176bcbabc36ead21084330bac254bfb 100755 (executable)
@@ -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
index 2481cdfad9814bd83ae6a09835b31030a5188388..0e525758870cb863d01bb077a46626158caa4592 100644 (file)
@@ -102,6 +102,8 @@ public:
 
   GEOMGUI_AnnotationMgr*      GetAnnotationMgr();
 
+  GEOMGUI_TextTreeWdg*        GetTextTreeWdg() const;
+
   // Get active dialog box
   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
   // Set active dialog box
index 2d347c99b9c0b2250a503839605bd265012baf51..a99aab047da881406685d1fbb55bd4eb21d2b58c 100755 (executable)
@@ -32,6 +32,7 @@
 #include <GEOM_Displayer.h>
 #include <GeometryGUI.h>
 #include <GEOMGUI_AnnotationMgr.h>
+#include <GEOMGUI_TextTreeWdg.h>
 
 #include <SOCC_Prs.h>
 #include <SOCC_ViewModel.h>
@@ -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<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() ) );
   }
-  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<GEOMGUI_ShapeAnnotations>();
-    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 );
   }
 }
 
index 4ca12bc0b4c2d3390f6b52d3a40561f90200620d..a3f0bf04e1d96cd3d4cd050c91243e6568448de1 100755 (executable)
@@ -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