Salome HOME
Temporary modification
[modules/shaper.git] / src / PartSet / PartSet_SketcherReetntrantMgr.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #include "PartSet_SketcherReetntrantMgr.h"
4 #include "PartSet_Module.h"
5 #include "PartSet_SketcherMgr.h"
6 #include "PartSet_WidgetPoint2d.h"
7
8 #include "ModelAPI_Session.h"
9 #include "ModelAPI_AttributeString.h"
10 #include "ModelAPI_AttributeRefAttr.h"
11
12 #include "GeomDataAPI_Point2D.h"
13
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
25 #include <SketchPlugin_Feature.h>
26 #include <SketchPlugin_Line.h>
27 #include <SketchPlugin_Arc.h>
28 #include <SketchPlugin_Circle.h>
29
30 #include <XGUI_Workshop.h>
31 #include <XGUI_ModuleConnector.h>
32 #include <XGUI_OperationMgr.h>
33 #include <XGUI_PropertyPanel.h>
34 #include <XGUI_ErrorMgr.h>
35
36 #include <QToolButton>
37
38 PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop)
39 : QObject(theWorkshop),
40   myWorkshop(theWorkshop),
41   myRestartingMode(RM_None),
42   myIsFlagsBlocked(false),
43   myIsInternalEditOperation(false),
44   myNoMoreWidgetsAttribute("")
45 {
46 }
47
48 PartSet_SketcherReetntrantMgr::~PartSet_SketcherReetntrantMgr()
49 {
50 }
51
52 ModuleBase_ModelWidget* PartSet_SketcherReetntrantMgr::internalActiveWidget() const
53 {
54   ModuleBase_ModelWidget* aWidget = 0;
55   if (!isActiveMgr())
56     return aWidget;
57
58   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
59   if (anOperation) {
60     ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
61     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
62     if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector()))
63       aWidget = myInternalActiveWidget;
64   }
65   return aWidget;
66 }
67
68 bool PartSet_SketcherReetntrantMgr::isInternalEditActive() const
69 {
70   return myIsInternalEditOperation;
71 }
72
73 void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState()
74 {
75   if  (myIsInternalEditOperation) {
76     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
77                                                          (myWorkshop->currentOperation());
78     if (aFOperation) {
79       FeaturePtr aFeature = aFOperation->feature();
80       QString anError = myWorkshop->module()->getFeatureError(aFeature);
81       // stop started internal edit operation as soon as the operation becomes invalid
82       // it is especially important for the sketch tangent arc feature
83       if (!anError.isEmpty()) {
84         aFOperation->setEditOperation(false);
85         //workshop()->operationMgr()->updateApplyOfOperations();
86         beforeStopInternalEdit();
87         myIsInternalEditOperation = false;
88         updateAcceptAllAction();
89       }
90     }
91   }
92 }
93
94 bool PartSet_SketcherReetntrantMgr::operationCommitted(ModuleBase_Operation* theOperation)
95 {
96   bool aProcessed = false;
97   if (!isActiveMgr())
98     return aProcessed;
99
100   aProcessed = myIsInternalEditOperation;
101   resetFlags();
102
103   return aProcessed;
104 }
105
106 void PartSet_SketcherReetntrantMgr::operationStarted(ModuleBase_Operation* theOperation)
107 {
108   if (!isActiveMgr())
109     return;
110
111   resetFlags();
112 }
113
114 void PartSet_SketcherReetntrantMgr::operationAborted(ModuleBase_Operation* theOperation)
115 {
116   if (!isActiveMgr())
117     return;
118
119   resetFlags();
120 }
121
122 bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /* theWnd*/,
123                                                       QMouseEvent* /* theEvent*/)
124 {
125   bool aProcessed = false;
126   if (!isActiveMgr())
127     return aProcessed;
128
129   if  (myIsInternalEditOperation) {
130     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
131                                                          (myWorkshop->currentOperation());
132     FeaturePtr aLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature()
133                                                                      : FeaturePtr();
134     if (aLastFeature) {
135       ModuleBase_ModelWidget* anActiveWidget = module()->activeWidget();
136       ModuleBase_IPropertyPanel* aPanel = myWorkshop->currentOperation()->propertyPanel();
137       bool aWidgetIsFilled = false;
138
139       //bool aCanBeActivatedByMove = false;
140       FeaturePtr aCurrentFeature = aFOperation->feature();
141       bool isLineFeature = false, isArcFeature = false;
142       if (aCurrentFeature->getKind() == SketchPlugin_Line::ID())
143         isLineFeature = anActiveWidget->attributeID() == SketchPlugin_Line::START_ID();
144       else if (isTangentArc(aFOperation))
145         isArcFeature = anActiveWidget->attributeID() == SketchPlugin_Arc::TANGENT_POINT_ID();
146
147       bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
148       if (aCanBeActivatedByMove) {
149         restartOperation();
150
151         anActiveWidget = module()->activeWidget();
152         aCurrentFeature = anActiveWidget->feature();
153         aProcessed = true;
154         if (isLineFeature) {
155           PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
156           if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line
157             QList<ModuleBase_ViewerPrsPtr> aSelection;
158             aSelection.append(std::shared_ptr<ModuleBase_ViewerPrs>(
159                new ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL)));
160             aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true);
161           }
162         }
163         else if (isArcFeature) { // arc, start point should be equal last point of the last feature arc
164           if (aCurrentFeature->getKind() == SketchPlugin_Arc::ID()) {
165             // get the last point of the previuos arc feature(geom point 2d)
166             std::shared_ptr<ModelAPI_Data> aData = aLastFeature->data();
167             std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = 
168                 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
169                                            aData->attribute(SketchPlugin_Arc::END_ID()));
170             // get point attribute on the current feature
171             AttributeRefAttrPtr aTangentPointAttr = aCurrentFeature->data()->refattr(
172                                                          SketchPlugin_Arc::TANGENT_POINT_ID());
173             aTangentPointAttr->setAttr(aPointAttr);
174             aWidgetIsFilled = true;
175           }
176         }
177       }
178       if (aWidgetIsFilled)
179         aPanel->activateNextWidget(anActiveWidget);
180     }
181   }
182   return aProcessed;
183 }
184
185 bool PartSet_SketcherReetntrantMgr::processMousePressed(ModuleBase_IViewWindow* /* theWnd*/,
186                                                         QMouseEvent* /* theEvent*/)
187 {
188   return isActiveMgr() && myIsInternalEditOperation;
189 }
190
191 bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* theWnd,
192                                                          QMouseEvent* theEvent)
193 {
194   bool aProcessed = false;
195   if (!isActiveMgr())
196     return aProcessed;
197
198   if (myIsInternalEditOperation) {
199     ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
200     ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
201
202     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
203     if (!anActiveWidget || !anActiveWidget->isViewerSelector()) {
204
205       // block of viewer update
206       // we need to block update content of the viewer because of Sketch Point feature
207       // in activate() the value of the point is initialized and it can be displayed
208       // but the default value is [0, 0]. So, we block update viewer contentent until
209       // onMouseRelease happens, which correct the point position
210       ModuleBase_Tools::blockUpdateViewer(true);
211
212       restartOperation();
213       aProcessed = true;
214
215       // fill the first widget by the mouse event point
216       // if the active widget is not the first, it means that the restarted operation is filled by
217       // the current preselection.
218       PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
219       ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
220       if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
221         aPoint2DWdg->onMouseRelease(theWnd, theEvent);
222       }
223       // unblock viewer update
224       ModuleBase_Tools::blockUpdateViewer(false);
225     }
226   }
227
228   return aProcessed;
229 }
230
231 void PartSet_SketcherReetntrantMgr::onWidgetActivated()
232 {
233   if (!isActiveMgr())
234     return;
235   if (!myIsInternalEditOperation)
236     return;
237
238   PartSet_Module* aModule = module();
239   ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget();
240   ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
241   if (aFirstWidget != aPanel->activeWidget()) {
242     ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
243     if (aWSelector)
244       aWSelector->activateSelectionAndFilters(true);
245   }
246 }
247
248 void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePreviousAttributeID)
249 {
250   if (!isActiveMgr())
251     return;
252
253   // we should avoid processing of the signal about no more widgets attributes and 
254   // do this after the restart operaion is finished if it was called
255   // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
256   // if it should be called after restart
257   if (myIsFlagsBlocked) {
258     myNoMoreWidgetsAttribute = thePreviousAttributeID;
259     return;
260   }
261
262   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
263                                                        (myWorkshop->currentOperation());
264   if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
265     return;
266
267   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
268     bool isStarted = false;
269     if (!module()->sketchMgr()->sketchSolverError()) {
270       if (myRestartingMode != RM_Forbided) {
271         myRestartingMode = RM_LastFeatureUsed;
272         isStarted = startInternalEdit(thePreviousAttributeID);
273       }
274     }
275     if (!isStarted)
276       aFOperation->commit();
277   }
278 }
279
280 bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousAttributeID)
281 {
282   bool isDone = false;
283
284   if (!isActiveMgr())
285     return isDone;
286
287   // empty previous attribute means that the Apply/Ok button has focus and the enter
288   // should not lead to start edition mode of the previous operation
289   if (thePreviousAttributeID.empty())
290     return isDone;
291
292   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
293                                                        (myWorkshop->currentOperation());
294   if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
295     return isDone;
296
297   bool isSketchSolverError = module()->sketchMgr()->sketchSolverError();
298
299   if (!isSketchSolverError) {
300     myRestartingMode = RM_EmptyFeatureUsed;
301     isDone = startInternalEdit(thePreviousAttributeID);
302   }
303
304   return isDone;
305 }
306
307 void PartSet_SketcherReetntrantMgr::onVertexSelected()
308 {
309   if (!isActiveMgr())
310     return;
311
312   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
313   std::string anOperationId = anOperation->id().toStdString();
314   if (anOperationId == SketchPlugin_Line::ID() || isTangentArc(anOperation)) {
315     /// If last line finished on vertex the lines creation sequence has to be break
316     ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
317     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
318     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
319     QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
320     bool aFoundWidget = false;
321     bool aFoundObligatory = false;
322     for (; anIt != aLast && !aFoundObligatory; anIt++) {
323       if (!aFoundWidget)
324         aFoundWidget = *anIt == anActiveWidget;
325       else
326         aFoundObligatory = (*anIt)->isObligatory();
327     }
328     if (!aFoundObligatory)
329       myRestartingMode = RM_Forbided;
330   }
331 }
332
333 void PartSet_SketcherReetntrantMgr::onBeforeStopped()
334 {
335   if (!isActiveMgr() || !myIsInternalEditOperation)
336     return;
337
338   beforeStopInternalEdit();
339 }
340
341 bool PartSet_SketcherReetntrantMgr::canBeCommittedByPreselection()
342 {
343   return !isActiveMgr() || myRestartingMode == RM_None;
344 }
345
346 bool PartSet_SketcherReetntrantMgr::isInternalEditStarted() const
347 {
348   return myIsInternalEditOperation;
349 }
350
351 bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
352 {
353   ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
354
355   bool anActive = PartSet_SketcherMgr::isSketchOperation(aCurrentOperation);
356   if (!anActive) {
357     anActive = PartSet_SketcherMgr::isNestedSketchOperation(aCurrentOperation);
358     if (anActive) { // the manager is not active when the current operation is a usual Edit
359       ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
360                                                        (myWorkshop->currentOperation());
361       if (aFOperation->isEditOperation())
362         anActive = myIsInternalEditOperation;
363     }
364   }
365   return anActive;
366 }
367
368 bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
369 {
370   bool isDone = false;
371   /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter
372   /// event comes two times, so we should not start another internal edit operation
373   /// the Apply button becomes disabled becase the second additional internal feature is created
374   if (myIsInternalEditOperation)
375     return true;
376
377   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
378                                                      (myWorkshop->currentOperation());
379
380   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
381     aFOperation->setEditOperation(true/*, false*/);
382     createInternalFeature();
383
384     myIsInternalEditOperation = true;
385     updateAcceptAllAction();
386
387     isDone = true;
388     connect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
389     connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
390
391     // activate selection filters of the first widget in the viewer
392     onWidgetActivated();
393
394     // activate the last active widget in the Property Panel
395     if (!thePreviousAttributeID.empty()) {
396       ModuleBase_Operation* anEditOperation = module()->currentOperation();
397       if (anEditOperation) {
398         ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
399         ModuleBase_ModelWidget* aPreviousAttributeWidget = 0;
400         QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
401         for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) {
402           if (aWidgets[i]->attributeID() == thePreviousAttributeID) {
403           /// workaround for the same attributes used in different stacked widgets(attribute types)
404           if (ModuleBase_ToolBox::isOffToolBoxParent(aWidgets[i]))
405             continue;
406             aPreviousAttributeWidget = aWidgets[i];
407           }
408         }
409         // If the current widget is a selector, do nothing, it processes the mouse press
410         if (aPreviousAttributeWidget) {
411           if (!aPreviousAttributeWidget->isViewerSelector()) {
412             aPreviousAttributeWidget->focusTo();
413             aPreviousAttributeWidget->selectContent();
414           }
415           else {
416             // in case of shape multi selector, the widget does not lose focus by filling
417             // like it is in shape selector. So, if enter is pressed, the multi shape selector
418             // control should be deactivated. The focus is moved to Apply button and there
419             // should not be active control visualized in property panel
420             if (aPreviousAttributeWidget == aPanel->activeWidget()) {
421               aPanel->activateWidget(NULL, false);
422             }
423             // if there is no the next widget to be automatically activated, the Ok button in property
424             // panel should accept the focus(example is parallel constraint on sketch lines)
425             QToolButton* anOkBtn = dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_OK);
426             if (anOkBtn)
427               anOkBtn->setFocus(Qt::TabFocusReason);
428           }
429         }
430       }
431     }
432   }
433   if (isDone)
434     module()->sketchMgr()->clearClickedFlags();
435
436   return isDone;
437 }
438
439 void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
440 {
441   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
442                                                       (myWorkshop->currentOperation());
443   if (aFOperation) {
444     disconnect(aFOperation, SIGNAL(beforeCommitted()), this, SLOT(onBeforeStopped()));
445     disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
446   }
447
448   deleteInternalFeature();
449 }
450
451 void PartSet_SketcherReetntrantMgr::restartOperation()
452 {
453   if (myIsInternalEditOperation) {
454     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(
455                                                                   myWorkshop->currentOperation());
456     if (aFOperation) {
457       myNoMoreWidgetsAttribute = "";
458       myIsFlagsBlocked = true;
459       FeaturePtr aPrevFeature = aFOperation->feature();
460       aFOperation->commit();
461       module()->launchOperation(aFOperation->id(), false);
462       // allow the same attribute values in restarted operation
463       ModuleBase_OperationFeature* aCurrentOperation = dynamic_cast<ModuleBase_OperationFeature*>(
464                                                                   myWorkshop->currentOperation());
465       copyReetntrantAttributes(aPrevFeature, aCurrentOperation->feature());
466
467       // update property panel: it should be done because in launchOperation, the 'false' is given
468       workshop()->propertyPanel()->updateContentWidget(aCurrentOperation->feature());
469       workshop()->propertyPanel()->createContentPanel(aCurrentOperation->feature());
470
471       myIsFlagsBlocked = false;
472       resetFlags();
473       // we should avoid processing of the signal about no more widgets attributes and 
474       // do this after the restart operaion is finished if it was called
475       // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute
476       // if it should be called after restart
477       if (!myNoMoreWidgetsAttribute.empty()) {
478         onNoMoreWidgets(myNoMoreWidgetsAttribute);
479         myNoMoreWidgetsAttribute = "";
480       }
481     }
482   }
483 }
484
485 void PartSet_SketcherReetntrantMgr::createInternalFeature()
486 {
487   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
488                                                      (myWorkshop->currentOperation());
489
490   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
491     FeaturePtr anOperationFeature = aFOperation->feature();
492
493     CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
494     myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
495
496     bool isFeatureChanged = copyReetntrantAttributes(anOperationFeature, myInternalFeature);
497     XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
498                                                   (aFOperation->propertyPanel());
499
500     myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
501     myInternalWidget->setVisible(false);
502
503     ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
504
505     QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
506     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
507
508     aFactory.createWidget(anInternalPage);
509     QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
510
511     foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
512       bool isStoreValue = !aFOperation->isEditOperation() &&
513                           !aWidget->getDefaultValue().empty() &&
514                           !aWidget->isComputedDefault();
515       aWidget->setFeature(myInternalFeature, isStoreValue);
516       if (!isStoreValue && isFeatureChanged)
517         aWidget->restoreValue();
518     }
519
520     ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
521                                                                                         (aWidgets);
522     if (aFirstWidget)
523       myInternalActiveWidget = aFirstWidget;
524   }
525 }
526
527 void PartSet_SketcherReetntrantMgr::deleteInternalFeature()
528 {
529   if (myInternalActiveWidget) {
530     ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
531     if (aWSelector)
532       aWSelector->activateSelectionAndFilters(false);
533     myInternalActiveWidget = 0;
534   }
535   delete myInternalWidget;
536   myInternalWidget = 0;
537
538   QObjectPtrList anObjects;
539   anObjects.append(myInternalFeature);
540   workshop()->deleteFeatures(anObjects);
541 }
542
543 void PartSet_SketcherReetntrantMgr::resetFlags()
544 {
545   if (!myIsFlagsBlocked) {
546     myIsInternalEditOperation = false;
547     updateAcceptAllAction();
548     myRestartingMode = RM_None;
549   }
550 }
551
552 bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
553                                                              const FeaturePtr& theNewFeature)
554 {
555   bool aChanged = false;
556   std::string aTypeAttributeId;
557   if (theSourceFeature->getKind() == SketchPlugin_Circle::ID()) {
558     aTypeAttributeId = SketchPlugin_Circle::CIRCLE_TYPE();
559   }
560   if (theSourceFeature->getKind() == SketchPlugin_Arc::ID()) {
561     aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
562   }
563   if (!aTypeAttributeId.empty()) {
564     AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
565     AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
566     aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
567     ModuleBase_Tools::flushUpdated(theNewFeature);
568     aChanged = true;
569   }
570   return aChanged;
571 }
572
573 bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation)
574 {
575   bool aTangentArc = false;
576   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
577                                                                         (theOperation);
578   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
579     FeaturePtr aFeature = aFOperation->feature();
580     if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
581       AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
582       std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
583       aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
584     }
585   }
586   return aTangentArc;
587 }
588
589 void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
590 {
591   CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
592   if (aSketch.get())
593     workshop()->errorMgr()->updateAcceptAllAction(aSketch);
594 }
595
596 XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
597 {
598   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
599   return aConnector->workshop();
600 }
601
602 PartSet_Module* PartSet_SketcherReetntrantMgr::module() const
603 {
604   return dynamic_cast<PartSet_Module*>(myWorkshop->module());
605 }
606