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 #include <PartSet_Validators.h>
14 #include <ModuleBase_Operation.h>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Events.h>
17 #include <ModelAPI_Validator.h>
19 #include <ModelAPI_Data.h>
20 #include <GeomDataAPI_Point2D.h>
21 #include <PartSet_Tools.h>
23 #include <XGUI_MainWindow.h>
24 #include <XGUI_Displayer.h>
25 #include <XGUI_Viewer.h>
26 #include <XGUI_Workshop.h>
27 #include <XGUI_OperationMgr.h>
28 #include <XGUI_SelectionMgr.h>
29 #include <XGUI_Selection.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>
38 #include <SketchPlugin_Line.h>
40 #include <Config_PointerMessage.h>
41 #include <Config_ModuleReader.h>
42 #include <Config_WidgetReader.h>
43 #include <Events_Loop.h>
44 #include <Events_Message.h>
45 #include <Events_Error.h>
47 #include <GeomAPI_Shape.h>
48 #include <GeomAPI_AISObject.h>
49 #include <AIS_Shape.hxx>
52 #include <QMouseEvent>
55 #include <GeomAlgoAPI_FaceBuilder.h>
56 #include <GeomDataAPI_Dir.h>
63 /*!Create and return new instance of XGUI_Module*/
64 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
66 return new PartSet_Module(theWshop);
69 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
71 myWorkshop = theWshop;
72 myListener = new PartSet_Listener(this);
74 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
76 connect(anOperationMgr, SIGNAL(operationStarted()),
77 this, SLOT(onOperationStarted()));
79 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
80 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
82 XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
83 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
84 this, SLOT(onContextMenuCommand(const QString&, bool)));
86 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
87 this, SLOT(onMousePressed(QMouseEvent*)));
88 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
89 this, SLOT(onMouseReleased(QMouseEvent*)));
90 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
91 this, SLOT(onMouseMoved(QMouseEvent*)));
92 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
93 this, SLOT(onKeyRelease(QKeyEvent*)));
94 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
95 this, SLOT(onMouseDoubleClick(QMouseEvent*)));
98 PartSet_Module::~PartSet_Module()
102 XGUI_Workshop* PartSet_Module::workshop() const
107 void PartSet_Module::createFeatures()
109 Config_ModuleReader aXMLReader = Config_ModuleReader();
110 aXMLReader.readAll();
111 myFeaturesInFiles = aXMLReader.featuresInFiles();
113 //!! Test registering of validators
114 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
115 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
116 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
117 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
118 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
119 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
120 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
123 void PartSet_Module::featureCreated(QAction* theFeature)
125 connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
128 QStringList PartSet_Module::nestedFeatures(QString)
130 return QStringList();
133 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
135 return myFeaturesInFiles[theFeatureId];
141 void PartSet_Module::onFeatureTriggered()
143 //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
144 // myWorkshop->viewer()->activeView());
146 //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
147 // myWorkshop->viewer()->activeView());
148 QAction* aCmd = dynamic_cast<QAction*>(sender());
149 //Do nothing on uncheck
150 if(aCmd->isCheckable() && !aCmd->isChecked())
152 launchOperation(aCmd->data().toString());
155 void PartSet_Module::launchOperation(const QString& theCmdId)
157 ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
158 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
160 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
161 // Initialise operation with preliminary selection
162 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
163 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
164 aPreviewOp->initSelection(aSelected, aHighlighted);
166 sendOperation(anOperation);
169 void PartSet_Module::onOperationStarted()
171 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
172 myWorkshop->operationMgr()->currentOperation());
174 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
175 connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
176 this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
180 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
184 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
186 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
187 //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
188 // this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
192 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
194 QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
195 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
196 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
198 editFeature(aFeature);
202 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
204 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
205 myWorkshop->operationMgr()->currentOperation());
207 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
208 // Initialise operation with preliminary selection
209 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
210 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
212 aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
216 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
218 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
219 myWorkshop->operationMgr()->currentOperation());
221 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
222 // Initialise operation with preliminary selection
223 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
224 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
226 aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
230 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
232 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
233 myWorkshop->operationMgr()->currentOperation());
235 aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
238 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
240 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
241 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
243 aPreviewOp->keyReleased(theEvent->key());
247 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
249 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
250 myWorkshop->operationMgr()->currentOperation());
253 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
254 // Initialise operation with preliminary selection
255 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
256 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
257 aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
262 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
265 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
266 myWorkshop->actionsMgr()->update();
268 //PartSet_TestOCC::testSelection(myWorkshop);
271 void PartSet_Module::onFitAllView()
273 myWorkshop->viewer()->fitAll();
276 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theFeature)
278 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
280 qDebug("Warning! Restart operation without feature!");
283 ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
284 theFeature ? aFeature->getKind() : "");
285 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
288 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
289 // Initialise operation with preliminary selection
290 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
291 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
292 aPreviewOp->initFeature(aFeature);
293 aPreviewOp->initSelection(aSelected, aHighlighted);
295 anOperation->setEditingFeature(aFeature);
297 sendOperation(anOperation);
298 myWorkshop->actionsMgr()->updateCheckState();
301 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
303 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
304 aViewer->enableMultiselection(theEnabled);
307 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
309 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
311 foreach(ObjectPtr aObject, theFeatures) {
312 activateFeature(aObject, false);
315 //ObjectPtr aResults;
316 //foreach(ObjectPtr aFeature, theFeatures) {
317 /* TODO if (aFeature->results().size() > 0) {
318 const std::list<ResultPtr>& aResList = aFeature->results();
319 std::list<ResultPtr>::const_iterator aIt;
320 for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt)
321 aResults.append(*aIt);
324 aDisplayer->stopSelection(theFeatures, isStop, false);
326 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
327 aViewer->enableSelection(!isStop);
329 aDisplayer->updateViewer();
332 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
334 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
335 aDisplayer->setSelected(theFeatures, false);
336 aDisplayer->updateViewer();
339 void PartSet_Module::onCloseLocalContext()
341 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
342 aDisplayer->closeLocalContexts();
345 void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
347 // bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
349 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
350 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
352 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
353 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
354 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
355 std::list<FeaturePtr>::iterator aSFIt;
356 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
357 std::list<ResultPtr> aResults = (*aSFIt)->results();
358 std::list<ResultPtr>::iterator aIt;
359 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
360 aDisplayer->activateInLocalContext((*aIt), aModes, false);
364 /* FeaturePtr aFeature = aPrevOp->feature();
366 std::list<ResultPtr> aResList = aFeature->results();
367 std::list<ResultPtr>::iterator aIt;
368 for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) {
369 aDisplayer->deactivate((*aIt), false);
373 ModelAPI_EventCreator::get()->sendUpdated(theFeature,
374 Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
377 // ->erase(theFeature->firstResult(), true);
378 /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
379 // TODO visualizePreview(theFeature, isDisplay, false);
381 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
383 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
385 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
386 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
387 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
389 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
391 //TODO for (; anIt != aLast; anIt++)
392 // visualizePreview((*anIt), false, false);
393 //aDisplayer->updateViewer();
397 if (theMode == PartSet_OperationSketchBase::FM_Activation ||
398 theMode == PartSet_OperationSketchBase::FM_Deactivation)
399 activateFeature(theFeature, true);*/
402 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
403 const std::string& theFeatureKind)
405 // create the operation
406 ModuleBase_Operation* anOperation = 0;
407 if (theCmdId == PartSet_OperationSketch::Type()) {
408 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
411 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
413 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
415 aSketch = aPrevOp->sketch();
416 if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
417 anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
418 else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
419 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
420 else if (theCmdId == PartSet_OperationFeatureEdit::Type())
421 anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
425 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
428 // set operation description and list of widgets corresponding to the feature xml definition
429 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
431 std::string aPluginFileName = featureFile(aFeatureKind);
432 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
433 aWdgReader.readAll();
434 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
435 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
437 //QString aXmlRepr = QString::fromStdString(aXmlCfg);
438 //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
439 // myWorkshop->moduleConnector());
440 //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
441 //qDeleteAll(aContent->children());
442 //aFactory.createWidget(aContent);
444 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
445 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
447 //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
449 // connect the operation
450 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
452 connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
453 this, SLOT(onFeatureConstructed(FeaturePtr, int)));
454 connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
455 this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
456 connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
457 this, SLOT(onMultiSelectionEnabled(bool)));
459 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)),
460 this, SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
461 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)),
462 this, SLOT(onSetSelection(const QList<ObjectPtr>&)));
464 connect(aPreviewOp, SIGNAL(closeLocalContext()),
465 this, SLOT(onCloseLocalContext()));
467 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
469 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
470 this, SLOT(onPlaneSelected(double, double, double)));
471 connect(aSketchOp, SIGNAL(fitAllView()),
472 this, SLOT(onFitAllView()));
479 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
481 static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
482 Config_PointerMessage aMessage(aModuleEvent, this);
483 aMessage.setPointer(theOperation);
484 Events_Loop::loop()->send(aMessage);
488 /*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
489 const bool isUpdateViewer)
491 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
495 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
499 ResultPtr aResult = theFeature->firstResult();
500 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
502 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
503 boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
505 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
506 if (aSketchOp && !aSketchOp->hasSketchPlane())
511 aDisplayer->erase(aResult, false);
514 aDisplayer->updateViewer();
517 void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
519 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
520 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
522 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
523 std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
524 aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
528 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
530 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
534 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
538 FeaturePtr aFeature = aPreviewOp->feature();
539 if (!aFeature || aFeature->getKind() != theCmdId)
542 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
543 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
544 std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
546 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
548 for (; anIt != aLast; anIt++) {
549 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
550 boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
553 //visualizePreview((*anIt), true, false);
554 aDisplayer->activateInLocalContext((*anIt), aModes, false);
556 aDisplayer->updateViewer();
559 void PartSet_Module::editFeature(FeaturePtr theFeature)
564 // if (theFeature->getKind() == SKETCH_KIND) {
565 //FeaturePtr aFeature = theFeature;
566 //if (XGUI_Tools::isModelObject(aFeature)) {
567 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
568 // aFeature = aObject->featureRef();
572 onLaunchOperation(theFeature->getKind(), theFeature);
573 updateCurrentPreview(theFeature->getKind());
578 void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute)
580 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
581 myWorkshop->operationMgr()->currentOperation());
585 boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
586 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
588 PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute,
589 aPoint->x(), aPoint->y());
592 /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
594 XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
595 XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
597 ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
599 return !aActMgr->isNested(theCmdId);
601 PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
603 QStringList aConstraintList;
604 aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
605 <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
606 return aConstraintList.contains(theCmdId);
608 QStringList aList = aActMgr->nestedCommands(aOperation->id());
609 return aList.contains(theCmdId);
612 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
613 Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
615 if (theType == "sketch-start-label") {
616 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
617 aWgt->setOperationsMgr(myWorkshop->operationMgr());
618 theModelWidgets.append(aWgt);
619 return aWgt->getControl();