ENH:show big bed image

jira: none
Change-Id: Iaf3529345f688f2dbdc35c16f45253a5b65feb84
This commit is contained in:
zhou.xu 2025-02-06 09:32:06 +08:00 committed by lane.wei
parent d2d620f87c
commit 5e2861acca
9 changed files with 130 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -174,6 +174,8 @@ set(SLIC3R_GUI_SOURCES
GUI/IMToolbar.cpp
GUI/GCodeViewer.hpp
GUI/GCodeViewer.cpp
GUI/ImageDPIFrame.cpp
GUI/ImageDPIFrame.hpp
GUI/Preferences.cpp
GUI/Preferences.hpp
GUI/AMSSetting.cpp

View File

@ -0,0 +1,85 @@
#include "ImageDPIFrame.hpp"
#include <wx/event.h>
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/dcmemory.h>
#include "GUI_App.hpp"
#include "Tab.hpp"
#include "PartPlate.hpp"
#include "I18N.hpp"
#include "MainFrame.hpp"
#include <chrono>
#include "wxExtensions.hpp"
using namespace Slic3r;
using namespace Slic3r::GUI;
namespace Slic3r { namespace GUI {
#define ANIMATION_REFRESH_INTERVAL 20
ImageDPIFrame::ImageDPIFrame()
: DPIFrame(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, "", wxDefaultPosition, wxDefaultSize, !wxCAPTION | !wxCLOSE_BOX | wxBORDER_NONE)
{
m_image_px = 260;
int width = 270;
//SetTransparent(0);
SetMinSize(wxSize(FromDIP(width), -1));
SetMaxSize(wxSize(FromDIP(width), -1));
m_sizer_main = new wxBoxSizer(wxVERTICAL);
auto image_sizer = new wxBoxSizer(wxVERTICAL);
auto imgsize = FromDIP(width);
m_bitmap = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("printer_preview_C13", this, m_image_px), wxDefaultPosition, wxSize(imgsize, imgsize * 0.94), 0);
image_sizer->Add(m_bitmap, 0, wxALIGN_CENTER | wxALL, FromDIP(0));
m_sizer_main->Add(image_sizer, FromDIP(0), wxALIGN_CENTER, FromDIP(0));
Bind(wxEVT_CLOSE_WINDOW, [this](auto &e) {
on_hide();
});
SetSizer(m_sizer_main);
Layout();
Fit();
}
ImageDPIFrame::~ImageDPIFrame() {
}
bool ImageDPIFrame::Show(bool show)
{
Layout();
return DPIFrame::Show(show);
}
void ImageDPIFrame::set_bitmap(const wxBitmap &bit_map) {
m_bitmap->SetBitmap(bit_map);
}
void ImageDPIFrame::on_dpi_changed(const wxRect &suggested_rect)
{
// m_image->Rescale();
//m_bitmap->Rescale();
}
void ImageDPIFrame::on_show() {
if (IsShown()) {
on_hide();
}
Show();
Raise();
}
void ImageDPIFrame::on_hide()
{
if (IsShown()) {
Hide();
if (wxGetApp().mainframe != nullptr) {
wxGetApp().mainframe->Show();
wxGetApp().mainframe->Raise();
}
}
}
} // namespace GUI
} // namespace Slic3r

View File

@ -0,0 +1,28 @@
#ifndef _ImageDPIFrame_H_
#define _ImageDPIFrame_H_
#include "GUI_App.hpp"
#include "GUI_Utils.hpp"
class wxStaticBitmap;
namespace Slic3r { namespace GUI {
class ImageDPIFrame : public Slic3r::GUI::DPIFrame
{
public:
ImageDPIFrame();
~ImageDPIFrame() override;
void on_dpi_changed(const wxRect &suggested_rect) override;
void on_show();
void on_hide();
bool Show(bool show = true) override;
void set_bitmap(const wxBitmap& bit_map);
int get_image_px() { return m_image_px; }
private:
wxStaticBitmap *m_bitmap = nullptr;
wxBoxSizer *m_sizer_main{nullptr};
int m_image_px;
};
}} // namespace Slic3r::GUI
#endif // _STEP_MESH_DIALOG_H_

View File

@ -116,6 +116,7 @@
#include "BBLStatusBar.hpp"
#include "BitmapCache.hpp"
#include "ParamsDialog.hpp"
#include "ImageDPIFrame.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/RoundedRectangle.hpp"
#include "Widgets/RadioBox.hpp"
@ -414,6 +415,8 @@ struct Sidebar::priv
StaticBox * panel_printer_bed = nullptr;
wxStaticBitmap *image_printer_bed = nullptr;
ComboBox * combo_printer_bed = nullptr;
ImageDPIFrame *big_bed_image_popup = nullptr;
// Printer - sync
Button *btn_sync_printer;
std::shared_ptr<int> counter_sync_printer = std::make_shared<int>();
@ -1557,6 +1560,7 @@ Sidebar::Sidebar(Plater *parent)
wiki_bed->Bind(wxEVT_BUTTON, [](wxCommandEvent) {
wxLaunchDefaultBrowser("https://wiki.bambulab.com/en/x1/manual/compatibility-and-parameter-settings-of-filaments");
});
p->big_bed_image_popup = new ImageDPIFrame();
ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", 32);
p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0);
@ -1573,9 +1577,20 @@ Sidebar::Sidebar(Plater *parent)
auto select_bed_type = get_cur_select_bed_type();
bool isDual = static_cast<wxBoxSizer *>(p->panel_printer_preset->GetSizer())->GetOrientation() == wxVERTICAL;
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[select_bed_type], this, isDual ? 48 : 32));
p->big_bed_image_popup->set_bitmap(create_scaled_bitmap("big_" + bed_type_thumbnails[select_bed_type], p->big_bed_image_popup, p->big_bed_image_popup->get_image_px()));
e.Skip(); // fix bug:Event spreads to sidebar
});
p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent &evt) {
auto pos = p->image_printer_bed->GetScreenPosition();
auto rect = p->image_printer_bed->GetRect();
wxPoint temp_pos(pos.x + rect.GetWidth(), pos.y);
p->big_bed_image_popup->SetCanFocus(false);
p->big_bed_image_popup->SetPosition(temp_pos);
p->big_bed_image_popup->on_show();
});
p->image_printer_bed->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) { p->big_bed_image_popup->on_hide(); });
wxBoxSizer *bed_type_sizer = new wxBoxSizer(wxVERTICAL);
bed_type_sizer->AddStretchSpacer(1);
wxBoxSizer *bed_type_hsizer = new wxBoxSizer(wxHORIZONTAL);