}
}
+void PartSet_PreviewSketchPlane::displaySketchPlane(ModuleBase_IWorkshop* theWorkshop)
+{
+ if (myPlane.get() && (!myPreviewIsDisplayed)) {
+ XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
+ aDisp->displayAIS(myPlane, false/*load object in selection*/, 1/*shaded*/, false);
+ myPreviewIsDisplayed = true;
+ }
+}
+
+
void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop)
{
if (!aSelAttr)
return;
- if (myShape.get() && myShape->isSame(aSelAttr->value()))
+ if (myShape.get() && myShape->isSame(aSelAttr->value()) && myPlane.get())
return;
XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
void setSizeOfView(double theSizeOfView, bool isUseSizeOfView,
const std::shared_ptr<GeomAPI_Pnt>& theCentralPoint = std::shared_ptr<GeomAPI_Pnt>());
+ bool isPlaneCreated() const {
+ return myPlane.get();
+ }
+
+ void displaySketchPlane(ModuleBase_IWorkshop* theWorkshop);
+
private:
/// Create a square face by parameters
std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
void PartSet_WidgetSketchLabel::onShowViewPlane(bool toShow)
{
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ PartSet_PreviewSketchPlane* aPreviewPlane = aModule->sketchMgr()->previewSketchPlane();
if (toShow) {
CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
- aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+ if (aPreviewPlane->isPlaneCreated())
+ aPreviewPlane->displaySketchPlane(myWorkshop);
+ else
+ aPreviewPlane->createSketchPlane(aSketch, myWorkshop);
}
else {
- aModule->sketchMgr()->previewSketchPlane()->eraseSketchPlane(myWorkshop, false);
+ aPreviewPlane->eraseSketchPlane(myWorkshop, false);
}
myWorkshop->viewer()->update();
}