]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Thu, 24 Apr 2014 06:35:27 +0000 (10:35 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 24 Apr 2014 06:35:27 +0000 (10:35 +0400)
Removes unnecessary realization of preview() in the feature.
Call the preview visualize/hide mannualy, not by listening the signal.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index 99bd4c85ba788cf32592e49af916dd5d068bc7ac..452b546e29b315658e59516ad507e21756df4fab 100644 (file)
@@ -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<PartSet_OperationSketchBase*>(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<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
-    disconnect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool)));
     disconnect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
                aPreviewOp, SLOT(onViewSelectionChanged()));
+    visualizePreview(false);
   }
 }
index e343e4373ace6aa18bad89931116c3f22ea91469..64f03d59c082c136abacc51be272d6a9644a9c96 100644 (file)
@@ -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;
index 8586525f792f4a46811caef7d1c1bfaaaae2201d..e7d9d292ac90e44937429ac44a5ea2fb23052938 100644 (file)
@@ -1,18 +1,11 @@
 #include "SketchPlugin_Feature.h"
 
-/**
- * Returns the sketch preview
- */
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::preview()
+void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& 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<GeomAPI_Shape>& theShape)
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::getPreview() const
 {
-  myPreview = theShape;
+  return myPreview;
 }
index 964abe80e4f8b97c299afb162abcfbb95146b044..2bb33c268c36be267526e0b38cfa6aca00640d30 100644 (file)
 
 /**\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<GeomAPI_Shape>& preview() = 0;
+  /// Returns the sketch preview
+  /// \return the built preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
 
 protected:
+  /// Set the shape to the internal preview field
+  /// \param theShape a preview shape
   void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
+  /// Return the shape from the internal preview field
+  /// \return theShape a preview shape
+  const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
 
 private:
   boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
index f450ec74660b28ce3eaa72c5bd68d5a50e6a595b..5a597ebf627d43d248aa333d36149b23610a8ac4 100644 (file)
@@ -26,14 +26,11 @@ void SketchPlugin_Sketch::execute()
 
 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
 {
-  if (!SketchPlugin_Feature::preview())
-  {
-
-    boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
-    boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
-    boost::shared_ptr<GeomAPI_Shape> aFace = 
-      GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
-    setPreview(aFace);
-  }
-  return SketchPlugin_Feature::preview();
+  boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+  boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
+  boost::shared_ptr<GeomAPI_Shape> aFace = 
+    GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+  setPreview(aFace);
+
+  return getPreview();
 }