Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPalette.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #include <limits>
17 #include <cmath>
18 
19 #include <boost/foreach.hpp>
20 #include <boost/tuple/tuple.hpp>
21 #include <boost/math/special_functions/fpclassify.hpp>
22 
23 #include <QDebug>
24 
25 #include "Tympan/core/logging.h"
28 #include "TYPalette.h"
29 
30 #include <math.h>
31 
32 #if TY_USE_IHM
35 #endif
36 
39 
40 const TYPalette::values_type TYPalette::infinity = std::numeric_limits<values_type>::infinity();
41 
43 {
45 
47 }
48 
50 {
51  // Valeurs min et max
52  double valueMin = 40.0f;
53  double valueMax = 75.0f;
54 
55  // NB : Legacy LookupTable for preferences backward compatibility
56  OLookupTable lookupTable;
57  lookupTable.resize(9);
58 
59  // Couleurs
60  lookupTable[0] = OColor(76.0f / 255.0f, 230.0f / 255.0f, 0.0f);
61  lookupTable[1] = OColor(85.0f / 255.0f, 1.0f, 0.0f);
62  lookupTable[2] = OColor(209.0f / 255.0f, 1.0f, 115.0f / 255.0f);
63  lookupTable[3] = OColor(1.0f, 1.0f, 81.0f / 255.0f);
64  lookupTable[4] = OColor(1.0f, 1.0f, 0.0f);
65  lookupTable[5] = OColor(1.0f, 170.0f / 255.0f, 0.0f);
66  lookupTable[6] = OColor(1.0f, 85.0f / 255.0f, 0.0f);
67  lookupTable[7] = OColor(227.0f / 255.0f, 0.0f, 0.0f);
68  lookupTable[8] = OColor(168.0f / 255.0f, 0.0f, 0.0f);
69  resetcolorMapFromColors(valueMin, valueMax, lookupTable);
70 }
71 
73 {
74 #if TY_USE_IHM
75  QString pref = "PaletteDefault";
76  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, pref + "Min"))
77  {
78  OLookupTable lookupTable;
79  double valueMin = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, pref + "Min");
80  double valueMax = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, pref + "Max");
81  lookupTable.resize(TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, pref + "NbColors"));
82  for (size_t i = 0; i < lookupTable.size(); ++i)
83  {
84  OColor color;
85  // TODO load values in an analogous way ?
86  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER,
87  pref + "Color" + QString(uintToStr(i).c_str()), color.r, color.g,
88  color.b);
89  lookupTable[i] = color;
90  }
91  resetcolorMapFromColors(valueMin, valueMax, lookupTable);
92  return true;
93  }
94  else
95  {
96  return false;
97  }
98 #else
99  return false;
100 #endif
101 }
102 
104 {
105 #if TY_USE_IHM
106  QString pref = "PaletteDefault";
107  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, pref + "Min", getValueMin());
108  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, pref + "Max", getValueMax());
109  TYPreferenceManager::setUInt(TYDIRPREFERENCEMANAGER, pref + "NbColors", getNbColors());
110 
111  // For each (value : color) in the color map
112  values_type value = NAN;
113  OColor color;
114  unsigned i = 0;
115  BOOST_FOREACH (boost::tie(value, color), getColorMap())
116  {
117  // TODO save values in an analogous way ?
118  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, pref + "Color" + QString(uintToStr(i).c_str()),
119  color.r, color.g, color.b);
120  ++i;
121  }
122  assert(i == getNbColors());
123 #endif
124 }
125 
127  const std::vector<OColor>& lookupTable)
128 {
129  const size_t nbColors = lookupTable.size();
130  const size_t nbValues = lookupTable.size() - 1;
131  assert(nbColors > 2 && "A color map needs at least three colors");
132  const values_type interval = (valueMax - valueMin) / (values_type)(nbValues - 1);
133 
134  _colorMap.clear();
135  for (size_t i = 0; i < lookupTable.size(); ++i)
136  {
137  // the key for the last color is + infinity
138  // otherwise we compute a regular scale of nbValues-1 intervals
139  const values_type value = (i == nbColors - 1) ? infinity : valueMin + interval * i;
140  _colorMap.insert(_colorMap.end(), std::make_pair(value, lookupTable[i]));
141  }
142 }
143 
145 {
146  _colorMap.clear();
147  _colorMap.insert(_colorMap.end(), std::make_pair(0.0f, OColor::BLACK));
148  _colorMap.insert(_colorMap.end(), std::make_pair(infinity, OColor::WHITE));
149 }
150 
151 // XXX Not needed
153 {
154  *this = other;
155 }
156 
157 // XXX Not needed
159 
161 {
162  if (this != &other)
163  {
164  TYElement::operator=(other);
165  _colorMap = other._colorMap;
166  }
167  return *this;
168 }
169 
170 bool TYPalette::operator==(const TYPalette& other) const
171 {
172  if (this == &other)
173  {
174  return true;
175  }
176  // This might be not the best way to compare two TYPalette
177  if (TYElement::operator!=(other))
178  {
179  return false;
180  }
181  if (_colorMap != other._colorMap)
182  {
183  return false;
184  }
185 
186  return true;
187 }
188 
189 bool TYPalette::deepCopy(const TYElement* pOther, bool copyId /*= true*/, bool pUseCopyTag /*=false*/)
190 {
191  if (!TYElement::deepCopy(pOther, copyId))
192  {
193  return false;
194  }
195  TYPalette* pOtherPalette = (TYPalette*)pOther;
196  _colorMap = pOtherPalette->_colorMap;
197  return true;
198 }
199 
200 std::string TYPalette::toString() const
201 {
202  return "TYPalette";
203 }
204 
205 bool TYPalette::insertColor(values_type value, const OColor& color)
206 {
207 
208  std::pair<TYPalette::color_map_iter, bool> status = _colorMap.insert(std::make_pair(value, color));
209  if (!status.second) // Insertion was not possible : value already exists
210  {
211  status.first->second = color; // The existing value is associated to the new color
212  }
213  return status.second;
214 }
215 
216 bool TYPalette::moveValue(values_type old_value, values_type new_value)
217 {
218  TYPalette::color_map_iter where = _colorMap.lower_bound(old_value); // XXX Use find of lower bound ?
219  assert(where != _colorMap.end() &&
220  "This should never happen as the last value is always supposed to be +inf");
221  values_type actual_value = where->first;
222  TYPalette::color_map_iter after(where);
223  if (boost::math::isfinite(actual_value)) // is not greater than the upper bound
224  {
225  ++after;
226  }
227  else // We are moving the upper bound from a greater old_value
228  {
229  --where;
230  }
231 
232  // The new value must lie betwee the (otherwise unchanged) values around old value.
233  if (new_value >= after->first)
234  {
235  return false;
236  }
237  if (where != _colorMap.begin())
238  {
239  TYPalette::color_map_iter before(where);
240  --before;
241  if (new_value <= before->first)
242  {
243  return false;
244  }
245  }
246  // Otherwise, we do update the map
247  OColor color = where->second;
248  _colorMap.erase(where);
249  _colorMap.insert(after, std::make_pair(new_value, color));
250  return true;
251 }
252 
254 {
255  TYPalette::color_map_iter where = _colorMap.find(value);
256  if (where == _colorMap.end()) // value was not en exact bound
257  {
258  return false;
259  }
260  values_type actual_value = where->first;
261  if (boost::math::isfinite(actual_value) &&
262  getNbValues() > 1) // We can not remove the infinite bound nor the last finite one
263  {
264  _colorMap.erase(where);
265  return true;
266  }
267  else
268  {
269  return false;
270  }
271 }
272 
273 DOM_Element TYPalette::toXML(DOM_Element& domElement) /* const */
274 {
275  // Keep basic stuff for pseudo compat / testing XXX
276  DOM_Element domNewElem = save_legacy_XML(domElement); // TYElement::toXML(domElement);
277 
278  // Creates a new node to save the color map
279  DOM_Document domDoc = domElement.ownerDocument();
280  DOM_Element colorMapElem = domDoc.createElement("colorMap");
281 
282  // For each (value : color) in the color map
283  values_type value = NAN;
284  OColor color;
285  unsigned i = 0;
286  BOOST_FOREACH (boost::tie(value, color), getColorMap())
287  {
288  DOM_Element colorMapEntry = domDoc.createElement("colorMapEntry");
289  // NB infinity (lest value) will be rendered as "inf"
290  colorMapEntry.setAttribute("value", value);
291  unsigned colorcode = color.getAsRGBA();
292  colorMapEntry.setAttribute("color", colorcode);
293  ++i;
294  colorMapElem.appendChild(colorMapEntry);
295  }
296  assert(i == getNbColors());
297 
298  domNewElem.appendChild(colorMapElem);
299  return domNewElem;
300 }
301 
303 {
304  DOM_Element domNewElem = TYElement::toXML(domElement);
305 
306  // Valeurs min et max
307  TYXMLTools::addElementFloatValue(domNewElem, "valueMin", getValueMin());
308  TYXMLTools::addElementFloatValue(domNewElem, "valueMax", getValueMax());
309 
310  // Creation d'un nouveau noeud pour l'ensemble des couleurs
311  DOM_Document domDoc = domElement.ownerDocument();
312  DOM_Element lookupTableElem = domDoc.createElement("lookupTable");
313  domNewElem.appendChild(lookupTableElem);
314 
315  // Ajout du nombre de couleur
316  unsigned int nbColors = static_cast<uint32>(_colorMap.size());
317  lookupTableElem.setAttribute("nbColors", nbColors);
318 
319  // Formatage des donnees
320  std::ostringstream oss;
321  values_type value = NAN;
322  OColor color;
323  BOOST_FOREACH (boost::tie(value, color), getColorMap())
324  {
325  oss << color.getAsRGBA() << " ";
326  }
327 
328  DOMString tab(oss.str().c_str());
329 
330  // Ajout des donnees
331  QDomText data = domDoc.createTextNode(tab);
332  lookupTableElem.appendChild(data);
333 
334  return domNewElem;
335 }
336 
338 {
339  DOM_Element elemCur;
340  QDomNodeList children = domElement.elementsByTagName("lookupTable");
341  values_type valueMin = NAN, valueMax = NAN;
342  // NB : Legacy LookupTable for preferences backward compatibility
343  OLookupTable lookupTable;
344 
345  int status = 0;
346  if (children.length() == 0)
347  {
348  // no colorMap entry, attempt loading according to legacy format
349  status = load_legacy_XML(domElement);
350  if (!status)
352  "No lookupTable element while reading the legacy 'Palette' named %s (id %s).",
353  this->_name.toLocal8Bit().data(), this->getID().toString().toLocal8Bit().data());
354  return status;
355  }
356  if (children.length() > 1)
357  {
359  "While reading the 'Palette' named %s (id %s) : only one lookupTable element is expected.",
360  this->_name.toLocal8Bit().data(), this->getID().toString().toLocal8Bit().data());
361  return 0;
362  }
363  assert(children.length() == 1);
364  QDomElement lookupTableElement = children.at(0).toElement();
365  QString elemName = lookupTableElement.nodeName();
366  assert(elemName == "lookupTable");
367 
368  TYXMLTools::getElementFloatValue(domElement.firstChildElement("valueMin"), "valueMin", valueMin);
369  TYXMLTools::getElementFloatValue(domElement.firstChildElement("valueMax"), "valueMax", valueMax);
370  // On recupere le nombre de couleur
371  size_t nbColors = TYXMLTools::getElementAttributeToInt(lookupTableElement, "nbColors");
372 
373  // On resize la lookupTable
374  lookupTable.resize(nbColors);
375 
376  // On recupere les couleurs
377  QString colors;
378  TYXMLTools::getElementStringValue(lookupTableElement, "lookupTable", colors);
379  std::istringstream iss(colors.toLatin1().data());
380 
381  // On extrait les couleurs de la string
382  unsigned int rgba = 0;
383  for (unsigned int i = 0; i < nbColors; ++i)
384  {
385  iss >> rgba;
386  lookupTable[i].setAsRGBA(rgba);
387  }
388  resetcolorMapFromColors(valueMin, valueMax, lookupTable);
389  return 1;
390 }
391 
393 {
394  TYElement::fromXML(domElement);
395  QDomNodeList children = domElement.elementsByTagName("colorMap");
396  int status = 0;
397  if (children.length() == 0)
398  {
399  // no colorMap entry, attempt loading according to legacy format
400  status = load_legacy_XML(domElement);
401  if (!status)
403  "Invalid legacy format (pre colorMap) while reading the 'Palette' named %s (id %s).",
404  this->_name.toLocal8Bit().data(), this->getID().toString().toLocal8Bit().data());
405  return status;
406  }
407  if (children.length() > 1)
408  {
409  OMessageManager::get()->error("Invalid format while reading the 'Palette' named %s (id %s) : only "
410  "one colorMap element is expected.",
411  this->_name.toLocal8Bit().data(),
412  this->getID().toString().toLocal8Bit().data());
413  return 0;
414  }
415  assert(children.length() == 1);
416  QDomElement colorMapElement = children.at(0).toElement();
417  QString elemName = colorMapElement.nodeName();
418  assert(elemName == "colorMap");
419  children = domElement.elementsByTagName("colorMapEntry"); // XXX colorMapElement
420 
421  clear();
422  for (unsigned i = 0; i < children.length(); ++i)
423  {
424  bool ok = false;
425  double value = NAN;
426  OColor color;
427  int rgb = 0;
428  const QDomElement entryElement = children.item(i).toElement();
429 
430  value = TYXMLTools::getElementAttributeToDouble(entryElement, "value", &ok);
431  if (!ok)
432  {
433 
434  OMessageManager::get()->error("Invalid %dth colorMapEntry while reading the 'Palette' named %s "
435  "(id %s) : expected value field not '%s'",
436  i, this->_name.toLocal8Bit().data(),
437  this->getID().toString().toLocal8Bit().data(),
438  xml2cstring(entryElement));
439  return 0;
440  }
441  else
442  {
443  ok = false;
444  }
445  rgb = TYXMLTools::getElementAttributeToUnsigned(entryElement, "color", &ok);
446  if (!ok)
447  {
448  QString msg;
449  QTextStream str(&msg);
450  entryElement.save(str, 0);
451  OMessageManager::get()->error("Invalid %dth colorMapEntry while reading the 'Palette' named %s "
452  "(id %s) : expected RGB field not '%s'",
453  i, this->_name.toLocal8Bit().data(),
454  this->getID().toString().toLocal8Bit().data(),
455  msg.toLocal8Bit().data());
456  return 0;
457  }
458  else
459  {
460  ok = false;
461  }
462  color.setAsRGBA(static_cast<unsigned>(rgb));
463  if (i == 0) // This lower bound needs to be moved, not inserted
464  {
465  assert(getValueMin() == 0.0 && getInfColor() == OColor::BLACK); // Check cleared state
466  ok = moveValue(0, value);
467  assert(ok);
468  ok = insertColor(value, color);
469  assert(!ok); // False status means the value already existed, which is expected here.
470  }
471  else
472  {
473  ok = insertColor(value, color);
474  if (!ok)
475  {
476  return 0;
477  }
478  }
479  }
480  return 1;
481 }
482 
484 {
485  assert(getNbColors() > 1);
486  const double amplitude = getValueMax() - getValueMin();
487  assert(amplitude > std::numeric_limits<values_type>::epsilon());
488  return (value - getValueMin()) / amplitude;
489 }
490 
492 {
493  // Look up into the map
494  color_map_type::const_iterator it = _colorMap.lower_bound(value);
495  assert(it != _colorMap.end() && "This should never happen.");
496  return it->second;
497 }
498 
499 const OColor& TYPalette::getColorFromIndex(unsigned i) const
500 {
501  assert(i < getNbColors());
502  color_map_type::const_iterator it = _colorMap.begin();
503  for (; i > 0; i--) // Advance it by i elements
504  {
505  assert(it != _colorMap.end());
506  ++it;
507  }
508  return it->second;
509 }
510 
512 {
513  assert(i < getNbColors());
514  color_map_type::const_iterator it = _colorMap.begin();
515  for (; i > 0; i--) // Advance it by i elements
516  {
517  assert(it != _colorMap.end());
518  ++it;
519  }
520  return it->first;
521 }
522 
523 // This function hold code moved from TYPalletteWidget, where it did not belong.
525 {
526  // Chargement du fichier
527  TYXMLManager xmlManager;
528  LPTYElementArray elements;
529 
530  bool status = xmlManager.load(qFileName, elements);
531  if (status)
532  if (elements.size() == 1)
533  {
534  return TYPalette::safeDownCast(elements[0]);
535  }
536  elements.clear();
537  return LPTYPalette(); // Invalid file format
538 }
539 
540 // This function hold code moved from TYPalletteWidget, where it did not belong.
541 bool TYPalette::savePaletteToFile(const QString& qFileName)
542 {
543  TYXMLManager xmlManager;
544  xmlManager.createDoc("Tympan", "");
545  LPTYPalette pPalette = new TYPalette(*this);
546  xmlManager.addElement(pPalette);
547  bool status = xmlManager.save(qFileName) == 0;
548  return status;
549 }
550 
551 void TYPalette::makeLinearPalette(unsigned int nb_colors, float value_min, float value_max)
552 {
553  float hueRange[2], saturationRange[2], valueRange[2];
554  getInfColor().getAsHSB(hueRange[0], saturationRange[0], valueRange[0]);
555  getSupColor().getAsHSB(hueRange[1], saturationRange[1], valueRange[1]);
556  OLookupTable lookupLinear;
557 
558  // const size_t nb_colors = getNbColors();
559  TYColorManager::getLinearColorTable(nb_colors, hueRange, saturationRange, valueRange, lookupLinear);
560 
561  // resetcolorMapFromColors(getValueMin(), getValueMax(), lookupLinear);
562  resetcolorMapFromColors(value_min, value_max, lookupLinear);
563 }
QString DOMString
Definition: QT2DOM.h:31
QDomDocument DOM_Document
Definition: QT2DOM.h:33
QDomElement DOM_Element
Definition: QT2DOM.h:30
SmartPtr< TYPalette > LPTYPalette
Smart pointer sur TYPalette.
Definition: TYDefines.h:316
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:345
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
const char * xml2cstring(const QDomNode &node)
Definition: TYElement.h:1025
Representation d'une palette graphique (fichier header)
Outil IHM pour une palette (fichier header)
TY_EXT_GRAPHIC_INST(TYPalette)
TY_EXTENSION_INST(TYPalette)
Definition: color.h:31
unsigned int getAsRGBA() const
Definition: color.cpp:44
float b
Definition: color.h:33
static const OColor BLACK
Definition: color.h:86
static const OColor WHITE
Definition: color.h:93
void getAsHSB(float &hue, float &saturation, float &brightness) const
Definition: color.cpp:91
float r
Definition: color.h:33
float g
Definition: color.h:33
void setAsRGBA(const unsigned int val)
Definition: color.cpp:71
virtual void error(const char *message,...)
Definition: logging.cpp:127
static OMessageManager * get()
Definition: logging.cpp:108
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
static void getLinearColorTable(const unsigned int &nbColors, const float *hueRange, const float *saturationRange, const float *valueRange, OLookupTable &outColors)
Generation de la table de couleurs basee sur une rampe lineaire ( y = x+0.5/255 )
Definition: color.cpp:308
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
Classe de definition d'une palette.
Definition: TYPalette.h:41
virtual std::string toString() const
Definition: TYPalette.cpp:200
size_t getNbValues() const
Getter for the number of values.
Definition: TYPalette.h:131
bool removeValue(values_type value)
Removes an existing bound.
Definition: TYPalette.cpp:253
void makeLinearPalette(unsigned int nb_colors, float value_min, float value_max)
Make a linear palette from a min/max couple.
Definition: TYPalette.cpp:551
const OColor & getColorFromValue(values_type value) const
Set de la lookup table.
Definition: TYPalette.cpp:491
bool resetFromPreferences()
Reset the colormap from the preferences XXX.
Definition: TYPalette.cpp:72
const OColor & getInfColor() const
Get de la couleur pour la borne inf.
Definition: TYPalette.h:140
const color_map_type & getColorMap() const
Get de la lookup table.
Definition: TYPalette.h:226
size_t getNbColors() const
Getter for the number of colors.
Definition: TYPalette.h:122
void resetToDefault()
Reset the colormap to a hard-coded default.
Definition: TYPalette.cpp:49
const OColor & getSupColor() const
Get/Set de la couleur pour la borne sup.
Definition: TYPalette.h:159
const OColor & getColorFromIndex(unsigned i) const
Get de la couleur par index.
Definition: TYPalette.cpp:499
DOM_Element save_legacy_XML(DOM_Element &domElement)
implement loading legacy (pre v4.6) XML format for TYPalettes
Definition: TYPalette.cpp:302
TYPalette()
A TYPalette represents a mapping from values to colors.
Definition: TYPalette.cpp:42
static LPTYPalette loadPaletteFromFile(const QString &qFileName)
Create a new TYPalette from an XML file Holding only one Palette.
Definition: TYPalette.cpp:524
color_map_type _colorMap
Definition: TYPalette.h:292
bool operator==(const TYPalette &other) const
Definition: TYPalette.cpp:170
bool savePaletteToFile(const QString &qFileName)
Save the Palette into a file with the name given.
Definition: TYPalette.cpp:541
values_type getValueMax() const
Get de la valeur max.
Definition: TYPalette.h:112
TYPalette & operator=(const TYPalette &other)
Definition: TYPalette.cpp:160
void clear()
Definition: TYPalette.cpp:144
TYPalette::values_type getValueFromIndex(unsigned i) const
Get de la valeur par index.
Definition: TYPalette.cpp:511
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYPalette.cpp:273
bool moveValue(values_type old_value, values_type new_value)
Moves an existing bound,.
Definition: TYPalette.cpp:216
float values_type
The real number type used to store values (typically double or float)
Definition: TYPalette.h:49
void saveToPreferences()
Saves the colormap to the preferences XXX.
Definition: TYPalette.cpp:103
virtual ~TYPalette()
Destructeur. Destructeur de la classe TYPalette.
Definition: TYPalette.cpp:158
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.
Definition: TYPalette.cpp:126
values_type normalize(values_type value) const
Normalize a value, ie convert a value between min and max to a percentage.
Definition: TYPalette.cpp:483
static const values_type infinity
Definition: TYPalette.h:96
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYPalette.cpp:189
virtual int fromXML(DOM_Element domElement)
Definition: TYPalette.cpp:392
values_type getValueMin() const
Get de la valeur min.
Definition: TYPalette.h:102
bool insertColor(values_type value, const OColor &color)
Insert a new color or update an existing one.
Definition: TYPalette.cpp:205
color_map_type::iterator color_map_iter
Definition: TYPalette.h:52
int load_legacy_XML(const DOM_Element &domElement)
implement loading legacy (pre v4.6) XML format for TYPalettes
Definition: TYPalette.cpp:337
int save(QString fileName)
int load(const QString &fileName, LPTYElementArray &eltCollection)
void createDoc(QString docName, QString version)
int addElement(TYElement *pElt)
static int getElementAttributeToInt(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:293
static bool getElementStringValue(DOM_Element parentElem, DOMString nodeName, QString &nodeValue)
Definition: TYXMLTools.cpp:93
static unsigned getElementAttributeToUnsigned(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:298
static bool getElementFloatValue(DOM_Element parentElem, DOMString nodeName, float &nodeValue)
Definition: TYXMLTools.cpp:211
static double getElementAttributeToDouble(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:288
static void addElementFloatValue(DOM_Element &parentElem, DOMString nodeName, float nodeValue)
Definition: TYXMLTools.cpp:82
std::vector< OColor > OLookupTable
Collection de OColor.
Definition: color.h:105
unsigned int uint32
Definition: defines.h:60
std::string uintToStr(unsigned int val)
Definition: macros.h:86