From: nds Date: Tue, 19 Apr 2016 14:21:42 +0000 (+0300) Subject: DOF is visualized in label widget. X-Git-Tag: V_2.3.0~182 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3a60523c3fa0af9d8daf760fcf13f7f2c45836de;p=modules%2Fshaper.git DOF is visualized in label widget. XGUI_Workshop correction to have right error solver value by resume sketch operation. Earlier it was done by repaint of this widget. --- diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 471d0b9da..a941f30d2 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -26,7 +26,6 @@ const static char* PROPERTY_PANEL_ID = "property_panel_id"; // Widgets const static char* WDG_INFO = "label"; -const static char* WDG_ERRORINFO = "error_label"; const static char* WDG_DOUBLEVALUE = "doublevalue"; const static char* WDG_INTEGERVALUE = "integervalue"; const static char* WDG_BOOLVALUE = "boolvalue"; @@ -72,6 +71,7 @@ const static char* _PARAMETERS = "parameters"; const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP; const static char* ATTR_ICON = FEATURE_ICON; const static char* ATTR_LABEL = "label"; +const static char* ATTR_STYLE_SHEET = "styleSheet"; const static char* ATTR_DEFAULT = "default"; const static char* ATTR_INTERNAL = "internal"; const static char* ATTR_OBLIGATORY = "obligatory"; diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 2553a9506..0e3066310 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -61,7 +61,6 @@ SET(PROJECT_HEADERS ModuleBase_WidgetValidated.h ModuleBase_WidgetValidator.h ModuleBase_IconFactory.h - ModuleBase_WidgetErrorLabel.h ModuleBase_Dialog.h ) @@ -120,7 +119,6 @@ SET(PROJECT_SOURCES ModuleBase_WidgetValidated.cpp ModuleBase_WidgetValidator.cpp ModuleBase_IconFactory.cpp - ModuleBase_WidgetErrorLabel.cpp ModuleBase_SelectionValidator.cpp ModuleBase_Dialog.cpp ) diff --git a/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp b/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp deleted file mode 100644 index cbcbae63f..000000000 --- a/src/ModuleBase/ModuleBase_WidgetErrorLabel.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetErrorLabel.cpp -// Created: 03 Dec 2014 -// Author: Vitaly SMETANNIKOV - -#include "ModuleBase_WidgetErrorLabel.h" - -#include -#include -#include - -#include -#include - -ModuleBase_WidgetErrorLabel::ModuleBase_WidgetErrorLabel(QWidget* theParent, - const Config_WidgetAPI* theData) -: ModuleBase_WidgetLabel(theParent, theData) -{ - myDefaultStyle = myLabel->styleSheet(); - myLabel->setContentsMargins(0,0,0,4); - myLabel->setWordWrap(true); - myLabel->installEventFilter(this); -} - -ModuleBase_WidgetErrorLabel::~ModuleBase_WidgetErrorLabel() -{ -} - -bool ModuleBase_WidgetErrorLabel::restoreValueCustom() -{ - DataPtr aData = myFeature->data(); - AttributeStringPtr aStrAttr = aData->string(attributeID()); - std::string aMsg; - if (aStrAttr.get()) { - aMsg = aStrAttr->value(); - } - if (aMsg.empty()) { - myLabel->setText(""); - myLabel->setStyleSheet(myDefaultStyle); - } else { - myLabel->setText(aMsg.c_str()); - //myLabel->setStyleSheet("QLabel { color : red; font : italic }"); - myLabel->setStyleSheet("QLabel { color : red; font : bold }"); - //myLabel->setStyleSheet("QLabel { border: 1px solid red; }"); - } - return true; -} - - -bool ModuleBase_WidgetErrorLabel::focusTo() -{ - restoreValue(); - return false; -} - -bool ModuleBase_WidgetErrorLabel::eventFilter(QObject* theObj, QEvent* theEvent) -{ - if (theObj == myLabel) { - if (theEvent->type() == QEvent::Show) - restoreValue(); - } - return ModuleBase_WidgetLabel::eventFilter(theObj, theEvent); -} diff --git a/src/ModuleBase/ModuleBase_WidgetErrorLabel.h b/src/ModuleBase/ModuleBase_WidgetErrorLabel.h deleted file mode 100644 index 9adee7cce..000000000 --- a/src/ModuleBase/ModuleBase_WidgetErrorLabel.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetErrorLabel.h -// Created: 03 Dec 2014 -// Author: Vitaly SMETANNIKOV - -#ifndef ModuleBase_WidgetErrorLabel_H -#define ModuleBase_WidgetErrorLabel_H - -#include "ModuleBase.h" -#include "ModuleBase_WidgetLabel.h" - -class QLabel; - -/** -* \ingroup GUI -* Implementation of model widget for a label with error message -*/ -class MODULEBASE_EXPORT ModuleBase_WidgetErrorLabel : public ModuleBase_WidgetLabel -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent the parent object - /// \param theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetErrorLabel(QWidget* theParent, const Config_WidgetAPI* theData); - - virtual ~ModuleBase_WidgetErrorLabel(); - - virtual bool restoreValueCustom(); - - virtual bool focusTo(); - -protected: - bool eventFilter(QObject* theObj, QEvent* theEvent); - -private: - QString myDefaultStyle; -}; - -#endif diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 7e100f94e..d8e6bc262 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -283,8 +282,6 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std:: if (theType == WDG_INFO) { result = new ModuleBase_WidgetLabel(theParent, myWidgetApi); - } else if (theType == WDG_ERRORINFO) { - result = new ModuleBase_WidgetErrorLabel(theParent, myWidgetApi); } else if (theType == WDG_DOUBLEVALUE) { result = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi); } else if (theType == WDG_INTEGERVALUE) { diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.cpp b/src/ModuleBase/ModuleBase_WidgetLabel.cpp index e1e41ecd1..31fe1f6c7 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLabel.cpp @@ -7,8 +7,11 @@ #include "ModuleBase_WidgetLabel.h" #include +#include #include +#include + #include #include @@ -22,10 +25,16 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent, myLabel->setWordWrap(true); myLabel->setIndent(5); myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); + myLabel->setContentsMargins(0,0,0,4); + QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); aLayout->addWidget(myLabel); setLayout(aLayout); + + std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET).c_str(); + if (!aStyleSheet.empty()) + myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str())); } ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel() @@ -37,3 +46,22 @@ QList ModuleBase_WidgetLabel::getControls() const return QList(); } +bool ModuleBase_WidgetLabel::restoreValueCustom() +{ + DataPtr aData = myFeature->data(); + AttributeStringPtr aStrAttr = aData->string(attributeID()); + if (aStrAttr.get()) { + std::string aMsg; + if (aStrAttr.get()) { + aMsg = aStrAttr->value(); + } + myLabel->setText(aMsg.c_str()); + } + return true; +} + +bool ModuleBase_WidgetLabel::focusTo() +{ + restoreValue(); + return false; +} diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.h b/src/ModuleBase/ModuleBase_WidgetLabel.h index d2ab2d647..4812f29b6 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.h +++ b/src/ModuleBase/ModuleBase_WidgetLabel.h @@ -31,15 +31,12 @@ Q_OBJECT /// It returns false because this is an info widget virtual bool canAcceptFocus() const { return false; }; - virtual bool restoreValueCustom() - { - return true; - } + virtual bool restoreValueCustom(); virtual QList getControls() const; /// This control doesn't accept focus - virtual bool focusTo() { return false; } + virtual bool focusTo(); protected: /// Saves the internal parameters to the given feature diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 354666bc9..e30faa17a 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -55,6 +55,7 @@ void SketchPlugin_Sketch::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID()); data()->addAttribute(SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), SketchPlugin_Sketch::SOLVER_ERROR()); } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index d541415f3..a67069fe8 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -68,6 +68,13 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu return MY_SOLVER_ERROR; } + /// Sketch solver error + inline static const std::string& SOLVER_DOF() + { + static const std::string MY_SOLVER_DOF("SolverDOF"); + return MY_SOLVER_DOF; + } + /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() { diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index d60744f51..2839741b7 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -13,7 +13,8 @@ - +