OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::IMSlider Class Reference

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

Collaboration diagram for Slic3r::GUI::IMSlider:

Public Member Functions

 IMSlider (int lowerValue, int higherValue, int minValue, int maxValue, long style=wxSL_VERTICAL)
bool init_texture ()
 ~IMSlider ()
int GetMinValue () const
int GetMaxValue () const
double GetMinValueD ()
double GetMaxValueD ()
int GetLowerValue () const
int GetHigherValue () const
int GetActiveValue () const
double GetLowerValueD ()
double GetHigherValueD ()
SelectedSlider GetSelection ()
void SetLowerValue (const int lower_val)
void SetHigherValue (const int higher_val)
void SetSelectionSpan (const int lower_val, const int higher_val)
void SetMaxValue (const int max_value)
void SetKoefForLabels (const double koef)
void SetSliderValues (const std::vector< double > &values)
void SetSliderAlternateValues (const std::vector< double > &values)
CustomGCode::Info GetTicksValues () const
void SetTicksValues (const CustomGCode::Info &custom_gcode_per_print_z)
void SetLayersTimes (const std::vector< float > &layers_times, float total_time)
void SetLayersTimes (const std::vector< double > &layers_times)
void SetDrawMode (bool is_sequential_print)
void SetDrawMode (DrawMode mode)
void SetExtraStyle (long style)
void SetManipulationMode (CustomGCode::Mode mode)
CustomGCode::Mode GetManipulationMode () const
void SetModeAndOnlyExtruder (const bool is_one_extruder_printed_model, const int only_extruder, bool can_change_color)
void SetExtruderColors (const std::vector< std::string > &extruder_colors)
bool IsNewPrint ()
void set_render_as_disabled (bool value)
bool is_rendering_as_disabled () const
bool is_horizontal () const
bool is_one_layer () const
bool is_lower_at_min () const
bool is_higher_at_max () const
bool is_full_span () const
void UseDefaultColors (bool def_colors_on)
void on_mouse_wheel (wxMouseEvent &evt)
void post_ticks_changed_event (CustomGCode::Type type=CustomGCode::Unknown)
bool check_ticks_changed_event (CustomGCode::Type type)
bool switch_one_layer_mode ()
void show_go_to_layer (bool show)
bool render (int canvas_width, int canvas_height)
bool is_dirty ()
void set_as_dirty (bool dirty=true)
bool is_need_post_tick_event ()
void reset_post_tick_event (bool val=false)
CustomGCode::Type get_post_tick_event_type ()
void set_scale (float scale=1.0)
void on_change_color_mode (bool is_dark)
void set_menu_enable (bool enable=true)

Static Public Member Functions

static float vertical_slider_window_width ()

Public Attributes

float m_scale = 1.0

Protected Member Functions

void add_custom_gcode (std::string custom_gcode)
void add_code_as_tick (CustomGCode::Type type, int selected_extruder=-1)
void delete_tick (const TickCode &tick)
void do_go_to_layer (size_t layer_number)
void correct_lower_value ()
void correct_higher_value ()
bool horizontal_slider (const char *str_id, int *v, int v_min, int v_max, const ImVec2 &size, float scale=1.0)
void render_go_to_layer_dialog ()
void render_input_custom_gcode (std::string custom_gcode="")
void render_menu ()
void render_add_menu ()
void render_edit_menu (const TickCode &tick)
void draw_background_and_groove (const ImRect &bg_rect, const ImRect &groove)
void draw_colored_band (const ImRect &groove, const ImRect &slideable_region)
void draw_custom_label_block (const ImVec2 anchor, CustomGCode::Type type)
void draw_ticks (const ImRect &slideable_region)
void draw_tick_on_mouse_position (const ImRect &slideable_region)
void show_tooltip (const TickCode &tick)
void show_tooltip (const std::string tooltip)
bool vertical_slider (const char *str_id, int *higher_value, int *lower_value, std::string &higher_label, std::string &lower_label, int v_min, int v_max, const ImVec2 &size, SelectedSlider &selection, bool one_layer_flag=false, float scale=1.0f)
bool is_wipe_tower_layer (int tick) const

Private Member Functions

std::string get_label (int tick, LabelType label_type=ltHeightWithLayer)
double get_double_value (const SelectedSlider &selection)
int get_tick_from_value (double value, bool force_lower_bound=false)
float get_pos_from_value (int v_min, int v_max, int value, const ImRect &rect)
int get_tick_near_point (int v_min, int v_max, const ImVec2 &pt, const ImRect &rect)
std::string get_color_for_tool_change_tick (std::set< TickCode >::const_iterator it) const
std::array< int, 2 > get_active_extruders_for_tick (int tick) const

Private Attributes

bool m_is_dark = false
int m_min_value
int m_max_value
int m_lower_value
int m_higher_value
int m_one_layer_value
bool m_dirty = false
bool m_render_as_disabled { false }
SelectedSlider m_selection
bool m_is_one_layer = false
bool m_menu_enable = true
bool m_show_menu = false
bool m_show_custom_gcode_window = false
bool m_show_go_to_layer_dialog = false
bool m_force_mode_apply = true
bool m_is_wipe_tower = false
bool m_is_spiral_vase = false
void * m_one_layer_on_id
void * m_one_layer_on_hover_id
void * m_one_layer_off_id
void * m_one_layer_off_hover_id
void * m_one_layer_on_dark_id
void * m_one_layer_on_hover_dark_id
void * m_one_layer_off_dark_id
void * m_one_layer_off_hover_dark_id
void * m_pause_icon_id
void * m_custom_icon_id
void * m_delete_icon_id
DrawMode m_draw_mode = dmRegular
CustomGCode::Mode m_mode = CustomGCode::SingleExtruder
int m_only_extruder = -1
long m_style
long m_extra_style
float m_label_koef {1.0}
std::vector< double > m_values
TickCodeInfo m_ticks
std::vector< double > m_layers_times
std::vector< double > m_layers_values
std::vector< std::string > m_extruder_colors
bool m_can_change_color
std::string m_print_obj_idxs
bool m_is_need_post_tick_changed_event { false }
CustomGCode::Type m_tick_change_event_type
std::vector< double > m_alternate_values
char m_custom_gcode [1024] = { 0 }
char m_layer_number [64] = { 0 }

Detailed Description

Constructor & Destructor Documentation

◆ IMSlider()

Slic3r::GUI::IMSlider::IMSlider ( int lowerValue,
int higherValue,
int minValue,
int maxValue,
long style = wxSL_VERTICAL )
173{
174 m_lower_value = lowerValue;
175 m_higher_value = higherValue;
176 m_min_value = minValue;
177 m_max_value = maxValue;
178 m_style = style == wxSL_HORIZONTAL || style == wxSL_VERTICAL ? style : wxSL_HORIZONTAL;
179 // BBS set to none style by default
180 m_extra_style = style == wxSL_VERTICAL ? 0 : 0;
183 m_tick_change_event_type = Type::Unknown;
184
185 m_ticks.set_extruder_colors(&m_extruder_colors);
186}
#define style
Definition WipeTowerDialog.cpp:101
int m_lower_value
Definition IMSlider.hpp:188
TickCodeInfo m_ticks
Definition IMSlider.hpp:227
std::vector< std::string > m_extruder_colors
Definition IMSlider.hpp:230
long m_extra_style
Definition IMSlider.hpp:223
SelectedSlider m_selection
Definition IMSlider.hpp:195
bool m_is_need_post_tick_changed_event
Definition IMSlider.hpp:233
int m_min_value
Definition IMSlider.hpp:186
int m_higher_value
Definition IMSlider.hpp:189
long m_style
Definition IMSlider.hpp:222
int m_max_value
Definition IMSlider.hpp:187
CustomGCode::Type m_tick_change_event_type
Definition IMSlider.hpp:234
@ ssHigher
Definition IMSlider.hpp:44

References m_extra_style, m_extruder_colors, m_higher_value, m_is_need_post_tick_changed_event, m_lower_value, m_max_value, m_min_value, m_selection, m_style, m_tick_change_event_type, m_ticks, Slic3r::GUI::ssHigher, and style.

◆ ~IMSlider()

Slic3r::GUI::IMSlider::~IMSlider ( )
inline
69{}

Member Function Documentation

◆ add_code_as_tick()

void Slic3r::GUI::IMSlider::add_code_as_tick ( CustomGCode::Type type,
int selected_extruder = -1 )
protected
425{
426 if (m_selection == ssUndef) return;
427 const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
428
429 if (!check_ticks_changed_event(type)) {
430 BOOST_LOG_TRIVIAL(trace) << "check ticks change event false";
431 return;
432 }
433
434 if (type == ColorChange && gcode(ColorChange).empty()) GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::EmptyColorChangeCode);
435
436 const int extruder = selected_extruder > 0 ? selected_extruder : std::max<int>(1, m_only_extruder);
437 const auto it = m_ticks.ticks.find(TickCode{tick});
438
439 if (it == m_ticks.ticks.end()) {
440 // try to add tick
441 if (!m_ticks.add_tick(tick, type, extruder, m_values[tick])) return;
442 } else if (type == ToolChange || type == ColorChange) {
443 // try to switch tick code to ToolChange or ColorChange accordingly
444 if (!m_ticks.switch_code_for_tick(it, type, extruder)) return;
445 } else
446 return;
447
449}
std::vector< double > m_values
Definition IMSlider.hpp:226
void post_ticks_changed_event(CustomGCode::Type type=CustomGCode::Unknown)
Definition IMSlider.cpp:403
int m_only_extruder
Definition IMSlider.hpp:220
bool check_ticks_changed_event(CustomGCode::Type type)
Definition IMSlider.cpp:457
@ ToolChange
Definition CustomGCode.hpp:21
@ ColorChange
Definition CustomGCode.hpp:19
static std::string gcode(Type type)
Definition IMSlider.cpp:111
@ EmptyColorChangeCode
Definition NotificationManager.hpp:120
@ ssLower
Definition IMSlider.hpp:43
@ ssUndef
Definition IMSlider.hpp:42
void trace(unsigned int level, const char *message)
Definition utils.cpp:247
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References check_ticks_changed_event(), Slic3r::CustomGCode::ColorChange, Slic3r::empty(), Slic3r::GUI::EmptyColorChangeCode, Slic3r::GUI::gcode(), m_higher_value, m_lower_value, m_only_extruder, m_selection, m_ticks, m_values, post_ticks_changed_event(), Slic3r::GUI::ssLower, Slic3r::GUI::ssUndef, Slic3r::CustomGCode::ToolChange, and Slic3r::trace().

Referenced by render_add_menu(), and render_edit_menu().

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

◆ add_custom_gcode()

void Slic3r::GUI::IMSlider::add_custom_gcode ( std::string custom_gcode)
protected
410{
411 if (m_selection == ssUndef) return;
412 const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
413
414 const auto it = m_ticks.ticks.find(TickCode{ tick });
415
416 if (it != m_ticks.ticks.end()) {
417 m_ticks.ticks.erase(it);
418 }
419 m_ticks.ticks.emplace(TickCode{ tick, Custom, std::max<int>(1, m_only_extruder), "", custom_gcode });
420
422}
@ Custom
Definition CustomGCode.hpp:23

References Slic3r::CustomGCode::Custom, m_higher_value, m_lower_value, m_only_extruder, m_selection, m_ticks, post_ticks_changed_event(), Slic3r::GUI::ssLower, and Slic3r::GUI::ssUndef.

Referenced by render_input_custom_gcode().

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

◆ check_ticks_changed_event()

bool Slic3r::GUI::IMSlider::check_ticks_changed_event ( CustomGCode::Type type)
458{
459 //BBL only support MultiExtruder
460 if (m_ticks.mode == m_mode || (type != ColorChange && type != ToolChange) ||
461 (m_ticks.mode == SingleExtruder && m_mode == MultiAsSingle) || // All ColorChanges will be applied for 1st extruder
462 (m_ticks.mode == MultiExtruder && m_mode == MultiAsSingle)) // Just mark ColorChanges for all unused extruders
463 return true;
464
465 if ((m_ticks.mode == SingleExtruder && m_mode == MultiExtruder) || (m_ticks.mode == MultiExtruder && m_mode == SingleExtruder)) {
466 if (!m_ticks.has_tick_with_code(ColorChange)) return true;
467 /*
468 wxString message = (m_ticks.mode == SingleExtruder ? _L("The last color change data was saved for a single extruder printing.") :
469 _L("The last color change data was saved for a multi extruder printing.")) +
470 "\n" + _L("Your current changes will delete all saved color changes.") + "\n\n\t" + _L("Are you sure you want to continue?");
471
472
473 GUI::MessageDialog msg(this, message, _L("Notice"), wxYES_NO);
474 if (msg.ShowModal() == wxID_YES) {
475 m_ticks.erase_all_ticks_with_code(ColorChange);
476 post_ticks_changed_event(ColorChange);
477 }
478 */
479 return false;
480 }
481
482 return true;
483}
CustomGCode::Mode m_mode
Definition IMSlider.hpp:219
@ MultiAsSingle
Definition CustomGCode.hpp:57
@ SingleExtruder
Definition CustomGCode.hpp:56
@ MultiExtruder
Definition CustomGCode.hpp:60

References Slic3r::CustomGCode::ColorChange, m_mode, m_ticks, Slic3r::CustomGCode::MultiAsSingle, Slic3r::CustomGCode::MultiExtruder, Slic3r::CustomGCode::SingleExtruder, and Slic3r::CustomGCode::ToolChange.

Referenced by add_code_as_tick().

Here is the caller graph for this function:

◆ correct_higher_value()

void Slic3r::GUI::IMSlider::correct_higher_value ( )
protected

References m_higher_value, m_is_one_layer, m_lower_value, m_max_value, and m_min_value.

Referenced by get_double_value(), and SetHigherValue().

Here is the caller graph for this function:

◆ correct_lower_value()

void Slic3r::GUI::IMSlider::correct_lower_value ( )
protected

References m_higher_value, m_is_one_layer, m_lower_value, m_max_value, and m_min_value.

Referenced by SetLowerValue().

Here is the caller graph for this function:

◆ delete_tick()

void Slic3r::GUI::IMSlider::delete_tick ( const TickCode & tick)
protected
451 {
452 Type t = tick.type; // Avoid Use-After-Free issue, which resets the tick.type to 0
453 m_ticks.ticks.erase(tick);
455}
Type
Definition CustomGCode.hpp:18

References m_ticks, post_ticks_changed_event(), and Slic3r::GUI::TickCode::type.

Referenced by draw_ticks(), and render_edit_menu().

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

◆ do_go_to_layer()

void Slic3r::GUI::IMSlider::do_go_to_layer ( size_t layer_number)
protected
1409 {
1410 layer_number = std::clamp((int)layer_number, m_min_value, m_max_value);
1411 GetSelection() == ssLower ? SetLowerValue(layer_number) : SetHigherValue(layer_number);
1412}
void SetHigherValue(const int higher_val)
Definition IMSlider.cpp:224
SelectedSlider GetSelection()
Definition IMSlider.hpp:80
void SetLowerValue(const int lower_val)
Definition IMSlider.cpp:217

References GetSelection(), m_max_value, m_min_value, SetHigherValue(), SetLowerValue(), and Slic3r::GUI::ssLower.

Referenced by render_go_to_layer_dialog().

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

◆ draw_background_and_groove()

void Slic3r::GUI::IMSlider::draw_background_and_groove ( const ImRect & bg_rect,
const ImRect & groove )
protected
513 {
514 const ImU32 bg_rect_col = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT;
515 const ImU32 groove_col = m_is_dark ? GROOVE_COLOR_DARK : GROOVE_COLOR_LIGHT;
516
517 // draw bg of slider
518 ImGui::RenderFrame(bg_rect.Min, bg_rect.Max, bg_rect_col, false, 0.5 * bg_rect.GetWidth());
519 // draw groove
520 ImGui::RenderFrame(groove.Min, groove.Max, groove_col, false, 0.5 * groove.GetWidth());
521}
bool m_is_dark
Definition IMSlider.hpp:184
static const ImU32 BACKGROUND_COLOR_DARK
Definition IMSlider.cpp:66
static const ImU32 GROOVE_COLOR_LIGHT
Definition IMSlider.cpp:69
static const ImU32 GROOVE_COLOR_DARK
Definition IMSlider.cpp:68
static const ImU32 BACKGROUND_COLOR_LIGHT
Definition IMSlider.cpp:67

References Slic3r::GUI::BACKGROUND_COLOR_DARK, Slic3r::GUI::BACKGROUND_COLOR_LIGHT, Slic3r::GUI::GROOVE_COLOR_DARK, Slic3r::GUI::GROOVE_COLOR_LIGHT, ImRect, and m_is_dark.

Referenced by horizontal_slider(), and vertical_slider().

Here is the caller graph for this function:

◆ draw_colored_band()

void Slic3r::GUI::IMSlider::draw_colored_band ( const ImRect & groove,
const ImRect & slideable_region )
protected
619 {
620 if (!m_ticks.has_tick_with_code(ToolChange))
621 return;
622
623 ImRect main_band = groove;
624
625 auto draw_band = [this](const ImU32& clr, const ImRect& band_rc)
626 {
628 ImRect rc = band_rc;
629 rc.Min += ImVec2(1, 1) * m_scale;
630 rc.Max -= ImVec2(1, 1) * m_scale;
631 ImGui::RenderFrame(band_rc.Min, band_rc.Max, m_is_dark ? GROOVE_COLOR_DARK : GROOVE_COLOR_LIGHT, false, band_rc.GetWidth() * 0.5);
632 //cover round corner
633 ImGui::RenderFrame(ImVec2(band_rc.Min.x, band_rc.Max.y - band_rc.GetWidth() * 0.5), band_rc.Max, m_is_dark ? GROOVE_COLOR_DARK : GROOVE_COLOR_LIGHT, false);
634
635 ImGui::RenderFrame(rc.Min, rc.Max, clr, false, rc.GetWidth() * 0.5);
636 //cover round corner
637 ImGui::RenderFrame(ImVec2(rc.Min.x, rc.Max.y - rc.GetWidth() * 0.5), rc.Max, clr, false);
638 }
639 else {
640 ImGui::RenderFrame(band_rc.Min, band_rc.Max, clr, false, band_rc.GetWidth() * 0.5);
641 //cover round corner
642 ImGui::RenderFrame(ImVec2(band_rc.Min.x, band_rc.Max.y - band_rc.GetWidth() * 0.5), band_rc.Max, clr, false);
643 }
644 };
645 auto draw_main_band = [&main_band, this](const ImU32& clr) {
647 ImRect rc = main_band;
648 rc.Min += ImVec2(1, 1) * m_scale;
649 rc.Max -= ImVec2(1, 1) * m_scale;
650 ImGui::RenderFrame(main_band.Min, main_band.Max, m_is_dark ? GROOVE_COLOR_DARK : GROOVE_COLOR_LIGHT, false, main_band.GetWidth() * 0.5);
651 ImGui::RenderFrame(rc.Min, rc.Max, clr, false, rc.GetWidth() * 0.5);
652 }
653 else {
654 ImGui::RenderFrame(main_band.Min, main_band.Max, clr, false, main_band.GetWidth() * 0.5);
655 }
656 };
657 //draw main colored band
658 const int default_color_idx = m_mode == MultiAsSingle ? std::max<int>(m_only_extruder - 1, 0) : 0;
659 ColorRGBA rgba = decode_color_to_float_array(m_extruder_colors[default_color_idx]);
660 ImU32 band_clr = ImGuiWrapper::to_ImU32(rgba);
661 draw_main_band(band_clr);
662
663 static float tick_pos;
664 std::set<TickCode>::const_iterator tick_it = m_ticks.ticks.begin();
665 while (tick_it != m_ticks.ticks.end())
666 {
667 //get position from tick
668 tick_pos = get_pos_from_value(GetMinValue(), GetMaxValue(), tick_it->tick, slideable_region);
669 //draw colored band
670 if (tick_it->type == ToolChange) {
671 if ((m_mode == SingleExtruder) || (m_mode == MultiAsSingle))
672 {
673 ImRect band_rect = ImRect(main_band.Min, ImVec2(main_band.Max.x, tick_pos));
674
675 const std::string clr_str = m_mode == SingleExtruder ? tick_it->color : get_color_for_tool_change_tick(tick_it);
676
677 if (!clr_str.empty()) {
678 ColorRGBA rgba = decode_color_to_float_array(clr_str);
679 ImU32 band_clr = ImGuiWrapper::to_ImU32(rgba);
680 if (tick_it->tick == 0)
681 draw_main_band(band_clr);
682 else
683 draw_band(band_clr, band_rect);
684 }
685 }
686 }
687 tick_it++;
688 }
689}
struct IMGUI_API ImRect
Definition IMSlider.hpp:19
float get_pos_from_value(int v_min, int v_max, int value, const ImRect &rect)
Definition IMSlider.cpp:1807
float m_scale
Definition IMSlider.hpp:136
int GetMaxValue() const
Definition IMSlider.hpp:72
int GetMinValue() const
Definition IMSlider.hpp:71
std::string get_color_for_tool_change_tick(std::set< TickCode >::const_iterator it) const
Definition IMSlider.cpp:1820
static ImU32 to_ImU32(const ColorRGBA &color)
Definition ImGuiWrapper.cpp:2239
static ColorRGBA decode_color_to_float_array(const std::string color)
Definition GUI_Utils.hpp:60

References Slic3r::GUI::BACKGROUND_COLOR_DARK, Slic3r::GUI::BACKGROUND_COLOR_LIGHT, Slic3r::GUI::decode_color_to_float_array(), get_color_for_tool_change_tick(), get_pos_from_value(), GetMaxValue(), GetMinValue(), Slic3r::GUI::GROOVE_COLOR_DARK, Slic3r::GUI::GROOVE_COLOR_LIGHT, ImRect, m_extruder_colors, m_is_dark, m_mode, m_only_extruder, m_scale, m_ticks, Slic3r::CustomGCode::MultiAsSingle, Slic3r::CustomGCode::SingleExtruder, Slic3r::GUI::ImGuiWrapper::to_ImU32(), and Slic3r::CustomGCode::ToolChange.

Referenced by vertical_slider().

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

◆ draw_custom_label_block()

void Slic3r::GUI::IMSlider::draw_custom_label_block ( const ImVec2 anchor,
CustomGCode::Type type )
protected
692{
693 wxString label;
694 switch (type)
695 {
696 case ColorChange:
697 label = _L("Color");
698 break;
699 case PausePrint:
700 label = _L("Pause");
701 break;
702 case ToolChange:
703 label = _L("Color");
704 break;
705 case Template:
706 label = _L("Template");
707 break;
708 case Custom:
709 label = _L("Custom");
710 break;
711 case Unknown:
712 break;
713 default:
714 break;
715 }
716 const ImVec2 text_size = ImGui::CalcTextSize(into_u8(label).c_str());
717 const ImVec2 padding = ImVec2(4, 2) * m_scale;
718 const ImU32 clr = IM_COL32(255, 111, 0, 255);
719 const float rounding = 2.0f * m_scale;
720 ImVec2 block_pos = { anchor.x - text_size.x - padding.x * 2, anchor.y - text_size.y / 2 - padding.y };
721 ImVec2 block_size = { text_size.x + padding.x * 2, text_size.y + padding.y * 2 };
722 ImGui::RenderFrame(block_pos, block_pos + block_size, clr, false, rounding);
723 ImGui::PushStyleColor(ImGuiCol_Text, { 1,1,1,1 });
724 ImGui::RenderText(block_pos + padding, into_u8(label).c_str());
725 ImGui::PopStyleColor();
726}
#define _L(s)
Definition OBJ.cpp:34
@ PausePrint
Definition CustomGCode.hpp:20
@ Template
Definition CustomGCode.hpp:22
@ Unknown
Definition CustomGCode.hpp:24
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References _L, Slic3r::CustomGCode::ColorChange, Slic3r::CustomGCode::Custom, Slic3r::GUI::into_u8(), m_scale, Slic3r::CustomGCode::PausePrint, Slic3r::CustomGCode::Template, Slic3r::CustomGCode::ToolChange, and Slic3r::CustomGCode::Unknown.

Referenced by draw_ticks().

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

◆ draw_tick_on_mouse_position()

void Slic3r::GUI::IMSlider::draw_tick_on_mouse_position ( const ImRect & slideable_region)
protected
891 {
892 int v_min = GetMinValue();
893 int v_max = GetMaxValue();
894 ImGuiContext& context = *GImGui;
895
896 int tick = get_tick_near_point(v_min, v_max, context.IO.MousePos, slideable_region);
897
898 //draw tick
899 ImVec2 tick_offset = ImVec2(22.0f, 14.0f) * m_scale;
900 float tick_width = 1.0f * m_scale;
901
902 const ImU32 tick_clr = IM_COL32(144, 144, 144, 255);
903
904 float tick_pos = get_pos_from_value(v_min, v_max, tick, slideable_region);
905 ImRect tick_left = ImRect(slideable_region.GetCenter().x - tick_offset.x, tick_pos - tick_width, slideable_region.GetCenter().x - tick_offset.y, tick_pos);
906 ImRect tick_right = ImRect(slideable_region.GetCenter().x + tick_offset.y, tick_pos - tick_width, slideable_region.GetCenter().x + tick_offset.x, tick_pos);
907 ImGui::RenderFrame(tick_left.Min, tick_left.Max, tick_clr, false);
908 ImGui::RenderFrame(tick_right.Min, tick_right.Max, tick_clr, false);
909
910 // draw layer time
911 std::string label = get_label(tick, ltEstimatedTime);
912 show_tooltip(label);
913}
void show_tooltip(const TickCode &tick)
Definition IMSlider.cpp:842
int get_tick_near_point(int v_min, int v_max, const ImVec2 &pt, const ImRect &rect)
Definition IMSlider.cpp:875
std::string get_label(int tick, LabelType label_type=ltHeightWithLayer)
Definition IMSlider.cpp:1737
@ ltEstimatedTime
Definition IMSlider.hpp:59

References get_label(), get_pos_from_value(), get_tick_near_point(), GetMaxValue(), GetMinValue(), ImRect, Slic3r::GUI::ltEstimatedTime, m_scale, and show_tooltip().

Referenced by vertical_slider().

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

◆ draw_ticks()

void Slic3r::GUI::IMSlider::draw_ticks ( const ImRect & slideable_region)
protected
728 {
729 //if(m_draw_mode != dmRegular)
730 // return;
731 //if (m_ticks.empty() || m_mode == MultiExtruder)
732 // return;
733 if (m_ticks.empty())
734 return;
735
736 ImGuiContext &context = *GImGui;
737
738 ImVec2 tick_box = ImVec2(52.0f, 16.0f) * m_scale;
739 ImVec2 tick_offset = ImVec2(22.0f, 14.0f) * m_scale;
740 float tick_width = 1.0f * m_scale;
741 ImVec2 icon_offset = ImVec2(16.0f, 7.0f) * m_scale;
742 ImVec2 icon_size = ImVec2(14.0f, 14.0f) * m_scale;
743
744 const ImU32 tick_clr = IM_COL32(144, 144, 144, 255);
745 const ImU32 tick_hover_box_clr = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(219, 253, 231, 255);
746
747 auto get_tick_pos = [this, slideable_region](int tick)
748 {
749 int v_min = GetMinValue();
750 int v_max = GetMaxValue();
751 return get_pos_from_value(v_min, v_max, tick, slideable_region);
752 };
753
754 std::set<TickCode>::const_iterator tick_it = m_ticks.ticks.begin();
755 while (tick_it != m_ticks.ticks.end())
756 {
757 float tick_pos = get_tick_pos(tick_it->tick);
758
759 //draw tick hover box when hovered
760 ImRect tick_hover_box = ImRect(slideable_region.GetCenter().x - tick_box.x / 2, tick_pos - tick_box.y / 2, slideable_region.GetCenter().x + tick_box.x / 2,
761 tick_pos + tick_box.y / 2);
762
763 if (ImGui::IsMouseHoveringRect(tick_hover_box.Min, tick_hover_box.Max))
764 {
765 // render left tick box
766 ImRect left_hover_box = ImRect(tick_hover_box.Min, { slideable_region.Min.x, tick_hover_box.Max.y });
767 ImGui::RenderFrame(left_hover_box.Min, left_hover_box.Max, tick_hover_box_clr, false);
768 // render right tick box
769 ImRect right_hover_box = ImRect({ slideable_region.Max.x, tick_hover_box.Min.y }, tick_hover_box.Max);
770 ImGui::RenderFrame(right_hover_box.Min, right_hover_box.Max, tick_hover_box_clr, false);
771
772 show_tooltip(*tick_it);
773 m_tick_value = tick_it->tick;
774 m_tick_rect = ImVec4(tick_hover_box.Min.x, tick_hover_box.Min.y, tick_hover_box.Max.x, tick_hover_box.Max.y);
775 }
776 ++tick_it;
777 }
778
779 tick_it = m_ticks.ticks.begin();
780 while (tick_it != m_ticks.ticks.end())
781 {
782 float tick_pos = get_tick_pos(tick_it->tick);
783
784 //draw ticks
785 ImRect tick_left = ImRect(slideable_region.GetCenter().x - tick_offset.x, tick_pos - tick_width, slideable_region.GetCenter().x - tick_offset.y, tick_pos);
786 ImRect tick_right = ImRect(slideable_region.GetCenter().x + tick_offset.y, tick_pos - tick_width, slideable_region.GetCenter().x + tick_offset.x, tick_pos);
787 ImGui::RenderFrame(tick_left.Min, tick_left.Max, tick_clr, false);
788 ImGui::RenderFrame(tick_right.Min, tick_right.Max, tick_clr, false);
789
790 //draw pause icon
791 if (tick_it->type == PausePrint) {
792 ImTextureID pause_icon_id = m_pause_icon_id;
793 ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, tick_pos - icon_offset.y);
794 button_with_pos(pause_icon_id, icon_size, icon_pos);
795 }
796 if (tick_it->type == Custom || tick_it->type == Template) {
797 ImTextureID custom_icon_id = m_custom_icon_id;
798 ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, tick_pos - icon_offset.y);
799 button_with_pos(custom_icon_id, icon_size, icon_pos);
800 }
801
802 //draw label block
803 ImVec2 label_block_anchor = ImVec2(slideable_region.GetCenter().x - tick_offset.y, tick_pos);
804 draw_custom_label_block(label_block_anchor, tick_it->type);
805
806 ++tick_it;
807 }
808
809 tick_it = GetSelection() == ssHigher ? m_ticks.ticks.find(TickCode{this->GetHigherValue()}) :
810 GetSelection() == ssLower ? m_ticks.ticks.find(TickCode{this->GetLowerValue()}) :
811 m_ticks.ticks.end();
812 if (tick_it != m_ticks.ticks.end()) {
813 //draw label block again, to keep it in front
814 ImVec2 label_block_anchor = ImVec2(slideable_region.GetCenter().x - tick_offset.y, get_tick_pos(tick_it->tick));
815 draw_custom_label_block(label_block_anchor, tick_it->type);
816
817 // draw delete icon
818 ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, get_tick_pos(tick_it->tick) - icon_offset.y);
819 button_with_pos(m_delete_icon_id, icon_size, icon_pos);
820 if (ImGui::IsMouseHoveringRect(icon_pos, icon_pos + icon_size)) {
821 if (context.IO.MouseClicked[0]) {
822 // delete tick
823 delete_tick(*tick_it);
824 }
825 }
826 }
827}
void draw_custom_label_block(const ImVec2 anchor, CustomGCode::Type type)
Definition IMSlider.cpp:691
void * m_custom_icon_id
Definition IMSlider.hpp:215
int GetLowerValue() const
Definition IMSlider.hpp:75
void * m_pause_icon_id
Definition IMSlider.hpp:214
int GetHigherValue() const
Definition IMSlider.hpp:76
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
bool button_with_pos(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &pos, const ImVec2 &uv0, const ImVec2 &uv1, int frame_padding, const ImVec4 &bg_col, const ImVec4 &tint_col, const ImVec2 &margin)
Definition ImGuiWrapper.cpp:342
RaycastManager::TrItems::iterator find(RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
Definition RaycastManager.cpp:298

References Slic3r::GUI::button_with_pos(), Slic3r::CustomGCode::Custom, delete_tick(), draw_custom_label_block(), get_pos_from_value(), GetHigherValue(), GetLowerValue(), GetMaxValue(), GetMinValue(), GetSelection(), ImRect, m_custom_icon_id, m_delete_icon_id, m_is_dark, m_pause_icon_id, m_scale, Slic3r::GUI::m_tick_rect, Slic3r::GUI::m_tick_value, m_ticks, Slic3r::CustomGCode::PausePrint, show_tooltip(), Slic3r::GUI::ssHigher, Slic3r::GUI::ssLower, and Slic3r::CustomGCode::Template.

Referenced by vertical_slider().

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

◆ get_active_extruders_for_tick()

std::array< int, 2 > Slic3r::GUI::IMSlider::get_active_extruders_for_tick ( int tick) const
private
1843{
1844 int default_initial_extruder = m_mode == MultiAsSingle ? std::max<int>(1, m_only_extruder) : 1;
1845 std::array<int, 2> extruders = {default_initial_extruder, -1};
1846 if (m_ticks.empty()) return extruders;
1847
1848 auto it = m_ticks.ticks.lower_bound(TickCode{tick});
1849
1850 if (it != m_ticks.ticks.end() && it->tick == tick) // current tick exists
1851 extruders[1] = it->extruder;
1852
1853 while (it != m_ticks.ticks.begin()) {
1854 --it;
1855 if (it->type == ToolChange) {
1856 extruders[0] = it->extruder;
1857 break;
1858 }
1859 }
1860
1861 return extruders;
1862}

References m_mode, m_only_extruder, m_ticks, Slic3r::CustomGCode::MultiAsSingle, and Slic3r::CustomGCode::ToolChange.

◆ get_color_for_tool_change_tick()

std::string Slic3r::GUI::IMSlider::get_color_for_tool_change_tick ( std::set< TickCode >::const_iterator it) const
private
1821{
1822 const int current_extruder = it->extruder == 0 ? std::max<int>(m_only_extruder, 1) : it->extruder;
1823
1824 auto it_n = it;
1825 while (it_n != m_ticks.ticks.begin()) {
1826 --it_n;
1827 if (it_n->type == ColorChange && it_n->extruder == current_extruder)
1828 return it_n->color;
1829 }
1830
1831 if ((current_extruder > 0 && (current_extruder - 1) < m_extruder_colors.size()))
1832 {
1833 return m_extruder_colors[current_extruder - 1]; // return a color for a specific extruder from the colors list
1834 }
1835 return "";
1836}

References Slic3r::CustomGCode::ColorChange, m_extruder_colors, m_only_extruder, and m_ticks.

Referenced by draw_colored_band().

Here is the caller graph for this function:

◆ get_double_value()

double Slic3r::GUI::IMSlider::get_double_value ( const SelectedSlider & selection)
private
1786{
1787 if (m_values.empty() || m_lower_value < 0) return 0.0;
1788 if (m_values.size() <= size_t(m_higher_value)) {
1790 return m_values.back();
1791 }
1792 return m_values[selection == ssLower ? m_lower_value : m_higher_value];
1793}
void correct_higher_value()
Definition IMSlider.cpp:1713

References correct_higher_value(), m_higher_value, m_lower_value, m_values, and Slic3r::GUI::ssLower.

Referenced by GetHigherValueD(), and GetLowerValueD().

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

◆ get_label()

std::string Slic3r::GUI::IMSlider::get_label ( int tick,
LabelType label_type = ltHeightWithLayer )
private
1738{
1739 const size_t value = tick;
1740
1741 if (m_label_koef == 1.0 && m_values.empty()) {
1742 return std::to_string(value);
1743 }
1744 if (value >= m_values.size()) return "error";
1745
1746 auto get_layer_number = [this](int value, LabelType label_type) {
1747 if (label_type == ltEstimatedTime && m_layers_times.empty()) return size_t(-1);
1748 double layer_print_z = m_values[is_wipe_tower_layer(value) ? std::max<int>(value - 1, 0) : value];
1749 auto it = std::lower_bound(m_layers_values.begin(), m_layers_values.end(), layer_print_z - epsilon());
1750 if (it == m_layers_values.end()) {
1751 it = std::lower_bound(m_values.begin(), m_values.end(), layer_print_z - epsilon());
1752 if (it == m_values.end()) return size_t(-1);
1753 return size_t(value);
1754 }
1755 return size_t(it - m_layers_values.begin());
1756 };
1757
1759 return std::to_string(tick);
1760
1761 } else {
1762 if (label_type == ltEstimatedTime) {
1763 if (m_is_wipe_tower) {
1764 size_t layer_number = get_layer_number(value, label_type);
1765 return (layer_number == size_t(-1) || layer_number == m_layers_times.size()) ? "" : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number]));
1766 }
1767 return value < m_layers_times.size() ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : "";
1768 }
1769
1770 char layer_height[64];
1771 ::sprintf(layer_height, "%.2f", m_values.empty() ? m_label_koef * value : m_values[value]);
1772 if (label_type == ltHeight) return std::string(layer_height);
1773 if (label_type == ltHeightWithLayer) {
1774 char buffer[90];
1775 size_t layer_number;
1776 layer_number = m_draw_mode == dmSequentialFffPrint ? (m_values.empty() ? value : value + 1) : m_is_wipe_tower ? get_layer_number(value, label_type) + 1 : (m_values.empty() ? value : value + 1);
1777 ::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height);
1778 return std::string(buffer);
1779 }
1780 }
1781
1782 return "";
1783}
bool is_wipe_tower_layer(int tick) const
Definition IMSlider.cpp:1723
DrawMode m_draw_mode
Definition IMSlider.hpp:218
std::vector< double > m_layers_values
Definition IMSlider.hpp:229
float m_label_koef
Definition IMSlider.hpp:224
std::vector< double > m_layers_times
Definition IMSlider.hpp:228
bool m_is_wipe_tower
Definition IMSlider.hpp:202
static std::string layer_height
Definition Tab.cpp:4294
@ dmSequentialFffPrint
Definition IMSlider.hpp:51
@ dmSequentialGCodeView
Definition IMSlider.hpp:52
LabelType
Definition IMSlider.hpp:56
@ ltHeight
Definition IMSlider.hpp:58
@ ltHeightWithLayer
Definition IMSlider.hpp:57
constexpr double epsilon()
Definition IMSlider.hpp:31
static std::string short_and_splitted_time(const std::string &time)
Definition IMSlider.cpp:132
std::string get_time_dhms(float time_in_secs)
Definition Utils.hpp:609

References Slic3r::GUI::dmSequentialFffPrint, Slic3r::GUI::dmSequentialGCodeView, Slic3r::GUI::epsilon(), Slic3r::get_time_dhms(), is_wipe_tower_layer(), Slic3r::GUI::layer_height, Slic3r::GUI::ltEstimatedTime, Slic3r::GUI::ltHeight, Slic3r::GUI::ltHeightWithLayer, m_draw_mode, m_is_wipe_tower, m_label_koef, m_layers_times, m_layers_values, m_values, and Slic3r::GUI::short_and_splitted_time().

Referenced by draw_tick_on_mouse_position(), render(), and show_tooltip().

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

◆ get_pos_from_value()

float Slic3r::GUI::IMSlider::get_pos_from_value ( int v_min,
int v_max,
int value,
const ImRect & rect )
private
1807 {
1808 float pos_ratio = (v_max - v_min) != 0 ? ((float)(value - v_min) / (float)(v_max - v_min)) : 0.0f;
1809 float handle_pos;
1810 if (is_horizontal()) {
1811 handle_pos = rect.Min.x + (rect.Max.x - rect.Min.x) * pos_ratio;
1812 }
1813 else {
1814 pos_ratio = 1.0f - pos_ratio;
1815 handle_pos = rect.Min.y + (rect.Max.y - rect.Min.y) * pos_ratio;
1816 }
1817 return handle_pos;
1818}
bool is_horizontal() const
Definition IMSlider.hpp:110

References ImRect, and is_horizontal().

Referenced by draw_colored_band(), draw_tick_on_mouse_position(), draw_ticks(), horizontal_slider(), and vertical_slider().

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

◆ get_post_tick_event_type()

CustomGCode::Type Slic3r::GUI::IMSlider::get_post_tick_event_type ( )
inline
134{ return m_tick_change_event_type; }

References m_tick_change_event_type.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay().

Here is the caller graph for this function:

◆ get_tick_from_value()

int Slic3r::GUI::IMSlider::get_tick_from_value ( double value,
bool force_lower_bound = false )
private
1796{
1797 std::vector<double>::iterator it;
1798 if (m_is_wipe_tower && !force_lower_bound)
1799 it = std::find_if(m_values.begin(), m_values.end(), [value](const double &val) { return fabs(value - val) <= epsilon(); });
1800 else
1801 it = std::lower_bound(m_values.begin(), m_values.end(), value - epsilon());
1802
1803 if (it == m_values.end()) return -1;
1804 return int(it - m_values.begin());
1805}

References Slic3r::GUI::epsilon(), m_is_wipe_tower, and m_values.

Referenced by SetTicksValues().

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

◆ get_tick_near_point()

int Slic3r::GUI::IMSlider::get_tick_near_point ( int v_min,
int v_max,
const ImVec2 & pt,
const ImRect & rect )
private
875 {
876 ImS32 v_range = (v_min < v_max ? v_max - v_min : v_min - v_max);
877
878 const ImGuiAxis axis = is_horizontal() ? ImGuiAxis_X : ImGuiAxis_Y;
879 const float region_usable_sz = (rect.Max[axis] - rect.Min[axis]);
880 const float region_usable_pos_min = rect.Min[axis];
881
882 const float abs_pos = pt[axis];
883
884 float pos_ratio = (region_usable_sz > 0.0f) ? ImClamp((abs_pos - region_usable_pos_min) / region_usable_sz, 0.0f, 1.0f) : 0.0f;
885 if (axis == ImGuiAxis_Y)
886 pos_ratio = 1.0f - pos_ratio;
887
888 return v_min + (ImS32)(v_range * pos_ratio + 0.5f);
889}

References ImRect, and is_horizontal().

Referenced by draw_tick_on_mouse_position().

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

◆ GetActiveValue()

int Slic3r::GUI::IMSlider::GetActiveValue ( ) const

◆ GetHigherValue()

int Slic3r::GUI::IMSlider::GetHigherValue ( ) const
inline

◆ GetHigherValueD()

double Slic3r::GUI::IMSlider::GetHigherValueD ( )
inline
79{ return get_double_value(ssHigher); }
double get_double_value(const SelectedSlider &selection)
Definition IMSlider.cpp:1785

References get_double_value(), and Slic3r::GUI::ssHigher.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay(), and Slic3r::GUI::Preview::update_layers_slider().

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

◆ GetLowerValue()

int Slic3r::GUI::IMSlider::GetLowerValue ( ) const
inline
75{ return m_lower_value; }

References m_lower_value.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay(), draw_ticks(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), on_mouse_wheel(), Slic3r::GUI::Preview::refresh_belt_view(), render(), and render_menu().

Here is the caller graph for this function:

◆ GetLowerValueD()

double Slic3r::GUI::IMSlider::GetLowerValueD ( )
inline
78{ return get_double_value(ssLower); }

References get_double_value(), and Slic3r::GUI::ssLower.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay(), and Slic3r::GUI::Preview::update_layers_slider().

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

◆ GetManipulationMode()

CustomGCode::Mode Slic3r::GUI::IMSlider::GetManipulationMode ( ) const
inline
101{ return m_mode; }

References m_mode.

◆ GetMaxValue()

int Slic3r::GUI::IMSlider::GetMaxValue ( ) const
inline

◆ GetMaxValueD()

double Slic3r::GUI::IMSlider::GetMaxValueD ( )
inline
74{ return m_values.empty() ? 0. : m_values[m_max_value]; }

References m_max_value, and m_values.

Referenced by Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ GetMinValue()

int Slic3r::GUI::IMSlider::GetMinValue ( ) const
inline
71{ return m_min_value; }

References m_min_value.

Referenced by draw_colored_band(), draw_tick_on_mouse_position(), draw_ticks(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), render(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::set_top_layer(), and Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ GetMinValueD()

double Slic3r::GUI::IMSlider::GetMinValueD ( )
inline
73{ return m_values.empty() ? 0. : m_values[m_min_value]; }

References m_min_value, and m_values.

◆ GetSelection()

SelectedSlider Slic3r::GUI::IMSlider::GetSelection ( )
inline
80{ return m_selection; }

References m_selection.

Referenced by do_go_to_layer(), draw_ticks(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), and render_menu().

Here is the caller graph for this function:

◆ GetTicksValues()

Info Slic3r::GUI::IMSlider::GetTicksValues ( ) const
256{
258 std::vector<CustomGCode::Item> &values = custom_gcode_per_print_z.gcodes;
259
260 const int val_size = m_values.size();
261 if (!m_values.empty())
262 for (const TickCode &tick : m_ticks.ticks) {
263 if (tick.tick > val_size) break;
264 values.emplace_back(CustomGCode::Item{m_values[tick.tick], tick.type, tick.extruder, tick.color, tick.extra});
265 }
266
268
270}
bool m_force_mode_apply
Definition IMSlider.hpp:201
static CustomGCode::Info custom_gcode_per_print_z
Definition ToolOrdering.cpp:3253
Mode mode
Definition CustomGCode.hpp:70
std::vector< Item > gcodes
Definition CustomGCode.hpp:71

References Slic3r::GUI::TickCode::color, Slic3r::custom_gcode_per_print_z, Slic3r::GUI::TickCode::extra, Slic3r::GUI::TickCode::extruder, m_force_mode_apply, m_mode, m_ticks, m_values, Slic3r::GUI::TickCode::tick, and Slic3r::GUI::TickCode::type.

◆ horizontal_slider()

bool Slic3r::GUI::IMSlider::horizontal_slider ( const char * str_id,
int * v,
int v_min,
int v_max,
const ImVec2 & size,
float scale = 1.0 )
protected
524{
525 ImGuiWindow* window = ImGui::GetCurrentWindow();
526 if (window->SkipItems)
527 return false;
528
529 ImGuiContext& context = *GImGui;
530 const ImGuiID id = window->GetID(str_id);
531
532 const ImVec2 pos = window->DC.CursorPos;
533 const ImRect draw_region(pos, pos + size);
534 ImGui::ItemSize(draw_region);
535
536 const float handle_dummy_width = 10.0f * m_scale;
537 const float text_right_dummy = 70.0f * scale * m_scale;
538
539 const float handle_radius = 12.0f * m_scale;
540 const float handle_border = 2.0f * m_scale;
541 const float text_start_offset = 8.0f * m_scale;
542 const ImVec2 text_padding = ImVec2(5.0f, 2.0f) * m_scale;
543
544 const ImU32 handle_clr = BRAND_COLOR;
545 const ImU32 handle_border_clr = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT;
546 const wxColour label_bg = StateColor::darkModeColorFor(wxGetApp().get_window_default_clr());
547 const wxColour label_border = StateColor::darkModeColorFor(wxColour("#CECECE"));
548 const wxColour rail_inner_bg = m_is_dark ? StateColor::darkModeColorFor(wxColour("#CECECE")) : wxGetApp().get_highlight_default_clr();
549 const wxColour rail_border = m_is_dark ? StateColor::darkModeColorFor(wxColour("#F0F0F1")) : wxColour("#CECECE");
550 const ImU32 label_bg_clr = IM_COL32(label_bg.Red(), label_bg.Green(), label_bg.Blue(), 238);
551 const ImU32 label_border_clr = IM_COL32(label_border.Red(), label_border.Green(), label_border.Blue(), 255);
552 const ImU32 label_shadow_clr = m_is_dark ? IM_COL32(0, 0, 0, 84) : IM_COL32(0, 0, 0, 38);
553 ImVec4 range_fill = ImGui::ColorConvertU32ToFloat4(BRAND_COLOR);
554 range_fill.w = (m_is_dark ? 210.0f : 190.0f) / 255.0f;
555 const ImU32 range_fill_clr = ImGui::GetColorU32(range_fill);
556 const ImU32 rail_inner_clr = IM_COL32(rail_inner_bg.Red(), rail_inner_bg.Green(), rail_inner_bg.Blue(), 255);
557 const ImU32 rail_border_clr = IM_COL32(rail_border.Red(), rail_border.Green(), rail_border.Blue(), 190);
558
559 // calculate groove size
560 const ImVec2 groove_start = ImVec2(pos.x + handle_dummy_width, pos.y + size.y - ONE_LAYER_MARGIN.y * m_scale - (ONE_LAYER_BUTTON_SIZE.y / 2) * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f);
561 const ImVec2 groove_size = ImVec2(size.x - 2 * handle_dummy_width - text_right_dummy, GROOVE_WIDTH * m_scale);
562 const ImRect groove = ImRect(groove_start, groove_start + groove_size);
563 const ImRect bg_rect = ImRect(groove.Min - ImVec2(6.0f, 6.0f) * m_scale, groove.Max + ImVec2(6.0f, 6.0f) * m_scale);
564 const float mid_y = groove.GetCenter().y;
565
566 // set mouse active region. active region.
567 bool slider_hovered = ImGui::ItemHoverable(draw_region, id);
568 if (slider_hovered && context.IO.MouseDown[0]) {
569 ImGui::SetActiveID(id, window);
570 ImGui::SetFocusID(id, window);
571 ImGui::FocusWindow(window);
572 }
573
574 // draw background
575 draw_background_and_groove(bg_rect, groove);
576 window->DrawList->AddRect(groove.Min, groove.Max, rail_border_clr, 0.5f * groove.GetHeight(), 0, 1.0f * m_scale);
577 const ImRect rail_inner(groove.Min + ImVec2(2.0f, 2.0f) * m_scale, groove.Max - ImVec2(2.0f, 2.0f) * m_scale);
578 window->DrawList->AddRectFilled(rail_inner.Min, rail_inner.Max, rail_inner_clr, 0.5f * rail_inner.GetHeight());
579
580 // set scrollable region
581 const ImRect slideable_region = ImRect(bg_rect.Min + ImVec2(handle_radius, 0.0f), bg_rect.Max - ImVec2(handle_radius, 0.0f));
582
583 // initialize the handle
584 float handle_pos = get_pos_from_value(v_min, v_max, *value, groove);
585 ImRect handle = ImRect(handle_pos - handle_radius, mid_y - handle_radius, handle_pos + handle_radius, mid_y + handle_radius);
586
587 // update handle position and value
588 bool value_changed = slider_behavior(id, slideable_region, (const ImS32) v_min, (const ImS32) v_max, (ImS32 *) value, &handle);
589 ImVec2 handle_center = handle.GetCenter();
590
591 // draw scroll line
592 ImRect scroll_line = ImRect(ImVec2(groove.Min.x, groove.Min.y - 2.0f * m_scale),
593 ImVec2(handle_center.x, groove.Max.y + 2.0f * m_scale));
594 window->DrawList->AddRectFilled(scroll_line.Min, scroll_line.Max, range_fill_clr, 0.5f * scroll_line.GetHeight());
595
596 // draw handle
597 window->DrawList->AddCircleFilled(handle_center, handle_radius + 2.0f * m_scale, handle_border_clr);
598 window->DrawList->AddCircleFilled(handle_center, handle_radius, handle_border_clr);
599 window->DrawList->AddCircleFilled(handle_center, handle_radius - handle_border, handle_clr);
600 window->DrawList->AddCircle(handle_center, handle_radius + 3.0f * m_scale, handle_clr, 0, 2.0f * m_scale);
601
602 // draw label
603 const std::string value_label = std::to_string(*value);
604 const ImVec2 text_content_size = ImGui::CalcTextSize(value_label.c_str());
605 ImVec2 text_size = text_content_size + text_padding * 2;
606 ImVec2 text_start = ImVec2(handle_center.x + handle_radius + text_start_offset, handle_center.y - 0.5 * text_size.y);
607 ImRect text_rect(text_start, text_start + text_size);
608 const float label_rounding = 5.0f * m_scale;
609 const ImVec2 shadow_offset = ImVec2(2.0f, 2.0f) * m_scale;
610 window->DrawList->AddRectFilled(text_rect.Min + shadow_offset, text_rect.Max + shadow_offset, label_shadow_clr, label_rounding);
611 ImGui::RenderFrame(text_rect.Min, text_rect.Max, label_bg_clr, false, label_rounding);
612 window->DrawList->AddRect(text_rect.Min, text_rect.Max, label_border_clr, label_rounding, 0, 1.0f * m_scale);
613 ImGui::RenderText(text_rect.Min + ImVec2((text_size.x - text_content_size.x) * 0.5f,
614 (text_size.y - text_content_size.y) * 0.5f), value_label.c_str());
615
616 return value_changed;
617}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
void draw_background_and_groove(const ImRect &bg_rect, const ImRect &groove)
Definition IMSlider.cpp:513
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
static const float GROOVE_WIDTH
Definition IMSlider.cpp:62
static const ImVec2 ONE_LAYER_MARGIN
Definition IMSlider.cpp:63
bool slider_behavior(ImGuiID id, const ImRect &region, const ImS32 v_min, const ImS32 v_max, ImS32 *out_value, ImRect *out_handle, ImGuiSliderFlags flags, const int fixed_value, const ImVec4 &fixed_rect)
Definition ImGuiWrapper.cpp:280
static const ImVec2 ONE_LAYER_BUTTON_SIZE
Definition IMSlider.cpp:64
static const ImU32 BRAND_COLOR
Definition IMSlider.cpp:70
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References Slic3r::GUI::BACKGROUND_COLOR_DARK, Slic3r::GUI::BACKGROUND_COLOR_LIGHT, Slic3r::GUI::BRAND_COLOR, StateColor::darkModeColorFor(), draw_background_and_groove(), get_pos_from_value(), Slic3r::GUI::GROOVE_WIDTH, ImRect, m_is_dark, m_scale, Slic3r::GUI::ONE_LAYER_BUTTON_SIZE, Slic3r::GUI::ONE_LAYER_MARGIN, scale(), and Slic3r::GUI::slider_behavior().

Referenced by render().

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

◆ init_texture()

bool Slic3r::GUI::IMSlider::init_texture ( )
189{
190 bool result = true;
191 if (!is_horizontal()) {
192 // BBS init image texture id
193 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on.svg", 56, 56, m_one_layer_on_id);
194 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover.svg", 56, 56, m_one_layer_on_hover_id);
195 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off.svg", 56, 56, m_one_layer_off_id);
196 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover.svg", 56, 56, m_one_layer_off_hover_id);
197 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_dark.svg", 56, 56, m_one_layer_on_dark_id);
198 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_on_hover_dark.svg", 56, 56, m_one_layer_on_hover_dark_id);
199 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_dark.svg", 56, 56, m_one_layer_off_dark_id);
200 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover_dark.svg", 56, 56, m_one_layer_off_hover_dark_id);
201 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_pause.svg", 14, 14, m_pause_icon_id);
202 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_custom.svg", 14, 14, m_custom_icon_id);
203 result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_slider_delete.svg", 14, 14, m_delete_icon_id);
204 }
205
206 return result;
207}
void * m_one_layer_off_id
Definition IMSlider.hpp:208
void * m_one_layer_on_hover_id
Definition IMSlider.hpp:207
void * m_one_layer_off_hover_dark_id
Definition IMSlider.hpp:213
void * m_one_layer_off_dark_id
Definition IMSlider.hpp:212
void * m_one_layer_off_hover_id
Definition IMSlider.hpp:209
void * m_one_layer_on_id
Definition IMSlider.hpp:206
void * m_one_layer_on_dark_id
Definition IMSlider.hpp:210
void * m_one_layer_on_hover_dark_id
Definition IMSlider.hpp:211
void * m_delete_icon_id
Definition IMSlider.hpp:216
static bool load_from_svg_file(const std::string &filename, unsigned width, unsigned height, ImTextureID &texture_id)
Definition ImGuiWrapper.cpp:3655
const std::string & resources_dir()
Definition utils.cpp:296

References is_horizontal(), Slic3r::GUI::IMTexture::load_from_svg_file(), m_custom_icon_id, m_delete_icon_id, m_one_layer_off_dark_id, m_one_layer_off_hover_dark_id, m_one_layer_off_hover_id, m_one_layer_off_id, m_one_layer_on_dark_id, m_one_layer_on_hover_dark_id, m_one_layer_on_hover_id, m_one_layer_on_id, m_pause_icon_id, and Slic3r::resources_dir().

Here is the call graph for this function:

◆ is_dirty()

bool Slic3r::GUI::IMSlider::is_dirty ( )
inline
127{ return m_dirty; }
bool m_dirty
Definition IMSlider.hpp:191

References m_dirty.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay(), and Slic3r::GUI::GLCanvas3D::handle_shortcut().

Here is the caller graph for this function:

◆ is_full_span()

bool Slic3r::GUI::IMSlider::is_full_span ( ) const
inline
114{ return this->is_lower_at_min() && this->is_higher_at_max(); }
bool is_lower_at_min() const
Definition IMSlider.hpp:112
bool is_higher_at_max() const
Definition IMSlider.hpp:113

References is_higher_at_max(), and is_lower_at_min().

Here is the call graph for this function:

◆ is_higher_at_max()

bool Slic3r::GUI::IMSlider::is_higher_at_max ( ) const
inline
113{ return m_higher_value == m_max_value; }

References m_higher_value, and m_max_value.

Referenced by is_full_span(), and Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ is_horizontal()

bool Slic3r::GUI::IMSlider::is_horizontal ( ) const
inline
110{ return m_style == wxSL_HORIZONTAL; }

References m_style.

Referenced by get_pos_from_value(), get_tick_near_point(), init_texture(), on_mouse_wheel(), and render().

Here is the caller graph for this function:

◆ is_lower_at_min()

bool Slic3r::GUI::IMSlider::is_lower_at_min ( ) const
inline
112{ return m_lower_value == m_min_value; }

References m_lower_value, and m_min_value.

Referenced by is_full_span(), and Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ is_need_post_tick_event()

bool Slic3r::GUI::IMSlider::is_need_post_tick_event ( )
inline

References m_is_need_post_tick_changed_event.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay().

Here is the caller graph for this function:

◆ is_one_layer()

bool Slic3r::GUI::IMSlider::is_one_layer ( ) const
inline
111{ return m_is_one_layer; }

References m_is_one_layer.

Referenced by Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::go_to_layer(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), on_mouse_wheel(), and render().

Here is the caller graph for this function:

◆ is_rendering_as_disabled()

bool Slic3r::GUI::IMSlider::is_rendering_as_disabled ( ) const
inline
108{ return m_render_as_disabled; }
bool m_render_as_disabled
Definition IMSlider.hpp:193

References m_render_as_disabled.

◆ is_wipe_tower_layer()

bool Slic3r::GUI::IMSlider::is_wipe_tower_layer ( int tick) const
protected
1724{
1725 // BBS: This function is useless in BBS
1726 return false;
1727
1728 if (!m_is_wipe_tower || tick >= (int) m_values.size()) return false;
1729 if (tick == 0 || (tick == (int) m_values.size() - 1 && m_values[tick] > m_values[tick - 1])) return false;
1730 if ((m_values[tick - 1] == m_values[tick + 1] && m_values[tick] < m_values[tick + 1]) ||
1731 (tick > 0 && m_values[tick] < m_values[tick - 1])) // if there is just one wiping on the layer
1732 return true;
1733
1734 return false;
1735}

References m_is_wipe_tower, and m_values.

Referenced by get_label().

Here is the caller graph for this function:

◆ IsNewPrint()

bool Slic3r::GUI::IMSlider::IsNewPrint ( )
392{
393 const Print &print = GUI::wxGetApp().plater()->fff_print();
394 std::string idxs;
395 for (auto object : print.objects()) idxs += std::to_string(object->id().id) + "_";
396
397 if (idxs == m_print_obj_idxs) return false;
398
399 m_print_obj_idxs = idxs;
400 return true;
401}
std::string m_print_obj_idxs
Definition IMSlider.hpp:232

References Slic3r::ObjectBase::id(), Slic3r::ObjectID::id, m_print_obj_idxs, and Slic3r::Print::objects().

Referenced by Slic3r::GUI::Preview::update_layers_slider().

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

◆ on_change_color_mode()

void Slic3r::GUI::IMSlider::on_change_color_mode ( bool is_dark)
1636 {
1638}
static bool is_dark()
Definition TextureImportDialog.cpp:85

References is_dark(), and m_is_dark.

Referenced by Slic3r::GUI::GLCanvas3D::on_change_color_mode().

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

◆ on_mouse_wheel()

void Slic3r::GUI::IMSlider::on_mouse_wheel ( wxMouseEvent & evt)
1645 {
1646 auto moves_slider_window = ImGui::FindWindowByName("moves_slider");
1647 auto layers_slider_window = ImGui::FindWindowByName("laysers_slider");
1648 if (!moves_slider_window || !layers_slider_window) {
1649 BOOST_LOG_TRIVIAL(info) << "Couldn't find slider window";
1650 return;
1651 }
1652
1653 ImGuiWrapper& imgui = *wxGetApp().imgui();
1654
1655 float wheel = evt.GetWheelRotation();
1656 // mac trackpads trigger this event with value 0 when right-clicking with two fingers
1657 if (wheel == 0.0f)
1658 return;
1659 wheel = wheel > 0 ? 1.0f : -1.0f;
1660
1661#ifdef __WXOSX__
1662 if (wxGetKeyState(WXK_SHIFT)) {
1663 wheel *= -5;
1664 }
1665 else if (wxGetKeyState(WXK_RAW_CONTROL)) {
1666 wheel *= 5;
1667 }
1668#else
1669 if (wxGetKeyState(WXK_COMMAND) || wxGetKeyState(WXK_SHIFT))
1670 wheel *= 5;
1671#endif
1672 if (is_horizontal()) {
1673 if( evt.GetPosition().x > moves_slider_window->Pos.x &&
1674 evt.GetPosition().x < moves_slider_window->Pos.x + moves_slider_window->Size.x &&
1675 evt.GetPosition().y > moves_slider_window->Pos.y &&
1676 evt.GetPosition().y < moves_slider_window->Pos.y + moves_slider_window->Size.y){
1677 const int new_pos = GetHigherValue() + wheel;
1678 SetHigherValue(new_pos);
1679 set_as_dirty();
1680 imgui.set_requires_extra_frame();
1681 }
1682 }
1683 else {
1684 if (evt.GetPosition().x > layers_slider_window->Pos.x &&
1685 evt.GetPosition().x < layers_slider_window->Pos.x + layers_slider_window->Size.x &&
1686 evt.GetPosition().y > layers_slider_window->Pos.y &&
1687 evt.GetPosition().y < layers_slider_window->Pos.y + layers_slider_window->Size.y) {
1688 if (is_one_layer()) {
1689 const int new_pos = GetHigherValue() + wheel;
1690 SetHigherValue(new_pos);
1691 m_one_layer_value = new_pos; // ORCA backup value for single layer mode
1692 }
1693 else {
1694 const int new_pos = m_selection == ssLower ? GetLowerValue() + wheel : GetHigherValue() + wheel;
1695 m_selection == ssLower ? SetLowerValue(new_pos) : SetHigherValue(new_pos);
1696 }
1697 set_as_dirty();
1698 imgui.set_requires_extra_frame();
1699 }
1700 }
1701}
int m_one_layer_value
Definition IMSlider.hpp:190
bool is_one_layer() const
Definition IMSlider.hpp:111
void set_as_dirty(bool dirty=true)
Definition IMSlider.hpp:128

References GetHigherValue(), GetLowerValue(), is_horizontal(), is_one_layer(), m_one_layer_value, m_selection, set_as_dirty(), Slic3r::GUI::ImGuiWrapper::set_requires_extra_frame(), SetHigherValue(), SetLowerValue(), Slic3r::GUI::ssLower, and Slic3r::GUI::wxMouseEvent.

Referenced by Slic3r::GUI::GLCanvas3D::on_mouse_wheel().

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

◆ post_ticks_changed_event()

void Slic3r::GUI::IMSlider::post_ticks_changed_event ( CustomGCode::Type type = CustomGCode::Unknown)

References m_is_need_post_tick_changed_event, and m_tick_change_event_type.

Referenced by add_code_as_tick(), add_custom_gcode(), delete_tick(), and SetTicksValues().

Here is the caller graph for this function:

◆ render()

bool Slic3r::GUI::IMSlider::render ( int canvas_width,
int canvas_height )
1260{
1261 bool result = false;
1262 ImGuiWrapper &imgui = *wxGetApp().imgui();
1263 /* style and colors */
1264 ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_WindowBorderSize, 0);
1265 ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
1266 ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
1267 ImGui::PushStyleColor(ImGuiCol_::ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
1268 ImGui::PushStyleColor(ImGuiCol_::ImGuiCol_Text, ImGuiWrapper::COL_ORCA); // ORCA: Use orca color for slider value text
1269
1270 int windows_flag = ImGuiWindowFlags_NoTitleBar
1271 | ImGuiWindowFlags_NoCollapse
1272 | ImGuiWindowFlags_NoMove
1273 | ImGuiWindowFlags_NoResize
1274 | ImGuiWindowFlags_NoScrollbar
1275 | ImGuiWindowFlags_NoScrollWithMouse;
1276
1277 float scale = (float) wxGetApp().em_unit() / 10.0f;
1278
1279 if (is_horizontal()) {
1280 ImVec2 size = ImVec2(canvas_width - 2 * std::max(LEFT_MARGIN * m_scale, 0.2f * canvas_width), HORIZONTAL_SLIDER_WINDOW_HEIGHT * m_scale);
1281 imgui.set_next_window_pos(0.5f * static_cast<float>(canvas_width), canvas_height, ImGuiCond_Always, 0.5f, 1.0f);
1282 imgui.begin(std::string("moves_slider"), windows_flag);
1283 int value = GetHigherValue();
1284 if (horizontal_slider("moves_slider", &value, GetMinValue(), GetMaxValue(), size, scale)) {
1285 result = true;
1286 SetHigherValue(value);
1287 }
1288 imgui.end();
1289 } else {
1290 ImVec2 size = ImVec2(VERTICAL_SLIDER_WINDOW_WIDTH * m_scale, 0.8f * canvas_height);
1291 imgui.set_next_window_pos(canvas_width, 0.5f * static_cast<float>(canvas_height), ImGuiCond_Always, 1.0f, 0.5f);
1292 imgui.begin(std::string("laysers_slider"), windows_flag);
1293
1294 int higher_value = GetHigherValue();
1295 int lower_value = GetLowerValue();
1296 std::string higher_label = get_label(m_higher_value);
1297 std::string lower_label = get_label(m_lower_value);
1298 int temp_higher_value = higher_value;
1299 int temp_lower_value = lower_value;
1300 if (vertical_slider("laysers_slider", &higher_value, &lower_value, higher_label, lower_label, GetMinValue(), GetMaxValue(),
1301 size, m_selection, is_one_layer(), scale)) {
1302 if (temp_higher_value != higher_value)
1303 SetHigherValue(higher_value);
1304 if (temp_lower_value != lower_value)
1305 SetLowerValue(lower_value);
1306 result = true;
1307 }
1308 render_menu();
1309 imgui.end();
1310
1311 imgui.set_next_window_pos(canvas_width, canvas_height, ImGuiCond_Always, 1.0f, 1.0f);
1312 ImGui::SetNextWindowSize((ONE_LAYER_BUTTON_SIZE + ONE_LAYER_MARGIN) * m_scale, 0);
1313 imgui.begin(std::string("one_layer_button"), windows_flag);
1314 ImTextureID normal_id = m_is_dark ?
1317 ImTextureID hover_id = m_is_dark ?
1320 if (ImGui::ImageButton3(normal_id, hover_id, ONE_LAYER_BUTTON_SIZE * m_scale)) {
1322 }
1323 imgui.end();
1324 }
1325
1326 ImGui::PopStyleVar(3);
1327 ImGui::PopStyleColor(2);
1328
1329 return result;
1330}
bool switch_one_layer_mode()
Definition IMSlider.cpp:487
bool horizontal_slider(const char *str_id, int *v, int v_min, int v_max, const ImVec2 &size, float scale=1.0)
Definition IMSlider.cpp:523
bool vertical_slider(const char *str_id, int *higher_value, int *lower_value, std::string &higher_label, std::string &lower_label, int v_min, int v_max, const ImVec2 &size, SelectedSlider &selection, bool one_layer_flag=false, float scale=1.0f)
Definition IMSlider.cpp:915
void render_menu()
Definition IMSlider.cpp:1494
static const ImVec4 COL_ORCA
Definition ImGuiWrapper.hpp:408
static const float HORIZONTAL_SLIDER_WINDOW_HEIGHT
Definition IMSlider.cpp:59
static const float LEFT_MARGIN
Definition IMSlider.cpp:58
static const float VERTICAL_SLIDER_WINDOW_WIDTH
Definition IMSlider.cpp:61

References Slic3r::GUI::ImGuiWrapper::begin(), Slic3r::GUI::ImGuiWrapper::COL_ORCA, Slic3r::GUI::ImGuiWrapper::end(), get_label(), GetHigherValue(), GetLowerValue(), GetMaxValue(), GetMinValue(), horizontal_slider(), Slic3r::GUI::HORIZONTAL_SLIDER_WINDOW_HEIGHT, is_horizontal(), is_one_layer(), Slic3r::GUI::LEFT_MARGIN, m_higher_value, m_is_dark, m_lower_value, m_one_layer_off_dark_id, m_one_layer_off_hover_dark_id, m_one_layer_off_hover_id, m_one_layer_off_id, m_one_layer_on_dark_id, m_one_layer_on_hover_dark_id, m_one_layer_on_hover_id, m_one_layer_on_id, m_scale, m_selection, Slic3r::GUI::ONE_LAYER_BUTTON_SIZE, Slic3r::GUI::ONE_LAYER_MARGIN, render_menu(), scale(), Slic3r::GUI::ImGuiWrapper::set_next_window_pos(), SetHigherValue(), SetLowerValue(), switch_one_layer_mode(), vertical_slider(), and Slic3r::GUI::VERTICAL_SLIDER_WINDOW_WIDTH.

Here is the call graph for this function:

◆ render_add_menu()

void Slic3r::GUI::IMSlider::render_add_menu ( )
protected
1522{
1523 int extruder_num = m_extruder_colors.size();
1524
1525 if (m_show_menu) {
1526 ImGui::OpenPopup("slider_add_menu_popup");
1527 m_show_menu = false;
1528 }
1529 if (ImGui::BeginPopup("slider_add_menu_popup", ImGuiWindowFlags_NoMove)) {
1530 bool menu_item_enable = m_draw_mode != dmSequentialFffPrint;
1531 bool hovered = false;
1532 {
1533 if (menu_item_with_icon(_u8L("Add Pause").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable, &hovered)) {
1535 }
1536 if (hovered) { show_tooltip(_u8L("Insert a pause command at the beginning of this layer.")); }
1537
1538
1539 if (menu_item_with_icon(_u8L("Add Custom G-code").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable, &hovered)) {
1541 }
1542 if (hovered) { show_tooltip(_u8L("Insert custom G-code at the beginning of this layer.")); }
1543
1544 if (!gcode(Template).empty()) {
1545 if (menu_item_with_icon(_u8L("Add Custom Template").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable, &hovered)) {
1547 }
1548 if (hovered) { show_tooltip(_u8L("Insert template custom G-code at the beginning of this layer.")); }
1549 }
1550
1551 if (menu_item_with_icon(_u8L("Jump to layer").c_str(), "")) {
1553 }
1554 }
1555
1556 //BBS render this menu item only when extruder_num > 1
1557 if (extruder_num > 1) {
1558 if (!m_can_change_color) {
1559 begin_menu(_u8L("Change Filament").c_str(), false);
1560 }
1561 else if (begin_menu(_u8L("Change Filament").c_str())) {
1562 for (int i = 0; i < extruder_num; i++) {
1564 ImU32 icon_clr = ImGuiWrapper::to_ImU32(rgba);
1565 if (rgba.a() == 0)
1566 icon_clr = 0;
1567 if (menu_item_with_icon(into_u8(wxString::Format(_L("Filament %d"), i + 1)).c_str(), "", ImVec2(14, 14) * m_scale, icon_clr, false, true, &hovered)) add_code_as_tick(ToolChange, i + 1);
1568 if (hovered) { show_tooltip(_u8L("Change filament at the beginning of this layer.")); }
1569 }
1570 end_menu();
1571 }
1572 }
1573
1574 ImGui::EndPopup();
1575 }
1576}
bool m_can_change_color
Definition IMSlider.hpp:231
void add_code_as_tick(CustomGCode::Type type, int selected_extruder=-1)
Definition IMSlider.cpp:424
bool m_show_menu
Definition IMSlider.hpp:198
bool m_show_custom_gcode_window
Definition IMSlider.hpp:199
bool m_show_go_to_layer_dialog
Definition IMSlider.hpp:200
bool menu_item_with_icon(const char *label, const char *shortcut, ImVec2 icon_size, ImU32 icon_color, bool selected, bool enabled, bool *hovered)
Definition ImGuiWrapper.cpp:1803
bool begin_menu(const char *label, bool enabled)
Definition ImGuiWrapper.cpp:1639
void end_menu()
Definition ImGuiWrapper.cpp:1798
@ hovered
Definition GLGizmoEmboss.cpp:223
#define _u8L(s)
Definition I18N.hpp:11

References _L, _u8L, Slic3r::ColorRGBA::a(), add_code_as_tick(), Slic3r::GUI::begin_menu(), Slic3r::GUI::decode_color_to_float_array(), Slic3r::GUI::dmSequentialFffPrint, Slic3r::empty(), Slic3r::GUI::end_menu(), Slic3r::GUI::gcode(), Slic3r::GUI::into_u8(), m_can_change_color, m_draw_mode, m_extruder_colors, m_scale, m_show_custom_gcode_window, m_show_go_to_layer_dialog, m_show_menu, Slic3r::GUI::menu_item_with_icon(), Slic3r::CustomGCode::PausePrint, show_tooltip(), Slic3r::CustomGCode::Template, Slic3r::GUI::ImGuiWrapper::to_ImU32(), and Slic3r::CustomGCode::ToolChange.

Referenced by render_menu().

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

◆ render_edit_menu()

void Slic3r::GUI::IMSlider::render_edit_menu ( const TickCode & tick)
protected
1579{
1580 if (m_show_menu) {
1581 ImGui::OpenPopup("slider_edit_menu_popup");
1582 m_show_menu = false;
1583 }
1584 if (ImGui::BeginPopup("slider_edit_menu_popup", ImGuiWindowFlags_NoMove)) {
1585 switch (tick.type)
1586 {
1588 if (menu_item_with_icon(_u8L("Delete Pause").c_str(), "")) {
1589 delete_tick(tick);
1590 }
1591 break;
1593 if (!gcode(Template).empty()) {
1594 if (menu_item_with_icon(_u8L("Delete Custom Template").c_str(), "")) {
1595 delete_tick(tick);
1596 }
1597 }
1598 break;
1600 if (menu_item_with_icon(_u8L("Edit Custom G-code").c_str(), "")) {
1602 }
1603 if (menu_item_with_icon(_u8L("Delete Custom G-code").c_str(), "")) {
1604 delete_tick(tick);
1605 }
1606 break;
1608 int extruder_num = m_extruder_colors.size();
1609 if (extruder_num > 1) {
1610 if (!m_can_change_color) {
1611 begin_menu(_u8L("Change Filament").c_str(), false);
1612 }
1613 else if (begin_menu(_u8L("Change Filament").c_str())) {
1614 for (int i = 0; i < extruder_num; i++) {
1616 ImU32 icon_clr = ImGuiWrapper::to_ImU32(rgba);
1617 if (menu_item_with_icon(into_u8(wxString::Format(_L("Filament %d"), i + 1)).c_str(), "", ImVec2(14, 14) * m_scale, icon_clr)) add_code_as_tick(ToolChange, i + 1);
1618 }
1619 end_menu();
1620 }
1621 if (menu_item_with_icon(_u8L("Delete Filament Change").c_str(), "")) {
1622 delete_tick(tick);
1623 }
1624 }
1625 break;
1626 }
1629 default:
1630 break;
1631 }
1632 ImGui::EndPopup();
1633 }
1634}
void delete_tick(const TickCode &tick)
Definition IMSlider.cpp:451

References _L, _u8L, add_code_as_tick(), Slic3r::GUI::begin_menu(), Slic3r::CustomGCode::ColorChange, Slic3r::CustomGCode::Custom, Slic3r::GUI::decode_color_to_float_array(), delete_tick(), Slic3r::empty(), Slic3r::GUI::end_menu(), Slic3r::GUI::gcode(), Slic3r::GUI::into_u8(), m_can_change_color, m_extruder_colors, m_scale, m_show_custom_gcode_window, m_show_menu, Slic3r::GUI::menu_item_with_icon(), Slic3r::CustomGCode::PausePrint, Slic3r::CustomGCode::Template, Slic3r::GUI::ImGuiWrapper::to_ImU32(), Slic3r::CustomGCode::ToolChange, Slic3r::GUI::TickCode::type, and Slic3r::CustomGCode::Unknown.

Referenced by render_menu().

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

◆ render_go_to_layer_dialog()

void Slic3r::GUI::IMSlider::render_go_to_layer_dialog ( )
protected
1415{
1417 ImGui::OpenPopup((_u8L("Jump to layer")).c_str());
1418
1419 ImGuiWrapper& imgui = *wxGetApp().imgui();
1420 ImVec2 center = ImGui::GetMainViewport()->GetCenter();
1421 ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
1422 static bool set_focus = true;
1423
1424 imgui.push_menu_style(m_scale);
1425 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10) * m_scale);
1426 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * m_scale);
1427 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 3) * m_scale);
1428 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 7) * m_scale);
1429 ImGui::PushStyleColor(ImGuiCol_TitleBgActive, m_is_dark ? ImVec4(54 / 255.0f, 54 / 255.0f, 60 / 255.0f, 1.00f) : ImVec4(245 / 255.0f, 245 / 255.0f, 245 / 255.0f, 1.00f));
1430 ImGui::GetCurrentContext()->DimBgRatio = 1.0f;
1431 int windows_flag =
1432 ImGuiWindowFlags_NoCollapse
1433 | ImGuiWindowFlags_AlwaysAutoResize
1434 | ImGuiWindowFlags_NoResize
1435 | ImGuiWindowFlags_NoScrollbar
1436 | ImGuiWindowFlags_NoScrollWithMouse;
1437 if (ImGui::BeginPopupModal((_u8L("Jump to layer")).c_str(), NULL, windows_flag))
1438 {
1439 imgui.text(_u8L("Please enter the layer number.") + " (" + std::to_string(m_min_value + 1) + " - " + std::to_string(m_max_value + 1) + "):");
1440 if (ImGui::IsMouseClicked(0)) {
1441 set_focus = false;
1442 }
1443 if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
1444 wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
1445 ImGui::SetKeyboardFocusHere(0);
1446 }
1447 ImGui::InputText("##input_layer_number", m_layer_number, sizeof(m_layer_number));
1448
1449 ImGui::NewLine();
1450 ImGui::SameLine(GImGui->Style.WindowPadding.x * 8);
1451 imgui.push_confirm_button_style();
1452 bool disable_button = false;
1453 if (strlen(m_layer_number) == 0)
1454 disable_button = true;
1455 else {
1456 for (size_t i = 0; i < strlen(m_layer_number); i++)
1457 if (!isdigit(m_layer_number[i]))
1458 disable_button = true;
1459 if (!disable_button && (m_min_value > atoi(m_layer_number) - 1 || atoi(m_layer_number) - 1 > m_max_value))
1460 disable_button = true;
1461 }
1462 if (disable_button) {
1463 ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
1464 imgui.push_button_disable_style();
1465 }
1466 if (imgui.bbl_button(_L("OK")) || (!disable_button && ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Enter)))) {
1467 do_go_to_layer(atoi(m_layer_number) - 1);
1469 ImGui::CloseCurrentPopup();
1470 set_focus = true;
1471 }
1472 if (disable_button) {
1473 ImGui::PopItemFlag();
1474 imgui.pop_button_disable_style();
1475 }
1476 imgui.pop_confirm_button_style();
1477
1478 ImGui::SameLine();
1479 imgui.push_cancel_button_style();
1480 if (imgui.bbl_button(_L("Cancel")) || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
1482 ImGui::CloseCurrentPopup();
1483 set_focus = true;
1484 }
1485 imgui.pop_cancel_button_style();
1486
1487 ImGui::EndPopup();
1488 }
1489 ImGui::PopStyleVar(4);
1490 ImGui::PopStyleColor();
1491 imgui.pop_menu_style();
1492}
void do_go_to_layer(size_t layer_number)
Definition IMSlider.cpp:1409
char m_layer_number[64]
Definition IMSlider.hpp:239
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382

References _L, _u8L, Slic3r::GUI::ImGuiWrapper::bbl_button(), Slic3r::center(), do_go_to_layer(), m_is_dark, m_layer_number, m_max_value, m_min_value, m_scale, m_show_go_to_layer_dialog, Slic3r::GUI::ImGuiWrapper::pop_button_disable_style(), Slic3r::GUI::ImGuiWrapper::pop_cancel_button_style(), Slic3r::GUI::ImGuiWrapper::pop_confirm_button_style(), Slic3r::GUI::ImGuiWrapper::pop_menu_style(), Slic3r::GUI::ImGuiWrapper::push_button_disable_style(), Slic3r::GUI::ImGuiWrapper::push_cancel_button_style(), Slic3r::GUI::ImGuiWrapper::push_confirm_button_style(), Slic3r::GUI::ImGuiWrapper::push_menu_style(), and Slic3r::GUI::ImGuiWrapper::text().

Referenced by render_menu().

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

◆ render_input_custom_gcode()

void Slic3r::GUI::IMSlider::render_input_custom_gcode ( std::string custom_gcode = "")
protected
1333{
1335 ImGui::OpenPopup((_u8L("Custom G-code")).c_str());
1336
1337 ImGuiWrapper& imgui = *wxGetApp().imgui();
1338 ImVec2 center = ImGui::GetMainViewport()->GetCenter();
1339 static bool set_focus = true;
1340
1341 ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
1342 imgui.push_menu_style(m_scale);
1343 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10) * m_scale);
1344 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * m_scale);
1345 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 3) * m_scale);
1346 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 7) * m_scale);
1347 ImGui::PushStyleColor(ImGuiCol_TitleBgActive, m_is_dark ? ImVec4(54 / 255.0f, 54 / 255.0f, 60 / 255.0f, 1.00f) : ImVec4(245 / 255.0f, 245 / 255.0f, 245 / 255.0f, 1.00f));
1348 ImGui::GetCurrentContext()->DimBgRatio = 1.0f;
1349 int windows_flag =
1350 ImGuiWindowFlags_NoCollapse
1351 | ImGuiWindowFlags_AlwaysAutoResize
1352 | ImGuiWindowFlags_NoResize
1353 | ImGuiWindowFlags_NoScrollbar
1354 | ImGuiWindowFlags_NoScrollWithMouse;
1355 if (ImGui::BeginPopupModal((_u8L("Custom G-code")).c_str(), NULL, windows_flag))
1356 {
1357 imgui.text(_u8L("Enter Custom G-code used on current layer:"));
1358 if (ImGui::IsMouseClicked(0)) {
1359 set_focus = false;
1360 }
1361 if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
1362 wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
1363 ImGui::SetKeyboardFocusHere(0);
1364 strcpy(m_custom_gcode, custom_gcode.c_str());
1365 }
1366 const int text_height = 6;
1367
1368 ImGui::InputTextMultiline("##text", m_custom_gcode, sizeof(m_custom_gcode), ImVec2(-1, ImGui::GetTextLineHeight() * text_height));
1369
1370 ImGui::NewLine();
1371 ImGui::SameLine(ImGui::GetStyle().WindowPadding.x * 14);
1372 imgui.push_confirm_button_style();
1373
1374 bool disable_button = false;
1375 if (strlen(m_custom_gcode) == 0)
1376 disable_button = true;
1377 if (disable_button) {
1378 ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
1379 imgui.push_button_disable_style();
1380 }
1381 if (imgui.bbl_button(_L("OK"))) {
1384 ImGui::CloseCurrentPopup();
1385 set_focus = true;
1386 }
1387 if (disable_button) {
1388 ImGui::PopItemFlag();
1389 imgui.pop_button_disable_style();
1390 }
1391 imgui.pop_confirm_button_style();
1392
1393 ImGui::SameLine();
1394 imgui.push_cancel_button_style();
1395 if (imgui.bbl_button(_L("Cancel")) || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
1397 ImGui::CloseCurrentPopup();
1398 set_focus = true;
1399 }
1400 imgui.pop_cancel_button_style();
1401
1402 ImGui::EndPopup();
1403 }
1404 ImGui::PopStyleVar(4);
1405 ImGui::PopStyleColor();
1406 imgui.pop_menu_style();
1407}
void add_custom_gcode(std::string custom_gcode)
Definition IMSlider.cpp:409
char m_custom_gcode[1024]
Definition IMSlider.hpp:238

References _L, _u8L, add_custom_gcode(), Slic3r::GUI::ImGuiWrapper::bbl_button(), Slic3r::center(), m_custom_gcode, m_is_dark, m_scale, m_show_custom_gcode_window, Slic3r::GUI::ImGuiWrapper::pop_button_disable_style(), Slic3r::GUI::ImGuiWrapper::pop_cancel_button_style(), Slic3r::GUI::ImGuiWrapper::pop_confirm_button_style(), Slic3r::GUI::ImGuiWrapper::pop_menu_style(), Slic3r::GUI::ImGuiWrapper::push_button_disable_style(), Slic3r::GUI::ImGuiWrapper::push_cancel_button_style(), Slic3r::GUI::ImGuiWrapper::push_confirm_button_style(), Slic3r::GUI::ImGuiWrapper::push_menu_style(), and Slic3r::GUI::ImGuiWrapper::text().

Referenced by render_menu().

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

◆ render_menu()

void Slic3r::GUI::IMSlider::render_menu ( )
protected
1494 {
1495 if (!m_menu_enable)
1496 return;
1497
1499 ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_ChildRounding, 4.0f * m_scale);
1500
1501 auto tick_it = GetSelection() == ssHigher ? m_ticks.ticks.find(TickCode{ GetHigherValue() }) :
1502 GetSelection() == ssLower ? m_ticks.ticks.find(TickCode{ GetLowerValue() }) :
1503 m_ticks.ticks.end();
1504 std::string custom_code;
1505 if (tick_it != m_ticks.ticks.end()) {
1506 if (tick_it->type == CustomGCode::Custom)
1507 custom_code = tick_it->extra;
1508 render_edit_menu(*tick_it);
1509 }
1510 else {
1511 render_add_menu();
1512 }
1513
1514 ImGui::PopStyleVar(1);
1516
1517 render_input_custom_gcode(custom_code);
1519}
bool m_menu_enable
Definition IMSlider.hpp:197
void render_go_to_layer_dialog()
Definition IMSlider.cpp:1414
void render_input_custom_gcode(std::string custom_gcode="")
Definition IMSlider.cpp:1332
static void push_menu_style(const float scale)
Definition ImGuiWrapper.cpp:2764
static void pop_menu_style()
Definition ImGuiWrapper.cpp:2787

References Slic3r::CustomGCode::Custom, GetHigherValue(), GetLowerValue(), GetSelection(), m_menu_enable, m_scale, m_ticks, Slic3r::GUI::ImGuiWrapper::pop_menu_style(), Slic3r::GUI::ImGuiWrapper::push_menu_style(), render_add_menu(), render_edit_menu(), render_go_to_layer_dialog(), render_input_custom_gcode(), Slic3r::GUI::ssHigher, and Slic3r::GUI::ssLower.

Referenced by render().

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

◆ reset_post_tick_event()

void Slic3r::GUI::IMSlider::reset_post_tick_event ( bool val = false)
inline

References m_is_need_post_tick_changed_event, m_tick_change_event_type, and Slic3r::CustomGCode::Unknown.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay().

Here is the caller graph for this function:

◆ set_as_dirty()

void Slic3r::GUI::IMSlider::set_as_dirty ( bool dirty = true)
inline
128{ m_dirty = dirty; }

References m_dirty.

Referenced by Slic3r::GUI::GLCanvas3D::_render_gcode_overlay(), Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::go_to_layer(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), on_mouse_wheel(), SetHigherValue(), SetLayersTimes(), SetLowerValue(), SetMaxValue(), SetSelectionSpan(), SetTicksValues(), and switch_one_layer_mode().

Here is the caller graph for this function:

◆ set_menu_enable()

void Slic3r::GUI::IMSlider::set_menu_enable ( bool enable = true)
inline
141{ m_menu_enable = enable; }

References m_menu_enable.

◆ set_render_as_disabled()

void Slic3r::GUI::IMSlider::set_render_as_disabled ( bool value)
inline
107{ m_render_as_disabled = value; }

References m_render_as_disabled.

◆ set_scale()

void Slic3r::GUI::IMSlider::set_scale ( float scale = 1.0)
1641{
1642 if(m_scale != scale) m_scale = scale;
1643}

References m_scale, and scale().

Referenced by Slic3r::GUI::GLCanvas3D::_check_and_update_toolbar_icon_scale().

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

◆ SetDrawMode() [1/2]

void Slic3r::GUI::IMSlider::SetDrawMode ( bool is_sequential_print)
359{
360 m_draw_mode = is_sequential_print ? dmSequentialFffPrint :
361 dmRegular;
363}
@ dmRegular
Definition IMSlider.hpp:49

References Slic3r::GUI::dmRegular, Slic3r::GUI::dmSequentialFffPrint, m_can_change_color, and m_draw_mode.

Referenced by Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ SetDrawMode() [2/2]

void Slic3r::GUI::IMSlider::SetDrawMode ( DrawMode mode)
inline
97{ m_draw_mode = mode; }

References m_draw_mode.

◆ SetExtraStyle()

void Slic3r::GUI::IMSlider::SetExtraStyle ( long style)
inline

References m_extra_style, and style.

◆ SetExtruderColors()

void Slic3r::GUI::IMSlider::SetExtruderColors ( const std::vector< std::string > & extruder_colors)
387{
388 m_extruder_colors = extruder_colors;
389}

References m_extruder_colors.

Referenced by Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ SetHigherValue()

void Slic3r::GUI::IMSlider::SetHigherValue ( const int higher_val)
225{
226 m_higher_value = higher_val;
228 set_as_dirty();
229}

References correct_higher_value(), m_higher_value, and set_as_dirty().

Referenced by do_go_to_layer(), Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::go_to_layer(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), on_mouse_wheel(), render(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::set_top_layer(), and switch_one_layer_mode().

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

◆ SetKoefForLabels()

void Slic3r::GUI::IMSlider::SetKoefForLabels ( const double koef)
inline
87{ m_label_koef = koef; }

References m_label_koef.

◆ SetLayersTimes() [1/2]

void Slic3r::GUI::IMSlider::SetLayersTimes ( const std::vector< double > & layers_times)
352{
353 m_is_wipe_tower = false;
354 m_layers_times = layers_times;
355 for (size_t i = 1; i < m_layers_times.size(); i++) m_layers_times[i] += m_layers_times[i - 1];
356}

References m_is_wipe_tower, and m_layers_times.

◆ SetLayersTimes() [2/2]

void Slic3r::GUI::IMSlider::SetLayersTimes ( const std::vector< float > & layers_times,
float total_time )
328{
329 m_layers_times.clear();
330 if (layers_times.empty()) return;
331 m_layers_times.resize(layers_times.size(), 0.0);
332 m_layers_times[0] = layers_times[0];
333 for (size_t i = 1; i < layers_times.size(); i++) m_layers_times[i] = m_layers_times[i - 1] + layers_times[i];
334
335 // Erase duplicates values from m_values and save it to the m_layers_values
336 // They will be used for show the correct estimated time for MM print, when "No sparce layer" is enabled
337 if (m_is_wipe_tower && m_values.size() != m_layers_times.size()) {
339 sort(m_layers_values.begin(), m_layers_values.end());
340 m_layers_values.erase(unique(m_layers_values.begin(), m_layers_values.end()), m_layers_values.end());
341
342 // When whipe tower is used to the end of print, there is one layer which is not marked in layers_times
343 // So, add this value from the total print time value
344 if (m_layers_values.size() != m_layers_times.size())
345 for (size_t i = m_layers_times.size(); i < m_layers_values.size(); i++) m_layers_times.push_back(total_time);
346 set_as_dirty();
347 set_as_dirty();
348 }
349}

References m_is_wipe_tower, m_layers_times, m_layers_values, m_values, and set_as_dirty().

Referenced by Slic3r::GUI::Preview::update_layers_slider().

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

◆ SetLowerValue()

void Slic3r::GUI::IMSlider::SetLowerValue ( const int lower_val)
218{
219 m_lower_value = lower_val;
221 set_as_dirty();
222}
void correct_lower_value()
Definition IMSlider.cpp:1703

References correct_lower_value(), m_lower_value, and set_as_dirty().

Referenced by do_go_to_layer(), Slic3r::GUI::anonymous_namespace{NativeCommands.cpp}::go_to_layer(), Slic3r::GUI::GLCanvas3D::handle_shortcut(), on_mouse_wheel(), render(), and switch_one_layer_mode().

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

◆ SetManipulationMode()

void Slic3r::GUI::IMSlider::SetManipulationMode ( CustomGCode::Mode mode)
inline
100{ m_mode = mode; }

References m_mode.

◆ SetMaxValue()

void Slic3r::GUI::IMSlider::SetMaxValue ( const int max_value)
245{
246 m_max_value = max_value;
247 set_as_dirty();
248}

References m_max_value, and set_as_dirty().

Referenced by Slic3r::GUI::Preview::update_layers_slider().

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

◆ SetModeAndOnlyExtruder()

void Slic3r::GUI::IMSlider::SetModeAndOnlyExtruder ( const bool is_one_extruder_printed_model,
const int only_extruder,
bool can_change_color )
366{
367 m_mode = !is_one_extruder_printed_model ? MultiExtruder : only_extruder < 0 ? SingleExtruder : MultiAsSingle;
368 if (!m_ticks.mode || (m_ticks.empty() && m_ticks.mode != m_mode)) m_ticks.mode = m_mode;
369 m_only_extruder = only_extruder;
370
372
374
375 auto config = wxGetApp().preset_bundle->full_config();
376 m_is_spiral_vase = config.option<ConfigOptionBool>("spiral_mode")->value;
377
378 m_can_change_color = can_change_color && !m_is_spiral_vase;
379
380 // close opened menu window after reslice
381 m_show_menu = false;
384}
void UseDefaultColors(bool def_colors_on)
Definition IMSlider.hpp:116
bool m_is_spiral_vase
Definition IMSlider.hpp:203

References m_can_change_color, m_is_spiral_vase, m_is_wipe_tower, m_mode, m_only_extruder, m_show_custom_gcode_window, m_show_go_to_layer_dialog, m_show_menu, m_ticks, Slic3r::CustomGCode::MultiAsSingle, Slic3r::CustomGCode::MultiExtruder, Slic3r::CustomGCode::SingleExtruder, and UseDefaultColors().

Referenced by Slic3r::GUI::Preview::update_layers_slider_mode().

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

◆ SetSelectionSpan()

void Slic3r::GUI::IMSlider::SetSelectionSpan ( const int lower_val,
const int higher_val )
232{
233 m_lower_value = std::max(lower_val, m_min_value);
234 m_higher_value = std::max(std::min(higher_val, m_max_value), m_lower_value);
236
237 // ORCA reset single layer position when min max values changed
238 // This will trigger when print height changed. but stays same on reslicing if layer count is same
240
241 set_as_dirty();
242}

References m_higher_value, m_is_one_layer, m_lower_value, m_max_value, m_min_value, m_one_layer_value, and set_as_dirty().

Referenced by Slic3r::GUI::Preview::refresh_belt_view(), and Slic3r::GUI::Preview::update_layers_slider().

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

◆ SetSliderAlternateValues()

void Slic3r::GUI::IMSlider::SetSliderAlternateValues ( const std::vector< double > & values)
inline
89{ m_alternate_values = values; }
std::vector< double > m_alternate_values
Definition IMSlider.hpp:236

References m_alternate_values.

◆ SetSliderValues()

void Slic3r::GUI::IMSlider::SetSliderValues ( const std::vector< double > & values)
251{
252 m_values = values;
253}

References m_values.

Referenced by Slic3r::GUI::Preview::update_layers_slider().

Here is the caller graph for this function:

◆ SetTicksValues()

void Slic3r::GUI::IMSlider::SetTicksValues ( const CustomGCode::Info & custom_gcode_per_print_z)
273{
274 if (m_values.empty()) {
275 m_ticks.mode = m_mode;
276 return;
277 }
278
279 static bool last_spiral_vase_status = false;
280
281 const bool was_empty = m_ticks.empty();
282
283 m_ticks.ticks.clear();
284 const std::vector<CustomGCode::Item> &heights = custom_gcode_per_print_z.gcodes;
285 for (auto h : heights) {
286 int tick = get_tick_from_value(h.print_z, true);
287 if (tick >= 0) m_ticks.ticks.emplace(TickCode{tick, h.type, h.extruder, h.color, h.extra});
288 }
289
290 if (m_ticks.has_tick_with_code(ToolChange) && !m_can_change_color) {
291 if (!wxGetApp().plater()->only_gcode_mode() && !wxGetApp().plater()->using_exported_file())
292 {
293 m_ticks.erase_all_ticks_with_code(ToolChange);
295 }
296 }
297
298 if (last_spiral_vase_status != m_is_spiral_vase) {
299 last_spiral_vase_status = m_is_spiral_vase;
300 if (!m_ticks.empty()) {
301 m_ticks.ticks.clear();
303 }
304 }
305
306 //auto has_tick_execpt = [this](CustomGCode::Type type) {
307 // for (const TickCode& tick : m_ticks.ticks)
308 // if (tick.type != type) return true;
309
310 // return false;
311 //};
312 if ((!m_ticks.empty() /*&& has_tick_execpt(PausePrint)*/) && m_draw_mode == dmSequentialFffPrint) {
313 for (auto it{ m_ticks.ticks.begin() }, end{ m_ticks.ticks.end() }; it != end;) {
314 if (true/*it->type != PausePrint*/)
315 it = m_ticks.ticks.erase(it);
316 else
317 ++it;
318 }
320 }
321
323
324 set_as_dirty();
325}
int get_tick_from_value(double value, bool force_lower_bound=false)
Definition IMSlider.cpp:1795
static Plater * plater()
Definition GUI_Factories.cpp:400

References Slic3r::custom_gcode_per_print_z, Slic3r::GUI::dmSequentialFffPrint, get_tick_from_value(), m_can_change_color, m_draw_mode, m_is_spiral_vase, m_mode, m_ticks, m_values, Slic3r::GUI::plater(), post_ticks_changed_event(), set_as_dirty(), and Slic3r::CustomGCode::ToolChange.

Referenced by Slic3r::GUI::Preview::update_layers_slider().

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

◆ show_go_to_layer()

void Slic3r::GUI::IMSlider::show_go_to_layer ( bool show)
inline

References m_show_go_to_layer_dialog.

Referenced by Slic3r::GUI::GLCanvas3D::handle_shortcut().

Here is the caller graph for this function:

◆ show_tooltip() [1/2]

void Slic3r::GUI::IMSlider::show_tooltip ( const std::string tooltip)
protected
829 {
830 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 6 * m_scale, 3 * m_scale });
831 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3 * m_scale);
832 ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
833 ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });
834 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.00f, 1.00f, 1.00f, 1.00f));
835 ImGui::BeginTooltip();
836 ImGui::TextUnformatted(tooltip.c_str());
837 ImGui::EndTooltip();
838 ImGui::PopStyleColor(3);
839 ImGui::PopStyleVar(2);
840}
static const ImVec4 COL_WINDOW_BACKGROUND
Definition ImGuiWrapper.hpp:388

References Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BACKGROUND, and m_scale.

◆ show_tooltip() [2/2]

void Slic3r::GUI::IMSlider::show_tooltip ( const TickCode & tick)
protected
842 {
843 // Use previous layer's complete time as current layer's tick time,
844 // since ticks are added at the beginning of current layer
845 std::string time_str = "";
846 // TODO: support first layer
847 if (tick.tick > 0) {
848 time_str = get_label(tick.tick - 1, ltEstimatedTime);
849 }
850 if (!time_str.empty()) {
851 time_str += "\n";
852 }
853
854 switch (tick.type)
855 {
857 break;
859 show_tooltip(time_str + _u8L("Pause:") + " \"" + gcode(PausePrint) + "\"");
860 break;
862 show_tooltip(time_str + _u8L("Change Filament"));
863 break;
865 show_tooltip(time_str + _u8L("Custom Template:") + " \"" + gcode(Template) + "\"");
866 break;
868 show_tooltip(time_str + _u8L("Custom G-code:") + " \"" + tick.extra + "\"");
869 break;
870 default:
871 break;
872 }
873}

References _u8L, Slic3r::CustomGCode::ColorChange, Slic3r::CustomGCode::Custom, Slic3r::GUI::TickCode::extra, Slic3r::GUI::gcode(), get_label(), Slic3r::GUI::ltEstimatedTime, Slic3r::CustomGCode::PausePrint, show_tooltip(), Slic3r::CustomGCode::Template, Slic3r::GUI::TickCode::tick, Slic3r::CustomGCode::ToolChange, and Slic3r::GUI::TickCode::type.

Referenced by draw_tick_on_mouse_position(), draw_ticks(), render_add_menu(), and show_tooltip().

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

◆ switch_one_layer_mode()

bool Slic3r::GUI::IMSlider::switch_one_layer_mode ( )
488{
490 return false;
491
493 if (!m_is_one_layer) { // DEACTIVATE
494 m_one_layer_value = GetHigherValue(); // ORCA Backup value on deactivate
496 SetHigherValue(m_max_value); // Higher value resets on toggling off one layer mode to show whole model
497 }else{ // ACTIVATE
498 // ORCA Ensure value fits range. value set in IMSlider::SetSelectionSpan but added this just in case
502 }
503 else if(GetHigherValue() == m_max_value) // ORCA Prefer backup value if higher value reseted
504 SetHigherValue(m_one_layer_value); // ORCA Restore value
505 else // ORCA Prefer higher value if user changed higher value. so it will show section on same view
506 SetHigherValue(GetHigherValue()); // ORCA use same position with higher value if user changed its position. visible section stays same when switching one layer mode with this
507 }
509 set_as_dirty();
510 return true;
511}

References GetHigherValue(), m_is_one_layer, m_max_value, m_min_value, m_one_layer_value, m_selection, m_show_custom_gcode_window, set_as_dirty(), SetHigherValue(), SetLowerValue(), Slic3r::GUI::ssHigher, and Slic3r::GUI::ssUndef.

Referenced by Slic3r::GUI::GLCanvas3D::handle_shortcut(), and render().

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

◆ UseDefaultColors()

void Slic3r::GUI::IMSlider::UseDefaultColors ( bool def_colors_on)
inline
116{ m_ticks.set_default_colors(def_colors_on); }

References m_ticks.

Referenced by SetModeAndOnlyExtruder().

Here is the caller graph for this function:

◆ vertical_slider()

bool Slic3r::GUI::IMSlider::vertical_slider ( const char * str_id,
int * higher_value,
int * lower_value,
std::string & higher_label,
std::string & lower_label,
int v_min,
int v_max,
const ImVec2 & size,
SelectedSlider & selection,
bool one_layer_flag = false,
float scale = 1.0f )
protected
916{
917 ImGuiWindow* window = ImGui::GetCurrentWindow();
918 if (window->SkipItems)
919 return false;
920
921 ImGuiContext& context = *GImGui;
922 const ImGuiID id = window->GetID(str_id);
923
924 const ImVec2 pos = window->DC.CursorPos;
925 const ImRect draw_region(pos, pos + size);
926 ImGui::ItemSize(draw_region);
927
928 const float text_dummy_height = 60.0f * scale * m_scale;
929
930 const float handle_radius = 12.0f * m_scale;
931 const float handle_border = 2.0f * m_scale;
932 const float line_width = 1.0f * m_scale;
933 const float line_length = 12.0f * m_scale;
934
935 const ImVec2 text_padding = ImVec2(5.0f, 2.0f) * m_scale;
936 ImVec2 text_size;
937
938 const ImU32 white_bg = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT;
939 const ImU32 handle_clr = BRAND_COLOR;
940 const ImU32 handle_border_clr = m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT;
941 const wxColour label_bg = StateColor::darkModeColorFor(wxGetApp().get_window_default_clr());
942 const wxColour label_bg_active = StateColor::darkModeColorFor(wxColour("#E5F0EE"));
943 const wxColour label_border = StateColor::darkModeColorFor(wxColour("#CECECE"));
944 const wxColour rail_inner_bg = m_is_dark ? StateColor::darkModeColorFor(wxColour("#CECECE")) : wxGetApp().get_highlight_default_clr();
945 const wxColour rail_border = m_is_dark ? StateColor::darkModeColorFor(wxColour("#F0F0F1")) : wxColour("#CECECE");
946 const ImU32 label_bg_clr = IM_COL32(label_bg.Red(), label_bg.Green(), label_bg.Blue(), 238);
947 const ImU32 label_bg_active_clr = IM_COL32(label_bg_active.Red(), label_bg_active.Green(), label_bg_active.Blue(), 246);
948 const ImU32 label_border_clr = IM_COL32(label_border.Red(), label_border.Green(), label_border.Blue(), 255);
949 const ImU32 label_shadow_clr = m_is_dark ? IM_COL32(0, 0, 0, 84) : IM_COL32(0, 0, 0, 38);
950 ImVec4 range_fill = ImGui::ColorConvertU32ToFloat4(BRAND_COLOR);
951 range_fill.w = (m_is_dark ? 210.0f : 190.0f) / 255.0f;
952 const ImU32 range_fill_clr = ImGui::GetColorU32(range_fill);
953 const ImU32 rail_inner_clr = IM_COL32(rail_inner_bg.Red(), rail_inner_bg.Green(), rail_inner_bg.Blue(), 255);
954 const ImU32 rail_border_clr = IM_COL32(rail_border.Red(), rail_border.Green(), rail_border.Blue(), 190);
955 // calculate slider groove size
956 const ImVec2 groove_start = ImVec2(pos.x + size.x - ONE_LAYER_MARGIN.x * m_scale - (ONE_LAYER_BUTTON_SIZE.x / 2) * m_scale * 0.5f - GROOVE_WIDTH * m_scale * 0.5f, pos.y + text_dummy_height);
957 const ImVec2 groove_size = ImVec2(GROOVE_WIDTH * m_scale, size.y - 2 * text_dummy_height);
958 const ImRect groove = ImRect(groove_start, groove_start + groove_size);
959 const ImRect bg_rect = ImRect(groove.Min - ImVec2(6.0f, 6.0f) * m_scale, groove.Max + ImVec2(6.0f, 6.0f) * m_scale);
960 const float mid_x = groove.GetCenter().x;
961 // ORCA: tune label box width to fit the slider window without overlapping the groove.
962 const float label_width_margin = 10.0f * m_scale;
963 const float max_label_width = std::max(0.0f,
964 groove.Min.x - draw_region.Min.x - label_width_margin * 2.0f - text_padding.x * 2.0f);
965
966 // Processing interacting
967 // set scrollable region
968 const ImRect region = ImRect(bg_rect.Min + ImVec2(0.0f, handle_radius), bg_rect.Max - ImVec2(0.0f, handle_radius));
969 const ImRect higher_slideable_region = ImRect(region.Min, region.Max - ImVec2(0, handle_radius));
970 const ImRect lower_slideable_region = ImRect(region.Min + ImVec2(0, handle_radius), region.Max);
971 const ImRect one_slideable_region = region;
972
973 // initialize the handles.
974 float higher_handle_pos = get_pos_from_value(v_min, v_max, *higher_value, higher_slideable_region);
975 ImRect higher_handle = ImRect(mid_x - handle_radius, higher_handle_pos - handle_radius, mid_x + handle_radius, higher_handle_pos + handle_radius);
976
977 float lower_handle_pos = get_pos_from_value(v_min, v_max, *lower_value, lower_slideable_region);
978 ImRect lower_handle = ImRect(mid_x - handle_radius, lower_handle_pos - handle_radius, mid_x + handle_radius, lower_handle_pos + handle_radius);
979
980 auto one_layer_handle = [&](int value) {
981 const float handle_pos = get_pos_from_value(v_min, v_max, value, one_slideable_region);
982 return ImRect(mid_x - handle_radius, handle_pos - handle_radius,
983 mid_x + handle_radius, handle_pos + handle_radius);
984 };
985 ImRect one_handle;
986 if (one_layer_flag)
987 one_handle = one_layer_handle(*higher_value);
988
989 // Label hit testing enables delta-based label drag without jumping to the mouse position.
990 SelectedSlider hovered_label = ssUndef;
991 const bool menu_open = ImGui::IsPopupOpen("slider_add_menu_popup") || ImGui::IsPopupOpen("slider_edit_menu_popup");
992 const ImVec2 higher_text_content_size = ImGui::CalcTextSize(into_u8(higher_label).c_str());
993 const ImVec2 lower_text_content_size = one_layer_flag ? ImVec2() : ImGui::CalcTextSize(into_u8(lower_label).c_str());
994 auto label_hit = [&](const ImRect& label_rect, SelectedSlider selection_value) {
995 if (!label_rect.Contains(context.IO.MousePos))
996 return;
997 hovered_label = selection_value;
998 };
999 auto range_label_rect = [&](const ImRect& handle, const ImVec2& content_size, bool top_label) {
1000 const ImVec2 text_size = ImVec2(max_label_width, content_size.y) + text_padding * 2.0f;
1001 const ImVec2 text_start = ImVec2(handle.Min.x - text_size.x - label_width_margin,
1002 top_label ? handle.GetCenter().y - text_size.y : handle.GetCenter().y);
1003 return ImRect(text_start, text_start + text_size + ImVec2(label_width_margin, 0.0f));
1004 };
1005 auto one_layer_label_rect = [&](const ImRect& handle) {
1006 const ImVec2 text_size = ImVec2(max_label_width, higher_text_content_size.y) + text_padding * 2.0f;
1007 const ImVec2 text_start = ImVec2(handle.Min.x - text_size.x - label_width_margin,
1008 handle.GetCenter().y - 0.5f * text_size.y);
1009 return ImRect(text_start, text_start + text_size);
1010 };
1011 auto draw_label = [&](const ImRect& rect, const ImVec2& content_size, const std::string& label, bool hovered, bool active) {
1012 const float rounding = 5.0f * m_scale;
1013 const ImU32 bg_clr = active ? label_bg_active_clr : label_bg_clr;
1014 const ImVec2 shadow_offset = ImVec2(2.0f, 2.0f) * m_scale;
1015 window->DrawList->AddRectFilled(rect.Min + shadow_offset, rect.Max + shadow_offset, label_shadow_clr, rounding);
1016 ImGui::RenderFrame(rect.Min, rect.Max, bg_clr, false, rounding);
1017 window->DrawList->AddRect(rect.Min, rect.Max, hovered ? handle_clr : label_border_clr, rounding, 0, hovered ? 1.5f * m_scale : 1.0f * m_scale);
1018 const ImVec2 rect_size = rect.GetSize();
1019 ImGui::RenderText(rect.Min + ImVec2((rect_size.x - content_size.x) * 0.5f,
1020 (rect_size.y - content_size.y) * 0.5f), label.c_str());
1021 };
1022 auto draw_handle = [&](const ImVec2& center) {
1023 window->DrawList->AddCircleFilled(center, handle_radius, handle_border_clr);
1024 window->DrawList->AddCircleFilled(center, handle_radius - handle_border, handle_clr);
1025 };
1026 auto draw_active_handle = [&](const ImVec2& center) {
1027 window->DrawList->AddCircleFilled(center, handle_radius + 2.0f * m_scale, handle_border_clr);
1028 draw_handle(center);
1029 window->DrawList->AddCircle(center, handle_radius + 3.0f * m_scale, handle_clr, 0, 2.0f * m_scale);
1030 window->DrawList->AddLine(center + ImVec2(-0.5f * line_length, 0.0f), center + ImVec2(0.5f * line_length, 0.0f), white_bg, line_width);
1031 window->DrawList->AddLine(center + ImVec2(0.0f, -0.5f * line_length), center + ImVec2(0.0f, 0.5f * line_length), white_bg, line_width);
1032 };
1033
1034 // Prevent interaction with labels if slider add/edit menu is open
1035 // or the mouse was pressed elsewhere and then dragged over them.
1036 if (!menu_open && (!context.IO.MouseDown[0] || context.IO.MouseClicked[0])) {
1037 if (!one_layer_flag) {
1038 label_hit(range_label_rect(higher_handle, higher_text_content_size, true), ssHigher);
1039 label_hit(range_label_rect(lower_handle, lower_text_content_size, false), ssLower);
1040 } else {
1041 label_hit(one_layer_label_rect(one_handle), ssHigher);
1042 }
1043 }
1044
1045 // set mouse active region
1046 const ImRect slider_active_region = ImRect(ImVec2(draw_region.Min.x + 35.0f * m_scale, draw_region.Min.y), draw_region.Max);
1047 bool slider_hovered = !menu_open && ImGui::ItemHoverable(slider_active_region, id) && !ImGui::ItemHoverable(m_tick_rect, id) && hovered_label == ssUndef;
1048 struct LabelDragState
1049 {
1050 ImGuiID id = 0;
1051 SelectedSlider selection = ssUndef;
1052 ImVec2 start_mouse;
1053 int start_value = 0;
1054 };
1055 // Persist the label that started the drag after the cursor leaves its rect.
1056 static LabelDragState label_drag;
1057
1058 if (hovered_label != ssUndef && context.IO.MouseClicked[0]) {
1059 selection = hovered_label;
1060 label_drag.id = id;
1061 label_drag.selection = hovered_label;
1062 label_drag.start_mouse = context.IO.MousePos;
1063 label_drag.start_value = hovered_label == ssHigher ? *higher_value : *lower_value;
1064 ImGui::SetActiveID(id, window);
1065 ImGui::SetFocusID(id, window);
1066 ImGui::FocusWindow(window);
1067 }
1068 if (slider_hovered && context.IO.MouseDown[0]) {
1069 ImGui::SetActiveID(id, window);
1070 ImGui::SetFocusID(id, window);
1071 ImGui::FocusWindow(window);
1072 }
1073
1074 // draw background
1075 draw_background_and_groove(bg_rect, groove);
1076 window->DrawList->AddRect(groove.Min, groove.Max, rail_border_clr, 0.5f * groove.GetWidth(), 0, 1.0f * m_scale);
1077 const ImRect rail_inner(groove.Min + ImVec2(2.0f, 2.0f) * m_scale, groove.Max - ImVec2(2.0f, 2.0f) * m_scale);
1078 window->DrawList->AddRectFilled(rail_inner.Min, rail_inner.Max, rail_inner_clr, 0.5f * rail_inner.GetWidth());
1079
1080 bool value_changed = false;
1081 if (!one_layer_flag)
1082 {
1083 const SelectedSlider dragged_label = label_drag.id == id && context.IO.MouseDown[0] ? label_drag.selection : ssUndef;
1084 if (dragged_label == ssUndef && !menu_open) {
1085 if (ImGui::ItemHoverable(higher_handle, id) && context.IO.MouseClicked[0]) {
1086 selection = ssHigher;
1087 }
1088 if (ImGui::ItemHoverable(lower_handle, id) && context.IO.MouseClicked[0]) {
1089 selection = ssLower;
1090 }
1091 }
1092 bool h_selected = selection != ssLower;
1093
1094 // update handle position and value
1095 if (dragged_label != ssUndef) {
1096 const ImRect& drag_region = dragged_label == ssHigher ? higher_slideable_region : lower_slideable_region;
1097 const float region_height = drag_region.GetHeight();
1098 if (region_height > 0.0f) {
1099 const float delta = context.IO.MousePos.y - label_drag.start_mouse.y;
1100 const float value_delta = delta * (float)(v_max - v_min) / region_height;
1101 const int new_value = (int)ImClamp((float)label_drag.start_value - value_delta, (float)v_min, (float)v_max);
1102 if (dragged_label == ssHigher) {
1103 value_changed = *higher_value != new_value;
1104 *higher_value = new_value;
1105 } else {
1106 value_changed = *lower_value != new_value;
1107 *lower_value = new_value;
1108 }
1109 }
1110 h_selected = dragged_label == ssHigher;
1111 if (dragged_label == ssHigher) {
1112 higher_handle_pos = get_pos_from_value(v_min, v_max, *higher_value, higher_slideable_region);
1113 higher_handle = ImRect(mid_x - handle_radius, higher_handle_pos - handle_radius, mid_x + handle_radius, higher_handle_pos + handle_radius);
1114 } else {
1115 lower_handle_pos = get_pos_from_value(v_min, v_max, *lower_value, lower_slideable_region);
1116 lower_handle = ImRect(mid_x - handle_radius, lower_handle_pos - handle_radius, mid_x + handle_radius, lower_handle_pos + handle_radius);
1117 }
1118 } else {
1119 if (h_selected)
1120 {
1121 value_changed = slider_behavior(id, higher_slideable_region, v_min, v_max,
1122 higher_value, &higher_handle, ImGuiSliderFlags_Vertical,
1124 }
1125 if (!h_selected) {
1126 value_changed = slider_behavior(id, lower_slideable_region, v_min, v_max,
1127 lower_value, &lower_handle, ImGuiSliderFlags_Vertical,
1129 }
1130 }
1131 SelectedSlider active_label = ssUndef;
1132 if (dragged_label != ssUndef)
1133 active_label = dragged_label;
1134 else if (context.ActiveId == id && context.IO.MouseDown[0])
1135 active_label = h_selected ? ssHigher : ssLower;
1136
1137 ImVec2 higher_handle_center = higher_handle.GetCenter();
1138 ImVec2 lower_handle_center = lower_handle.GetCenter();
1139 if (higher_handle_center.y + handle_radius > lower_handle_center.y && h_selected)
1140 {
1141 lower_handle = higher_handle;
1142 lower_handle.TranslateY(handle_radius);
1143 lower_handle_center.y = higher_handle_center.y + handle_radius;
1144 *lower_value = *higher_value;
1145 }
1146 if (higher_handle_center.y + handle_radius > lower_handle_center.y && !h_selected)
1147 {
1148 higher_handle = lower_handle;
1149 higher_handle.TranslateY(-handle_radius);
1150 higher_handle_center.y = lower_handle_center.y - handle_radius;
1151 *higher_value = *lower_value;
1152 }
1153
1154 // judge whether to open menu
1155 if (!menu_open && ImGui::ItemHoverable(h_selected ? higher_handle : lower_handle, id) && context.IO.MouseClicked[1])
1156 m_show_menu = true;
1157 if (!menu_open && ((!ImGui::ItemHoverable(h_selected ? higher_handle : lower_handle, id) && context.IO.MouseClicked[1]) ||
1158 context.IO.MouseClicked[0]))
1159 m_show_menu = false;
1160
1161 // draw ticks
1162 draw_ticks(h_selected ? higher_slideable_region : lower_slideable_region);
1163 // draw colored band
1164 draw_colored_band(groove, h_selected ? higher_slideable_region : lower_slideable_region);
1165
1166 if (!m_ticks.has_tick_with_code(ToolChange)) {
1167 // draw scroll line
1168 ImRect scroll_line = ImRect(ImVec2(groove.Min.x - 2.0f * m_scale, higher_handle_center.y),
1169 ImVec2(groove.Max.x + 2.0f * m_scale, lower_handle_center.y));
1170 window->DrawList->AddRectFilled(scroll_line.Min, scroll_line.Max, range_fill_clr, 0.5f * scroll_line.GetWidth());
1171 }
1172
1173 // draw handles
1174 draw_handle(higher_handle_center);
1175 draw_handle(lower_handle_center);
1176 draw_active_handle(h_selected ? higher_handle_center : lower_handle_center);
1177
1178 // ORCA: render fixed-width label boxes
1179 // draw higher label
1180 text_size = ImVec2(max_label_width, higher_text_content_size.y) + text_padding * 2;
1181 ImVec2 text_start = ImVec2(higher_handle.Min.x - text_size.x - label_width_margin, higher_handle_center.y - text_size.y);
1182 ImRect text_rect(text_start, text_start + text_size);
1183 const bool higher_label_active = active_label == ssHigher;
1184 draw_label(text_rect, higher_text_content_size, higher_label,
1185 hovered_label == ssHigher || higher_label_active, higher_label_active);
1186 // draw lower label
1187 text_size = ImVec2(max_label_width, lower_text_content_size.y) + text_padding * 2;
1188 text_start = ImVec2(lower_handle.Min.x - text_size.x - label_width_margin, lower_handle_center.y);
1189 text_rect = ImRect(text_start, text_start + text_size);
1190 const bool lower_label_active = active_label == ssLower;
1191 draw_label(text_rect, lower_text_content_size, lower_label,
1192 hovered_label == ssLower || lower_label_active, lower_label_active);
1193
1194 // draw mouse position
1195 if (slider_hovered && !context.IO.MouseDown[0]) {
1196 draw_tick_on_mouse_position(h_selected ? higher_slideable_region : lower_slideable_region);
1197 }
1198 }
1199 if (one_layer_flag)
1200 {
1201 // update handle position
1202 const SelectedSlider dragged_label = label_drag.id == id && context.IO.MouseDown[0] ? label_drag.selection : ssUndef;
1203 if (dragged_label == ssHigher) {
1204 const float region_height = one_slideable_region.GetHeight();
1205 if (region_height > 0.0f) {
1206 const float delta = context.IO.MousePos.y - label_drag.start_mouse.y;
1207 const float value_delta = delta * (float)(v_max - v_min) / region_height;
1208 const int new_value = (int)ImClamp((float)label_drag.start_value - value_delta, (float)v_min, (float)v_max);
1209 value_changed = *higher_value != new_value;
1210 *higher_value = new_value;
1211 }
1212 one_handle = one_layer_handle(*higher_value);
1213 } else {
1214 value_changed = slider_behavior(id, one_slideable_region, v_min, v_max,
1215 higher_value, &one_handle, ImGuiSliderFlags_Vertical,
1217 }
1218
1219 ImVec2 handle_center = one_handle.GetCenter();
1220
1221 // judge whether to open menu
1222 if (!menu_open && ImGui::ItemHoverable(one_handle, id) && context.IO.MouseClicked[1])
1223 m_show_menu = true;
1224 if (!menu_open && ((!ImGui::ItemHoverable(one_handle, id) && context.IO.MouseClicked[1]) ||
1225 context.IO.MouseClicked[0]))
1226 m_show_menu = false;
1227
1228 // draw ticks
1229 draw_ticks(one_slideable_region);
1230 // draw colored band
1231 draw_colored_band(groove, one_slideable_region);
1232
1233 // draw handle
1234 draw_active_handle(handle_center);
1235
1236 // draw label
1237 text_size = ImVec2(max_label_width, higher_text_content_size.y) + text_padding * 2;
1238 ImVec2 text_start = ImVec2(one_handle.Min.x - text_size.x - label_width_margin, handle_center.y - 0.5 * text_size.y);
1239 ImRect text_rect = ImRect(text_start, text_start + text_size);
1240 const bool label_active = context.ActiveId == id && context.IO.MouseDown[0];
1241 draw_label(text_rect, higher_text_content_size, higher_label, hovered_label == ssHigher || label_active, label_active);
1242
1243 // draw mouse position
1244 if (slider_hovered && !context.IO.MouseDown[0]) {
1245 draw_tick_on_mouse_position(one_slideable_region);
1246 }
1247 }
1248
1249 if (!context.IO.MouseDown[0] && label_drag.id == id) {
1250 label_drag.id = 0;
1251 label_drag.selection = ssUndef;
1252 if (context.ActiveId == id)
1253 ImGui::ClearActiveID();
1254 }
1255
1256 return value_changed;
1257}
void draw_colored_band(const ImRect &groove, const ImRect &slideable_region)
Definition IMSlider.cpp:619
void draw_ticks(const ImRect &slideable_region)
Definition IMSlider.cpp:728
void draw_tick_on_mouse_position(const ImRect &slideable_region)
Definition IMSlider.cpp:891
static ImVec4 m_tick_rect
Definition IMSlider.cpp:73
SelectedSlider
Definition IMSlider.hpp:41
static int m_tick_value
Definition IMSlider.cpp:72

References Slic3r::GUI::BACKGROUND_COLOR_DARK, Slic3r::GUI::BACKGROUND_COLOR_LIGHT, Slic3r::GUI::BRAND_COLOR, Slic3r::center(), StateColor::darkModeColorFor(), draw_background_and_groove(), draw_colored_band(), draw_tick_on_mouse_position(), draw_ticks(), get_pos_from_value(), Slic3r::GUI::GROOVE_WIDTH, ImRect, Slic3r::GUI::into_u8(), m_is_dark, m_scale, m_show_menu, Slic3r::GUI::m_tick_rect, Slic3r::GUI::m_tick_value, m_ticks, Slic3r::GUI::ONE_LAYER_BUTTON_SIZE, Slic3r::GUI::ONE_LAYER_MARGIN, scale(), Slic3r::GUI::slider_behavior(), Slic3r::GUI::ssHigher, Slic3r::GUI::ssLower, Slic3r::GUI::ssUndef, and Slic3r::CustomGCode::ToolChange.

Referenced by render().

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

◆ vertical_slider_window_width()

float Slic3r::GUI::IMSlider::vertical_slider_window_width ( )
static

Member Data Documentation

◆ m_alternate_values

std::vector<double> Slic3r::GUI::IMSlider::m_alternate_values
private

◆ m_can_change_color

bool Slic3r::GUI::IMSlider::m_can_change_color
private

◆ m_custom_gcode

char Slic3r::GUI::IMSlider::m_custom_gcode[1024] = { 0 }
private
238{ 0 }; //menu

Referenced by render_input_custom_gcode().

◆ m_custom_icon_id

void* Slic3r::GUI::IMSlider::m_custom_icon_id
private

Referenced by draw_ticks(), and init_texture().

◆ m_delete_icon_id

void* Slic3r::GUI::IMSlider::m_delete_icon_id
private

Referenced by draw_ticks(), and init_texture().

◆ m_dirty

bool Slic3r::GUI::IMSlider::m_dirty = false
private

Referenced by is_dirty(), and set_as_dirty().

◆ m_draw_mode

DrawMode Slic3r::GUI::IMSlider::m_draw_mode = dmRegular
private

◆ m_extra_style

long Slic3r::GUI::IMSlider::m_extra_style
private

Referenced by IMSlider(), and SetExtraStyle().

◆ m_extruder_colors

std::vector<std::string> Slic3r::GUI::IMSlider::m_extruder_colors
private

◆ m_force_mode_apply

bool Slic3r::GUI::IMSlider::m_force_mode_apply = true
private

Referenced by GetTicksValues().

◆ m_higher_value

◆ m_is_dark

◆ m_is_need_post_tick_changed_event

bool Slic3r::GUI::IMSlider::m_is_need_post_tick_changed_event { false }
private

◆ m_is_one_layer

bool Slic3r::GUI::IMSlider::m_is_one_layer = false
private

◆ m_is_spiral_vase

bool Slic3r::GUI::IMSlider::m_is_spiral_vase = false
private

◆ m_is_wipe_tower

bool Slic3r::GUI::IMSlider::m_is_wipe_tower = false
private

◆ m_label_koef

float Slic3r::GUI::IMSlider::m_label_koef {1.0}
private
224{1.0};

Referenced by get_label(), and SetKoefForLabels().

◆ m_layer_number

char Slic3r::GUI::IMSlider::m_layer_number[64] = { 0 }
private
239{ 0 }; //menu

Referenced by render_go_to_layer_dialog().

◆ m_layers_times

std::vector<double> Slic3r::GUI::IMSlider::m_layers_times
private

◆ m_layers_values

std::vector<double> Slic3r::GUI::IMSlider::m_layers_values
private

Referenced by get_label(), and SetLayersTimes().

◆ m_lower_value

◆ m_max_value

◆ m_menu_enable

bool Slic3r::GUI::IMSlider::m_menu_enable = true
private

Referenced by render_menu(), and set_menu_enable().

◆ m_min_value

◆ m_mode

◆ m_one_layer_off_dark_id

void* Slic3r::GUI::IMSlider::m_one_layer_off_dark_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_off_hover_dark_id

void* Slic3r::GUI::IMSlider::m_one_layer_off_hover_dark_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_off_hover_id

void* Slic3r::GUI::IMSlider::m_one_layer_off_hover_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_off_id

void* Slic3r::GUI::IMSlider::m_one_layer_off_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_on_dark_id

void* Slic3r::GUI::IMSlider::m_one_layer_on_dark_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_on_hover_dark_id

void* Slic3r::GUI::IMSlider::m_one_layer_on_hover_dark_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_on_hover_id

void* Slic3r::GUI::IMSlider::m_one_layer_on_hover_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_on_id

void* Slic3r::GUI::IMSlider::m_one_layer_on_id
private

Referenced by init_texture(), and render().

◆ m_one_layer_value

int Slic3r::GUI::IMSlider::m_one_layer_value
private

◆ m_only_extruder

◆ m_pause_icon_id

void* Slic3r::GUI::IMSlider::m_pause_icon_id
private

Referenced by draw_ticks(), and init_texture().

◆ m_print_obj_idxs

std::string Slic3r::GUI::IMSlider::m_print_obj_idxs
private

Referenced by IsNewPrint().

◆ m_render_as_disabled

bool Slic3r::GUI::IMSlider::m_render_as_disabled { false }
private
193{ false };

Referenced by is_rendering_as_disabled(), and set_render_as_disabled().

◆ m_scale

◆ m_selection

◆ m_show_custom_gcode_window

bool Slic3r::GUI::IMSlider::m_show_custom_gcode_window = false
private

◆ m_show_go_to_layer_dialog

bool Slic3r::GUI::IMSlider::m_show_go_to_layer_dialog = false
private

◆ m_show_menu

bool Slic3r::GUI::IMSlider::m_show_menu = false
private

◆ m_style

long Slic3r::GUI::IMSlider::m_style
private

Referenced by IMSlider(), and is_horizontal().

◆ m_tick_change_event_type

CustomGCode::Type Slic3r::GUI::IMSlider::m_tick_change_event_type
private

◆ m_ticks

◆ m_values


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/IMSlider.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/IMSlider.cpp