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(keyDeleteReleased()), this, SLOT(onDeleteObjects()));
99 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
100 this, SLOT(onOperationActivatedByPreselection()));
102 ModuleBase_IViewer* aViewer = theWshop->viewer();
103 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
104 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
109 PartSet_Module::~PartSet_Module()
111 if (!myDocumentShapeFilter.IsNull())
112 myDocumentShapeFilter.Nullify();
115 void PartSet_Module::registerValidators()
117 //Registering of validators
118 SessionPtr aMgr = ModelAPI_Session::get();
119 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
120 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
121 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
122 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
123 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
124 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
125 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
126 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
127 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
128 aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
131 void PartSet_Module::registerFilters()
133 //Registering of selection filters
134 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
135 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
137 aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
138 aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
139 aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
140 Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
141 aFactory->registerFilter("NoConstructionSubShapesFilter",
142 new ModuleBase_FilterCustom(aSelectFilter));
145 void PartSet_Module::registerProperties()
147 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
149 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
150 Config_Prop::Integer, SKETCH_WIDTH);
153 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
155 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
156 mySketchMgr->commitNestedSketch(theOperation);
159 if (theOperation->isEditOperation())
161 // the selection is cleared after commit the create operation
162 // in order to do not use the same selected objects in the restarted operation
163 // for common behaviour, the selection is cleared even if the operation is not restarted
164 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
165 if (!aContext.IsNull())
166 aContext->ClearSelected();
168 /// Restart sketcher operations automatically
169 FeaturePtr aFeature = theOperation->feature();
170 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
171 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
172 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
173 myRestartingMode == RM_EmptyFeatureUsed)) {
174 myLastOperationId = theOperation->id();
175 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
177 launchOperation(myLastOperationId);
179 breakOperationSequence();
182 void PartSet_Module::breakOperationSequence()
184 myLastOperationId = "";
185 myLastFeature = FeaturePtr();
186 myRestartingMode = RM_None;
189 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
191 breakOperationSequence();
194 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
196 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
197 mySketchMgr->startSketch(theOperation);
199 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
200 mySketchMgr->startNestedSketch(theOperation);
203 if (myDocumentShapeFilter.IsNull())
204 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
205 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
208 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
210 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
211 mySketchMgr->stopSketch(theOperation);
213 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
214 mySketchMgr->stopNestedSketch(theOperation);
216 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
219 bool PartSet_Module::canUndo() const
221 bool aCanUndo = false;
222 SessionPtr aMgr = ModelAPI_Session::get();
223 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
224 aCanUndo = !aMgr->isOperation();
225 if (!aCanUndo) // check the enable state additionally by sketch manager
226 aCanUndo = aMgr->canUndo();
231 bool PartSet_Module::canRedo() const
233 bool aCanRedo = false;
234 SessionPtr aMgr = ModelAPI_Session::get();
235 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
236 aCanRedo = !aMgr->isOperation();
237 if (!aCanRedo) // check the enable state additionally by sketch manager
238 aCanRedo = aMgr->canRedo();
243 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
245 bool aCanDisplay = false;
246 if (!mySketchMgr->canDisplayObject())
248 CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
249 if (aSketchFeature.get() != NULL) {
250 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
252 // MPV: the second and third conditions to avoid crash on exit for application
253 if (aFeature.get() != NULL && aFeature->data().get() && aFeature->data()->isValid()) {
254 if (aFeature == aSketchFeature) {
257 else if (aSketchFeature.get() && aSketchFeature->data().get() &&
258 aSketchFeature->data()->isValid()) {
259 for (int i = 0; i < aSketchFeature->numberOfSubs() && !aCanDisplay; i++) {
260 FeaturePtr aSubFeature = aSketchFeature->subFeature(i);
261 std::list<ResultPtr> aResults = aSubFeature->results();
262 std::list<ResultPtr>::const_iterator aIt;
263 for (aIt = aResults.begin(); aIt != aResults.end() && !aCanDisplay; ++aIt) {
264 if (theObject == (*aIt))
267 if (aSubFeature == theObject)
274 aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
279 void PartSet_Module::addViewerItems(QMenu* theMenu) const
281 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
282 if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
283 !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
286 ModuleBase_ISelection* aSelection = myWorkshop->selection();
287 QObjectPtrList aObjects = aSelection->selectedPresentations();
288 if (aObjects.size() > 0) {
289 bool hasFeature = false;
290 foreach(ObjectPtr aObject, aObjects)
292 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
293 if (aFeature.get() != NULL) {
298 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
299 XGUI_Workshop* aWorkshop = aConnector->workshop();
300 QAction* anAction = aWorkshop->contextMenuMgr()->action("DELETE_CMD");
301 theMenu->addAction(anAction);
302 theMenu->addAction(action("DELETE_PARTSET_CMD"));
306 if (mySketchMgr->canChangeConstruction(isConstruction)) {
307 QAction* anAction = action("CONSTRUCTION_CMD");
308 theMenu->addAction(anAction);
309 anAction->setChecked(isConstruction);
313 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
315 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
316 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
317 // we have to manually activate the sketch label in edit mode
318 aPanel->activateWidget(aPanel->modelWidgets().first());
322 // Restart last operation type
323 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
324 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
325 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
326 // Initialise new line with first point equal to end of previous
327 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
329 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
330 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
331 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
333 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
334 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
335 aWgt->attributeID(), aPoint->x(), aPoint->y());
336 aPanel->activateNextWidget(aPnt2dWgt);
341 // Start editing constraint
342 if (theOperation->isEditOperation()) {
343 // TODO: #391 - to be removed
344 std::string aId = theOperation->id().toStdString();
345 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
346 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
347 // Find and activate widget for management of point for dimension line position
348 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
349 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
350 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
352 aPanel->activateWidget(aPntWgt);
362 void PartSet_Module::onSelectionChanged()
364 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
368 bool isSketcherOp = false;
369 // An edit operation is enable only if the current opeation is the sketch operation
370 if (mySketchMgr->activeSketch()) {
371 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
372 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
375 // Editing of constraints can be done on selection
376 ModuleBase_ISelection* aSelect = myWorkshop->selection();
377 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
378 if (aSelected.size() == 1) {
379 ModuleBase_ViewerPrs aPrs = aSelected.first();
380 ObjectPtr aObject = aPrs.object();
381 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
383 std::string aId = aFeature->getKind();
384 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
385 (aId == SketchPlugin_ConstraintLength::ID()) ||
386 (aId == SketchPlugin_ConstraintDistance::ID())) {
387 editFeature(aFeature);
394 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
396 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
397 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
398 anOpMgr->onKeyReleased(theEvent);
401 void PartSet_Module::onEnterReleased()
403 myRestartingMode = RM_EmptyFeatureUsed;
406 void PartSet_Module::onDeleteObjects()
408 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
409 if (PartSet_SketcherMgr::isSketchOperation(anOperation) ||
410 PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
414 void PartSet_Module::onOperationActivatedByPreselection()
416 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
417 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
418 // Set final definitions if they are necessary
419 //propertyPanelDefined(aOperation);
421 /// Commit sketcher operations automatically
422 anOperation->commit();
426 void PartSet_Module::onNoMoreWidgets()
428 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
429 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
431 if (myRestartingMode != RM_Forbided)
432 myRestartingMode = RM_LastFeatureUsed;
433 anOperation->commit();
438 void PartSet_Module::onVertexSelected()
440 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
441 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
442 /// If last line finished on vertex the lines creation sequence has to be break
443 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
444 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
445 if (aWidgets.last() == aPanel->activeWidget()) {
446 myRestartingMode = RM_Forbided;
451 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
452 Config_WidgetAPI* theWidgetApi, std::string theParentId,
453 QList<ModuleBase_ModelWidget*>& theModelWidgets)
455 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
456 XGUI_Workshop* aWorkshop = aConnector->workshop();
457 ModuleBase_ModelWidget* aWgt = NULL;
458 if (theType == "sketch-start-label") {
459 PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
460 aLabelWgt->setWorkshop(aWorkshop);
461 connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
462 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
464 } else if (theType == "sketch-2dpoint_selector") {
465 PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
466 aPointWgt->setWorkshop(aWorkshop);
467 aPointWgt->setSketch(mySketchMgr->activeSketch());
468 connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
470 } if (theType == "point2ddistance") {
471 PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
472 aDistanceWgt->setWorkshop(aWorkshop);
473 aDistanceWgt->setSketch(mySketchMgr->activeSketch());
475 } if (theType == "sketch_shape_selector") {
476 PartSet_WidgetShapeSelector* aShapeSelectorWgt =
477 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
478 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
479 aWgt = aShapeSelectorWgt;
480 } if (theType == "sketch_constraint_shape_selector") {
481 PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
482 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
483 aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
484 aWgt = aConstraintShapeSelectorWgt;
487 theModelWidgets.append(aWgt);
491 void PartSet_Module::createActions()
495 anAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
496 addAction("DELETE_PARTSET_CMD", anAction);
498 anAction = new QAction(tr("Construction"), this);
499 anAction->setCheckable(true);
500 addAction("CONSTRUCTION_CMD", anAction);
503 QAction* PartSet_Module::action(const QString& theId) const
505 if (myActions.contains(theId))
506 return myActions[theId];
510 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
512 if (myActions.contains(theId))
513 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
514 theAction->setData(theId);
515 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
516 myActions[theId] = theAction;
519 void PartSet_Module::onAction(bool isChecked)
521 QAction* aAction = static_cast<QAction*>(sender());
522 QString anId = aAction->data().toString();
524 if (anId == "DELETE_PARTSET_CMD") {
527 if (anId == "CONSTRUCTION_CMD") {
528 mySketchMgr->setConstruction(isChecked);
532 void PartSet_Module::deleteObjects()
534 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
535 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
536 if (!isSketchOp && !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
539 // sketch feature should be skipped, only sub-features can be removed
540 // when sketch operation is active
541 CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
543 // selected objects should be collected before the current operation abort because
544 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
545 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
546 ModuleBase_ISelection* aSel = aConnector->selection();
547 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
549 XGUI_Workshop* aWorkshop = aConnector->workshop();
550 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
551 if (!isSketchOp && anOpMgr->canStopOperation()) {
552 ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
557 std::set<FeaturePtr> aRefFeatures;
558 foreach (ObjectPtr aObj, aSelectedObj)
560 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
562 // TODO: check for what there is this condition. It is placed here historicaly because
563 // ther is this condition during remove features.
565 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
566 if (aFeature.get() != NULL) {
567 aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
571 QString aDescription = tr("Delete");
573 // according to #355 feature, it is not necessary to inform about dependencies during
574 // sketch delete operation
576 if (!aRefFeatures.empty()) {
577 QStringList aRefNames;
578 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
579 aLast = aRefFeatures.end();
580 for (; anIt != aLast; anIt++) {
581 FeaturePtr aFeature = (*anIt);
582 if (aFeature == aSketch)
584 aRefNames.append((*anIt)->name().c_str());
586 if (!aRefNames.empty()) {
587 QString aNames = aRefNames.join(", ");
588 aDescription += aNames.prepend(" ");
590 QMainWindow* aDesktop = aWorkshop->desktop();
591 QMessageBox::StandardButton aRes = QMessageBox::warning(
592 aDesktop, tr("Delete features"),
593 QString(tr("Selected features are used in the following features: %1.\
594 These features will be deleted also. Would you like to continue?")).arg(aNames),
595 QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
596 if (aRes != QMessageBox::Yes)
601 SessionPtr aMgr = ModelAPI_Session::get();
602 aMgr->startOperation(aDescription.toStdString());
603 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
604 aLast = aRefFeatures.end();
605 for (; anIt != aLast; anIt++) {
606 FeaturePtr aRefFeature = (*anIt);
607 if (aRefFeature == aSketch)
609 aRefFeature->document()->removeFeature(aRefFeature);
612 foreach (ObjectPtr aObj, aSelectedObj)
614 DocumentPtr aDoc = aObj->document();
615 //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
617 // if (aDoc == aMgr->activeDocument()) {
621 //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
622 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
623 if (aFeature.get() != NULL) {
624 aDoc->removeFeature(aFeature);
628 aWorkshop->displayer()->updateViewer();
629 //myDisplayer->updateViewer();
630 aMgr->finishOperation();