Merge branch 'master' of https://github.com/Prusa3d/PrusaSlicer
This commit is contained in:
commit
b0fe7ad865
@ -27,7 +27,9 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
/* currently not used, left for possible future use
|
||||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
*/
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
m_current_drives.clear();
|
m_current_drives.clear();
|
||||||
@ -44,7 +46,7 @@ void RemovableDriveManager::search_for_drives()
|
|||||||
if (drive_type == DRIVE_REMOVABLE)
|
if (drive_type == DRIVE_REMOVABLE)
|
||||||
{
|
{
|
||||||
// get name of drive
|
// get name of drive
|
||||||
std::wstring wpath = boost::nowide::widen(path);//std::wstring(path.begin(), path.end());
|
std::wstring wpath = boost::nowide::widen(path);
|
||||||
std::wstring volume_name;
|
std::wstring volume_name;
|
||||||
volume_name.resize(1024);
|
volume_name.resize(1024);
|
||||||
std::wstring file_system_name;
|
std::wstring file_system_name;
|
||||||
@ -54,12 +56,6 @@ void RemovableDriveManager::search_for_drives()
|
|||||||
if(error != 0)
|
if(error != 0)
|
||||||
{
|
{
|
||||||
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
||||||
/*
|
|
||||||
if (volume_name == L"")
|
|
||||||
{
|
|
||||||
volume_name = L"REMOVABLE DRIVE";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (file_system_name != L"")
|
if (file_system_name != L"")
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER free_space;
|
ULARGE_INTEGER free_space;
|
||||||
@ -147,6 +143,7 @@ void RemovableDriveManager::register_window()
|
|||||||
{
|
{
|
||||||
//creates new unvisible window that is recieving callbacks from system
|
//creates new unvisible window that is recieving callbacks from system
|
||||||
// structure to register
|
// structure to register
|
||||||
|
/* currently not used, left for possible future use
|
||||||
WNDCLASSEX wndClass;
|
WNDCLASSEX wndClass;
|
||||||
wndClass.cbSize = sizeof(WNDCLASSEX);
|
wndClass.cbSize = sizeof(WNDCLASSEX);
|
||||||
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||||
@ -182,13 +179,15 @@ void RemovableDriveManager::register_window()
|
|||||||
}
|
}
|
||||||
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
/* currently not used, left for possible future use
|
||||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// here we need to catch messeges about device removal
|
// here we need to catch messeges about device removal
|
||||||
// problem is that when ejecting usb (how is it implemented above) there is no messege dispached. Only after physical removal of the device.
|
// problem is that when ejecting usb (how is it implemented above) there is no messege dispached. Only after physical removal of the device.
|
||||||
//uncomment register_window() in init() to register and comment update() in GUI_App.cpp (only for windows!) to stop recieving periodical updates
|
//uncomment register_window() in init() to register and comment update() in GUI_App.cpp (only for windows!) to stop recieving periodical updates
|
||||||
|
|
||||||
LRESULT lRet = 1;
|
LRESULT lRet = 1;
|
||||||
static HDEVNOTIFY hDeviceNotify;
|
static HDEVNOTIFY hDeviceNotify;
|
||||||
|
|
||||||
@ -221,8 +220,9 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return lRet;
|
return lRet;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#else
|
#else
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
@ -370,7 +370,7 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
{
|
{
|
||||||
std::size_t found = path.find_last_of("/");
|
std::size_t found = path.find_last_of("/");
|
||||||
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
||||||
@ -440,7 +440,7 @@ bool RemovableDriveManager::update(const long time,const bool check)
|
|||||||
return !m_current_drives.empty();
|
return !m_current_drives.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
bool RemovableDriveManager::is_drive_mounted(const std::string &path) const
|
||||||
{
|
{
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -451,7 +451,7 @@ bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_path()
|
std::string RemovableDriveManager::get_drive_path()
|
||||||
{
|
{
|
||||||
if (m_current_drives.size() == 0)
|
if (m_current_drives.size() == 0)
|
||||||
{
|
{
|
||||||
@ -462,17 +462,17 @@ std::string RemovableDriveManager::get_drive_path()
|
|||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
return m_current_drives.back().path;
|
return m_current_drives.back().path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_path()
|
std::string RemovableDriveManager::get_last_save_path() const
|
||||||
{
|
{
|
||||||
if (!m_last_save_path_verified)
|
if (!m_last_save_path_verified)
|
||||||
return "";
|
return "";
|
||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_name()
|
std::string RemovableDriveManager::get_last_save_name() const
|
||||||
{
|
{
|
||||||
return m_last_save_name;
|
return m_last_save_name;
|
||||||
}
|
}
|
||||||
std::vector<DriveData> RemovableDriveManager::get_all_drives()
|
std::vector<DriveData> RemovableDriveManager::get_all_drives() const
|
||||||
{
|
{
|
||||||
return m_current_drives;
|
return m_current_drives;
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ void RemovableDriveManager::check_and_notify()
|
|||||||
{
|
{
|
||||||
m_drive_count_changed_callback(m_plater_ready_to_slice);
|
m_drive_count_changed_callback(m_plater_ready_to_slice);
|
||||||
}
|
}
|
||||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() /*&& m_last_save_path_verified */&& !is_drive_mounted(m_last_save_path))
|
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && !is_drive_mounted(m_last_save_path))
|
||||||
{
|
{
|
||||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ void RemovableDriveManager::verify_last_save_path()
|
|||||||
reset_last_save_path();
|
reset_last_save_path();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
std::string RemovableDriveManager::get_drive_name(const std::string& path) const
|
||||||
{
|
{
|
||||||
if (m_current_drives.size() == 0)
|
if (m_current_drives.size() == 0)
|
||||||
return "";
|
return "";
|
||||||
@ -546,7 +546,7 @@ std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::is_last_drive_removed()
|
bool RemovableDriveManager::is_last_drive_removed()
|
||||||
{
|
{
|
||||||
if(!m_last_save_path_verified)
|
if(!m_last_save_path_verified)
|
||||||
{
|
{
|
||||||
@ -578,27 +578,27 @@ void RemovableDriveManager::set_is_writing(const bool b)
|
|||||||
m_did_eject = false;
|
m_did_eject = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::get_is_writing()
|
bool RemovableDriveManager::get_is_writing() const
|
||||||
{
|
{
|
||||||
return m_is_writing;
|
return m_is_writing;
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::get_did_eject()
|
bool RemovableDriveManager::get_did_eject() const
|
||||||
{
|
{
|
||||||
return m_did_eject;
|
return m_did_eject;
|
||||||
}
|
}
|
||||||
void RemovableDriveManager::set_did_eject(const bool b)
|
void RemovableDriveManager::set_did_eject(const bool b)
|
||||||
{
|
{
|
||||||
m_did_eject = b;
|
m_did_eject = b;
|
||||||
}
|
}
|
||||||
size_t RemovableDriveManager::get_drives_count()
|
size_t RemovableDriveManager::get_drives_count() const
|
||||||
{
|
{
|
||||||
return m_current_drives.size();
|
return m_current_drives.size();
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_ejected_path()
|
std::string RemovableDriveManager::get_ejected_path() const
|
||||||
{
|
{
|
||||||
return m_ejected_path;
|
return m_ejected_path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_ejected_name()
|
std::string RemovableDriveManager::get_ejected_name() const
|
||||||
{
|
{
|
||||||
return m_ejected_name;
|
return m_ejected_name;
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,14 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
//update() searches for removable devices, returns false if empty. /time = 0 is forced update, time expects wxGetLocalTime()
|
//update() searches for removable devices, returns false if empty. /time = 0 is forced update, time expects wxGetLocalTime()
|
||||||
bool update(const long time = 0,const bool check = false);
|
bool update(const long time = 0,const bool check = false);
|
||||||
bool is_drive_mounted(const std::string &path);
|
bool is_drive_mounted(const std::string &path) const;
|
||||||
void eject_drive(const std::string &path);
|
void eject_drive(const std::string &path);
|
||||||
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
||||||
std::string get_last_save_path();
|
std::string get_last_save_path() const;
|
||||||
std::string get_last_save_name();
|
std::string get_last_save_name() const;
|
||||||
//returns path to last drive which was used, if none was used, returns empty string
|
//returns path to last drive which was used, if none was used, returns empty string
|
||||||
std::string get_drive_path();
|
std::string get_drive_path();
|
||||||
std::vector<DriveData> get_all_drives();
|
std::vector<DriveData> get_all_drives() const;
|
||||||
bool is_path_on_removable_drive(const std::string &path);
|
bool is_path_on_removable_drive(const std::string &path);
|
||||||
// callback will notify only if device with last save path was removed
|
// callback will notify only if device with last save path was removed
|
||||||
void add_remove_callback(std::function<void()> callback);
|
void add_remove_callback(std::function<void()> callback);
|
||||||
@ -59,13 +59,13 @@ public:
|
|||||||
// param as update()
|
// param as update()
|
||||||
bool is_last_drive_removed_with_update(const long time = 0);
|
bool is_last_drive_removed_with_update(const long time = 0);
|
||||||
void set_is_writing(const bool b);
|
void set_is_writing(const bool b);
|
||||||
bool get_is_writing();
|
bool get_is_writing() const;
|
||||||
bool get_did_eject();
|
bool get_did_eject() const;
|
||||||
void set_did_eject(const bool b);
|
void set_did_eject(const bool b);
|
||||||
std::string get_drive_name(const std::string& path);
|
std::string get_drive_name(const std::string& path) const;
|
||||||
size_t get_drives_count();
|
size_t get_drives_count() const;
|
||||||
std::string get_ejected_path();
|
std::string get_ejected_path() const;
|
||||||
std::string get_ejected_name();
|
std::string get_ejected_name() const;
|
||||||
private:
|
private:
|
||||||
RemovableDriveManager();
|
RemovableDriveManager();
|
||||||
void search_for_drives();
|
void search_for_drives();
|
||||||
|
@ -3212,7 +3212,7 @@ void DoubleSlider::OnMotion(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu)
|
void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu, bool switch_current_code/* = false*/)
|
||||||
{
|
{
|
||||||
const int extruders_cnt = Slic3r::GUI::wxGetApp().extruders_edited_cnt();
|
const int extruders_cnt = Slic3r::GUI::wxGetApp().extruders_edited_cnt();
|
||||||
if (extruders_cnt > 1)
|
if (extruders_cnt > 1)
|
||||||
@ -3233,7 +3233,9 @@ void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu)
|
|||||||
[is_active_extruder]() { return !is_active_extruder; }, Slic3r::GUI::wxGetApp().plater());
|
[is_active_extruder]() { return !is_active_extruder; }, Slic3r::GUI::wxGetApp().plater());
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString change_extruder_menu_name = m_mode == t_mode::MultiAsSingle ? _(L("Change extruder")) : _(L("Change extruder (N/A)"));
|
const wxString change_extruder_menu_name = m_mode == t_mode::MultiAsSingle ?
|
||||||
|
(switch_current_code ? _(L("Switch code to Change extruder")) : _(L("Change extruder")) ) :
|
||||||
|
_(L("Change extruder (N/A)"));
|
||||||
|
|
||||||
wxMenuItem* change_extruder_menu_item = menu->AppendSubMenu(change_extruder_menu, change_extruder_menu_name, _(L("Use another extruder")));
|
wxMenuItem* change_extruder_menu_item = menu->AppendSubMenu(change_extruder_menu, change_extruder_menu_name, _(L("Use another extruder")));
|
||||||
change_extruder_menu_item->SetBitmap(create_scaled_bitmap(this, "change_extruder"));
|
change_extruder_menu_item->SetBitmap(create_scaled_bitmap(this, "change_extruder"));
|
||||||
@ -3244,7 +3246,7 @@ void DoubleSlider::append_change_extruder_menu_item(wxMenu* menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSlider::append_add_color_change_menu_item(wxMenu* menu)
|
void DoubleSlider::append_add_color_change_menu_item(wxMenu* menu, bool switch_current_code/* = false*/)
|
||||||
{
|
{
|
||||||
const int extruders_cnt = Slic3r::GUI::wxGetApp().extruders_edited_cnt();
|
const int extruders_cnt = Slic3r::GUI::wxGetApp().extruders_edited_cnt();
|
||||||
if (extruders_cnt > 1)
|
if (extruders_cnt > 1)
|
||||||
@ -3265,7 +3267,9 @@ void DoubleSlider::append_add_color_change_menu_item(wxMenu* menu)
|
|||||||
[is_used_extruder]() { return is_used_extruder; }, Slic3r::GUI::wxGetApp().plater());
|
[is_used_extruder]() { return is_used_extruder; }, Slic3r::GUI::wxGetApp().plater());
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString menu_name = from_u8((boost::format(_utf8(L("Add color change (%1%) for:"))) % Slic3r::ColorChangeCode).str());
|
const wxString menu_name = switch_current_code ?
|
||||||
|
from_u8((boost::format(_utf8(L("Switch code to Color change (%1%) for:"))) % Slic3r::ColorChangeCode).str()) :
|
||||||
|
from_u8((boost::format(_utf8(L("Add color change (%1%) for:"))) % Slic3r::ColorChangeCode).str());
|
||||||
wxMenuItem* add_color_change_menu_item = menu->AppendSubMenu(add_color_change_menu, menu_name, "");
|
wxMenuItem* add_color_change_menu_item = menu->AppendSubMenu(add_color_change_menu, menu_name, "");
|
||||||
add_color_change_menu_item->SetBitmap(create_scaled_bitmap(this, "colorchange_add_m"));
|
add_color_change_menu_item->SetBitmap(create_scaled_bitmap(this, "colorchange_add_m"));
|
||||||
}
|
}
|
||||||
@ -3427,20 +3431,13 @@ void DoubleSlider::OnRightDown(wxMouseEvent& event)
|
|||||||
if (is_point_in_rect(pos, m_rect_tick_action) && m_is_enabled_tick_manipulation)
|
if (is_point_in_rect(pos, m_rect_tick_action) && m_is_enabled_tick_manipulation)
|
||||||
{
|
{
|
||||||
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
||||||
// if on this Z doesn't exist tick
|
if (m_ticks.ticks.find(TICK_CODE{ tick }) == m_ticks.ticks.end()) // if on this Z doesn't exist tick
|
||||||
auto it = m_ticks.ticks.find(TICK_CODE{ tick });
|
|
||||||
if (it == m_ticks.ticks.end())
|
|
||||||
{
|
|
||||||
// show context menu on OnRightUp()
|
// show context menu on OnRightUp()
|
||||||
m_show_context_menu = true;
|
m_show_context_menu = true;
|
||||||
return;
|
else
|
||||||
}
|
|
||||||
if (it->gcode != Slic3r::ToolChangeCode)
|
|
||||||
{
|
|
||||||
// show "Edit" and "Delete" menu on OnRightUp()
|
// show "Edit" and "Delete" menu on OnRightUp()
|
||||||
m_show_edit_menu = true;
|
m_show_edit_menu = true;
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_selected_slider(event.GetLogicalPosition(dc));
|
detect_selected_slider(event.GetLogicalPosition(dc));
|
||||||
@ -3489,7 +3486,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
|
|||||||
std::set<int> used_extruders;
|
std::set<int> used_extruders;
|
||||||
|
|
||||||
auto it_layer_tools = std::lower_bound(tool_ordering.begin(), tool_ordering.end(), Slic3r::LayerTools(m_values[tick]));
|
auto it_layer_tools = std::lower_bound(tool_ordering.begin(), tool_ordering.end(), Slic3r::LayerTools(m_values[tick]));
|
||||||
for (; it_layer_tools != tool_ordering.end(); it_layer_tools++)
|
for (; it_layer_tools != tool_ordering.end(); ++it_layer_tools)
|
||||||
{
|
{
|
||||||
const std::vector<unsigned>& extruders = it_layer_tools->extruders;
|
const std::vector<unsigned>& extruders = it_layer_tools->extruders;
|
||||||
for (const auto& extruder : extruders)
|
for (const auto& extruder : extruders)
|
||||||
@ -3508,7 +3505,10 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
|
|||||||
|
|
||||||
auto it_start = ticks.lower_bound(TICK_CODE{tick});
|
auto it_start = ticks.lower_bound(TICK_CODE{tick});
|
||||||
auto it = it_start;
|
auto it = it_start;
|
||||||
if (it == ticks.begin() && it->gcode == Slic3r::ToolChangeCode) {
|
if (it == ticks.begin() && it->gcode == Slic3r::ToolChangeCode &&
|
||||||
|
tick != it->tick ) // In case of switch of ToolChange to ColorChange, when tick exists,
|
||||||
|
// we shouldn't change color for extruder, which will be deleted
|
||||||
|
{
|
||||||
used_extruders.emplace(it->extruder);
|
used_extruders.emplace(it->extruder);
|
||||||
if (tick < it->tick)
|
if (tick < it->tick)
|
||||||
used_extruders.emplace(default_initial_extruder);
|
used_extruders.emplace(default_initial_extruder);
|
||||||
@ -3516,8 +3516,7 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
|
|||||||
|
|
||||||
while (it != ticks.begin()) {
|
while (it != ticks.begin()) {
|
||||||
--it;
|
--it;
|
||||||
if(it->gcode == Slic3r::ToolChangeCode)
|
if (it->gcode == Slic3r::ToolChangeCode && tick != it->tick) {
|
||||||
{
|
|
||||||
used_extruders.emplace(it->extruder);
|
used_extruders.emplace(it->extruder);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3526,12 +3525,9 @@ std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
|
|||||||
if (it == ticks.begin() && used_extruders.empty())
|
if (it == ticks.begin() && used_extruders.empty())
|
||||||
used_extruders.emplace(default_initial_extruder);
|
used_extruders.emplace(default_initial_extruder);
|
||||||
|
|
||||||
it = it_start;
|
for (it = it_start; it != ticks.end(); ++it)
|
||||||
while (it != ticks.end()) {
|
if (it->gcode == Slic3r::ToolChangeCode && tick != it->tick)
|
||||||
if(it->gcode == Slic3r::ToolChangeCode)
|
|
||||||
used_extruders.emplace(it->extruder);
|
used_extruders.emplace(it->extruder);
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return used_extruders;
|
return used_extruders;
|
||||||
}
|
}
|
||||||
@ -3574,13 +3570,20 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
|
|||||||
std::set<TICK_CODE>::iterator it = m_ticks.ticks.find(TICK_CODE{ m_selection == ssLower ? m_lower_value : m_higher_value });
|
std::set<TICK_CODE>::iterator it = m_ticks.ticks.find(TICK_CODE{ m_selection == ssLower ? m_lower_value : m_higher_value });
|
||||||
const bool is_color_change = it->gcode == Slic3r::ColorChangeCode;
|
const bool is_color_change = it->gcode == Slic3r::ColorChangeCode;
|
||||||
|
|
||||||
append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Edit color")) :
|
if (it->gcode == Slic3r::ToolChangeCode)
|
||||||
it->gcode == Slic3r::PausePrintCode ? _(L("Edit pause print message")) :
|
append_add_color_change_menu_item(&menu, true);
|
||||||
_(L("Edit custom G-code")), "",
|
else
|
||||||
[this](wxCommandEvent&) { edit_tick(); }, "edit_uni", &menu);
|
append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Edit color")) :
|
||||||
|
it->gcode == Slic3r::PausePrintCode ? _(L("Edit pause print message")) :
|
||||||
|
_(L("Edit custom G-code")), "",
|
||||||
|
[this](wxCommandEvent&) { edit_tick(); }, "edit_uni", &menu);
|
||||||
|
|
||||||
|
if (it->gcode == Slic3r::ColorChangeCode && m_mode == t_mode::MultiAsSingle)
|
||||||
|
append_change_extruder_menu_item(&menu, true);
|
||||||
|
|
||||||
append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Delete color change")) :
|
append_menu_item(&menu, wxID_ANY, it->gcode == Slic3r::ColorChangeCode ? _(L("Delete color change")) :
|
||||||
it->gcode == Slic3r::PausePrintCode ? _(L("Delete pause print")) :
|
it->gcode == Slic3r::ToolChangeCode ? _(L("Delete tool change")) :
|
||||||
|
it->gcode == Slic3r::PausePrintCode ? _(L("Delete pause print")) :
|
||||||
_(L("Delete custom G-code")), "",
|
_(L("Delete custom G-code")), "",
|
||||||
[this](wxCommandEvent&) { delete_current_tick();}, "colorchange_del_f", &menu);
|
[this](wxCommandEvent&) { delete_current_tick();}, "colorchange_del_f", &menu);
|
||||||
|
|
||||||
@ -3645,13 +3648,23 @@ void DoubleSlider::add_code_as_tick(std::string code, int selected_extruder/* =
|
|||||||
return;
|
return;
|
||||||
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
|
||||||
|
|
||||||
if (m_ticks.ticks.find(TICK_CODE{ tick }) != m_ticks.ticks.end() || // if on this Z doesn't exist tick
|
if ( !check_ticks_changed_event(code) )
|
||||||
!check_ticks_changed_event(code))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int extruder = selected_extruder > 0 ? selected_extruder : std::max<int>(1, m_only_extruder);
|
const int extruder = selected_extruder > 0 ? selected_extruder : std::max<int>(1, m_only_extruder);
|
||||||
|
const auto it = m_ticks.ticks.find(TICK_CODE{ tick });
|
||||||
if (!m_ticks.add_tick(tick, code, extruder, m_values[tick]))
|
|
||||||
|
if ( it == m_ticks.ticks.end() ) {
|
||||||
|
// try to add tick
|
||||||
|
if (!m_ticks.add_tick(tick, code, extruder, m_values[tick]))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (code == Slic3r::ToolChangeCode || code == Slic3r::ColorChangeCode) {
|
||||||
|
// try to switch tick code to ToolChangeCode or ColorChangeCode accordingly
|
||||||
|
if (!m_ticks.switch_code_for_tick(it, code, extruder))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
post_ticks_changed_event(code);
|
post_ticks_changed_event(code);
|
||||||
@ -3679,7 +3692,10 @@ void DoubleSlider::add_current_tick(bool call_from_keyboard /*= false*/)
|
|||||||
else
|
else
|
||||||
append_add_color_change_menu_item(&menu);
|
append_add_color_change_menu_item(&menu);
|
||||||
|
|
||||||
wxPoint pos = wxDefaultPosition;
|
wxPoint pos = wxDefaultPosition;
|
||||||
|
/* Menu position will be calculated from mouse click position, but...
|
||||||
|
* if function is called from keyboard (pressing "+"), we should to calculate it
|
||||||
|
* */
|
||||||
if (call_from_keyboard)
|
if (call_from_keyboard)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -3701,17 +3717,15 @@ void DoubleSlider::delete_current_tick()
|
|||||||
{
|
{
|
||||||
if (m_selection == ssUndef)
|
if (m_selection == ssUndef)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto it = m_ticks.ticks.find(TICK_CODE{ m_selection == ssLower ? m_lower_value : m_higher_value });
|
auto it = m_ticks.ticks.find(TICK_CODE{ m_selection == ssLower ? m_lower_value : m_higher_value });
|
||||||
|
if (it == m_ticks.ticks.end() ||
|
||||||
|
!check_ticks_changed_event(it->gcode))
|
||||||
|
return;
|
||||||
|
|
||||||
if (it != m_ticks.ticks.end())
|
const std::string code = it->gcode;
|
||||||
{
|
m_ticks.ticks.erase(it);
|
||||||
if (!check_ticks_changed_event(it->gcode))
|
post_ticks_changed_event(code);
|
||||||
return;
|
|
||||||
|
|
||||||
const std::string code = it->gcode;
|
|
||||||
m_ticks.ticks.erase(it);
|
|
||||||
post_ticks_changed_event(code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleSlider::edit_tick()
|
void DoubleSlider::edit_tick()
|
||||||
@ -3719,7 +3733,7 @@ void DoubleSlider::edit_tick()
|
|||||||
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 std::set<TICK_CODE>::iterator it = m_ticks.ticks.find(TICK_CODE{ tick });
|
const std::set<TICK_CODE>::iterator it = m_ticks.ticks.find(TICK_CODE{ tick });
|
||||||
|
|
||||||
if (it == m_ticks.ticks.end() || // if on this Z exists tick
|
if (it == m_ticks.ticks.end() ||
|
||||||
!check_ticks_changed_event(it->gcode))
|
!check_ticks_changed_event(it->gcode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -3842,6 +3856,31 @@ bool DoubleSlider::check_ticks_changed_event(const std::string& gcode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string DoubleSlider::TICK_CODE_INFO::get_color_for_tick(TICK_CODE tick, const std::string& code, const int extruder)
|
||||||
|
{
|
||||||
|
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||||
|
std::string color = colors[extruder - 1];
|
||||||
|
|
||||||
|
if (code == Slic3r::ColorChangeCode)
|
||||||
|
{
|
||||||
|
if (!ticks.empty())
|
||||||
|
{
|
||||||
|
auto before_tick_it = std::lower_bound(ticks.begin(), ticks.end(), tick );
|
||||||
|
while (before_tick_it != ticks.begin()) {
|
||||||
|
--before_tick_it;
|
||||||
|
if (before_tick_it->gcode == Slic3r::ColorChangeCode && before_tick_it->extruder == extruder) {
|
||||||
|
color = before_tick_it->color;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color = get_new_color(color);
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
bool DoubleSlider::TICK_CODE_INFO::add_tick(const int tick, std::string& code, const int extruder, double print_z)
|
bool DoubleSlider::TICK_CODE_INFO::add_tick(const int tick, std::string& code, const int extruder, double print_z)
|
||||||
{
|
{
|
||||||
std::string color;
|
std::string color;
|
||||||
@ -3864,28 +3903,10 @@ bool DoubleSlider::TICK_CODE_INFO::add_tick(const int tick, std::string& code, c
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
color = get_color_for_tick(TICK_CODE{ tick }, code, extruder);
|
||||||
color = colors[extruder - 1];
|
if (color.empty())
|
||||||
|
return false;
|
||||||
if (code == Slic3r::ColorChangeCode)
|
}
|
||||||
{
|
|
||||||
if (!ticks.empty())
|
|
||||||
{
|
|
||||||
auto before_tick_it = std::lower_bound(ticks.begin(), ticks.end(), TICK_CODE{ tick });
|
|
||||||
while (before_tick_it != ticks.begin()) {
|
|
||||||
--before_tick_it;
|
|
||||||
if (before_tick_it->gcode == Slic3r::ColorChangeCode && before_tick_it->extruder == extruder) {
|
|
||||||
color = before_tick_it->color;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
color = get_new_color(color);
|
|
||||||
if (color.empty())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ticks.emplace(TICK_CODE{ tick, code, extruder, color });
|
ticks.emplace(TICK_CODE{ tick, code, extruder, color });
|
||||||
return true;
|
return true;
|
||||||
@ -3937,6 +3958,23 @@ void DoubleSlider::TICK_CODE_INFO::switch_code(const std::string& code_from, con
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DoubleSlider::TICK_CODE_INFO::switch_code_for_tick(std::set<TICK_CODE>::iterator it, const std::string& code_to, const int extruder)
|
||||||
|
{
|
||||||
|
const std::string color = get_color_for_tick(*it, code_to, extruder);
|
||||||
|
if (color.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TICK_CODE changed_tick = *it;
|
||||||
|
changed_tick.gcode = code_to;
|
||||||
|
changed_tick.extruder = extruder;
|
||||||
|
changed_tick.color = color;
|
||||||
|
|
||||||
|
ticks.erase(it);
|
||||||
|
ticks.emplace(changed_tick);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void DoubleSlider::TICK_CODE_INFO::erase_all_ticks_with_code(const std::string& gcode)
|
void DoubleSlider::TICK_CODE_INFO::erase_all_ticks_with_code(const std::string& gcode)
|
||||||
{
|
{
|
||||||
for (auto it{ ticks.begin() }, end{ ticks.end() }; it != end; ) {
|
for (auto it{ ticks.begin() }, end{ ticks.end() }; it != end; ) {
|
||||||
|
@ -910,8 +910,8 @@ private:
|
|||||||
|
|
||||||
void post_ticks_changed_event(const std::string& gcode = "");
|
void post_ticks_changed_event(const std::string& gcode = "");
|
||||||
bool check_ticks_changed_event(const std::string& gcode);
|
bool check_ticks_changed_event(const std::string& gcode);
|
||||||
void append_change_extruder_menu_item(wxMenu*);
|
void append_change_extruder_menu_item (wxMenu*, bool switch_current_code = false);
|
||||||
void append_add_color_change_menu_item(wxMenu*);
|
void append_add_color_change_menu_item(wxMenu*, bool switch_current_code = false);
|
||||||
|
|
||||||
bool is_osx { false };
|
bool is_osx { false };
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
@ -988,6 +988,7 @@ private:
|
|||||||
bool add_tick (const int tick, std::string &code, int extruder, double print_z);
|
bool add_tick (const int tick, std::string &code, int extruder, double print_z);
|
||||||
bool edit_tick (std::set<TICK_CODE>::iterator it, double print_z);
|
bool edit_tick (std::set<TICK_CODE>::iterator it, double print_z);
|
||||||
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<TICK_CODE>::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);
|
||||||
|
|
||||||
@ -1002,6 +1003,8 @@ private:
|
|||||||
std::string pause_print_msg = "";
|
std::string pause_print_msg = "";
|
||||||
bool m_suppress_plus = false;
|
bool m_suppress_plus = false;
|
||||||
bool m_suppress_minus = false;
|
bool m_suppress_minus = false;
|
||||||
|
|
||||||
|
std::string get_color_for_tick(TICK_CODE tick, const std::string& code, const int extruder);
|
||||||
}
|
}
|
||||||
m_ticks;
|
m_ticks;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user