mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
parent
cf391383a8
commit
cb3ad0a422
2 changed files with 69 additions and 26 deletions
|
@ -555,15 +555,8 @@ void Control::draw_ticks(wxDC& dc)
|
||||||
// Draw icon for "Pause print" or "Custom Gcode"
|
// Draw icon for "Pause print" or "Custom Gcode"
|
||||||
if (tick.gcode != ColorChangeCode && tick.gcode != ToolChangeCode)
|
if (tick.gcode != ColorChangeCode && tick.gcode != ToolChangeCode)
|
||||||
icon = create_scaled_bitmap(this, tick.gcode == PausePrintCode ? "pause_print" : "edit_gcode");
|
icon = create_scaled_bitmap(this, tick.gcode == PausePrintCode ? "pause_print" : "edit_gcode");
|
||||||
else
|
else if (m_ticks.is_conflict_tick(tick, m_mode))
|
||||||
{
|
|
||||||
if ((tick.gcode == ColorChangeCode && (
|
|
||||||
(m_ticks.mode == t_mode::SingleExtruder && m_mode == t_mode::MultiExtruder ) ||
|
|
||||||
(m_ticks.mode == t_mode::MultiExtruder && m_mode == t_mode::SingleExtruder) )) ||
|
|
||||||
(tick.gcode == ToolChangeCode &&
|
|
||||||
(m_ticks.mode == t_mode::MultiAsSingle && m_mode != t_mode::MultiAsSingle ) ))
|
|
||||||
icon = create_scaled_bitmap(this, "error_tick");
|
icon = create_scaled_bitmap(this, "error_tick");
|
||||||
}
|
|
||||||
|
|
||||||
if (!icon.IsNull())
|
if (!icon.IsNull())
|
||||||
{
|
{
|
||||||
|
@ -753,7 +746,7 @@ bool Control::is_point_in_rect(const wxPoint& pt, const wxRect& rect)
|
||||||
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
|
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Control::is_point_near_tick(const wxPoint& pt)
|
int Control::get_tick_near_point(const wxPoint& pt)
|
||||||
{
|
{
|
||||||
for (auto tick : m_ticks.ticks) {
|
for (auto tick : m_ticks.ticks) {
|
||||||
const wxCoord pos = get_position_from_value(tick.tick);
|
const wxCoord pos = get_position_from_value(tick.tick);
|
||||||
|
@ -833,7 +826,7 @@ void Control::OnLeftDown(wxMouseEvent& event)
|
||||||
detect_selected_slider(pos);
|
detect_selected_slider(pos);
|
||||||
|
|
||||||
if (!m_selection) {
|
if (!m_selection) {
|
||||||
const int tick_val = is_point_near_tick(pos);
|
const int tick_val = get_tick_near_point(pos);
|
||||||
/* Set current thumb position to the nearest tick (if it is)
|
/* Set current thumb position to the nearest tick (if it is)
|
||||||
* OR to a value corresponding to the mouse click
|
* OR to a value corresponding to the mouse click
|
||||||
* */
|
* */
|
||||||
|
@ -896,20 +889,59 @@ wxString Control::get_tooltip(IconFocus icon_focus)
|
||||||
{
|
{
|
||||||
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
||||||
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
|
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
|
||||||
tooltip = tick_code_it == m_ticks.ticks.end() ? (m_mode == t_mode::MultiAsSingle ?
|
|
||||||
_(L("For add change extruder use left mouse button click")) :
|
/* Note: just on OSX!!!
|
||||||
_(L("For add color change use left mouse button click")) ) + "\n" +
|
* Right click event causes a little scrolling.
|
||||||
_(L("For add another code use right mouse button click")) :
|
* So, as a workaround we use Ctrl+LeftMouseClick instead of RightMouseClick
|
||||||
tick_code_it->gcode == ColorChangeCode ? ( m_mode == t_mode::SingleExtruder ?
|
* Show this information in tooltip
|
||||||
_(L("For Delete color change use left mouse button click\n"
|
* */
|
||||||
"For Edit color use right mouse button click")) :
|
|
||||||
from_u8((boost::format(_utf8(L("Delete color change for Extruder %1%"))) % tick_code_it->extruder).str()) ):
|
if (tick_code_it == m_ticks.ticks.end()) // tick doesn't exist
|
||||||
tick_code_it->gcode == PausePrintCode ?
|
{
|
||||||
_(L("Delete pause")) :
|
// Show mode as a first string of tooltop
|
||||||
tick_code_it->gcode == ToolChangeCode ?
|
tooltip = " " + _(L("Slider(print) mode")) + ": ";
|
||||||
from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) :
|
tooltip += (m_mode == t_mode::SingleExtruder ? CustomGCode::SingleExtruderMode :
|
||||||
from_u8((boost::format(_utf8(L("For Delete \"%1%\" code use left mouse button click\n"
|
m_mode == t_mode::MultiAsSingle ? CustomGCode::MultiAsSingleMode :
|
||||||
"For Edit \"%1%\" code use right mouse button click"))) % tick_code_it->gcode ).str());
|
CustomGCode::MultiExtruderMode );
|
||||||
|
tooltip += "\n\n";
|
||||||
|
|
||||||
|
// Show list of actions with new tick
|
||||||
|
tooltip += ( m_mode == t_mode::MultiAsSingle ?
|
||||||
|
_(L("For add change extruder use left mouse button click")) :
|
||||||
|
_(L("For add color change use left mouse button click")) ) + " " +
|
||||||
|
_(L("OR pres \"+\" key")) + "\n" + (
|
||||||
|
is_osx ?
|
||||||
|
_(L("For add another code use Ctrl + Left mouse button click")) :
|
||||||
|
_(L("For add another code use right mouse button click")) );
|
||||||
|
}
|
||||||
|
else // tick exists
|
||||||
|
{
|
||||||
|
// Show custom Gcode as a first string of tooltop
|
||||||
|
tooltip = " ";
|
||||||
|
tooltip += tick_code_it->gcode == ColorChangeCode ? (
|
||||||
|
m_mode == t_mode::SingleExtruder ?
|
||||||
|
from_u8((boost::format(_utf8(L("Color change (\"%1%\")"))) % tick_code_it->gcode ).str()) :
|
||||||
|
from_u8((boost::format(_utf8(L("Color change (\"%1%\") for Extruder %2%"))) %
|
||||||
|
tick_code_it->gcode % tick_code_it->extruder).str()) ) :
|
||||||
|
tick_code_it->gcode == PausePrintCode ?
|
||||||
|
from_u8((boost::format(_utf8(L("Pause print (\"%1%\")"))) % tick_code_it->gcode ).str()) :
|
||||||
|
tick_code_it->gcode == ToolChangeCode ?
|
||||||
|
from_u8((boost::format(_utf8(L("Extruder(tool) is changed to Extruder \"%1%\""))) % tick_code_it->extruder ).str()) :
|
||||||
|
from_u8((boost::format(_utf8(L("\"%1%\""))) % tick_code_it->gcode ).str()) ;
|
||||||
|
|
||||||
|
// If tick is marked as a conflict (exclamation icon),
|
||||||
|
// we should to explain why
|
||||||
|
if (m_ticks.is_conflict_tick(*tick_code_it, m_mode))
|
||||||
|
tooltip += "\n" + _(L("Note")) + "! " +
|
||||||
|
_(L("G-code of this tick has a conflict with slider(print) mode.")) + "\n" +
|
||||||
|
_(L("Any its editing will cause a changes of DoubleSlider data."));
|
||||||
|
|
||||||
|
// Show list of actions with existing tick
|
||||||
|
tooltip += "\n\n" + _(L("For Delete tick use left mouse button click OR pres \"-\" key")) + "\n" + (
|
||||||
|
is_osx ?
|
||||||
|
_(L("For Edit tick use Ctrl + Left mouse button click")) :
|
||||||
|
_(L("For Edit tick use right mouse button click")) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tooltip;
|
return tooltip;
|
||||||
|
@ -1220,7 +1252,7 @@ std::array<int, 2> Control::get_active_extruders_for_tick(int tick) const
|
||||||
|
|
||||||
auto it = m_ticks.ticks.lower_bound(TickCode{tick});
|
auto it = m_ticks.ticks.lower_bound(TickCode{tick});
|
||||||
|
|
||||||
if (it->tick == tick) // current tick exists
|
if (it != m_ticks.ticks.end() && it->tick == tick) // current tick exists
|
||||||
extruders[1] = it->extruder;
|
extruders[1] = it->extruder;
|
||||||
|
|
||||||
while (it != m_ticks.ticks.begin()) {
|
while (it != m_ticks.ticks.begin()) {
|
||||||
|
@ -1759,6 +1791,15 @@ bool TickCodeInfo::has_tick_with_code(const std::string& gcode)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TickCodeInfo::is_conflict_tick(const TickCode& tick, t_mode out_mode)
|
||||||
|
{
|
||||||
|
return (tick.gcode == ColorChangeCode && (
|
||||||
|
(mode == t_mode::SingleExtruder && out_mode == t_mode::MultiExtruder ) ||
|
||||||
|
(mode == t_mode::MultiExtruder && out_mode == t_mode::SingleExtruder) )) ||
|
||||||
|
(tick.gcode == ToolChangeCode &&
|
||||||
|
(mode == t_mode::MultiAsSingle && out_mode != t_mode::MultiAsSingle));
|
||||||
|
}
|
||||||
|
|
||||||
} // DoubleSlider
|
} // DoubleSlider
|
||||||
|
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|
|
@ -73,7 +73,9 @@ public:
|
||||||
void switch_code(const std::string& code_from, const std::string& code_to);
|
void switch_code(const std::string& code_from, const std::string& code_to);
|
||||||
bool switch_code_for_tick(std::set<TickCode>::iterator it, const std::string& code_to, const int extruder);
|
bool switch_code_for_tick(std::set<TickCode>::iterator it, const std::string& code_to, const int extruder);
|
||||||
void erase_all_ticks_with_code(const std::string& gcode);
|
void erase_all_ticks_with_code(const std::string& gcode);
|
||||||
|
|
||||||
bool has_tick_with_code(const std::string& gcode);
|
bool has_tick_with_code(const std::string& gcode);
|
||||||
|
bool is_conflict_tick(const TickCode& tick, t_mode out_mode);
|
||||||
|
|
||||||
void suppress_plus (bool suppress) { m_suppress_plus = suppress; }
|
void suppress_plus (bool suppress) { m_suppress_plus = suppress; }
|
||||||
void suppress_minus(bool suppress) { m_suppress_minus = suppress; }
|
void suppress_minus(bool suppress) { m_suppress_minus = suppress; }
|
||||||
|
@ -230,7 +232,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool is_point_in_rect(const wxPoint& pt, const wxRect& rect);
|
bool is_point_in_rect(const wxPoint& pt, const wxRect& rect);
|
||||||
int is_point_near_tick(const wxPoint& pt);
|
int get_tick_near_point(const wxPoint& pt);
|
||||||
|
|
||||||
double get_scroll_step();
|
double get_scroll_step();
|
||||||
wxString get_label(const SelectedSlider& selection) const;
|
wxString get_label(const SelectedSlider& selection) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue