mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merged with dev
This commit is contained in:
parent
d934b63424
commit
fe3b92870f
90 changed files with 3310 additions and 1748 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if __APPLE__
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
@ -121,7 +122,6 @@ wxPanel *g_wxPlater = nullptr;
|
|||
AppConfig *g_AppConfig = nullptr;
|
||||
PresetBundle *g_PresetBundle= nullptr;
|
||||
PresetUpdater *g_PresetUpdater = nullptr;
|
||||
_3DScene *g_3DScene = nullptr;
|
||||
wxColour g_color_label_modified;
|
||||
wxColour g_color_label_sys;
|
||||
wxColour g_color_label_default;
|
||||
|
@ -141,14 +141,9 @@ wxButton* g_wiping_dialog_button = nullptr;
|
|||
//showed/hided controls according to the view mode
|
||||
wxWindow *g_right_panel = nullptr;
|
||||
wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr;
|
||||
wxBoxSizer *g_expert_mode_part_sizer = nullptr;
|
||||
wxBoxSizer *g_scrolled_window_sizer = nullptr;
|
||||
wxBoxSizer *g_info_sizer = nullptr;
|
||||
wxBoxSizer *g_object_list_sizer = nullptr;
|
||||
wxButton *g_btn_export_gcode = nullptr;
|
||||
wxButton *g_btn_export_stl = nullptr;
|
||||
wxButton *g_btn_reslice = nullptr;
|
||||
wxButton *g_btn_print = nullptr;
|
||||
wxButton *g_btn_send_gcode = nullptr;
|
||||
std::vector<wxButton*> g_buttons;
|
||||
wxStaticBitmap *g_manifold_warning_icon = nullptr;
|
||||
bool g_show_print_info = false;
|
||||
bool g_show_manifold_warning_icon = false;
|
||||
|
@ -241,27 +236,36 @@ void set_preset_updater(PresetUpdater *updater)
|
|||
g_PresetUpdater = updater;
|
||||
}
|
||||
|
||||
void set_3DScene(_3DScene *scene)
|
||||
enum ActionButtons
|
||||
{
|
||||
g_3DScene = scene;
|
||||
}
|
||||
abExportGCode,
|
||||
abReslice,
|
||||
abPrint,
|
||||
abSendGCode,
|
||||
};
|
||||
|
||||
void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer,
|
||||
wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer,
|
||||
void set_objects_from_perl( wxWindow* parent,
|
||||
wxBoxSizer *frequently_changed_parameters_sizer,
|
||||
wxBoxSizer *info_sizer,
|
||||
wxButton *btn_export_gcode,
|
||||
wxButton *btn_export_stl, wxButton *btn_reslice,
|
||||
wxButton *btn_print, wxButton *btn_send_gcode,
|
||||
wxButton *btn_reslice,
|
||||
wxButton *btn_print,
|
||||
wxButton *btn_send_gcode,
|
||||
wxStaticBitmap *manifold_warning_icon)
|
||||
{
|
||||
g_right_panel = parent;
|
||||
g_right_panel = parent->GetParent();
|
||||
g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer;
|
||||
g_expert_mode_part_sizer = expert_mode_part_sizer;
|
||||
g_scrolled_window_sizer = scrolled_window_sizer;
|
||||
g_btn_export_gcode = btn_export_gcode;
|
||||
g_btn_export_stl = btn_export_stl;
|
||||
g_btn_reslice = btn_reslice;
|
||||
g_btn_print = btn_print;
|
||||
g_btn_send_gcode = btn_send_gcode;
|
||||
g_info_sizer = info_sizer;
|
||||
|
||||
g_buttons.push_back(btn_export_gcode);
|
||||
g_buttons.push_back(btn_reslice);
|
||||
g_buttons.push_back(btn_print);
|
||||
g_buttons.push_back(btn_send_gcode);
|
||||
|
||||
// Update font style for buttons
|
||||
for (auto btn : g_buttons)
|
||||
btn->SetFont(bold_font());
|
||||
|
||||
g_manifold_warning_icon = manifold_warning_icon;
|
||||
}
|
||||
|
||||
|
@ -273,6 +277,15 @@ void set_show_print_info(bool show)
|
|||
void set_show_manifold_warning_icon(bool show)
|
||||
{
|
||||
g_show_manifold_warning_icon = show;
|
||||
if (!g_manifold_warning_icon)
|
||||
return;
|
||||
|
||||
// update manifold_warning_icon showing
|
||||
if (show && !g_info_sizer->IsShown(static_cast<size_t>(0)))
|
||||
g_show_manifold_warning_icon = false;
|
||||
|
||||
g_manifold_warning_icon->Show(g_show_manifold_warning_icon);
|
||||
g_manifold_warning_icon->GetParent()->Layout();
|
||||
}
|
||||
|
||||
void set_objects_list_sizer(wxBoxSizer *objects_list_sizer){
|
||||
|
@ -963,12 +976,11 @@ wxString from_u8(const std::string &str)
|
|||
return wxString::FromUTF8(str.c_str());
|
||||
}
|
||||
|
||||
void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer,
|
||||
Model &model,
|
||||
int event_object_selection_changed,
|
||||
int event_object_settings_changed,
|
||||
int event_remove_object,
|
||||
int event_update_scene)
|
||||
void set_model_events_from_perl(Model &model,
|
||||
int event_object_selection_changed,
|
||||
int event_object_settings_changed,
|
||||
int event_remove_object,
|
||||
int event_update_scene)
|
||||
{
|
||||
set_event_object_selection_changed(event_object_selection_changed);
|
||||
set_event_object_settings_changed(event_object_settings_changed);
|
||||
|
@ -1105,7 +1117,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
|
|||
};
|
||||
optgroup->append_line(line);
|
||||
|
||||
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxBOTTOM, 2);
|
||||
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2);
|
||||
|
||||
m_optgroups.push_back(optgroup);// ogFrequentlyChangingParameters
|
||||
|
||||
|
@ -1132,24 +1144,23 @@ void show_frequently_changed_parameters(bool show)
|
|||
|
||||
void show_buttons(bool show)
|
||||
{
|
||||
g_btn_export_stl->Show(show);
|
||||
g_btn_reslice->Show(show);
|
||||
g_buttons[abReslice]->Show(show);
|
||||
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) {
|
||||
TabPrinter *tab = dynamic_cast<TabPrinter*>(g_wxTabPanel->GetPage(i));
|
||||
if (!tab)
|
||||
continue;
|
||||
if (g_PresetBundle->printers.get_selected_preset().printer_technology() == ptFFF) {
|
||||
g_btn_print->Show(show && !tab->m_config->opt_string("serial_port").empty());
|
||||
g_btn_send_gcode->Show(show && !tab->m_config->opt_string("print_host").empty());
|
||||
g_buttons[abPrint]->Show(show && !tab->m_config->opt_string("serial_port").empty());
|
||||
g_buttons[abSendGCode]->Show(show && !tab->m_config->opt_string("print_host").empty());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void show_info_sizer(bool show)
|
||||
void show_info_sizer(const bool show)
|
||||
{
|
||||
g_scrolled_window_sizer->Show(static_cast<size_t>(0), show);
|
||||
g_scrolled_window_sizer->Show(1, show && g_show_print_info);
|
||||
g_info_sizer->Show(static_cast<size_t>(0), show);
|
||||
g_info_sizer->Show(1, show && g_show_print_info);
|
||||
g_manifold_warning_icon->Show(show && g_show_manifold_warning_icon);
|
||||
}
|
||||
|
||||
|
@ -1162,31 +1173,22 @@ void show_object_name(bool show)
|
|||
|
||||
void update_mode()
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates(g_right_panel);
|
||||
|
||||
// TODO There is a not the best place of it!
|
||||
//*** Update style of the "Export G-code" button****
|
||||
if (g_btn_export_gcode->GetFont() != bold_font()){
|
||||
g_btn_export_gcode->SetBackgroundColour(wxColour(252, 77, 1));
|
||||
g_btn_export_gcode->SetFont(bold_font());
|
||||
}
|
||||
// ***********************************
|
||||
wxWindowUpdateLocker noUpdates(g_right_panel->GetParent());
|
||||
|
||||
ConfigMenuIDs mode = get_view_mode();
|
||||
|
||||
// show_frequently_changed_parameters(mode >= ConfigMenuModeRegular);
|
||||
// g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert);
|
||||
g_object_list_sizer->Show(mode == ConfigMenuModeExpert);
|
||||
show_info_sizer(mode == ConfigMenuModeExpert);
|
||||
show_buttons(mode == ConfigMenuModeExpert);
|
||||
show_object_name(mode == ConfigMenuModeSimple);
|
||||
show_manipulation_sizer(mode == ConfigMenuModeSimple);
|
||||
|
||||
// TODO There is a not the best place of it!
|
||||
// *** Update showing of the collpane_settings
|
||||
// show_collpane_settings(mode == ConfigMenuModeExpert);
|
||||
// *************************
|
||||
g_right_panel->Layout();
|
||||
g_right_panel->GetParent()->GetParent()->Layout();
|
||||
g_right_panel->GetParent()->Layout();
|
||||
}
|
||||
|
||||
bool is_expert_mode(){
|
||||
|
@ -1254,12 +1256,77 @@ int get_export_option(wxFileDialog* dlg)
|
|||
|
||||
}
|
||||
|
||||
void get_current_screen_size(unsigned &width, unsigned &height)
|
||||
bool get_current_screen_size(wxWindow *window, unsigned &width, unsigned &height)
|
||||
{
|
||||
wxDisplay display(wxDisplay::GetFromWindow(g_wxMainFrame));
|
||||
const auto idx = wxDisplay::GetFromWindow(window);
|
||||
if (idx == wxNOT_FOUND) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wxDisplay display(idx);
|
||||
const auto disp_size = display.GetClientArea();
|
||||
width = disp_size.GetWidth();
|
||||
height = disp_size.GetHeight();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void save_window_size(wxTopLevelWindow *window, const std::string &name)
|
||||
{
|
||||
const wxSize size = window->GetSize();
|
||||
const wxPoint pos = window->GetPosition();
|
||||
const auto maximized = window->IsMaximized() ? "1" : "0";
|
||||
|
||||
g_AppConfig->set((boost::format("window_%1%_size") % name).str(), (boost::format("%1%;%2%") % size.GetWidth() % size.GetHeight()).str());
|
||||
g_AppConfig->set((boost::format("window_%1%_maximized") % name).str(), maximized);
|
||||
}
|
||||
|
||||
void restore_window_size(wxTopLevelWindow *window, const std::string &name)
|
||||
{
|
||||
// XXX: This still doesn't behave nicely in some situations (mostly on Linux).
|
||||
// The problem is that it's hard to obtain window position with respect to screen geometry reliably
|
||||
// from wxWidgets. Sometimes wxWidgets claim a window is located on a different screen than on which
|
||||
// it's actually visible. I suspect this has something to do with window initialization (maybe we
|
||||
// restore window geometry too early), but haven't yet found a workaround.
|
||||
|
||||
const auto display_idx = wxDisplay::GetFromWindow(window);
|
||||
if (display_idx == wxNOT_FOUND) { return; }
|
||||
|
||||
const auto display = wxDisplay(display_idx).GetClientArea();
|
||||
std::vector<std::string> pair;
|
||||
|
||||
try {
|
||||
const auto key_size = (boost::format("window_%1%_size") % name).str();
|
||||
if (g_AppConfig->has(key_size)) {
|
||||
if (unescape_strings_cstyle(g_AppConfig->get(key_size), pair) && pair.size() == 2) {
|
||||
auto width = boost::lexical_cast<int>(pair[0]);
|
||||
auto height = boost::lexical_cast<int>(pair[1]);
|
||||
|
||||
window->SetSize(width, height);
|
||||
}
|
||||
}
|
||||
} catch(const boost::bad_lexical_cast &) {}
|
||||
|
||||
// Maximizing should be the last thing to do.
|
||||
// This ensure the size and position are sane when the user un-maximizes the window.
|
||||
const auto key_maximized = (boost::format("window_%1%_maximized") % name).str();
|
||||
if (g_AppConfig->get(key_maximized) == "1") {
|
||||
window->Maximize(true);
|
||||
}
|
||||
}
|
||||
|
||||
void enable_action_buttons(bool enable)
|
||||
{
|
||||
if (g_buttons.empty())
|
||||
return;
|
||||
|
||||
// Update background colour for buttons
|
||||
const wxColour bgrd_color = enable ? wxColour(224, 224, 224/*255, 96, 0*/) : wxColour(204, 204, 204);
|
||||
|
||||
for (auto btn : g_buttons) {
|
||||
btn->Enable(enable);
|
||||
btn->SetBackgroundColour(bgrd_color);
|
||||
}
|
||||
}
|
||||
|
||||
void about()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue