]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide editing of dimensions
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 1 Dec 2014 10:22:38 +0000 (13:22 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 1 Dec 2014 10:22:38 +0000 (13:22 +0300)
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_PropertyPanel.h

index b0114eb0b9367e2611fd65cdd9945132037319a8..00ff516b8c3ac9dcca21e7fb545e028d86f90af0 100644 (file)
@@ -46,6 +46,11 @@ public slots:
 
   /// Activate the next from current widget in the property panel
   virtual void activateNextWidget() = 0;
+
+  // Makes the given widget active, highlights it and removes
+  // highlighting from the previous active widget
+  // emits widgetActivated(theWidget) signal
+  virtual void activateWidget(ModuleBase_ModelWidget* theWidget) = 0;
 };
 
 #endif
\ No newline at end of file
index a63aecd79e1be309031624c3deebe5ed598bb756..ba997dcd37879ac691669d57c1304512aecd2242 100644 (file)
@@ -214,9 +214,11 @@ void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
 
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
+  // Restart last operation type 
   if ((theOperation->id() == myLastOperationId) && myLastFeature) {
     ModuleBase_ModelWidget* aWgt = theOperation->propertyPanel()->activeWidget();
     if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
+      // Initialise new line with first point equal to end of previous
       PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
       if (aPnt2dWgt) {
         std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
@@ -230,12 +232,47 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
         }
       }
     }
+  } else {
+    // Start editing constraint
+    if (theOperation->isEditOperation()) {
+      std::string aId = theOperation->id().toStdString();
+      if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
+          (aId == SketchPlugin_ConstraintLength::ID()) || 
+          (aId == SketchPlugin_ConstraintDistance::ID())) {
+        ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
+        // Find and activate widget for management of point for dimension line position
+        QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+        foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+          PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+          if (aPntWgt) {
+            aPanel->activateWidget(aPntWgt);
+            return;
+          }
+        }
+      }
+    }
   }
 }
 
 
 void PartSet_Module::onSelectionChanged()
 {
+  // Editing of constraints can be done on selection
+  ModuleBase_ISelection* aSelect = myWorkshop->selection();
+  QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+  if (aSelected.size() == 1) {
+    ModuleBase_ViewerPrs aPrs = aSelected.first();
+    ObjectPtr aObject = aPrs.object();
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+    if (aFeature) {
+      std::string aId = aFeature->getKind();
+      if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
+          (aId == SketchPlugin_ConstraintLength::ID()) || 
+          (aId == SketchPlugin_ConstraintDistance::ID())) {
+        editFeature(aFeature);
+      }
+    }
+  }
 }
 
 void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
index 2a3f8e613d1939893d8280ab61d597e7a0dc30b8..28c62461856c5a0c64fd5833c40127076133c334 100644 (file)
@@ -56,11 +56,10 @@ Q_OBJECT
   // Enables / disables "ok" ("accept") button
   void setAcceptEnabled(bool);
 
- protected slots:
   // Makes the given widget active, highlights it and removes
   // highlighting from the previous active widget
   // emits widgetActivated(theWidget) signal
-  void activateWidget(ModuleBase_ModelWidget* theWidget);
+  virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
 
  signals:
   /// Signal about the point 2d set to the feature