Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::DoubleSlider Namespace Reference

Classes

class  Control
 
struct  ExtrudersSequence
 
struct  TickCode
 
class  TickCodeInfo
 

Enumerations

enum  SelectedSlider { ssUndef , ssLower , ssHigher }
 
enum  FocusedItem {
  fiNone , fiRevertIcon , fiOneLayerIcon , fiCogIcon ,
  fiColorBand , fiActionIcon , fiLowerThumb , fiHigherThumb ,
  fiSmartWipeTower , fiTick
}
 
enum  ConflictType {
  ctNone , ctModeConflict , ctMeaninglessColorChange , ctMeaninglessToolChange ,
  ctRedundant
}
 
enum  MouseAction {
  maNone , maAddMenu , maEditMenu , maCogIconMenu ,
  maForceColorEdit , maAddTick , maDeleteTick , maCogIconClick ,
  maOneLayerIconClick , maRevertIconClick
}
 
enum  DrawMode { dmRegular , dmSlaPrint , dmSequentialFffPrint , dmSequentialGCodeView }
 
enum  LabelType { ltHeightWithLayer , ltHeight , ltEstimatedTime }
 

Functions

bool equivalent_areas (const double &bottom_area, const double &top_area)
 
 wxDEFINE_EVENT (wxCUSTOMEVT_TICKSCHANGED, wxEvent)
 
static std::string gcode (Type type)
 
static wxString short_and_splitted_time (const std::string &time)
 
bool check_color_change (const PrintObject *object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function< bool(const Layer *)> break_condition)
 
static std::string get_new_color (const std::string &color)
 
static void upgrade_text_entry_dialog (wxTextEntryDialog *dlg, double min=-1.0, double max=-1.0)
 
static std::string get_custom_code (const std::string &code_in, double height)
 
static std::string get_pause_print_msg (const std::string &msg_in, double height)
 
static double get_value_to_jump (double active_value, double min_z, double max_z, DrawMode mode)
 
constexpr double epsilon ()
 
 wxDECLARE_EVENT (wxCUSTOMEVT_TICKSCHANGED, wxEvent)
 

Variables

constexpr double min_delta_area = scale_(scale_(25))
 
constexpr double miscalculation = scale_(scale_(1))
 

Enumeration Type Documentation

◆ ConflictType

Enumerator
ctNone 
ctModeConflict 
ctMeaninglessColorChange 
ctMeaninglessToolChange 
ctRedundant 
62{
63 ctNone,
68};
@ ctRedundant
Definition DoubleSlider.hpp:67
@ ctMeaninglessToolChange
Definition DoubleSlider.hpp:66
@ ctMeaninglessColorChange
Definition DoubleSlider.hpp:65
@ ctNone
Definition DoubleSlider.hpp:63
@ ctModeConflict
Definition DoubleSlider.hpp:64

◆ DrawMode

Enumerator
dmRegular 
dmSlaPrint 
dmSequentialFffPrint 
dmSequentialGCodeView 
85{
90};
@ dmSequentialFffPrint
Definition DoubleSlider.hpp:88
@ dmRegular
Definition DoubleSlider.hpp:86
@ dmSequentialGCodeView
Definition DoubleSlider.hpp:89
@ dmSlaPrint
Definition DoubleSlider.hpp:87

◆ FocusedItem

Enumerator
fiNone 
fiRevertIcon 
fiOneLayerIcon 
fiCogIcon 
fiColorBand 
fiActionIcon 
fiLowerThumb 
fiHigherThumb 
fiSmartWipeTower 
fiTick 
48 {
49 fiNone,
58 fiTick
59};
@ fiCogIcon
Definition DoubleSlider.hpp:52
@ fiTick
Definition DoubleSlider.hpp:58
@ fiSmartWipeTower
Definition DoubleSlider.hpp:57
@ fiActionIcon
Definition DoubleSlider.hpp:54
@ fiNone
Definition DoubleSlider.hpp:49
@ fiLowerThumb
Definition DoubleSlider.hpp:55
@ fiHigherThumb
Definition DoubleSlider.hpp:56
@ fiOneLayerIcon
Definition DoubleSlider.hpp:51
@ fiRevertIcon
Definition DoubleSlider.hpp:50
@ fiColorBand
Definition DoubleSlider.hpp:53

◆ LabelType

Enumerator
ltHeightWithLayer 
ltHeight 
ltEstimatedTime 
93{
97};
@ ltEstimatedTime
Definition DoubleSlider.hpp:96
@ ltHeight
Definition DoubleSlider.hpp:95
@ ltHeightWithLayer
Definition DoubleSlider.hpp:94

◆ MouseAction

Enumerator
maNone 
maAddMenu 
maEditMenu 
maCogIconMenu 
maForceColorEdit 
maAddTick 
maDeleteTick 
maCogIconClick 
maOneLayerIconClick 
maRevertIconClick 
71{
72 maNone,
73 maAddMenu, // show "Add" context menu for NOTexist active tick
74 maEditMenu, // show "Edit" context menu for exist active tick
75 maCogIconMenu, // show context for "cog" icon
76 maForceColorEdit, // force color editing from colored band
77 maAddTick, // force tick adding
78 maDeleteTick, // force tick deleting
79 maCogIconClick, // LeftMouseClick on "cog" icon
80 maOneLayerIconClick, // LeftMouseClick on "one_layer" icon
81 maRevertIconClick, // LeftMouseClick on "revert" icon
82};
@ maRevertIconClick
Definition DoubleSlider.hpp:81
@ maCogIconClick
Definition DoubleSlider.hpp:79
@ maCogIconMenu
Definition DoubleSlider.hpp:75
@ maOneLayerIconClick
Definition DoubleSlider.hpp:80
@ maEditMenu
Definition DoubleSlider.hpp:74
@ maAddTick
Definition DoubleSlider.hpp:77
@ maForceColorEdit
Definition DoubleSlider.hpp:76
@ maAddMenu
Definition DoubleSlider.hpp:73
@ maNone
Definition DoubleSlider.hpp:72
@ maDeleteTick
Definition DoubleSlider.hpp:78

◆ SelectedSlider

Enumerator
ssUndef 
ssLower 
ssHigher 
42 {
43 ssUndef,
44 ssLower,
46};
@ ssUndef
Definition DoubleSlider.hpp:43
@ ssLower
Definition DoubleSlider.hpp:44
@ ssHigher
Definition DoubleSlider.hpp:45

Function Documentation

◆ check_color_change()

bool Slic3r::DoubleSlider::check_color_change ( const PrintObject object,
size_t  frst_layer_id,
size_t  layers_cnt,
bool  check_overhangs,
std::function< bool(const Layer *)>  break_condition 
)
2127{
2128 double prev_area = area(object->get_layer(frst_layer_id)->lslices);
2129
2130 bool detected = false;
2131 for (size_t i = frst_layer_id+1; i < layers_cnt; i++) {
2132 const Layer* layer = object->get_layer(i);
2133 double cur_area = area(layer->lslices);
2134
2135 // check for overhangs
2136 if (check_overhangs && cur_area > prev_area && !equivalent_areas(prev_area, cur_area))
2137 break;
2138
2139 // Check percent of the area decrease.
2140 // This value have to be more than min_delta_area and more then 10%
2141 if ((prev_area - cur_area > min_delta_area) && (cur_area / prev_area < 0.9)) {
2142 detected = true;
2143 if (break_condition(layer))
2144 break;
2145 }
2146
2147 prev_area = cur_area;
2148 }
2149 return detected;
2150}
Definition Layer.hpp:312
ExPolygons lslices
Definition Layer.hpp:339
const Layer * get_layer(int idx) const
Definition Print.hpp:280
bool equivalent_areas(const double &bottom_area, const double &top_area)
Definition DoubleSlider.cpp:44

References Slic3r::area(), equivalent_areas(), Slic3r::PrintObject::get_layer(), Slic3r::Layer::lslices, and min_delta_area.

Referenced by Slic3r::DoubleSlider::Control::auto_color_change(), and Slic3r::GUI::Preview::update_layers_slider().

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

◆ epsilon()

constexpr double Slic3r::DoubleSlider::epsilon ( )
constexpr
28{ return 0.0011; }

Referenced by Slic3r::DoubleSlider::Control::get_label(), Slic3r::DoubleSlider::Control::get_tick_from_value(), Slic3r::GUI::GCodeViewer::render_legend(), Slic3r::DoubleSlider::Control::Ruler::update(), Slic3r::GUI::Preview::update_layers_slider(), and upgrade_text_entry_dialog().

+ Here is the caller graph for this function:

◆ equivalent_areas()

bool Slic3r::DoubleSlider::equivalent_areas ( const double &  bottom_area,
const double &  top_area 
)
45{
46 return fabs(bottom_area - top_area) <= miscalculation;
47}
constexpr double miscalculation
Definition DoubleSlider.cpp:42

References miscalculation.

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

+ Here is the caller graph for this function:

◆ gcode()

static std::string Slic3r::DoubleSlider::gcode ( Type  type)
static
52{
53 const PrintConfig& config = GUI::wxGetApp().plater()->fff_print().config();
54 switch (type) {
55 case ColorChange: return config.color_change_gcode;
56 case PausePrint: return config.pause_print_gcode;
57 case Template: return config.template_custom_gcode;
58 default: return "";
59 }
60}
@ PausePrint
Definition CustomGCode.hpp:16
@ Template
Definition CustomGCode.hpp:18
@ ColorChange
Definition CustomGCode.hpp:15

References Slic3r::CustomGCode::ColorChange, Slic3r::CustomGCode::PausePrint, and Slic3r::CustomGCode::Template.

Referenced by Slic3r::DoubleSlider::Control::add_code_as_tick(), Slic3r::DoubleSlider::Control::append_add_color_change_menu_item(), Slic3r::DoubleSlider::TickCodeInfo::edit_tick(), Slic3r::DoubleSlider::Control::get_tooltip(), and Slic3r::DoubleSlider::Control::show_add_context_menu().

+ Here is the caller graph for this function:

◆ get_custom_code()

static std::string Slic3r::DoubleSlider::get_custom_code ( const std::string &  code_in,
double  height 
)
static
2284{
2285 wxString msg_text = _L("Enter custom G-code used on current layer") + ":";
2286 wxString msg_header = format_wxstr(_L("Custom G-code on current layer (%1% mm)."), height);
2287
2288 // get custom gcode
2289 wxTextEntryDialog dlg(nullptr, msg_text, msg_header, code_in,
2290 wxTextEntryDialogStyle | wxTE_MULTILINE);
2292
2293 bool valid = true;
2294 std::string value;
2295 do {
2296 if (dlg.ShowModal() != wxID_OK)
2297 return "";
2298
2299 value = into_u8(dlg.GetValue());
2300 valid = GUI::Tab::validate_custom_gcode("Custom G-code", value);
2301 } while (!valid);
2302 return value;
2303}
static void upgrade_text_entry_dialog(wxTextEntryDialog *dlg, double min=-1.0, double max=-1.0)
Definition DoubleSlider.cpp:2249
#define _L(s)
Definition I18N.hpp:3

References _L, upgrade_text_entry_dialog(), and Slic3r::GUI::Tab::validate_custom_gcode().

Referenced by Slic3r::DoubleSlider::TickCodeInfo::add_tick(), and Slic3r::DoubleSlider::TickCodeInfo::edit_tick().

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

◆ get_new_color()

static std::string Slic3r::DoubleSlider::get_new_color ( const std::string &  color)
static
2229{
2230 wxColour clr(color);
2231 if (!clr.IsOk())
2232 clr = wxColour(0, 0, 0); // Don't set alfa to transparence
2233
2234 auto data = new wxColourData();
2235 data->SetChooseFull(1);
2236 data->SetColour(clr);
2237
2238 wxColourDialog dialog(nullptr, data);
2239 dialog.CenterOnParent();
2240 if (dialog.ShowModal() == wxID_OK)
2241 return dialog.GetColourData().GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
2242 return "";
2243}

Referenced by Slic3r::DoubleSlider::TickCodeInfo::edit_tick(), and Slic3r::DoubleSlider::TickCodeInfo::get_color_for_tick().

+ Here is the caller graph for this function:

◆ get_pause_print_msg()

static std::string Slic3r::DoubleSlider::get_pause_print_msg ( const std::string &  msg_in,
double  height 
)
static
2306{
2307 wxString msg_text = _L("Enter short message shown on Printer display when a print is paused") + ":";
2308 wxString msg_header = format_wxstr(_L("Message for pause print on current layer (%1% mm)."), height);
2309
2310 // get custom gcode
2311 wxTextEntryDialog dlg(nullptr, msg_text, msg_header, from_u8(msg_in),
2312 wxTextEntryDialogStyle);
2314
2315 if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
2316 return "";
2317
2318 return into_u8(dlg.GetValue());
2319}

References _L, and upgrade_text_entry_dialog().

Referenced by Slic3r::DoubleSlider::TickCodeInfo::add_tick(), and Slic3r::DoubleSlider::TickCodeInfo::edit_tick().

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

◆ get_value_to_jump()

static double Slic3r::DoubleSlider::get_value_to_jump ( double  active_value,
double  min_z,
double  max_z,
DrawMode  mode 
)
static
2322{
2323 wxString msg_text = (mode == dmSequentialGCodeView) ? _L("Enter the move you want to jump to") + ":" : _L("Enter the height you want to jump to") + ":";
2324 wxString msg_header = (mode == dmSequentialGCodeView) ? _L("Jump to move") : _L("Jump to height");
2325 wxString msg_in = GUI::double_to_string(active_value);
2326
2327 // get custom gcode
2328 wxTextEntryDialog dlg(nullptr, msg_text, msg_header, msg_in, wxTextEntryDialogStyle);
2329 upgrade_text_entry_dialog(&dlg, min_z, max_z);
2330
2331 if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
2332 return -1.0;
2333
2334 double value = -1.0;
2335 return dlg.GetValue().ToDouble(&value) ? value : -1.0;
2336}

References _L, dmSequentialGCodeView, Slic3r::GUI::double_to_string(), and upgrade_text_entry_dialog().

Referenced by Slic3r::DoubleSlider::Control::jump_to_value().

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

◆ short_and_splitted_time()

static wxString Slic3r::DoubleSlider::short_and_splitted_time ( const std::string &  time)
static
695{
696 // Parse the dhms time format.
697 int days = 0;
698 int hours = 0;
699 int minutes = 0;
700 int seconds = 0;
701 if (time.find('d') != std::string::npos)
702 ::sscanf(time.c_str(), "%dd %dh %dm %ds", &days, &hours, &minutes, &seconds);
703 else if (time.find('h') != std::string::npos)
704 ::sscanf(time.c_str(), "%dh %dm %ds", &hours, &minutes, &seconds);
705 else if (time.find('m') != std::string::npos)
706 ::sscanf(time.c_str(), "%dm %ds", &minutes, &seconds);
707 else if (time.find('s') != std::string::npos)
708 ::sscanf(time.c_str(), "%ds", &seconds);
709
710 // Format the dhm time.
711 auto get_d = [days]() { return format(_u8L("%1%d"), days); };
712 auto get_h = [hours]() { return format(_u8L("%1%h"), hours); };
713 auto get_m = [minutes](){ return format(_u8L("%1%m"), minutes); };
714 auto get_s = [seconds](){ return format(_u8L("%1%s"), seconds); };
715
716 if (days > 0)
717 return format_wxstr("%1%%2%\n%3%", get_d(), get_h(), get_m());
718 if (hours > 0) {
719 if (hours < 10 && minutes < 10 && seconds < 10)
720 return format_wxstr("%1%%2%%3%", get_h(), get_m(), get_s());
721 if (hours > 10 && minutes > 10 && seconds > 10)
722 return format_wxstr("%1%\n%2%\n%3%", get_h(), get_m(), get_s());
723 if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
724 return format_wxstr("%1%\n%2%%3%", get_h(), get_m(), get_s());
725 return format_wxstr("%1%%2%\n%3%", get_h(), get_m(), get_s());
726 }
727 if (minutes > 0) {
728 if (minutes > 10 && seconds > 10)
729 return format_wxstr("%1%\n%2%", get_m(), get_s());
730 return format_wxstr("%1%%2%", get_m(), get_s());
731 }
732 return from_u8(get_s());
733}
#define _u8L(s)
macro used to mark string used at localization, return same string
Definition SLAPrint.cpp:29
wxString format_wxstr(const char *fmt, TArgs &&... args)
Definition format.hpp:42
wxString from_u8(const std::string &str)
Definition GUI.cpp:437
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:44

References _u8L, and Slic3r::format().

Referenced by Slic3r::DoubleSlider::Control::get_label().

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

◆ upgrade_text_entry_dialog()

static void Slic3r::DoubleSlider::upgrade_text_entry_dialog ( wxTextEntryDialog *  dlg,
double  min = -1.0,
double  max = -1.0 
)
static
2250{
2251 GUI::wxGetApp().UpdateDlgDarkUI(dlg);
2252
2253 // detect TextCtrl and OK button
2254 wxTextCtrl* textctrl {nullptr};
2255 wxWindowList& dlg_items = dlg->GetChildren();
2256 for (auto item : dlg_items) {
2257 textctrl = dynamic_cast<wxTextCtrl*>(item);
2258 if (textctrl)
2259 break;
2260 }
2261
2262 if (!textctrl)
2263 return;
2264
2265 textctrl->SetInsertionPointEnd();
2266
2267 wxButton* btn_OK = static_cast<wxButton*>(dlg->FindWindowById(wxID_OK));
2268 btn_OK->Bind(wxEVT_UPDATE_UI, [textctrl, min, max](wxUpdateUIEvent& evt)
2269 {
2270 bool disable = textctrl->IsEmpty();
2271 if (!disable && min >= 0.0 && max >= 0.0) {
2272 double value = -1.0;
2273 if (!textctrl->GetValue().ToDouble(&value)) // input value couldn't be converted to double
2274 disable = true;
2275 else
2276 disable = value < min - epsilon() || value > max + epsilon(); // is input value is out of valid range ?
2277 }
2278
2279 evt.Enable(!disable);
2280 }, btn_OK->GetId());
2281}

References epsilon().

Referenced by get_custom_code(), get_pause_print_msg(), and get_value_to_jump().

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

◆ wxDECLARE_EVENT()

Slic3r::DoubleSlider::wxDECLARE_EVENT ( wxCUSTOMEVT_TICKSCHANGED  ,
wxEvent   
)

◆ wxDEFINE_EVENT()

Slic3r::DoubleSlider::wxDEFINE_EVENT ( wxCUSTOMEVT_TICKSCHANGED  ,
wxEvent   
)

Variable Documentation

◆ min_delta_area

constexpr double Slic3r::DoubleSlider::min_delta_area = scale_(scale_(25))
constexpr

Referenced by check_color_change().

◆ miscalculation

constexpr double Slic3r::DoubleSlider::miscalculation = scale_(scale_(1))
constexpr

Referenced by equivalent_areas().