Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPaletteWidget.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 
23 #include <limits>
24 
25 #include <boost/foreach.hpp>
26 #include <boost/tuple/tuple.hpp>
27 #include <boost/math/special_functions/fpclassify.hpp>
28 
30 #include "Tympan/core/logging.h"
31 #include "Tympan/core/color.h"
32 #include "TYLookupTableWidget.h"
36 
37 #include <math.h>
38 #include <qcolordialog.h>
39 #include <qfiledialog.h>
40 #include <qpainter.h>
41 #include <qmessagebox.h>
42 #include <qtablewidget.h>
43 // Added by qt3to4:
44 #include <QGridLayout>
45 #include <QLabel>
46 #include <QTextStream>
47 
48 #include "TYPaletteWidget.h"
49 
50 #define TR(id) OLocalizator::getString("TYPaletteWidget", (id))
51 
52 TYPaletteWidget::TYPaletteWidget(TYPalette* pElement, QWidget* _pParent /*=NULL*/)
53  : TYWidget(pElement, _pParent, NULL, Qt::Dialog)
54 {
55 #ifndef NDEBUG
56  bool ok = false;
57 #endif
58  resize(500, 800);
59  setWindowTitle(TR("id_caption"));
60  _paletteLayout = new QVBoxLayout();
61  setLayout(_paletteLayout);
62 
63  // ELEMENT
64  _elmW = new TYElementWidget(pElement, this);
65  _paletteLayout->addWidget(_elmW);
66 
67  // ColorMap table
68  QGroupBox* pGroupBoxColorMap = new QGroupBox(this);
69  pGroupBoxColorMap->setTitle(TR("id_editarray"));
70  QVBoxLayout* internalLayout = new QVBoxLayout();
71  pGroupBoxColorMap->setLayout(internalLayout);
72  _editor = new PaletteEditor(getElement());
73  internalLayout->addWidget(_editor);
74  _paletteLayout->addWidget(pGroupBoxColorMap, 1);
75 
76  // ColorMap preview
77  QGroupBox* pGroupBoxPreview = new QGroupBox(this);
78  pGroupBoxPreview->setTitle(TR("id_lookuptableview"));
79  // NB The internal layout of the pGroupBoxPreview is set by TYLabeledLookupTableWidget()
80  p_previewWidget = new TYLabeledLookupTableWidget(getElement(), pGroupBoxPreview);
81  _paletteLayout->addWidget(pGroupBoxPreview);
82 #ifndef NDEBUG
83  ok =
84 #endif
87  assert(ok);
88 
89  // SAVE/LOAD/RESET
90  QGroupBox* pGroupBoxSaveLoad = new QGroupBox(this);
91  pGroupBoxSaveLoad->setTitle(TR("id_saveload"));
92  QGridLayout* pGroupBoxSaveLoadLayout = new QGridLayout();
93  pGroupBoxSaveLoad->setLayout(pGroupBoxSaveLoadLayout);
94  // Load button
95  _pushButtonLoadPalette = new QPushButton(pGroupBoxSaveLoad);
96  _pushButtonLoadPalette->setText(TR("id_load"));
97  pGroupBoxSaveLoadLayout->addWidget(_pushButtonLoadPalette, 0, 0);
98  QObject::connect(_pushButtonLoadPalette, &QPushButton::clicked, this, &TYPaletteWidget::loadPalette);
99  // Save button
100  _pushButtonSavePalette = new QPushButton(pGroupBoxSaveLoad);
101  _pushButtonSavePalette->setText(TR("id_save"));
102  pGroupBoxSaveLoadLayout->addWidget(_pushButtonSavePalette, 0, 1);
103  QObject::connect(_pushButtonSavePalette, &QPushButton::clicked, this, &TYPaletteWidget::savePalette);
104  // Reset button
105  _pushButtonResetPalette = new QPushButton(pGroupBoxSaveLoad);
106  _pushButtonResetPalette->setText(TR("id_reset"));
107  pGroupBoxSaveLoadLayout->addWidget(_pushButtonResetPalette, 0, 2);
108  QObject::connect(_pushButtonResetPalette, &QPushButton::clicked, this, &TYPaletteWidget::resetPalette);
109  // Linear button
110  _pushButtonLinearPalette = new QPushButton(pGroupBoxSaveLoad);
111  _pushButtonLinearPalette->setText(TR("id_linear"));
112  pGroupBoxSaveLoadLayout->addWidget(_pushButtonLinearPalette, 0, 3);
113  QObject::connect(_pushButtonLinearPalette, &QPushButton::clicked, this,
115 
116  _paletteLayout->addWidget(pGroupBoxSaveLoad);
117 
118  updateContent();
119 }
120 
122 
124 {
125  // Mise a jour de l'element
126  _elmW->updateContent();
128 }
129 
130 void TYPaletteWidget::apply() // Override
131 {
132  // Element
133  _elmW->apply();
134 }
135 
137 {
138  if (!getElement()->resetFromPreferences())
139  {
140  getElement()->resetToDefault();
141  getElement()->saveToPreferences();
142  }
143  updateContent();
144 }
145 
147 {
148  TYPaletteLimitsWidget* limits = new TYPaletteLimitsWidget(getElement(), this);
149  bool ret = limits->exec();
150  if (ret == QDialog::Accepted)
151  {
152  updateContent();
153  }
154 }
155 
157 {
158  QString qFileName = QFileDialog::getOpenFileName(this, "Choose a file", QString(), "XML (*.xml)");
159 
160  if (!qFileName.isEmpty())
161  {
162  if (!qFileName.endsWith(".xml"))
163  {
164  qFileName += ".xml";
165  }
166 
167  bool loaded = false;
168  LPTYPalette pPalette = TYPalette::loadPaletteFromFile(qFileName);
169  if (pPalette)
170  {
171  (*getElement()) = *pPalette;
172  updateContent();
173  loaded = true;
174  }
175  else
176  {
177  OMessageManager::get()->error("Invalid Palette file %s : the one element is not a Palette.",
178  qFileName.toUtf8().data());
179  }
180 
181  if (loaded)
182  {
183  QMessageBox::information(this, "Tympan", TR("id_import_ok").arg(qFileName));
184  }
185  else
186  {
187  QMessageBox::warning(this, "Tympan", TR("id_import_failed").arg(qFileName));
188  }
189  }
190 }
191 
193 {
194  QString qFileName = QFileDialog::getSaveFileName(this, "Choose a file", QString(), "XML (*.xml)");
195 
196  if (qFileName.isEmpty())
197  {
198  return;
199  }
200 
201  if (!qFileName.endsWith(".xml"))
202  {
203  qFileName += ".xml";
204  }
205 
206  bool save = true;
207 
208  // Verification de l'etat du fichier
209  QFileInfo fi(qFileName);
210 
211  // Si le fichier existe , on demande confirmation a l'utilisateur
212  if (fi.exists())
213  {
214  // On ecrase le fichier, puis on sauve
215  QFile* file = new QFile(qFileName);
216  switch (
217  QMessageBox::warning(this, "Attention", TR("id_file_exist"), QMessageBox::Yes, QMessageBox::No))
218  {
219  case QMessageBox::Yes:
220  if (!file->remove())
221  {
222  QMessageBox::warning(this, "Attention", TR("id_file_cannot_be_clear"));
223  save = false;
224  }
225  break;
226  case QMessageBox::No:
227  save = false;
228  break;
229  }
230 
231  delete file;
232  }
233 
234  if (save)
235  {
236  LPTYPalette pPalette = new TYPalette(*getElement());
237 
238  bool status = pPalette->savePaletteToFile(qFileName);
239  if (status)
240  {
241  QMessageBox::information(this, "Tympan", TR("id_export_ok").arg(qFileName));
242  }
243  else
244  {
245  QMessageBox::warning(this, "Tympan", TR("id_export_failed").arg(qFileName));
246  }
247  }
248 }
249 
250 /* --------------- class PaletteModel --------------- */
251 
252 PaletteModel::PaletteModel(TYPalette* p_palette_, QObject* parent)
253  : QAbstractTableModel(parent), p_palette(p_palette_)
254 {
255 }
256 
258 
259 int PaletteModel::rowCount(const QModelIndex& parent) const
260 {
261  return static_cast<int>(p_palette->getNbColors());
262 }
263 
264 int PaletteModel::columnCount(const QModelIndex& parent) const
265 {
266  return 2;
267 }
268 
269 void PaletteModel::getBoundsForValue(unsigned row, float& inf, float& sup) const
270 
271 {
272  inf = -std::numeric_limits<float>::infinity();
273  sup = +std::numeric_limits<float>::infinity();
274 
275  if (row > 0)
276  {
277  inf = p_palette->getValueFromIndex(row - 1);
278  }
279  if (row < rowCount(QModelIndex()) - 1)
280  {
281  sup = p_palette->getValueFromIndex(row + 1);
282  }
283 }
284 
285 QVariant PaletteModel::data(const QModelIndex& index, int role) const
286 {
287  if (!index.isValid())
288  {
289  return QVariant();
290  }
291  switch (index.column())
292  {
293  case 0: // Request noise level (1st column)
294  if (isSpecialInfiniteCell(index)) // Last cell can not be edited
295  {
296  if (role == Qt::DisplayRole)
297  {
298  return TR("id_editarrayInfinity");
299  }
300  }
301  switch (role)
302  {
303  case Qt::DisplayRole:
304  return QString("%1").arg(p_palette->getValueFromIndex(index.row()), 0, 'f', 1);
305  break;
306  case Qt::EditRole:
307  return p_palette->getValueFromIndex(index.row());
308  break;
309  case Qt::CheckStateRole:
310  return checked_rows.count(index.row()) ? Qt::Checked : Qt::Unchecked;
311  break;
312  case Qt::TextAlignmentRole:
313  return Qt::AlignRight;
314  break;
315  }
316  break;
317  case 1: // Request color (2nd column)
318  switch (role)
319  {
320  case Qt::BackgroundRole:
321  OColor ocolor(p_palette->getColorFromIndex(index.row()));
322  return toQColor(ocolor);
323  break;
324  }
325  break;
326  default:
327  break;
328  }
329  return QVariant();
330 }
331 
332 QVariant PaletteModel::headerData(int section, Qt::Orientation orientation, int role) const
333 {
334  switch (section)
335  {
336  case 0:
337  return TR("id_editarraycol0");
338  break;
339  case 1:
340  return TR("id_editarraycol1");
341  break;
342  default:
343  return QVariant();
344  break;
345  }
346 }
347 
348 Qt::ItemFlags PaletteModel::flags(const QModelIndex& index) const
349 {
350  if (!index.isValid())
351  {
352  return Qt::ItemIsEnabled;
353  }
354  Qt::ItemFlags flags = QAbstractTableModel::flags(index);
355  flags |= Qt::ItemIsEditable;
356  flags &= ~Qt::ItemIsSelectable;
357  switch (index.column())
358  {
359  case 0:
360  if (isSpecialInfiniteCell(index))
361  {
362  // No edition possible for the last row value
363  flags &= ~Qt::ItemIsEditable;
364  flags &= ~Qt::ItemIsUserCheckable;
365  }
366  else
367  {
368  flags |= Qt::ItemIsUserCheckable;
369  }
370  break;
371  case 1:
372  // Nothing specific yet
373  break;
374  default:
375  assert(false && "Should never be reachable");
376  break;
377  }
378  return flags;
379 }
380 
381 bool PaletteModel::setData(const QModelIndex& index, const QVariant& value, int role)
382 {
383  if (!index.isValid())
384  {
385  return false;
386  }
387  TYPalette::values_type real_value = NAN;
388  QColor qcolor;
389  bool ok = false;
390  TYPalette::values_type old_value = p_palette->getValueFromIndex(index.row());
391 
392  switch (index.column())
393  {
394  case 0: // Request noise level (1st column)
395  if (isSpecialInfiniteCell(index)) // Last cell can not be edited
396  {
397  return false;
398  }
399  switch (role)
400  {
401  case Qt::EditRole:
402  real_value = value.toFloat(&ok);
403  if (ok)
404  {
405  ok = p_palette->moveValue(old_value, real_value);
406  if (ok)
407  {
408  emit dataChanged(index, index);
409  }
410  return ok;
411  }
412  break;
413  case Qt::CheckStateRole:
414  if (value == Qt::Checked)
415  {
416  ok = checked_rows.insert(index.row()).second;
417  }
418  else
419  {
420  ok = checked_rows.erase(index.row()) == 1;
421  }
422  break;
423  }
424  return ok;
425  break;
426  case 1: // Request color (2nd column)
427  switch (role)
428  {
429  case Qt::BackgroundRole:
430  case Qt::EditRole:
431  qcolor = value.value<QColor>();
432  p_palette->insertColor(old_value, toOColor(qcolor));
433  emit dataChanged(index, index);
434  return true;
435  break;
436  default:
437  assert(false && "This should be an unreachable case");
438  break;
439  }
440  break;
441  default:
442  assert(false && "This should be an unreachable case");
443  break;
444  }
445  return false; // to make the compiler happy with all exec path having a return.
446 }
447 
449 {
450  BOOST_REVERSE_FOREACH(unsigned r, checked_rows)
451  {
452  beginRemoveRows(QModelIndex(), r, r);
454 #ifndef NDEBUG
455  bool ok = p_palette->removeValue(value);
456  assert(ok && "This value must be valid");
457 #else
458  p_palette->removeValue(value);
459 #endif
460  endRemoveRows();
461  }
462  checked_rows.clear();
463  emit dataChanged(index(0, 0), index(rowCount() - 1, 1));
464 }
465 
466 void PaletteModel::addRow(float noiseLevel)
467 {
468  TYPalette::values_type value = NAN;
469  OColor color;
470  unsigned r = 0;
471  // We look for the index r of the row to be created
472  BOOST_FOREACH (boost::tie(value, color), p_palette->getColorMap())
473  {
474  if (value == noiseLevel)
475  {
476  return; // We don't try to inser duplicates
477  }
478  if (value > noiseLevel)
479  {
480  break;
481  }
482  ++r;
483  }
484  // Now r is the index of the new row
485  beginInsertRows(QModelIndex(), r, r);
486  p_palette->insertColor(noiseLevel, OColor::WHITE);
487  endInsertRows();
488  emit dataChanged(index(r, 0), index(r, 1));
489  checked_rows.clear();
490 }
491 
492 /* --------------- class PaletteColorDelegate --------------- */
493 
494 QWidget* PaletteColorDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
495  const QModelIndex& index) const
496 {
497  return new QWidget(parent);
498 }
499 
500 void PaletteColorDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
501 {
502 #ifndef NDEBUG
503  bool ok = false;
504 #endif
505 
506  QColor qcolor = index.model()->data(index, Qt::BackgroundRole).value<QColor>();
507  QPalette p = editor->palette();
508  p.setColor(QPalette::Window, qcolor);
509  p.setColor(QPalette::Base, qcolor);
510  QColorDialog* dialog = new QColorDialog(editor);
511  dialog->setCurrentColor(qcolor);
512 #ifndef NDEBUG
513  ok =
514 #endif
515  QObject::connect(dialog, &QColorDialog::finished, this, &PaletteColorDelegate::validateColor);
516  assert(ok && "Connection failed for validateColor()");
517  dialog->show();
518 }
519 
521 {
522  QColorDialog* dialog = qobject_cast<QColorDialog*>(this->sender());
523  QWidget* editor = dialog->parentWidget();
524  if (dialog->result() == QDialog::Accepted)
525  {
526  QColor qcolor = dialog->currentColor();
527  QPalette p = editor->palette();
528  p.setColor(QPalette::Window, qcolor);
529  p.setColor(QPalette::Base, qcolor);
530  editor->setPalette(p);
531  emit commitData(editor);
532  }
533  emit closeEditor(editor, QAbstractItemDelegate::NoHint);
534 }
535 
536 void PaletteColorDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
537  const QModelIndex& index) const
538 {
539  QColor color = editor->palette().color(QPalette::Base);
540  model->setData(index, color);
541 }
542 
543 /* --------------- class PaletteValueDelegate --------------- */
544 
545 QWidget* PaletteValueDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
546  const QModelIndex& index) const
547 {
548  QDoubleSpinBox* editor = new QDoubleSpinBox(parent);
549  editor->setDecimals(1);
550  TYPalette::values_type inf = NAN, sup = NAN;
551  const PaletteModel* model = qobject_cast<const PaletteModel*>(index.model());
552  assert(model && "This cast shoul always succeed.");
553  model->getBoundsForValue(index.row(), inf, sup);
554  editor->setMinimum(inf);
555  editor->setMaximum(sup);
556  return editor;
557 }
558 
559 void PaletteValueDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
560 {
561  bool ok = false;
562  TYPalette::values_type value = index.model()->data(index).toFloat(&ok);
563  QDoubleSpinBox* spinbox = qobject_cast<QDoubleSpinBox*>(editor);
564  assert(spinbox && "THis cast is expecto to always work.");
565  if (ok)
566  {
567  spinbox->setValue(value);
568  }
569  else
570  {
572  QString("Invalid value for noise level : %1").arg(index.model()->data(index).toString()));
573  }
574 }
575 
576 void PaletteValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
577  const QModelIndex& index) const
578 {
579  QDoubleSpinBox* spinbox = qobject_cast<QDoubleSpinBox*>(editor);
580  spinbox->interpretText();
581  TYPalette::values_type value = spinbox->value();
582  model->setData(index, value, Qt::EditRole);
583 }
584 
585 /* --------------- class PaletteColorDelegate --------------- */
586 
587 PaletteEditor::PaletteEditor(TYPalette* palette_, QWidget* parent)
588  : QFrame(parent), newNoiseLevelSpin(NULL), newNoiseLevelButton(NULL), deleteNoiseLevelButton(NULL),
589  p_palette(palette_), p_table(NULL), color_delegate(this), value_delegate(this),
590  p_model(new PaletteModel(p_palette, this))
591 {
592 #ifndef NDEBUG
593  bool ok = false;
594 #endif
595 
596  QVBoxLayout* main_layout = new QVBoxLayout(this);
597  QFrame* hframe = new QFrame();
598  main_layout->addWidget(hframe);
599 
600  QHBoxLayout* addEntryLayout = new QHBoxLayout(hframe);
601  addEntryLayout->addWidget(new QLabel(TR("id_noise_level"), hframe), 1);
602 
603  newNoiseLevelSpin = new QDoubleSpinBox();
604  newNoiseLevelSpin->setSuffix(" dBA");
605  newNoiseLevelSpin->setMaximum(1000);
606  newNoiseLevelSpin->setDecimals(1);
607  addEntryLayout->addWidget(newNoiseLevelSpin, 1);
608 
609  newNoiseLevelButton = new QPushButton();
610  newNoiseLevelButton->setText(TR("id_newentry"));
611 #ifndef NDEBUG
612  ok =
613 #endif
614  QObject::connect(newNoiseLevelButton, &QPushButton::pressed, this, &PaletteEditor::addNoiseLevel);
615  assert(ok && "Connection failed for addNoiseLevel");
616  addEntryLayout->addWidget(newNoiseLevelButton, 1);
617 
618  deleteNoiseLevelButton = new QPushButton();
619  deleteNoiseLevelButton->setText(TR("id_delete_sel"));
620 #ifndef NDEBUG
621  ok =
622 #endif
623  QObject::connect(deleteNoiseLevelButton, &QPushButton::pressed, this,
625  assert(ok && "Connection failed for addNoiseLevel");
626  addEntryLayout->addWidget(deleteNoiseLevelButton, 1);
627 
628  p_table = new QTableView(this);
629  p_table->setModel(p_model);
630  main_layout->addWidget(p_table, 1);
631  p_table->setItemDelegateForColumn(0, &value_delegate);
632  p_table->setItemDelegateForColumn(1, &color_delegate);
633 
634 #ifndef NDEBUG
635  ok =
636 #endif
637  connect(p_model, &PaletteModel::dataChanged, this, &PaletteEditor::propagateModelChanges);
638  assert(ok && "Connection failed for slot propagateModelChanges");
639 }
640 
642 
644 {
646 };
647 
648 void PaletteEditor::propagateModelChanges(const QModelIndex& topLeft, const QModelIndex& bottomRight)
649 {
651 }
652 
654 {
655  qobject_cast<PaletteModel*>(p_table->model())->addRow(newNoiseLevelSpin->value());
656 }
657 
659 {
660  qobject_cast<PaletteModel*>(p_table->model())->deleteSelectedRows();
661 }
662 
663 // ================================================================================
664 
666  : QDialog(_pParent), _pElement(pElement)
667 {
668  Q_ASSERT(pElement);
669  setWindowTitle(TR("id_caption_limits"));
670  resize(300, 174);
671 
672  QGroupBox* _groupBox = new QGroupBox(this);
673  QGridLayout* internalLayout = new QGridLayout();
674  _groupBox->setLayout(internalLayout);
675  _label_lower_bound = new QLabel(_groupBox);
676  _label_lower_bound->setText(TR("id_lb_label"));
677  _label_upper_bound = new QLabel(_groupBox);
678  _label_upper_bound->setText(TR("id_ub_label"));
679  _label_nb_colors = new QLabel(_groupBox);
680  _label_nb_colors->setText(TR("id_nb_label"));
683  _lineEdit_nb_colors = new QLineEdit(_groupBox);
684  internalLayout->addWidget(_label_lower_bound, 0, 0);
685  internalLayout->addWidget(_lineEdit_lower_bound, 0, 1);
686  internalLayout->addWidget(_label_upper_bound, 1, 0);
687  internalLayout->addWidget(_lineEdit_upper_bound, 1, 1);
688  internalLayout->addWidget(_label_nb_colors, 2, 0);
689  internalLayout->addWidget(_lineEdit_nb_colors, 2, 1);
690 
691  QBoxLayout* pBtnLayout = new QHBoxLayout();
692 
693  pBtnLayout->addStretch(1);
694 
695  QPushButton* pButtonOK = new QPushButton(TR("id_ok_btn"), this);
696  pButtonOK->setDefault(true);
697  QObject::connect(pButtonOK, &QPushButton::clicked, this, &TYPaletteLimitsWidget::apply);
698  pBtnLayout->addWidget(pButtonOK);
699 
700  QPushButton* pButtonCancel = new QPushButton(TR("id_cancel_btn"), this);
701  pButtonCancel->setShortcut(Qt::Key_Escape);
702  QObject::connect(pButtonCancel, &QPushButton::clicked, this, &TYPaletteLimitsWidget::reject);
703  pBtnLayout->addWidget(pButtonCancel);
704 
705  internalLayout->addLayout(pBtnLayout, 3, 1);
706  updateContent();
707 }
708 
710 {
711  _lineEdit_lower_bound->setText(QString().setNum(_pElement->getValueMin(), 'f', 2));
712  _lineEdit_upper_bound->setText(QString().setNum(_pElement->getValueMax(), 'f', 2));
713  _lineEdit_nb_colors->setText(QString().setNum(_pElement->getNbColors()));
714 }
715 
717 {
718  double lower_bound = _lineEdit_lower_bound->text().toDouble();
719  double upper_bound = _lineEdit_upper_bound->text().toDouble();
720  unsigned int nb_colors = _lineEdit_nb_colors->text().toUInt();
721 
722  _pElement->makeLinearPalette(nb_colors, lower_bound, upper_bound);
723  accept();
724 }
outil IHM pour une entrée utilisateur (fichier header)
Outil IHM utile a l'affichage de la palette de couleur (fichier header)
OColor toOColor(const QColor &color)
QColor toQColor(const OColor &color)
#define TR(id)
Outil IHM pour une palette (fichier header)
Definition: color.h:31
static const OColor WHITE
Definition: color.h:93
virtual void debug(const char *message,...)
Definition: logging.cpp:151
virtual void error(const char *message,...)
Definition: logging.cpp:127
static OMessageManager * get()
Definition: logging.cpp:108
void setEditorData(QWidget *editor, const QModelIndex &index) const
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
PaletteEditor(TYPalette *palette, QWidget *parent=NULL)
QPushButton * deleteNoiseLevelButton
void propagateModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight)
QTableView * p_table
PaletteValueDelegate value_delegate
virtual ~PaletteEditor()
QDoubleSpinBox * newNoiseLevelSpin
void notifyTYPaletteExternalyChanged()
PaletteColorDelegate color_delegate
PaletteModel * p_model
QPushButton * newNoiseLevelButton
void paletteChanged(const TYPalette *palette)
TYPalette * p_palette
(Qt) Data model for a TYPalette
void addRow(float noiseLevel)
bool isSpecialInfiniteCell(const QModelIndex &index) const
void getBoundsForValue(unsigned i, float &inf, float &sup) const
std::set< unsigned > checked_rows
void deleteSelectedRows()
virtual ~PaletteModel()
QVariant data(const QModelIndex &index, int role) const
PaletteModel(TYPalette *p_palette, QObject *parent=NULL)
int rowCount(const QModelIndex &parent=QModelIndex()) const
TYPalette * p_palette
Qt::ItemFlags flags(const QModelIndex &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setEditorData(QWidget *editor, const QModelIndex &index) const
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
void update(const TYPalette *palette)
TYPaletteLimitsWidget(TYPalette *pElement, QWidget *_pParent=nullptr)
TYLineEdit * _lineEdit_upper_bound
virtual void updateContent()
TYLineEdit * _lineEdit_lower_bound
QLineEdit * _lineEdit_nb_colors
QPushButton * _pushButtonLinearPalette
virtual ~TYPaletteWidget()
TYElementWidget * _elmW
QPushButton * _pushButtonSavePalette
QPushButton * _pushButtonLoadPalette
QPushButton * _pushButtonResetPalette
virtual void updateContent()
PaletteEditor * _editor
virtual void apply()
TYPaletteWidget(TYPalette *pElement, QWidget *_pParent=NULL)
TYLabeledLookupTableWidget * p_previewWidget
QVBoxLayout * _paletteLayout
Classe de definition d'une palette.
Definition: TYPalette.h:41
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 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
const OColor & getColorFromIndex(unsigned i) const
Get de la couleur par index.
Definition: TYPalette.cpp:499
static LPTYPalette loadPaletteFromFile(const QString &qFileName)
Create a new TYPalette from an XML file Holding only one Palette.
Definition: TYPalette.cpp:524
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::values_type getValueFromIndex(unsigned i) const
Get de la valeur par index.
Definition: TYPalette.cpp:511
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
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
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43