From 56fef5302cd8cdf7e2b3c1f9190887ac909d27c1 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 27 Mar 2018 14:42:47 +0200 Subject: [PATCH] Added axis-labels to RammingChart --- xs/src/slic3r/GUI/RammingChart.cpp | 23 ++++++++++++++++++----- xs/src/slic3r/GUI/RammingChart.hpp | 2 +- xs/src/slic3r/GUI/WipeTowerDialog.cpp | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/xs/src/slic3r/GUI/RammingChart.cpp b/xs/src/slic3r/GUI/RammingChart.cpp index e07b95839..79a701847 100644 --- a/xs/src/slic3r/GUI/RammingChart.cpp +++ b/xs/src/slic3r/GUI/RammingChart.cpp @@ -2,6 +2,12 @@ #include "RammingChart.hpp" +//! macro used to mark string used at localization, +//! return same string +#define L(s) s + + + wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent); @@ -43,9 +49,9 @@ void Chart::draw(wxDC& dc) { // draw x-axis: float last_mark = -10000; - for (float math_x=int(visible_area.m_x*10)/10 ; math_x <= (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) { + for (float math_x=int(visible_area.m_x*10)/10 ; math_x < (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) { int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x; - int y = m_rect.GetBottom(); + int y = m_rect.GetBottom(); if (x-last_mark < 50) continue; dc.DrawLine(x,y+3,x,y-3); dc.DrawText(wxString().Format(wxT("%.1f"), math_x),wxPoint(x-10,y+7)); @@ -54,7 +60,7 @@ void Chart::draw(wxDC& dc) { // draw y-axis: last_mark=10000; - for (int math_y=visible_area.m_y ; math_y <= (visible_area.m_y+visible_area.m_height) ; math_y+=1) { + for (int math_y=visible_area.m_y ; math_y < (visible_area.m_y+visible_area.m_height) ; math_y+=1) { int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y; int x = m_rect.GetLeft(); if (last_mark-y < 50) continue; @@ -63,8 +69,15 @@ void Chart::draw(wxDC& dc) { last_mark = y; } - - + // axis labels: + wxString label = L("Time (s)"); + int text_width = 0; + int text_height = 0; + dc.GetTextExtent(label,&text_width,&text_height); + dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+25)); + label = L("Volumetric speed (mm\u00B3/s)"); + dc.GetTextExtent(label,&text_width,&text_height); + dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90); } void Chart::mouse_right_button_clicked(wxMouseEvent& event) { diff --git a/xs/src/slic3r/GUI/RammingChart.hpp b/xs/src/slic3r/GUI/RammingChart.hpp index 5ec8b33ee..aa1e7acc7 100644 --- a/xs/src/slic3r/GUI/RammingChart.hpp +++ b/xs/src/slic3r/GUI/RammingChart.hpp @@ -16,7 +16,7 @@ public: Chart(wxWindow* parent, wxRect rect,const std::vector>& initial_buttons,int ramming_speed_size, float sampling) : wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()) { - m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30)); + m_rect = wxRect(wxPoint(50,0),rect.GetSize()-wxSize(50,50)); visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.); m_buttons.clear(); if (initial_buttons.size()>0) diff --git a/xs/src/slic3r/GUI/WipeTowerDialog.cpp b/xs/src/slic3r/GUI/WipeTowerDialog.cpp index 1989a82f1..255c0d6bd 100644 --- a/xs/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/xs/src/slic3r/GUI/WipeTowerDialog.cpp @@ -38,7 +38,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters) RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters) -: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED) +: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,400),wxBORDER_RAISED) { new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT); m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5);