This commit is contained in:
Vojtech Bubnik 2021-11-11 10:11:03 +01:00
parent 549c98ac88
commit 117302ba22
12 changed files with 29 additions and 12 deletions

View file

@ -117,6 +117,13 @@ int CLI::run(int argc, char **argv)
// On Unix systems, the prusa-slicer binary may be symlinked to give the application a different meaning. // On Unix systems, the prusa-slicer binary may be symlinked to give the application a different meaning.
boost::algorithm::iends_with(boost::filesystem::path(argv[0]).filename().string(), "gcodeviewer"); boost::algorithm::iends_with(boost::filesystem::path(argv[0]).filename().string(), "gcodeviewer");
#endif // _WIN32 #endif // _WIN32
bool start_as_medical =
boost::algorithm::iends_with(boost::filesystem::path(argv[0]).filename().string(),
#ifdef _WIN32
"-medical.exe");
#else
"-medical");
#endif // _WIN32
const std::vector<std::string> &load_configs = m_config.option<ConfigOptionStrings>("load", true)->values; const std::vector<std::string> &load_configs = m_config.option<ConfigOptionStrings>("load", true)->values;
const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("config_compatibility", true)->value; const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("config_compatibility", true)->value;
@ -602,6 +609,7 @@ int CLI::run(int argc, char **argv)
params.extra_config = std::move(m_extra_config); params.extra_config = std::move(m_extra_config);
params.input_files = std::move(m_input_files); params.input_files = std::move(m_input_files);
params.start_as_gcodeviewer = start_as_gcodeviewer; params.start_as_gcodeviewer = start_as_gcodeviewer;
params.start_as_medical = start_as_medical;
return Slic3r::GUI::GUI_Run(params); return Slic3r::GUI::GUI_Run(params);
#else // SLIC3R_GUI #else // SLIC3R_GUI
// No GUI support. Just print out a help. // No GUI support. Just print out a help.

View file

@ -20,7 +20,7 @@
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
BitmapCache::BitmapCache() BitmapCache::BitmapCache(bool medical) : m_medical(medical)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
// Note: win->GetContentScaleFactor() is not used anymore here because it tends to // Note: win->GetContentScaleFactor() is not used anymore here because it tends to
@ -280,7 +280,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
if (dark_mode) if (dark_mode)
replaces["#808080"] = "#FFFFFF"; replaces["#808080"] = "#FFFFFF";
if (!new_color.empty()) if (!new_color.empty())
replaces["#ED6B21"] = new_color; replaces[m_medical ? "#5EA796" : "#ED6B21"] = new_color;
if (m_medical)
replaces["#ED6B21"] = "#5EA796";
NSVGimage *image = ::nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces); NSVGimage *image = ::nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
if (image == nullptr) if (image == nullptr)

View file

@ -14,7 +14,7 @@ namespace Slic3r { namespace GUI {
class BitmapCache class BitmapCache
{ {
public: public:
BitmapCache(); BitmapCache(bool medical);
~BitmapCache() { clear(); } ~BitmapCache() { clear(); }
void clear(); void clear();
double scale() { return m_scale; } double scale() { return m_scale; }
@ -42,6 +42,7 @@ public:
static bool parse_color(const std::string& scolor, unsigned char* rgb_out); static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
private: private:
bool m_medical;
std::map<std::string, wxBitmap*> m_map; std::map<std::string, wxBitmap*> m_map;
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs) double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display

View file

@ -195,7 +195,7 @@ public:
int width = lround(bmp.GetWidth() * 0.4); int width = lround(bmp.GetWidth() * 0.4);
// load bitmap for logo // load bitmap for logo
BitmapCache bmp_cache; BitmapCache bmp_cache { wxGetApp().is_medical() };
int logo_size = lround(width * 0.25); int logo_size = lround(width * 0.25);
wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().logo_name(), logo_size, logo_size); wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().logo_name(), logo_size, logo_size);
@ -758,9 +758,10 @@ void GUI_App::post_init()
IMPLEMENT_APP(GUI_App) IMPLEMENT_APP(GUI_App)
GUI_App::GUI_App(EAppMode mode) GUI_App::GUI_App(EAppMode mode, bool medical)
: wxApp() : wxApp()
, m_app_mode(mode) , m_app_mode(mode)
, m_medical(medical)
, m_em_unit(10) , m_em_unit(10)
, m_imgui(new ImGuiWrapper()) , m_imgui(new ImGuiWrapper())
, m_removable_drive_manager(std::make_unique<RemovableDriveManager>()) , m_removable_drive_manager(std::make_unique<RemovableDriveManager>())

View file

@ -113,6 +113,7 @@ private:
bool m_initialized { false }; bool m_initialized { false };
bool m_app_conf_exists{ false }; bool m_app_conf_exists{ false };
EAppMode m_app_mode{ EAppMode::Editor }; EAppMode m_app_mode{ EAppMode::Editor };
bool m_medical { false };
bool m_is_recreating_gui{ false }; bool m_is_recreating_gui{ false };
#ifdef __linux__ #ifdef __linux__
bool m_opengl_initialized{ false }; bool m_opengl_initialized{ false };
@ -159,12 +160,13 @@ public:
bool OnInit() override; bool OnInit() override;
bool initialized() const { return m_initialized; } bool initialized() const { return m_initialized; }
explicit GUI_App(EAppMode mode = EAppMode::Editor); explicit GUI_App(EAppMode mode = EAppMode::Editor, bool medical = false);
~GUI_App() override; ~GUI_App() override;
EAppMode get_app_mode() const { return m_app_mode; } EAppMode get_app_mode() const { return m_app_mode; }
bool is_editor() const { return m_app_mode == EAppMode::Editor; } bool is_editor() const { return m_app_mode == EAppMode::Editor; }
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; } bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
bool is_medical() const { return m_medical; }
bool is_recreating_gui() const { return m_is_recreating_gui; } bool is_recreating_gui() const { return m_is_recreating_gui; }
std::string logo_name() const { return is_editor() ? "PrusaSlicer" : "PrusaSlicer-gcodeviewer"; } std::string logo_name() const { return is_editor() ? "PrusaSlicer" : "PrusaSlicer-gcodeviewer"; }

View file

@ -37,7 +37,7 @@ int GUI_Run(GUI_InitParams &params)
#endif // __APPLE__ #endif // __APPLE__
try { try {
GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor); GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor, params.start_as_medical);
if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) { if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {
// G-code viewer is currently not performing instance check, a new G-code viewer is started every time. // G-code viewer is currently not performing instance check, a new G-code viewer is started every time.
bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1"; bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1";

View file

@ -21,6 +21,7 @@ struct GUI_InitParams
std::vector<std::string> input_files; std::vector<std::string> input_files;
bool start_as_gcodeviewer; bool start_as_gcodeviewer;
bool start_as_medical;
}; };
int GUI_Run(GUI_InitParams &params); int GUI_Run(GUI_InitParams &params);

View file

@ -644,6 +644,8 @@ void MainFrame::update_title()
#endif #endif
} }
} }
if (wxGetApp().is_medical())
boost::replace_first(build_id, "PrusaSlicer", "PrusaSlicer-medical");
title += wxString(build_id); title += wxString(build_id);
if (wxGetApp().is_editor()) if (wxGetApp().is_editor())

View file

@ -322,7 +322,7 @@ static int get_root_idx(ObjectDataViewModelNode *parent_node, const ItemType roo
ObjectDataViewModel::ObjectDataViewModel() ObjectDataViewModel::ObjectDataViewModel()
{ {
m_bitmap_cache = new Slic3r::GUI::BitmapCache; m_bitmap_cache = new Slic3r::GUI::BitmapCache { wxGetApp().is_medical() };
m_volume_bmps = MenuFactory::get_volume_bitmaps(); m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_warning_bmp = create_scaled_bitmap(WarningIcon); m_warning_bmp = create_scaled_bitmap(WarningIcon);

View file

@ -150,7 +150,7 @@ PresetComboBox::~PresetComboBox()
BitmapCache& PresetComboBox::bitmap_cache() BitmapCache& PresetComboBox::bitmap_cache()
{ {
static BitmapCache bmps; static BitmapCache bmps { wxGetApp().is_medical() };
return bmps; return bmps;
} }

View file

@ -123,7 +123,7 @@ wxBitmap ModelNode::get_bitmap(const wxString& color)
const int icon_width = lround(6.4 * em); const int icon_width = lround(6.4 * em);
const int icon_height = lround(1.6 * em); const int icon_height = lround(1.6 * em);
BitmapCache bmp_cache; BitmapCache bmp_cache { wxGetApp().is_medical() };
unsigned char rgb[3]; unsigned char rgb[3];
BitmapCache::parse_color(into_u8(color), rgb); BitmapCache::parse_color(into_u8(color), rgb);
// there is no need to scale created solid bitmap // there is no need to scale created solid bitmap

View file

@ -432,7 +432,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
const std::string& new_color/* = std::string()*/, // color witch will used instead of orange const std::string& new_color/* = std::string()*/, // color witch will used instead of orange
const bool menu_bitmap/* = false*/) const bool menu_bitmap/* = false*/)
{ {
static Slic3r::GUI::BitmapCache cache; static Slic3r::GUI::BitmapCache cache { Slic3r::GUI::wxGetApp().is_medical() };
unsigned int width = 0; unsigned int width = 0;
unsigned int height = (unsigned int)(em_unit(win) * px_cnt * 0.1f + 0.5f); unsigned int height = (unsigned int)(em_unit(win) * px_cnt * 0.1f + 0.5f);
@ -462,7 +462,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/) std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
{ {
static Slic3r::GUI::BitmapCache bmp_cache; static Slic3r::GUI::BitmapCache bmp_cache { Slic3r::GUI::wxGetApp().is_medical() };
// Create the bitmap with color bars. // Create the bitmap with color bars.
std::vector<wxBitmap*> bmps; std::vector<wxBitmap*> bmps;