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