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>
59 #include <SketchPlugin_MultiRotation.h>
60 #include <SketchPlugin_MultiTranslation.h>
62 #include <SketcherPrs_Tools.h>
64 #include <SelectMgr_IndexedMapOfOwner.hxx>
65 #include <StdSelect_BRepOwner.hxx>
67 //#include <AIS_DimensionSelectionMode.hxx>
68 #include <AIS_Shape.hxx>
70 #include <ModelAPI_Events.h>
71 #include <ModelAPI_Session.h>
73 #include <QMouseEvent>
74 #include <QApplication>
76 //#define DEBUG_DO_NOT_BY_ENTER
77 //#define DEBUG_MOUSE_OVER_WINDOW_FLAGS
79 /// Returns list of unique objects by sum of objects from List1 and List2
80 /*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
81 const QList<ModuleBase_ViewerPrs>& theList2)
83 QList<ModuleBase_ViewerPrs> aRes;
84 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
85 if (!aRes.contains(aPrs))
88 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
89 if (!aRes.contains(aPrs))
95 void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
96 QMap<FeaturePtr, QList<AttributePtr> >& theFeature2AttributeMap,
97 const FeaturePtr theSketch)
99 QList<ModuleBase_ViewerPrs> aRes;
101 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
102 aLast = theList.end();
103 for (; anIt != aLast; anIt++)
105 ModuleBase_ViewerPrs aPrs = *anIt;
106 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
107 if (aFeature.get() == NULL)
110 QList<AttributePtr> anAttributes;
111 if (theFeature2AttributeMap.contains(aFeature)) {
112 anAttributes = theFeature2AttributeMap[aFeature];
115 TopoDS_Shape aShape = aPrs.shape();
116 if (!aShape.IsNull()) {
117 if (aShape.ShapeType() == TopAbs_VERTEX) {
118 anAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
119 if (anAttr.get() != NULL && !anAttributes.contains(anAttr))
120 anAttributes.push_back(anAttr);
123 theFeature2AttributeMap[aFeature] = anAttributes;
130 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
131 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
132 myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
133 myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
134 myIsPopupMenuActive(false), myIsConstraintsShown(true)
136 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
137 ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
139 myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled();
141 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
142 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
144 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
145 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
147 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
148 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
150 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
151 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
153 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
154 XGUI_Workshop* aWorkshop = aConnector->workshop();
155 connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted()));
158 PartSet_SketcherMgr::~PartSet_SketcherMgr()
160 if (!myPlaneFilter.IsNull())
161 myPlaneFilter.Nullify();
164 void PartSet_SketcherMgr::onEnterViewPort()
166 // 1. if the mouse over window, update the next flag. Do not perform update visibility of
167 // created feature because it should be done in onMouseMove(). Some widgets watch
168 // the mouse move and use the cursor position to update own values. If the presentaion is
169 // redisplayed before this update, the feature presentation jumps from reset value to current.
170 myIsMouseOverWindow = true;
171 myIsPropertyPanelValueChanged = false;
172 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
173 qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
176 #ifdef DEBUG_DO_NOT_BY_ENTER
180 if (!isNestedCreateOperation(getCurrentOperation()))
182 // we need change displayed state of the current operation feature
183 // if the feature is presentable, e.g. distance construction. It has no results, so workshop does
184 // not accept a signal about the result created. Nothing is shown until mouse is moved out/in view
185 // port. If the isDisplayed flag is true, the presentable feature is displayed as soon as the
186 // presentation becomes valid and redisplay happens
187 ModuleBase_Operation* aOperation = getCurrentOperation();
189 FeaturePtr aFeature = aOperation->feature();
190 if (aFeature.get() && aFeature->data()->isValid()) {
191 visualizeFeature(aOperation, canDisplayObject(aFeature), false);
196 void PartSet_SketcherMgr::onLeaveViewPort()
198 myIsMouseOverViewProcessed = false;
199 myIsMouseOverWindow = false;
200 myIsPropertyPanelValueChanged = false;
201 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
202 qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
205 #ifdef DEBUG_DO_NOT_BY_ENTER
209 if (!isNestedCreateOperation(getCurrentOperation()))
211 // the method should be performed if the popup menu is called,
212 // the reset of the current widget should not happen
213 if (myIsPopupMenuActive)
216 // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
217 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
218 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
219 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
220 // disable the viewer update in order to avoid visualization of redisplayed feature in viewer
221 // obtained after reset value
222 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
223 ModuleBase_Operation* aOperation = getCurrentOperation();
224 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
225 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
229 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
231 // hides the presentation of the current operation feature
232 //myIsPropertyPanelValueChanged = false;
233 // the feature is to be erased here, but it is correct to call canDisplayObject because
234 // there can be additional check (e.g. editor widget in distance constraint)
235 FeaturePtr aFeature = getCurrentOperation()->feature();
236 visualizeFeature(aOperation, canDisplayObject(aFeature));
239 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
241 if (isNestedCreateOperation(getCurrentOperation()))
243 // it is necessary to save current selection in order to restore it after the values are modifed
246 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
247 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
248 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
249 myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
252 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
254 if (isNestedCreateOperation(getCurrentOperation()))
256 // it is necessary to restore current selection in order to restore it after the values are modified
258 myCurrentSelection.clear();
260 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
261 // viewer happens by deselect/select the modified objects. The flag should be restored after
262 // the selection processing. The update viewer should be also called.
263 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
264 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
265 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
266 aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
267 aDisplayer->updateViewer();
270 void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
272 if (!isNestedCreateOperation(getCurrentOperation()))
275 // visualize the current operation feature
276 myIsPropertyPanelValueChanged = true;
277 ModuleBase_Operation* aOperation = getCurrentOperation();
278 // the feature is to be erased here, but it is correct to call canDisplayObject because
279 // there can be additional check (e.g. editor widget in distance constraint)
280 FeaturePtr aFeature = getCurrentOperation()->feature();
281 visualizeFeature(aOperation, canDisplayObject(aFeature));
284 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
286 get2dPoint(theWnd, theEvent, myClickedPoint);
288 if (!(theEvent->buttons() & Qt::LeftButton))
291 // Clear dragging mode
292 myIsDragging = false;
294 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
295 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
296 if (!aViewer->canDragByMouse())
299 ModuleBase_Operation* aOperation = getCurrentOperation();
300 if (aOperation && aOperation->isEditOperation()) {
301 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
302 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
303 // If the current widget is a selector, do do nothing, it processes the mouse press
304 if(aActiveWgt && aActiveWgt->isViewerSelector()) {
309 // Use only for sketch operations
310 if (aOperation && myCurrentSketch) {
311 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
314 bool isSketcher = isSketchOperation(aOperation);
315 bool isSketchOpe = isNestedSketchOperation(aOperation);
317 // Avoid non-sketch operations
318 if ((!isSketchOpe) && (!isSketcher))
321 bool isEditing = aOperation->isEditOperation();
323 // Ignore creation sketch operation
324 if ((!isSketcher) && (!isEditing))
327 // MoveTo in order to highlight current object
328 aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
330 // Remember highlighted objects for editing
331 ModuleBase_ISelection* aSelect = aWorkshop->selection();
333 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
334 storeSelection(!aHasShift);
336 if (myCurrentSelection.empty()) {
337 if (isSketchOpe && (!isSketcher))
338 // commit previous operation
339 if (!aOperation->commit())
343 // Init flyout point for radius rotation
344 FeaturePtr aFeature = myCurrentSelection.begin().key();
348 get2dPoint(theWnd, theEvent, myCurrentPoint);
351 if (aFeature.get() != NULL) {
352 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
353 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
354 if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
355 DataPtr aData = aSPFeature->data();
356 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
357 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
358 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
359 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
362 } else if (isSketchOpe && isEditing) {
363 // If selected another object commit current result
364 aOperation->commit();
367 get2dPoint(theWnd, theEvent, myCurrentPoint);
370 // This is necessary in order to finalize previous operation
371 QApplication::processEvents();
377 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
379 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
380 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
381 if (!aViewer->canDragByMouse())
383 ModuleBase_Operation* aOp = getCurrentOperation();
385 if (isNestedSketchOperation(aOp)) {
386 get2dPoint(theWnd, theEvent, myClickedPoint);
388 // Only for sketcher operations
392 myCurrentSelection.clear();
393 // Reselect edited object
394 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
395 if (theEvent->modifiers() & Qt::ShiftModifier)
396 aViewer->AISContext()->ShiftSelect();
398 aViewer->AISContext()->Select();
404 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
405 myIsDragging = false;
408 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
410 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
411 myIsMouseOverViewProcessed = true;
412 // 1. perform the widget mouse move functionality and display the presentation
413 ModuleBase_Operation* aOperation = getCurrentOperation();
414 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
415 ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
416 // the mouse move should be processed in the widget, if it can in order to visualize correct
417 // presentation. These widgets correct the feature attribute according to the mouse position
418 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
420 aPoint2DWdg->onMouseMove(theWnd, theEvent);
422 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
425 aDistanceWdg->onMouseMove(theWnd, theEvent);
427 // the feature is to be erased here, but it is correct to call canDisplayObject because
428 // there can be additional check (e.g. editor widget in distance constraint)
429 FeaturePtr aFeature = getCurrentOperation()->feature();
430 visualizeFeature(aOperation, canDisplayObject(aFeature));
433 myClickedPoint.clear();
436 // 1. the current selection is saved in the mouse press method in order to restore it after moving
437 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
438 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
439 // deselected). This flag should be restored in the slot, processed the mouse release signal.
440 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
441 aViewer->enableSelection(false);
443 ModuleBase_Operation* aOperation = getCurrentOperation();
446 if (isSketchOperation(aOperation))
447 return; // No edit operation activated
449 Handle(V3d_View) aView = theWnd->v3dView();
450 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
452 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
453 double dX = aX - myCurrentPoint.myCurX;
454 double dY = aY - myCurrentPoint.myCurY;
456 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
457 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
458 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
459 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
460 // viewer happens by deselect/select the modified objects. The flag should be restored after
461 // the selection processing. The update viewer should be also called.
462 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
464 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
465 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
466 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
467 aLast = myCurrentSelection.end();
468 // 4. the features and attributes modification(move)
469 for (; anIt != aLast; anIt++) {
470 FeaturePtr aFeature = anIt.key();
472 std::set<AttributePtr> anAttributes = anIt.value().first;
473 // Process selection by attribute: the priority to the attribute
474 if (!anAttributes.empty()) {
475 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
476 anAttLast = anAttributes.end();
477 for (; anAttIt != anAttLast; anAttIt++) {
478 AttributePtr anAttr = *anAttIt;
479 if (anAttr.get() == NULL)
481 std::string aAttrId = anAttr->id();
482 DataPtr aData = aFeature->data();
483 if (aData->isValid()) {
484 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
485 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
486 if (aPoint.get() != NULL) {
487 bool isImmutable = aPoint->setImmutable(true);
488 aPoint->move(dX, dY);
489 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
490 aPoint->setImmutable(isImmutable);
495 // Process selection by feature
496 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
497 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
498 if (aSketchFeature) {
499 aSketchFeature->move(dX, dY);
500 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
504 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
505 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
507 // 5. it is necessary to save current selection in order to restore it after the features moving
509 // 6. restore the update viewer flag and call this update
510 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
511 aDisplayer->updateViewer();
514 myCurrentPoint.setValue(aX, aY);
518 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
520 ModuleBase_Operation* aOperation = getCurrentOperation();
521 if (aOperation && aOperation->isEditOperation()) {
522 std::string aId = aOperation->id().toStdString();
523 if (isDistanceOperation(aOperation))
525 // Activate dimension value editing on double click
526 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
527 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
528 // Find corresponded widget to activate value editing
529 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
530 if (aWgt->attributeID() == "ConstraintValue") {
539 void PartSet_SketcherMgr::onApplicationStarted()
541 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
542 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
543 XGUI_Workshop* aWorkshop = aConnector->workshop();
544 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
545 if (aPropertyPanel) {
546 connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
547 this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
550 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
551 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
552 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
554 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
555 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
556 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
559 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
561 if (!myClickedPoint.myIsInitialized)
564 ModuleBase_Operation* aOperation = getCurrentOperation();
565 // the distance constraint feature should not use the clickedd point
566 // this is workaround in order to don't throw down the flyout point value,
567 // set by execute() method of these type of features
568 if (isDistanceOperation(aOperation))
571 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
573 aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
577 void PartSet_SketcherMgr::onBeforeContextMenu()
579 myIsPopupMenuActive = true;
582 void PartSet_SketcherMgr::onAfterContextMenu()
584 myIsPopupMenuActive = false;
587 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
590 Handle(V3d_View) aView = theWnd->v3dView();
591 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
593 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
594 thePoint.setValue(aX, anY);
597 void PartSet_SketcherMgr::launchEditing()
599 if (!myCurrentSelection.empty()) {
600 FeaturePtr aFeature = myCurrentSelection.begin().key();
601 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
602 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
604 myModule->editFeature(aSPFeature);
610 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
612 static QStringList aIds;
613 if (aIds.size() == 0) {
614 aIds << SketchPlugin_Line::ID().c_str();
615 aIds << SketchPlugin_Point::ID().c_str();
616 aIds << SketchPlugin_Arc::ID().c_str();
617 aIds << SketchPlugin_Circle::ID().c_str();
618 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
619 aIds.append(constraintsIdList());
624 const QStringList& PartSet_SketcherMgr::constraintsIdList()
626 static QStringList aIds;
627 if (aIds.size() == 0) {
628 aIds << SketchPlugin_ConstraintLength::ID().c_str();
629 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
630 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
631 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
632 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
633 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
634 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
635 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
636 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
637 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
638 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
639 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
640 aIds << SketchPlugin_MultiRotation::ID().c_str();
641 aIds << SketchPlugin_MultiTranslation::ID().c_str();
646 void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
650 theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
651 theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
652 theModes.append(SketcherPrs_Tools::Sel_Constraint);
653 theModes.append(TopAbs_VERTEX);
654 theModes.append(TopAbs_EDGE);
657 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
659 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
662 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
664 return theOperation &&
665 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
668 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
670 return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
673 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
675 return (theId == SketchPlugin_Line::ID()) ||
676 (theId == SketchPlugin_Point::ID()) ||
677 (theId == SketchPlugin_Arc::ID()) ||
678 (theId == SketchPlugin_Circle::ID());
681 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
683 std::string aId = theOperation ? theOperation->id().toStdString() : "";
685 return (aId == SketchPlugin_ConstraintLength::ID()) ||
686 (aId == SketchPlugin_ConstraintDistance::ID()) ||
687 (aId == SketchPlugin_ConstraintRadius::ID());
690 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
692 // Display all sketcher sub-Objects
693 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
694 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
696 // Hide sketcher result
697 std::list<ResultPtr> aResults = myCurrentSketch->results();
698 std::list<ResultPtr>::const_iterator aIt;
699 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
700 (*aIt)->setDisplayed(false);
702 myCurrentSketch->setDisplayed(false);
704 // Display sketcher objects
705 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
706 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
707 std::list<ResultPtr> aResults = aFeature->results();
708 std::list<ResultPtr>::const_iterator aIt;
709 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
710 (*aIt)->setDisplayed(true);
712 aFeature->setDisplayed(true);
715 if (myPlaneFilter.IsNull())
716 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
718 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
719 if (theOperation->isEditOperation()) {
720 // If it is editing of sketch then it means that plane is already defined
721 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
723 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
725 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
726 // all sketch objects should be activated in the sketch selection modes by edit operation start
727 // in case of creation operation, there is an active widget, which activates own selection mode
728 if (theOperation->isEditOperation())
729 aConnector->activateModuleSelectionModes();
732 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
734 myIsMouseOverWindow = false;
735 myIsConstraintsShown = true;
736 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
737 qDebug(QString("stopSketch: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
739 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
741 DataPtr aData = myCurrentSketch->data();
742 if (!aData->isValid()) {
743 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
744 // The sketch was aborted
745 myCurrentSketch = CompositeFeaturePtr();
746 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
748 // Erase all sketcher objects
749 QStringList aSketchIds = sketchOperationIdList();
750 QObjectPtrList aObjects = aDisplayer->displayedObjects();
751 foreach (ObjectPtr aObj, aObjects) {
752 DataPtr aObjData = aObj->data();
753 if (!aObjData->isValid())
754 aObj->setDisplayed(false);
758 // Hide all sketcher sub-Objects
759 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
760 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
761 std::list<ResultPtr> aResults = aFeature->results();
762 std::list<ResultPtr>::const_iterator aIt;
763 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
764 (*aIt)->setDisplayed(false);
766 aFeature->setDisplayed(false);
768 // Display sketcher result
769 std::list<ResultPtr> aResults = myCurrentSketch->results();
770 std::list<ResultPtr>::const_iterator aIt;
771 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
772 (*aIt)->setDisplayed(true);
774 myCurrentSketch->setDisplayed(true);
776 myCurrentSketch = CompositeFeaturePtr();
777 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
778 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
780 // restore the module selection modes, which were changed on startSketch
781 aConnector->activateModuleSelectionModes();
784 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
786 if (constraintsIdList().contains(theOperation->id())) {
787 // Show constraints if a constraint was created
788 onShowConstraintsToggle(true);
790 connectToPropertyPanel(true);
793 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
795 connectToPropertyPanel(false);
796 myIsPropertyPanelValueChanged = false;
797 myIsMouseOverViewProcessed = true;
800 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
802 if (isNestedCreateOperation(theOperation)) {
803 FeaturePtr aFeature = theOperation->feature();
804 // it is necessary to check the the feature data validity because
805 // some kind of features are removed by an operation commit(the macro state of a feature)
806 if (aFeature.get() && aFeature->data()->isValid()) {
807 visualizeFeature(theOperation, true);
812 bool PartSet_SketcherMgr::canUndo() const
814 return isNestedCreateOperation(getCurrentOperation());
817 bool PartSet_SketcherMgr::canRedo() const
819 return isNestedCreateOperation(getCurrentOperation());
822 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
824 bool aCanDisplay = true;
826 bool aHasActiveSketch = activeSketch().get() != NULL;
827 if (aHasActiveSketch) {
828 // 1. the sketch feature should not be displayed during the sketch active operation
829 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
830 // nested features can be visualized
831 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
832 if (aFeature.get() != NULL && aFeature == activeSketch()) {
836 else { // there are no an active sketch
837 // 2. sketch sub-features should not be visualized if the sketch operation is not active
838 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
839 if (aFeature.get() != NULL) {
840 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
841 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
842 if (aSketchFeature.get()) {
848 // 3. the method should not filter the objects, which are not related to the current operation.
849 // The object is filtered just if it is a current operation feature or this feature result
850 bool isObjectFound = false;
851 ModuleBase_Operation* anOperation = getCurrentOperation();
853 FeaturePtr aFeature = anOperation->feature();
854 if (aFeature.get()) {
855 std::list<ResultPtr> aResults = aFeature->results();
856 if (theObject == aFeature)
857 isObjectFound = true;
859 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
860 for (; anIt != aLast; anIt++) {
861 isObjectFound = *anIt == theObject;
869 // 4. For created nested feature operation do not display the created feature if
870 // the mouse curstor leaves the OCC window.
871 // The correction cases, which ignores this condition:
872 // a. the property panel values modification
873 // b. the popup menu activated
874 // c. widget editor control
875 #ifndef DEBUG_DO_NOT_BY_ENTER
876 if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
877 ModuleBase_Operation* aOperation = getCurrentOperation();
878 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
879 ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
880 ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
881 // the active widget editor should not influence here. The presentation should be visible always
882 // when this widget is active.
883 if (!anEditorWdg && !myIsPopupMenuActive) {
884 // during a nested create operation, the feature is redisplayed only if the mouse over view
885 // of there was a value modified in the property panel after the mouse left the view
886 aCanDisplay = canDisplayCurrentCreatedFeature();
893 bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
895 return myIsPropertyPanelValueChanged || myIsMouseOverWindow;
896 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
897 qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
901 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
903 bool isFoundObject = false;
905 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
906 if (anObjectFeature.get()) {
907 int aSize = myCurrentSketch->numberOfSubs();
908 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
909 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
910 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
913 return isFoundObject;
916 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
918 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
921 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
922 const FeaturePtr& theSketch,
923 ModuleBase_IWorkshop* theWorkshop,
924 FeatureToSelectionMap& theSelection)
926 if (theFeature.get() == NULL)
929 std::set<AttributePtr> aSelectedAttributes;
930 std::set<ResultPtr> aSelectedResults;
932 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
933 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
934 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
935 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
937 std::list<ResultPtr> aResults = theFeature->results();
938 std::list<ResultPtr>::const_iterator aIt;
939 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
941 ResultPtr aResult = *aIt;
942 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
943 if (aAISObj.get() == NULL)
945 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
946 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
948 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
949 aContext->SelectedOwner());
950 if (aBRepOwner.IsNull())
952 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
953 aBRepOwner->Selectable());
957 if (aBRepOwner->HasShape()) {
958 const TopoDS_Shape& aShape = aBRepOwner->Shape();
959 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
960 if (aShapeType == TopAbs_VERTEX) {
961 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
963 if (aPntAttr.get() != NULL)
964 aSelectedAttributes.insert(aPntAttr);
966 else if (aShapeType == TopAbs_EDGE &&
967 aSelectedResults.find(aResult) == aSelectedResults.end()) {
968 aSelectedResults.insert(aResult);
973 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
976 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
977 const FeaturePtr& theSketch,
978 ModuleBase_IWorkshop* theWorkshop,
979 const FeatureToSelectionMap& theSelection,
980 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
982 if (theFeature.get() == NULL)
985 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
986 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
987 std::set<ResultPtr> aSelectedResults = anIt.value().second;
989 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
990 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
991 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
992 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
994 // 1. found the feature's owners. Check the AIS objects of the constructions
995 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
996 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
997 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
999 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1000 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1001 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
1002 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
1003 if (!anOwner.IsNull())
1004 anOwnersToSelect.Add(anOwner);
1008 // 2. found the feature results's owners
1009 std::list<ResultPtr> aResults = theFeature->results();
1010 std::list<ResultPtr>::const_iterator aIt;
1011 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
1013 ResultPtr aResult = *aIt;
1014 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
1015 if (aAISObj.get() == NULL)
1017 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1019 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1020 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1021 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
1022 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
1023 if ( anOwner.IsNull() || !anOwner->HasShape() )
1025 const TopoDS_Shape& aShape = anOwner->Shape();
1026 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
1027 if (aShapeType == TopAbs_VERTEX) {
1028 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
1029 if (aPntAttr.get() != NULL &&
1030 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1031 anOwnersToSelect.Add(anOwner);
1034 else if (aShapeType == TopAbs_EDGE) {
1035 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1036 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1037 anOwnersToSelect.FindIndex(anOwner) <= 0)
1038 anOwnersToSelect.Add(anOwner);
1044 void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
1046 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1047 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1048 XGUI_Workshop* aWorkshop = aConnector->workshop();
1049 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
1050 if (aPropertyPanel) {
1051 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
1052 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
1054 connect(aWidget, SIGNAL(beforeValuesChanged()),
1055 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1056 connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1057 connect(aWidget, SIGNAL(afterValuesChanged()),
1058 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1061 disconnect(aWidget, SIGNAL(beforeValuesChanged()),
1062 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1063 disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1064 disconnect(aWidget, SIGNAL(afterValuesChanged()),
1065 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1071 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1073 return myModule->workshop()->currentOperation();
1076 void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
1077 const bool isToDisplay,
1078 const bool isFlushRedisplay)
1080 #ifdef DEBUG_DO_NOT_BY_ENTER
1084 if (!theOperation || theOperation->isEditOperation())
1087 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1088 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1090 // 1. change visibility of the object itself, here the presentable object is processed,
1091 // e.g. constraints features
1092 FeaturePtr aFeature = theOperation->feature();
1093 std::list<ResultPtr> aResults = aFeature->results();
1095 aFeature->setDisplayed(true);
1097 aFeature->setDisplayed(false);
1099 // change visibility of the object results, e.g. non-constraint features
1100 std::list<ResultPtr>::const_iterator aIt;
1101 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1103 (*aIt)->setDisplayed(true);
1106 (*aIt)->setDisplayed(false);
1109 if (isFlushRedisplay)
1110 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1113 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1115 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1116 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1117 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
1119 QMap<FeaturePtr, QList<AttributePtr> > aFeature2AttributeMap;
1120 if (theHighlightedOnly) {
1121 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1124 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1126 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
1127 fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch);
1130 // 1. it is necessary to save current selection in order to restore it after the features moving
1131 myCurrentSelection.clear();
1132 QMap<FeaturePtr, QList<AttributePtr> >::const_iterator anIt = aFeature2AttributeMap.begin(),
1133 aLast = aFeature2AttributeMap.end();
1134 for (; anIt != aLast; anIt++) {
1135 FeaturePtr aFeature = anIt.key();
1136 getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection);
1138 //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1141 void PartSet_SketcherMgr::restoreSelection()
1143 //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1144 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1145 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1146 FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
1147 aSLast = myCurrentSelection.end();
1148 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
1149 for (; aSIt != aSLast; aSIt++) {
1150 anOwnersToSelect.Clear();
1151 getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
1153 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
1157 void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
1159 if (myIsConstraintsShown == theOn)
1161 if (myCurrentSketch.get() == NULL)
1164 myIsConstraintsShown = theOn;
1166 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1167 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1169 const QStringList& aConstrIds = constraintsIdList();
1170 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
1171 FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
1172 if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
1173 if (myIsConstraintsShown)
1174 aSubFeature->setDisplayed(true);
1176 aSubFeature->setDisplayed(false);
1179 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1182 QString PartSet_SketcherMgr::mouseOverWindowFlagsInfo() const
1184 return QString("myIsPropertyPanelValueChanged = %1, myIsMouseOverWindow = %2")
1185 .arg(myIsPropertyPanelValueChanged).arg(myIsMouseOverWindow);