1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include "PartSet_Module.h"
4 #include <PartSet_WidgetSketchLabel.h>
5 #include <PartSet_Validators.h>
6 #include <PartSet_Tools.h>
7 #include <PartSet_WidgetPoint2d.h>
8 #include <PartSet_WidgetPoint2dDistance.h>
9 #include <PartSet_WidgetShapeSelector.h>
10 #include <PartSet_WidgetConstraintShapeSelector.h>
11 #include <PartSet_WidgetEditor.h>
12 #include <PartSet_SketcherMgr.h>
14 #include <ModuleBase_Operation.h>
15 #include <ModuleBase_IViewer.h>
16 #include <ModuleBase_IViewWindow.h>
17 #include <ModuleBase_IPropertyPanel.h>
18 #include <ModuleBase_WidgetEditor.h>
19 #include <ModuleBase_FilterFactory.h>
20 #include <ModuleBase_FilterLinearEdge.h>
21 #include <ModuleBase_FilterFace.h>
22 #include <ModuleBase_FilterMulti.h>
23 #include <ModuleBase_FilterCustom.h>
24 #include <ModuleBase_FilterNoConsructionSubShapes.h>
25 #include <GeomValidators_Edge.h>
26 #include <GeomValidators_EdgeOrVertex.h>
27 #include <GeomValidators_Face.h>
28 #include <GeomValidators_ConstructionComposite.h>
30 #include <PartSet_FilterSketchEntity.h>
32 #include <ModelAPI_Object.h>
33 #include <ModelAPI_Events.h>
34 #include <ModelAPI_Validator.h>
35 #include <ModelAPI_Data.h>
36 #include <ModelAPI_Session.h>
37 #include <ModelAPI_ShapeValidator.h>
39 #include <GeomDataAPI_Point2D.h>
40 #include <GeomDataAPI_Point.h>
41 #include <GeomDataAPI_Dir.h>
43 #include <XGUI_Displayer.h>
44 #include <XGUI_Workshop.h>
45 #include <XGUI_OperationMgr.h>
46 #include <XGUI_PropertyPanel.h>
47 #include <XGUI_ModuleConnector.h>
48 #include <XGUI_ContextMenuMgr.h>
49 #include <XGUI_Tools.h>
51 #include <SketchPlugin_Feature.h>
52 #include <SketchPlugin_Sketch.h>
53 #include <SketchPlugin_Line.h>
54 //#include <SketchPlugin_Arc.h>
55 //#include <SketchPlugin_Circle.h>
56 #include <SketchPlugin_ConstraintLength.h>
57 #include <SketchPlugin_ConstraintDistance.h>
58 #include <SketchPlugin_ConstraintParallel.h>
59 #include <SketchPlugin_ConstraintPerpendicular.h>
60 #include <SketchPlugin_ConstraintRadius.h>
62 #include <SketcherPrs_SymbolPrs.h>
63 #include <SketcherPrs_Tools.h>
65 #include <Events_Loop.h>
66 #include <Config_PropManager.h>
67 #include <Config_Keywords.h>
69 #include <StdSelect_TypeOfFace.hxx>
70 #include <TopoDS_Vertex.hxx>
72 #include <TopoDS_Shape.hxx>
73 #include <BRep_Tool.hxx>
74 #include <AIS_Dimension.hxx>
77 #include <QMouseEvent>
80 #include <QApplication>
81 #include <QMessageBox>
82 #include <QMainWindow>
84 #include <GeomAlgoAPI_FaceBuilder.h>
85 #include <GeomDataAPI_Dir.h>
91 /*!Create and return new instance of XGUI_Module*/
92 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
94 return new PartSet_Module(theWshop);
97 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
98 : ModuleBase_IModule(theWshop),
99 myRestartingMode(RM_None), myVisualLayerId(0)
101 mySketchMgr = new PartSet_SketcherMgr(this);
103 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
104 XGUI_Workshop* aWorkshop = aConnector->workshop();
106 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
107 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
108 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
109 this, SLOT(onOperationActivatedByPreselection()));
111 ModuleBase_IViewer* aViewer = theWshop->viewer();
112 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
113 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
114 connect(aViewer, SIGNAL(viewTransformed(int)),
115 SLOT(onViewTransformed(int)));
120 PartSet_Module::~PartSet_Module()
122 if (!myDocumentShapeFilter.IsNull())
123 myDocumentShapeFilter.Nullify();
126 void PartSet_Module::registerValidators()
128 //Registering of validators
129 SessionPtr aMgr = ModelAPI_Session::get();
130 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
131 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
132 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
133 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
134 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
135 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
136 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
137 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
138 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
140 aFactory->registerValidator("GeomValidators_Edge", new GeomValidators_Edge);
141 aFactory->registerValidator("GeomValidators_EdgeOrVertex",
142 new GeomValidators_EdgeOrVertex);
143 aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
145 aFactory->registerValidator("GeomValidators_ConstructionComposite",
146 new GeomValidators_ConstructionComposite);
148 aFactory->registerValidator("PartSet_SketchEntityValidator",
149 new PartSet_SketchEntityValidator);
151 aFactory->registerValidator("PartSet_SameTypeAttr",
152 new PartSet_SameTypeAttrValidator);
155 void PartSet_Module::registerFilters()
157 //Registering of selection filters
158 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
159 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
161 //aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
162 //aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
163 //aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
164 //Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
165 //aFactory->registerFilter("NoConstructionSubShapesFilter",
166 // new ModuleBase_FilterCustom(aSelectFilter));
167 //Handle(SelectMgr_Filter) aSelectFilter = new PartSet_FilterSketchEntity(workshop());
168 //aFactory->registerFilter("SketchEntityFilter", new ModuleBase_FilterCustom(aSelectFilter));
171 void PartSet_Module::registerProperties()
173 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
175 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
176 Config_Prop::Integer, SKETCH_WIDTH);
179 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
181 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
182 mySketchMgr->commitNestedSketch(theOperation);
185 if (theOperation->isEditOperation())
187 // the selection is cleared after commit the create operation
188 // in order to do not use the same selected objects in the restarted operation
189 // for common behaviour, the selection is cleared even if the operation is not restarted
190 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
191 if (!aContext.IsNull())
192 aContext->ClearSelected();
194 /// Restart sketcher operations automatically
195 FeaturePtr aFeature = theOperation->feature();
196 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
197 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
198 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
199 myRestartingMode == RM_EmptyFeatureUsed)) {
200 myLastOperationId = theOperation->id();
201 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
203 launchOperation(myLastOperationId);
205 breakOperationSequence();
208 void PartSet_Module::breakOperationSequence()
210 myLastOperationId = "";
211 myLastFeature = FeaturePtr();
212 myRestartingMode = RM_None;
215 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
217 breakOperationSequence();
220 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
222 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
223 Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
224 aViewer->AddZLayer(myVisualLayerId);
225 mySketchMgr->startSketch(theOperation);
227 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
228 mySketchMgr->startNestedSketch(theOperation);
231 if (myDocumentShapeFilter.IsNull())
232 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
233 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
236 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
238 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
239 mySketchMgr->stopSketch(theOperation);
240 Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
241 aViewer->RemoveZLayer(myVisualLayerId);
244 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
245 mySketchMgr->stopNestedSketch(theOperation);
247 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
250 ModuleBase_Operation* PartSet_Module::currentOperation() const
252 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
253 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
254 return anOpMgr->currentOperation();
257 bool PartSet_Module::canUndo() const
259 bool aCanUndo = false;
260 SessionPtr aMgr = ModelAPI_Session::get();
261 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
262 aCanUndo = !aMgr->isOperation();
263 if (!aCanUndo) // check the enable state additionally by sketch manager
264 aCanUndo = aMgr->canUndo();
269 bool PartSet_Module::canRedo() const
271 bool aCanRedo = false;
272 SessionPtr aMgr = ModelAPI_Session::get();
273 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
274 aCanRedo = !aMgr->isOperation();
275 if (!aCanRedo) // check the enable state additionally by sketch manager
276 aCanRedo = aMgr->canRedo();
281 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
283 // the display should be possible almost always, with exception of some specific cases
285 bool aCanDisplay = true;
287 if (mySketchMgr->activeSketch()) {
288 aCanDisplay = mySketchMgr->canDisplayObject(theObject);
293 bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
295 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
296 if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
297 !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
300 ModuleBase_ISelection* aSelection = myWorkshop->selection();
301 QObjectPtrList aObjects = aSelection->selectedPresentations();
302 if (aObjects.size() > 0) {
303 bool hasFeature = false;
304 foreach(ObjectPtr aObject, aObjects)
306 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
307 if (aFeature.get() != NULL) {
312 theMenu->addAction(theStdActions["DELETE_CMD"]);
316 if (mySketchMgr->canSetAuxiliary(isAuxiliary)) {
317 QAction* anAction = action("AUXILIARY_CMD");
318 theMenu->addAction(anAction);
319 anAction->setChecked(isAuxiliary);
324 bool PartSet_Module::isMouseOverWindow()
326 return mySketchMgr->isMouseOverWindow();
329 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
331 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
332 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
333 // we have to manually activate the sketch label in edit mode
334 aPanel->activateWidget(aPanel->modelWidgets().first());
338 // Restart last operation type
339 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
340 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
341 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
342 // Initialise new line with first point equal to end of previous
343 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
345 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
346 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
347 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
349 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
350 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
351 aWgt->attributeID(), aPoint->x(), aPoint->y());
352 aPanel->activateNextWidget(aPnt2dWgt);
357 // Start editing constraint
358 if (theOperation->isEditOperation()) {
359 // TODO: #391 - to be removed
360 std::string aId = theOperation->id().toStdString();
361 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
362 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
363 // Find and activate widget for management of point for dimension line position
364 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
365 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
366 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
368 aPanel->activateWidget(aPntWgt);
378 void PartSet_Module::onSelectionChanged()
380 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
384 bool isSketcherOp = false;
385 // An edit operation is enable only if the current opeation is the sketch operation
386 if (mySketchMgr->activeSketch()) {
387 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
388 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
391 // Editing of constraints can be done on selection
392 ModuleBase_ISelection* aSelect = myWorkshop->selection();
393 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
394 if (aSelected.size() == 1) {
395 ModuleBase_ViewerPrs aPrs = aSelected.first();
396 ObjectPtr aObject = aPrs.object();
397 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
399 std::string aId = aFeature->getKind();
400 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
401 (aId == SketchPlugin_ConstraintLength::ID()) ||
402 (aId == SketchPlugin_ConstraintDistance::ID())) {
403 editFeature(aFeature);
410 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
412 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
413 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
414 anOpMgr->onKeyReleased(theEvent);
417 void PartSet_Module::onEnterReleased()
419 myRestartingMode = RM_EmptyFeatureUsed;
422 void PartSet_Module::onOperationActivatedByPreselection()
424 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
425 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
426 // Set final definitions if they are necessary
427 //propertyPanelDefined(aOperation);
429 /// Commit sketcher operations automatically
430 anOperation->commit();
434 void PartSet_Module::onNoMoreWidgets()
436 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
438 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
439 if (myRestartingMode != RM_Forbided)
440 myRestartingMode = RM_LastFeatureUsed;
441 anOperation->commit();
446 void PartSet_Module::onVertexSelected()
448 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
449 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
450 /// If last line finished on vertex the lines creation sequence has to be break
451 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
452 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
453 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
454 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
455 bool aFoundWidget = false;
456 bool aFoundObligatory = false;
457 for (; anIt != aLast && !aFoundObligatory; anIt++) {
459 aFoundWidget = *anIt == anActiveWidget;
461 aFoundObligatory = (*anIt)->isObligatory();
463 if (!aFoundObligatory)
464 myRestartingMode = RM_Forbided;
468 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
469 Config_WidgetAPI* theWidgetApi, std::string theParentId)
471 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
472 XGUI_Workshop* aWorkshop = aConnector->workshop();
473 ModuleBase_ModelWidget* aWgt = NULL;
474 if (theType == "sketch-start-label") {
475 PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent,
476 theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
477 aLabelWgt->setWorkshop(aWorkshop);
478 connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
479 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
480 connect(aLabelWgt, SIGNAL(showConstraintToggled(bool)),
481 mySketchMgr, SLOT(onShowConstraintsToggle(bool)));
483 } else if (theType == "sketch-2dpoint_selector") {
484 PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
485 aPointWgt->setWorkshop(aWorkshop);
486 aPointWgt->setSketch(mySketchMgr->activeSketch());
487 connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
489 } if (theType == "point2ddistance") {
490 PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
491 aDistanceWgt->setWorkshop(aWorkshop);
492 aDistanceWgt->setSketch(mySketchMgr->activeSketch());
494 } if (theType == "sketch_shape_selector") {
495 PartSet_WidgetShapeSelector* aShapeSelectorWgt =
496 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
497 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
498 aWgt = aShapeSelectorWgt;
499 } if (theType == "sketch_constraint_shape_selector") {
500 PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
501 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
502 aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
503 aWgt = aConstraintShapeSelectorWgt;
504 } if (theType == WDG_DOUBLEVALUE_EDITOR) {
505 aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
510 void PartSet_Module::createActions()
514 anAction = new QAction(tr("Auxiliary"), this);
515 anAction->setCheckable(true);
516 addAction("AUXILIARY_CMD", anAction);
519 QAction* PartSet_Module::action(const QString& theId) const
521 if (myActions.contains(theId))
522 return myActions[theId];
526 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
528 if (myActions.contains(theId))
529 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
530 theAction->setData(theId);
531 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
532 myActions[theId] = theAction;
535 void PartSet_Module::onAction(bool isChecked)
537 QAction* aAction = static_cast<QAction*>(sender());
538 QString anId = aAction->data().toString();
540 if (anId == "AUXILIARY_CMD") {
541 mySketchMgr->setAuxiliary(isChecked);
545 bool PartSet_Module::deleteObjects()
547 // 1. check whether the delete should be processed in the module
548 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
549 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
550 isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
551 if (!isSketchOp && !isNestedOp)
554 // 2. find selected presentations
555 // selected objects should be collected before the current operation abort because
556 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
557 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
558 XGUI_Workshop* aWorkshop = aConnector->workshop();
559 ModuleBase_ISelection* aSel = aConnector->selection();
560 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
561 // if there are no selected objects in the viewer, that means that the selection in another
562 // place cased this method. It is necessary to return the false value to understande in above
563 // method that delete is not processed
564 if (aSelectedObj.count() == 0)
567 // the active nested sketch operation should be aborted unconditionally
569 anOperation->abort();
571 // 3. start operation
572 QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
573 SessionPtr aMgr = ModelAPI_Session::get();
574 aMgr->startOperation(aDescription.toStdString());
576 // 4. delete features
577 // sketch feature should be skipped, only sub-features can be removed
578 // when sketch operation is active
579 std::set<FeaturePtr> anIgnoredFeatures;
580 anIgnoredFeatures.insert(mySketchMgr->activeSketch());
581 aWorkshop->deleteFeatures(aSelectedObj, anIgnoredFeatures);
584 aWorkshop->displayer()->updateViewer();
585 aMgr->finishOperation();
591 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
593 Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
594 if (!anAIS.IsNull()) {
595 Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
596 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
597 if (!aDim.IsNull()) {
598 aCtx->SetZLayer(aDim, myVisualLayerId);
600 Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
602 aCtx->SetZLayer(aCons, myVisualLayerId);
607 void PartSet_Module::onViewTransformed(int theTrsfType)
609 // Set length of arrows constant in pixel size
610 // if the operation is panning or rotate or panglobal then do nothing
611 if ((theTrsfType == 1) || (theTrsfType == 3) || (theTrsfType == 4))
614 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
615 Handle(V3d_View) aView = aViewer->activeView();
617 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
618 XGUI_Workshop* aWorkshop = aConnector->workshop();
619 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
620 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
622 double aLen = aView->Convert(15);
624 SketcherPrs_Tools::setArrowSize(aLen);
625 bool isModified = false;
626 QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
627 foreach (AISObjectPtr aAIS, aPrsList) {
628 Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
630 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
631 if (!aDim.IsNull()) {
632 aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
633 aContext->Redisplay(aDim, false);
638 aDisplayer->updateViewer();