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>
23 #include <GeomDataAPI_Point.h>
24 #include <GeomDataAPI_Dir.h>
26 #include <XGUI_MainWindow.h>
27 #include <XGUI_Displayer.h>
28 #include <XGUI_Viewer.h>
29 #include <XGUI_Workshop.h>
30 #include <XGUI_OperationMgr.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>
40 #include <SketchPlugin_Sketch.h>
42 #include <Config_PointerMessage.h>
43 #include <Config_ModuleReader.h>
44 #include <Config_WidgetReader.h>
45 #include <Events_Loop.h>
46 //#include <Events_Message.h>
47 //#include <Events_Error.h>
49 #include <GeomAPI_Shape.h>
50 #include <GeomAPI_AISObject.h>
51 #include <AIS_Shape.hxx>
52 #include <AIS_DimensionSelectionMode.hxx>
54 #include <StdSelect_TypeOfFace.hxx>
57 #include <QMouseEvent>
60 #include <GeomAlgoAPI_FaceBuilder.h>
61 #include <GeomDataAPI_Dir.h>
67 /*!Create and return new instance of XGUI_Module*/
68 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
70 return new PartSet_Module(theWshop);
73 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
74 : ModuleBase_IModule(theWshop)
76 //myWorkshop = theWshop;
77 myListener = new PartSet_Listener(this);
79 connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)),
80 this, SLOT(onOperationStarted(ModuleBase_Operation*)));
82 connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
83 SLOT(onOperationStopped(ModuleBase_Operation*)));
85 XGUI_Workshop* aXWshop = xWorkshop();
86 XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
87 connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
88 SLOT(onContextMenuCommand(const QString&, bool)));
90 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
91 SLOT(onMousePressed(QMouseEvent*)));
92 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
93 SLOT(onMouseReleased(QMouseEvent*)));
94 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
95 SLOT(onMouseMoved(QMouseEvent*)));
96 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
97 SLOT(onKeyRelease(QKeyEvent*)));
98 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
99 SLOT(onMouseDoubleClick(QMouseEvent*)));
102 PartSet_Module::~PartSet_Module()
106 void PartSet_Module::createFeatures()
108 //Registering of validators
109 SessionPtr aMgr = ModelAPI_Session::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 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
129 return myFeaturesInFiles[theFeatureId];
135 void PartSet_Module::onFeatureTriggered()
137 QAction* aCmd = dynamic_cast<QAction*>(sender());
138 //Do nothing on uncheck
139 if (aCmd->isCheckable() && !aCmd->isChecked())
141 launchOperation(aCmd->data().toString());
145 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
147 XGUI_Workshop* aXWshp = xWorkshop();
148 XGUI_Displayer* aDisplayer = aXWshp->displayer();
149 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
151 XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
152 connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
153 SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
155 //aDisplayer->deactivateObjectsOutOfContext();
156 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
158 if (aSketchOp->isEditOperation()) {
159 setSketchingMode(getSketchPlane(aSketchOp->feature()));
161 aDisplayer->openLocalContext();
162 aDisplayer->activateObjectsOutOfContext(QIntList());
163 myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
164 aDisplayer->addSelectionFilter(myPlaneFilter);
165 QIntList aModes = sketchSelectionModes(aPreviewOp->feature());
166 aDisplayer->setSelectionModes(aModes);
172 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
176 XGUI_Workshop* aXWshp = xWorkshop();
177 XGUI_Displayer* aDisplayer = aXWshp->displayer();
178 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
180 XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
182 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
184 aDisplayer->closeLocalContexts();
186 PartSet_OperationFeatureCreate* aCreationOp =
187 dynamic_cast<PartSet_OperationFeatureCreate*>(aPreviewOp);
189 // Activate just created object for selection
190 FeaturePtr aFeature = aCreationOp->feature();
191 QIntList aModes = sketchSelectionModes(aFeature);
192 const std::list<ResultPtr>& aResults = aFeature->results();
193 std::list<ResultPtr>::const_iterator anIt, aLast = aResults.end();
194 for (anIt = aResults.begin(); anIt != aLast; anIt++) {
195 aDisplayer->activate(*anIt, aModes);
197 aDisplayer->activate(aFeature, aModes);
201 // Activate results of current feature for selection
202 //FeaturePtr aFeature = theOperation->feature();
203 //XGUI_Displayer* aDisplayer = aXWshp->displayer();
204 //std::list<ResultPtr> aResults = aFeature->results();
205 //std::list<ResultPtr>::const_iterator aIt;
206 //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
207 // aDisplayer->activate(*aIt);
212 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
214 QList<ObjectPtr> aFeatures = workshop()->selection()->selectedObjects();
215 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
216 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
218 editFeature(aFeature);
222 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
224 XGUI_Workshop* aXWshp = xWorkshop();
225 PartSet_OperationSketchBase* aPreviewOp =
226 dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
227 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
228 if (aPreviewOp && (!aView.IsNull())) {
229 ModuleBase_ISelection* aSelection = workshop()->selection();
230 // Initialise operation with preliminary selection
231 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
232 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
234 aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
238 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
240 PartSet_OperationSketchBase* aPreviewOp =
241 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
242 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
243 if (aPreviewOp && (!aView.IsNull())) {
244 ModuleBase_ISelection* aSelection = workshop()->selection();
245 // Initialise operation with preliminary selection
246 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
247 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
249 aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
253 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
255 PartSet_OperationSketchBase* aPreviewOp =
256 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
257 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
258 if (aPreviewOp && (!aView.IsNull()))
259 aPreviewOp->mouseMoved(theEvent, aView);
262 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
264 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
265 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
267 aPreviewOp->keyReleased(theEvent->key());
271 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
273 PartSet_OperationSketchBase* aPreviewOp =
274 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
275 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
276 if (aPreviewOp && (!aView.IsNull())) {
277 ModuleBase_ISelection* aSelection = workshop()->selection();
278 // Initialise operation with preliminary selection
279 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
280 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
281 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
285 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
287 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
288 xWorkshop()->actionsMgr()->update();
290 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
291 FeaturePtr aSketch = anOperation->feature();
292 setSketchingMode(getSketchPlane(aSketch));
295 void PartSet_Module::onFitAllView()
297 myWorkshop->viewer()->fitAll();
300 void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
302 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
304 std::string aKind = aFeature ? aFeature->getKind() : "";
305 ModuleBase_Operation* anOperation = createOperation(theName, aKind);
307 PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
309 PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
311 aCreateOp->initFeature(aFeature);
313 anOperation->setFeature(aFeature);
315 ModuleBase_ISelection* aSelection = workshop()->selection();
316 // Initialise operation with preliminary selection
317 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
318 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
319 aSketchOp->initSelection(aSelected, aHighlighted);
320 } //else if (aFeature) {
321 //anOperation->setFeature(aFeature);
322 ////Deactivate result of current feature in order to avoid its selection
323 //XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
324 //std::list<ResultPtr> aResults = aFeature->results();
325 //std::list<ResultPtr>::const_iterator aIt;
326 //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
327 // aDisplayer->deactivate(*aIt);
330 sendOperation(anOperation);
331 xWorkshop()->actionsMgr()->updateCheckState();
334 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
336 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
337 aViewer->enableMultiselection(theEnabled);
340 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
342 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
344 // foreach(ObjectPtr aObject, theFeatures) {
345 // activateFeature(aObject);
348 aDisplayer->stopSelection(theFeatures, isStop, false);
350 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
351 aViewer->enableSelection(!isStop);
353 aDisplayer->updateViewer();
356 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
358 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
359 aDisplayer->setSelected(theFeatures, false);
360 aDisplayer->updateViewer();
363 void PartSet_Module::setSketchingMode(const gp_Pln& thePln)
365 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
366 if (!myPlaneFilter.IsNull()) {
367 aDisplayer->removeSelectionFilter(myPlaneFilter);
368 myPlaneFilter.Nullify();
371 // Clear standard selection modes
372 aDisplayer->setSelectionModes(aModes);
373 aDisplayer->openLocalContext();
374 // Get default selection modes
375 aModes = sketchSelectionModes(ObjectPtr());
376 aDisplayer->activateObjectsOutOfContext(aModes);
379 mySketchFilter = new ModuleBase_ShapeInPlaneFilter(thePln);
380 aDisplayer->addSelectionFilter(mySketchFilter);
383 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
385 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
386 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
387 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
389 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
390 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
391 QIntList aModes = sketchSelectionModes(aPrevOp->feature());
392 std::list<FeaturePtr>::iterator aSFIt;
393 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
394 std::list<ResultPtr> aResults = (*aSFIt)->results();
395 std::list<ResultPtr>::iterator aIt;
396 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
398 aDisplayer->erase((*aIt), false);
401 aDisplayer->erase((*aSFIt), false);
403 //aDisplayer->deactivateObjectsOutOfContext();
406 ModelAPI_EventCreator::get()->sendUpdated(
407 theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
410 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
411 const std::string& theFeatureKind)
413 // create the operation
414 ModuleBase_Operation* anOperation = 0;
415 if (theCmdId == PartSet_OperationSketch::Type()) {
416 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
418 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
419 CompositeFeaturePtr aSketch;
420 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
422 aSketch = aPrevOp->sketch();
424 if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
425 anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
426 } else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) {
427 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
428 } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
429 anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
434 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
437 // set operation description and list of widgets corresponding to the feature xml definition
438 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
440 std::string aPluginFileName = featureFile(aFeatureKind);
441 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
442 aWdgReader.readAll();
443 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
444 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
446 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
447 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
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(restartRequired(std::string, ObjectPtr)), this,
455 SLOT(onRestartOperation(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 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
466 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
467 SLOT(onPlaneSelected(double, double, double)));
468 connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
476 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
478 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
482 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
486 FeaturePtr aFeature = aPreviewOp->feature();
487 if (!aFeature || aFeature->getKind() != theCmdId)
490 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
491 // Hide result of sketch
492 std::list<ResultPtr> aResults = aFeature->results();
493 std::list<ResultPtr>::const_iterator aIt;
494 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
495 aDisplayer->erase(*aIt, false);
497 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
499 std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
500 for (; anIt != aLast; anIt++) {
501 boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
502 SketchPlugin_Feature>(*anIt);
505 std::list<ResultPtr> aResults = aSPFeature->results();
506 std::list<ResultPtr>::const_iterator aRIt;
507 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
508 aDisplayer->display((*aRIt), false);
509 aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
511 aDisplayer->display(aSPFeature, false);
512 aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
514 aDisplayer->updateViewer();
517 void PartSet_Module::editFeature(FeaturePtr theFeature)
522 // if (theFeature->getKind() == SKETCH_KIND) {
523 //FeaturePtr aFeature = theFeature;
524 //if (XGUI_Tools::isModelObject(aFeature)) {
525 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
526 // aFeature = aObject->featureRef();
530 onRestartOperation(theFeature->getKind(), theFeature);
531 updateCurrentPreview(theFeature->getKind());
536 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
538 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
540 PartSet_OperationSketchBase* aPreviewOp =
541 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
545 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
546 aFeature->data()->attribute(theAttribute));
548 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
552 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
553 Config_WidgetAPI* theWidgetApi,
554 QList<ModuleBase_ModelWidget*>& theModelWidgets)
556 if (theType == "sketch-start-label") {
557 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
558 aWgt->setOperationsMgr(xWorkshop()->operationMgr());
559 theModelWidgets.append(aWgt);
560 return aWgt->getControl();
566 XGUI_Workshop* PartSet_Module::xWorkshop() const
568 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
570 return aConnector->workshop();
576 QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
579 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
581 if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
582 aModes.append(TopAbs_FACE);
584 } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
585 aModes.append(AIS_DSM_Text);
586 aModes.append(AIS_DSM_Line);
590 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
591 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
596 gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const
598 DataPtr aData = theSketch->data();
599 boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
600 aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
601 boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
602 aData->attribute(SketchPlugin_Sketch::NORM_ID()));
603 gp_Pnt aOrig(anOrigin->x(), anOrigin->y(), anOrigin->z());
604 gp_Dir aDir(aNorm->x(), aNorm->y(), aNorm->z());
605 return gp_Pln(aOrig, aDir);