]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Bug fixing for constraints
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 15:41:20 +0000 (19:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 24 Jul 2014 15:41:20 +0000 (19:41 +0400)
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_ResultValidators.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Workshop.cpp

index 0387105b784b57acc96c4ddb5ce475f42b48692f..f3a657548a6fcf25bf613f9cb9b4662d02f2074b 100644 (file)
@@ -137,12 +137,12 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
 {
   FeaturePtr aFeature = feature();
   if (aFeature) {
-    if (aFeature.get() == theObj.get())
+    if (aFeature == theObj)
       return true;
     std::list<ResultPtr> aResults = aFeature->results();
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-      if ((*aIt).get() == theObj.get())
+      if ((*aIt) == theObj)
         return true;
     }
   }
index 631857d15c8cc4a28c58f74406e178b7c9d93f89..548fc549cf307a3557b4cf2c4585c4c1c07c6d60 100644 (file)
@@ -71,6 +71,7 @@ bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
   if (aShape.IsNull())
     return false;
 
+  TopAbs_ShapeEnum aa = aShape.ShapeType();
   if (aShape.ShapeType() == TopAbs_EDGE) {
     TopoDS_Edge aEdge = TopoDS::Edge(aShape);
     Standard_Real aStart, aEnd;
index fe1faa56db70f3b18e20855641ce48e3963da796..b46cf90967b30b86bf225e4baa781bd40931bea3 100644 (file)
@@ -104,7 +104,7 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
   if (anAttr)
-    aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
+    aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
 
   if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
index 456ff056943eebb5946a8277da84dd386d724a84..a112da05c7394e6d83c5efdaadaf6f01520dd559 100644 (file)
@@ -7,7 +7,9 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
-#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_Sketch.h"
+
+#include <GeomAPI_IPresentable.h>
 #include <list>
 
 /** \class SketchPlugin_ConstraintDistance
@@ -18,7 +20,8 @@
  *  These constraint has three attributes:
  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
-class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint, 
+                                       public GeomAPI_IPresentable
 {
 public:
   /// Distance constraint kind
index f21aa9979389169d7ad90477c555952b0cf1403a..1a82f07250a180008166d883e1f6adce84140ad7 100644 (file)
@@ -9,12 +9,15 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
 
 #include <GeomDataAPI_Point2D.h>
 
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
 
+
+
 SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
 {
 }
@@ -33,7 +36,7 @@ void SketchPlugin_ConstraintLength::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    ObjectPtr aFeature = aRef->object();
+    FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
index 9cd5ccff43a88e807def5aab6a57d98b8ea335bc..76e48e0760ce6f565de147baa5d92159f07c37c9 100644 (file)
@@ -159,3 +159,17 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::
   }
   return boost::shared_ptr<GeomAPI_AISObject>();
 }
+
+FeaturePtr SketchPlugin_Sketch::getFeature(ObjectPtr theObject)
+{
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature) {
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+      DocumentPtr aDoc = aMgr->rootDocument();
+      return aDoc->feature(aResult);
+    }
+  }
+  return aFeature;
+}
\ No newline at end of file
index 8a1d22db4701ad7fa263979b921ebc1058e9b67b..374f8a9e1d9cf1ae62458093272301f17b6cdb1f 100644 (file)
@@ -96,6 +96,8 @@ public:
   virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                             boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
+  static FeaturePtr getFeature(ObjectPtr theObject);
+
 protected:
   /// Creates a plane and append it to the list
   /// \param theX the X normal value
index 27eee74701d21f716bc7f1b6a43ba4059287590f..9080ebfaa6d71674647e1b4932e2651a7138b94a 100644 (file)
@@ -312,7 +312,13 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t
     if (!aObj->data() )
       myDisplayer->erase(aObj, false);
     else {
-      if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing
+      //if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing
+      if(myOperationMgr->hasOperation()) {
+        ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+        if (aOperation->hasObject(aObj)) { // Display only current operation results
+          myDisplayer->display(aObj, false);        
+        }
+      } else if (myDisplayer->isVisible(aObj))
         myDisplayer->display(aObj, false); // In order to update presentation
     }
   }
@@ -988,6 +994,8 @@ void XGUI_Workshop::updateCommandsOnViewSelection()
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   XGUI_Selection* aSelection = mySelector->selection();
+  if (aSelection->getSelected().size() == 0)
+    return;
 
   QList<QAction*> aActions = getModuleCommands();
   foreach(QAction* aAction, aActions) {