BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::ColorScalePlotController::ColorScalePlotControllerImpl Struct Reference
Collaboration diagram for ModelView::ColorScalePlotController::ColorScalePlotControllerImpl:
[legend]

Public Member Functions

 ColorScalePlotControllerImpl (ColorScalePlotController *controller, QCPColorScale *color_scale)
 
QCustomPlot * customPlot ()
 
void hide_colorscale ()
 
void setup_components ()
 
void setup_margins ()
 Setup margins of color scale to match top/bottom margins of axis rectangle. More...
 
void show_colorscale ()
 
void update_log_scale ()
 Updates color scale for log10. More...
 

Public Attributes

std::unique_ptr< ViewportAxisPlotControlleraxisController
 
QCPColorScale * color_scale {nullptr}
 
ColorScalePlotControllercontroller {nullptr}
 
QCPLayoutGrid * layout_grid {new QCPLayoutGrid}
 
QCPMarginGroup * margin_group {nullptr}
 

Detailed Description

Definition at line 23 of file colorscaleplotcontroller.cpp.

Constructor & Destructor Documentation

◆ ColorScalePlotControllerImpl()

ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::ColorScalePlotControllerImpl ( ColorScalePlotController controller,
QCPColorScale *  color_scale 
)
inline

Definition at line 31 of file colorscaleplotcontroller.cpp.

33  {
34  if (!color_scale)
35  throw std::runtime_error("ColorScalePlotController: axis is not initialized.");
36 
37  axisController = std::make_unique<ViewportAxisPlotController>(color_scale->axis());
38  }

References ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::axisController, and ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::color_scale.

Member Function Documentation

◆ customPlot()

◆ hide_colorscale()

void ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::hide_colorscale ( )
inline

Definition at line 65 of file colorscaleplotcontroller.cpp.

66  {
67  layout_grid->setVisible(false);
68  customPlot()->plotLayout()->take(layout_grid);
69  customPlot()->plotLayout()->simplify();
70  }

References ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::customPlot(), and ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::layout_grid.

Here is the call graph for this function:

◆ setup_components()

void ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::setup_components ( )
inline

◆ setup_margins()

void ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::setup_margins ( )
inline

Setup margins of color scale to match top/bottom margins of axis rectangle.

Definition at line 74 of file colorscaleplotcontroller.cpp.

75  {
76  if (margin_group)
77  return;
78 
79  if (!customPlot()->axisRect())
80  return;
81  margin_group = new QCPMarginGroup(customPlot());
82  customPlot()->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, margin_group);
83  color_scale->setMarginGroup(QCP::msBottom | QCP::msTop, margin_group);
84  }

References ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::color_scale, ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::customPlot(), and ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::margin_group.

Referenced by ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::setup_components().

Here is the call graph for this function:

◆ show_colorscale()

void ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::show_colorscale ( )
inline

Definition at line 56 of file colorscaleplotcontroller.cpp.

57  {
58  if (!layout_grid->hasElement(0, 0))
59  layout_grid->addElement(0, 0, color_scale);
60 
61  layout_grid->setVisible(true);
62  customPlot()->plotLayout()->addElement(0, 1, layout_grid);
63  }

References ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::color_scale, ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::customPlot(), and ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::layout_grid.

Referenced by ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::setup_components().

Here is the call graph for this function:

◆ update_log_scale()

void ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::update_log_scale ( )
inline

Updates color scale for log10.

Definition at line 50 of file colorscaleplotcontroller.cpp.

51  {
52  const bool is_log = controller->currentItem()->is_in_log();
53  color_scale->setDataScaleType(is_log ? QCPAxis::stLogarithmic : QCPAxis::stLinear);
54  }

References ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::color_scale, ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::controller, ModelView::ItemListener< T >::currentItem(), and ModelView::ViewportAxisItem::is_in_log().

Referenced by ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::setup_components().

Here is the call graph for this function:

Member Data Documentation

◆ axisController

◆ color_scale

◆ controller

◆ layout_grid

QCPLayoutGrid* ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::layout_grid {new QCPLayoutGrid}

◆ margin_group

QCPMarginGroup* ModelView::ColorScalePlotController::ColorScalePlotControllerImpl::margin_group {nullptr}

The documentation for this struct was generated from the following file: