BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
Plot1D Class Reference

Description

The Plot1D class presents data of several 1D DataItems contained in a Data1DViewItem. Provides minimal functionality for data plotting and axes interaction. Should be a component for more complicated plotting widgets.

Definition at line 32 of file Plot1D.h.

Inheritance diagram for Plot1D:
[legend]
Collaboration diagram for Plot1D:
[legend]

Public Types

enum class  PLOT_TYPE { Plot1D , Plot2D }
 

Signals

void statusString (const QString &text)
 

Public Member Functions

 Plot1D (QWidget *parent=nullptr)
 
virtual QList< QAction * > actionList ()
 
bool axesRangeContains (double xpos, double ypos) const
 Returns true if axes rectangle contains given in axes coordinates. More...
 
SessionItemcurrentItem ()
 
const SessionItemcurrentItem () const
 
const QCustomPlot * customPlot () const override
 
QCustomPlot * customPlot () override
 
PlotEventInfo eventInfo (double xpos, double ypos) const override
 Returns PlotEventInfo corresponding to given axes coordinates. More...
 
QSize minimumSizeHint () const override
 
double pixelToXaxisCoord (double pixel) const
 transform widget coordinates to axes coordinates More...
 
double pixelToYaxisCoord (double pixel) const
 
ScientificPlotEventplotEvent ()
 
PLOT_TYPE plotType () const
 Returns the type of current plot. More...
 
void resetView ()
 reset all axes min,max to initial value More...
 
virtual void setItem (SessionItem *item)
 
void setLog (bool log)
 sets logarithmic scale More...
 
void setMouseTrackingEnabled (bool enable)
 Tracks move events (used when showing profile histograms and printing status string) More...
 
QSize sizeHint () const override
 
double xAxisCoordToPixel (double axis_coordinate) const
 transform axes coordinates to CustomPlot widget coordinates More...
 
double yAxisCoordToPixel (double axis_coordinate) const
 

Protected Member Functions

void hideEvent (QHideEvent *) override
 
void showEvent (QShowEvent *) override
 
void subscribeToItem () override
 
void unsubscribeFromItem () override
 

Private Slots

void onPropertyChanged (const QString &property_name)
 updates plot depending on IntensityDataItem properties More...
 
void onTimeToReplot ()
 Replots SpecularPlot. More...
 
void onXaxisRangeChanged (QCPRange newRange)
 Propagate xmin, xmax back to IntensityDataItem. More...
 
void onYaxisRangeChanged (QCPRange newRange)
 Propagate ymin, ymax back to IntensityDataItem. More...
 

Private Member Functions

void initPlots ()
 creates and initializes the color map More...
 
void modifyAxesProperties (const QString &axisName, const QString &propertyName)
 
void refreshPlotData ()
 Refresh axes' labels, range and graph data. More...
 
void replot ()
 Schedule replot for later execution by onTimeReplot() slot. More...
 
void setAxesLabelsFromItem (Data1DViewItem *item)
 Sets X,Y axes labels from item. More...
 
void setAxesRangeConnected (bool isConnected)
 Connects/disconnects signals related to SpecularPlot's X,Y axes rectangle change. More...
 
void setAxesRangeFromItem (Data1DViewItem *item)
 Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item. Also sets logarithmic scale on y-axis if necessary. More...
 
void setConnected (bool isConnected)
 
void setLabel (const BasicAxisItem *item, QCPAxis *axis, QString label)
 Sets label to axis. More...
 
void setUpdateTimerConnected (bool isConnected)
 
void updateAllGraphs ()
 Sets data to graphs. More...
 
void updateGraph (Data1DProperties *item)
 Sets data to the graph corresponding to the passed Data1DProperties. More...
 
Data1DViewItemviewItem ()
 
const Data1DViewItemviewItem () const
 

Private Attributes

bool m_block_update
 
QCustomPlot * m_custom_plot
 
ScientificPlotEventm_event
 
std::map< Data1DProperties *, QCPGraph * > m_graph_map
 
SessionItemControllerm_itemController
 
PLOT_TYPE m_plot_type
 
UpdateTimerm_update_timer
 

Member Enumeration Documentation

◆ PLOT_TYPE

enum ScientificPlot::PLOT_TYPE
stronginherited
Enumerator
Plot1D 
Plot2D 

Definition at line 31 of file ScientificPlot.h.

31 { Plot1D, Plot2D };
The Plot1D class presents data of several 1D DataItems contained in a Data1DViewItem....
Definition: Plot1D.h:32

Constructor & Destructor Documentation

◆ Plot1D()

Plot1D::Plot1D ( QWidget *  parent = nullptr)
explicit

Definition at line 34 of file Plot1D.cpp.

36  , m_custom_plot(new QCustomPlot)
37  , m_update_timer(new UpdateTimer(replot_update_interval, this))
38  , m_block_update(false)
39 {
40  auto* vlayout = new QVBoxLayout(this);
41  vlayout->setContentsMargins(0, 0, 0, 0);
42  vlayout->setSpacing(0);
43  vlayout->addWidget(m_custom_plot);
44  m_custom_plot->setAttribute(Qt::WA_NoMousePropagation, false);
45  setLayout(vlayout);
46 
47  m_custom_plot->xAxis->setTickLabelFont(
48  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
49  m_custom_plot->yAxis->setTickLabelFont(
50  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
51 
53 }
QCustomPlot * m_custom_plot
Definition: Plot1D.h:108
UpdateTimer * m_update_timer
Definition: Plot1D.h:109
bool m_block_update
Definition: Plot1D.h:112
ScientificPlot(QWidget *parent, PLOT_TYPE plot_type)
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
Definition: UpdateTimer.h:27
int plot_tick_label_size()
Definition: PlotConstants.h:23

References m_custom_plot, GUI::Constants::plot_tick_label_size(), and ScientificPlot::setMouseTrackingEnabled().

Here is the call graph for this function:

Member Function Documentation

◆ actionList()

QList< QAction * > SessionItemWidget::actionList ( )
virtualinherited

◆ axesRangeContains()

bool ScientificPlot::axesRangeContains ( double  xpos,
double  ypos 
) const
inherited

Returns true if axes rectangle contains given in axes coordinates.

Definition at line 52 of file ScientificPlot.cpp.

53 {
54  return customPlot()->xAxis->range().contains(xpos)
55  && customPlot()->yAxis->range().contains(ypos);
56 }
virtual QCustomPlot * customPlot()=0

References ScientificPlot::customPlot().

Referenced by eventInfo(), SpecularPlot::eventInfo(), and ColorMap::eventInfo().

Here is the call graph for this function:

◆ currentItem() [1/2]

◆ currentItem() [2/2]

const SessionItem * SessionItemWidget::currentItem ( ) const
inherited

Definition at line 46 of file SessionItemWidget.cpp.

47 {
48  return m_itemController->currentItem();
49 }
SessionItemController * m_itemController

References SessionItemController::currentItem(), and SessionItemWidget::m_itemController.

Here is the call graph for this function:

◆ customPlot() [1/2]

const QCustomPlot* Plot1D::customPlot ( ) const
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 45 of file Plot1D.h.

45 { return m_custom_plot; }

References m_custom_plot.

◆ customPlot() [2/2]

QCustomPlot* Plot1D::customPlot ( )
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 44 of file Plot1D.h.

44 { return m_custom_plot; }

References m_custom_plot.

Referenced by Plot1DCanvas::customPlot().

◆ eventInfo()

PlotEventInfo Plot1D::eventInfo ( double  xpos,
double  ypos 
) const
overridevirtual

Returns PlotEventInfo corresponding to given axes coordinates.

Implements ScientificPlot.

Definition at line 55 of file Plot1D.cpp.

56 {
57  PlotEventInfo result(plotType());
58  if (!viewItem())
59  return result;
60 
61  result.setX(xpos);
62  result.setValue(ypos);
63 
64  result.setInAxesRange(axesRangeContains(xpos, ypos));
65  result.setNx(bin(result.x(), m_custom_plot->graph()));
66 
67  return result;
68 }
Data1DViewItem * viewItem()
Definition: Plot1D.cpp:258
Contains parameters of mouse position in 1D or 2D plot.
Definition: PlotEventInfo.h:26
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.

References ScientificPlot::axesRangeContains(), m_custom_plot, ScientificPlot::plotType(), PlotEventInfo::setInAxesRange(), PlotEventInfo::setNx(), PlotEventInfo::setValue(), PlotEventInfo::setX(), viewItem(), and PlotEventInfo::x().

Here is the call graph for this function:

◆ hideEvent()

void SessionItemWidget::hideEvent ( QHideEvent *  )
overrideprotectedinherited

Definition at line 56 of file SessionItemWidget.cpp.

57 {
59 }
void unsubscribe()
Fully unsubscribes the parent from listening item's signals. Controller stays active to track item de...

References SessionItemWidget::m_itemController, and SessionItemController::unsubscribe().

Here is the call graph for this function:

◆ initPlots()

void Plot1D::initPlots ( )
private

creates and initializes the color map

Definition at line 148 of file Plot1D.cpp.

149 {
150  auto property_items = viewItem()->propertyContainerItem()->propertyItems();
151 
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;
158  });
159 }
Holds data required for 1D DataItem representation.
DataPropertyContainer * propertyContainerItem()
QVector< Data1DProperties * > propertyItems()

References Data1DViewItem::propertyContainerItem(), DataPropertyContainer::propertyItems(), and viewItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ minimumSizeHint()

QSize Plot1D::minimumSizeHint ( ) const
inlineoverride

Definition at line 39 of file Plot1D.h.

39 { return QSize(128, 128); }

◆ modifyAxesProperties()

void Plot1D::modifyAxesProperties ( const QString &  axisName,
const QString &  propertyName 
)
private

Definition at line 270 of file Plot1D.cpp.

271 {
272  if (m_block_update)
273  return;
274 
275  if (BasicAxisItem::isTitlePropertyName(propertyName)
278  replot();
279  }
280 
281  if (Data1DViewItem::isXAxisPropertyName(axisName)) {
282  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
283  setAxesRangeConnected(false);
284  m_custom_plot->xAxis->setRange(viewItem()->getLowerX(), viewItem()->getUpperX());
285  setAxesRangeConnected(true);
286  replot();
287  }
288  } else if (Data1DViewItem::isYAxisPropertyName(axisName)) {
289  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
290  setAxesRangeConnected(false);
291  m_custom_plot->yAxis->setRange(viewItem()->getLowerY(), viewItem()->getUpperY());
292  setAxesRangeConnected(true);
293  replot();
294  } else if (AmplitudeAxisItem::isLogScalePropertyName(propertyName)) {
295  setLog(viewItem()->isLog());
296  replot();
297  }
298  }
299 }
static bool isLogScalePropertyName(const QString &name)
Definition: AxesItems.cpp:193
static bool isBoundsPropertiesName(const QString &name)
either lower bound or upper bound property name
Definition: AxesItems.cpp:75
static bool isTitlePropertyName(const QString &name)
Definition: AxesItems.cpp:95
static bool isTitleVisiblePropertyName(const QString &name)
Definition: AxesItems.cpp:105
static bool isXAxisPropertyName(const QString &name)
static bool isYAxisPropertyName(const QString &name)
void setAxesRangeConnected(bool isConnected)
Connects/disconnects signals related to SpecularPlot's X,Y axes rectangle change.
Definition: Plot1D.cpp:167
void setAxesLabelsFromItem(Data1DViewItem *item)
Sets X,Y axes labels from item.
Definition: Plot1D.cpp:228
void replot()
Schedule replot for later execution by onTimeReplot() slot.
Definition: Plot1D.cpp:301
void setLog(bool log)
sets logarithmic scale
Definition: Plot1D.cpp:70

References BasicAxisItem::isBoundsPropertiesName(), AmplitudeAxisItem::isLogScalePropertyName(), BasicAxisItem::isTitlePropertyName(), BasicAxisItem::isTitleVisiblePropertyName(), Data1DViewItem::isXAxisPropertyName(), Data1DViewItem::isYAxisPropertyName(), m_block_update, m_custom_plot, replot(), setAxesLabelsFromItem(), setAxesRangeConnected(), setLog(), and viewItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onPropertyChanged

void Plot1D::onPropertyChanged ( const QString &  property_name)
privateslot

updates plot depending on IntensityDataItem properties

Definition at line 81 of file Plot1D.cpp.

82 {
83  if (m_block_update)
84  return;
85 
86  if (Data1DViewItem::isAxesUnitsPropertyName(property_name)) {
89  replot();
90  }
91 }
static bool isAxesUnitsPropertyName(const QString &name)
void updateAllGraphs()
Sets data to graphs.
Definition: Plot1D.cpp:243
void setAxesRangeFromItem(Data1DViewItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item. Also sets logarithmic scale on y...
Definition: Plot1D.cpp:216

References Data1DViewItem::isAxesUnitsPropertyName(), m_block_update, replot(), setAxesRangeFromItem(), updateAllGraphs(), and viewItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onTimeToReplot

void Plot1D::onTimeToReplot ( )
privateslot

Replots SpecularPlot.

Definition at line 109 of file Plot1D.cpp.

110 {
111  m_custom_plot->replot();
112 }

References m_custom_plot.

Referenced by setUpdateTimerConnected().

◆ onXaxisRangeChanged

void Plot1D::onXaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate xmin, xmax back to IntensityDataItem.

Definition at line 93 of file Plot1D.cpp.

94 {
95  m_block_update = true;
96  viewItem()->setLowerX(newRange.lower);
97  viewItem()->setUpperX(newRange.upper);
98  m_block_update = false;
99 }
void setLowerX(double value)
void setUpperX(double value)

References m_block_update, Data1DViewItem::setLowerX(), Data1DViewItem::setUpperX(), and viewItem().

Referenced by setAxesRangeConnected().

Here is the call graph for this function:

◆ onYaxisRangeChanged

void Plot1D::onYaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate ymin, ymax back to IntensityDataItem.

Definition at line 101 of file Plot1D.cpp.

102 {
103  m_block_update = true;
104  viewItem()->setLowerY(newRange.lower);
105  viewItem()->setUpperY(newRange.upper);
106  m_block_update = false;
107 }
void setUpperY(double value)
void setLowerY(double value)

References m_block_update, Data1DViewItem::setLowerY(), Data1DViewItem::setUpperY(), and viewItem().

Referenced by setAxesRangeConnected().

Here is the call graph for this function:

◆ pixelToXaxisCoord()

double ScientificPlot::pixelToXaxisCoord ( double  pixel) const
inherited

transform widget coordinates to axes coordinates

Definition at line 37 of file ScientificPlot.cpp.

38 {
39  return customPlot()->xAxis->pixelToCoord(pixel);
40 }

References ScientificPlot::customPlot().

Referenced by ScientificPlotEvent::currentPlotDescriptor(), and ColorMapSceneAdaptor::fromSceneX().

Here is the call graph for this function:

◆ pixelToYaxisCoord()

double ScientificPlot::pixelToYaxisCoord ( double  pixel) const
inherited

Definition at line 42 of file ScientificPlot.cpp.

43 {
44  return customPlot()->yAxis->pixelToCoord(pixel);
45 }

References ScientificPlot::customPlot().

Referenced by ScientificPlotEvent::currentPlotDescriptor(), and ColorMapSceneAdaptor::fromSceneY().

Here is the call graph for this function:

◆ plotEvent()

ScientificPlotEvent* ScientificPlot::plotEvent ( )
inlineinherited

Definition at line 42 of file ScientificPlot.h.

42 { return m_event; }
ScientificPlotEvent * m_event

References ScientificPlot::m_event.

Referenced by ProjectionsEditorCanvas::setConnected().

◆ plotType()

PLOT_TYPE ScientificPlot::plotType ( ) const
inlineinherited

Returns the type of current plot.

Definition at line 59 of file ScientificPlot.h.

59 { return m_plot_type; }
PLOT_TYPE m_plot_type

References ScientificPlot::m_plot_type.

Referenced by eventInfo(), SpecularPlot::eventInfo(), ColorMap::eventInfo(), and FontScalingEvent::setTickLabelFont().

◆ refreshPlotData()

void Plot1D::refreshPlotData ( )
private

Refresh axes' labels, range and graph data.

Definition at line 197 of file Plot1D.cpp.

198 {
199  if (m_block_update)
200  return;
201 
202  m_block_update = true;
203 
204  auto* view_item = viewItem();
205  ASSERT(view_item);
206 
207  setAxesRangeFromItem(view_item);
208  setAxesLabelsFromItem(view_item);
209  updateAllGraphs();
210 
211  replot();
212 
213  m_block_update = false;
214 }

References m_block_update, replot(), setAxesLabelsFromItem(), setAxesRangeFromItem(), updateAllGraphs(), and viewItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ replot()

void Plot1D::replot ( )
private

Schedule replot for later execution by onTimeReplot() slot.

Definition at line 301 of file Plot1D.cpp.

302 {
304 }
void scheduleUpdate()
Definition: UpdateTimer.cpp:42

References m_update_timer, and UpdateTimer::scheduleUpdate().

Referenced by modifyAxesProperties(), onPropertyChanged(), and refreshPlotData().

Here is the call graph for this function:

◆ resetView()

void Plot1D::resetView ( )

reset all axes min,max to initial value

Definition at line 76 of file Plot1D.cpp.

77 {
78  viewItem()->resetView();
79 }
void resetView()
Set axes viewport to original data.

References Data1DViewItem::resetView(), and viewItem().

Here is the call graph for this function:

◆ setAxesLabelsFromItem()

void Plot1D::setAxesLabelsFromItem ( Data1DViewItem item)
private

Sets X,Y axes labels from item.

Definition at line 228 of file Plot1D.cpp.

229 {
230  setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle());
231  setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle());
232 }
const AmplitudeAxisItem * yAxisItem() const
const BasicAxisItem * xAxisItem() const
QString getYaxisTitle() const
QString getXaxisTitle() const
void setLabel(const BasicAxisItem *item, QCPAxis *axis, QString label)
Sets label to axis.
Definition: Plot1D.cpp:234

References Data1DViewItem::getXaxisTitle(), Data1DViewItem::getYaxisTitle(), m_custom_plot, setLabel(), Data1DViewItem::xAxisItem(), and Data1DViewItem::yAxisItem().

Referenced by modifyAxesProperties(), and refreshPlotData().

Here is the call graph for this function:

◆ setAxesRangeConnected()

void Plot1D::setAxesRangeConnected ( bool  isConnected)
private

Connects/disconnects signals related to SpecularPlot's X,Y axes rectangle change.

Definition at line 167 of file Plot1D.cpp.

168 {
169  if (isConnected) {
170  connect(m_custom_plot->xAxis,
171  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
172  &Plot1D::onXaxisRangeChanged, Qt::UniqueConnection);
173 
174  connect(m_custom_plot->yAxis,
175  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
176  &Plot1D::onYaxisRangeChanged, Qt::UniqueConnection);
177  } else {
178  disconnect(m_custom_plot->xAxis,
179  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
181 
182  disconnect(m_custom_plot->yAxis,
183  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
185  }
186 }
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.
Definition: Plot1D.cpp:101
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
Definition: Plot1D.cpp:93

References m_custom_plot, onXaxisRangeChanged(), and onYaxisRangeChanged().

Referenced by modifyAxesProperties(), setAxesRangeFromItem(), and setConnected().

Here is the call graph for this function:

◆ setAxesRangeFromItem()

void Plot1D::setAxesRangeFromItem ( Data1DViewItem item)
private

Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item. Also sets logarithmic scale on y-axis if necessary.

Definition at line 216 of file Plot1D.cpp.

217 {
218  m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
219  m_custom_plot->axisRect()->setupFullAxesBox(true);
220 
221  setAxesRangeConnected(false);
222  m_custom_plot->xAxis->setRange(item->getLowerX(), item->getUpperX());
223  m_custom_plot->yAxis->setRange(item->getLowerY(), item->getUpperY());
224  setLog(item->isLog());
225  setAxesRangeConnected(true);
226 }
double getUpperY() const
bool isLog() const
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.
double getUpperX() const

References Data1DViewItem::getLowerX(), Data1DViewItem::getLowerY(), Data1DViewItem::getUpperX(), Data1DViewItem::getUpperY(), Data1DViewItem::isLog(), m_custom_plot, setAxesRangeConnected(), and setLog().

Referenced by onPropertyChanged(), and refreshPlotData().

Here is the call graph for this function:

◆ setConnected()

void Plot1D::setConnected ( bool  isConnected)
private

Definition at line 161 of file Plot1D.cpp.

162 {
163  setAxesRangeConnected(isConnected);
164  setUpdateTimerConnected(isConnected);
165 }
void setUpdateTimerConnected(bool isConnected)
Definition: Plot1D.cpp:188

References setAxesRangeConnected(), and setUpdateTimerConnected().

Referenced by unsubscribeFromItem().

Here is the call graph for this function:

◆ setItem()

◆ setLabel()

void Plot1D::setLabel ( const BasicAxisItem item,
QCPAxis *  axis,
QString  label 
)
private

Sets label to axis.

Definition at line 234 of file Plot1D.cpp.

235 {
236  ASSERT(item && axis);
237  if (item->isTitleVisible())
238  axis->setLabel(label);
239  else
240  axis->setLabel(QString());
241 }
bool isTitleVisible() const
Definition: AxesItems.cpp:100

References BasicAxisItem::isTitleVisible().

Referenced by setAxesLabelsFromItem().

Here is the call graph for this function:

◆ setLog()

void Plot1D::setLog ( bool  log)

sets logarithmic scale

Definition at line 70 of file Plot1D.cpp.

71 {
74 }
void setLogz(QCPColorScale *scale, bool isLogz)
Definition: RangeUtils.cpp:110

References m_custom_plot, and GUI::View::RangeUtils::setLogz().

Referenced by modifyAxesProperties(), and setAxesRangeFromItem().

Here is the call graph for this function:

◆ setMouseTrackingEnabled()

void ScientificPlot::setMouseTrackingEnabled ( bool  enable)
inherited

Tracks move events (used when showing profile histograms and printing status string)

Definition at line 47 of file ScientificPlot.cpp.

48 {
50 }
void setMouseTrackingEnabled(bool enable)
Sets tracking of the mouse for parent DescriptedPlot.

References ScientificPlot::m_event, and ScientificPlotEvent::setMouseTrackingEnabled().

Referenced by ColorMap::ColorMap(), Plot1D(), SpecularPlot::SpecularPlot(), and PlotStatusLabel::setPlotLabelEnabled().

Here is the call graph for this function:

◆ setUpdateTimerConnected()

void Plot1D::setUpdateTimerConnected ( bool  isConnected)
private

Definition at line 188 of file Plot1D.cpp.

189 {
190  if (isConnected)
192  Qt::UniqueConnection);
193  else
195 }
void onTimeToReplot()
Replots SpecularPlot.
Definition: Plot1D.cpp:109
void timeToUpdate()

References m_update_timer, onTimeToReplot(), and UpdateTimer::timeToUpdate().

Referenced by setConnected().

Here is the call graph for this function:

◆ showEvent()

void SessionItemWidget::showEvent ( QShowEvent *  )
overrideprotectedinherited

Definition at line 51 of file SessionItemWidget.cpp.

52 {
54 }

References SessionItemWidget::m_itemController, and SessionItemController::subscribe().

Here is the call graph for this function:

◆ sizeHint()

QSize Plot1D::sizeHint ( ) const
inlineoverride

Definition at line 38 of file Plot1D.h.

38 { return QSize(500, 400); }

◆ statusString

void ScientificPlot::statusString ( const QString &  text)
signalinherited

◆ subscribeToItem()

void Plot1D::subscribeToItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 114 of file Plot1D.cpp.

115 {
116  initPlots();
117  refreshPlotData();
118 
120  [this](const QString& name) { onPropertyChanged(name); }, this);
121 
123  [this](SessionItem* item, const QString name) {
124  if (dynamic_cast<BasicAxisItem*>(item))
126  },
127  this);
128 
129  std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
130  DataItem* dataItem = pair.first->dataItem();
131  connect(dataItem, &DataItem::datafieldChanged, caller,
132  [=](Datafield*) { caller->refreshPlotData(); });
133  });
134 
135  setConnected(true);
136 }
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
Definition: ModelMapper.cpp:39
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=nullptr)
Calls back on child property change, report childItem and property name.
Definition: ModelMapper.cpp:53
void initPlots()
creates and initializes the color map
Definition: Plot1D.cpp:148
void setConnected(bool isConnected)
Definition: Plot1D.cpp:161
void refreshPlotData()
Refresh axes' labels, range and graph data.
Definition: Plot1D.cpp:197
void onPropertyChanged(const QString &property_name)
updates plot depending on IntensityDataItem properties
Definition: Plot1D.cpp:81
std::map< Data1DProperties *, QCPGraph * > m_graph_map
Definition: Plot1D.h:110
void modifyAxesProperties(const QString &axisName, const QString &propertyName)
Definition: Plot1D.cpp:270
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 const & name(EShape k)
Definition: particles.cpp:20

References initPlots(), SessionItem::itemName(), m_graph_map, SessionItem::mapper(), modifyAxesProperties(), GUI::RealSpace::Particles::name(), onPropertyChanged(), refreshPlotData(), ModelMapper::setOnChildPropertyChange(), ModelMapper::setOnPropertyChange(), and viewItem().

Here is the call graph for this function:

◆ unsubscribeFromItem()

void Plot1D::unsubscribeFromItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 138 of file Plot1D.cpp.

139 {
140  m_custom_plot->clearGraphs();
141  std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
142  disconnect(pair.first->dataItem(), nullptr, caller, nullptr);
143  });
144  m_graph_map.clear();
145  setConnected(false);
146 }

References m_custom_plot, m_graph_map, and setConnected().

Here is the call graph for this function:

◆ updateAllGraphs()

void Plot1D::updateAllGraphs ( )
private

Sets data to graphs.

Definition at line 243 of file Plot1D.cpp.

244 {
245  auto property_items = viewItem()->propertyContainerItem()->propertyItems();
246  std::for_each(property_items.begin(), property_items.end(),
247  [this](Data1DProperties* item) { updateGraph(item); });
248 }

References Data1DViewItem::propertyContainerItem(), DataPropertyContainer::propertyItems(), and viewItem().

Referenced by onPropertyChanged(), and refreshPlotData().

Here is the call graph for this function:

◆ updateGraph()

void Plot1D::updateGraph ( Data1DProperties item)
private

Sets data to the graph corresponding to the passed Data1DProperties.

Definition at line 250 of file Plot1D.cpp.

251 {
252  auto data_points = viewItem()->graphData(item);
253 
254  auto* graph = m_graph_map.at(item);
255  graph->setData(data_points.first, data_points.second, /*alreadySorted =*/true);
256 }
QPair< QVector< double >, QVector< double > > graphData(Data1DProperties *property_item)
Returns point data for drawing.

References Data1DViewItem::graphData(), m_graph_map, and viewItem().

Here is the call graph for this function:

◆ viewItem() [1/2]

Data1DViewItem * Plot1D::viewItem ( )
private

Definition at line 258 of file Plot1D.cpp.

259 {
260  return const_cast<Data1DViewItem*>(static_cast<const Plot1D*>(this)->viewItem());
261 }
View model for 1D DataItem. Can represent several items at once. In current implementation the first ...

Referenced by eventInfo(), initPlots(), modifyAxesProperties(), onPropertyChanged(), onXaxisRangeChanged(), onYaxisRangeChanged(), refreshPlotData(), resetView(), subscribeToItem(), updateAllGraphs(), and updateGraph().

◆ viewItem() [2/2]

const Data1DViewItem * Plot1D::viewItem ( ) const
private

Definition at line 263 of file Plot1D.cpp.

264 {
265  const auto* const result = dynamic_cast<const Data1DViewItem*>(currentItem());
266  ASSERT(result);
267  return result;
268 }

References SessionItemWidget::currentItem().

Here is the call graph for this function:

◆ xAxisCoordToPixel()

double ScientificPlot::xAxisCoordToPixel ( double  axis_coordinate) const
inherited

transform axes coordinates to CustomPlot widget coordinates

Definition at line 27 of file ScientificPlot.cpp.

28 {
29  return customPlot()->xAxis->coordToPixel(axis_coordinate);
30 }

References ScientificPlot::customPlot().

Referenced by ColorMapSceneAdaptor::toSceneX(), and ColorMap::viewportRectangleInWidgetCoordinates().

Here is the call graph for this function:

◆ yAxisCoordToPixel()

double ScientificPlot::yAxisCoordToPixel ( double  axis_coordinate) const
inherited

Definition at line 32 of file ScientificPlot.cpp.

33 {
34  return customPlot()->yAxis->coordToPixel(axis_coordinate);
35 }

References ScientificPlot::customPlot().

Referenced by ColorMapSceneAdaptor::toSceneY(), and ColorMap::viewportRectangleInWidgetCoordinates().

Here is the call graph for this function:

Member Data Documentation

◆ m_block_update

bool Plot1D::m_block_update
private

◆ m_custom_plot

◆ m_event

ScientificPlotEvent* ScientificPlot::m_event
privateinherited

◆ m_graph_map

std::map<Data1DProperties*, QCPGraph*> Plot1D::m_graph_map
private

Definition at line 110 of file Plot1D.h.

Referenced by subscribeToItem(), unsubscribeFromItem(), and updateGraph().

◆ m_itemController

◆ m_plot_type

PLOT_TYPE ScientificPlot::m_plot_type
privateinherited

Definition at line 65 of file ScientificPlot.h.

Referenced by ScientificPlot::plotType().

◆ m_update_timer

UpdateTimer* Plot1D::m_update_timer
private

Definition at line 109 of file Plot1D.h.

Referenced by replot(), and setUpdateTimerConnected().


The documentation for this class was generated from the following files: