]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 05:15:57 +0000 (09:15 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 05:15:57 +0000 (09:15 +0400)
Constraint for a line, which is started in the end of the previous line.

src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h

index c13fb2d31803a99baa1830d497cc498d8bff0698..58130a384f6230cb091987d237bfebc85f9a9f19 100644 (file)
@@ -146,7 +146,10 @@ void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
   if (aPoint) {
     bool isBlocked = this->blockSignals(true);
     myXSpin->setValue(aPoint->x());
-    this->blockSignals(isBlocked);
     myYSpin->setValue(aPoint->y());
+    this->blockSignals(isBlocked);
+
+    emit valuesChanged();
+    emit storedPoint2D(theFeature, myOptionParam);
   }
 }
index 255a3950c43bee860c65d9b6eee023d4d6fc8b70..519e96ccc64235d3abfbf3972179422a56307de9 100644 (file)
@@ -57,6 +57,12 @@ public:
 
   void initFromPrevious(FeaturePtr theFeature);
 
+signals:
+  /// Signal about the point 2d set to the feature
+  /// \param the feature
+  /// \param the attribute of the feature
+  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+
 private:
   QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
   QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
index bc88fa82119949b60fd018e8030c2b892843821c..fb9983b01ef67b8750df301d589c58e408f4f98b 100644 (file)
 #include <ModuleBase_Operation.h>
 #include <ModelAPI_Object.h>
 
+#include <ModelAPI_Data.h>
+#include <GeomDataAPI_Point2D.h>
+#include <PartSet_Tools.h>
+
 #include <XGUI_MainWindow.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_Viewer.h>
@@ -84,7 +88,6 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
           this, SLOT(onKeyRelease(QKeyEvent*)));
   connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
           this, SLOT(onMouseDoubleClick(QMouseEvent*)));
-
 }
 
 PartSet_Module::~PartSet_Module()
@@ -149,6 +152,9 @@ void PartSet_Module::onOperationStarted()
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
     connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
             aPropPanel, SLOT(onFocusActivated(const std::string&)));
+
+    connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
+      this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
   }
 }
 
@@ -161,6 +167,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
     disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
                aPropPanel, SLOT(onFocusActivated(const std::string&)));
+    //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
+    //           this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
   }
 }
 
@@ -513,3 +521,17 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
     }
 //  }
 }
+
+void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
+{
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+                                       myWorkshop->operationMgr()->currentOperation());
+  if (!aPreviewOp)
+    return;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
+
+  PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
+                                aPoint->x(), aPoint->y());
+}
index 0bdcb88f03774e7ac0540d035ea927eb38e4fccb..561c97fe0224741d042221903ba80f27d388a000 100644 (file)
@@ -119,6 +119,12 @@ public slots:
   /// \param theMode the mode appeared on the feature
   void onFeatureConstructed(FeaturePtr theFeature,
                             int theMode);
+
+  /// Slot which reacts to the point 2d set to the feature. Creates a constraint
+  /// \param the feature
+  /// \param the attribute of the feature
+  void onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+
 protected:
   /// Creates a new operation
   /// \param theCmdId the operation name
index 83de5b27d792671585cfa538f5340433a05686be..54933b4b243af44dd2a25f1495654c8b5ec086b3 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <XGUI_Constants.h>
 #include <XGUI_PropertyPanel.h>
+#include <ModuleBase_WidgetPoint2D.h>
 
 #include <QWidget>
 #include <QVBoxLayout>
@@ -95,6 +96,11 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
 
       connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
               this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+
+      ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
+      if (aPointWidget)
+        connect(aPointWidget, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
+                this, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)));
     }
     ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
     if (aLastWidget) {
index d156289b56ee88ffd7ff72f302ca8890377b67c3..51155a481ebc3f88ecb28ef2030098c5d8c4e88d 100644 (file)
@@ -51,6 +51,11 @@ signals:
   /// \param theWidget the activated widget
   void widgetActivated(ModuleBase_ModelWidget* theWidget);
 
+  /// Signal about the point 2d set to the feature
+  /// \param the feature
+  /// \param the attribute of the feature
+  void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+
 protected:
   /// Activate the widget, which means the focus on the widget.
   /// The signal about the widget activation is emitted