Removes unnecessary realization of preview() in the feature.
Call the preview visualize/hide mannualy, not by listening the signal.
* 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)
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);
}
}
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);
}
}
void onFeatureTriggered();
void onOperationStarted();
void onOperationStopped(ModuleBase_Operation* theOperation);
- void onVisualizePreview(bool isDisplay);
+
+private:
+ void visualizePreview(bool isDisplay);
private:
XGUI_Workshop* myWorkshop;
#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;
}
/**\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
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();
}