Salome HOME
History for undo and redo commands
[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
215 void PartSet_Module::addViewerItems(QMenu* theMenu) const
216 {
217   if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
218     return;
219   ModuleBase_ISelection* aSelection = myWorkshop->selection();
220   QObjectPtrList aObjects = aSelection->selectedPresentations();
221   if (aObjects.size() > 0) {
222     bool hasFeature = false;
223     foreach(ObjectPtr aObject, aObjects)
224     {
225       FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
226       if (aFeature.get() != NULL) {
227         hasFeature = true;
228       }
229     }
230     if (hasFeature)
231       theMenu->addAction(action("DELETE_PARTSET_CMD"));
232   }
233 }
234
235 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
236 {
237   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
238   if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) && 
239     (theOperation->isEditOperation())) {
240     // we have to manually activate the sketch label in edit mode
241       aPanel->activateWidget(aPanel->modelWidgets().first());
242       return;
243   }
244
245   // Restart last operation type 
246   if ((theOperation->id() == myLastOperationId) && myLastFeature) {
247     ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
248     if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
249       // Initialise new line with first point equal to end of previous
250       PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
251       if (aPnt2dWgt) {
252         std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
253         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
254           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
255         if (aPoint) {
256           aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
257           PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(), 
258             aWgt->attributeID(), aPoint->x(), aPoint->y());
259           aPanel->activateNextWidget(aPnt2dWgt);
260         }
261       }
262     }
263   } else {
264     // Start editing constraint
265     if (theOperation->isEditOperation()) {
266       // TODO: #391 - to be removed
267       std::string aId = theOperation->id().toStdString();
268       if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
269         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
270             (aId == SketchPlugin_ConstraintLength::ID()) || 
271             (aId == SketchPlugin_ConstraintDistance::ID())) {
272           // Find and activate widget for management of point for dimension line position
273           QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
274           foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
275             PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
276             if (aPntWgt) {
277               aPanel->activateWidget(aPntWgt);
278               return;
279             }
280           }
281         } 
282       }
283     }
284   }
285 }
286
287
288 void PartSet_Module::onSelectionChanged()
289 {
290   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
291   if (!aOperation)
292     return;
293
294   bool isSketcherOp = false;
295   // An edit operation is enable only if the current opeation is the sketch operation
296   if (mySketchMgr->activeSketch()) {
297     if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
298       isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
299   }
300   if (isSketcherOp) {
301     // Editing of constraints can be done on selection
302     ModuleBase_ISelection* aSelect = myWorkshop->selection();
303     QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
304     if (aSelected.size() == 1) {
305       ModuleBase_ViewerPrs aPrs = aSelected.first();
306       ObjectPtr aObject = aPrs.object();
307       FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
308       if (aFeature) {
309         std::string aId = aFeature->getKind();
310         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
311             (aId == SketchPlugin_ConstraintLength::ID()) || 
312             (aId == SketchPlugin_ConstraintDistance::ID())) {
313           editFeature(aFeature);
314         }
315       }
316     }
317   } 
318 }
319
320 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
321 {
322   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
323   XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
324   anOpMgr->onKeyReleased(theEvent);
325 }
326
327 void PartSet_Module::onEnterReleased()
328 {
329   myRestartingMode = RM_EmptyFeatureUsed;
330 }
331
332 void PartSet_Module::onOperationActivatedByPreselection()
333 {
334   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
335   if(aOperation && isSketchFeatureOperationActive()) {
336     // Set final definitions if they are necessary
337     //propertyPanelDefined(aOperation);
338
339     /// Commit sketcher operations automatically
340     aOperation->commit();
341   }
342 }
343
344 void PartSet_Module::onNoMoreWidgets()
345 {
346   if (isSketchFeatureOperationActive()) {
347     ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
348     if (aOperation) {
349       if (myRestartingMode != RM_Forbided)
350         myRestartingMode = RM_LastFeatureUsed;
351       aOperation->commit();
352     }
353   }
354 }
355
356 void PartSet_Module::onVertexSelected()
357 {
358   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
359   if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
360     /// If last line finished on vertex the lines creation sequence has to be break
361     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
362     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
363     if (aWidgets.last() == aPanel->activeWidget()) {
364       myRestartingMode = RM_Forbided;
365     }
366   }
367 }
368
369 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
370                                             Config_WidgetAPI* theWidgetApi, std::string theParentId,
371                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
372 {
373   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
374   XGUI_Workshop* aWorkshop = aConnector->workshop();
375   if (theType == "sketch-start-label") {
376     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
377     aWgt->setWorkshop(aWorkshop);
378     connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
379       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
380     theModelWidgets.append(aWgt);
381     return aWgt->getControl();
382
383   } else if (theType == "sketch-2dpoint_selector") {
384     PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
385     aWgt->setWorkshop(aWorkshop);
386     aWgt->setSketch(mySketchMgr->activeSketch());
387
388     connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
389
390     theModelWidgets.append(aWgt);
391     return aWgt->getControl();
392
393   } if (theType == "point2ddistance") {
394     PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
395     aWgt->setWorkshop(aWorkshop);
396     aWgt->setSketch(mySketchMgr->activeSketch());
397
398     theModelWidgets.append(aWgt);
399     return aWgt->getControl();
400
401   } if (theType == "sketch_shape_selector") {
402     PartSet_WidgetShapeSelector* aWgt = 
403       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
404     aWgt->setSketcher(mySketchMgr->activeSketch());
405
406     theModelWidgets.append(aWgt);
407     return aWgt->getControl();
408
409   } if (theType == "sketch_constraint_shape_selector") {
410     PartSet_WidgetConstraintShapeSelector* aWgt = 
411       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
412     aWgt->setSketcher(mySketchMgr->activeSketch());
413
414     theModelWidgets.append(aWgt);
415     return aWgt->getControl();
416
417   } else
418     return 0;
419 }
420
421 bool PartSet_Module::isSketchOperationActive() const
422 {
423   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
424
425   bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
426   return isSketchOp;
427 }
428
429 bool PartSet_Module::isSketchFeatureOperationActive() const
430 {
431   bool isCurrentSketchOp = false;
432   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
433   if (aOperation) {
434     FeaturePtr aFeature = aOperation->feature();
435     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
436               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
437     isCurrentSketchOp = aSPFeature.get() != NULL;
438   }
439   return isCurrentSketchOp;
440 }
441
442 void PartSet_Module::createActions()
443 {
444   QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
445   addAction("DELETE_PARTSET_CMD", aAction);
446 }
447
448 QAction* PartSet_Module::action(const QString& theId) const
449 {
450   if (myActions.contains(theId))
451     return myActions[theId];
452   return 0;
453 }
454
455 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
456 {
457   if (myActions.contains(theId))
458     qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
459   theAction->setData(theId);
460   connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
461   myActions[theId] = theAction;
462 }
463
464 void PartSet_Module::onAction(bool isChecked)
465 {
466   QAction* aAction = static_cast<QAction*>(sender());
467   QString anId = aAction->data().toString();
468
469   if (anId == "DELETE_PARTSET_CMD") {
470     deleteObjects();
471   }
472 }
473
474 void PartSet_Module::deleteObjects()
475 {
476   bool isSketchOp = isSketchOperationActive();
477   if (!isSketchOp && !isSketchFeatureOperationActive())
478     return;
479
480   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
481   XGUI_Workshop* aWorkshop = aConnector->workshop();
482
483   XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
484   if (!isSketchOp && anOpMgr->canStopOperation()) {
485     ModuleBase_Operation* aCurrentOp = anOpMgr->currentOperation();
486     if (aCurrentOp) {
487       aCurrentOp->abort();
488     }
489   }
490   // sketch feature should be skipped, only sub-features can be removed
491   // when sketch operation is active
492   CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
493
494   ModuleBase_ISelection* aSel = aConnector->selection();
495   QObjectPtrList aSelectedObj = aSel->selectedPresentations();
496
497   std::set<FeaturePtr> aRefFeatures;
498   foreach (ObjectPtr aObj, aSelectedObj)
499   {
500     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
501     //if (aPart) {
502       // TODO: check for what there is this condition. It is placed here historicaly because
503       // ther is this condition during remove features.
504     //} else {
505     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
506     if (aFeature.get() != NULL) {
507       aObj->document()->refsToFeature(aFeature, aRefFeatures, false);
508     }
509     //}
510   }
511
512   if (!aRefFeatures.empty()) {
513     QStringList aRefNames;
514     std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
515                                          aLast = aRefFeatures.end();
516     for (; anIt != aLast; anIt++) {
517       FeaturePtr aFeature = (*anIt);
518       if (aFeature == aSketch)
519         continue;
520       aRefNames.append((*anIt)->name().c_str());
521     }
522     if (!aRefNames.empty()) {
523       QString aNames = aRefNames.join(", ");
524
525       QMainWindow* aDesktop = aWorkshop->desktop();
526       QMessageBox::StandardButton aRes = QMessageBox::warning(
527           aDesktop, tr("Delete features"),
528           QString(tr("Selected features are used in the following features: %1.\
529   These features will be deleted also. Would you like to continue?")).arg(aNames),
530           QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
531       if (aRes != QMessageBox::Yes)
532         return;
533     }
534   }
535
536   SessionPtr aMgr = ModelAPI_Session::get();
537   aMgr->startOperation("DeletePartSet");
538   std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
539                                        aLast = aRefFeatures.end();
540   for (; anIt != aLast; anIt++) {
541     FeaturePtr aRefFeature = (*anIt);
542     if (aRefFeature == aSketch)
543       continue;
544     aRefFeature->document()->removeFeature(aRefFeature);
545   }
546
547   foreach (ObjectPtr aObj, aSelectedObj)
548   {
549     DocumentPtr aDoc = aObj->document();
550     //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
551     //if (aPart) {
552     //  if (aDoc == aMgr->activeDocument()) {
553     //    aDoc->close();
554     //  }
555     //} else {
556       //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
557     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
558     if (aFeature.get() != NULL) {
559       aDoc->removeFeature(aFeature);
560     }
561     //}
562   }
563   aWorkshop->displayer()->updateViewer();
564   //myDisplayer->updateViewer();
565   aMgr->finishOperation();
566 }