FIX: cli: fix the thumbnail rendering issue

1. fix the color not correct issue
2. fix the warning when loading thumbnail under cli
3. remove the invalid error log

Change-Id: I4dd553b218e264bb811606053d920b5861ad6bd4
This commit is contained in:
lane.wei 2022-10-31 22:36:28 +08:00 committed by Lane.Wei
parent b685cbf37c
commit 2406cc35b6
3 changed files with 19 additions and 12 deletions

View File

@ -126,7 +126,7 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << "index="<< index <<", arg is "<< argv[index] <<std::endl; BOOST_LOG_TRIVIAL(info) << "index="<< index <<", arg is "<< argv[index] <<std::endl;
int debug_argc = 9; int debug_argc = 9;
char *debug_argv[] = { char *debug_argv[] = {
"E:\work\projects\bambu_studio\bamboo_slicer\build\src\Debug\bambu-studio.exe", "E:\work\projects\bambu_release\bamboo_slicer\build_debug\src\Debug\bambu-studio.exe",
"--slice", "--slice",
"0", "0",
"--export-3mf=output.3mf", "--export-3mf=output.3mf",
@ -1330,6 +1330,13 @@ int CLI::run(int argc, char **argv)
unsigned char rgb_color[3] = {}; unsigned char rgb_color[3] = {};
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color); Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
glvolume_collection.volumes.back()->set_render_color( float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f); glvolume_collection.volumes.back()->set_render_color( float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f);
std::array<float, 4> new_color;
new_color[0] = float(rgb_color[0]) / 255.f;
new_color[1] = float(rgb_color[1]) / 255.f;
new_color[2] = float(rgb_color[2]) / 255.f;
new_color[3] = 1.f;
glvolume_collection.volumes.back()->set_color(new_color);
} }
} }
} }

View File

@ -211,16 +211,16 @@ bool OpenGLManager::m_use_manually_generated_mipmaps = true;
OpenGLManager::EMultisampleState OpenGLManager::s_multisample = OpenGLManager::EMultisampleState::Unknown; OpenGLManager::EMultisampleState OpenGLManager::s_multisample = OpenGLManager::EMultisampleState::Unknown;
OpenGLManager::EFramebufferType OpenGLManager::s_framebuffers_type = OpenGLManager::EFramebufferType::Unknown; OpenGLManager::EFramebufferType OpenGLManager::s_framebuffers_type = OpenGLManager::EFramebufferType::Unknown;
#ifdef __APPLE__ #ifdef __APPLE__
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
OpenGLManager::OSInfo OpenGLManager::s_os_info; OpenGLManager::OSInfo OpenGLManager::s_os_info;
#endif // __APPLE__ #endif // __APPLE__
OpenGLManager::~OpenGLManager() OpenGLManager::~OpenGLManager()
{ {
m_shaders_manager.shutdown(); m_shaders_manager.shutdown();
#ifdef __APPLE__ #ifdef __APPLE__
// This is an ugly hack needed to solve the crash happening when closing the application on OSX 10.9.5 with newer wxWidgets // This is an ugly hack needed to solve the crash happening when closing the application on OSX 10.9.5 with newer wxWidgets
// The crash is triggered inside wxGLContext destructor // The crash is triggered inside wxGLContext destructor
if (s_os_info.major != 10 || s_os_info.minor != 9 || s_os_info.micro != 5) if (s_os_info.major != 10 || s_os_info.minor != 9 || s_os_info.micro != 5)
@ -228,7 +228,7 @@ OpenGLManager::~OpenGLManager()
#endif //__APPLE__ #endif //__APPLE__
if (m_context != nullptr) if (m_context != nullptr)
delete m_context; delete m_context;
#ifdef __APPLE__ #ifdef __APPLE__
} }
#endif //__APPLE__ #endif //__APPLE__
} }
@ -302,7 +302,7 @@ bool OpenGLManager::init_gl()
BOOST_LOG_TRIVIAL(error) << "Not recognized format of version."; BOOST_LOG_TRIVIAL(error) << "Not recognized format of version.";
} }
} else { } else {
BOOST_LOG_TRIVIAL(error) << "Unable to parse version of AMD driver."; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "not AMD driver.";
} }
#endif #endif
} }
@ -315,7 +315,7 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
if (m_context == nullptr) { if (m_context == nullptr) {
m_context = new wxGLContext(&canvas); m_context = new wxGLContext(&canvas);
#ifdef __APPLE__ #ifdef __APPLE__
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets // Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
s_os_info.major = wxPlatformInfo::Get().GetOSMajorVersion(); s_os_info.major = wxPlatformInfo::Get().GetOSMajorVersion();
s_os_info.minor = wxPlatformInfo::Get().GetOSMinorVersion(); s_os_info.minor = wxPlatformInfo::Get().GetOSMinorVersion();
@ -327,7 +327,7 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent) wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
{ {
int attribList[] = { int attribList[] = {
WX_GL_RGBA, WX_GL_RGBA,
WX_GL_DOUBLEBUFFER, WX_GL_DOUBLEBUFFER,
// RGB channels each should be allocated with 8 bit depth. One should almost certainly get these bit depths by default. // RGB channels each should be allocated with 8 bit depth. One should almost certainly get these bit depths by default.
@ -361,7 +361,7 @@ void OpenGLManager::detect_multisample(int* attribList)
{ {
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER; int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
bool enable_multisample = wxVersion >= 30003; bool enable_multisample = wxVersion >= 30003;
s_multisample = s_multisample =
enable_multisample && enable_multisample &&
// Disable multi-sampling on ChromeOS, as the OpenGL virtualization swaps Red/Blue channels with multi-sampling enabled, // Disable multi-sampling on ChromeOS, as the OpenGL virtualization swaps Red/Blue channels with multi-sampling enabled,
// at least on some platforms. // at least on some platforms.

View File

@ -4137,19 +4137,19 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
gcode_result->toolpath_outside = plate_data_list[i]->toolpath_outside; gcode_result->toolpath_outside = plate_data_list[i]->toolpath_outside;
m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info; m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info;
gcode_result->warnings = plate_data_list[i]->warnings; gcode_result->warnings = plate_data_list[i]->warnings;
if (!plate_data_list[i]->thumbnail_file.empty()) { if (m_plater && !plate_data_list[i]->thumbnail_file.empty()) {
if (boost::filesystem::exists(plate_data_list[i]->thumbnail_file)) { if (boost::filesystem::exists(plate_data_list[i]->thumbnail_file)) {
m_plate_list[index]->load_thumbnail_data(plate_data_list[i]->thumbnail_file); m_plate_list[index]->load_thumbnail_data(plate_data_list[i]->thumbnail_file);
} }
} }
if (!plate_data_list[i]->pattern_file.empty()) { if (m_plater && !plate_data_list[i]->pattern_file.empty()) {
if (boost::filesystem::exists(plate_data_list[i]->pattern_file)) { if (boost::filesystem::exists(plate_data_list[i]->pattern_file)) {
//no need to load pattern data currently //no need to load pattern data currently
//m_plate_list[index]->load_pattern_thumbnail_data(plate_data_list[i]->pattern_file); //m_plate_list[index]->load_pattern_thumbnail_data(plate_data_list[i]->pattern_file);
} }
} }
if (!plate_data_list[i]->pattern_bbox_file.empty()) { if (m_plater && !plate_data_list[i]->pattern_bbox_file.empty()) {
if (boost::filesystem::exists(plate_data_list[i]->pattern_bbox_file)) { if (boost::filesystem::exists(plate_data_list[i]->pattern_bbox_file)) {
m_plate_list[index]->load_pattern_box_data(plate_data_list[i]->pattern_bbox_file); m_plate_list[index]->load_pattern_box_data(plate_data_list[i]->pattern_bbox_file);
} }