Hide preview by clicking "Apply" or "Abort" button in the sketch operation.
void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
-
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- if (anOperation) {
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- visualizePreview(aPreviewOp->feature(), false);
- }
- }
-
myWorkshop->actionsMgr()->setNestedActionsEnabled(true);
}
aDisplayer->UpdateViewer();
}
+void PartSet_Module::onCloseLocalContext()
+{
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ aDisplayer->CloseLocalContexts();
+}
+
void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
int theMode)
{
- bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Abort;
+ bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
visualizePreview(theFeature, isDisplay, false);
+ if (!isDisplay) {
+ ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
+ boost::shared_ptr<ModelAPI_Feature> aSketch;
+ PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
+ if (aPrevOp) {
+ std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
+ aList = aPrevOp->subPreview();
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
+
+ std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
+ anIt = aList.begin(), aLast = aList.end();
+ for (; anIt != aLast; anIt++) {
+ boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).first;
+ visualizePreview(aFeature, false, false);
+ }
+ aDisplayer->UpdateViewer();
+ }
+ }
if (theMode == PartSet_OperationSketchBase::FM_Activation ||
theMode == PartSet_OperationSketchBase::FM_Deactivation)
connect(aPreviewOp, SIGNAL(setSelection(const std::list<XGUI_ViewerPrs>&)),
this, SLOT(onSetSelection(const std::list<XGUI_ViewerPrs>&)));
+ connect(aPreviewOp, SIGNAL(closeLocalContext()),
+ this, SLOT(onCloseLocalContext()));
+
PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
if (aSketchOp) {
connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
}
else
- aDisplayer->Erase(anOperation->feature(), false);
+ aDisplayer->Erase(theFeature, false);
if (isUpdateViewer)
aDisplayer->UpdateViewer();
return;
std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
- aList = aPreviewOp->preview();
+ aList = aPreviewOp->subPreview();
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
/// \param theFeatures a list of features to be selected
void onSetSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
+ /// SLOT, to close the viewer local context
+ void onCloseLocalContext();
+
/// SLOT, to visualize the feature in another local context mode
/// \param theFeature the feature to be put in another local context mode
/// \param theMode the mode appeared on the feature
}
std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
- PartSet_OperationSketch::preview() const
+ PartSet_OperationSketch::subPreview() const
{
std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > aPreviewMap;
return aPreviewMap;
}
+void PartSet_OperationSketch::stopOperation()
+{
+ PartSet_OperationSketchBase::stopOperation();
+ emit featureConstructed(feature(), FM_Hide);
+ emit closeLocalContext();
+}
+
void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
{
if (theShape.IsNull())
boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
aDirY->setValue(aC, anA, aB);
boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+ emit featureConstructed(feature(), FM_Hide);
+ emit closeLocalContext();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
}
/// Returns the map of the operation previews including the nested feature previews
/// \return the map of feature to the feature preview
virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
- preview() const;
+ subPreview() const;
+
+ /// Virtual method called when operation stopped - committed or aborted.
+ /// Emits a signal to hide the preview of the operation
+ virtual void stopOperation();
+
signals:
/// signal about the sketch plane is selected
/// \param theX the value in the X direction of the plane
}
std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
- PartSet_OperationSketchBase::preview() const
+ PartSet_OperationSketchBase::subPreview() const
{
return std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >();
}
{
Q_OBJECT
public:
- enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Abort };
+ enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Hide };
public:
/// Constructor
/// Returns the map of the operation previews including the nested feature previews
/// \return the map of feature to the feature preview
- virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > preview() const;
+ virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > subPreview() const;
/// Returns the operation local selection mode
/// \param theFeature the feature object to get the selection mode
/// \param theFeatures a list of features to be disabled
void setSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
- /// signal to enable/disable usual selection in the viewer
- /// \param theEnabled the boolean state
- void selectionEnabled(bool theEnabled);
+ /// signal to close the operation local context if it is opened
+ void closeLocalContext();
protected:
/// Creates an operation new feature
void PartSet_OperationSketchLine::abortOperation()
{
- emit featureConstructed(feature(), FM_Abort);
+ emit featureConstructed(feature(), FM_Hide);
PartSet_OperationSketchBase::abortOperation();
}