PrusaSlicer-NonPlainar/src/slic3r/GUI/GUI_App.hpp

179 lines
4.9 KiB
C++
Raw Normal View History

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>
#include "libslic3r/PrintConfig.hpp"
#include "MainFrame.hpp"
2018-10-31 09:19:44 +00:00
#if ENABLE_IMGUI
#include "ImGuiWrapper.hpp"
#endif // ENABLE_IMGUI
2018-09-20 06:40:22 +00:00
#include <wx/app.h>
#include <wx/colour.h>
#include <wx/font.h>
#include <wx/string.h>
2018-09-20 06:40:22 +00:00
#include <mutex>
#include <stack>
class wxMenuItem;
class wxMenuBar;
2018-09-20 06:40:22 +00:00
class wxTopLevelWindow;
class wxNotebook;
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
namespace GUI
{
2018-10-05 21:29:15 +00:00
2018-10-04 09:12:55 +00:00
enum FileType
{
FT_STL,
FT_OBJ,
FT_AMF,
FT_3MF,
FT_PRUSA,
FT_GCODE,
FT_MODEL,
FT_INI,
FT_SVG,
FT_PNGZIP,
2018-10-04 09:12:55 +00:00
FT_SIZE,
};
2018-10-05 21:29:15 +00:00
extern wxString file_wildcards(FileType file_type, const std::string &custom_extension = std::string());
2018-10-05 21:29:15 +00:00
enum ConfigMenuIDs {
ConfigMenuWizard,
ConfigMenuSnapshots,
ConfigMenuTakeSnapshot,
ConfigMenuUpdate,
ConfigMenuPreferences,
ConfigMenuModeSimple,
2018-10-25 12:55:03 +00:00
ConfigMenuModeAdvanced,
ConfigMenuModeExpert,
ConfigMenuLanguage,
ConfigMenuFlashFirmware,
ConfigMenuCnt,
};
class Tab;
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
{
bool m_initialized { false };
2018-09-20 06:40:22 +00:00
bool app_conf_exists{ false };
wxColour m_color_label_modified;
wxColour m_color_label_sys;
wxColour m_color_label_default;
wxFont m_small_font;
wxFont m_bold_font;
wxLocale* m_wxLocale{ nullptr };
2018-10-31 09:19:44 +00:00
#if ENABLE_IMGUI
2018-11-26 09:56:07 +00:00
std::unique_ptr<ImGuiWrapper> m_imgui;
2018-10-31 09:19:44 +00:00
#endif // ENABLE_IMGUI
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
2018-12-11 09:33:11 +00:00
2018-09-20 06:40:22 +00:00
public:
bool OnInit() override;
bool initialized() const { return m_initialized; }
2018-11-26 09:56:07 +00:00
GUI_App();
2018-09-20 06:40:22 +00:00
unsigned get_colour_approx_luma(const wxColour &colour);
void init_label_colours();
void update_label_colours_from_appconfig();
void init_fonts();
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; }
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();
void load_project(wxWindow *parent, wxString& input_file);
void import_model(wxWindow *parent, wxArrayString& input_files);
2018-09-20 06:40:22 +00:00
static bool catch_error(std::function<void()> cb,
// wxMessageDialog* message_dialog,
const std::string& err);
// void notify(/*message*/);
2019-01-11 17:09:21 +00:00
void persist_window_geometry(wxTopLevelWindow *window);
2018-09-20 06:40:22 +00:00
void update_ui_from_settings();
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
bool load_language();
void save_language();
void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers);
Tab* get_tab(Preset::Type type);
ConfigOptionMode get_mode();
void save_mode(const /*ConfigOptionMode*/int mode) ;
2018-10-03 13:14:52 +00:00
void update_mode();
void add_config_menu(wxMenuBar *menu);
bool check_unsaved_changes();
bool checked_tab(Tab* tab);
void load_current_presets();
2018-09-20 06:40:22 +00:00
#ifdef __APPLE__
// wxWidgets override to get an event on open files.
void MacOpenFiles(const wxArrayString &fileNames) override;
#endif /* __APPLE */
Sidebar& sidebar();
ObjectManipulation* obj_manipul();
ObjectSettings* obj_settings();
2018-10-05 21:29:15 +00:00
ObjectList* obj_list();
Plater* plater();
2018-10-05 21:29:15 +00:00
std::vector<ModelObject*> *model_objects();
2018-09-20 06:40:22 +00:00
AppConfig* app_config{ nullptr };
PresetBundle* preset_bundle{ nullptr };
PresetUpdater* preset_updater{ nullptr };
MainFrame* mainframe{ nullptr };
Plater* plater_{ nullptr };
wxNotebook* tab_panel() const ;
std::vector<Tab *> tabs_list;
2018-10-31 09:19:44 +00:00
#if ENABLE_IMGUI
2018-11-26 09:56:07 +00:00
ImGuiWrapper* imgui() { return m_imgui.get(); }
2018-10-31 09:19:44 +00:00
#endif // ENABLE_IMGUI
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
2018-12-11 09:33:11 +00:00
2019-01-11 17:09:21 +00:00
private:
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 06:40:22 +00:00
};
DECLARE_APP(GUI_App)
2018-09-20 06:40:22 +00:00
} // GUI
} //Slic3r
#endif // slic3r_GUI_App_hpp_