From: nds Date: Thu, 24 Apr 2014 06:35:27 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~129 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=70b396cd8865ebdef607506b2c3803bc640cc817;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Removes unnecessary realization of preview() in the feature. Call the preview visualize/hide mannualy, not by listening the signal. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 99bd4c85b..452b546e2 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -96,7 +96,7 @@ void PartSet_Module::onFeatureTriggered() * Slot that is called by the operation requiring of preview display or erase * \param isDisplay the display or erase state */ -void PartSet_Module::onVisualizePreview(bool isDisplay) +void PartSet_Module::visualizePreview(bool isDisplay) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); if (!anOperation) @@ -118,9 +118,9 @@ void PartSet_Module::onOperationStarted() PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - connect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool))); connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()), aPreviewOp, SLOT(onViewSelectionChanged())); + visualizePreview(true); } } @@ -132,8 +132,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - disconnect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool))); disconnect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()), aPreviewOp, SLOT(onViewSelectionChanged())); + visualizePreview(false); } } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index e343e4373..64f03d59c 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -24,7 +24,9 @@ public slots: void onFeatureTriggered(); void onOperationStarted(); void onOperationStopped(ModuleBase_Operation* theOperation); - void onVisualizePreview(bool isDisplay); + +private: + void visualizePreview(bool isDisplay); private: XGUI_Workshop* myWorkshop; diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 8586525f7..e7d9d292a 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -1,18 +1,11 @@ #include "SketchPlugin_Feature.h" -/** - * Returns the sketch preview - */ -const boost::shared_ptr& SketchPlugin_Feature::preview() +void SketchPlugin_Feature::setPreview(const boost::shared_ptr& theShape) { - return myPreview; + myPreview = theShape; } -/** - * Set the shape to the internal preview field - * \param theShape a preview shape - */ -void SketchPlugin_Feature::setPreview(const boost::shared_ptr& theShape) +const boost::shared_ptr& SketchPlugin_Feature::getPreview() const { - myPreview = theShape; + return myPreview; } diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 964abe80e..2bb33c268 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -12,15 +12,23 @@ /**\class SketchPlugin_Feature * \ingroup DataModel - * \brief Feature for creation of the new part in PartSet. + * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give + * an interface to create the sketch feature preview. */ class SketchPlugin_Feature: public ModelAPI_Feature { public: - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview() = 0; + /// Returns the sketch preview + /// \return the built preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview() = 0; protected: + /// Set the shape to the internal preview field + /// \param theShape a preview shape void setPreview(const boost::shared_ptr& theShape); ///< the preview shape + /// Return the shape from the internal preview field + /// \return theShape a preview shape + const boost::shared_ptr& getPreview() const; private: boost::shared_ptr myPreview; ///< the preview shape diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index f450ec746..5a597ebf6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -26,14 +26,11 @@ void SketchPlugin_Sketch::execute() const boost::shared_ptr& SketchPlugin_Sketch::preview() { - if (!SketchPlugin_Feature::preview()) - { - - boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); - boost::shared_ptr aNormal(new GeomAPI_Dir(1, 0, 0)); - boost::shared_ptr aFace = - GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE); - setPreview(aFace); - } - return SketchPlugin_Feature::preview(); + boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); + boost::shared_ptr aNormal(new GeomAPI_Dir(1, 0, 0)); + boost::shared_ptr aFace = + GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE); + setPreview(aFace); + + return getPreview(); }