return;
}
- if (!selection(SKETCH_SELECTION_ID())->isInitialized() || selection(SKETCH_SELECTION_ID())->context() != aSketchRes) {
- selection(SKETCH_SELECTION_ID())->setValue(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
+ /// feature extrusion does not have the next attribute
+ if (data()->attribute(SKETCH_SELECTION_ID()).get()) {
+ if (!selection(SKETCH_SELECTION_ID())->isInitialized() || selection(SKETCH_SELECTION_ID())->context() != aSketchRes) {
+ selection(SKETCH_SELECTION_ID())->setValue(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
+ }
}
int aSketchFacesNum = aConstruction->facesNum();
if(aSketchFacesNum == 0) {
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeReference.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Prism.h>
LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
// extrusion works with faces always
aSelection->setSelectionType("FACE");
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
+ FeaturesPlugin_Extrusion::LIST_ID());
+
data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
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_Extrusion::execute()
{
+ /// feature extrusion does not have the next attribute
+ 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());
+ //AttributeSelectionListPtr 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();
theResultBody->generated(aFromFace, aStr.str(), aFromTag++);
}
}
+
+//=================================================================================================
+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>());
+ }
+ }
+}
#define FeaturesPlugin_Extrusion_H_
#include <FeaturesPlugin.h>
-#include <ModelAPI_Feature.h>
#include <GeomAlgoAPI_Prism.h>
+#include <FeaturesPlugin_CompositeSketch.h>
+
class GeomAPI_Shape;
class ModelAPI_ResultBody;
* bounding planes if they were set. Direction of extrusion is taken from the face
* plane or if the bounding faces were set then it will be from the bottom to the top plane.
*/
-class FeaturesPlugin_Extrusion : public ModelAPI_Feature
+class FeaturesPlugin_Extrusion : public FeaturesPlugin_CompositeSketch
{
public:
/// Extrusion kind
/// 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
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
+ <sketch_launcher id="sketch"
+ label="Sketch"
+ icon=":icons/sketch.png"
+ use_body="false"
+ tooltip="Create or edit a sketch">
+ </sketch_launcher>
<toolbox id="CreationMethod">
<box id="BySizes" title="By sizes" icon=":icons/dimension_up_down_32x32.png">
- <multi_selector id="base"
+ <composite_multi_selector id="base"
label="Select a sketch face"
icon=":icons/sketch.png"
tooltip="Select a sketch face"
type_choice="Faces">
<validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
- </multi_selector>
+ </composite_multi_selector>
<groupbox>
<doublevalue
id="to_size"
</groupbox>
</box>
<box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted_32x32.png">
- <multi_selector id="base"
+ <composite_multi_selector id="base"
label="Select a sketch face"
icon=":icons/sketch.png"
tooltip="Select a sketch face"
type_choice="Faces">
<validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
- </multi_selector>
+ </composite_multi_selector>
<groupbox title="From">
<shape_selector id="from_object"
icon=":icons/plane.png"
PartSet_WidgetPoint2d.h
PartSet_WidgetEditor.h
PartSet_WidgetMultiSelector.h
+ PartSet_WidgetMultiSelectorComposite.h
PartSet_WidgetPoint2dDistance.h
PartSet_WidgetPoint2DFlyout.h
PartSet_WidgetShapeSelector.h
PartSet_Validators.cpp
PartSet_WidgetEditor.cpp
PartSet_WidgetMultiSelector.cpp
+ PartSet_WidgetMultiSelectorComposite.cpp
PartSet_WidgetPoint2d.cpp
PartSet_WidgetPoint2dDistance.cpp
PartSet_WidgetPoint2DFlyout.cpp
#include "PartSet_WidgetPoint2DFlyout.h"
#include "PartSet_WidgetShapeSelector.h"
#include "PartSet_WidgetMultiSelector.h"
+#include "PartSet_WidgetMultiSelectorComposite.h"
#include "PartSet_WidgetEditor.h"
#include "PartSet_WidgetFileSelector.h"
#include "PartSet_WidgetSketchCreator.h"
new PartSet_WidgetMultiSelector(theParent, aWorkshop, theWidgetApi);
aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
aWgt = aShapeSelectorWgt;
- } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
+ } else if (theType == "composite_multi_selector") {
+ PartSet_WidgetMultiSelectorComposite* aShapeSelectorWgt =
+ new PartSet_WidgetMultiSelectorComposite(theParent, aWorkshop, theWidgetApi);
+ aWgt = aShapeSelectorWgt;
+ }
+ else if (theType == WDG_DOUBLEVALUE_EDITOR) {
aWgt = new PartSet_WidgetEditor(theParent, aWorkshop, theWidgetApi);
} else if (theType == "export_file_selector") {
aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetMultiSelectorComposite.cpp
+// Created: 17 Mar 2016
+// Author: Natalia Ermolaeva
+
+#include "PartSet_WidgetMultiSelectorComposite.h"
+
+PartSet_WidgetMultiSelectorComposite::PartSet_WidgetMultiSelectorComposite(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData)
+: ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData)
+{
+}
+
+PartSet_WidgetMultiSelectorComposite::~PartSet_WidgetMultiSelectorComposite()
+{
+}
+
+bool PartSet_WidgetMultiSelectorComposite::focusTo()
+{
+ bool aCanSetFocus = true;
+ CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aComposite.get())
+ aCanSetFocus = aComposite->numberOfSubs() == 0;
+
+ // disable widget controls
+ if (!aCanSetFocus) {
+ disableControls();
+ }
+
+ return aCanSetFocus;
+}
+
+void PartSet_WidgetMultiSelectorComposite::disableControls()
+{
+ QList<QWidget*> aMyControls = getControls();
+ foreach(QWidget* eachControl, aMyControls) {
+ eachControl->setFocusPolicy(Qt::NoFocus);
+ eachControl->setEnabled(false);
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetMultiSelectorComposite.h
+// Created: 17 Mar 2016
+// Author: Natalia Ermolaeva
+
+#ifndef PartSet_WidgetMultiSelectorComposite_H
+#define PartSet_WidgetMultiSelectorComposite_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetMultiSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetMultiSelector in order to provide
+* working with sketch specific objects and creation of external objects.
+*/
+class PARTSET_EXPORT PartSet_WidgetMultiSelectorComposite: public ModuleBase_WidgetMultiSelector
+{
+Q_OBJECT
+ public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theWorkshop instance of workshop interface
+ /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ PartSet_WidgetMultiSelectorComposite(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData);
+
+ virtual ~PartSet_WidgetMultiSelectorComposite();
+
+ /// Set focus to the first control of the current widget. The focus policy of the control is checked.
+ /// If the widget has the NonFocus focus policy, it is skipped.
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
+
+private:
+ /// Disable controls by setting them focus policy NoFocus and disabling them
+ void disableControls();
+};
+
+#endif
\ No newline at end of file