Salome HOME
Define Selection validator interface.
[modules/shaper.git] / src / PartSet / PartSet_Module.cpp
1 #include <PartSet_Module.h>
2 #include <PartSet_OperationSketch.h>
3 #include <PartSet_OperationFeatureCreate.h>
4 #include <PartSet_OperationFeatureEditMulti.h>
5 #include <PartSet_OperationFeatureEdit.h>
6 #include <ModuleBase_Operation.h>
7 #include <ModuleBase_OperationDescription.h>
8 #include <ModuleBase_WidgetFactory.h>
9 #include <PartSet_Listener.h>
10 #include <PartSet_TestOCC.h>
11 #include <PartSet_WidgetSketchLabel.h>
12
13 #include <ModuleBase_Operation.h>
14 #include <ModelAPI_Object.h>
15 #include <ModelAPI_Events.h>
16
17 #include <ModelAPI_Data.h>
18 #include <GeomDataAPI_Point2D.h>
19 #include <PartSet_Tools.h>
20
21 #include <XGUI_MainWindow.h>
22 #include <XGUI_Displayer.h>
23 #include <XGUI_Viewer.h>
24 #include <XGUI_Workshop.h>
25 #include <XGUI_OperationMgr.h>
26 #include <XGUI_SelectionMgr.h>
27 #include <XGUI_ViewPort.h>
28 #include <XGUI_ActionsMgr.h>
29 #include <XGUI_ViewerProxy.h>
30 #include <XGUI_ContextMenuMgr.h>
31 #include <XGUI_PropertyPanel.h>
32 #include <XGUI_ModuleConnector.h>
33 #include <XGUI_Tools.h>
34
35 #include <SketchPlugin_Line.h>
36
37 #include <Config_PointerMessage.h>
38 #include <Config_ModuleReader.h>
39 #include <Config_WidgetReader.h>
40 #include <Events_Loop.h>
41 #include <Events_Message.h>
42 #include <Events_Error.h>
43
44 #include <GeomAPI_Shape.h>
45 #include <GeomAPI_AISObject.h>
46
47 #include <QObject>
48 #include <QMouseEvent>
49 #include <QString>
50
51 #ifdef _DEBUG
52 #include <QDebug>
53 #endif
54
55 /*!Create and return new instance of XGUI_Module*/
56 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
57 {
58   return new PartSet_Module(theWshop);
59 }
60
61 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
62 {
63   myWorkshop = theWshop;
64   myListener = new PartSet_Listener(this);
65
66   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
67
68   connect(anOperationMgr, SIGNAL(operationStarted()),
69           this, SLOT(onOperationStarted()));
70
71   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
72           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
73
74   XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
75   connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), 
76           this, SLOT(onContextMenuCommand(const QString&, bool)));
77
78   connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
79           this, SLOT(onMousePressed(QMouseEvent*)));
80   connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
81           this, SLOT(onMouseReleased(QMouseEvent*)));
82   connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
83           this, SLOT(onMouseMoved(QMouseEvent*)));
84   connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
85           this, SLOT(onKeyRelease(QKeyEvent*)));
86   connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
87           this, SLOT(onMouseDoubleClick(QMouseEvent*)));
88 }
89
90 PartSet_Module::~PartSet_Module()
91 {
92 }
93
94 XGUI_Workshop* PartSet_Module::workshop() const
95 {
96   return myWorkshop;
97 }
98
99 void PartSet_Module::createFeatures()
100 {
101   Config_ModuleReader aXMLReader = Config_ModuleReader();
102   aXMLReader.readAll();
103   myFeaturesInFiles = aXMLReader.featuresInFiles();
104 }
105
106 void PartSet_Module::featureCreated(QAction* theFeature)
107 {
108   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
109 }
110
111 QStringList PartSet_Module::nestedFeatures(QString)
112 {
113   return QStringList();
114 }
115
116 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
117 {
118   return myFeaturesInFiles[theFeatureId];
119 }
120
121 /*
122  *
123  */
124 void PartSet_Module::onFeatureTriggered()
125 {
126   //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
127   //                                   myWorkshop->viewer()->activeView());
128
129   //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
130   //                                       myWorkshop->viewer()->activeView());
131   QAction* aCmd = dynamic_cast<QAction*>(sender());
132   //Do nothing on uncheck
133   if(aCmd->isCheckable() && !aCmd->isChecked())
134     return;
135   launchOperation(aCmd->data().toString());
136 }
137   
138 void PartSet_Module::launchOperation(const QString& theCmdId)
139 {
140   ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
141   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
142   if (aPreviewOp) {
143     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
144     // Initialise operation with preliminary selection
145     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
146     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
147     aPreviewOp->initSelection(aSelected, aHighlighted);
148   } 
149   sendOperation(anOperation);
150 }
151
152 void PartSet_Module::onOperationStarted()
153 {
154   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
155                                        myWorkshop->operationMgr()->currentOperation());
156   if (aPreviewOp) {
157     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
158     connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
159       this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
160   }
161 }
162
163 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
164 {
165   if (!theOperation)
166     return;
167   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
168   if (aPreviewOp) {
169     XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
170     //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
171     //           this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
172   }
173 }
174
175 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
176 {
177   QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures();
178   if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
179     editFeature(aFeatures.first());
180   }
181 }
182
183 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
184 {
185   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
186                                        myWorkshop->operationMgr()->currentOperation());
187   if (aPreviewOp) {
188     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
189     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
190     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
191
192     aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
193   }
194 }
195
196 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
197 {
198   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
199                                        myWorkshop->operationMgr()->currentOperation());
200   if (aPreviewOp)
201   {
202     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
203     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
204     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
205
206     aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
207   }
208 }
209
210 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
211 {
212   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
213                                        myWorkshop->operationMgr()->currentOperation());
214   if (aPreviewOp)
215     aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
216 }
217
218 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
219 {
220   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
221   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
222   if (aPreviewOp) {
223     aPreviewOp->keyReleased(theEvent->key());
224   }
225 }
226
227 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
228 {
229   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
230                                        myWorkshop->operationMgr()->currentOperation());
231   if (aPreviewOp)
232   {
233     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
234     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
235     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
236     aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
237                                  aHighlighted);
238   }
239 }
240
241 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
242 {
243   myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
244   myWorkshop->actionsMgr()->update();
245
246   //PartSet_TestOCC::testSelection(myWorkshop);
247 }
248
249 void PartSet_Module::onFitAllView()
250 {
251   myWorkshop->viewer()->fitAll();
252 }
253
254 void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature)
255 {
256   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
257                                                       theFeature ? theFeature->getKind() : "");
258   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
259   if (aPreviewOp)
260   {
261     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
262     // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
263     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
264     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
265     aPreviewOp->initFeature(theFeature);
266     aPreviewOp->initSelection(aSelected, aHighlighted);
267   } else {
268     anOperation->setEditingFeature(theFeature);
269   }
270   sendOperation(anOperation);
271   myWorkshop->actionsMgr()->updateCheckState();
272 }
273
274 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
275 {
276   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
277   aViewer->enableMultiselection(theEnabled);
278 }
279
280 void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop)
281 {
282   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
283   if (!isStop) {
284     QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
285     for (; anIt != aLast; anIt++) {
286       activateFeature((*anIt), false);
287     }
288   }
289   aDisplayer->stopSelection(theFeatures, isStop, false);
290
291   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
292   aViewer->enableSelection(!isStop);
293
294   aDisplayer->updateViewer();
295 }
296
297 void PartSet_Module::onSetSelection(const QFeatureList& theFeatures)
298 {
299   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
300   aDisplayer->setSelected(theFeatures, false);
301   aDisplayer->updateViewer();
302 }
303
304 void PartSet_Module::onCloseLocalContext()
305 {
306   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
307   aDisplayer->closeLocalContexts();
308 }
309
310 void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
311 {
312   bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
313   visualizePreview(theFeature, isDisplay, false);
314   if (!isDisplay) {
315     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
316     FeaturePtr aSketch;
317     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
318     if (aPrevOp) {
319       std::list<FeaturePtr> aList = aPrevOp->subFeatures();
320       XGUI_Displayer* aDisplayer = myWorkshop->displayer();
321       std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
322
323       std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
324                                             aLast = aList.end();
325       for (; anIt != aLast; anIt++)
326         visualizePreview(*anIt, false, false);
327       aDisplayer->updateViewer();
328     }
329   }
330
331   if (theMode == PartSet_OperationSketchBase::FM_Activation ||
332       theMode == PartSet_OperationSketchBase::FM_Deactivation)
333     activateFeature(theFeature, true);
334 }
335
336 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
337                                                       const std::string& theFeatureKind)
338 {
339   // create the operation
340   ModuleBase_Operation* anOperation = 0;
341   if (theCmdId == PartSet_OperationSketch::Type()) {
342     anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
343   }
344   else {
345     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
346     FeaturePtr aSketch;
347     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
348     if (aPrevOp)
349       aSketch = aPrevOp->sketch();
350     if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
351       anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
352     else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
353                 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
354     else if (theCmdId == PartSet_OperationFeatureEdit::Type())
355       anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
356   }
357
358   if (!anOperation) {
359     anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
360   }
361
362   // set operation description and list of widgets corresponding to the feature xml definition
363   std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
364
365   std::string aPluginFileName = featureFile(aFeatureKind);
366   Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
367   aWdgReader.readAll();
368   std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
369   std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
370
371   //QString aXmlRepr = QString::fromStdString(aXmlCfg);
372   //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
373   //                                                             myWorkshop->moduleConnector());
374   //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
375   //qDeleteAll(aContent->children());
376   //aFactory.createWidget(aContent);
377
378   anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
379   anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
380
381   //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
382
383   // connect the operation
384   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
385   if (aPreviewOp) {
386     connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
387             this, SLOT(onFeatureConstructed(FeaturePtr, int)));
388     connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)),
389             this, SLOT(onLaunchOperation(std::string, FeaturePtr)));
390     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
391             this, SLOT(onMultiSelectionEnabled(bool)));
392
393     connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)),
394             this, SLOT(onStopSelection(const QFeatureList&, const bool)));
395     connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)),
396             this, SLOT(onSetSelection(const QFeatureList&)));
397
398      connect(aPreviewOp, SIGNAL(closeLocalContext()),
399              this, SLOT(onCloseLocalContext()));
400
401     PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
402     if (aSketchOp) {
403       connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
404               this, SLOT(onPlaneSelected(double, double, double)));
405       connect(aSketchOp, SIGNAL(fitAllView()),
406               this, SLOT(onFitAllView()));
407     }
408   }
409
410   return anOperation;
411 }
412
413 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
414 {
415   static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
416   Config_PointerMessage aMessage(aModuleEvent, this);
417   aMessage.setPointer(theOperation);
418   Events_Loop::loop()->send(aMessage);
419 }
420
421 void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
422                                       const bool isUpdateViewer)
423 {
424   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
425   if (!anOperation)
426     return;
427
428   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
429   if (!aPreviewOp)
430     return;
431
432   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
433   if (isDisplay) {
434     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
435       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
436     if (aSPFeature)
437     {
438       boost::shared_ptr<GeomAPI_AISObject> anAIS = 
439         aSPFeature->getAISObject(aDisplayer->getAISObject(theFeature));
440       aDisplayer->redisplay(theFeature, anAIS, false);
441     }
442   }
443   else
444     aDisplayer->erase(theFeature, false);
445
446   if (isUpdateViewer)
447     aDisplayer->updateViewer();
448 }
449
450 void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer)
451 {
452   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
453   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
454   if (aPreviewOp) {
455     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
456     aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
457                                        isUpdateViewer);
458   }
459 }
460
461 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
462 {
463   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
464   if (!anOperation)
465     return;
466
467   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
468   if (!aPreviewOp)
469     return;
470
471   FeaturePtr aFeature = aPreviewOp->feature();
472   if (!aFeature || aFeature->getKind() != theCmdId)
473     return;
474
475   std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
476   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
477   std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
478
479   std::list<FeaturePtr>::const_iterator anIt = aList.begin(), 
480                                         aLast = aList.end();
481   for (; anIt != aLast; anIt++) {
482     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
483       boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
484     if (!aSPFeature)
485       continue;
486     visualizePreview(*anIt, true, false);
487     aDisplayer->activateInLocalContext(*anIt, aModes, false);
488   }
489   aDisplayer->updateViewer();
490 }
491
492 void PartSet_Module::editFeature(FeaturePtr theFeature)
493 {
494   if (!theFeature)
495     return;
496
497 //  if (theFeature->getKind() == SKETCH_KIND) {
498     FeaturePtr aFeature = theFeature;
499     if (XGUI_Tools::isModelObject(aFeature)) {
500       ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
501       aFeature = aObject->featureRef();
502     }
503
504     if (aFeature) {
505       onLaunchOperation(aFeature->getKind(), aFeature);
506       updateCurrentPreview(aFeature->getKind());
507     }
508 //  }
509 }
510
511 void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
512 {
513   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
514                                        myWorkshop->operationMgr()->currentOperation());
515   if (!aPreviewOp)
516     return;
517
518   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
519         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
520
521   PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
522                                 aPoint->x(), aPoint->y());
523 }
524
525 /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
526 {
527   XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
528   XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
529
530   ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
531   if (!aOperation)
532     return !aActMgr->isNested(theCmdId);
533
534   PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
535   if (aSketchEdtOp) {
536     QStringList aConstraintList;
537     aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
538       <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
539     return aConstraintList.contains(theCmdId);
540   }
541   QStringList aList = aActMgr->nestedCommands(aOperation->id());
542   return aList.contains(theCmdId);
543 }*/
544
545 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, 
546                          Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
547 {
548   if (theType == "sketch-start-label") {
549     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
550     aWgt->setOperationsMgr(myWorkshop->operationMgr());
551     theModelWidgets.append(aWgt);
552     return aWgt->getControl();
553   } else
554     return 0;
555 }