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>
52 #include <StdSelect_FaceFilter.hxx>
53 #include <StdSelect_TypeOfFace.hxx>
56 #include <QMouseEvent>
59 #include <GeomAlgoAPI_FaceBuilder.h>
60 #include <GeomDataAPI_Dir.h>
66 /*!Create and return new instance of XGUI_Module*/
67 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
69 return new PartSet_Module(theWshop);
72 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
74 myWorkshop = theWshop;
75 myListener = new PartSet_Listener(this);
77 XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
79 connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
81 connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
82 SLOT(onOperationStopped(ModuleBase_Operation*)));
84 XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
85 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
86 SLOT(onContextMenuCommand(const QString&, bool)));
88 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
89 SLOT(onMousePressed(QMouseEvent*)));
90 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
91 SLOT(onMouseReleased(QMouseEvent*)));
92 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
93 SLOT(onMouseMoved(QMouseEvent*)));
94 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
95 SLOT(onKeyRelease(QKeyEvent*)));
96 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
97 SLOT(onMouseDoubleClick(QMouseEvent*)));
100 PartSet_Module::~PartSet_Module()
104 XGUI_Workshop* PartSet_Module::workshop() const
109 void PartSet_Module::createFeatures()
111 //Registering of validators
112 PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
113 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
114 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
115 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
116 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
117 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
118 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
120 Config_ModuleReader aXMLReader = Config_ModuleReader();
121 aXMLReader.readAll();
122 myFeaturesInFiles = aXMLReader.featuresInFiles();
125 void PartSet_Module::featureCreated(QAction* theFeature)
127 connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
130 QStringList PartSet_Module::nestedFeatures(QString)
132 return QStringList();
135 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
137 return myFeaturesInFiles[theFeatureId];
143 void PartSet_Module::onFeatureTriggered()
145 //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
146 // myWorkshop->viewer()->activeView());
148 //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
149 // myWorkshop->viewer()->activeView());
150 QAction* aCmd = dynamic_cast<QAction*>(sender());
151 //Do nothing on uncheck
152 if (aCmd->isCheckable() && !aCmd->isChecked())
154 launchOperation(aCmd->data().toString());
157 void PartSet_Module::launchOperation(const QString& theCmdId)
159 ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
160 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
162 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
163 // Initialise operation with preliminary selection
164 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
165 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
166 aPreviewOp->initSelection(aSelected, aHighlighted);
168 sendOperation(anOperation);
171 void PartSet_Module::onOperationStarted()
173 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
174 ->operationMgr()->currentOperation());
176 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
177 connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
178 SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
182 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
186 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
188 XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
189 //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
190 // this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
192 // Activate results of current feature for selection
193 FeaturePtr aFeature = theOperation->feature();
194 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
195 std::list<ResultPtr> aResults = aFeature->results();
196 std::list<ResultPtr>::const_iterator aIt;
197 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
198 aDisplayer->activate(*aIt);
203 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
205 QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
206 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
207 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
209 editFeature(aFeature);
213 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
215 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
216 ->operationMgr()->currentOperation());
217 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
218 if (aPreviewOp && (!aView.IsNull())) {
219 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
220 // Initialise operation with preliminary selection
221 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
222 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
224 aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
228 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
230 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
231 ->operationMgr()->currentOperation());
232 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
233 if (aPreviewOp && (!aView.IsNull())) {
234 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
235 // Initialise operation with preliminary selection
236 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
237 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
239 aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
243 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
245 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
246 ->operationMgr()->currentOperation());
247 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
248 if (aPreviewOp && (!aView.IsNull()))
249 aPreviewOp->mouseMoved(theEvent, aView);
252 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
254 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
255 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
257 aPreviewOp->keyReleased(theEvent->key());
261 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
263 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
264 ->operationMgr()->currentOperation());
265 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
266 if (aPreviewOp && (!aView.IsNull())) {
267 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
268 // Initialise operation with preliminary selection
269 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
270 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
271 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
275 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
278 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
279 myWorkshop->actionsMgr()->update();
281 //PartSet_TestOCC::testSelection(myWorkshop);
284 void PartSet_Module::onFitAllView()
286 myWorkshop->viewer()->fitAll();
289 void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
291 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
293 qDebug("Warning! Restart operation without feature!");
296 ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
297 aFeature ? aFeature->getKind() : "");
298 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
300 XGUI_Selection* aSelection = myWorkshop->selector()->selection();
301 // Initialise operation with preliminary selection
302 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
303 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
304 aPreviewOp->initFeature(aFeature);
305 aPreviewOp->initSelection(aSelected, aHighlighted);
307 anOperation->setEditingFeature(aFeature);
308 //Deactivate result of current feature in order to avoid its selection
309 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
310 std::list<ResultPtr> aResults = aFeature->results();
311 std::list<ResultPtr>::const_iterator aIt;
312 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
313 aDisplayer->deactivate(*aIt);
316 sendOperation(anOperation);
317 myWorkshop->actionsMgr()->updateCheckState();
320 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
322 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
323 aViewer->enableMultiselection(theEnabled);
326 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
328 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
330 foreach(ObjectPtr aObject, theFeatures)
332 activateFeature(aObject, false);
335 aDisplayer->stopSelection(theFeatures, isStop, false);
337 XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
338 aViewer->enableSelection(!isStop);
340 aDisplayer->updateViewer();
343 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
345 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
346 aDisplayer->setSelected(theFeatures, false);
347 aDisplayer->updateViewer();
350 void PartSet_Module::onCloseLocalContext()
352 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
353 aDisplayer->deactivateObjectsOutOfContext();
354 aDisplayer->closeLocalContexts();
357 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
359 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
360 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
361 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
363 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
364 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
365 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
366 std::list<FeaturePtr>::iterator aSFIt;
367 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
368 std::list<ResultPtr> aResults = (*aSFIt)->results();
369 std::list<ResultPtr>::iterator aIt;
370 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
372 aDisplayer->activateInLocalContext((*aIt), aModes, false);
374 aDisplayer->erase((*aIt), false);
377 aDisplayer->erase((*aSFIt), false);
381 ModelAPI_EventCreator::get()->sendUpdated(
382 theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
383 /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
384 // TODO visualizePreview(theFeature, isDisplay, false);
386 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
388 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
390 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
391 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
392 std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
394 std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
396 //TODO for (; anIt != aLast; anIt++)
397 // visualizePreview((*anIt), false, false);
398 //aDisplayer->updateViewer();
402 if (theMode == PartSet_OperationSketchBase::FM_Activation ||
403 theMode == PartSet_OperationSketchBase::FM_Deactivation)
404 activateFeature(theFeature, true);*/
407 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
408 const std::string& theFeatureKind)
410 // create the operation
411 ModuleBase_Operation* anOperation = 0;
412 if (theCmdId == PartSet_OperationSketch::Type()) {
413 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
415 ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
417 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
419 aSketch = aPrevOp->sketch();
420 if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
421 anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
422 else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
423 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
424 else if (theCmdId == PartSet_OperationFeatureEdit::Type())
425 anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
429 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
432 // set operation description and list of widgets corresponding to the feature xml definition
433 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
435 std::string aPluginFileName = featureFile(aFeatureKind);
436 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
437 aWdgReader.readAll();
438 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
439 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
441 //QString aXmlRepr = QString::fromStdString(aXmlCfg);
442 //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
443 // myWorkshop->moduleConnector());
444 //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
445 //qDeleteAll(aContent->children());
446 //aFactory.createWidget(aContent);
448 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
449 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
451 //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
453 // connect the operation
454 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
456 connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
457 SLOT(onFeatureConstructed(ObjectPtr, int)));
458 connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), this,
459 SLOT(onLaunchOperation(std::string, ObjectPtr)));
460 connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
461 SLOT(onMultiSelectionEnabled(bool)));
463 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
464 SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
465 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
466 SLOT(onSetSelection(const QList<ObjectPtr>&)));
468 connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext()));
470 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
472 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
473 SLOT(onPlaneSelected(double, double, double)));
474 connect(aSketchOp, SIGNAL(fitAllView()), 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);
489 /*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
490 const bool isUpdateViewer)
492 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
496 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
500 ResultPtr aResult = theFeature->firstResult();
501 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
503 boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
504 boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
506 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
507 if (aSketchOp && !aSketchOp->hasSketchPlane())
512 aDisplayer->erase(aResult, false);
515 aDisplayer->updateViewer();
518 void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
520 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
521 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
523 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
524 std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
525 aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
527 // If this is a Sketcher then activate objects (planar faces) outside of context
528 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
530 Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane);
531 aDisplayer->activateObjectsOutOfContext(aModes, aFilter);
536 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
538 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
542 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
546 FeaturePtr aFeature = aPreviewOp->feature();
547 if (!aFeature || aFeature->getKind() != theCmdId)
550 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
551 // Hide result of sketch
552 std::list<ResultPtr> aResults = aFeature->results();
553 std::list<ResultPtr>::const_iterator aIt;
554 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
555 aDisplayer->erase(*aIt, false);
557 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
558 std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
560 std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
561 for (; anIt != aLast; anIt++) {
562 boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
563 SketchPlugin_Feature>(*anIt);
566 std::list<ResultPtr> aResults = aSPFeature->results();
567 std::list<ResultPtr>::const_iterator aRIt;
568 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
569 aDisplayer->display((*aRIt), false);
570 aDisplayer->activateInLocalContext((*aRIt), aModes, false);
572 aDisplayer->display(aSPFeature, false);
573 aDisplayer->activateInLocalContext(aSPFeature, aModes, false);
575 aDisplayer->updateViewer();
578 void PartSet_Module::editFeature(FeaturePtr theFeature)
583 // if (theFeature->getKind() == SKETCH_KIND) {
584 //FeaturePtr aFeature = theFeature;
585 //if (XGUI_Tools::isModelObject(aFeature)) {
586 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
587 // aFeature = aObject->featureRef();
591 onLaunchOperation(theFeature->getKind(), theFeature);
592 updateCurrentPreview(theFeature->getKind());
597 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
599 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
601 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
602 ->operationMgr()->currentOperation());
606 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
607 aFeature->data()->attribute(theAttribute));
609 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
613 /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
615 XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
616 XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
618 ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
620 return !aActMgr->isNested(theCmdId);
622 PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
624 QStringList aConstraintList;
625 aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
626 <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
627 return aConstraintList.contains(theCmdId);
629 QStringList aList = aActMgr->nestedCommands(aOperation->id());
630 return aList.contains(theCmdId);
633 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
634 Config_WidgetAPI* theWidgetApi,
635 QList<ModuleBase_ModelWidget*>& theModelWidgets)
637 if (theType == "sketch-start-label") {
638 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
639 aWgt->setOperationsMgr(myWorkshop->operationMgr());
640 theModelWidgets.append(aWgt);
641 return aWgt->getControl();