1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "PartSet_Module.h"
21 #include "PartSet_WidgetSketchLabel.h"
22 #include "PartSet_Validators.h"
23 #include "PartSet_Tools.h"
24 #include "PartSet_PreviewPlanes.h"
25 #include "PartSet_WidgetBSplinePoints.h"
26 #include "PartSet_WidgetPoint2d.h"
27 #include "PartSet_WidgetPoint2DFlyout.h"
28 #include "PartSet_WidgetShapeSelector.h"
29 #include "PartSet_WidgetMultiSelector.h"
30 #include "PartSet_WidgetFeaturePointSelector.h"
31 #include "PartSet_WidgetEditor.h"
32 #include "PartSet_WidgetFileSelector.h"
33 #include "PartSet_WidgetSketchCreator.h"
34 #include "PartSet_SketcherMgr.h"
35 #include "PartSet_SketcherReentrantMgr.h"
36 #include "PartSet_ResultSketchPrs.h"
37 #include "PartSet_MenuMgr.h"
38 #include "PartSet_CustomPrs.h"
39 #include "PartSet_IconFactory.h"
40 #include "PartSet_OverconstraintListener.h"
41 #include "PartSet_TreeNodes.h"
42 #include "PartSet_FieldStepPrs.h"
43 #include "PartSet_BSplineWidget.h"
45 #include "PartSet_Filters.h"
46 #include "PartSet_FilterInfinite.h"
52 #include <PartSetPlugin_Remove.h>
53 #include <PartSetPlugin_Part.h>
54 #include <PartSetPlugin_Duplicate.h>
56 #include <SketchPlugin_ConstraintCoincidence.h>
58 #include <ModuleBase_Operation.h>
59 #include <ModuleBase_IViewer.h>
60 #include <ModuleBase_IViewWindow.h>
61 #include <ModuleBase_IPropertyPanel.h>
62 #include <ModuleBase_ISelectionActivate.h>
63 #include <ModuleBase_WidgetChoice.h>
64 #include <ModuleBase_WidgetEditor.h>
65 #include <ModuleBase_WidgetValidated.h>
66 #include <ModuleBase_Tools.h>
67 #include <ModuleBase_OperationFeature.h>
68 #include <ModuleBase_WidgetFactory.h>
69 #include <ModuleBase_OperationDescription.h>
70 #include <ModuleBase_ViewerPrs.h>
71 #include <ModuleBase_ResultPrs.h>
73 #include <ModelAPI_ResultField.h>
74 #include <ModelAPI_Object.h>
75 #include <ModelAPI_Events.h>
76 #include <ModelAPI_Validator.h>
77 #include <ModelAPI_Data.h>
78 #include <ModelAPI_Session.h>
79 #include <ModelAPI_ResultBody.h>
80 #include <ModelAPI_AttributeString.h>
81 #include <ModelAPI_AttributeSelectionList.h>
82 #include <ModelAPI_Tools.h>
83 #include <ModelAPI_ResultConstruction.h>
84 #include <ModelAPI_AttributeIntArray.h>
85 #include <ModelAPI_ResultGroup.h>
87 #include <GeomDataAPI_Point2D.h>
88 #include <GeomDataAPI_Point.h>
89 #include <GeomDataAPI_Dir.h>
91 #include <XGUI_ActiveControlMgr.h>
92 #include <XGUI_ActiveControlSelector.h>
93 #include <XGUI_ActionsMgr.h>
94 #include <XGUI_ContextMenuMgr.h>
95 #include <XGUI_DataModel.h>
96 #include <XGUI_Displayer.h>
97 #include <XGUI_ErrorMgr.h>
98 #include <XGUI_FacesPanelSelector.h>
99 #include <XGUI_ModuleConnector.h>
100 #include <XGUI_ObjectsBrowser.h>
101 #include <XGUI_OperationMgr.h>
102 #include <XGUI_PropertyPanel.h>
103 #include <XGUI_SelectionMgr.h>
104 #include <XGUI_Tools.h>
105 #include <XGUI_Workshop.h>
107 #include <SketchPlugin_ConstraintAngle.h>
108 #include <SketchPlugin_ConstraintLength.h>
109 #include <SketchPlugin_ConstraintDistance.h>
110 #include <SketchPlugin_ConstraintParallel.h>
111 #include <SketchPlugin_ConstraintPerpendicular.h>
112 #include <SketchPlugin_ConstraintRadius.h>
113 #include <SketchPlugin_Feature.h>
114 #include <SketchPlugin_Projection.h>
115 #include <SketchPlugin_Sketch.h>
117 #include <SketcherPrs_SymbolPrs.h>
118 #include <SketcherPrs_PositionMgr.h>
119 #include <SketcherPrs_Coincident.h>
120 #include <SketcherPrs_Tools.h>
122 #include <Events_Loop.h>
123 #include <Config_PropManager.h>
124 #include <Config_Keywords.h>
126 #include <AIS_Dimension.hxx>
127 #include <AIS_InteractiveObject.hxx>
128 #include <StdSelect_TypeOfFace.hxx>
129 #include <TopoDS_Vertex.hxx>
130 #include <TopoDS.hxx>
131 #include <TopoDS_Shape.hxx>
132 #include <BRep_Tool.hxx>
135 #include <QMouseEvent>
138 #include <QApplication>
139 #include <QMessageBox>
140 #include <QMainWindow>
144 #include <GeomAlgoAPI_FaceBuilder.h>
145 #include <GeomDataAPI_Dir.h>
147 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
149 /*!Create and return new instance of XGUI_Module*/
150 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
152 return new PartSet_Module(theWshop);
155 //******************************************************
156 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
157 : ModuleBase_IModule(theWshop),
158 myIsOperationIsLaunched(false),
162 new PartSet_IconFactory(this);
164 mySketchMgr = new PartSet_SketcherMgr(this);
165 mySketchReentrantMgr = new PartSet_SketcherReentrantMgr(theWshop);
167 ModuleBase_IViewer* aViewer = theWshop->viewer();
168 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
169 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
170 connect(aViewer, SIGNAL(viewTransformed(int)),
171 SLOT(onViewTransformed(int)));
172 connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)),
173 SLOT(onViewCreated(ModuleBase_IViewWindow*)));
174 myMenuMgr = new PartSet_MenuMgr(this);
175 myCustomPrs = new PartSet_CustomPrs(theWshop);
177 myOverconstraintListener = new PartSet_OverconstraintListener(theWshop);
179 Events_Loop* aLoop = Events_Loop::loop();
180 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
181 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
183 registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
184 registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
185 Handle(PartSet_ResultGroupNameFilter) aCRFilter = new PartSet_ResultGroupNameFilter(myWorkshop);
186 std::set<std::string> aCRGroupNames;
187 aCRGroupNames.insert(ModelAPI_ResultConstruction::group());
188 aCRFilter->setGroupNames(aCRGroupNames);
189 registerSelectionFilter(SF_ResultGroupNameFilter, aCRFilter);
191 setDefaultConstraintShown();
193 //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
194 // Config_Prop::Color, "225,225,225");
196 Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
197 Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
199 Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
200 Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
202 Config_PropManager::registerProp("Visualization", "result_construction_color",
203 "Construction color",
205 ModelAPI_ResultConstruction::DEFAULT_COLOR());
207 Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
208 Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
210 Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
211 Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
213 Config_PropManager::registerProp("Visualization", "operation_parameter_color",
214 "Reference shape wireframe color in operation", Config_Prop::Color,
215 PartSet_CustomPrs::OPERATION_PARAMETER_COLOR());
216 Config_PropManager::registerProp("Visualization", "operation_result_color",
217 "Result shape wireframe color in operation", Config_Prop::Color,
218 PartSet_CustomPrs::OPERATION_RESULT_COLOR());
219 Config_PropManager::registerProp("Visualization", "operation_highlight_color",
220 "Multi selector item color in operation", Config_Prop::Color,
221 PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR());
222 Config_PropManager::registerProp("Visualization", "operation_remove_feature_color",
223 "Color of removed feature in operation", Config_Prop::Color,
224 PartSet_CustomPrs::OPERATION_REMOVE_FEATURE_COLOR());
225 Config_PropManager::registerProp("Visualization", "sketch_preview_plane",
226 "Color of sketch plane", Config_Prop::Color,
227 PartSet_CustomPrs::OPERATION_SKETCH_PLANE());
229 Config_PropManager::registerProp("Visualization", "hidden_face_transparency",
230 "Hidden faces transparency",
231 Config_Prop::DblSpin,
233 std::ostringstream aStream;
234 aStream << SketcherPrs_Tools::getDefaultArrowSize();
235 Config_PropManager::registerProp("Visualization", "dimension_arrow_size",
236 "Dimension arrow size", Config_Prop::IntSpin, aStream.str());
238 Config_PropManager::registerProp("Visualization", "dimension_font", "Dimension font",
239 Config_Prop::String, "Times-bold");
243 aStream << SketcherPrs_Tools::getDefaultTextHeight();
244 Config_PropManager::registerProp("Visualization", "dimension_value_size",
245 "Dimension value size", Config_Prop::IntSpin, aStream.str());
247 Config_PropManager::registerProp("Visualization", "sketch_dimension_color",
249 Config_Prop::Color, SKETCH_DIMENSION_COLOR);
251 Config_PropManager::registerProp("Shortcuts", "add_parameter_shortcut",
252 "Add parameter in parameters manager dialog",
253 Config_Prop::Shortcut, "Ctrl+A");
255 Config_PropManager::registerProp("Windows", "use_hide_faces_panel",
256 "Use HideFaces panel in operations", Config_Prop::Boolean, "false");
259 //******************************************************
260 PartSet_Module::~PartSet_Module()
263 delete myOverconstraintListener;
267 //******************************************************
268 void PartSet_Module::createFeatures()
270 ModuleBase_IModule::createFeatures();
271 myRoot = new PartSet_RootNode();
272 myRoot->setWorkshop(workshop());
276 //******************************************************
277 void PartSet_Module::storeSelection()
279 // cash is used only to restore selection, so it should be filled in storeSelection and
280 // after applying immediatelly cleared in restoreSelection
281 myCurrentSelection.clear();
282 sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
285 //******************************************************
286 void PartSet_Module::restoreSelection()
288 // cash is used only to restore selection, so it should be filled in storeSelection and
289 // after applying immediatelly cleared in restoreSelection
290 sketchMgr()->restoreSelection(myCurrentSelection);
291 myCurrentSelection.clear();
294 //******************************************************
295 void PartSet_Module::registerValidators()
297 //Registering of validators
298 SessionPtr aMgr = ModelAPI_Session::get();
299 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
300 aFactory->registerValidator("PartSet_DistanceSelection", new PartSet_DistanceSelection);
301 aFactory->registerValidator("PartSet_LengthSelection", new PartSet_LengthSelection);
302 aFactory->registerValidator("PartSet_PerpendicularSelection", new PartSet_PerpendicularSelection);
303 aFactory->registerValidator("PartSet_ParallelSelection", new PartSet_ParallelSelection);
304 aFactory->registerValidator("PartSet_RadiusSelection", new PartSet_RadiusSelection);
305 aFactory->registerValidator("PartSet_RigidSelection", new PartSet_RigidSelection);
306 aFactory->registerValidator("PartSet_CoincidentSelection", new PartSet_CoincidentSelection);
307 aFactory->registerValidator("PartSet_HVDirSelection", new PartSet_HVDirSelection);
308 aFactory->registerValidator("PartSet_TangentSelection", new PartSet_TangentSelection);
309 aFactory->registerValidator("PartSet_FilletSelection", new PartSet_FilletSelection);
310 aFactory->registerValidator("PartSet_AngleSelection", new PartSet_AngleSelection);
311 aFactory->registerValidator("PartSet_EqualSelection", new PartSet_EqualSelection);
312 aFactory->registerValidator("PartSet_CollinearSelection", new PartSet_CollinearSelection);
313 aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
314 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
315 aFactory->registerValidator("PartSet_DifferentPoints", new PartSet_DifferentPointsValidator);
316 aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
317 aFactory->registerValidator("PartSet_MultyTranslationSelection",
318 new PartSet_MultyTranslationSelection);
319 aFactory->registerValidator("PartSet_SplitSelection", new PartSet_SplitSelection);
320 aFactory->registerValidator("PartSet_ProjectionSelection", new PartSet_ProjectionSelection);
321 aFactory->registerValidator("PartSet_IntersectionSelection", new PartSet_IntersectionSelection);
324 //******************************************************
325 void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget,
326 const bool isToConnect)
328 mySketchMgr->connectToPropertyPanel(theWidget, isToConnect);
331 //******************************************************
332 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
334 if (sketchMgr()->isNestedSketchOperation(theOperation)) {
335 mySketchMgr->commitNestedSketch(theOperation);
337 /// deactivate of overconstraint listener should be performed after Sketch commit (#2176)
338 if (PartSet_SketcherMgr::isSketchOperation(theOperation))
339 overconstraintListener()->setActive(false);
341 /// Restart sketcher operations automatically
342 if (!mySketchReentrantMgr->operationCommitted(theOperation)) {
344 ModuleBase_OperationFeature* aFOperation =
345 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
346 if (aFOperation && !aFOperation->isEditOperation()) {
347 // the selection is cleared after commit the create operation
348 // in order to do not use the same selected objects in the restarted operation
349 // for common behaviour, the selection is cleared even if the operation is not restarted
350 getWorkshop()->selector()->clearSelection();
355 //******************************************************
356 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
358 /// Restart sketcher operations automatically
359 mySketchReentrantMgr->operationAborted(theOperation);
360 /// deactivate of overconstraint listener should be performed after Sketch abort (#2176)
361 if (PartSet_SketcherMgr::isSketchOperation(theOperation))
362 overconstraintListener()->setActive(false);
365 //******************************************************
366 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
368 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
371 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(workshop());
372 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
374 ModuleBase_ModelWidget* aFilledWidget = 0;
375 bool aPostonedWidgetActivation = false;
377 FeaturePtr aFeature = aFOperation->feature();
378 /// Restart sketcher operations automatically
379 /// it is important to call method of sketch reentrant manager before filling of PP
380 /// because it fills some created feature attributes, these new values should be used
381 /// to fill the property panel
382 mySketchReentrantMgr->operationStarted(theOperation);
384 aWorkshop->fillPropertyPanel(aFOperation);
385 // filling the operation values by the current selection
386 // if the operation can be committed after the controls filling, the method perform should
387 // be stopped. Otherwise unnecessary presentations can be shown(e.g. operation prs in sketch)
388 bool isOperationCommitted = false;
389 if (!aFOperation->isEditOperation()) {
390 std::string aGreedAttributeId = ModuleBase_Tools::findGreedAttribute(workshop(), aFeature);
391 // if there is a greed attribute, automatic commit by preselection
392 // for this feature is prohibited
393 aFilledWidget = aFOperation->activateByPreselection(aGreedAttributeId);
394 if (currentOperation() != aFOperation)
395 isOperationCommitted = true;
397 if (aGreedAttributeId.empty()) {
398 // a signal should be emitted before the next widget activation
399 // because, the activation of the next widget will give a focus to the widget.
400 // As a result the value of the widget is initialized.
401 // And commit may happens until the value is entered.
403 if (mySketchReentrantMgr->canBeCommittedByPreselection())
404 isOperationCommitted = mySketchMgr->operationActivatedByPreselection();
405 // activate the next obligatory widget
406 if (!isOperationCommitted)
407 aPropertyPanel->activateNextWidget(aFilledWidget);
410 else { // there is a greed widget
411 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
412 std::string aFirstAttributeId = aWidgets.front()->attributeID();
413 // activate next widget after greeded if it is the first widget in the panel
414 // else the first panel widget is already activated by operation start
415 if (aFirstAttributeId == aGreedAttributeId)
416 aPostonedWidgetActivation = true;
419 } if (!isOperationCommitted) {
420 aWorkshop->connectToPropertyPanel(true);
421 updateSketcherOnStart(aFOperation);
422 updatePresentationsOnStart(aFOperation);
424 // the objects of the current operation should be deactivated
425 QObjectPtrList anObjects;
426 anObjects.append(aFeature);
427 std::list<ResultPtr> aResults;
428 ModelAPI_Tools::allResults(aFeature, aResults);
429 std::list<ResultPtr>::const_iterator aIt;
430 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
431 anObjects.append(*aIt);
433 QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
434 for (; anIt != aLast; anIt++)
435 aWorkshop->deactivateActiveObject(*anIt, false);
436 if (anObjects.size() > 0) {
437 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
438 aDisplayer->updateViewer();
440 /// state of command actions should be updated after displayed objects modification because
441 /// deactivation(for example) of objects may influence on selection in the viewer
442 /// State of command actions may depend on selection in the viewer(e.g. Sketch)
443 workshop()->updateCommandStatus();
445 if (aPostonedWidgetActivation) {
446 // if the widget is an empty in the chain of activated widgets, the current operation
447 // is restarted. It should be performed after functionality of the operation starting
448 aPropertyPanel->activateNextWidget(aFilledWidget);
453 //******************************************************
454 void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
456 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
457 mySketchMgr->startSketch(theOperation);
459 // It is switched off because of
460 // Task #3067: 5.2.2 Drawing in the sketcher: change the mouse cursor arrow
461 else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
462 mySketchMgr->startNestedSketch(theOperation);
466 //******************************************************
467 void PartSet_Module::updatePresentationsOnStart(ModuleBase_Operation* theOperation)
469 ModuleBase_OperationFeature* aFOperation =
470 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
472 myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, false);
473 myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, false);
477 //******************************************************
478 void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
480 ModuleBase_IModule::operationResumed(theOperation);
482 ModuleBase_OperationFeature* aFOperation =
483 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
485 myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeArguments, false);
486 myCustomPrs->activate(aFOperation->feature(), ModuleBase_IModule::CustomizeResults, false);
490 //******************************************************
491 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
493 bool isModifiedArgs = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeArguments, false);
494 bool isModifiedResults = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeResults, false);
495 bool isModified = isModifiedArgs || isModifiedResults;
497 if (sketchMgr()->isNestedSketchOperation(theOperation)) {
498 mySketchMgr->stopNestedSketch(theOperation);
500 else if (PartSet_SketcherMgr::isSketchOperation(theOperation))
501 setDefaultConstraintShown();
503 //VSV: Viewer is updated on feature update and redisplay
505 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
506 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
507 aDisplayer->updateViewer();
510 QMap<PartSet_Tools::ConstraintVisibleState, bool>::const_iterator
511 anIt = myHasConstraintShown.begin(), aLast = myHasConstraintShown.end();
512 for (; anIt != aLast; anIt++) {
513 mySketchMgr->updateBySketchParameters(anIt.key(), anIt.value());
517 //******************************************************
518 ModuleBase_Operation* PartSet_Module::currentOperation() const
520 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
521 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
522 return anOpMgr->currentOperation();
525 //******************************************************
526 bool PartSet_Module::canUndo() const
528 bool aCanUndo = false;
529 SessionPtr aMgr = ModelAPI_Session::get();
530 if (aMgr->hasModuleDocument() && aMgr->canUndo()) {
531 aCanUndo = !aMgr->isOperation();
532 if (!aCanUndo) // check the enable state additionally by sketch manager
533 aCanUndo = aMgr->canUndo();
538 //******************************************************
539 bool PartSet_Module::canRedo() const
541 bool aCanRedo = false;
542 SessionPtr aMgr = ModelAPI_Session::get();
543 if (aMgr->hasModuleDocument() && aMgr->canRedo()) {
544 aCanRedo = !aMgr->isOperation();
545 if (!aCanRedo) // check the enable state additionally by sketch manager
546 aCanRedo = aMgr->canRedo();
551 //******************************************************
552 bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const
555 if (theActionId == "MOVE_CMD" || theActionId == "MOVE_SPLIT_CMD") {
556 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
558 ResultPtr aResult = ModuleBase_Tools::firstResult(aFeature);
559 // part features can not be moved in the history.
560 if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group())
567 //******************************************************
568 bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const
570 // the sketch manager put the restriction to the objects erase
571 return mySketchMgr->canEraseObject(theObject);
574 //******************************************************
575 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
577 // the sketch manager put the restriction to the objects display
578 return mySketchMgr->canDisplayObject(theObject);
581 //******************************************************
582 bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
583 const QString& theStartedOperationKind)
585 if (ModuleBase_IModule::canUsePreselection(thePreviousOperationKind, theStartedOperationKind))
588 return mySketchMgr->isNestedSketchFeature(theStartedOperationKind);
591 /*void PartSet_Module::processHiddenObject(const std::list<ObjectPtr>& theObjects)
593 mySketchMgr->processHiddenObject(theObjects);
596 //******************************************************
597 bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
599 bool aCanActivate = ModuleBase_IModule::canActivateSelection(theObject);
601 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
602 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
603 isNestedOp = sketchMgr()->isNestedSketchOperation(anOperation);
604 if (isSketchOp || isNestedOp) {
605 // in active sketch operation it is possible to activate operation object in selection
606 // in the edit operation, e.g. points of the line can be moved when the line is edited
607 ModuleBase_OperationFeature* aFOperation =
608 dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
609 aCanActivate = aCanActivate || (aFOperation && aFOperation->isEditOperation());
614 //******************************************************
615 bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
617 QMap<int, QAction*>& theMenuActions) const
619 return myMenuMgr->addViewerMenu(theStdActions, theParent, theMenuActions);
622 //******************************************************
623 void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
625 myMenuMgr->updateViewerMenu(theStdActions);
628 //******************************************************
629 bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
631 bool isEnabledFixed = false;
632 if (theActionId == XGUI_ActionsMgr::AcceptAll &&
633 mySketchReentrantMgr->isInternalEditActive())
634 isEnabledFixed = true;
635 return isEnabledFixed;
638 //******************************************************
639 QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
641 QString anError = ModuleBase_IModule::getFeatureError(theFeature);
642 if (anError.isEmpty())
643 anError = sketchMgr()->getFeatureError(theFeature);
648 //******************************************************
649 void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation,
650 QStringList& theIds) const
652 myMenuMgr->grantedOperationIds(theOperation, theIds);
654 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
655 XGUI_Workshop* aWorkshop = getWorkshop();
656 theIds.append(aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text());
660 //******************************************************
661 void PartSet_Module::activeSelectionModes(QIntList& theModes)
663 if (mySketchMgr->activeSketch().get())
664 PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
666 theModes = XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes();
669 //******************************************************
670 void PartSet_Module::moduleSelectionModes(int theModesType, QIntList& theModes)
672 customSubShapesSelectionModes(theModes);
673 //theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes());
674 //myWorkshop->module()->activeSelectionModes(theModes);
677 //******************************************************
678 void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes,
679 SelectMgr_ListOfFilter& theSelectionFilters)
681 bool isSketchActive = mySketchMgr->activeSketch().get();
683 std::map<ModuleBase_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
684 mySelectionFilters.begin();
685 for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
686 int aFilterType = aFiltersIt->first;
687 // do not add not participating filters in given parameters
688 if (!theFilterTypes.contains(aFilterType))
691 // using sketch filters only if sketch operation is active
692 if (!isSketchActive &&
693 mySketchMgr->sketchSelectionFilter((ModuleBase_SelectionFilterType)aFilterType))
696 // using filtering of construction results only from faces panel
697 if (aFilterType == SF_ResultGroupNameFilter)
700 theSelectionFilters.Append(aFiltersIt->second);
704 //******************************************************
705 void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes)
707 if (theModes.contains(TopAbs_FACE))
708 theModes.append(SketcherPrs_Tools::Sel_Sketch_Face);
709 if (theModes.contains(TopAbs_WIRE))
710 theModes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
712 if (mySketchMgr->activeSketch().get())
713 PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
716 //******************************************************
717 void PartSet_Module::getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelected,
718 ObjectPtr& theObject, AttributePtr& theAttribute)
720 ObjectPtr anObject = theSelected->object();
721 GeomShapePtr aShape = theSelected->shape();
723 theAttribute = findAttribute(anObject, aShape);
724 // TODO: try to create result if object is an external object
725 theObject = anObject;
728 //******************************************************
729 bool PartSet_Module::isMouseOverWindow()
731 return mySketchMgr->isMouseOverWindow();
734 //******************************************************
735 bool PartSet_Module::isSketchNeutralPointActivated() const
737 bool isNeutralPoint = true;
738 if (sketchReentranceMgr()->isInternalEditActive())
739 isNeutralPoint = false;
740 if (myIsOperationIsLaunched)
741 isNeutralPoint = false;
743 return isNeutralPoint;
746 //******************************************************
747 void PartSet_Module::closeDocument()
749 myActivePartIndex = QModelIndex();
750 SketcherPrs_PositionMgr::get()->clearAll();
753 //******************************************************
754 void PartSet_Module::clearViewer()
756 myCustomPrs->clearPrs();
758 XGUI_Workshop* aWorkshop = getWorkshop();
759 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
760 aDisplayer->deactivateSelectionFilters(false);
763 //******************************************************
764 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
766 ModuleBase_OperationFeature* aFOperation =
767 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
771 ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
772 // we have to manually activate the sketch label in edit mode
773 if (PartSet_SketcherMgr::isSketchOperation(aFOperation) && (aFOperation->isEditOperation()))
774 aPanel->activateWidget(aPanel->modelWidgets().first());
777 //******************************************************
778 bool PartSet_Module::createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
779 QList<ModuleBase_ModelWidget*>& theWidgets) const
781 bool aProcessed = false;
783 XGUI_Workshop* aWorkshop = getWorkshop();
784 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
785 if (mySketchMgr->activeSketch().get() && aPropertyPanel) {
786 ModuleBase_ISelection* aSelection = workshop()->selection();
787 // click on a point in sketch leads here with the point is highlighted, not yet selected
788 QList<ModuleBase_ViewerPrsPtr> aPreselection = aSelection->getHighlighted();
789 if (aPreselection.size() == 1) {
790 ModuleBase_ViewerPrsPtr aSelectedPrs = aPreselection[0];
791 ObjectPtr anObject = aSelectedPrs->object();
793 FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
794 GeomShapePtr aShape = aSelectedPrs->shape();
795 // click on the digit of dimension constrain comes here
796 // with an empty shape, so we need the check
797 if (aFeature == theFeature && aShape.get() && !aShape->isNull()) {
798 // if feature has only one result and shape of result is equal to selected shape
799 // this attribute is not processed. It is a case of Sketch Point.
800 if (aFeature->results().size() == 1) {
801 ResultPtr aResult = aFeature->results().front();
802 if (aResult.get() && aResult->shape()->isEqual(aShape))
805 const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
806 std::pair<AttributePtr, int> anAttribute =
807 PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape, mySketchMgr->activeSketch());
808 if (anAttribute.first.get()) {
809 ModuleBase_WidgetFactory aFactory(theXmlRepr.toStdString(), workshop());
811 const std::string anAttributeId = anAttribute.first->id();
812 aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId);
814 theWidgets = aFactory.getModelWidgets();
815 // it is possible that the point does not present in XML definition,
816 // in this case, we assume that it is not processed by this module
817 // e.g. "Intersection point" feature
818 aProcessed = !theWidgets.isEmpty();
826 //******************************************************
827 void PartSet_Module::onSelectionChanged()
829 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
833 bool isSketcherOp = false;
834 // An edit operation is enable only if the current opeation is the sketch operation
835 if (mySketchMgr->activeSketch()) {
836 if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
837 isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
840 // Editing of constraints can be done on selection
841 ModuleBase_ISelection* aSelect = myWorkshop->selection();
842 QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected();
843 if (aSelected.size() == 1) {
844 ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
845 ObjectPtr aObject = aPrs->object();
846 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
848 std::string aId = aFeature->getKind();
849 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
850 (aId == SketchPlugin_ConstraintLength::ID()) ||
851 (aId == SketchPlugin_ConstraintDistance::ID()) ||
852 (aId == SketchPlugin_ConstraintAngle::ID())) {
853 editFeature(aFeature);
860 //******************************************************
861 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
863 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
864 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
865 anOpMgr->onKeyReleased(theWnd->viewPort(), theEvent);
868 //******************************************************
869 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType,
871 Config_WidgetAPI* theWidgetApi)
873 ModuleBase_IWorkshop* aWorkshop = workshop();
874 ModuleBase_ModelWidget* aWgt = NULL;
875 if (theType == "sketch-start-label") {
876 PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop,
877 theWidgetApi, myHasConstraintShown);
878 connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
879 mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
880 connect(aLabelWgt, SIGNAL(showConstraintToggled(int, bool)),
881 mySketchMgr, SLOT(onShowConstraintsToggle(int, bool)));
882 connect(aLabelWgt, SIGNAL(showFreePoints(bool)), mySketchMgr, SLOT(onShowPoints(bool)));
883 connect(aLabelWgt, SIGNAL(autoConstraints(bool)),
884 sketchReentranceMgr(), SLOT(onAutoConstraints(bool)));
885 aLabelWgt->setShowPointsState(mySketchMgr->isShowFreePointsShown());
887 } else if (theType == "sketch-2dpoint_selector") {
888 PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
890 aPointWgt->setSketch(mySketchMgr->activeSketch());
891 connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected()));
893 }else if (theType == "sketch-2dpoint_flyout_selector") {
894 PartSet_WidgetPoint2DFlyout* aPointWgt = new PartSet_WidgetPoint2DFlyout(theParent, aWorkshop,
896 aPointWgt->setSketch(mySketchMgr->activeSketch());
897 connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected()));
899 } else if (theType == "sketch_shape_selector") {
900 PartSet_WidgetShapeSelector* aShapeSelectorWgt =
901 new PartSet_WidgetShapeSelector(theParent, aWorkshop, theWidgetApi);
902 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
903 aWgt = aShapeSelectorWgt;
904 } else if (theType == "sketch_multi_selector") {
905 PartSet_WidgetMultiSelector* aShapeSelectorWgt =
906 new PartSet_WidgetMultiSelector(theParent, aWorkshop, theWidgetApi);
907 aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
908 aWgt = aShapeSelectorWgt;
910 else if (theType == "sketch_feature_point_selector") {
911 PartSet_WidgetFeaturePointSelector* aPointSelectorWgt =
912 new PartSet_WidgetFeaturePointSelector(theParent, aWorkshop, theWidgetApi);
913 aPointSelectorWgt->setSketcher(mySketchMgr->activeSketch());
914 aWgt = aPointSelectorWgt;
916 else if (theType == "sketch-bspline_selector") {
917 PartSet_WidgetBSplinePoints* aBSplineWgt =
918 new PartSet_WidgetBSplinePoints(theParent, aWorkshop, theWidgetApi);
919 aBSplineWgt->setSketch(mySketchMgr->activeSketch());
922 else if (theType == WDG_DOUBLEVALUE_EDITOR) {
923 aWgt = new PartSet_WidgetEditor(theParent, aWorkshop, theWidgetApi);
924 } else if (theType == "export_file_selector") {
925 aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi);
926 } else if (theType == "sketch_launcher") {
927 aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
929 else if (theType == "module_choice") {
930 aWgt = new ModuleBase_WidgetChoice(theParent, theWidgetApi);
931 connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
932 this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
933 } else if (theType == "bspline-panel") {
934 PartSet_BSplineWidget* aPanel = new PartSet_BSplineWidget(theParent, theWidgetApi);
935 //aPanel->setFeature(theFeature);
941 //******************************************************
942 ModuleBase_ModelWidget* PartSet_Module::activeWidget() const
944 ModuleBase_ModelWidget* anActiveWidget = 0;
946 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
948 return anActiveWidget;
950 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
952 return anActiveWidget;
954 return aPanel->activeWidget(true);
957 //******************************************************
958 bool PartSet_Module::deleteObjects()
960 bool isProcessed = false;
962 XGUI_Workshop* aWorkshop = getWorkshop();
963 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
965 //SessionPtr aMgr = ModelAPI_Session::get();
966 // 1. check whether the delete should be processed in the module
967 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
968 bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
969 isNestedOp = sketchMgr()->isNestedSketchOperation(anOperation);
970 if (isSketchOp || isNestedOp) {
972 // 2. find selected presentations
973 // selected objects should be collected before the current operation abort because
974 // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
975 ModuleBase_ISelection* aSel = workshop()->selection();
976 QObjectPtrList aSelectedObj = aSel->selectedPresentations();
977 // if there are no selected objects in the viewer, that means that the selection in another
978 // place cased this method. It is necessary to return the false value to understande in above
979 // method that delete is not processed
980 if (aSelectedObj.count() == 0)
983 // avoid delete of the objects, which are not belong to the current sketch
984 // in order to do not delete results of other sketches
985 QObjectPtrList aSketchObjects;
986 QObjectPtrList::const_iterator anIt = aSelectedObj.begin(), aLast = aSelectedObj.end();
987 for ( ; anIt != aLast; anIt++) {
988 ObjectPtr anObject = *anIt;
989 if (mySketchMgr->isObjectOfSketch(anObject)) {
990 // sketch feature should be used in this list because workshop deletes features only
991 // results are skipped
992 FeaturePtr aSketchFeature = ModelAPI_Feature::feature(anObject);
993 aSketchObjects.append(aSketchFeature);
996 // if the selection contains only local selected presentations from other sketches,
997 // the Delete operation should not be done at all
998 if (aSketchObjects.size() == 0)
1001 // 3. start operation
1002 QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
1003 ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, this);
1005 // the active nested sketch operation should be aborted unconditionally
1006 // the Delete action should be additionally granted for the Sketch operation
1007 // in order to do not abort/commit it
1009 if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
1010 return true; // the objects are processed but can not be deleted
1012 anOpMgr->startOperation(anOpAction);
1014 // WORKAROUND, should be done to avoid viewer highlight update after deletetion of objects
1015 // the problem is in AIS Dimensions recompute
1016 // if a line and the dim are removed, line is the first
1017 // it causes the AIS recompute, where the base line is null,
1018 // the result is empty AIS in the viewer
1019 XGUI_Tools::workshop(myWorkshop)->selector()->clearSelection();
1021 // 4. delete features
1022 // sketch feature should be skipped, only sub-features can be removed
1023 // when sketch operation is active
1024 aWorkshop->deleteFeatures(aSketchObjects);
1025 // 5. stop operation
1026 anOpMgr->commitOperation();
1031 //******************************************************
1032 void PartSet_Module::editFeature(FeaturePtr theFeature)
1034 storeConstraintsState(theFeature->getKind());
1035 ModuleBase_IModule::editFeature(theFeature);
1038 //******************************************************
1039 bool PartSet_Module::canCommitOperation() const
1044 //******************************************************
1045 void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
1047 myIsOperationIsLaunched = true;
1048 storeConstraintsState(theCmdId.toStdString());
1049 updateConstraintsState(theCmdId.toStdString());
1051 ModuleBase_IModule::launchOperation(theCmdId, isStartAfterCommitOnly);
1053 myIsOperationIsLaunched = false;
1056 //******************************************************
1057 void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind)
1059 if (myWorkshop->currentOperation() &&
1060 myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) {
1061 const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates =
1062 mySketchMgr->showConstraintStates();
1063 myHasConstraintShown = aShownStates;
1067 //******************************************************
1068 void PartSet_Module::updateConstraintsState(const std::string& theFeatureKind)
1070 if (PartSet_SketcherMgr::constraintsIdList().contains(theFeatureKind.c_str()) ||
1071 PartSet_SketcherMgr::replicationsIdList().contains(theFeatureKind.c_str())) {
1072 // Show constraints if a constraint was anOperation
1073 mySketchMgr->updateBySketchParameters(PartSet_Tools::Geometrical, true);
1074 mySketchMgr->updateBySketchParameters(PartSet_Tools::Dimensional, true);
1075 mySketchMgr->updateBySketchParameters(PartSet_Tools::Expressions,
1076 myHasConstraintShown[PartSet_Tools::Expressions]);
1080 //******************************************************
1081 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
1083 Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
1084 if (!anAIS.IsNull()) {
1085 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1086 if (aFeature.get()) {
1087 bool aToUseZLayer = false;
1088 if (PartSet_Tools::findRefsToMeFeature(aFeature,SketchPlugin_Projection::ID()))
1089 aToUseZLayer = true;
1091 CompositeFeaturePtr aParent = ModelAPI_Tools::compositeOwner(aFeature);
1092 aToUseZLayer = (aParent.get() && (aParent->getKind() == SketchPlugin_Sketch::ID()));
1095 Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
1096 if (aFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID())
1097 aCtx->SetZLayer(anAIS, Graphic3d_ZLayerId_Top);
1099 aCtx->SetZLayer(anAIS, myVisualLayerId);
1105 //******************************************************
1106 void PartSet_Module::onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS)
1109 // it should be recomputed in order to disappear in the viewer if the corresponded object
1111 //if (myCustomPrs->isActive())
1112 // myCustomPrs->redisplay(theObject, false);
1115 //******************************************************
1116 void PartSet_Module::onViewTransformed(int theTrsfType)
1118 // Set length of arrows constant in pixel size
1119 // if the operation is panning or rotate or panglobal then do nothing
1120 if ((theTrsfType == 1) || (theTrsfType == 3) || (theTrsfType == 4))
1122 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
1123 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
1124 if (aContext.IsNull())
1127 //Handle(V3d_View) aView = aViewer->activeView();
1129 XGUI_Workshop* aWorkshop = getWorkshop();
1130 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
1131 Handle(V3d_Viewer) aV3dViewer = aContext->CurrentViewer();
1132 Handle(V3d_View) aView;
1134 for (aV3dViewer->InitDefinedViews();
1135 aV3dViewer->MoreDefinedViews();
1136 aV3dViewer->NextDefinedViews()) {
1137 Handle(V3d_View) aV = aV3dViewer->DefinedView();
1138 double aS = aV->Scale();
1147 bool isModified = false;
1148 ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
1149 if (aCurrentOperation &&
1150 (PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
1151 sketchMgr()->isNestedSketchOperation(aCurrentOperation) ||
1152 (aCurrentOperation->id() == "Measurement")))
1154 double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
1155 SketcherPrs_Tools::setArrowSize(aLen);
1156 const double aCurScale = aViewer->activeView()->Camera()->Scale();
1157 aViewer->SetScale(aViewer->activeView(), aCurScale);
1159 QList<Handle(AIS_InteractiveObject)> aPrsList = aDisplayer->displayedPresentations();
1160 foreach(Handle(AIS_InteractiveObject) aAisObj, aPrsList) {
1162 QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
1163 foreach(AISObjectPtr aAIS, aPrsList) {
1164 Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
1166 Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
1167 if (!aDim.IsNull()) {
1168 aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
1169 aContext->Redisplay(aDim, false);
1174 aDisplayer->updateViewer();
1179 //******************************************************
1180 bool PartSet_Module::isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const
1182 return myCustomPrs->isActive(theFlag);
1185 //******************************************************
1186 void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature,
1187 const ModuleBase_CustomizeFlag& theFlag,
1188 const bool theUpdateViewer)
1190 myCustomPrs->activate(theFeature, theFlag, theUpdateViewer);
1193 //******************************************************
1194 void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
1195 const bool theUpdateViewer)
1197 myCustomPrs->deactivate(theFlag, theUpdateViewer);
1200 //******************************************************
1201 //bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
1202 // std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
1204 // bool aCustomized = false;
1206 // XGUI_Workshop* aWorkshop = getWorkshop();
1207 // XGUI_Displayer* aDisplayer = aWorkshop->displayer();
1208 // ObjectPtr anObject = aDisplayer->getObject(thePrs);
1210 // return aCustomized;
1212 // if (!theResult.get()) {
1213 // std::vector<int> aColor;
1214 // XGUI_CustomPrs::getDefaultColor(anObject, true, aColor);
1215 // if (!aColor.empty()) {
1216 // aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
1219 // // customize dimentional constrains
1220 // sketchMgr()->customisePresentation(anObject);
1222 // return aCustomized;
1225 ////******************************************************
1226 //bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
1227 // AISObjectPtr thePrs,
1228 // GeomCustomPrsPtr theCustomPrs)
1230 // bool aCustomized = false;
1232 // XGUI_Workshop* aWorkshop = getWorkshop();
1233 // XGUI_Displayer* aDisplayer = aWorkshop->displayer();
1234 // ObjectPtr anObject = aDisplayer->getObject(thePrs);
1236 // return aCustomized;
1238 // std::vector<int> aColor;
1239 // bool aUseCustomColor = true;
1240 // if (aUseCustomColor)
1241 // myOverconstraintListener->getCustomColor(anObject, aColor);
1242 // // customize sketch symbol presentation
1243 // Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
1244 // if (!anAISIO.IsNull()) {
1245 // if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
1246 // Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
1247 // if (!aPrs.IsNull()) {
1248 // aPrs->SetCustomColor(aColor);
1249 // aCustomized = true;
1251 // } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
1252 // Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
1253 // if (!aPrs.IsNull()) {
1254 // aPrs->SetCustomColor(aColor);
1255 // aCustomized = true;
1259 // // customize sketch dimension constraint presentation
1260 // if (!aCustomized) {
1261 // if (!aColor.empty()) { // otherwise presentation has the default color
1262 // aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
1265 // return aCustomized;
1268 //******************************************************
1269 bool PartSet_Module::customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
1270 const bool theUpdateViewer)
1272 bool isRedisplayed = false;
1273 if (myCustomPrs->isActive(theFlag))
1274 isRedisplayed = myCustomPrs->redisplay(theObject, theFlag, theUpdateViewer);
1276 return isRedisplayed;
1279 //******************************************************
1280 void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
1282 XGUI_ObjectsBrowser* aOB = dynamic_cast<XGUI_ObjectsBrowser*>(theObjectBrowser);
1284 QLabel* aLabel = aOB->activeDocLabel();
1285 aLabel->installEventFilter(myMenuMgr);
1286 connect(aLabel, SIGNAL(customContextMenuRequested(const QPoint&)),
1287 SLOT(onActiveDocPopup(const QPoint&)));
1288 aOB->treeView()->setExpandsOnDoubleClick(false);
1289 connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)),
1290 SLOT(onTreeViewDoubleClick(const QModelIndex&)));
1292 Events_Loop* aLoop = Events_Loop::loop();
1293 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
1297 //******************************************************
1298 void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
1300 SessionPtr aMgr = ModelAPI_Session::get();
1301 QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD");
1303 XGUI_Workshop* aWorkshop = getWorkshop();
1304 QLabel* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
1306 aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
1309 aMenu.addAction(aActivatePartAction);
1312 if (aMgr->activeDocument() == aMgr->moduleDocument()) {
1313 DocumentPtr aDoc = aMgr->moduleDocument();
1314 int aNbParts = aDoc->size(ModelAPI_ResultPart::group());
1315 bool aHaveToActivate = false;
1316 for (int i = 0; i < aNbParts; i++) {
1317 ObjectPtr aObj = aDoc->object(ModelAPI_ResultPart::group(), i);
1318 ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1319 if (!aPartRes->partDoc().get()) {
1320 aHaveToActivate = true;
1324 if (aHaveToActivate) {
1325 QAction* aActivateAllPartAction = myMenuMgr->action("ACTIVATE_ALL_PARTS_CMD");
1326 aMenu.addAction(aActivateAllPartAction);
1331 aMenu.exec(aHeader->mapToGlobal(thePnt));
1334 //******************************************************
1335 AISObjectPtr PartSet_Module::createPresentation(const ObjectPtr& theObject)
1337 Handle(AIS_InteractiveObject) anAISPrs = mySketchMgr->createPresentation(theObject);
1338 if (anAISPrs.IsNull()) {
1339 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
1340 if (aResult.get()) {
1341 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
1342 if (aShapePtr.get() != NULL)
1343 anAISPrs = new ModuleBase_ResultPrs(aResult);
1346 FieldStepPtr aStep =
1347 std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
1349 anAISPrs = new PartSet_FieldStepPrs(aStep);
1354 if (!anAISPrs.IsNull()) {
1355 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
1356 if (!aShapePrs.IsNull())
1357 ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
1359 anAIS = AISObjectPtr(new GeomAPI_AISObject());
1360 anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
1361 customizePresentation(theObject, anAIS);
1366 //******************************************************
1367 void getResultColor(const ResultPtr& theResult, std::vector<int>& theColor)
1369 ModelAPI_Tools::getColor(theResult, theColor);
1370 if (theColor.empty())
1371 PartSet_Tools::getDefaultColor(theResult, false, theColor);
1374 //******************************************************
1375 double getResultDeflection(const ResultPtr& theResult)
1377 double aDeflection = ModelAPI_Tools::getDeflection(theResult);
1378 if (aDeflection < 0)
1379 aDeflection = PartSet_Tools::getDefaultDeflection(theResult);
1383 //******************************************************
1384 double getResultTransparency(const ResultPtr& theResult)
1386 double aTransparency = ModelAPI_Tools::getTransparency(theResult);
1387 if (aTransparency < 0)
1388 aTransparency = PartSet_Tools::getDefaultTransparency();
1389 return aTransparency;
1393 //******************************************************
1394 void PartSet_Module::customizePresentation(const ObjectPtr& theObject,
1395 const AISObjectPtr& thePrs) const
1397 if (mySketchMgr->isObjectOfSketch(theObject)) {
1398 mySketchMgr->customizeSketchPresentation(theObject, thePrs);
1401 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
1402 if (aResult.get()) {
1403 std::vector<int> aColor;
1404 getResultColor(aResult, aColor);
1406 SessionPtr aMgr = ModelAPI_Session::get();
1407 if (aMgr->activeDocument() != aResult->document()) {
1408 QColor aQColor(aColor[0], aColor[1], aColor[2]);
1410 QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF() / 3., aQColor.valueF());
1411 aColor[0] = aNewColor.red();
1412 aColor[1] = aNewColor.green();
1413 aColor[2] = aNewColor.blue();
1415 thePrs->setColor(aColor[0], aColor[1], aColor[2]);
1417 thePrs->setDeflection(getResultDeflection(aResult));
1419 thePrs->setTransparency(getResultTransparency(aResult));
1421 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1422 if (aFeature.get()) {
1423 if (aFeature->getKind() == SketchPlugin_Sketch::ID())
1424 thePrs->setWidth(2);
1430 //******************************************************
1431 ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
1434 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
1436 /// If last line finished on vertex the lines creation sequence has to be break
1437 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
1439 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
1440 // if there is an active widget, find the presented object in it
1441 if (!anActiveWidget)
1442 anActiveWidget = aPanel->preselectionWidget();
1444 ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
1446 if (aWidgetValidated)
1447 anObject = aWidgetValidated->findPresentedObject(theAIS);
1453 //******************************************************
1454 bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
1456 bool aCanBeShaged = true;
1458 Handle(PartSet_ResultSketchPrs) aPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theAIS);
1460 aCanBeShaged = false;
1462 return aCanBeShaged;
1465 //******************************************************
1466 void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
1468 QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
1469 int aSelected = aObjects.size();
1470 SessionPtr aMgr = ModelAPI_Session::get();
1471 QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PART_CMD");
1473 bool hasResult = false;
1474 bool hasFeature = false;
1475 bool hasParameter = false;
1476 bool hasCompositeOwner = false;
1477 bool hasResultInHistory = false;
1478 bool hasFolder = false;
1479 ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
1480 hasCompositeOwner, hasResultInHistory, hasFolder);
1482 ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
1483 if (aSelected == 1) {
1484 ObjectPtr aObject = aObjects.first();
1486 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
1487 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
1488 bool isPart = aPart.get() ||
1489 (aFeature.get() && (aFeature->getKind() == PartSetPlugin_Part::ID()));
1491 DocumentPtr aPartDoc;
1493 aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFeature->firstResult());
1495 if (aPart.get()) // this may be null is Part feature is disabled
1496 aPartDoc = aPart->partDoc();
1498 theMenu->addAction(aActivatePartAction);
1499 aActivatePartAction->setEnabled((aMgr->activeDocument() != aPartDoc));
1501 } else if (aObject->document() == aMgr->activeDocument()) {
1502 if (hasParameter || hasFeature) {
1503 myMenuMgr->action("EDIT_CMD")->setEnabled(true);
1504 theMenu->addAction(myMenuMgr->action("EDIT_CMD"));
1505 if (aCurrentOp && aFeature.get()) {
1506 if (aCurrentOp->id().toStdString() == aFeature->getKind())
1507 myMenuMgr->action("EDIT_CMD")->setEnabled(false);
1514 myMenuMgr->action("EDIT_CMD")->setEnabled(aCurrentOp == 0);
1515 theMenu->addAction(myMenuMgr->action("EDIT_CMD"));
1516 theMenu->addSeparator();
1519 bool aNotDeactivate = (aCurrentOp == 0);
1520 if (!aNotDeactivate) {
1521 aActivatePartAction->setEnabled(false);
1525 //******************************************************
1526 #define EXPAND_PARENT(OBJ) \
1527 QModelIndex aObjIndex = aDataModel->objectIndex(OBJ); \
1528 if (aObjIndex.isValid()) { \
1529 QModelIndex aParent = aObjIndex.parent(); \
1530 int aCount = aDataModel->rowCount(aParent); \
1532 aTreeView->setExpanded(aParent, true); \
1535 //******************************************************
1536 void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
1538 if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
1539 // Do not change activation of parts if an operation active
1540 static QStringList aAllowActivationList;
1541 if (aAllowActivationList.isEmpty())
1542 aAllowActivationList <<
1543 QString(PartSetPlugin_Part::ID().c_str()) <<
1544 QString(PartSetPlugin_Duplicate::ID().c_str()) <<
1545 QString(PartSetPlugin_Remove::ID().c_str());
1546 if (myWorkshop->currentOperation() &&
1547 (!aAllowActivationList.contains(myWorkshop->currentOperation()->id())))
1549 XGUI_Workshop* aWorkshop = getWorkshop();
1550 XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
1551 QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
1552 QPalette aPalet = aLabel->palette();
1554 SessionPtr aMgr = ModelAPI_Session::get();
1555 DocumentPtr aActiveDoc = aMgr->activeDocument();
1557 // Clear active part index if there is no Part documents
1558 // It could be not null if document was closed and opened a new
1559 // without closeDocument call
1560 if (aMgr->allOpenedDocuments().size() <= 1)
1561 myActivePartIndex = QModelIndex();
1563 XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
1564 QModelIndex aOldActive = myActivePartIndex;
1565 myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
1566 bool needUpdate = false;
1567 if (myActivePartIndex.isValid()) {
1568 needUpdate = aTreeView->isExpanded(myActivePartIndex);
1570 aTreeView->setExpanded(myActivePartIndex, true);
1572 if ((aOldActive != myActivePartIndex) && (aOldActive.isValid()))
1573 aTreeView->setExpanded(aOldActive, false);
1575 aLabel->setPalette(aPalet);
1576 aWorkshop->updateCommandStatus();
1578 // Update displayed objects in order to update active color
1579 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
1580 QObjectPtrList aObjects = aDisplayer->displayedObjects();
1582 foreach(ObjectPtr aObj, aObjects) {
1583 aHidden = !aObj->data() || !aObj->data()->isValid() ||
1584 aObj->isDisabled() || (!aObj->isDisplayed());
1586 aDisplayer->redisplay(aObj, false);
1589 aDisplayer->updateViewer();
1590 // Update tree items if they are expanded
1592 aTreeView->viewport()->update(aTreeView->viewport()->rect());
1594 } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
1595 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
1596 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
1597 std::set<ObjectPtr> aObjects = aUpdMsg->objects();
1599 ObjectPtr aConstrObj;
1600 ObjectPtr aResultObj;
1601 std::set<ObjectPtr>::const_iterator aIt;
1602 DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
1603 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
1604 ObjectPtr aObject = (*aIt);
1605 if ((!aResultObj.get()) && (aObject->groupName() == ModelAPI_ResultBody::group())
1606 && (aObject->document() != aRootDoc))
1607 aResultObj = aObject;
1608 if ((!aConstrObj.get()) && (aObject->groupName() == ModelAPI_ResultConstruction::group())
1609 && (aObject->document() != aRootDoc))
1610 aConstrObj = aObject;
1611 if (aResultObj.get() && aConstrObj.get())
1615 if (aResultObj.get() || aConstrObj.get()) {
1616 XGUI_Workshop* aWorkshop = getWorkshop();
1617 XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
1618 XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
1620 if (aResultObj.get()) {
1621 EXPAND_PARENT(aResultObj)
1623 if (aConstrObj.get()) {
1624 EXPAND_PARENT(aConstrObj)
1628 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
1629 CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
1630 if (aSketch.get()) {
1631 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
1632 if (PartSet_SketcherMgr::isSketchOperation(anOperation))
1633 mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
1638 //******************************************************
1639 void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
1641 if (myWorkshop->currentOperation()) // Do not change activation of parts if an operation active
1643 SessionPtr aMgr = ModelAPI_Session::get();
1644 if (!theIndex.isValid()) {
1645 // It seems that this code is obsolete
1646 //aMgr->setActiveDocument(aMgr->moduleDocument());
1649 if (theIndex.column() != 1) // Use only first column
1652 XGUI_Workshop* aWorkshop = getWorkshop();
1653 XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
1654 // De not use non editable Indexes
1655 if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0)
1657 ObjectPtr aObj = aDataModel->object(theIndex);
1659 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
1660 if (!aPart.get()) { // Probably this is Feature
1661 FeaturePtr aPartFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
1662 if (aPartFeature.get() && (aPartFeature->getKind() == PartSetPlugin_Part::ID())) {
1663 aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aPartFeature->firstResult());
1666 if (aPart.get()) { // if this is a part
1667 if (aPart->partDoc() == aMgr->activeDocument()) {
1668 myMenuMgr->activatePartSet();
1670 myMenuMgr->activatePart(aPart);
1675 //******************************************************
1676 void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
1678 // z layer is created for all started operations in order to visualize operation AIS presentation
1680 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
1681 if (aContext.IsNull())
1684 Handle(V3d_Viewer) aViewer = aContext->CurrentViewer();
1685 if (myVisualLayerId == 0) {
1686 if (myVisualLayerId == 0)
1687 aViewer->AddZLayer(myVisualLayerId);
1689 TColStd_SequenceOfInteger aZList;
1690 aViewer->GetAllZLayers(aZList);
1691 bool aFound = false;
1692 for (int i = 1; i <= aZList.Length(); i++) {
1693 if (aZList(i) == myVisualLayerId) {
1699 aViewer->AddZLayer(myVisualLayerId);
1701 // if there is an active operation with validated widget,
1702 // the filters of this widget should be activated in the created view
1703 myWorkshop->selectionActivate()->updateSelectionFilters();
1704 myWorkshop->selectionActivate()->updateSelectionModes();
1707 //******************************************************
1708 void PartSet_Module::widgetStateChanged(int thePreviousState)
1710 mySketchMgr->widgetStateChanged(thePreviousState);
1713 //******************************************************
1714 bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID)
1716 return mySketchReentrantMgr->processEnter(thePreviousAttributeID);
1719 //******************************************************
1720 void PartSet_Module::beforeOperationStopped(ModuleBase_Operation* theOperation)
1722 if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
1723 mySketchMgr->stopSketch(theOperation);
1727 //******************************************************
1728 GeomShapePtr PartSet_Module::findShape(const AttributePtr& theAttribute)
1730 GeomShapePtr aGeomShape;
1732 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
1733 if (anOperation && sketchMgr()->isNestedSketchOperation(anOperation)) {
1734 aGeomShape = PartSet_Tools::findShapeBy2DPoint(theAttribute, myWorkshop);
1739 //******************************************************
1740 AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject,
1741 const GeomShapePtr& theGeomShape)
1743 AttributePtr anAttribute;
1744 GeomShapePtr aGeomShape = theGeomShape;
1745 if (!aGeomShape.get()) {
1746 // processing shape of result, e.g. sketch circle center is selected, this is a result
1747 // the geom shape is empty, the shape of result should be used
1748 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
1749 if (aResult.get()) {
1750 aGeomShape = aResult->shape();
1754 if (aGeomShape.get()) {
1755 TopoDS_Shape aTDSShape = aGeomShape->impl<TopoDS_Shape>();
1756 std::pair<AttributePtr, int> anAttrAndIndex =
1757 PartSet_Tools::findAttributeBy2dPoint(theObject, aTDSShape, mySketchMgr->activeSketch());
1758 return anAttrAndIndex.first;
1763 //******************************************************
1764 std::shared_ptr<Events_Message> PartSet_Module::reentrantMessage()
1766 return sketchReentranceMgr()->reentrantMessage();
1769 //******************************************************
1770 void PartSet_Module::setReentrantPreSelection(const std::shared_ptr<Events_Message>& theMessage)
1772 sketchReentranceMgr()->setReentrantPreSelection(theMessage);
1775 //******************************************************
1776 void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
1779 ModuleBase_WidgetChoice* aChoiceWidget = dynamic_cast<ModuleBase_WidgetChoice*>(theWidget);
1783 QString aChoiceTitle = aChoiceWidget->getPropertyPanelTitle(theIndex);
1784 if (!aChoiceTitle.isEmpty()) {
1785 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
1788 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
1790 aPanel->setWindowTitle(aChoiceTitle);
1794 //******************************************************
1795 XGUI_Workshop* PartSet_Module::getWorkshop() const
1797 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
1798 return aConnector->workshop();
1801 void PartSet_Module::setDefaultConstraintShown()
1803 myHasConstraintShown[PartSet_Tools::Geometrical] = true;
1804 myHasConstraintShown[PartSet_Tools::Dimensional] = true;
1805 myHasConstraintShown[PartSet_Tools::Expressions] = false;
1808 //******************************************************
1809 ModuleBase_ITreeNode* PartSet_Module::rootNode() const
1814 //******************************************************
1815 void PartSet_Module::disableCustomMode(ModuleBase_CustomizeFlag theMode) {
1816 myCustomPrs->disableCustomMode(theMode);
1819 //******************************************************
1820 void PartSet_Module::enableCustomModes() {
1821 myCustomPrs->enableCustomModes();