Salome HOME
Rename canAbortOperation on branch Dev_1.1.0 as in 3ef4f71fa94dbd4055244bd7715061b0ea...
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
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_SketcherMgr.h>
11
12 #include <ModuleBase_Operation.h>
13 #include <ModuleBase_IViewer.h>
14 #include <ModuleBase_IViewWindow.h>
15 #include <ModuleBase_IPropertyPanel.h>
16 #include <ModuleBase_WidgetEditor.h>
17 #include <ModuleBase_FilterFactory.h>
18 #include <ModuleBase_FilterLinearEdge.h>
19 #include <ModuleBase_FilterFace.h>
20 #include <ModuleBase_FilterMulti.h>
21 #include <ModuleBase_FilterCustom.h>
22 #include <ModuleBase_FilterNoConsructionSubShapes.h>
23
24 #include <ModelAPI_Object.h>
25 #include <ModelAPI_Events.h>
26 #include <ModelAPI_Validator.h>
27 #include <ModelAPI_Data.h>
28 #include <ModelAPI_Session.h>
29
30 #include <GeomDataAPI_Point2D.h>
31 #include <GeomDataAPI_Point.h>
32 #include <GeomDataAPI_Dir.h>
33
34 #include <XGUI_Displayer.h>
35 #include <XGUI_Workshop.h>
36 #include <XGUI_OperationMgr.h>
37 #include <XGUI_PropertyPanel.h>
38 #include <XGUI_ModuleConnector.h>
39 #include <XGUI_Tools.h>
40
41 #include <SketchPlugin_Feature.h>
42 #include <SketchPlugin_Sketch.h>
43 #include <SketchPlugin_Line.h>
44 //#include <SketchPlugin_Arc.h>
45 //#include <SketchPlugin_Circle.h>
46 #include <SketchPlugin_ConstraintLength.h>
47 #include <SketchPlugin_ConstraintDistance.h>
48 #include <SketchPlugin_ConstraintParallel.h>
49 #include <SketchPlugin_ConstraintPerpendicular.h>
50 #include <SketchPlugin_ConstraintRadius.h>
51 //#include <SketchPlugin_ConstraintRigid.h>
52
53 #include <Events_Loop.h>
54
55 #include <StdSelect_TypeOfFace.hxx>
56 #include <TopoDS_Vertex.hxx>
57 #include <TopoDS.hxx>
58 #include <TopoDS_Shape.hxx>
59 #include <BRep_Tool.hxx>
60
61 #include <QObject>
62 #include <QMouseEvent>
63 #include <QString>
64 #include <QTimer>
65 #include <QApplication>
66 #include <QMessageBox>
67 #include <QMainWindow>
68
69 #include <GeomAlgoAPI_FaceBuilder.h>
70 #include <GeomDataAPI_Dir.h>
71
72 #ifdef _DEBUG
73 #include <QDebug>
74 #endif
75
76 /*!Create and return new instance of XGUI_Module*/
77 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
78 {
79   return new PartSet_Module(theWshop);
80 }
81
82 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
83   : ModuleBase_IModule(theWshop), 
84   myRestartingMode(RM_None)
85 {
86   //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
87   mySketchMgr = new PartSet_SketcherMgr(this);
88
89   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
90   XGUI_Workshop* aWorkshop = aConnector->workshop();
91
92   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
93   connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
94   connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
95           this, SLOT(onOperationActivatedByPreselection()));
96
97   ModuleBase_IViewer* aViewer = theWshop->viewer();
98   connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
99           this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
100
101   createActions();
102 }
103
104 PartSet_Module::~PartSet_Module()
105 {
106   if (!myDocumentShapeFilter.IsNull())
107     myDocumentShapeFilter.Nullify();
108 }
109
110 void PartSet_Module::registerValidators()
111 {
112   //Registering of validators
113   SessionPtr aMgr = ModelAPI_Session::get();
114   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
115   aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
116   aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
117   aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
118   aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
119   aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
120   aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
121   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
122   aFactory->registerValidator("PartSet_SketchValidator", new PartSet_SketchValidator);
123 }
124
125 void PartSet_Module::registerFilters()
126 {
127   //Registering of selection filters
128   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
129   ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
130
131   aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
132   aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
133   aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
134   Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
135   aFactory->registerFilter("NoConstructionSubShapesFilter",
136             new ModuleBase_FilterCustom(aSelectFilter));
137 }
138
139 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
140 {
141   if (theOperation->isEditOperation())
142     return;
143   // the selection is cleared after commit the create operation
144   // in order to do not use the same selected objects in the restarted operation
145   // for common behaviour, the selection is cleared even if the operation is not restarted
146   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
147   if (!aContext.IsNull())
148     aContext->ClearSelected();
149
150   /// Restart sketcher operations automatically
151   FeaturePtr aFeature = theOperation->feature();
152   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
153             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
154   if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
155                      myRestartingMode == RM_EmptyFeatureUsed)) {
156     myLastOperationId = theOperation->id();
157     myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
158     
159     launchOperation(myLastOperationId);
160   }
161   breakOperationSequence();
162 }
163
164 void PartSet_Module::breakOperationSequence()
165 {
166   myLastOperationId = "";
167   myLastFeature = FeaturePtr();
168   myRestartingMode = RM_None;
169 }
170
171 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
172 {
173   breakOperationSequence();
174 }
175
176 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
177 {
178   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
179     mySketchMgr->startSketch(theOperation);
180   }
181   if (myDocumentShapeFilter.IsNull())
182     myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
183   myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
184 }
185
186 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
187 {
188   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
189     mySketchMgr->stopSketch(theOperation);
190   }
191   myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
192 }
193
194 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
195 {
196   bool aCanDisplay = false;
197   if (mySketchMgr->activeSketch()) {
198     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
199
200     if (aFeature.get() != NULL) {
201       if (aFeature == mySketchMgr->activeSketch()) {
202         aCanDisplay = false;
203       }
204       else {
205         aCanDisplay = mySketchMgr->sketchOperationIdList().contains(aFeature->getKind().c_str());
206       }
207     }
208   }
209   else {
210     aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
211   }
212   return aCanDisplay;
213
214 void PartSet_Module::addViewerItems(QMenu* theMenu) const
215 {
216   if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
217     return;
218   ModuleBase_ISelection* aSelection = myWorkshop->selection();
219   QObjectPtrList aObjects = aSelection->selectedPresentations();
220   if (aObjects.size() > 0) {
221     bool hasFeature = false;
222     foreach(ObjectPtr aObject, aObjects)
223     {
224       FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
225       if (aFeature.get() != NULL) {
226         hasFeature = true;
227       }
228     }
229     if (hasFeature)
230       theMenu->addAction(action("DELETE_PARTSET_CMD"));
231   }
232 }
233
234 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
235 {
236   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
237   if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) && 
238     (theOperation->isEditOperation())) {
239     // we have to manually activate the sketch label in edit mode
240       aPanel->activateWidget(aPanel->modelWidgets().first());
241       return;
242   }
243
244   // Restart last operation type 
245   if ((theOperation->id() == myLastOperationId) && myLastFeature) {
246     ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
247     if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
248       // Initialise new line with first point equal to end of previous
249       PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
250       if (aPnt2dWgt) {
251         std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
252         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
253           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
254         if (aPoint) {
255           aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
256           PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(), 
257             aWgt->attributeID(), aPoint->x(), aPoint->y());
258           aPanel->activateNextWidget(aPnt2dWgt);
259         }
260       }
261     }
262   } else {
263     // Start editing constraint
264     if (theOperation->isEditOperation()) {
265       // TODO: #391 - to be removed
266       std::string aId = theOperation->id().toStdString();
267       if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
268         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
269             (aId == SketchPlugin_ConstraintLength::ID()) || 
270             (aId == SketchPlugin_ConstraintDistance::ID())) {
271           // Find and activate widget for management of point for dimension line position
272           QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
273           foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
274             PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
275             if (aPntWgt) {
276               aPanel->activateWidget(aPntWgt);
277               return;
278             }
279           }
280         } 
281       }
282     }
283   }
284 }
285
286
287 void PartSet_Module::onSelectionChanged()
288 {
289   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
290   if (!aOperation)
291     return;
292
293   bool isSketcherOp = false;
294   // An edit operation is enable only if the current opeation is the sketch operation
295   if (mySketchMgr->activeSketch()) {
296     if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
297       isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
298   }
299   if (isSketcherOp) {
300     // Editing of constraints can be done on selection
301     ModuleBase_ISelection* aSelect = myWorkshop->selection();
302     QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
303     if (aSelected.size() == 1) {
304       ModuleBase_ViewerPrs aPrs = aSelected.first();
305       ObjectPtr aObject = aPrs.object();
306       FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
307       if (aFeature) {
308         std::string aId = aFeature->getKind();
309         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
310             (aId == SketchPlugin_ConstraintLength::ID()) || 
311             (aId == SketchPlugin_ConstraintDistance::ID())) {
312           editFeature(aFeature);
313         }
314       }
315     }
316   } 
317 }
318
319 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
320 {
321   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
322   XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
323   anOpMgr->onKeyReleased(theEvent);
324 }
325
326 void PartSet_Module::onEnterReleased()
327 {
328   myRestartingMode = RM_EmptyFeatureUsed;
329 }
330
331 void PartSet_Module::onOperationActivatedByPreselection()
332 {
333   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
334   if(aOperation && isSketchFeatureOperationActive()) {
335     // Set final definitions if they are necessary
336     //propertyPanelDefined(aOperation);
337
338     /// Commit sketcher operations automatically
339     aOperation->commit();
340   }
341 }
342
343 void PartSet_Module::onNoMoreWidgets()
344 {
345   if (isSketchFeatureOperationActive()) {
346     ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
347     if (aOperation) {
348       if (myRestartingMode != RM_Forbided)
349         myRestartingMode = RM_LastFeatureUsed;
350       aOperation->commit();
351     }
352   }
353 }
354
355 void PartSet_Module::onVertexSelected()
356 {
357   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
358   if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
359     /// If last line finished on vertex the lines creation sequence has to be break
360     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
361     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
362     if (aWidgets.last() == aPanel->activeWidget()) {
363       myRestartingMode = RM_Forbided;
364     }
365   }
366 }
367
368 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
369                                             Config_WidgetAPI* theWidgetApi, std::string theParentId,
370                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
371 {
372   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
373   XGUI_Workshop* aWorkshop = aConnector->workshop();
374   if (theType == "sketch-start-label") {
375     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
376     aWgt->setWorkshop(aWorkshop);
377     connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
378       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
379     theModelWidgets.append(aWgt);
380     return aWgt->getControl();
381
382   } else if (theType == "sketch-2dpoint_selector") {
383     PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
384     aWgt->setWorkshop(aWorkshop);
385     aWgt->setSketch(mySketchMgr->activeSketch());
386
387     connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
388
389     theModelWidgets.append(aWgt);
390     return aWgt->getControl();
391
392   } if (theType == "point2ddistance") {
393     PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
394     aWgt->setWorkshop(aWorkshop);
395     aWgt->setSketch(mySketchMgr->activeSketch());
396
397     theModelWidgets.append(aWgt);
398     return aWgt->getControl();
399
400   } if (theType == "sketch_shape_selector") {
401     PartSet_WidgetShapeSelector* aWgt = 
402       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
403     aWgt->setSketcher(mySketchMgr->activeSketch());
404
405     theModelWidgets.append(aWgt);
406     return aWgt->getControl();
407
408   } if (theType == "sketch_constraint_shape_selector") {
409     PartSet_WidgetConstraintShapeSelector* aWgt = 
410       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
411     aWgt->setSketcher(mySketchMgr->activeSketch());
412
413     theModelWidgets.append(aWgt);
414     return aWgt->getControl();
415
416   } else
417     return 0;
418 }
419
420 bool PartSet_Module::isSketchOperationActive() const
421 {
422   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
423
424   bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
425   return isSketchOp;
426 }
427
428 bool PartSet_Module::isSketchFeatureOperationActive() const
429 {
430   bool isCurrentSketchOp = false;
431   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
432   if (aOperation) {
433     FeaturePtr aFeature = aOperation->feature();
434     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
435               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
436     isCurrentSketchOp = aSPFeature.get() != NULL;
437   }
438   return isCurrentSketchOp;
439 }
440
441 void PartSet_Module::createActions()
442 {
443   QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
444   addAction("DELETE_PARTSET_CMD", aAction);
445 }
446
447 QAction* PartSet_Module::action(const QString& theId) const
448 {
449   if (myActions.contains(theId))
450     return myActions[theId];
451   return 0;
452 }
453
454 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
455 {
456   if (myActions.contains(theId))
457     qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
458   theAction->setData(theId);
459   connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
460   myActions[theId] = theAction;
461 }
462
463 void PartSet_Module::onAction(bool isChecked)
464 {
465   QAction* aAction = static_cast<QAction*>(sender());
466   QString anId = aAction->data().toString();
467
468   if (anId == "DELETE_PARTSET_CMD") {
469     deleteObjects();
470   }
471 }
472
473 void PartSet_Module::deleteObjects()
474 {
475   bool isSketchOp = isSketchOperationActive();
476   if (!isSketchOp && !isSketchFeatureOperationActive())
477     return;
478
479   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
480   XGUI_Workshop* aWorkshop = aConnector->workshop();
481
482   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
483   if (!isSketchOp && anOpMgr->canStopOperation()) {
484     ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
485     if (aCurrentOp) {
486       aCurrentOp->abort();
487     }
488   }
489   // sketch feature should be skipped, only sub-features can be removed
490   // when sketch operation is active
491   CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
492
493   ModuleBase_ISelection* aSel = aConnector->selection();
494   QObjectPtrList aSelectedObj = aSel->selectedPresentations();
495
496   std::set<FeaturePtr> aRefFeatures;
497   foreach (ObjectPtr aObj, aSelectedObj)
498   {
499     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
500     //if (aPart) {
501       // TODO: check for what there is this condition. It is placed here historicaly because
502       // ther is this condition during remove features.
503     //} else {
504     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
505     if (aFeature.get() != NULL) {
506       aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
507     }
508     //}
509   }
510
511   if (!aRefFeatures.empty()) {
512     QStringList aRefNames;
513     std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
514                                          aLast = aRefFeatures.end();
515     for (; anIt != aLast; anIt++) {
516       FeaturePtr aFeature = (*anIt);
517       if (aFeature == aSketch)
518         continue;
519       aRefNames.append((*anIt)->name().c_str());
520     }
521     if (!aRefNames.empty()) {
522       QString aNames = aRefNames.join(", ");
523
524       QMainWindow* aDesktop = aWorkshop->desktop();
525       QMessageBox::StandardButton aRes = QMessageBox::warning(
526           aDesktop, tr("Delete features"),
527           QString(tr("Selected features are used in the following features: %1.\
528   These features will be deleted also. Would you like to continue?")).arg(aNames),
529           QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
530       if (aRes != QMessageBox::Yes)
531         return;
532     }
533   }
534
535   SessionPtr aMgr = ModelAPI_Session::get();
536   aMgr->startOperation();
537   std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
538                                        aLast = aRefFeatures.end();
539   for (; anIt != aLast; anIt++) {
540     FeaturePtr aRefFeature = (*anIt);
541     if (aRefFeature == aSketch)
542       continue;
543     aRefFeature->document()->removeFeature(aRefFeature);
544   }
545
546   foreach (ObjectPtr aObj, aSelectedObj)
547   {
548     DocumentPtr aDoc = aObj->document();
549     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
550     //if (aPart) {
551     //  if (aDoc == aMgr->activeDocument()) {
552     //    aDoc->close();
553     //  }
554     //} else {
555       //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
556     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
557     if (aFeature.get() != NULL) {
558       aDoc->removeFeature(aFeature);
559     }
560     //}
561   }
562   aWorkshop->displayer()->updateViewer();
563   //myDisplayer->updateViewer();
564   aMgr->finishOperation();
565 }