25 const int replot_update_interval = 10;
26 const int colorbar_width_logz = 50;
27 const int colorbar_width = 80;
33 , m_customPlot(new QCustomPlot)
35 , m_colorScale(nullptr)
36 , m_updateTimer(new
UpdateTimer(replot_update_interval, this))
37 , m_colorBarLayout(new QCPLayoutGrid)
38 , m_block_update(true)
42 auto* vlayout =
new QVBoxLayout(
this);
43 vlayout->setMargin(0);
44 vlayout->setSpacing(0);
46 m_customPlot->setAttribute(Qt::WA_NoMousePropagation,
false);
57 double left = xrange.lower;
58 double right = xrange.upper;
59 double top = yrange.upper;
60 double bottom = yrange.lower;
74 m_colorMap->data()->coordToCell(xpos, ypos, &nx, &ny);
91 m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10);
244 m_colorScale->axis()->axisRect()->setMargins(QMargins(0, 0, 0, 0));
245 m_colorScale->axis()->axisRect()->setAutoMargins(QCP::msNone);
271 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
275 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
279 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
283 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
294 Qt::UniqueConnection);
303 Qt::UniqueConnection);
338 m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
360 if (xaxis->isTitleVisible())
368 if (yaxis->isTitleVisible())
384 int nx(item->
xSize());
385 int ny(item->
ySize());
386 for (
int ix = 0; ix < nx; ++ix)
387 for (
int iy = 0; iy < ny; ++iy)
388 m_colorMap->data()->setCell(ix, iy, (*data)[iy + ny * ix]);
401 m_customPlot->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
402 m_colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
416 if (visibility_flag) {
430 QMargins axesMargins =
m_customPlot->axisRect()->margins();
434 double left = axesMargins.left();
Defines various axis items.
Defines class IntensityDataItem.
Defines various constants for plotting.
Defines the class PlotEventInfo.
Defines RangeUtils namespace.
Defines class UpdateTimer.
static bool isLogScalePropertyName(const QString &name)
static constexpr auto M_TYPE
static bool isVisibilityPropertyName(const QString &name)
static bool isBoundsPropertiesName(const QString &name)
either lower bound or upper bound property name
bool visibilityValue() const
static bool isTitlePropertyName(const QString &name)
static constexpr auto M_TYPE
static bool isTitleVisiblePropertyName(const QString &name)
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.
static bool isAxesUnitsPropertyName(const QString &name)
Datafield * getDatafield()
void setLowerX(double value)
const AmplitudeAxisItem * zAxisItem() const
QString getXaxisTitle() const
void setLowerY(double value)
void setLowerAndUpperZ(double zmin, double zmax)
static bool isXaxisPropertyName(const QString &name)
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
static bool isZaxisPropertyName(const QString &name)
void resetView()
Set axes viewport to original data.
const BasicAxisItem * yAxisItem() const
void setUpperX(double value)
QString getYaxisTitle() const
static bool isInterpolatedPropertyName(const QString &name)
const BasicAxisItem * xAxisItem() const
static bool isYaxisPropertyName(const QString &name)
void setUpperY(double value)
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.
static bool isGradientPropertyName(const QString &name)
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
void setOnValueChange(std::function< void(void)> f, const void *caller=nullptr)
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=nullptr)
Calls back on child property change, report childItem and property name.
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
Base class for a GUI data item.
QString itemName() const
Get item name, return display name if no name is set.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString modelType() const
Get model type.
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
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.
QCPRange itemYrange(const IntensityDataItem *item)
Returns y-axis range.
QCPColorGradient itemGradient(const IntensityDataItem *item)
QCPRange itemZoomY(const IntensityDataItem *item)
Returns y-axis vizible range (zoom).
void setLogz(QCPColorScale *scale, bool isLogz)
void setDefaultMargins(QCustomPlot *customPlot)
Sets default margins for axes rectangle plot.
QCPRange itemXrange(const IntensityDataItem *item)
Returns x-axis range.
QCPRange itemDataZoom(const IntensityDataItem *item)
Returns z-axis visible range (zoom).
QCPRange itemZoomX(const IntensityDataItem *item)
Returns x-axis vizible range (zoom).