#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
data()->addAttribute(DIRECTION_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
- data()->addAttribute(USE_SHAPES_ID(), ModelAPI_AttributeInteger::typeId());
-
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), DIRECTION_OBJECT_ID());
return MY_FROM_OFFSET_ID;
}
- /// Attribute name of using shape types.
- inline static const std::string& USE_SHAPES_ID()
- {
- static const std::string MY_USE_SHAPEST_ID("use_sapes");
- return MY_USE_SHAPEST_ID;
- }
-
/// \return the kind of a feature.
FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
{
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="vertices edges wires faces shells solids compsolids compounds">
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
- <choice id="use_sapes"
- widget_type="radiobuttons"
- buttons_dir="horizontal"
- label="Type"
- tooltip="Using shapes type"
- string_list="Vertices Edges Faces"
- icons_list=":pictures/vertex32.png :pictures/edge32.png :pictures/face32.png"
- default="2">
- </choice>
<multi_selector id="base"
label="Base objects:"
tooltip="Select a base objects"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true"
concealment="true">
- <validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
+ <validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face"/>
</multi_selector>
<shape_selector id="direction_object"
icon="icons/Features/axis.png"
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="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Select a sketch face"
icon="icons/Features/sketch.png"
tooltip="Select a sketch face"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
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="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Base objects:"
tooltip="Select a base objects"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
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="vertices edges wires faces shells compounds">
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true">
<validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="base,Sketch"/>
</sketch_launcher>
<multi_selector id="base"
label="Select a sketch face"
icon="icons/Features/sketch.png"
tooltip="Select a sketch face"
- shape_types="vertices edges wires faces shells compounds"
+ shape_types="Vertices Edges Faces"
+ default_type = "2"
+ use_choice="true"
concealment="true">
<validator id="FeaturesPlugin_ValidatorBaseForGeneration" parameters="vertex,edge,wire,face,shell,compound"/>
</multi_selector>
myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
myTypeCtrl->setLabel(tr("Type"));
if (!myShapeTypes.empty()) {
- myTypeCtrl->setValue(0);
- myDefMode = myShapeTypes.first().toStdString();
+ std::string aDefType = theData->getProperty("default_type");
+ if (aDefType.size() > 0) {
+ bool aOk = false;
+ int aId = QString(aDefType.c_str()).toInt(&aOk);
+ if (aOk) {
+ myTypeCtrl->setValue(aId);
+ myDefMode = myShapeTypes.at(aId).toStdString();
+ }
+ }
+ if (myDefMode.size() == 0) {
+ myTypeCtrl->setValue(0);
+ myDefMode = myShapeTypes.first().toStdString();
+ }
}
myMainLayout->addWidget(myTypeCtrl);
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
QList<QWidget*> result;
+ if (myTypeCtrl->isVisible())
+ result << myTypeCtrl;
result << myListView->getControl();
return result;
}
restoreValue();
myWorkshop->setSelected(getAttributeSelection());
// may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
- true); /// hope that something is redisplayed by object updated
+ // hope that something is redisplayed by object updated
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, false);
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeResults, true);
// clear history should follow after set selected to do not increase history by setSelected
clearSelectedHistory();
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ChoiceCtrl.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelectionActivate.h>
#include <Config_WidgetAPI.h>
#define DEBUG_UNDO_INVALID_SKETCH
+
+
+QStringList getIconsList(const QStringList& theNames)
+{
+ QStringList aIcons;
+ foreach(QString aName, theNames) {
+ QString aUName = aName.toUpper();
+ if ((aUName == "VERTICES") || (aUName == "VERTEX"))
+ aIcons << ":pictures/vertex32.png";
+ else if ((aUName == "EDGES") || (aUName == "EDGE"))
+ aIcons << ":pictures/edge32.png";
+ else if ((aUName == "FACES") || (aUName == "FACE"))
+ aIcons << ":pictures/face32.png";
+ }
+ return aIcons;
+}
+
+
+
PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
PartSet_Module* theModule,
const Config_WidgetAPI* theData)
aLayout->addWidget(mySizeOfViewWidget);
aLayout->addWidget(myLabel);
- aLayout->addStretch(1);
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
+ myIsUseChoice = theData->getBooleanAttribute("use_choice", false);
+ QStringList aIconsList = getIconsList(myShapeTypes);
+ myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
+ myTypeCtrl->setLabel(tr("Type"));
+ if (!myShapeTypes.empty()) {
+ std::string aDefType = theData->getProperty("default_type");
+ if (aDefType.size() > 0) {
+ bool aOk = false;
+ int aId = QString(aDefType.c_str()).toInt(&aOk);
+ if (aOk) {
+ myTypeCtrl->setValue(aId);
+ myDefMode = myShapeTypes.at(aId).toStdString();
+ }
+ }
+ if (myDefMode.size() == 0) {
+ myTypeCtrl->setValue(0);
+ myDefMode = myShapeTypes.first().toStdString();
+ }
+ }
+ aLayout->addWidget(myTypeCtrl);
+ // There is no sense to parameterize list of types while we can not parameterize selection mode
+ // if the xml definition contains one type, the controls to select a type should not be shown
+ if (myShapeTypes.size() <= 1 || !myIsUseChoice) {
+ myTypeCtrl->setVisible(false);
+ }
+ connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged()));
+ aLayout->addStretch(1);
myPreviewPlanes = new PartSet_PreviewPlanes();
}
XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
- QString aType(aWidget->metaObject()->className());
- if (aType == "ModuleBase_WidgetChoice")
- continue;
if (theSelectionControl) { // hide other controls
if (aWidget != this)
aWidget->setVisible(false);
QIntList PartSet_WidgetSketchCreator::shapeTypes() const
{
QIntList aShapeTypes;
- foreach(QString aType, myShapeTypes) {
- aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ if (myShapeTypes.length() > 1 && myIsUseChoice) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
+ }
+ else {
+ foreach(QString aType, myShapeTypes) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ }
}
return aShapeTypes;
}
eachControl->setEnabled(theEnabled);
}
}
+
+void PartSet_WidgetSketchCreator::onSelectionTypeChanged()
+{
+ // Clear current selection in order to avoid updating of object browser with obsolete indexes
+ // which can appear because of results deletetion after changing a type of selection
+ QString aSelectionType = myTypeCtrl->textValue();
+ QList<ModuleBase_ViewerPrsPtr> aEmptyList;
+ myWorkshop->setSelected(aEmptyList);
+
+ updateSelectionModesAndFilters(true);
+ myWorkshop->selectionActivate()->updateSelectionModes();
+
+ if (!myFeature)
+ return;
+
+ if (aSelectionType != "Faces") {
+ setVisibleSelectionControl(false);
+ myWorkshop->propertyPanel()->activateNextWidget();
+ }
+
+ /// store the selected type
+ AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
+ anAttrList->setSelectionType(aSelectionType.toStdString());
+ anAttrList->clear();
+
+ // update object is necessary to flush update signal. It leads to objects references map update
+ // and the operation presentation will not contain deleted items visualized as parameters of
+ // the feature.
+ updateObject(myFeature);
+ myWorkshop->propertyPanel()->activeWidget()->restoreValue();
+ myWorkshop->setSelected(getAttributeSelection());
+ // may be the feature's result is not displayed, but attributes should be
+ // hope that something is redisplayed by object updated
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, true);
+}
\ No newline at end of file
class ModuleBase_Operation;
class ModuleBase_IWorkshop;
class PartSet_PreviewPlanes;
+class ModuleBase_ChoiceCtrl;
/**
* \ingroup Modules
private slots:
void onResumed(ModuleBase_Operation* theOp);
+ /// Slot is called on selection type changed
+ void onSelectionTypeChanged();
+
private:
/// Append new Sketch, set the selected plane for the sketch and start Edit operation.
/// \param theValues a selection list
/// class to show/hide preview planes
PartSet_PreviewPlanes* myPreviewPlanes;
+
+ bool myIsUseChoice; ///< A flag to store use_choice parameter state
+
+ /// Control for types
+ ModuleBase_ChoiceCtrl* myTypeCtrl;
+ std::string myDefMode;
};
#endif
\ No newline at end of file