16 #include "Base/Axis/Frame.h"
27 const int replot_update_interval = 10;
29 int bin(
double x,
const QCPGraph* graph);
35 , m_custom_plot(new QCustomPlot)
36 , m_update_timer(new
UpdateTimer(replot_update_interval, this))
37 , m_block_update(true)
41 auto* vlayout =
new QVBoxLayout(
this);
42 vlayout->setContentsMargins(0, 0, 0, 0);
43 vlayout->setSpacing(0);
45 m_custom_plot->setAttribute(Qt::WA_NoMousePropagation,
false);
139 QPen pen(QColor(0, 0, 255, 200));
152 m_custom_plot->graph()->setScatterStyle(QCPScatterStyle::ssDisc);
154 m_custom_plot->graph()->setScatterStyle(QCPScatterStyle::ssNone);
169 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
173 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
177 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
181 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
190 Qt::UniqueConnection);
213 m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
231 ASSERT(item && axis);
233 axis->setLabel(label);
235 axis->setLabel(QString());
245 for (
size_t i = 0, size = data->size(); i < size; ++i) {
246 double x = data->frame().projectedCoord(i, 0);
247 double y = data->operator[](i);
303 int bin(
double x,
const QCPGraph* graph)
305 const int key_start = graph->findBegin(x);
306 const int key_end = graph->findBegin(x,
false);
307 if (key_end == key_start || key_end == graph->dataCount())
309 return (x - graph->dataSortKey(key_start)) <= (graph->dataSortKey(key_end) - x) ? key_start
Defines various axis items.
Defines various constants for plotting.
Defines the class PlotEventInfo.
Defines RangeUtils namespace.
Defines class RealDataItem.
Defines class SpecularDataItem.
Defines class SpecularPlot.
Defines class UpdateTimer.
static bool isLogScalePropertyName(const QString &name)
static constexpr auto M_TYPE
bool isTitleVisible() const
static bool isBoundsPropertiesName(const QString &name)
either lower bound or upper bound property name
static bool isTitlePropertyName(const QString &name)
static constexpr auto M_TYPE
static bool isTitleVisiblePropertyName(const QString &name)
static bool isAxesUnitsPropertyName(const QString &name)
Datafield * getDatafield()
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.
The Plot1D class presents data of several 1D DataItems contained in a Data1DViewItem....
Contains parameters of mouse position in 1D or 2D plot.
void setInAxesRange(bool flag)
void setValue(double value)
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
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.
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
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.
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
QString getXaxisTitle() const
void setUpperY(double value)
static bool isXaxisPropertyName(const QString &name)
void setUpperX(double value)
void setLowerX(double value)
void setLowerY(double value)
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.
QString getYaxisTitle() const
static bool isYaxisPropertyName(const QString &name)
void resetView()
Set axes viewport to original data.
const AmplitudeAxisItem * yAxisItem() const
const BasicAxisItem * xAxisItem() const
The SpecularPlot class presents 1D intensity data from SpecularDataItem.
void initPlot()
creates and initializes the color map
void setAxesRangeConnected(bool isConnected)
Connects/disconnects signals related to SpecularPlot's X,Y axes rectangle change.
void setConnected(bool isConnected)
void setAxesLabelsFromItem(SpecularDataItem *item)
Sets X,Y axes labels from item.
SpecularPlot(QWidget *parent=nullptr)
void setLog(bool log)
sets logarithmic scale
PlotEventInfo eventInfo(double xpos, double ypos) const override
Returns PlotEventInfo corresponding to given axes coordinates.
UpdateTimer * m_update_timer
void setUpdateTimerConnected(bool isConnected)
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
void setPlotFromItem(SpecularDataItem *specularItem)
Sets initial state of SpecularPlot to match given intensity item.
void initScatter()
Adds scatter ro real data plot.
void setAxesRangeFromItem(SpecularDataItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item. Also sets logarithmic scale on y...
void modifyAxesProperties(const QString &axisName, const QString &propertyName)
void onTimeToReplot()
Replots SpecularPlot.
void setLabel(const BasicAxisItem *item, QCPAxis *axis, QString label)
Sets label to axis.
void onPropertyChanged(const QString &property_name)
updates plot depending on IntensityDataItem properties
QCustomPlot * m_custom_plot
void setDataFromItem(SpecularDataItem *item)
Sets the intensity values to SpecularPlot.
void subscribeToItem() override
SpecularDataItem * specularItem()
void replot()
Schedule replot for later execution by onTimeReplot() slot.
void unsubscribeFromItem() override
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.
void resetView()
reset all axes min,max to initial value
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)
void setLogz(QCPColorScale *scale, bool isLogz)