Files
EgtGeomKernel/Color.cpp
T
Dario Sassi 155c722466 EgtGeomKernel 1.5c9 :
- migliorata gestione colori standard
- aggiunta gestione attributi Mark
- aggiunta gestione degli oggetti selezionati
- modifiche ad esecutore per selezionati  e variabile $SEL.
2014-03-23 12:33:48 +00:00

143 lines
4.1 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : Color.cpp Data : 12.03.14 Versione : 1.5a5
// Contenuto : Implementazione funzioni per gestione colori.
//
//
//
// Modifiche : 12.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnStringUtils.h"
using namespace std ;
//------------------------- Constants ----------------------------------------
static const char* SZ_WHITE = "WHITE" ;
static const char* SZ_LGRAY = "LGRAY" ;
static const char* SZ_GRAY = "GRAY" ;
static const char* SZ_BLACK = "BLACK" ;
static const char* SZ_RED = "RED" ;
static const char* SZ_MAROON = "MAROON" ;
static const char* SZ_YELLOW = "YELLOW" ;
static const char* SZ_OLIVE = "OLIVE" ;
static const char* SZ_LIME = "LIME" ;
static const char* SZ_GREEN = "GREEN" ;
static const char* SZ_AQUA = "AQUA" ;
static const char* SZ_TEAL = "TEAL" ;
static const char* SZ_BLUE = "BLUE" ;
static const char* SZ_NAVY = "NAVY" ;
static const char* SZ_FUCHSIA = "FUCHSIA" ;
static const char* SZ_PURPLE = "PURPLE" ;
static const char* SZ_ORANGE = "ORANGE" ;
static const char* SZ_BROWN = "BROWN" ;
//----------------------------------------------------------------------------
bool
GetStdColor( const string& sName, Color& cCol)
{
string sCol = sName ;
ToUpper( sCol) ;
if ( sCol == SZ_WHITE)
cCol = WHITE ;
else if ( sCol == SZ_LGRAY)
cCol = LGRAY ;
else if ( sCol == SZ_GRAY)
cCol = GRAY ;
else if ( sCol == SZ_BLACK)
cCol = BLACK ;
else if ( sCol == SZ_RED)
cCol = RED ;
else if ( sCol == SZ_MAROON)
cCol = MAROON ;
else if ( sCol == SZ_YELLOW)
cCol = YELLOW ;
else if ( sCol == SZ_OLIVE)
cCol = OLIVE ;
else if ( sCol == SZ_LIME)
cCol = LIME ;
else if ( sCol == SZ_GREEN)
cCol = GREEN ;
else if ( sCol == SZ_AQUA)
cCol = AQUA ;
else if ( sCol == SZ_TEAL)
cCol = TEAL ;
else if ( sCol == SZ_BLUE)
cCol = BLUE ;
else if ( sCol == SZ_NAVY)
cCol = NAVY ;
else if ( sCol == SZ_FUCHSIA)
cCol = FUCHSIA ;
else if ( sCol == SZ_PURPLE)
cCol = PURPLE ;
else if ( sCol == SZ_ORANGE)
cCol = ORANGE ;
else if ( sCol == SZ_BROWN)
cCol = BROWN ;
else
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
GetNameOfStdColor( Color cCol, string& sName)
{
if ( cCol == WHITE)
sName = SZ_WHITE ;
else if ( cCol == LGRAY)
sName = SZ_LGRAY ;
else if ( cCol == GRAY)
sName = SZ_GRAY ;
else if ( cCol == BLACK)
sName = SZ_BLACK ;
else if ( cCol == RED)
sName = SZ_RED ;
else if ( cCol == MAROON)
sName = SZ_MAROON ;
else if ( cCol == YELLOW)
sName = SZ_YELLOW ;
else if ( cCol == OLIVE)
sName = SZ_OLIVE ;
else if ( cCol == LIME)
sName = SZ_LIME ;
else if ( cCol == GREEN)
sName = SZ_GREEN ;
else if ( cCol == AQUA)
sName = SZ_AQUA ;
else if ( cCol == TEAL)
sName = SZ_TEAL ;
else if ( cCol == BLUE)
sName = SZ_BLUE ;
else if ( cCol == NAVY)
sName = SZ_NAVY ;
else if ( cCol == FUCHSIA)
sName = SZ_FUCHSIA ;
else if ( cCol == PURPLE)
sName = SZ_PURPLE ;
else if ( cCol == ORANGE)
sName = SZ_ORANGE ;
else if ( cCol == BROWN)
sName = SZ_BROWN ;
else
return false ;
return true ;
}
//----------------------------------------------------------------------------
Color
GetOppositeColor( Color cCol)
{
return Color( MAX_RGB - cCol.GetIntRed(),
MAX_RGB - cCol.GetIntGreen(),
MAX_RGB - cCol.GetIntBlue(),
cCol.GetIntAlpha()) ;
}