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

The SpecularPlot class presents 1D intensity data from SpecularDataItem. More...

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...
 
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

virtual void hideEvent (QHideEvent *)
 
virtual void showEvent (QShowEvent *)
 
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. 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 *intensityItem)
 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
 

Detailed 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.

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 30 of file SpecularPlot.cpp.

32  , m_custom_plot(new QCustomPlot)
33  , m_update_timer(new UpdateTimer(replot_update_interval, this))
34  , m_block_update(true)
35 {
36  initPlot();
37 
38  QVBoxLayout* vlayout = new QVBoxLayout(this);
39  vlayout->setContentsMargins(0, 0, 0, 0);
40  vlayout->setSpacing(0);
41  vlayout->addWidget(m_custom_plot);
42  setLayout(vlayout);
43 
45 }
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:108
void initPlot()
creates and initializes the color map
UpdateTimer * m_update_timer
Definition: SpecularPlot.h:106
QCustomPlot * m_custom_plot
Definition: SpecularPlot.h:105
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 50 of file ScientificPlot.cpp.

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

References ScientificPlot::customPlot().

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

Here is the call graph for this function:

◆ currentItem() [1/2]

SessionItem * SessionItemWidget::currentItem ( )
inherited

Definition at line 41 of file SessionItemWidget.cpp.

42 {
43  return const_cast<SessionItem*>(static_cast<const SessionItemWidget*>(this)->currentItem());
44 }
The SessionItemWidget class is a base for all widgets representing the content of SessionItem.
SessionItem * currentItem()

Referenced by RectangularDetectorEditor::detectorItem(), SphericalDetectorEditor::detectorItem(), FitFlowWidget::fitSuiteItem(), DistributionEditor::groupItem(), DepthProbeInstrumentEditor::instrumentItem(), EnvironmentEditor::instrumentItem(), GISASBeamEditor::instrumentItem(), GISASDetectorEditor::instrumentItem(), GISASInstrumentEditor::instrumentItem(), OffSpecularBeamEditor::instrumentItem(), OffSpecularInstrumentEditor::instrumentItem(), PolarizationAnalysisEditor::instrumentItem(), SpecularBeamEditor::instrumentItem(), SpecularInstrumentEditor::instrumentItem(), RealDataMaskWidget::intensityDataItem(), IntensityDataCanvas::intensityDataItem(), IntensityDataProjectionsWidget::intensityDataItem(), IntensityDataWidget::intensityDataItem(), ProjectionsPlot::intensityItem(), ColorMap::intensityItem(), DetectorPresenter::itemPresentation(), InstrumentPresenter::itemPresentation(), JobResultsPresenter::itemPresentation(), FitComparisonWidget::jobItem(), FitComparisonWidget1D::jobItem(), FitParameterWidget::jobItem(), RunFitControlWidget::jobItem(), JobPropertiesWidget::jobItem(), ParameterTuningWidget::jobItem(), SpecularDataImportWidget::realDataItem(), ItemComboWidget::setPresentation(), JobResultsPresenter::setPresentation(), SpecularDataCanvas::specularDataItem(), SpecularDataImportWidget::specularDataItem(), SpecularDataWidget::specularDataItem(), specularItem(), ItemComboWidget::subscribeToItem(), DistributionEditor::subscribeToItem(), GISASDetectorEditor::subscribeToItem(), PolarizationAnalysisEditor::subscribeToItem(), IntensityDataPropertyWidget::subscribeToItem(), JobPropertiesWidget::subscribeToItem(), ProjectionsPropertyPanel::subscribeToItem(), ProjectionsPlot::unsubscribeFromChildren(), and Plot1D::viewItem().

◆ 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 47 of file SpecularPlot.cpp.

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

Definition at line 56 of file SessionItemWidget.cpp.

57 {
59 }
void unsubscribe()
Fully unsubscribes the parent from listening item's signals.

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 130 of file SpecularPlot.cpp.

131 {
132  m_custom_plot->addGraph();
133 
134  QPen pen(QColor(0, 0, 255, 200));
135  m_custom_plot->graph()->setLineStyle(QCPGraph::lsLine);
136  m_custom_plot->graph()->setPen(pen);
137 
138  m_custom_plot->xAxis->setTickLabelFont(
139  QFont(QFont().family(), Constants::plot_tick_label_size()));
140  m_custom_plot->yAxis->setTickLabelFont(
141  QFont(QFont().family(), Constants::plot_tick_label_size()));
142 }
int plot_tick_label_size()

References m_custom_plot, and Constants::plot_tick_label_size().

Referenced by SpecularPlot().

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 249 of file SpecularPlot.cpp.

250 {
251  if (m_block_update)
252  return;
253 
254  if (propertyName == BasicAxisItem::P_TITLE
255  || propertyName == BasicAxisItem::P_TITLE_IS_VISIBLE) {
257  replot();
258  }
259 
260  if (axisName == SpecularDataItem::P_XAXIS) {
261  if (propertyName == BasicAxisItem::P_MIN_DEG || propertyName == BasicAxisItem::P_MAX_DEG) {
262  setAxesRangeConnected(false);
263  m_custom_plot->xAxis->setRange(specularItem()->getLowerX(),
264  specularItem()->getUpperX());
265  setAxesRangeConnected(true);
266  replot();
267  }
268  } else if (axisName == SpecularDataItem::P_YAXIS) {
269  if (propertyName == BasicAxisItem::P_MIN_DEG || propertyName == BasicAxisItem::P_MAX_DEG) {
270  setAxesRangeConnected(false);
271  m_custom_plot->yAxis->setRange(specularItem()->getLowerY(),
272  specularItem()->getUpperY());
273  setAxesRangeConnected(true);
274  replot();
275  } else if (propertyName == AmplitudeAxisItem::P_IS_LOGSCALE) {
276  setLog(specularItem()->isLog());
277  replot();
278  }
279  }
280 }
static const QString P_IS_LOGSCALE
Definition: AxesItems.h:55
static const QString P_MAX_DEG
Definition: AxesItems.h:28
static const QString P_TITLE
Definition: AxesItems.h:29
static const QString P_TITLE_IS_VISIBLE
Definition: AxesItems.h:30
static const QString P_MIN_DEG
Definition: AxesItems.h:27
static const QString P_YAXIS
static const QString P_XAXIS
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 m_block_update, m_custom_plot, AmplitudeAxisItem::P_IS_LOGSCALE, BasicAxisItem::P_MAX_DEG, BasicAxisItem::P_MIN_DEG, BasicAxisItem::P_TITLE, BasicAxisItem::P_TITLE_IS_VISIBLE, SpecularDataItem::P_XAXIS, SpecularDataItem::P_YAXIS, 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 73 of file SpecularPlot.cpp.

74 {
75  if (m_block_update)
76  return;
77 
78  if (property_name == DataItem::P_AXES_UNITS) {
80  replot();
81  }
82 }
static const QString P_AXES_UNITS
Definition: DataItem.h:34
void setAxesRangeFromItem(SpecularDataItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item.

References m_block_update, DataItem::P_AXES_UNITS, 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 100 of file SpecularPlot.cpp.

101 {
102  m_custom_plot->replot();
103 }

References m_custom_plot.

Referenced by setUpdateTimerConnected().

◆ onXaxisRangeChanged

void SpecularPlot::onXaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate xmin, xmax back to IntensityDataItem.

Definition at line 84 of file SpecularPlot.cpp.

85 {
86  m_block_update = true;
87  specularItem()->setLowerX(newRange.lower);
88  specularItem()->setUpperX(newRange.upper);
89  m_block_update = false;
90 }
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 92 of file SpecularPlot.cpp.

93 {
94  m_block_update = true;
95  specularItem()->setLowerY(newRange.lower);
96  specularItem()->setUpperY(newRange.upper);
97  m_block_update = false;
98 }
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 35 of file ScientificPlot.cpp.

36 {
37  return customPlot()->xAxis->pixelToCoord(pixel);
38 }

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 40 of file ScientificPlot.cpp.

41 {
42  return customPlot()->yAxis->pixelToCoord(pixel);
43 }

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

◆ replot()

void SpecularPlot::replot ( )
private

Schedule replot for later execution by onTimeReplot() slot.

Definition at line 282 of file SpecularPlot.cpp.

283 {
285 }
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 68 of file SpecularPlot.cpp.

69 {
71 }
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 209 of file SpecularPlot.cpp.

210 {
211  setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle());
212  setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle());
213 }
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 150 of file SpecularPlot.cpp.

151 {
152  if (isConnected) {
153  connect(m_custom_plot->xAxis,
154  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
155  &SpecularPlot::onXaxisRangeChanged, Qt::UniqueConnection);
156 
157  connect(m_custom_plot->yAxis,
158  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
159  &SpecularPlot::onYaxisRangeChanged, Qt::UniqueConnection);
160 
161  } else {
162  disconnect(m_custom_plot->xAxis,
163  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
165 
166  disconnect(m_custom_plot->yAxis,
167  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
169  }
170 }
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 197 of file SpecularPlot.cpp.

198 {
199  m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
200  m_custom_plot->axisRect()->setupFullAxesBox(true);
201 
202  setAxesRangeConnected(false);
203  m_custom_plot->xAxis->setRange(item->getLowerX(), item->getUpperX());
204  m_custom_plot->yAxis->setRange(item->getLowerY(), item->getUpperY());
205  setLog(item->isLog());
206  setAxesRangeConnected(true);
207 }
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 144 of file SpecularPlot.cpp.

145 {
146  setAxesRangeConnected(isConnected);
147  setUpdateTimerConnected(isConnected);
148 }
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 224 of file SpecularPlot.cpp.

225 {
226  ASSERT(item);
227  auto data = item->getOutputData();
228  if (!data)
229  return;
230 
231  for (size_t i = 0, size = data->getAllocatedSize(); i < size; ++i) {
232  double x = data->getAxisValue(i, 0);
233  double y = data->operator[](i);
234  m_custom_plot->graph()->addData(x, y);
235  }
236 }
#define ASSERT(condition)
Definition: Assert.h:31
OutputData< double > * getOutputData()
Definition: DataItem.h:36
double getAxisValue(size_t global_index, size_t i_selected_axis) const
Returns the value of selected axis for given global_index.
Definition: OutputData.h:430

References ASSERT, OutputData< T >::getAxisValue(), DataItem::getOutputData(), and m_custom_plot.

Referenced by setPlotFromItem().

Here is the call graph for this function:

◆ setItem()

void SessionItemWidget::setItem ( SessionItem item)
virtualinherited

Reimplemented in SpecularPlotCanvas, SpecularDataImportWidget, SpecularDataWidget, IntensityDataWidget, SpecularDataCanvas, ProjectionsWidget, IntensityDataCanvas, ColorMapCanvas, and Plot1DCanvas.

Definition at line 28 of file SessionItemWidget.cpp.

29 {
31 
32  if (isVisible())
34 }
void setItem(SessionItem *item)
void subscribe()
Subscribe parent to item's signals.

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

Referenced by IntensityDataWidget::onFFTAction(), JobSelectorWidget::onSelectionChanged(), ProjectionsEditor::resetContext(), ProjectionsEditor::setContext(), MaskGraphicsProxy::setIntensityItem(), FitSessionWidget::setItem(), Plot1DCanvas::setItem(), InstrumentEditorWidget::setItem(), ColorMapCanvas::setItem(), IntensityDataCanvas::setItem(), ProjectionsWidget::setItem(), SpecularDataCanvas::setItem(), DistributionDialog::setItem(), IntensityDataWidget::setItem(), SpecularDataWidget::setItem(), SpecularDataImportWidget::setItem(), SpecularPlotCanvas::setItem(), ItemComboWidget::setPresentation(), GISASInstrumentEditor::subscribeToItem(), OffSpecularInstrumentEditor::subscribeToItem(), SpecularInstrumentEditor::subscribeToItem(), FitComparisonWidget::subscribeToItem(), FitComparisonWidget1D::subscribeToItem(), and GISASDetectorEditor::updateDetectorPresenter().

Here is the call graph for this function:

◆ setLabel()

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

Sets label to axis.

Definition at line 215 of file SpecularPlot.cpp.

216 {
217  ASSERT(item && axis);
219  axis->setLabel(std::move(label));
220  else
221  axis->setLabel(QString());
222 }
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.

References ASSERT, SessionItem::getItemValue(), and BasicAxisItem::P_TITLE_IS_VISIBLE.

Referenced by setAxesLabelsFromItem().

Here is the call graph for this function:

◆ setLog()

void SpecularPlot::setLog ( bool  log)

sets logarithmic scale

Definition at line 62 of file SpecularPlot.cpp.

63 {
66 }
void setLogz(QCPColorScale *scale, bool isLogz)

References m_custom_plot, and ColorMapUtils::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 45 of file ScientificPlot.cpp.

46 {
48 }
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 intensityItem)
private

Sets initial state of SpecularPlot to match given intensity item.

Definition at line 181 of file SpecularPlot.cpp.

182 {
184 
185  m_block_update = true;
186 
187  m_custom_plot->graph(0)->data()->clear();
191 
192  replot();
193 
194  m_block_update = false;
195 }
void setDataFromItem(SpecularDataItem *item)
Sets the intensity values to SpecularPlot.

References ASSERT, 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 172 of file SpecularPlot.cpp.

173 {
174  if (isConnected)
176  Qt::UniqueConnection);
177  else
179 }
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 *  )
protectedvirtualinherited

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 238 of file SpecularPlot.cpp.

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

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

◆ specularItem() [2/2]

const SpecularDataItem * SpecularPlot::specularItem ( ) const
private

Definition at line 243 of file SpecularPlot.cpp.

244 {
245  const auto result = dynamic_cast<const SpecularDataItem*>(currentItem());
246  return result;
247 }

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 105 of file SpecularPlot.cpp.

106 {
108 
110  [this](const QString& name) { onPropertyChanged(name); }, this);
111 
113  [this](SessionItem* item, const QString name) {
114  if (item->modelType() == "BasicAxis" || item->modelType() == "AmplitudeAxis")
116  },
117  this);
118 
119  specularItem()->mapper()->setOnValueChange([this]() { setPlotFromItem(this->specularItem()); },
120  this);
121 
122  setConnected(true);
123 }
void setOnValueChange(std::function< void(void)> f, const void *caller=0)
Definition: ModelMapper.cpp:30
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=0)
Calls back on child property change, report childItem and property name.
Definition: ModelMapper.cpp:49
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=0)
Definition: ModelMapper.cpp:35
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 *intensityItem)
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:21

References SessionItem::itemName(), SessionItem::mapper(), SessionItem::modelType(), modifyAxesProperties(), 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 125 of file SpecularPlot.cpp.

126 {
127  setConnected(false);
128 }

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 25 of file ScientificPlot.cpp.

26 {
27  return customPlot()->xAxis->coordToPixel(axis_coordinate);
28 }

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 30 of file ScientificPlot.cpp.

31 {
32  return customPlot()->yAxis->coordToPixel(axis_coordinate);
33 }

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 106 of file SpecularPlot.h.

Referenced by replot(), and setUpdateTimerConnected().


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