28 const int replot_update_interval = 10;
30 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(false)
39 QVBoxLayout* vlayout =
new QVBoxLayout(
this);
40 vlayout->setContentsMargins(0, 0, 0, 0);
41 vlayout->setSpacing(0);
128 auto property_item = pair.first;
129 property_item->dataItem()->mapper()->setOnValueChange(
130 [caller]() { caller->refreshPlotData(); }, caller);
140 pair.first->dataItem()->mapper()->unsubscribe(caller);
149 std::for_each(property_items.begin(), property_items.end(), [
this](
Data1DProperties* item) {
150 auto graph = m_custom_plot->addGraph();
151 graph->setLineStyle(QCPGraph::lsLine);
152 graph->setPen(QPen(item->color()));
153 m_graph_map[item] = graph;
167 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
171 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
176 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
180 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
189 Qt::UniqueConnection);
215 m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
235 axis->setLabel(std::move(label));
237 axis->setLabel(QString());
243 std::for_each(property_items.begin(), property_items.end(),
252 graph->setData(data_points.first, data_points.second,
true);
304 int bin(
double x,
const QCPGraph* graph)
306 const int key_start = graph->findBegin(x);
307 const int key_end = graph->findBegin(x,
false);
308 if (key_end == key_start || key_end == graph->dataCount())
310 return (x - graph->dataSortKey(key_start)) <= (graph->dataSortKey(key_end) - x) ? key_start
#define ASSERT(condition)
Defines various axis items.
Defines ColorMapUtils namespace.
Defines M_PI and some more mathematical constants.
Defines class Data1DViewItem.
Defines class DataProperties and its descendants.
Defines class DataPropertyContainer.
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_TITLE_IS_VISIBLE
static const QString P_MIN_DEG
Holds data required for 1D DataItem representation.
View model for 1D DataItem.
static const QString P_YAXIS
const AmplitudeAxisItem * yAxisItem() const
static const QString P_AXES_UNITS
DataPropertyContainer * propertyContainerItem()
void resetView()
Set axes viewport to original data.
double getLowerY() const
returns lower and upper zoom ranges of y-axis
const BasicAxisItem * xAxisItem() const
QString getYaxisTitle() const
void setUpperY(double value)
QString getXaxisTitle() const
double getLowerX() const
returns lower and upper zoom ranges of x-axis
QPair< QVector< double >, QVector< double > > graphData(Data1DProperties *property_item)
Returns point data for drawing.
void setLowerX(double value)
void setLowerY(double value)
static const QString P_XAXIS
void setUpperX(double value)
QVector< Data1DProperties * > propertyItems()
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)
The Plot1D class presents data of several 1D DataItems contained in a Data1DViewItem.
void onTimeToReplot()
Replots SpecularPlot.
void updateAllGraphs()
Sets data to graphs.
void initPlots()
creates and initializes the color map
void setAxesRangeConnected(bool isConnected)
Connects/disconnects signals related to SpecularPlot's X,Y axes rectangle change.
void resetView()
reset all axes min,max to initial value
Plot1D(QWidget *parent=nullptr)
void setAxesLabelsFromItem(Data1DViewItem *item)
Sets X,Y axes labels from item.
void setAxesRangeFromItem(Data1DViewItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item.
void setConnected(bool isConnected)
void refreshPlotData()
Refresh axes' labels, range and graph data.
void setUpdateTimerConnected(bool isConnected)
void replot()
Schedule replot for later execution by onTimeReplot() slot.
QCustomPlot * m_custom_plot
UpdateTimer * m_update_timer
PlotEventInfo eventInfo(double xpos, double ypos) const override
Returns PlotEventInfo corresponding to given axes coordinates.
void updateGraph(Data1DProperties *item)
Sets data to the graph corresponding to the passed Data1DProperties.
void onPropertyChanged(const QString &property_name)
updates plot depending on IntensityDataItem properties
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.
void setLog(bool log)
sets logarithmic scale
Data1DViewItem * viewItem()
void unsubscribeFromItem() override
std::map< Data1DProperties *, QCPGraph * > m_graph_map
void setLabel(const BasicAxisItem *item, QCPAxis *axis, QString label)
Sets label to axis.
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
void modifyAxesProperties(const QString &axisName, const QString &propertyName)
void subscribeToItem() override
Contains parameters of mouse position in 1D or 2D plot.
void setInAxesRange(bool flag)
void setValue(double value)
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)
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.
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
void setLogz(QCPColorScale *scale, bool isLogz)
int plot_tick_label_size()
QString const & name(EShape k)
Defines various constants for plotting.