BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::CustomPlotSceneAdapter Class Reference

Converts QGraphicsScene coordinates in the coordinates of local system of QCustomPlot and vice versa. More...

Inheritance diagram for ModelView::CustomPlotSceneAdapter:
[legend]
Collaboration diagram for ModelView::CustomPlotSceneAdapter:
[legend]

Classes

struct  CustomPlotSceneAdapterImpl
 

Public Member Functions

 CustomPlotSceneAdapter (QCustomPlot *custom_plot)
 
 ~CustomPlotSceneAdapter () override
 
double fromSceneX (double scene_x) const override
 convert scene x-coordinate to local axis coordinate More...
 
double fromSceneY (double scene_y) const override
 convert scene y-coordinate to local axis coordinate More...
 
double toSceneX (double customplot_x) const override
 convert local x-coordinate to scene coordinate More...
 
double toSceneY (double customplot_y) const override
 convert local y-coordinate to scene coordinate More...
 
QRectF viewportRectangle () const override
 returns viewport rectangle in scene coordinates More...
 

Private Attributes

std::unique_ptr< CustomPlotSceneAdapterImplp_impl
 

Detailed Description

Converts QGraphicsScene coordinates in the coordinates of local system of QCustomPlot and vice versa.

Definition at line 28 of file customplotsceneadapter.h.

Constructor & Destructor Documentation

◆ CustomPlotSceneAdapter()

CustomPlotSceneAdapter::CustomPlotSceneAdapter ( QCustomPlot *  custom_plot)
explicit

Definition at line 63 of file customplotsceneadapter.cpp.

64  : p_impl(std::make_unique<CustomPlotSceneAdapterImpl>(custom_plot))
65 {
66  auto on_customplot_destroy = [this]() { p_impl->custom_plot = nullptr; };
67  *p_impl->conn_to_customplot =
68  QObject::connect(custom_plot, &QCustomPlot::destroyed, on_customplot_destroy);
69 }
std::unique_ptr< CustomPlotSceneAdapterImpl > p_impl

References p_impl.

◆ ~CustomPlotSceneAdapter()

CustomPlotSceneAdapter::~CustomPlotSceneAdapter ( )
override

Definition at line 71 of file customplotsceneadapter.cpp.

72 {
73  if (p_impl->custom_plot)
74  QObject::disconnect(*p_impl->conn_to_customplot);
75 }

References p_impl.

Member Function Documentation

◆ fromSceneX()

double CustomPlotSceneAdapter::fromSceneX ( double  ) const
overridevirtual

convert scene x-coordinate to local axis coordinate

Implements ModelView::SceneAdapterInterface.

Definition at line 87 of file customplotsceneadapter.cpp.

88 {
89  return p_impl->fromSceneX(scene_x);
90 }

References p_impl.

◆ fromSceneY()

double CustomPlotSceneAdapter::fromSceneY ( double  ) const
overridevirtual

convert scene y-coordinate to local axis coordinate

Implements ModelView::SceneAdapterInterface.

Definition at line 92 of file customplotsceneadapter.cpp.

93 {
94  return p_impl->fromSceneY(scene_y);
95 }

References p_impl.

◆ toSceneX()

double CustomPlotSceneAdapter::toSceneX ( double  ) const
overridevirtual

convert local x-coordinate to scene coordinate

Implements ModelView::SceneAdapterInterface.

Definition at line 77 of file customplotsceneadapter.cpp.

78 {
79  return p_impl->toSceneX(customplot_x);
80 }

References p_impl.

◆ toSceneY()

double CustomPlotSceneAdapter::toSceneY ( double  ) const
overridevirtual

convert local y-coordinate to scene coordinate

Implements ModelView::SceneAdapterInterface.

Definition at line 82 of file customplotsceneadapter.cpp.

83 {
84  return p_impl->toSceneY(customplot_y);
85 }

References p_impl.

◆ viewportRectangle()

QRectF CustomPlotSceneAdapter::viewportRectangle ( ) const
overridevirtual

returns viewport rectangle in scene coordinates

Implements ModelView::SceneAdapterInterface.

Definition at line 97 of file customplotsceneadapter.cpp.

98 {
99  return p_impl->viewportRectangle();
100 }

References p_impl.

Member Data Documentation

◆ p_impl

std::unique_ptr<CustomPlotSceneAdapterImpl> ModelView::CustomPlotSceneAdapter::p_impl
private

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