1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include "PartSet_SketcherReetntrantMgr.h"
4 #include "PartSet_Module.h"
5 #include "PartSet_SketcherMgr.h"
6 #include "PartSet_WidgetPoint2d.h"
8 #include "ModelAPI_Session.h"
9 #include "ModelAPI_AttributeString.h"
10 #include "ModelAPI_AttributeRefAttr.h"
12 #include "GeomDataAPI_Point2D.h"
14 #include <ModuleBase_IPropertyPanel.h>
15 #include <ModuleBase_OperationFeature.h>
16 #include <ModuleBase_ModelWidget.h>
17 #include <ModuleBase_ViewerPrs.h>
18 #include <ModuleBase_WidgetSelector.h>
19 #include <ModuleBase_PageWidget.h>
20 #include <ModuleBase_PageBase.h>
21 #include <ModuleBase_WidgetFactory.h>
22 #include <ModuleBase_OperationDescription.h>
23 #include "ModuleBase_ToolBox.h"
24 #include "ModuleBase_ISelection.h"
26 #include <SketchPlugin_Feature.h>
27 #include <SketchPlugin_Line.h>
28 #include <SketchPlugin_Arc.h>
29 #include <SketchPlugin_Circle.h>
30 #include <SketchPlugin_Point.h>
32 #include <XGUI_Workshop.h>
33 #include <XGUI_ModuleConnector.h>
34 #include <XGUI_OperationMgr.h>
35 #include <XGUI_PropertyPanel.h>
36 #include <XGUI_ErrorMgr.h>
37 #include <XGUI_SelectionMgr.h>
39 #include <QToolButton>
41 PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop)
42 : QObject(theWorkshop),
43 myWorkshop(theWorkshop),
44 myRestartingMode(RM_None),
45 myIsFlagsBlocked(false),
46 myIsInternalEditOperation(false),
47 myNoMoreWidgetsAttribute("")
51 PartSet_SketcherReetntrantMgr::~PartSet_SketcherReetntrantMgr()
55 ModuleBase_ModelWidget* PartSet_SketcherReetntrantMgr::internalActiveWidget() const
57 ModuleBase_ModelWidget* aWidget = 0;
61 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
63 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
64 if (aPanel) { // check for case when the operation is started but property panel is not filled
65 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
66 if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector()))
67 aWidget = myInternalActiveWidget;
73 bool PartSet_SketcherReetntrantMgr::isInternalEditActive() const
75 return myIsInternalEditOperation;
78 void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState()
80 if (myIsInternalEditOperation) {
81 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
82 (myWorkshop->currentOperation());
84 FeaturePtr aFeature = aFOperation->feature();
85 QString anError = myWorkshop->module()->getFeatureError(aFeature);
86 // stop started internal edit operation as soon as the operation becomes invalid
87 // it is especially important for the sketch tangent arc feature
88 if (!anError.isEmpty()) {
89 aFOperation->setEditOperation(false);
90 //workshop()->operationMgr()->updateApplyOfOperations();
91 myIsInternalEditOperation = false;
92 updateAcceptAllAction();
98 bool PartSet_SketcherReetntrantMgr::operationCommitted(ModuleBase_Operation* theOperation)
100 bool aProcessed = false;
104 aProcessed = myIsInternalEditOperation;
110 void PartSet_SketcherReetntrantMgr::operationStarted(ModuleBase_Operation* theOperation)
115 if (myPreviousFeature.get() && myRestartingMode == RM_LastFeatureUsed) {
116 ModuleBase_OperationFeature* aCurrentOperation = dynamic_cast<ModuleBase_OperationFeature*>(
117 myWorkshop->currentOperation());
118 CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
119 copyReetntrantAttributes(myPreviousFeature, aCurrentOperation->feature(), aSketch);
124 void PartSet_SketcherReetntrantMgr::operationAborted(ModuleBase_Operation* theOperation)
132 bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* theWnd,
133 QMouseEvent* theEvent)
135 bool aProcessed = false;
139 if (myIsInternalEditOperation) {
140 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
141 (myWorkshop->currentOperation());
142 FeaturePtr aLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature()
145 ModuleBase_ModelWidget* anActiveWidget = module()->activeWidget();
146 ModuleBase_IPropertyPanel* aPanel = myWorkshop->currentOperation()->propertyPanel();
148 FeaturePtr aCurrentFeature = aFOperation->feature();
149 bool isLineFeature = false, isArcFeature = false;
150 std::string anAttributeOnStart;
151 if (aCurrentFeature->getKind() == SketchPlugin_Line::ID()) {
152 anAttributeOnStart = SketchPlugin_Line::START_ID();
153 isLineFeature = anActiveWidget->attributeID() == anAttributeOnStart;
155 else if (isTangentArc(aFOperation, module()->sketchMgr()->activeSketch())) {
156 anAttributeOnStart = SketchPlugin_Arc::TANGENT_POINT_ID();
157 isArcFeature = anActiveWidget->attributeID() == anAttributeOnStart;
159 bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
160 if (aCanBeActivatedByMove) {
161 /// before restarting of operation we need to clear selection, as it may take part in
162 /// new feature creation, e.g. tangent arc. But it is not necessary as it was processed
163 /// by mouse release when the operation was restarted.
164 workshop()->selector()->clearSelection();
\r
166 myPreviousFeature = aFOperation->feature();
168 myPreviousFeature = FeaturePtr();
170 anActiveWidget = module()->activeWidget();
171 aCurrentFeature = anActiveWidget->feature();
173 if (anActiveWidget->attributeID() == anAttributeOnStart) {
174 // it was not deactivated by preselection processing
175 aPanel->activateNextWidget(anActiveWidget);
178 // processing mouse move in active widget of restarted operation
179 ModuleBase_ModelWidget* anActiveWidget = module()->activeWidget();
180 PartSet_MouseProcessor* aProcessor = dynamic_cast<PartSet_MouseProcessor*>(anActiveWidget);
182 aProcessor->mouseMoved(theWnd, theEvent);
189 bool PartSet_SketcherReetntrantMgr::processMousePressed(ModuleBase_IViewWindow* /* theWnd*/,
190 QMouseEvent* /* theEvent*/)
192 return isActiveMgr() && myIsInternalEditOperation;
195 bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* theWnd,
196 QMouseEvent* theEvent)
198 bool aProcessed = false;
202 if (myIsInternalEditOperation) {
203 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
204 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
206 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
207 if (!anActiveWidget || !anActiveWidget->isViewerSelector()) {
209 // block of viewer update
210 // we need to block update content of the viewer because of Sketch Point feature
211 // in activate() the value of the point is initialized and it can be displayed
212 // but the default value is [0, 0]. So, we block update viewer contentent until
213 // onMouseRelease happens, which correct the point position
214 ModuleBase_Tools::blockUpdateViewer(true);
216 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
217 (myWorkshop->currentOperation());
218 myPreviousFeature = aFOperation->feature();
220 /// selection should be obtained from workshop before ask if the operation can be started as
221 /// the canStartOperation method performs commit/abort of previous operation. Sometimes commit/abort
222 /// may cause selection clear(Sketch operation) as a result it will be lost and is not used for preselection.
223 ModuleBase_ISelection* aSelection = myWorkshop->selection();
224 QList<ModuleBase_ViewerPrsPtr> aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls);
227 myPreviousFeature = FeaturePtr();
230 // fill the first widget by the mouse event point
231 // if the active widget is not the first, it means that the restarted operation is filled by
232 // the current preselection.
233 PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
234 ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
235 if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
236 if (!aPreSelected.empty())
237 aPoint2DWdg->setPreSelection(aPreSelected.front());
238 aPoint2DWdg->mouseReleased(theWnd, theEvent);
239 if (!aPreSelected.empty())
240 aPoint2DWdg->setPreSelection(ModuleBase_ViewerPrsPtr());
242 // unblock viewer update
243 ModuleBase_Tools::blockUpdateViewer(false);
250 void PartSet_SketcherReetntrantMgr::onWidgetActivated()
254 if (!myIsInternalEditOperation)
257 PartSet_Module* aModule = module();
258 ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget();
259 ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
260 if (aFirstWidget != aPanel->activeWidget()) {
261 ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
263 aWSelector->activateSelectionAndFilters(true);
267 void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePreviousAttributeID)
272 // we should avoid processing of the signal about no more widgets attributes and
273 // do this after the restart operaion is finished if it was called
274 // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
275 // if it should be called after restart
276 if (myIsFlagsBlocked) {
277 myNoMoreWidgetsAttribute = thePreviousAttributeID;
281 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
282 (myWorkshop->currentOperation());
283 if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
286 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
287 bool isStarted = false;
288 if (!module()->sketchMgr()->sketchSolverError()) {
289 if (myRestartingMode != RM_Forbided) {
290 myRestartingMode = RM_LastFeatureUsed;
291 isStarted = startInternalEdit(thePreviousAttributeID);
295 aFOperation->commit();
299 bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousAttributeID)
306 // empty previous attribute means that the Apply/Ok button has focus and the enter
307 // should not lead to start edition mode of the previous operation
308 if (thePreviousAttributeID.empty())
311 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
312 (myWorkshop->currentOperation());
313 if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
316 bool isSketchSolverError = module()->sketchMgr()->sketchSolverError();
318 if (!isSketchSolverError) {
319 myRestartingMode = RM_EmptyFeatureUsed;
320 isDone = startInternalEdit(thePreviousAttributeID);
326 void PartSet_SketcherReetntrantMgr::onVertexSelected()
331 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
332 std::string anOperationId = anOperation->id().toStdString();
333 if (anOperationId == SketchPlugin_Line::ID() ||
334 isTangentArc(anOperation, module()->sketchMgr()->activeSketch())) {
335 /// If last line finished on vertex the lines creation sequence has to be break
336 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
337 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
338 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
339 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
340 bool aFoundWidget = false;
341 bool aFoundObligatory = false;
342 for (; anIt != aLast && !aFoundObligatory; anIt++) {
344 aFoundWidget = *anIt == anActiveWidget;
346 aFoundObligatory = (*anIt)->isObligatory();
348 if (!aFoundObligatory)
349 myRestartingMode = RM_Forbided;
353 void PartSet_SketcherReetntrantMgr::onBeforeStopped()
355 if (!isActiveMgr() || !myIsInternalEditOperation)
358 beforeStopInternalEdit();
361 bool PartSet_SketcherReetntrantMgr::canBeCommittedByPreselection()
363 return !isActiveMgr() || myRestartingMode == RM_None;
366 bool PartSet_SketcherReetntrantMgr::isInternalEditStarted() const
368 return myIsInternalEditOperation;
371 bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
373 ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
375 bool anActive = PartSet_SketcherMgr::isSketchOperation(aCurrentOperation);
377 anActive = module()->sketchMgr()->isNestedSketchOperation(aCurrentOperation);
378 if (anActive) { // the manager is not active when the current operation is a usual Edit
379 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
380 (myWorkshop->currentOperation());
381 if (aFOperation->isEditOperation())
382 anActive = myIsInternalEditOperation;
388 bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
391 /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter
392 /// event comes two times, so we should not start another internal edit operation
393 /// the Apply button becomes disabled becase the second additional internal feature is created
394 if (myIsInternalEditOperation)
397 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
398 (myWorkshop->currentOperation());
400 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
401 aFOperation->setEditOperation(true/*, false*/);
402 createInternalFeature();
404 myIsInternalEditOperation = true;
405 updateAcceptAllAction();
408 connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
409 connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
411 // activate selection filters of the first widget in the viewer
414 // activate the last active widget in the Property Panel
415 if (!thePreviousAttributeID.empty()) {
416 ModuleBase_Operation* anEditOperation = module()->currentOperation();
417 if (anEditOperation) {
418 ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
419 ModuleBase_ModelWidget* aPreviousAttributeWidget = 0;
420 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
421 for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) {
422 if (aWidgets[i]->attributeID() == thePreviousAttributeID) {
423 /// workaround for the same attributes used in different stacked widgets(attribute types)
424 if (ModuleBase_ToolBox::isOffToolBoxParent(aWidgets[i]))
426 aPreviousAttributeWidget = aWidgets[i];
429 // If the current widget is a selector, do nothing, it processes the mouse press
430 if (aPreviousAttributeWidget) {
431 if (!aPreviousAttributeWidget->isViewerSelector()) {
432 aPreviousAttributeWidget->focusTo();
433 aPreviousAttributeWidget->selectContent();
436 // in case of shape multi selector, the widget does not lose focus by filling
437 // like it is in shape selector. So, if enter is pressed, the multi shape selector
438 // control should be deactivated. The focus is moved to Apply button and there
439 // should not be active control visualized in property panel
440 if (aPreviousAttributeWidget == aPanel->activeWidget()) {
441 aPanel->activateWidget(NULL, false);
443 // if there is no the next widget to be automatically activated, the Ok button in property
444 // panel should accept the focus(example is parallel constraint on sketch lines)
445 QToolButton* anOkBtn = dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_OK);
447 anOkBtn->setFocus(Qt::TabFocusReason);
454 module()->sketchMgr()->clearClickedFlags();
459 void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
461 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
462 (myWorkshop->currentOperation());
464 disconnect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
465 disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
468 deleteInternalFeature();
471 void PartSet_SketcherReetntrantMgr::restartOperation()
473 if (myIsInternalEditOperation) {
474 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(
475 myWorkshop->currentOperation());
477 myNoMoreWidgetsAttribute = "";
478 myIsFlagsBlocked = true;
479 module()->launchOperation(aFOperation->id());
480 myIsFlagsBlocked = false;
482 // we should avoid processing of the signal about no more widgets attributes and
483 // do this after the restart operaion is finished if it was called
484 // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
485 // if it should be called after restart
486 if (!myNoMoreWidgetsAttribute.empty()) {
487 onNoMoreWidgets(myNoMoreWidgetsAttribute);
488 myNoMoreWidgetsAttribute = "";
494 void PartSet_SketcherReetntrantMgr::createInternalFeature()
496 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
497 (myWorkshop->currentOperation());
499 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
500 FeaturePtr anOperationFeature = aFOperation->feature();
502 CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
503 myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
505 bool isFeatureChanged = copyReetntrantAttributes(anOperationFeature, myInternalFeature,
507 XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
508 (aFOperation->propertyPanel());
510 myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
511 myInternalWidget->setVisible(false);
513 ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
515 QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
516 ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
518 aFactory.createWidget(anInternalPage);
519 QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
521 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
522 bool isStoreValue = !aFOperation->isEditOperation() &&
523 !aWidget->getDefaultValue().empty() &&
524 !aWidget->isComputedDefault();
525 aWidget->setFeature(myInternalFeature, isStoreValue);
526 if (!isStoreValue && isFeatureChanged)
527 aWidget->restoreValue();
530 ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
533 myInternalActiveWidget = aFirstWidget;
537 void PartSet_SketcherReetntrantMgr::deleteInternalFeature()
539 if (myInternalActiveWidget) {
540 ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
542 aWSelector->activateSelectionAndFilters(false);
543 myInternalActiveWidget = 0;
545 delete myInternalWidget;
546 myInternalWidget = 0;
548 QObjectPtrList anObjects;
549 anObjects.append(myInternalFeature);
550 workshop()->deleteFeatures(anObjects);
551 myInternalFeature = FeaturePtr();
554 void PartSet_SketcherReetntrantMgr::resetFlags()
556 if (!myIsFlagsBlocked) {
557 myIsInternalEditOperation = false;
558 updateAcceptAllAction();
559 myRestartingMode = RM_None;
563 bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
564 const FeaturePtr& theNewFeature,
565 const CompositeFeaturePtr& theSketch,
566 const bool isTemporary)
568 bool aChanged = false;
569 if (!theSourceFeature.get() || !theSourceFeature->data().get() ||
570 !theSourceFeature->data()->isValid())
573 std::string aFeatureKind = theSourceFeature->getKind();
574 if (aFeatureKind == SketchPlugin_Line::ID()) {
575 // Initialize new line with first point equal to end of previous
576 std::shared_ptr<ModelAPI_Data> aSFData = theSourceFeature->data();
577 std::shared_ptr<GeomDataAPI_Point2D> aSPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
578 aSFData->attribute(SketchPlugin_Line::END_ID()));
579 std::shared_ptr<ModelAPI_Data> aNFData = theNewFeature->data();
580 std::shared_ptr<GeomDataAPI_Point2D> aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
581 aNFData->attribute(SketchPlugin_Line::START_ID()));
582 aNPoint->setValue(aSPoint->x(), aSPoint->y());
583 PartSet_Tools::createConstraint(theSketch, aSPoint, aNPoint);
585 aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
586 aSFData->attribute(SketchPlugin_Line::END_ID()));
587 aNPoint->setValue(aSPoint->x(), aSPoint->y());
589 else if (aFeatureKind == SketchPlugin_Circle::ID()) {
591 std::string aTypeAttributeId = SketchPlugin_Circle::CIRCLE_TYPE();
592 AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
593 AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
594 aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
595 //ModuleBase_Tools::flushUpdated(theNewFeature);
598 else if (aFeatureKind == SketchPlugin_Arc::ID()) {
600 std::string aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
601 AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
602 AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
603 aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
605 // if the arc is tangent, set coincidence to end point of the previous arc
606 std::string anArcType = aSourceFeatureTypeAttr->value();
607 if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
608 // get the last point of the previuos arc feature(geom point 2d)
609 std::shared_ptr<ModelAPI_Data> aSData = theSourceFeature->data();
610 std::shared_ptr<GeomDataAPI_Point2D> aSPointAttr =
611 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
612 aSData->attribute(SketchPlugin_Arc::END_ID()));
613 // get point attribute on the current feature
614 AttributeRefAttrPtr aTangentPointAttr = theNewFeature->data()->refattr(
615 SketchPlugin_Arc::TANGENT_POINT_ID());
616 aTangentPointAttr->setAttr(aSPointAttr);
618 std::shared_ptr<GeomDataAPI_Point2D> aNPointAttr =
619 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
620 theNewFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
621 aNPointAttr->setValue(aSPointAttr->x(), aSPointAttr->y());
624 //ModuleBase_Tools::flushUpdated(theNewFeature);
630 bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation,
631 const CompositeFeaturePtr& /*theSketch*/) const
633 bool aTangentArc = false;
634 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
636 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
637 FeaturePtr aFeature = aFOperation->feature();
638 if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
639 AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
640 std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
641 aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
647 void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
649 CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
651 workshop()->errorMgr()->updateAcceptAllAction(aSketch);
654 XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
656 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
657 return aConnector->workshop();
660 PartSet_Module* PartSet_SketcherReetntrantMgr::module() const
662 return dynamic_cast<PartSet_Module*>(myWorkshop->module());