]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Initialization of WidgetPoint2d with point from last feature.
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 24 Jun 2014 11:17:07 +0000 (15:17 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 24 Jun 2014 11:17:07 +0000 (15:17 +0400)
src/Config/Config_Keywords.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/SketchPlugin/plugin-Sketch.xml

index c9d705d551da19b2980e08176a27197f2ccce6cb..e44e5ad836af545785a46624d3fa322e778df2bd 100644 (file)
@@ -47,6 +47,7 @@ const static char* FEATURE_NESTED = "nested";
 const static char* FEATURE_INTERNAL = "internal";
 const static char* SOURCE_FILE = "path";
 
+const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param";
 
 // doublevalue properties:
 const static char* INFO_WDG_TEXT = FEATURE_TEXT;
index 7903c829333acd1615e8db23da85477f6b0fec7a..c13fb2d31803a99baa1830d497cc498d8bff0698 100644 (file)
@@ -30,6 +30,7 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent,
                                                    const Config_WidgetAPI* theData)
 : ModuleBase_ModelWidget(theParent, theData)
 {
+  myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
   myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
                              theParent);
   QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
@@ -73,6 +74,7 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
 
 void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
 {
+
   bool isBlocked = this->blockSignals(true);
   myXSpin->setValue(thePoint->x());
   myYSpin->setValue(thePoint->y());
@@ -133,3 +135,18 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent)
   }
   return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
 }
+
+void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+{
+  if (myOptionParam.length() == 0)
+    return;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
+  if (aPoint) {
+    bool isBlocked = this->blockSignals(true);
+    myXSpin->setValue(aPoint->x());
+    this->blockSignals(isBlocked);
+    myYSpin->setValue(aPoint->y());
+  }
+}
index cf92afd3a020d43749965c6d497521599519ae97..255a3950c43bee860c65d9b6eee023d4d6fc8b70 100644 (file)
@@ -55,10 +55,14 @@ public:
   /// \param theEvent the processed event
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
+  void initFromPrevious(FeaturePtr theFeature);
+
 private:
   QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
   QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
   QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
+
+  std::string myOptionParam; /// Parameter name which has to be taken from previous feature
 };
 
 #endif
index afc823140cd60e077c05384086e463c865c87c34..82cf4225c175c5c39a3bdf80e9d3942616b4a1ac 100644 (file)
@@ -202,10 +202,9 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
   myActiveWidget = theWidget;
 
   if (myInitFeature && myActiveWidget) {
-    // TODO: to be realized in the custom point selector. The last point values of the init feature
-    // should be to to the start point of a new feature
-    //myActiveWidget->init(myInitFeature);
-    //PartSet_FeatureLinePrs::setFeature(myInitFeature, SM_FirstPoint);
+    ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+    if (aWgt)
+      aWgt->initFromPrevious(myInitFeature);
     myInitFeature = FeaturePtr();
     emit activateNextWidget(myActiveWidget);
   }
index 96665b483a252266e012f76cc3e332a296bbb5e9..fd884f1da687d5bdfcdc6cafd9d226fd170ed088 100644 (file)
@@ -9,7 +9,7 @@
         <point_selector id="PointCoordindates" title="Point" tooltip="Point"/>
       </feature>
       <feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
-        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
+        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
       <feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon="">