libpappsomspp
Library for mass spectrometry
basecolormapplotwidget.cpp
Go to the documentation of this file.
1 /* This code comes right from the msXpertSuite software project.
2  *
3  * msXpertSuite - mass spectrometry software suite
4  * -----------------------------------------------
5  * Copyright(C) 2009,...,2018 Filippo Rusconi
6  *
7  * http://www.msxpertsuite.org
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  *
22  * END software license
23  */
24 
25 
26 /////////////////////// StdLib includes
27 #include <vector>
28 
29 
30 /////////////////////// Qt includes
31 #include <QVector>
32 
33 
34 /////////////////////// Local includes
35 #include "basecolormapplotwidget.h"
36 #include "../../trace/maptrace.h"
37 #include "../../pappsoexception.h"
38 
39 
40 namespace pappso
41 {
42 
43 
45  const QString &x_axis_label,
46  const QString &y_axis_label)
47  : BasePlotWidget(parent, x_axis_label, y_axis_label)
48 {
49  // Do not call createAllAncillaryItems() in this base class because all the
50  // items will have been created *before* the addition of plots and then the
51  // rendering order will hide them to the viewer, since the rendering order is
52  // according to the order in which the items have been created.
53  //
54  // The fact that the ancillary items are created before trace plots is not a
55  // problem because the trace plots are sparse and do not effectively hide the
56  // data.
57  //
58  // But, in the color map plot widgets, we cannot afford to create the
59  // ancillary items *before* the plot itself because then, the rendering of the
60  // plot (created after) would screen off the ancillary items (created before).
61  //
62  // So, the createAllAncillaryItems() function needs to be called in the
63  // derived classes at the most appropriate moment in the setting up of the
64  // widget.
65  //
66  // In the present case, the function needs to be called right after addition
67  // of the color map plot.
68 }
69 
70 
71 //! Destruct \c this BaseColorMapPlotWidget instance.
72 /*!
73 
74  The destruction involves clearing the history, deleting all the axis range
75  history items for x and y axes.
76 
77 */
79 {
80  if(mpa_origColorMapData != nullptr)
81  delete mpa_origColorMapData;
82 
83  if(mpa_origColorMapPlotConfig != nullptr)
85 }
86 
87 
88 void
90  const ColorMapPlotConfig &color_map_config)
91 {
92  m_colorMapPlotConfig = color_map_config;
93 }
94 
95 
96 const ColorMapPlotConfig *
98 {
100 }
101 
102 
103 const ColorMapPlotConfig &
105 {
106  return m_colorMapPlotConfig;
107 }
108 
109 
110 QCPColorMap *
112  std::shared_ptr<std::map<double, MapTrace>> double_map_trace_map_sp,
113  const ColorMapPlotConfig color_map_plot_config,
114  const QColor &color)
115 {
116  // qDebug() << "Adding color map with config:" <<
117  // color_map_plot_config.toString();
118 
119  if(!color.isValid())
120  throw PappsoException(
121  QString("The color to be used for the plot graph is invalid."));
122 
123  QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
124 
125  color_map_p->setLayer("plotsLayer");
126 
127  // Do not forget to copy the config!
128  m_colorMapPlotConfig = color_map_plot_config;
129 
130  // Immediately create a copy of the original data for backup.
131  mpa_origColorMapPlotConfig = new ColorMapPlotConfig(color_map_plot_config);
132 
133 #if 0
134  // This is the code on the QCustomPlot documentation and it works fine.
135  QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
136 
137  color_map_p->data()->setSize(50, 50);
138  color_map_p->data()->setRange(QCPRange(0, 2), QCPRange(0, 2));
139  for(int x = 0; x < 50; ++x)
140  for(int y = 0; y < 50; ++y)
141  color_map_p->data()->setCell(x, y, qCos(x / 10.0) + qSin(y / 10.0));
142  color_map_p->setGradient(QCPColorGradient::gpPolar);
143  color_map_p->rescaleDataRange(true);
144  rescaleAxes();
145  replot();
146 #endif
147 
148  // Only now can afford to call createAllAncillaryItems() in this derived class
149  // because the color map has been created already. The rendering order will
150  // thus not hide the ancillary items, since they have been created after the
151  // color map plot (since the rendering order is according to the
152  // order in which the items have been created). See contructor note.
154 
155  // Connect the signal of selection change so that we can re-emit it for the
156  // widget that is using *this widget.
157 
158  connect(color_map_p,
159  static_cast<void (QCPAbstractPlottable::*)(bool)>(
160  &QCPAbstractPlottable::selectionChanged),
161  [this, color_map_p]() {
162  emit plottableSelectionChangedSignal(color_map_p,
163  color_map_p->selected());
164  });
165 
166  // qDebug() << "Configuring the color map with this config:"
167  //<< color_map_plot_config.toString();
168 
169  color_map_p->data()->setSize(color_map_plot_config.keyCellCount,
170  color_map_plot_config.mzCellCount);
171 
172  color_map_p->data()->setRange(QCPRange(color_map_plot_config.minKeyValue,
173  color_map_plot_config.maxKeyValue),
174  QCPRange(color_map_plot_config.minMzValue,
175  color_map_plot_config.maxMzValue));
176  color_map_p->data()->fill(0.0);
177 
178  // We have now to fill the color map.
179 
180  for(auto &&pair : *double_map_trace_map_sp)
181  {
182 
183  // The first value is the key and the second value is the MapTrace into
184  // which we need to iterated and for each point (double mz, double
185  // intensity) create a map cell.
186 
187  double dt_or_rt_key = pair.first;
188  MapTrace map_trace = pair.second;
189 
190  for(auto &&data_point_pair : map_trace)
191  {
192  double mz = data_point_pair.first;
193  double intensity = data_point_pair.second;
194 
195  // We are filling dynamically the color map. If a cell had already
196  // something in, then we need to take that into account. This is
197  // because we let QCustomPlot handle the fuzzy transition between
198  // color map plot cells.
199 
200  double prev_intensity = color_map_p->data()->data(dt_or_rt_key, mz);
201  double new_intensity = prev_intensity + intensity;
202 
203  // Record the min/max cell intensity value (origM(in/ax)ZValue). We
204  // will need that later. Also update the lastM(in/ax)ZValue because
205  // when doing this kind of data conversion it is assume that the user
206  // actually changes the data.
208  std::min(m_colorMapPlotConfig.origMinZValue, new_intensity));
209 
211  std::max(m_colorMapPlotConfig.origMaxZValue, new_intensity));
212 
213  // qDebug() << "Setting tri-point:" << dt_or_rt_key << "," << mz <<
214  // ","
215  //<< new_intensity;
216 
217  color_map_p->data()->setData(dt_or_rt_key, mz, new_intensity);
218  }
219  }
220 
221  // At this point we have finished filling-up the color map.
222 
223  // The gpThermal is certainly one of the best.
224 
225  color_map_p->setGradient(QCPColorGradient::gpThermal);
226 
227  color_map_p->rescaleDataRange(true);
228 
229  color_map_p->rescaleAxes();
231 
232  // The pen of the color map itself is of no use. Instead the user will see the
233  // color of the axes' labels.
234 
235  QPen pen = xAxis->basePen();
236  pen.setColor(color);
237 
238  xAxis->setBasePen(pen);
239  xAxis->setLabelColor(color);
240  xAxis->setTickLabelColor(color);
241 
242  yAxis->setBasePen(pen);
243  yAxis->setLabelColor(color);
244  yAxis->setTickLabelColor(color);
245 
246  // And now set the color map's pen to the same color, even if we do not use
247  // it, we need it for coloring the plots that might be integrated from this
248  // color map.
249 
250  color_map_p->setPen(pen);
251 
252  // Copy the original color map's data into a backup copy.
253 
254  mpa_origColorMapData = new QCPColorMapData(*(color_map_p->data()));
255 
256  replot();
257 
258  return color_map_p;
259 }
260 
261 
262 void
264 {
265  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
266 
267  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
268 
269  QCPColorMapData *origData = color_map_p->data();
270 
271  int keySize = origData->keySize();
272  int valueSize = origData->valueSize();
273 
274  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
275  //<< "Orig data size:" << keySize << valueSize;
276 
277  QCPRange keyRange = origData->keyRange();
278  QCPRange valueRange = origData->valueRange();
279 
280  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
281  //<< "Value at cell 80,650:" << origData->cell(80,650);
282 
283  // Transposed map.
284  QCPColorMapData *newData =
285  new QCPColorMapData(valueSize, keySize, valueRange, keyRange);
286 
287  for(int iter = 0; iter < keySize; ++iter)
288  {
289  for(int jter = 0; jter < valueSize; ++jter)
290  {
291  double cellData = origData->cell(iter, jter);
292 
293  newData->setCell(jter, iter, cellData);
294  }
295  }
296 
297  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
298  //<< "New data size:" << newData->keySize() << newData->valueSize();
299 
300  // At this point the transposition has been done.
301 
302  color_map_p->data()->clear();
303  color_map_p->rescaleDataRange(true);
304 
305  // Now we need to invert the labels and data kinds.
306 
309  m_colorMapPlotConfig.yAxisDataKind = temp_data_kind;
310 
311  QString temp_axis_label = xAxis->label();
312  xAxis->setLabel(yAxis->label());
313  yAxis->setLabel(temp_axis_label);
314 
315  // Will take ownership of the newData.
316  color_map_p->setData(newData);
317 
318  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
319  //<< "Value at cell 80,650:" << newData->cell(80,650)
320  //<< "Value at cell 650, 80:" << newData->cell(650,80);
321 
322  // QCPAxis *p_keyAxis = mp_colorMap->keyAxis();
323  // QCPAxis *p_valueAxis = mp_colorMap->valueAxis();
324 
325  // mp_colorMap->setKeyAxis(p_valueAxis);
326  // mp_colorMap->setValueAxis(p_keyAxis);
327 
328  color_map_p->rescaleAxes();
329 
330  replot();
331 }
332 
333 
334 void
336 {
337  // The user wants to rescale the intensity values of the color map according
338  // to: new_int = log10(orig_int).
339 
340  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
341 
343  {
344  qDebug() << "Asking to change z axis scale to log10 while it is already "
345  "like so.";
346 
347  return;
348  }
349 
350  // qDebug() << "m_colorMapPlotConfig:" << m_colorMapPlotConfig.toString();
351 
352  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
353 
354  QCPColorMapData *map_data = color_map_p->data();
355 
356  int keySize = map_data->keySize();
357  int valueSize = map_data->valueSize();
358 
359  QCPRange keyRange = map_data->keyRange();
360  QCPRange valueRange = map_data->valueRange();
361 
362  // Make a copy of the current config so that we can modify
363  // the xxxZvalue values.
364  ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
365 
366  // But we need to reset these two values to be able to update them using
367  // std::min() and std::max() below.
368  new_color_map_plot_config.setOrigAndLastMinZValue(
369  std::numeric_limits<double>::max());
370 
371  new_color_map_plot_config.setOrigAndLastMaxZValue(
372  std::numeric_limits<double>::min());
373 
374  // qDebug() << "new_color_map_plot_config"
375  //<< new_color_map_plot_config.toString();
376 
377  // Log-ified heat map.
378  QCPColorMapData *new_map_data =
379  new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
380 
381  // qDebug() << "Starting iteration in the color map.";
382 
383  for(int iter = 0; iter < keySize; ++iter)
384  {
385  for(int jter = 0; jter < valueSize; ++jter)
386  {
387  double cell_data = map_data->cell(iter, jter);
388 
389  double new_cell_data = 0;
390 
391  if(!cell_data)
392  // The log10 would be -inf, but then we'd have a huge data range and
393  // the color map would look totally blue... that is like 0 intensity
394  // all over.
395  new_cell_data = -1;
396  else
397  new_cell_data = std::log10(cell_data);
398 
399  // Store the new values here. Should we change the last or orig or
400  // both ?
401  new_color_map_plot_config.lastMinZValue =
402  //(new_cell_data < new_color_map_plot_config.minZValue
403  //? new_cell_data
404  //: new_color_map_plot_config.minZValue);
405  std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
406 
407  new_color_map_plot_config.lastMaxZValue =
408  //(new_cell_data > new_color_map_plot_config.maxZValue
409  //? new_cell_data
410  //: new_color_map_plot_config.maxZValue);
411  std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
412 
413  // qDebug() << "cell_data:" << cell_data
414  //<< "new_cell_data:" << new_cell_data
415  //<< "new_color_map_plot_config.minZValue:"
416  //<< new_color_map_plot_config.minZValue
417  //<< "new_color_map_plot_config.maxZValue:"
418  //<< new_color_map_plot_config.maxZValue;
419 
420  new_map_data->setCell(iter, jter, new_cell_data);
421  }
422  }
423 
424  // qDebug() << "Finished iteration in the color map.";
425 
426  color_map_p->data()->clear();
427 
428  // Will take ownership of the new_map_data.
429  color_map_p->setData(new_map_data);
430 
431  color_map_p->data()->recalculateDataBounds();
432  color_map_p->rescaleDataRange(true);
433 
434  // At this point the new color map data have taken their place, we can update
435  // the config. This, way any new filtering can take advantage of the new
436  // values and compute the threshold correctly.
437  m_colorMapPlotConfig = new_color_map_plot_config;
438 
439  // Now we need to document the change.
441 
442  // qDebug() << "new_color_map_plot_config"
443  //<< new_color_map_plot_config.toString();
444 
445  // qDebug() << "m_colorMapPlotConfig:" << m_colorMapPlotConfig.toString();
446 
447  // We should not do this, as the user might have zoomed to a region of
448  // interest.
449  // color_map_p->rescaleAxes();
450 
451  replot();
452 }
453 
454 void
456  double threshold_percentage)
457 {
458  // This filter allows all the values smaller than a threshold to remain
459  // unchanged. Instead, all the values above the threshold will be reset to
460  // that threshold.
461  //
462  // The effect of this filter is to enhance the high-intensity signal.
463 
464  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
465 
466  QCPColorMapData *map_data = color_map_p->data();
467 
468  int keySize = map_data->keySize();
469  int valueSize = map_data->valueSize();
470 
471  QCPRange keyRange = map_data->keyRange();
472  QCPRange valueRange = map_data->valueRange();
473 
474  double minZValue = m_colorMapPlotConfig.lastMinZValue;
475  double maxZValue = m_colorMapPlotConfig.lastMaxZValue;
476 
477  double amplitude = maxZValue - minZValue;
478 
479  double amplitude_fraction = amplitude * threshold_percentage / 100;
480 
481  double threshold = minZValue + amplitude_fraction;
482 
483  //qDebug() << "Before filtering minZValue:" << minZValue
484  //<< "maxZValue:" << maxZValue << "fraction:" << fraction
485  //<< "threshold:" << threshold
486  //<< "new threshold percentage:" << new_threshold_percentage;
487 
488  // Make a copy of the current config so that we can modify
489  // the xxxZvalue values.
490  ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
491 
492  // But we need to reset these two values to be able to update them using
493  // std::min() and std::max() below.
494  new_color_map_plot_config.lastMinZValue = std::numeric_limits<double>::max();
495  new_color_map_plot_config.lastMaxZValue = std::numeric_limits<double>::min();
496 
497  // Filtered
498  QCPColorMapData *new_map_data =
499  new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
500 
501  for(int iter = 0; iter < keySize; ++iter)
502  {
503  for(int jter = 0; jter < valueSize; ++jter)
504  {
505  double cell_data = map_data->cell(iter, jter);
506 
507  double new_cell_data = 0;
508 
509  if(cell_data < threshold)
510  // Keep the value, we are in low-pass
511  new_cell_data = cell_data;
512  else
513  new_cell_data = threshold;
514 
515  // Store the new values here.
516  new_color_map_plot_config.lastMinZValue =
517  //(new_cell_data < new_color_map_plot_config.minZValue
518  //? new_cell_data
519  //: new_color_map_plot_config.minZValue);
520  std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
521 
522  new_color_map_plot_config.lastMaxZValue =
523  //(new_cell_data > new_color_map_plot_config.maxZValue
524  //? new_cell_data
525  //: new_color_map_plot_config.maxZValue);
526  std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
527 
528  // qDebug() << "cell_data:" << cell_data
529  //<< "new_cell_data:" << new_cell_data
530  //<< "new_color_map_plot_config.minZValue:"
531  //<< new_color_map_plot_config.minZValue
532  //<< "new_color_map_plot_config.maxZValue:"
533  //<< new_color_map_plot_config.maxZValue;
534 
535  new_map_data->setCell(iter, jter, new_cell_data);
536  }
537  }
538 
539  color_map_p->data()->clear();
540 
541  // Will take ownership of the new_map_data.
542  color_map_p->setData(new_map_data);
543 
544  color_map_p->data()->recalculateDataBounds();
545  color_map_p->rescaleDataRange(true);
546 
547 
548  // At this point the new color map data have taken their place, we can update
549  // the config. This, way any new filtering can take advantage of the new
550  // values and compute the threshold correctly.
551  m_colorMapPlotConfig = new_color_map_plot_config;
552 
553  // qDebug() << "Member colormap plot config is now, after filter was applied:"
554  //<< m_colorMapPlotConfig.toString();
555 
556  // We should not do this, as the user might have zoomed to a region of
557  // interest.
558  // color_map_p->rescaleAxes();
559 
560  replot();
561 }
562 
563 
564 void
566  double threshold_percentage)
567 {
568  // This filter allows all the value greater than a threshold to remain
569  // unchanged. Instead, all the values below the threshold will be reset to
570  // that threshold value.
571  //
572  // The effect of this filter is to reduce the low-intensity signal: reduce
573  // noise.
574 
575  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
576 
577  QCPColorMapData *map_data = color_map_p->data();
578 
579  int keySize = map_data->keySize();
580  int valueSize = map_data->valueSize();
581 
582  QCPRange keyRange = map_data->keyRange();
583  QCPRange valueRange = map_data->valueRange();
584 
585  double minZValue = m_colorMapPlotConfig.lastMinZValue;
586  double maxZValue = m_colorMapPlotConfig.lastMaxZValue;
587 
588  double amplitude = maxZValue - minZValue;
589 
590  double amplitude_fraction = amplitude * threshold_percentage / 100;
591 
592  double threshold = minZValue + amplitude_fraction;
593 
594  //qDebug() << "Before filtering minZValue:" << minZValue
595  //<< "maxZValue:" << maxZValue << "fraction:" << fraction
596  //<< "threshold:" << threshold
597  //<< "new threshold percentage:" << new_threshold_percentage;
598 
599  // Make a copy of the current config so that we can modify
600  // the xxxZvalue values.
601  ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
602 
603  // But we need to reset these two values to be able to update them using
604  // std::min() and std::max() below.
605  new_color_map_plot_config.lastMinZValue = std::numeric_limits<double>::max();
606  new_color_map_plot_config.lastMaxZValue = std::numeric_limits<double>::min();
607 
608  // Filtered
609  QCPColorMapData *new_map_data =
610  new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
611 
612  for(int iter = 0; iter < keySize; ++iter)
613  {
614  for(int jter = 0; jter < valueSize; ++jter)
615  {
616  double cell_data = map_data->cell(iter, jter);
617 
618  double new_cell_data = 0;
619 
620  if(cell_data > threshold)
621  // Keep the value, we are in high-pass
622  new_cell_data = cell_data;
623  else
624  new_cell_data = threshold;
625 
626  // Store the new values here.
627  new_color_map_plot_config.lastMinZValue =
628  //(new_cell_data < new_color_map_plot_config.minZValue
629  //? new_cell_data
630  //: new_color_map_plot_config.minZValue);
631  std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
632 
633  new_color_map_plot_config.lastMaxZValue =
634  //(new_cell_data > new_color_map_plot_config.maxZValue
635  //? new_cell_data
636  //: new_color_map_plot_config.maxZValue);
637  std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
638 
639  // qDebug() << "cell_data:" << cell_data
640  //<< "new_cell_data:" << new_cell_data
641  //<< "new_color_map_plot_config.minZValue:"
642  //<< new_color_map_plot_config.minZValue
643  //<< "new_color_map_plot_config.maxZValue:"
644  //<< new_color_map_plot_config.maxZValue;
645 
646  new_map_data->setCell(iter, jter, new_cell_data);
647  }
648  }
649 
650  color_map_p->data()->clear();
651 
652  // Will take ownership of the new_map_data.
653  color_map_p->setData(new_map_data);
654 
655  color_map_p->data()->recalculateDataBounds();
656  color_map_p->rescaleDataRange(true);
657 
658 
659  // At this point the new color map data have taken their place, we can update
660  // the config. This, way any new filtering can take advantage of the new
661  // values and compute the threshold correctly.
662  m_colorMapPlotConfig = new_color_map_plot_config;
663 
664  // qDebug() << "Member colormap plot config is now, after filter was applied:"
665  //<< m_colorMapPlotConfig.toString();
666 
667  // We should not do this, as the user might have zoomed to a region of
668  // interest.
669  // color_map_p->rescaleAxes();
670 
671  replot();
672 }
673 
674 
675 void
677 {
678  // The user might have changed to the axis scale to log10, for example.
679  // While doing this, the original data were still available in
680  // mpa_origColorMapData,with mpa_origColorMapPlotConfig. We need to reset the
681  // current data to the original data.
682  //
683  // Same thing for filters that might have been applied to the data.
684 
685  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
686  color_map_p->data()->clear();
687 
688  if(mpa_origColorMapData == nullptr)
689  throw(PappsoException(
690  "Not possible that the mpa_origColorMapData pointer be null."));
691 
692  // We do no want that the color_map_p takes ownership of the data, because
693  // these must remain there always, so pass true, to say that we want to copy
694  // the data not transfer the pointer.
695  color_map_p->setData(mpa_origColorMapData, true);
696 
697  color_map_p->data()->recalculateDataBounds();
698  color_map_p->rescaleDataRange(true);
699 
700  // We should not do this, as the user might have zoomed to a region of
701  // interest.
702  // color_map_p->rescaleAxes();
703 
704  // Reset the current plot config to what it was originally. The member
705  // m_colorMapPlotConfig.zAxisScale is now AxisScale::orig.
707 
708  replot();
709 }
710 
711 
712 DataKind
714 {
716 }
717 
718 
719 DataKind
721 {
723 }
724 
725 
726 AxisScale
728 {
729  if(axis == Axis::x)
731  else if(axis == Axis::y)
733  else if(axis == Axis::z)
735  else
736  throw PappsoException(
737  QString("basecolormapplotwidget.cpp: The axis cannot be different than "
738  "x, y or z."));
739 
740  return AxisScale::unset;
741 }
742 
743 
744 AxisScale
746 {
748 }
749 
750 
751 AxisScale
753 {
755 }
756 
757 
758 AxisScale
760 {
762 }
763 
764 
765 void
766 BaseColorMapPlotWidget::setPlottingColor(QCPAbstractPlottable *plottable_p,
767  const QColor &new_color)
768 {
769  Q_UNUSED(plottable_p);
770 
771  // The pen of the color map itself is of no use. Instead the user will see the
772  // color of the axes' labels.
773 
774  QPen pen = xAxis->basePen();
775  pen.setColor(new_color);
776 
777  xAxis->setBasePen(pen);
778  xAxis->setLabelColor(new_color);
779  xAxis->setTickLabelColor(new_color);
780 
781  yAxis->setBasePen(pen);
782  yAxis->setLabelColor(new_color);
783  yAxis->setTickLabelColor(new_color);
784 
785  // And now set the color map's pen to the same color, even if we do not use
786  // it, we need it for coloring the plots that might be integrated from this
787  // color map.
788 
789  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
790 
791  color_map_p->setPen(pen);
792 
793  replot();
794 }
795 
796 
797 QColor
799 {
800  Q_UNUSED(index);
801 
802  QPen pen = xAxis->basePen();
803  return pen.color();
804 }
805 
806 
807 QString
809 {
810  // We want to export the data to a string in the x y z format, with
811  // x=key (cell's x coordinate)
812  // y=value (cell's y coordinate)
813  // z=intensity (cell value)
814 
815  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
816 
817  QCPColorMapData *map_data = color_map_p->data();
818 
819  int keySize = map_data->keySize();
820  int valueSize = map_data->valueSize();
821 
822  QString text;
823 
824  for(int iter = 0; iter < keySize; ++iter)
825  {
826  for(int jter = 0; jter < valueSize; ++jter)
827  {
828  text += QString("%1 %2 %3\n")
829  .arg(iter, 0, 'f', 6, ' ')
830  .arg(jter, 0, 'f', 6, ' ')
831  .arg(map_data->cell(iter, jter), 0, 'f', 6, ' ');
832  }
833  }
834 
835  return text;
836 }
837 
838 
839 } // namespace pappso
virtual QCPColorMap * addColorMap(std::shared_ptr< std::map< double, MapTrace >> double_map_trace_map_sp, const ColorMapPlotConfig color_map_plot_config, const QColor &color)
virtual QColor getPlottingColor(int index=0) const override
ColorMapPlotConfig * mpa_origColorMapPlotConfig
const ColorMapPlotConfig * getOrigColorMapPlotConfig()
BaseColorMapPlotWidget(QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual void setColorMapPlotConfig(const ColorMapPlotConfig &color_map_config)
virtual void setPlottingColor(QCPAbstractPlottable *plottable_p, const QColor &new_color) override
AxisScale axisScale(Axis axis) const
virtual const ColorMapPlotConfig & getColorMapPlotConfig()
virtual void zAxisFilterHighPassPercentage(double threshold_percentage)
virtual ~BaseColorMapPlotWidget()
Destruct this BaseColorMapPlotWidget instance.
virtual void zAxisFilterLowPassPercentage(double threshold_percentage)
virtual void createAllAncillaryItems()
virtual void resetAxesRangeHistory()
void plottableSelectionChangedSignal(QCPAbstractPlottable *plottable_p, bool selected)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
Axis
Definition: types.h:180
AxisScale
Definition: types.h:189
DataKind
Definition: types.h:171
void setOrigAndLastMaxZValue(double value)
void setOrigAndLastMinZValue(double value)