const static char* ATTR_OBLIGATORY = "obligatory";
const static char* ATTR_CONCEALMENT = "concealment";
const static char* ATTR_USE_RESET = "use_reset";
+const static char* ATTR_GREED = "greed";
// WDG_INFO properties
const static char* INFO_WDG_TEXT = FEATURE_TEXT;
#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_ISelection.h"
#include "ModuleBase_IViewer.h"
+#include "ModuleBase_Tools.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
return false;
}
-void ModuleBase_OperationFeature::activateByPreselection()
+void ModuleBase_OperationFeature::activateByPreselection(ModuleBase_IWorkshop* theWorkshop)
{
if (myPreSelection.empty())
return;
ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection);
- ModuleBase_ModelWidget* aFilledWgt = 0;
+ std::string aGreedAttributeId = ModuleBase_Tools::findGreedAttribute(theWorkshop, myFeature);
+
ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
+ ModuleBase_ModelWidget* aFilledWgt = 0;
if (aPropertyPanel) {
const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+ QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+ ModuleBase_ModelWidget* aWgt = 0;
if (!aWidgets.empty()) {
- ModuleBase_ModelWidget* aWgt = 0;
- QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
- bool isSet = false;
- // 1. apply the selection to controls
- for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
- aWgt = (*aWIt);
- if (!aWgt->canSetValue())
- continue;
- aPropertyPanel->setPreselectionWidget(aWgt);
- if (!aWgt->setSelection(myPreSelection, true)) {
- isSet = false;
- break;
- } else {
- isSet = true;
- aFilledWgt = aWgt;
+ if (!aGreedAttributeId.empty()) {
+ // set preselection to greed widget
+ for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
+ aWgt = (*aWIt);
+ if (aWgt->attributeID() == aGreedAttributeId) {
+ aPropertyPanel->setPreselectionWidget(aWgt);
+ aWgt->setSelection(myPreSelection, true);
+ aPropertyPanel->setPreselectionWidget(NULL);
+ break;
+ }
+ }
+ // activate first not greed widget
+ std::string aFirstAttributeId = aWidgets.front()->attributeID();
+ if (aFirstAttributeId == aGreedAttributeId) // activate next widget after greeded
+ aFilledWgt = aWidgets.front();
+ else
+ aFilledWgt = NULL; // activate first widget of the panel
+ }
+ else {
+ bool isSet = false;
+ // 1. apply the selection to controls
+ for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
+ aWgt = (*aWIt);
+ if (!aWgt->canSetValue())
+ continue;
+ aPropertyPanel->setPreselectionWidget(aWgt);
+ if (!aWgt->setSelection(myPreSelection, true)) {
+ isSet = false;
+ break;
+ } else {
+ isSet = true;
+ aFilledWgt = aWgt;
+ }
}
}
aPropertyPanel->setPreselectionWidget(NULL);
if (aFilledWgt)
emit activatedByPreselection();
}
- // 4. activate the next obligatory widget
- aPropertyPanel->activateNextWidget(aFilledWgt);
}
+ // 4. activate the next obligatory widget
+ aPropertyPanel->activateNextWidget(aFilledWgt);
clearPreselection();
}
class ModuleBase_ModelWidget;
class ModuleBase_ISelection;
class ModuleBase_IViewer;
+class ModuleBase_IWorkshop;
class QKeyEvent;
//ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
/// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
- virtual void activateByPreselection();
+ virtual void activateByPreselection(ModuleBase_IWorkshop* theWorkshop);
/// If the operation works with feature which is sub-feature of another one
/// then this variable has to be initialised by parent feature
#include <ModuleBase_ParamIntSpinBox.h>
#include <ModuleBase_ParamSpinBox.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeRefAttr.h>
}
}
+std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop, const FeaturePtr& theFeature)
+{
+ std::string anAttributeId;
+
+ std::string aXmlCfg, aDescription;
+ theWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
+
+ ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
+ std::string anAttributeTitle;
+ aFactory.getGreedAttribute(anAttributeId);
+
+ return anAttributeId;
+}
+
} // namespace ModuleBase_Tools
class QDoubleSpinBox;
class ModuleBase_ParamIntSpinBox;
class ModuleBase_ParamSpinBox;
+class ModuleBase_IWorkshop;
namespace ModuleBase_Tools {
/// \theParameters a list of parameter names
MODULEBASE_EXPORT void getParameters(QStringList& theParameters);
+/// Returns list of parameters accessible in the active part and partset
+/// \theParameters a list of parameter names
+MODULEBASE_EXPORT std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
+ const FeaturePtr& theFeature);
}
#endif
thePage->alignToTop();
}
-void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theFeatureKind,
- const std::string& theAttributeId,
+void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theAttributeId,
std::string& theTitle)
{
bool aFound = false;
}
}
+void ModuleBase_WidgetFactory::getGreedAttribute(std::string& theAttributeId)
+{
+ if (!theAttributeId.empty())
+ return;
+
+ myParentId = myWidgetApi->widgetId();
+ if (!myWidgetApi->toChildWidget())
+ return;
+
+ do { //Iterate over each node
+ std::string aWdgType = myWidgetApi->widgetType();
+ // Find title under PageGroup
+ if (myWidgetApi->isGroupBoxWidget() ||
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
+ getGreedAttribute(theAttributeId);
+ }
+ else {
+ // Find title here
+ std::string anAttributeId = myWidgetApi->widgetId();
+ if (myWidgetApi->getBooleanAttribute(ATTR_GREED, false))
+ theAttributeId = anAttributeId;
+ if (theAttributeId.empty() && myWidgetApi->isPagedWidget()) {
+ //If current widget is toolbox or switch-casebox then fetch all
+ //it's pages recursively and setup into the widget.
+ myWidgetApi->toChildWidget();
+ do {
+ getGreedAttribute(theAttributeId);
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+ }
+ }
+ } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+}
+
void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound)
{
if (theFound)
}
/// Returns the value of the title key from XML definition of the attribute in the feature
- /// \param theFeatureKind a value of a kind of a feature
/// \param theAttributeId a value of a kind of the attribute under the feature
/// \param theTitle the result title
- void getAttributeTitle(const std::string& theFeatureKind,
- const std::string& theAttributeId,
+ void getAttributeTitle(const std::string& theAttributeId,
std::string& theTitle);
+ /// Returns the identifier of the first found attribute where greed field value is set and true
+ /// \param theAttributeId an outpup parameter with attribute
+ void getGreedAttribute(std::string& theAttributeId);
+
protected:
/// check if ModuleBase_Widget has expandable widgets in getControls
bool hasExpandingControls(QWidget* theParent);
ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
std::string anAttributeTitle;
- aFactory.getAttributeTitle(aFeature->getKind(), theAttribute->id(), anAttributeTitle);
+ aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle);
std::stringstream aStreamName;
aStreamName << theAttribute->owner()->data()->name() << "/"<< anAttributeTitle.c_str();
label="Segments:"
tooltip="Select list of mirroring objects"
type_choice="Edges"
- use_external="true">
+ use_external="true"
+ greed ="true">
<validator id="SketchPlugin_MirrorAttr" />
</sketch_multi_selector>
</feature>
// if the operation can be committed after the controls filling, the method perform should
// be stopped. Otherwise unnecessary presentations can be shown(e.g. operation prs in sketch)
if (!aFOperation->isEditOperation()) {
- aFOperation->activateByPreselection();
+ aFOperation->activateByPreselection(moduleConnector());
if (operationMgr()->currentOperation() != aFOperation)
return;
}