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 <PartSet_Listener.h>
7 #include <PartSet_TestOCC.h>
8 #include <PartSet_WidgetSketchLabel.h>
9 #include <PartSet_Validators.h>
10 #include <PartSet_Tools.h>
12 #include <ModuleBase_Operation.h>
13 #include <ModuleBase_OperationDescription.h>
14 #include <ModuleBase_WidgetFactory.h>
15 #include <ModuleBase_Operation.h>
17 #include <ModelAPI_Object.h>
18 #include <ModelAPI_Events.h>
19 #include <ModelAPI_Validator.h>
20 #include <ModelAPI_Data.h>
22 #include <GeomDataAPI_Point2D.h>
24 #include <XGUI_MainWindow.h>
25 #include <XGUI_Displayer.h>
26 #include <XGUI_Viewer.h>
27 #include <XGUI_Workshop.h>
28 #include <XGUI_OperationMgr.h>
29 #include <XGUI_SelectionMgr.h>
30 #include <XGUI_Selection.h>
31 #include <XGUI_ViewPort.h>
32 #include <XGUI_ActionsMgr.h>
33 #include <XGUI_ViewerProxy.h>
34 #include <XGUI_ContextMenuMgr.h>
35 #include <XGUI_PropertyPanel.h>
36 #include <XGUI_ModuleConnector.h>
37 #include <XGUI_Tools.h>
39 #include <SketchPlugin_Line.h>
41 #include <Config_PointerMessage.h>
42 #include <Config_ModuleReader.h>
43 #include <Config_WidgetReader.h>
44 #include <Events_Loop.h>
45 #include <Events_Message.h>
46 #include <Events_Error.h>
48 #include <GeomAPI_Shape.h>
49 #include <GeomAPI_AISObject.h>
50 #include <AIS_Shape.hxx>
53 #include <QMouseEvent>
56 #include <GeomAlgoAPI_FaceBuilder.h>
57 #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()), this, SLOT(onOperationStarted()));
78 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
79 SLOT(onOperationStopped(ModuleBase_Operation*)));
81 XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
82 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
83 SLOT(onContextMenuCommand(const QString&, bool)));
85 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
86 SLOT(onMousePressed(QMouseEvent*)));
87 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
88 SLOT(onMouseReleased(QMouseEvent*)));
89 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
90 SLOT(onMouseMoved(QMouseEvent*)));
91 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
92 SLOT(onKeyRelease(QKeyEvent*)));
93 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
94 SLOT(onMouseDoubleClick(QMouseEvent*)));
97 PartSet_Module::~PartSet_Module()
101 XGUI_Workshop* PartSet_Module::workshop() const
106 void PartSet_Module::createFeatures()
108 //Registering of validators
109 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
110 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
111 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
112 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
113 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
114 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
115 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
117 Config_ModuleReader aXMLReader = Config_ModuleReader();
118 aXMLReader.readAll();
119 myFeaturesInFiles = aXMLReader.featuresInFiles();
122 void PartSet_Module::featureCreated(QAction* theFeature)
124 connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
127 QStringList PartSet_Module::nestedFeatures(QString)
129 return QStringList();
132 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
134 return myFeaturesInFiles[theFeatureId];
140 void PartSet_Module::onFeatureTriggered()
142 //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
143 // myWorkshop->viewer()->activeView());
145 //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
146 // myWorkshop->viewer()->activeView());
147 QAction* aCmd = dynamic_cast<QAction*>(sender());
148 //Do nothing on uncheck
149 if (aCmd->isCheckable() && !aCmd->isChecked())
151 launchOperation(aCmd->data().toString());
154 void PartSet_Module::launchOperation(const QString& theCmdId)
156 ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
157 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
159 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
160 // Initialise operation with preliminary selection
161 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
162 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
163 aPreviewOp->initSelection(aSelected, aHighlighted);
165 sendOperation(anOperation);
168 void PartSet_Module::onOperationStarted()
170 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
171 ->operationMgr()->currentOperation());
173 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
174 connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
175 SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
179 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
183 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
185 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
186 //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
187 // this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
189 // Activate results of current feature for selection
190 FeaturePtr aFeature = theOperation->feature();
191 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
192 std::list<ResultPtr> aResults = aFeature->results();
193 std::list<ResultPtr>::const_iterator aIt;
194 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
195 aDisplayer->activate(*aIt);
200 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
202 QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
203 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
204 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
206 editFeature(aFeature);
210 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
212 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
213 ->operationMgr()->currentOperation());
214 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
215 if (aPreviewOp && (!aView.IsNull())) {
216 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
217 // Initialise operation with preliminary selection
218 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
219 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
221 aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
225 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
227 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
228 ->operationMgr()->currentOperation());
229 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
230 if (aPreviewOp && (!aView.IsNull())) {
231 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
232 // Initialise operation with preliminary selection
233 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
234 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
236 aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
240 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
242 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
243 ->operationMgr()->currentOperation());
244 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
245 if (aPreviewOp && (!aView.IsNull()))
246 aPreviewOp->mouseMoved(theEvent, aView);
249 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
251 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
252 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
254 aPreviewOp->keyReleased(theEvent->key());
258 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
260 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
261 ->operationMgr()->currentOperation());
262 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
263 if (aPreviewOp && (!aView.IsNull())) {
264 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
265 // Initialise operation with preliminary selection
266 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
267 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
268 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
272 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
275 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
276 myWorkshop->actionsMgr()->update();
278 //PartSet_TestOCC::testSelection(myWorkshop);
281 void PartSet_Module::onFitAllView()
283 myWorkshop->viewer()->fitAll();
286 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
288 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
290 qDebug("Warning! Restart operation without feature!");
293 ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
294 aFeature ? aFeature->getKind() : "");
295 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
297 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
298 // Initialise operation with preliminary selection
299 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
300 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
301 aPreviewOp->initFeature(aFeature);
302 aPreviewOp->initSelection(aSelected, aHighlighted);
304 anOperation->setEditingFeature(aFeature);
305 //Deactivate result of current feature in order to avoid its selection
306 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
307 std::list<ResultPtr> aResults = aFeature->results();
308 std::list<ResultPtr>::const_iterator aIt;
309 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
310 aDisplayer->deactivate(*aIt);
313 sendOperation(anOperation);
314 myWorkshop->actionsMgr()->updateCheckState();
317 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
319 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
320 aViewer->enableMultiselection(theEnabled);
323 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
325 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
327 foreach(ObjectPtr aObject, theFeatures)
329 activateFeature(aObject, false);
332 aDisplayer->stopSelection(theFeatures, isStop, false);
334 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
335 aViewer->enableSelection(!isStop);
337 aDisplayer->updateViewer();
340 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
342 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
343 aDisplayer->setSelected(theFeatures, false);
344 aDisplayer->updateViewer();
347 void PartSet_Module::onCloseLocalContext()
349 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
350 aDisplayer->closeLocalContexts();
353 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
355 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
356 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
357 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
359 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
360 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
361 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
362 std::list<FeaturePtr>::iterator aSFIt;
363 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
364 std::list<ResultPtr> aResults = (*aSFIt)->results();
365 std::list<ResultPtr>::iterator aIt;
366 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
368 aDisplayer->activateInLocalContext((*aIt), aModes, false);
370 aDisplayer->erase((*aIt), false);
373 aDisplayer->erase((*aSFIt), false);
377 ModelAPI_EventCreator::get()->sendUpdated(
378 theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
379 /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
380 // TODO visualizePreview(theFeature, isDisplay, false);
382 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
384 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
386 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
387 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
388 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
390 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
392 //TODO for (; anIt != aLast; anIt++)
393 // visualizePreview((*anIt), false, false);
394 //aDisplayer->updateViewer();
398 if (theMode == PartSet_OperationSketchBase::FM_Activation ||
399 theMode == PartSet_OperationSketchBase::FM_Deactivation)
400 activateFeature(theFeature, true);*/
403 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
404 const std::string& theFeatureKind)
406 // create the operation
407 ModuleBase_Operation* anOperation = 0;
408 if (theCmdId == PartSet_OperationSketch::Type()) {
409 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(ObjectPtr, int)), this,
453 SLOT(onFeatureConstructed(ObjectPtr, int)));
454 connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), this,
455 SLOT(onLaunchOperation(std::string, ObjectPtr)));
456 connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
457 SLOT(onMultiSelectionEnabled(bool)));
459 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
460 SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
461 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
462 SLOT(onSetSelection(const QList<ObjectPtr>&)));
464 connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext()));
466 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
468 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
469 SLOT(onPlaneSelected(double, double, double)));
470 connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
477 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
479 static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
480 Config_PointerMessage aMessage(aModuleEvent, this);
481 aMessage.setPointer(theOperation);
482 Events_Loop::loop()->send(aMessage);
485 /*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
486 const bool isUpdateViewer)
488 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
492 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
496 ResultPtr aResult = theFeature->firstResult();
497 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
499 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
500 boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
502 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
503 if (aSketchOp && !aSketchOp->hasSketchPlane())
508 aDisplayer->erase(aResult, false);
511 aDisplayer->updateViewer();
514 void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
516 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
517 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
519 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
520 std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
521 aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
525 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
527 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
531 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
535 FeaturePtr aFeature = aPreviewOp->feature();
536 if (!aFeature || aFeature->getKind() != theCmdId)
539 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
540 // Hide result of sketch
541 std::list<ResultPtr> aResults = aFeature->results();
542 std::list<ResultPtr>::const_iterator aIt;
543 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
544 aDisplayer->erase(*aIt, false);
546 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
547 std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
549 std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
550 for (; anIt != aLast; anIt++) {
551 boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
552 SketchPlugin_Feature>(*anIt);
555 std::list<ResultPtr> aResults = aSPFeature->results();
556 std::list<ResultPtr>::const_iterator aRIt;
557 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
558 aDisplayer->display((*aRIt), false);
559 aDisplayer->activateInLocalContext((*aRIt), aModes, false);
561 aDisplayer->display(aSPFeature, false);
562 aDisplayer->activateInLocalContext(aSPFeature, aModes, false);
564 aDisplayer->updateViewer();
567 void PartSet_Module::editFeature(FeaturePtr theFeature)
572 // if (theFeature->getKind() == SKETCH_KIND) {
573 //FeaturePtr aFeature = theFeature;
574 //if (XGUI_Tools::isModelObject(aFeature)) {
575 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
576 // aFeature = aObject->featureRef();
580 onLaunchOperation(theFeature->getKind(), theFeature);
581 updateCurrentPreview(theFeature->getKind());
586 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
588 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
590 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
591 ->operationMgr()->currentOperation());
595 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
596 aFeature->data()->attribute(theAttribute));
598 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
602 /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
604 XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
605 XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
607 ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
609 return !aActMgr->isNested(theCmdId);
611 PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
613 QStringList aConstraintList;
614 aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
615 <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
616 return aConstraintList.contains(theCmdId);
618 QStringList aList = aActMgr->nestedCommands(aOperation->id());
619 return aList.contains(theCmdId);
622 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
623 Config_WidgetAPI* theWidgetApi,
624 QList<ModuleBase_ModelWidget*>& theModelWidgets)
626 if (theType == "sketch-start-label") {
627 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
628 aWgt->setOperationsMgr(myWorkshop->operationMgr());
629 theModelWidgets.append(aWgt);
630 return aWgt->getControl();