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());
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<GeomAPI_Shape> aFromShape;
std::shared_ptr<GeomAPI_Shape> aToShape;
+ std::shared_ptr<GeomAPI_Shape> aFromShape;
if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
- std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(FROM_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
- if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
- aFromShape = anObjRef->context()->shape();
- }
- }
- anObjRef = selection(TO_OBJECT_ID());
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(TO_OBJECT_ID());
if(anObjRef.get() != NULL) {
aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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<GeomAPI_Shape>(anObjRef->value());
+ if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+ aFromShape = anObjRef->context()->shape();
+ }
+ }
}
// for each selected face generate a result
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()
{
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()
{
{
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());
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<GeomAPI_Shape> aFromShape;
std::shared_ptr<GeomAPI_Shape> aToShape;
+ std::shared_ptr<GeomAPI_Shape> aFromShape;
if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
- std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(FROM_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
- if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
- aFromShape = anObjRef->context()->shape();
- }
- }
- anObjRef = selection(TO_OBJECT_ID());
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(TO_OBJECT_ID());
if(anObjRef.get() != NULL) {
aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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<GeomAPI_Shape>(anObjRef->value());
+ if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+ aFromShape = anObjRef->context()->shape();
+ }
+ }
}
// Extrude faces.
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");
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:
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());
}
// 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<GeomAPI_Shape> aFromShape;
std::shared_ptr<GeomAPI_Shape> aToShape;
+ std::shared_ptr<GeomAPI_Shape> aFromShape;
if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
- anObjRef = selection(FROM_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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<GeomAPI_Shape>(anObjRef->value());
aToShape = anObjRef->context()->shape();
}
}
+ anObjRef = selection(FROM_OBJECT_ID());
+ if(anObjRef.get() != NULL) {
+ aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+ if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+ aFromShape = anObjRef->context()->shape();
+ }
+ }
}
// for each selected face generate a result
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()
{
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()
{
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());
}
// 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<GeomAPI_Shape> aFromShape;
std::shared_ptr<GeomAPI_Shape> aToShape;
+ std::shared_ptr<GeomAPI_Shape> aFromShape;
if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
- anObjRef = selection(FROM_OBJECT_ID());
- if(anObjRef.get() != NULL) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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<GeomAPI_Shape>(anObjRef->value());
aToShape = anObjRef->context()->shape();
}
}
+ anObjRef = selection(FROM_OBJECT_ID());
+ if(anObjRef.get() != NULL) {
+ aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+ if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+ aFromShape = anObjRef->context()->shape();
+ }
+ }
}
// Revol faces.
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.
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:
<validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
</multi_selector>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="BySizes" title="By sizes">
<groupbox>
<doublevalue
id="to_size"
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
<doublevalue
- id="to_size"
- label="Size"
+ id="to_offset"
+ label="Offset"
min="0"
step="1.0"
- default="10"
+ default="0"
icon=":icons/dimension_up.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
</groupbox>
<groupbox title="From">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
<doublevalue
- id="from_size"
- label="Size"
+ id="from_offset"
+ label="Offset"
min="0"
step="1.0"
default="0"
icon=":icons/dimension_down.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
</toolbox>
- <validator id="GeomValidators_ZeroOffset" parameters="from_object,to_object,from_size,to_size"/>
+ <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
</source>
tooltip="Create or edit a sketch">
</sketch_launcher>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="BySizes" title="By sizes">
<groupbox>
<doublevalue
id="to_size"
label="Size"
min="0"
step="1.0"
- default="10"
+ default="0"
icon=":icons/dimension_up.png"
tooltip="Size">
</doublevalue>
label="Size"
min="0"
step="1.0"
- default="0"
+ default="10"
icon=":icons/dimension_down.png"
tooltip="Size">
</doublevalue>
default="<base sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="to_size"
- label="Size" min="0" step="1.0" default="0"
+ <doublevalue id="to_offset"
+ label="Offset" min="0" step="1.0" default="0"
icon=":icons/dimension_up.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
- </groupbox>
+ </groupbox>
<groupbox title="From">
<shape_selector id="from_object"
icon=":icons/plane.png"
default="<base sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="from_size" label="Size"
- min="0" step="1.0" default="10"
+ <doublevalue id="from_offset"
+ label="Offset" min="0" step="1.0" default="0"
icon=":icons/dimension_down.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
tooltip="Create or edit a sketch">
</sketch_launcher>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="BySizes" title="By sizes">
<groupbox>
<doublevalue
id="to_size"
default="<base sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="to_size"
- label="Size" min="0" step="1.0" default="0"
+ <doublevalue id="to_offset"
+ label="Offset" min="0" step="1.0" default="0"
icon=":icons/dimension_up.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
</groupbox>
<groupbox title="From">
default="<base sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="from_size" label="Size"
- min="0" step="1.0" default="10"
+ <doublevalue id="from_offset"
+ label="Offset" min="0" step="1.0" default="0"
icon=":icons/dimension_down.png"
- tooltip="Size">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="ByAngles" title="By angles">
<groupbox>
<doublevalue
id="to_angle"
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
<doublevalue
- id="to_angle"
- label="Angle"
+ id="to_offset"
+ label="Offset"
min="0"
step="1.0"
- default="360"
+ default="0"
icon=":icons/angle_up.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
<groupbox title="From">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
<doublevalue
- id="from_angle"
- label="Angle"
+ id="from_offset"
+ label="Offset"
min="0"
step="1.0"
default="0"
icon=":icons/angle_down.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
</toolbox>
- <validator id="GeomValidators_ZeroOffset" parameters="from_object,to_object,from_angle,to_angle"/>
+ <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
</source>
\ No newline at end of file
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="ByAngles" title="By angles">
<groupbox>
<doublevalue
id="to_angle"
label="Angle"
min="0"
step="1.0"
- default="360"
+ default="0"
icon=":icons/angle_up.png"
tooltip="Angle">
</doublevalue>
label="Angle"
min="0"
step="1.0"
- default="0"
+ default="10"
icon=":icons/angle_down.png"
tooltip="Angle">
</doublevalue>
default="<sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="to_angle" label="Angle"
+ <doublevalue id="to_offset" label="Offset"
min="0" step="1.0" default="0"
icon=":icons/angle_up.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
<groupbox title="From">
default="<sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="from_angle" label="Angle"
+ <doublevalue id="from_offset" label="Offset"
min="0" step="1.0" default="0"
icon=":icons/angle_down.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByOffsets" title="By offsets">
+ <box id="ByAngles" title="By angles">
<groupbox>
<doublevalue
id="to_angle"
label="Angle"
min="0"
step="1.0"
- default="360"
+ default="10"
icon=":icons/angle_up.png"
tooltip="Angle">
</doublevalue>
default="<sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="to_angle" label="Angle"
+ <doublevalue id="to_offset" label="Offset"
min="0" step="1.0" default="0"
icon=":icons/angle_up.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
<groupbox title="From">
default="<sketch>">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
- <doublevalue id="from_angle" label="Angle"
+ <doublevalue id="from_offset" label="Offset"
min="0" step="1.0" default="0"
icon=":icons/angle_down.png"
- tooltip="Angle">
+ tooltip="Offset">
</doublevalue>
</groupbox>
</box>
#include <GeomAPI_Shape.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
//=================================================================================================
bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments) const
{
- if(theArguments.size() < 4) {
+ if(theArguments.size() != 8) {
return false;
}
std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
- std::shared_ptr<GeomAPI_Shape> aFromShape;
- std::shared_ptr<GeomAPI_Shape> 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<ModelAPI_AttributeSelection> anAttrSel = theFeature->selection(*anIt);
- if(anAttrSel) {
- aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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<GeomAPI_Shape> aToShape;
+ std::shared_ptr<GeomAPI_Shape> aFromShape;
+
+ std::shared_ptr<ModelAPI_AttributeSelection> anAttrSel = theFeature->selection(*anIt);
if(anAttrSel) {
aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) {
}
anIt++;
- double aFromOffset = 0.0;
- double aToOffset = 0.0;
-
std::shared_ptr<ModelAPI_AttributeDouble> anAttrDouble = theFeature->real(*anIt);
if(anAttrDouble) {
- aFromOffset = anAttrDouble->value();
+ aToSize = anAttrDouble->value();
+ }
+ anIt++;
+
+ anAttrSel = theFeature->selection(*anIt);
+ if(anAttrSel) {
+ aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(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;
}
/** \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<ModelAPI_Feature>& theFeature,