Salome HOME
Detach, Auxiliary and Delete actions are granted for the Sketch feature.
[modules/shaper.git] / src / PartSet / PartSet_MenuMgr.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_MenuMgr.cpp
4 // Created:     03 April 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "PartSet_MenuMgr.h"
8 #include "PartSet_Module.h"
9 #include "PartSet_SketcherMgr.h"
10 #include "PartSet_Tools.h"
11
12 #include <PartSetPlugin_Part.h>
13
14 #include <GeomAPI_Pnt2d.h>
15 #include <GeomDataAPI_Point2D.h>
16
17 #include <SketchPlugin_ConstraintCoincidence.h>
18 #include <SketchPlugin_Line.h>
19 #include <SketchPlugin_Circle.h>
20 #include <SketchPlugin_Point.h>
21 #include <SketchPlugin_Sketch.h>
22
23 #include <ModuleBase_ISelection.h>
24 #include <ModuleBase_Operation.h>
25 #include <ModuleBase_OperationAction.h>
26 #include <ModuleBase_OperationFeature.h>
27
28 #include <XGUI_ModuleConnector.h>
29 #include <XGUI_Workshop.h>
30 #include <XGUI_Displayer.h>
31 #include <XGUI_DataModel.h>
32 #include <XGUI_ObjectsBrowser.h>
33 #include <XGUI_OperationMgr.h>
34
35 #include <Events_Loop.h>
36 #include <ModelAPI_Events.h>
37 #include <ModelAPI_Session.h>
38 #include <ModelAPI_ResultPart.h>
39 #include <ModelAPI_ResultParameter.h>
40
41 #include <QAction>
42 #include <QMenu>
43
44 #include <TopoDS.hxx>
45 #include <BRep_Tool.hxx>
46
47 PartSet_MenuMgr::PartSet_MenuMgr(PartSet_Module* theModule)
48   : QObject(theModule), myModule(theModule), myPrevId(-1)
49 {
50   createActions();
51 }
52
53
54 QAction* PartSet_MenuMgr::action(const QString& theId) const
55 {
56   if (myActions.contains(theId))
57     return myActions[theId];
58   return 0;
59 }
60
61 void PartSet_MenuMgr::addAction(const QString& theId, QAction* theAction)
62 {
63   if (myActions.contains(theId))
64     qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
65   theAction->setData(theId);
66   connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
67   myActions[theId] = theAction;
68 }
69
70 void PartSet_MenuMgr::createActions()
71 {
72   QAction* aAction;
73
74   aAction = new QAction(tr("Auxiliary"), this);
75   aAction->setCheckable(true);
76   addAction("AUXILIARY_CMD", aAction);
77
78   aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this);
79   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePart(bool)));
80   myActions["ACTIVATE_PART_CMD"] = aAction;
81
82   // Activate PartSet
83   aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this);
84   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePartSet(bool)));
85   myActions["ACTIVATE_PARTSET_CMD"] = aAction;
86
87   aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this);
88   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool)));
89   myActions["EDIT_CMD"] = aAction;
90
91   aAction = new QAction(QIcon(), tr("Select parent feature"), this);
92   aAction->setCheckable(false);
93   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSelectParentFeature()));
94   myActions["SELECT_PARENT_CMD"] = aAction;
95 }
96
97
98 void PartSet_MenuMgr::onAction(bool isChecked)
99 {
100   QAction* aAction = static_cast<QAction*>(sender());
101   QString anId = aAction->data().toString();
102
103   if (anId == "AUXILIARY_CMD") {
104     setAuxiliary(isChecked);
105   }
106 }
107
108 bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
109 {
110   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
111   if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
112       !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
113     return false;
114
115   myCoinsideLines.clear();
116   ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
117
118   bool aIsDetach = false;
119   bool hasAttribute = false;
120   bool hasFeature = false;
121
122   QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
123   TopoDS_Shape aShape;
124   ResultPtr aResult;
125   FeaturePtr aFeature;
126   foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
127     aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
128     if (aResult.get() != NULL) {
129       aShape = aPrs.shape();
130       if (aShape.IsEqual(aResult->shape()->impl<TopoDS_Shape>()))
131         hasFeature = true;
132       else
133         hasAttribute = true;
134     } else {
135       aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs.object());
136       hasFeature = (aFeature.get() != NULL);
137     }
138   }
139
140   if (aPrsList.size() == 1) {
141     TopoDS_Shape aShape = aPrsList.first().shape();
142     if ((!aShape.IsNull()) && aShape.ShapeType() == TopAbs_VERTEX) {
143       // Find 2d coordinates
144       FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch();
145       if (aSketchFea->getKind() == SketchPlugin_Sketch::ID()) {
146         gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
147         std::shared_ptr<GeomAPI_Pnt> aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
148         std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d);
149
150         // Find coincident in these coordinates
151         ObjectPtr aObj = aPrsList.first().object();
152         FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
153         const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
154         std::set<AttributePtr>::const_iterator aIt;
155         FeaturePtr aCoincident;
156         for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
157           std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
158           FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
159           if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
160             std::shared_ptr<GeomAPI_Pnt2d> a2dPnt = 
161               PartSet_Tools::getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A());
162             if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { 
163               aCoincident = aConstrFeature;
164               break;
165             } else {
166               a2dPnt = PartSet_Tools::getPoint(aConstrFeature,
167                                                SketchPlugin_ConstraintCoincidence::ENTITY_B());
168               if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { 
169                 aCoincident = aConstrFeature;
170                 break;
171               }
172             }
173           }
174         }
175         // If we have coincidence then add Detach menu
176         if (aCoincident.get() != NULL) {
177           mySelectedFeature = aCoincident;
178           PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
179                                           SketchPlugin_ConstraintCoincidence::ENTITY_A());
180           PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
181                                           SketchPlugin_ConstraintCoincidence::ENTITY_B());
182           if (myCoinsideLines.size() > 0) {
183             aIsDetach = true;
184             QMenu* aSubMenu = theMenu->addMenu(tr("Detach"));
185             QAction* aAction;
186             int i = 0;
187             foreach (FeaturePtr aCoins, myCoinsideLines) {
188               aAction = aSubMenu->addAction(aCoins->data()->name().c_str());
189               aAction->setData(QVariant(i));
190               i++;
191             }
192             connect(aSubMenu, SIGNAL(hovered(QAction*)), SLOT(onLineHighlighted(QAction*)));
193             connect(aSubMenu, SIGNAL(aboutToHide()), SLOT(onDetachMenuHide()));
194             connect(aSubMenu, SIGNAL(triggered(QAction*)), SLOT(onLineDetach(QAction*)));
195           } 
196         }
197       }
198     }
199   }
200   if ((!aIsDetach) && hasFeature) {
201     theMenu->addAction(theStdActions["DELETE_CMD"]);
202   }
203   if (hasAttribute)
204     return true;
205   bool isAuxiliary;
206   if (canSetAuxiliary(isAuxiliary)) {
207     QAction* anAction = action("AUXILIARY_CMD");
208     theMenu->addAction(anAction);
209     anAction->setChecked(isAuxiliary);
210   }
211   return true;
212 }
213
214 void PartSet_MenuMgr::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
215 {
216   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
217
218   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
219                         PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
220   if (isActiveSketch) {
221     theStdActions["WIREFRAME_CMD"]->setEnabled(false);
222     theStdActions["SHADING_CMD"]->setEnabled(false);
223     theStdActions["SHOW_ONLY_CMD"]->setEnabled(false);
224     theStdActions["SHOW_CMD"]->setEnabled(false);
225     theStdActions["HIDE_CMD"]->setEnabled(false);
226     theStdActions["HIDEALL_CMD"]->setEnabled(false);
227   }
228 }
229
230
231 void PartSet_MenuMgr::onLineHighlighted(QAction* theAction)
232 {
233   if (myPrevId != -1) {
234     // Restore color for previous object
235     setLineColor(myPrevId, myColor, false);
236   }
237   myPrevId = theAction->data().toInt();
238   myColor = setLineColor(myPrevId, Qt::white, true);
239 }
240
241 QColor PartSet_MenuMgr::setLineColor(int theId, const QColor theColor, bool theUpdate)
242 {
243   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
244   XGUI_Workshop* aWorkshop = aConnector->workshop();
245   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
246
247   FeaturePtr aLine = myCoinsideLines.at(myPrevId);
248   std::list<ResultPtr>::const_iterator aIt;
249   const std::list<ResultPtr>& aResults = aLine->results();
250   QColor aColor;
251   for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
252     aColor = aDisplayer->setObjectColor((*aIt), theColor, false);
253   }
254   if (theUpdate)
255     aDisplayer->updateViewer();
256   return aColor;
257 }
258
259
260 void PartSet_MenuMgr::onLineDetach(QAction* theAction)
261 {
262   int aId = theAction->data().toInt();
263   FeaturePtr aLine = myCoinsideLines.at(aId);
264   std::shared_ptr<GeomAPI_Pnt2d> aOrig = PartSet_Tools::getPoint(mySelectedFeature,
265                                                         SketchPlugin_ConstraintCoincidence::ENTITY_A());
266   if (aOrig.get() == NULL)
267     aOrig = PartSet_Tools::getPoint(mySelectedFeature,
268                                     SketchPlugin_ConstraintCoincidence::ENTITY_B());
269   
270   gp_Pnt aOr = aOrig->impl<gp_Pnt>();
271   const std::set<AttributePtr>& aRefsList = aLine->data()->refsToMe();
272
273   QObjectPtrList aToDelFeatures;
274   std::set<AttributePtr>::const_iterator aIt;
275   // Find all coincedences corresponded to the selected line in the selected point
276   for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
277     std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
278     FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
279     if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
280       std::shared_ptr<GeomAPI_Pnt2d> aPnt = PartSet_Tools::getPoint(aConstrFeature,
281                                             SketchPlugin_ConstraintCoincidence::ENTITY_A());
282       if (aPnt.get() == NULL)
283         aPnt = PartSet_Tools::getPoint(aConstrFeature,
284                                        SketchPlugin_ConstraintCoincidence::ENTITY_B());
285       if (aPnt.get() == NULL)
286         return;
287       gp_Pnt aP = aPnt->impl<gp_Pnt>();
288       if (aOrig->isEqual(aPnt)) {
289         aToDelFeatures.append(aConstrFeature);
290       } else {
291         aPnt = PartSet_Tools::getPoint(aConstrFeature,
292                                        SketchPlugin_ConstraintCoincidence::ENTITY_B());
293         if (aPnt.get() == NULL)
294           return;
295         aP = aPnt->impl<gp_Pnt>();
296         if (aOrig->isEqual(aPnt)) {
297           aToDelFeatures.append(aConstrFeature);
298           break;
299         }
300       }
301     }
302   }
303   if (aToDelFeatures.size() > 0) {
304     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
305     XGUI_Workshop* aWorkshop = aConnector->workshop();
306     ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
307
308     ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(
309                                    tr("Detach %1").arg(aLine->data()->name().c_str()), myModule);
310     bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
311     XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
312     // the active nested sketch operation should be aborted unconditionally
313     // the Delete action should be additionally granted for the Sketch operation
314     // in order to do not abort/commit it
315     if (!anOpMgr->canStartOperation(tr("Detach")))
316       return; // the objects are processed but can not be deleted
317
318     anOpMgr->startOperation(anOpAction);
319     aWorkshop->deleteFeatures(aToDelFeatures);
320     
321     anOpMgr->commitOperation();
322   }
323   myCoinsideLines.clear();
324 }
325
326
327 void PartSet_MenuMgr::onDetachMenuHide()
328 {
329   if (myPrevId != -1) {
330     // Restore color for previous object
331     setLineColor(myPrevId, myColor, false);
332   }
333   // Clear previous definitions
334   myPrevId = -1;
335 }
336
337   
338 void PartSet_MenuMgr::setAuxiliary(const bool isChecked)
339 {
340   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
341
342   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
343                         PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
344   if (!isActiveSketch)
345     return;
346
347   QObjectPtrList anObjects;
348   bool isUseTransaction = false;
349   // 1. change auxiliary type of a created feature
350   if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
351       PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
352       ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
353                                                                (anOperation);
354       if (aFOperation)
355         anObjects.append(aFOperation->feature());
356   }
357   else {
358     isUseTransaction = true;
359     // 2. change auxiliary type of selected sketch entities
360     ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
361     anObjects = aSelection->selectedPresentations();
362   }
363
364   QAction* anAction = action("AUXILIARY_CMD");
365   //SessionPtr aMgr = ModelAPI_Session::get();
366   ModuleBase_OperationAction* anOpAction = 0;
367   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
368   XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
369   if (isUseTransaction) {
370     anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
371     bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
372
373     if (!anOpMgr->canStartOperation(anOpAction->id()))
374       return; // the objects are processed but can not be deleted
375
376     anOpMgr->startOperation(anOpAction);
377   }
378   myModule->sketchMgr()->storeSelection();
379
380   if (anObjects.size() > 0) {
381     QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
382     for (; anIt != aLast; anIt++) {
383       FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
384       if (aFeature.get() != NULL) {
385         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
386                             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
387         if (aSketchFeature.get() != NULL) {
388           std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
389
390           std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr = 
391             std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
392           if (anAuxiliaryAttr)
393             anAuxiliaryAttr->setValue(isChecked);
394         }
395       }
396     }
397   }
398   if (isUseTransaction)
399     anOpMgr->commitOperation();
400
401   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
402   myModule->sketchMgr()->restoreSelection();
403 }
404
405 bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const
406 {
407   bool anEnabled = false;
408   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
409
410   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
411                         PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
412   if (!isActiveSketch)
413     return anEnabled;
414
415   QObjectPtrList anObjects;
416   // 1. change auxiliary type of a created feature
417   if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
418     PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
419     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
420     if (aFOperation)
421       anObjects.append(aFOperation->feature());
422   }
423   else {
424     /// The operation should not be aborted here, because the method does not changed
425     /// the auxilliary state, but checks the possibility to perform this
426     ///if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
427     ///  anOperation->abort();
428     // 2. change auxiliary type of selected sketch entities
429     ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
430     anObjects = aSelection->selectedPresentations();
431   }
432
433   bool isNotAuxiliaryFound = false;
434   if (anObjects.size() > 0) {
435     QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
436     for (; anIt != aLast && !isNotAuxiliaryFound; anIt++) {
437       FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
438       if ((aFeature.get() != NULL) && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
439         anEnabled = true;
440         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
441                             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
442         if (aSketchFeature.get() != NULL) {
443           std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
444
445           std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr = 
446             std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
447           if (anAuxiliaryAttr)
448             isNotAuxiliaryFound = !anAuxiliaryAttr->value();
449         }
450       }
451     }
452   }
453   theValue = anObjects.size() && !isNotAuxiliaryFound;
454   return anEnabled;
455 }
456
457 void PartSet_MenuMgr::onActivatePart(bool)
458 {
459   if (myModule->workshop()->currentOperation())
460     return;
461   QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects();
462   if (aObjects.size() > 0) {
463     ObjectPtr aObj = aObjects.first();
464     ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
465     if (!aPart.get()) {
466       FeaturePtr aPartFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
467       if (aPartFeature.get() && (aPartFeature->getKind() == PartSetPlugin_Part::ID())) {
468         aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aPartFeature->firstResult());
469       }
470     }
471     if (aPart.get())
472       aPart->activate();
473   }
474 }
475
476 void PartSet_MenuMgr::onActivatePartSet(bool)
477 {
478   if (myModule->workshop()->currentOperation())
479     return;
480   activatePartSet();
481 }
482
483 void PartSet_MenuMgr::activatePartSet() const
484 {
485   SessionPtr aMgr = ModelAPI_Session::get();
486   bool isNewTransaction = !aMgr->isOperation();
487   // activation may cause changes in current features in document, so it must be in transaction
488   if (isNewTransaction) aMgr->startOperation("Activation");
489   aMgr->setActiveDocument(aMgr->moduleDocument());
490   if (isNewTransaction) aMgr->finishOperation();
491 }
492
493 void PartSet_MenuMgr::grantedOperationIds(ModuleBase_Operation* theOperation,
494                                           QStringList& theIds) const
495 {
496   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
497     theIds.append(tr("Detach"));
498     theIds.append(tr("Auxiliary"));
499   }
500 }
501
502 void PartSet_MenuMgr::onEdit(bool)
503 {
504   QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects();
505   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObjects.first());
506   if (aFeature == NULL) {
507     ResultParameterPtr aParam = 
508       std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObjects.first());
509     if (aParam.get() != NULL) {
510       aFeature = ModelAPI_Feature::feature(aParam);
511     }
512   }
513   if (aFeature.get() != NULL)
514     myModule->editFeature(aFeature);
515 }
516
517 void PartSet_MenuMgr::onSelectParentFeature()
518 {
519   QObjectPtrList aObjects = myModule->workshop()->selection()->selectedObjects();
520   if (aObjects.size() != 1)
521     return;
522
523   SessionPtr aMgr = ModelAPI_Session::get();
524   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>( aObjects.first() );
525   if( !aResult.get() )
526     return;
527
528   FeaturePtr aParentFeature = aResult->document()->feature( aResult );
529   QObjectPtrList aSelection;
530   aSelection.append( aParentFeature );
531   myModule->workshop()->selection()->setSelectedObjects( aSelection );
532 }