From: nds Date: Mon, 8 Dec 2014 16:40:43 +0000 (+0300) Subject: Icons correction X-Git-Tag: V_0.6.0^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e87259160f612bdf93435ccb8399c96bd7fba671;p=modules%2Fshaper.git Icons correction --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index b95b5bc9f..0f57b4c7b 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -53,12 +53,21 @@ QPixmap composite(const QString& theAdditionalIcon, const int theXShift, if (anIcon.isNull()) return QPixmap(); - for (int i = theXShift; i < anAditional.width() + theXShift && i < anIcon.width(); i++) + int anAddWidth = anAditional.width(); + int anAddHeight = anAditional.height(); + + int aWidth = anIcon.width(); + int aHeight = anIcon.height(); + + int aStartWidthPos = aWidth-anAddWidth-1; + int aStartHeightPos = aHeight-anAddHeight-1; + + for (int i = 0; i < anAddWidth; i++) { - for (int j = theYShift; j < anAditional.height() + theYShift && j < anIcon.height(); j++) + for (int j = 0; j < anAddHeight; j++) { - if (qAlpha(anAditional.pixel(i - theXShift, j - theYShift)) > 0) - anIcon.setPixel(i, j, anAditional.pixel(i - theXShift, j - theYShift)); + if (qAlpha(anAditional.pixel(i, j)) > 0) + anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j)); } } return QPixmap::fromImage(anIcon); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8a696e67e..0bf4c4bcb 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -76,41 +76,44 @@ QMap XGUI_Workshop::myIcons; -QPixmap XGUI_Workshop::featureIcon(const FeaturePtr& theFeature) +std::string XGUI_Workshop::featureIconStr(const FeaturePtr& theFeature) { - QPixmap aPixmap; - std::string aKind = theFeature->getKind(); QString aId(aKind.c_str()); if (!myIcons.contains(aId)) - return aPixmap; + return std::string(); + + return myIcons[aId].toStdString(); +} - QString anIconString = myIcons[aId]; +QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature) +{ + QIcon anIcon; + + QString anIconString = featureIconStr(theFeature).c_str(); ModelAPI_ExecState aState = theFeature->data()->execState(); switch(aState) { case ModelAPI_StateDone: case ModelAPI_StateNothing: - aPixmap = QPixmap(anIconString); - break; + anIcon = QIcon(anIconString); case ModelAPI_StateMustBeUpdated: { - aPixmap = ModuleBase_Tools::lighter(anIconString); + anIcon = ModuleBase_Tools::lighter(anIconString); } break; case ModelAPI_StateExecFailed: { - aPixmap = ModuleBase_Tools::composite(":pictures/exec_state_failed.png", + anIcon = ModuleBase_Tools::composite(":pictures/exec_state_failed.png", 12, 12, anIconString); } break; case ModelAPI_StateInvalidArgument: { - aPixmap = ModuleBase_Tools::composite(":pictures/exec_state_invalid_parameters.png", + anIcon = ModuleBase_Tools::composite(":pictures/exec_state_invalid_parameters.png", 12, 12, anIconString); } break; default: break; } - - return aPixmap; + return anIcon; } XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 54e9f26fd..95a70579a 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include class XGUI_MainWindow; class XGUI_Command; @@ -143,8 +143,11 @@ Q_OBJECT return myModuleConnector; } - //! Returns icon name according to feature Id - static QPixmap featureIcon(const FeaturePtr& theFeature); + //! Returns icon name according to feature + static QIcon featureIcon(const FeaturePtr& theFeature); + + //! Returns icon name according to feature + static std::string featureIconStr(const FeaturePtr& theFeature); //! Activates or deactivates a part //! If PartPtr is Null pointer then PartSet will be activated