if (aMessage.get()) {
ModuleBase_IPropertyPanel* aPanel = workshop()->propertyPanel();
std::string aPrevAttribute = aReentrantFeature->processEvent(aMessage);
- workshop()->errorMgr()->updateActions(aFeature);
-
- ModuleBase_ModelWidget* aPrevWidget = aPanel->modelWidget(aPrevAttribute);
- aPanel->activateNextWidget(aPrevWidget);
+ if (!aPrevAttribute.empty()) {
+ workshop()->errorMgr()->updateActions(aFeature);
+ ModuleBase_ModelWidget* aPrevWidget = aPanel->modelWidget(aPrevAttribute);
+ aPanel->activateNextWidget(aPrevWidget);
+ }
}
}
}
ModuleBase_IPropertyPanel* aPanel = myWorkshop->currentOperation()->propertyPanel();
FeaturePtr aCurrentFeature = aFOperation->feature();
- bool isLineFeature = false, isArcFeature = false;
+ bool isLineFeature = false, isReentrantArcFeature = false;
std::string anAttributeOnStart;
if (aCurrentFeature->getKind() == SketchPlugin_Line::ID()) {
anAttributeOnStart = SketchPlugin_Line::START_ID();
isLineFeature = anActiveWidget->attributeID() == anAttributeOnStart;
}
else if (isTangentArc(aFOperation, module()->sketchMgr()->activeSketch())) {
- anAttributeOnStart = SketchPlugin_MacroArc::TANGENT_POINT_ID();
- isArcFeature = anActiveWidget->attributeID() == anAttributeOnStart;
+ isReentrantArcFeature = true;
}
- bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
+ bool aCanBeActivatedByMove = isLineFeature || isReentrantArcFeature;
if (aCanBeActivatedByMove) {
/// before restarting of operation we need to clear selection, as it may take part in
/// new feature creation, e.g. tangent arc. But it is not necessary as it was processed
AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
if (aNewFeatureTypeAttr->value() != aTypeAttributeId) // do nothing if there is no changes
aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
- //ModuleBase_Tools::flushUpdated(theNewFeature);
- aChanged = true;*/
+ //ModuleBase_Tools::flushUpdated(theNewFeature);*/
+ //aChanged = true;
}
else if (aFeatureKind == SketchPlugin_MacroArc::ID()) {
// set arc type
- std::string aTypeAttributeId = SketchPlugin_MacroArc::ARC_TYPE();
+ /*std::string aTypeAttributeId = SketchPlugin_MacroArc::ARC_TYPE();
AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
if (aNewFeatureTypeAttr->value() != aTypeAttributeId) // do nothing if there is no changes
- aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
+ aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());*/
//// if the arc is tangent, set coincidence to end point of the previous arc
//std::string anArcType = aSourceFeatureTypeAttr->value();
//if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
//}
//ModuleBase_Tools::flushUpdated(theNewFeature);
- aChanged = true;
+ //aChanged = true;
}
else if (aFeatureKind == SketchPlugin_Trim::ID()) {
/*std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
theNewFeature->data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
aNRefSelectedAttr->setValue(aRefSelectedAttr->value());*/
- std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
+ /*std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
theSourceFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
std::shared_ptr<ModelAPI_AttributeReference> aNRefPreviewAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
theNewFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
- aNRefPreviewAttr->setValue(aRefPreviewAttr->value());
+ aNRefPreviewAttr->setValue(aRefPreviewAttr->value());*/
/*std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
theNewFeature->data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
aNPointSelectedAttr->setValue(aPointSelectedAttr->x(), aPointSelectedAttr->y());
*/
- std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
+ /*std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
theSourceFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
std::shared_ptr<GeomDataAPI_Point2D> aNPointPreviewAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
theNewFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
aNPointPreviewAttr->setValue(aPointPreviewAttr->x(), aPointPreviewAttr->y());
-
- aChanged = true;
+ */
+ //aChanged = true;
}
return aChanged;
}
#endif
SketchPlugin_Sketch* aSketch = sketch();
- if (!aSketch)
+ if (!aSketch) {
+ setError("Error: Sketch object is empty.");
return;
+ }
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
return;
}
ObjectPtr aBaseObject = aBaseObjectAttr->value();
- if (!aBaseObject.get())
+ if (!aBaseObject.get()) {
+ setError("Error: Base object is not initialized.");
return;
+ }
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
/// Remove reference of this feature to feature used in preview, it is not necessary anymore
#ifdef DEBUG_TRIM_METHODS
std::cout << "SketchPlugin_Trim::processEvent:" << data()->name() << std::endl;
#endif
-
std::string aFilledAttributeName;
std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage =
std::shared_ptr<GeomAPI_Pnt2d> aPoint = aMessage->clickedPoint();
if (anObject.get() && aPoint.get()) {
- std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
- std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
- aRefSelectedAttr->setValue(anObject);
- aRefPreviewAttr->setValue(anObject);
-
- std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
- std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
- aPointSelectedAttr->setValue(aPoint);
- aPointPreviewAttr->setValue(aPoint);
-
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
- GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
-#ifdef DEBUG_TRIM_METHODS
- if (!aSelectedShape.get())
- std::cout << "Set empty selected object" << std::endl;
- else
- std::cout << "Set shape with ShapeType: " << aSelectedShape->shapeTypeStr() << std::endl;
-#endif
- aFilledAttributeName = SketchPlugin_Trim::SELECTED_OBJECT();
+ if (myCashedShapes.find(anObject) == myCashedShapes.end())
+ fillObjectShapes(anObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
+ const std::set<GeomShapePtr>& aShapes = myCashedShapes[anObject];
+ if (aShapes.size() > 1) {
+ std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
+ std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+ aRefSelectedAttr->setValue(anObject);
+ aRefPreviewAttr->setValue(anObject);
+
+ std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
+ std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+ aPointSelectedAttr->setValue(aPoint);
+ aPointPreviewAttr->setValue(aPoint);
+
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+
+ GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
+ #ifdef DEBUG_TRIM_METHODS
+ if (!aSelectedShape.get())
+ std::cout << "Set empty selected object" << std::endl;
+ else
+ std::cout << "Set shape with ShapeType: " << aSelectedShape->shapeTypeStr() << std::endl;
+ #endif
+ aFilledAttributeName = SketchPlugin_Trim::SELECTED_OBJECT();
+ }
}
}
return aFilledAttributeName;