]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Local selection in annotation dialog.
authornds <natalia.ermolaeva@opencascade.com>
Thu, 6 Oct 2016 11:33:25 +0000 (14:33 +0300)
committernds <natalia.ermolaeva@opencascade.com>
Thu, 6 Oct 2016 11:33:25 +0000 (14:33 +0300)
src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
src/GEOMGUI/GEOM_msg_en.ts
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
src/MeasureGUI/MeasureGUI_AnnotationDlg.h

index 2e3218b1e20e66607f095845d6179bb8be58455c..d7b0c221cdd7aacdec4f4f5d87fea8da55bb5790 100644 (file)
@@ -84,6 +84,12 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
   myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
   addTopLevelItem( myDimensionsItem );
 
+  rootNames.clear();
+  rootNames << tr("GEOM_ANNOTATIONS") << "";
+  myAnnotationsItem = new QTreeWidgetItem( this, rootNames );
+  myAnnotationsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+  addTopLevelItem( myAnnotationsItem );
+
   // get a free dockable window id
   myWindowID = 11;
   while( app->dockWindow( myWindowID ))
index 4f6677c88047b0fefdf6ab3057a620fd52b23123..6efa1609ab225217683c982250bc9522da668536 100644 (file)
@@ -81,6 +81,7 @@ private slots:
   QHash<QString, QTreeWidgetItem*> myObjects;
   SalomeApp_Study*              myStudy;
   QTreeWidgetItem*              myDimensionsItem;
+  QTreeWidgetItem*              myAnnotationsItem;
   GEOM_Displayer                myDisplayer;
 
   QMap<int, QAction*>           myActions;   //!< menu actions list
index 5fedc59b9878cf0c284882c4391f076daec22cf4..8cd44f2a40854c8534d98c8e806ca9b4dfd3b706 100755 (executable)
@@ -575,6 +575,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_DIMENSIONS</source>
         <translation>Dimensions</translation>
     </message>
+    <message>
+        <source>GEOM_ANNOTATIONS</source>
+        <translation>Annotations</translation>
+    </message>
     <message>
         <source>GEOM_SKETCHER_DIST</source>
         <translation>Distance</translation>
@@ -6757,6 +6761,10 @@ Please specify suitable arguments.</translation>
         <source>ANNOTATION_SUB_SHAPE</source>
         <translation>Sub-shape type</translation>
     </message>
+    <message>
+        <source>WHOLE_SHAPE</source>
+        <translation>Whole shape</translation>
+    </message>
     <message>
         <source>ANNOTATION_STYLE</source>
         <translation>Style</translation>
index be023857fd9839782f44a8697a287bca889cb7ef..705877db39df2aea1ba473dbc369241c155ffd9d 100644 (file)
@@ -148,16 +148,11 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
 
   QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
   mySubShapeTypeCombo = new QComboBox(propGroup);
-  QMap<QString, TopAbs_ShapeEnum> aShapeTypes;
-  aShapeTypes[tr("WHOLE_SHAPE")] = TopAbs_SHAPE;
-  aShapeTypes[tr("GEOM_VERTEX")] = TopAbs_VERTEX;
-  aShapeTypes[tr("GEOM_EDGE")] = TopAbs_EDGE;
-  aShapeTypes[tr("GEOM_FACE")] = TopAbs_FACE;
-  aShapeTypes[tr("GEOM_SOLID")] = TopAbs_SOLID;
-  QMap<QString, TopAbs_ShapeEnum>::const_iterator anIt = aShapeTypes.begin(),
-                                                  aLast = aShapeTypes.end();
-  for (; anIt != aLast; anIt++)
-    mySubShapeTypeCombo->addItem(anIt.key(), anIt.value());
+  mySubShapeTypeCombo->addItem(tr("WHOLE_SHAPE"), TopAbs_SHAPE);
+  mySubShapeTypeCombo->addItem(tr("GEOM_VERTEX"), TopAbs_VERTEX);
+  mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
+  mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
+  mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
   mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX
 
   propLayout->addWidget(shapeTypeLabel, 3, 0);
@@ -224,17 +219,16 @@ void MeasureGUI_AnnotationDlg::Init()
 
     // default presentation values
     myAnnotationProperties.Position = gp_Pnt(50, 50, 50);
-    myAnnotationProperties.Text = "Text";
+    myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
     myAnnotationProperties.IsVisible = true;
-    myAnnotationProperties.IsScreenFixed = true;
-    myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);;
-    myAnnotationProperties.ShapeIndex = 1;
-    myAnnotationProperties.ShapeType = 1;
+    myAnnotationProperties.IsScreenFixed = false;
+    myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
+    myAnnotationProperties.ShapeIndex = -1;
+    myAnnotationProperties.ShapeType = (int)TopAbs_SHAPE;
 
     SelectionIntoArgument();
 
-    mySelectionModes.clear();
-    mySelectionModes.append(TopAbs_SHAPE);
+    mySelectionMode = TopAbs_SHAPE;
 
     connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
     connect(mySubShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@@ -244,6 +238,7 @@ void MeasureGUI_AnnotationDlg::Init()
     connect(mySubShapeTypeCombo,   SIGNAL(currentIndexChanged(int)),
             this, SLOT(onSubShapeTypeChange()));
 
+    SelectionIntoArgument();
   }
   else { // edition
 
@@ -251,6 +246,18 @@ void MeasureGUI_AnnotationDlg::Init()
   redisplayPreview();
 }
 
+//=================================================================================
+// function : activateSelection
+// purpose  : Activate local selection
+//=================================================================================
+void MeasureGUI_AnnotationDlg::activateSelection()
+{
+  globalSelection(GEOM_ALLSHAPES);
+  if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) {
+    localSelection(myShape.get(), mySelectionMode);
+  }
+}
+
 //=================================================================================
 // function : getShapeType()
 // purpose  :
@@ -288,6 +295,7 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply()
         showError(msg);
         return false;
     }
+
     SUIT_OverrideCursor wc;
     SUIT_Session::session()->activeApplication()->putInfo("");
 
@@ -345,6 +353,8 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
   if (myEditCurrentArgument)
     myEditCurrentArgument->setFocus();
 
+  aSelectButton->setDown(true);
+
   if (aSelectButton->isChecked())
     anOtherButton->setDown(false);
 
@@ -359,28 +369,39 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
 void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
 {
   if (myIsCreation && myEditCurrentArgument) {
-    GEOM::GeomObjPtr anObj = getSelected(mySelectionModes);
+    GEOM::GeomObjPtr anObj = getSelected(mySelectionMode);
 
     QString aName = GEOMBase::GetName(anObj.get());
-    myEditCurrentArgument->setText(aName);
 
-    gp_Pnt anAttachPoint;
+    gp_Pnt anAttachPoint(0, 0, 0);
     int aSubShapeIndex = -1;
     if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
-      if (myShape->_is_nil())
-        myShape = GEOM::GEOM_Object::_nil();
-      else
-        myShape = anObj;
+      if (mySelectionMode == TopAbs_SHAPE) {
+        myEditCurrentArgument->setText(aName);
 
-      if (!myShape->_is_nil()) {
-        TopoDS_Shape aShape;
-        GEOMBase::GetShape(myShape.get(), aShape);
+        if (anObj->_is_nil())
+          myShape = GEOM::GEOM_Object::_nil();
+        else
+          myShape = anObj;
+
+        bool aNullShape = myShape->_is_nil();
+        mySubShapeTypeCombo->setEnabled(!aNullShape);
+        mySubShapeSelBtn->setEnabled(!aNullShape);
+        mySubShapeName->setEnabled(!aNullShape);
+        activateSelection();
 
-        anAttachPoint = getAttachPoint(aShape);
+
+        if (!myShape->_is_nil()) {
+          TopoDS_Shape aShape;
+          GEOMBase::GetShape(myShape.get(), aShape);
+          anAttachPoint = getAttachPoint(aShape);
+        }
       }
     }
-    else if (myEditCurrentArgument == myShapeName) {
+    else if (myEditCurrentArgument == mySubShapeName) {
       if (!myShape->_is_nil()) {
+        myEditCurrentArgument->setText(aName);
+
         TopTools_IndexedMapOfShape aMainMap;
         TopoDS_Shape aMainShape;
         GEOMBase::GetShape(myShape.get(), aMainShape);
@@ -431,9 +452,11 @@ void MeasureGUI_AnnotationDlg::onTypeChange()
 //=======================================================================
 void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
 {
-  //TopAbs_ShapeEnum aShapeType = getShapeType();
-  //myAnnotationProperties.ShapeType = aShapeType;
+  TopAbs_ShapeEnum aShapeType = getShapeType();
+  myAnnotationProperties.ShapeType = aShapeType;
 
+  mySelectionMode = getShapeType();
+  activateSelection();
   redisplayPreview();
 }
 
@@ -455,7 +478,7 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
                   tr("GEOM_STUDY_LOCKED"))
 
   if (myIsCreation) {
-    //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_SHAPE"))
+    RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
   }
   else {
     //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
@@ -463,7 +486,7 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
 
   if (getShapeType() != TopAbs_SHAPE) {
     if (myIsCreation) {
-      //RETURN_WITH_MSG(myAnnotationProperties.SubShapeId >= 0, tr("NO_SUB_SHAPE"))
+      RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
     }
     else {
       //RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
index 2c70750b90218b658c214ea48b044900519bf5d8..94d41bfffa2d3f72ed76f0d884e61e146fd12977 100644 (file)
@@ -83,11 +83,12 @@ private slots:
 private:
   void                                Init();
 
+  void                                activateSelection();
   TopAbs_ShapeEnum                    getShapeType() const;
   gp_Pnt                              getAttachPoint(const TopoDS_Shape& theShape);
 
 private:
-  QList<TopAbs_ShapeEnum>             mySelectionModes;
+  TopAbs_ShapeEnum                    mySelectionMode;
   GEOMGUI_ShapeAnnotations::ShapeAnnotation myAnnotationProperties;
   /// an index of edited annotation in the list shape annotations, -1 in create operation
   bool                                myIsCreation;