2018-09-20 06:40:22 +00:00
|
|
|
#ifndef slic3r_GUI_App_hpp_
|
|
|
|
#define slic3r_GUI_App_hpp_
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
#include <memory>
|
2018-09-20 06:40:22 +00:00
|
|
|
#include <string>
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "libslic3r/PrintConfig.hpp"
|
2018-10-02 11:23:38 +00:00
|
|
|
#include "MainFrame.hpp"
|
2018-10-31 09:19:44 +00:00
|
|
|
#include "ImGuiWrapper.hpp"
|
2019-06-04 16:01:41 +00:00
|
|
|
#include "ConfigWizard.hpp"
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
|
|
#include <wx/app.h>
|
2018-10-01 13:09:31 +00:00
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/font.h>
|
2018-11-26 13:41:58 +00:00
|
|
|
#include <wx/string.h>
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
class wxMenuItem;
|
2018-09-20 23:33:41 +00:00
|
|
|
class wxMenuBar;
|
2018-09-20 06:40:22 +00:00
|
|
|
class wxTopLevelWindow;
|
2018-09-20 23:33:41 +00:00
|
|
|
class wxNotebook;
|
2019-05-10 12:43:35 +00:00
|
|
|
struct wxLanguageInfo;
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
class AppConfig;
|
|
|
|
class PresetBundle;
|
|
|
|
class PresetUpdater;
|
2018-10-05 21:29:15 +00:00
|
|
|
class ModelObject;
|
2018-12-11 09:33:11 +00:00
|
|
|
class PrintHostJobQueue;
|
2018-09-20 06:40:22 +00:00
|
|
|
|
2018-10-05 21:29:15 +00:00
|
|
|
|
2020-03-06 14:10:58 +00:00
|
|
|
namespace GUI{
|
|
|
|
class RemovableDriveManager;
|
2018-10-04 09:12:55 +00:00
|
|
|
enum FileType
|
|
|
|
{
|
|
|
|
FT_STL,
|
|
|
|
FT_OBJ,
|
|
|
|
FT_AMF,
|
|
|
|
FT_3MF,
|
|
|
|
FT_PRUSA,
|
|
|
|
FT_GCODE,
|
|
|
|
FT_MODEL,
|
2019-05-15 08:23:02 +00:00
|
|
|
FT_PROJECT,
|
2018-10-04 09:12:55 +00:00
|
|
|
|
|
|
|
FT_INI,
|
|
|
|
FT_SVG,
|
2019-07-18 09:12:11 +00:00
|
|
|
|
|
|
|
FT_TEX,
|
|
|
|
|
2018-11-12 17:09:47 +00:00
|
|
|
FT_PNGZIP,
|
2018-10-04 09:12:55 +00:00
|
|
|
|
|
|
|
FT_SIZE,
|
|
|
|
};
|
2018-10-05 21:29:15 +00:00
|
|
|
|
2018-12-06 16:32:49 +00:00
|
|
|
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string());
|
2018-10-05 21:29:15 +00:00
|
|
|
|
2018-09-20 23:33:41 +00:00
|
|
|
enum ConfigMenuIDs {
|
|
|
|
ConfigMenuWizard,
|
|
|
|
ConfigMenuSnapshots,
|
|
|
|
ConfigMenuTakeSnapshot,
|
|
|
|
ConfigMenuUpdate,
|
|
|
|
ConfigMenuPreferences,
|
|
|
|
ConfigMenuModeSimple,
|
2018-10-25 12:55:03 +00:00
|
|
|
ConfigMenuModeAdvanced,
|
2018-09-20 23:33:41 +00:00
|
|
|
ConfigMenuModeExpert,
|
|
|
|
ConfigMenuLanguage,
|
|
|
|
ConfigMenuFlashFirmware,
|
|
|
|
ConfigMenuCnt,
|
|
|
|
};
|
|
|
|
|
|
|
|
class Tab;
|
2019-06-04 16:01:41 +00:00
|
|
|
class ConfigWizard;
|
2018-09-20 06:40:22 +00:00
|
|
|
|
2018-11-06 16:38:40 +00:00
|
|
|
static wxString dots("…", wxConvUTF8);
|
2018-10-03 13:14:52 +00:00
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
class GUI_App : public wxApp
|
|
|
|
{
|
2019-02-05 17:12:42 +00:00
|
|
|
bool m_initialized { false };
|
2019-05-17 15:35:15 +00:00
|
|
|
bool app_conf_exists{ false };
|
2018-09-20 06:40:22 +00:00
|
|
|
|
2018-10-01 13:09:31 +00:00
|
|
|
wxColour m_color_label_modified;
|
|
|
|
wxColour m_color_label_sys;
|
|
|
|
wxColour m_color_label_default;
|
|
|
|
|
|
|
|
wxFont m_small_font;
|
|
|
|
wxFont m_bold_font;
|
2019-03-18 19:54:01 +00:00
|
|
|
wxFont m_normal_font;
|
2018-10-01 13:09:31 +00:00
|
|
|
|
2019-10-29 09:40:34 +00:00
|
|
|
int m_em_unit; // width of a "m"-symbol in pixels for current system font
|
2019-02-06 09:55:11 +00:00
|
|
|
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
|
2019-01-31 14:55:09 +00:00
|
|
|
|
2019-08-29 13:35:28 +00:00
|
|
|
std::unique_ptr<wxLocale> m_wxLocale;
|
|
|
|
// System language, from locales, owned by wxWidgets.
|
|
|
|
const wxLanguageInfo *m_language_info_system = nullptr;
|
|
|
|
// Best translation language, provided by Windows or OSX, owned by wxWidgets.
|
|
|
|
const wxLanguageInfo *m_language_info_best = nullptr;
|
2018-10-01 13:09:31 +00:00
|
|
|
|
2020-03-06 14:10:58 +00:00
|
|
|
std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
std::unique_ptr<ImGuiWrapper> m_imgui;
|
2018-12-14 14:27:34 +00:00
|
|
|
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
|
2019-06-17 14:39:22 +00:00
|
|
|
ConfigWizard* m_wizard; // Managed by wxWindow tree
|
2018-12-11 09:33:11 +00:00
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
public:
|
|
|
|
bool OnInit() override;
|
2019-02-05 17:12:42 +00:00
|
|
|
bool initialized() const { return m_initialized; }
|
2018-11-26 09:56:07 +00:00
|
|
|
|
|
|
|
GUI_App();
|
2019-10-29 09:40:34 +00:00
|
|
|
~GUI_App() override;
|
2018-09-20 06:40:22 +00:00
|
|
|
|
2019-04-26 14:59:14 +00:00
|
|
|
static unsigned get_colour_approx_luma(const wxColour &colour);
|
|
|
|
static bool dark_mode();
|
2018-10-01 13:09:31 +00:00
|
|
|
void init_label_colours();
|
|
|
|
void update_label_colours_from_appconfig();
|
|
|
|
void init_fonts();
|
2019-05-06 16:28:23 +00:00
|
|
|
void update_fonts(const MainFrame *main_frame = nullptr);
|
2018-10-01 13:09:31 +00:00
|
|
|
void set_label_clr_modified(const wxColour& clr);
|
|
|
|
void set_label_clr_sys(const wxColour& clr);
|
|
|
|
|
|
|
|
const wxColour& get_label_clr_modified(){ return m_color_label_modified; }
|
|
|
|
const wxColour& get_label_clr_sys() { return m_color_label_sys; }
|
|
|
|
const wxColour& get_label_clr_default() { return m_color_label_default; }
|
|
|
|
|
|
|
|
const wxFont& small_font() { return m_small_font; }
|
|
|
|
const wxFont& bold_font() { return m_bold_font; }
|
2019-03-18 19:54:01 +00:00
|
|
|
const wxFont& normal_font() { return m_normal_font; }
|
2019-10-29 09:40:34 +00:00
|
|
|
int em_unit() const { return m_em_unit; }
|
2019-05-22 11:51:02 +00:00
|
|
|
float toolbar_icon_scale(const bool is_limited = false) const;
|
2018-10-01 13:09:31 +00:00
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
void recreate_GUI();
|
|
|
|
void system_info();
|
2018-12-19 12:06:24 +00:00
|
|
|
void keyboard_shortcuts();
|
2019-07-17 13:48:53 +00:00
|
|
|
void load_project(wxWindow *parent, wxString& input_file) const;
|
|
|
|
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
2019-05-03 14:27:56 +00:00
|
|
|
static bool catch_error(std::function<void()> cb, const std::string& err);
|
2019-01-11 17:09:21 +00:00
|
|
|
|
2019-04-29 14:55:41 +00:00
|
|
|
void persist_window_geometry(wxTopLevelWindow *window, bool default_maximized = false);
|
2018-09-20 06:40:22 +00:00
|
|
|
void update_ui_from_settings();
|
2018-10-17 12:01:10 +00:00
|
|
|
|
2019-04-29 16:27:46 +00:00
|
|
|
bool switch_language();
|
2019-08-29 12:07:45 +00:00
|
|
|
bool load_language(wxString language, bool initial);
|
2018-10-02 11:23:38 +00:00
|
|
|
|
2018-10-10 11:53:45 +00:00
|
|
|
Tab* get_tab(Preset::Type type);
|
2019-01-10 10:05:58 +00:00
|
|
|
ConfigOptionMode get_mode();
|
|
|
|
void save_mode(const /*ConfigOptionMode*/int mode) ;
|
2018-10-03 13:14:52 +00:00
|
|
|
void update_mode();
|
2018-10-02 11:23:38 +00:00
|
|
|
|
2018-09-20 23:33:41 +00:00
|
|
|
void add_config_menu(wxMenuBar *menu);
|
2019-07-18 15:41:47 +00:00
|
|
|
bool check_unsaved_changes(const wxString &header = wxString());
|
2018-10-01 13:09:31 +00:00
|
|
|
bool checked_tab(Tab* tab);
|
|
|
|
void load_current_presets();
|
2018-09-20 06:40:22 +00:00
|
|
|
|
2019-08-29 12:07:45 +00:00
|
|
|
wxString current_language_code() const { return m_wxLocale->GetCanonicalName(); }
|
2019-07-29 15:55:50 +00:00
|
|
|
// Translate the language code to a code, for which Prusa Research maintains translations. Defaults to "en_US".
|
2019-08-28 09:53:53 +00:00
|
|
|
wxString current_language_code_safe() const;
|
2019-04-17 12:56:44 +00:00
|
|
|
|
2019-10-29 09:40:34 +00:00
|
|
|
virtual bool OnExceptionInMainLoop() override;
|
2019-02-14 14:28:18 +00:00
|
|
|
|
2019-01-09 14:40:12 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// wxWidgets override to get an event on open files.
|
|
|
|
void MacOpenFiles(const wxArrayString &fileNames) override;
|
|
|
|
#endif /* __APPLE */
|
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
Sidebar& sidebar();
|
|
|
|
ObjectManipulation* obj_manipul();
|
2018-11-09 17:39:07 +00:00
|
|
|
ObjectSettings* obj_settings();
|
2018-10-05 21:29:15 +00:00
|
|
|
ObjectList* obj_list();
|
2019-05-28 14:38:04 +00:00
|
|
|
ObjectLayers* obj_layers();
|
2018-10-08 14:27:38 +00:00
|
|
|
Plater* plater();
|
2019-07-18 15:41:47 +00:00
|
|
|
Model& model();
|
2018-10-04 14:43:10 +00:00
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
AppConfig* app_config{ nullptr };
|
|
|
|
PresetBundle* preset_bundle{ nullptr };
|
|
|
|
PresetUpdater* preset_updater{ nullptr };
|
|
|
|
MainFrame* mainframe{ nullptr };
|
2018-10-24 10:57:23 +00:00
|
|
|
Plater* plater_{ nullptr };
|
2018-09-20 23:33:41 +00:00
|
|
|
|
|
|
|
wxNotebook* tab_panel() const ;
|
2019-03-19 13:36:32 +00:00
|
|
|
int extruders_cnt() const;
|
2019-06-03 12:52:15 +00:00
|
|
|
int extruders_edited_cnt() const;
|
2018-09-20 23:33:41 +00:00
|
|
|
|
|
|
|
std::vector<Tab *> tabs_list;
|
|
|
|
|
2020-03-06 14:10:58 +00:00
|
|
|
RemovableDriveManager* removable_drive_manager() { return m_removable_drive_manager.get(); }
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
ImGuiWrapper* imgui() { return m_imgui.get(); }
|
2018-10-31 09:19:44 +00:00
|
|
|
|
2018-12-14 14:27:34 +00:00
|
|
|
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
|
2018-12-11 09:33:11 +00:00
|
|
|
|
2019-05-13 14:34:41 +00:00
|
|
|
void open_web_page_localized(const std::string &http_address);
|
2019-06-04 16:01:41 +00:00
|
|
|
bool run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage start_page = ConfigWizard::SP_WELCOME);
|
2019-05-13 14:34:41 +00:00
|
|
|
|
2019-12-03 11:44:20 +00:00
|
|
|
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG
|
2019-10-25 10:18:10 +00:00
|
|
|
// temporary and debug only -> extract thumbnails from selected gcode and save them as png files
|
|
|
|
void gcode_thumbnails_debug();
|
2019-12-03 11:44:20 +00:00
|
|
|
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG
|
2019-10-25 10:18:10 +00:00
|
|
|
|
2019-01-11 17:09:21 +00:00
|
|
|
private:
|
2019-04-09 09:28:11 +00:00
|
|
|
bool on_init_inner();
|
2019-01-11 17:09:21 +00:00
|
|
|
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
2019-04-29 14:55:41 +00:00
|
|
|
void window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
|
2019-01-11 17:09:21 +00:00
|
|
|
void window_pos_sanitize(wxTopLevelWindow* window);
|
2019-05-10 12:43:35 +00:00
|
|
|
bool select_language();
|
2019-06-04 16:01:41 +00:00
|
|
|
|
|
|
|
bool config_wizard_startup();
|
2020-02-04 14:24:35 +00:00
|
|
|
void check_updates(const bool verbose);
|
2019-06-04 16:01:41 +00:00
|
|
|
|
2019-05-03 13:50:05 +00:00
|
|
|
#ifdef __WXMSW__
|
2019-05-10 12:43:35 +00:00
|
|
|
void associate_3mf_files();
|
2019-05-03 13:50:05 +00:00
|
|
|
#endif // __WXMSW__
|
2018-09-20 06:40:22 +00:00
|
|
|
};
|
2018-09-20 23:33:41 +00:00
|
|
|
DECLARE_APP(GUI_App)
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
|
|
} // GUI
|
|
|
|
} //Slic3r
|
|
|
|
|
2018-11-12 17:09:47 +00:00
|
|
|
#endif // slic3r_GUI_App_hpp_
|