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_SketcherMgr.h>
13 #include <ModuleBase_Operation.h>
14 #include <ModuleBase_IViewer.h>
15 #include <ModuleBase_IViewWindow.h>
16 #include <ModuleBase_IPropertyPanel.h>
17 #include <ModuleBase_WidgetEditor.h>
18 #include <ModuleBase_FilterFactory.h>
19 #include <ModuleBase_FilterLinearEdge.h>
20 #include <ModuleBase_FilterFace.h>
21 #include <ModuleBase_FilterMulti.h>
22 #include <ModuleBase_FilterCustom.h>
23 #include <ModuleBase_FilterNoConsructionSubShapes.h>
24 #include <GeomValidators_Edge.h>
25 #include <GeomValidators_EdgeOrVertex.h>
26 #include <GeomValidators_Face.h>
27 #include <GeomValidators_ConstructionComposite.h>
29 #include <PartSet_FilterSketchEntity.h>
31 #include <ModelAPI_Object.h>
32 #include <ModelAPI_Events.h>
33 #include <ModelAPI_Validator.h>
34 #include <ModelAPI_Data.h>
35 #include <ModelAPI_Session.h>
36 #include <ModelAPI_ShapeValidator.h>
38 #include <GeomDataAPI_Point2D.h>
39 #include <GeomDataAPI_Point.h>
40 #include <GeomDataAPI_Dir.h>
42 #include <XGUI_Displayer.h>
43 #include <XGUI_Workshop.h>
44 #include <XGUI_OperationMgr.h>
45 #include <XGUI_PropertyPanel.h>
46 #include <XGUI_ModuleConnector.h>
47 #include <XGUI_ContextMenuMgr.h>
48 #include <XGUI_Tools.h>
50 #include <SketchPlugin_Feature.h>
51 #include <SketchPlugin_Sketch.h>
52 #include <SketchPlugin_Line.h>
53 //#include <SketchPlugin_Arc.h>
54 //#include <SketchPlugin_Circle.h>
55 #include <SketchPlugin_ConstraintLength.h>
56 #include <SketchPlugin_ConstraintDistance.h>
57 #include <SketchPlugin_ConstraintParallel.h>
58 #include <SketchPlugin_ConstraintPerpendicular.h>
59 #include <SketchPlugin_ConstraintRadius.h>
61 #include <SketcherPrs_SymbolPrs.h>
62 #include <SketcherPrs_Tools.h>
64 #include <Events_Loop.h>
65 #include <Config_PropManager.h>
67 #include <StdSelect_TypeOfFace.hxx>
68 #include <TopoDS_Vertex.hxx>
70 #include <TopoDS_Shape.hxx>
71 #include <BRep_Tool.hxx>
72 #include <AIS_Dimension.hxx>
75 #include <QMouseEvent>
78 #include <QApplication>
79 #include <QMessageBox>
80 #include <QMainWindow>
82 #include <GeomAlgoAPI_FaceBuilder.h>
83 #include <GeomDataAPI_Dir.h>
89 /*!Create and return new instance of XGUI_Module*/
90 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
92 return new PartSet_Module(theWshop);
95 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
96 : ModuleBase_IModule(theWshop),
97 myRestartingMode(RM_None), myVisualLayerId(0)
99 mySketchMgr = new PartSet_SketcherMgr(this);
101 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
102 XGUI_Workshop* aWorkshop = aConnector->workshop();
104 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
105 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
106 connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
107 this, SLOT(onOperationActivatedByPreselection()));
109 ModuleBase_IViewer* aViewer = theWshop->viewer();
110 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
111 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
112 connect(aViewer, SIGNAL(viewTransformed(int)),
113 SLOT(onViewTransformed(int)));
118 PartSet_Module::~PartSet_Module()
120 if (!myDocumentShapeFilter.IsNull())
121 myDocumentShapeFilter.Nullify();
124 void PartSet_Module::registerValidators()
126 //Registering of validators
127 SessionPtr aMgr = ModelAPI_Session::get();
128 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
129 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
130 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
131 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
132 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
133 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
134 aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
135 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
136 aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
138 aFactory->registerValidator("GeomValidators_Edge", new GeomValidators_Edge);
139 aFactory->registerValidator("GeomValidators_EdgeOrVertex",
140 new GeomValidators_EdgeOrVertex);
141 aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
143 aFactory->registerValidator("GeomValidators_ConstructionComposite",
144 new GeomValidators_ConstructionComposite);
146 aFactory->registerValidator("PartSet_SketchEntityValidator",
147 new PartSet_SketchEntityValidator);
149 aFactory->registerValidator("PartSet_SameTypeAttr",
150 new PartSet_SameTypeAttrValidator);
153 void PartSet_Module::registerFilters()
155 //Registering of selection filters
156 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
157 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
159 //aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
160 //aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
161 //aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
162 //Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop());
163 //aFactory->registerFilter("NoConstructionSubShapesFilter",
164 // new ModuleBase_FilterCustom(aSelectFilter));
165 //Handle(SelectMgr_Filter) aSelectFilter = new PartSet_FilterSketchEntity(workshop());
166 //aFactory->registerFilter("SketchEntityFilter", new ModuleBase_FilterCustom(aSelectFilter));
169 void PartSet_Module::registerProperties()
171 Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
173 Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
174 Config_Prop::Integer, SKETCH_WIDTH);
177 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
179 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
180 mySketchMgr->commitNestedSketch(theOperation);
183 if (theOperation->isEditOperation())
185 // the selection is cleared after commit the create operation
186 // in order to do not use the same selected objects in the restarted operation
187 // for common behaviour, the selection is cleared even if the operation is not restarted
188 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
189 if (!aContext.IsNull())
190 aContext->ClearSelected();
192 /// Restart sketcher operations automatically
193 FeaturePtr aFeature = theOperation->feature();
194 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
195 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
196 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
197 myRestartingMode == RM_EmptyFeatureUsed)) {
198 myLastOperationId = theOperation->id();
199 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
201 launchOperation(myLastOperationId);
203 breakOperationSequence();
206 void PartSet_Module::breakOperationSequence()
208 myLastOperationId = "";
209 myLastFeature = FeaturePtr();
210 myRestartingMode = RM_None;
213 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
215 breakOperationSequence();
218 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
220 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
221 Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
222 aViewer->AddZLayer(myVisualLayerId);
223 mySketchMgr->startSketch(theOperation);
225 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
226 mySketchMgr->startNestedSketch(theOperation);
229 if (myDocumentShapeFilter.IsNull())
230 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
231 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
234 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
236 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
237 mySketchMgr->stopSketch(theOperation);
238 Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer();
239 aViewer->RemoveZLayer(myVisualLayerId);
242 else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
243 mySketchMgr->stopNestedSketch(theOperation);
245 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
248 ModuleBase_Operation* PartSet_Module::currentOperation() const
250 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
251 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
252 return anOpMgr->currentOperation();
255 bool PartSet_Module::canUndo() const
257 bool aCanUndo = false;
258 SessionPtr aMgr = ModelAPI_Session::get();
259 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
260 aCanUndo = !aMgr->isOperation();
261 if (!aCanUndo) // check the enable state additionally by sketch manager
262 aCanUndo = aMgr->canUndo();
267 bool PartSet_Module::canRedo() const
269 bool aCanRedo = false;
270 SessionPtr aMgr = ModelAPI_Session::get();
271 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
272 aCanRedo = !aMgr->isOperation();
273 if (!aCanRedo) // check the enable state additionally by sketch manager
274 aCanRedo = aMgr->canRedo();
279 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
281 // the display should be possible almost always, with exception of some specific cases
283 bool aCanDisplay = true;
285 if (mySketchMgr->activeSketch()) {
286 aCanDisplay = mySketchMgr->canDisplayObject(theObject);
291 bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
293 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
294 if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
295 !PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
298 ModuleBase_ISelection* aSelection = myWorkshop->selection();
299 QObjectPtrList aObjects = aSelection->selectedPresentations();
300 if (aObjects.size() > 0) {
301 bool hasFeature = false;
302 foreach(ObjectPtr aObject, aObjects)
304 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
305 if (aFeature.get() != NULL) {
310 theMenu->addAction(theStdActions["DELETE_CMD"]);
314 if (mySketchMgr->canSetAuxiliary(isAuxiliary)) {
315 QAction* anAction = action("AUXILIARY_CMD");
316 theMenu->addAction(anAction);
317 anAction->setChecked(isAuxiliary);
322 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
324 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
325 if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
326 // we have to manually activate the sketch label in edit mode
327 aPanel->activateWidget(aPanel->modelWidgets().first());
331 // Restart last operation type
332 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
333 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
334 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
335 // Initialise new line with first point equal to end of previous
336 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
338 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
339 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
340 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
342 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
343 PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
344 aWgt->attributeID(), aPoint->x(), aPoint->y());
345 aPanel->activateNextWidget(aPnt2dWgt);
350 // Start editing constraint
351 if (theOperation->isEditOperation()) {
352 // TODO: #391 - to be removed
353 std::string aId = theOperation->id().toStdString();
354 if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
355 PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
356 // Find and activate widget for management of point for dimension line position
357 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
358 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
359 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
361 aPanel->activateWidget(aPntWgt);
371 void PartSet_Module::onSelectionChanged()
373 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
377 bool isSketcherOp = false;
378 // An edit operation is enable only if the current opeation is the sketch operation
379 if (mySketchMgr->activeSketch()) {
380 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
381 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
384 // Editing of constraints can be done on selection
385 ModuleBase_ISelection* aSelect = myWorkshop->selection();
386 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
387 if (aSelected.size() == 1) {
388 ModuleBase_ViewerPrs aPrs = aSelected.first();
389 ObjectPtr aObject = aPrs.object();
390 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
392 std::string aId = aFeature->getKind();
393 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
394 (aId == SketchPlugin_ConstraintLength::ID()) ||
395 (aId == SketchPlugin_ConstraintDistance::ID())) {
396 editFeature(aFeature);
403 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
405 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
406 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
407 anOpMgr->onKeyReleased(theEvent);
410 void PartSet_Module::onEnterReleased()
412 myRestartingMode = RM_EmptyFeatureUsed;
415 void PartSet_Module::onOperationActivatedByPreselection()
417 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
418 if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
419 // Set final definitions if they are necessary
420 //propertyPanelDefined(aOperation);
422 /// Commit sketcher operations automatically
423 anOperation->commit();
427 void PartSet_Module::onNoMoreWidgets()
429 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
431 if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
432 if (myRestartingMode != RM_Forbided)
433 myRestartingMode = RM_LastFeatureUsed;
434 anOperation->commit();
439 void PartSet_Module::onVertexSelected()
441 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
442 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
443 /// If last line finished on vertex the lines creation sequence has to be break
444 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
445 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
446 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
447 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
448 bool aFoundWidget = false;
449 bool aFoundObligatory = false;
450 for (; anIt != aLast && !aFoundObligatory; anIt++) {
452 aFoundWidget = *anIt == anActiveWidget;
454 aFoundObligatory = (*anIt)->isObligatory();
456 if (!aFoundObligatory)
457 myRestartingMode = RM_Forbided;
461 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
462 Config_WidgetAPI* theWidgetApi, std::string theParentId)
464 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
465 XGUI_Workshop* aWorkshop = aConnector->workshop();
466 ModuleBase_ModelWidget* aWgt = NULL;
467 if (theType == "sketch-start-label") {
468 PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent,
469 theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
470 aLabelWgt->setWorkshop(aWorkshop);
471 connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
472 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
473 connect(aLabelWgt, SIGNAL(showConstraintToggled(bool)),
474 mySketchMgr, SLOT(onShowConstraintsToggle(bool)));
476 } else if (theType == "sketch-2dpoint_selector") {
477 PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
478 aPointWgt->setWorkshop(aWorkshop);
479 aPointWgt->setSketch(mySketchMgr->activeSketch());
480 connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
482 } if (theType == "point2ddistance") {
483 PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
484 aDistanceWgt->setWorkshop(aWorkshop);
485 aDistanceWgt->setSketch(mySketchMgr->activeSketch());
487 } if (theType == "sketch_shape_selector") {
488 PartSet_WidgetShapeSelector* aShapeSelectorWgt =
489 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
490 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
491 aWgt = aShapeSelectorWgt;
492 } if (theType == "sketch_constraint_shape_selector") {
493 PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
494 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
495 aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
496 aWgt = aConstraintShapeSelectorWgt;
501 void PartSet_Module::createActions()
505 anAction = new QAction(tr("Auxiliary"), this);
506 anAction->setCheckable(true);
507 addAction("AUXILIARY_CMD", anAction);
510 QAction* PartSet_Module::action(const QString& theId) const
512 if (myActions.contains(theId))
513 return myActions[theId];
517 void PartSet_Module::addAction(const QString& theId, QAction* theAction)
519 if (myActions.contains(theId))
520 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
521 theAction->setData(theId);
522 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
523 myActions[theId] = theAction;
526 void PartSet_Module::onAction(bool isChecked)
528 QAction* aAction = static_cast<QAction*>(sender());
529 QString anId = aAction->data().toString();
531 if (anId == "AUXILIARY_CMD") {
532 mySketchMgr->setAuxiliary(isChecked);
536 bool PartSet_Module::deleteObjects()
538 // 1. check whether the delete should be processed in the module
539 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
540 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
541 isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
542 if (!isSketchOp && !isNestedOp)
545 // 2. find selected presentations
546 // selected objects should be collected before the current operation abort because
547 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
548 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
549 XGUI_Workshop* aWorkshop = aConnector->workshop();
550 ModuleBase_ISelection* aSel = workshop()->selection();
551 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
552 // if there are no selected objects in the viewer, that means that the selection in another
553 // place cased this method. It is necessary to return the false value to understande in above
554 // method that delete is not processed
555 if (aSelectedObj.count() == 0)
558 // the active nested sketch operation should be aborted unconditionally
560 anOperation->abort();
562 // 3. start operation
563 QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
564 SessionPtr aMgr = ModelAPI_Session::get();
565 aMgr->startOperation(aDescription.toStdString());
567 // 4. delete features
568 // sketch feature should be skipped, only sub-features can be removed
569 // when sketch operation is active
570 std::set<FeaturePtr> anIgnoredFeatures;
571 anIgnoredFeatures.insert(mySketchMgr->activeSketch());
572 aWorkshop->deleteFeatures(aSelectedObj, anIgnoredFeatures);
575 aWorkshop->displayer()->updateViewer();
576 aMgr->finishOperation();
582 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
584 Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
585 if (!anAIS.IsNull()) {
586 Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
587 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
588 if (!aDim.IsNull()) {
589 aCtx->SetZLayer(aDim, myVisualLayerId);
591 Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
593 aCtx->SetZLayer(aCons, myVisualLayerId);
598 void PartSet_Module::onViewTransformed(int theTrsfType)
600 // Set length of arrows constant in pixel size
601 // if the operation is panning or rotate or panglobal then do nothing
602 if ((theTrsfType == 1) || (theTrsfType == 3) || (theTrsfType == 4))
605 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
606 Handle(V3d_View) aView = aViewer->activeView();
608 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
609 XGUI_Workshop* aWorkshop = aConnector->workshop();
610 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
611 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
613 double aLen = aView->Convert(15);
615 SketcherPrs_Tools::setArrowSize(aLen);
616 bool isModified = false;
617 QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
618 foreach (AISObjectPtr aAIS, aPrsList) {
619 Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
621 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
622 if (!aDim.IsNull()) {
623 aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
624 aContext->Redisplay(aDim, false);
629 aDisplayer->updateViewer();