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>
21 #include <ModelAPI_Session.h>
23 #include <GeomDataAPI_Point2D.h>
24 #include <GeomDataAPI_Point.h>
25 #include <GeomDataAPI_Dir.h>
27 #include <XGUI_MainWindow.h>
28 #include <XGUI_Displayer.h>
29 #include <XGUI_Viewer.h>
30 #include <XGUI_Workshop.h>
31 #include <XGUI_OperationMgr.h>
32 #include <XGUI_ViewPort.h>
33 #include <XGUI_ActionsMgr.h>
34 #include <XGUI_ViewerProxy.h>
35 #include <XGUI_ContextMenuMgr.h>
36 #include <XGUI_PropertyPanel.h>
37 #include <XGUI_ModuleConnector.h>
38 #include <XGUI_Tools.h>
40 #include <SketchPlugin_Line.h>
41 #include <SketchPlugin_Sketch.h>
43 #include <Config_PointerMessage.h>
44 #include <Config_ModuleReader.h>
45 #include <Config_WidgetReader.h>
46 #include <Events_Loop.h>
47 //#include <Events_Message.h>
48 //#include <Events_Error.h>
50 #include <GeomAPI_Shape.h>
51 #include <GeomAPI_AISObject.h>
52 #include <AIS_Shape.hxx>
53 #include <AIS_DimensionSelectionMode.hxx>
55 #include <StdSelect_TypeOfFace.hxx>
58 #include <QMouseEvent>
61 #include <GeomAlgoAPI_FaceBuilder.h>
62 #include <GeomDataAPI_Dir.h>
68 /*!Create and return new instance of XGUI_Module*/
69 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
71 return new PartSet_Module(theWshop);
74 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
75 : ModuleBase_IModule(theWshop)
77 //myWorkshop = theWshop;
78 myListener = new PartSet_Listener(this);
80 connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)),
81 this, SLOT(onOperationStarted(ModuleBase_Operation*)));
83 connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
84 SLOT(onOperationStopped(ModuleBase_Operation*)));
86 XGUI_Workshop* aXWshop = xWorkshop();
87 XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
88 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
89 SLOT(onContextMenuCommand(const QString&, bool)));
93 PartSet_Module::~PartSet_Module()
97 void PartSet_Module::createFeatures()
99 //Registering of validators
100 SessionPtr aMgr = ModelAPI_Session::get();
101 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
102 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
103 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
104 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
105 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
106 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
108 Config_ModuleReader aXMLReader = Config_ModuleReader();
109 aXMLReader.readAll();
110 myFeaturesInFiles = aXMLReader.featuresInFiles();
113 void PartSet_Module::featureCreated(QAction* theFeature)
115 connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
118 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
120 return myFeaturesInFiles[theFeatureId];
126 void PartSet_Module::onFeatureTriggered()
128 QAction* aCmd = dynamic_cast<QAction*>(sender());
129 //Do nothing on uncheck
130 if (aCmd->isCheckable() && !aCmd->isChecked())
132 launchOperation(aCmd->data().toString());
136 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
138 XGUI_Workshop* aXWshp = xWorkshop();
139 XGUI_Displayer* aDisplayer = aXWshp->displayer();
140 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
142 XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
143 connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
144 SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
146 //aDisplayer->deactivateObjectsOutOfContext();
147 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
149 if (aSketchOp->isEditOperation()) {
150 setSketchingMode(getSketchPlane(aSketchOp->feature()));
152 aDisplayer->openLocalContext();
153 aDisplayer->activateObjectsOutOfContext(QIntList());
154 myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
155 aDisplayer->addSelectionFilter(myPlaneFilter);
156 QIntList aModes = sketchSelectionModes(aPreviewOp->feature());
157 aDisplayer->setSelectionModes(aModes);
163 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
167 XGUI_Workshop* aXWshp = xWorkshop();
168 XGUI_Displayer* aDisplayer = aXWshp->displayer();
169 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
171 XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
173 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
175 aDisplayer->closeLocalContexts();
177 PartSet_OperationFeatureCreate* aCreationOp =
178 dynamic_cast<PartSet_OperationFeatureCreate*>(aPreviewOp);
180 // Activate just created object for selection
181 FeaturePtr aFeature = aCreationOp->feature();
182 QIntList aModes = sketchSelectionModes(aFeature);
183 const std::list<ResultPtr>& aResults = aFeature->results();
184 std::list<ResultPtr>::const_iterator anIt, aLast = aResults.end();
185 for (anIt = aResults.begin(); anIt != aLast; anIt++) {
186 aDisplayer->activate(*anIt, aModes);
188 aDisplayer->activate(aFeature, aModes);
192 // Activate results of current feature for selection
193 //FeaturePtr aFeature = theOperation->feature();
194 //XGUI_Displayer* aDisplayer = aXWshp->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 = workshop()->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 XGUI_Workshop* aXWshp = xWorkshop();
216 PartSet_OperationSketchBase* aPreviewOp =
217 dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
219 ModuleBase_ISelection* aSelection = workshop()->selection();
220 // Initialise operation with preliminary selection
221 //QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
222 //QList<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
223 //QList<ObjectPtr> aObjList;
224 //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
226 // foreach(ModuleBase_ViewerPrs aPrs, aSelected)
227 // aObjList.append(aPrs.object());
229 // foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
230 // if (!aObjList.contains(aPrs.object()))
231 // aObjList.append(aPrs.object());
234 // foreach(ModuleBase_ViewerPrs aPrs, aHighlighted)
235 // aObjList.append(aPrs.object());
237 //onSetSelection(aObjList);
238 aPreviewOp->mousePressed(theEvent, myWorkshop->viewer(), aSelection);
242 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
244 PartSet_OperationSketchBase* aPreviewOp =
245 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
247 ModuleBase_ISelection* aSelection = workshop()->selection();
248 // Initialise operation with preliminary selection
249 aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer(), aSelection);
253 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
255 PartSet_OperationSketchBase* aPreviewOp =
256 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
258 aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer());
261 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
263 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
264 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
266 aPreviewOp->keyReleased(theEvent->key());
270 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
272 PartSet_OperationSketchBase* aPreviewOp =
273 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
274 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
275 if (aPreviewOp && (!aView.IsNull())) {
276 ModuleBase_ISelection* aSelection = workshop()->selection();
277 // Initialise operation with preliminary selection
278 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelection);
282 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
284 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
285 xWorkshop()->actionsMgr()->update();
287 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
288 FeaturePtr aSketch = anOperation->feature();
289 setSketchingMode(getSketchPlane(aSketch));
292 void PartSet_Module::onFitAllView()
294 myWorkshop->viewer()->fitAll();
297 void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
299 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
301 std::string aKind = aFeature ? aFeature->getKind() : "";
302 ModuleBase_Operation* anOperation = createOperation(theName, aKind);
304 PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
306 PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
308 aCreateOp->initFeature(aFeature);
310 anOperation->setFeature(aFeature);
312 ModuleBase_ISelection* aSelection = workshop()->selection();
313 // Initialise operation with preliminary selection
314 aSketchOp->initSelection(aSelection, myWorkshop->viewer());
315 } //else if (aFeature) {
316 //anOperation->setFeature(aFeature);
317 ////Deactivate result of current feature in order to avoid its selection
318 //XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
319 //std::list<ResultPtr> aResults = aFeature->results();
320 //std::list<ResultPtr>::const_iterator aIt;
321 //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
322 // aDisplayer->deactivate(*aIt);
325 sendOperation(anOperation);
326 xWorkshop()->actionsMgr()->updateCheckState();
329 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
331 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
332 aViewer->enableMultiselection(theEnabled);
335 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
337 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
339 // foreach(ObjectPtr aObject, theFeatures) {
340 // activateFeature(aObject);
343 aDisplayer->stopSelection(theFeatures, isStop, false);
345 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
346 aViewer->enableSelection(!isStop);
348 aDisplayer->updateViewer();
351 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
353 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
354 aDisplayer->setSelected(theFeatures, false);
355 aDisplayer->updateViewer();
358 void PartSet_Module::setSketchingMode(const gp_Pln& thePln)
360 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
361 if (!myPlaneFilter.IsNull()) {
362 aDisplayer->removeSelectionFilter(myPlaneFilter);
363 myPlaneFilter.Nullify();
366 // Clear standard selection modes
367 aDisplayer->setSelectionModes(aModes);
368 aDisplayer->openLocalContext();
371 mySketchFilter = new ModuleBase_ShapeInPlaneFilter(thePln);
372 aDisplayer->addSelectionFilter(mySketchFilter);
374 // Get default selection modes
375 aModes = sketchSelectionModes(ObjectPtr());
376 aDisplayer->activateObjectsOutOfContext(aModes);
379 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
381 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
382 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
383 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
385 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
386 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
387 QIntList aModes = sketchSelectionModes(aPrevOp->feature());
388 std::list<FeaturePtr>::iterator aSFIt;
389 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
390 std::list<ResultPtr> aResults = (*aSFIt)->results();
391 std::list<ResultPtr>::iterator aIt;
392 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
394 aDisplayer->erase((*aIt), false);
397 aDisplayer->erase((*aSFIt), false);
399 //aDisplayer->deactivateObjectsOutOfContext();
402 ModelAPI_EventCreator::get()->sendUpdated(
403 theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
406 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
407 const std::string& theFeatureKind)
409 // create the operation
410 ModuleBase_Operation* anOperation = 0;
411 if (theCmdId == PartSet_OperationSketch::Type()) {
412 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
414 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
415 CompositeFeaturePtr aSketch;
416 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
418 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);
430 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
433 // set operation description and list of widgets corresponding to the feature xml definition
434 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
436 std::string aPluginFileName = featureFile(aFeatureKind);
437 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
438 aWdgReader.readAll();
439 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
440 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
442 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
443 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
445 // connect the operation
446 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
448 connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
449 SLOT(onFeatureConstructed(ObjectPtr, int)));
450 connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this,
451 SLOT(onRestartOperation(std::string, ObjectPtr)));
452 // If manage multi selection the it will be impossible to select more then one
453 // object under operation Edit
454 // connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
455 // SLOT(onMultiSelectionEnabled(bool)));
457 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
458 SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
459 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
460 SLOT(onSetSelection(const QList<ObjectPtr>&)));
462 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
464 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
465 SLOT(onPlaneSelected(double, double, double)));
466 connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
474 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
476 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
480 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
484 FeaturePtr aFeature = aPreviewOp->feature();
485 if (!aFeature || aFeature->getKind() != theCmdId)
488 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
489 // Hide result of sketch
490 std::list<ResultPtr> aResults = aFeature->results();
491 std::list<ResultPtr>::const_iterator aIt;
492 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
493 aDisplayer->erase(*aIt, false);
495 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
497 std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
498 for (; anIt != aLast; anIt++) {
499 boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
500 SketchPlugin_Feature>(*anIt);
503 std::list<ResultPtr> aResults = aSPFeature->results();
504 std::list<ResultPtr>::const_iterator aRIt;
505 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
506 aDisplayer->display((*aRIt), false);
507 aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
509 aDisplayer->display(aSPFeature, false);
510 aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
512 aDisplayer->updateViewer();
515 void PartSet_Module::editFeature(FeaturePtr theFeature)
520 // if (theFeature->getKind() == SKETCH_KIND) {
521 //FeaturePtr aFeature = theFeature;
522 //if (XGUI_Tools::isModelObject(aFeature)) {
523 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
524 // aFeature = aObject->featureRef();
528 onRestartOperation(theFeature->getKind(), theFeature);
529 updateCurrentPreview(theFeature->getKind());
534 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
536 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
538 PartSet_OperationSketchBase* aPreviewOp =
539 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
543 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
544 aFeature->data()->attribute(theAttribute));
546 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
550 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
551 Config_WidgetAPI* theWidgetApi,
552 QList<ModuleBase_ModelWidget*>& theModelWidgets)
554 if (theType == "sketch-start-label") {
555 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
556 aWgt->setOperationsMgr(xWorkshop()->operationMgr());
557 theModelWidgets.append(aWgt);
558 return aWgt->getControl();
564 XGUI_Workshop* PartSet_Module::xWorkshop() const
566 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
568 return aConnector->workshop();
574 QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
577 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
579 if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
580 aModes.append(TopAbs_FACE);
582 } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
583 aModes.append(AIS_DSM_Text);
584 aModes.append(AIS_DSM_Line);
588 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
589 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
594 gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const
596 DataPtr aData = theSketch->data();
597 boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
598 aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
599 boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
600 aData->attribute(SketchPlugin_Sketch::NORM_ID()));
601 gp_Pnt aOrig(anOrigin->x(), anOrigin->y(), anOrigin->z());
602 gp_Dir aDir(aNorm->x(), aNorm->y(), aNorm->z());
603 return gp_Pln(aOrig, aDir);
607 void PartSet_Module::onSelectionChanged()
609 ModuleBase_ISelection* aSelect = myWorkshop->selection();
610 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
611 // We need to stop edit operation if selection is cleared
612 if (aSelected.size() == 0) {
613 PartSet_OperationFeatureEdit* anEditOp =
614 dynamic_cast<PartSet_OperationFeatureEdit*>(myWorkshop->currentOperation());
619 PartSet_OperationSketchBase* aSketchOp =
620 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
622 aSketchOp->selectionChanged(aSelect);