From: Clarisse Genrault Date: Fri, 24 Jun 2016 08:09:22 +0000 (+0200) Subject: Removal of the widget "checkbox with spinbox". X-Git-Tag: V_2.5.0~226 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e815d16900c2971b585566f4e66d023e30d02817;p=modules%2Fshaper.git Removal of the widget "checkbox with spinbox". --- diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 21aca6e1c..0fc75262d 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -27,7 +27,6 @@ const static char* PROPERTY_PANEL_ID = "property_panel_id"; // Widgets const static char* WDG_INFO = "label"; const static char* WDG_DOUBLEVALUE = "doublevalue"; -const static char* WDG_CHECK_DOUBLEVALUE = "check_doublevalue"; const static char* WDG_INTEGERVALUE = "integervalue"; const static char* WDG_BOOLVALUE = "boolvalue"; const static char* WDG_STRINGVALUE = "stringvalue"; diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 26eacfa29..c4fe31943 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -42,7 +42,6 @@ SET(PROJECT_HEADERS ModuleBase_ViewerPrs.h ModuleBase_WidgetAction.h ModuleBase_WidgetBoolValue.h - ModuleBase_WidgetCheckDoubleValue.h ModuleBase_WidgetCheckGroupBox.h ModuleBase_WidgetChoice.h ModuleBase_WidgetCreatorFactory.h @@ -102,7 +101,6 @@ SET(PROJECT_SOURCES ModuleBase_ViewerPrs.cpp ModuleBase_WidgetAction.cpp ModuleBase_WidgetBoolValue.cpp - ModuleBase_WidgetCheckDoubleValue.cpp ModuleBase_WidgetCheckGroupBox.cpp ModuleBase_WidgetChoice.cpp ModuleBase_WidgetCreatorFactory.cpp diff --git a/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.cpp deleted file mode 100644 index fcce1121f..000000000 --- a/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2014-2016 CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetCheckDoubleValue.cpp -// Created: 16 June 2016 -// Author: Clarisse Genrault (CEA) - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#ifndef DBL_MAX -#define DBL_MAX 1.7976931348623158e+308 -#endif -#ifdef _DEBUG -#include -#endif - -//#define DEBUG_COMPLETE_WITH_PARAMETERS - -ModuleBase_WidgetCheckDoubleValue::ModuleBase_WidgetCheckDoubleValue(QWidget* theParent, - const Config_WidgetAPI* theData) - : ModuleBase_ModelWidget(theParent, theData) -{ - QFormLayout* aControlLay = new QFormLayout(this); - ModuleBase_Tools::adjustMargins(aControlLay); - - myCheckAttributeId = theData->getProperty("id_check"); - - QString aCheckText = QString::fromStdString(theData->widgetLabel()); - myCheckBox = new QCheckBox(aCheckText, this); - - bool aAcceptVariables = theData->getBooleanAttribute(DOUBLE_WDG_ACCEPT_EXPRESSIONS, true); - - mySpinBox = new ModuleBase_ParamSpinBox(this); - mySpinBox->setAcceptVariables(aAcceptVariables); - QString anObjName = QString::fromStdString(attributeID()); - mySpinBox->setObjectName(anObjName); - - bool isOk = false; - std::string aProp = theData->getProperty(DOUBLE_WDG_MIN); - double aMinVal = QString::fromStdString(aProp).toDouble(&isOk); - if (isOk) { - mySpinBox->setMinimum(aMinVal); - } else { - mySpinBox->setMinimum(-DBL_MAX); - } - - aProp = theData->getProperty(DOUBLE_WDG_MAX); - double aMaxVal = QString::fromStdString(aProp).toDouble(&isOk); - if (isOk) { - mySpinBox->setMaximum(aMaxVal); - } else { - mySpinBox->setMaximum(DBL_MAX); - } - - aProp = theData->getProperty(DOUBLE_WDG_STEP); - double aStepVal = QString::fromStdString(aProp).toDouble(&isOk); - if (isOk) { - double aMinStep = pow(10, -1. * (double) mySpinBox->decimals()); - if(aStepVal < aMinStep){ - aStepVal = aMinStep; - } - mySpinBox->setSingleStep(aStepVal); - } - - double aDefVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - if (isOk) { - mySpinBox->setValue(aDefVal); - } - - QString aTTip = QString::fromStdString(theData->widgetTooltip()); - mySpinBox->setToolTip(aTTip); - myCheckBox->setToolTip(aTTip); - - myCheckBox->setChecked(false); - mySpinBox->setEnabled(false); - - aControlLay->addRow(myCheckBox, mySpinBox); - connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified())); - connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged())); -} - -ModuleBase_WidgetCheckDoubleValue::~ModuleBase_WidgetCheckDoubleValue() -{ -} - -void ModuleBase_WidgetCheckDoubleValue::activateCustom() -{ - ModuleBase_ModelWidget::activateCustom(); -#ifdef DEBUG_COMPLETE_WITH_PARAMETERS - QStringList aParameters; - ModuleBase_Tools::getParameters(aParameters); - mySpinBox->setCompletionList(aParameters); -#endif -} - -bool ModuleBase_WidgetCheckDoubleValue::resetCustom() -{ - bool aDone = false; - if (!isUseReset() || isComputedDefault() || mySpinBox->hasVariable()) { - aDone = false; - } else { - bool isOk; - double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - // reset the value just if there is a default value definition in the XML definition - // if the value can not be found by the default value, do nothing - if (isOk) { - ModuleBase_Tools::setSpinValue(mySpinBox, aDefValue); - storeValue(); - aDone = true; - } - } - return aDone; -} - -bool ModuleBase_WidgetCheckDoubleValue::storeValueCustom() -{ - DataPtr aData = myFeature->data(); - AttributeDoublePtr aReal = aData->real(attributeID()); - AttributeBooleanPtr aBoolean = aData->boolean(myCheckAttributeId); - - if (mySpinBox->hasVariable()) { - // Here is a text of a real value or an expression. - std::string aText = mySpinBox->text().toStdString(); - aReal->setText(aText); - } else { - // it is important to set the empty text value to the attribute before set the value - // because setValue tries to calculate the attribute value according to the - // attribute current text - aReal->setText(""); - aReal->setValue(mySpinBox->value()); - } - - // The spinbox is enabled/disabled only if the checkbox is checked/unchecked - aBoolean->setValue(myCheckBox->isChecked()); - mySpinBox->setEnabled(myCheckBox->isChecked()); - - updateObject(myFeature); - return true; -} - -bool ModuleBase_WidgetCheckDoubleValue::restoreValueCustom() -{ - DataPtr aData = myFeature->data(); - AttributeDoublePtr aRef = aData->real(attributeID()); - AttributeBooleanPtr aBoolean = aData->boolean(myCheckAttributeId); - std::string aTextRepr = aRef->text(); - if (!aTextRepr.empty()) { - ModuleBase_Tools::setSpinText(mySpinBox, QString::fromStdString(aTextRepr)); - } else { - ModuleBase_Tools::setSpinValue(mySpinBox, aRef->value()); - } - - // The spinbox is enabled/disabled only if the checkbox is checked/unchecked - myCheckBox->setChecked(aBoolean->value()); - mySpinBox->setEnabled(aBoolean->value()); - - return true; -} - -void ModuleBase_WidgetCheckDoubleValue::selectContent() -{ - mySpinBox->selectAll(); -} - -QList ModuleBase_WidgetCheckDoubleValue::getControls() const -{ - QList aList; - aList.append(mySpinBox); - aList.append(myCheckBox); - return aList; -} - -bool ModuleBase_WidgetCheckDoubleValue::processEnter() -{ - bool isModified = getValueState() == ModifiedInPP; - if (isModified) { - emit valuesChanged(); - mySpinBox->selectAll(); - } - return isModified; -} diff --git a/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.h deleted file mode 100644 index fa0d5f16e..000000000 --- a/src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetCheckDoubleValue.h -// Created: 04 June 2014 -// Author: Vitaly Smetannikov - -#ifndef ModuleBase_WidgetCheckDoubleValue_H -#define ModuleBase_WidgetCheckDoubleValue_H - -#include "ModuleBase.h" -#include "ModuleBase_ModelWidget.h" - -class ModuleBase_ParamSpinBox; -class Config_WidgetAPI; -class QWidget; -class QTimer; -class QCheckBox; - -/** -* \ingroup GUI -* A class of property panel widget for double value input -* It can be defined with "doublevalue" keyword. For example: -* \code -* -* \endcode -*/ -class MODULEBASE_EXPORT ModuleBase_WidgetCheckDoubleValue : public ModuleBase_ModelWidget -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent the parent object - /// \param theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetCheckDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData); - - virtual ~ModuleBase_WidgetCheckDoubleValue(); - - /// The methiod called when widget is activated - virtual void activateCustom(); - - /// Select the internal content if it can be selected. It is empty in the default realization - virtual void selectContent(); - - /// Returns list of widget controls - /// \return a control list - virtual QList getControls() const; - - /// Returns true if the event is processed. - virtual bool processEnter(); - - public slots: - // Delayed value chnged: when user starts typing something, - // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal -// void onValueChanged(); - -protected: - /// Saves the internal parameters to the given feature - /// \return True in success - virtual bool storeValueCustom(); - - //! Read value of corresponded attribute from data model to the input control - // \return True in success - virtual bool restoreValueCustom(); - - /// Fills the widget with default values - /// \return true if the widget current value is reset - virtual bool resetCustom(); - -protected: - /// Check box of the widget - QCheckBox* myCheckBox; - - /// Input value control - ModuleBase_ParamSpinBox* mySpinBox; - -private: - /// Check attribute - std::string myCheckAttributeId; -}; - -#endif diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 4e0bc4798..d8e6bc262 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -285,8 +284,6 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std:: result = new ModuleBase_WidgetLabel(theParent, myWidgetApi); } else if (theType == WDG_DOUBLEVALUE) { result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi); - } else if (theType == WDG_CHECK_DOUBLEVALUE) { - result = new ModuleBase_WidgetCheckDoubleValue(theParent, myWidgetApi); } else if (theType == WDG_INTEGERVALUE) { result = new ModuleBase_WidgetIntValue(theParent, myWidgetApi); } else if (theType == WDG_SHAPE_SELECTOR) {