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

Description

The ColorMap class presents 2D intensity data from IntensityDataItem as color map.

Provides a minimal functionality for data plotting and axes interaction. Should be a component for more complicated plotting widgets. This is a replacement for ColorMapPlot.

Definition at line 36 of file ColorMap.h.

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

Public Types

enum class  PLOT_TYPE { Plot1D , Plot2D }
 

Public Slots

void resetView ()
 reset all axes min,max to initial value More...
 
void setLogz (bool logz)
 sets logarithmic scale More...
 

Signals

void marginsChanged (double left, double right)
 
void statusString (const QString &text)
 

Public Member Functions

 ColorMap (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...
 
QCPColorScale * colorScale ()
 
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...
 
virtual void setItem (SessionItem *item)
 
void setMouseTrackingEnabled (bool enable)
 Tracks move events (used when showing profile histograms and printing status string) More...
 
QSize sizeHint () const override
 
QRectF viewportRectangleInWidgetCoordinates ()
 Returns rectangle representing current axes zoom state in widget coordinates. More...
 
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 marginsChangedNotify ()
 Calculates left, right margins around color map to report to projection plot. More...
 
void onAxisPropertyChanged (const QString &axisName, const QString &propertyName)
 
void onDataRangeChanged (QCPRange newRange)
 Propagate zmin, zmax back to IntensityDataItem. More...
 
void onIntensityModified ()
 
void onPropertyChanged (const QString &property_name)
 updates color map depending on IntensityDataItem properties More...
 
void onTimeToReplot ()
 Replots ColorMap. More...
 
void onXaxisRangeChanged (QCPRange newRange)
 Propagate xmin, xmax back to IntensityDataItem. More...
 
void onYaxisRangeChanged (QCPRange newRange)
 Propagate ymin, ymax back to IntensityDataItem. More...
 
void replot ()
 Schedule replot for later execution by onTimeReplot() slot. More...
 

Private Member Functions

void initColorMap ()
 creates and initializes the color map More...
 
IntensityDataItemintensityItem ()
 
const IntensityDataItemintensityItem () const
 
void setAxesLabelsFromItem (IntensityDataItem *item)
 Sets X,Y axes labels from item. More...
 
void setAxesRangeConnected (bool isConnected)
 Connects/disconnects signals related to ColorMap's X,Y axes rectangle change. More...
 
void setAxesRangeFromItem (IntensityDataItem *item)
 Sets (xmin,xmax,nbins) and (ymin,ymax,nbins) of ColorMap from intensity item. More...
 
void setAxesZoomFromItem (IntensityDataItem *item)
 Sets zoom range of X,Y axes as in intensity item. More...
 
void setColorMapFromItem (IntensityDataItem *intensityItem)
 Sets initial state of ColorMap to match given intensity item. More...
 
void setColorScaleAppearanceFromItem (IntensityDataItem *item)
 Sets the appearance of color scale (visibility, gradient type) from intensity item. More...
 
void setColorScaleVisible (bool visibility_flag)
 
void setConnected (bool isConnected)
 
void setDataFromItem (IntensityDataItem *item)
 Sets the intensity values to ColorMap. More...
 
void setDataRangeConnected (bool isConnected)
 Connects/disconnects signals related to ColorMap's Z-axis (min,max) change. More...
 
void setDataRangeFromItem (IntensityDataItem *item)
 
void setFixedColorMapMargins ()
 to make fixed margins for whole colormap (change in axes labels wont affect axes rectangle) More...
 
void setUpdateTimerConnected (bool isConnected)
 

Private Attributes

bool m_block_update
 
QCPLayoutGrid * m_colorBarLayout
 
QCPColorMap * m_colorMap
 
QCPColorScale * m_colorScale
 
QCustomPlot * m_customPlot
 
ScientificPlotEventm_event
 
SessionItemControllerm_itemController
 
PLOT_TYPE m_plot_type
 
UpdateTimerm_updateTimer
 

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

◆ ColorMap()

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

Definition at line 31 of file ColorMap.cpp.

33  , m_customPlot(new QCustomPlot)
34  , m_colorMap(nullptr)
35  , m_colorScale(nullptr)
36  , m_updateTimer(new UpdateTimer(replot_update_interval, this))
37  , m_colorBarLayout(new QCPLayoutGrid)
38  , m_block_update(true)
39 {
40  initColorMap();
41 
42  auto* vlayout = new QVBoxLayout(this);
43  vlayout->setMargin(0);
44  vlayout->setSpacing(0);
45  vlayout->addWidget(m_customPlot);
46  m_customPlot->setAttribute(Qt::WA_NoMousePropagation, false);
47  setLayout(vlayout);
48 
50  // setFixedColorMapMargins();
51 }
QCPColorMap * m_colorMap
Definition: ColorMap.h:101
UpdateTimer * m_updateTimer
Definition: ColorMap.h:103
QCPLayoutGrid * m_colorBarLayout
Definition: ColorMap.h:104
bool m_block_update
Definition: ColorMap.h:106
void initColorMap()
creates and initializes the color map
Definition: ColorMap.cpp:233
QCPColorScale * m_colorScale
Definition: ColorMap.h:102
QCustomPlot * m_customPlot
Definition: ColorMap.h:100
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

References initColorMap(), m_customPlot, 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(), SpecularPlot::eventInfo(), and eventInfo().

Here is the call graph for this function:

◆ colorScale()

QCPColorScale* ColorMap::colorScale ( )
inline

Definition at line 47 of file ColorMap.h.

47 { return m_colorScale; }

References m_colorScale.

Referenced by FontScalingEvent::setTickLabelFont().

◆ 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* ColorMap::customPlot ( ) const
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 46 of file ColorMap.h.

46 { return m_customPlot; }

References m_customPlot.

◆ customPlot() [2/2]

QCustomPlot* ColorMap::customPlot ( )
inlineoverridevirtual

Implements ScientificPlot.

Definition at line 45 of file ColorMap.h.

45 { return m_customPlot; }

References m_customPlot.

Referenced by ColorMapCanvas::customPlot(), and MaskEditorCanvas::onSavePlotRequest().

◆ eventInfo()

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

Returns PlotEventInfo corresponding to given axes coordinates.

Implements ScientificPlot.

Definition at line 67 of file ColorMap.cpp.

68 {
69  PlotEventInfo result(plotType());
70  if (!intensityItem())
71  return result;
72 
73  int nx(0), ny(0);
74  m_colorMap->data()->coordToCell(xpos, ypos, &nx, &ny);
75 
76  result.setX(xpos);
77  result.setY(ypos);
78  result.setNx(nx);
79  result.setNy(ny);
80 
81  result.setInAxesRange(axesRangeContains(xpos, ypos));
82  result.setValue(m_colorMap->data()->cell(result.nx(), result.ny()));
83  result.setLogValueAxis(intensityItem()->isLogz());
84 
85  return result;
86 }
IntensityDataItem * intensityItem()
Definition: ColorMap.cpp:443
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(), intensityItem(), m_colorMap, PlotEventInfo::nx(), PlotEventInfo::ny(), ScientificPlot::plotType(), PlotEventInfo::setInAxesRange(), PlotEventInfo::setLogValueAxis(), PlotEventInfo::setNx(), PlotEventInfo::setNy(), PlotEventInfo::setValue(), PlotEventInfo::setX(), and PlotEventInfo::setY().

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:

◆ initColorMap()

void ColorMap::initColorMap ( )
private

creates and initializes the color map

Definition at line 233 of file ColorMap.cpp.

234 {
235  m_colorMap = new QCPColorMap(m_customPlot->xAxis, m_customPlot->yAxis);
236  m_colorScale = new QCPColorScale(m_customPlot);
237  m_colorMap->setColorScale(m_colorScale);
238 
239  m_colorBarLayout->addElement(0, 0, m_colorScale);
240  m_colorBarLayout->setMinimumSize(colorbar_width_logz, 10);
241  auto base_size = GUI::Util::Style::SizeOfLetterM(this).width() * 0.5;
242  m_colorBarLayout->setMargins(QMargins(base_size, 0, base_size, 0));
243 
244  m_colorScale->axis()->axisRect()->setMargins(QMargins(0, 0, 0, 0));
245  m_colorScale->axis()->axisRect()->setAutoMargins(QCP::msNone);
246 
248  m_colorScale->axis()->setTickLabelFont(
249  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
250  m_customPlot->xAxis->setTickLabelFont(
251  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
252  m_customPlot->yAxis->setTickLabelFont(
253  QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
254 
255  connect(m_customPlot, &QCustomPlot::afterReplot, this, &ColorMap::marginsChangedNotify);
256 }
void marginsChangedNotify()
Calculates left, right margins around color map to report to projection plot.
Definition: ColorMap.cpp:428
int plot_tick_label_size()
Definition: PlotConstants.h:23
int plot_colorbar_size()
Definition: PlotConstants.h:33
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Definition: StyleUtils.cpp:113

References m_colorBarLayout, m_colorMap, m_colorScale, m_customPlot, marginsChangedNotify(), GUI::Constants::plot_colorbar_size(), GUI::Constants::plot_tick_label_size(), and GUI::Util::Style::SizeOfLetterM().

Referenced by ColorMap().

Here is the call graph for this function:

◆ intensityItem() [1/2]

IntensityDataItem * ColorMap::intensityItem ( )
private

Definition at line 443 of file ColorMap.cpp.

444 {
445  return const_cast<IntensityDataItem*>(static_cast<const ColorMap*>(this)->intensityItem());
446 }
The ColorMap class presents 2D intensity data from IntensityDataItem as color map.
Definition: ColorMap.h:36

Referenced by eventInfo(), onAxisPropertyChanged(), onDataRangeChanged(), onIntensityModified(), onPropertyChanged(), onXaxisRangeChanged(), onYaxisRangeChanged(), resetView(), setColorMapFromItem(), setColorScaleAppearanceFromItem(), and subscribeToItem().

◆ intensityItem() [2/2]

const IntensityDataItem * ColorMap::intensityItem ( ) const
private

Definition at line 448 of file ColorMap.cpp.

449 {
450  return dynamic_cast<const IntensityDataItem*>(currentItem());
451 }

References SessionItemWidget::currentItem().

Here is the call graph for this function:

◆ marginsChanged

void ColorMap::marginsChanged ( double  left,
double  right 
)
signal

◆ marginsChangedNotify

void ColorMap::marginsChangedNotify ( )
privateslot

Calculates left, right margins around color map to report to projection plot.

Definition at line 428 of file ColorMap.cpp.

429 {
430  QMargins axesMargins = m_customPlot->axisRect()->margins();
431  // QMargins colorBarMargins = m_colorScale->margins();
432  // QMargins colorScaleMargins = m_colorScale->axis()->axisRect()->margins();
433 
434  double left = axesMargins.left();
435  // double right = axesMargins.right() + colorBarMargins.right() + m_colorScale->barWidth()
436  // + colorScaleMargins.right() + m_colorBarLayout->rect().width();
437 
438  double right = axesMargins.right() + m_colorBarLayout->rect().width();
439 
440  emit marginsChanged(left, right);
441 }
void marginsChanged(double left, double right)

References m_colorBarLayout, m_customPlot, and marginsChanged().

Referenced by initColorMap().

◆ minimumSizeHint()

QSize ColorMap::minimumSizeHint ( ) const
inlineoverride

Definition at line 43 of file ColorMap.h.

43 { return QSize(128, 128); }

◆ onAxisPropertyChanged

void ColorMap::onAxisPropertyChanged ( const QString &  axisName,
const QString &  propertyName 
)
privateslot

Definition at line 126 of file ColorMap.cpp.

127 {
128  if (m_block_update)
129  return;
130 
131  if (BasicAxisItem::isTitlePropertyName(propertyName)
134  replot();
135  }
136 
138  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
139  setAxesRangeConnected(false);
141  setAxesRangeConnected(true);
142  replot();
143  }
144  } else if (IntensityDataItem::isYaxisPropertyName(axisName)) {
145  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
146  setAxesRangeConnected(false);
148  setAxesRangeConnected(true);
149  replot();
150  }
151  }
152 
153  else if (IntensityDataItem::isZaxisPropertyName(axisName)) {
154  if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
156  replot();
157  } else if (AmplitudeAxisItem::isLogScalePropertyName(propertyName)) {
158  setLogz(intensityItem()->isLogz());
159  replot();
160  } else if (BasicAxisItem::isVisibilityPropertyName(propertyName)) {
161  setColorScaleVisible(intensityItem()->zAxisItem()->visibilityValue());
162  replot();
163  }
164  }
165 }
static bool isLogScalePropertyName(const QString &name)
Definition: AxesItems.cpp:193
static bool isVisibilityPropertyName(const QString &name)
Definition: AxesItems.cpp:131
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
void replot()
Schedule replot for later execution by onTimeReplot() slot.
Definition: ColorMap.cpp:195
void setAxesRangeConnected(bool isConnected)
Connects/disconnects signals related to ColorMap's X,Y axes rectangle change.
Definition: ColorMap.cpp:267
void setAxesLabelsFromItem(IntensityDataItem *item)
Sets X,Y axes labels from item.
Definition: ColorMap.cpp:357
void setDataRangeFromItem(IntensityDataItem *item)
Definition: ColorMap.cpp:405
void setLogz(bool logz)
sets logarithmic scale
Definition: ColorMap.cpp:89
void setColorScaleVisible(bool visibility_flag)
Definition: ColorMap.cpp:413
static bool isXaxisPropertyName(const QString &name)
static bool isZaxisPropertyName(const QString &name)
static bool isYaxisPropertyName(const QString &name)
QCPRange itemZoomY(const IntensityDataItem *item)
Returns y-axis vizible range (zoom).
Definition: RangeUtils.cpp:94
QCPRange itemZoomX(const IntensityDataItem *item)
Returns x-axis vizible range (zoom).
Definition: RangeUtils.cpp:84

References intensityItem(), BasicAxisItem::isBoundsPropertiesName(), AmplitudeAxisItem::isLogScalePropertyName(), BasicAxisItem::isTitlePropertyName(), BasicAxisItem::isTitleVisiblePropertyName(), BasicAxisItem::isVisibilityPropertyName(), IntensityDataItem::isXaxisPropertyName(), IntensityDataItem::isYaxisPropertyName(), IntensityDataItem::isZaxisPropertyName(), GUI::View::RangeUtils::itemZoomX(), GUI::View::RangeUtils::itemZoomY(), m_block_update, m_customPlot, replot(), setAxesLabelsFromItem(), setAxesRangeConnected(), setColorScaleVisible(), setDataRangeFromItem(), and setLogz().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onDataRangeChanged

void ColorMap::onDataRangeChanged ( QCPRange  newRange)
privateslot

Propagate zmin, zmax back to IntensityDataItem.

Definition at line 168 of file ColorMap.cpp.

169 {
170  m_block_update = true;
171  intensityItem()->setLowerAndUpperZ(newRange.lower, newRange.upper);
172  m_block_update = false;
173 }
void setLowerAndUpperZ(double zmin, double zmax)

References intensityItem(), m_block_update, and IntensityDataItem::setLowerAndUpperZ().

Referenced by setDataRangeConnected().

Here is the call graph for this function:

◆ onIntensityModified

void ColorMap::onIntensityModified ( )
privateslot

Definition at line 101 of file ColorMap.cpp.

102 {
105  replot();
106 }
void setAxesRangeFromItem(IntensityDataItem *item)
Sets (xmin,xmax,nbins) and (ymin,ymax,nbins) of ColorMap from intensity item.
Definition: ColorMap.cpp:336
void setDataFromItem(IntensityDataItem *item)
Sets the intensity values to ColorMap.
Definition: ColorMap.cpp:376

References intensityItem(), replot(), setAxesRangeFromItem(), and setDataFromItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onPropertyChanged

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

updates color map depending on IntensityDataItem properties

Definition at line 109 of file ColorMap.cpp.

110 {
111  if (m_block_update)
112  return;
113 
114  if (IntensityDataItem::isGradientPropertyName(property_name)) {
116  replot();
117  } else if (IntensityDataItem::isInterpolatedPropertyName(property_name)) {
118  m_colorMap->setInterpolate(intensityItem()->isInterpolated());
119  replot();
120  } else if (DataItem::isAxesUnitsPropertyName(property_name)) {
122  replot();
123  }
124 }
static bool isAxesUnitsPropertyName(const QString &name)
Definition: DataItem.cpp:113
static bool isInterpolatedPropertyName(const QString &name)
static bool isGradientPropertyName(const QString &name)
QCPColorGradient itemGradient(const IntensityDataItem *item)
Definition: RangeUtils.cpp:74

References intensityItem(), DataItem::isAxesUnitsPropertyName(), IntensityDataItem::isGradientPropertyName(), IntensityDataItem::isInterpolatedPropertyName(), GUI::View::RangeUtils::itemGradient(), m_block_update, m_colorMap, replot(), and setAxesRangeFromItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ onTimeToReplot

void ColorMap::onTimeToReplot ( )
privateslot

Replots ColorMap.

Definition at line 202 of file ColorMap.cpp.

203 {
204  m_customPlot->replot();
205 }

References m_customPlot.

Referenced by setUpdateTimerConnected().

◆ onXaxisRangeChanged

void ColorMap::onXaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate xmin, xmax back to IntensityDataItem.

Definition at line 176 of file ColorMap.cpp.

177 {
178  m_block_update = true;
179  intensityItem()->setLowerX(newRange.lower);
180  intensityItem()->setUpperX(newRange.upper);
181  m_block_update = false;
182 }
void setLowerX(double value)
void setUpperX(double value)

References intensityItem(), m_block_update, IntensityDataItem::setLowerX(), and IntensityDataItem::setUpperX().

Referenced by setAxesRangeConnected().

Here is the call graph for this function:

◆ onYaxisRangeChanged

void ColorMap::onYaxisRangeChanged ( QCPRange  newRange)
privateslot

Propagate ymin, ymax back to IntensityDataItem.

Definition at line 185 of file ColorMap.cpp.

186 {
187  m_block_update = true;
188  intensityItem()->setLowerY(newRange.lower);
189  intensityItem()->setUpperY(newRange.upper);
190  m_block_update = false;
191 }
void setLowerY(double value)
void setUpperY(double value)

References intensityItem(), m_block_update, IntensityDataItem::setLowerY(), and IntensityDataItem::setUpperY().

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

◆ replot

void ColorMap::replot ( )
privateslot

Schedule replot for later execution by onTimeReplot() slot.

Definition at line 195 of file ColorMap.cpp.

196 {
198 }
void scheduleUpdate()
Definition: UpdateTimer.cpp:42

References m_updateTimer, and UpdateTimer::scheduleUpdate().

Referenced by onAxisPropertyChanged(), onIntensityModified(), onPropertyChanged(), and setColorMapFromItem().

Here is the call graph for this function:

◆ resetView

void ColorMap::resetView ( )
slot

reset all axes min,max to initial value

Definition at line 96 of file ColorMap.cpp.

97 {
99 }
void resetView()
Set axes viewport to original data.

References intensityItem(), and IntensityDataItem::resetView().

Here is the call graph for this function:

◆ setAxesLabelsFromItem()

void ColorMap::setAxesLabelsFromItem ( IntensityDataItem item)
private

Sets X,Y axes labels from item.

Definition at line 357 of file ColorMap.cpp.

358 {
359  auto* xaxis = item->xAxisItem();
360  if (xaxis->isTitleVisible())
361  m_customPlot->xAxis->setLabel(item->getXaxisTitle());
362  else
363  m_customPlot->xAxis->setLabel(QString());
364 
365  m_colorScale->setMargins(QMargins(0, 0, 0, 0));
366 
367  auto* yaxis = item->yAxisItem();
368  if (yaxis->isTitleVisible())
369  m_customPlot->yAxis->setLabel(item->getYaxisTitle());
370  else
371  m_customPlot->yAxis->setLabel(QString());
372 }
QString getXaxisTitle() const
const BasicAxisItem * yAxisItem() const
QString getYaxisTitle() const
const BasicAxisItem * xAxisItem() const

References IntensityDataItem::getXaxisTitle(), IntensityDataItem::getYaxisTitle(), m_colorScale, m_customPlot, IntensityDataItem::xAxisItem(), and IntensityDataItem::yAxisItem().

Referenced by onAxisPropertyChanged(), and setColorMapFromItem().

Here is the call graph for this function:

◆ setAxesRangeConnected()

void ColorMap::setAxesRangeConnected ( bool  isConnected)
private

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

Definition at line 267 of file ColorMap.cpp.

268 {
269  if (isConnected) {
270  connect(m_customPlot->xAxis,
271  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
272  &ColorMap::onXaxisRangeChanged, Qt::UniqueConnection);
273 
274  connect(m_customPlot->yAxis,
275  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
276  &ColorMap::onYaxisRangeChanged, Qt::UniqueConnection);
277  } else {
278  disconnect(m_customPlot->xAxis,
279  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
281 
282  disconnect(m_customPlot->yAxis,
283  static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
285  }
286 }
void onYaxisRangeChanged(QCPRange newRange)
Propagate ymin, ymax back to IntensityDataItem.
Definition: ColorMap.cpp:185
void onXaxisRangeChanged(QCPRange newRange)
Propagate xmin, xmax back to IntensityDataItem.
Definition: ColorMap.cpp:176

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

Referenced by onAxisPropertyChanged(), setAxesZoomFromItem(), and setConnected().

Here is the call graph for this function:

◆ setAxesRangeFromItem()

void ColorMap::setAxesRangeFromItem ( IntensityDataItem item)
private

Sets (xmin,xmax,nbins) and (ymin,ymax,nbins) of ColorMap from intensity item.

Definition at line 336 of file ColorMap.cpp.

337 {
338  m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
339  m_customPlot->axisRect()->setupFullAxesBox(true);
340  m_colorMap->data()->setSize(item->xSize(), item->ySize());
341  m_colorMap->data()->setRange(GUI::View::RangeUtils::itemXrange(item),
343 }
QCPRange itemYrange(const IntensityDataItem *item)
Returns y-axis range.
Definition: RangeUtils.cpp:89
QCPRange itemXrange(const IntensityDataItem *item)
Returns x-axis range.
Definition: RangeUtils.cpp:79

References GUI::View::RangeUtils::itemXrange(), GUI::View::RangeUtils::itemYrange(), m_colorMap, m_customPlot, IntensityDataItem::xSize(), and IntensityDataItem::ySize().

Referenced by onIntensityModified(), onPropertyChanged(), and setColorMapFromItem().

Here is the call graph for this function:

◆ setAxesZoomFromItem()

void ColorMap::setAxesZoomFromItem ( IntensityDataItem item)
private

Sets zoom range of X,Y axes as in intensity item.

Definition at line 347 of file ColorMap.cpp.

348 {
349  setAxesRangeConnected(false);
350  m_customPlot->xAxis->setRange(item->getLowerX(), item->getUpperX());
351  m_customPlot->yAxis->setRange(item->getLowerY(), item->getUpperY());
352  setAxesRangeConnected(true);
353 }
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
double getUpperY() const
double getUpperX() const
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.

References IntensityDataItem::getLowerX(), IntensityDataItem::getLowerY(), IntensityDataItem::getUpperX(), IntensityDataItem::getUpperY(), m_customPlot, and setAxesRangeConnected().

Referenced by setColorMapFromItem().

Here is the call graph for this function:

◆ setColorMapFromItem()

void ColorMap::setColorMapFromItem ( IntensityDataItem intensityItem)
private

Sets initial state of ColorMap to match given intensity item.

Definition at line 316 of file ColorMap.cpp.

317 {
318  ASSERT(intensityItem);
319 
320  m_block_update = true;
321 
328 
329  replot();
330 
331  m_block_update = false;
332 }
void setColorScaleAppearanceFromItem(IntensityDataItem *item)
Sets the appearance of color scale (visibility, gradient type) from intensity item.
Definition: ColorMap.cpp:393
void setAxesZoomFromItem(IntensityDataItem *item)
Sets zoom range of X,Y axes as in intensity item.
Definition: ColorMap.cpp:347

References intensityItem(), m_block_update, replot(), setAxesLabelsFromItem(), setAxesRangeFromItem(), setAxesZoomFromItem(), setColorScaleAppearanceFromItem(), setDataFromItem(), and setDataRangeFromItem().

Referenced by subscribeToItem().

Here is the call graph for this function:

◆ setColorScaleAppearanceFromItem()

void ColorMap::setColorScaleAppearanceFromItem ( IntensityDataItem item)
private

Sets the appearance of color scale (visibility, gradient type) from intensity item.

Definition at line 393 of file ColorMap.cpp.

394 {
397  m_colorMap->setInterpolate(intensityItem()->isInterpolated());
398  // make sure the axis rect and color scale synchronize their bottom and top margins (so they
399  // line up):
400  auto* marginGroup = new QCPMarginGroup(m_customPlot);
401  m_customPlot->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
402  m_colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
403 }
bool visibilityValue() const
Definition: AxesItems.cpp:121
const AmplitudeAxisItem * zAxisItem() const

References intensityItem(), GUI::View::RangeUtils::itemGradient(), m_colorMap, m_colorScale, m_customPlot, setColorScaleVisible(), BasicAxisItem::visibilityValue(), and IntensityDataItem::zAxisItem().

Referenced by setColorMapFromItem().

Here is the call graph for this function:

◆ setColorScaleVisible()

void ColorMap::setColorScaleVisible ( bool  visibility_flag)
private

Definition at line 413 of file ColorMap.cpp.

414 {
415  m_colorBarLayout->setVisible(visibility_flag);
416  if (visibility_flag) {
417  // add it to the right of the main axis rect
418  if (!m_customPlot->plotLayout()->hasElement(0, 1))
419  m_customPlot->plotLayout()->addElement(0, 1, m_colorBarLayout);
420  } else {
421  m_customPlot->plotLayout()->take(m_colorBarLayout);
422  m_customPlot->plotLayout()->simplify();
423  }
424 }

References m_colorBarLayout, and m_customPlot.

Referenced by onAxisPropertyChanged(), and setColorScaleAppearanceFromItem().

◆ setConnected()

void ColorMap::setConnected ( bool  isConnected)
private

Definition at line 258 of file ColorMap.cpp.

259 {
260  setAxesRangeConnected(isConnected);
261  setDataRangeConnected(isConnected);
262  setUpdateTimerConnected(isConnected);
263 }
void setUpdateTimerConnected(bool isConnected)
Definition: ColorMap.cpp:299
void setDataRangeConnected(bool isConnected)
Connects/disconnects signals related to ColorMap's Z-axis (min,max) change.
Definition: ColorMap.cpp:290

References setAxesRangeConnected(), setDataRangeConnected(), and setUpdateTimerConnected().

Referenced by subscribeToItem(), and unsubscribeFromItem().

Here is the call graph for this function:

◆ setDataFromItem()

void ColorMap::setDataFromItem ( IntensityDataItem item)
private

Sets the intensity values to ColorMap.

Definition at line 376 of file ColorMap.cpp.

377 {
378  auto* data = item->getDatafield();
379  if (!data) {
380  m_colorMap->data()->clear();
381  return;
382  }
383 
384  int nx(item->xSize()); // outside of the loop because of slow retrieval
385  int ny(item->ySize());
386  for (int ix = 0; ix < nx; ++ix)
387  for (int iy = 0; iy < ny; ++iy)
388  m_colorMap->data()->setCell(ix, iy, (*data)[iy + ny * ix]);
389 }
Datafield * getDatafield()
Definition: DataItem.h:41

References DataItem::getDatafield(), m_colorMap, IntensityDataItem::xSize(), and IntensityDataItem::ySize().

Referenced by onIntensityModified(), and setColorMapFromItem().

Here is the call graph for this function:

◆ setDataRangeConnected()

void ColorMap::setDataRangeConnected ( bool  isConnected)
private

Connects/disconnects signals related to ColorMap's Z-axis (min,max) change.

Definition at line 290 of file ColorMap.cpp.

291 {
292  if (isConnected)
293  connect(m_colorMap, &QCPColorMap::dataRangeChanged, this, &ColorMap::onDataRangeChanged,
294  Qt::UniqueConnection);
295  else
296  disconnect(m_colorMap, &QCPColorMap::dataRangeChanged, this, &ColorMap::onDataRangeChanged);
297 }
void onDataRangeChanged(QCPRange newRange)
Propagate zmin, zmax back to IntensityDataItem.
Definition: ColorMap.cpp:168

References m_colorMap, and onDataRangeChanged().

Referenced by setConnected(), and setDataRangeFromItem().

Here is the call graph for this function:

◆ setDataRangeFromItem()

void ColorMap::setDataRangeFromItem ( IntensityDataItem item)
private

Definition at line 405 of file ColorMap.cpp.

406 {
407  setDataRangeConnected(false);
408  m_colorMap->setDataRange(GUI::View::RangeUtils::itemDataZoom(item));
409  setLogz(item->isLogz());
410  setDataRangeConnected(true);
411 }
QCPRange itemDataZoom(const IntensityDataItem *item)
Returns z-axis visible range (zoom).
Definition: RangeUtils.cpp:105

References IntensityDataItem::isLogz(), GUI::View::RangeUtils::itemDataZoom(), m_colorMap, setDataRangeConnected(), and setLogz().

Referenced by onAxisPropertyChanged(), and setColorMapFromItem().

Here is the call graph for this function:

◆ setFixedColorMapMargins()

void ColorMap::setFixedColorMapMargins ( )
private

to make fixed margins for whole colormap (change in axes labels wont affect axes rectangle)

Definition at line 309 of file ColorMap.cpp.

310 {
312 }
void setDefaultMargins(QCustomPlot *customPlot)
Sets default margins for axes rectangle plot.
Definition: RangeUtils.cpp:138

References m_customPlot, and GUI::View::RangeUtils::setDefaultMargins().

Here is the call graph for this function:

◆ setItem()

◆ setLogz

void ColorMap::setLogz ( bool  logz)
slot

sets logarithmic scale

Definition at line 89 of file ColorMap.cpp.

90 {
91  m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10);
93 }
void setLogz(QCPColorScale *scale, bool isLogz)
Definition: RangeUtils.cpp:110

References m_colorBarLayout, m_colorScale, and GUI::View::RangeUtils::setLogz().

Referenced by onAxisPropertyChanged(), and setDataRangeFromItem().

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

Here is the call graph for this function:

◆ setUpdateTimerConnected()

void ColorMap::setUpdateTimerConnected ( bool  isConnected)
private

Definition at line 299 of file ColorMap.cpp.

300 {
301  if (isConnected)
303  Qt::UniqueConnection);
304  else
306 }
void onTimeToReplot()
Replots ColorMap.
Definition: ColorMap.cpp:202
void timeToUpdate()

References m_updateTimer, 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 ColorMap::sizeHint ( ) const
inlineoverride

Definition at line 42 of file ColorMap.h.

42 { return QSize(500, 400); }

◆ statusString

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

◆ subscribeToItem()

void ColorMap::subscribeToItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 207 of file ColorMap.cpp.

208 {
210 
212  [this](const QString& name) { onPropertyChanged(name); }, this);
213 
215  [this](SessionItem* item, const QString name) {
216  if (item->modelType() == BasicAxisItem::M_TYPE
217  || item->modelType() == AmplitudeAxisItem::M_TYPE)
219  },
220  this);
221 
222  intensityItem()->mapper()->setOnValueChange([this]() { onIntensityModified(); }, this);
223 
224  setConnected(true);
225 }
static constexpr auto M_TYPE
Definition: AxesItems.h:81
static constexpr auto M_TYPE
Definition: AxesItems.h:35
void setConnected(bool isConnected)
Definition: ColorMap.cpp:258
void setColorMapFromItem(IntensityDataItem *intensityItem)
Sets initial state of ColorMap to match given intensity item.
Definition: ColorMap.cpp:316
void onPropertyChanged(const QString &property_name)
updates color map depending on IntensityDataItem properties
Definition: ColorMap.cpp:109
void onAxisPropertyChanged(const QString &axisName, const QString &propertyName)
Definition: ColorMap.cpp:126
void onIntensityModified()
Definition: ColorMap.cpp:101
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.
QString const & name(EShape k)
Definition: particles.cpp:20

References intensityItem(), SessionItem::itemName(), BasicAxisItem::M_TYPE, AmplitudeAxisItem::M_TYPE, SessionItem::mapper(), SessionItem::modelType(), GUI::RealSpace::Particles::name(), onAxisPropertyChanged(), onIntensityModified(), onPropertyChanged(), setColorMapFromItem(), setConnected(), ModelMapper::setOnChildPropertyChange(), ModelMapper::setOnPropertyChange(), and ModelMapper::setOnValueChange().

Here is the call graph for this function:

◆ unsubscribeFromItem()

void ColorMap::unsubscribeFromItem ( )
overrideprotectedvirtual

Reimplemented from SessionItemWidget.

Definition at line 227 of file ColorMap.cpp.

228 {
229  setConnected(false);
230 }

References setConnected().

Here is the call graph for this function:

◆ viewportRectangleInWidgetCoordinates()

QRectF ColorMap::viewportRectangleInWidgetCoordinates ( )

Returns rectangle representing current axes zoom state in widget coordinates.

Definition at line 53 of file ColorMap.cpp.

54 {
55  QCPRange xrange = m_customPlot->xAxis->range();
56  QCPRange yrange = m_customPlot->yAxis->range();
57  double left = xrange.lower;
58  double right = xrange.upper;
59  double top = yrange.upper;
60  double bottom = yrange.lower;
61 
62  return QRectF(xAxisCoordToPixel(left), yAxisCoordToPixel(top),
63  xAxisCoordToPixel(right) - xAxisCoordToPixel(left),
64  yAxisCoordToPixel(bottom) - yAxisCoordToPixel(top));
65 }
double yAxisCoordToPixel(double axis_coordinate) const
double xAxisCoordToPixel(double axis_coordinate) const
transform axes coordinates to CustomPlot widget coordinates

References m_customPlot, ScientificPlot::xAxisCoordToPixel(), and ScientificPlot::yAxisCoordToPixel().

Referenced by ColorMapSceneAdaptor::eventFilter().

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 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 viewportRectangleInWidgetCoordinates().

Here is the call graph for this function:

Member Data Documentation

◆ m_block_update

bool ColorMap::m_block_update
private

◆ m_colorBarLayout

QCPLayoutGrid* ColorMap::m_colorBarLayout
private

Definition at line 104 of file ColorMap.h.

Referenced by initColorMap(), marginsChangedNotify(), setColorScaleVisible(), and setLogz().

◆ m_colorMap

◆ m_colorScale

QCPColorScale* ColorMap::m_colorScale
private

◆ m_customPlot

◆ 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_updateTimer

UpdateTimer* ColorMap::m_updateTimer
private

Definition at line 103 of file ColorMap.h.

Referenced by replot(), and setUpdateTimerConnected().


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