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_SketcherReetntrantMgr.h"
9 #include "PartSet_Module.h"
10 #include "PartSet_WidgetPoint2d.h"
11 #include "PartSet_WidgetPoint2dDistance.h"
12 #include "PartSet_Tools.h"
13 #include "PartSet_WidgetSketchLabel.h"
14 #include "PartSet_WidgetEditor.h"
15 #include "PartSet_ResultSketchPrs.h"
17 #include <XGUI_ModuleConnector.h>
18 #include <XGUI_Displayer.h>
19 #include <XGUI_Workshop.h>
20 #include <XGUI_ContextMenuMgr.h>
21 #include <XGUI_Selection.h>
22 #include <XGUI_SelectionMgr.h>
23 #include <XGUI_ModuleConnector.h>
24 #include <XGUI_PropertyPanel.h>
25 #include <XGUI_ViewerProxy.h>
26 #include <XGUI_OperationMgr.h>
27 #include <XGUI_Tools.h>
29 #include <ModuleBase_IPropertyPanel.h>
30 #include <ModuleBase_ISelection.h>
31 #include <ModuleBase_IViewer.h>
32 #include <ModuleBase_IWorkshop.h>
33 #include <ModuleBase_IViewWindow.h>
34 #include <ModuleBase_ModelWidget.h>
35 #include <ModuleBase_Operation.h>
36 #include <ModuleBase_OperationFeature.h>
37 #include <ModuleBase_Operation.h>
38 #include <ModuleBase_WidgetEditor.h>
39 #include <ModuleBase_ViewerPrs.h>
40 #include <ModuleBase_Tools.h>
42 #include <GeomDataAPI_Point2D.h>
44 #include <Events_Loop.h>
46 #include <SketchPlugin_Line.h>
47 #include <SketchPlugin_Sketch.h>
48 #include <SketchPlugin_Point.h>
49 #include <SketchPlugin_Arc.h>
50 #include <SketchPlugin_Circle.h>
51 #include <SketchPlugin_ConstraintLength.h>
52 #include <SketchPlugin_ConstraintDistance.h>
53 #include <SketchPlugin_ConstraintParallel.h>
54 #include <SketchPlugin_ConstraintPerpendicular.h>
55 #include <SketchPlugin_ConstraintRadius.h>
56 #include <SketchPlugin_ConstraintRigid.h>
57 #include <SketchPlugin_ConstraintHorizontal.h>
58 #include <SketchPlugin_ConstraintVertical.h>
59 #include <SketchPlugin_ConstraintEqual.h>
60 #include <SketchPlugin_ConstraintTangent.h>
61 #include <SketchPlugin_ConstraintCoincidence.h>
62 #include <SketchPlugin_ConstraintFillet.h>
63 #include <SketchPlugin_ConstraintMirror.h>
64 #include <SketchPlugin_ConstraintAngle.h>
65 #include <SketchPlugin_ConstraintCollinear.h>
66 #include <SketchPlugin_ConstraintMiddle.h>
67 #include <SketchPlugin_MultiRotation.h>
68 #include <SketchPlugin_MultiTranslation.h>
69 #include <SketchPlugin_IntersectionPoint.h>
71 #include <SketcherPrs_Tools.h>
73 #include <SelectMgr_IndexedMapOfOwner.hxx>
74 #include <StdSelect_BRepOwner.hxx>
76 //#include <AIS_DimensionSelectionMode.hxx>
77 #include <AIS_Shape.hxx>
78 #include <AIS_Dimension.hxx>
80 #include <ModelAPI_Events.h>
81 #include <ModelAPI_Session.h>
82 #include <ModelAPI_AttributeString.h>
84 #include <QMouseEvent>
85 #include <QApplication>
87 #include <QMessageBox>
89 //#define DEBUG_DO_NOT_BY_ENTER
91 //#define DEBUG_CURSOR
93 /// Returns list of unique objects by sum of objects from List1 and List2
94 /*QList<ModuleBase_ViewerPrsPtr> getSumList(const QList<ModuleBase_ViewerPrsPtr>& theList1,
95 const QList<ModuleBase_ViewerPrsPtr>& theList2)
97 QList<ModuleBase_ViewerPrsPtr> aRes;
98 foreach (ModuleBase_ViewerPrsPtr aPrs, theList1) {
99 if (!aRes.contains(aPrs))
102 foreach (ModuleBase_ViewerPrsPtr aPrs, theList2) {
103 if (!aRes.contains(aPrs))
109 // Fills the list of features the list of selected presentations.
110 // \param theList a list of selected presentations
111 // \param theSketch a sketch to project a vertex shape of a presentation to the plane
112 // and find the corresponded attribute
113 // \param theFeatureList an output list of features
114 void fillFeatureList(const QList<ModuleBase_ViewerPrsPtr>& theList,
115 const FeaturePtr theSketch,
116 QList<FeaturePtr>& theFeatureList)
118 QList<ModuleBase_ViewerPrsPtr> aRes;
120 QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theList.begin(),
121 aLast = theList.end();
122 for (; anIt != aLast; anIt++)
124 ModuleBase_ViewerPrsPtr aPrs = *anIt;
125 FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object());
126 if (aFeature.get() && !theFeatureList.contains(aFeature))
127 theFeatureList.append(aFeature);
131 /// Fills attribute and result lists by the selected owner. In case if the attribute is found,
132 /// by the owner shape, it is put to the list. Otherwise if type of owner shape is edge, put the function
133 /// result as is to the list of results.
134 /// \param theOwner a viewer selected owner
135 /// \param theFeature a feature, where the attribute is searched
136 /// \param theSketch a current sketch
137 /// \param theSelectedAttribute an output list of attributes
138 /// \param theSelectedResults an output list of edge results
139 void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner,
140 const FeaturePtr& theFeature, const FeaturePtr& theSketch,
141 const ResultPtr& theResult,
142 std::set<AttributePtr>& aSelectedAttributes,
143 std::set<ResultPtr>& aSelectedResults)
145 Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
146 if (aBRepOwner.IsNull())
148 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
149 aBRepOwner->Selectable());
150 if (aBRepOwner->HasShape()) {
151 const TopoDS_Shape& aShape = aBRepOwner->Shape();
152 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
153 if (aShapeType == TopAbs_VERTEX) {
154 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature,
156 if (aPntAttr.get() != NULL)
157 aSelectedAttributes.insert(aPntAttr);
159 else if (aShapeType == TopAbs_EDGE &&
160 aSelectedResults.find(theResult) == aSelectedResults.end()) {
161 aSelectedResults.insert(theResult);
166 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
167 : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
168 myIsMouseOverWindow(false),
169 myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
170 myIsPopupMenuActive(false)
172 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
173 ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
175 myPreviousDrawModeEnabled = true;//aViewer->isSelectionEnabled();
177 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
178 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
180 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
181 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
183 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
184 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
186 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
187 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
189 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
190 XGUI_Workshop* aWorkshop = aConnector->workshop();
191 connect(aWorkshop, SIGNAL(applicationStarted()), this, SLOT(onApplicationStarted()));
193 myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
194 myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
195 myIsConstraintsShown[PartSet_Tools::Expressions] = false;
198 PartSet_SketcherMgr::~PartSet_SketcherMgr()
200 if (!myPlaneFilter.IsNull())
201 myPlaneFilter.Nullify();
204 void PartSet_SketcherMgr::onEnterViewPort()
206 // 1. if the mouse over window, update the next flag. Do not perform update visibility of
207 // created feature because it should be done in onMouseMove(). Some widgets watch
208 // the mouse move and use the cursor position to update own values. If the presentaion is
209 // redisplayed before this update, the feature presentation jumps from reset value to current.
210 myIsMouseOverWindow = true;
212 #ifdef DEBUG_DO_NOT_BY_ENTER
216 if (canChangeCursor(getCurrentOperation())) {
217 QCursor* aCurrentCursor = QApplication::overrideCursor();
218 if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
219 QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
221 qDebug("onEnterViewPort() : Qt::CrossCursor");
226 if (!isNestedCreateOperation(getCurrentOperation()))
229 operationMgr()->onValidateOperation();
231 // we need change displayed state of the current operation feature
232 // if the feature is presentable, e.g. distance construction. It has no results, so workshop does
233 // not accept a signal about the result created. Nothing is shown until mouse is moved out/in view
234 // port. If the isDisplayed flag is true, the presentable feature is displayed as soon as the
235 // presentation becomes valid and redisplay happens
236 //ModuleBase_Operation* aOperation = getCurrentOperation();
237 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
238 (getCurrentOperation());
240 FeaturePtr aFeature = aFOperation->feature();
241 if (aFeature.get() && aFeature->data()->isValid()) {
242 visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature), false);
247 void PartSet_SketcherMgr::onLeaveViewPort()
249 myIsMouseOverViewProcessed = false;
250 myIsMouseOverWindow = false;
252 #ifdef DEBUG_DO_NOT_BY_ENTER
256 if (canChangeCursor(getCurrentOperation())) {
257 QApplication::restoreOverrideCursor();
259 qDebug("onLeaveViewPort() : None");
263 if (!isNestedCreateOperation(getCurrentOperation()))
266 // the method should be performed if the popup menu is called,
267 // the reset of the current widget should not happen
268 if (myIsPopupMenuActive)
271 // it is important to validate operation here only if sketch entity create operation is active
272 // because at this operation we reacts to the mouse leave/enter view port
273 operationMgr()->onValidateOperation();
275 // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
276 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
277 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
278 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
279 // disable the viewer update in order to avoid visualization of redisplayed feature in viewer
280 // obtained after reset value
281 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
282 ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
284 anActiveWidget->reset();
286 // hides the presentation of the current operation feature
287 // the feature is to be erased here, but it is correct to call canDisplayObject because
288 // there can be additional check (e.g. editor widget in distance constraint)
289 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
290 (getCurrentOperation());
292 FeaturePtr aFeature = aFOperation->feature();
293 visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
295 // we should update viewer after the presentation are hidden in the viewer
296 // otherwise the reset presentation(line) appears in the viewer(by quick move from viewer to PP)
297 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
300 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
302 if (!isNestedEditOperation(getCurrentOperation()) ||
303 myModule->sketchReentranceMgr()->isInternalEditActive())
305 // it is necessary to save current selection in order to restore it after the values are modifed
308 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
309 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
310 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
311 myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
314 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
316 if (!isNestedEditOperation(getCurrentOperation()) ||
317 myModule->sketchReentranceMgr()->isInternalEditActive()) {
318 myModule->sketchReentranceMgr()->updateInternalEditActiveState();
321 // it is necessary to restore current selection in order to restore it after the values are modified
323 myCurrentSelection.clear();
325 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
326 // viewer happens by deselect/select the modified objects. The flag should be restored after
327 // the selection processing. The update viewer should be also called.
328 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
329 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
330 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
331 aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
332 aDisplayer->updateViewer();
337 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
339 if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent))
342 //get2dPoint(theWnd, theEvent, myClickedPoint);
344 if (!(theEvent->buttons() & Qt::LeftButton))
347 // Clear dragging mode
348 myIsDragging = false;
350 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
351 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
352 if (!aViewer->canDragByMouse())
355 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
356 (getCurrentOperation());
360 if (aFOperation->isEditOperation()) {
361 // If the current widget is a selector, do nothing, it processes the mouse press
362 ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
363 if(anActiveWidget && anActiveWidget->isViewerSelector()) {
368 // Use only for sketch operations
369 if (myCurrentSketch) {
370 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
373 bool isSketcher = isSketchOperation(aFOperation);
374 bool isSketchOpe = isNestedSketchOperation(aFOperation);
376 // Avoid non-sketch operations
377 if ((!isSketchOpe) && (!isSketcher))
380 bool isEditing = aFOperation->isEditOperation();
382 // Ignore creation sketch operation
383 if ((!isSketcher) && (!isEditing))
386 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
387 if (!aContext.IsNull()) {
388 // MoveTo in order to highlight current object
389 aContext->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
390 ModuleBase_Tools::selectionInfo(aContext, "PartSet_SketcherMgr::onMousePressed -- MoveTo");
392 // Remember highlighted objects for editing
393 ModuleBase_ISelection* aSelect = aWorkshop->selection();
395 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
396 storeSelection(!aHasShift);
398 if (myCurrentSelection.empty()) {
399 if (isSketchOpe && (!isSketcher))
400 // commit previous operation
401 if (!aFOperation->commit())
402 aFOperation->abort();
405 // Init flyout point for radius rotation
406 FeaturePtr aFeature = myCurrentSelection.begin().key();
410 get2dPoint(theWnd, theEvent, myCurrentPoint);
413 myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);
415 if (aFeature.get() != NULL) {
416 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
417 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
418 if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
419 DataPtr aData = aSPFeature->data();
420 AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
421 std::shared_ptr<GeomDataAPI_Point2D> aFPAttr =
422 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
423 aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
426 } else if (isSketchOpe && isEditing) {
427 // If selected another object commit current result
428 aFOperation->commit();
431 get2dPoint(theWnd, theEvent, myCurrentPoint);
434 myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);
436 // this is temporary commented in order to avoid the following wrong case:
437 // Distance constraint is under edition, double click on the digit -> nothing happens
438 // because QApplication::processEvents() calls onMouseDoubleClick, which try to show editor
439 // but as the prev edit is commited an new one is not started, editor is not shown.
440 // This is necessary in order to finalize previous operation
441 //QApplication::processEvents();
447 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
449 if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent))
452 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
453 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
454 if (!aViewer->canDragByMouse())
456 ModuleBase_Operation* aOp = getCurrentOperation();
458 if (isNestedSketchOperation(aOp)) {
459 //get2dPoint(theWnd, theEvent, myClickedPoint);
461 // Only for sketcher operations
465 myCurrentSelection.clear();
466 /*Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
467 if (!aContext.IsNull()) {
468 // Reselect edited object
469 aContext->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
470 if (theEvent->modifiers() & Qt::ShiftModifier)
471 aContext->ShiftSelect();
480 aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
481 myIsDragging = false;
484 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
486 if (myModule->sketchReentranceMgr()->processMouseMoved(theWnd, theEvent))
489 if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) {
490 myIsMouseOverViewProcessed = true;
491 // 1. perform the widget mouse move functionality and display the presentation
492 // the mouse move should be processed in the widget, if it can in order to visualize correct
493 // presentation. These widgets correct the feature attribute according to the mouse position
494 ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
495 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
497 aPoint2DWdg->onMouseMove(theWnd, theEvent);
499 PartSet_WidgetPoint2dDistance* aDistanceWdg = dynamic_cast<PartSet_WidgetPoint2dDistance*>
502 aDistanceWdg->onMouseMove(theWnd, theEvent);
504 // the feature is to be erased here, but it is correct to call canDisplayObject because
505 // there can be additional check (e.g. editor widget in distance constraint)
506 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
507 (getCurrentOperation());
509 FeaturePtr aFeature = aFOperation->feature();
510 visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
514 //myClickedPoint.clear();
517 // 1. the current selection is saved in the mouse press method in order to restore it after moving
518 // 2. the enable selection in the viewer should be temporary switched off in order to ignore
519 // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
520 // deselected). This flag should be restored in the slot, processed the mouse release signal.
522 ModuleBase_Operation* aCurrentOperation = getCurrentOperation();
523 if (!aCurrentOperation)
525 if (isSketchOperation(aCurrentOperation))
526 return; // No edit operation activated
528 Handle(V3d_View) aView = theWnd->v3dView();
529 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
531 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
532 double dX = aX - myCurrentPoint.myCurX;
533 double dY = aY - myCurrentPoint.myCurY;
535 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
536 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
537 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
538 // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
539 // viewer happens by deselect/select the modified objects. The flag should be restored after
540 // the selection processing. The update viewer should be also called.
541 bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
543 static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
544 //static Events_ID aUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
545 FeatureToSelectionMap::const_iterator anIt = myCurrentSelection.begin(),
546 aLast = myCurrentSelection.end();
547 // 4. the features and attributes modification(move)
548 bool isModified = false;
549 for (; anIt != aLast; anIt++) {
550 FeaturePtr aFeature = anIt.key();
552 std::set<AttributePtr> anAttributes = anIt.value().first;
553 // Process selection by attribute: the priority to the attribute
554 if (!anAttributes.empty()) {
555 std::set<AttributePtr>::const_iterator anAttIt = anAttributes.begin(),
556 anAttLast = anAttributes.end();
557 for (; anAttIt != anAttLast; anAttIt++) {
558 AttributePtr anAttr = *anAttIt;
559 if (anAttr.get() == NULL)
561 std::string aAttrId = anAttr->id();
562 DataPtr aData = aFeature->data();
563 if (aData->isValid()) {
564 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
565 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
566 if (aPoint.get() != NULL) {
567 bool isImmutable = aPoint->setImmutable(true);
568 aPoint->move(dX, dY);
570 ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
571 aPoint->setImmutable(isImmutable);
576 // Process selection by feature
577 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
578 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
579 if (aSketchFeature) {
580 aSketchFeature->move(dX, dY);
582 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
586 // the modified state of the current operation should be updated if there are features, which
589 aCurrentOperation->onValuesChanged();
591 Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
592 //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
594 // 5. it is necessary to save current selection in order to restore it after the features moving
596 // 6. restore the update viewer flag and call this update
597 aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
598 aDisplayer->updateViewer();
601 myCurrentPoint.setValue(aX, aY);
605 void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
607 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
608 (getCurrentOperation());
609 if (aFOperation && aFOperation->isEditOperation()) {
610 std::string aId = aFOperation->id().toStdString();
611 if (isDistanceOperation(aFOperation))
613 // Activate dimension value editing on double click
614 ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
615 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
616 // Find corresponded widget to activate value editing
617 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
618 if (aWgt->attributeID() == SketchPlugin_Constraint::VALUE() ||
619 aWgt->attributeID() == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()) {
620 PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
622 anEditor->showPopupEditor();
630 void PartSet_SketcherMgr::onApplicationStarted()
632 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
633 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
634 XGUI_Workshop* aWorkshop = aConnector->workshop();
635 PartSet_SketcherReetntrantMgr* aReentranceMgr = myModule->sketchReentranceMgr();
637 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
638 if (aPropertyPanel) {
639 //connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
640 // this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
642 connect(aPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)),
643 aReentranceMgr, SLOT(onNoMoreWidgets(const std::string&)));
644 connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
645 aReentranceMgr, SLOT(onWidgetActivated()));
648 XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
649 connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort()));
650 connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort()));
652 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
653 connect(aContextMenuMgr, SIGNAL(beforeContextMenu()), this, SLOT(onBeforeContextMenu()));
654 connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu()));
657 //void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
659 //if (!myClickedPoint.myIsInitialized)
662 //ModuleBase_Operation* aOperation = getCurrentOperation();
663 // the distance constraint feature should not use the clickedd point
664 // this is workaround in order to don't throw down the flyout point value,
665 // set by execute() method of these type of features
666 //if (isDistanceOperation(aOperation))
669 //PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(theWidget);
671 // aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY);
675 void PartSet_SketcherMgr::onBeforeContextMenu()
677 myIsPopupMenuActive = true;
680 void PartSet_SketcherMgr::onAfterContextMenu()
682 myIsPopupMenuActive = false;
685 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
688 Handle(V3d_View) aView = theWnd->v3dView();
689 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
691 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
692 thePoint.setValue(aX, anY);
695 void PartSet_SketcherMgr::launchEditing()
697 if (!myCurrentSelection.empty()) {
698 FeaturePtr aFeature = myCurrentSelection.begin().key();
699 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
700 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
701 if (aSPFeature && (!aSPFeature->isExternal())) {
702 myModule->editFeature(aSPFeature);
707 bool PartSet_SketcherMgr::sketchSolverError()
709 bool anError = false;
710 CompositeFeaturePtr aSketch = activeSketch();
712 AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
713 anError = !aAttributeString->value().empty();
718 QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature)
720 std::string anError = "";
721 if (!theFeature.get() || !theFeature->data()->isValid())
722 return anError.c_str();
724 CompositeFeaturePtr aSketch = activeSketch();
725 if (aSketch.get() && aSketch == theFeature) {
726 AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
727 anError = aAttributeString->value();
728 ModuleBase_Tools::translate(aSketch->getKind(), anError);
730 return anError.c_str();
733 void PartSet_SketcherMgr::clearClickedFlags()
735 //myClickedPoint.clear();
736 myCurrentPoint.clear();
739 const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
741 static QStringList aIds;
742 if (aIds.size() == 0) {
743 aIds << SketchPlugin_Line::ID().c_str();
744 aIds << SketchPlugin_Point::ID().c_str();
745 aIds << SketchPlugin_Arc::ID().c_str();
746 aIds << SketchPlugin_Circle::ID().c_str();
747 aIds << SketchPlugin_ConstraintFillet::ID().c_str();
748 aIds << SketchPlugin_IntersectionPoint::ID().c_str();
750 // SketchRectangle is a python feature, so its ID is passed just as a string
751 aIds << "SketchRectangle";
752 aIds.append(replicationsIdList());
753 aIds.append(constraintsIdList());
758 const QStringList& PartSet_SketcherMgr::replicationsIdList()
760 static QStringList aReplicationIds;
761 if (aReplicationIds.size() == 0) {
762 aReplicationIds << SketchPlugin_ConstraintMirror::ID().c_str();
763 aReplicationIds << SketchPlugin_MultiRotation::ID().c_str();
764 aReplicationIds << SketchPlugin_MultiTranslation::ID().c_str();
766 return aReplicationIds;
769 const QStringList& PartSet_SketcherMgr::constraintsIdList()
771 static QStringList aConstraintIds;
772 if (aConstraintIds.size() == 0) {
773 aConstraintIds << SketchPlugin_ConstraintLength::ID().c_str();
774 aConstraintIds << SketchPlugin_ConstraintDistance::ID().c_str();
775 aConstraintIds << SketchPlugin_ConstraintRigid::ID().c_str();
776 aConstraintIds << SketchPlugin_ConstraintRadius::ID().c_str();
777 aConstraintIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
778 aConstraintIds << SketchPlugin_ConstraintParallel::ID().c_str();
779 aConstraintIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
780 aConstraintIds << SketchPlugin_ConstraintVertical::ID().c_str();
781 aConstraintIds << SketchPlugin_ConstraintEqual::ID().c_str();
782 aConstraintIds << SketchPlugin_ConstraintTangent::ID().c_str();
783 aConstraintIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
784 aConstraintIds << SketchPlugin_ConstraintAngle::ID().c_str();
785 aConstraintIds << SketchPlugin_ConstraintCollinear::ID().c_str();
786 aConstraintIds << SketchPlugin_ConstraintMiddle::ID().c_str();
788 return aConstraintIds;
791 void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
795 theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
796 theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
797 theModes.append(SketcherPrs_Tools::Sel_Constraint);
798 theModes.append(TopAbs_VERTEX);
799 theModes.append(TopAbs_EDGE);
802 Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ResultPtr& theResult)
804 Handle(AIS_InteractiveObject) aPrs;
806 FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
807 if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) {
808 aPrs = new PartSet_ResultSketchPrs(theResult);
813 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
815 return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
818 bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
820 return theOperation &&
821 PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
824 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation)
826 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
828 return aFOperation && !aFOperation->isEditOperation() && isNestedSketchOperation(aFOperation);
831 bool PartSet_SketcherMgr::isNestedEditOperation(ModuleBase_Operation* theOperation)
833 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
835 return aFOperation && aFOperation->isEditOperation() && isNestedSketchOperation(aFOperation);
838 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
840 return (theId == SketchPlugin_Line::ID()) ||
841 (theId == SketchPlugin_Point::ID()) ||
842 (theId == SketchPlugin_Arc::ID()) ||
843 (theId == SketchPlugin_Circle::ID());
846 bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
848 std::string anId = theOperation ? theOperation->id().toStdString() : "";
850 return isDistanceKind(anId);
853 bool PartSet_SketcherMgr::isDistanceKind(std::string& theKind)
855 return (theKind == SketchPlugin_ConstraintLength::ID()) ||
856 (theKind == SketchPlugin_ConstraintDistance::ID()) ||
857 (theKind == SketchPlugin_ConstraintRadius::ID()) ||
858 (theKind == SketchPlugin_ConstraintAngle::ID());
861 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
863 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
864 (getCurrentOperation());
868 myModule->onViewTransformed();
870 // Display all sketcher sub-Objects
871 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFOperation->feature());
872 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
874 // Hide sketcher result
875 std::list<ResultPtr> aResults = myCurrentSketch->results();
876 std::list<ResultPtr>::const_iterator aIt;
877 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
878 (*aIt)->setDisplayed(false);
880 myCurrentSketch->setDisplayed(false);
882 // Display sketcher objects
883 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
884 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
885 std::list<ResultPtr> aResults = aFeature->results();
886 std::list<ResultPtr>::const_iterator aIt;
887 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
888 (*aIt)->setDisplayed(true);
890 aFeature->setDisplayed(true);
893 if(myCirclePointFilter.IsNull()) {
894 myCirclePointFilter = new PartSet_CirclePointFilter(myModule->workshop());
897 myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
899 if (myPlaneFilter.IsNull())
900 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
902 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
903 bool aHasPlane = false;
904 std::shared_ptr<GeomAPI_Pln> aPln;
905 aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
906 myPlaneFilter->setPlane(aPln);
908 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
909 // all displayed objects should be activated in current selection modes according to switched
912 aConnector->activateModuleSelectionModes();
915 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
917 myIsMouseOverWindow = false;
918 myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
919 myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
920 myIsConstraintsShown[PartSet_Tools::Expressions] = false;
922 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
924 DataPtr aData = myCurrentSketch->data();
925 if (!aData->isValid()) {
926 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
927 // The sketch was aborted
928 myCurrentSketch = CompositeFeaturePtr();
929 // TODO: move this outside of if-else
930 myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
931 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
933 // Erase all sketcher objects
934 QStringList aSketchIds = sketchOperationIdList();
935 QObjectPtrList aObjects = aDisplayer->displayedObjects();
936 foreach (ObjectPtr aObj, aObjects) {
937 DataPtr aObjData = aObj->data();
938 if (!aObjData->isValid())
939 aObj->setDisplayed(false);
943 // Hide all sketcher sub-Objects
944 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
945 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
946 std::list<ResultPtr> aResults = aFeature->results();
947 std::list<ResultPtr>::const_iterator aIt;
948 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
949 (*aIt)->setDisplayed(false);
951 aFeature->setDisplayed(false);
953 // Display sketcher result
954 std::list<ResultPtr> aResults = myCurrentSketch->results();
955 std::list<ResultPtr>::const_iterator aIt;
956 Events_Loop* aLoop = Events_Loop::loop();
957 static Events_ID aDispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
959 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
961 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
962 if (!aFOperation->isDisplayedOnStart(*aIt)) {
963 (*aIt)->setDisplayed(true);
964 // this display event is needed because sketch already may have "displayed" state,
965 // but not displayed while it is still active (issue 613, abort of existing sketch)
966 ModelAPI_EventCreator::get()->sendUpdated(*aIt, aDispEvent);
969 if (!aFOperation->isDisplayedOnStart(myCurrentSketch))
970 myCurrentSketch->setDisplayed(true);
972 myCurrentSketch = CompositeFeaturePtr();
974 myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
975 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
977 Events_Loop::loop()->flush(aDispEvent);
979 // restore the module selection modes, which were changed on startSketch
980 aConnector->activateModuleSelectionModes();
983 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
985 if (canChangeCursor(theOperation) && myIsMouseOverWindow) {
986 QCursor* aCurrentCursor = QApplication::overrideCursor();
987 if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
988 QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
990 qDebug("startNestedSketch() : Qt::CrossCursor");
996 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
998 myIsMouseOverViewProcessed = true;
999 operationMgr()->onValidateOperation();
1000 if (canChangeCursor(theOperation)) {
1001 QApplication::restoreOverrideCursor();
1003 qDebug("stopNestedSketch() : None");
1008 void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
1010 if (isNestedCreateOperation(theOperation)) {
1011 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1014 FeaturePtr aFeature = aFOperation->feature();
1015 // it is necessary to check the the feature data validity because
1016 // some kind of features are removed by an operation commit(the macro state of a feature)
1017 if (aFeature.get() && aFeature->data()->isValid()) {
1018 visualizeFeature(aFeature, aFOperation->isEditOperation(), true);
1024 void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
1027 myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
1029 myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
1032 bool PartSet_SketcherMgr::operationActivatedByPreselection()
1034 bool isOperationStopped = false;
1035 ModuleBase_Operation* anOperation = getCurrentOperation();
1036 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
1037 // Set final definitions if they are necessary
1038 //propertyPanelDefined(aOperation);
1039 /// Commit sketcher operations automatically
1040 /// distance operation are able to show popup editor to modify the distance value
1041 /// after entering the value, the operation should be committed/aborted(by Esc key)
1042 bool aCanCommitOperation = true;
1043 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1045 if (aFOperation && PartSet_SketcherMgr::isDistanceOperation(aFOperation)) {
1046 bool aValueAccepted = setDistanceValueByPreselection(anOperation, myModule->workshop(),
1047 aCanCommitOperation);
1048 if (!aValueAccepted)
1049 return isOperationStopped;
1052 if (aCanCommitOperation)
1053 isOperationStopped = anOperation->commit();
1055 anOperation->abort();
1056 isOperationStopped = true;
1059 return isOperationStopped;
1062 bool PartSet_SketcherMgr::canUndo() const
1064 return isNestedCreateOperation(getCurrentOperation());
1067 bool PartSet_SketcherMgr::canRedo() const
1069 return isNestedCreateOperation(getCurrentOperation());
1072 bool PartSet_SketcherMgr::canEraseObject(const ObjectPtr& theObject) const
1074 bool aCanErase = true;
1075 // when the sketch operation is active, results of sketch sub-feature can not be hidden
1076 if (myCurrentSketch.get()) {
1077 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
1078 if (aResult.get()) {
1079 // Display sketcher objects
1080 for (int i = 0; i < myCurrentSketch->numberOfSubs() && aCanErase; i++) {
1082 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
1083 std::list<ResultPtr> aResults = aFeature->results();
1084 std::list<ResultPtr>::const_iterator anIt;
1085 for (anIt = aResults.begin(); anIt != aResults.end() && aCanErase; ++anIt) {
1086 aCanErase = *anIt != aResult;
1094 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
1096 bool aCanDisplay = true;
1098 bool aHasActiveSketch = activeSketch().get() != NULL;
1099 if (aHasActiveSketch) {
1100 // 1. the sketch feature should not be displayed during the sketch active operation
1101 // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
1102 // nested features can be visualized
1103 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1104 if (aFeature.get() != NULL && aFeature == activeSketch()) {
1105 aCanDisplay = false;
1107 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
1108 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
1109 /// some sketch entities should be never shown, e.g. projection feature
1110 if (aSketchFeature.get())
1111 aCanDisplay = aSketchFeature->canBeDisplayed();
1113 else { // there are no an active sketch
1114 // 2. sketch sub-features should not be visualized if the sketch operation is not active
1115 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1116 if (aFeature.get() != NULL) {
1117 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
1118 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
1119 if (aSketchFeature.get()) {
1120 aCanDisplay = false;
1125 // 3. the method should not filter the objects, which are not related to the current operation.
1126 // The object is filtered just if it is a current operation feature or this feature result
1128 bool isObjectFound = false;
1129 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1130 (getCurrentOperation());
1132 FeaturePtr aFeature = aFOperation->feature();
1133 if (aFeature.get()) {
1134 std::list<ResultPtr> aResults = aFeature->results();
1135 if (theObject == aFeature)
1136 isObjectFound = true;
1138 std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
1139 for (; anIt != aLast && !isObjectFound; anIt++) {
1140 isObjectFound = *anIt == theObject;
1145 if (isObjectFound) {
1146 // 4. For created nested feature operation do not display the created feature if
1147 // the mouse curstor leaves the OCC window.
1148 // The correction cases, which ignores this condition:
1149 // a. the property panel values modification
1150 // b. the popup menu activated
1151 // c. widget editor control
1152 #ifndef DEBUG_DO_NOT_BY_ENTER
1153 if (isNestedCreateOperation(getCurrentOperation())) {
1154 ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
1155 ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWidget) : 0;
1156 // the active widget editor should not influence here. The presentation should be visible always
1157 // when this widget is active.
1158 if (!anEditorWdg && !myIsPopupMenuActive) {
1159 // during a nested create operation, the feature is redisplayed only if the mouse over view
1160 // of there was a value modified in the property panel after the mouse left the view
1161 aCanDisplay = canDisplayCurrentCreatedFeature();
1168 // checks the sketcher constraints visibility according to active sketch check box states
1170 bool aProcessed = false;
1171 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1172 if (aFeature.get()) {
1173 bool aConstraintDisplayed = canDisplayConstraint(aFeature, PartSet_Tools::Any, aProcessed);
1175 aCanDisplay = aConstraintDisplayed;
1182 bool PartSet_SketcherMgr::canDisplayConstraint(const FeaturePtr& theFeature,
1183 const PartSet_Tools::ConstraintVisibleState& theState,
1184 bool& isProcessed) const
1186 bool aSwitchedOn = true;
1188 const QStringList& aConstrIds = constraintsIdList();
1190 std::string aKind = theFeature->getKind();
1191 if (aConstrIds.contains(QString(aKind.c_str()))) {
1192 bool isTypedConstraint = false;
1195 case PartSet_Tools::Dimensional: {
1196 bool isDistance = isDistanceKind(aKind);
1199 aSwitchedOn = myIsConstraintsShown[theState];
1203 case PartSet_Tools::Geometrical: {
1204 bool isGeometrical = !isDistanceKind(aKind);
1205 if (isGeometrical) {
1207 aSwitchedOn = myIsConstraintsShown[theState];
1211 case PartSet_Tools::Any: {
1213 bool isDistance = isDistanceKind(aKind);
1215 aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Dimensional];
1217 aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Geometrical];
1227 /*void PartSet_SketcherMgr::processHiddenObject(const std::list<ObjectPtr>& theObjects)
1229 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1230 (getCurrentOperation());
1231 if (aFOperation && myCurrentSketch.get()) {
1232 // find results of the current operation
1233 // these results should not be proposed to be deleted
1234 FeaturePtr anOperationFeature = aFOperation->feature();
1235 std::list<ResultPtr> anOperationResultList = anOperationFeature->results();
1236 std::set<ResultPtr> anOperationResults;
1237 std::list<ResultPtr>::const_iterator aRIt = anOperationResultList.begin(),
1238 aRLast = anOperationResultList.end();
1239 for (; aRIt != aRLast; aRIt++)
1240 anOperationResults.insert(*aRIt);
1242 std::set<FeaturePtr> anObjectsToBeDeleted;
1243 QStringList anObjectsToBeDeletedNames;
1244 std::list<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1245 for (; anIt != aLast; anIt++) {
1246 ObjectPtr anObject = *anIt;
1247 bool aCanErase = true;
1248 // when the sketch operation is active, results of sketch sub-feature can not be hidden
1249 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
1250 // the result is found between current feature results
1251 if (anOperationResults.find(aResult) != anOperationResults.end())
1254 if (aResult.get()) {
1255 // Display sketcher objects
1256 for (int i = 0; i < myCurrentSketch->numberOfSubs() && aCanErase; i++) {
1257 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
1258 std::list<ResultPtr> aResults = aFeature->results();
1259 std::list<ResultPtr>::const_iterator anIt;
1260 for (anIt = aResults.begin(); anIt != aResults.end() && aCanErase; ++anIt) {
1261 aCanErase = *anIt != aResult;
1266 FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
1267 if (aFeature.get() && anObjectsToBeDeleted.find(aFeature) == anObjectsToBeDeleted.end()) {
1268 anObjectsToBeDeleted.insert(aFeature);
1269 anObjectsToBeDeletedNames.append(aFeature->name().c_str());
1273 if (!anObjectsToBeDeleted.empty()) {
1274 QString aFeatureNames = anObjectsToBeDeletedNames.join(", ");
1275 QString aMessage = tr("The following features have incorrect presentation and \
1276 will be hidden: %1. Would you like to delete them?")
1277 .arg(aFeatureNames);
1278 int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Features hide"),
1279 aMessage, QMessageBox::Ok | QMessageBox::Cancel,
1280 QMessageBox::Cancel);
1281 if (anAnswer == QMessageBox::Ok) {
1282 QObjectPtrList anObjects;
1283 std::set<FeaturePtr>::const_iterator anIt = anObjectsToBeDeleted.begin(),
1284 aLast = anObjectsToBeDeleted.end();
1285 for (; anIt != aLast; anIt++)
1286 anObjects.append(*anIt);
1287 SessionPtr aMgr = ModelAPI_Session::get();
1288 DocumentPtr aDoc = aMgr->activeDocument();
1289 bool aIsOp = aMgr->isOperation();
1291 aMgr->startOperation();
1292 workshop()->deleteFeatures(anObjects);
1293 //static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
1294 //static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
1295 //Events_Loop::loop()->flush(aDeletedEvent);
1296 //Events_Loop::loop()->flush(aRedispEvent);
1299 aMgr->finishOperation();
1305 bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
1307 bool aCanDisplay = myIsMouseOverWindow;
1309 ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
1311 aCanDisplay = anActiveWidget->getValueState() == ModuleBase_ModelWidget::Stored;
1316 bool PartSet_SketcherMgr::canChangeCursor(ModuleBase_Operation* theOperation) const
1318 return isNestedCreateOperation(theOperation) ||
1319 myModule->sketchReentranceMgr()->isInternalEditActive();
1322 const QMap<PartSet_Tools::ConstraintVisibleState, bool>& PartSet_SketcherMgr::showConstraintStates()
1324 return myIsConstraintsShown;
1327 bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
1329 bool isFoundObject = false;
1331 FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
1332 if (anObjectFeature.get()) {
1333 int aSize = myCurrentSketch->numberOfSubs();
1334 for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
1335 FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
1336 isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
1339 return isFoundObject;
1342 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
1344 if (myPlaneFilter.IsNull())
1345 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
1347 myPlaneFilter->setPlane(thePln);
1350 bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation,
1351 ModuleBase_IWorkshop* theWorkshop,
1352 bool& theCanCommitOperation)
1354 bool isValueAccepted = false;
1355 theCanCommitOperation = false;
1357 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1359 FeaturePtr aFeature = aFOperation->feature();
1360 // editor is shown only if all attribute references are filled by preseletion
1361 bool anAllRefAttrInitialized = true;
1363 std::list<AttributePtr> aRefAttrs = aFeature->data()->attributes(
1364 ModelAPI_AttributeRefAttr::typeId());
1365 std::list<AttributePtr>::const_iterator anIt = aRefAttrs.begin(), aLast = aRefAttrs.end();
1366 for (; anIt != aLast && anAllRefAttrInitialized; anIt++) {
1367 anAllRefAttrInitialized = (*anIt)->isInitialized();
1369 if (anAllRefAttrInitialized) {
1370 // Activate dimension value editing on double click
1371 ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
1372 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
1373 // Find corresponded widget to activate value editing
1374 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
1375 if (aWgt->attributeID() == "ConstraintValue") {
1376 // the featue should be displayed in order to find the AIS text position,
1377 // the place where the editor will be shown
1378 aFeature->setDisplayed(true);
1379 /// the execute is necessary to perform in the feature compute for flyout position
1380 aFeature->execute();
1382 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
1383 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1385 PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
1387 int aX = 0, anY = 0;
1389 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(theWorkshop);
1390 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
1391 AISObjectPtr anAIS = aDisplayer->getAISObject(aFeature);
1392 Handle(AIS_InteractiveObject) anAISIO;
1393 if (anAIS.get() != NULL) {
1394 anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
1396 if (anAIS.get() != NULL) {
1397 Handle(AIS_InteractiveObject) anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
1399 if (!anAISIO.IsNull()) {
1400 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAISIO);
1401 if (!aDim.IsNull()) {
1402 gp_Pnt aPosition = aDim->GetTextPosition();
1404 ModuleBase_IViewer* aViewer = aWorkshop->viewer();
1405 Handle(V3d_View) aView = aViewer->activeView();
1407 aView->Convert(aPosition.X(), aPosition.Y(), aPosition.Z(), aCX, aCY);
1409 QWidget* aViewPort = aViewer->activeViewPort();
1410 QPoint aGlPoint = aViewPort->mapToGlobal(QPoint(aCX, aCY));
1415 anEditor->setCursorPosition(aX, anY);
1416 isValueAccepted = anEditor->showPopupEditor(false);
1417 theCanCommitOperation = true;
1423 return isValueAccepted;
1426 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
1427 const FeaturePtr& theSketch,
1428 ModuleBase_IWorkshop* theWorkshop,
1429 FeatureToSelectionMap& theSelection)
1431 if (theFeature.get() == NULL)
1434 std::set<AttributePtr> aSelectedAttributes;
1435 std::set<ResultPtr> aSelectedResults;
1437 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
1438 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
1439 if (!aContext.IsNull()) {
1440 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
1441 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1443 std::list<ResultPtr> aResults = theFeature->results();
1444 std::list<ResultPtr>::const_iterator aIt;
1445 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
1447 ResultPtr aResult = *aIt;
1448 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
1449 if (aAISObj.get() == NULL)
1451 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1452 for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
1454 Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
1455 if (anOwner->Selectable() != anAISIO)
1457 getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
1458 aSelectedAttributes, aSelectedResults);
1460 for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
1461 Handle(SelectMgr_EntityOwner) anOwner = aContext->DetectedOwner();
1462 if (anOwner.IsNull())
1464 if (anOwner->Selectable() != anAISIO)
1466 getAttributesOrResults(anOwner, theFeature, theSketch, aResult,
1467 aSelectedAttributes, aSelectedResults);
1471 theSelection[theFeature] = std::make_pair(aSelectedAttributes, aSelectedResults);
1474 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
1475 const FeaturePtr& theSketch,
1476 ModuleBase_IWorkshop* theWorkshop,
1477 const FeatureToSelectionMap& theSelection,
1478 SelectMgr_IndexedMapOfOwner& theOwnersToSelect)
1480 if (theFeature.get() == NULL)
1483 FeatureToSelectionMap::const_iterator anIt = theSelection.find(theFeature);
1484 std::set<AttributePtr> aSelectedAttributes = anIt.value().first;
1485 std::set<ResultPtr> aSelectedResults = anIt.value().second;
1487 ModuleBase_IViewer* aViewer = theWorkshop->viewer();
1489 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
1490 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
1492 // 1. found the feature's owners. Check the AIS objects of the constructions
1493 AISObjectPtr aAISObj = aDisplayer->getAISObject(theFeature);
1494 if (aAISObj.get() != NULL && aSelectedAttributes.empty() && aSelectedResults.empty()) {
1495 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1497 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1498 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1499 for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
1500 Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
1501 if (!anOwner.IsNull())
1502 theOwnersToSelect.Add(anOwner);
1506 // 2. found the feature results's owners
1507 std::list<ResultPtr> aResults = theFeature->results();
1508 std::list<ResultPtr>::const_iterator aIt;
1509 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
1511 ResultPtr aResult = *aIt;
1512 AISObjectPtr aAISObj = aDisplayer->getAISObject(aResult);
1513 if (aAISObj.get() == NULL)
1515 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1517 SelectMgr_IndexedMapOfOwner aSelectedOwners;
1518 aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
1519 for ( Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++ ) {
1520 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(aSelectedOwners(i));
1521 if ( anOwner.IsNull() || !anOwner->HasShape() )
1523 const TopoDS_Shape& aShape = anOwner->Shape();
1524 TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
1525 if (aShapeType == TopAbs_VERTEX) {
1526 AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(theFeature, aShape, theSketch);
1527 if (aPntAttr.get() != NULL &&
1528 aSelectedAttributes.find(aPntAttr) != aSelectedAttributes.end()) {
1529 theOwnersToSelect.Add(anOwner);
1532 else if (aShapeType == TopAbs_EDGE) {
1533 bool aFound = aSelectedResults.find(aResult) != aSelectedResults.end();
1534 if (aSelectedResults.find(aResult) != aSelectedResults.end() &&
1535 theOwnersToSelect.FindIndex(anOwner) <= 0)
1536 theOwnersToSelect.Add(anOwner);
1542 void PartSet_SketcherMgr::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect)
1545 connect(theWidget, SIGNAL(beforeValuesChanged()),
1546 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1547 connect(theWidget, SIGNAL(afterValuesChanged()),
1548 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1551 disconnect(theWidget, SIGNAL(beforeValuesChanged()),
1552 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
1553 disconnect(theWidget, SIGNAL(afterValuesChanged()),
1554 this, SLOT(onAfterValuesChangedInPropertyPanel()));
1558 void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
1560 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1561 (getCurrentOperation());
1563 if (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
1564 PartSet_SketcherMgr::isNestedSketchOperation(aFOperation) &&
1565 thePreviousState == ModuleBase_ModelWidget::ModifiedInPP) {
1566 FeaturePtr aFeature = aFOperation->feature();
1567 visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
1572 void PartSet_SketcherMgr::customizePresentation(const ObjectPtr& theObject)
1574 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
1575 (getCurrentOperation());
1576 if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
1577 PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)))
1578 SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
1581 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
1583 return myModule->workshop()->currentOperation();
1586 //**************************************************************
1587 ModuleBase_ModelWidget* PartSet_SketcherMgr::getActiveWidget() const
1589 ModuleBase_ModelWidget* aWidget = 0;
1590 ModuleBase_Operation* anOperation = getCurrentOperation();
1592 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
1594 aWidget = aPanel->activeWidget();
1599 void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature,
1600 const bool isEditOperation,
1601 const bool isToDisplay,
1602 const bool isFlushRedisplay)
1604 #ifdef DEBUG_DO_NOT_BY_ENTER
1608 if (isEditOperation || !theFeature.get())
1611 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1612 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1614 // 1. change visibility of the object itself, here the presentable object is processed,
1615 // e.g. constraints features
1616 //FeaturePtr aFeature = aFOperation->feature();
1617 std::list<ResultPtr> aResults = theFeature->results();
1619 theFeature->setDisplayed(true);
1621 theFeature->setDisplayed(false);
1623 // change visibility of the object results, e.g. non-constraint features
1624 std::list<ResultPtr>::const_iterator aIt;
1625 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
1627 (*aIt)->setDisplayed(true);
1630 (*aIt)->setDisplayed(false);
1633 if (isFlushRedisplay)
1634 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1637 void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
1639 if (!myCurrentSketch.get())
1642 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1643 ModuleBase_ISelection* aSelect = aWorkshop->selection();
1644 QList<ModuleBase_ViewerPrsPtr> aHighlighted = aSelect->getHighlighted();
1646 QList<FeaturePtr> aFeatureList;
1647 if (theHighlightedOnly) {
1648 fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList);
1651 fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList);
1653 QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls);
1654 fillFeatureList(aSelected, myCurrentSketch, aFeatureList);
1657 // 1. it is necessary to save current selection in order to restore it after the features moving
1658 myCurrentSelection.clear();
1659 QList<FeaturePtr>::const_iterator anIt = aFeatureList.begin(), aLast = aFeatureList.end();
1660 for (; anIt != aLast; anIt++) {
1661 getCurrentSelection(*anIt, myCurrentSketch, aWorkshop, myCurrentSelection);
1663 //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1666 void PartSet_SketcherMgr::restoreSelection()
1668 if (!myCurrentSketch.get())
1671 //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
1672 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1673 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1674 FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
1675 aSLast = myCurrentSelection.end();
1676 SelectMgr_IndexedMapOfOwner anOwnersToSelect;
1677 for (; aSIt != aSLast; aSIt++) {
1678 anOwnersToSelect.Clear();
1679 getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
1681 aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
1685 void PartSet_SketcherMgr::onShowConstraintsToggle(int theType, bool theState)
1687 PartSet_Tools::ConstraintVisibleState aType = (PartSet_Tools::ConstraintVisibleState)theType;
1689 updateBySketchParameters(aType, theState);
1692 void PartSet_SketcherMgr::updateBySketchParameters(
1693 const PartSet_Tools::ConstraintVisibleState& theType,
1696 if (myCurrentSketch.get() == NULL)
1699 bool aPrevState = myIsConstraintsShown[theType];
1700 myIsConstraintsShown[theType] = theState;
1703 case PartSet_Tools::Geometrical:
1704 case PartSet_Tools::Dimensional: {
1705 if (aPrevState != theState) {
1706 ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
1707 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
1708 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
1709 FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
1710 bool aProcessed = false;
1711 bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, theType, aProcessed);
1713 aSubFeature->setDisplayed(aConstraintDisplayed);
1715 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
1719 case PartSet_Tools::Expressions: {
1720 if (aPrevState != theState) {
1721 /// call all sketch features redisplay, the expression state will be corrected in customize
1722 /// of distance presentation
1723 Events_ID anEventId = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
1724 PartSet_Tools::sendSubFeaturesEvent(myCurrentSketch, anEventId);
1731 XGUI_Workshop* PartSet_SketcherMgr::workshop() const
1733 ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
1734 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
1735 return aConnector->workshop();
1738 XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const
1740 return workshop()->operationMgr();