data()->addAttribute(SKETCH_SELECTION_ID(), ModelAPI_AttributeSelection::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SKETCH_SELECTION_ID());
- initMakeSolidsAttributes();
+ //initMakeSolidsAttributes();
}
//=================================================================================================
//=================================================================================================
void FeaturesPlugin_CompositeSketch::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
{
+ AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
+ if (aFacesSelectionList.get() && aFacesSelectionList->size() > 0)
+ aFacesSelectionList->clear();
}
//=================================================================================================
}
}
}
+//=================================================================================================
+void FeaturesPlugin_CompositeSketch::setSketchObjectToList()
+{
+ std::shared_ptr<ModelAPI_Feature> aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
+ reference(SKETCH_OBJECT_ID())->value());
+
+ if(aSketchFeature.get() && !aSketchFeature->results().empty()) {
+ ResultPtr aSketchRes = aSketchFeature->results().front();
+ ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
+ if(aConstruction.get()) {
+ AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
+ if (aFacesSelectionList.get() && aFacesSelectionList->size() == 0)
+ aFacesSelectionList->append(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
+ }
+ }
+}
+
return MY_SKETCH_SELECTION_ID;
}
+ /// attribute name of references sketch entities list, it should contain a sketch result or
+ /// a pair a sketch result to sketch face
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("base");
+ return MY_GROUP_LIST_ID;
+ }
+
/// Creates a new part document if needed.
FEATURESPLUGIN_EXPORT virtual void execute();
FeaturesPlugin_CompositeSketch(){};
/// Define this function to init attributes for extrusion/revolution.
- virtual void initMakeSolidsAttributes() = 0;
+ //virtual void initMakeSolidsAttributes() {};
/// Define this function to create solids from faces with extrusion/revolution.
virtual void makeSolid(const std::shared_ptr<GeomAPI_Shape> theFace,
- std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape) = 0;
+ std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape) {};
/// Results naming.
void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape);
+
+ /// Set the sub-object to list of exturusion base.
+ void setSketchObjectToList();
+
};
#endif
//=================================================================================================
void FeaturesPlugin_Extrusion::execute()
{
- /// feature extrusion does not have the next attribute
+ /// sub feature of the composite should be set in the base list
AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
if (aFacesSelectionList.get() && !aFacesSelectionList->isInitialized()) {
AttributeReferencePtr aSketchAttr = reference(SKETCH_OBJECT_ID());
removeResults(aResultIndex);
}
-//=================================================================================================
-void FeaturesPlugin_Extrusion::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
-{
- AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
- if (aFacesSelectionList.get() && aFacesSelectionList->size() > 0)
- aFacesSelectionList->clear();
-}
-
//=================================================================================================
void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
}
}
-//=================================================================================================
-void FeaturesPlugin_Extrusion::setSketchObjectToList()
-{
- std::shared_ptr<ModelAPI_Feature> aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
- reference(SKETCH_OBJECT_ID())->value());
-
- if(aSketchFeature.get() && !aSketchFeature->results().empty()) {
- ResultPtr aSketchRes = aSketchFeature->results().front();
- ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
- if(aConstruction.get()) {
- AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
- if (aFacesSelectionList.get() && aFacesSelectionList->size() == 0)
- aFacesSelectionList->append(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
- }
- }
-}
-
static const std::string MY_EXTRUSION_ID("Extrusion");
return MY_EXTRUSION_ID;
}
- /// attribute name of references sketch entities list, it should contain a sketch result or
- /// a pair a sketch result to sketch face
- inline static const std::string& LIST_ID()
- {
- static const std::string MY_GROUP_LIST_ID("base");
- return MY_GROUP_LIST_ID;
- }
/// attribute name of an object to which the extrusion grows
inline static const std::string& AXIS_OBJECT_ID()
/// Request for initialization of data model of the feature: adding all attributes
FEATURESPLUGIN_EXPORT virtual void initAttributes();
- /// This method to inform that sub-feature is removed and must be removed from the internal data
- /// structures of the owner (the remove from the document will be done outside just after)
- FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
-
/// Use plugin manager for features creation
FeaturesPlugin_Extrusion();
-protected:
- /// Init attributes for extrusion.
- virtual void initMakeSolidsAttributes() {};
-
- /// Create solid from face with extrusion.
- virtual void makeSolid(const std::shared_ptr<GeomAPI_Shape> theFace,
- std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape) {};
-
private:
/// Load Naming data structure of the feature to the document
void loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBasis);
-
- /// Set the sub-object to list of exturusion base.
- void setSketchObjectToList();
};
#endif
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_BodyBuilder.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
+
+ // Composite Sketch attribute
+ data()->addAttribute(FeaturesPlugin_CompositeSketch::SKETCH_OBJECT_ID(),
+ ModelAPI_AttributeReference::typeId());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
+ FeaturesPlugin_CompositeSketch::SKETCH_OBJECT_ID());
}
//=================================================================================================
void FeaturesPlugin_Revolution::execute()
{
+ /// sub feature of the composite should be set in the base list
+ AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
+ if (aFacesSelectionList.get() && !aFacesSelectionList->isInitialized()) {
+ AttributeReferencePtr aSketchAttr = reference(SKETCH_OBJECT_ID());
+ if (aSketchAttr.get() && aSketchAttr->isInitialized())
+ setSketchObjectToList();
+ }
+
// Getting faces.
ListOfShape aFacesList;
- AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
+ aFacesSelectionList = selectionList(LIST_ID());
for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) {
AttributeSelectionPtr aFaceSel = aFacesSelectionList->value(anIndex);
std::shared_ptr<GeomAPI_Shape> aFaceShape = aFaceSel->value();
#include <FeaturesPlugin.h>
#include <GeomAlgoAPI_Revolution.h>
-#include <ModelAPI_Feature.h>
+#include <FeaturesPlugin_CompositeSketch.h>
class GeomAPI_Shape;
class ModelAPI_ResultBody;
* Revolution creates the lateral faces based on edges of the base face and
* the start and end faces and/or start and end angles.
*/
-class FeaturesPlugin_Revolution : public ModelAPI_Feature
+class FeaturesPlugin_Revolution : public FeaturesPlugin_CompositeSketch
{
public:
/// Revolution kind.
return MY_REVOLUTION_ID;
}
- /// Attribute name of references sketch entities list, it should contain a sketch result or
- /// a pair a sketch result to sketch face.
- inline static const std::string& LIST_ID()
- {
- static const std::string MY_GROUP_LIST_ID("base");
- return MY_GROUP_LIST_ID;
- }
-
/// Attribute name of an revolution axis.
inline static const std::string& AXIS_OBJECT_ID()
{
<source>
<groupbox title="Extrusion">
<sketch_launcher id="sketch"
- label="Sketch"
- icon=":icons/sketch.png"
- tooltip="Create or edit a sketch">
+ attribute_list_id="base"
+ label="Select:<br />
+1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
+2. An existing sketch face or contour. Extrusion will be filled by it.<br />
+3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it."
+ shape_types="face objects">
</sketch_launcher>
+ <composite_multi_selector id="base"
+ label="Select a sketch face"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch face"
+ type_choice="Faces Objects">
+ <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+ </composite_multi_selector>
<toolbox id="CreationMethod">
<box id="BySizes" title="By sizes" icon=":icons/dimension_up_down_32x32.png">
<groupbox>
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
+ <sketch_launcher id="sketch"
+ attribute_list_id="base"
+ label="Select:<br />
+1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
+2. An existing sketch face or contour. Extrusion will be filled by it.<br />
+3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it."
+ shape_types="face objects">
+ </sketch_launcher>
+ <composite_multi_selector id="base"
+ label="Select a sketch face"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch face"
+ type_choice="Faces Objects">
+ <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+ </composite_multi_selector>
<toolbox id="CreationMethod">
<box id="ByAngles" title="By angles" icon=":icons/angle_up_down_32x32.png">
<multi_selector id="base"
<source>
<groupbox title="Revolution">
<sketch_launcher id="sketch"
- label="Sketch"
- icon=":icons/sketch.png"
- tooltip="Create or edit a sketch">
+ attribute_list_id="base"
+ label="Select:<br />
+1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
+2. An existing sketch face or contour. Extrusion will be filled by it.<br />
+3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it."
+ shape_types="face objects">
</sketch_launcher>
+ <composite_multi_selector id="base"
+ label="Select a sketch face"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch face"
+ type_choice="Faces Objects">
+ <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+ </composite_multi_selector>
<toolbox id="CreationMethod">
<box id="ByAngles" title="By angles" icon=":icons/angle_up_down_32x32.png">
<shape_selector id="axis_object"
<source>
<groupbox title="Revolution">
<sketch_launcher id="sketch"
- label="Sketch"
- icon=":icons/sketch.png"
- tooltip="Create or edit a sketch">
+ attribute_list_id="base"
+ label="Select:<br />
+1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br />
+2. An existing sketch face or contour. Extrusion will be filled by it.<br />
+3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it."
+ shape_types="face objects">
</sketch_launcher>
+ <composite_multi_selector id="base"
+ label="Select a sketch face"
+ icon=":icons/sketch.png"
+ tooltip="Select a sketch face"
+ type_choice="Faces Objects">
+ <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+ </composite_multi_selector>
<toolbox id="CreationMethod">
<box id="ByAngles" title="By angles" icon=":icons/angle_up_down_32x32.png">
<shape_selector id="axis_object"