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

Public Member Functions

 GraphViewportPlotControllerImpl (GraphViewportPlotController *master, QCustomPlot *plot)
 
void add_controller_for_item (SessionItem *parent, const TagRow &tagrow)
 Adds controller for item. More...
 
void create_axis_controllers ()
 Creates axes controllers. More...
 
void create_graph_controllers ()
 Run through all GraphItem's and create graph controllers for QCustomPlot. More...
 
void remove_controller_for_item (SessionItem *parent, const TagRow &tagrow)
 Remove GraphPlotController corresponding to GraphItem. More...
 
void setup_components ()
 Setup controller components. More...
 
GraphViewportItemviewport_item ()
 

Public Attributes

QCustomPlot * custom_plot {nullptr}
 
std::list< std::unique_ptr< GraphPlotController > > graph_controllers
 
GraphViewportPlotControllermaster {nullptr}
 
std::unique_ptr< ViewportAxisPlotControllerxAxisController
 
std::unique_ptr< ViewportAxisPlotControlleryAxisController
 

Detailed Description

Definition at line 27 of file graphviewportplotcontroller.cpp.

Constructor & Destructor Documentation

◆ GraphViewportPlotControllerImpl()

ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::GraphViewportPlotControllerImpl ( GraphViewportPlotController master,
QCustomPlot *  plot 
)
inline

Member Function Documentation

◆ add_controller_for_item()

void ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::add_controller_for_item ( SessionItem parent,
const TagRow tagrow 
)
inline

Adds controller for item.

Definition at line 76 of file graphviewportplotcontroller.cpp.

77  {
78  auto added_child = dynamic_cast<GraphItem*>(parent->getItem(tagrow.tag, tagrow.row));
79 
80  for (auto& controller : graph_controllers)
81  if (controller->currentItem() == added_child)
82  throw std::runtime_error("Attempt to create second controller");
83 
84  auto controller = std::make_unique<GraphPlotController>(custom_plot);
85  controller->setItem(added_child);
86  graph_controllers.push_back(std::move(controller));
87  custom_plot->replot();
88  }
One-dimensional graph representation of Data1DItem.
Definition: graphitem.h:29
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.
std::string tag
Definition: tagrow.h:27

References ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::custom_plot, ModelView::SessionItem::getItem(), ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::graph_controllers, ModelView::TagRow::row, and ModelView::TagRow::tag.

Here is the call graph for this function:

◆ create_axis_controllers()

void ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::create_axis_controllers ( )
inline

Creates axes controllers.

Definition at line 50 of file graphviewportplotcontroller.cpp.

51  {
52  auto viewport = viewport_item();
53 
54  xAxisController = std::make_unique<ViewportAxisPlotController>(custom_plot->xAxis);
55  xAxisController->setItem(viewport->xAxis());
56 
57  yAxisController = std::make_unique<ViewportAxisPlotController>(custom_plot->yAxis);
58  yAxisController->setItem(viewport->yAxis());
59  }

References ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::custom_plot, ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::viewport_item(), ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::xAxisController, and ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::yAxisController.

Referenced by ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::setup_components().

Here is the call graph for this function:

◆ create_graph_controllers()

void ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::create_graph_controllers ( )
inline

Run through all GraphItem's and create graph controllers for QCustomPlot.

Definition at line 63 of file graphviewportplotcontroller.cpp.

64  {
65  graph_controllers.clear();
66  auto viewport = viewport_item();
67  for (auto graph_item : viewport->graphItems()) {
68  auto controller = std::make_unique<GraphPlotController>(custom_plot);
69  controller->setItem(graph_item);
70  graph_controllers.push_back(std::move(controller));
71  }
72  viewport->setViewportToContent();
73  }

References ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::custom_plot, ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::graph_controllers, and ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::viewport_item().

Referenced by ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::setup_components().

Here is the call graph for this function:

◆ remove_controller_for_item()

void ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::remove_controller_for_item ( SessionItem parent,
const TagRow tagrow 
)
inline

Remove GraphPlotController corresponding to GraphItem.

Definition at line 92 of file graphviewportplotcontroller.cpp.

93  {
94  auto child_about_to_be_removed = parent->getItem(tagrow.tag, tagrow.row);
95  auto if_func = [&](const std::unique_ptr<GraphPlotController>& cntrl) -> bool {
96  return cntrl->currentItem() == child_about_to_be_removed;
97  };
98  graph_controllers.remove_if(if_func);
99  custom_plot->replot();
100  }

References ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::custom_plot, ModelView::SessionItem::getItem(), ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::graph_controllers, ModelView::TagRow::row, and ModelView::TagRow::tag.

Here is the call graph for this function:

◆ setup_components()

void ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::setup_components ( )
inline

Setup controller components.

Definition at line 42 of file graphviewportplotcontroller.cpp.

43  {
46  }
void create_graph_controllers()
Run through all GraphItem's and create graph controllers for QCustomPlot.

References ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::create_axis_controllers(), and ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::create_graph_controllers().

Here is the call graph for this function:

◆ viewport_item()

GraphViewportItem* ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::viewport_item ( )
inline

Member Data Documentation

◆ custom_plot

◆ graph_controllers

◆ master

GraphViewportPlotController* ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::master {nullptr}

◆ xAxisController

std::unique_ptr<ViewportAxisPlotController> ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::xAxisController

◆ yAxisController

std::unique_ptr<ViewportAxisPlotController> ModelView::GraphViewportPlotController::GraphViewportPlotControllerImpl::yAxisController

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