*/
#include <ModuleBase_WidgetFactory.h>
-#include <ModuleBase_MetaWidget.h>
-#include <ModuleBase_PropPanelOperation.h>
+
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_SelectorWidget.h>
+#include <ModuleBase_Widgets.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <cfloat>
#include <climits>
-ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_PropPanelOperation* theOperation)
- : myOperation(theOperation)
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop)
+ : myOperation(theOperation), myWorkshop(theWorkshop)
{
- QString aXml = myOperation->xmlRepresentation();
+ QString aXml = myOperation->getDescription()->xmlRepresentation();
myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
}
{
QWidget* result = NULL;
if (theType == WDG_DOUBLEVALUE) {
- result = doubleSpinBoxControl();
+ result = doubleSpinBoxControl(theParent);
+
} else if (theType == WDG_INFO) {
result = labelControl(theParent);
- }
- else if (theType == WDG_POINT_SELECTOR) {
+
+ } else if (theType == WDG_SELECTOR) {
+ result = selectorControl(theParent);
+
+ } else if (theType == WDG_BOOLVALUE) {
+ result = booleanControl(theParent);
+
+ } else if (theType == WDG_POINT_SELECTOR) {
result = pointSelectorControl(theParent);
- }
- else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
+
+ } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
}
#ifdef _DEBUG
return result;
}
-QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl()
+QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
{
- QWidget* result = new QWidget();
- QHBoxLayout* aControlLay = new QHBoxLayout(result);
- aControlLay->setContentsMargins(0, 0, 0, 0);
- QString aLabelText = qs(myWidgetApi->widgetLabel());
- QString aLabelIcon = qs(myWidgetApi->widgetIcon());
- QLabel* aLabel = new QLabel(aLabelText);
- aLabel->setPixmap(QPixmap(aLabelIcon));
-
- aControlLay->addWidget(aLabel);
- QDoubleSpinBox* aBox = new QDoubleSpinBox(result);
- QString anObjName = QString::fromStdString(myWidgetApi->widgetId());
- aBox->setObjectName(anObjName);
- bool isOk = false;
- std::string aProp = myWidgetApi->getProperty(DOUBLE_WDG_MIN);
- double aMinVal = qs(aProp).toDouble(&isOk);
- if (isOk) {
- aBox->setMinimum(aMinVal);
- } else {
- aBox->setMinimum(-DBL_MAX);
- }
- aProp = myWidgetApi->getProperty(DOUBLE_WDG_MAX);
- double aMaxVal = qs(aProp).toDouble(&isOk);
- if (isOk) {
- aBox->setMaximum(aMaxVal);
- } else {
- aBox->setMaximum(DBL_MAX);
- }
- aProp = myWidgetApi->getProperty(DOUBLE_WDG_STEP);
- double aStepVal = qs(aProp).toDouble(&isOk);
- if (isOk) {
- aBox->setSingleStep(aStepVal);
- }
- aProp = myWidgetApi->getProperty(DOUBLE_WDG_DFLT);
- double aDefVal = qs(aProp).toDouble(&isOk);
- if (isOk) {
- aBox->setValue(aDefVal);
- }
- QString aTTip = qs(myWidgetApi->widgetTooltip());
- aBox->setToolTip(aTTip);
- aControlLay->addWidget(aBox);
- aControlLay->setStretch(1, 1);
- result->setLayout(aControlLay);
- connectWidget(aBox, WDG_DOUBLEVALUE);
- ModuleBase_MetaWidget* aWrappedWdg =
- new ModuleBase_MetaWidget(anObjName, aBox, myOperation->feature());
- myWidgets.append(aWrappedWdg);
- return result;
+ ModuleBase_DoubleValueWidget* aDblWgt = new ModuleBase_DoubleValueWidget(theParent, myWidgetApi);
+ QObject::connect(aDblWgt, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue()));
+
+ myModelWidgets.append(aDblWgt);
+
+ // Init default values
+ if (!myOperation->isEditOperation())
+ aDblWgt->storeValue(myOperation->feature());
+ return aDblWgt->getControl();
}
QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
{
ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent,
- qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)), myWidgetApi->widgetId());
+ qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)),
+ myWidgetApi->widgetId());
connectWidget(aWidget, WDG_POINT_SELECTOR);
+ myModelWidgets.append(aWidget);
return aWidget->getControl();
}
myOperation, SLOT(storeReal(double)));
}
if (theType == WDG_POINT_SELECTOR) {
- ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(theWidget);
- result = QObject::connect(aCustom, SIGNAL(valuesChanged()),
+ result = QObject::connect(theWidget, SIGNAL(valuesChanged()),
myOperation, SLOT(storeCustomValue()));
}
return result;
{
return QString::fromStdString(theStdString);
}
+
+
+QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
+{
+ ModuleBase_SelectorWidget* aSelector = new ModuleBase_SelectorWidget(theParent, myWorkshop, myWidgetApi);
+
+ QObject::connect(aSelector, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue()));
+
+ myModelWidgets.append(aSelector);
+ return aSelector->getControl();
+}
+
+
+QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
+{
+ ModuleBase_BoolValueWidget* aBoolWgt = new ModuleBase_BoolValueWidget(theParent, myWidgetApi);
+ QObject::connect(aBoolWgt, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue()));
+
+ myModelWidgets.append(aBoolWgt);
+
+ // Init default values
+ if (!myOperation->isEditOperation())
+ aBoolWgt->storeValue(myOperation->feature());
+ return aBoolWgt->getControl();
+}
\ No newline at end of file