X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Tools.cpp;h=21fa0db1f29eb7d676bf0b2aab3a964a6272268b;hb=a2982d2108f929cf9e7f996cfd590c4ce59dc21c;hp=f246677ce22ad2e8a0aaff7dbac4d01854c3c991;hpb=efaa3e56c591f0b6a0e018cc91027ff5f82b2438;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index f246677ce..21fa0db1f 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModuleBase_Tools.cpp // Created: 11 July 2014 // Author: Vitaly Smetannikov @@ -5,6 +7,8 @@ #include "ModuleBase_Tools.h" #include #include +#include +#include namespace ModuleBase_Tools { @@ -42,7 +46,56 @@ void zeroMargins(QLayout* theLayout) theLayout->setSpacing(5); } +QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon) +{ + QImage anIcon(theIcon); + QImage anAditional(theAdditionalIcon); + + if (anIcon.isNull()) + return QPixmap(); + + 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 + aStartWidthPos < aWidth; i++) + { + for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++) + { + if (qAlpha(anAditional.pixel(i, j)) > 0) + anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j)); + } + } + return QPixmap::fromImage(anIcon); +} + +QPixmap lighter(const QString& theIcon, const int theLighterValue) +{ + QImage anIcon(theIcon); + if (anIcon.isNull()) + return QPixmap(); + + QImage aResult(theIcon); + for ( int i = 0; i < anIcon.width(); i++ ) + { + for ( int j = 0; j < anIcon.height(); j++ ) + { + QRgb anRgb = anIcon.pixel( i, j ); + QColor aPixelColor(qRed(anRgb), qGreen(anRgb), qBlue(anRgb), + qAlpha( aResult.pixel( i, j ) )); + QColor aLighterColor = aPixelColor.lighter(theLighterValue); + aResult.setPixel(i, j, qRgba( aLighterColor.red(), aLighterColor.green(), + aLighterColor.blue(), aLighterColor.alpha() ) ); + } + } + return QPixmap::fromImage(aResult); +} }