22 #include <qcustomplot.h>
67 for (
auto graph_item : viewport->graphItems()) {
68 auto controller = std::make_unique<GraphPlotController>(
custom_plot);
69 controller->setItem(graph_item);
72 viewport->setViewportToContent();
81 if (controller->currentItem() == added_child)
82 throw std::runtime_error(
"Attempt to create second controller");
84 auto controller = std::make_unique<GraphPlotController>(
custom_plot);
85 controller->setItem(added_child);
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;
111 p_impl->add_controller_for_item(parent, tagrow);
116 p_impl->remove_controller_for_item(parent, tagrow);
120 p_impl->setup_components();
One-dimensional graph representation of Data1DItem.
2D viewport specialized for showing multiple GraphItem's.
Establishes communications and mutual updates for GraphViewportItem and QCutomPlot.
GraphViewportPlotController(QCustomPlot *plot)
void subscribe() override
~GraphViewportPlotController() override
std::unique_ptr< GraphViewportPlotControllerImpl > p_impl
void setOnItemInserted(Callbacks::item_tagrow_t f)
Sets callback to be notified on child insertion.
void setOnAboutToRemoveItem(Callbacks::item_tagrow_t f)
The main object representing an editable/displayable/serializable entity.
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.
Aggregate to hold (tag, row) information for SessionModel.
materialitems.h Collection of materials to populate MaterialModel.
void remove_controller_for_item(SessionItem *parent, const TagRow &tagrow)
Remove GraphPlotController corresponding to GraphItem.
void setup_components()
Setup controller components.
GraphViewportItem * viewport_item()
void create_axis_controllers()
Creates axes controllers.
GraphViewportPlotController * master
void add_controller_for_item(SessionItem *parent, const TagRow &tagrow)
Adds controller for item.
QCustomPlot * custom_plot
std::unique_ptr< ViewportAxisPlotController > xAxisController
void create_graph_controllers()
Run through all GraphItem's and create graph controllers for QCustomPlot.
std::unique_ptr< ViewportAxisPlotController > yAxisController
GraphViewportPlotControllerImpl(GraphViewportPlotController *master, QCustomPlot *plot)
std::list< std::unique_ptr< GraphPlotController > > graph_controllers