1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_SketcherMgr.cpp
4 // Created: 19 Dec 2014
5 // Author: Vitaly SMETANNIKOV
7 #include "PartSet_SketcherMgr.h"
8 #include "PartSet_Module.h"
9 #include "PartSet_WidgetPoint2d.h"
10 #include "PartSet_WidgetPoint2dDistance.h"
11 #include "PartSet_Tools.h"
12 #include "PartSet_WidgetSketchLabel.h"
14 #include <ModuleBase_WidgetEditor.h>
16 #include <XGUI_ModuleConnector.h>
17 #include <XGUI_Displayer.h>
18 #include <XGUI_Workshop.h>
19 #include <XGUI_ContextMenuMgr.h>
20 #include <XGUI_Selection.h>
21 #include <XGUI_SelectionMgr.h>
22 #include <ModuleBase_ModelWidget.h>
23 #include <XGUI_ModuleConnector.h>
24 #include <XGUI_PropertyPanel.h>
25 #include <XGUI_ViewerProxy.h>
27 #include <AppElements_MainWindow.h>
29 #include <ModuleBase_IViewer.h>
30 #include <ModuleBase_IWorkshop.h>
31 #include <ModuleBase_IViewWindow.h>
32 #include <ModuleBase_Operation.h>
33 #include <ModuleBase_ISelection.h>
34 #include <ModuleBase_IPropertyPanel.h>
35 #include <ModuleBase_Operation.h>
37 #include <GeomDataAPI_Point2D.h>
39 #include <Events_Loop.h>
41 #include <SketchPlugin_Line.h>
42 #include <SketchPlugin_Sketch.h>
43 #include <SketchPlugin_Point.h>
44 #include <SketchPlugin_Arc.h>
45 #include <SketchPlugin_Circle.h>
46 #include <SketchPlugin_ConstraintLength.h>
47 #include <SketchPlugin_ConstraintDistance.h>
48 #include <SketchPlugin_ConstraintParallel.h>
49 #include <SketchPlugin_ConstraintPerpendicular.h>
50 #include <SketchPlugin_ConstraintRadius.h>
51 #include <SketchPlugin_ConstraintRigid.h>
52 #include <SketchPlugin_ConstraintHorizontal.h>
53 #include <SketchPlugin_ConstraintVertical.h>
54 #include <SketchPlugin_ConstraintEqual.h>
55 #include <SketchPlugin_ConstraintTangent.h>
56 #include <SketchPlugin_ConstraintCoincidence.h>
57 #include <SketchPlugin_ConstraintFillet.h>
58 #include <SketchPlugin_ConstraintMirror.h>
60 #include <SketcherPrs_Tools.h>
62 #include <SelectMgr_IndexedMapOfOwner.hxx>
63 #include <StdSelect_BRepOwner.hxx>
65 //#include <AIS_DimensionSelectionMode.hxx>
66 #include <AIS_Shape.hxx>
68 #include <ModelAPI_Events.h>
69 #include <ModelAPI_Session.h>
71 #include <QMouseEvent>
72 #include <QApplication>
74 //#define DEBUG_DO_NOT_BY_ENTER
76 /// Returns list of unique objects by sum of objects from List1 and List2
77 /*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
78 const QList<ModuleBase_ViewerPrs>& theList2)
80 QList<ModuleBase_ViewerPrs> aRes;
81 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
82 if (!aRes.contains(aPrs))
85 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
86 if (!aRes.contains(aPrs))
92 void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
93 QMap<FeaturePtr, QList<AttributePtr> >& theFeature2AttributeMap,
94 const FeaturePtr theSketch)
96 QList<ModuleBase_ViewerPrs> aRes;
98 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
99 aLast = theList.end();
100 for (; anIt != aLast; anIt++)
102 ModuleBase_ViewerPrs aPrs = *anIt;
103 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
104 if (aFeature.get() == NULL)
107 QList<AttributePtr> anAttributes;
108 if (theFeature2AttributeMap.contains(aFeature)) {
109 anAttributes = theFeature2AttributeMap[aFeature];
112 TopoDS_Shape aShape = aPrs.shape();
113 if (!aShape.IsNull()) {
114 if (aShape.ShapeType() == TopAbs_VERTEX) {
115 anAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
116 if (anAttr.get() != NULL && !anAttributes.contains(anAttr))
117 anAttributes.push_back(anAttr);
120 theFeature2AttributeMap[aFeature] = anAttributes;
127 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
128 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
129 myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
130 myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
131 myIsPopupMenuActive(false), myIsConstraintsShown(true)
133 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
134 ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
136 myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled();
138 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
139 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
141 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
142 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
144 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
145 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
147 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
148 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
150 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
151 XGUI_Workshop* aWorkshop = aConnector->workshop();
152 connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted()));
155 PartSet_SketcherMgr::~PartSet_SketcherMgr()
157 if (!myPlaneFilter.IsNull())
158 myPlaneFilter.Nullify();
161 void PartSet_SketcherMgr::onEnterViewPort()
163 // 1. if the mouse over window, update the next flag. Do not perform update visibility of
164 // created feature because it should be done in onMouseMove(). Some widgets watch
165 // the mouse move and use the cursor position to update own values. If the presentaion is
166 // redisplayed before this update, the feature presentation jumps from reset value to current.
167 myIsMouseOverWindow = true;
168 myIsPropertyPanelValueChanged = false;
170 #ifdef DEBUG_DO_NOT_BY_ENTER
173 //if (!isNestedCreateOperation(getCurrentOperation()))
177 void PartSet_SketcherMgr::onLeaveViewPort()
179 myIsMouseOverViewProcessed = false;
180 myIsMouseOverWindow = false;
181 myIsPropertyPanelValueChanged = false;
183 #ifdef DEBUG_DO_NOT_BY_ENTER
187 if (!isNestedCreateOperation(getCurrentOperation()))
189 // the method should be performed if the popup menu is called,
190 // the reset of the current widget should not happen
191 if (myIsPopupMenuActive)
194 // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
195 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
196 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
197 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
198 // disable the viewer update in order to avoid visualization of redisplayed feature in viewer
199 // obtained after reset value
200 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
201 ModuleBase_Operation* aOperation = getCurrentOperation();
202 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
203 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
207 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
209 // hides the presentation of the current operation feature
210 //myIsPropertyPanelValueChanged = false;
211 // the feature is to be erased here, but it is correct to call canDisplayObject because
212 // there can be additional check (e.g. editor widget in distance constraint)
213 FeaturePtr aFeature = getCurrentOperation()->feature();
214 visualizeFeature(aOperation, canDisplayObject(aFeature));
217 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
219 if (isNestedCreateOperation(getCurrentOperation()))
221 // it is necessary to save current selection in order to restore it after the values are modifed
224 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
225 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
226 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
227 myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
230 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
232 if (isNestedCreateOperation(getCurrentOperation()))
234 // it is necessary to restore current selection in order to restore it after the values are modified
236 myCurrentSelection.clear();
238 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
239 // viewer happens by deselect/select the modified objects. The flag should be restored after
240 // the selection processing. The update viewer should be also called.
241 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
242 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
243 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
244 aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
245 aDisplayer->updateViewer();
248 void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
250 if (!isNestedCreateOperation(getCurrentOperation()))
253 // visualize the current operation feature
254 myIsPropertyPanelValueChanged = true;
255 ModuleBase_Operation* aOperation = getCurrentOperation();
256 // the feature is to be erased here, but it is correct to call canDisplayObject because
257 // there can be additional check (e.g. editor widget in distance constraint)
258 FeaturePtr aFeature = getCurrentOperation()->feature();
259 visualizeFeature(aOperation, canDisplayObject(aFeature));
262 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
264 get2dPoint(theWnd, theEvent, myClickedPoint);
266 if (!(theEvent->buttons() & Qt::LeftButton))
269 // Clear dragging mode
270 myIsDragging = false;
272 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
273 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
274 if (!aViewer->canDragByMouse())
277 ModuleBase_Operation* aOperation = getCurrentOperation();
278 if (aOperation && aOperation->isEditOperation()) {
279 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
280 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
281 // If the current widget is a selector, do do nothing, it processes the mouse press
282 if(aActiveWgt && aActiveWgt->isViewerSelector()) {
287 // Use only for sketch operations
288 if (aOperation && myCurrentSketch) {
289 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
292 bool isSketcher = isSketchOperation(aOperation);
293 bool isSketchOpe = isNestedSketchOperation(aOperation);
295 // Avoid non-sketch operations
296 if ((!isSketchOpe) && (!isSketcher))
299 bool isEditing = aOperation->isEditOperation();
301 // Ignore creation sketch operation
302 if ((!isSketcher) && (!isEditing))
305 // MoveTo in order to highlight current object
306 aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
308 // Remember highlighted objects for editing
309 ModuleBase_ISelection* aSelect = aWorkshop->selection();
311 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
312 storeSelection(!aHasShift);
314 if (myCurrentSelection.empty()) {
315 if (isSketchOpe && (!isSketcher))
316 // commit previous operation
317 if (!aOperation->commit())
324 get2dPoint(theWnd, theEvent, myCurrentPoint);
327 // Init flyout point for radius rotation
328 FeaturePtr aFeature = myCurrentSelection.begin().key();
329 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
330 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
331 if (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
332 DataPtr aData = aSPFeature->data();
333 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
334 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
335 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
336 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
339 } else if (isSketchOpe && isEditing) {
340 // If selected another object commit current result
341 aOperation->commit();
344 get2dPoint(theWnd, theEvent, myCurrentPoint);
347 // This is necessary in order to finalize previous operation
348 QApplication::processEvents();
354 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
356 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
357 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
358 if (!aViewer->canDragByMouse())
360 ModuleBase_Operation* aOp = getCurrentOperation();
362 if (isNestedSketchOperation(aOp)) {
363 get2dPoint(theWnd, theEvent, myClickedPoint);
365 // Only for sketcher operations
369 myCurrentSelection.clear();
370 // Reselect edited object
371 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
372 if (theEvent->modifiers() & Qt::ShiftModifier)
373 aViewer->AISContext()->ShiftSelect();
375 aViewer->AISContext()->Select();
381 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
382 myIsDragging = false;
385 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
387 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
388 myIsMouseOverViewProcessed = true;
389 // 1. perform the widget mouse move functionality and display the presentation
390 ModuleBase_Operation* aOperation = getCurrentOperation();
391 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
392 ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
393 // the mouse move should be processed in the widget, if it can in order to visualize correct
394 // presentation. These widgets correct the feature attribute according to the mouse position
395 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
397 aPoint2DWdg->onMouseMove(theWnd, theEvent);
399 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
402 aDistanceWdg->onMouseMove(theWnd, theEvent);
404 // the feature is to be erased here, but it is correct to call canDisplayObject because
405 // there can be additional check (e.g. editor widget in distance constraint)
406 FeaturePtr aFeature = getCurrentOperation()->feature();
407 visualizeFeature(aOperation, canDisplayObject(aFeature));
410 myClickedPoint.clear();
413 // 1. the current selection is saved in the mouse press method in order to restore it after moving
414 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
415 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
416 // deselected). This flag should be restored in the slot, processed the mouse release signal.
417 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
418 aViewer->enableSelection(false);
420 ModuleBase_Operation* aOperation = getCurrentOperation();
423 if (isSketchOperation(aOperation))
424 return; // No edit operation activated
426 Handle(V3d_View) aView = theWnd->v3dView();
427 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
429 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
430 double dX = aX - myCurrentPoint.myCurX;
431 double dY = aY - myCurrentPoint.myCurY;
433 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
434 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
435 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
436 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
437 // viewer happens by deselect/select the modified objects. The flag should be restored after
438 // the selection processing. The update viewer should be also called.
439 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
441 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
442 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
443 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
444 aLast = myCurrentSelection.end();
445 // 4. the features and attributes modification(move)
446 for (; anIt != aLast; anIt++) {
447 FeaturePtr aFeature = anIt.key();
449 std::set<AttributePtr> anAttributes = anIt.value().first;
450 // Process selection by attribute: the priority to the attribute
451 if (!anAttributes.empty()) {
452 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
453 anAttLast = anAttributes.end();
454 for (; anAttIt != anAttLast; anAttIt++) {
455 AttributePtr anAttr = *anAttIt;
456 if (anAttr.get() == NULL)
458 std::string aAttrId = anAttr->id();
459 DataPtr aData = aFeature->data();
460 if (aData.get() != NULL) {
461 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
462 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
463 if (aPoint.get() != NULL) {
464 bool isImmutable = aPoint->setImmutable(true);
465 aPoint->move(dX, dY);
466 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
467 aPoint->setImmutable(isImmutable);
472 // Process selection by feature
473 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
474 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
475 if (aSketchFeature) {
476 aSketchFeature->move(dX, dY);
477 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
481 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
482 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
484 // 5. it is necessary to save current selection in order to restore it after the features moving
486 // 6. restore the update viewer flag and call this update
487 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
488 aDisplayer->updateViewer();
491 myCurrentPoint.setValue(aX, aY);
495 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
497 ModuleBase_Operation* aOperation = getCurrentOperation();
498 if (aOperation && aOperation->isEditOperation()) {
499 std::string aId = aOperation->id().toStdString();
500 if (isDistanceOperation(aOperation))
502 // Activate dimension value editing on double click
503 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
504 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
505 // Find corresponded widget to activate value editing
506 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
507 if (aWgt->attributeID() == "ConstraintValue") {
516 void PartSet_SketcherMgr::onApplicationStarted()
518 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
519 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
520 XGUI_Workshop* aWorkshop = aConnector->workshop();
521 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
522 if (aPropertyPanel) {
523 connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
524 this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
527 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
528 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
529 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
531 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
532 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
533 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
536 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
538 if (!myClickedPoint.myIsInitialized)
541 ModuleBase_Operation* aOperation = getCurrentOperation();
542 // the distance constraint feature should not use the clickedd point
543 // this is workaround in order to don't throw down the flyout point value,
544 // set by execute() method of these type of features
545 if (isDistanceOperation(aOperation))
548 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
550 aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
554 void PartSet_SketcherMgr::onBeforeContextMenu()
556 myIsPopupMenuActive = true;
559 void PartSet_SketcherMgr::onAfterContextMenu()
561 myIsPopupMenuActive = false;
564 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
567 Handle(V3d_View) aView = theWnd->v3dView();
568 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
570 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
571 thePoint.setValue(aX, anY);
574 void PartSet_SketcherMgr::launchEditing()
576 // there should be activate the sketch selection mode because the edit can happens
577 // by any sketch entity or consttant selected
578 activateObjectsInSketchMode(true);
580 if (!myCurrentSelection.empty()) {
581 FeaturePtr aFeature = myCurrentSelection.begin().key();
582 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
583 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
585 myModule->editFeature(aSPFeature);
592 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
594 static QStringList aIds;
595 if (aIds.size() == 0) {
596 aIds << SketchPlugin_Line::ID().c_str();
597 aIds << SketchPlugin_Point::ID().c_str();
598 aIds << SketchPlugin_Arc::ID().c_str();
599 aIds << SketchPlugin_Circle::ID().c_str();
600 aIds << SketchPlugin_ConstraintLength::ID().c_str();
601 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
602 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
603 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
604 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
605 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
606 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
607 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
608 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
609 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
610 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
611 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
612 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
617 const QStringList& PartSet_SketcherMgr::constraintsIdList()
619 static QStringList aIds;
620 if (aIds.size() == 0) {
621 aIds << SketchPlugin_ConstraintLength::ID().c_str();
622 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
623 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
624 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
625 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
626 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
627 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
628 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
629 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
630 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
631 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
632 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
638 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
640 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
643 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
645 return theOperation &&
646 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
649 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
651 return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
654 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
656 return (theId == SketchPlugin_Line::ID()) ||
657 (theId == SketchPlugin_Point::ID()) ||
658 (theId == SketchPlugin_Arc::ID()) ||
659 (theId == SketchPlugin_Circle::ID());
662 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
664 std::string aId = theOperation ? theOperation->id().toStdString() : "";
666 return (aId == SketchPlugin_ConstraintLength::ID()) ||
667 (aId == SketchPlugin_ConstraintDistance::ID()) ||
668 (aId == SketchPlugin_ConstraintRadius::ID());
671 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
673 // Display all sketcher sub-Objects
674 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
675 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
676 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
678 // Hide sketcher result
679 std::list<ResultPtr> aResults = myCurrentSketch->results();
680 std::list<ResultPtr>::const_iterator aIt;
681 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
682 aDisplayer->erase((*aIt), false);
684 aDisplayer->erase(myCurrentSketch, false);
686 // Display sketcher objects
687 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
688 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
689 std::list<ResultPtr> aResults = aFeature->results();
690 std::list<ResultPtr>::const_iterator aIt;
691 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
692 aDisplayer->display((*aIt), false);
694 aDisplayer->display(aFeature, false);
697 if (myPlaneFilter.IsNull())
698 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
700 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
701 if (theOperation->isEditOperation()) {
702 // If it is editing of sketch then it means that plane is already defined
703 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
704 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
706 aDisplayer->updateViewer();
709 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
711 myIsMouseOverWindow = false;
712 myIsConstraintsShown = true;
713 // the objects activated in the sketch should be deactivated in order to do not have the specific
714 // sketch selection mode activated on objects in neutral point of the application(no started operation)
715 activateObjectsInSketchMode(false);
717 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
718 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
720 DataPtr aData = myCurrentSketch->data();
721 if ((!aData) || (!aData->isValid())) {
722 // The sketch was aborted
723 myCurrentSketch = CompositeFeaturePtr();
724 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
726 // Erase all sketcher objects
727 QStringList aSketchIds = sketchOperationIdList();
728 QObjectPtrList aObjects = aDisplayer->displayedObjects();
729 foreach (ObjectPtr aObj, aObjects) {
730 DataPtr aObjData = aObj->data();
731 if ((!aObjData) || (!aObjData->isValid()))
732 aDisplayer->erase(aObj);
736 // Hide all sketcher sub-Objects
737 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
738 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
739 std::list<ResultPtr> aResults = aFeature->results();
740 std::list<ResultPtr>::const_iterator aIt;
741 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
742 aDisplayer->erase((*aIt), false);
744 aDisplayer->erase(aFeature, false);
746 // Display sketcher result
747 std::list<ResultPtr> aResults = myCurrentSketch->results();
748 std::list<ResultPtr>::const_iterator aIt;
749 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
750 aDisplayer->display((*aIt), false);
752 aDisplayer->display(myCurrentSketch);
754 myCurrentSketch = CompositeFeaturePtr();
755 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
756 aDisplayer->updateViewer();
759 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
761 if (constraintsIdList().contains(theOperation->id())) {
762 // Show constraints if a constraint was created
763 onShowConstraintsToggle(true);
765 connectToPropertyPanel(true);
768 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
770 connectToPropertyPanel(false);
771 myIsPropertyPanelValueChanged = false;
772 myIsMouseOverViewProcessed = true;
774 // the sketch objects selection should be activated in order to select any sketch
776 activateObjectsInSketchMode(true);
779 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
781 if (isNestedCreateOperation(theOperation))
782 visualizeFeature(theOperation, true);
786 bool PartSet_SketcherMgr::canUndo() const
788 return isNestedCreateOperation(getCurrentOperation());
791 bool PartSet_SketcherMgr::canRedo() const
793 return isNestedCreateOperation(getCurrentOperation());
796 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
798 bool aCanDisplay = true;
800 bool aHasActiveSketch = activeSketch().get() != NULL;
801 if (aHasActiveSketch) {
802 // 1. the sketch feature should not be displayed during the sketch active operation
803 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
804 // nested features can be visualized
805 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
806 if (aFeature.get() != NULL && aFeature == activeSketch())
809 else { // there are no an active sketch
810 // 2. sketch sub-features should not be visualized if the sketch operation is not active
811 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
812 if (aFeature.get() != NULL) {
813 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
814 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
815 if (aSketchFeature.get())
820 // 3. the method should not filter the objects, which are not related to the current operation.
821 // The object is filtered just if it is a current operation feature or this feature result
822 bool isObjectFound = false;
823 ModuleBase_Operation* anOperation = getCurrentOperation();
825 FeaturePtr aFeature = anOperation->feature();
826 if (aFeature.get()) {
827 std::list<ResultPtr> aResults = aFeature->results();
828 if (theObject == aFeature)
829 isObjectFound = true;
831 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
832 for (; anIt != aLast; anIt++) {
833 isObjectFound = *anIt == theObject;
841 // 4. For created nested feature operation do not display the created feature if
842 // the mouse curstor leaves the OCC window.
843 // The correction cases, which ignores this condition:
844 // a. the property panel values modification
845 // b. the popup menu activated
846 // c. widget editor control
847 #ifndef DEBUG_DO_NOT_BY_ENTER
848 if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
849 ModuleBase_Operation* aOperation = getCurrentOperation();
850 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
851 ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
852 ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
853 // the active widget editor should not influence here. The presentation should be visible always
854 // when this widget is active.
855 if (!anEditorWdg && !myIsPopupMenuActive) {
856 // during a nested create operation, the feature is redisplayed only if the mouse over view
857 // of there was a value modified in the property panel after the mouse left the view
858 aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
865 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
867 bool isFoundObject = false;
869 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
870 if (anObjectFeature.get()) {
871 int aSize = myCurrentSketch->numberOfSubs();
872 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
873 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
874 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
877 return isFoundObject;
880 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
882 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
884 // after the plane is selected in the sketch, the sketch selection should be activated
885 // it can not be performed in the sketch label widget because, we don't need to switch off
886 // the selection by any label deactivation, but need to switch it off by stop the sketch
887 activateObjectsInSketchMode(true);
890 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
891 const FeaturePtr& theSketch,
892 ModuleBase_IWorkshop* theWorkshop,
893 FeatureToSelectionMap& theSelection)
895 if (theFeature.get() == NULL)
898 std::set<AttributePtr> aSelectedAttributes;
899 std::set<ResultPtr> aSelectedResults;
901 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
902 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
903 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
904 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
906 std::list<ResultPtr> aResults = theFeature->results();
907 std::list<ResultPtr>::const_iterator aIt;
908 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
910 ResultPtr aResult = *aIt;
911 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
912 if (aAISObj.get() == NULL)
914 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
915 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
917 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
918 aContext->SelectedOwner());
919 if (aBRepOwner.IsNull())
921 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
922 aBRepOwner->Selectable());
926 if (aBRepOwner->HasShape()) {
927 const TopoDS_Shape& aShape = aBRepOwner->Shape();
928 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
929 if (aShapeType == TopAbs_VERTEX) {
930 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
932 if (aPntAttr.get() != NULL)
933 aSelectedAttributes.insert(aPntAttr);
935 else if (aShapeType == TopAbs_EDGE &&
936 aSelectedResults.find(aResult) == aSelectedResults.end()) {
937 aSelectedResults.insert(aResult);
942 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
945 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
946 const FeaturePtr& theSketch,
947 ModuleBase_IWorkshop* theWorkshop,
948 const FeatureToSelectionMap& theSelection,
949 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
951 if (theFeature.get() == NULL)
954 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
955 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
956 std::set<ResultPtr> aSelectedResults = anIt.value().second;
958 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
959 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
960 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
961 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
963 // 1. found the feature's owners. Check the AIS objects of the constructions
964 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
965 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
966 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
968 SelectMgr_IndexedMapOfOwner aSelectedOwners;
969 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
970 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
971 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
972 if (!anOwner.IsNull())
973 anOwnersToSelect.Add(anOwner);
977 // 2. found the feature results's owners
978 std::list<ResultPtr> aResults = theFeature->results();
979 std::list<ResultPtr>::const_iterator aIt;
980 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
982 ResultPtr aResult = *aIt;
983 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
984 if (aAISObj.get() == NULL)
986 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
988 SelectMgr_IndexedMapOfOwner aSelectedOwners;
989 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
990 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
991 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
992 if ( anOwner.IsNull() || !anOwner->HasShape() )
994 const TopoDS_Shape& aShape = anOwner->Shape();
995 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
996 if (aShapeType == TopAbs_VERTEX) {
997 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
998 if (aPntAttr.get() != NULL &&
999 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1000 anOwnersToSelect.Add(anOwner);
1003 else if (aShapeType == TopAbs_EDGE) {
1004 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1005 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1006 anOwnersToSelect.FindIndex(anOwner) <= 0)
1007 anOwnersToSelect.Add(anOwner);
1013 void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
1015 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1016 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1017 XGUI_Workshop* aWorkshop = aConnector->workshop();
1018 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
1019 if (aPropertyPanel) {
1020 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
1021 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
1023 connect(aWidget, SIGNAL(beforeValuesChanged()),
1024 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1025 connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1026 connect(aWidget, SIGNAL(afterValuesChanged()),
1027 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1030 disconnect(aWidget, SIGNAL(beforeValuesChanged()),
1031 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1032 disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1033 disconnect(aWidget, SIGNAL(afterValuesChanged()),
1034 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1040 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1042 return myModule->workshop()->currentOperation();
1045 void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
1046 const bool isToDisplay)
1048 #ifdef DEBUG_DO_NOT_BY_ENTER
1052 if (!theOperation || theOperation->isEditOperation())
1055 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1056 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1057 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1059 // 1. change visibility of the object itself, here the presentable object is processed,
1060 // e.g. constraints features
1061 FeaturePtr aFeature = theOperation->feature();
1062 std::list<ResultPtr> aResults = aFeature->results();
1064 aDisplayer->display(aFeature, false);
1066 aDisplayer->erase(aFeature, false);
1068 // change visibility of the object results, e.g. non-constraint features
1069 std::list<ResultPtr>::const_iterator aIt;
1070 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1072 aDisplayer->display(*aIt, false);
1075 aDisplayer->erase(*aIt, false);
1078 aDisplayer->updateViewer();
1081 void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive)
1083 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1084 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1085 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1089 aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
1090 aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
1091 aModes.append(SketcherPrs_Tools::Sel_Constraint);
1092 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
1093 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
1095 aDisplayer->activateObjects(aModes);
1098 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1100 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1101 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1102 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
1104 QMap<FeaturePtr, QList<AttributePtr> > aFeature2AttributeMap;
1105 if (theHighlightedOnly) {
1106 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1109 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1111 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
1112 fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch);
1115 // 1. it is necessary to save current selection in order to restore it after the features moving
1116 myCurrentSelection.clear();
1117 QMap<FeaturePtr, QList<AttributePtr> >::const_iterator anIt = aFeature2AttributeMap.begin(),
1118 aLast = aFeature2AttributeMap.end();
1119 for (; anIt != aLast; anIt++) {
1120 FeaturePtr aFeature = anIt.key();
1121 getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection);
1123 //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1126 void PartSet_SketcherMgr::restoreSelection()
1128 //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1129 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1130 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1131 FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
1132 aSLast = myCurrentSelection.end();
1133 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
1134 for (; aSIt != aSLast; aSIt++) {
1135 anOwnersToSelect.Clear();
1136 getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
1138 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
1142 void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
1144 if (myIsConstraintsShown == theOn)
1146 if (myCurrentSketch.get() == NULL)
1149 myIsConstraintsShown = theOn;
1151 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1152 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1153 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1155 const QStringList& aConstrIds = constraintsIdList();
1156 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
1157 FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
1158 if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
1159 if (myIsConstraintsShown)
1160 aDisplayer->display(aSubFeature, false);
1162 aDisplayer->erase(aSubFeature, false);
1165 aDisplayer->updateViewer();