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

The Plot1D class presents data of several 1D DataItems contained in a Data1DViewItem. More...

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

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

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

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 33 of file Plot1D.cpp.

35  , m_custom_plot(new QCustomPlot)
36  , m_update_timer(new UpdateTimer(replot_update_interval, this))
37  , m_block_update(false)
38 {
39  QVBoxLayout* vlayout = new QVBoxLayout(this);
40  vlayout->setContentsMargins(0, 0, 0, 0);
41  vlayout->setSpacing(0);
42  vlayout->addWidget(m_custom_plot);
43  setLayout(vlayout);
44 
45  m_custom_plot->xAxis->setTickLabelFont(
46  QFont(QFont().family(), Constants::plot_tick_label_size()));
47  m_custom_plot->yAxis->setTickLabelFont(
48  QFont(QFont().family(), Constants::plot_tick_label_size()));
49 
51 }
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()

References m_custom_plot, 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 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(), eventInfo(), and SpecularPlot::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(), SpecularPlot::specularItem(), ItemComboWidget::subscribeToItem(), DistributionEditor::subscribeToItem(), GISASDetectorEditor::subscribeToItem(), PolarizationAnalysisEditor::subscribeToItem(), IntensityDataPropertyWidget::subscribeToItem(), JobPropertiesWidget::subscribeToItem(), ProjectionsPropertyPanel::subscribeToItem(), ProjectionsPlot::unsubscribeFromChildren(), and 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* 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 53 of file Plot1D.cpp.

54 {
55  PlotEventInfo result(plotType());
56  if (!viewItem())
57  return result;
58 
59  result.setX(xpos);
60  result.setValue(ypos);
61 
62  result.setInAxesRange(axesRangeContains(xpos, ypos));
63  result.setNx(bin(result.x(), m_custom_plot->graph()));
64 
65  return result;
66 }
Data1DViewItem * viewItem()
Definition: Plot1D.cpp:255
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 *  )
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:

◆ initPlots()

void Plot1D::initPlots ( )
private

creates and initializes the color map

Definition at line 146 of file Plot1D.cpp.

147 {
148  auto property_items = viewItem()->propertyContainerItem()->propertyItems();
149  std::for_each(property_items.begin(), property_items.end(), [this](Data1DProperties* item) {
150  auto graph = m_custom_plot->addGraph();
151  graph->setLineStyle(QCPGraph::lsLine);
152  graph->setPen(QPen(item->color()));
153  m_graph_map[item] = graph;
154  });
155 }
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 267 of file Plot1D.cpp.

268 {
269  if (m_block_update)
270  return;
271 
272  if (propertyName == BasicAxisItem::P_TITLE
273  || propertyName == BasicAxisItem::P_TITLE_IS_VISIBLE) {
275  replot();
276  }
277 
278  if (axisName == Data1DViewItem::P_XAXIS) {
279  if (propertyName == BasicAxisItem::P_MIN_DEG || propertyName == BasicAxisItem::P_MAX_DEG) {
280  setAxesRangeConnected(false);
281  m_custom_plot->xAxis->setRange(viewItem()->getLowerX(), viewItem()->getUpperX());
282  setAxesRangeConnected(true);
283  replot();
284  }
285  } else if (axisName == Data1DViewItem::P_YAXIS) {
286  if (propertyName == BasicAxisItem::P_MIN_DEG || propertyName == BasicAxisItem::P_MAX_DEG) {
287  setAxesRangeConnected(false);
288  m_custom_plot->yAxis->setRange(viewItem()->getLowerY(), viewItem()->getUpperY());
289  setAxesRangeConnected(true);
290  replot();
291  } else if (propertyName == AmplitudeAxisItem::P_IS_LOGSCALE) {
292  setLog(viewItem()->isLog());
293  replot();
294  }
295  }
296 }
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.
Definition: Plot1D.cpp:163
void setAxesLabelsFromItem(Data1DViewItem *item)
Sets X,Y axes labels from item.
Definition: Plot1D.cpp:225
void replot()
Schedule replot for later execution by onTimeReplot() slot.
Definition: Plot1D.cpp:298
void setLog(bool log)
sets logarithmic scale
Definition: Plot1D.cpp:68

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, Data1DViewItem::P_XAXIS, Data1DViewItem::P_YAXIS, 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 79 of file Plot1D.cpp.

80 {
81  if (m_block_update)
82  return;
83 
84  if (property_name == Data1DViewItem::P_AXES_UNITS) {
87  replot();
88  }
89 }
static const QString P_AXES_UNITS
void updateAllGraphs()
Sets data to graphs.
Definition: Plot1D.cpp:240
void setAxesRangeFromItem(Data1DViewItem *item)
Sets (xmin,xmax) and (ymin,ymax) of SpecularPlot from specular item.
Definition: Plot1D.cpp:213

References m_block_update, Data1DViewItem::P_AXES_UNITS, 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 107 of file Plot1D.cpp.

108 {
109  m_custom_plot->replot();
110 }

References m_custom_plot.

Referenced by setUpdateTimerConnected().

◆ onXaxisRangeChanged

void Plot1D::onXaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate xmin, xmax back to IntensityDataItem.

Definition at line 91 of file Plot1D.cpp.

92 {
93  m_block_update = true;
94  viewItem()->setLowerX(newRange.lower);
95  viewItem()->setUpperX(newRange.upper);
96  m_block_update = false;
97 }
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 99 of file Plot1D.cpp.

100 {
101  m_block_update = true;
102  viewItem()->setLowerY(newRange.lower);
103  viewItem()->setUpperY(newRange.upper);
104  m_block_update = false;
105 }
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 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(), eventInfo(), SpecularPlot::eventInfo(), and FontScalingEvent::setTickLabelFont().

◆ refreshPlotData()

void Plot1D::refreshPlotData ( )
private

Refresh axes' labels, range and graph data.

Definition at line 194 of file Plot1D.cpp.

195 {
196  if (m_block_update)
197  return;
198 
199  m_block_update = true;
200 
201  auto view_item = viewItem();
202  ASSERT(view_item);
203 
204  setAxesRangeFromItem(view_item);
205  setAxesLabelsFromItem(view_item);
206  updateAllGraphs();
207 
208  replot();
209 
210  m_block_update = false;
211 }
#define ASSERT(condition)
Definition: Assert.h:31

References ASSERT, 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 298 of file Plot1D.cpp.

299 {
301 }
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 74 of file Plot1D.cpp.

75 {
76  viewItem()->resetView();
77 }
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 225 of file Plot1D.cpp.

226 {
227  setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle());
228  setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle());
229 }
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:231

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 163 of file Plot1D.cpp.

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

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 213 of file Plot1D.cpp.

214 {
215  m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
216  m_custom_plot->axisRect()->setupFullAxesBox(true);
217 
218  setAxesRangeConnected(false);
219  m_custom_plot->xAxis->setRange(item->getLowerX(), item->getUpperX());
220  m_custom_plot->yAxis->setRange(item->getLowerY(), item->getUpperY());
221  setLog(item->isLog());
222  setAxesRangeConnected(true);
223 }
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 157 of file Plot1D.cpp.

158 {
159  setAxesRangeConnected(isConnected);
160  setUpdateTimerConnected(isConnected);
161 }
void setUpdateTimerConnected(bool isConnected)
Definition: Plot1D.cpp:185

References setAxesRangeConnected(), and setUpdateTimerConnected().

Referenced by unsubscribeFromItem().

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 Plot1D::setLabel ( const BasicAxisItem item,
QCPAxis *  axis,
QString  label 
)
private

Sets label to axis.

Definition at line 231 of file Plot1D.cpp.

232 {
233  ASSERT(item && axis);
235  axis->setLabel(std::move(label));
236  else
237  axis->setLabel(QString());
238 }
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 Plot1D::setLog ( bool  log)

sets logarithmic scale

Definition at line 68 of file Plot1D.cpp.

69 {
72 }
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(), SpecularPlot::SpecularPlot(), and PlotStatusLabel::setPlotLabelEnabled().

Here is the call graph for this function:

◆ setUpdateTimerConnected()

void Plot1D::setUpdateTimerConnected ( bool  isConnected)
private

Definition at line 185 of file Plot1D.cpp.

186 {
187  if (isConnected)
189  Qt::UniqueConnection);
190  else
192 }
void onTimeToReplot()
Replots SpecularPlot.
Definition: Plot1D.cpp:107
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 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 112 of file Plot1D.cpp.

113 {
114  initPlots();
115  refreshPlotData();
116 
118  [this](const QString& name) { onPropertyChanged(name); }, this);
119 
121  [this](SessionItem* item, const QString name) {
122  if (dynamic_cast<BasicAxisItem*>(item))
124  },
125  this);
126 
127  std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
128  auto property_item = pair.first;
129  property_item->dataItem()->mapper()->setOnValueChange(
130  [caller]() { caller->refreshPlotData(); }, caller);
131  });
132 
133  setConnected(true);
134 }
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
void initPlots()
creates and initializes the color map
Definition: Plot1D.cpp:146
void setConnected(bool isConnected)
Definition: Plot1D.cpp:157
void refreshPlotData()
Refresh axes' labels, range and graph data.
Definition: Plot1D.cpp:194
void onPropertyChanged(const QString &property_name)
updates plot depending on IntensityDataItem properties
Definition: Plot1D.cpp:79
std::map< Data1DProperties *, QCPGraph * > m_graph_map
Definition: Plot1D.h:110
void modifyAxesProperties(const QString &axisName, const QString &propertyName)
Definition: Plot1D.cpp:267
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:21

References initPlots(), SessionItem::itemName(), m_graph_map, SessionItem::mapper(), modifyAxesProperties(), 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 136 of file Plot1D.cpp.

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

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 240 of file Plot1D.cpp.

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

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 247 of file Plot1D.cpp.

248 {
249  auto data_points = viewItem()->graphData(item);
250 
251  auto graph = m_graph_map.at(item);
252  graph->setData(data_points.first, data_points.second, /*sorted =*/true);
253 }
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 255 of file Plot1D.cpp.

256 {
257  return const_cast<Data1DViewItem*>(static_cast<const Plot1D*>(this)->viewItem());
258 }
View model for 1D DataItem.

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 260 of file Plot1D.cpp.

261 {
262  const auto result = dynamic_cast<const Data1DViewItem*>(currentItem());
263  ASSERT(result);
264  return result;
265 }

References ASSERT, and 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 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 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: