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);
213 // Clear selection done during operation
214 aDisplayer->clearSelected();
217 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
219 QList<ObjectPtr> aFeatures = workshop()->selection()->selectedObjects();
220 if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
221 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
223 editFeature(aFeature);
227 void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
229 XGUI_Workshop* aXWshp = xWorkshop();
230 PartSet_OperationSketchBase* aPreviewOp =
231 dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
232 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
233 if (aPreviewOp && (!aView.IsNull())) {
234 ModuleBase_ISelection* aSelection = workshop()->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->mousePressed(theEvent, aView, aSelected, aHighlighted);
243 void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
245 PartSet_OperationSketchBase* aPreviewOp =
246 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
247 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
248 if (aPreviewOp && (!aView.IsNull())) {
249 ModuleBase_ISelection* aSelection = workshop()->selection();
250 // Initialise operation with preliminary selection
251 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
252 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
254 aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
258 void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
260 PartSet_OperationSketchBase* aPreviewOp =
261 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
262 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
263 if (aPreviewOp && (!aView.IsNull()))
264 aPreviewOp->mouseMoved(theEvent, aView);
267 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
269 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
270 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
272 aPreviewOp->keyReleased(theEvent->key());
276 void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
278 PartSet_OperationSketchBase* aPreviewOp =
279 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
280 Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
281 if (aPreviewOp && (!aView.IsNull())) {
282 ModuleBase_ISelection* aSelection = workshop()->selection();
283 // Initialise operation with preliminary selection
284 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
285 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
286 aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
290 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
292 myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
293 xWorkshop()->actionsMgr()->update();
295 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
296 FeaturePtr aSketch = anOperation->feature();
297 setSketchingMode(getSketchPlane(aSketch));
300 void PartSet_Module::onFitAllView()
302 myWorkshop->viewer()->fitAll();
305 void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
307 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
309 std::string aKind = aFeature ? aFeature->getKind() : "";
310 ModuleBase_Operation* anOperation = createOperation(theName, aKind);
312 PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
314 PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
316 aCreateOp->initFeature(aFeature);
318 anOperation->setFeature(aFeature);
320 ModuleBase_ISelection* aSelection = workshop()->selection();
321 // Initialise operation with preliminary selection
322 std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
323 std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
324 aSketchOp->initSelection(aSelected, aHighlighted);
325 } //else if (aFeature) {
326 //anOperation->setFeature(aFeature);
327 ////Deactivate result of current feature in order to avoid its selection
328 //XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
329 //std::list<ResultPtr> aResults = aFeature->results();
330 //std::list<ResultPtr>::const_iterator aIt;
331 //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
332 // aDisplayer->deactivate(*aIt);
335 sendOperation(anOperation);
336 xWorkshop()->actionsMgr()->updateCheckState();
339 void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
341 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
342 aViewer->enableMultiselection(theEnabled);
345 void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
347 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
349 // foreach(ObjectPtr aObject, theFeatures) {
350 // activateFeature(aObject);
353 aDisplayer->stopSelection(theFeatures, isStop, false);
355 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
356 aViewer->enableSelection(!isStop);
358 aDisplayer->updateViewer();
361 void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
363 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
364 aDisplayer->setSelected(theFeatures, false);
365 aDisplayer->updateViewer();
368 void PartSet_Module::setSketchingMode(const gp_Pln& thePln)
370 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
371 if (!myPlaneFilter.IsNull()) {
372 aDisplayer->removeSelectionFilter(myPlaneFilter);
373 myPlaneFilter.Nullify();
376 // Clear standard selection modes
377 aDisplayer->setSelectionModes(aModes);
378 aDisplayer->openLocalContext();
379 // Get default selection modes
380 aModes = sketchSelectionModes(ObjectPtr());
381 aDisplayer->activateObjectsOutOfContext(aModes);
384 mySketchFilter = new ModuleBase_ShapeInPlaneFilter(thePln);
385 aDisplayer->addSelectionFilter(mySketchFilter);
388 void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
390 bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
391 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
392 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
394 std::list<FeaturePtr> aList = aPrevOp->subFeatures();
395 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
396 QIntList aModes = sketchSelectionModes(aPrevOp->feature());
397 std::list<FeaturePtr>::iterator aSFIt;
398 for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
399 std::list<ResultPtr> aResults = (*aSFIt)->results();
400 std::list<ResultPtr>::iterator aIt;
401 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
403 aDisplayer->erase((*aIt), false);
406 aDisplayer->erase((*aSFIt), false);
408 //aDisplayer->deactivateObjectsOutOfContext();
411 ModelAPI_EventCreator::get()->sendUpdated(
412 theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
415 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
416 const std::string& theFeatureKind)
418 // create the operation
419 ModuleBase_Operation* anOperation = 0;
420 if (theCmdId == PartSet_OperationSketch::Type()) {
421 anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
423 ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
425 PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
427 aSketch = aPrevOp->sketch();
429 if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
430 anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
431 } else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) {
432 anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
433 } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
434 anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
439 anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
442 // set operation description and list of widgets corresponding to the feature xml definition
443 std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
445 std::string aPluginFileName = featureFile(aFeatureKind);
446 Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
447 aWdgReader.readAll();
448 std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
449 std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
451 anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
452 anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
454 // connect the operation
455 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
457 connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
458 SLOT(onFeatureConstructed(ObjectPtr, int)));
459 connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this,
460 SLOT(onRestartOperation(std::string, ObjectPtr)));
461 connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
462 SLOT(onMultiSelectionEnabled(bool)));
464 connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
465 SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
466 connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
467 SLOT(onSetSelection(const QList<ObjectPtr>&)));
469 PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
471 connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
472 SLOT(onPlaneSelected(double, double, double)));
473 connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
481 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
483 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
487 PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
491 FeaturePtr aFeature = aPreviewOp->feature();
492 if (!aFeature || aFeature->getKind() != theCmdId)
495 XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
496 // Hide result of sketch
497 std::list<ResultPtr> aResults = aFeature->results();
498 std::list<ResultPtr>::const_iterator aIt;
499 for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
500 aDisplayer->erase(*aIt, false);
502 std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
504 std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
505 for (; anIt != aLast; anIt++) {
506 boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
507 SketchPlugin_Feature>(*anIt);
510 std::list<ResultPtr> aResults = aSPFeature->results();
511 std::list<ResultPtr>::const_iterator aRIt;
512 for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
513 aDisplayer->display((*aRIt), false);
514 aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
516 aDisplayer->display(aSPFeature, false);
517 aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
519 aDisplayer->updateViewer();
522 void PartSet_Module::editFeature(FeaturePtr theFeature)
527 // if (theFeature->getKind() == SKETCH_KIND) {
528 //FeaturePtr aFeature = theFeature;
529 //if (XGUI_Tools::isModelObject(aFeature)) {
530 // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
531 // aFeature = aObject->featureRef();
535 onRestartOperation(theFeature->getKind(), theFeature);
536 updateCurrentPreview(theFeature->getKind());
541 void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
543 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
545 PartSet_OperationSketchBase* aPreviewOp =
546 dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
550 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
551 aFeature->data()->attribute(theAttribute));
553 PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
557 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
558 Config_WidgetAPI* theWidgetApi,
559 QList<ModuleBase_ModelWidget*>& theModelWidgets)
561 if (theType == "sketch-start-label") {
562 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
563 aWgt->setOperationsMgr(xWorkshop()->operationMgr());
564 theModelWidgets.append(aWgt);
565 return aWgt->getControl();
571 XGUI_Workshop* PartSet_Module::xWorkshop() const
573 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
575 return aConnector->workshop();
581 QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
584 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
586 if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
587 aModes.append(TopAbs_FACE);
589 } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
590 aModes.append(AIS_DSM_Text);
591 aModes.append(AIS_DSM_Line);
595 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
596 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
601 gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const
603 DataPtr aData = theSketch->data();
604 boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
605 aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
606 boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
607 aData->attribute(SketchPlugin_Sketch::NORM_ID()));
608 gp_Pnt aOrig(anOrigin->x(), anOrigin->y(), anOrigin->z());
609 gp_Dir aDir(aNorm->x(), aNorm->y(), aNorm->z());
610 return gp_Pln(aOrig, aDir);