From: vsv Date: Fri, 25 Jul 2014 14:03:55 +0000 (+0400) Subject: Fix sketcher bugs X-Git-Tag: V_0.4.4~145 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=625280d2a73437339d19053ee7d0712ae976ef3e;p=modules%2Fshaper.git Fix sketcher bugs --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 756451c29..86a8a8e0f 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -6,9 +6,12 @@ #include #include +#include #include "Config_WidgetAPI.h" +#include + #include 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); +} diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 45c5789a5..de0548b3d 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -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: diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 1c3b68d1d..c77ecad44 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 04f80d879..97782bf74 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 6d533508e..b08058a60 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 633adbc43..4b456e859 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 9fbc7b7e6..c9c3dd9c7 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -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; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 1ae894aeb..9ad17625a 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -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; } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ba88c8251..1391a0b2f 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -314,15 +314,6 @@ void PartSet_Module::onStopSelection(const QList& theFeatures, const activateFeature(aObject, false); } } - //ObjectPtr aResults; - //foreach(ObjectPtr aFeature, theFeatures) { -/* TODO if (aFeature->results().size() > 0) { - const std::list& aResList = aFeature->results(); - std::list::const_iterator aIt; - for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) - aResults.append(*aIt); - } - }*/ aDisplayer->stopSelection(theFeatures, isStop, false); XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index d0a76b1cf..585de840a 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -10,6 +10,9 @@ #include #include #include + +#include + #include @@ -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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index a112da05c..3aed4ba9e 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -9,7 +9,6 @@ #include "SketchPlugin_Constraint.h" #include "SketchPlugin_Sketch.h" -#include #include /** \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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 1a82f0725..3c2b146b8 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -65,7 +65,7 @@ boost::shared_ptr SketchPlugin_ConstraintLength::getAISObject boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); if (!anAttr) return thePrevious; - FeaturePtr aFeature = boost::dynamic_pointer_cast(anAttr->object()); + FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object()); if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID()) return thePrevious; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index aba3df370..0d73cba02 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -44,10 +44,19 @@ boost::shared_ptr 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 aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->object()); + boost::dynamic_pointer_cast(aFeature); + + aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object()); + if (!aFeature) + return thePrevious; boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->object()); + boost::dynamic_pointer_cast(aFeature); + if (!aLine1Feature || !aLine2Feature) return thePrevious; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index 3f8281208..0aa05e89d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -44,10 +44,19 @@ boost::shared_ptr 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 aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->object()); + boost::dynamic_pointer_cast(aFeature); + + aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object()); + if (!aFeature) + return thePrevious; boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->object()); + boost::dynamic_pointer_cast(aFeature); + if (!aLine1Feature || !aLine2Feature) return thePrevious; diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 43fe782d1..6082e445b 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -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()?