Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TYPalette Class Reference

Classe de definition d'une palette. More...

#include <TYPalette.h>

Inheritance diagram for TYPalette:
Inheritance graph
[legend]
Collaboration diagram for TYPalette:
Collaboration graph
[legend]

Public Types

typedef float values_type
 The real number type used to store values (typically double or float) More...
 
typedef std::map< values_type, OColorcolor_map_type
 
typedef color_map_type::iterator color_map_iter
 
typedef color_map_type::const_iterator color_map_const_iter
 
typedef color_map_type::value_type color_map_item
 

Public Member Functions

 TYPalette ()
 A TYPalette represents a mapping from values to colors. More...
 
 TYPalette (const TYPalette &other)
 Constructeur par copie. Constructeur par copie de la classe TYPalette. More...
 
virtual ~TYPalette ()
 Destructeur. Destructeur de la classe TYPalette. More...
 
TYPaletteoperator= (const TYPalette &other)
 
bool operator== (const TYPalette &other) const
 
bool operator!= (const TYPalette &other) const
 
virtual bool deepCopy (const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
 
virtual std::string toString () const
 
virtual DOM_Element toXML (DOM_Element &domElement)
 
virtual int fromXML (DOM_Element domElement)
 
void clear ()
 
values_type getValueMin () const
 Get de la valeur min. More...
 
values_type getValueMax () const
 Get de la valeur max. More...
 
size_t getNbColors () const
 Getter for the number of colors. More...
 
size_t getNbValues () const
 Getter for the number of values. More...
 
const OColorgetInfColor () const
 Get de la couleur pour la borne inf. More...
 
void setInfColor (const OColor &color)
 Set de la couleur pour la borne inf. More...
 
const OColorgetSupColor () const
 Get/Set de la couleur pour la borne sup. More...
 
void setSupColor (const OColor &color)
 Set de la couleur pour la borne sup. More...
 
bool insertColor (values_type value, const OColor &color)
 Insert a new color or update an existing one. More...
 
bool moveValue (values_type old_value, values_type new_value)
 Moves an existing bound,. More...
 
bool removeValue (values_type value)
 Removes an existing bound. More...
 
void resetcolorMapFromColors (values_type valueMin, values_type valueMax, const std::vector< OColor > &lookupTable)
 Reset the colormap as a linear scale with the given colors between minValue and maxValue. More...
 
void resetToDefault ()
 Reset the colormap to a hard-coded default. More...
 
bool resetFromPreferences ()
 Reset the colormap from the preferences XXX. More...
 
void saveToPreferences ()
 Saves the colormap to the preferences XXX. More...
 
const color_map_typegetColorMap () const
 Get de la lookup table. More...
 
const OColorgetColorFromValue (values_type value) const
 Set de la lookup table. More...
 
const OColorgetColorFromIndex (unsigned i) const
 Get de la couleur par index. More...
 
TYPalette::values_type getValueFromIndex (unsigned i) const
 Get de la valeur par index. More...
 
values_type denormalize (values_type percent) const
 Set de la couleur pour une valeur. More...
 
values_type normalize (values_type value) const
 Normalize a value, ie convert a value between min and max to a percentage. More...
 
bool savePaletteToFile (const QString &qFileName)
 Save the Palette into a file with the name given. More...
 
void makeLinearPalette (size_t nb_colors, float value_min, float value_max)
 Make a linear palette from a min/max couple. More...
 
- Public Member Functions inherited from TYElement
void * getAllUses ()
 
void setAllUses (void *allUses)
 
void cleanAllUses ()
 
 TYElement ()
 
 TYElement (TYElement *pParent, bool PutInInstanceList=true)
 
 TYElement (const TYElement &other, bool PutInInstanceList=true)
 
virtual ~TYElement ()
 
void setID (TYUUID id)
 
void setID (const QString &str_id)
 
const TYUUIDgetID () const
 
QString getStringID () const
 
bool hasNullID () const
 
void regenerateID ()
 
void setName (QString name)
 
void setName (std::string name)
 
virtual QString getName () const
 
void setParent (TYElement *pParent)
 
TYElementgetParent () const
 
virtual void setIsAcousticModified (bool isModified)
 
bool getIsAcousticModified ()
 
virtual void setIsGeometryModified (bool isModified)
 
bool getIsGeometryModified ()
 
TYElementoperator= (const TYElement &other)
 
bool operator== (const TYElement &other) const
 
bool operator!= (const TYElement &other) const
 
bool callFromXMLIfEqual (DOM_Element &domElement, int *pRetVal=NULL)
 
std::string getMetierName ()
 
virtual void updateCurrentCalcul (TYListID &listID, bool recursif=true)
 
virtual void getChilds (LPTYElementArray &childs, bool recursif=true)
 
virtual void setInCurrentCalcul (bool state, bool recurschild=true, bool recursparent=true)
 
virtual bool isInCurrentCalcul ()
 
void addCopy ()
 Increment le compteur de nombre de copies. More...
 
void setCopyCount (const unsigned int copyCount)
 Modifie la vaeur du compteur. More...
 
- Public Member Functions inherited from IRefCount
 IRefCount ()
 
virtual ~IRefCount ()
 
virtual int incRef ()
 
virtual int decRef ()
 
int getRefCount () const
 
- Public Member Functions inherited from OPrototype
virtual ~OPrototype ()
 
virtual OPrototypeclone () const =0
 
virtual const char * getClassName () const
 
bool isA (const char *className) const
 

Static Public Member Functions

static LPTYPalette loadPaletteFromFile (const QString &qFileName)
 Create a new TYPalette from an XML file Holding only one Palette. More...
 
- Static Public Member Functions inherited from TYElement
static LPTYElementArray findTypeCollectionAndCallFromXML (DOM_Element parentElem, const char *type)
 
static void setLogInstances (bool log)
 
static bool getLogInstances ()
 
static TYElementgetInstance (TYUUID uuid)
 
static void purgeInstances ()
 
static bool testId (const TYUUID &id, const TYElement *pElem)
 
static TYUUID newID ()
 
static TYUUID fromString (QString id)
 
static QString toString (TYUUID &uuid)
 
static uint64 getConstructorCount ()
 
static uint64 getDestructorCount ()
 
static uint64 getIdGenerationCount ()
 
static bool getIsSavedOk ()
 
static void setIsSavedOk (const bool &toSave)
 
static void setRegenerateID (const bool &bRegenerate)
 
static bool getRegenerateID ()
 
- Static Public Member Functions inherited from OPrototype
static OPrototypefindAndClone (const char *className)
 
static int findPrototype (const char *className)
 
static OPrototypesafeDownCast (OPrototype *pObject)
 
static void add_factory (const char *, IOProtoFactory::ptr_type factory)
 

Static Public Attributes

static const values_type infinity = std::numeric_limits<values_type>::infinity()
 

Protected Member Functions

int load_legacy_XML (const DOM_Element &domElement)
 implement loading legacy (pre v4.6) XML format for TYPalettes More...
 
DOM_Element save_legacy_XML (DOM_Element &domElement)
 implement loading legacy (pre v4.6) XML format for TYPalettes More...
 
- Protected Member Functions inherited from OPrototype
 OPrototype ()
 

Protected Attributes

color_map_type _colorMap
 
- Protected Attributes inherited from TYElement
QString _name
 Nom courant de l'element. More...
 
TYElement_pParent
 Reference sur l'element parent. More...
 
bool _bPutInInstanceList
 
unsigned int _copyCount
 
bool _inCurrentCalcul
 Indique si cet element est actif dans le Calcul courant. More...
 
bool _isAcousticModified
 Indicateur de modification acoustique. More...
 
bool _isGeometryModified
 Indicateur de modification de la geometrie. More...
 
LPTYElementGraphic _pGraphicObject
 L'object graphique metier associe a cet element. More...
 
void * _allUses
 Multi purpose void pointer (use for compatibility actually) More...
 
- Protected Attributes inherited from IRefCount
int m_refCount
 The reference counter. More...
 

Detailed Description

Classe de definition d'une palette.

Version
v 1.0
Author
Projet_Tympan
Date
2008/04/17

Definition at line 40 of file TYPalette.h.

Member Typedef Documentation

◆ color_map_const_iter

typedef color_map_type::const_iterator TYPalette::color_map_const_iter

Definition at line 54 of file TYPalette.h.

◆ color_map_item

typedef color_map_type::value_type TYPalette::color_map_item

Definition at line 55 of file TYPalette.h.

◆ color_map_iter

typedef color_map_type::iterator TYPalette::color_map_iter

Definition at line 53 of file TYPalette.h.

◆ color_map_type

Definition at line 52 of file TYPalette.h.

◆ values_type

typedef float TYPalette::values_type

The real number type used to store values (typically double or float)

Definition at line 50 of file TYPalette.h.

Constructor & Destructor Documentation

◆ TYPalette() [1/2]

TYPalette::TYPalette ( )

A TYPalette represents a mapping from values to colors.

Definition at line 42 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TYPalette() [2/2]

TYPalette::TYPalette ( const TYPalette other)

Constructeur par copie. Constructeur par copie de la classe TYPalette.

Definition at line 151 of file TYPalette.cpp.

◆ ~TYPalette()

TYPalette::~TYPalette ( )
virtual

Destructeur. Destructeur de la classe TYPalette.

Definition at line 157 of file TYPalette.cpp.

Member Function Documentation

◆ clear()

void TYPalette::clear ( )

Definition at line 143 of file TYPalette.cpp.

Here is the caller graph for this function:

◆ deepCopy()

bool TYPalette::deepCopy ( const TYElement pOther,
bool  copyId = true,
bool  pUseCopyTag = false 
)
virtual

Effectue une copie en allouant de la memoire (deep copy) et non pas en copiant seulement les pointeurs (shallow copy). Cette methode s'utilise comme l'operateur egal. L'ID peut ne pas etre copie, le parent n'est jamais copie.

Parameters
pOtherL'element a copier.
copyIdCopie l'identifiant unique ou pas.
Returns
true si la copie est possible; false sinon.

Reimplemented from TYElement.

Definition at line 185 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ denormalize()

values_type TYPalette::denormalize ( values_type  percent) const
inline

Set de la couleur pour une valeur.

Denormalize a value, ie convert a percentage to a value between min and max

Definition at line 227 of file TYPalette.h.

Here is the call graph for this function:

◆ fromXML()

int TYPalette::fromXML ( DOM_Element  domElement)
virtual

Extrait les informations a partir du noeud DOM passe afin de recuperer les parametres de la classe.

Parameters
domElementLe noeud DOM a partir duquel les parametres doivent etre recuperes.
Returns
1 si la recuperation des parametres a reussie.

Reimplemented from TYElement.

Definition at line 381 of file TYPalette.cpp.

Here is the call graph for this function:

◆ getColorFromIndex()

const OColor & TYPalette::getColorFromIndex ( unsigned  i) const

Get de la couleur par index.

Definition at line 479 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getColorFromValue()

const OColor & TYPalette::getColorFromValue ( values_type  value) const

Set de la lookup table.

Set de la couleur pour un pourcentage Get de la couleur pour une valeur

Definition at line 470 of file TYPalette.cpp.

Here is the caller graph for this function:

◆ getColorMap()

const color_map_type& TYPalette::getColorMap ( ) const
inline

Get de la lookup table.

Returns
_colorMap

Definition at line 191 of file TYPalette.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInfColor()

const OColor& TYPalette::getInfColor ( ) const
inline

Get de la couleur pour la borne inf.

Returns
_colorMap.front()

Definition at line 121 of file TYPalette.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNbColors()

size_t TYPalette::getNbColors ( ) const
inline

Getter for the number of colors.

Returns
the number of colors (i.e. number of values plus one)

Definition at line 109 of file TYPalette.h.

Here is the caller graph for this function:

◆ getNbValues()

size_t TYPalette::getNbValues ( ) const
inline

Getter for the number of values.

Returns
the number of values (i.e. number of colors minus one)

Definition at line 115 of file TYPalette.h.

Here is the caller graph for this function:

◆ getSupColor()

const OColor& TYPalette::getSupColor ( ) const
inline

Get/Set de la couleur pour la borne sup.

Returns
_colorMap.back()

Definition at line 132 of file TYPalette.h.

Here is the caller graph for this function:

◆ getValueFromIndex()

TYPalette::values_type TYPalette::getValueFromIndex ( unsigned  i) const

Get de la valeur par index.

Definition at line 491 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValueMax()

values_type TYPalette::getValueMax ( ) const
inline

Get de la valeur max.

Returns
_valueMax

Definition at line 103 of file TYPalette.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValueMin()

values_type TYPalette::getValueMin ( ) const
inline

Get de la valeur min.

Returns
_valueMin

Definition at line 97 of file TYPalette.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertColor()

bool TYPalette::insertColor ( values_type  value,
const OColor color 
)

Insert a new color or update an existing one.

Parameters
valuethe upper-bound to insert or update
colorvalues up to value will be associated to
Returns
true when a new value has been inserted, false when the color for an existing one has been updated

Definition at line 198 of file TYPalette.cpp.

Here is the caller graph for this function:

◆ load_legacy_XML()

int TYPalette::load_legacy_XML ( const DOM_Element domElement)
protected

implement loading legacy (pre v4.6) XML format for TYPalettes

Definition at line 328 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadPaletteFromFile()

LPTYPalette TYPalette::loadPaletteFromFile ( const QString &  qFileName)
static

Create a new TYPalette from an XML file Holding only one Palette.

Returns
a Smart Pointer to the Palette newly created or NULL in case of failure

Definition at line 504 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeLinearPalette()

void TYPalette::makeLinearPalette ( size_t  nb_colors,
float  value_min,
float  value_max 
)

Make a linear palette from a min/max couple.

Definition at line 532 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveValue()

bool TYPalette::moveValue ( values_type  old_value,
values_type  new_value 
)

Moves an existing bound,.

The new value must lie within the interval occupied by the old one. You can move the upper bound by giving a greater value as well.

Returns
whether the move was successful (otherwise the palette is not modified)

Definition at line 210 of file TYPalette.cpp.

Here is the caller graph for this function:

◆ normalize()

TYPalette::values_type TYPalette::normalize ( values_type  value) const

Normalize a value, ie convert a value between min and max to a percentage.

Definition at line 462 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool TYPalette::operator!= ( const TYPalette other) const

◆ operator=()

TYPalette & TYPalette::operator= ( const TYPalette other)

Definition at line 162 of file TYPalette.cpp.

Here is the call graph for this function:

◆ operator==()

bool TYPalette::operator== ( const TYPalette other) const

Definition at line 172 of file TYPalette.cpp.

◆ removeValue()

bool TYPalette::removeValue ( values_type  value)

Removes an existing bound.

Returns
whether the removal was successful (otherwise the palette is not modified)

Definition at line 245 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetcolorMapFromColors()

void TYPalette::resetcolorMapFromColors ( values_type  valueMin,
values_type  valueMax,
const std::vector< OColor > &  lookupTable 
)

Reset the colormap as a linear scale with the given colors between minValue and maxValue.

Definition at line 125 of file TYPalette.cpp.

Here is the caller graph for this function:

◆ resetFromPreferences()

bool TYPalette::resetFromPreferences ( )

Reset the colormap from the preferences XXX.

Definition at line 73 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetToDefault()

void TYPalette::resetToDefault ( )

Reset the colormap to a hard-coded default.

Definition at line 49 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_legacy_XML()

DOM_Element TYPalette::save_legacy_XML ( DOM_Element domElement)
protected

implement loading legacy (pre v4.6) XML format for TYPalettes

Definition at line 293 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ savePaletteToFile()

bool TYPalette::savePaletteToFile ( const QString &  qFileName)

Save the Palette into a file with the name given.

Returns
if the operation was succesful

Definition at line 521 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToPreferences()

void TYPalette::saveToPreferences ( )

Saves the colormap to the preferences XXX.

Definition at line 103 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInfColor()

void TYPalette::setInfColor ( const OColor color)
inline

Set de la couleur pour la borne inf.

Definition at line 126 of file TYPalette.h.

Here is the call graph for this function:

◆ setSupColor()

void TYPalette::setSupColor ( const OColor color)
inline

Set de la couleur pour la borne sup.

Definition at line 137 of file TYPalette.h.

Here is the call graph for this function:

◆ toString()

std::string TYPalette::toString ( ) const
virtual

Retourne une chaine de caractere donnant des informations sur cet objet (utile pour le debugage).

Returns
Une chaine de caractere informative sur cet objet.

Reimplemented from TYElement.

Definition at line 193 of file TYPalette.cpp.

◆ toXML()

DOM_Element TYPalette::toXML ( DOM_Element domElement)
virtual

Construit une arborescence DOM a partir du noeud passe afin de sauvegarder les parametres au format XML.

Parameters
domElementLe noeud DOM parent a partir duquel l'arborescence doit etre creee.
Returns
Le noeud DOM nouvellement cree.

Reimplemented from TYElement.

Definition at line 264 of file TYPalette.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _colorMap

color_map_type TYPalette::_colorMap
protected

Definition at line 253 of file TYPalette.h.

◆ infinity

const TYPalette::values_type TYPalette::infinity = std::numeric_limits<values_type>::infinity()
static

Definition at line 91 of file TYPalette.h.


The documentation for this class was generated from the following files: