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 // Fills the list of features the list of selected presentations.
94 // \param theList a list of selected presentations
95 // \param theSketch a sketch to project a vertex shape of a presentation to the plane
96 // and find the corresponded attribute
97 // \param theFeatureList an output list of features
98 void fillFeatureList(const QList<ModuleBase_ViewerPrs>& theList,
99 const FeaturePtr theSketch,
100 QList<FeaturePtr>& theFeatureList)
102 QList<ModuleBase_ViewerPrs> aRes;
104 QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
105 aLast = theList.end();
106 for (; anIt != aLast; anIt++)
108 ModuleBase_ViewerPrs aPrs = *anIt;
109 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
110 if (aFeature.get() && !theFeatureList.contains(aFeature))
111 theFeatureList.append(aFeature);
115 /// Fills attribute and result lists by the selected owner. In case if the attribute is found,
116 /// by the owner shape, it is put to the list. Otherwise if type of owner shape is edge, put the function
117 /// result as is to the list of results.
118 /// \param theOwner a viewer selected owner
119 /// \param theFeature a feature, where the attribute is searched
120 /// \param theSketch a current sketch
121 /// \param theSelectedAttribute an output list of attributes
122 /// \param theSelectedResults an output list of edge results
123 void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner,
124 const FeaturePtr& theFeature, const FeaturePtr& theSketch,
125 const ResultPtr& theResult,
126 std::set<AttributePtr>& aSelectedAttributes,
127 std::set<ResultPtr>& aSelectedResults)
129 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
130 if (aBRepOwner.IsNull())
132 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
133 aBRepOwner->Selectable());
134 if (aBRepOwner->HasShape()) {
135 const TopoDS_Shape& aShape = aBRepOwner->Shape();
136 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
137 if (aShapeType == TopAbs_VERTEX) {
138 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
140 if (aPntAttr.get() != NULL)
141 aSelectedAttributes.insert(aPntAttr);
143 else if (aShapeType == TopAbs_EDGE &&
144 aSelectedResults.find(theResult) == aSelectedResults.end()) {
145 aSelectedResults.insert(theResult);
150 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
151 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
152 myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
153 myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
154 myIsPopupMenuActive(false), myIsConstraintsShown(true)
156 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
157 ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
159 myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled();
161 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
162 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
164 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
165 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
167 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
168 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
170 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
171 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
173 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
174 XGUI_Workshop* aWorkshop = aConnector->workshop();
175 connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted()));
178 PartSet_SketcherMgr::~PartSet_SketcherMgr()
180 if (!myPlaneFilter.IsNull())
181 myPlaneFilter.Nullify();
184 void PartSet_SketcherMgr::onEnterViewPort()
186 // 1. if the mouse over window, update the next flag. Do not perform update visibility of
187 // created feature because it should be done in onMouseMove(). Some widgets watch
188 // the mouse move and use the cursor position to update own values. If the presentaion is
189 // redisplayed before this update, the feature presentation jumps from reset value to current.
190 myIsMouseOverWindow = true;
191 myIsPropertyPanelValueChanged = false;
192 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
193 qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
196 #ifdef DEBUG_DO_NOT_BY_ENTER
200 if (!isNestedCreateOperation(getCurrentOperation()))
202 // we need change displayed state of the current operation feature
203 // if the feature is presentable, e.g. distance construction. It has no results, so workshop does
204 // not accept a signal about the result created. Nothing is shown until mouse is moved out/in view
205 // port. If the isDisplayed flag is true, the presentable feature is displayed as soon as the
206 // presentation becomes valid and redisplay happens
207 ModuleBase_Operation* aOperation = getCurrentOperation();
209 FeaturePtr aFeature = aOperation->feature();
210 if (aFeature.get() && aFeature->data()->isValid()) {
211 visualizeFeature(aOperation, canDisplayObject(aFeature), false);
216 void PartSet_SketcherMgr::onLeaveViewPort()
218 myIsMouseOverViewProcessed = false;
219 myIsMouseOverWindow = false;
220 myIsPropertyPanelValueChanged = false;
221 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
222 qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
225 #ifdef DEBUG_DO_NOT_BY_ENTER
229 if (!isNestedCreateOperation(getCurrentOperation()))
231 // the method should be performed if the popup menu is called,
232 // the reset of the current widget should not happen
233 if (myIsPopupMenuActive)
236 // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
237 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
238 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
239 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
240 // disable the viewer update in order to avoid visualization of redisplayed feature in viewer
241 // obtained after reset value
242 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
243 ModuleBase_Operation* aOperation = getCurrentOperation();
244 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
245 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
249 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
251 // hides the presentation of the current operation feature
252 //myIsPropertyPanelValueChanged = false;
253 // the feature is to be erased here, but it is correct to call canDisplayObject because
254 // there can be additional check (e.g. editor widget in distance constraint)
255 FeaturePtr aFeature = getCurrentOperation()->feature();
256 visualizeFeature(aOperation, canDisplayObject(aFeature));
259 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
261 if (isNestedCreateOperation(getCurrentOperation()))
263 // it is necessary to save current selection in order to restore it after the values are modifed
266 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
267 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
268 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
269 myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
272 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
274 if (isNestedCreateOperation(getCurrentOperation()))
276 // it is necessary to restore current selection in order to restore it after the values are modified
278 myCurrentSelection.clear();
280 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
281 // viewer happens by deselect/select the modified objects. The flag should be restored after
282 // the selection processing. The update viewer should be also called.
283 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
284 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
285 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
286 aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
287 aDisplayer->updateViewer();
290 void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
292 if (!isNestedCreateOperation(getCurrentOperation()))
295 // visualize the current operation feature
296 myIsPropertyPanelValueChanged = true;
297 ModuleBase_Operation* aOperation = getCurrentOperation();
298 // the feature is to be erased here, but it is correct to call canDisplayObject because
299 // there can be additional check (e.g. editor widget in distance constraint)
300 FeaturePtr aFeature = getCurrentOperation()->feature();
301 visualizeFeature(aOperation, canDisplayObject(aFeature));
304 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
306 get2dPoint(theWnd, theEvent, myClickedPoint);
308 if (!(theEvent->buttons() & Qt::LeftButton))
311 // Clear dragging mode
312 myIsDragging = false;
314 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
315 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
316 if (!aViewer->canDragByMouse())
319 ModuleBase_Operation* aOperation = getCurrentOperation();
320 if (aOperation && aOperation->isEditOperation()) {
321 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
322 ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
323 // If the current widget is a selector, do nothing, it processes the mouse press
324 if(aActiveWgt && aActiveWgt->isViewerSelector()) {
329 // Use only for sketch operations
330 if (aOperation && myCurrentSketch) {
331 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
334 bool isSketcher = isSketchOperation(aOperation);
335 bool isSketchOpe = isNestedSketchOperation(aOperation);
337 // Avoid non-sketch operations
338 if ((!isSketchOpe) && (!isSketcher))
341 bool isEditing = aOperation->isEditOperation();
343 // Ignore creation sketch operation
344 if ((!isSketcher) && (!isEditing))
347 // MoveTo in order to highlight current object
348 aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
350 // Remember highlighted objects for editing
351 ModuleBase_ISelection* aSelect = aWorkshop->selection();
353 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
354 storeSelection(!aHasShift);
356 if (myCurrentSelection.empty()) {
357 if (isSketchOpe && (!isSketcher))
358 // commit previous operation
359 if (!aOperation->commit())
363 // Init flyout point for radius rotation
364 FeaturePtr aFeature = myCurrentSelection.begin().key();
368 get2dPoint(theWnd, theEvent, myCurrentPoint);
371 if (aFeature.get() != NULL) {
372 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
373 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
374 if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
375 DataPtr aData = aSPFeature->data();
376 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
377 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
378 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
379 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
382 } else if (isSketchOpe && isEditing) {
383 // If selected another object commit current result
384 aOperation->commit();
387 get2dPoint(theWnd, theEvent, myCurrentPoint);
390 // This is necessary in order to finalize previous operation
391 QApplication::processEvents();
397 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
399 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
400 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
401 if (!aViewer->canDragByMouse())
403 ModuleBase_Operation* aOp = getCurrentOperation();
405 if (isNestedSketchOperation(aOp)) {
406 get2dPoint(theWnd, theEvent, myClickedPoint);
408 // Only for sketcher operations
412 myCurrentSelection.clear();
413 // Reselect edited object
414 /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
415 if (theEvent->modifiers() & Qt::ShiftModifier)
416 aViewer->AISContext()->ShiftSelect();
418 aViewer->AISContext()->Select();
424 aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
425 myIsDragging = false;
428 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
430 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
431 myIsMouseOverViewProcessed = true;
432 // 1. perform the widget mouse move functionality and display the presentation
433 ModuleBase_Operation* aOperation = getCurrentOperation();
434 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
435 ModuleBase_ModelWidget* anActiveWdg = aPanel->activeWidget();
436 // the mouse move should be processed in the widget, if it can in order to visualize correct
437 // presentation. These widgets correct the feature attribute according to the mouse position
438 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWdg);
440 aPoint2DWdg->onMouseMove(theWnd, theEvent);
442 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
445 aDistanceWdg->onMouseMove(theWnd, theEvent);
447 // the feature is to be erased here, but it is correct to call canDisplayObject because
448 // there can be additional check (e.g. editor widget in distance constraint)
449 FeaturePtr aFeature = getCurrentOperation()->feature();
450 visualizeFeature(aOperation, canDisplayObject(aFeature));
453 myClickedPoint.clear();
456 // 1. the current selection is saved in the mouse press method in order to restore it after moving
457 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
458 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
459 // deselected). This flag should be restored in the slot, processed the mouse release signal.
460 ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
461 aViewer->enableSelection(false);
463 ModuleBase_Operation* aOperation = getCurrentOperation();
466 if (isSketchOperation(aOperation))
467 return; // No edit operation activated
469 Handle(V3d_View) aView = theWnd->v3dView();
470 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
472 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
473 double dX = aX - myCurrentPoint.myCurX;
474 double dY = aY - myCurrentPoint.myCurY;
476 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
477 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
478 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
479 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
480 // viewer happens by deselect/select the modified objects. The flag should be restored after
481 // the selection processing. The update viewer should be also called.
482 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
484 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
485 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
486 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
487 aLast = myCurrentSelection.end();
488 // 4. the features and attributes modification(move)
489 for (; anIt != aLast; anIt++) {
490 FeaturePtr aFeature = anIt.key();
492 std::set<AttributePtr> anAttributes = anIt.value().first;
493 // Process selection by attribute: the priority to the attribute
494 if (!anAttributes.empty()) {
495 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
496 anAttLast = anAttributes.end();
497 for (; anAttIt != anAttLast; anAttIt++) {
498 AttributePtr anAttr = *anAttIt;
499 if (anAttr.get() == NULL)
501 std::string aAttrId = anAttr->id();
502 DataPtr aData = aFeature->data();
503 if (aData->isValid()) {
504 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
505 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
506 if (aPoint.get() != NULL) {
507 bool isImmutable = aPoint->setImmutable(true);
508 aPoint->move(dX, dY);
509 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
510 aPoint->setImmutable(isImmutable);
515 // Process selection by feature
516 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
517 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
518 if (aSketchFeature) {
519 aSketchFeature->move(dX, dY);
520 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
524 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
525 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
527 // 5. it is necessary to save current selection in order to restore it after the features moving
529 // 6. restore the update viewer flag and call this update
530 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
531 aDisplayer->updateViewer();
534 myCurrentPoint.setValue(aX, aY);
538 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
540 ModuleBase_Operation* aOperation = getCurrentOperation();
541 if (aOperation && aOperation->isEditOperation()) {
542 std::string aId = aOperation->id().toStdString();
543 if (isDistanceOperation(aOperation))
545 // Activate dimension value editing on double click
546 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
547 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
548 // Find corresponded widget to activate value editing
549 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
550 if (aWgt->attributeID() == "ConstraintValue") {
559 void PartSet_SketcherMgr::onApplicationStarted()
561 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
562 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
563 XGUI_Workshop* aWorkshop = aConnector->workshop();
564 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
565 if (aPropertyPanel) {
566 connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
567 this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
570 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
571 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
572 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
574 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
575 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
576 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
579 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
581 if (!myClickedPoint.myIsInitialized)
584 ModuleBase_Operation* aOperation = getCurrentOperation();
585 // the distance constraint feature should not use the clickedd point
586 // this is workaround in order to don't throw down the flyout point value,
587 // set by execute() method of these type of features
588 if (isDistanceOperation(aOperation))
591 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
593 aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
597 void PartSet_SketcherMgr::onBeforeContextMenu()
599 myIsPopupMenuActive = true;
602 void PartSet_SketcherMgr::onAfterContextMenu()
604 myIsPopupMenuActive = false;
607 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
610 Handle(V3d_View) aView = theWnd->v3dView();
611 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
613 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
614 thePoint.setValue(aX, anY);
617 void PartSet_SketcherMgr::launchEditing()
619 if (!myCurrentSelection.empty()) {
620 FeaturePtr aFeature = myCurrentSelection.begin().key();
621 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
622 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
624 myModule->editFeature(aSPFeature);
630 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
632 static QStringList aIds;
633 if (aIds.size() == 0) {
634 aIds << SketchPlugin_Line::ID().c_str();
635 aIds << SketchPlugin_Point::ID().c_str();
636 aIds << SketchPlugin_Arc::ID().c_str();
637 aIds << SketchPlugin_Circle::ID().c_str();
638 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
639 aIds.append(constraintsIdList());
644 const QStringList& PartSet_SketcherMgr::constraintsIdList()
646 static QStringList aIds;
647 if (aIds.size() == 0) {
648 aIds << SketchPlugin_ConstraintLength::ID().c_str();
649 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
650 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
651 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
652 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
653 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
654 aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
655 aIds << SketchPlugin_ConstraintVertical::ID().c_str();
656 aIds << SketchPlugin_ConstraintEqual::ID().c_str();
657 aIds << SketchPlugin_ConstraintTangent::ID().c_str();
658 aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
659 aIds << SketchPlugin_ConstraintMirror::ID().c_str();
660 aIds << SketchPlugin_MultiRotation::ID().c_str();
661 aIds << SketchPlugin_MultiTranslation::ID().c_str();
666 void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
670 theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
671 theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
672 theModes.append(SketcherPrs_Tools::Sel_Constraint);
673 theModes.append(TopAbs_VERTEX);
674 theModes.append(TopAbs_EDGE);
677 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
679 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
682 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
684 return theOperation &&
685 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
688 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
690 return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
693 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
695 return (theId == SketchPlugin_Line::ID()) ||
696 (theId == SketchPlugin_Point::ID()) ||
697 (theId == SketchPlugin_Arc::ID()) ||
698 (theId == SketchPlugin_Circle::ID());
701 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
703 std::string aId = theOperation ? theOperation->id().toStdString() : "";
705 return (aId == SketchPlugin_ConstraintLength::ID()) ||
706 (aId == SketchPlugin_ConstraintDistance::ID()) ||
707 (aId == SketchPlugin_ConstraintRadius::ID());
710 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
712 myModule->onViewTransformed();
714 // Display all sketcher sub-Objects
715 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
716 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
718 // Hide sketcher result
719 std::list<ResultPtr> aResults = myCurrentSketch->results();
720 std::list<ResultPtr>::const_iterator aIt;
721 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
722 (*aIt)->setDisplayed(false);
724 myCurrentSketch->setDisplayed(false);
726 // Display sketcher objects
727 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
728 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
729 std::list<ResultPtr> aResults = aFeature->results();
730 std::list<ResultPtr>::const_iterator aIt;
731 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
732 (*aIt)->setDisplayed(true);
734 aFeature->setDisplayed(true);
737 if (myPlaneFilter.IsNull())
738 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
740 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
742 bool aHasPlane = false;
743 if (theOperation->isEditOperation()) {
744 // If it is editing of sketch then it means that plane is already defined
745 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
747 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
751 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
752 // all sketch objects should be activated in the sketch selection modes by edit operation start
753 // in case of creation operation, there is an active widget, which activates own selection mode
754 if (theOperation->isEditOperation() && aHasPlane)
755 aConnector->activateModuleSelectionModes();
758 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
760 myIsMouseOverWindow = false;
761 myIsConstraintsShown = true;
762 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
763 qDebug(QString("stopSketch: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
765 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
767 DataPtr aData = myCurrentSketch->data();
768 if (!aData->isValid()) {
769 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
770 // The sketch was aborted
771 myCurrentSketch = CompositeFeaturePtr();
772 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
774 // Erase all sketcher objects
775 QStringList aSketchIds = sketchOperationIdList();
776 QObjectPtrList aObjects = aDisplayer->displayedObjects();
777 foreach (ObjectPtr aObj, aObjects) {
778 DataPtr aObjData = aObj->data();
779 if (!aObjData->isValid())
780 aObj->setDisplayed(false);
784 // Hide all sketcher sub-Objects
785 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
786 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
787 std::list<ResultPtr> aResults = aFeature->results();
788 std::list<ResultPtr>::const_iterator aIt;
789 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
790 (*aIt)->setDisplayed(false);
792 aFeature->setDisplayed(false);
794 // Display sketcher result
795 std::list<ResultPtr> aResults = myCurrentSketch->results();
796 std::list<ResultPtr>::const_iterator aIt;
797 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
798 (*aIt)->setDisplayed(true);
800 myCurrentSketch->setDisplayed(true);
802 myCurrentSketch = CompositeFeaturePtr();
803 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
805 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
807 // restore the module selection modes, which were changed on startSketch
808 aConnector->activateModuleSelectionModes();
811 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
813 if (constraintsIdList().contains(theOperation->id())) {
814 // Show constraints if a constraint was created
815 onShowConstraintsToggle(true);
817 connectToPropertyPanel(true);
820 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
822 connectToPropertyPanel(false);
823 myIsPropertyPanelValueChanged = false;
824 myIsMouseOverViewProcessed = true;
827 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
829 if (isNestedCreateOperation(theOperation)) {
830 FeaturePtr aFeature = theOperation->feature();
831 // it is necessary to check the the feature data validity because
832 // some kind of features are removed by an operation commit(the macro state of a feature)
833 if (aFeature.get() && aFeature->data()->isValid()) {
834 visualizeFeature(theOperation, true);
839 bool PartSet_SketcherMgr::canUndo() const
841 return isNestedCreateOperation(getCurrentOperation());
844 bool PartSet_SketcherMgr::canRedo() const
846 return isNestedCreateOperation(getCurrentOperation());
849 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
851 bool aCanDisplay = true;
853 bool aHasActiveSketch = activeSketch().get() != NULL;
854 if (aHasActiveSketch) {
855 // 1. the sketch feature should not be displayed during the sketch active operation
856 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
857 // nested features can be visualized
858 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
859 if (aFeature.get() != NULL && aFeature == activeSketch()) {
863 else { // there are no an active sketch
864 // 2. sketch sub-features should not be visualized if the sketch operation is not active
865 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
866 if (aFeature.get() != NULL) {
867 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
868 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
869 if (aSketchFeature.get()) {
875 // 3. the method should not filter the objects, which are not related to the current operation.
876 // The object is filtered just if it is a current operation feature or this feature result
877 bool isObjectFound = false;
878 ModuleBase_Operation* anOperation = getCurrentOperation();
880 FeaturePtr aFeature = anOperation->feature();
881 if (aFeature.get()) {
882 std::list<ResultPtr> aResults = aFeature->results();
883 if (theObject == aFeature)
884 isObjectFound = true;
886 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
887 for (; anIt != aLast; anIt++) {
888 isObjectFound = *anIt == theObject;
896 // 4. For created nested feature operation do not display the created feature if
897 // the mouse curstor leaves the OCC window.
898 // The correction cases, which ignores this condition:
899 // a. the property panel values modification
900 // b. the popup menu activated
901 // c. widget editor control
902 #ifndef DEBUG_DO_NOT_BY_ENTER
903 if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
904 ModuleBase_Operation* aOperation = getCurrentOperation();
905 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
906 ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
907 ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
908 // the active widget editor should not influence here. The presentation should be visible always
909 // when this widget is active.
910 if (!anEditorWdg && !myIsPopupMenuActive) {
911 // during a nested create operation, the feature is redisplayed only if the mouse over view
912 // of there was a value modified in the property panel after the mouse left the view
913 aCanDisplay = canDisplayCurrentCreatedFeature();
920 bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
922 return myIsPropertyPanelValueChanged || myIsMouseOverWindow;
923 #ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
924 qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
928 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
930 bool isFoundObject = false;
932 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
933 if (anObjectFeature.get()) {
934 int aSize = myCurrentSketch->numberOfSubs();
935 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
936 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
937 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
940 return isFoundObject;
943 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
945 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
948 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
949 const FeaturePtr& theSketch,
950 ModuleBase_IWorkshop* theWorkshop,
951 FeatureToSelectionMap& theSelection)
953 if (theFeature.get() == NULL)
956 std::set<AttributePtr> aSelectedAttributes;
957 std::set<ResultPtr> aSelectedResults;
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 std::list<ResultPtr> aResults = theFeature->results();
965 std::list<ResultPtr>::const_iterator aIt;
966 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
968 ResultPtr aResult = *aIt;
969 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
970 if (aAISObj.get() == NULL)
972 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
973 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
975 Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
976 if (anOwner->Selectable() != anAISIO)
978 getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
979 aSelectedAttributes, aSelectedResults);
981 for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
982 Handle(SelectMgr_EntityOwner) anOwner = aContext->DetectedOwner();
983 if (anOwner->Selectable() != anAISIO)
985 getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
986 aSelectedAttributes, aSelectedResults);
989 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
992 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
993 const FeaturePtr& theSketch,
994 ModuleBase_IWorkshop* theWorkshop,
995 const FeatureToSelectionMap& theSelection,
996 SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
998 if (theFeature.get() == NULL)
1001 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
1002 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
1003 std::set<ResultPtr> aSelectedResults = anIt.value().second;
1005 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
1006 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
1007 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
1008 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1010 // 1. found the feature's owners. Check the AIS objects of the constructions
1011 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
1012 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
1013 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1015 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1016 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1017 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
1018 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
1019 if (!anOwner.IsNull())
1020 anOwnersToSelect.Add(anOwner);
1024 // 2. found the feature results's owners
1025 std::list<ResultPtr> aResults = theFeature->results();
1026 std::list<ResultPtr>::const_iterator aIt;
1027 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
1029 ResultPtr aResult = *aIt;
1030 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
1031 if (aAISObj.get() == NULL)
1033 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1035 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1036 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1037 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
1038 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
1039 if ( anOwner.IsNull() || !anOwner->HasShape() )
1041 const TopoDS_Shape& aShape = anOwner->Shape();
1042 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
1043 if (aShapeType == TopAbs_VERTEX) {
1044 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
1045 if (aPntAttr.get() != NULL &&
1046 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1047 anOwnersToSelect.Add(anOwner);
1050 else if (aShapeType == TopAbs_EDGE) {
1051 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1052 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1053 anOwnersToSelect.FindIndex(anOwner) <= 0)
1054 anOwnersToSelect.Add(anOwner);
1060 void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
1062 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1063 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1064 XGUI_Workshop* aWorkshop = aConnector->workshop();
1065 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
1066 if (aPropertyPanel) {
1067 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
1068 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
1070 connect(aWidget, SIGNAL(beforeValuesChanged()),
1071 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1072 connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1073 connect(aWidget, SIGNAL(afterValuesChanged()),
1074 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1077 disconnect(aWidget, SIGNAL(beforeValuesChanged()),
1078 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1079 disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
1080 disconnect(aWidget, SIGNAL(afterValuesChanged()),
1081 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1087 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1089 return myModule->workshop()->currentOperation();
1092 void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
1093 const bool isToDisplay,
1094 const bool isFlushRedisplay)
1096 #ifdef DEBUG_DO_NOT_BY_ENTER
1100 if (!theOperation || theOperation->isEditOperation())
1103 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1104 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1106 // 1. change visibility of the object itself, here the presentable object is processed,
1107 // e.g. constraints features
1108 FeaturePtr aFeature = theOperation->feature();
1109 std::list<ResultPtr> aResults = aFeature->results();
1111 aFeature->setDisplayed(true);
1113 aFeature->setDisplayed(false);
1115 // change visibility of the object results, e.g. non-constraint features
1116 std::list<ResultPtr>::const_iterator aIt;
1117 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1119 (*aIt)->setDisplayed(true);
1122 (*aIt)->setDisplayed(false);
1125 if (isFlushRedisplay)
1126 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1129 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1131 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1132 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1133 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
1135 QList<FeaturePtr> aFeatureList;
1136 if (theHighlightedOnly) {
1137 fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList);
1140 fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList);
1142 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls);
1143 fillFeatureList(aSelected, myCurrentSketch, aFeatureList);
1146 // 1. it is necessary to save current selection in order to restore it after the features moving
1147 myCurrentSelection.clear();
1148 QList<FeaturePtr>::const_iterator anIt = aFeatureList.begin(), aLast = aFeatureList.end();
1149 for (; anIt != aLast; anIt++) {
1150 getCurrentSelection(*anIt, 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);