From 28d64622a1b933c484fa4a8df26302e1358ba5d0 Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 23 Jun 2015 18:57:34 +0300 Subject: [PATCH] Separate attributes for Extrusion and Revolution features. --- .../FeaturesPlugin_Extrusion.cpp | 35 +++++++---- src/FeaturesPlugin/FeaturesPlugin_Extrusion.h | 14 +++++ .../FeaturesPlugin_ExtrusionBoolean.cpp | 37 ++++++++---- .../FeaturesPlugin_ExtrusionBoolean.h | 32 +++++++--- .../FeaturesPlugin_Revolution.cpp | 33 ++++++---- .../FeaturesPlugin_Revolution.h | 14 +++++ .../FeaturesPlugin_RevolutionBoolean.cpp | 33 ++++++---- .../FeaturesPlugin_RevolutionBoolean.h | 34 +++++++---- src/FeaturesPlugin/extrusion_widget.xml | 18 +++--- src/FeaturesPlugin/extrusioncut_widget.xml | 20 +++---- src/FeaturesPlugin/extrusionfuse_widget.xml | 14 ++--- src/FeaturesPlugin/revolution_widget.xml | 18 +++--- src/FeaturesPlugin/revolutioncut_widget.xml | 14 ++--- src/FeaturesPlugin/revolutionfuse_widget.xml | 12 ++-- .../GeomValidators_ZeroOffset.cpp | 60 ++++++++++++++----- .../GeomValidators_ZeroOffset.h | 2 - 16 files changed, 258 insertions(+), 132 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 31015f839..8775c3ac6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -43,10 +43,13 @@ void FeaturesPlugin_Extrusion::initAttributes() data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); @@ -58,28 +61,36 @@ void FeaturesPlugin_Extrusion::execute() AttributeSelectionListPtr aFaceRefs = selectionList(LIST_ID()); // Getting sizes. - double aFromSize = real(FROM_SIZE_ID())->value(); - double aToSize = real(TO_SIZE_ID())->value(); + double aToSize = 0.0; + double aFromSize = 0.0; + + if(string(CREATION_METHOD())->value() == "BySizes") { + aToSize = real(TO_SIZE_ID())->value(); + aFromSize = real(FROM_SIZE_ID())->value(); + } else { + aToSize = real(TO_OFFSET_ID())->value(); + aFromSize = real(FROM_OFFSET_ID())->value(); + } // Getting bounding planes. - std::shared_ptr aFromShape; std::shared_ptr aToShape; + std::shared_ptr aFromShape; if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") { - std::shared_ptr anObjRef = selection(FROM_OBJECT_ID()); - if(anObjRef.get() != NULL) { - aFromShape = std::dynamic_pointer_cast(anObjRef->value()); - if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { - aFromShape = anObjRef->context()->shape(); - } - } - anObjRef = selection(TO_OBJECT_ID()); + std::shared_ptr anObjRef = selection(TO_OBJECT_ID()); if(anObjRef.get() != NULL) { aToShape = std::dynamic_pointer_cast(anObjRef->value()); if(aToShape.get() == NULL && anObjRef->context().get() != NULL) { aToShape = anObjRef->context()->shape(); } } + anObjRef = selection(FROM_OBJECT_ID()); + if(anObjRef.get() != NULL) { + aFromShape = std::dynamic_pointer_cast(anObjRef->value()); + if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { + aFromShape = anObjRef->context()->shape(); + } + } } // for each selected face generate a result diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index 2d72d49bb..965463691 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -75,6 +75,13 @@ class FeaturesPlugin_Extrusion : public ModelAPI_Feature return MY_TO_OBJECT_ID; } + /// attribute name of extrusion offset + inline static const std::string& TO_OFFSET_ID() + { + static const std::string MY_TO_OFFSET_ID("to_offset"); + return MY_TO_OFFSET_ID; + } + /// attribute name of tool object inline static const std::string& FROM_OBJECT_ID() { @@ -82,6 +89,13 @@ class FeaturesPlugin_Extrusion : public ModelAPI_Feature return MY_FROM_OBJECT_ID; } + /// attribute name of extrusion offset + inline static const std::string& FROM_OFFSET_ID() + { + static const std::string MY_FROM_OFFSET_ID("from_offset"); + return MY_FROM_OFFSET_ID; + } + /// Returns the kind of a feature FEATURESPLUGIN_EXPORT virtual const std::string& getKind() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp index 76bf4d291..2a564e955 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp @@ -19,11 +19,14 @@ void FeaturesPlugin_ExtrusionBoolean::initMakeSolidsAttributes() { data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); + + data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); @@ -33,28 +36,36 @@ void FeaturesPlugin_ExtrusionBoolean::initMakeSolidsAttributes() ListOfShape FeaturesPlugin_ExtrusionBoolean::MakeSolids(const ListOfShape& theFaces) { // Getting extrusion sizes. - double aFromSize = real(FROM_SIZE_ID())->value(); - double aToSize = real(TO_SIZE_ID())->value(); + double aToSize = 0.0; + double aFromSize = 0.0; + + if(string(CREATION_METHOD())->value() == "BySizes") { + aToSize = real(TO_SIZE_ID())->value(); + aFromSize = real(FROM_SIZE_ID())->value(); + } else { + aToSize = real(TO_OFFSET_ID())->value(); + aFromSize = real(FROM_OFFSET_ID())->value(); + } // Getting extrusion bounding planes. - std::shared_ptr aFromShape; std::shared_ptr aToShape; + std::shared_ptr aFromShape; if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") { - std::shared_ptr anObjRef = selection(FROM_OBJECT_ID()); - if(anObjRef.get() != NULL) { - aFromShape = std::dynamic_pointer_cast(anObjRef->value()); - if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { - aFromShape = anObjRef->context()->shape(); - } - } - anObjRef = selection(TO_OBJECT_ID()); + std::shared_ptr anObjRef = selection(TO_OBJECT_ID()); if(anObjRef.get() != NULL) { aToShape = std::dynamic_pointer_cast(anObjRef->value()); if(aToShape.get() == NULL && anObjRef->context().get() != NULL) { aToShape = anObjRef->context()->shape(); } } + anObjRef = selection(FROM_OBJECT_ID()); + if(anObjRef.get() != NULL) { + aFromShape = std::dynamic_pointer_cast(anObjRef->value()); + if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { + aFromShape = anObjRef->context()->shape(); + } + } } // Extrude faces. diff --git a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h index 8fd63449f..f83ec9147 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h @@ -23,14 +23,14 @@ class FeaturesPlugin_ExtrusionBoolean : public FeaturesPlugin_CompositeBoolean return METHOD_ATTR; } - /// Attribute name of an object from which the extrusion grows. - inline static const std::string& FROM_OBJECT_ID() + /// attribute name of extrusion size + inline static const std::string& TO_SIZE_ID() { - static const std::string MY_FROM_OBJECT_ID("from_object"); - return MY_FROM_OBJECT_ID; + static const std::string MY_TO_SIZE_ID("to_size"); + return MY_TO_SIZE_ID; } - /// Attribute name of extrusion from size. + /// attribute name of extrusion size inline static const std::string& FROM_SIZE_ID() { static const std::string MY_FROM_SIZE_ID("from_size"); @@ -44,11 +44,25 @@ class FeaturesPlugin_ExtrusionBoolean : public FeaturesPlugin_CompositeBoolean return MY_TO_OBJECT_ID; } - /// Attribute name of extrusion to size. - inline static const std::string& TO_SIZE_ID() + /// attribute name of extrusion offset + inline static const std::string& TO_OFFSET_ID() { - static const std::string MY_TO_SIZE_ID("to_size"); - return MY_TO_SIZE_ID; + static const std::string MY_TO_OFFSET_ID("to_offset"); + return MY_TO_OFFSET_ID; + } + + /// Attribute name of an object from which the extrusion grows. + inline static const std::string& FROM_OBJECT_ID() + { + static const std::string MY_FROM_OBJECT_ID("from_object"); + return MY_FROM_OBJECT_ID; + } + + /// attribute name of extrusion offset + inline static const std::string& FROM_OFFSET_ID() + { + static const std::string MY_FROM_OFFSET_ID("from_offset"); + return MY_FROM_OFFSET_ID; } protected: diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 4a7795a06..3bd64910c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -41,11 +41,14 @@ void FeaturesPlugin_Revolution::initAttributes() data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + + data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); @@ -70,21 +73,22 @@ void FeaturesPlugin_Revolution::execute() } // Getting angles. - double aFromAngle = real(FROM_ANGLE_ID())->value(); double aToAngle = real(TO_ANGLE_ID())->value(); + double aFromAngle = real(FROM_ANGLE_ID())->value(); + + if(string(CREATION_METHOD())->value() == "ByAngles") { + aToAngle = real(TO_ANGLE_ID())->value(); + aFromAngle = real(FROM_ANGLE_ID())->value(); + } else { + aToAngle = real(TO_OFFSET_ID())->value(); + aFromAngle = real(FROM_OFFSET_ID())->value(); + } // Getting bounding planes. - std::shared_ptr aFromShape; std::shared_ptr aToShape; + std::shared_ptr aFromShape; if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") { - anObjRef = selection(FROM_OBJECT_ID()); - if(anObjRef.get() != NULL) { - aFromShape = std::dynamic_pointer_cast(anObjRef->value()); - if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { - aFromShape = anObjRef->context()->shape(); - } - } anObjRef = selection(TO_OBJECT_ID()); if(anObjRef.get() != NULL) { aToShape = std::dynamic_pointer_cast(anObjRef->value()); @@ -92,6 +96,13 @@ void FeaturesPlugin_Revolution::execute() aToShape = anObjRef->context()->shape(); } } + anObjRef = selection(FROM_OBJECT_ID()); + if(anObjRef.get() != NULL) { + aFromShape = std::dynamic_pointer_cast(anObjRef->value()); + if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { + aFromShape = anObjRef->context()->shape(); + } + } } // for each selected face generate a result diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h index 9edc1dc0e..57150bdf7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h @@ -74,6 +74,13 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature return MY_TO_OBJECT_ID; } + /// attribute name of extrusion offset. + inline static const std::string& TO_OFFSET_ID() + { + static const std::string MY_TO_OFFSET_ID("to_offset"); + return MY_TO_OFFSET_ID; + } + /// Attribute name of tool object. inline static const std::string& FROM_OBJECT_ID() { @@ -81,6 +88,13 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature return MY_FROM_OBJECT_ID; } + /// attribute name of extrusion offset. + inline static const std::string& FROM_OFFSET_ID() + { + static const std::string MY_FROM_OFFSET_ID("from_offset"); + return MY_FROM_OFFSET_ID; + } + /// \return the kind of a feature. FEATURESPLUGIN_EXPORT virtual const std::string& getKind() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp index a5f5140a3..ef3af8ec6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp @@ -23,11 +23,14 @@ void FeaturesPlugin_RevolutionBoolean::initMakeSolidsAttributes() data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + + data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); @@ -50,21 +53,22 @@ ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theF } // Getting revolution angles. - double aFromAngle = real(FROM_ANGLE_ID())->value(); double aToAngle = real(TO_ANGLE_ID())->value(); + double aFromAngle = real(FROM_ANGLE_ID())->value(); + + if(string(CREATION_METHOD())->value() == "ByAngles") { + aToAngle = real(TO_ANGLE_ID())->value(); + aFromAngle = real(FROM_ANGLE_ID())->value(); + } else { + aToAngle = real(TO_OFFSET_ID())->value(); + aFromAngle = real(FROM_OFFSET_ID())->value(); + } // Getting revolution bounding planes. - std::shared_ptr aFromShape; std::shared_ptr aToShape; + std::shared_ptr aFromShape; if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") { - anObjRef = selection(FROM_OBJECT_ID()); - if(anObjRef.get() != NULL) { - aFromShape = std::dynamic_pointer_cast(anObjRef->value()); - if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { - aFromShape = anObjRef->context()->shape(); - } - } anObjRef = selection(TO_OBJECT_ID()); if(anObjRef.get() != NULL) { aToShape = std::dynamic_pointer_cast(anObjRef->value()); @@ -72,6 +76,13 @@ ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theF aToShape = anObjRef->context()->shape(); } } + anObjRef = selection(FROM_OBJECT_ID()); + if(anObjRef.get() != NULL) { + aFromShape = std::dynamic_pointer_cast(anObjRef->value()); + if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) { + aFromShape = anObjRef->context()->shape(); + } + } } // Revol faces. diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h index 354f5badc..3e8576aad 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h @@ -29,11 +29,11 @@ public: return METHOD_ATTR; } - /// Attribute name of an object from which the revolution grows. - inline static const std::string& FROM_OBJECT_ID() + /// Attribute name of revolution to angle. + inline static const std::string& TO_ANGLE_ID() { - static const std::string MY_FROM_OBJECT_ID("from_object"); - return MY_FROM_OBJECT_ID; + static const std::string MY_TO_ANGLE_ID("to_angle"); + return MY_TO_ANGLE_ID; } /// Attribute name of revolution from angle. @@ -42,19 +42,33 @@ public: static const std::string MY_FROM_ANGLE_ID("from_angle"); return MY_FROM_ANGLE_ID; } - - /// attribute name of an object to which the revolution grows. + + /// Attribute name of an object to which the revolution grows. inline static const std::string& TO_OBJECT_ID() { static const std::string MY_TO_OBJECT_ID("to_object"); return MY_TO_OBJECT_ID; } - /// Attribute name of revolution to angle. - inline static const std::string& TO_ANGLE_ID() + /// Attribute name of extrusion offset. + inline static const std::string& TO_OFFSET_ID() { - static const std::string MY_TO_ANGLE_ID("to_angle"); - return MY_TO_ANGLE_ID; + static const std::string MY_TO_OFFSET_ID("to_offset"); + return MY_TO_OFFSET_ID; + } + + /// Attribute name of an object from which the revolution grows. + inline static const std::string& FROM_OBJECT_ID() + { + static const std::string MY_FROM_OBJECT_ID("from_object"); + return MY_FROM_OBJECT_ID; + } + + /// Attribute name of extrusion offset. + inline static const std::string& FROM_OFFSET_ID() + { + static const std::string MY_FROM_OFFSET_ID("from_offset"); + return MY_FROM_OFFSET_ID; } protected: diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 85f3179d3..5e1c3fe8e 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -10,7 +10,7 @@ - + + tooltip="Offset"> @@ -64,16 +64,16 @@ + tooltip="Offset"> - + diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index 4c1a3c256..0b9f14a6e 100755 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -8,14 +8,14 @@ tooltip="Create or edit a sketch"> - + @@ -26,7 +26,7 @@ label="Size" min="0" step="1.0" - default="0" + default="10" icon=":icons/dimension_down.png" tooltip="Size"> @@ -42,12 +42,12 @@ default="<base sketch>"> - + tooltip="Offset"> - + - + tooltip="Offset"> diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index 08a2605f8..70579aa19 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -8,7 +8,7 @@ tooltip="Create or edit a sketch"> - + - + tooltip="Offset"> @@ -57,10 +57,10 @@ default="<base sketch>"> - + tooltip="Offset"> diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index c11aa4c19..47b5ee04e 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -17,7 +17,7 @@ - + + tooltip="Offset"> @@ -71,16 +71,16 @@ + tooltip="Offset"> - + \ No newline at end of file diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml index 6d1683b35..93bfdcf06 100644 --- a/src/FeaturesPlugin/revolutioncut_widget.xml +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -16,14 +16,14 @@ - + @@ -34,7 +34,7 @@ label="Angle" min="0" step="1.0" - default="0" + default="10" icon=":icons/angle_down.png" tooltip="Angle"> @@ -50,10 +50,10 @@ default="<sketch>"> - + tooltip="Offset"> @@ -65,10 +65,10 @@ default="<sketch>"> - + tooltip="Offset"> diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml index a039094de..6bbcd3270 100644 --- a/src/FeaturesPlugin/revolutionfuse_widget.xml +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -16,14 +16,14 @@ - + @@ -50,10 +50,10 @@ default="<sketch>"> - + tooltip="Offset"> @@ -65,10 +65,10 @@ default="<sketch>"> - + tooltip="Offset"> diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index 8c532b0ba..6eb651f57 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -9,29 +9,50 @@ #include #include #include +#include //================================================================================================= bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& theFeature, const std::list& theArguments) const { - if(theArguments.size() < 4) { + if(theArguments.size() != 8) { return false; } std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); - std::shared_ptr aFromShape; - std::shared_ptr aToShape; + std::string aSelectedMethod; + if(theFeature->string(*anIt)) { + aSelectedMethod = theFeature->string(*anIt)->value(); + } + anIt++; + std::string aCreationMethod = *anIt; + anIt++; + + double aToSize = 0.0; + double aFromSize = 0.0; - std::shared_ptr anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { - aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); - if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { - aFromShape = anAttrSel->context()->shape(); - } + if(theFeature->real(*anIt)) { + aToSize = theFeature->real(*anIt)->value(); } anIt++; - anAttrSel = theFeature->selection(*anIt); + if(theFeature->real(*anIt)) { + aFromSize = theFeature->real(*anIt)->value(); + } + anIt++; + + if(aSelectedMethod == aCreationMethod) { + if(aToSize == 0.0 && aFromSize == 0.0) { + return false; + } else { + return true; + } + } + + std::shared_ptr aToShape; + std::shared_ptr aFromShape; + + std::shared_ptr anAttrSel = theFeature->selection(*anIt); if(anAttrSel) { aToShape = std::dynamic_pointer_cast(anAttrSel->value()); if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { @@ -40,21 +61,28 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& } anIt++; - double aFromOffset = 0.0; - double aToOffset = 0.0; - std::shared_ptr anAttrDouble = theFeature->real(*anIt); if(anAttrDouble) { - aFromOffset = anAttrDouble->value(); + aToSize = anAttrDouble->value(); + } + anIt++; + + anAttrSel = theFeature->selection(*anIt); + if(anAttrSel) { + aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); + if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { + aFromShape = anAttrSel->context()->shape(); + } } anIt++; + anAttrDouble = theFeature->real(*anIt); if(anAttrDouble) { - aToOffset = anAttrDouble->value(); + aFromSize = anAttrDouble->value(); } if(((!aFromShape && !aToShape) || ((aFromShape && aToShape) && aFromShape->isEqual(aToShape))) - && (aFromOffset == 0.0 && aToOffset == 0.0)) { + && (aFromSize == 0.0 && aToSize == 0.0)) { return false; } diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.h b/src/GeomValidators/GeomValidators_ZeroOffset.h index b0ce4eb67..d9f7f07af 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.h +++ b/src/GeomValidators/GeomValidators_ZeroOffset.h @@ -21,8 +21,6 @@ public: /** \brief Returns true if feature and/or attributes are valid. * \param[in] theFeature the validated feature. * \param[in] theArguments the arguments in the configuration file for this validator. - * \n First pair of arguments should be bounding planes id. - * \n Second pair of arguments should be offsets id. * \returns true if feature is valid. */ GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, -- 2.39.2