From: vsv Date: Thu, 24 Jul 2014 15:41:20 +0000 (+0400) Subject: Bug fixing for constraints X-Git-Tag: V_0.4.4~151 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a098c6dac2e5b8316012631ace0b692e6ca60874;p=modules%2Fshaper.git Bug fixing for constraints --- diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 0387105b7..f3a657548 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -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 aResults = aFeature->results(); std::list::const_iterator aIt; for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { - if ((*aIt).get() == theObj.get()) + if ((*aIt) == theObj) return true; } } diff --git a/src/ModuleBase/ModuleBase_ResultValidators.cpp b/src/ModuleBase/ModuleBase_ResultValidators.cpp index 631857d15..548fc549c 100644 --- a/src/ModuleBase/ModuleBase_ResultValidators.cpp +++ b/src/ModuleBase/ModuleBase_ResultValidators.cpp @@ -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; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index fe1faa56d..b46cf9096 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -104,7 +104,7 @@ boost::shared_ptr getFeaturePoint(DataPtr theData, boost::shared_ptr anAttr = boost::dynamic_pointer_cast(theData->attribute(theAttribute)); if (anAttr) - aFeature = boost::dynamic_pointer_cast(anAttr->object()); + aFeature = SketchPlugin_Sketch::getFeature(anAttr->object()); if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) aPointAttr = boost::dynamic_pointer_cast diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 456ff0569..a112da05c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -7,7 +7,9 @@ #include "SketchPlugin.h" #include "SketchPlugin_Constraint.h" -#include +#include "SketchPlugin_Sketch.h" + +#include #include /** \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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index f21aa9979..1a82f0725 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -9,12 +9,15 @@ #include #include +#include #include #include #include + + SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength() { } @@ -33,7 +36,7 @@ void SketchPlugin_ConstraintLength::execute() boost::shared_ptr aRef = boost::dynamic_pointer_cast(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 aPoint1 = diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 9cd5ccff4..76e48e076 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -159,3 +159,17 @@ boost::shared_ptr SketchPlugin_Sketch:: } return boost::shared_ptr(); } + +FeaturePtr SketchPlugin_Sketch::getFeature(ObjectPtr theObject) +{ + FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); + if (!aFeature) { + ResultPtr aResult = boost::dynamic_pointer_cast(theObject); + if (aResult) { + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + DocumentPtr aDoc = aMgr->rootDocument(); + return aDoc->feature(aResult); + } + } + return aFeature; +} \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 8a1d22db4..374f8a9e1 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -96,6 +96,8 @@ public: virtual boost::shared_ptr getAISObject( boost::shared_ptr thePrevious); + static FeaturePtr getFeature(ObjectPtr theObject); + protected: /// Creates a plane and append it to the list /// \param theX the X normal value diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 27eee7470..9080ebfaa 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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 aActions = getModuleCommands(); foreach(QAction* aAction, aActions) {