2018-09-20 08:40:22 +02:00
|
|
|
#ifndef slic3r_GUI_App_hpp_
|
|
|
|
|
#define slic3r_GUI_App_hpp_
|
|
|
|
|
|
2018-11-26 10:56:07 +01:00
|
|
|
#include <memory>
|
2018-09-20 08:40:22 +02:00
|
|
|
#include <string>
|
2018-11-26 14:41:58 +01:00
|
|
|
#include "libslic3r/PrintConfig.hpp"
|
2018-10-02 13:23:38 +02:00
|
|
|
#include "MainFrame.hpp"
|
2018-10-31 10:19:44 +01:00
|
|
|
#include "ImGuiWrapper.hpp"
|
2018-09-20 08:40:22 +02:00
|
|
|
|
|
|
|
|
#include <wx/app.h>
|
2018-10-01 15:09:31 +02:00
|
|
|
#include <wx/colour.h>
|
|
|
|
|
#include <wx/font.h>
|
2018-11-26 14:41:58 +01:00
|
|
|
#include <wx/string.h>
|
2018-09-20 08:40:22 +02:00
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
|
|
class wxMenuItem;
|
2018-09-21 01:33:41 +02:00
|
|
|
class wxMenuBar;
|
2018-09-20 08:40:22 +02:00
|
|
|
class wxTopLevelWindow;
|
2018-09-21 01:33:41 +02:00
|
|
|
class wxNotebook;
|
2018-09-20 08:40:22 +02:00
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
class AppConfig;
|
|
|
|
|
class PresetBundle;
|
|
|
|
|
class PresetUpdater;
|
2018-10-05 23:29:15 +02:00
|
|
|
class ModelObject;
|
2018-12-11 10:33:11 +01:00
|
|
|
class PrintHostJobQueue;
|
2018-09-20 08:40:22 +02:00
|
|
|
|
|
|
|
|
namespace GUI
|
|
|
|
|
{
|
2018-10-04 11:12:55 +02:00
|
|
|
|
|
|
|
|
enum FileType
|
|
|
|
|
{
|
|
|
|
|
FT_STL,
|
|
|
|
|
FT_OBJ,
|
|
|
|
|
FT_AMF,
|
|
|
|
|
FT_3MF,
|
|
|
|
|
FT_PRUSA,
|
|
|
|
|
FT_GCODE,
|
|
|
|
|
FT_MODEL,
|
|
|
|
|
|
|
|
|
|
FT_INI,
|
|
|
|
|
FT_SVG,
|
2018-11-12 18:09:47 +01:00
|
|
|
FT_PNGZIP,
|
2018-10-04 11:12:55 +02:00
|
|
|
|
|
|
|
|
FT_SIZE,
|
2018-10-05 23:29:15 +02:00
|
|
|
};
|
|
|
|
|
|
2018-12-06 17:32:49 +01:00
|
|
|
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string());
|
2018-10-05 23:29:15 +02:00
|
|
|
|
2018-09-21 01:33:41 +02:00
|
|
|
enum ConfigMenuIDs {
|
|
|
|
|
ConfigMenuWizard,
|
|
|
|
|
ConfigMenuSnapshots,
|
|
|
|
|
ConfigMenuTakeSnapshot,
|
|
|
|
|
ConfigMenuUpdate,
|
|
|
|
|
ConfigMenuPreferences,
|
|
|
|
|
ConfigMenuModeSimple,
|
2018-10-25 14:55:03 +02:00
|
|
|
ConfigMenuModeAdvanced,
|
2018-09-21 01:33:41 +02:00
|
|
|
ConfigMenuModeExpert,
|
|
|
|
|
ConfigMenuLanguage,
|
|
|
|
|
ConfigMenuFlashFirmware,
|
|
|
|
|
ConfigMenuCnt,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Tab;
|
2018-09-20 08:40:22 +02:00
|
|
|
|
2018-11-06 17:38:40 +01:00
|
|
|
static wxString dots("…", wxConvUTF8);
|
2018-10-03 15:14:52 +02:00
|
|
|
|
2018-09-20 08:40:22 +02:00
|
|
|
class GUI_App : public wxApp
|
|
|
|
|
{
|
2019-02-05 18:12:42 +01:00
|
|
|
bool m_initialized { false };
|
2018-09-20 08:40:22 +02:00
|
|
|
bool app_conf_exists{ false };
|
|
|
|
|
|
2018-10-01 15:09:31 +02: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 20:54:01 +01:00
|
|
|
wxFont m_normal_font;
|
2018-10-01 15:09:31 +02:00
|
|
|
|
2019-02-06 10:55:11 +01:00
|
|
|
size_t m_em_unit; // width of a "m"-symbol in pixels for current system font
|
|
|
|
|
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
|
2019-01-31 15:55:09 +01:00
|
|
|
|
2018-10-02 13:23:38 +02:00
|
|
|
wxLocale* m_wxLocale{ nullptr };
|
2018-10-01 15:09:31 +02:00
|
|
|
|
2018-11-26 10:56:07 +01:00
|
|
|
std::unique_ptr<ImGuiWrapper> m_imgui;
|
2018-12-14 15:27:34 +01:00
|
|
|
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
|
2018-12-11 10:33:11 +01:00
|
|
|
|
2018-09-20 08:40:22 +02:00
|
|
|
public:
|
|
|
|
|
bool OnInit() override;
|
2019-02-05 18:12:42 +01:00
|
|
|
bool initialized() const { return m_initialized; }
|
2018-11-26 10:56:07 +01:00
|
|
|
|
|
|
|
|
GUI_App();
|
2018-09-20 08:40:22 +02:00
|
|
|
|
2019-04-26 16:59:14 +02:00
|
|
|
static unsigned get_colour_approx_luma(const wxColour &colour);
|
|
|
|
|
static bool dark_mode();
|
|
|
|
|
static bool dark_mode_menus();
|
2018-10-01 15:09:31 +02:00
|
|
|
void init_label_colours();
|
|
|
|
|
void update_label_colours_from_appconfig();
|
|
|
|
|
void init_fonts();
|
2019-04-18 02:03:40 +02:00
|
|
|
void update_fonts();
|
2018-10-01 15:09:31 +02: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 20:54:01 +01:00
|
|
|
const wxFont& normal_font() { return m_normal_font; }
|
2019-02-04 10:35:16 +01:00
|
|
|
size_t em_unit() const { return m_em_unit; }
|
|
|
|
|
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
|
2018-10-01 15:09:31 +02:00
|
|
|
|
2018-09-20 08:40:22 +02:00
|
|
|
void recreate_GUI();
|
|
|
|
|
void system_info();
|
2018-12-19 13:06:24 +01:00
|
|
|
void keyboard_shortcuts();
|
2018-11-15 15:27:39 +01:00
|
|
|
void load_project(wxWindow *parent, wxString& input_file);
|
|
|
|
|
void import_model(wxWindow *parent, wxArrayString& input_files);
|
2018-09-20 08:40:22 +02:00
|
|
|
static bool catch_error(std::function<void()> cb,
|
|
|
|
|
// wxMessageDialog* message_dialog,
|
|
|
|
|
const std::string& err);
|
|
|
|
|
// void notify(/*message*/);
|
2019-01-11 18:09:21 +01:00
|
|
|
|
|
|
|
|
void persist_window_geometry(wxTopLevelWindow *window);
|
2018-09-20 08:40:22 +02:00
|
|
|
void update_ui_from_settings();
|
2018-10-17 14:01:10 +02:00
|
|
|
|
2018-10-02 13:23:38 +02:00
|
|
|
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
|
2018-09-21 01:33:41 +02:00
|
|
|
bool load_language();
|
2018-10-02 13:23:38 +02:00
|
|
|
void save_language();
|
|
|
|
|
void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers);
|
|
|
|
|
|
2018-10-10 13:53:45 +02:00
|
|
|
Tab* get_tab(Preset::Type type);
|
2019-01-10 11:05:58 +01:00
|
|
|
ConfigOptionMode get_mode();
|
|
|
|
|
void save_mode(const /*ConfigOptionMode*/int mode) ;
|
2018-10-03 15:14:52 +02:00
|
|
|
void update_mode();
|
2018-10-02 13:23:38 +02:00
|
|
|
|
2018-09-21 01:33:41 +02:00
|
|
|
void add_config_menu(wxMenuBar *menu);
|
|
|
|
|
bool check_unsaved_changes();
|
2018-10-01 15:09:31 +02:00
|
|
|
bool checked_tab(Tab* tab);
|
|
|
|
|
void load_current_presets();
|
2018-09-20 08:40:22 +02:00
|
|
|
|
2019-04-17 14:56:44 +02:00
|
|
|
wxString current_language_code() { return m_wxLocale != nullptr ? m_wxLocale->GetCanonicalName() : wxString("en_US"); }
|
|
|
|
|
|
2019-02-14 15:28:18 +01:00
|
|
|
virtual bool OnExceptionInMainLoop();
|
|
|
|
|
|
2019-01-09 15:40:12 +01:00
|
|
|
#ifdef __APPLE__
|
|
|
|
|
// wxWidgets override to get an event on open files.
|
|
|
|
|
void MacOpenFiles(const wxArrayString &fileNames) override;
|
|
|
|
|
#endif /* __APPLE */
|
|
|
|
|
|
2018-10-04 16:43:10 +02:00
|
|
|
Sidebar& sidebar();
|
|
|
|
|
ObjectManipulation* obj_manipul();
|
2018-11-09 18:39:07 +01:00
|
|
|
ObjectSettings* obj_settings();
|
2018-10-05 23:29:15 +02:00
|
|
|
ObjectList* obj_list();
|
2018-10-08 16:27:38 +02:00
|
|
|
Plater* plater();
|
2018-10-05 23:29:15 +02:00
|
|
|
std::vector<ModelObject*> *model_objects();
|
2018-10-04 16:43:10 +02:00
|
|
|
|
2018-09-20 08:40:22 +02:00
|
|
|
AppConfig* app_config{ nullptr };
|
|
|
|
|
PresetBundle* preset_bundle{ nullptr };
|
|
|
|
|
PresetUpdater* preset_updater{ nullptr };
|
|
|
|
|
MainFrame* mainframe{ nullptr };
|
2018-10-24 12:57:23 +02:00
|
|
|
Plater* plater_{ nullptr };
|
2018-09-21 01:33:41 +02:00
|
|
|
|
|
|
|
|
wxNotebook* tab_panel() const ;
|
2019-03-19 14:36:32 +01:00
|
|
|
int extruders_cnt() const;
|
2018-09-21 01:33:41 +02:00
|
|
|
|
|
|
|
|
std::vector<Tab *> tabs_list;
|
|
|
|
|
|
2018-11-26 10:56:07 +01:00
|
|
|
ImGuiWrapper* imgui() { return m_imgui.get(); }
|
2018-10-31 10:19:44 +01:00
|
|
|
|
2018-12-14 15:27:34 +01:00
|
|
|
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
|
2018-12-11 10:33:11 +01:00
|
|
|
|
2019-01-11 18:09:21 +01:00
|
|
|
private:
|
2019-04-09 11:28:11 +02:00
|
|
|
bool on_init_inner();
|
2019-01-11 18:09:21 +01:00
|
|
|
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
|
|
|
|
void window_pos_restore(wxTopLevelWindow* window, const std::string &name);
|
|
|
|
|
void window_pos_sanitize(wxTopLevelWindow* window);
|
2018-09-20 08:40:22 +02:00
|
|
|
};
|
2018-09-21 01:33:41 +02:00
|
|
|
DECLARE_APP(GUI_App)
|
2018-09-20 08:40:22 +02:00
|
|
|
|
|
|
|
|
} // GUI
|
|
|
|
|
} //Slic3r
|
|
|
|
|
|
2018-11-12 18:09:47 +01:00
|
|
|
#endif // slic3r_GUI_App_hpp_
|