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

Description

The SpecularPlot class presents 1D intensity data from SpecularDataItem.

Provides minimal functionality for data plotting and axes interaction. Should be a component for more complicated plotting widgets. Corresponds to ColorMap for 2D intensity data.

Definition at line 32 of file SpecularPlot.h.

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

Public Types

enum class  PLOT_TYPE { Plot1D , Plot2D }
 

Signals

void statusString (const QString &text)
 

Public Member Functions

 SpecularPlot (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...
 
void initScatter ()
 Adds scatter ro real data plot. 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 initPlot ()
 creates and initializes the color map More...
 
void modifyAxesProperties (const QString &axisName, const QString &propertyName)
 
void replot ()
 Schedule replot for later execution by onTimeReplot() slot. More...
 
void setAxesLabelsFromItem (SpecularDataItem *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 (SpecularDataItem *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 setDataFromItem (SpecularDataItem *item)
 Sets the intensity values to SpecularPlot. More...
 
void setLabel (const BasicAxisItem *item, QCPAxis *axis, QString label)
 Sets label to axis. More...
 
void setPlotFromItem (SpecularDataItem *specularItem)
 Sets initial state of SpecularPlot to match given intensity item. More...
 
void setUpdateTimerConnected (bool isConnected)
 
SpecularDataItemspecularItem ()
 
const SpecularDataItemspecularItem () const
 

Private Attributes

bool m_block_update
 
QCustomPlot * m_custom_plot
 
ScientificPlotEventm_event
 
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

◆ SpecularPlot()

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

Definition at line 33 of file SpecularPlot.cpp.

35  , m_custom_plot(new QCustomPlot)
36  , m_update_timer(new UpdateTimer(replot_update_interval, this))
37  , m_block_update(true)
38 {
39  initPlot();
40 
41  auto* vlayout = new QVBoxLayout(this);
42  vlayout->setContentsMargins(0, 0, 0, 0);
43  vlayout->setSpacing(0);
44  vlayout->addWidget(m_custom_plot);
45  m_custom_plot->setAttribute(Qt::WA_NoMousePropagation, false);
46  setLayout(vlayout);
47 
49 }
ScientificPlot(QWidget *parent, PLOT_TYPE plot_type)
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
bool m_block_update
Definition: SpecularPlot.h:111
void initPlot()
creates and initializes the color map
UpdateTimer * m_update_timer
Definition: SpecularPlot.h:109
QCustomPlot * m_custom_plot
Definition: SpecularPlot.h:108
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
Definition: UpdateTimer.h:27

References initPlot(), m_custom_plot, 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 Plot1D::eventInfo(), 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* SpecularPlot::customPlot ( ) const
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 45 of file SpecularPlot.h.

45 { return m_custom_plot; }

References m_custom_plot.

◆ customPlot() [2/2]

QCustomPlot* SpecularPlot::customPlot ( )
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 44 of file SpecularPlot.h.

44 { return m_custom_plot; }

References m_custom_plot.

Referenced by SpecularPlotCanvas::customPlot().

◆ eventInfo()

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

Returns PlotEventInfo corresponding to given axes coordinates.

Implements ScientificPlot.

Definition at line 51 of file SpecularPlot.cpp.

52 {
53  PlotEventInfo result(plotType());
54  if (!specularItem())
55  return result;
56 
57  result.setX(xpos);
58  result.setValue(ypos);
59 
60  result.setInAxesRange(axesRangeContains(xpos, ypos));
61  result.setNx(bin(result.x(), m_custom_plot->graph()));
62 
63  return result;
64 }
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.
SpecularDataItem * specularItem()

References ScientificPlot::axesRangeContains(), m_custom_plot, ScientificPlot::plotType(), PlotEventInfo::setInAxesRange(), PlotEventInfo::setNx(), PlotEventInfo::setValue(), PlotEventInfo::setX(), specularItem(), 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:

◆ initPlot()

void SpecularPlot::initPlot ( )
private

creates and initializes the color map

Definition at line 135 of file SpecularPlot.cpp.

136 {
137  m_custom_plot->addGraph();
138 
139  QPen pen(QColor(0, 0, 255, 200));
140  m_custom_plot->graph()->setLineStyle(QCPGraph::lsLine);
141  m_custom_plot->graph()->setPen(pen);
142 
143  m_custom_plot->xAxis->setTickLabelFont(
144  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
145  m_custom_plot->yAxis->setTickLabelFont(
146  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
147 }
int plot_tick_label_size()
Definition: PlotConstants.h:23

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

Referenced by SpecularPlot().

Here is the call graph for this function:

◆ initScatter()

void SpecularPlot::initScatter ( )

Adds scatter ro real data plot.

Definition at line 149 of file SpecularPlot.cpp.

150 {
151  if (dynamic_cast<RealDataItem*>(specularItem()->parentItem())) {
152  m_custom_plot->graph()->setScatterStyle(QCPScatterStyle::ssDisc);
153  } else {
154  m_custom_plot->graph()->setScatterStyle(QCPScatterStyle::ssNone);
155  }
156  m_custom_plot->replot();
157 }
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33

References m_custom_plot, and specularItem().

Referenced by SpecularPlotCanvas::initScatter().

Here is the call graph for this function:

◆ minimumSizeHint()

QSize SpecularPlot::minimumSizeHint ( ) const
inlineoverride

Definition at line 39 of file SpecularPlot.h.

39 { return QSize(128, 128); }

◆ modifyAxesProperties()

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

Definition at line 263 of file SpecularPlot.cpp.

264 {
265  if (m_block_update)
266  return;
267 
268  if (BasicAxisItem::isTitlePropertyName(propertyName)
271  replot();
272  }
273 
275  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
276  setAxesRangeConnected(false);
277  m_custom_plot->xAxis->setRange(specularItem()->getLowerX(),
278  specularItem()->getUpperX());
279  setAxesRangeConnected(true);
280  replot();
281  }
282  } else if (SpecularDataItem::isYaxisPropertyName(axisName)) {
283  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
284  setAxesRangeConnected(false);
285  m_custom_plot->yAxis->setRange(specularItem()->getLowerY(),
286  specularItem()->getUpperY());
287  setAxesRangeConnected(true);
288  replot();
289  } else if (AmplitudeAxisItem::isLogScalePropertyName(propertyName)) {
290  setLog(specularItem()->isLog());
291  replot();
292  }
293  }
294 }
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.
void setAxesLabelsFromItem(SpecularDataItem *item)
Sets X,Y axes labels from item.
void setLog(bool log)
sets logarithmic scale
void replot()
Schedule replot for later execution by onTimeReplot() slot.

References BasicAxisItem::isBoundsPropertiesName(), AmplitudeAxisItem::isLogScalePropertyName(), BasicAxisItem::isTitlePropertyName(), BasicAxisItem::isTitleVisiblePropertyName(), SpecularDataItem::isXaxisPropertyName(), SpecularDataItem::isYaxisPropertyName(), m_block_update, m_custom_plot, replot(), setAxesLabelsFromItem(), setAxesRangeConnected(), setLog(), and specularItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onPropertyChanged

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

updates plot depending on IntensityDataItem properties

Definition at line 77 of file SpecularPlot.cpp.

78 {
79  if (m_block_update)
80  return;
81 
82  if (DataItem::isAxesUnitsPropertyName(property_name)) {
84  replot();
85  }
86 }
static bool isAxesUnitsPropertyName(const QString &name)
Definition: DataItem.cpp:113
void setAxesRangeFromItem(SpecularDataItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item. Also sets logarithmic scale on y...

References DataItem::isAxesUnitsPropertyName(), m_block_update, replot(), setAxesRangeFromItem(), and specularItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onTimeToReplot

void SpecularPlot::onTimeToReplot ( )
privateslot

Replots SpecularPlot.

Definition at line 104 of file SpecularPlot.cpp.

105 {
106  m_custom_plot->replot();
107 }

References m_custom_plot.

Referenced by setUpdateTimerConnected().

◆ onXaxisRangeChanged

void SpecularPlot::onXaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate xmin, xmax back to IntensityDataItem.

Definition at line 88 of file SpecularPlot.cpp.

89 {
90  m_block_update = true;
91  specularItem()->setLowerX(newRange.lower);
92  specularItem()->setUpperX(newRange.upper);
93  m_block_update = false;
94 }
void setUpperX(double value)
void setLowerX(double value)

References m_block_update, SpecularDataItem::setLowerX(), SpecularDataItem::setUpperX(), and specularItem().

Referenced by setAxesRangeConnected().

Here is the call graph for this function:

◆ onYaxisRangeChanged

void SpecularPlot::onYaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate ymin, ymax back to IntensityDataItem.

Definition at line 96 of file SpecularPlot.cpp.

97 {
98  m_block_update = true;
99  specularItem()->setLowerY(newRange.lower);
100  specularItem()->setUpperY(newRange.upper);
101  m_block_update = false;
102 }
void setUpperY(double value)
void setLowerY(double value)

References m_block_update, SpecularDataItem::setLowerY(), SpecularDataItem::setUpperY(), and specularItem().

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 Plot1D::eventInfo(), eventInfo(), ColorMap::eventInfo(), and FontScalingEvent::setTickLabelFont().

◆ replot()

void SpecularPlot::replot ( )
private

Schedule replot for later execution by onTimeReplot() slot.

Definition at line 296 of file SpecularPlot.cpp.

297 {
299 }
void scheduleUpdate()
Definition: UpdateTimer.cpp:42

References m_update_timer, and UpdateTimer::scheduleUpdate().

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

Here is the call graph for this function:

◆ resetView()

void SpecularPlot::resetView ( )

reset all axes min,max to initial value

Definition at line 72 of file SpecularPlot.cpp.

73 {
75 }
void resetView()
Set axes viewport to original data.

References SpecularDataItem::resetView(), and specularItem().

Here is the call graph for this function:

◆ setAxesLabelsFromItem()

void SpecularPlot::setAxesLabelsFromItem ( SpecularDataItem item)
private

Sets X,Y axes labels from item.

Definition at line 223 of file SpecularPlot.cpp.

224 {
225  setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle());
226  setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle());
227 }
QString getXaxisTitle() const
QString getYaxisTitle() const
const AmplitudeAxisItem * yAxisItem() const
const BasicAxisItem * xAxisItem() const
void setLabel(const BasicAxisItem *item, QCPAxis *axis, QString label)
Sets label to axis.

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

Referenced by modifyAxesProperties(), and setPlotFromItem().

Here is the call graph for this function:

◆ setAxesRangeConnected()

void SpecularPlot::setAxesRangeConnected ( bool  isConnected)
private

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

Definition at line 165 of file SpecularPlot.cpp.

166 {
167  if (isConnected) {
168  connect(m_custom_plot->xAxis,
169  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
170  &SpecularPlot::onXaxisRangeChanged, Qt::UniqueConnection);
171 
172  connect(m_custom_plot->yAxis,
173  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
174  &SpecularPlot::onYaxisRangeChanged, Qt::UniqueConnection);
175  } else {
176  disconnect(m_custom_plot->xAxis,
177  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
179 
180  disconnect(m_custom_plot->yAxis,
181  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
183  }
184 }
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.

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

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

Here is the call graph for this function:

◆ setAxesRangeFromItem()

void SpecularPlot::setAxesRangeFromItem ( SpecularDataItem 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 211 of file SpecularPlot.cpp.

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

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

Referenced by onPropertyChanged(), and setPlotFromItem().

Here is the call graph for this function:

◆ setConnected()

void SpecularPlot::setConnected ( bool  isConnected)
private

Definition at line 159 of file SpecularPlot.cpp.

160 {
161  setAxesRangeConnected(isConnected);
162  setUpdateTimerConnected(isConnected);
163 }
void setUpdateTimerConnected(bool isConnected)

References setAxesRangeConnected(), and setUpdateTimerConnected().

Referenced by subscribeToItem(), and unsubscribeFromItem().

Here is the call graph for this function:

◆ setDataFromItem()

void SpecularPlot::setDataFromItem ( SpecularDataItem item)
private

Sets the intensity values to SpecularPlot.

Definition at line 238 of file SpecularPlot.cpp.

239 {
240  ASSERT(item);
241  auto* data = item->getDatafield();
242  if (!data)
243  return;
244 
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);
248  m_custom_plot->graph()->addData(x, y);
249  }
250 }
Datafield * getDatafield()
Definition: DataItem.h:41

References DataItem::getDatafield(), and m_custom_plot.

Referenced by setPlotFromItem().

Here is the call graph for this function:

◆ setItem()

◆ setLabel()

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

Sets label to axis.

Definition at line 229 of file SpecularPlot.cpp.

230 {
231  ASSERT(item && axis);
232  if (item->isTitleVisible())
233  axis->setLabel(label);
234  else
235  axis->setLabel(QString());
236 }
bool isTitleVisible() const
Definition: AxesItems.cpp:100

References BasicAxisItem::isTitleVisible().

Referenced by setAxesLabelsFromItem().

Here is the call graph for this function:

◆ setLog()

void SpecularPlot::setLog ( bool  log)

sets logarithmic scale

Definition at line 66 of file SpecularPlot.cpp.

67 {
70 }
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::Plot1D(), SpecularPlot(), and PlotStatusLabel::setPlotLabelEnabled().

Here is the call graph for this function:

◆ setPlotFromItem()

void SpecularPlot::setPlotFromItem ( SpecularDataItem specularItem)
private

Sets initial state of SpecularPlot to match given intensity item.

Definition at line 195 of file SpecularPlot.cpp.

196 {
197  ASSERT(specularItem);
198 
199  m_block_update = true;
200 
201  m_custom_plot->graph(0)->data()->clear();
205 
206  replot();
207 
208  m_block_update = false;
209 }
void setDataFromItem(SpecularDataItem *item)
Sets the intensity values to SpecularPlot.

References m_block_update, m_custom_plot, replot(), setAxesLabelsFromItem(), setAxesRangeFromItem(), setDataFromItem(), and specularItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ setUpdateTimerConnected()

void SpecularPlot::setUpdateTimerConnected ( bool  isConnected)
private

Definition at line 186 of file SpecularPlot.cpp.

187 {
188  if (isConnected)
190  Qt::UniqueConnection);
191  else
193 }
void onTimeToReplot()
Replots SpecularPlot.
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 SpecularPlot::sizeHint ( ) const
inlineoverride

Definition at line 38 of file SpecularPlot.h.

38 { return QSize(500, 400); }

◆ specularItem() [1/2]

SpecularDataItem * SpecularPlot::specularItem ( )
private

Definition at line 252 of file SpecularPlot.cpp.

253 {
254  return const_cast<SpecularDataItem*>(static_cast<const SpecularPlot*>(this)->specularItem());
255 }
The SpecularPlot class presents 1D intensity data from SpecularDataItem.
Definition: SpecularPlot.h:32

Referenced by eventInfo(), initScatter(), modifyAxesProperties(), onPropertyChanged(), onXaxisRangeChanged(), onYaxisRangeChanged(), resetView(), setPlotFromItem(), and subscribeToItem().

◆ specularItem() [2/2]

const SpecularDataItem * SpecularPlot::specularItem ( ) const
private

Definition at line 257 of file SpecularPlot.cpp.

258 {
259  const auto* const result = dynamic_cast<const SpecularDataItem*>(currentItem());
260  return result;
261 }

References SessionItemWidget::currentItem().

Here is the call graph for this function:

◆ statusString

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

◆ subscribeToItem()

void SpecularPlot::subscribeToItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 109 of file SpecularPlot.cpp.

110 {
112 
114  [this](const QString& name) { onPropertyChanged(name); }, this);
115 
117  [this](SessionItem* item, const QString name) {
118  if (item->modelType() == BasicAxisItem::M_TYPE
119  || item->modelType() == AmplitudeAxisItem::M_TYPE)
121  },
122  this);
123 
124  specularItem()->mapper()->setOnValueChange([this]() { setPlotFromItem(this->specularItem()); },
125  this);
126 
127  setConnected(true);
128 }
static constexpr auto M_TYPE
Definition: AxesItems.h:81
static constexpr auto M_TYPE
Definition: AxesItems.h:35
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
Definition: ModelMapper.cpp:39
void setOnValueChange(std::function< void(void)> f, const void *caller=nullptr)
Definition: ModelMapper.cpp:34
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
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.
void setConnected(bool isConnected)
void setPlotFromItem(SpecularDataItem *specularItem)
Sets initial state of SpecularPlot to match given intensity item.
void modifyAxesProperties(const QString &axisName, const QString &propertyName)
void onPropertyChanged(const QString &property_name)
updates plot depending on IntensityDataItem properties
QString const & name(EShape k)
Definition: particles.cpp:20

References SessionItem::itemName(), BasicAxisItem::M_TYPE, AmplitudeAxisItem::M_TYPE, SessionItem::mapper(), SessionItem::modelType(), modifyAxesProperties(), GUI::RealSpace::Particles::name(), onPropertyChanged(), setConnected(), ModelMapper::setOnChildPropertyChange(), ModelMapper::setOnPropertyChange(), ModelMapper::setOnValueChange(), setPlotFromItem(), and specularItem().

Here is the call graph for this function:

◆ unsubscribeFromItem()

void SpecularPlot::unsubscribeFromItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 130 of file SpecularPlot.cpp.

131 {
132  setConnected(false);
133 }

References setConnected().

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 SpecularPlot::m_block_update
private

◆ m_custom_plot

◆ m_event

ScientificPlotEvent* ScientificPlot::m_event
privateinherited

◆ 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* SpecularPlot::m_update_timer
private

Definition at line 109 of file SpecularPlot.h.

Referenced by replot(), and setUpdateTimerConnected().


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