Removed old sliders from 3DPreview

This commit is contained in:
YuSanka 2018-08-30 15:30:31 +02:00
parent 99aaedffc1
commit 1358c8efd2
5 changed files with 221 additions and 173 deletions

View file

@ -1679,6 +1679,7 @@ void create_double_slider(wxWindow* parent, wxBoxSizer* sizer, wxGLCanvas* canva
sizer->Add(m_slider, 0, wxEXPAND, 0);
m_preview_canvas = canvas;
m_preview_canvas->Bind(wxEVT_KEY_DOWN, update_double_slider_from_canvas);
m_slider->Bind(wxEVT_SCROLL_CHANGED, [parent](wxEvent& event) {
_3DScene::set_toolpaths_range(m_preview_canvas, m_slider->GetLowerValueD() - 1e-6, m_slider->GetHigherValueD() + 1e-6);
@ -1710,7 +1711,9 @@ void set_double_slider_thumbs( const bool force_sliders_full_range,
const std::vector<double> &layers_z,
const double z_low, const double z_high)
{
if (force_sliders_full_range) {
// Force slider full range only when slider is created.
// Support selected diapason on the all next steps
if (/*force_sliders_full_range*/z_high == 0.0) {
m_slider->SetLowerValue(0);
m_slider->SetHigherValue(layers_z.size() - 1);
return;
@ -1748,5 +1751,25 @@ void reset_double_slider()
m_slider->SetLowerValue(0);
}
void update_double_slider_from_canvas(wxKeyEvent& event)
{
if (event.HasModifiers()) {
event.Skip();
return;
}
const auto key = event.GetKeyCode();
if (key == 'U' || key == 'D') {
const int new_pos = key == 'U' ? m_slider->GetHigherValue() + 1 : m_slider->GetHigherValue() - 1;
m_slider->SetHigherValue(new_pos);
if (event.ShiftDown()) m_slider->SetLowerValue(m_slider->GetHigherValue());
}
else if (key == 'S')
m_slider->ChangeOneLayerLock();
else
event.Skip();
}
} //namespace GUI
} //namespace Slic3r

View file

@ -126,6 +126,8 @@ void update_objects_list_extruder_column(int extruders_count);
void create_double_slider(wxWindow* parent, wxBoxSizer* sizer, wxGLCanvas* canvas);
void update_double_slider(bool force_sliders_full_range);
void reset_double_slider();
// update DoubleSlider after keyDown in canvas
void update_double_slider_from_canvas(wxKeyEvent& event);
} //namespace GUI
} //namespace Slic3r

View file

@ -829,7 +829,9 @@ wxSize PrusaDoubleSlider::DoGetBestSize() const
void PrusaDoubleSlider::SetLowerValue(const int lower_val)
{
m_selection = ssLower;
m_lower_value = lower_val;
correct_lower_value();
Refresh();
Update();
@ -840,7 +842,9 @@ void PrusaDoubleSlider::SetLowerValue(const int lower_val)
void PrusaDoubleSlider::SetHigherValue(const int higher_val)
{
m_selection = ssHigher;
m_higher_value = higher_val;
correct_higher_value();
Refresh();
Update();
@ -1193,6 +1197,20 @@ bool PrusaDoubleSlider::is_point_in_rect(const wxPoint& pt, const wxRect& rect)
return false;
}
void PrusaDoubleSlider::ChangeOneLayerLock()
{
m_is_one_layer = !m_is_one_layer;
m_selection == ssLower ? correct_lower_value() : correct_higher_value();
if (!m_selection) m_selection = ssHigher;
Refresh();
Update();
wxCommandEvent e(wxEVT_SCROLL_CHANGED);
e.SetEventObject(this);
ProcessWindowEvent(e);
}
void PrusaDoubleSlider::OnLeftDown(wxMouseEvent& event)
{
this->CaptureMouse();

View file

@ -540,6 +540,7 @@ public:
void SetSliderValues(const std::vector<std::pair<int, double>>& values) {
m_values = values;
}
void ChangeOneLayerLock();
void OnPaint(wxPaintEvent& ){ render();}
void OnLeftDown(wxMouseEvent& event);