concealment="true">
<validator id="GeomValidators_DifferentShapes"/>
</multi_selector>
- <boolvalue id="closed" label="Closed" tooltip="Makes the curve closed." default="false"/>
<boolvalue id="reorder" label="Reorder" tooltip="Changes the order of points to construct the shortest curve." default="false"/>
- <optionalbox id="use_tangents" title="Tangents" default="false">
- <shape_selector id="tangent_start"
- icon="icons/Features/axis.png"
- label="Start"
- tooltip="Select vector tangent to the start of curve"
- shape_types="edge"
- default="<start>">
- <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
- </shape_selector>
- <shape_selector id="tangent_end"
- icon="icons/Features/axis.png"
- label="End"
- tooltip="Select vector tangent to the end of curve"
- shape_types="edge"
- default="<end>">
- <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
- </shape_selector>
+ <optionalbox id="closed" title="Closed" tooltip="Makes the curve closed or not." default="false"
+ has_frame="false" enable_on_check="false">
+ <optionalbox id="use_tangents" title="Tangents" default="false">
+ <shape_selector id="tangent_start"
+ icon="icons/Features/axis.png"
+ label="Start"
+ tooltip="Select vector tangent to the start of curve"
+ shape_types="edge"
+ default="<start>">
+ <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
+ </shape_selector>
+ <shape_selector id="tangent_end"
+ icon="icons/Features/axis.png"
+ label="End"
+ tooltip="Select vector tangent to the end of curve"
+ shape_types="edge"
+ default="<end>">
+ <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
+ </shape_selector>
+ </optionalbox>
</optionalbox>
<validator id="GeomValidators_MinObjectsSelected" parameters="base_objects,2"/>
</source>
#include <ModuleBase_WidgetOptionalBox.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeBoolean.h>
#include <Config_WidgetAPI.h>
#include <Config_Keywords.h>
myCheckBoxLayout(0),
myCheckBoxWidget(0),
myGroupBox(0),
- myGroupBoxLayout(0)
+ myGroupBoxLayout(0),
+ myCheckGroup(0),
+ myCheckGroupLayout(0),
+ myCheckContent(0),
+ myCheckGroupBtn(0),
+ myEnableOnCheck(true)
{
myToolTip = theData->widgetTooltip();
myGroupTitle = theData->getProperty(CONTAINER_PAGE_NAME);
+ myHaveFrame = theData->getBooleanAttribute("has_frame", true);
+ myEnableOnCheck = theData->getBooleanAttribute("enable_on_check", true);
+
bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
setDefaultValue(isChecked ? "true" : "false");
QWidget* ModuleBase_WidgetOptionalBox::pageWidget()
{
- return myOptionType == GroupBox ? myGroupBox : (QWidget*)myCheckBoxFrame;
+ return myOptionType == GroupBox ? (myGroupBox? myGroupBox : myCheckGroup) :
+ (QWidget*)myCheckBoxFrame;
}
QList<QWidget*> ModuleBase_WidgetOptionalBox::getControls() const
{
QList<QWidget*> aControls;
- if (myOptionType == GroupBox)
- aControls.append(myGroupBox);
+ if (myOptionType == GroupBox) {
+ if (myGroupBox)
+ aControls.append(myGroupBox);
+ else
+ aControls.append(myCheckGroup);
+ }
else
aControls.append(myCheckBoxFrame);
#endif
return;
}
- const int kCol = 0;
- const int kRow = myGroupBoxLayout->count();
- myGroupBoxLayout->addWidget(theWidget, kRow, kCol);
- myGroupBoxLayout->setRowStretch(kRow, 0);
+ if (myGroupBoxLayout) {
+ const int kCol = 0;
+ const int kRow = myGroupBoxLayout->count();
+ myGroupBoxLayout->addWidget(theWidget, kRow, kCol);
+ myGroupBoxLayout->setRowStretch(kRow, 0);
+ }
+ else {
+ myCheckGroupLayout->addWidget(theWidget);
+ }
}
QLayout* ModuleBase_WidgetOptionalBox::pageLayout()
{
if (theType == GroupBox && !myGroupBox) {
// group box: more than one model widget is inside
- myGroupBox = new QGroupBox(this);
- myGroupBox->setTitle(translate(myGroupTitle));
- myGroupBox->setVisible(false);
- myGroupBox->setCheckable(true);
- myGroupBox->setChecked(getDefaultValue() == "true");
- myGroupBox->setToolTip(translate(myToolTip));
-
- myGroupBoxLayout = new QGridLayout(myGroupBox);
- ModuleBase_Tools::zeroMargins(myGroupBoxLayout);
- myGroupBox->setLayout(myGroupBoxLayout);
-
- // default vertical size policy is preferred
- myMainLayout->addWidget(myGroupBox);
- connect(myGroupBox, SIGNAL(clicked(bool)), this, SLOT(onPageClicked()));
+ if (myHaveFrame) {
+ myGroupBox = new QGroupBox(this);
+ myGroupBox->setTitle(translate(myGroupTitle));
+ myGroupBox->setVisible(false);
+ myGroupBox->setCheckable(true);
+ myGroupBox->setChecked(getDefaultValue() == "true");
+ myGroupBox->setToolTip(translate(myToolTip));
+
+ myGroupBoxLayout = new QGridLayout(myGroupBox);
+ ModuleBase_Tools::zeroMargins(myGroupBoxLayout);
+ myGroupBox->setLayout(myGroupBoxLayout);
+
+ // default vertical size policy is preferred
+ myMainLayout->addWidget(myGroupBox);
+ connect(myGroupBox, SIGNAL(clicked(bool)), this, SLOT(onPageClicked()));
+ }
+ else {
+ myCheckGroup = new QWidget(this);
+ QVBoxLayout* aLayout = new QVBoxLayout(myCheckGroup);
+ ModuleBase_Tools::zeroMargins(aLayout);
+
+ myCheckGroupBtn = new QCheckBox(translate(myGroupTitle), myCheckGroup);
+ aLayout->addWidget(myCheckGroupBtn);
+
+ myCheckContent = new QWidget(myCheckGroup);
+ myCheckGroupLayout = new QVBoxLayout(myCheckContent);
+ ModuleBase_Tools::zeroMargins(myCheckGroupLayout);
+ aLayout->addWidget(myCheckContent);
+
+ myMainLayout->addWidget(myCheckGroup);
+ connect(myCheckGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onPageClicked()));
+ }
}
else if (theType == CheckBox && !myCheckBoxFrame) {
myCheckBoxFrame = new QFrame(this);
{
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
- aStringAttr->setValue(getCurrentValue() ? attributeID() : "");
+ if (aStringAttr.get())
+ aStringAttr->setValue(getCurrentValue() ? attributeID() : "");
+ else {
+ AttributeBooleanPtr aBoolAtr = aData->boolean(attributeID());
+ aBoolAtr->setValue(getCurrentValue());
+ }
updateObject(myFeature);
{
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
- setCurrentValue(!aStringAttr->value().empty());
-
+ if (aStringAttr.get())
+ setCurrentValue(!aStringAttr->value().empty());
+ else {
+ AttributeBooleanPtr aBoolAtr = aData->boolean(attributeID());
+ setCurrentValue(aBoolAtr->value());
+ }
return true;
}
myCheckBoxFrame->setVisible(!isGroupBox);
if (myGroupBox)
myGroupBox->setVisible(isGroupBox);
+ else if (myCheckContent)
+ myCheckGroup->setVisible(isGroupBox);
}
bool ModuleBase_WidgetOptionalBox::isCheckBoxFilled() const
bool ModuleBase_WidgetOptionalBox::getCurrentValue() const
{
bool isGroupBox = myOptionType == GroupBox;
- return isGroupBox ? myGroupBox->isChecked() : myCheckBox->isChecked();
+ return isGroupBox ? (myGroupBox? myGroupBox->isChecked() : myCheckGroupBtn->isChecked()) :
+ myCheckBox->isChecked();
}
void ModuleBase_WidgetOptionalBox::setCurrentValue(const bool& theValue)
{
bool isGroupBox = myOptionType == GroupBox;
if (isGroupBox) {
- bool isBlocked = myGroupBox->blockSignals(true);
- myGroupBox->setChecked(theValue);
- myGroupBox->blockSignals(isBlocked);
+ if (myGroupBox) {
+ bool isBlocked = myGroupBox->blockSignals(true);
+ myGroupBox->setChecked(theValue);
+ myGroupBox->blockSignals(isBlocked);
+ }
+ else {
+ bool isBlocked = myCheckGroupBtn->blockSignals(true);
+ myCheckGroupBtn->setChecked(theValue);
+ myCheckGroupBtn->blockSignals(isBlocked);
+ }
}
else {
bool isBlocked = myCheckBox->blockSignals(true);
void ModuleBase_WidgetOptionalBox::updateControlsVisibility()
{
if (myOptionType == GroupBox) {
- bool aChecked = myGroupBox->isChecked();
+ bool aChecked = toEnableWidgets();
ModuleBase_Tools::adjustMargins(myGroupBoxLayout);
- int aNbSubControls = myGroupBoxLayout->count();
+ QLayout* aLayout = myGroupBoxLayout ? myGroupBoxLayout : (QLayout*)myCheckGroupLayout;
+
+ int aNbSubControls = aLayout->count();
for (int i = 0; i < aNbSubControls; i++) {
- QWidget* aWidget = myGroupBoxLayout->itemAt(i)->widget();
+ QWidget* aWidget = aLayout->itemAt(i)->widget();
if (aWidget)
aWidget->setEnabled(aChecked);
}
}
else {
- bool aChecked = myCheckBox->isChecked();
- myCheckBoxWidget->setEnabled(aChecked);
+ myCheckBoxWidget->setEnabled(toEnableWidgets());
}
}
+
+bool ModuleBase_WidgetOptionalBox::toEnableWidgets() const
+{
+ bool aChecked;
+ if (myOptionType == GroupBox)
+ aChecked = myGroupBox ? myGroupBox->isChecked() : myCheckGroupBtn->isChecked();
+ else
+ aChecked = myCheckBox->isChecked();
+
+ if (myEnableOnCheck)
+ return aChecked;
+ else
+ return !aChecked;
+}