Salome HOME
39830ef5576aaf32c67ddb31707b383bdaeab0b5
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
1 #include "PartSet_Module.h"
2 #include <PartSet_OperationSketch.h>
3 #include <PartSet_WidgetSketchLabel.h>
4 #include <PartSet_Validators.h>
5 #include <PartSet_Tools.h>
6 #include <PartSet_WidgetPoint2D.h>
7 #include <PartSet_WidgetPoint2dDistance.h>
8 #include <PartSet_WidgetShapeSelector.h>
9
10 #include <ModuleBase_Operation.h>
11 #include <ModuleBase_IViewer.h>
12 #include <ModuleBase_IViewWindow.h>
13 #include <ModuleBase_IPropertyPanel.h>
14
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Events.h>
17 #include <ModelAPI_Validator.h>
18 #include <ModelAPI_Data.h>
19 #include <ModelAPI_Session.h>
20
21 #include <GeomDataAPI_Point2D.h>
22 #include <GeomDataAPI_Point.h>
23 #include <GeomDataAPI_Dir.h>
24
25 #include <XGUI_MainWindow.h>
26 #include <XGUI_Displayer.h>
27 #include <XGUI_Viewer.h>
28 #include <XGUI_Workshop.h>
29 #include <XGUI_OperationMgr.h>
30 #include <XGUI_ViewPort.h>
31 #include <XGUI_ActionsMgr.h>
32 #include <XGUI_ViewerProxy.h>
33 #include <XGUI_ContextMenuMgr.h>
34 #include <XGUI_PropertyPanel.h>
35 #include <XGUI_ModuleConnector.h>
36 #include <XGUI_Tools.h>
37
38 #include <SketchPlugin_Line.h>
39 #include <SketchPlugin_Sketch.h>
40 #include <SketchPlugin_Point.h>
41 #include <SketchPlugin_Arc.h>
42 #include <SketchPlugin_Circle.h>
43 #include <SketchPlugin_ConstraintLength.h>
44 #include <SketchPlugin_ConstraintDistance.h>
45 #include <SketchPlugin_ConstraintParallel.h>
46 #include <SketchPlugin_ConstraintPerpendicular.h>
47 #include <SketchPlugin_ConstraintRadius.h>
48 #include <SketchPlugin_ConstraintRigid.h>
49
50 #include <Events_Loop.h>
51
52 #include <StdSelect_TypeOfFace.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <TopoDS.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <BRep_Tool.hxx>
57
58 #include <QObject>
59 #include <QMouseEvent>
60 #include <QString>
61 #include <QTimer>
62 #include <QApplication>
63
64 #include <GeomAlgoAPI_FaceBuilder.h>
65 #include <GeomDataAPI_Dir.h>
66
67 #ifdef _DEBUG
68 #include <QDebug>
69 #endif
70
71
72 /// Returns list of unique objects by sum of objects from List1 and List2
73 QList<ObjectPtr> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
74                                        const QList<ModuleBase_ViewerPrs>& theList2)
75 {
76   QList<ObjectPtr> aRes;
77   foreach (ModuleBase_ViewerPrs aPrs, theList1) {
78     if (!aRes.contains(aPrs.object()))
79       aRes.append(aPrs.object());
80   }
81   foreach (ModuleBase_ViewerPrs aPrs, theList2) {
82     if (!aRes.contains(aPrs.object()))
83       aRes.append(aPrs.object());
84   }
85   return aRes;
86 }
87
88 /*!Create and return new instance of XGUI_Module*/
89 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
90 {
91   return new PartSet_Module(theWshop);
92 }
93
94 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
95   : ModuleBase_IModule(theWshop), 
96   myIsDragging(false), myRestartingMode(true), myDragDone(false)
97 {
98   //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
99   ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
100   connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
101           this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
102
103   connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
104           this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
105
106   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
107           this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
108
109 }
110
111 PartSet_Module::~PartSet_Module()
112 {
113 }
114
115 void PartSet_Module::registerValidators()
116 {
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 }
126
127
128 void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation) 
129 {
130   if (theOperation->isEditOperation())
131     return;
132   /// Restart sketcher operations automatically
133   FeaturePtr aFeature = theOperation->feature();
134   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
135             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
136   if (aSPFeature && myRestartingMode) {
137     myLastOperationId = theOperation->id();
138     myLastFeature = theOperation->feature();
139     launchOperation(myLastOperationId);
140   } else {
141     breakOperationSequence();
142   }
143 }
144
145 void PartSet_Module::breakOperationSequence()
146 {
147   myLastOperationId = "";
148   myLastFeature = FeaturePtr();
149   myRestartingMode = false;
150
151 }
152
153 void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
154 {
155   breakOperationSequence();
156 }
157
158 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
159 {
160   myRestartingMode = true;
161   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
162     // Display all sketcher sub-Objects
163     myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
164     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
165     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
166
167     for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
168       FeaturePtr aFeature = myCurrentSketch->subFeature(i);
169       std::list<ResultPtr> aResults = aFeature->results();
170       std::list<ResultPtr>::const_iterator aIt;
171       for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
172         aDisplayer->display((*aIt), false);
173       }
174       aDisplayer->display(aFeature);
175     }
176     // Hide sketcher result
177     std::list<ResultPtr> aResults = myCurrentSketch->results();
178     std::list<ResultPtr>::const_iterator aIt;
179     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
180       aDisplayer->erase((*aIt), false);
181     }
182     aDisplayer->erase(myCurrentSketch);
183
184
185     if (myPlaneFilter.IsNull()) 
186       myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
187     myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
188     if (theOperation->isEditOperation()) {
189       // If it is editing of sketch then it means that plane is already defined
190       std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
191       myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
192     }
193   }
194 }
195
196 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
197 {
198   if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
199     DataPtr aData = myCurrentSketch->data();
200     if ((!aData) || (!aData->isValid())) {
201       // The sketch was aborted
202       myCurrentSketch = CompositeFeaturePtr();
203       return; 
204     }
205     // Hide all sketcher sub-Objects
206     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
207     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
208     for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
209       FeaturePtr aFeature = myCurrentSketch->subFeature(i);
210       std::list<ResultPtr> aResults = aFeature->results();
211       std::list<ResultPtr>::const_iterator aIt;
212       for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
213         aDisplayer->erase((*aIt), false);
214       }
215       aDisplayer->erase(aFeature, false);
216     }
217     // Display sketcher result
218     std::list<ResultPtr> aResults = myCurrentSketch->results();
219     std::list<ResultPtr>::const_iterator aIt;
220     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
221       aDisplayer->display((*aIt), false);
222     }
223     aDisplayer->display(myCurrentSketch);
224     
225     myCurrentSketch = CompositeFeaturePtr();
226     myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
227   }
228 }
229
230 void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
231 {
232   myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
233 }
234
235
236 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
237 {
238   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
239   // Restart last operation type 
240   if ((theOperation->id() == myLastOperationId) && myLastFeature) {
241     ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
242     if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
243       // Initialise new line with first point equal to end of previous
244       PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
245       if (aPnt2dWgt) {
246         std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
247         std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
248           std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
249         if (aPoint) {
250           aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
251           PartSet_Tools::setConstraints(myCurrentSketch, theOperation->feature(), 
252             aWgt->attributeID(), aPoint->x(), aPoint->y());
253           theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt);
254         }
255       }
256     }
257   } else {
258     // Start editing constraint
259     if (theOperation->isEditOperation()) {
260       std::string aId = theOperation->id().toStdString();
261       if (sketchOperationIdList().contains(QString(aId.c_str()))) {
262         if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
263             (aId == SketchPlugin_ConstraintLength::ID()) || 
264             (aId == SketchPlugin_ConstraintDistance::ID())) {
265           // Find and activate widget for management of point for dimension line position
266           QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
267           foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
268             PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
269             if (aPntWgt) {
270               aPanel->activateWidget(aPntWgt);
271               return;
272             }
273           }
274         } 
275       }
276     }
277   }
278 }
279
280
281 void PartSet_Module::onSelectionChanged()
282 {
283   // Editing of constraints can be done on selection
284   ModuleBase_ISelection* aSelect = myWorkshop->selection();
285   QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
286   if (aSelected.size() == 1) {
287     ModuleBase_ViewerPrs aPrs = aSelected.first();
288     ObjectPtr aObject = aPrs.object();
289     FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
290     if (aFeature) {
291       std::string aId = aFeature->getKind();
292       if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
293           (aId == SketchPlugin_ConstraintLength::ID()) || 
294           (aId == SketchPlugin_ConstraintDistance::ID())) {
295         editFeature(aFeature);
296       }
297     }
298   }
299 }
300
301 void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) 
302 {
303   if (!(theEvent->buttons() & Qt::LeftButton))
304     return;
305
306   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
307   // Use only for sketch operations
308   if (aOperation && myCurrentSketch) {
309     if (!PartSet_Tools::sketchPlane(myCurrentSketch))
310       return;
311
312     bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
313     bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
314
315     // Avoid non-sketch operations
316     if ((!isSketchOpe) && (!isSketcher))
317       return;
318
319     bool isEditing = aOperation->isEditOperation();
320
321     // Ignore creation sketch operation
322     if ((!isSketcher) && (!isEditing))
323       return;
324
325     if (theEvent->modifiers()) {
326       // If user performs multiselection
327       if (isSketchOpe && (!isSketcher))
328         if (!aOperation->commit())
329           aOperation->abort();
330       return;
331     }
332     // Remember highlighted objects for editing
333     ModuleBase_ISelection* aSelect = myWorkshop->selection();
334     QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
335     QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
336     myEditingFeatures.clear();
337     myEditingAttr.clear();
338     if ((aHighlighted.size() == 0) && (aSelected.size() == 0)) {
339       if (isSketchOpe && (!isSketcher))
340         // commit previous operation
341         if (!aOperation->commit())
342           aOperation->abort();
343       return;
344     }
345
346     if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
347       // Move by selected shape (vertex). Can be used only for single selection
348       foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
349         FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object());
350         if (aFeature) {
351           myEditingFeatures.append(aFeature);
352           TopoDS_Shape aShape = aPrs.shape();
353           if (!aShape.IsNull()) {
354             if (aShape.ShapeType() == TopAbs_VERTEX) {
355               AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(), 
356                                                                          aShape, myCurrentSketch);
357               if (aAttr)
358                 myEditingAttr.append(aAttr);
359             }
360           }
361         }
362       }
363     } else {
364       // Provide multi-selection. Can be used only for features
365       QList<ObjectPtr> aObjects = getSumList(aHighlighted, aSelected);
366       foreach (ObjectPtr aObj, aObjects) {
367         FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
368         if (aFeature && (!myEditingFeatures.contains(aFeature)))
369           myEditingFeatures.append(aFeature);
370       }
371
372     }
373     // If nothing highlighted - return
374     if (myEditingFeatures.size() == 0)
375       return;
376
377     if (isSketcher) {
378       myIsDragging = true;
379       get2dPoint(theWnd, theEvent, myCurX, myCurY);
380       myDragDone = false;
381       myWorkshop->viewer()->enableSelection(false);
382
383       launchEditing();
384
385     } else if (isSketchOpe && isEditing) {
386       // If selected another object
387       aOperation->abort();
388
389       myIsDragging = true;
390       get2dPoint(theWnd, theEvent, myCurX, myCurY);
391       myDragDone = false;
392       myWorkshop->viewer()->enableSelection(false);
393
394       // This is necessary in order to finalize previous operation
395       QApplication::processEvents();
396       launchEditing();
397     }
398   }
399 }
400
401
402 void PartSet_Module::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
403                                 double& theX, double& theY)
404 {
405   Handle(V3d_View) aView = theWnd->v3dView();
406   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
407   PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
408 }
409
410
411 void PartSet_Module::launchEditing()
412 {
413   if (myEditingFeatures.size() > 0) {
414     FeaturePtr aFeature = myEditingFeatures.first();
415     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
416               std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
417     if (aSPFeature) {
418       editFeature(aSPFeature);
419     }
420   }
421 }
422
423 /// Returns new instance of operation object (used in createOperation for customization)
424 ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
425 {
426   if (theFeatureId == PartSet_OperationSketch::Type()) {
427     return new PartSet_OperationSketch(theFeatureId.c_str(), this);
428   }
429   return ModuleBase_IModule::getNewOperation(theFeatureId);
430 }
431
432
433 void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
434 {
435   myWorkshop->viewer()->enableSelection(true);
436   if (myIsDragging) {
437     myIsDragging = false;
438     if (myDragDone) {
439       myWorkshop->currentOperation()->commit();
440       myEditingFeatures.clear();
441       myEditingAttr.clear();
442     }
443   }
444 }
445
446
447 void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
448 {
449   if (myIsDragging) {
450     ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
451     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
452       return; // No edit operation activated
453
454     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
455     Handle(V3d_View) aView = theWnd->v3dView();
456     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
457     double aX, aY;
458     PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
459     double dX =  aX - myCurX;
460     double dY =  aY - myCurY;
461
462     if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
463         (myEditingAttr.size() == 1) && 
464         myEditingAttr.first()) {
465       // probably we have prehighlighted point
466       AttributePtr aAttr = myEditingAttr.first();
467       std::string aAttrId = aAttr->id();
468       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
469       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
470       // Find corresponded widget to provide dragging
471       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
472         if (aWgt->attributeID() == aAttrId) {
473           PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
474           if (aWgt2d) {
475             aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
476             break;
477           }
478         }
479       }
480     } else {
481       foreach(FeaturePtr aFeature, myEditingFeatures) {
482         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
483           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
484         if (aSketchFeature) { 
485           aSketchFeature->move(dX, dY);
486           ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
487         }
488       }
489       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
490       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
491     }
492     myDragDone = true;
493     myCurX = aX;
494     myCurY = aY;
495   }
496 }
497
498
499 QStringList PartSet_Module::sketchOperationIdList() const
500 {
501   QStringList aIds;
502   aIds << SketchPlugin_Line::ID().c_str();
503   aIds << SketchPlugin_Point::ID().c_str();
504   aIds << SketchPlugin_Arc::ID().c_str();
505   aIds << SketchPlugin_Circle::ID().c_str();
506   aIds << SketchPlugin_ConstraintLength::ID().c_str();
507   aIds << SketchPlugin_ConstraintDistance::ID().c_str();
508   aIds << SketchPlugin_ConstraintRigid::ID().c_str();
509   aIds << SketchPlugin_ConstraintRadius::ID().c_str();
510   aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
511   aIds << SketchPlugin_ConstraintParallel::ID().c_str();
512   return aIds;
513 }
514
515 void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape)
516 {
517   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
518   if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
519     /// If last line finished on vertex the lines creation sequence has to be break
520     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
521     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
522     if (aWidgets.last() == aPanel->activeWidget()) {
523       breakOperationSequence();
524     }
525   }
526 }
527
528 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
529                                             Config_WidgetAPI* theWidgetApi, std::string theParentId,
530                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
531 {
532   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
533   XGUI_Workshop* aWorkshop = aConnector->workshop();
534   if (theType == "sketch-start-label") {
535     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
536     aWgt->setWorkshop(aWorkshop);
537     connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
538       this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
539     theModelWidgets.append(aWgt);
540     return aWgt->getControl();
541
542   } else if (theType == "sketch-2dpoint_selector") {
543     PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
544     aWgt->setWorkshop(aWorkshop);
545     aWgt->setSketch(myCurrentSketch);
546
547     connect(aWgt, SIGNAL(vertexSelected(ObjectPtr, const TopoDS_Shape&)), 
548       this, SLOT(onVertexSelected(ObjectPtr, const TopoDS_Shape&)));
549
550     theModelWidgets.append(aWgt);
551     return aWgt->getControl();
552
553   } if (theType == "point2ddistance") {
554     PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
555     aWgt->setWorkshop(aWorkshop);
556     aWgt->setSketch(myCurrentSketch);
557
558     theModelWidgets.append(aWgt);
559     return aWgt->getControl();
560
561   } if (theType == "sketch_shape_selector") {
562     PartSet_WidgetShapeSelector* aWgt = 
563       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
564     aWgt->setSketcher(myCurrentSketch);
565
566     theModelWidgets.append(aWgt);
567     return aWgt->getControl();
568
569   } if (theType == "sketch_constraint_shape_selector") {
570     PartSet_WidgetConstraintShapeSelector* aWgt = 
571       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
572     aWgt->setSketcher(myCurrentSketch);
573
574     theModelWidgets.append(aWgt);
575     return aWgt->getControl();
576
577   }else
578     return 0;
579 }