28 const int replot_update_interval = 10;
30 int bin(
double x,
const QCPGraph* graph);
36 , m_custom_plot(new QCustomPlot)
37 , m_update_timer(new
UpdateTimer(replot_update_interval, this))
38 , m_block_update(false)
40 auto* vlayout =
new QVBoxLayout(
this);
41 vlayout->setContentsMargins(0, 0, 0, 0);
42 vlayout->setSpacing(0);
44 m_custom_plot->setAttribute(Qt::WA_NoMousePropagation,
false);
130 DataItem* dataItem = pair.first->dataItem();
131 connect(dataItem, &DataItem::datafieldChanged, caller,
132 [=](Datafield*) { caller->refreshPlotData(); });
142 disconnect(pair.first->dataItem(), nullptr, caller, nullptr);
152 std::for_each(property_items.begin(), property_items.end(), [
this](
Data1DProperties* item) {
153 auto* graph = m_custom_plot->addGraph();
154 graph->setLineStyle(item->line());
155 graph->setPen(QPen(item->color()));
156 graph->setScatterStyle(item->scatter());
157 m_graph_map[item] = graph;
171 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
175 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
179 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
183 static_cast<void (QCPAxis::*)(
const QCPRange&)
>(&QCPAxis::rangeChanged),
this,
192 Qt::UniqueConnection);
218 m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
236 ASSERT(item && axis);
238 axis->setLabel(label);
240 axis->setLabel(QString());
246 std::for_each(property_items.begin(), property_items.end(),
255 graph->setData(data_points.first, data_points.second,
true);
308 int bin(
double x,
const QCPGraph* graph)
310 const int key_start = graph->findBegin(x);
311 const int key_end = graph->findBegin(x,
false);
312 if (key_end == key_start || key_end == graph->dataCount())
314 return (x - graph->dataSortKey(key_start)) <= (graph->dataSortKey(key_end) - x) ? key_start
Defines various axis items.
Defines class Data1DViewItem.
Defines class DataProperties and its descendants.
Defines class DataPropertyContainer.
Defines various constants for plotting.
Defines the class PlotEventInfo.
Defines RangeUtils namespace.
Defines class UpdateTimer.
static bool isLogScalePropertyName(const QString &name)
bool isTitleVisible() const
static bool isBoundsPropertiesName(const QString &name)
either lower bound or upper bound property name
static bool isTitlePropertyName(const QString &name)
static bool isTitleVisiblePropertyName(const QString &name)
Holds data required for 1D DataItem representation.
View model for 1D DataItem. Can represent several items at once. In current implementation the first ...
static bool isXAxisPropertyName(const QString &name)
static bool isAxesUnitsPropertyName(const QString &name)
static bool isYAxisPropertyName(const QString &name)
const AmplitudeAxisItem * yAxisItem() const
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)
void setUpperX(double value)
QVector< Data1DProperties * > propertyItems()
void setOnPropertyChange(std::function< void(QString)> 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....
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. Also sets logarithmic scale on y...
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)
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.
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)