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 <ModuleBase_IViewer.h>
28 #include <ModuleBase_IWorkshop.h>
29 #include <ModuleBase_IViewWindow.h>
30 #include <ModuleBase_Operation.h>
31 #include <ModuleBase_ISelection.h>
32 #include <ModuleBase_IPropertyPanel.h>
33 #include <ModuleBase_Operation.h>
35 #include <GeomDataAPI_Point2D.h>
37 #include <Events_Loop.h>
39 #include <SketchPlugin_Line.h>
40 #include <SketchPlugin_Sketch.h>
41 #include <SketchPlugin_Point.h>
42 #include <SketchPlugin_Arc.h>
43 #include <SketchPlugin_Circle.h>
44 #include <SketchPlugin_ConstraintLength.h>
45 #include <SketchPlugin_ConstraintDistance.h>
46 #include <SketchPlugin_ConstraintParallel.h>
47 #include <SketchPlugin_ConstraintPerpendicular.h>
48 #include <SketchPlugin_ConstraintRadius.h>
49 #include <SketchPlugin_ConstraintRigid.h>
50 #include <SketchPlugin_ConstraintHorizontal.h>
51 #include <SketchPlugin_ConstraintVertical.h>
52 #include <SketchPlugin_ConstraintEqual.h>
53 #include <SketchPlugin_ConstraintTangent.h>
54 #include <SketchPlugin_ConstraintCoincidence.h>
55 #include <SketchPlugin_ConstraintFillet.h>
56 #include <SketchPlugin_ConstraintMirror.h>
57 #include <SketchPlugin_MultiRotation.h>
58 #include <SketchPlugin_MultiTranslation.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
75 //#define DEBUG_MOUSE_OVER_WINDOW_FLAGS
77 /// Returns list of unique objects by sum of objects from List1 and List2
78 /*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
79 const QList<ModuleBase_ViewerPrs>& theList2)
81 QList<ModuleBase_ViewerPrs> aRes;
82 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
83 if (!aRes.contains(aPrs))
86 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
87 if (!aRes.contains(aPrs))
93 void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
94 QMap<FeaturePtr, QList<AttributePtr> >& theFeature2AttributeMap,
95 const FeaturePtr theSketch)
97 QList<ModuleBase_ViewerPrs> aRes;
99 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
100 aLast = theList.end();
101 for (; anIt != aLast; anIt++)
103 ModuleBase_ViewerPrs aPrs = *anIt;
104 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
105 if (aFeature.get() == NULL)
108 QList<AttributePtr> anAttributes;
109 if (theFeature2AttributeMap.contains(aFeature)) {
110 anAttributes = theFeature2AttributeMap[aFeature];
113 TopoDS_Shape aShape = aPrs.shape();
114 if (!aShape.IsNull()) {
115 if (aShape.ShapeType() == TopAbs_VERTEX) {
116 anAttr = PartSet_Tools::findAttributeBy2dPoint(aFeature, aShape, theSketch);
117 if (anAttr.get() != NULL && !anAttributes.contains(anAttr))
118 anAttributes.push_back(anAttr);
121 theFeature2AttributeMap[aFeature] = anAttributes;
128 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
129 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
130 myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
131 myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
132 myIsPopupMenuActive(false), myIsConstraintsShown(true)
134 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
135 ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
137 myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled();
139 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
140 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
142 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
143 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
145 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
146 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
148 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
149 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
151 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
152 XGUI_Workshop* aWorkshop = aConnector->workshop();
153 connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted()));
156 PartSet_SketcherMgr::~PartSet_SketcherMgr()
158 if (!myPlaneFilter.IsNull())
159 myPlaneFilter.Nullify();
160 if (!myFilterInfinite.IsNull())
161 myFilterInfinite.Nullify();
165 void PartSet_SketcherMgr::onEnterViewPort()
167 // 1. if the mouse over window, update the next flag. Do not perform update visibility of
168 // created feature because it should be done in onMouseMove(). Some widgets watch
169 // the mouse move and use the cursor position to update own values. If the presentaion is
170 // redisplayed before this update, the feature presentation jumps from reset value to current.
171 myIsMouseOverWindow = true;
172 myIsPropertyPanelValueChanged = false;
173 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
174 qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
177 #ifdef DEBUG_DO_NOT_BY_ENTER
181 if (!isNestedCreateOperation(getCurrentOperation()))
183 // we need change displayed state of the current operation feature
184 // if the feature is presentable, e.g. distance construction. It has no results, so workshop does
185 // not accept a signal about the result created. Nothing is shown until mouse is moved out/in view
186 // port. If the isDisplayed flag is true, the presentable feature is displayed as soon as the
187 // presentation becomes valid and redisplay happens
188 ModuleBase_Operation* aOperation = getCurrentOperation();
190 FeaturePtr aFeature = aOperation->feature();
191 if (aFeature.get() && aFeature->data()->isValid()) {
192 visualizeFeature(aOperation, canDisplayObject(aFeature), false);
197 void PartSet_SketcherMgr::onLeaveViewPort()
199 myIsMouseOverViewProcessed = false;
200 myIsMouseOverWindow = false;
201 myIsPropertyPanelValueChanged = false;
202 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
203 qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
206 #ifdef DEBUG_DO_NOT_BY_ENTER
210 if (!isNestedCreateOperation(getCurrentOperation()))
212 // the method should be performed if the popup menu is called,
213 // the reset of the current widget should not happen
214 if (myIsPopupMenuActive)
217 // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
218 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
219 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
220 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
221 // disable the viewer update in order to avoid visualization of redisplayed feature in viewer
222 // obtained after reset value
223 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
224 ModuleBase_Operation* aOperation = getCurrentOperation();
225 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
226 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
230 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
232 // hides the presentation of the current operation feature
233 //myIsPropertyPanelValueChanged = false;
234 // the feature is to be erased here, but it is correct to call canDisplayObject because
235 // there can be additional check (e.g. editor widget in distance constraint)
236 FeaturePtr aFeature = getCurrentOperation()->feature();
237 visualizeFeature(aOperation, canDisplayObject(aFeature));
240 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
242 if (isNestedCreateOperation(getCurrentOperation()))
244 // it is necessary to save current selection in order to restore it after the values are modifed
247 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
248 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
249 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
250 myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
253 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
255 if (isNestedCreateOperation(getCurrentOperation()))
257 // it is necessary to restore current selection in order to restore it after the values are modified
259 myCurrentSelection.clear();
261 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
262 // viewer happens by deselect/select the modified objects. The flag should be restored after
263 // the selection processing. The update viewer should be also called.
264 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
265 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
266 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
267 aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
268 aDisplayer->updateViewer();
271 void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
273 if (!isNestedCreateOperation(getCurrentOperation()))
276 // visualize the current operation feature
277 myIsPropertyPanelValueChanged = true;
278 ModuleBase_Operation* aOperation = getCurrentOperation();
279 // the feature is to be erased here, but it is correct to call canDisplayObject because
280 // there can be additional check (e.g. editor widget in distance constraint)
281 FeaturePtr aFeature = getCurrentOperation()->feature();
282 visualizeFeature(aOperation, canDisplayObject(aFeature));
285 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
287 get2dPoint(theWnd, theEvent, myClickedPoint);
289 if (!(theEvent->buttons() & Qt::LeftButton))
292 // Clear dragging mode
293 myIsDragging = false;
295 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
296 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
297 if (!aViewer->canDragByMouse())
300 ModuleBase_Operation* aOperation = getCurrentOperation();
301 if (aOperation && aOperation->isEditOperation()) {
302 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
303 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
304 // If the current widget is a selector, do nothing, it processes the mouse press
305 if(aActiveWgt && aActiveWgt->isViewerSelector()) {
310 // Use only for sketch operations
311 if (aOperation && myCurrentSketch) {
312 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
315 bool isSketcher = isSketchOperation(aOperation);
316 bool isSketchOpe = isNestedSketchOperation(aOperation);
318 // Avoid non-sketch operations
319 if ((!isSketchOpe) && (!isSketcher))
322 bool isEditing = aOperation->isEditOperation();
324 // Ignore creation sketch operation
325 if ((!isSketcher) && (!isEditing))
328 // MoveTo in order to highlight current object
329 aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
331 // Remember highlighted objects for editing
332 ModuleBase_ISelection* aSelect = aWorkshop->selection();
334 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
335 storeSelection(!aHasShift);
337 if (myCurrentSelection.empty()) {
338 if (isSketchOpe && (!isSketcher))
339 // commit previous operation
340 if (!aOperation->commit())
344 // Init flyout point for radius rotation
345 FeaturePtr aFeature = myCurrentSelection.begin().key();
349 get2dPoint(theWnd, theEvent, myCurrentPoint);
352 if (aFeature.get() != NULL) {
353 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
354 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
355 if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
356 DataPtr aData = aSPFeature->data();
357 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
358 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
359 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
360 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
363 } else if (isSketchOpe && isEditing) {
364 // If selected another object commit current result
365 aOperation->commit();
368 get2dPoint(theWnd, theEvent, myCurrentPoint);
371 // This is necessary in order to finalize previous operation
372 QApplication::processEvents();
378 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
380 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
381 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
382 if (!aViewer->canDragByMouse())
384 ModuleBase_Operation* aOp = getCurrentOperation();
386 if (isNestedSketchOperation(aOp)) {
387 get2dPoint(theWnd, theEvent, myClickedPoint);
389 // Only for sketcher operations
393 myCurrentSelection.clear();
394 // Reselect edited object
395 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
396 if (theEvent->modifiers() & Qt::ShiftModifier)
397 aViewer->AISContext()->ShiftSelect();
399 aViewer->AISContext()->Select();
405 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
406 myIsDragging = false;
409 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
411 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
412 myIsMouseOverViewProcessed = true;
413 // 1. perform the widget mouse move functionality and display the presentation
414 ModuleBase_Operation* aOperation = getCurrentOperation();
415 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
416 ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
417 // the mouse move should be processed in the widget, if it can in order to visualize correct
418 // presentation. These widgets correct the feature attribute according to the mouse position
419 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
421 aPoint2DWdg->onMouseMove(theWnd, theEvent);
423 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
426 aDistanceWdg->onMouseMove(theWnd, theEvent);
428 // the feature is to be erased here, but it is correct to call canDisplayObject because
429 // there can be additional check (e.g. editor widget in distance constraint)
430 FeaturePtr aFeature = getCurrentOperation()->feature();
431 visualizeFeature(aOperation, canDisplayObject(aFeature));
434 myClickedPoint.clear();
437 // 1. the current selection is saved in the mouse press method in order to restore it after moving
438 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
439 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
440 // deselected). This flag should be restored in the slot, processed the mouse release signal.
441 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
442 aViewer->enableSelection(false);
444 ModuleBase_Operation* aOperation = getCurrentOperation();
447 if (isSketchOperation(aOperation))
448 return; // No edit operation activated
450 Handle(V3d_View) aView = theWnd->v3dView();
451 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
453 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
454 double dX = aX - myCurrentPoint.myCurX;
455 double dY = aY - myCurrentPoint.myCurY;
457 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
458 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
459 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
460 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
461 // viewer happens by deselect/select the modified objects. The flag should be restored after
462 // the selection processing. The update viewer should be also called.
463 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
465 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
466 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
467 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
468 aLast = myCurrentSelection.end();
469 // 4. the features and attributes modification(move)
470 for (; anIt != aLast; anIt++) {
471 FeaturePtr aFeature = anIt.key();
473 std::set<AttributePtr> anAttributes = anIt.value().first;
474 // Process selection by attribute: the priority to the attribute
475 if (!anAttributes.empty()) {
476 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
477 anAttLast = anAttributes.end();
478 for (; anAttIt != anAttLast; anAttIt++) {
479 AttributePtr anAttr = *anAttIt;
480 if (anAttr.get() == NULL)
482 std::string aAttrId = anAttr->id();
483 DataPtr aData = aFeature->data();
484 if (aData->isValid()) {
485 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
486 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
487 if (aPoint.get() != NULL) {
488 bool isImmutable = aPoint->setImmutable(true);
489 aPoint->move(dX, dY);
490 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
491 aPoint->setImmutable(isImmutable);
496 // Process selection by feature
497 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
498 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
499 if (aSketchFeature) {
500 aSketchFeature->move(dX, dY);
501 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
505 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
506 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
508 // 5. it is necessary to save current selection in order to restore it after the features moving
510 // 6. restore the update viewer flag and call this update
511 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
512 aDisplayer->updateViewer();
515 myCurrentPoint.setValue(aX, aY);
519 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
521 ModuleBase_Operation* aOperation = getCurrentOperation();
522 if (aOperation && aOperation->isEditOperation()) {
523 std::string aId = aOperation->id().toStdString();
524 if (isDistanceOperation(aOperation))
526 // Activate dimension value editing on double click
527 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
528 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
529 // Find corresponded widget to activate value editing
530 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
531 if (aWgt->attributeID() == "ConstraintValue") {
540 void PartSet_SketcherMgr::onApplicationStarted()
542 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
543 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
544 XGUI_Workshop* aWorkshop = aConnector->workshop();
545 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
546 if (aPropertyPanel) {
547 connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
548 this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
551 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
552 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
553 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
555 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
556 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
557 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
560 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
562 if (!myClickedPoint.myIsInitialized)
565 ModuleBase_Operation* aOperation = getCurrentOperation();
566 // the distance constraint feature should not use the clickedd point
567 // this is workaround in order to don't throw down the flyout point value,
568 // set by execute() method of these type of features
569 if (isDistanceOperation(aOperation))
572 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
574 aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
578 void PartSet_SketcherMgr::onBeforeContextMenu()
580 myIsPopupMenuActive = true;
583 void PartSet_SketcherMgr::onAfterContextMenu()
585 myIsPopupMenuActive = false;
588 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
591 Handle(V3d_View) aView = theWnd->v3dView();
592 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
594 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
595 thePoint.setValue(aX, anY);
598 void PartSet_SketcherMgr::launchEditing()
600 if (!myCurrentSelection.empty()) {
601 FeaturePtr aFeature = myCurrentSelection.begin().key();
602 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
603 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
605 myModule->editFeature(aSPFeature);
611 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
613 static QStringList aIds;
614 if (aIds.size() == 0) {
615 aIds << SketchPlugin_Line::ID().c_str();
616 aIds << SketchPlugin_Point::ID().c_str();
617 aIds << SketchPlugin_Arc::ID().c_str();
618 aIds << SketchPlugin_Circle::ID().c_str();
619 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
620 aIds.append(constraintsIdList());
625 const QStringList& PartSet_SketcherMgr::constraintsIdList()
627 static QStringList aIds;
628 if (aIds.size() == 0) {
629 aIds << SketchPlugin_ConstraintLength::ID().c_str();
630 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
631 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
632 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
633 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
634 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
635 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
636 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
637 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
638 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
639 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
640 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
641 aIds << SketchPlugin_MultiRotation::ID().c_str();
642 aIds << SketchPlugin_MultiTranslation::ID().c_str();
647 void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
651 theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
652 theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
653 theModes.append(SketcherPrs_Tools::Sel_Constraint);
654 theModes.append(TopAbs_VERTEX);
655 theModes.append(TopAbs_EDGE);
658 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
660 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
663 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
665 return theOperation &&
666 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
669 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
671 return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
674 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
676 return (theId == SketchPlugin_Line::ID()) ||
677 (theId == SketchPlugin_Point::ID()) ||
678 (theId == SketchPlugin_Arc::ID()) ||
679 (theId == SketchPlugin_Circle::ID());
682 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
684 std::string aId = theOperation ? theOperation->id().toStdString() : "";
686 return (aId == SketchPlugin_ConstraintLength::ID()) ||
687 (aId == SketchPlugin_ConstraintDistance::ID()) ||
688 (aId == SketchPlugin_ConstraintRadius::ID());
691 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
693 myModule->onViewTransformed();
695 // Display all sketcher sub-Objects
696 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
697 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
699 // Hide sketcher result
700 std::list<ResultPtr> aResults = myCurrentSketch->results();
701 std::list<ResultPtr>::const_iterator aIt;
702 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
703 (*aIt)->setDisplayed(false);
705 myCurrentSketch->setDisplayed(false);
707 // Display sketcher objects
708 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
709 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
710 std::list<ResultPtr> aResults = aFeature->results();
711 std::list<ResultPtr>::const_iterator aIt;
712 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
713 (*aIt)->setDisplayed(true);
715 aFeature->setDisplayed(true);
718 if (myPlaneFilter.IsNull())
719 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
721 if (myFilterInfinite.IsNull())
722 myFilterInfinite = new PartSet_FilterInfinite();
724 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
725 myModule->workshop()->viewer()->addSelectionFilter(myFilterInfinite);
727 bool aHasPlane = false;
728 if (theOperation->isEditOperation()) {
729 // If it is editing of sketch then it means that plane is already defined
730 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
732 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
736 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
737 // all sketch objects should be activated in the sketch selection modes by edit operation start
738 // in case of creation operation, there is an active widget, which activates own selection mode
739 if (theOperation->isEditOperation() && aHasPlane)
740 aConnector->activateModuleSelectionModes();
743 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
745 myIsMouseOverWindow = false;
746 myIsConstraintsShown = true;
747 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
748 qDebug(QString("stopSketch: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
750 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
752 DataPtr aData = myCurrentSketch->data();
753 if (!aData->isValid()) {
754 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
755 // The sketch was aborted
756 myCurrentSketch = CompositeFeaturePtr();
757 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
758 myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
760 // Erase all sketcher objects
761 QStringList aSketchIds = sketchOperationIdList();
762 QObjectPtrList aObjects = aDisplayer->displayedObjects();
763 foreach (ObjectPtr aObj, aObjects) {
764 DataPtr aObjData = aObj->data();
765 if (!aObjData->isValid())
766 aObj->setDisplayed(false);
770 // Hide all sketcher sub-Objects
771 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
772 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
773 std::list<ResultPtr> aResults = aFeature->results();
774 std::list<ResultPtr>::const_iterator aIt;
775 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
776 (*aIt)->setDisplayed(false);
778 aFeature->setDisplayed(false);
780 // Display sketcher result
781 std::list<ResultPtr> aResults = myCurrentSketch->results();
782 std::list<ResultPtr>::const_iterator aIt;
783 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
784 (*aIt)->setDisplayed(true);
786 myCurrentSketch->setDisplayed(true);
788 myCurrentSketch = CompositeFeaturePtr();
789 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
790 myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
792 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
794 // restore the module selection modes, which were changed on startSketch
795 aConnector->activateModuleSelectionModes();
798 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
800 if (constraintsIdList().contains(theOperation->id())) {
801 // Show constraints if a constraint was created
802 onShowConstraintsToggle(true);
804 connectToPropertyPanel(true);
807 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
809 connectToPropertyPanel(false);
810 myIsPropertyPanelValueChanged = false;
811 myIsMouseOverViewProcessed = true;
814 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
816 if (isNestedCreateOperation(theOperation)) {
817 FeaturePtr aFeature = theOperation->feature();
818 // it is necessary to check the the feature data validity because
819 // some kind of features are removed by an operation commit(the macro state of a feature)
820 if (aFeature.get() && aFeature->data()->isValid()) {
821 visualizeFeature(theOperation, true);
826 bool PartSet_SketcherMgr::canUndo() const
828 return isNestedCreateOperation(getCurrentOperation());
831 bool PartSet_SketcherMgr::canRedo() const
833 return isNestedCreateOperation(getCurrentOperation());
836 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
838 bool aCanDisplay = true;
840 bool aHasActiveSketch = activeSketch().get() != NULL;
841 if (aHasActiveSketch) {
842 // 1. the sketch feature should not be displayed during the sketch active operation
843 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
844 // nested features can be visualized
845 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
846 if (aFeature.get() != NULL && aFeature == activeSketch()) {
850 else { // there are no an active sketch
851 // 2. sketch sub-features should not be visualized if the sketch operation is not active
852 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
853 if (aFeature.get() != NULL) {
854 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
855 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
856 if (aSketchFeature.get()) {
862 // 3. the method should not filter the objects, which are not related to the current operation.
863 // The object is filtered just if it is a current operation feature or this feature result
864 bool isObjectFound = false;
865 ModuleBase_Operation* anOperation = getCurrentOperation();
867 FeaturePtr aFeature = anOperation->feature();
868 if (aFeature.get()) {
869 std::list<ResultPtr> aResults = aFeature->results();
870 if (theObject == aFeature)
871 isObjectFound = true;
873 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
874 for (; anIt != aLast; anIt++) {
875 isObjectFound = *anIt == theObject;
883 // 4. For created nested feature operation do not display the created feature if
884 // the mouse curstor leaves the OCC window.
885 // The correction cases, which ignores this condition:
886 // a. the property panel values modification
887 // b. the popup menu activated
888 // c. widget editor control
889 #ifndef DEBUG_DO_NOT_BY_ENTER
890 if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
891 ModuleBase_Operation* aOperation = getCurrentOperation();
892 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
893 ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
894 ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
895 // the active widget editor should not influence here. The presentation should be visible always
896 // when this widget is active.
897 if (!anEditorWdg && !myIsPopupMenuActive) {
898 // during a nested create operation, the feature is redisplayed only if the mouse over view
899 // of there was a value modified in the property panel after the mouse left the view
900 aCanDisplay = canDisplayCurrentCreatedFeature();
907 bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
909 return myIsPropertyPanelValueChanged || myIsMouseOverWindow;
910 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
911 qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
915 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
917 bool isFoundObject = false;
919 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
920 if (anObjectFeature.get()) {
921 int aSize = myCurrentSketch->numberOfSubs();
922 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
923 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
924 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
927 return isFoundObject;
930 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
932 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
935 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
936 const FeaturePtr& theSketch,
937 ModuleBase_IWorkshop* theWorkshop,
938 FeatureToSelectionMap& theSelection)
940 if (theFeature.get() == NULL)
943 std::set<AttributePtr> aSelectedAttributes;
944 std::set<ResultPtr> aSelectedResults;
946 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
947 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
948 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
949 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
951 std::list<ResultPtr> aResults = theFeature->results();
952 std::list<ResultPtr>::const_iterator aIt;
953 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
955 ResultPtr aResult = *aIt;
956 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
957 if (aAISObj.get() == NULL)
959 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
960 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
962 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(
963 aContext->SelectedOwner());
964 if (aBRepOwner.IsNull())
966 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
967 aBRepOwner->Selectable());
971 if (aBRepOwner->HasShape()) {
972 const TopoDS_Shape& aShape = aBRepOwner->Shape();
973 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
974 if (aShapeType == TopAbs_VERTEX) {
975 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
977 if (aPntAttr.get() != NULL)
978 aSelectedAttributes.insert(aPntAttr);
980 else if (aShapeType == TopAbs_EDGE &&
981 aSelectedResults.find(aResult) == aSelectedResults.end()) {
982 aSelectedResults.insert(aResult);
987 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
990 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
991 const FeaturePtr& theSketch,
992 ModuleBase_IWorkshop* theWorkshop,
993 const FeatureToSelectionMap& theSelection,
994 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
996 if (theFeature.get() == NULL)
999 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
1000 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
1001 std::set<ResultPtr> aSelectedResults = anIt.value().second;
1003 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
1004 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
1005 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
1006 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1008 // 1. found the feature's owners. Check the AIS objects of the constructions
1009 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
1010 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
1011 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1013 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1014 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1015 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
1016 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
1017 if (!anOwner.IsNull())
1018 anOwnersToSelect.Add(anOwner);
1022 // 2. found the feature results's owners
1023 std::list<ResultPtr> aResults = theFeature->results();
1024 std::list<ResultPtr>::const_iterator aIt;
1025 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
1027 ResultPtr aResult = *aIt;
1028 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
1029 if (aAISObj.get() == NULL)
1031 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1033 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1034 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1035 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
1036 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
1037 if ( anOwner.IsNull() || !anOwner->HasShape() )
1039 const TopoDS_Shape& aShape = anOwner->Shape();
1040 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
1041 if (aShapeType == TopAbs_VERTEX) {
1042 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
1043 if (aPntAttr.get() != NULL &&
1044 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1045 anOwnersToSelect.Add(anOwner);
1048 else if (aShapeType == TopAbs_EDGE) {
1049 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1050 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1051 anOwnersToSelect.FindIndex(anOwner) <= 0)
1052 anOwnersToSelect.Add(anOwner);
1058 void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
1060 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1061 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1062 XGUI_Workshop* aWorkshop = aConnector->workshop();
1063 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
1064 if (aPropertyPanel) {
1065 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
1066 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
1068 connect(aWidget, SIGNAL(beforeValuesChanged()),
1069 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1070 connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1071 connect(aWidget, SIGNAL(afterValuesChanged()),
1072 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1075 disconnect(aWidget, SIGNAL(beforeValuesChanged()),
1076 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1077 disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1078 disconnect(aWidget, SIGNAL(afterValuesChanged()),
1079 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1085 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1087 return myModule->workshop()->currentOperation();
1090 void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
1091 const bool isToDisplay,
1092 const bool isFlushRedisplay)
1094 #ifdef DEBUG_DO_NOT_BY_ENTER
1098 if (!theOperation || theOperation->isEditOperation())
1101 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1102 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1104 // 1. change visibility of the object itself, here the presentable object is processed,
1105 // e.g. constraints features
1106 FeaturePtr aFeature = theOperation->feature();
1107 std::list<ResultPtr> aResults = aFeature->results();
1109 aFeature->setDisplayed(true);
1111 aFeature->setDisplayed(false);
1113 // change visibility of the object results, e.g. non-constraint features
1114 std::list<ResultPtr>::const_iterator aIt;
1115 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1117 (*aIt)->setDisplayed(true);
1120 (*aIt)->setDisplayed(false);
1123 if (isFlushRedisplay)
1124 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1127 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1129 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1130 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1131 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
1133 QMap<FeaturePtr, QList<AttributePtr> > aFeature2AttributeMap;
1134 if (theHighlightedOnly) {
1135 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1138 fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
1140 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
1141 fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch);
1144 // 1. it is necessary to save current selection in order to restore it after the features moving
1145 myCurrentSelection.clear();
1146 QMap<FeaturePtr, QList<AttributePtr> >::const_iterator anIt = aFeature2AttributeMap.begin(),
1147 aLast = aFeature2AttributeMap.end();
1148 for (; anIt != aLast; anIt++) {
1149 FeaturePtr aFeature = anIt.key();
1150 getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection);
1152 //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1155 void PartSet_SketcherMgr::restoreSelection()
1157 //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1158 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1159 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1160 FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
1161 aSLast = myCurrentSelection.end();
1162 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
1163 for (; aSIt != aSLast; aSIt++) {
1164 anOwnersToSelect.Clear();
1165 getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
1167 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
1171 void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
1173 if (myIsConstraintsShown == theOn)
1175 if (myCurrentSketch.get() == NULL)
1178 myIsConstraintsShown = theOn;
1180 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1181 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1183 const QStringList& aConstrIds = constraintsIdList();
1184 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
1185 FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
1186 if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
1187 if (myIsConstraintsShown)
1188 aSubFeature->setDisplayed(true);
1190 aSubFeature->setDisplayed(false);
1193 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1196 QString PartSet_SketcherMgr::mouseOverWindowFlagsInfo() const
1198 return QString("myIsPropertyPanelValueChanged = %1, myIsMouseOverWindow = %2")
1199 .arg(myIsPropertyPanelValueChanged).arg(myIsMouseOverWindow);