From: nds Date: Wed, 15 Apr 2015 07:42:45 +0000 (+0300) Subject: Fillet visualization problem: the first visualization is not correct. X-Git-Tag: V_1.1.0~30^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b2fd5369b5567e04a61aaa861237876501dc5c49;p=modules%2Fshaper.git Fillet visualization problem: the first visualization is not correct. The model correction to use the up-to-date number of composite features(it is increased by fillet execution) Sketch manager should not filter the features and results, which are not related to the operation feature (fillet arc, coincidents, radius). Constraint fillet is corrected: setInitialized() for a list attribute is not correct because currently the list combine this condition with a list size. The recalculate of the center of an arc is not necessary because it happens in earlier code(azv) --- diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index f1b4f50ff..653860b6b 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -221,8 +221,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(theFeature); if (aComposite) { - int aSubsNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubsNum; a++) { + // number of subs can be changed in execution: like fillet + for(int a = 0; a < aComposite->numberOfSubs(); a++) { if (updateFeature(aComposite->subFeature(a))) aMustbeUpdated = true; } @@ -290,8 +290,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) // for sketch after update of plane (by update of selection attribute) // but before execute, all sub-elements also must be updated (due to the plane changes) if (aComposite) { - int aSubsNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubsNum; a++) { + // number of subs can be changed in execution: like fillet + for(int a = 0; a < aComposite->numberOfSubs(); a++) { FeaturePtr aSub = aComposite->subFeature(a); bool aWasModified = myUpdated[aSub]; myUpdated.erase(myUpdated.find(aSub)); // erase to update for sure (plane may be changed) @@ -301,7 +301,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) } // re-execute after update: solver may update the previous values, so, shapes must be // updated - for(int a = 0; a < aSubsNum; a++) { + for(int a = 0; a < aComposite->numberOfSubs(); a++) { if (aComposite->subFeature(a) && aFactory->validate(aComposite->subFeature(a))) aComposite->subFeature(a)->execute(); } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 6639a548a..03569839c 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -8,6 +8,10 @@ #include #include +#include +#include + +#include #include #include @@ -109,7 +113,7 @@ void setSpinValue(QDoubleSpinBox* theSpin, double theValue) theSpin->blockSignals(isBlocked); } -QString objectInfo(const ObjectPtr& theObj) +QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { ResultPtr aRes = std::dynamic_pointer_cast(theObj); FeaturePtr aFeature = std::dynamic_pointer_cast(theObj); @@ -121,8 +125,32 @@ QString objectInfo(const ObjectPtr& theObj) if (aFeature.get()) { aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str()); if (aFeature->data().get() && aFeature->data()->isValid()) - aFeatureStr.append(QString("(name=%1)").arg(aFeature->data()->name().c_str()).toStdString().c_str()); + aFeatureStr.append(QString(", name=%1").arg(aFeature->data()->name().c_str()).toStdString() + .c_str()); + if (isUseAttributesInfo) { + std::list anAttrs = aFeature->data()->attributes(""); + std::list::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end(); + QStringList aValues; + for(; anIt != aLast; anIt++) { + AttributePtr anAttr = *anIt; + QString aValue = "not defined"; + std::string aType = anAttr->attributeType(); + if (aType == GeomDataAPI_Point2D::typeId()) { + std::shared_ptr aPoint = std::dynamic_pointer_cast( + anAttr); + if (aPoint.get()) + aValue = QString("(%1, %2)").arg(aPoint->x()).arg(aPoint->y()); + } + else if (aType == ModelAPI_AttributeRefAttr::typeId()) { + } + + aValues.push_back(QString("%1: %2").arg(anAttr->id().c_str()).arg(aValue).toStdString().c_str()); + } + if (!aValues.empty()) + aFeatureStr.append(QString(", attributes: %1").arg(aValues.join(", ").toStdString().c_str())); + } } + return aFeatureStr; } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index c54c5441e..3c9006d9a 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -61,8 +61,9 @@ MODULEBASE_EXPORT void setSpinValue(QDoubleSpinBox* theSpin, double theValue); /// Converts the object to the feature or a result and generate information string /// \param theObj an object +/// \param isUseAttributesInfo a flag whether the attribute values information is used /// \return a string -MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj); +MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false); } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 9c1c1be0b..2ed91dd5e 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -796,7 +796,7 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const aCanDisplay = false; } else { // there are no an active sketch - // 2. sketch sub-features should not visualized if the sketch operation is not active + // 2. sketch sub-features should not be visualized if the sketch operation is not active FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); if (aFeature.get() != NULL) { std::shared_ptr aSketchFeature = @@ -806,7 +806,28 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const } } - // 3. For created nested feature operation do not display the created feature if + // 3. the method should not filter the objects, which are not related to the current operation. + // The object is filtered just if it is a current operation feature or this feature result + bool isObjectFound = false; + ModuleBase_Operation* anOperation = getCurrentOperation(); + if (anOperation) { + FeaturePtr aFeature = anOperation->feature(); + if (aFeature.get()) { + std::list aResults = aFeature->results(); + if (theObject == aFeature) + isObjectFound = true; + else { + std::list::const_iterator anIt = aResults.begin(), aLast = aResults.end(); + for (; anIt != aLast; anIt++) { + isObjectFound = *anIt == theObject; + } + } + } + } + if (!isObjectFound) + return aCanDisplay; + + // 4. For created nested feature operation do not display the created feature if // the mouse curstor leaves the OCC window. // The correction cases, which ignores this condition: // a. the property panel values modification diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 7d8e142bc..5f23e1e88 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -49,13 +50,19 @@ void SketchPlugin_ConstraintFillet::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(PREVIOUS_VALUE, ModelAPI_AttributeDouble::typeId()); // initialize attribute not applicable for user - data()->attribute(SketchPlugin_Constraint::ENTITY_C())->setInitialized(); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C()); data()->attribute(PREVIOUS_VALUE)->setInitialized(); std::dynamic_pointer_cast(data()->attribute(PREVIOUS_VALUE))->setValue(0.0); } void SketchPlugin_ConstraintFillet::execute() { + // the viewer update should be blocked in order to avoid the temporaty fillet sub-features visualization + // before they are processed by the solver + //std::shared_ptr aMsg = std::shared_ptr( + // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED))); + //Events_Loop::loop()->send(aMsg); + std::shared_ptr aData = data(); ResultConstructionPtr aRC; // Check the base objects are initialized @@ -221,7 +228,6 @@ void SketchPlugin_ConstraintFillet::execute() aNewArc->execute(); // attach new arc to the list aRefListOfFillet->append(aNewArc->lastResult()); - aRefListOfFillet->setInitialized(); // Create list of additional constraints: // 1. Coincidence of boundary points of features and fillet arc @@ -251,15 +257,6 @@ void SketchPlugin_ConstraintFillet::execute() recalculateAttributes(aNewArc, SketchPlugin_Arc::END_ID(), aFeature[aFeatInd], aFeatAttributes[anAttrInd]); aConstraint->execute(); ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); - // recalculate center of fillet arc - std::shared_ptr aStartPoint = std::dynamic_pointer_cast( - aNewArc->attribute(SketchPlugin_Arc::START_ID()))->pnt(); - std::shared_ptr aEndPoint = std::dynamic_pointer_cast( - aNewArc->attribute(SketchPlugin_Arc::END_ID()))->pnt(); - aCenter = aStartPoint->xy()->added(aEndPoint->xy())->multiplied(0.5); - std::dynamic_pointer_cast( - aNewArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue( - aCenter->x(), aCenter->y()); // 2. Fillet arc radius aConstraint = sketch()->addFeature(SketchPlugin_ConstraintRadius::ID()); aRefAttr = std::dynamic_pointer_cast( @@ -285,19 +282,19 @@ void SketchPlugin_ConstraintFillet::execute() aConstraint->execute(); ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); } - // make base features auxiliary - static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); aFeatureA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true); aFeatureB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(true); - ModelAPI_EventCreator::get()->sendUpdated(aFeatureA, aRedisplayEvent); - ModelAPI_EventCreator::get()->sendUpdated(aFeatureB, aRedisplayEvent); -//// Events_Loop::loop()->flush(aRedisplayEvent); - // send events + // send events to update the sub-features by the solver if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, true); - Events_Loop::loop()->flush(anUpdateEvent); + + // the viewer update should be unblocked in order after the fillet features + // are processed by the solver + //aMsg = std::shared_ptr( + // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); + //Events_Loop::loop()->send(aMsg); } AISObjectPtr SketchPlugin_ConstraintFillet::getAISObject(AISObjectPtr thePrevious)