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