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_MacroCircle.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();
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.
222 /// Sometimes commit/abort
223 /// may cause selection clear(Sketch operation) as a result
224 /// it will be lost and is not used for preselection.
225 ModuleBase_ISelection* aSelection = myWorkshop->selection();
226 QList<ModuleBase_ViewerPrsPtr> aPreSelected =
227 aSelection->getSelected(ModuleBase_ISelection::AllControls);
230 myPreviousFeature = FeaturePtr();
233 // fill the first widget by the mouse event point
234 // if the active widget is not the first, it means that the restarted operation is filled by
235 // the current preselection.
236 PartSet_MouseProcessor* aMouseProcessor = dynamic_cast<PartSet_MouseProcessor*>(
237 module()->activeWidget());
238 //PartSet_WidgetPoint2D* aPoint2DWdg =
239 // dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
240 PartSet_MouseProcessor* aFirstWidget = dynamic_cast<PartSet_MouseProcessor*>(
241 aPanel->findFirstAcceptingValueWidget());
242 //if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
243 if (aMouseProcessor && aMouseProcessor == aFirstWidget) {
244 std::shared_ptr<ModuleBase_ViewerPrs> aSelectedPrs;
245 if (!aPreSelected.empty())
246 aSelectedPrs = aPreSelected.front();
247 aMouseProcessor->setPreSelection(aSelectedPrs, theWnd, theEvent);
248 //aPoint2DWdg->mouseReleased(theWnd, theEvent);
249 //if (!aPreSelected.empty())
250 // aPoint2DWdg->setPreSelection(ModuleBase_ViewerPrsPtr());
252 // unblock viewer update
253 ModuleBase_Tools::blockUpdateViewer(false);
260 void PartSet_SketcherReetntrantMgr::onWidgetActivated()
264 if (!myIsInternalEditOperation)
267 PartSet_Module* aModule = module();
268 ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget();
269 ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
270 if (aFirstWidget != aPanel->activeWidget()) {
271 ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
273 aWSelector->activateSelectionAndFilters(true);
277 void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePreviousAttributeID)
282 // we should avoid processing of the signal about no more widgets attributes and
283 // do this after the restart operaion is finished if it was called
284 // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
285 // if it should be called after restart
286 if (myIsFlagsBlocked) {
287 myNoMoreWidgetsAttribute = thePreviousAttributeID;
291 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
292 (myWorkshop->currentOperation());
293 if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
296 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
297 bool isStarted = false;
298 if (!module()->sketchMgr()->sketchSolverError()) {
299 if (myRestartingMode != RM_Forbided) {
300 myRestartingMode = RM_LastFeatureUsed;
301 isStarted = startInternalEdit(thePreviousAttributeID);
305 aFOperation->commit();
309 bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousAttributeID)
316 // empty previous attribute means that the Apply/Ok button has focus and the enter
317 // should not lead to start edition mode of the previous operation
318 if (thePreviousAttributeID.empty())
321 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
322 (myWorkshop->currentOperation());
323 if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
326 bool isSketchSolverError = module()->sketchMgr()->sketchSolverError();
328 if (!isSketchSolverError) {
329 myRestartingMode = RM_EmptyFeatureUsed;
330 isDone = startInternalEdit(thePreviousAttributeID);
336 void PartSet_SketcherReetntrantMgr::onVertexSelected()
341 ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
342 std::string anOperationId = anOperation->id().toStdString();
343 if (anOperationId == SketchPlugin_Line::ID() ||
344 isTangentArc(anOperation, module()->sketchMgr()->activeSketch())) {
345 /// If last line finished on vertex the lines creation sequence has to be break
346 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
347 ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
348 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
349 QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
350 bool aFoundWidget = false;
351 bool aFoundObligatory = false;
352 for (; anIt != aLast && !aFoundObligatory; anIt++) {
354 aFoundWidget = *anIt == anActiveWidget;
356 aFoundObligatory = (*anIt)->isObligatory();
358 if (!aFoundObligatory)
359 myRestartingMode = RM_Forbided;
363 void PartSet_SketcherReetntrantMgr::onBeforeStopped()
365 if (!isActiveMgr() || !myIsInternalEditOperation)
368 beforeStopInternalEdit();
371 bool PartSet_SketcherReetntrantMgr::canBeCommittedByPreselection()
373 return !isActiveMgr() || myRestartingMode == RM_None;
376 bool PartSet_SketcherReetntrantMgr::isInternalEditStarted() const
378 return myIsInternalEditOperation;
381 bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
383 ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
385 bool anActive = PartSet_SketcherMgr::isSketchOperation(aCurrentOperation);
387 anActive = module()->sketchMgr()->isNestedSketchOperation(aCurrentOperation);
388 if (anActive) { // the manager is not active when the current operation is a usual Edit
389 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
390 (myWorkshop->currentOperation());
391 if (aFOperation->isEditOperation())
392 anActive = myIsInternalEditOperation;
398 bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
401 /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter
402 /// event comes two times, so we should not start another internal edit operation
403 /// the Apply button becomes disabled becase the second additional internal feature is created
404 if (myIsInternalEditOperation)
407 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
408 (myWorkshop->currentOperation());
410 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
411 aFOperation->setEditOperation(true/*, false*/);
412 createInternalFeature();
414 myIsInternalEditOperation = true;
415 updateAcceptAllAction();
418 connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
419 connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
421 // activate selection filters of the first widget in the viewer
424 // activate the last active widget in the Property Panel
425 if (!thePreviousAttributeID.empty()) {
426 ModuleBase_Operation* anEditOperation = module()->currentOperation();
427 if (anEditOperation) {
428 ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
429 ModuleBase_ModelWidget* aPreviousAttributeWidget = 0;
430 QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
431 for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) {
432 if (aWidgets[i]->attributeID() == thePreviousAttributeID) {
433 /// workaround for the same attributes used in different stacked widgets(attribute types)
434 if (ModuleBase_ToolBox::isOffToolBoxParent(aWidgets[i]))
436 aPreviousAttributeWidget = aWidgets[i];
439 // If the current widget is a selector, do nothing, it processes the mouse press
440 if (aPreviousAttributeWidget) {
441 if (!aPreviousAttributeWidget->isViewerSelector()) {
442 aPreviousAttributeWidget->focusTo();
443 aPreviousAttributeWidget->selectContent();
446 // in case of shape multi selector, the widget does not lose focus by filling
447 // like it is in shape selector. So, if enter is pressed, the multi shape selector
448 // control should be deactivated. The focus is moved to Apply button and there
449 // should not be active control visualized in property panel
450 if (aPreviousAttributeWidget == aPanel->activeWidget()) {
451 aPanel->activateWidget(NULL, false);
453 // if there is no the next widget to be automatically activated,
454 // the Ok button in property
455 // panel should accept the focus(example is parallel constraint on sketch lines)
456 QToolButton* anOkBtn =
457 dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_OK);
459 anOkBtn->setFocus(Qt::TabFocusReason);
466 module()->sketchMgr()->clearClickedFlags();
471 void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
473 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
474 (myWorkshop->currentOperation());
476 disconnect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
477 disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
480 deleteInternalFeature();
483 void PartSet_SketcherReetntrantMgr::restartOperation()
485 if (myIsInternalEditOperation) {
486 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(
487 myWorkshop->currentOperation());
489 myNoMoreWidgetsAttribute = "";
490 myIsFlagsBlocked = true;
491 module()->launchOperation(aFOperation->id());
492 myIsFlagsBlocked = false;
494 // we should avoid processing of the signal about no more widgets attributes and
495 // do this after the restart operaion is finished if it was called
496 // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
497 // if it should be called after restart
498 if (!myNoMoreWidgetsAttribute.empty()) {
499 onNoMoreWidgets(myNoMoreWidgetsAttribute);
500 myNoMoreWidgetsAttribute = "";
506 void PartSet_SketcherReetntrantMgr::createInternalFeature()
508 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
509 (myWorkshop->currentOperation());
511 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
512 FeaturePtr anOperationFeature = aFOperation->feature();
514 CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
515 myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
517 bool isFeatureChanged = copyReetntrantAttributes(anOperationFeature, myInternalFeature,
519 XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
520 (aFOperation->propertyPanel());
522 myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
523 myInternalWidget->setVisible(false);
525 ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
527 QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
528 ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
530 aFactory.createWidget(anInternalPage);
531 QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
533 foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
534 bool isStoreValue = !aFOperation->isEditOperation() &&
535 !aWidget->getDefaultValue().empty() &&
536 !aWidget->isComputedDefault();
537 aWidget->setFeature(myInternalFeature, isStoreValue);
538 if (!isStoreValue && isFeatureChanged)
539 aWidget->restoreValue();
542 ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
545 myInternalActiveWidget = aFirstWidget;
549 void PartSet_SketcherReetntrantMgr::deleteInternalFeature()
551 if (myInternalActiveWidget) {
552 ModuleBase_WidgetSelector* aWSelector =
553 dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
555 aWSelector->activateSelectionAndFilters(false);
556 myInternalActiveWidget = 0;
558 delete myInternalWidget;
559 myInternalWidget = 0;
561 QObjectPtrList anObjects;
562 anObjects.append(myInternalFeature);
563 workshop()->deleteFeatures(anObjects);
564 myInternalFeature = FeaturePtr();
567 void PartSet_SketcherReetntrantMgr::resetFlags()
569 if (!myIsFlagsBlocked) {
570 myIsInternalEditOperation = false;
571 updateAcceptAllAction();
572 myRestartingMode = RM_None;
576 bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
577 const FeaturePtr& theNewFeature,
578 const CompositeFeaturePtr& theSketch,
579 const bool isTemporary)
581 bool aChanged = false;
582 if (!theSourceFeature.get() || !theSourceFeature->data().get() ||
583 !theSourceFeature->data()->isValid())
586 std::string aFeatureKind = theSourceFeature->getKind();
587 if (aFeatureKind == SketchPlugin_Line::ID()) {
588 // Initialize new line with first point equal to end of previous
589 std::shared_ptr<ModelAPI_Data> aSFData = theSourceFeature->data();
590 std::shared_ptr<GeomDataAPI_Point2D> aSPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
591 aSFData->attribute(SketchPlugin_Line::END_ID()));
592 std::shared_ptr<ModelAPI_Data> aNFData = theNewFeature->data();
593 std::shared_ptr<GeomDataAPI_Point2D> aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
594 aNFData->attribute(SketchPlugin_Line::START_ID()));
595 aNPoint->setValue(aSPoint->x(), aSPoint->y());
596 PartSet_Tools::createConstraint(theSketch, aSPoint, aNPoint);
598 aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
599 aSFData->attribute(SketchPlugin_Line::END_ID()));
600 aNPoint->setValue(aSPoint->x(), aSPoint->y());
602 else if (aFeatureKind == SketchPlugin_MacroCircle::ID()) {
604 std::string aTypeAttributeId = SketchPlugin_MacroCircle::CIRCLE_TYPE();
605 AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
606 AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
607 aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
608 //ModuleBase_Tools::flushUpdated(theNewFeature);
611 else if (aFeatureKind == SketchPlugin_Arc::ID()) {
613 std::string aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
614 AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
615 AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
616 aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
618 // if the arc is tangent, set coincidence to end point of the previous arc
619 std::string anArcType = aSourceFeatureTypeAttr->value();
620 if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
621 // get the last point of the previuos arc feature(geom point 2d)
622 std::shared_ptr<ModelAPI_Data> aSData = theSourceFeature->data();
623 std::shared_ptr<GeomDataAPI_Point2D> aSPointAttr =
624 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
625 aSData->attribute(SketchPlugin_Arc::END_ID()));
626 // get point attribute on the current feature
627 AttributeRefAttrPtr aTangentPointAttr = theNewFeature->data()->refattr(
628 SketchPlugin_Arc::TANGENT_POINT_ID());
629 aTangentPointAttr->setAttr(aSPointAttr);
631 std::shared_ptr<GeomDataAPI_Point2D> aNPointAttr =
632 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
633 theNewFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
634 aNPointAttr->setValue(aSPointAttr->x(), aSPointAttr->y());
637 //ModuleBase_Tools::flushUpdated(theNewFeature);
643 bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation,
644 const CompositeFeaturePtr& /*theSketch*/) const
646 bool aTangentArc = false;
647 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
649 if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
650 FeaturePtr aFeature = aFOperation->feature();
651 if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
652 AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
653 std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
654 aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
660 void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
662 CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
664 workshop()->errorMgr()->updateAcceptAllAction(aSketch);
667 XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
669 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
670 return aConnector->workshop();
673 PartSet_Module* PartSet_SketcherReetntrantMgr::module() const
675 return dynamic_cast<PartSet_Module*>(myWorkshop->module());