pappso::BaseColorMapPlotWidget Class Reference

`#include <basecolormapplotwidget.h>`

Inheritance diagram for pappso::BaseColorMapPlotWidget:

## 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 ColorMapPlotConfig & | getColorMapPlotConfig ()
const ColorMapPlotConfig * | getOrigColorMapPlotConfig ()
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 void | transposeAxes ()
virtual void | zAxisScaleToLog10 ()
virtual void | zAxisFilterLowPassPercentage (double threshold_percentage)
virtual void | zAxisFilterHighPassPercentage (double threshold_percentage)
virtual void | zAxisDataResetToOriginal ()
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
QString | dataToString ()
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 BasePlotContext & | getContext () const

## Protected Attributes

QCPColorMapData * | mpa_origColorMapData = nullptr
ColorMapPlotConfig | m_colorMapPlotConfig
ColorMapPlotConfig * | mpa_origColorMapPlotConfig = nullptr
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.

: BasePlotWidget(parent, x_axis_label, y_axis_label)
{
// Do not call createAllAncillaryItems() in this base class because all the
// items will have been created *before* the addition of plots and then the
// rendering order will hide them to the viewer, since the rendering order is
// according to the order in which the items have been created.
//
// The fact that the ancillary items are created before trace plots is not a
// problem because the trace plots are sparse and do not effectively hide the
// data.
//
// But, in the color map plot widgets, we cannot afford to create the
// ancillary items *before* the plot itself because then, the rendering of the
// plot (created after) would screen off the ancillary items (created before).
//
// So, the createAllAncillaryItems() function needs to be called in the
// derived classes at the most appropriate moment in the setting up of the
// widget.
//
// In the present case, the function needs to be called right after addition
// of the color map plot.
}
pappso::BasePlotWidget::BasePlotWidget
BasePlotWidget(QWidget *parent)
Definition: baseplotwidget.cpp:49

## ~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.

{
if(mpa_origColorMapData != nullptr)
delete mpa_origColorMapData;
if(mpa_origColorMapPlotConfig != nullptr)
delete mpa_origColorMapPlotConfig;
}
pappso::BaseColorMapPlotWidget::mpa_origColorMapPlotConfig
ColorMapPlotConfig * mpa_origColorMapPlotConfig
Definition: basecolormapplotwidget.h:111
pappso::BaseColorMapPlotWidget::mpa_origColorMapData
QCPColorMapData * mpa_origColorMapData
Definition: basecolormapplotwidget.h:108

References mpa_origColorMapData, and mpa_origColorMapPlotConfig.

## Member Function Documentation

## addColorMap()

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

virtual

Definition at line 111 of file basecolormapplotwidget.cpp.

{
// qDebug() << "Adding color map with config:" <<
// color_map_plot_config.toString();
if(!color.isValid())
throw PappsoException(
QString("The color to be used for the plot graph is invalid."));
QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
color_map_p->setLayer("plotsLayer");
// Do not forget to copy the config!
m_colorMapPlotConfig = color_map_plot_config;
// Immediately create a copy of the original data for backup.
mpa_origColorMapPlotConfig = new ColorMapPlotConfig(color_map_plot_config);
#if 0
// This is the code on the QCustomPlot documentation and it works fine.
QCPColorMap *color_map_p = new QCPColorMap(xAxis, yAxis);
color_map_p->data()->setSize(50, 50);
color_map_p->data()->setRange(QCPRange(0, 2), QCPRange(0, 2));
for(int x = 0; x < 50; ++x)
for(int y = 0; y < 50; ++y)
color_map_p->data()->setCell(x, y, qCos(x / 10.0) + qSin(y / 10.0));
color_map_p->setGradient(QCPColorGradient::gpPolar);
color_map_p->rescaleDataRange(true);
rescaleAxes();
replot();
#endif
// Only now can afford to call createAllAncillaryItems() in this derived class
// because the color map has been created already. The rendering order will
// thus not hide the ancillary items, since they have been created after the
// color map plot (since the rendering order is according to the
// order in which the items have been created). See contructor note.
createAllAncillaryItems();
// Connect the signal of selection change so that we can re-emit it for the
// widget that is using *this widget.
connect(color_map_p,
static_cast<void (QCPAbstractPlottable::*)(bool)>(
&QCPAbstractPlottable::selectionChanged),
[this, color_map_p]() {
emit plottableSelectionChangedSignal(color_map_p,
color_map_p->selected());
});
// qDebug() << "Configuring the color map with this config:"
//<< color_map_plot_config.toString();
color_map_p->data()->setSize(color_map_plot_config.keyCellCount,
color_map_plot_config.mzCellCount);
color_map_p->data()->setRange(QCPRange(color_map_plot_config.minKeyValue,
color_map_plot_config.maxKeyValue),
QCPRange(color_map_plot_config.minMzValue,
color_map_plot_config.maxMzValue));
color_map_p->data()->fill(0.0);
// We have now to fill the color map.
for(auto &&pair : *double_map_trace_map_sp)
{
// The first value is the key and the second value is the MapTrace into
// which we need to iterated and for each point (double mz, double
// intensity) create a map cell.
double dt_or_rt_key = pair.first;
MapTrace map_trace = pair.second;
for(auto &&data_point_pair : map_trace)
{
double mz = data_point_pair.first;
double intensity = data_point_pair.second;
// We are filling dynamically the color map. If a cell had already
// something in, then we need to take that into account. This is
// because we let QCustomPlot handle the fuzzy transition between
// color map plot cells.
double prev_intensity = color_map_p->data()->data(dt_or_rt_key, mz);
double new_intensity = prev_intensity + intensity;
// Record the min/max cell intensity value (origM(in/ax)ZValue). We
// will need that later. Also update the lastM(in/ax)ZValue because
// when doing this kind of data conversion it is assume that the user
// actually changes the data.
m_colorMapPlotConfig.setOrigAndLastMinZValue(
std::min(m_colorMapPlotConfig.origMinZValue, new_intensity));
m_colorMapPlotConfig.setOrigAndLastMaxZValue(
std::max(m_colorMapPlotConfig.origMaxZValue, new_intensity));
// qDebug() << "Setting tri-point:" << dt_or_rt_key << "," << mz <<
// ","
//<< new_intensity;
color_map_p->data()->setData(dt_or_rt_key, mz, new_intensity);
}
}
// At this point we have finished filling-up the color map.
// The gpThermal is certainly one of the best.
color_map_p->setGradient(QCPColorGradient::gpThermal);
color_map_p->rescaleDataRange(true);
color_map_p->rescaleAxes();
resetAxesRangeHistory();
// The pen of the color map itself is of no use. Instead the user will see the
// color of the axes' labels.
QPen pen = xAxis->basePen();
pen.setColor(color);
xAxis->setBasePen(pen);
xAxis->setLabelColor(color);
xAxis->setTickLabelColor(color);
yAxis->setBasePen(pen);
yAxis->setLabelColor(color);
yAxis->setTickLabelColor(color);
// And now set the color map's pen to the same color, even if we do not use
// it, we need it for coloring the plots that might be integrated from this
// color map.
color_map_p->setPen(pen);
// Copy the original color map's data into a backup copy.
mpa_origColorMapData = new QCPColorMapData(*(color_map_p->data()));
replot();
return color_map_p;
}
pappso::BaseColorMapPlotWidget::m_colorMapPlotConfig
ColorMapPlotConfig m_colorMapPlotConfig
Definition: basecolormapplotwidget.h:110
pappso::BasePlotWidget::createAllAncillaryItems
virtual void createAllAncillaryItems()
Definition: baseplotwidget.cpp:221
pappso::BasePlotWidget::resetAxesRangeHistory
virtual void resetAxesRangeHistory()
Definition: baseplotwidget.cpp:482
pappso::BasePlotWidget::plottableSelectionChangedSignal
void plottableSelectionChangedSignal(QCPAbstractPlottable *plottable_p, bool selected)
pappso::PrecisionUnit::mz
@ mz
pappso::PeptideIonCter::y
@ y
pappso::PeptideIonCter::x
@ x
pappso::ColorMapPlotConfig::setOrigAndLastMaxZValue
void setOrigAndLastMaxZValue(double value)
Definition: colormapplotconfig.cpp:144
pappso::ColorMapPlotConfig::setOrigAndLastMinZValue
void setOrigAndLastMinZValue(double value)
Definition: colormapplotconfig.cpp:130
pappso::ColorMapPlotConfig::origMaxZValue
double origMaxZValue
Definition: colormapplotconfig.h:46
pappso::ColorMapPlotConfig::origMinZValue
double origMinZValue
Definition: colormapplotconfig.h:43

References pappso::BasePlotWidget::createAllAncillaryItems(), pappso::ColorMapPlotConfig::keyCellCount, m_colorMapPlotConfig, pappso::ColorMapPlotConfig::maxKeyValue, pappso::ColorMapPlotConfig::maxMzValue, pappso::ColorMapPlotConfig::minKeyValue, pappso::ColorMapPlotConfig::minMzValue, mpa_origColorMapData, mpa_origColorMapPlotConfig, pappso::mz, pappso::ColorMapPlotConfig::mzCellCount, pappso::ColorMapPlotConfig::origMaxZValue, pappso::ColorMapPlotConfig::origMinZValue, pappso::BasePlotWidget::plottableSelectionChangedSignal(), pappso::BasePlotWidget::resetAxesRangeHistory(), pappso::ColorMapPlotConfig::setOrigAndLastMaxZValue(), pappso::ColorMapPlotConfig::setOrigAndLastMinZValue(), pappso::x, and pappso::y.

## axisScale()

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

Definition at line 727 of file basecolormapplotwidget.cpp.

{
if(axis == Axis::x)
return m_colorMapPlotConfig.xAxisScale;
else if(axis == Axis::y)
return m_colorMapPlotConfig.yAxisScale;
else if(axis == Axis::z)
return m_colorMapPlotConfig.zAxisScale;
else
throw PappsoException(
QString("basecolormapplotwidget.cpp: The axis cannot be different than "
"x, y or z."));
return AxisScale::unset;
}
pappso::Axis::y
@ y
pappso::Axis::x
@ x
pappso::Axis::z
@ z
pappso::AxisScale::unset
@ unset
pappso::ColorMapPlotConfig::xAxisScale
AxisScale xAxisScale
Definition: colormapplotconfig.h:27
pappso::ColorMapPlotConfig::zAxisScale
AxisScale zAxisScale
Definition: colormapplotconfig.h:29
pappso::ColorMapPlotConfig::yAxisScale
AxisScale yAxisScale
Definition: colormapplotconfig.h:28

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

## dataToString()

QString pappso::BaseColorMapPlotWidget::dataToString | ( |  | ) |

Definition at line 808 of file basecolormapplotwidget.cpp.

{
// We want to export the data to a string in the x y z format, with
// x=key (cell's x coordinate)
// y=value (cell's y coordinate)
// z=intensity (cell value)
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
QCPColorMapData *map_data = color_map_p->data();
int keySize = map_data->keySize();
int valueSize = map_data->valueSize();
QString text;
for(int iter = 0; iter < keySize; ++iter)
{
for(int jter = 0; jter < valueSize; ++jter)
{
text += QString("%1 %2 %3\n")
.arg(iter, 0, 'f', 6, ' ')
.arg(jter, 0, 'f', 6, ' ')
.arg(map_data->cell(iter, jter), 0, 'f', 6, ' ');
}
}
return text;
}

## getColorMapPlotConfig()

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

virtual

Definition at line 104 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig;
}

References m_colorMapPlotConfig.

## getOrigColorMapPlotConfig()

const ColorMapPlotConfig * pappso::BaseColorMapPlotWidget::getOrigColorMapPlotConfig | ( |  | ) |

Definition at line 97 of file basecolormapplotwidget.cpp.

{
return mpa_origColorMapPlotConfig;
}

References mpa_origColorMapPlotConfig.

## getPlottingColor()

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

override virtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 798 of file basecolormapplotwidget.cpp.

{
Q_UNUSED(index);
QPen pen = xAxis->basePen();
return pen.color();
}

## setColorMapPlotConfig()

void pappso::BaseColorMapPlotWidget::setColorMapPlotConfig | ( | const ColorMapPlotConfig & | color_map_config | ) |

virtual

Definition at line 89 of file basecolormapplotwidget.cpp.

{
m_colorMapPlotConfig = color_map_config;
}

References m_colorMapPlotConfig.

## setPlottingColor()

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

override virtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 766 of file basecolormapplotwidget.cpp.

{
Q_UNUSED(plottable_p);
// The pen of the color map itself is of no use. Instead the user will see the
// color of the axes' labels.
QPen pen = xAxis->basePen();
pen.setColor(new_color);
xAxis->setBasePen(pen);
xAxis->setLabelColor(new_color);
xAxis->setTickLabelColor(new_color);
yAxis->setBasePen(pen);
yAxis->setLabelColor(new_color);
yAxis->setTickLabelColor(new_color);
// And now set the color map's pen to the same color, even if we do not use
// it, we need it for coloring the plots that might be integrated from this
// color map.
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
color_map_p->setPen(pen);
replot();
}

## transposeAxes()

void pappso::BaseColorMapPlotWidget::transposeAxes | ( |  | ) |

virtual

Definition at line 263 of file basecolormapplotwidget.cpp.

{
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
QCPColorMapData *origData = color_map_p->data();
int keySize = origData->keySize();
int valueSize = origData->valueSize();
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
//<< "Orig data size:" << keySize << valueSize;
QCPRange keyRange = origData->keyRange();
QCPRange valueRange = origData->valueRange();
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
//<< "Value at cell 80,650:" << origData->cell(80,650);
// Transposed map.
QCPColorMapData *newData =
new QCPColorMapData(valueSize, keySize, valueRange, keyRange);
for(int iter = 0; iter < keySize; ++iter)
{
for(int jter = 0; jter < valueSize; ++jter)
{
double cellData = origData->cell(iter, jter);
newData->setCell(jter, iter, cellData);
}
}
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
//<< "New data size:" << newData->keySize() << newData->valueSize();
// At this point the transposition has been done.
color_map_p->data()->clear();
color_map_p->rescaleDataRange(true);
// Now we need to invert the labels and data kinds.
DataKind temp_data_kind = m_colorMapPlotConfig.xAxisDataKind;
m_colorMapPlotConfig.xAxisDataKind = m_colorMapPlotConfig.yAxisDataKind;
m_colorMapPlotConfig.yAxisDataKind = temp_data_kind;
QString temp_axis_label = xAxis->label();
xAxis->setLabel(yAxis->label());
yAxis->setLabel(temp_axis_label);
// Will take ownership of the newData.
color_map_p->setData(newData);
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()"
//<< "Value at cell 80,650:" << newData->cell(80,650)
//<< "Value at cell 650, 80:" << newData->cell(650,80);
// QCPAxis *p_keyAxis = mp_colorMap->keyAxis();
// QCPAxis *p_valueAxis = mp_colorMap->valueAxis();
// mp_colorMap->setKeyAxis(p_valueAxis);
// mp_colorMap->setValueAxis(p_keyAxis);
color_map_p->rescaleAxes();
replot();
}
pappso::DataKind
DataKind
Definition: types.h:171
pappso::ColorMapPlotConfig::xAxisDataKind
DataKind xAxisDataKind
Definition: colormapplotconfig.h:24
pappso::ColorMapPlotConfig::yAxisDataKind
DataKind yAxisDataKind
Definition: colormapplotconfig.h:25

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

## xAxisDataKind()

DataKind pappso::BaseColorMapPlotWidget::xAxisDataKind | ( |  | ) | const

Definition at line 713 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig.xAxisDataKind;
}

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

## xAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::xAxisScale | ( |  | ) | const

Definition at line 745 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig.xAxisScale;
}

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

## yAxisDataKind()

DataKind pappso::BaseColorMapPlotWidget::yAxisDataKind | ( |  | ) | const

Definition at line 720 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig.yAxisDataKind;
}

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

## yAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::yAxisScale | ( |  | ) | const

Definition at line 752 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig.yAxisScale;
}

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

## zAxisDataResetToOriginal()

void pappso::BaseColorMapPlotWidget::zAxisDataResetToOriginal | ( |  | ) |

virtual

Definition at line 676 of file basecolormapplotwidget.cpp.

{
// The user might have changed to the axis scale to log10, for example.
// While doing this, the original data were still available in
// mpa_origColorMapData,with mpa_origColorMapPlotConfig. We need to reset the
// current data to the original data.
//
// Same thing for filters that might have been applied to the data.
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
color_map_p->data()->clear();
if(mpa_origColorMapData == nullptr)
throw(PappsoException(
"Not possible that the mpa_origColorMapData pointer be null."));
// We do no want that the color_map_p takes ownership of the data, because
// these must remain there always, so pass true, to say that we want to copy
// the data not transfer the pointer.
color_map_p->setData(mpa_origColorMapData, true);
color_map_p->data()->recalculateDataBounds();
color_map_p->rescaleDataRange(true);
// We should not do this, as the user might have zoomed to a region of
// interest.
// color_map_p->rescaleAxes();
// Reset the current plot config to what it was originally. The member
// m_colorMapPlotConfig.zAxisScale is now AxisScale::orig.
m_colorMapPlotConfig = *mpa_origColorMapPlotConfig;
replot();
}

References m_colorMapPlotConfig, mpa_origColorMapData, and mpa_origColorMapPlotConfig.

## zAxisFilterHighPassPercentage()

void pappso::BaseColorMapPlotWidget::zAxisFilterHighPassPercentage | ( | double | threshold_percentage | ) |

virtual

Definition at line 565 of file basecolormapplotwidget.cpp.

{
// This filter allows all the value greater than a threshold to remain
// unchanged. Instead, all the values below the threshold will be reset to
// that threshold value.
//
// The effect of this filter is to reduce the low-intensity signal: reduce
// noise.
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
QCPColorMapData *map_data = color_map_p->data();
int keySize = map_data->keySize();
int valueSize = map_data->valueSize();
QCPRange keyRange = map_data->keyRange();
QCPRange valueRange = map_data->valueRange();
double minZValue = m_colorMapPlotConfig.lastMinZValue;
double maxZValue = m_colorMapPlotConfig.lastMaxZValue;
double amplitude = maxZValue - minZValue;
double amplitude_fraction = amplitude * threshold_percentage / 100;
double threshold = minZValue + amplitude_fraction;
//qDebug() << "Before filtering minZValue:" << minZValue
//<< "maxZValue:" << maxZValue << "fraction:" << fraction
//<< "threshold:" << threshold
//<< "new threshold percentage:" << new_threshold_percentage;
// Make a copy of the current config so that we can modify
// the xxxZvalue values.
ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
// But we need to reset these two values to be able to update them using
// std::min() and std::max() below.
new_color_map_plot_config.lastMinZValue = std::numeric_limits<double>::max();
new_color_map_plot_config.lastMaxZValue = std::numeric_limits<double>::min();
// Filtered
QCPColorMapData *new_map_data =
new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
for(int iter = 0; iter < keySize; ++iter)
{
for(int jter = 0; jter < valueSize; ++jter)
{
double cell_data = map_data->cell(iter, jter);
double new_cell_data = 0;
if(cell_data > threshold)
// Keep the value, we are in high-pass
new_cell_data = cell_data;
else
new_cell_data = threshold;
// Store the new values here.
new_color_map_plot_config.lastMinZValue =
//(new_cell_data < new_color_map_plot_config.minZValue
//? new_cell_data
//: new_color_map_plot_config.minZValue);
std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
new_color_map_plot_config.lastMaxZValue =
//(new_cell_data > new_color_map_plot_config.maxZValue
//? new_cell_data
//: new_color_map_plot_config.maxZValue);
std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
// qDebug() << "cell_data:" << cell_data
//<< "new_cell_data:" << new_cell_data
//<< "new_color_map_plot_config.minZValue:"
//<< new_color_map_plot_config.minZValue
//<< "new_color_map_plot_config.maxZValue:"
//<< new_color_map_plot_config.maxZValue;
new_map_data->setCell(iter, jter, new_cell_data);
}
}
color_map_p->data()->clear();
// Will take ownership of the new_map_data.
color_map_p->setData(new_map_data);
color_map_p->data()->recalculateDataBounds();
color_map_p->rescaleDataRange(true);
// At this point the new color map data have taken their place, we can update
// the config. This, way any new filtering can take advantage of the new
// values and compute the threshold correctly.
m_colorMapPlotConfig = new_color_map_plot_config;
// qDebug() << "Member colormap plot config is now, after filter was applied:"
//<< m_colorMapPlotConfig.toString();
// We should not do this, as the user might have zoomed to a region of
// interest.
// color_map_p->rescaleAxes();
replot();
}
pappso::ColorMapPlotConfig::lastMaxZValue
double lastMaxZValue
Definition: colormapplotconfig.h:47
pappso::ColorMapPlotConfig::lastMinZValue
double lastMinZValue
Definition: colormapplotconfig.h:44

References pappso::ColorMapPlotConfig::lastMaxZValue, pappso::ColorMapPlotConfig::lastMinZValue, and m_colorMapPlotConfig.

## zAxisFilterLowPassPercentage()

void pappso::BaseColorMapPlotWidget::zAxisFilterLowPassPercentage | ( | double | threshold_percentage | ) |

virtual

Definition at line 455 of file basecolormapplotwidget.cpp.

{
// This filter allows all the values smaller than a threshold to remain
// unchanged. Instead, all the values above the threshold will be reset to
// that threshold.
//
// The effect of this filter is to enhance the high-intensity signal.
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
QCPColorMapData *map_data = color_map_p->data();
int keySize = map_data->keySize();
int valueSize = map_data->valueSize();
QCPRange keyRange = map_data->keyRange();
QCPRange valueRange = map_data->valueRange();
double minZValue = m_colorMapPlotConfig.lastMinZValue;
double maxZValue = m_colorMapPlotConfig.lastMaxZValue;
double amplitude = maxZValue - minZValue;
double amplitude_fraction = amplitude * threshold_percentage / 100;
double threshold = minZValue + amplitude_fraction;
//qDebug() << "Before filtering minZValue:" << minZValue
//<< "maxZValue:" << maxZValue << "fraction:" << fraction
//<< "threshold:" << threshold
//<< "new threshold percentage:" << new_threshold_percentage;
// Make a copy of the current config so that we can modify
// the xxxZvalue values.
ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
// But we need to reset these two values to be able to update them using
// std::min() and std::max() below.
new_color_map_plot_config.lastMinZValue = std::numeric_limits<double>::max();
new_color_map_plot_config.lastMaxZValue = std::numeric_limits<double>::min();
// Filtered
QCPColorMapData *new_map_data =
new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
for(int iter = 0; iter < keySize; ++iter)
{
for(int jter = 0; jter < valueSize; ++jter)
{
double cell_data = map_data->cell(iter, jter);
double new_cell_data = 0;
if(cell_data < threshold)
// Keep the value, we are in low-pass
new_cell_data = cell_data;
else
new_cell_data = threshold;
// Store the new values here.
new_color_map_plot_config.lastMinZValue =
//(new_cell_data < new_color_map_plot_config.minZValue
//? new_cell_data
//: new_color_map_plot_config.minZValue);
std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
new_color_map_plot_config.lastMaxZValue =
//(new_cell_data > new_color_map_plot_config.maxZValue
//? new_cell_data
//: new_color_map_plot_config.maxZValue);
std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
// qDebug() << "cell_data:" << cell_data
//<< "new_cell_data:" << new_cell_data
//<< "new_color_map_plot_config.minZValue:"
//<< new_color_map_plot_config.minZValue
//<< "new_color_map_plot_config.maxZValue:"
//<< new_color_map_plot_config.maxZValue;
new_map_data->setCell(iter, jter, new_cell_data);
}
}
color_map_p->data()->clear();
// Will take ownership of the new_map_data.
color_map_p->setData(new_map_data);
color_map_p->data()->recalculateDataBounds();
color_map_p->rescaleDataRange(true);
// At this point the new color map data have taken their place, we can update
// the config. This, way any new filtering can take advantage of the new
// values and compute the threshold correctly.
m_colorMapPlotConfig = new_color_map_plot_config;
// qDebug() << "Member colormap plot config is now, after filter was applied:"
//<< m_colorMapPlotConfig.toString();
// We should not do this, as the user might have zoomed to a region of
// interest.
// color_map_p->rescaleAxes();
replot();
}

References pappso::ColorMapPlotConfig::lastMaxZValue, pappso::ColorMapPlotConfig::lastMinZValue, and m_colorMapPlotConfig.

## zAxisScale()

AxisScale pappso::BaseColorMapPlotWidget::zAxisScale | ( |  | ) | const

Definition at line 759 of file basecolormapplotwidget.cpp.

{
return m_colorMapPlotConfig.zAxisScale;
}

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

## zAxisScaleToLog10()

void pappso::BaseColorMapPlotWidget::zAxisScaleToLog10 | ( |  | ) |

virtual

Definition at line 335 of file basecolormapplotwidget.cpp.

{
// The user wants to rescale the intensity values of the color map according
// to: new_int = log10(orig_int).
// qDebug() << __FILE__ << __LINE__ << __FUNCTION__ << "()" ;
if(m_colorMapPlotConfig.zAxisScale == AxisScale::log10)
{
qDebug() << "Asking to change z axis scale to log10 while it is already "
"like so.";
return;
}
// qDebug() << "m_colorMapPlotConfig:" << m_colorMapPlotConfig.toString();
QCPColorMap *color_map_p = static_cast<QCPColorMap *>(plottable(0));
QCPColorMapData *map_data = color_map_p->data();
int keySize = map_data->keySize();
int valueSize = map_data->valueSize();
QCPRange keyRange = map_data->keyRange();
QCPRange valueRange = map_data->valueRange();
// Make a copy of the current config so that we can modify
// the xxxZvalue values.
ColorMapPlotConfig new_color_map_plot_config(m_colorMapPlotConfig);
// But we need to reset these two values to be able to update them using
// std::min() and std::max() below.
new_color_map_plot_config.setOrigAndLastMinZValue(
std::numeric_limits<double>::max());
new_color_map_plot_config.setOrigAndLastMaxZValue(
std::numeric_limits<double>::min());
// qDebug() << "new_color_map_plot_config"
//<< new_color_map_plot_config.toString();
// Log-ified heat map.
QCPColorMapData *new_map_data =
new QCPColorMapData(keySize, valueSize, keyRange, valueRange);
// qDebug() << "Starting iteration in the color map.";
for(int iter = 0; iter < keySize; ++iter)
{
for(int jter = 0; jter < valueSize; ++jter)
{
double cell_data = map_data->cell(iter, jter);
double new_cell_data = 0;
if(!cell_data)
// The log10 would be -inf, but then we'd have a huge data range and
// the color map would look totally blue... that is like 0 intensity
// all over.
new_cell_data = -1;
else
new_cell_data = std::log10(cell_data);
// Store the new values here. Should we change the last or orig or
// both ?
new_color_map_plot_config.lastMinZValue =
//(new_cell_data < new_color_map_plot_config.minZValue
//? new_cell_data
//: new_color_map_plot_config.minZValue);
std::min(new_color_map_plot_config.lastMinZValue, new_cell_data);
new_color_map_plot_config.lastMaxZValue =
//(new_cell_data > new_color_map_plot_config.maxZValue
//? new_cell_data
//: new_color_map_plot_config.maxZValue);
std::max(new_color_map_plot_config.lastMaxZValue, new_cell_data);
// qDebug() << "cell_data:" << cell_data
//<< "new_cell_data:" << new_cell_data
//<< "new_color_map_plot_config.minZValue:"
//<< new_color_map_plot_config.minZValue
//<< "new_color_map_plot_config.maxZValue:"
//<< new_color_map_plot_config.maxZValue;
new_map_data->setCell(iter, jter, new_cell_data);
}
}
// qDebug() << "Finished iteration in the color map.";
color_map_p->data()->clear();
// Will take ownership of the new_map_data.
color_map_p->setData(new_map_data);
color_map_p->data()->recalculateDataBounds();
color_map_p->rescaleDataRange(true);
// At this point the new color map data have taken their place, we can update
// the config. This, way any new filtering can take advantage of the new
// values and compute the threshold correctly.
m_colorMapPlotConfig = new_color_map_plot_config;
// Now we need to document the change.
m_colorMapPlotConfig.zAxisScale = AxisScale::log10;
// qDebug() << "new_color_map_plot_config"
//<< new_color_map_plot_config.toString();
// qDebug() << "m_colorMapPlotConfig:" << m_colorMapPlotConfig.toString();
// We should not do this, as the user might have zoomed to a region of
// interest.
// color_map_p->rescaleAxes();
replot();
}
pappso::AxisScale::log10
@ log10

References pappso::ColorMapPlotConfig::lastMaxZValue, pappso::ColorMapPlotConfig::lastMinZValue, pappso::log10, m_colorMapPlotConfig, pappso::ColorMapPlotConfig::setOrigAndLastMaxZValue(), pappso::ColorMapPlotConfig::setOrigAndLastMinZValue(), and pappso::ColorMapPlotConfig::zAxisScale.

## Member Data Documentation

## m_colorMapPlotConfig

ColorMapPlotConfig pappso::BaseColorMapPlotWidget::m_colorMapPlotConfig

protected

Definition at line 110 of file basecolormapplotwidget.h.

Referenced by addColorMap(), axisScale(), getColorMapPlotConfig(), setColorMapPlotConfig(), transposeAxes(), xAxisDataKind(), xAxisScale(), yAxisDataKind(), yAxisScale(), zAxisDataResetToOriginal(), zAxisFilterHighPassPercentage(), zAxisFilterLowPassPercentage(), zAxisScale(), and zAxisScaleToLog10().

## mpa_origColorMapData

QCPColorMapData* pappso::BaseColorMapPlotWidget::mpa_origColorMapData = nullptr

protected

Definition at line 108 of file basecolormapplotwidget.h.

Referenced by ~BaseColorMapPlotWidget(), addColorMap(), and zAxisDataResetToOriginal().

## mpa_origColorMapPlotConfig

ColorMapPlotConfig* pappso::BaseColorMapPlotWidget::mpa_origColorMapPlotConfig = nullptr

protected

Definition at line 111 of file basecolormapplotwidget.h.

Referenced by ~BaseColorMapPlotWidget(), addColorMap(), getOrigColorMapPlotConfig(), and zAxisDataResetToOriginal().

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

- pappsomspp/widget/plotwidget/basecolormapplotwidget.h
- pappsomspp/widget/plotwidget/basecolormapplotwidget.cpp