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>
64 /*!Create and return new instance of XGUI_Module*/
65 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
67 return new PartSet_Module(theWshop);
70 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
72 myWorkshop = theWshop;
73 myListener = new PartSet_Listener(this);
75 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
77 connect(anOperationMgr, SIGNAL(operationStarted()),
78 this, SLOT(onOperationStarted()));
80 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
81 this, SLOT(onOperationStopped(ModuleBase_Operation*)));
83 XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
84 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
85 this, SLOT(onContextMenuCommand(const QString&, bool)));
87 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)),
88 this, SLOT(onMousePressed(QMouseEvent*)));
89 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
90 this, SLOT(onMouseReleased(QMouseEvent*)));
91 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
92 this, SLOT(onMouseMoved(QMouseEvent*)));
93 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
94 this, SLOT(onKeyRelease(QKeyEvent*)));
95 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
96 this, SLOT(onMouseDoubleClick(QMouseEvent*)));
99 PartSet_Module::~PartSet_Module()
103 XGUI_Workshop* PartSet_Module::workshop() const
108 void PartSet_Module::createFeatures()
110 //Registering of validators
111 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
112 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
113 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
114 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
115 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
116 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
117 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
119 Config_ModuleReader aXMLReader = Config_ModuleReader();
120 aXMLReader.readAll();
121 myFeaturesInFiles = aXMLReader.featuresInFiles();
124 void PartSet_Module::featureCreated(QAction* theFeature)
126 connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
129 QStringList PartSet_Module::nestedFeatures(QString)
131 return QStringList();
134 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
136 return myFeaturesInFiles[theFeatureId];
142 void PartSet_Module::onFeatureTriggered()
144 //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
145 // myWorkshop->viewer()->activeView());
147 //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
148 // myWorkshop->viewer()->activeView());
149 QAction* aCmd = dynamic_cast<QAction*>(sender());
150 //Do nothing on uncheck
151 if(aCmd->isCheckable() && !aCmd->isChecked())
153 launchOperation(aCmd->data().toString());
156 void PartSet_Module::launchOperation(const QString& theCmdId)
158 ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
159 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
161 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
162 // Initialise operation with preliminary selection
163 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
164 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
165 aPreviewOp->initSelection(aSelected, aHighlighted);
167 sendOperation(anOperation);
170 void PartSet_Module::onOperationStarted()
172 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
173 myWorkshop->operationMgr()->currentOperation());
175 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
176 connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
177 this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
181 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
185 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
187 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
188 //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
189 // this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
191 // Activate results of current feature for selection
192 FeaturePtr aFeature = theOperation->feature();
193 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
194 std::list<ResultPtr> aResults = aFeature->results();
195 std::list<ResultPtr>::const_iterator aIt;
196 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
197 aDisplayer->activate(*aIt);
202 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
204 QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
205 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
206 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
208 editFeature(aFeature);
212 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
214 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
215 myWorkshop->operationMgr()->currentOperation());
216 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
217 if (aPreviewOp && (!aView.IsNull())) {
218 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
219 // Initialise operation with preliminary selection
220 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
221 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
223 aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
227 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
229 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
230 myWorkshop->operationMgr()->currentOperation());
231 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
232 if (aPreviewOp && (!aView.IsNull())) {
233 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
234 // Initialise operation with preliminary selection
235 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
236 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
238 aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
242 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
244 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
245 myWorkshop->operationMgr()->currentOperation());
246 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
247 if (aPreviewOp && (!aView.IsNull()))
248 aPreviewOp->mouseMoved(theEvent, aView);
251 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
253 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
254 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
256 aPreviewOp->keyReleased(theEvent->key());
260 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
262 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
263 myWorkshop->operationMgr()->currentOperation());
264 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
265 if (aPreviewOp && (!aView.IsNull())) {
266 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
267 // Initialise operation with preliminary selection
268 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
269 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
270 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
274 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
277 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
278 myWorkshop->actionsMgr()->update();
280 //PartSet_TestOCC::testSelection(myWorkshop);
283 void PartSet_Module::onFitAllView()
285 myWorkshop->viewer()->fitAll();
288 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
290 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
292 qDebug("Warning! Restart operation without feature!");
295 ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
296 aFeature ? aFeature->getKind() : "");
297 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
299 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
300 // Initialise operation with preliminary selection
301 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
302 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
303 aPreviewOp->initFeature(aFeature);
304 aPreviewOp->initSelection(aSelected, aHighlighted);
306 anOperation->setEditingFeature(aFeature);
307 //Deactivate result of current feature in order to avoid its selection
308 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
309 std::list<ResultPtr> aResults = aFeature->results();
310 std::list<ResultPtr>::const_iterator aIt;
311 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
312 aDisplayer->deactivate(*aIt);
315 sendOperation(anOperation);
316 myWorkshop->actionsMgr()->updateCheckState();
319 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
321 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
322 aViewer->enableMultiselection(theEnabled);
325 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
327 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
329 foreach(ObjectPtr aObject, theFeatures) {
330 activateFeature(aObject, false);
333 aDisplayer->stopSelection(theFeatures, isStop, false);
335 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
336 aViewer->enableSelection(!isStop);
338 aDisplayer->updateViewer();
341 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
343 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
344 aDisplayer->setSelected(theFeatures, false);
345 aDisplayer->updateViewer();
348 void PartSet_Module::onCloseLocalContext()
350 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
351 aDisplayer->closeLocalContexts();
354 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
356 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
357 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
358 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
360 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
361 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
362 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
363 std::list<FeaturePtr>::iterator aSFIt;
364 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
365 std::list<ResultPtr> aResults = (*aSFIt)->results();
366 std::list<ResultPtr>::iterator aIt;
367 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
369 aDisplayer->activateInLocalContext((*aIt), aModes, false);
371 aDisplayer->erase((*aIt), false);
374 aDisplayer->erase((*aSFIt), false);
378 ModelAPI_EventCreator::get()->sendUpdated(theFeature,
379 Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
380 /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
381 // TODO visualizePreview(theFeature, isDisplay, false);
383 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
385 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
387 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
388 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
389 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
391 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
393 //TODO for (; anIt != aLast; anIt++)
394 // visualizePreview((*anIt), false, false);
395 //aDisplayer->updateViewer();
399 if (theMode == PartSet_OperationSketchBase::FM_Activation ||
400 theMode == PartSet_OperationSketchBase::FM_Deactivation)
401 activateFeature(theFeature, true);*/
404 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
405 const std::string& theFeatureKind)
407 // create the operation
408 ModuleBase_Operation* anOperation = 0;
409 if (theCmdId == PartSet_OperationSketch::Type()) {
410 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
413 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
415 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
417 aSketch = aPrevOp->sketch();
418 if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
419 anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
420 else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
421 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
422 else if (theCmdId == PartSet_OperationFeatureEdit::Type())
423 anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
427 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
430 // set operation description and list of widgets corresponding to the feature xml definition
431 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
433 std::string aPluginFileName = featureFile(aFeatureKind);
434 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
435 aWdgReader.readAll();
436 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
437 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
439 //QString aXmlRepr = QString::fromStdString(aXmlCfg);
440 //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
441 // myWorkshop->moduleConnector());
442 //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
443 //qDeleteAll(aContent->children());
444 //aFactory.createWidget(aContent);
446 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
447 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
449 //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
451 // connect the operation
452 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
454 connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)),
455 this, SLOT(onFeatureConstructed(ObjectPtr, int)));
456 connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
457 this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
458 connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
459 this, SLOT(onMultiSelectionEnabled(bool)));
461 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)),
462 this, SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
463 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)),
464 this, SLOT(onSetSelection(const QList<ObjectPtr>&)));
466 connect(aPreviewOp, SIGNAL(closeLocalContext()),
467 this, SLOT(onCloseLocalContext()));
469 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
471 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
472 this, SLOT(onPlaneSelected(double, double, double)));
473 connect(aSketchOp, SIGNAL(fitAllView()),
474 this, SLOT(onFitAllView()));
481 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
483 static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
484 Config_PointerMessage aMessage(aModuleEvent, this);
485 aMessage.setPointer(theOperation);
486 Events_Loop::loop()->send(aMessage);
490 /*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
491 const bool isUpdateViewer)
493 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
497 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
501 ResultPtr aResult = theFeature->firstResult();
502 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
504 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
505 boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
507 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
508 if (aSketchOp && !aSketchOp->hasSketchPlane())
513 aDisplayer->erase(aResult, false);
516 aDisplayer->updateViewer();
519 void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
521 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
522 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
524 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
525 std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
526 aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
530 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
532 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
536 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
540 FeaturePtr aFeature = aPreviewOp->feature();
541 if (!aFeature || aFeature->getKind() != theCmdId)
544 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
545 // Hide result of sketch
546 std::list<ResultPtr> aResults = aFeature->results();
547 std::list<ResultPtr>::const_iterator aIt;
548 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
549 aDisplayer->erase(*aIt, false);
551 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
552 std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
554 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
556 for (; anIt != aLast; anIt++) {
557 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
558 boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
561 std::list<ResultPtr> aResults = aSPFeature->results();
562 std::list<ResultPtr>::const_iterator aRIt;
563 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
564 aDisplayer->display((*aRIt), false);
565 aDisplayer->activateInLocalContext((*aRIt), aModes, false);
567 aDisplayer->display(aSPFeature, false);
568 aDisplayer->activateInLocalContext(aSPFeature, aModes, false);
570 aDisplayer->updateViewer();
573 void PartSet_Module::editFeature(FeaturePtr theFeature)
578 // if (theFeature->getKind() == SKETCH_KIND) {
579 //FeaturePtr aFeature = theFeature;
580 //if (XGUI_Tools::isModelObject(aFeature)) {
581 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
582 // aFeature = aObject->featureRef();
586 onLaunchOperation(theFeature->getKind(), theFeature);
587 updateCurrentPreview(theFeature->getKind());
592 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
594 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
596 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
597 myWorkshop->operationMgr()->currentOperation());
601 boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
602 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(theAttribute));
604 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute,
605 aPoint->x(), aPoint->y());
608 /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
610 XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
611 XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
613 ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
615 return !aActMgr->isNested(theCmdId);
617 PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
619 QStringList aConstraintList;
620 aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
621 <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
622 return aConstraintList.contains(theCmdId);
624 QStringList aList = aActMgr->nestedCommands(aOperation->id());
625 return aList.contains(theCmdId);
628 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
629 Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
631 if (theType == "sketch-start-label") {
632 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
633 aWgt->setOperationsMgr(myWorkshop->operationMgr());
634 theModelWidgets.append(aWgt);
635 return aWgt->getControl();