1 #include "PartSet_Module.h"
2 #include <PartSet_OperationSketch.h>
3 #include <PartSet_WidgetSketchLabel.h>
4 #include <PartSet_Validators.h>
5 #include <PartSet_Tools.h>
6 #include <PartSet_WidgetPoint2d.h>
7 #include <PartSet_WidgetPoint2dDistance.h>
8 #include <PartSet_WidgetShapeSelector.h>
10 #include <ModuleBase_Operation.h>
11 #include <ModuleBase_IViewer.h>
12 #include <ModuleBase_IViewWindow.h>
13 #include <ModuleBase_IPropertyPanel.h>
14 #include <ModuleBase_WidgetEditor.h>
15 #include <ModuleBase_FilterFactory.h>
16 #include <ModuleBase_FilterLinearEdge.h>
19 #include <ModelAPI_Object.h>
20 #include <ModelAPI_Events.h>
21 #include <ModelAPI_Validator.h>
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_Session.h>
25 #include <GeomDataAPI_Point2D.h>
26 #include <GeomDataAPI_Point.h>
27 #include <GeomDataAPI_Dir.h>
29 #include <XGUI_Displayer.h>
30 #include <XGUI_Workshop.h>
31 #include <XGUI_OperationMgr.h>
32 #include <XGUI_PropertyPanel.h>
33 #include <XGUI_ModuleConnector.h>
34 #include <XGUI_Tools.h>
36 #include <SketchPlugin_Line.h>
37 #include <SketchPlugin_Sketch.h>
38 #include <SketchPlugin_Point.h>
39 #include <SketchPlugin_Arc.h>
40 #include <SketchPlugin_Circle.h>
41 #include <SketchPlugin_ConstraintLength.h>
42 #include <SketchPlugin_ConstraintDistance.h>
43 #include <SketchPlugin_ConstraintParallel.h>
44 #include <SketchPlugin_ConstraintPerpendicular.h>
45 #include <SketchPlugin_ConstraintRadius.h>
46 #include <SketchPlugin_ConstraintRigid.h>
48 #include <Events_Loop.h>
50 #include <StdSelect_TypeOfFace.hxx>
51 #include <TopoDS_Vertex.hxx>
53 #include <TopoDS_Shape.hxx>
54 #include <BRep_Tool.hxx>
57 #include <QMouseEvent>
60 #include <QApplication>
62 #include <GeomAlgoAPI_FaceBuilder.h>
63 #include <GeomDataAPI_Dir.h>
70 /// Returns list of unique objects by sum of objects from List1 and List2
71 QList<ObjectPtr> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
72 const QList<ModuleBase_ViewerPrs>& theList2)
74 QList<ObjectPtr> aRes;
75 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
76 if (!aRes.contains(aPrs.object()))
77 aRes.append(aPrs.object());
79 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
80 if (!aRes.contains(aPrs.object()))
81 aRes.append(aPrs.object());
86 /*!Create and return new instance of XGUI_Module*/
87 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
89 return new PartSet_Module(theWshop);
92 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
93 : ModuleBase_IModule(theWshop),
94 myIsDragging(false), myRestartingMode(RM_None), myDragDone(false)
96 //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
97 ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
98 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
99 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
101 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
102 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
104 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
105 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
107 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
108 this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
110 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
111 XGUI_Workshop* aWorkshop = aConnector->workshop();
113 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
114 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
116 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
117 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
120 PartSet_Module::~PartSet_Module()
122 if (!myDocumentShapeFilter.IsNull())
123 myDocumentShapeFilter.Nullify();
124 if (!myPlaneFilter.IsNull())
125 myPlaneFilter.Nullify();
128 void PartSet_Module::registerValidators()
130 //Registering of validators
131 SessionPtr aMgr = ModelAPI_Session::get();
132 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
133 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
134 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
135 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
136 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
137 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
138 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
141 void PartSet_Module::registerFilters()
143 //Registering of selection filters
144 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
145 ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
147 aFactory->registerFilter("LinearEdgeFilter", new ModuleBase_FilterLinearEdge);
150 void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation)
152 if (theOperation->isEditOperation())
154 /// Restart sketcher operations automatically
155 FeaturePtr aFeature = theOperation->feature();
156 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
157 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
158 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
159 myRestartingMode == RM_EmptyFeatureUsed)) {
160 myLastOperationId = theOperation->id();
161 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
162 launchOperation(myLastOperationId);
164 breakOperationSequence();
167 void PartSet_Module::breakOperationSequence()
169 myLastOperationId = "";
170 myLastFeature = FeaturePtr();
171 myRestartingMode = RM_None;
174 void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
176 breakOperationSequence();
179 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
181 if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
182 // Display all sketcher sub-Objects
183 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
184 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
185 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
187 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
188 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
189 std::list<ResultPtr> aResults = aFeature->results();
190 std::list<ResultPtr>::const_iterator aIt;
191 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
192 aDisplayer->display((*aIt), false);
194 aDisplayer->display(aFeature);
196 // Hide sketcher result
197 std::list<ResultPtr> aResults = myCurrentSketch->results();
198 std::list<ResultPtr>::const_iterator aIt;
199 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
200 aDisplayer->erase((*aIt), false);
202 aDisplayer->erase(myCurrentSketch);
205 if (myPlaneFilter.IsNull())
206 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
207 myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
208 if (theOperation->isEditOperation()) {
209 // If it is editing of sketch then it means that plane is already defined
210 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
211 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
214 if (myDocumentShapeFilter.IsNull())
215 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
216 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
219 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
221 if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
222 DataPtr aData = myCurrentSketch->data();
223 if ((!aData) || (!aData->isValid())) {
224 // The sketch was aborted
225 myCurrentSketch = CompositeFeaturePtr();
228 // Hide all sketcher sub-Objects
229 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
230 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
231 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
232 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
233 std::list<ResultPtr> aResults = aFeature->results();
234 std::list<ResultPtr>::const_iterator aIt;
235 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
236 aDisplayer->erase((*aIt), false);
238 aDisplayer->erase(aFeature, false);
240 // Display sketcher result
241 std::list<ResultPtr> aResults = myCurrentSketch->results();
242 std::list<ResultPtr>::const_iterator aIt;
243 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
244 aDisplayer->display((*aIt), false);
246 aDisplayer->display(myCurrentSketch);
248 myCurrentSketch = CompositeFeaturePtr();
249 myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
251 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
254 void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
256 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
260 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
262 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
263 if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
264 (theOperation->isEditOperation())) {
265 // we have to manually activate the sketch label in edit mode
266 aPanel->activateWidget(aPanel->modelWidgets().first());
270 // Restart last operation type
271 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
272 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
273 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
274 // Initialise new line with first point equal to end of previous
275 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
277 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
278 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
279 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
281 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
282 PartSet_Tools::setConstraints(myCurrentSketch, theOperation->feature(),
283 aWgt->attributeID(), aPoint->x(), aPoint->y());
284 theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt);
289 // Start editing constraint
290 if (theOperation->isEditOperation()) {
291 std::string aId = theOperation->id().toStdString();
292 if (sketchOperationIdList().contains(QString(aId.c_str()))) {
293 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
294 (aId == SketchPlugin_ConstraintLength::ID()) ||
295 (aId == SketchPlugin_ConstraintDistance::ID())) {
296 // Find and activate widget for management of point for dimension line position
297 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
298 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
299 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
301 aPanel->activateWidget(aPntWgt);
312 void PartSet_Module::onSelectionChanged()
314 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
315 bool isSketcherOp = false;
316 // An edit operation is enable only if the current opeation is the sketch operation
317 if (aOperation && myCurrentSketch) {
318 if (PartSet_Tools::sketchPlane(myCurrentSketch))
319 isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
324 // Editing of constraints can be done on selection
325 ModuleBase_ISelection* aSelect = myWorkshop->selection();
326 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
327 if (aSelected.size() == 1) {
328 ModuleBase_ViewerPrs aPrs = aSelected.first();
329 ObjectPtr aObject = aPrs.object();
330 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
332 std::string aId = aFeature->getKind();
333 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
334 (aId == SketchPlugin_ConstraintLength::ID()) ||
335 (aId == SketchPlugin_ConstraintDistance::ID())) {
336 editFeature(aFeature);
342 void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
344 if (!(theEvent->buttons() & Qt::LeftButton))
347 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
348 // Use only for sketch operations
349 if (aOperation && myCurrentSketch) {
350 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
353 bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
354 bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
356 // Avoid non-sketch operations
357 if ((!isSketchOpe) && (!isSketcher))
360 bool isEditing = aOperation->isEditOperation();
362 // Ignore creation sketch operation
363 if ((!isSketcher) && (!isEditing))
366 if (theEvent->modifiers()) {
367 // If user performs multiselection
368 if (isSketchOpe && (!isSketcher))
369 if (!aOperation->commit())
373 // Remember highlighted objects for editing
374 ModuleBase_ISelection* aSelect = myWorkshop->selection();
375 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
376 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
377 myEditingFeatures.clear();
378 myEditingAttr.clear();
379 if ((aHighlighted.size() == 0) && (aSelected.size() == 0)) {
380 if (isSketchOpe && (!isSketcher))
381 // commit previous operation
382 if (!aOperation->commit())
387 QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected);
388 if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
389 // Move by selected shape (vertex). Can be used only for single selection
390 foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
391 FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object());
393 myEditingFeatures.append(aFeature);
394 TopoDS_Shape aShape = aPrs.shape();
395 if (!aShape.IsNull()) {
396 if (aShape.ShapeType() == TopAbs_VERTEX) {
397 AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(),
398 aShape, myCurrentSketch);
400 myEditingAttr.append(aAttr);
406 // Provide multi-selection. Can be used only for features
407 foreach (ObjectPtr aObj, aSelObjects) {
408 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
409 if (aFeature && (!myEditingFeatures.contains(aFeature)))
410 myEditingFeatures.append(aFeature);
414 // If nothing highlighted - return
415 if (myEditingFeatures.size() == 0)
420 get2dPoint(theWnd, theEvent, myCurX, myCurY);
422 myWorkshop->viewer()->enableSelection(false);
425 } else if (isSketchOpe && isEditing) {
426 // If selected another object
430 get2dPoint(theWnd, theEvent, myCurX, myCurY);
432 myWorkshop->viewer()->enableSelection(false);
434 // This is necessary in order to finalize previous operation
435 QApplication::processEvents();
442 void PartSet_Module::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
443 double& theX, double& theY)
445 Handle(V3d_View) aView = theWnd->v3dView();
446 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
447 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
451 void PartSet_Module::launchEditing()
453 if (myEditingFeatures.size() > 0) {
454 FeaturePtr aFeature = myEditingFeatures.first();
455 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
456 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
458 editFeature(aSPFeature);
463 /// Returns new instance of operation object (used in createOperation for customization)
464 ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
466 if (theFeatureId == PartSet_OperationSketch::Type()) {
467 return new PartSet_OperationSketch(theFeatureId.c_str(), this);
469 return ModuleBase_IModule::getNewOperation(theFeatureId);
473 void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
475 myWorkshop->viewer()->enableSelection(true);
477 myIsDragging = false;
479 myWorkshop->currentOperation()->commit();
480 myEditingFeatures.clear();
481 myEditingAttr.clear();
487 void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
490 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
491 if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
492 return; // No edit operation activated
494 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
495 Handle(V3d_View) aView = theWnd->v3dView();
496 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
498 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
499 double dX = aX - myCurX;
500 double dY = aY - myCurY;
502 if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
503 (myEditingAttr.size() == 1) &&
504 myEditingAttr.first()) {
505 // probably we have prehighlighted point
506 AttributePtr aAttr = myEditingAttr.first();
507 std::string aAttrId = aAttr->id();
508 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
509 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
510 // Find corresponded widget to provide dragging
511 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
512 if (aWgt->attributeID() == aAttrId) {
513 PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
515 aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
521 foreach(FeaturePtr aFeature, myEditingFeatures) {
522 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
523 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
524 if (aSketchFeature) {
525 aSketchFeature->move(dX, dY);
526 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
529 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
530 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
538 void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
540 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
541 if (aOperation->isEditOperation()) {
542 std::string aId = aOperation->id().toStdString();
543 if ((aId == SketchPlugin_ConstraintLength::ID()) ||
544 (aId == SketchPlugin_ConstraintDistance::ID()) ||
545 (aId == SketchPlugin_ConstraintRadius::ID()))
547 // Activate dimension value editing on double click
548 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
549 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
550 // Find corresponded widget to activate value editing
551 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
552 if (aWgt->attributeID() == "ConstraintValue") {
561 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
563 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
564 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
565 anOpMgr->onKeyReleased(theEvent);
568 void PartSet_Module::onEnterReleased()
570 myRestartingMode = RM_EmptyFeatureUsed;
573 void PartSet_Module::onNoMoreWidgets()
575 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
577 /// Restart sketcher operations automatically
578 FeaturePtr aFeature = aOperation->feature();
579 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
580 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
582 if (myRestartingMode != RM_Forbided)
583 myRestartingMode = RM_LastFeatureUsed;
584 aOperation->commit();
589 QStringList PartSet_Module::sketchOperationIdList() const
592 aIds << SketchPlugin_Line::ID().c_str();
593 aIds << SketchPlugin_Point::ID().c_str();
594 aIds << SketchPlugin_Arc::ID().c_str();
595 aIds << SketchPlugin_Circle::ID().c_str();
596 aIds << SketchPlugin_ConstraintLength::ID().c_str();
597 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
598 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
599 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
600 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
601 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
605 void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape)
607 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
608 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
609 /// If last line finished on vertex the lines creation sequence has to be break
610 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
611 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
612 if (aWidgets.last() == aPanel->activeWidget()) {
613 myRestartingMode = RM_Forbided;
618 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
619 Config_WidgetAPI* theWidgetApi, std::string theParentId,
620 QList<ModuleBase_ModelWidget*>& theModelWidgets)
622 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
623 XGUI_Workshop* aWorkshop = aConnector->workshop();
624 if (theType == "sketch-start-label") {
625 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
626 aWgt->setWorkshop(aWorkshop);
627 connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
628 this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
629 theModelWidgets.append(aWgt);
630 return aWgt->getControl();
632 } else if (theType == "sketch-2dpoint_selector") {
633 PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
634 aWgt->setWorkshop(aWorkshop);
635 aWgt->setSketch(myCurrentSketch);
637 connect(aWgt, SIGNAL(vertexSelected(ObjectPtr, const TopoDS_Shape&)),
638 this, SLOT(onVertexSelected(ObjectPtr, const TopoDS_Shape&)));
640 theModelWidgets.append(aWgt);
641 return aWgt->getControl();
643 } if (theType == "point2ddistance") {
644 PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
645 aWgt->setWorkshop(aWorkshop);
646 aWgt->setSketch(myCurrentSketch);
648 theModelWidgets.append(aWgt);
649 return aWgt->getControl();
651 } if (theType == "sketch_shape_selector") {
652 PartSet_WidgetShapeSelector* aWgt =
653 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
654 aWgt->setSketcher(myCurrentSketch);
656 theModelWidgets.append(aWgt);
657 return aWgt->getControl();
659 } if (theType == "sketch_constraint_shape_selector") {
660 PartSet_WidgetConstraintShapeSelector* aWgt =
661 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
662 aWgt->setSketcher(myCurrentSketch);
664 theModelWidgets.append(aWgt);
665 return aWgt->getControl();