XGUI_Workshop correction to have right error solver value by resume sketch operation. Earlier it was done by repaint of this widget.
// 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";
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";
ModuleBase_WidgetValidated.h
ModuleBase_WidgetValidator.h
ModuleBase_IconFactory.h
- ModuleBase_WidgetErrorLabel.h
ModuleBase_Dialog.h
)
ModuleBase_WidgetValidated.cpp
ModuleBase_WidgetValidator.cpp
ModuleBase_IconFactory.cpp
- ModuleBase_WidgetErrorLabel.cpp
ModuleBase_SelectionValidator.cpp
ModuleBase_Dialog.cpp
)
+++ /dev/null
-// 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 <Config_WidgetAPI.h>
-#include <ModuleBase_Tools.h>
-#include <ModelAPI_AttributeString.h>
-
-#include <QLabel>
-#include <QEvent>
-
-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);
-}
+++ /dev/null
-// 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
#include <ModuleBase_WidgetLineEdit.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetLabel.h>
-#include <ModuleBase_WidgetErrorLabel.h>
#include <ModuleBase_WidgetToolbox.h>
#include <ModuleBase_PageBase.h>
#include <ModuleBase_PageGroupBox.h>
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) {
#include "ModuleBase_WidgetLabel.h"
#include <Config_WidgetAPI.h>
+#include <Config_Keywords.h>
#include <ModuleBase_Tools.h>
+#include <ModelAPI_AttributeString.h>
+
#include <QLabel>
#include <QVBoxLayout>
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()
return QList<QWidget*>();
}
+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;
+}
/// 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<QWidget*> 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
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());
}
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()
{
<sketch-start-label id="External" title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch">
<validator id="GeomValidators_Face" parameters="plane"/>
</sketch-start-label>
- <error_label id="SolverError"/>
+ <label id="SolverDOF"/>
+ <label id="SolverError" styleSheet="color : red; font : bold"/>
<validator id="SketchPlugin_SolverErrorValidator"/>
</feature>
} catch (...) {
// Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::SOLVESPACE_CRASH());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
if (myPrevResult == STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
// the error message should be changed before sending the message
sendMessage(EVENT_SOLVER_FAILED);
updateMultiConstraints(myConstraints);
if (myPrevResult != STATUS_OK || myPrevResult == STATUS_UNKNOWN) {
getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue("");
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
// the error message should be changed before sending the message
sendMessage(EVENT_SOLVER_REPAIRED, myConflictingConstraints);
myConflictingConstraints.clear();
if (!myConstraints.empty()) {
// the error message should be changed before sending the message
getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(SketchSolver_Error::CONSTRAINTS());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
if (myPrevResult != aResult || myPrevResult == STATUS_UNKNOWN) {
// Obtain list of conflicting constraints
std::set<ObjectPtr> aConflicting = myStorage->getConflictingConstraints(mySketchSolver);
#include <list>
#include <set>
#include <memory>
+#include <cmath>
static const Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
// reset error message on the sketch
aGroup->getWorkplane()->string(SketchPlugin_Sketch::SOLVER_ERROR())->setValue(
SketchSolver_Error::CONSTRAINTS());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
break;
}
}
if (aFound != myDoF.end() && aFound->second == aDoFIt->second)
continue; // nothing is changed
myDoF[aDoFIt->first] = aDoFIt->second;
- // send a message
- std::shared_ptr<ModelAPI_SolverFailedMessage> aMessage =
- std::shared_ptr<ModelAPI_SolverFailedMessage>(
- new ModelAPI_SolverFailedMessage(Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)));
- aMessage->dof(aDoFIt->second);
- Events_Loop::loop()->send(aMessage);
+ // change attribute value
+ char aValue[10];
+ _itoa_s(aDoFIt->second, aValue, 10);
+ aDoFIt->first->data()->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(
+ "DOF(degree of freedom) = "+ std::string(aValue));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
}
}
!aWidget->getDefaultValue().empty() &&
!aWidget->isComputedDefault();
aWidget->setFeature(aFeature, isStoreValue, isUpdateFlushed);
+ if (!isStoreValue)
+ aWidget->restoreValue();
aWidget->enableFocusProcessing();
}
ModuleBase_Tools::flushUpdated(aFeature);