Salome HOME
Removal of the widget "checkbox with spinbox".
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 24 Jun 2016 08:09:22 +0000 (10:09 +0200)
committerdbv <dbv@opencascade.com>
Thu, 7 Jul 2016 09:39:40 +0000 (12:39 +0300)
src/Config/Config_Keywords.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetCheckDoubleValue.h [deleted file]
src/ModuleBase/ModuleBase_WidgetFactory.cpp

index 21aca6e1cb9457b6b23c25782acb3ec340b8106a..0fc75262dd3a8789d26cc607fb4038799a059200 100644 (file)
@@ -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";
index 26eacfa2945e6af9b9a834a27d01ea128fb2dbf9..c4fe31943fd2fab04a5925cc7e793c10ce1f391d 100644 (file)
@@ -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 (file)
index fcce112..0000000
+++ /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 <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeBoolean.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Object.h>
-
-#include <ModuleBase_ParamSpinBox.h>
-#include <ModuleBase_Tools.h>
-#include <ModuleBase_WidgetCheckDoubleValue.h>
-#include <ModuleBase_IconFactory.h>
-
-#include <QFormLayout>
-#include <QCheckBox>
-#include <QList>
-#include <QObject>
-#include <QPixmap>
-#include <QString>
-
-#include <cfloat>
-
-#ifndef DBL_MAX
-#define DBL_MAX 1.7976931348623158e+308 
-#endif
-#ifdef _DEBUG
-#include <iostream>
-#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<QWidget*> ModuleBase_WidgetCheckDoubleValue::getControls() const
-{
-  QList<QWidget*> 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 (file)
index fa0d5f1..0000000
+++ /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
-* <doublevalue id="x" id_check="y" label="X:" icon=":pictures/x_point.png" tooltip="X coordinate"/>
-* \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<QWidget*> 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
index 4e0bc4798ba51e359abe1d25a4824cc9bd9198e0..d8e6bc26229a8c950ed918a3b6c08f006f3f83e0 100644 (file)
@@ -16,7 +16,6 @@
 #include <ModuleBase_WidgetSwitch.h>
 #include <ModuleBase_WidgetShapeSelector.h>
 #include <ModuleBase_WidgetDoubleValue.h>
-#include <ModuleBase_WidgetCheckDoubleValue.h>
 #include <ModuleBase_WidgetIntValue.h>
 #include <ModuleBase_WidgetBoolValue.h>
 #include <ModuleBase_WidgetFileSelector.h>
@@ -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) {