// Widgets
const static char* WDG_INFO = "label";
const static char* WDG_DOUBLEVALUE = "doublevalue";
+const static char* WDG_DOUBLEVALUELABEL = "labelvalue";
const static char* WDG_INTEGERVALUE = "integervalue";
const static char* WDG_BOOLVALUE = "boolvalue";
const static char* WDG_STRINGVALUE = "stringvalue";
ModuleBase_IViewer.h
ModuleBase_IWidgetCreator.h
ModuleBase_IWorkshop.h
+ ModuleBase_LabelValue.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
ModuleBase_OperationAction.h
ModuleBase_WidgetFileSelector.h
ModuleBase_WidgetIntValue.h
ModuleBase_WidgetLabel.h
+ ModuleBase_WidgetLabelValue.h
ModuleBase_WidgetLineEdit.h
ModuleBase_WidgetMultiSelector.h
ModuleBase_WidgetOptionalBox.h
ModuleBase_IViewer.cpp
ModuleBase_IWidgetCreator.cpp
ModuleBase_IWorkshop.cpp
+ ModuleBase_LabelValue.cpp
ModuleBase_ModelWidget.cpp
ModuleBase_Operation.cpp
ModuleBase_OperationAction.cpp
ModuleBase_WidgetFileSelector.cpp
ModuleBase_WidgetIntValue.cpp
ModuleBase_WidgetLabel.cpp
+ ModuleBase_WidgetLabelValue.cpp
ModuleBase_WidgetLineEdit.cpp
ModuleBase_WidgetMultiSelector.cpp
ModuleBase_WidgetOptionalBox.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_IWorkshop.cpp
+// Created: 30 Nov 2016
+// Author: Natalia ERMOLAEVA
+
+#include <ModuleBase_LabelValue.h>
+#include <ModuleBase_IconFactory.h>
+
+#include <QHBoxLayout>
+#include <QLabel>
+
+ModuleBase_LabelValue::ModuleBase_LabelValue(QWidget* theParent, const QString& theText,
+ const QString& theToolTip, const QString& theIcon)
+: QWidget(theParent)
+{
+ QHBoxLayout* aLayout = new QHBoxLayout(this);
+ aLayout->setContentsMargins(2, 0, 0, 0);
+ aLayout->setSpacing(0);
+
+ myLabel = new QLabel(QString("%1 : ").arg(theText), this);
+ if (!theIcon.isEmpty()) {
+ myLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(theIcon));
+ aLayout->setSpacing(4);
+ }
+ myLabel->setToolTip(!theToolTip.isEmpty() ? theToolTip : theText);
+ aLayout->addWidget(myLabel);
+
+ myLabelValue = new QLabel("", this);
+ aLayout->addWidget(myLabelValue, 1);
+
+ aLayout->addStretch(1);
+}
+
+ModuleBase_LabelValue::~ModuleBase_LabelValue()
+{
+}
+
+void ModuleBase_LabelValue::setValue(const double theValue)
+{
+ myValue = theValue;
+ myLabelValue->setText(QString::number(theValue));
+ myLabelValue->setToolTip(QString::number(theValue));
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_LabelValue.h
+// Created: 30 Nov 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_LabelValue_H
+#define ModuleBase_LabelValue_H
+
+#include "ModuleBase.h"
+
+#include <QWidget>
+
+class QLabel;
+
+/**
+* \ingroup GUI
+* Implementation of model widget for a label control
+*/
+class MODULEBASE_EXPORT ModuleBase_LabelValue : public QWidget
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theText a text value
+ /// \param theToolTip a tool tip value
+ /// \param theIcon a icon value
+ ModuleBase_LabelValue(QWidget* theParent, const QString& theText,
+ const QString& theToolTip = "",
+ const QString& theIcon = "");
+
+ virtual ~ModuleBase_LabelValue();
+
+ /// Fills the label value with the given value
+ /// \param theValue a value
+ void setValue(const double theValue);
+
+ /// Returns double value
+ /// \return the value
+ double value() const { return myValue; }
+
+protected:
+ QLabel* myLabel; ///< A label information control
+ QLabel* myLabelValue; ///< A label value control
+
+ double myValue; ///< A cashed value to avoid a string conversion
+};
+
+#endif
#include <ModuleBase_WidgetShapeSelector.h>
#include <ModuleBase_WidgetFeatureSelector.h>
#include <ModuleBase_WidgetDoubleValue.h>
+#include <ModuleBase_WidgetLabelValue.h>
#include <ModuleBase_WidgetIntValue.h>
#include <ModuleBase_WidgetBoolValue.h>
#include <ModuleBase_WidgetFileSelector.h>
result = new ModuleBase_WidgetLabel(theParent, myWidgetApi);
} else if (theType == WDG_DOUBLEVALUE) {
result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi);
+ } else if (theType == WDG_DOUBLEVALUELABEL) {
+ result = new ModuleBase_WidgetLabelValue(theParent, myWidgetApi);
} else if (theType == WDG_INTEGERVALUE) {
result = new ModuleBase_WidgetIntValue(theParent, myWidgetApi);
} else if (theType == WDG_SHAPE_SELECTOR) {
--- /dev/null
+// Copyright (C) 2014-2016 CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetLabelValue.cpp
+// Created: 30 Nov 2016
+// Author: Natalia ERMOLAEVA
+
+#include "ModuleBase_WidgetLabelValue.h"
+
+#include <Config_WidgetAPI.h>
+#include <Config_Keywords.h>
+#include <ModuleBase_LabelValue.h>
+
+#include <ModelAPI_AttributeDouble.h>
+
+#include <QLabel>
+#include <QVBoxLayout>
+
+ModuleBase_WidgetLabelValue::ModuleBase_WidgetLabelValue(QWidget* theParent,
+ const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
+{
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ aLayout->setContentsMargins(0, 0, 0, 0);
+ aLayout->setSpacing(0);
+
+ QString aText = QString::fromStdString(theData->widgetLabel());
+ QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+ QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+
+ myLabel = new ModuleBase_LabelValue(theParent, aText, aToolTip, aLabelIcon);
+ aLayout->addWidget(myLabel);
+}
+
+ModuleBase_WidgetLabelValue::~ModuleBase_WidgetLabelValue()
+{
+}
+
+QList<QWidget*> ModuleBase_WidgetLabelValue::getControls() const
+{
+ return QList<QWidget*>();
+}
+
+bool ModuleBase_WidgetLabelValue::restoreValueCustom()
+{
+ DataPtr aData = myFeature->data();
+ AttributeDoublePtr anAttribute = aData->real(attributeID());
+ double aValue = 0;
+ if (anAttribute.get() && anAttribute->isInitialized())
+ aValue = anAttribute->value();
+ myLabel->setValue(aValue);
+ return true;
+}
+
+bool ModuleBase_WidgetLabelValue::storeValueCustom()
+{
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetLabelValue.h
+// Created: 30 Nov 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModuleBase_WidgetLabelValue_H
+#define ModuleBase_WidgetLabelValue_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+class ModuleBase_LabelValue;
+
+/**
+* \ingroup GUI
+* Implementation of model widget for a label control
+*/
+class MODULEBASE_EXPORT ModuleBase_WidgetLabelValue : 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_WidgetLabelValue(QWidget* theParent, const Config_WidgetAPI* theData);
+
+ virtual ~ModuleBase_WidgetLabelValue();
+
+ virtual bool restoreValueCustom();
+
+ virtual QList<QWidget*> getControls() const;
+
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValueCustom();
+
+private:
+ ModuleBase_LabelValue* myLabel; ///< A label control
+};
+
+#endif
#include <ModuleBase_ISelection.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_WidgetValidator.h>
+#include <ModuleBase_LabelValue.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
aGroupLay->setColumnStretch(1, 1);
{
QLabel* aLabel = new QLabel(myGroupBox);
- aLabel->setText(tr("X "));
- aGroupLay->addWidget(aLabel, 0, 0);
-
- myXSpin = new ModuleBase_ParamSpinBox(myGroupBox);
- myXSpin->setAcceptVariables(aAcceptVariables);
- myXSpin->setMinimum(-DBL_MAX);
- myXSpin->setMaximum(DBL_MAX);
- myXSpin->setToolTip(tr("X"));
+
+ myXSpin = new ModuleBase_LabelValue(myGroupBox, tr("X"));
+ //ModuleBase_ParamSpinBox(myGroupBox);
+ //myXSpin->setAcceptVariables(aAcceptVariables);
+ //myXSpin->setMinimum(-DBL_MAX);
+ //myXSpin->setMaximum(DBL_MAX);
+ //myXSpin->setToolTip(tr("X"));
aGroupLay->addWidget(myXSpin, 0, 1);
- connect(myXSpin, SIGNAL(textChanged(const QString&)), this, SIGNAL(valuesModified()));
- myXSpin->setValueEnabled(isValueEnabled());
+ //connect(myXSpin, SIGNAL(textChanged(const QString&)), this, SIGNAL(valuesModified()));
+ //myXSpin->setValueEnabled(isValueEnabled());
}
{
- QLabel* aLabel = new QLabel(myGroupBox);
- aLabel->setText(tr("Y "));
- aGroupLay->addWidget(aLabel, 1, 0);
-
- myYSpin = new ModuleBase_ParamSpinBox(myGroupBox);
- myYSpin->setAcceptVariables(aAcceptVariables);
- myYSpin->setMinimum(-DBL_MAX);
- myYSpin->setMaximum(DBL_MAX);
- myYSpin->setToolTip(tr("Y"));
+ //QLabel* aLabel = new QLabel(myGroupBox);
+ //aLabel->setText(tr("Y "));
+ //aGroupLay->addWidget(aLabel, 1, 0);
+
+ myYSpin = new ModuleBase_LabelValue(myGroupBox, tr("Y"));
+ //ModuleBase_ParamSpinBox(myGroupBox);
+ //myYSpin = new ModuleBase_ParamSpinBox(myGroupBox);
+ //myYSpin->setAcceptVariables(aAcceptVariables);
+ //myYSpin->setMinimum(-DBL_MAX);
+ //myYSpin->setMaximum(DBL_MAX);
+ //myYSpin->setToolTip(tr("Y"));
aGroupLay->addWidget(myYSpin, 1, 1);
- connect(myYSpin, SIGNAL(textChanged(const QString&)), this, SIGNAL(valuesModified()));
- myYSpin->setValueEnabled(isValueEnabled());
+ //connect(myYSpin, SIGNAL(textChanged(const QString&)), this, SIGNAL(valuesModified()));
+ //myYSpin->setValueEnabled(isValueEnabled());
}
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
bool PartSet_WidgetPoint2D::resetCustom()
{
bool aDone = false;
- if (!isUseReset() || isComputedDefault() || myXSpin->hasVariable() || myYSpin->hasVariable()) {
+ if (!isUseReset() || isComputedDefault() /*|| myXSpin->hasVariable() || myYSpin->hasVariable()*/) {
aDone = false;
}
else {
double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
// it is important to block the spin box control in order to do not through out the
// locking of the validating state.
- ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
- ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
+ myXSpin->setValue(isOk ? aDefValue : 0.0);
+ myYSpin->setValue(isOk ? aDefValue : 0.0);
+
+ //ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
+ //ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
storeValueCustom();
aDone = true;
}
void PartSet_WidgetPoint2D::selectContent()
{
- myXSpin->selectAll();
+ // myXSpin->selectAll();
}
bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
if (fabs(theY) >= MaxCoordinate)
return false;
- ModuleBase_Tools::setSpinValue(myXSpin, theX);
- ModuleBase_Tools::setSpinValue(myYSpin, theY);
+ myXSpin->setValue(theX);
+ myYSpin->setValue(theY);
+
+ //ModuleBase_Tools::setSpinValue(myXSpin, theX);
+ //ModuleBase_Tools::setSpinValue(myYSpin, theY);
storeValue();
return true;
// if text is not empty then setValue will be ignored
// so we should set the text at first
- aPoint->setText(myXSpin->hasVariable() ? myXSpin->text().toStdString() : "",
- myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
- aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
- !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
+ //aPoint->setText(myXSpin->hasVariable() ? myXSpin->text().toStdString() : "",
+ // myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
+ //aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
+ // !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
+ aPoint->setValue(myXSpin->value(), myYSpin->value());
// after movement the solver will call the update event: optimization
moveObject(myFeature);
bool isDouble = false;
double aVal = 0;
if (aTextX.isEmpty()) {
- ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
+ myXSpin->setValue(aPoint->x());
+ //ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
} else {
aVal = aTextX.toDouble(&isDouble);
- if (isDouble)
+ myXSpin->setValue(aVal);
+ /*if (isDouble)
ModuleBase_Tools::setSpinValue(myXSpin, aVal);
else
- ModuleBase_Tools::setSpinText(myXSpin, aTextX);
+ ModuleBase_Tools::setSpinText(myXSpin, aTextX);*/
}
if (aTextY.isEmpty()) {
- ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
+ myYSpin->setValue(aPoint->y());
+ //ModuleBase_Tools::setSpinValue(myYSpin, aPoint->y());
} else {
aVal = aTextY.toDouble(&isDouble);
- if (isDouble)
- ModuleBase_Tools::setSpinValue(myYSpin, aVal);
- else
- ModuleBase_Tools::setSpinText(myYSpin, aTextY);
+ myYSpin->setValue(aVal);
+ //if (isDouble)
+ // ModuleBase_Tools::setSpinValue(myYSpin, aVal);
+ //else
+ // ModuleBase_Tools::setSpinText(myYSpin, aTextY);
}
//if (aTextX.empty() || aTextY.empty()) {
// ModuleBase_Tools::setSpinValue(myXSpin, aPoint->x());
void PartSet_WidgetPoint2D::storeCurentValue()
{
// do not use cash if a variable is used
- if (myXSpin->hasVariable() || myYSpin->hasVariable())
- return;
+ //if (myXSpin->hasVariable() || myYSpin->hasVariable())
+ // return;
myValueIsCashed = true;
myIsFeatureVisibleInCash = XGUI_Displayer::isVisible(
myValueIsCashed = false;
myIsFeatureVisibleInCash = true;
- ModuleBase_Tools::setSpinValue(myXSpin, myXValueInCash);
- ModuleBase_Tools::setSpinValue(myYSpin, myYValueInCash);
+ myXSpin->setValue(myXValueInCash);
+ myYSpin->setValue(myYValueInCash);
+ //ModuleBase_Tools::setSpinValue(myXSpin, myXValueInCash);
+ //ModuleBase_Tools::setSpinValue(myYSpin, myYValueInCash);
// store value to the model
storeValueCustom();
}
}
+void PartSet_WidgetPoint2D::setHighlighted(bool isHighlighted)
+{
+}
+
void PartSet_WidgetPoint2D::deactivate()
{
// the value of the control should be stored to model if it was not
bool PartSet_WidgetPoint2D::processEnter()
{
- bool isModified = getValueState() == ModifiedInPP;
+ return false;
+ /*bool isModified = getValueState() == ModifiedInPP;
if (isModified) {
bool isXModified = myXSpin->hasFocus();
emit valuesChanged();
else
myYSpin->selectAll();
}
- return isModified;
+ return isModified;*/
}
bool PartSet_WidgetPoint2D::useSelectedShapes() const
class ModuleBase_IWorkshop;
class ModuleBase_ParamSpinBox;
class ModuleBase_IViewWindow;
+class ModuleBase_LabelValue;
class GeomAPI_Pnt2d;
class ModuleBase_IWorkshop;
/// The methiod called when widget is activated
virtual void activateCustom();
+ //! Switch On/Off highlighting of the widget
+ virtual void setHighlighted(bool isHighlighted);
+
/// Returns true if the feature contains Point2D attribute with the same coordinates
/// The attribute of the widget is not processed.
/// \param theFeature a feature
private:
QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
- ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
- ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
+ //ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
+ //ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
+ ModuleBase_LabelValue* myXSpin; ///< the label for the X coordinate
+ ModuleBase_LabelValue* myYSpin; ///< the label for the Y coordinate
/// value used as selection in mouse release method
std::shared_ptr<ModuleBase_ViewerPrs> myPreSelected;
enable_value="enable_by_preferences"/>
<sketch-2dpoint_selector id="EndPoint" accept_expressions="0" title="End point" tooltip="End point coordinates"
enable_value="enable_by_preferences"/>
- <doublevalue id="LineLength" accept_expressions="0" label="Length:" default="computed" icon="icons/Sketch/distance_value.png"
+ <labelvalue id="LineLength" accept_expressions="0" label="Length:" default="computed" icon="icons/Sketch/distance_value.png"
tooltip="Line length" obligatory="0" enable_value="false"/>
<boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
<validator id="GeomValidators_Different" parameters="StartPoint,EndPoint"/>
enable_value="enable_by_preferences"/>
</box>
</toolbox>
- <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon="icons/Sketch/radius.png"
+ <labelvalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon="icons/Sketch/radius.png"
tooltip="Set radius" obligatory="0" enable_value="enable_by_preferences">
<validator id="GeomValidators_Positive"/>
- </doublevalue>
- <doublevalue id="ArcAngle" label="Angle:" icon="icons/Sketch/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"
+ </labelvalue>
+ <labelvalue id="ArcAngle" label="Angle:" icon="icons/Sketch/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"
enable_value="enable_by_preferences"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"
- enable_value="enable_by_preferences"/>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
</feature>
<!-- SketchConstraintFillet -->
clear_in_neutral_point="false">
<validator id="SketchPlugin_FilletVertexValidator"/>
</sketch_multi_selector>
- <doublevalue label="Radius" tooltip="Fillet arc radius" id="ConstraintValue" accept_expressions="0" min="0" use_reset="false"
+ <labelvalue label="Radius" tooltip="Fillet arc radius" id="ConstraintValue" accept_expressions="0" min="0" use_reset="false"
enable_value="enable_by_preferences">
<validator id="GeomValidators_Positive"/>
- </doublevalue>
+ </labelvalue>
<validator id="PartSet_FilletSelection"/>
</feature>
<!-- SketchConstraintSplit -->