else if (!xmlStrcmp(aName, (const xmlChar *) WDG_TOOLBOX_BOX)) {
aSwitchNode = hasParentRecursive(aCaseNode, WDG_TOOLBOX, NULL);
}
+ else if (!xmlStrcmp(aName, (const xmlChar *)WDG_RADIOBOX_ITEM)) {
+ aSwitchNode = hasParentRecursive(aCaseNode, WDG_RADIOBOX, NULL);
+ }
if (!xmlStrcmp(aName, (const xmlChar *) WDG_OPTIONALBOX)) {
/// the box is optional, attribute is in case
/// if the optional attribute value is not empty
}
// container pages, like "case" or "box"
} else if (isNode(theNode, WDG_OPTIONALBOX, WDG_SWITCH, WDG_SWITCH_CASE,
- WDG_TOOLBOX, WDG_TOOLBOX_BOX, NULL)) {
+ WDG_TOOLBOX, WDG_TOOLBOX_BOX,
+ WDG_RADIOBOX, WDG_RADIOBOX_ITEM, NULL)) {
storeAttribute(theNode, _ID); // save case:caseId (or box:boxId)
}
}
result = isNode(theNode, NODE_FEATURE,
WDG_GROUP, WDG_OPTIONALBOX,
WDG_TOOLBOX, WDG_TOOLBOX_BOX,
+ WDG_RADIOBOX, WDG_RADIOBOX_ITEM,
WDG_SWITCH, WDG_SWITCH_CASE, NULL);
}
return result;
const static char* WDG_GROUP = "groupbox";
const static char* WDG_OPTIONALBOX = "optionalbox";
const static char* WDG_TOOLBOX = "toolbox";
+const static char* WDG_RADIOBOX = "radiobox";
+const static char* WDG_RADIOBOX_ITEM = "radio";
const static char* WDG_TOOLBOX_BOX = "box";
const static char* WDG_SWITCH = "switch";
const static char* WDG_SWITCH_CASE = "case";
bool Config_WidgetAPI::isPagedWidget() const
{
- return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
+ return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH, WDG_RADIOBOX,
NULL);
}
shape_types="edge">
<validator id="GeomValidators_Finite"/>
</shape_selector>
- <toolbox id="offset_type">
- <box id="offset_type_by_distance"
+ <radiobox id="offset_type">
+ <radio id="offset_type_by_distance"
title="Distance on edge by value"
tooltip="Point on an edge, at a given distance specified by value."
icon="icons/Construction/point_by_distance_on_edge_24x24.png">
<doublevalue id="distance"
label="Distance"
tooltip="Distance value."
- icon="icons/Construction/distance_value.png"
min="0.0"
default="10">
</doublevalue>
- </box>
- <box id="offset_type_by_ratio"
+ </radio>
+ <radio id="offset_type_by_ratio"
title="Distance on edge by ratio"
tooltip="Point on an edge, at a given distance specified by ratio."
icon="icons/Construction/point_by_ratio_on_edge_24x24.png">
<doublevalue id="ratio"
label="Ratio"
tooltip="Ratio value."
- icon="icons/Construction/distance_value.png"
min="0.0"
max="1.0"
default="0.5">
</doublevalue>
- </box>
- </toolbox>
+ </radio>
+ </radiobox>
<boolvalue id="reverse"
label="Reverse"
tooltip="Distance from edge end point."
ModuleBase_ActionIntParameter.h
ModuleBase_ChoiceCtrl.h
ModuleBase_WidgetNameEdit.h
+ ModuleBase_WidgetRadiobox.h
)
SET(PROJECT_MOC_HEADERS
ModuleBase_WidgetValidated.h
ModuleBase_ChoiceCtrl.h
ModuleBase_WidgetNameEdit.h
+ ModuleBase_WidgetRadiobox.h
)
SET(PROJECT_SOURCES
ModuleBase_Dialog.cpp
ModuleBase_ChoiceCtrl.cpp
ModuleBase_WidgetNameEdit.cpp
+ ModuleBase_WidgetRadiobox.cpp
)
SET(PROJECT_LIBRARIES
#include <ModuleBase_WidgetConcealedObjects.h>
#include <ModuleBase_WidgetLabel.h>
#include <ModuleBase_WidgetToolbox.h>
+#include <ModuleBase_WidgetRadiobox.h>
#include <ModuleBase_PageBase.h>
#include <ModuleBase_PageGroupBox.h>
#include <ModuleBase_WidgetOptionalBox.h>
QString aCaseId = qs(myWidgetApi->getProperty(_ID));
ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
createWidget(aPage);
- if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {
+ if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX || aWdgType == WDG_RADIOBOX) {
ModuleBase_PagedContainer* aContainer =
qobject_cast<ModuleBase_PagedContainer*>(aWidget);
result = new ModuleBase_WidgetConcealedObjects(theParent, myWidgetApi);
} else if (theType == WDG_TOOLBOX) {
result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi);
+ } else if (theType == WDG_RADIOBOX) {
+ result = new ModuleBase_WidgetRadiobox(theParent, myWidgetApi);
} else if (theType == WDG_SWITCH) {
result = new ModuleBase_WidgetSwitch(theParent, myWidgetApi);
} else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE ||
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <ModuleBase_WidgetRadiobox.h>
+#include <ModuleBase_PageBase.h>
+
+#include <QFormLayout>
+#include <QRadioButton>
+#include <QFrame>
+#include <QButtonGroup>
+
+
+ModuleBase_WidgetRadiobox::ModuleBase_WidgetRadiobox(QWidget* theParent,
+ const Config_WidgetAPI* theData)
+ : ModuleBase_PagedContainer(theParent, theData)
+{
+ myLayout = new QFormLayout(this);
+ ModuleBase_Tools::adjustMargins(myLayout);
+ myGroup = new QButtonGroup(this);
+ myGroup->setExclusive(true);
+
+ connect(myGroup, SIGNAL(buttonToggled(int, bool)), SLOT(onPageChanged()));
+}
+
+ModuleBase_WidgetRadiobox::~ModuleBase_WidgetRadiobox()
+{
+}
+
+int ModuleBase_WidgetRadiobox::addPage(ModuleBase_PageBase* thePage,
+ const QString& theName,
+ const QString& theCaseId,
+ const QPixmap& theIcon)
+{
+ ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
+ QWidget* aWgt = new QWidget(this);
+ QVBoxLayout* aLay = new QVBoxLayout(aWgt);
+ aLay->setContentsMargins(0, 0, 0, 0);
+
+ QRadioButton* aButton = new QRadioButton(aWgt);
+ aButton->setToolTip(theName);
+ aLay->addStretch();
+ aLay->addWidget(aButton);
+ aLay->addStretch();
+
+ //QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
+ QWidget* aPage = thePage->pageWidget();
+ myLayout->addRow(aWgt, aPage);
+ myGroup->addButton(aButton, myGroup->buttons().count());
+
+ bool isDefault = theCaseId.toStdString() == getDefaultValue();
+ aButton->setChecked(isDefault);
+ aPage->setEnabled(isDefault);
+ connect(aButton, SIGNAL(toggled(bool)), aPage, SLOT(setEnabled(bool)));
+
+ return myGroup->buttons().count();
+}
+
+int ModuleBase_WidgetRadiobox::currentPageIndex() const
+{
+ return myGroup->checkedId();
+}
+
+void ModuleBase_WidgetRadiobox::setCurrentPageIndex(int theIndex)
+{
+ bool isSignalsBlocked = myGroup->blockSignals(true);
+ myGroup->button(theIndex)->setChecked(true);
+ myGroup->blockSignals(isSignalsBlocked);
+}
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef MODULEBASE_WIDGETRADIOBOX_H_
+#define MODULEBASE_WIDGETRADIOBOX_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PagedContainer.h>
+
+class QFormLayout;
+class QButtonGroup;
+class QRadioButton;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetRadiobox : public ModuleBase_PagedContainer
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theData the widget configuration. The attribute of the model widget is obtained from
+ ModuleBase_WidgetRadiobox(QWidget* theParent, const Config_WidgetAPI* theData);
+ virtual ~ModuleBase_WidgetRadiobox();
+
+
+ /// Add a page to the widget
+ /// \param theWidget a page widget
+ /// \param theName a name of page
+ /// \param theCaseId an Id of the page
+ /// \param theIcon an icon of the page
+ virtual int addPage(ModuleBase_PageBase* theWidget,
+ const QString& theName,
+ const QString& theCaseId,
+ const QPixmap& theIcon);
+
+protected:
+ /// Implements ModuleBase_PagedContainer
+ virtual int currentPageIndex() const;
+
+ /// Implements ModuleBase_PagedContainer
+ virtual void setCurrentPageIndex(int);
+
+private:
+ QFormLayout* myLayout;
+ QButtonGroup* myGroup;
+};
+
+#endif
\ No newline at end of file