Salome HOME
Merge branch 'master' into cgt/devCEA
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 5 Apr 2017 13:15:51 +0000 (15:15 +0200)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 5 Apr 2017 13:15:51 +0000 (15:15 +0200)
45 files changed:
src/GeomAlgoAPI/GeomAlgoAPI_Circ2dBuilder.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Objects.cpp
src/Model/Model_Session.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_EventReentrantMessage.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_IWorkshop.h
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_MacroArc.cpp
src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketchPlugin/Test/TestCreateCircleChangeType.py
src/SketchPlugin/Test/TestTrimArc01.py
src/SketchPlugin/Test/TestTrimArc02.py
src/SketchPlugin/Test/TestTrimArc03.py
src/SketchPlugin/Test/TestTrimArc04.py
src/SketchPlugin/Test/TestTrimArc05.py
src/SketchPlugin/Test/TestTrimArc06.py
src/SketchPlugin/Test/TestTrimArc07.py
src/SketchPlugin/Test/TestTrimCircle01.py
src/SketchPlugin/Test/TestTrimCircle02.py
src/SketchPlugin/Test/TestTrimCircle03.py
src/SketchPlugin/Test/TestTrimCircle04.py
src/SketchPlugin/Test/TestTrimCircle05.py
src/SketchPlugin/Test/TestTrimCircleAndArc01.py
src/SketchPlugin/Test/TestTrimLine01.py
src/SketchPlugin/Test/TestTrimLine02.py
src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp
src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 754ef43a27d85edc962b50049ad0808715ac65be..286b226d3d88999797db05203cbfc948ba89a9a1 100644 (file)
@@ -527,7 +527,7 @@ std::shared_ptr<GeomAPI_Circ2d> GeomAlgoAPI_Circ2dBuilder::circle()
   std::shared_ptr<GeomAPI_Circ2d> aCircle;
   if (aCirc2d) {
     const gp_Pnt2d& aCenter = aCirc2d->Location();
-    const gp_Dir2d& aXAxis = aCirc2d->XAxis().Direction();
+    const gp_Dir2d& aXAxis = aCirc2d->Position().XDirection();
 
     std::shared_ptr<GeomAPI_Pnt2d> aCircleCenter(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
     std::shared_ptr<GeomAPI_Dir2d> aCircleDir(new GeomAPI_Dir2d(aXAxis.X(), aXAxis.Y()));
index 513c39d5c65b0afcc68d5d6793bed57ec070da0c..b2a4989dbac571ec9fd730f31e95d13bb0a46b5d 100644 (file)
@@ -538,7 +538,7 @@ void Model_AttributeSelection::selectBody(
     if (aFeatureOwner.get()) {
       aEraseResults = !aFeatureOwner->results().empty();
       if (aEraseResults) // erase results without flash deleted and redisplay: do it after Select
-        aFeatureOwner->removeResults(0, false);
+        aFeatureOwner->removeResults(0, false, false);
     }
     aSel.Select(aNewSub, aNewContext);
 
index 798e234c5c5c7b68a1c14bb6c0a5bf6d46f84d7e..f635941b3aeecb60a10eb7658f76405799351d1c 100644 (file)
@@ -75,7 +75,6 @@ Model_Objects::~Model_Objects()
     ModelAPI_EventCreator::get()->sendDeleted(myDoc, ModelAPI_Feature::group());
     ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP);
     aFeature->removeResults(0, false);
-    //aFeature->eraseResults();
     aFeature->erase();
     myFeatures.UnBind(aFeaturesIter.Key());
   }
index c73516a43069ef9382894fe3eb1456a588310bb1..98a1340f9c4b41eb0ed3a87a6da69aea163445f7 100644 (file)
@@ -504,8 +504,7 @@ void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
 {
   myPluginObjs[myCurrentPluginName] = thePlugin;
   static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
-  ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
-  Events_Loop::loop()->flush(EVENT_LOAD);
+  ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD, false);
   // If the plugin has an ability to process GUI events, register it
   Events_Listener* aListener = dynamic_cast<Events_Listener*>(thePlugin);
   if (aListener) {
index 2c18d72bc9b6c673acce6543c69f36a40d20d7b4..ee2e42be886a5dc52239e7a13ea6ab219923911f 100755 (executable)
@@ -580,7 +580,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
   #ifdef DEB_UPDATE
     std::cout<<"Invalid args "<<theFeature->name()<<std::endl;
   #endif
-    theFeature->eraseResults();
+    theFeature->eraseResults(false);
     redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
     return true; // so, feature is modified (results are erased)
   }
@@ -595,7 +595,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
     #ifdef DEB_UPDATE
       std::cout<<"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
     #endif
-    theFeature->eraseResults();
+    theFeature->eraseResults(false);
     redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
   }
   return true;
@@ -847,7 +847,7 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
   // The macro feature has to be deleted in any case even its execution is failed
   myWaitForFinish.insert(theFeature);
   if (aState != ModelAPI_StateDone) {
-    theFeature->eraseResults();
+    theFeature->eraseResults(false);
   }
   theFeature->data()->setUpdateID(ModelAPI_Session::get()->transactionID());
   redisplayWithResults(theFeature, aState);
index ded9c8b999f85275121531e1292e4f98d29c5d2a..381b4a9bde74c1da1f910aa3e13bd6ca0751a9e3 100644 (file)
@@ -26,7 +26,7 @@ class ModelAPI_EventReentrantMessage : public Events_Message
 public:
   /// Creates an empty message
   MODELAPI_EXPORT ModelAPI_EventReentrantMessage(const Events_ID theID,
-                                                 const void* theSender = 0);
+                                                 const void* theSender);
   /// The virtual destructor
   MODELAPI_EXPORT virtual ~ModelAPI_EventReentrantMessage() {}
   /// Static. Returns EventID of the message.
index bb387f81c92d22e435e60be0ec24141fc4123301..f83cf00a8d379592e284ec204e0c3e67f347156d 100644 (file)
@@ -104,7 +104,8 @@ void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr<ModelAPI_Result
   }
 }
 
-void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlush)
+void ModelAPI_Feature::removeResults(
+  const int theSinceIndex, const bool theForever, const bool theFlush)
 {
   std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
   for(int anIndex = 0; anIndex < theSinceIndex && aResIter != myResults.end(); anIndex++)
@@ -115,12 +116,12 @@ void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlus
   while( aNextIter != myResults.end()) {
     aGroup = (*aNextIter)->groupName();
     // remove previously erased results: to enable later if needed only actual (of history change)
-    //if (theSinceIndex == 0 && (*aNextIter)->isDisabled()) {
-    //  aNextIter = myResults.erase(aNextIter);
-    //} else {
-      (*aNextIter)->setDisabled(*aNextIter, true); // just disable results
+    (*aNextIter)->setDisabled(*aNextIter, true); // just disable results
+    if (theForever) {
+      aNextIter = myResults.erase(aNextIter);
+    } else {
       aNextIter++;
-    //}
+    }
   }
   if (!aGroup.empty() && theFlush) {
     // flush visualisation changes
@@ -132,9 +133,9 @@ void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlus
   }
 }
 
-void ModelAPI_Feature::eraseResults()
+void ModelAPI_Feature::eraseResults(const bool theForever)
 {
-  removeResults(0);
+  removeResults(0, theForever, true);
 }
 
 const std::string& ModelAPI_Feature::documentToAdd()
@@ -192,7 +193,7 @@ bool ModelAPI_Feature::setDisabled(const bool theFlag)
   if (myIsDisabled != theFlag) {
     myIsDisabled = theFlag;
     if (myIsDisabled) {
-      removeResults(0, false); // flush will be in setCurrentFeature
+      removeResults(0, false, false); // flush will be in setCurrentFeature
     } else {
       // enable all disabled previously results
       std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
index 71bd251d8802d78f6717193f34659fa367ddac7a..e30978a69b3afe8cb8bacffdb30fbea6af3e6384 100644 (file)
@@ -87,10 +87,12 @@ class ModelAPI_Feature : public ModelAPI_Object
   MODELAPI_EXPORT void removeResult(const std::shared_ptr<ModelAPI_Result>& theResult);
   /// removes all results starting from the given index (zero-based)
   /// \param theSinceIndex - index of the deleted result and all after also will be deleted
+  /// \param theForever - removes results for long period (not just because of feature disabling)
   /// \param theFlush - if it is false, REDISPLAY message is not flushed
-  MODELAPI_EXPORT void removeResults(const int theSinceIndex, const bool theFlush = true);
+  MODELAPI_EXPORT void removeResults(const int theSinceIndex,
+    const bool theForever = true, const bool theFlush = true);
   /// removes all results from the feature
-  MODELAPI_EXPORT void eraseResults();
+  MODELAPI_EXPORT void eraseResults(const bool theForever = true);
   /// removes all fields from this feature: results, data, etc
   MODELAPI_EXPORT virtual void erase();
   /// removes the result from the list of feature (not doing in disabled): normally this
index 7dc2d8f82e28c7b550a6c4919cb2151340858b92..39f9abc799b7e20de9e6ba9aa09aba247b15d782 100644 (file)
@@ -56,7 +56,8 @@ ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
 
 void ModuleBase_IModule::launchModal(const QString& theCmdId)
 {
-  if (!myWorkshop->canStartOperation(theCmdId))
+  bool isCommitted;
+  if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
     return;
 
   std::string aXmlCfg, aDescription;
@@ -74,7 +75,8 @@ void ModuleBase_IModule::launchModal(const QString& theCmdId)
 }
 
 
-void ModuleBase_IModule::launchOperation(const QString& theCmdId)
+void ModuleBase_IModule::launchOperation(const QString& theCmdId,
+                                         const bool& isStartAfterCommitOnly)
 {
   /// selection should be obtained from workshop before ask if the operation can be started as
   /// the canStartOperation method performs commit/abort of previous operation.
@@ -84,7 +86,12 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId)
   QList<ModuleBase_ViewerPrsPtr> aPreSelected =
     aSelection->getSelected(ModuleBase_ISelection::AllControls);
 
-  if (!myWorkshop->canStartOperation(theCmdId))
+  bool isCommitted;
+  if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
+    return;
+
+  /// reentrant operation(Sketch Line) should not be started if operation is aborted
+  if (isStartAfterCommitOnly && !isCommitted)
     return;
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
@@ -220,8 +227,10 @@ void ModuleBase_IModule::onFeatureTriggered()
   //Do nothing on uncheck
   if (aCmd->isCheckable() && !aCmd->isChecked()) {
     ModuleBase_Operation* anOperation = myWorkshop->findStartedOperation(aCmd->data().toString());
-    if (myWorkshop->canStopOperation(anOperation))
-      myWorkshop->stopOperation(anOperation);
+    if (myWorkshop->canStopOperation(anOperation)) {
+      bool isCommitted;
+      myWorkshop->stopOperation(anOperation, isCommitted);
+    }
     else {
       aCmd->setChecked(true);
     }
@@ -232,7 +241,7 @@ void ModuleBase_IModule::onFeatureTriggered()
     if (aInfo.get() && aInfo->isModal()) {
       launchModal(aCmdId);
     } else {
-      launchOperation(aCmdId);
+      launchOperation(aCmdId, false);
       emit operationLaunched();
     }
   }
@@ -241,7 +250,8 @@ void ModuleBase_IModule::onFeatureTriggered()
 void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
 {
   std::string aFeatureId = theFeature->getKind();
-  if (!myWorkshop->canStartOperation(aFeatureId.c_str()))
+  bool isCommitted;
+  if (!myWorkshop->canStartOperation(aFeatureId.c_str(), isCommitted))
     return;
 
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
index 62b746eabb821cd8fe4c368bbece1eb705162d6c..11a32c888e23b37930f0c333e2081eb6e8aa1045 100755 (executable)
@@ -85,7 +85,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
 
   /// Creates an operation and send it to loop
   /// \param theCmdId the operation name
-  virtual void launchOperation(const QString& theCmdId);
+  /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+  ///        it is committed
+  virtual void launchOperation(const QString& theCmdId,
+                               const bool& isStartAfterCommitOnly);
 
   /// Executes feature as a modal dialog box
   /// \param theCmdId the operation name
index a9c66405d9a8836758299ebe1ceee3920f6c2fd5..97e13ffbbd59674b111db54177da1fd9e5781496 100644 (file)
@@ -74,7 +74,7 @@ Q_OBJECT
   virtual ModuleBase_Operation* currentOperation() const = 0;
 
   //! Returns true if the operation with id theId can be started
-  virtual bool canStartOperation(QString theId) = 0;
+  virtual bool canStartOperation(QString theId, bool& isCommitted) = 0;
 
   //! Performs the operation launch
   //! \param theOperation an operation to be launched
@@ -92,7 +92,9 @@ Q_OBJECT
 
   //! Commits if possible or aborts the given operation.
   //! \param theOperation an aborted operation
-  virtual void stopOperation(ModuleBase_Operation* theOperation) = 0;
+  /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+  virtual void stopOperation(ModuleBase_Operation* theOperation,
+                             bool& isCommitted) = 0;
 
   //! Returns AIS object by data object
   //! \param theObject a data object
index b249f2311983ade7c75c110a9b176c1c74c641d9..c65d42515b6d585fba3d8e195bed6c497166622f 100644 (file)
@@ -299,7 +299,8 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction)
     // the active nested sketch operation should be aborted unconditionally
     // the Delete action should be additionally granted for the Sketch operation
     // in order to do not abort/commit it
-    if (!anOpMgr->canStartOperation(tr("Detach")))
+    bool isCommitted;
+    if (!anOpMgr->canStartOperation(tr("Detach"), isCommitted))
       return; // the objects are processed but can not be deleted
 
     anOpMgr->startOperation(anOpAction);
@@ -358,7 +359,8 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked)
     anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
     bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
 
-    if (!anOpMgr->canStartOperation(anOpAction->id()))
+    bool isCommitted;
+    if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
       return; // the objects are processed but can not be deleted
 
     anOpMgr->startOperation(anOpAction);
index 41c2d3b04db528cb807b85e8bab3ff3fd3310732..e1bac3b35ead0d0ad08436dfc1cfc9ed6ec74aa5 100755 (executable)
@@ -828,7 +828,8 @@ bool PartSet_Module::deleteObjects()
     // the active nested sketch operation should be aborted unconditionally
     // the Delete action should be additionally granted for the Sketch operation
     // in order to do not abort/commit it
-    if (!anOpMgr->canStartOperation(anOpAction->id()))
+    bool isCommitted;
+    if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
       return true; // the objects are processed but can not be deleted
 
     anOpMgr->startOperation(anOpAction);
@@ -850,29 +851,6 @@ bool PartSet_Module::deleteObjects()
   return isProcessed;
 }
 
-void PartSet_Module::onFeatureTriggered()
-{
-  // is commented for imp: Unpressing the button of the current action must behave like
-  // a validation if the entity can be created (instead of Cancel, as currently)
-  /*QAction* aCmd = dynamic_cast<QAction*>(sender());
-  if (aCmd->isCheckable() && aCmd->isChecked()) {
-    // 1. check whether the delete should be processed in the module
-    ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-    bool isNestedOp = myModule->sketchMgr()->isNestedCreateOperation(anOperation);
-    if (isNestedOp) {
-      // in case if in the viewer nothing is displayed, the create operation should not be
-      // comitted even if all values of the feature are initialized
-      if (!mySketchMgr->canDisplayCurrentCreatedFeature()) {
-        // the action information should be saved before the operation is aborted
-        // because this abort leads to update command status, which unchecks this action
-        anOperation->abort();
-        launchOperation(aCmd->data().toString());
-      }
-    }
-  }*/
-  ModuleBase_IModule::onFeatureTriggered();
-}
-
 void PartSet_Module::editFeature(FeaturePtr theFeature)
 {
   storeConstraintsState(theFeature->getKind());
@@ -884,13 +862,13 @@ bool PartSet_Module::canCommitOperation() const
   return true;
 }
 
-void PartSet_Module::launchOperation(const QString& theCmdId)
+void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
 {
   myIsOperationIsLaunched = true;
   storeConstraintsState(theCmdId.toStdString());
   updateConstraintsState(theCmdId.toStdString());
 
-  ModuleBase_IModule::launchOperation(theCmdId);
+  ModuleBase_IModule::launchOperation(theCmdId, isStartAfterCommitOnly);
 
   myIsOperationIsLaunched = false;
 }
index 7292bb30ad20c54e0ffc28aa478573394d6e782a..649e3d3e289e2c0e8af307c434b5874ef4c4eecf 100755 (executable)
@@ -106,7 +106,10 @@ public:
 
   /// Creates an operation and send it to loop
   /// \param theCmdId the operation name
-  virtual void launchOperation(const QString& theCmdId);
+  /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+  ///        it is committed
+  virtual void launchOperation(const QString& theCmdId,
+                               const bool& isStartAfterCommitOnly);
 
   /// Realizes some functionality by an operation start
   /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
@@ -349,11 +352,6 @@ public:
   XGUI_Workshop* getWorkshop() const;
 
 public slots:
-  /// Redefines the parent method in order to customize the next case:
-  /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
-  /// the operation should be always aborted.
-  virtual void onFeatureTriggered();
-
   /// Slolt called on object display
   /// \param theObject a data object
   /// \param theAIS a presentation object
index 1eff378359d69529ff52eba32e640742b7a9a680..d0de78c04d9b6eb02430594c34384ccd382d4b1d 100755 (executable)
 #include <PartSet_SketcherMgr.h>
 #include <PartSet_SketcherReentrantMgr.h>
 
+#include "XGUI_CustomPrs.h"
+#include "XGUI_Displayer.h"
 #include "XGUI_ModuleConnector.h"
+#include "XGUI_OperationMgr.h"
+#include "XGUI_Tools.h"
 #include "XGUI_Workshop.h"
-#include "XGUI_Displayer.h"
-#include "XGUI_CustomPrs.h"
 
 #include "SketcherPrs_SymbolPrs.h"
 #include "SketchPlugin_SketchEntity.h"
@@ -154,9 +156,34 @@ void PartSet_OverconstraintListener::processEvent(
   }
   else if (anEventID == ModelAPI_EventReentrantMessage::eventId() ||
            anEventID == SketchPlugin_MacroArcReentrantMessage::eventId()) {
-    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
-    PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
-    aReentrantMgr->setReentrantMessage(theMessage);
+    // the message is sent to sketcher reentrant manager only if the kind of feature
+    // sender is equal to kind of the current operation. E.g. Horizontal create operation
+    // is active. Sketch Line feature is changed, so execute is called, it will send message
+    // This Line's message should not be processed, as the reentrant operation is not for Line
+    std::string aCurrentFeatureKind;
+    ModuleBase_Operation* anOperation =
+                XGUI_Tools::workshop(myWorkshop)->operationMgr()->currentOperation();
+    if (anOperation) {
+      ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                           (anOperation);
+      if (aFOperation) {
+        FeaturePtr aFeature = aFOperation->feature();
+        if (aFeature.get())
+          aCurrentFeatureKind = aFeature->getKind();
+      }
+    }
+    if (theMessage->sender()) {
+      ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theMessage->sender());
+      if (aSender) {
+        FeaturePtr aFeatureSender =
+          std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
+        if (aFeatureSender.get() && aFeatureSender->getKind() == aCurrentFeatureKind) {
+          PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+          PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+          aReentrantMgr->setReentrantMessage(theMessage);
+        }
+      }
+    }
   }
 
 #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
index a63586cef8adb0c093ee969f3730e483d029477f..f724f3aa64619fdb862a6802234b490320057cd1 100755 (executable)
@@ -306,17 +306,15 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
 
 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
+  // Clear dragging mode
+  myIsDragging = false;
+
   if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent))
     return;
-
   //get2dPoint(theWnd, theEvent, myClickedPoint);
-
   if (!(theEvent->buttons() & Qt::LeftButton))
     return;
 
-  // Clear dragging mode
-  myIsDragging = false;
-
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
   if (!aViewer->canDragByMouse())
@@ -425,6 +423,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
 void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
+  bool aWasDragging = myIsDragging;
+  myIsDragging = false;
+
   if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent))
     return;
 
@@ -440,7 +441,7 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
   if (aOp) {
     if (isNestedSketchOperation(aOp)) {
       // Only for sketcher operations
-      if (myIsDragging) {
+      if (aWasDragging) {
         if (myDragDone) {
           myCurrentSelection.clear();
         }
@@ -449,7 +450,6 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
   }
 
   aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
-  myIsDragging = false;
 
   ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
   PartSet_MouseProcessor* aProcessor = dynamic_cast<PartSet_MouseProcessor*>(anActiveWidget);
index b355a8869e1bb8be90d1ee1b49b804fdfd1c5639..b9c92f940c6a08d417f4ea475cb1d873f8698882 100644 (file)
@@ -546,15 +546,16 @@ void PartSet_SketcherReentrantMgr::restartOperation()
       QList<ModuleBase_ViewerPrsPtr> aPreSelected =
         aSelection->getSelected(ModuleBase_ISelection::AllControls);
 
-
-
       if (myInternalFeature.get())
         copyReetntrantAttributes(myInternalFeature, aFOperation->feature(),
                                   module()->sketchMgr()->activeSketch());
 
       myNoMoreWidgetsAttribute = "";
       myIsFlagsBlocked = true;
-      module()->launchOperation(aFOperation->id());
+      /// launch has 'false' parameter to do not start new operation if the previous operation
+      /// is not committed. It is important for Line Sketch feature as it uses the previous
+      /// created feature parameter(to build coincidence), but by abort the previous is removed
+      module()->launchOperation(aFOperation->id(), true);
       myIsFlagsBlocked = false;
       resetFlags();
 
index 96e7591c95559ced89aec8c2bf7a22df443aecd3..75fe9e99392841d1f5cad66aefb88dcaacc5b1c8 100644 (file)
@@ -163,4 +163,19 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                Test1673.py
                Test1924.py
                Test1966.py
-               Test1967.py)
+               Test1967.py
+               TestTrimArc01.py
+               TestTrimArc02.py
+               TestTrimArc03.py
+               TestTrimArc04.py
+               TestTrimArc05.py
+               TestTrimArc06.py
+               TestTrimArc07.py
+               TestTrimCircle01.py
+               TestTrimCircle02.py
+               TestTrimCircle03.py
+               TestTrimCircle04.py
+               TestTrimCircle05.py
+               TestTrimCircleAndArc01.py
+               TestTrimLine01.py
+               TestTrimLine02.py)
index 5760a866f92da39fbd94002d8f7d2299e163c886..7c3f528d50330ded1ed7bf8ad97efefb0100e1a7 100644 (file)
@@ -70,7 +70,7 @@ void SketchPlugin_Line::execute()
 
       static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
       std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
-          <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, 0));
+          <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, this));
       aMessage->setCreatedFeature(ModelAPI_Feature::feature(
                                   data()->attribute(START_ID())->owner()));
       Events_Loop::loop()->send(aMessage);
index e963cfe14c33a4cc1a9b2503fda2fdc9e4f6e656..54c2f64b7ac2d928a5c48d28dcdc1a542eb71bab 100644 (file)
@@ -355,7 +355,7 @@ void SketchPlugin_MacroArc::execute()
   // message to init reentrant operation
   static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
   std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
-    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
 
   std::string anEditArcType = string(EDIT_ARC_TYPE_ID())->value();
   aMessage->setTypeOfCreation(!anEditArcType.empty() ? anEditArcType : anArcType);
index 5ad9a8ca145506005085afdf0a1a5b625082c0fe..942e9f9c3a42f4732f88305240b93c024bce88db 100644 (file)
@@ -21,7 +21,7 @@ class SketchPlugin_MacroArcReentrantMessage : public ModelAPI_EventReentrantMess
 public:
   /// Creates an empty message
   SKETCHPLUGIN_EXPORT SketchPlugin_MacroArcReentrantMessage(const Events_ID theID,
-                                                            const void* theSender = 0)
+                                                            const void* theSender)
   : ModelAPI_EventReentrantMessage(theID, theSender) {}
   /// The virtual destructor
   SKETCHPLUGIN_EXPORT virtual ~SketchPlugin_MacroArcReentrantMessage() {}
index e0c178ddd78f70f2a940676330d8b2a8bbd3e132..3af61c721b52505313a428b5336377ff8bf5b703 100644 (file)
@@ -97,7 +97,7 @@ void SketchPlugin_MacroCircle::execute()
   // message to init reentrant operation
   static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
   std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
-    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
 
   std::string anEditType = string(EDIT_CIRCLE_TYPE())->value();
   aMessage->setTypeOfCreation(!anEditType.empty() ? anEditType : aType);
@@ -140,8 +140,19 @@ std::string SketchPlugin_MacroCircle::processEvent(
       AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
                                                         attribute(aReferenceAttributeName));
       if (aRefAttr.get()) {
-        if (anAttribute.get())
+        if (anAttribute.get()) {
+          if (!anAttribute->owner().get() || !anAttribute->owner()->data()->isValid()) {
+            FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature();
+            if (aCreatedFeature.get()) {
+              std::string anID = anAttribute->id();
+              std::string anArcID;
+              if (anID == CENTER_POINT_ID())
+                anArcID = SketchPlugin_Circle::CENTER_ID();
+              anAttribute = aCreatedFeature->attribute(anArcID);
+            }
+          }
           aRefAttr->setAttr(anAttribute);
+        }
         else if (anObject.get()) {
           // if presentation of previous reentrant macro arc is used, the object is invalid,
           // we should use result of previous feature of the message(Arc)
@@ -400,6 +411,11 @@ void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) {
 
   AttributeDoublePtr aRadiusAttr = real(CIRCLE_RADIUS_ID());
   bool aWasBlocked = data()->blockSendAttributeUpdated(true);
+  if(myCenter.get()) {
+    // center attribute is used in processEvent() to set reference to reentrant arc
+    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_POINT_ID()))
+        ->setValue(myCenter);
+  }
   aRadiusAttr->setValue(myRadius);
   data()->blockSendAttributeUpdated(aWasBlocked, false);
 }
index 986b99b30d941314868403303847a83dfcf26bc0..4e60668376998ee0c60c7a55317efdd15f1b99d3 100644 (file)
@@ -467,7 +467,7 @@ void SketchPlugin_Trim::execute()
   if (aPreviewObject.get()) {
     std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
       <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(
-                                           ModelAPI_EventReentrantMessage::eventId(), 0));
+                                           ModelAPI_EventReentrantMessage::eventId(), this));
     aMessage->setSelectedObject(aPreviewObject);
     Events_Loop::loop()->send(aMessage);
   }
index 4a78584aa365d924d9175727f43f545253614445..8041ae1b575966174576717009eb36c8a7acc206 100644 (file)
@@ -23,9 +23,7 @@ __updated__ = "2017-03-22"
 
 def assertNotInitializedByCenterAndPassed(theMacroCircle):
     # check points
-    aCenterPoint = geomDataAPI_Point2D(theMacroCircle.attribute("center_point"))
     aPassedPoint = geomDataAPI_Point2D(theMacroCircle.attribute("passed_point"))
-    assert (not aCenterPoint.isInitialized())
     assert (not aPassedPoint.isInitialized())
     # check references
     aCenterPointRef = theMacroCircle.refattr("center_point_ref")
index c7a2e29cac1956baaa4a1b9d0289392b0e3cdb95..a8e63cff0ec7c82693c667a01428d822cbcf95ae 100644 (file)
@@ -93,4 +93,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 4b1cbf4b6527ee7f24334abadf1321d6332bdf92..9098e7413fb13ccda2634d4fae92a1f0897a3f7c 100644 (file)
@@ -98,4 +98,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 55c17601b299cd180c4e33b25b340d563adef8f1..1f8f0253dd2668b82b4c8c352be2d5b8fbf29e98 100644 (file)
@@ -102,4 +102,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index c694ef4901af97cae12529597ea60f708525da3a..b56d6bd1fb5856fd3540af54e5b39853ca188719 100644 (file)
@@ -102,4 +102,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 1bf8ae699c771f22e5b47e3b2c071feeaaa2e56a..c8fd1044a25803ce5780008c5eb1862459f138bc 100644 (file)
@@ -103,4 +103,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 610946cb31f46018d9bc4255756141f1c9b3c532..658998900f184dc5690012371886618293807116 100644 (file)
@@ -102,4 +102,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index b94d921b8e01e9d28c922389427397ea56c65a1c..a8099f486e3b676cf581b2e2ddcead94cf5e01cd 100644 (file)
@@ -53,14 +53,6 @@ model.do()
 SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint))
 SketchTrim.execute()
 
-
-# Another case
-#GeomPoint = geom.Pnt2d(60, 50)
-#model.do()
-#SketchTrim = Sketch.addTrim(SketchArc_1, GeomPoint)
-#SketchTrim.execute()
-
-
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index f9e270d050bcbcd40b876e9c1a2f4e348ff57e61..cbd7509cfecf9b5ea530e4e81390d1c3af24bdc3 100644 (file)
@@ -90,4 +90,4 @@ assert(len(Intersection_Points_3) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index e843c55da03a183f3680c37e060a8e04b795fbf7..b85aef8b80e20a149a79135a7e35d0b82efe37f3 100644 (file)
@@ -89,4 +89,4 @@ assert(len(Intersection_Points_3) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index e95823b037fa14457a067203f7c7d53c336f5b06..3e426dcd975d1f0c1eb7799fc5d000188f029bed 100644 (file)
@@ -94,4 +94,4 @@ assert(len(Intersection_Points_3) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 57db652282fac5b317571e57a2cfbb045d8f97e7..0d3adb8be1f4f29391238b12cf96f11388c5f9cf 100644 (file)
@@ -95,4 +95,4 @@ assert(len(Intersection_Points_3) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index d53d89b931ff6dcf7ef87c2203a7148d4872c831..5bd00a673f47c76bcda39c658d160c4144172c20 100644 (file)
@@ -99,4 +99,4 @@ assert(len(Intersection_Points_3) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 1bb501b1e21aba4832bc2f1b8af8c95e65bb0063..b4885a63532e9247c7aacc72d3e7d5062c279476 100644 (file)
@@ -90,23 +90,11 @@ assert(idList_after.count(SketchLineId) == 6)
 assert(idList_after.count(SketchConstraintCoincidenceId) == 8)
 
 
-#check arc position intersections of created arc to an additional line
-#SketchLine_intersecting_1 = Sketch.addLine(0, 0, 50, 50)
-#SketchLine_intersecting_2 = Sketch.addLine(50, 50, 100, 100)
-
-#Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_1.feature()]))
-#Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_2.feature()]))
-
-#assert(len(Intersection_Points_1) == 1)
-#assert(len(Intersection_Points_2) == 0)
-
 #add point for check
 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
 Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchPoint.feature()]))
 assert(len(Intersection_Points_3) == 0)
 
-
-
 #perform trim: horizontal
 #second intersection point - horizontal
 SketchLine_intersecting_h = Sketch.addLine(10, 48, 72, 48)
@@ -154,4 +142,4 @@ assert(len(Intersection_Points_5) == 0)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 5256326fb12a3926cc7c869e18c0cd58c5b602fe..b823a6ceb3464aaf4f5dc2a046ff2831178473ab 100644 (file)
@@ -68,4 +68,4 @@ assert(idList_after.count(SketchConstraintCoincidenceId) == 2)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 9730f8e0728a5fa2445b455e0b442471bef4242c..d9f3aa3d6bb04a32d2d48e052a071896a9d539cf 100644 (file)
@@ -85,4 +85,4 @@ assert(len(Intersection_Points_5) == 1)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index 3288c9830480d228ef7b87c0e68cea055707cd3a..2a91c6285cf281479c864bea6bd7e0406e407923 100644 (file)
@@ -58,9 +58,8 @@ void SketchSolver_ConstraintMultiRotation::process()
 
   EntityWrapperPtr anAngle;
   EntityWrapperPtr aRotationCenter;
-  bool isFullValue;
   std::list<EntityWrapperPtr> aBaseEntities;
-  getAttributes(aRotationCenter, anAngle, isFullValue, aBaseEntities);
+  getAttributes(aRotationCenter, anAngle, myIsFullValue, aBaseEntities);
   if (!myErrorMsg.empty())
     return;
 
index 1a26ea810177eb250bc8b91a9a42304b65c509e8..7bbd8c18f382dd972a7972da43cad7adc17a0271 100644 (file)
@@ -57,9 +57,8 @@ void SketchSolver_ConstraintMultiTranslation::process()
   }
 
   EntityWrapperPtr aStartPoint, aEndPoint;
-  bool aFullValue;
   std::list<EntityWrapperPtr> aBaseEntities;
-  getAttributes(aStartPoint, aEndPoint, aFullValue, aBaseEntities);
+  getAttributes(aStartPoint, aEndPoint, myIsFullValue, aBaseEntities);
   if (!myErrorMsg.empty())
     return;
 
index e6b6cf73fe249565817b83988643a47659e149df..51358f13c1246adc1cffa9591ced1e38f6404037 100644 (file)
@@ -131,9 +131,9 @@ void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage)
   myWorkshop->setStatusBarMessage(theMessage);
 }
 
-bool XGUI_ModuleConnector::canStartOperation(QString theId)
+bool XGUI_ModuleConnector::canStartOperation(QString theId, bool& isCommitted)
 {
-  return myWorkshop->operationMgr()->canStartOperation(theId);
+  return myWorkshop->operationMgr()->canStartOperation(theId, isCommitted);
 }
 
 void XGUI_ModuleConnector::processLaunchOperation(ModuleBase_Operation* theOperation)
@@ -164,9 +164,10 @@ bool XGUI_ModuleConnector::canStopOperation(ModuleBase_Operation* theOperation)
   return myWorkshop->operationMgr()->canStopOperation(theOperation);
 }
 
-void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation,
+                                         bool& isCommitted)
 {
-  myWorkshop->operationMgr()->stopOperation(theOperation);
+  myWorkshop->operationMgr()->stopOperation(theOperation, isCommitted);
 }
 
 void XGUI_ModuleConnector::updateCommandStatus()
index eb4c37c4f27de2caeda07fe73b2ef6b94c45e589..543d0279a62df6adb33c38fe6877d8c2c5e5ac96 100644 (file)
@@ -57,7 +57,9 @@ Q_OBJECT
   virtual ModuleBase_Operation* currentOperation() const;
 
   //! Returns true if the operation with id theId can be started
-  virtual bool canStartOperation(QString theId);
+  /// \param theId id of the operation which is going to start
+  /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+  virtual bool canStartOperation(QString theId, bool& isCommitted);
 
   //! Performs the operation launch
   //! \param theOperation an operation to be launched
@@ -75,7 +77,9 @@ Q_OBJECT
 
   //! Commits if possible or aborts the given operation.
   //! \param theOperation an aborted operation
-  virtual void stopOperation(ModuleBase_Operation* theOperation);
+  /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+  virtual void stopOperation(ModuleBase_Operation* theOperation,
+                             bool& isCommitted);
 
   //! Returns AIS object by data object
   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
index 6c234bee827ee14ad0639ccc8172e473cb5ca567..61adc99ea80937249f3c07a803ca494ad3c98561 100644 (file)
@@ -355,9 +355,10 @@ void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature)
     aMgr->finishOperation();
 }
 
-bool XGUI_OperationMgr::canStartOperation(const QString& theId)
+bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
 {
   bool aCanStart = true;
+  isCommitted = false;
   ModuleBase_Operation* aCurrentOp = currentOperation();
   if (aCurrentOp) {
     bool aGranted = aCurrentOp->isGranted(theId);
@@ -375,7 +376,7 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId)
       else if (canStopOperation(aCurrentOp)) {
         // the started operation is granted in the parrent operation,
         // e.g. current - Line in Sketch, started Circle
-        stopOperation(aCurrentOp);
+        stopOperation(aCurrentOp, isCommitted);
       } else {
         aCanStart = false;
       }
@@ -384,12 +385,14 @@ bool XGUI_OperationMgr::canStartOperation(const QString& theId)
   return aCanStart;
 }
 
-void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
 {
   if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
-    theOperation->commit();
-  else
+    isCommitted = theOperation->commit();
+  else {
+    isCommitted = false;
     abortOperation(theOperation);
+  }
 }
 
 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
index cca5bb926a37e9c32b903f1a7b36e28ceea54b3e..c8ccf9d08a7b2d1380db13cfe2f550e6f21ca277 100755 (executable)
@@ -101,11 +101,13 @@ Q_OBJECT
   /// Returns whether the operation can be started. Check if there is already started operation and
   /// the granted parameter of the launched operation
   /// \param theId id of the operation which is going to start
-  bool canStartOperation(const QString& theId);
+  /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+  bool canStartOperation(const QString& theId, bool& isCommitted);
 
   /// If Apply is enabled and operation has modification, it is applyed, otherwise aborted
   /// \param theOperation the started operation
-  void stopOperation(ModuleBase_Operation* theOperation);
+  /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+  void stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted);
 
   /// Aborts the parameter operation if it is current, else abort operations from the stack
   /// of operations until the operation is found. All operations upper the parameter one are