2018-09-20 06:40:22 +00:00
|
|
|
|
#ifndef slic3r_GUI_App_hpp_
|
|
|
|
|
#define slic3r_GUI_App_hpp_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2018-09-20 23:33:41 +00:00
|
|
|
|
#include "PrintConfig.hpp"
|
2018-10-02 11:23:38 +00:00
|
|
|
|
#include "MainFrame.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-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;
|
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-09-20 06:40:22 +00:00
|
|
|
|
|
|
|
|
|
namespace GUI
|
|
|
|
|
{
|
2018-10-05 21:29:15 +00:00
|
|
|
|
// Map from an file_type name to full file wildcard name.
|
|
|
|
|
const std::map<const std::string, const std::string> FILE_WILDCARDS{
|
|
|
|
|
std::make_pair("known", "Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA"),
|
|
|
|
|
std::make_pair("stl", "STL files (*.stl)|*.stl;*.STL"),
|
|
|
|
|
std::make_pair("obj", "OBJ files (*.obj)|*.obj;*.OBJ"),
|
|
|
|
|
std::make_pair("amf", "AMF files (*.amf)|*.zip.amf;*.amf;*.AMF;*.xml;*.XML"),
|
|
|
|
|
std::make_pair("3mf", "3MF files (*.3mf)|*.3mf;*.3MF;"),
|
|
|
|
|
std::make_pair("prusa", "Prusa Control files (*.prusa)|*.prusa;*.PRUSA"),
|
|
|
|
|
std::make_pair("ini", "INI files *.ini|*.ini;*.INI"),
|
|
|
|
|
std::make_pair("gcode", "G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC"),
|
|
|
|
|
std::make_pair("svg", "SVG files *.svg|*.svg;*.SVG")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const std::string MODEL_WILDCARD{ FILE_WILDCARDS.at("known") + std::string("|") +
|
|
|
|
|
FILE_WILDCARDS.at("stl") + std::string("|") +
|
|
|
|
|
FILE_WILDCARDS.at("obj") + std::string("|") +
|
|
|
|
|
FILE_WILDCARDS.at("amf") + std::string("|") +
|
|
|
|
|
FILE_WILDCARDS.at("3mf") + std::string("|") +
|
|
|
|
|
FILE_WILDCARDS.at("prusa") };
|
|
|
|
|
|
|
|
|
|
|
2018-09-20 23:33:41 +00:00
|
|
|
|
enum ConfigMenuIDs {
|
|
|
|
|
ConfigMenuWizard,
|
|
|
|
|
ConfigMenuSnapshots,
|
|
|
|
|
ConfigMenuTakeSnapshot,
|
|
|
|
|
ConfigMenuUpdate,
|
|
|
|
|
ConfigMenuPreferences,
|
|
|
|
|
ConfigMenuModeSimple,
|
|
|
|
|
ConfigMenuModeExpert,
|
|
|
|
|
ConfigMenuLanguage,
|
|
|
|
|
ConfigMenuFlashFirmware,
|
|
|
|
|
ConfigMenuCnt,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Tab;
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
2018-10-03 13:14:52 +00:00
|
|
|
|
static wxString dots("<EFBFBD>", wxConvUTF8);
|
|
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
|
class GUI_App : public wxApp
|
|
|
|
|
{
|
2018-09-17 10:15:11 +00:00
|
|
|
|
bool no_plater{ false };
|
2018-09-20 06:40:22 +00:00
|
|
|
|
bool app_conf_exists{ false };
|
|
|
|
|
|
|
|
|
|
// Lock to guard the callback stack
|
|
|
|
|
std::mutex callback_register;
|
|
|
|
|
// callbacks registered to run during idle event.
|
|
|
|
|
std::stack<std::function<void()>> m_cb{};
|
|
|
|
|
|
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;
|
|
|
|
|
|
2018-10-02 11:23:38 +00:00
|
|
|
|
wxLocale* m_wxLocale{ nullptr };
|
2018-10-01 13:09:31 +00:00
|
|
|
|
|
2018-09-20 06:40:22 +00:00
|
|
|
|
public:
|
|
|
|
|
bool OnInit() override;
|
|
|
|
|
GUI_App() : wxApp() {}
|
|
|
|
|
|
2018-10-01 13:09:31 +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-09-20 11:12:35 +00:00
|
|
|
|
void open_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*/);
|
|
|
|
|
void update_ui_from_settings();
|
|
|
|
|
void CallAfter(std::function<void()> cb);
|
|
|
|
|
wxMenuItem* append_menu_item( wxMenu* menu,
|
|
|
|
|
int id,
|
|
|
|
|
const wxString& string,
|
|
|
|
|
const wxString& description,
|
|
|
|
|
const std::string& icon,
|
|
|
|
|
std::function<void(wxCommandEvent& event)> cb,
|
|
|
|
|
wxItemKind kind = wxITEM_NORMAL);
|
|
|
|
|
wxMenuItem* append_submenu( wxMenu* menu,
|
|
|
|
|
wxMenu* sub_menu,
|
|
|
|
|
int id,
|
|
|
|
|
const wxString& string,
|
|
|
|
|
const wxString& description,
|
|
|
|
|
const std::string& icon);
|
|
|
|
|
void save_window_pos(wxTopLevelWindow* window, const std::string& name);
|
|
|
|
|
void restore_window_pos(wxTopLevelWindow* window, const std::string& name);
|
2018-10-02 11:23:38 +00:00
|
|
|
|
|
|
|
|
|
bool select_language(wxArrayString & names, wxArrayLong & identifiers);
|
2018-09-20 23:33:41 +00:00
|
|
|
|
bool load_language();
|
2018-10-02 11:23:38 +00:00
|
|
|
|
void save_language();
|
|
|
|
|
void get_installed_languages(wxArrayString & names, wxArrayLong & identifiers);
|
|
|
|
|
|
2018-09-20 23:33:41 +00:00
|
|
|
|
ConfigMenuIDs get_view_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);
|
|
|
|
|
bool check_unsaved_changes();
|
2018-10-01 13:09:31 +00:00
|
|
|
|
bool checked_tab(Tab* tab);
|
|
|
|
|
void delete_tab_from_list(Tab* tab);
|
|
|
|
|
void load_current_presets();
|
2018-09-20 06:40:22 +00:00
|
|
|
|
|
2018-10-04 14:43:10 +00:00
|
|
|
|
Sidebar& sidebar();
|
|
|
|
|
ObjectManipulation* obj_manipul();
|
2018-10-05 21:29:15 +00:00
|
|
|
|
ObjectList* obj_list();
|
|
|
|
|
std::vector<ModelObject*> *model_objects();
|
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-09-20 23:33:41 +00:00
|
|
|
|
|
|
|
|
|
wxNotebook* tab_panel() const ;
|
|
|
|
|
|
|
|
|
|
std::vector<Tab *> tabs_list;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
#endif // slic3r_GUI_App_hpp_
|