From: nds Date: Wed, 25 Jun 2014 05:15:57 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~244 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc7b73d2b779266ac1628194e317e7936e927a2e;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc Constraint for a line, which is started in the end of the previous line. --- diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index c13fb2d31..58130a384 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -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); } } diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index 255a3950c..519e96ccc 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index bc88fa821..fb9983b01 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -15,6 +15,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -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( + myWorkshop->operationMgr()->currentOperation()); + if (!aPreviewOp) + return; + + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast(theFeature->data()->attribute(theAttribute)); + + PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute, + aPoint->x(), aPoint->y()); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 0bdcb88f0..561c97fe0 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -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 diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 83de5b27d..54933b4b2 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -95,6 +96,11 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); + + ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*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) { diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index d156289b5..51155a481 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -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