libpappsomspp
Library for mass spectrometry
pappso::BaseColorMapPlotWidget Class Reference

#include <basecolormapplotwidget.h>

Inheritance diagram for pappso::BaseColorMapPlotWidget:
pappso::BasePlotWidget pappso::DriftSpecMassSpecColorMapPlotWidget pappso::TicXicChromDriftSpecColorMapPlotWidget pappso::TicXicChromMassSpecColorMapPlotWidget

Public Member Functions

 BaseColorMapPlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
 
virtual ~BaseColorMapPlotWidget ()
 Destruct this BaseColorMapPlotWidget instance. More...
 
virtual void setColorMapPlotConfig (const ColorMapPlotConfig &color_map_config)
 
virtual const ColorMapPlotConfiggetColorMapPlotConfig ()
 
virtual QCPColorMap * addColorMap (std::shared_ptr< std::map< double, MapTrace >> double_map_trace_map_sp, ColorMapPlotConfig color_map_plot_config, const QColor &color)
 
virtual void transposeAxes ()
 
virtual void zAxisScaleToLog10 ()
 
virtual void zAxisScaleResetToOriginal ()
 
DataKind xAxisDataKind () const
 
DataKind yAxisDataKind () const
 
AxisScale axisScale (Axis axis) const
 
AxisScale xAxisScale () const
 
AxisScale yAxisScale () const
 
AxisScale zAxisScale () const
 
virtual void setPlottingColor (QCPAbstractPlottable *plottable_p, const QColor &new_color) override
 
virtual QColor getPlottingColor (int index=0) const override
 
- Public Member Functions inherited from pappso::BasePlotWidget
 BasePlotWidget (QWidget *parent)
 
 BasePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
 
virtual ~BasePlotWidget ()
 Destruct this BasePlotWidget instance. More...
 
virtual bool setupWidget ()
 
virtual void setPen (const QPen &pen)
 
virtual const QPen & getPen () const
 
virtual void setPlottingColor (int index, const QColor &new_color)
 
virtual QColor getPlottingColor (QCPAbstractPlottable *plottable_p) const
 
virtual void setAxisLabelX (const QString &label)
 
virtual void setAxisLabelY (const QString &label)
 
virtual void resetAxesRangeHistory ()
 
virtual void updateAxesRangeHistory ()
 Create new axis range history items and append them to the history. More...
 
virtual void restorePreviousAxesRangeHistory ()
 Go up one history element in the axis history. More...
 
virtual void restoreAxesRangeHistory (std::size_t index)
 Get the axis histories at index index and update the plot ranges. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 KEYBOARD-related EVENTS. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Handle specific key codes and trigger respective actions. More...
 
virtual void spaceKeyReleaseEvent (QKeyEvent *event)
 
virtual void directionKeyPressEvent (QKeyEvent *event)
 
virtual void directionKeyReleaseEvent (QKeyEvent *event)
 
virtual void mousePseudoButtonKeyPressEvent (QKeyEvent *event)
 
virtual void mousePseudoButtonKeyReleaseEvent (QKeyEvent *event)
 
virtual void mousePressHandler (QMouseEvent *event)
 KEYBOARD-related EVENTS. More...
 
virtual void mouseReleaseHandler (QMouseEvent *event)
 
virtual void mouseReleaseHandlerLeftButton ()
 
virtual void mouseReleaseHandlerRightButton ()
 
virtual void mouseMoveHandler (QMouseEvent *event)
 KEYBOARD-related EVENTS. More...
 
virtual void mouseMoveHandlerNotDraggingCursor ()
 
virtual void mouseMoveHandlerDraggingCursor ()
 
virtual void mouseMoveHandlerLeftButtonDraggingCursor ()
 
virtual void mouseMoveHandlerRightButtonDraggingCursor ()
 
virtual void axisDoubleClickHandler (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 
bool isClickOntoXAxis (const QPointF &mousePoint)
 
bool isClickOntoYAxis (const QPointF &mousePoint)
 
int dragDirection ()
 MOUSE-related EVENTS. More...
 
virtual void moveMouseCursorGraphCoordToGlobal (QPointF plot_coordinates)
 
virtual void moveMouseCursorPixelCoordToGlobal (QPointF local_coordinates)
 
virtual void horizontalMoveMouseCursorCountPixels (int pixel_count)
 
virtual QPointF horizontalGetGraphCoordNewPointCountPixels (int pixel_count)
 
virtual void verticalMoveMouseCursorCountPixels (int pixel_count)
 
virtual QPointF verticalGetGraphCoordNewPointCountPixels (int pixel_count)
 
virtual QCPRange getRangeX (bool &found_range, int index) const
 MOUSE MOVEMENTS mouse/keyboard-triggered. More...
 
virtual QCPRange getRangeY (bool &found_range, int index) const
 
QCPRange getRange (Axis axis, RangeType range_type, bool &found_range) const
 
virtual QCPRange getInnermostRangeX (bool &found_range) const
 
virtual QCPRange getOutermostRangeX (bool &found_range) const
 
virtual QCPRange getInnermostRangeY (bool &found_range) const
 
virtual QCPRange getOutermostRangeY (bool &found_range) const
 
void yMinMaxOnXAxisCurrentRange (double &min, double &max, QCPAbstractPlottable *plottable_p=nullptr)
 
void yMinMaxOnXAxisCurrentRange (double &min, double &max, int index)
 
virtual void axisRescale ()
 RANGE-related functions. More...
 
virtual void axisReframe ()
 
virtual void axisZoom ()
 
virtual void axisPan ()
 
virtual void replotWithAxesRanges (QCPRange xAxisRange, QCPRange yAxisRange, Axis whichAxis)
 
virtual void replotWithAxisRangeX (double lower, double upper)
 
virtual void replotWithAxisRangeY (double lower, double upper)
 
virtual void hideAllPlotItems ()
 PLOTTING / REPLOTTING functions. More...
 
virtual void showTracers ()
 Show the traces (vertical and horizontal). More...
 
virtual void hideTracers ()
 Hide the traces (vertical and horizontal). More...
 
virtual void drawXDeltaFeatures ()
 
virtual void drawYDeltaFeatures ()
 
virtual void calculateDragDeltas ()
 
virtual bool isVerticalDisplacementAboveThreshold ()
 
virtual void drawSelectionRectangleAndPrepareZoom (bool as_line_segment=false, bool for_integration=false)
 
virtual void updateSelectionRectangle (bool as_line_segment=false, bool for_integration=false)
 
virtual void resetSelectionRectangle ()
 
virtual void hideSelectionRectangle (bool reset_values=false)
 
virtual bool isSelectionRectangleVisible ()
 
virtual PolygonType whatIsVisibleOfTheSelectionRectangle ()
 
virtual void setFocus ()
 PLOT ITEMS : TRACER TEXT ITEMS... More...
 
virtual void redrawPlotBackground (QWidget *focusedPlotWidget)
 Redraw the background of the focusedPlotWidget plot widget. More...
 
virtual void updateContextXandYAxisRanges ()
 
virtual const BasePlotContextgetContext () const
 

Protected Attributes

QCPColorMapData * mpa_backupColorMapData = nullptr
 
ColorMapPlotConfig m_colorMapPlotConfig
 
- Protected Attributes inherited from pappso::BasePlotWidget
QString m_name = "NOT_SET"
 Name of the plot widget. More...
 
QString m_desc = "NOT_SET"
 Description of the plot widget. More...
 
QString m_fileName
 The name of the data file from which the mass data were read. More...
 
QString m_axisLabelX
 
QString m_axisLabelY
 
BasePlotContext m_context
 
int m_leftMousePseudoButtonKey = Qt::Key_Less
 
int m_rightMousePseudoButtonKey = Qt::Key_Greater
 
QCPItemLine * mp_selectionRectangeLine1 = nullptr
 Rectangle defining the borders of zoomed-in/out data. More...
 
QCPItemLine * mp_selectionRectangeLine2 = nullptr
 
QCPItemLine * mp_selectionRectangeLine3 = nullptr
 
QCPItemLine * mp_selectionRectangeLine4 = nullptr
 
QCPItemText * mp_xDeltaTextItem = nullptr
 Text describing the x-axis delta value during a drag operation. More...
 
QCPItemText * mp_yDeltaTextItem = nullptr
 
bool m_shouldTracersBeVisible = true
 Tells if the tracers should be visible. More...
 
QCPItemLine * mp_hPosTracerItem = nullptr
 Horizontal position tracer. More...
 
QCPItemLine * mp_vPosTracerItem = nullptr
 Vertical position tracer. More...
 
QCPItemLine * mp_vStartTracerItem = nullptr
 Vertical selection start tracer (typically in green). More...
 
QCPItemLine * mp_vEndTracerItem = nullptr
 Vertical selection end tracer (typically in red). More...
 
std::size_t m_lastAxisRangeHistoryIndex = 0
 Index of the last axis range history item. More...
 
std::vector< QCPRange * > m_xAxisRangeHistory
 List of x axis ranges occurring during the panning zooming actions. More...
 
std::vector< QCPRange * > m_yAxisRangeHistory
 List of y axis ranges occurring during the panning zooming actions. More...
 
int m_mouseMoveHandlerSkipAmount = 10
 How many mouse move events must be skipped *‍/. More...
 
int m_mouseMoveHandlerSkipCount = 0
 Counter to handle the "fat data" mouse move event handling. More...
 
QColor m_unfocusedColor = QColor("lightgray")
 Color used for the background of unfocused plot. More...
 
QBrush m_unfocusedBrush = QBrush(m_unfocusedColor)
 Color used for the background of unfocused plot. More...
 
QColor m_focusedColor = QColor(Qt::transparent)
 Color used for the background of focused plot. More...
 
QBrush m_focusedBrush = QBrush(m_focusedColor)
 Color used for the background of focused plot. More...
 
QPen m_pen
 Pen used to draw the graph and textual elements in the plot widget. More...
 

Additional Inherited Members

- Signals inherited from pappso::BasePlotWidget
void setFocusSignal ()
 
void lastCursorHoveredPointSignal (const QPointF &pointf)
 
void plotRangesChangedSignal (const BasePlotContext &context)
 
void xAxisMeasurementSignal (const BasePlotContext &context, bool with_delta)
 
void keyPressEventSignal (const BasePlotContext &context)
 
void keyReleaseEventSignal (const BasePlotContext &context)
 
void mouseReleaseEventSignal (const BasePlotContext &context)
 
void plottableSelectionChangedSignal (QCPAbstractPlottable *plottable_p, bool selected)
 
void integrationRequestedSignal (const BasePlotContext &context)
 
void plottableDestructionRequestedSignal (BasePlotWidget *base_plot_widget_p, QCPAbstractPlottable *plottable_p, const BasePlotContext &context)
 
- Protected Member Functions inherited from pappso::BasePlotWidget
virtual void createAllAncillaryItems ()
 
virtual void update1DSelectionRectangle (bool for_integration=false)
 
virtual void update2DSelectionRectangleSquare (bool for_integration=false)
 
virtual void update2DSelectionRectangleSkewed (bool for_integration=false)
 
virtual QString allLayerNamesToString () const
 
virtual QString layerableLayerName (QCPLayerable *layerable_p) const
 
virtual int layerableLayerIndex (QCPLayerable *layerable_p) const
 

Detailed Description

Definition at line 61 of file basecolormapplotwidget.h.

Constructor & Destructor Documentation

◆ BaseColorMapPlotWidget()

pappso::BaseColorMapPlotWidget::BaseColorMapPlotWidget ( QWidget *  parent,
const QString &  x_axis_label,
const QString &  y_axis_label 
)
explicit

Definition at line 44 of file basecolormapplotwidget.cpp.

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 }
BasePlotWidget(QWidget *parent)

◆ ~BaseColorMapPlotWidget()

pappso::BaseColorMapPlotWidget::~BaseColorMapPlotWidget ( )
virtual

Destruct this BaseColorMapPlotWidget instance.

The destruction involves clearing the history, deleting all the axis range history items for x and y axes.

Definition at line 78 of file basecolormapplotwidget.cpp.

79 {
80 }

Member Function Documentation

◆ addColorMap()

QCPColorMap * pappso::BaseColorMapPlotWidget::addColorMap ( std::shared_ptr< std::map< double, MapTrace >>  double_map_trace_map_sp,
ColorMapPlotConfig  color_map_plot_config,
const QColor &  color 
)
virtual

Definition at line 99 of file basecolormapplotwidget.cpp.

103 {
104  // qDebug() << "Adding color map with config:" <<
105  // color_map_plot_config.toString();
106 
107  if(!color.isValid())
108  throw PappsoException(
109  QString("The color to be used for the plot graph is invalid."));
110 
111  QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
112 
113  color_map_p->setLayer("plotsLayer");
114 
115  // Do not forget to copy the config!
116 
117  m_colorMapPlotConfig = color_map_plot_config;
118 
119 #if 0
120  // This is the code on the QCustomPlot documentation and it works fine.
121  QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
122 
123  color_map_p->data()->setSize(50, 50);
124  color_map_p->data()->setRange(QCPRange(0, 2), QCPRange(0, 2));
125  for(int x = 0; x < 50; ++x)
126  for(int y = 0; y < 50; ++y)
127  color_map_p->data()->setCell(x, y, qCos(x / 10.0) + qSin(y / 10.0));
128  color_map_p->setGradient(QCPColorGradient::gpPolar);
129  color_map_p->rescaleDataRange(true);
130  rescaleAxes();
131  replot();
132 #endif
133 
134  // Only now can afford to call createAllAncillaryItems() in this derived class
135  // because the color map has been created already. The rendering order will
136  // thus not hide the ancillary items, since they have been created after the
137  // color map plot (since the rendering order is according to the
138  // order in which the items have been created). See contructor note.
140 
141  // Connect the signal of selection change so that we can re-emit it for the
142  // widget that is using *this widget.
143 
144  connect(color_map_p,
145  static_cast<void (QCPAbstractPlottable::*)(bool)>(
146  &QCPAbstractPlottable::selectionChanged),
147  [this, color_map_p]() {
148  emit plottableSelectionChangedSignal(color_map_p,
149  color_map_p->selected());
150  });
151 
152  // qDebug() << "Configuring the color map with this config:"
153  //<< color_map_plot_config.toString();
154 
155  color_map_p->data()->setSize(color_map_plot_config.keyCellCount,
156  color_map_plot_config.mzCellCount);
157 
158  color_map_p->data()->setRange(QCPRange(color_map_plot_config.minKeyValue,
159  color_map_plot_config.maxKeyValue),
160  QCPRange(color_map_plot_config.minMzValue,
161  color_map_plot_config.maxMzValue));
162  color_map_p->data()->fill(0.0);
163 
164  // We have now to fill the color map.
165 
166  for(auto &&pair : *double_map_trace_map_sp)
167  {
168 
169  // The first value is the key and the second value is the MapTrace into
170  // which we need to iterated and for each point (double mz, double
171  // intensity) create a map cell.
172 
173  double dt_or_rt_key = pair.first;
174  MapTrace map_trace = pair.second;
175 
176  for(auto &&data_point_pair : map_trace)
177  {
178  double mz = data_point_pair.first;
179  double intensity = data_point_pair.second;
180 
181  // We are filling dynamically the color map. If a cell had already
182  // something in, then we need to take that into account. This is
183  // because we let QCustomPlot handle the fuzzy transition between
184  // color map plot cells.
185 
186  double prev_intensity = color_map_p->data()->data(dt_or_rt_key, mz);
187 
188  // qDebug() << "Setting tri-point:" << dt_or_rt_key << "," << mz <<
189  // ","
190  //<< prev_intensity + intensity;
191 
192  color_map_p->data()->setData(
193  dt_or_rt_key, mz, prev_intensity + intensity);
194  }
195  }
196 
197  // At this point we have finished filling-up the color map.
198 
199  // The gpThermal is certainly one of the best.
200 
201  color_map_p->setGradient(QCPColorGradient::gpThermal);
202 
203  color_map_p->rescaleDataRange(true);
204 
205  color_map_p->rescaleAxes();
207 
208  // The pen of the color map itself is of no use. Instead the user will see the
209  // color of the axes' labels.
210 
211  QPen pen = xAxis->basePen();
212  pen.setColor(color);
213 
214  xAxis->setBasePen(pen);
215  xAxis->setLabelColor(color);
216  xAxis->setTickLabelColor(color);
217 
218  yAxis->setBasePen(pen);
219  yAxis->setLabelColor(color);
220  yAxis->setTickLabelColor(color);
221 
222  // And now set the color map's pen to the same color, even if we do not use
223  // it, we need it for coloring the plots that might be integrated from this
224  // color map.
225 
226  color_map_p->setPen(pen);
227 
228  // Copy the color map's data into a backup copy.
229 
230  mpa_backupColorMapData = new QCPColorMapData(*(color_map_p->data()));
231 
232  replot();
233 
234  return color_map_p;
235 }
virtual void createAllAncillaryItems()
virtual void resetAxesRangeHistory()
void plottableSelectionChangedSignal(QCPAbstractPlottable *plottable_p, bool selected)

References pappso::BasePlotWidget::createAllAncillaryItems(), pappso::ColorMapPlotConfig::keyCellCount, m_colorMapPlotConfig, pappso::ColorMapPlotConfig::maxKeyValue, pappso::ColorMapPlotConfig::maxMzValue, pappso::ColorMapPlotConfig::minKeyValue, pappso::ColorMapPlotConfig::minMzValue, mpa_backupColorMapData, pappso::mz, pappso::ColorMapPlotConfig::mzCellCount, pappso::BasePlotWidget::plottableSelectionChangedSignal(), pappso::BasePlotWidget::resetAxesRangeHistory(), pappso::x, and pappso::y.

◆ axisScale()

AxisScale pappso::BaseColorMapPlotWidget::axisScale ( Axis  axis) const

Definition at line 422 of file basecolormapplotwidget.cpp.

423 {
424  if(axis == Axis::x)
426  else if(axis == Axis::y)
428  else if(axis == Axis::z)
430  else
431  throw PappsoException(
432  QString("basecolormapplotwidget.cpp: The axis cannot be different than "
433  "x, y or z."));
434 
435  return AxisScale::unset;
436 }

References m_colorMapPlotConfig, pappso::unset, pappso::x, pappso::ColorMapPlotConfig::xAxisScale, pappso::y, pappso::ColorMapPlotConfig::yAxisScale, pappso::z, and pappso::ColorMapPlotConfig::zAxisScale.

◆ getColorMapPlotConfig()

const ColorMapPlotConfig & pappso::BaseColorMapPlotWidget::getColorMapPlotConfig ( )
virtual

Definition at line 92 of file basecolormapplotwidget.cpp.

93 {
94  return m_colorMapPlotConfig;
95 }

References m_colorMapPlotConfig.

◆ getPlottingColor()

QColor pappso::BaseColorMapPlotWidget::getPlottingColor ( int  index = 0) const
overridevirtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 493 of file basecolormapplotwidget.cpp.

494 {
495  Q_UNUSED(index);
496 
497  QPen pen = xAxis->basePen();
498  return pen.color();
499 }

◆ setColorMapPlotConfig()

void pappso::BaseColorMapPlotWidget::setColorMapPlotConfig ( const ColorMapPlotConfig color_map_config)
virtual

Definition at line 84 of file basecolormapplotwidget.cpp.

86 {
87  m_colorMapPlotConfig = color_map_config;
88 }

References m_colorMapPlotConfig.

◆ setPlottingColor()

void pappso::BaseColorMapPlotWidget::setPlottingColor ( QCPAbstractPlottable *  plottable_p,
const QColor &  new_color 
)
overridevirtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 461 of file basecolormapplotwidget.cpp.

463 {
464  Q_UNUSED(plottable_p);
465 
466  // The pen of the color map itself is of no use. Instead the user will see the
467  // color of the axes' labels.
468 
469  QPen pen = xAxis->basePen();
470  pen.setColor(new_color);
471 
472  xAxis->setBasePen(pen);
473  xAxis->setLabelColor(new_color);
474  xAxis->setTickLabelColor(new_color);
475 
476  yAxis->setBasePen(pen);
477  yAxis->setLabelColor(new_color);
478  yAxis->setTickLabelColor(new_color);
479 
480  // And now set the color map's pen to the same color, even if we do not use
481  // it, we need it for coloring the plots that might be integrated from this
482  // color map.
483 
484  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
485 
486  color_map_p->setPen(pen);
487 
488  replot();
489 }

◆ transposeAxes()

void pappso::BaseColorMapPlotWidget::transposeAxes ( )
virtual

Definition at line 239 of file basecolormapplotwidget.cpp.

240 {
241  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
242 
243  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
244 
245  QCPColorMapData *origData = color_map_p->data();
246 
247  int keySize = origData->keySize();
248  int valueSize = origData->valueSize();
249 
250  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
251  //<< "Orig data size:" << keySize << valueSize;
252 
253  QCPRange keyRange = origData->keyRange();
254  QCPRange valueRange = origData->valueRange();
255 
256  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
257  //<< "Value at cell 80,650:" << origData->cell(80,650);
258 
259  // Transposed map.
260  QCPColorMapData *newData =
261  new QCPColorMapData(valueSize, keySize, valueRange, keyRange);
262 
263  for(int iter = 0; iter < keySize; ++iter)
264  {
265  for(int jter = 0; jter < valueSize; ++jter)
266  {
267  double cellData = origData->cell(iter, jter);
268 
269  newData->setCell(jter, iter, cellData);
270  }
271  }
272 
273  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
274  //<< "New data size:" << newData->keySize() << newData->valueSize();
275 
276  // At this point the transposition has been done.
277 
278  color_map_p->data()->clear();
279  color_map_p->rescaleDataRange(true);
280 
281  // Now we need to invert the labels and data kinds.
282 
285  m_colorMapPlotConfig.yAxisDataKind = temp_data_kind;
286 
287  QString temp_axis_label = xAxis->label();
288  xAxis->setLabel(yAxis->label());
289  yAxis->setLabel(temp_axis_label);
290 
291  // Will take ownership of the newData.
292  color_map_p->setData(newData);
293 
294  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
295  //<< "Value at cell 80,650:" << newData->cell(80,650)
296  //<< "Value at cell 650, 80:" << newData->cell(650,80);
297 
298  // QCPAxis *p_keyAxis = mp_colorMap->keyAxis();
299  // QCPAxis *p_valueAxis = mp_colorMap->valueAxis();
300 
301  // mp_colorMap->setKeyAxis(p_valueAxis);
302  // mp_colorMap->setValueAxis(p_keyAxis);
303 
304  color_map_p->rescaleAxes();
305 
306  replot();
307 }
DataKind
Definition: types.h:171

References m_colorMapPlotConfig, pappso::ColorMapPlotConfig::xAxisDataKind, and pappso::ColorMapPlotConfig::yAxisDataKind.

◆ xAxisDataKind()

DataKind pappso::BaseColorMapPlotWidget::xAxisDataKind ( ) const

◆ xAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::xAxisScale ( ) const

Definition at line 440 of file basecolormapplotwidget.cpp.

441 {
443 }

References m_colorMapPlotConfig, and pappso::ColorMapPlotConfig::xAxisScale.

◆ yAxisDataKind()

DataKind pappso::BaseColorMapPlotWidget::yAxisDataKind ( ) const

◆ yAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::yAxisScale ( ) const

Definition at line 447 of file basecolormapplotwidget.cpp.

448 {
450 }

References m_colorMapPlotConfig, and pappso::ColorMapPlotConfig::yAxisScale.

◆ zAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::zAxisScale ( ) const

Definition at line 454 of file basecolormapplotwidget.cpp.

455 {
457 }

References m_colorMapPlotConfig, and pappso::ColorMapPlotConfig::zAxisScale.

◆ zAxisScaleResetToOriginal()

void pappso::BaseColorMapPlotWidget::zAxisScaleResetToOriginal ( )
virtual

Definition at line 380 of file basecolormapplotwidget.cpp.

381 {
382  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
383  color_map_p->data()->clear();
384 
385  if(mpa_backupColorMapData == nullptr)
386  throw(PappsoException(
387  "Not possible that the mpa_backupColorMapData pointer is null."));
388 
389  // We do no want that the color_map_p takes ownership of the data, because
390  // these must remain there always, so pass true, to say that we want to copy
391  // the data not transfer the pointer.
392  color_map_p->setData(mpa_backupColorMapData, true);
393 
394  color_map_p->data()->recalculateDataBounds();
395  color_map_p->rescaleDataRange(true);
396 
397  // We should not do this, as the user might have zoomed to a region of
398  // interest.
399  // color_map_p->rescaleAxes();
400 
402 
403  replot();
404 }

References m_colorMapPlotConfig, mpa_backupColorMapData, pappso::orig, and pappso::ColorMapPlotConfig::zAxisScale.

◆ zAxisScaleToLog10()

void pappso::BaseColorMapPlotWidget::zAxisScaleToLog10 ( )
virtual

Definition at line 311 of file basecolormapplotwidget.cpp.

312 {
313  // qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
314 
316  {
317  qDebug() << "Asking to change z axis scale to log10 while it is already "
318  "like so.";
319 
320  return;
321  }
322 
323  QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
324 
325  QCPColorMapData *origData = color_map_p->data();
326 
327  int keySize = origData->keySize();
328  int valueSize = origData->valueSize();
329 
330  QCPRange keyRange = origData->keyRange();
331  QCPRange valueRange = origData->valueRange();
332 
333  // Log-ified heat map.
334  QCPColorMapData *newData =
335  new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
336 
337  for(int iter = 0; iter < keySize; ++iter)
338  {
339  for(int jter = 0; jter < valueSize; ++jter)
340  {
341  double cell_data = origData->cell(iter, jter);
342 
343  double new_cell_data = 0;
344 
345  if(!cell_data)
346  // The log10 would be -inf, but then we'd have a huge data range and
347  // the color map would look totally blue... that is like 0 intensity
348  // all over.
349  new_cell_data = -1;
350  else
351  new_cell_data = std::log10(cell_data);
352 
353  // qDebug() << "cell_data:" << cell_data
354  //<< "new_cell_data:" << new_cell_data;
355 
356  newData->setCell(iter, jter, new_cell_data);
357  }
358  }
359 
360  color_map_p->data()->clear();
361  // Now we need to document the change.
362 
364 
365  // Will take ownership of the newData.
366  color_map_p->setData(newData);
367 
368  color_map_p->data()->recalculateDataBounds();
369  color_map_p->rescaleDataRange(true);
370 
371  // We should not do this, as the user might have zoomed to a region of
372  // interest.
373  // color_map_p->rescaleAxes();
374 
375  replot();
376 }

References pappso::log10, m_colorMapPlotConfig, and pappso::ColorMapPlotConfig::zAxisScale.

Member Data Documentation

◆ m_colorMapPlotConfig

◆ mpa_backupColorMapData

QCPColorMapData* pappso::BaseColorMapPlotWidget::mpa_backupColorMapData = nullptr
protected

Definition at line 102 of file basecolormapplotwidget.h.

Referenced by addColorMap(), and zAxisScaleResetToOriginal().


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