Salome HOME
Fix sketcher bugs
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Jul 2014 14:03:55 +0000 (18:03 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Jul 2014 14:03:55 +0000 (18:03 +0400)
15 files changed:
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/PartSet/PartSet_Module.cpp
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/XGUI/XGUI_DocumentDataModel.cpp

index 756451c299f834cd66652c3f911bd29c312da05f..86a8a8e0f1eb4a36b796a2889457c7763e224cf4 100644 (file)
@@ -6,9 +6,12 @@
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Attribute.h>
+#include <ModelAPI_Events.h>
 
 #include "Config_WidgetAPI.h"
 
+#include <Events_Loop.h>
+
 #include <QWidget>
 
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, 
@@ -37,3 +40,11 @@ bool ModuleBase_ModelWidget::focusTo()
   }
   return true;
 }
+
+
+void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
+{
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+}
index 45c5789a5ae75ffc83d67d28f63c1a03bf99b9b7..de0548b3d355b5ba765768d324f2015c4c32c548 100644 (file)
@@ -90,6 +90,8 @@ protected:
   /// \returns the string value
   void setAttributeID(const std::string& theAttribute) { myAttributeID = theAttribute; }
 
+  void updateObject(ObjectPtr theObj) const;
+
   bool myHasDefaultValue; /// the boolean state whether the control has a default value
 
 private:
index 1c3b68d1d9bcbb87029802de5b55f24aefb53eba..c77ecad44d99958e7f43cefb0a60f55b9eeadf81 100644 (file)
@@ -49,7 +49,7 @@ bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
 
   if (aBool->value() != myCheckBox->isChecked()) {
     aBool->setValue(myCheckBox->isChecked());
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    updateObject(theObject);
   }
   return true;
 }
index 04f80d8792ac2d21bcbf9e9a36e5dfb658d12610..97782bf745f66a89bcdf735736456c33948d1c9f 100644 (file)
@@ -96,7 +96,7 @@ bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal->value() != mySpinBox->value()) {
     aReal->setValue(mySpinBox->value());
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    updateObject(theObject);
   }
   return true;
 }
index 6d533508eb56a94828efe12ac513237227c76426..b08058a604c24e3c68ecce8bd6a3f18730ae5c7a 100644 (file)
@@ -85,9 +85,6 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
         return false;
     }
   }
-  // TODO
-  //if (!myObjectKinds.contains(theObject->getKind().c_str()))
-  //  return false;
 
   myObject = theObject;
   myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
@@ -107,8 +104,7 @@ bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
   ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
   aRef->setObject(myObject);
   aFeature->execute();
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
+  updateObject(theObject);
   return true;
 }
 
index 633adbc439e22e36df7a632acd878b5fd734b47d..4b456e859a45c5d0541b785e129c2636ce0a6096 100644 (file)
@@ -86,7 +86,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons
     aRef->setAttr(myAttribute);
 
   theFeature->execute();
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  updateObject(theFeature);
 
   return true;
 }
index 9fbc7b7e68ae29462f689255a78ee03e777cd73f..c9c3dd9c77bd4076df0a037ffd4b3827dc648ca2 100644 (file)
@@ -111,7 +111,7 @@ bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
   ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
   bool isBlocked = that->blockSignals(true);
   aPoint->setValue(myXSpin->value(), myYSpin->value());
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  updateObject(theObject);
   that->blockSignals(isBlocked);
 
   return true;
index 1ae894aeb82b5ddd4e5f8a756f0665347d48ed14..9ad17625a7e4e1e346ac286cf97800c690caaa1d 100644 (file)
@@ -111,7 +111,7 @@ bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
   ObjectPtr aObject = aRef->value();
   if (!(aObject && aObject->isSame(mySelectedObject))) {
     aRef->setValue(mySelectedObject);
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    updateObject(theObject);
   }
   return true;
 }
index ba88c8251297c949d651855c5fb487dc3edff51a..1391a0b2fff8eec3bc01716c31a0e37285316bca 100644 (file)
@@ -314,15 +314,6 @@ void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const
       activateFeature(aObject, false);
     }
   }
-  //ObjectPtr aResults;
-  //foreach(ObjectPtr aFeature, theFeatures) {
-/* TODO    if (aFeature->results().size() > 0) {
-      const std::list<ResultPtr>& aResList = aFeature->results();
-      std::list<ResultPtr>::const_iterator aIt;
-      for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt)
-        aResults.append(*aIt);
-    }
-  }*/
   aDisplayer->stopSelection(theFeatures, isStop, false);
 
   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
index d0a76b1cfd6a7d51fb2fdad963c809d051481147..585de840aee202fe281062b81261f5067b1f9002 100644 (file)
@@ -10,6 +10,9 @@
 #include <SketchPlugin_Sketch.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefAttr.h>
+
+#include <GeomAPI_IPresentable.h>
+
 #include <list>
 
 
@@ -34,7 +37,8 @@ const unsigned int CONSTRAINT_ATTR_SIZE = 4;
  *  \brief Feature for creation of a new constraint between other features.
  *         Base class for all constraints.
  */
-class SketchPlugin_Constraint: public SketchPlugin_Feature
+class SketchPlugin_Constraint: public SketchPlugin_Feature, 
+                               public GeomAPI_IPresentable
 {
 public:
   /// The value parameter for the constraint
index a112da05c7394e6d83c5efdaadaf6f01520dd559..3aed4ba9e0fa50600719afe9ca09561005ca458a 100644 (file)
@@ -9,7 +9,6 @@
 #include "SketchPlugin_Constraint.h"
 #include "SketchPlugin_Sketch.h"
 
-#include <GeomAPI_IPresentable.h>
 #include <list>
 
 /** \class SketchPlugin_ConstraintDistance
@@ -20,8 +19,7 @@
  *  These constraint has three attributes:
  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
-class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint, 
-                                       public GeomAPI_IPresentable
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
 {
 public:
   /// Distance constraint kind
index 1a82f07250a180008166d883e1f6adce84140ad7..3c2b146b82be40b3e5b6e7552e4295381bcb980a 100644 (file)
@@ -65,7 +65,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
+  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
   if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
     return thePrevious;
 
index aba3df37071afd63ec6d27605cb2c4a730ac0351..0d73cba025f4cacedbc4ba15403962679b7532d7 100644 (file)
@@ -44,10 +44,19 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
   if (!anAttr1 || !anAttr1->isObject() || 
       !anAttr2 || !anAttr2->isObject())
     return thePrevious;
+
+  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+  if (!aFeature)
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
+  aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+  if (!aFeature)
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
index 3f8281208ac998a224fcb6a31633ef40fe6262b1..0aa05e89d19671b353d466a6b0f3199e40bd8b89 100644 (file)
@@ -44,10 +44,19 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
   if (!anAttr1 || !anAttr1->isObject() || 
       !anAttr2 || !anAttr2->isObject())
     return thePrevious;
+
+  FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+  if (!aFeature)
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
+  aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+  if (!aFeature)
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
index 43fe782d1a7e45b5c58d68c381a9e4fcc72b529f..6082e445bb56df332252a752caa11c14477e13dd 100644 (file)
@@ -540,8 +540,8 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
         if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
           break;
       }
-      Q_ASSERT(aId < aNb);
-      return index(aId + historyOffset(), 0, QModelIndex());
+      if (aId < aNb)
+        return index(aId + historyOffset(), 0, QModelIndex());
     } else {
       QModelIndex aIndex = myModel->objectIndex(theObject);
       return aIndex.isValid()?