OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Chart Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/RammingChart.hpp>

Inheritance diagram for Chart:
Collaboration diagram for Chart:

Classes

class  ButtonToDrag

Public Member Functions

 Chart (wxWindow *parent, wxRect rect, const std::vector< std::pair< float, float > > &initial_buttons, int ramming_speed_size, float sampling, int scale_unit=10)
void set_xy_range (float x, float y)
float get_volume () const
float get_time () const
std::vector< float > get_ramming_speed (float sampling) const
std::vector< std::pair< float, float > > get_buttons () const
void draw ()
void mouse_clicked (wxMouseEvent &event)
void mouse_right_button_clicked (wxMouseEvent &event)
void mouse_moved (wxMouseEvent &event)
void mouse_double_clicked (wxMouseEvent &event)
void mouse_left_window (wxMouseEvent &)
void mouse_released (wxMouseEvent &)
void paint_event (wxPaintEvent &)

Private Member Functions

wxPoint math_to_screen (const wxPoint2DDouble &math) const
wxPoint2DDouble screen_to_math (const wxPoint &screen) const
int which_button_is_clicked (const wxPoint &point) const
void recalculate_line ()
void recalculate_volume ()

Private Attributes

int side = 10
const int scale_unit
int legend_side
wxRect m_rect
wxPoint m_previous_mouse
std::vector< ButtonToDrag > m_buttons
std::vector< int > m_line_to_draw
wxRect2DDouble visible_area
ButtonToDrag * m_dragged = nullptr
float m_total_volume = 0.f
bool m_uniform = false

Static Private Attributes

static const bool fixed_x = true
static const bool splines = true
static const bool manual_points_manipulation = false

Detailed Description

Constructor & Destructor Documentation

◆ Chart()

Chart::Chart ( wxWindow * parent,
wxRect rect,
const std::vector< std::pair< float, float > > & initial_buttons,
int ramming_speed_size,
float sampling,
int scale_unit = 10 )
inline
21 :
22 wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()),
24 {
25 SetBackgroundColour(*wxWHITE);
26 SetBackgroundStyle(wxBG_STYLE_PAINT);
27 m_rect = wxRect(wxPoint(legend_side,0),rect.GetSize()-wxSize(legend_side,legend_side));
28 visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 60.);
29 m_buttons.clear();
30 if (initial_buttons.size()>0)
31 for (const auto& pair : initial_buttons)
32 m_buttons.push_back(wxPoint2DDouble(pair.first,pair.second));
34 }
wxRect m_rect
Definition RammingChart.hpp:115
std::vector< ButtonToDrag > m_buttons
Definition RammingChart.hpp:117
wxRect2DDouble visible_area
Definition RammingChart.hpp:119
const int scale_unit
Definition RammingChart.hpp:67
void recalculate_line()
Definition RammingChart.cpp:211
int legend_side
Definition RammingChart.hpp:68

References legend_side, m_buttons, m_rect, recalculate_line(), scale_unit, and visible_area.

Here is the call graph for this function:

Member Function Documentation

◆ draw()

void Chart::draw ( )
21 {
22 wxAutoBufferedPaintDC dc(this); // unbuffered DC caused flickering on win
23
24 // scaling button and tick line from text size gives better result compared to dc.GetContentScale
25 int text_width, text_height;
26 dc.GetTextExtent("m",&text_width,&text_height);
27 side = text_width;
28 int tick_w = text_width / 2;
29
30 dc.SetBrush(GetBackgroundColour());
31 dc.SetPen(GetBackgroundColour());
32 dc.DrawRectangle(GetClientRect()); // otherwise the background would end up black on windows
33
34 dc.SetPen( wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), 1)); // input box border color
35 dc.SetBrush(wxBrush(StateColor::darkModeColorFor(wxColour("#F1F1F1")))); // sidebar titlebar bg color
36 dc.DrawRectangle(m_rect);
37
38 if (visible_area.m_width < 0.499) {
39 dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#FF6F00"))); // Use orange color for warning
40 dc.DrawText(_(L("NO RAMMING AT ALL")),wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-legend_side,m_rect.GetBottom()-m_rect.GetHeight()/2));
41 return;
42 }
43
44
45 if (!m_line_to_draw.empty()) {
46 for (unsigned int i=0;i<m_line_to_draw.size()-2;++i) {
47 int color = 444*((m_rect.GetBottom()-(m_line_to_draw)[i])/double(m_rect.GetHeight()));
48 dc.SetPen( wxPen( wxColor(std::min(222,color), 222-std::max(color-222,0), 60), 1) ); // adding blue color sligtly gives a bit more modern look instead using raw red & green
49 dc.DrawLine(m_rect.GetLeft()+1+i,(m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom());
50 }
51 dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#363636")), 1));
52 for (unsigned int i=0;i<m_line_to_draw.size()-2;++i) {
53 if (splines)
54 dc.DrawLine(m_rect.GetLeft()+i,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i+1]);
55 else {
56 dc.DrawLine(m_rect.GetLeft()+i,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i]);
57 dc.DrawLine(m_rect.GetLeft()+i+1,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i+1]);
58 }
59 }
60 }
61
62 // draw draggable buttons
63 dc.SetBrush(StateColor::darkModeColorFor(wxColour("#009688"))); // orca color for draggable circles
64 dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#363636")), 1));
65 for (auto& button : m_buttons)
66 //dc.DrawRectangle(math_to_screen(button.get_pos())-wxPoint(side/2.,side/2.), wxSize(side,side));
67 dc.DrawCircle(math_to_screen(button.get_pos()),side/2.);
68 //dc.DrawRectangle(math_to_screen(button.get_pos()-wxPoint2DDouble(0.125,0))-wxPoint(0,5),wxSize(50,10));
69
70 dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#363636"))); // Label color
71
72 // draw x-axis:
73 float last_mark = -10000;
74 for (float math_x=int(visible_area.m_x*10)/10 ; math_x < (visible_area.m_x+visible_area.m_width) ; math_x+=0.1f) {
75 int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x;
76 int y = m_rect.GetBottom();
77 if (x-last_mark < legend_side) continue;
78 dc.DrawLine(x,y+tick_w+1,x,y-tick_w); // +1 for border; make sure drawn on both size
79 auto label = math_x == 0 ? "0" : wxString().Format(wxT("%.1f") , math_x); // prefer "0" to match text with Y "0"
80 dc.GetTextExtent(label,&text_width,&text_height);// center text with lines
81 dc.DrawText(label ,wxPoint(x - text_width * .5, y + .8 * scale_unit));
82 last_mark = x;
83 }
84
85 // draw y-axis:
86 last_mark=10000;
87 for (int math_y=visible_area.m_y ; math_y < (visible_area.m_y+visible_area.m_height) ; math_y+=1) {
88 int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y;
89 int x = m_rect.GetLeft();
90 if (last_mark-y < legend_side) continue;
91 dc.DrawLine(x-tick_w,y,x+tick_w+1,y); // +1 for border; make sure drawn on both size
92 auto label = wxString()<<math_y;
93 dc.GetTextExtent(label,&text_width,&text_height);// center text with lines & make it right aligned
94 dc.DrawText(label ,wxPoint(x - scale_unit - text_width, y - .5 * text_height + 1));
95 last_mark = y;
96 }
97
98 // axis labels:
99 wxString label = _(L("Time")) + " (" + _(L("s")) + ")";
100 dc.GetTextExtent(label,&text_width,&text_height);
101 dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+0.6*legend_side));
102 label = _(L("Volumetric speed")) + " (" + _(L(u8"mm³/s")) + ")";
103 dc.GetTextExtent(label,&text_width,&text_height);
104 dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90);
105
106 // draw a label with the value above each button
107 for (auto& button : m_buttons) {
108 if (!visible_area.Contains(button.get_pos()))
109 continue;
110
111 wxPoint button_screen_pos = math_to_screen(button.get_pos());
112 wxString value_label = wxString().Format(wxT("%.1f"), button.get_pos().m_y);
113
114 int label_width, label_height;
115 dc.GetTextExtent(value_label, &label_width, &label_height);
116
117 const int padding = 4;
118 // Calculate label x position
119 int label_x = button_screen_pos.x - (label_width/2); // centered with button
120 label_x = std::clamp(label_x, m_rect.GetLeft() + (padding*2), m_rect.GetRight() - label_width - (padding*2)); // adjust to fit within chart bounds
121
122 // Calculate label y position
123 int label_y = button_screen_pos.y - (side/2) - label_height - (padding*2); // above button
124 if (label_y - (padding*2) < m_rect.GetTop()) { // move below the button if there isn't enough space
125 label_y = button_screen_pos.y + (side/2) + (padding*2);
126 }
127
128 // Draw label background
129 dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), 1));
130 wxColour bg_color = StateColor::darkModeColorFor(wxColour("#F1F1F1"));
131 dc.SetBrush(wxBrush(wxColour(bg_color.Red(), bg_color.Green(), bg_color.Blue(), 204))); // 80% opacity
132 wxRect label_rect(label_x - padding, label_y - padding, label_width + (2*padding), label_height + (2*padding));
133 dc.DrawRoundedRectangle(label_rect, 2);
134
135 // Draw the label text
136 dc.SetTextForeground(StateColor::darkModeColorFor("#363636"));
137 dc.DrawText(value_label, wxPoint(label_x, label_y));
138 }
139}
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
std::vector< int > m_line_to_draw
Definition RammingChart.hpp:118
wxPoint math_to_screen(const wxPoint2DDouble &math) const
Definition RammingChart.hpp:82
static const bool splines
Definition RammingChart.hpp:63
int side
Definition RammingChart.hpp:65
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
double label_height(double half)
Definition DesignSketchTool.cpp:5480
wxColour bg_color()
Definition SpeedDialDialog.cpp:69
bool button(const IconManager::Icon &activ, const IconManager::Icon &hover, const IconManager::Icon &disable, bool disabled)
Use icon as button with 3 states activ hover and disabled.
Definition IconManager.cpp:418

References _, StateColor::darkModeColorFor(), L, legend_side, m_buttons, m_line_to_draw, m_rect, math_to_screen(), scale_unit, side, splines, and visible_area.

Referenced by paint_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_buttons()

std::vector< std::pair< float, float > > Chart::get_buttons ( ) const
328 {
329 std::vector<std::pair<float, float>> buttons_out;
330 for (const auto& button : m_buttons)
331 buttons_out.push_back(std::make_pair(float(button.get_pos().m_x),float(button.get_pos().m_y)));
332 return buttons_out;
333}

References m_buttons.

◆ get_ramming_speed()

std::vector< float > Chart::get_ramming_speed ( float sampling) const
312 {
313 std::vector<float> speeds_out;
314
315 const int number_of_samples = std::round( visible_area.m_width / sampling);
316 if (number_of_samples>0) {
317 const int dx = (m_line_to_draw.size()-1) / number_of_samples;
318 for (int j=0;j<number_of_samples;++j) {
319 float left = screen_to_math(wxPoint(0,m_line_to_draw[j*dx])).m_y;
320 float right = screen_to_math(wxPoint(0,m_line_to_draw[(j+1)*dx])).m_y;
321 speeds_out.push_back((left+right)/2.f);
322 }
323 }
324 return speeds_out;
325}
wxPoint2DDouble screen_to_math(const wxPoint &screen) const
Definition RammingChart.hpp:90
@ right
Definition MarchingSquares.hpp:190
@ left
Definition MarchingSquares.hpp:188

References m_line_to_draw, screen_to_math(), and visible_area.

Here is the call graph for this function:

◆ get_time()

float Chart::get_time ( ) const
inline
42{ return visible_area.m_width; }

References visible_area.

◆ get_volume()

float Chart::get_volume ( ) const
inline
41{ return m_total_volume; }
float m_total_volume
Definition RammingChart.hpp:121

References m_total_volume.

◆ math_to_screen()

wxPoint Chart::math_to_screen ( const wxPoint2DDouble & math) const
inlineprivate
82 {
83 wxPoint screen;
84 screen.x = (math.m_x-visible_area.m_x) * (m_rect.GetWidth() / visible_area.m_width );
85 screen.y = (math.m_y-visible_area.m_y) * (m_rect.GetHeight() / visible_area.m_height );
86 screen.y *= -1;
87 screen += m_rect.GetLeftBottom();
88 return screen;
89 }

References m_rect, and visible_area.

Referenced by draw(), recalculate_line(), and which_button_is_clicked().

Here is the caller graph for this function:

◆ mouse_clicked()

void Chart::mouse_clicked ( wxMouseEvent & event)
154 {
155 m_uniform = (event.GetModifiers() == wxMOD_CONTROL);
156 wxPoint point = event.GetPosition();
157 int button_index = which_button_is_clicked(point);
158 if ( button_index != -1) {
159 m_dragged = &m_buttons[button_index];
160 m_previous_mouse = point;
161 }
162}
ButtonToDrag * m_dragged
Definition RammingChart.hpp:120
int which_button_is_clicked(const wxPoint &point) const
Definition RammingChart.hpp:99
wxPoint m_previous_mouse
Definition RammingChart.hpp:116
bool m_uniform
Definition RammingChart.hpp:122

References m_buttons, m_dragged, m_previous_mouse, m_uniform, and which_button_is_clicked().

Here is the call graph for this function:

◆ mouse_double_clicked()

void Chart::mouse_double_clicked ( wxMouseEvent & event)
196 {
198 return;
199 wxPoint point = event.GetPosition();
200 if (!m_rect.Contains(point)) // the click is outside the chart
201 return;
202 m_buttons.push_back(screen_to_math(point));
203 std::sort(m_buttons.begin(),m_buttons.end());
205 return;
206}
static const bool manual_points_manipulation
Definition RammingChart.hpp:64

References m_buttons, m_rect, manual_points_manipulation, recalculate_line(), and screen_to_math().

Here is the call graph for this function:

◆ mouse_left_window()

void Chart::mouse_left_window ( wxMouseEvent & )
inline
53{ m_dragged = nullptr; SetCursor(wxNullCursor);}

References m_dragged.

Referenced by mouse_moved().

Here is the caller graph for this function:

◆ mouse_moved()

void Chart::mouse_moved ( wxMouseEvent & event)
166 {
167 wxPoint pos = event.GetPosition();
168 wxRect rect = m_rect;
169 if (!event.Dragging() || !m_dragged){
170 // change cursor while button hovered && drag
171 SetCursor((which_button_is_clicked(pos) != -1) ? wxCursor(wxCURSOR_SIZENS) : wxNullCursor);
172 return;
173 }
174 rect.Deflate(side/2.);
175 if (!(rect.Contains(pos))) { // the mouse left chart area
176 mouse_left_window(event);
177 return;
178 }
179 int delta_x = pos.x - m_previous_mouse.x;
180 int delta_y = pos.y - m_previous_mouse.y;
181
182 double new_y = m_dragged->get_pos().m_y - double(delta_y) / m_rect.GetHeight() * visible_area.m_height;
183
184 if (m_uniform)
185 for (ButtonToDrag& b : m_buttons)
186 b.move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width, new_y - b.get_pos().m_y);
187 else
188 m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width, new_y - m_dragged->get_pos().m_y);
189
192}
Definition RammingChart.hpp:70
void mouse_left_window(wxMouseEvent &)
Definition RammingChart.hpp:53
static const bool fixed_x
Definition RammingChart.hpp:62
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References fixed_x, m_buttons, m_dragged, m_previous_mouse, m_rect, m_uniform, mouse_left_window(), recalculate_line(), side, visible_area, and which_button_is_clicked().

Here is the call graph for this function:

◆ mouse_released()

void Chart::mouse_released ( wxMouseEvent & )
inline
54{ m_dragged = nullptr; SetCursor(wxNullCursor);}

References m_dragged.

◆ mouse_right_button_clicked()

void Chart::mouse_right_button_clicked ( wxMouseEvent & event)
141 {
143 return;
144 wxPoint point = event.GetPosition();
145 int button_index = which_button_is_clicked(point);
146 if (button_index != -1 && m_buttons.size()>2) {
147 m_buttons.erase(m_buttons.begin()+button_index);
149 }
150}

References m_buttons, manual_points_manipulation, recalculate_line(), and which_button_is_clicked().

Here is the call graph for this function:

◆ paint_event()

void Chart::paint_event ( wxPaintEvent & )
inline
55{ draw(); }
void draw()
Definition RammingChart.cpp:21

References draw().

Here is the call graph for this function:

◆ recalculate_line()

void Chart::recalculate_line ( )
private
211 {
212 m_line_to_draw.clear();
213 m_total_volume = 0.f;
214
215 std::vector<wxPoint> points;
216 for (auto& but : m_buttons) {
217 points.push_back(wxPoint(math_to_screen(but.get_pos())));
218 if (points.size()>1 && points.back().x==points[points.size()-2].x) points.pop_back();
219 if (points.size()>1 && points.back().x > m_rect.GetRight()) {
220 points.pop_back();
221 break;
222 }
223 }
224
225 // The calculation wouldn't work in case the ramming is to be turned off completely.
226 if (points.size()>1) {
227 std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; });
228
229 // Cubic spline interpolation: see https://en.wikiversity.org/wiki/Cubic_Spline_Interpolation#Methods
230 const bool boundary_first_derivative = true; // true - first derivative is 0 at the leftmost and rightmost point
231 // false - second ---- || -------
232 const int N = points.size()-1; // last point can be accessed as N, we have N+1 total points
233 std::vector<float> diag(N+1);
234 std::vector<float> mu(N+1);
235 std::vector<float> lambda(N+1);
236 std::vector<float> h(N+1);
237 std::vector<float> rhs(N+1);
238
239 // let's fill in inner equations
240 for (int i=1;i<=N;++i) h[i] = points[i].x-points[i-1].x;
241 std::fill(diag.begin(),diag.end(),2.f);
242 for (int i=1;i<=N-1;++i) {
243 mu[i] = h[i]/(h[i]+h[i+1]);
244 lambda[i] = 1.f - mu[i];
245 rhs[i] = 6 * ( float(points[i+1].y-points[i].y )/(h[i+1]*(points[i+1].x-points[i-1].x)) -
246 float(points[i].y -points[i-1].y)/(h[i] *(points[i+1].x-points[i-1].x)) );
247 }
248
249 // now fill in the first and last equations, according to boundary conditions:
250 if (boundary_first_derivative) {
251 const float endpoints_derivative = 0;
252 lambda[0] = 1;
253 mu[N] = 1;
254 rhs[0] = (6.f/h[1]) * (float(points[0].y-points[1].y)/(points[0].x-points[1].x) - endpoints_derivative);
255 rhs[N] = (6.f/h[N]) * (endpoints_derivative - float(points[N-1].y-points[N].y)/(points[N-1].x-points[N].x));
256 }
257 else {
258 lambda[0] = 0;
259 mu[N] = 0;
260 rhs[0] = 0;
261 rhs[N] = 0;
262 }
263
264 // the trilinear system is ready to be solved:
265 for (int i=1;i<=N;++i) {
266 float multiple = mu[i]/diag[i-1]; // let's subtract proper multiple of above equation
267 diag[i]-= multiple * lambda[i-1];
268 rhs[i] -= multiple * rhs[i-1];
269 }
270 // now the back substitution (vector mu contains invalid values from now on):
271 rhs[N] = rhs[N]/diag[N];
272 for (int i=N-1;i>=0;--i)
273 rhs[i] = (rhs[i]-lambda[i]*rhs[i+1])/diag[i];
274
275 unsigned int i=1;
276 float y=0.f;
277 for (int x=m_rect.GetLeft(); x<=m_rect.GetRight() ; ++x) {
278 if (splines) {
279 if (i<points.size()-1 && points[i].x < x ) {
280 ++i;
281 }
282 if (points[0].x > x)
283 y = points[0].y;
284 else
285 if (points[N].x < x)
286 y = points[N].y;
287 else
288 y = (rhs[i-1]*pow(points[i].x-x,3)+rhs[i]*pow(x-points[i-1].x,3)) / (6*h[i]) +
289 (points[i-1].y-rhs[i-1]*h[i]*h[i]/6.f) * (points[i].x-x)/h[i] +
290 (points[i].y -rhs[i] *h[i]*h[i]/6.f) * (x-points[i-1].x)/h[i];
291 m_line_to_draw.push_back(y);
292 }
293 else {
294 float x_math = screen_to_math(wxPoint(x,0)).m_x;
295 if (i+2<=points.size() && m_buttons[i+1].get_pos().m_x-0.125 < x_math)
296 ++i;
297 m_line_to_draw.push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[i].get_pos().m_y)).y);
298 }
299
300 m_line_to_draw.back() = std::max(m_line_to_draw.back(), m_rect.GetTop()-1);
301 m_line_to_draw.back() = std::min(m_line_to_draw.back(), m_rect.GetBottom()-1);
302 m_total_volume += (m_rect.GetBottom() - m_line_to_draw.back()) * (visible_area.m_width / m_rect.GetWidth()) * (visible_area.m_height / m_rect.GetHeight());
303 }
304 }
305
306 wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED));
307 Refresh();
308}
@ N
Definition CalibrationWizardSavePage.cpp:124

References m_buttons, m_line_to_draw, m_rect, m_total_volume, math_to_screen(), screen_to_math(), splines, and visible_area.

Referenced by Chart(), mouse_double_clicked(), mouse_moved(), mouse_right_button_clicked(), and set_xy_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recalculate_volume()

void Chart::recalculate_volume ( )
private

◆ screen_to_math()

wxPoint2DDouble Chart::screen_to_math ( const wxPoint & screen) const
inlineprivate
90 {
91 wxPoint2DDouble math = screen;
92 math -= m_rect.GetLeftBottom();
93 math.m_y *= -1;
94 math.m_x *= visible_area.m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1]
95 math.m_y *= visible_area.m_height / m_rect.GetHeight();
96 return (math+visible_area.GetLeftTop());
97 }

References m_rect, and visible_area.

Referenced by get_ramming_speed(), mouse_double_clicked(), and recalculate_line().

Here is the caller graph for this function:

◆ set_xy_range()

void Chart::set_xy_range ( float x,
float y )
inline
35 {
36 x = int(x/0.25) * 0.25;
37 if (x>=0) visible_area.SetRight(x);
38 if (y>=0) visible_area.SetBottom(y);
40 }

References recalculate_line(), and visible_area.

Here is the call graph for this function:

◆ which_button_is_clicked()

int Chart::which_button_is_clicked ( const wxPoint & point) const
inlineprivate
99 {
100 if (!m_rect.Contains(point))
101 return -1;
102 for (unsigned int i=0;i<m_buttons.size();++i) {
103 wxRect rect(math_to_screen(m_buttons[i].get_pos())-wxPoint(side/2.,side/2.),wxSize(side,side)); // bounding rectangle of this button
104 if ( rect.Contains(point) )
105 return i;
106 }
107 return (-1);
108 }

References m_buttons, m_rect, math_to_screen(), and side.

Referenced by mouse_clicked(), mouse_moved(), and mouse_right_button_clicked().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fixed_x

const bool Chart::fixed_x = true
staticprivate

Referenced by mouse_moved().

◆ legend_side

int Chart::legend_side
private

Referenced by Chart(), and draw().

◆ m_buttons

◆ m_dragged

ButtonToDrag* Chart::m_dragged = nullptr
private

◆ m_line_to_draw

std::vector<int> Chart::m_line_to_draw
private

◆ m_previous_mouse

wxPoint Chart::m_previous_mouse
private

Referenced by mouse_clicked(), and mouse_moved().

◆ m_rect

◆ m_total_volume

float Chart::m_total_volume = 0.f
private

Referenced by get_volume(), and recalculate_line().

◆ m_uniform

bool Chart::m_uniform = false
private

Referenced by mouse_clicked(), and mouse_moved().

◆ manual_points_manipulation

const bool Chart::manual_points_manipulation = false
staticprivate

◆ scale_unit

const int Chart::scale_unit
private

Referenced by Chart(), and draw().

◆ side

int Chart::side = 10
private

◆ splines

const bool Chart::splines = true
staticprivate

Referenced by draw(), and recalculate_line().

◆ visible_area

wxRect2DDouble Chart::visible_area
private

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