25 const int replot_update_interval = 10;
26 const int colorbar_width_logz = 50;
27 const int colorbar_width = 80;
32 , m_customPlot(new QCustomPlot)
34 , m_colorScale(nullptr)
35 , m_updateTimer(new
UpdateTimer(replot_update_interval, this))
36 , m_colorBarLayout(new QCPLayoutGrid)
37 , m_block_update(true)
41 QVBoxLayout* vlayout =
new QVBoxLayout(
this);
42 vlayout->setMargin(0);
43 vlayout->setSpacing(0);
55 double left = xrange.lower;
56 double right = xrange.upper;
57 double top = yrange.upper;
58 double bottom = yrange.lower;
72 m_colorMap->data()->coordToCell(xpos, ypos, &nx, &ny);
89 m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10);
245 m_colorScale->axis()->axisRect()->setMargins(QMargins(0, 0, 0, 0));
246 m_colorScale->axis()->axisRect()->setAutoMargins(QCP::msNone);
272 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
276 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
281 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
285 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
296 Qt::UniqueConnection);
305 Qt::UniqueConnection);
340 m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
387 for (
int ix = 0; ix < nx; ++ix)
388 for (
int iy = 0; iy < ny; ++iy)
389 m_colorMap->data()->setCell(ix, iy, (*data)[iy + ny * ix]);
403 QCPMarginGroup* marginGroup =
new QCPMarginGroup(
m_customPlot);
404 m_customPlot->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
405 m_colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
419 if (visibility_flag) {
432 QMargins axesMargins =
m_customPlot->axisRect()->margins();
436 double left = axesMargins.left();
#define ASSERT(condition)
Defines various axis items.
Defines ColorMapUtils namespace.
Defines M_PI and some more mathematical constants.
Defines class IntensityDataItem.
Defines the class PlotEventInfo.
Defines class UpdateTimer.
static const QString P_IS_LOGSCALE
static const QString P_MAX_DEG
static const QString P_TITLE
static const QString P_IS_VISIBLE
static const QString P_TITLE_IS_VISIBLE
static const QString P_MIN_DEG
The ColorMap class presents 2D intensity data from IntensityDataItem as color map.
UpdateTimer * m_updateTimer
QRectF viewportRectangleInWidgetCoordinates()
returns rectangle representing current axes zoom state in widget coordinates
void setAxesRangeFromItem(IntensityDataItem *item)
Sets (xmin,xmax,nbins) and (ymin,ymax,nbins) of ColorMap from intensity item.
QCPLayoutGrid * m_colorBarLayout
ColorMap(QWidget *parent=nullptr)
void setUpdateTimerConnected(bool isConnected)
PlotEventInfo eventInfo(double xpos, double ypos) const override
Returns PlotEventInfo corresponding to given axes coordinates.
void setConnected(bool isConnected)
void setFixedColorMapMargins()
to make fixed margins for whole colormap (change in axes labels wont affect axes rectangle)
void replot()
Schedule replot for later execution by onTimeReplot() slot.
void unsubscribeFromItem() override
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.
void initColorMap()
creates and initializes the color map
void marginsChanged(double left, double right)
void setAxesRangeConnected(bool isConnected)
Connects/disconnects signals related to ColorMap's X,Y axes rectangle change.
void setAxesLabelsFromItem(IntensityDataItem *item)
Sets X,Y axes labels from item.
void setDataRangeFromItem(IntensityDataItem *item)
void setColorMapFromItem(IntensityDataItem *intensityItem)
Sets initial state of ColorMap to match given intensity item.
void setDataRangeConnected(bool isConnected)
Connects/disconnects signals related to ColorMap's Z-axis (min,max) change.
void onPropertyChanged(const QString &property_name)
updates color map depending on IntensityDataItem properties
void onAxisPropertyChanged(const QString &axisName, const QString &propertyName)
void onTimeToReplot()
Replots ColorMap.
void subscribeToItem() override
QCPColorScale * m_colorScale
void onDataRangeChanged(QCPRange newRange)
Propagate zmin, zmax back to IntensityDataItem.
void setColorScaleAppearanceFromItem(IntensityDataItem *item)
Sets the appearance of color scale (visibility, gradient type) from intensity item.
IntensityDataItem * intensityItem()
void setDataFromItem(IntensityDataItem *item)
Sets the intensity values to ColorMap.
void resetView()
reset all axes min,max to initial value
void setLogz(bool logz)
sets logarithmic scale
void onIntensityModified()
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
QCustomPlot * m_customPlot
void setColorScaleVisible(bool visibility_flag)
void marginsChangedNotify()
Calculates left, right margins around color map to report to projection plot.
void setAxesZoomFromItem(IntensityDataItem *item)
Sets zoom range of X,Y axes as in intensity item.
OutputData< double > * getOutputData()
static const QString P_AXES_UNITS
void setLowerX(double value)
static const QString P_ZAXIS
static const QString P_YAXIS
static const QString P_XAXIS
QString getXaxisTitle() const
void setLowerY(double value)
void setLowerAndUpperZ(double zmin, double zmax)
double getLowerY() const
returns lower and upper zoom ranges of y-axis
static const QString P_GRADIENT
void resetView()
Set axes viewport to original data.
const BasicAxisItem * yAxisItem() const
void setUpperX(double value)
QString getYaxisTitle() const
const BasicAxisItem * xAxisItem() const
void setUpperY(double value)
double getLowerX() const
returns lower and upper zoom ranges of x-axis
static const QString P_IS_INTERPOLATED
void setOnValueChange(std::function< void(void)> f, const void *caller=0)
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=0)
Calls back on child property change, report childItem and property name.
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=0)
Contains parameters of mouse position in 1D or 2D plot.
void setInAxesRange(bool flag)
void setValue(double value)
void setLogValueAxis(bool flag)
Common interface for plot-descriptor interaction.
PLOT_TYPE plotType() const
Returns the type of current plot.
bool axesRangeContains(double xpos, double ypos) const
Returns true if axes rectangle contains given in axes coordinates.
double yAxisCoordToPixel(double axis_coordinate) const
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
double xAxisCoordToPixel(double axis_coordinate) const
transform axes coordinates to CustomPlot widget coordinates
QString itemName() const
Get item name, return display name if no name is set.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString modelType() const
Get model type.
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
QCPRange itemDataZoom(const IntensityDataItem *item)
Returns z-axis visible range (zoom).
QCPRange itemZoomY(const IntensityDataItem *item)
Returns y-axis vizible range (zoom).
QCPRange itemXrange(const IntensityDataItem *item)
Returns x-axis range.
void setDefaultMargins(QCustomPlot *customPlot)
Sets default margins for axes rectangle plot.
QCPColorGradient itemGradient(const IntensityDataItem *item)
QCPRange itemYrange(const IntensityDataItem *item)
Returns y-axis range.
QCPRange itemZoomX(const IntensityDataItem *item)
Returns x-axis vizible range (zoom).
void setLogz(QCPColorScale *scale, bool isLogz)
int plot_tick_label_size()
QString const & name(EShape k)
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Defines various constants for plotting.