1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include "PartSet_Module.h"
4 #include <PartSet_WidgetSketchLabel.h>
5 #include <PartSet_Validators.h>
6 #include <PartSet_Tools.h>
7 #include <PartSet_WidgetPoint2d.h>
8 #include <PartSet_WidgetPoint2dDistance.h>
9 #include <PartSet_WidgetShapeSelector.h>
10 #include <PartSet_WidgetConstraintShapeSelector.h>
11 #include <PartSet_SketcherMgr.h>
13 #include <ModuleBase_Operation.h>
14 #include <ModuleBase_IViewer.h>
15 #include <ModuleBase_IViewWindow.h>
16 #include <ModuleBase_IPropertyPanel.h>
17 #include <ModuleBase_WidgetEditor.h>
18 #include <ModuleBase_FilterFactory.h>
19 #include <ModuleBase_FilterLinearEdge.h>
20 #include <ModuleBase_FilterFace.h>
21 #include <ModuleBase_FilterMulti.h>
22 #include <ModuleBase_FilterCustom.h>
23 #include <ModuleBase_FilterNoConsructionSubShapes.h>
25 #include <ModelAPI_Object.h>
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_Validator.h>
28 #include <ModelAPI_Data.h>
29 #include <ModelAPI_Session.h>
30 #include <ModelAPI_ShapeValidator.h>
32 #include <GeomDataAPI_Point2D.h>
33 #include <GeomDataAPI_Point.h>
34 #include <GeomDataAPI_Dir.h>
36 #include <XGUI_Displayer.h>
37 #include <XGUI_Workshop.h>
38 #include <XGUI_OperationMgr.h>
39 #include <XGUI_PropertyPanel.h>
40 #include <XGUI_ModuleConnector.h>
41 #include <XGUI_ContextMenuMgr.h>
42 #include <XGUI_Tools.h>
44 #include <SketchPlugin_Feature.h>
45 #include <SketchPlugin_Sketch.h>
46 #include <SketchPlugin_Line.h>
47 //#include <SketchPlugin_Arc.h>
48 //#include <SketchPlugin_Circle.h>
49 #include <SketchPlugin_ConstraintLength.h>
50 #include <SketchPlugin_ConstraintDistance.h>
51 #include <SketchPlugin_ConstraintParallel.h>
52 #include <SketchPlugin_ConstraintPerpendicular.h>
53 #include <SketchPlugin_ConstraintRadius.h>
54 //#include <SketchPlugin_ConstraintRigid.h>
56 #include <Events_Loop.h>
57 #include <Config_PropManager.h>
59 #include <StdSelect_TypeOfFace.hxx>
60 #include <TopoDS_Vertex.hxx>
62 #include <TopoDS_Shape.hxx>
63 #include <BRep_Tool.hxx>
66 #include <QMouseEvent>
69 #include <QApplication>
70 #include <QMessageBox>
71 #include <QMainWindow>
73 #include <GeomAlgoAPI_FaceBuilder.h>
74 #include <GeomDataAPI_Dir.h>
80 /*!Create and return new instance of XGUI_Module*/
81 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
83 return new PartSet_Module(theWshop);
86 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
87 : ModuleBase_IModule(theWshop),
88 myRestartingMode(RM_None)
90 //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
91 mySketchMgr = new PartSet_SketcherMgr(this);
93 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
94 XGUI_Workshop* aWorkshop = aConnector->workshop();
96 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
97 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
98 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
99 this, SLOT(onOperationActivatedByPreselection()));
101 ModuleBase_IViewer* aViewer = theWshop->viewer();
102 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
103 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
108 PartSet_Module::~PartSet_Module()
110 if (!myDocumentShapeFilter.IsNull())
111 myDocumentShapeFilter.Nullify();
114 void PartSet_Module::registerValidators()
116 //Registering of validators
117 SessionPtr aMgr = ModelAPI_Session::get();
118 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
119 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
120 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
121 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
122 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
123 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
124 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
125 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
126 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
127 aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
130 void PartSet_Module::registerFilters()
132 //Registering of selection filters
133 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
134 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
136 aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
137 aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
138 aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
139 Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
140 aFactory->registerFilter("NoConstructionSubShapesFilter",
141 new ModuleBase_FilterCustom(aSelectFilter));
144 void PartSet_Module::registerProperties()
146 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
148 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
149 Config_Prop::Integer, SKETCH_WIDTH);
152 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
154 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
155 mySketchMgr->commitNestedSketch(theOperation);
158 if (theOperation->isEditOperation())
160 // the selection is cleared after commit the create operation
161 // in order to do not use the same selected objects in the restarted operation
162 // for common behaviour, the selection is cleared even if the operation is not restarted
163 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
164 if (!aContext.IsNull())
165 aContext->ClearSelected();
167 /// Restart sketcher operations automatically
168 FeaturePtr aFeature = theOperation->feature();
169 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
170 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
171 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
172 myRestartingMode == RM_EmptyFeatureUsed)) {
173 myLastOperationId = theOperation->id();
174 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
176 launchOperation(myLastOperationId);
178 breakOperationSequence();
181 void PartSet_Module::breakOperationSequence()
183 myLastOperationId = "";
184 myLastFeature = FeaturePtr();
185 myRestartingMode = RM_None;
188 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
190 breakOperationSequence();
193 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
195 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
196 mySketchMgr->startSketch(theOperation);
198 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
199 mySketchMgr->startNestedSketch(theOperation);
202 if (myDocumentShapeFilter.IsNull())
203 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
204 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
207 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
209 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
210 mySketchMgr->stopSketch(theOperation);
212 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
213 mySketchMgr->stopNestedSketch(theOperation);
215 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
218 bool PartSet_Module::canUndo() const
220 bool aCanUndo = false;
221 SessionPtr aMgr = ModelAPI_Session::get();
222 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
223 aCanUndo = !aMgr->isOperation();
224 if (!aCanUndo) // check the enable state additionally by sketch manager
225 aCanUndo = aMgr->canUndo();
230 bool PartSet_Module::canRedo() const
232 bool aCanRedo = false;
233 SessionPtr aMgr = ModelAPI_Session::get();
234 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
235 aCanRedo = !aMgr->isOperation();
236 if (!aCanRedo) // check the enable state additionally by sketch manager
237 aCanRedo = aMgr->canRedo();
242 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
244 bool aCanDisplay = false;
245 if (!mySketchMgr->canDisplayObject())
247 CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
248 if (aSketchFeature.get() != NULL) {
249 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
251 // MPV: the second and third conditions to avoid crash on exit for application
252 if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
253 if (aFeature == aSketchFeature) {
256 else if (aSketchFeature.get() && aSketchFeature->data().get() &&
257 aSketchFeature->data()->isValid()) {
258 for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
259 FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
260 std::list<ResultPtr> aResults = aSubFeature->results();
261 std::list<ResultPtr>::const_iterator aIt;
262 for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
263 if (theObject == (*aIt))
266 if (aSubFeature == theObject)
273 aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
278 void PartSet_Module::addViewerItems(QMenu* theMenu) const
280 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
281 if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
282 !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
285 ModuleBase_ISelection* aSelection = myWorkshop->selection();
286 QObjectPtrList aObjects = aSelection->selectedPresentations();
287 if (aObjects.size() > 0) {
288 bool hasFeature = false;
289 foreach(ObjectPtr aObject, aObjects)
291 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
292 if (aFeature.get() != NULL) {
297 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
298 XGUI_Workshop* aWorkshop = aConnector->workshop();
299 QAction* anAction = aWorkshop->contextMenuMgr()->action("DELETE_CMD");
300 theMenu->addAction(anAction);
304 if (mySketchMgr->canChangeConstruction(isConstruction)) {
305 QAction* anAction = action("CONSTRUCTION_CMD");
306 theMenu->addAction(anAction);
307 anAction->setChecked(isConstruction);
311 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
313 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
314 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
315 // we have to manually activate the sketch label in edit mode
316 aPanel->activateWidget(aPanel->modelWidgets().first());
320 // Restart last operation type
321 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
322 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
323 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
324 // Initialise new line with first point equal to end of previous
325 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
327 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
328 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
329 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
331 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
332 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
333 aWgt->attributeID(), aPoint->x(), aPoint->y());
334 aPanel->activateNextWidget(aPnt2dWgt);
339 // Start editing constraint
340 if (theOperation->isEditOperation()) {
341 // TODO: #391 - to be removed
342 std::string aId = theOperation->id().toStdString();
343 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
344 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
345 // Find and activate widget for management of point for dimension line position
346 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
347 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
348 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
350 aPanel->activateWidget(aPntWgt);
360 void PartSet_Module::onSelectionChanged()
362 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
366 bool isSketcherOp = false;
367 // An edit operation is enable only if the current opeation is the sketch operation
368 if (mySketchMgr->activeSketch()) {
369 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
370 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
373 // Editing of constraints can be done on selection
374 ModuleBase_ISelection* aSelect = myWorkshop->selection();
375 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
376 if (aSelected.size() == 1) {
377 ModuleBase_ViewerPrs aPrs = aSelected.first();
378 ObjectPtr aObject = aPrs.object();
379 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
381 std::string aId = aFeature->getKind();
382 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
383 (aId == SketchPlugin_ConstraintLength::ID()) ||
384 (aId == SketchPlugin_ConstraintDistance::ID())) {
385 editFeature(aFeature);
392 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
394 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
395 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
396 anOpMgr->onKeyReleased(theEvent);
399 void PartSet_Module::onEnterReleased()
401 myRestartingMode = RM_EmptyFeatureUsed;
404 void PartSet_Module::onOperationActivatedByPreselection()
406 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
407 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
408 // Set final definitions if they are necessary
409 //propertyPanelDefined(aOperation);
411 /// Commit sketcher operations automatically
412 anOperation->commit();
416 void PartSet_Module::onNoMoreWidgets()
418 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
419 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
421 if (myRestartingMode != RM_Forbided)
422 myRestartingMode = RM_LastFeatureUsed;
423 anOperation->commit();
428 void PartSet_Module::onVertexSelected()
430 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
431 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
432 /// If last line finished on vertex the lines creation sequence has to be break
433 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
434 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
435 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
436 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
437 bool aFoundWidget = false;
438 bool aFoundObligatory = false;
439 for (; anIt != aLast && !aFoundObligatory; anIt++) {
441 aFoundWidget = *anIt == anActiveWidget;
443 aFoundObligatory = (*anIt)->isObligatory();
445 if (!aFoundObligatory)
446 myRestartingMode = RM_Forbided;
450 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
451 Config_WidgetAPI* theWidgetApi, std::string theParentId)
453 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
454 XGUI_Workshop* aWorkshop = aConnector->workshop();
455 ModuleBase_ModelWidget* aWgt = NULL;
456 if (theType == "sketch-start-label") {
457 PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
458 aLabelWgt->setWorkshop(aWorkshop);
459 connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
460 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
462 } else if (theType == "sketch-2dpoint_selector") {
463 PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
464 aPointWgt->setWorkshop(aWorkshop);
465 aPointWgt->setSketch(mySketchMgr->activeSketch());
466 connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
468 } if (theType == "point2ddistance") {
469 PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
470 aDistanceWgt->setWorkshop(aWorkshop);
471 aDistanceWgt->setSketch(mySketchMgr->activeSketch());
473 } if (theType == "sketch_shape_selector") {
474 PartSet_WidgetShapeSelector* aShapeSelectorWgt =
475 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
476 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
477 aWgt = aShapeSelectorWgt;
478 } if (theType == "sketch_constraint_shape_selector") {
479 PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
480 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
481 aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
482 aWgt = aConstraintShapeSelectorWgt;
487 void PartSet_Module::createActions()
491 anAction = new QAction(tr("Construction"), this);
492 anAction->setCheckable(true);
493 addAction("CONSTRUCTION_CMD", anAction);
496 QAction* PartSet_Module::action(const QString& theId) const
498 if (myActions.contains(theId))
499 return myActions[theId];
503 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
505 if (myActions.contains(theId))
506 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
507 theAction->setData(theId);
508 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
509 myActions[theId] = theAction;
512 void PartSet_Module::onAction(bool isChecked)
514 QAction* aAction = static_cast<QAction*>(sender());
515 QString anId = aAction->data().toString();
517 if (anId == "CONSTRUCTION_CMD") {
518 mySketchMgr->setConstruction(isChecked);
522 bool PartSet_Module::deleteObjects()
524 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
525 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
526 isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
527 if (!isSketchOp && !isNestedOp)
530 // sketch feature should be skipped, only sub-features can be removed
531 // when sketch operation is active
532 CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
534 // selected objects should be collected before the current operation abort because
535 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
536 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
537 XGUI_Workshop* aWorkshop = aConnector->workshop();
538 ModuleBase_ISelection* aSel = aConnector->selection();
539 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
541 // if there are no selected objects in the viewer, that means that the selection in another
542 // place cased this method. It is necessary to return the false value to understande in above
543 // method that delete is not processed
544 if (aSelectedObj.count() == 0)
548 anOperation->abort();
550 // the active nested sketch operation should be aborted unconditionally
551 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
552 anOperation->abort();
554 std::set<FeaturePtr> aRefFeatures;
555 foreach (ObjectPtr aObj, aSelectedObj)
557 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
559 // TODO: check for what there is this condition. It is placed here historicaly because
560 // ther is this condition during remove features.
562 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
563 if (aFeature.get() != NULL) {
564 aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
569 QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
571 // according to #355 feature, it is not necessary to inform about dependencies during
572 // sketch delete operation
574 if (!aRefFeatures.empty()) {
575 QStringList aRefNames;
576 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
577 aLast = aRefFeatures.end();
578 for (; anIt != aLast; anIt++) {
579 FeaturePtr aFeature = (*anIt);
580 if (aFeature == aSketch)
582 aRefNames.append((*anIt)->name().c_str());
584 if (!aRefNames.empty()) {
585 QString aNames = aRefNames.join(", ");
586 aDescription += aNames.prepend(" ");
588 QMainWindow* aDesktop = aWorkshop->desktop();
589 QMessageBox::StandardButton aRes = QMessageBox::warning(
590 aDesktop, tr("Delete features"),
591 QString(tr("Selected features are used in the following features: %1.\
592 These features will be deleted also. Would you like to continue?")).arg(aNames),
593 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
594 if (aRes != QMessageBox::Yes)
599 SessionPtr aMgr = ModelAPI_Session::get();
600 aMgr->startOperation(aDescription.toStdString());
601 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
602 aLast = aRefFeatures.end();
603 for (; anIt != aLast; anIt++) {
604 FeaturePtr aRefFeature = (*anIt);
605 if (aRefFeature == aSketch)
607 aRefFeature->document()->removeFeature(aRefFeature);
610 foreach (ObjectPtr aObj, aSelectedObj)
612 DocumentPtr aDoc = aObj->document();
613 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
615 // if (aDoc == aMgr->activeDocument()) {
619 //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
620 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
621 if (aFeature.get() != NULL) {
622 aDoc->removeFeature(aFeature);
626 aWorkshop->displayer()->updateViewer();
627 //myDisplayer->updateViewer();
628 aMgr->finishOperation();