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())
321 // Init flyout point for radius rotation
322 FeaturePtr aFeature = myCurrentSelection.begin().key();
326 get2dPoint(theWnd, theEvent, myCurrentPoint);
329 if (aFeature.get() != NULL) {
330 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
331 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
332 if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
333 DataPtr aData = aSPFeature->data();
334 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
335 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
336 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
337 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
340 } else if (isSketchOpe && isEditing) {
341 // If selected another object commit current result
342 aOperation->commit();
345 get2dPoint(theWnd, theEvent, myCurrentPoint);
348 // This is necessary in order to finalize previous operation
349 QApplication::processEvents();
355 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
357 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
358 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
359 if (!aViewer->canDragByMouse())
361 ModuleBase_Operation* aOp = getCurrentOperation();
363 if (isNestedSketchOperation(aOp)) {
364 get2dPoint(theWnd, theEvent, myClickedPoint);
366 // Only for sketcher operations
370 myCurrentSelection.clear();
371 // Reselect edited object
372 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
373 if (theEvent->modifiers() & Qt::ShiftModifier)
374 aViewer->AISContext()->ShiftSelect();
376 aViewer->AISContext()->Select();
382 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
383 myIsDragging = false;
386 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
388 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
389 myIsMouseOverViewProcessed = true;
390 // 1. perform the widget mouse move functionality and display the presentation
391 ModuleBase_Operation* aOperation = getCurrentOperation();
392 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
393 ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
394 // the mouse move should be processed in the widget, if it can in order to visualize correct
395 // presentation. These widgets correct the feature attribute according to the mouse position
396 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
398 aPoint2DWdg->onMouseMove(theWnd, theEvent);
400 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
403 aDistanceWdg->onMouseMove(theWnd, theEvent);
405 // the feature is to be erased here, but it is correct to call canDisplayObject because
406 // there can be additional check (e.g. editor widget in distance constraint)
407 FeaturePtr aFeature = getCurrentOperation()->feature();
408 visualizeFeature(aOperation, canDisplayObject(aFeature));
411 myClickedPoint.clear();
414 // 1. the current selection is saved in the mouse press method in order to restore it after moving
415 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
416 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
417 // deselected). This flag should be restored in the slot, processed the mouse release signal.
418 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
419 aViewer->enableSelection(false);
421 ModuleBase_Operation* aOperation = getCurrentOperation();
424 if (isSketchOperation(aOperation))
425 return; // No edit operation activated
427 Handle(V3d_View) aView = theWnd->v3dView();
428 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
430 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
431 double dX = aX - myCurrentPoint.myCurX;
432 double dY = aY - myCurrentPoint.myCurY;
434 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
435 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
436 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
437 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
438 // viewer happens by deselect/select the modified objects. The flag should be restored after
439 // the selection processing. The update viewer should be also called.
440 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
442 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
443 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
444 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
445 aLast = myCurrentSelection.end();
446 // 4. the features and attributes modification(move)
447 for (; anIt != aLast; anIt++) {
448 FeaturePtr aFeature = anIt.key();
450 std::set<AttributePtr> anAttributes = anIt.value().first;
451 // Process selection by attribute: the priority to the attribute
452 if (!anAttributes.empty()) {
453 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
454 anAttLast = anAttributes.end();
455 for (; anAttIt != anAttLast; anAttIt++) {
456 AttributePtr anAttr = *anAttIt;
457 if (anAttr.get() == NULL)
459 std::string aAttrId = anAttr->id();
460 DataPtr aData = aFeature->data();
461 if (aData.get() != NULL) {
462 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
463 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
464 if (aPoint.get() != NULL) {
465 bool isImmutable = aPoint->setImmutable(true);
466 aPoint->move(dX, dY);
467 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
468 aPoint->setImmutable(isImmutable);
473 // Process selection by feature
474 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
475 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
476 if (aSketchFeature) {
477 aSketchFeature->move(dX, dY);
478 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
482 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
483 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
485 // 5. it is necessary to save current selection in order to restore it after the features moving
487 // 6. restore the update viewer flag and call this update
488 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
489 aDisplayer->updateViewer();
492 myCurrentPoint.setValue(aX, aY);
496 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
498 ModuleBase_Operation* aOperation = getCurrentOperation();
499 if (aOperation && aOperation->isEditOperation()) {
500 std::string aId = aOperation->id().toStdString();
501 if (isDistanceOperation(aOperation))
503 // Activate dimension value editing on double click
504 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
505 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
506 // Find corresponded widget to activate value editing
507 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
508 if (aWgt->attributeID() == "ConstraintValue") {
517 void PartSet_SketcherMgr::onApplicationStarted()
519 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
520 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
521 XGUI_Workshop* aWorkshop = aConnector->workshop();
522 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
523 if (aPropertyPanel) {
524 connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
525 this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
528 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
529 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
530 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
532 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
533 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
534 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
537 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
539 if (!myClickedPoint.myIsInitialized)
542 ModuleBase_Operation* aOperation = getCurrentOperation();
543 // the distance constraint feature should not use the clickedd point
544 // this is workaround in order to don't throw down the flyout point value,
545 // set by execute() method of these type of features
546 if (isDistanceOperation(aOperation))
549 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
551 aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
555 void PartSet_SketcherMgr::onBeforeContextMenu()
557 myIsPopupMenuActive = true;
560 void PartSet_SketcherMgr::onAfterContextMenu()
562 myIsPopupMenuActive = false;
565 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
568 Handle(V3d_View) aView = theWnd->v3dView();
569 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
571 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
572 thePoint.setValue(aX, anY);
575 void PartSet_SketcherMgr::launchEditing()
577 // there should be activate the sketch selection mode because the edit can happens
578 // by any sketch entity or consttant selected
579 activateObjectsInSketchMode(true);
581 if (!myCurrentSelection.empty()) {
582 FeaturePtr aFeature = myCurrentSelection.begin().key();
583 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
584 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
586 myModule->editFeature(aSPFeature);
593 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
595 static QStringList aIds;
596 if (aIds.size() == 0) {
597 aIds << SketchPlugin_Line::ID().c_str();
598 aIds << SketchPlugin_Point::ID().c_str();
599 aIds << SketchPlugin_Arc::ID().c_str();
600 aIds << SketchPlugin_Circle::ID().c_str();
601 aIds << SketchPlugin_ConstraintLength::ID().c_str();
602 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
603 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
604 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
605 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
606 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
607 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
608 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
609 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
610 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
611 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
612 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
613 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
618 const QStringList& PartSet_SketcherMgr::constraintsIdList()
620 static QStringList aIds;
621 if (aIds.size() == 0) {
622 aIds << SketchPlugin_ConstraintLength::ID().c_str();
623 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
624 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
625 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
626 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
627 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
628 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
629 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
630 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
631 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
632 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
633 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
639 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
641 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
644 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
646 return theOperation &&
647 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
650 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
652 return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
655 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
657 return (theId == SketchPlugin_Line::ID()) ||
658 (theId == SketchPlugin_Point::ID()) ||
659 (theId == SketchPlugin_Arc::ID()) ||
660 (theId == SketchPlugin_Circle::ID());
663 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
665 std::string aId = theOperation ? theOperation->id().toStdString() : "";
667 return (aId == SketchPlugin_ConstraintLength::ID()) ||
668 (aId == SketchPlugin_ConstraintDistance::ID()) ||
669 (aId == SketchPlugin_ConstraintRadius::ID());
672 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
674 // Display all sketcher sub-Objects
675 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
676 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
677 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
679 // Hide sketcher result
680 std::list<ResultPtr> aResults = myCurrentSketch->results();
681 std::list<ResultPtr>::const_iterator aIt;
682 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
683 aDisplayer->erase((*aIt), false);
685 aDisplayer->erase(myCurrentSketch, false);
687 // Display sketcher objects
688 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
689 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
690 std::list<ResultPtr> aResults = aFeature->results();
691 std::list<ResultPtr>::const_iterator aIt;
692 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
693 aDisplayer->display((*aIt), false);
695 aDisplayer->display(aFeature, false);
698 if (myPlaneFilter.IsNull())
699 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
701 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
702 if (theOperation->isEditOperation()) {
703 // If it is editing of sketch then it means that plane is already defined
704 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
705 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
707 aDisplayer->updateViewer();
710 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
712 myIsMouseOverWindow = false;
713 myIsConstraintsShown = true;
714 // the objects activated in the sketch should be deactivated in order to do not have the specific
715 // sketch selection mode activated on objects in neutral point of the application(no started operation)
716 activateObjectsInSketchMode(false);
718 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
719 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
721 DataPtr aData = myCurrentSketch->data();
722 if ((!aData) || (!aData->isValid())) {
723 // The sketch was aborted
724 myCurrentSketch = CompositeFeaturePtr();
725 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
727 // Erase all sketcher objects
728 QStringList aSketchIds = sketchOperationIdList();
729 QObjectPtrList aObjects = aDisplayer->displayedObjects();
730 foreach (ObjectPtr aObj, aObjects) {
731 DataPtr aObjData = aObj->data();
732 if ((!aObjData) || (!aObjData->isValid()))
733 aDisplayer->erase(aObj);
737 // Hide all sketcher sub-Objects
738 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
739 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
740 std::list<ResultPtr> aResults = aFeature->results();
741 std::list<ResultPtr>::const_iterator aIt;
742 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
743 aDisplayer->erase((*aIt), false);
745 aDisplayer->erase(aFeature, false);
747 // Display sketcher result
748 std::list<ResultPtr> aResults = myCurrentSketch->results();
749 std::list<ResultPtr>::const_iterator aIt;
750 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
751 aDisplayer->display((*aIt), false);
753 aDisplayer->display(myCurrentSketch);
755 myCurrentSketch = CompositeFeaturePtr();
756 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
757 aDisplayer->updateViewer();
760 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
762 if (constraintsIdList().contains(theOperation->id())) {
763 // Show constraints if a constraint was created
764 onShowConstraintsToggle(true);
766 connectToPropertyPanel(true);
769 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
771 connectToPropertyPanel(false);
772 myIsPropertyPanelValueChanged = false;
773 myIsMouseOverViewProcessed = true;
775 // the sketch objects selection should be activated in order to select any sketch
777 activateObjectsInSketchMode(true);
780 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
782 if (isNestedCreateOperation(theOperation))
783 visualizeFeature(theOperation, true);
787 bool PartSet_SketcherMgr::canUndo() const
789 return isNestedCreateOperation(getCurrentOperation());
792 bool PartSet_SketcherMgr::canRedo() const
794 return isNestedCreateOperation(getCurrentOperation());
797 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
799 bool aCanDisplay = true;
801 bool aHasActiveSketch = activeSketch().get() != NULL;
802 if (aHasActiveSketch) {
803 // 1. the sketch feature should not be displayed during the sketch active operation
804 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
805 // nested features can be visualized
806 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
807 if (aFeature.get() != NULL && aFeature == activeSketch())
810 else { // there are no an active sketch
811 // 2. sketch sub-features should not be visualized if the sketch operation is not active
812 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
813 if (aFeature.get() != NULL) {
814 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
815 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
816 if (aSketchFeature.get())
821 // 3. the method should not filter the objects, which are not related to the current operation.
822 // The object is filtered just if it is a current operation feature or this feature result
823 bool isObjectFound = false;
824 ModuleBase_Operation* anOperation = getCurrentOperation();
826 FeaturePtr aFeature = anOperation->feature();
827 if (aFeature.get()) {
828 std::list<ResultPtr> aResults = aFeature->results();
829 if (theObject == aFeature)
830 isObjectFound = true;
832 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
833 for (; anIt != aLast; anIt++) {
834 isObjectFound = *anIt == theObject;
842 // 4. For created nested feature operation do not display the created feature if
843 // the mouse curstor leaves the OCC window.
844 // The correction cases, which ignores this condition:
845 // a. the property panel values modification
846 // b. the popup menu activated
847 // c. widget editor control
848 #ifndef DEBUG_DO_NOT_BY_ENTER
849 if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
850 ModuleBase_Operation* aOperation = getCurrentOperation();
851 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
852 ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
853 ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
854 // the active widget editor should not influence here. The presentation should be visible always
855 // when this widget is active.
856 if (!anEditorWdg && !myIsPopupMenuActive) {
857 // during a nested create operation, the feature is redisplayed only if the mouse over view
858 // of there was a value modified in the property panel after the mouse left the view
859 aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
866 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
868 bool isFoundObject = false;
870 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
871 if (anObjectFeature.get()) {
872 int aSize = myCurrentSketch->numberOfSubs();
873 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
874 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
875 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
878 return isFoundObject;
881 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
883 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
885 // after the plane is selected in the sketch, the sketch selection should be activated
886 // it can not be performed in the sketch label widget because, we don't need to switch off
887 // the selection by any label deactivation, but need to switch it off by stop the sketch
888 activateObjectsInSketchMode(true);
891 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
892 const FeaturePtr& theSketch,
893 ModuleBase_IWorkshop* theWorkshop,
894 FeatureToSelectionMap& theSelection)
896 if (theFeature.get() == NULL)
899 std::set<AttributePtr> aSelectedAttributes;
900 std::set<ResultPtr> aSelectedResults;
902 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
903 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
904 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
905 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
907 std::list<ResultPtr> aResults = theFeature->results();
908 std::list<ResultPtr>::const_iterator aIt;
909 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
911 ResultPtr aResult = *aIt;
912 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
913 if (aAISObj.get() == NULL)
915 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
916 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
918 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
919 aContext->SelectedOwner());
920 if (aBRepOwner.IsNull())
922 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
923 aBRepOwner->Selectable());
927 if (aBRepOwner->HasShape()) {
928 const TopoDS_Shape& aShape = aBRepOwner->Shape();
929 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
930 if (aShapeType == TopAbs_VERTEX) {
931 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
933 if (aPntAttr.get() != NULL)
934 aSelectedAttributes.insert(aPntAttr);
936 else if (aShapeType == TopAbs_EDGE &&
937 aSelectedResults.find(aResult) == aSelectedResults.end()) {
938 aSelectedResults.insert(aResult);
943 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
946 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
947 const FeaturePtr& theSketch,
948 ModuleBase_IWorkshop* theWorkshop,
949 const FeatureToSelectionMap& theSelection,
950 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
952 if (theFeature.get() == NULL)
955 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
956 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
957 std::set<ResultPtr> aSelectedResults = anIt.value().second;
959 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
960 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
961 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
962 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
964 // 1. found the feature's owners. Check the AIS objects of the constructions
965 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
966 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
967 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
969 SelectMgr_IndexedMapOfOwner aSelectedOwners;
970 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
971 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
972 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
973 if (!anOwner.IsNull())
974 anOwnersToSelect.Add(anOwner);
978 // 2. found the feature results's owners
979 std::list<ResultPtr> aResults = theFeature->results();
980 std::list<ResultPtr>::const_iterator aIt;
981 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
983 ResultPtr aResult = *aIt;
984 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
985 if (aAISObj.get() == NULL)
987 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
989 SelectMgr_IndexedMapOfOwner aSelectedOwners;
990 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
991 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
992 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
993 if ( anOwner.IsNull() || !anOwner->HasShape() )
995 const TopoDS_Shape& aShape = anOwner->Shape();
996 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
997 if (aShapeType == TopAbs_VERTEX) {
998 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
999 if (aPntAttr.get() != NULL &&
1000 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1001 anOwnersToSelect.Add(anOwner);
1004 else if (aShapeType == TopAbs_EDGE) {
1005 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1006 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1007 anOwnersToSelect.FindIndex(anOwner) <= 0)
1008 anOwnersToSelect.Add(anOwner);
1014 void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
1016 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1017 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1018 XGUI_Workshop* aWorkshop = aConnector->workshop();
1019 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
1020 if (aPropertyPanel) {
1021 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
1022 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
1024 connect(aWidget, SIGNAL(beforeValuesChanged()),
1025 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1026 connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1027 connect(aWidget, SIGNAL(afterValuesChanged()),
1028 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1031 disconnect(aWidget, SIGNAL(beforeValuesChanged()),
1032 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1033 disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1034 disconnect(aWidget, SIGNAL(afterValuesChanged()),
1035 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1041 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1043 return myModule->workshop()->currentOperation();
1046 void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
1047 const bool isToDisplay)
1049 #ifdef DEBUG_DO_NOT_BY_ENTER
1053 if (!theOperation || theOperation->isEditOperation())
1056 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1057 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1058 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1060 // 1. change visibility of the object itself, here the presentable object is processed,
1061 // e.g. constraints features
1062 FeaturePtr aFeature = theOperation->feature();
1063 std::list<ResultPtr> aResults = aFeature->results();
1065 aDisplayer->display(aFeature, false);
1067 aDisplayer->erase(aFeature, false);
1069 // change visibility of the object results, e.g. non-constraint features
1070 std::list<ResultPtr>::const_iterator aIt;
1071 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1073 aDisplayer->display(*aIt, false);
1076 aDisplayer->erase(*aIt, false);
1079 aDisplayer->updateViewer();
1082 void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive)
1084 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1085 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1086 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1090 aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
1091 aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
1092 aModes.append(SketcherPrs_Tools::Sel_Constraint);
1093 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
1094 aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
1096 aDisplayer->activateObjects(aModes);
1099 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1101 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1102 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1103 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
1105 QMap<FeaturePtr, QList<AttributePtr> > aFeature2AttributeMap;
1106 if (theHighlightedOnly) {
1107 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1110 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1112 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
1113 fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch);
1116 // 1. it is necessary to save current selection in order to restore it after the features moving
1117 myCurrentSelection.clear();
1118 QMap<FeaturePtr, QList<AttributePtr> >::const_iterator anIt = aFeature2AttributeMap.begin(),
1119 aLast = aFeature2AttributeMap.end();
1120 for (; anIt != aLast; anIt++) {
1121 FeaturePtr aFeature = anIt.key();
1122 getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection);
1124 //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1127 void PartSet_SketcherMgr::restoreSelection()
1129 //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1130 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1131 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1132 FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
1133 aSLast = myCurrentSelection.end();
1134 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
1135 for (; aSIt != aSLast; aSIt++) {
1136 anOwnersToSelect.Clear();
1137 getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
1139 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
1143 void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
1145 if (myIsConstraintsShown == theOn)
1147 if (myCurrentSketch.get() == NULL)
1150 myIsConstraintsShown = theOn;
1152 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1153 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1154 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1156 const QStringList& aConstrIds = constraintsIdList();
1157 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
1158 FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
1159 if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
1160 if (myIsConstraintsShown)
1161 aDisplayer->display(aSubFeature, false);
1163 aDisplayer->erase(aSubFeature, false);
1166 aDisplayer->updateViewer();