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)
CompositeFeaturePtr aComposite =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(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;
}
// 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)
}
// 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();
}
#include <ModelAPI_Result.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeRefAttr.h>
+
+#include <GeomDataAPI_Point2D.h>
#include <QWidget>
#include <QLayout>
theSpin->blockSignals(isBlocked);
}
-QString objectInfo(const ObjectPtr& theObj)
+QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
{
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(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<AttributePtr> anAttrs = aFeature->data()->attributes("");
+ std::list<AttributePtr>::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<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ 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;
}
/// 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);
}
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<SketchPlugin_Feature> aSketchFeature =
}
}
- // 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<ResultPtr> aResults = aFeature->results();
+ if (theObject == aFeature)
+ isObjectFound = true;
+ else {
+ std::list<ResultPtr>::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
#include <ModelAPI_Events.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Line.h>
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<ModelAPI_AttributeDouble>(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<Events_Message> aMsg = std::shared_ptr<Events_Message>(
+ // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
+ //Events_Loop::loop()->send(aMsg);
+
std::shared_ptr<ModelAPI_Data> aData = data();
ResultConstructionPtr aRC;
// Check the base objects are initialized
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
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<GeomAPI_Pnt2d> aStartPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aNewArc->attribute(SketchPlugin_Arc::START_ID()))->pnt();
- std::shared_ptr<GeomAPI_Pnt2d> aEndPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aNewArc->attribute(SketchPlugin_Arc::END_ID()))->pnt();
- aCenter = aStartPoint->xy()->added(aEndPoint->xy())->multiplied(0.5);
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- 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<ModelAPI_AttributeRefAttr>(
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<Events_Message>(
+ // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
+ //Events_Loop::loop()->send(aMsg);
}
AISObjectPtr SketchPlugin_ConstraintFillet::getAISObject(AISObjectPtr thePrevious)