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>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Events.h>
17 #include <ModelAPI_Validator.h>
18 #include <ModelAPI_Data.h>
19 #include <ModelAPI_Session.h>
21 #include <GeomDataAPI_Point2D.h>
22 #include <GeomDataAPI_Point.h>
23 #include <GeomDataAPI_Dir.h>
25 #include <XGUI_MainWindow.h>
26 #include <XGUI_Displayer.h>
27 #include <XGUI_Viewer.h>
28 #include <XGUI_Workshop.h>
29 #include <XGUI_OperationMgr.h>
30 #include <XGUI_ViewPort.h>
31 #include <XGUI_ActionsMgr.h>
32 #include <XGUI_ViewerProxy.h>
33 #include <XGUI_ContextMenuMgr.h>
34 #include <XGUI_PropertyPanel.h>
35 #include <XGUI_ModuleConnector.h>
36 #include <XGUI_Tools.h>
38 #include <SketchPlugin_Line.h>
39 #include <SketchPlugin_Sketch.h>
40 #include <SketchPlugin_Point.h>
41 #include <SketchPlugin_Arc.h>
42 #include <SketchPlugin_Circle.h>
43 #include <SketchPlugin_ConstraintLength.h>
44 #include <SketchPlugin_ConstraintDistance.h>
45 #include <SketchPlugin_ConstraintParallel.h>
46 #include <SketchPlugin_ConstraintPerpendicular.h>
47 #include <SketchPlugin_ConstraintRadius.h>
48 #include <SketchPlugin_ConstraintRigid.h>
50 #include <Events_Loop.h>
52 #include <StdSelect_TypeOfFace.hxx>
53 #include <TopoDS_Vertex.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <BRep_Tool.hxx>
59 #include <QMouseEvent>
62 #include <QApplication>
64 #include <GeomAlgoAPI_FaceBuilder.h>
65 #include <GeomDataAPI_Dir.h>
72 /// Returns list of unique objects by sum of objects from List1 and List2
73 QList<ObjectPtr> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
74 const QList<ModuleBase_ViewerPrs>& theList2)
76 QList<ObjectPtr> aRes;
77 foreach (ModuleBase_ViewerPrs aPrs, theList1) {
78 if (!aRes.contains(aPrs.object()))
79 aRes.append(aPrs.object());
81 foreach (ModuleBase_ViewerPrs aPrs, theList2) {
82 if (!aRes.contains(aPrs.object()))
83 aRes.append(aPrs.object());
88 /*!Create and return new instance of XGUI_Module*/
89 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
91 return new PartSet_Module(theWshop);
94 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
95 : ModuleBase_IModule(theWshop),
96 myIsDragging(false), myRestartingMode(RM_None), myDragDone(false)
98 //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
99 ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
100 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
101 this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
103 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
104 this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
106 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
107 this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
109 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
110 XGUI_Workshop* aWorkshop = aConnector->workshop();
112 XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
113 connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
115 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
116 this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
119 PartSet_Module::~PartSet_Module()
121 if (!myDocumentShapeFilter.IsNull())
122 myDocumentShapeFilter.Nullify();
123 if (!myPlaneFilter.IsNull())
124 myPlaneFilter.Nullify();
127 void PartSet_Module::registerValidators()
129 //Registering of validators
130 SessionPtr aMgr = ModelAPI_Session::get();
131 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
132 aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
133 aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
134 aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
135 aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
136 aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
137 aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
141 void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation)
143 if (theOperation->isEditOperation())
145 /// Restart sketcher operations automatically
146 FeaturePtr aFeature = theOperation->feature();
147 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
148 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
149 if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
150 myRestartingMode == RM_EmptyFeatureUsed)) {
151 myLastOperationId = theOperation->id();
152 myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
153 launchOperation(myLastOperationId);
155 breakOperationSequence();
158 void PartSet_Module::breakOperationSequence()
160 myLastOperationId = "";
161 myLastFeature = FeaturePtr();
162 myRestartingMode = RM_None;
165 void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
167 breakOperationSequence();
170 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
172 if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
173 // Display all sketcher sub-Objects
174 myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
175 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
176 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
178 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
179 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
180 std::list<ResultPtr> aResults = aFeature->results();
181 std::list<ResultPtr>::const_iterator aIt;
182 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
183 aDisplayer->display((*aIt), false);
185 aDisplayer->display(aFeature);
187 // Hide sketcher result
188 std::list<ResultPtr> aResults = myCurrentSketch->results();
189 std::list<ResultPtr>::const_iterator aIt;
190 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
191 aDisplayer->erase((*aIt), false);
193 aDisplayer->erase(myCurrentSketch);
196 if (myPlaneFilter.IsNull())
197 myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
198 myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
199 if (theOperation->isEditOperation()) {
200 // If it is editing of sketch then it means that plane is already defined
201 std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
202 myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
205 if (myDocumentShapeFilter.IsNull())
206 myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
207 myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
210 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
212 if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
213 DataPtr aData = myCurrentSketch->data();
214 if ((!aData) || (!aData->isValid())) {
215 // The sketch was aborted
216 myCurrentSketch = CompositeFeaturePtr();
219 // Hide all sketcher sub-Objects
220 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
221 XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
222 for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
223 FeaturePtr aFeature = myCurrentSketch->subFeature(i);
224 std::list<ResultPtr> aResults = aFeature->results();
225 std::list<ResultPtr>::const_iterator aIt;
226 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
227 aDisplayer->erase((*aIt), false);
229 aDisplayer->erase(aFeature, false);
231 // Display sketcher result
232 std::list<ResultPtr> aResults = myCurrentSketch->results();
233 std::list<ResultPtr>::const_iterator aIt;
234 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
235 aDisplayer->display((*aIt), false);
237 aDisplayer->display(myCurrentSketch);
239 myCurrentSketch = CompositeFeaturePtr();
240 myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
242 myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
245 void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
247 myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
251 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
253 ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
254 if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
255 (theOperation->isEditOperation())) {
256 // we have to manually activate the sketch label in edit mode
257 aPanel->activateWidget(aPanel->modelWidgets().first());
261 // Restart last operation type
262 if ((theOperation->id() == myLastOperationId) && myLastFeature) {
263 ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
264 if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
265 // Initialise new line with first point equal to end of previous
266 PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
268 std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
269 std::shared_ptr<GeomDataAPI_Point2D> aPoint =
270 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
272 aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
273 PartSet_Tools::setConstraints(myCurrentSketch, theOperation->feature(),
274 aWgt->attributeID(), aPoint->x(), aPoint->y());
275 theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt);
280 // Start editing constraint
281 if (theOperation->isEditOperation()) {
282 std::string aId = theOperation->id().toStdString();
283 if (sketchOperationIdList().contains(QString(aId.c_str()))) {
284 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
285 (aId == SketchPlugin_ConstraintLength::ID()) ||
286 (aId == SketchPlugin_ConstraintDistance::ID())) {
287 // Find and activate widget for management of point for dimension line position
288 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
289 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
290 PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
292 aPanel->activateWidget(aPntWgt);
303 void PartSet_Module::onSelectionChanged()
305 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
306 bool isSketcherOp = false;
307 // An edit operation is enable only if the current opeation is the sketch operation
308 if (aOperation && myCurrentSketch) {
309 if (PartSet_Tools::sketchPlane(myCurrentSketch))
310 isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
315 // Editing of constraints can be done on selection
316 ModuleBase_ISelection* aSelect = myWorkshop->selection();
317 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
318 if (aSelected.size() == 1) {
319 ModuleBase_ViewerPrs aPrs = aSelected.first();
320 ObjectPtr aObject = aPrs.object();
321 FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
323 std::string aId = aFeature->getKind();
324 if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
325 (aId == SketchPlugin_ConstraintLength::ID()) ||
326 (aId == SketchPlugin_ConstraintDistance::ID())) {
327 editFeature(aFeature);
333 void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
335 if (!(theEvent->buttons() & Qt::LeftButton))
338 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
339 // Use only for sketch operations
340 if (aOperation && myCurrentSketch) {
341 if (!PartSet_Tools::sketchPlane(myCurrentSketch))
344 bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
345 bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
347 // Avoid non-sketch operations
348 if ((!isSketchOpe) && (!isSketcher))
351 bool isEditing = aOperation->isEditOperation();
353 // Ignore creation sketch operation
354 if ((!isSketcher) && (!isEditing))
357 if (theEvent->modifiers()) {
358 // If user performs multiselection
359 if (isSketchOpe && (!isSketcher))
360 if (!aOperation->commit())
364 // Remember highlighted objects for editing
365 ModuleBase_ISelection* aSelect = myWorkshop->selection();
366 QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
367 QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
368 myEditingFeatures.clear();
369 myEditingAttr.clear();
370 if ((aHighlighted.size() == 0) && (aSelected.size() == 0)) {
371 if (isSketchOpe && (!isSketcher))
372 // commit previous operation
373 if (!aOperation->commit())
378 QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected);
379 if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
380 // Move by selected shape (vertex). Can be used only for single selection
381 foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
382 FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object());
384 myEditingFeatures.append(aFeature);
385 TopoDS_Shape aShape = aPrs.shape();
386 if (!aShape.IsNull()) {
387 if (aShape.ShapeType() == TopAbs_VERTEX) {
388 AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(),
389 aShape, myCurrentSketch);
391 myEditingAttr.append(aAttr);
397 // Provide multi-selection. Can be used only for features
398 foreach (ObjectPtr aObj, aSelObjects) {
399 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
400 if (aFeature && (!myEditingFeatures.contains(aFeature)))
401 myEditingFeatures.append(aFeature);
405 // If nothing highlighted - return
406 if (myEditingFeatures.size() == 0)
411 get2dPoint(theWnd, theEvent, myCurX, myCurY);
413 myWorkshop->viewer()->enableSelection(false);
416 } else if (isSketchOpe && isEditing) {
417 // If selected another object
421 get2dPoint(theWnd, theEvent, myCurX, myCurY);
423 myWorkshop->viewer()->enableSelection(false);
425 // This is necessary in order to finalize previous operation
426 QApplication::processEvents();
433 void PartSet_Module::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
434 double& theX, double& theY)
436 Handle(V3d_View) aView = theWnd->v3dView();
437 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
438 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
442 void PartSet_Module::launchEditing()
444 if (myEditingFeatures.size() > 0) {
445 FeaturePtr aFeature = myEditingFeatures.first();
446 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
447 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
449 editFeature(aSPFeature);
454 /// Returns new instance of operation object (used in createOperation for customization)
455 ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
457 if (theFeatureId == PartSet_OperationSketch::Type()) {
458 return new PartSet_OperationSketch(theFeatureId.c_str(), this);
460 return ModuleBase_IModule::getNewOperation(theFeatureId);
464 void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
466 myWorkshop->viewer()->enableSelection(true);
468 myIsDragging = false;
470 myWorkshop->currentOperation()->commit();
471 myEditingFeatures.clear();
472 myEditingAttr.clear();
478 void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
481 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
482 if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
483 return; // No edit operation activated
485 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
486 Handle(V3d_View) aView = theWnd->v3dView();
487 gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
489 PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
490 double dX = aX - myCurX;
491 double dY = aY - myCurY;
493 if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
494 (myEditingAttr.size() == 1) &&
495 myEditingAttr.first()) {
496 // probably we have prehighlighted point
497 AttributePtr aAttr = myEditingAttr.first();
498 std::string aAttrId = aAttr->id();
499 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
500 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
501 // Find corresponded widget to provide dragging
502 foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
503 if (aWgt->attributeID() == aAttrId) {
504 PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
506 aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
512 foreach(FeaturePtr aFeature, myEditingFeatures) {
513 std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
514 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
515 if (aSketchFeature) {
516 aSketchFeature->move(dX, dY);
517 ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
520 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
521 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
529 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
531 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
532 XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
533 anOpMgr->onKeyReleased(theEvent);
536 void PartSet_Module::onEnterReleased()
538 myRestartingMode = RM_EmptyFeatureUsed;
541 void PartSet_Module::onNoMoreWidgets()
543 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
545 /// Restart sketcher operations automatically
546 FeaturePtr aFeature = aOperation->feature();
547 std::shared_ptr<SketchPlugin_Feature> aSPFeature =
548 std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
550 if (myRestartingMode != RM_Forbided)
551 myRestartingMode = RM_LastFeatureUsed;
552 aOperation->commit();
557 QStringList PartSet_Module::sketchOperationIdList() const
560 aIds << SketchPlugin_Line::ID().c_str();
561 aIds << SketchPlugin_Point::ID().c_str();
562 aIds << SketchPlugin_Arc::ID().c_str();
563 aIds << SketchPlugin_Circle::ID().c_str();
564 aIds << SketchPlugin_ConstraintLength::ID().c_str();
565 aIds << SketchPlugin_ConstraintDistance::ID().c_str();
566 aIds << SketchPlugin_ConstraintRigid::ID().c_str();
567 aIds << SketchPlugin_ConstraintRadius::ID().c_str();
568 aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
569 aIds << SketchPlugin_ConstraintParallel::ID().c_str();
573 void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape)
575 ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
576 if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
577 /// If last line finished on vertex the lines creation sequence has to be break
578 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
579 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
580 if (aWidgets.last() == aPanel->activeWidget()) {
581 myRestartingMode = RM_Forbided;
586 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
587 Config_WidgetAPI* theWidgetApi, std::string theParentId,
588 QList<ModuleBase_ModelWidget*>& theModelWidgets)
590 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
591 XGUI_Workshop* aWorkshop = aConnector->workshop();
592 if (theType == "sketch-start-label") {
593 PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
594 aWgt->setWorkshop(aWorkshop);
595 connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
596 this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
597 theModelWidgets.append(aWgt);
598 return aWgt->getControl();
600 } else if (theType == "sketch-2dpoint_selector") {
601 PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
602 aWgt->setWorkshop(aWorkshop);
603 aWgt->setSketch(myCurrentSketch);
605 connect(aWgt, SIGNAL(vertexSelected(ObjectPtr, const TopoDS_Shape&)),
606 this, SLOT(onVertexSelected(ObjectPtr, const TopoDS_Shape&)));
608 theModelWidgets.append(aWgt);
609 return aWgt->getControl();
611 } if (theType == "point2ddistance") {
612 PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
613 aWgt->setWorkshop(aWorkshop);
614 aWgt->setSketch(myCurrentSketch);
616 theModelWidgets.append(aWgt);
617 return aWgt->getControl();
619 } if (theType == "sketch_shape_selector") {
620 PartSet_WidgetShapeSelector* aWgt =
621 new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
622 aWgt->setSketcher(myCurrentSketch);
624 theModelWidgets.append(aWgt);
625 return aWgt->getControl();
627 } if (theType == "sketch_constraint_shape_selector") {
628 PartSet_WidgetConstraintShapeSelector* aWgt =
629 new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
630 aWgt->setSketcher(myCurrentSketch);
632 theModelWidgets.append(aWgt);
633 return aWgt->getControl();