Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Thu, 16 Apr 2015 17:28:12 +0000 (20:28 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 16 Apr 2015 17:28:12 +0000 (20:28 +0300)
Conflicts:
src/PartSet/PartSet_SketcherMgr.cpp

src/Model/Model_AttributeSelection.h
src/Model/Model_Update.cpp
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.h
src/XGUI/XGUI_Workshop.cpp

index 22aaf8d9f9b831476ba6d1c63d47701f7570f6b3..b900299de1b8f16fc8e3b22e3e64c68d89e222e8 100644 (file)
@@ -72,7 +72,7 @@ protected:
   TDF_LabelMap& scope();
 
   /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting
-  MODELAPI_EXPORT virtual void setID(const std::string theID);
+  MODEL_EXPORT virtual void setID(const std::string theID);
 
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
index 142f5c1e12557284b0c4420054f1eb4c42b94dfe..403b3dffc759e217a86476a58ac5d94eeb84a630 100644 (file)
@@ -20,6 +20,7 @@
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
 #include <Events_Loop.h>
 #include <Events_LongOp.h>
 #include <Events_Error.h>
@@ -217,6 +218,28 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
     if (theFeature->data()->execState() != ModelAPI_StateDone)
       aMustbeUpdated = true;
 
+    ModelAPI_ExecState aState = ModelAPI_StateDone;
+
+    // check the parameters: values can be changed
+    std::list<AttributePtr> aDoubles = 
+      theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId()); 
+    std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
+    for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
+      AttributeDoublePtr aDouble = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
+      if (aDouble.get() && !aDouble->text().empty()) {
+        double aNewVal;
+        if (ModelAPI_Tools::findVariable(aDouble->text(), aNewVal)) {
+          if (aNewVal != aDouble->value()) {
+            aDouble->setValue(aNewVal);
+            aMustbeUpdated = true;
+          }
+        } else {
+          aState = ModelAPI_StateInvalidArgument;
+        }
+      }
+    }
+
     // composite feature must be executed after sub-features execution
     CompositeFeaturePtr aComposite = 
       std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
@@ -227,7 +250,6 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
           aMustbeUpdated = true;
       }
     }
-    ModelAPI_ExecState aState = ModelAPI_StateDone;
     // check all references: if referenced objects are updated, this object also must be updated
     // also check state of referenced objects: if they are not ready, inherit corresponding state
     std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
index 0aa5faf3eeb4ccff5ad0897b4d8a6164c7e93f26..91b6f859e32c9ba101dce6d18885978fc8b9cb44 100644 (file)
@@ -376,7 +376,11 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked)
   }
   if (isUseTransaction) {
     aMgr->finishOperation();
+    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
+    XGUI_Workshop* aWorkshop = aConnector->workshop();
+    aWorkshop->updateCommandStatus();
   }
+
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   myModule->sketchMgr()->restoreSelection();
 }
index 3a9487469f07de79def7b3e2e62f6b474d7a7c5a..2634dd7a3a7b825e9f388080ade8a2c29d3baeb3 100644 (file)
@@ -318,24 +318,25 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
           aOperation->abort();
       return;
     }
+    // Init flyout point for radius rotation
+    FeaturePtr aFeature = myCurrentSelection.begin().key();
 
     if (isSketcher) {
       myIsDragging = true;
       get2dPoint(theWnd, theEvent, myCurrentPoint);
       myDragDone = false;
       launchEditing();
-      // Init flyout point for radius rotation
-      FeaturePtr aFeature = myCurrentSelection.begin().key();
-      std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
-                std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+      if (aFeature.get() != NULL) {
+        std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+                  std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
       if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {
-        DataPtr aData = aSPFeature->data();
-        AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
-        std::shared_ptr<GeomDataAPI_Point2D> aFPAttr = 
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
-        aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
+          DataPtr aData = aSPFeature->data();
+          AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+          std::shared_ptr<GeomDataAPI_Point2D> aFPAttr = 
+            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
+          aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);
+        }
       }
-
     } else if (isSketchOpe && isEditing) {
       // If selected another object commit current result
       aOperation->commit();
index 868da0552900f20958902a229ee81dd13f4a7446..80fdfad7f07ece1ba1b23243e578fdf41ad8d9e6 100644 (file)
@@ -97,6 +97,16 @@ QAction* XGUI_ContextMenuMgr::action(const QString& theId) const
   return 0;
 }
 
+QAction* XGUI_ContextMenuMgr::actionByName(const QString& theName) const
+{
+  foreach(QAction* eachAction, myActions) {
+    if (eachAction->text() == theName) {
+      return eachAction;
+    }
+  }
+  return NULL;
+}
+
 QStringList XGUI_ContextMenuMgr::actionIds() const
 {
   return myActions.keys();
index 570fe912e1ac7b544f4200ba5b58929999f20468..805b376ef4fc159ce9c38e0accd568e87d673224 100644 (file)
@@ -33,6 +33,8 @@ Q_OBJECT
   /// \param theId an id of an action
   QAction* action(const QString& theId) const;
 
+  QAction* actionByName(const QString& theName) const;
+
   /// Returns list of registered actions Ids
   QStringList actionIds() const;
 
index eda3869245186db1cd2e1090526b5f686bbb07a3..a824d664c740f1bcba914d2fdfb60a939b215dc8 100644 (file)
@@ -677,6 +677,12 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   //QIntList aModes;
   //myDisplayer->activateObjects(aModes);
   myModule->operationStopped(theOperation);
+
+  if (myOperationMgr->operationsCount() == 0) {
+    // Activate selection mode for all objects
+    QIntList aModes;
+    myDisplayer->activateObjects(aModes);
+  }
 }
 
 
@@ -1377,8 +1383,10 @@ void XGUI_Workshop::deleteObjects()
 {
   ModuleBase_IModule* aModule = module();
   // 1. allow the module to delete objects, do nothing if it has succeed
-  if (aModule->deleteObjects())
+  if (aModule->deleteObjects()) {
+    updateCommandStatus();
     return;
+  }
 
   if (!isActiveOperationAborted())
     return;
@@ -1705,7 +1713,13 @@ QList<ActionInfo> XGUI_Workshop::processHistoryList(const std::list<std::string>
     if (isEditing) {
       anId.chop(ModuleBase_Operation::EditSuffix().size());
     }
-    ActionInfo anInfo = myActionsMgr->actionInfoById(anId);
+    ActionInfo anInfo;
+    QAction* aContextMenuAct = myContextMenuMgr->actionByName(anId);
+    if (aContextMenuAct) {
+      anInfo.initFrom(aContextMenuAct);
+    } else {
+      anInfo = myActionsMgr->actionInfoById(anId);
+    }
     if (isEditing) {
       anInfo.text = anInfo.text.prepend("Modify ");
     }