Skip to content

Commit

Permalink
fix bug of slic3r
Browse files Browse the repository at this point in the history
  • Loading branch information
QIDITECH committed Nov 18, 2024
1 parent 9ce2c02 commit 971cc58
Show file tree
Hide file tree
Showing 107 changed files with 875 additions and 1,195 deletions.
16 changes: 16 additions & 0 deletions src/slic3r/Config/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ Index::const_iterator Index::recommended() const
std::vector<Index> Index::load_db()
{
boost::filesystem::path cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache";
boost::filesystem::path vendor_dir = boost::filesystem::path(Slic3r::data_dir()) / "vendor";

std::vector<Index> index_db;
std::string errors_cummulative;

for (auto &dir_entry : boost::filesystem::directory_iterator(cache_dir))
if (Slic3r::is_idx_file(dir_entry)) {
Index idx;
Expand All @@ -252,6 +254,20 @@ std::vector<Index> Index::load_db()
index_db.emplace_back(std::move(idx));
}

for (auto &dir_entry : boost::filesystem::directory_iterator(vendor_dir))
if (Slic3r::is_idx_file(dir_entry)) {
Index idx;
try {
idx.load(dir_entry.path());
} catch (const std::runtime_error &err) {
errors_cummulative += err.what();
errors_cummulative += "\n";
continue;
}
if (std::find_if(index_db.begin(), index_db.end(), [idx](const Index& index) { return idx.vendor() == index.vendor();}) == index_db.end())
index_db.emplace_back(std::move(idx));
}

if (! errors_cummulative.empty())
throw Slic3r::RuntimeError(errors_cummulative);
return index_db;
Expand Down
9 changes: 2 additions & 7 deletions src/slic3r/GUI/3DBed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ namespace Slic3r {
namespace GUI {

//B52
bool Bed3D::set_shape(const Pointfs & bed_shape,
const double max_print_height,
const std::string &custom_texture,
const std::string &custom_model,
const Pointfs & exclude_bed_shape,
bool force_as_custom)
bool Bed3D::set_shape(const Pointfs& bed_shape, const double max_print_height, const std::string& custom_texture, const std::string& custom_model, const Pointfs & exclude_bed_shape, bool force_as_custom)
{
auto check_texture = [](const std::string& texture) {
boost::system::error_code ec; // so the exists call does not throw (e.g. after a permission problem)
Expand Down Expand Up @@ -79,7 +74,7 @@ bool Bed3D::set_shape(const Pointfs & bed_shape,

m_type = type;
//B52
m_build_volume = BuildVolume{bed_shape, max_print_height, exclude_bed_shape};
m_build_volume = BuildVolume { bed_shape, max_print_height, exclude_bed_shape};
m_texture_filename = texture_filename;
m_model_filename = model_filename;
m_extended_bounding_box = this->calc_extended_bounding_box();
Expand Down
7 changes: 1 addition & 6 deletions src/slic3r/GUI/3DBed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ class Bed3D
//FIXME if the build volume max print height is updated, this function still returns zero
// as this class does not use it, thus there is no need to update the UI.
//B52
bool set_shape(const Pointfs & bed_shape,
const double max_print_height,
const std::string &custom_texture,
const std::string &custom_model,
const Pointfs & exclude_bed_shape,
bool force_as_custom = false);
bool set_shape(const Pointfs& bed_shape, const double max_print_height, const std::string& custom_texture, const std::string& custom_model, const Pointfs& exclude_bed_shape, bool force_as_custom = false);

// Build volume geometry for various collision detection tasks.
const BuildVolume& build_volume() const { return m_build_volume; }
Expand Down
9 changes: 8 additions & 1 deletion src/slic3r/GUI/3DScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ const ColorRGBA GLVolume::SELECTED_COLOR = ColorRGBA::GREEN();
const ColorRGBA GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
const ColorRGBA GLVolume::HOVER_DESELECT_COLOR = { 1.0f, 0.75f, 0.75f, 1.0f };
//B22
//const ColorRGBA GLVolume::OUTSIDE_COLOR = { 0.0f, 0.38f, 0.8f, 1.0f };
const ColorRGBA GLVolume::OUTSIDE_COLOR = { 1.0f, 0.0f, 0.0f, 1.0f };
const ColorRGBA GLVolume::SELECTED_OUTSIDE_COLOR = { 0.19f, 0.58f, 1.0f, 1.0f };
const ColorRGBA GLVolume::DISABLED_COLOR = ColorRGBA::DARK_GRAY();
Expand Down Expand Up @@ -265,6 +264,14 @@ void GLVolume::set_render_color(bool force_transparent)
}
}
else {
//B22
/*if (hover == HS_Select)
set_render_color(HOVER_SELECT_COLOR);
else if (hover == HS_Deselect)
set_render_color(HOVER_DESELECT_COLOR);
else if (selected)
set_render_color(outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR);
else if (disabled)*/
if (disabled)
set_render_color(DISABLED_COLOR);
else if (outside && shader_outside_printer_detection_enabled)
Expand Down
29 changes: 14 additions & 15 deletions src/slic3r/GUI/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "MainFrame.hpp"
#include "format.hpp"

#include <wx/clipbrd.h>
#include <wx/clipbrd.h> // IWYU pragma: keep

namespace Slic3r {
namespace GUI {
Expand Down Expand Up @@ -223,16 +223,16 @@ AboutDialog::AboutDialog()
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);

// logo
//y15
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle("QIDI_Back", 99));
//hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
//Rectangle


wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
vsizer->Add(m_logo, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, -50);
hsizer->AddSpacer(15);
hsizer->Add(vsizer, 2, wxEXPAND|wxLEFT, 0);


//y15
// title
/*{
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
Expand Down Expand Up @@ -273,7 +273,7 @@ AboutDialog::AboutDialog()
m_html->SetBorders(2);
const wxString copyright_str = _L("Copyright");
// TRN AboutDialog: "Slic3r %1% GNU Affero General Public License"
const wxString a_url_str = _L("Amazon : https://www.amazon.com/stores/page/220AF7CA-5334-4ECA-8E62-B6C8A068E7AC");
//Y
const wxString s_url_str = _L("Shopify : https://qidi3d.com/");
const wxString is_lecensed_str = _L("is licensed under the");
const wxString license_str = _L("GNU Affero General Public License, version 3");
Expand All @@ -286,19 +286,18 @@ AboutDialog::AboutDialog()
"<font color=%3%>"
"%4%"
"<br /><br />"
"<a href=\"https://www.amazon.com/stores/page/220AF7CA-5334-4ECA-8E62-B6C8A068E7AC\">%5%</a> <br />"
"<a href=\"https://qidi3d.com/\">%6%</a>"
"<a href=\"https://qidi3d.com/\">%5%</a>"
"<br /><br />"
"%7%<br />"
"%12% &copy; 2023-2024 QIDI Technology. <br />"
"%8% &copy; 2016-2024 Prusa Research. <br />"
"%9% &copy; 2011-2018 Alessandro Ranellucci. <br />"
"<a href=\"http://slic3r.org/\">Slic3r</a> %10% "
"<a href=\"http://www.gnu.org/licenses/agpl-3.0.html\">%11%</a>."
"%6%<br />"
"%11% &copy; 2023-2024 QIDI Technology. <br />"
"%7% &copy; 2016-2024 Prusa Research. <br />"
"%8% &copy; 2011-2018 Alessandro Ranellucci. <br />"
"<a href=\"http://slic3r.org/\">Slic3r</a> %9% "
"<a href=\"http://www.gnu.org/licenses/agpl-3.0.html\">%10%</a>."
"</font>"
"</body>"
"</html>", bgr_clr_str, text_clr_str, text_clr_str
, contributors_str, a_url_str, s_url_str ,version_str
, contributors_str, s_url_str ,version_str
, copyright_str, copyright_str
, is_lecensed_str, license_str, copyright_str);
m_html->SetPage(text);
Expand Down
10 changes: 4 additions & 6 deletions src/slic3r/GUI/BedShapeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Slic3r {
namespace GUI {

//B52
BedShape::BedShape(const ConfigOptionPoints &points1, const ConfigOptionPoints &points2)
BedShape::BedShape(const ConfigOptionPoints& points1, const ConfigOptionPoints& points2)
{
m_build_volume = {points1.values, 0., points2.values};
m_build_volume = { points1.values, 0., points2.values};
}

static std::string get_option_label(BedShape::Parameter param)
Expand Down Expand Up @@ -299,8 +299,6 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
left_sizer->Add(exclude_panel, 0, wxEXPAND);
left_sizer->Add(texture_panel, 0, wxEXPAND);
left_sizer->Add(model_panel, 0, wxEXPAND);
left_sizer->Add(texture_panel, 1, wxEXPAND);
left_sizer->Add(model_panel, 1, wxEXPAND);

wxSizer* top_sizer = new wxBoxSizer(wxHORIZONTAL);
top_sizer->Add(left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 10);
Expand Down Expand Up @@ -348,7 +346,7 @@ wxSizer* BedShapePanel::init_exclude_sizer()
wxGetApp().UpdateDarkUI(panel_0, true);
exclude_optgroup_0 = std::make_shared<ConfigOptionsGroup>(panel_0, _L("Exclude area 1"));
exclude_optgroup_0->label_width = 10;
exclude_optgroup_0->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
exclude_optgroup_0->on_change = [this](t_config_option_key opt_key, boost::any value) {
update_shape();
};
BedShape::append_option_line(exclude_optgroup_0, BedShape::Parameter::ExcludeMax);
Expand All @@ -360,7 +358,7 @@ wxSizer* BedShapePanel::init_exclude_sizer()
wxGetApp().UpdateDarkUI(panel_1, true);
exclude_optgroup_1 = std::make_shared<ConfigOptionsGroup>(panel_1, _L("Exclude area 2"));
exclude_optgroup_1->label_width = 10;
exclude_optgroup_1->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
exclude_optgroup_1->on_change = [this](t_config_option_key opt_key, boost::any value) {
update_shape();
};
BedShape::append_option_line(exclude_optgroup_1, BedShape::Parameter::ExcludeMax);
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/BedShapeDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class BedShapePanel : public wxPanel
wxPanel* init_texture_panel();
wxPanel* init_model_panel();
//B52
void set_shape(const ConfigOptionPoints &points1, const ConfigOptionPoints &points2);
void set_shape(const ConfigOptionPoints &points1, const ConfigOptionPoints &points2);
//Y20 //B52
void set_exclude_area(const ConfigOptionPoints &points1, const ConfigOptionPoints &points2);
void update_preview();
Expand Down
13 changes: 4 additions & 9 deletions src/slic3r/GUI/BitmapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,14 @@ wxBitmapBundle *BitmapCache::from_png_of_login(const std::string &bitmap_name, u
int cx = image.GetWidth() / 2;
int cy = image.GetHeight() / 2;

for (int y = 0; y < height; ++y)
{
for (int x = 0; x < height; ++x)
{
for (int y = 0; y < height; ++y) {
for (int x = 0; x < height; ++x) {
int dx = x - radius;
int dy = y - radius;
if (dx * dx + dy * dy <= radius * radius)
{
if (dx * dx + dy * dy <= radius * radius) {
image.SetRGB(x, y, image.GetRed(cx + dx, cy + dy), image.GetGreen(cx + dx, cy + dy), image.GetBlue(cx + dx, cy + dy));
image.SetAlpha(x, y, 255);
} else
{
} else {
image.SetRGB(x, y, 38, 38, 41);
image.SetAlpha(x, y, 0);
}
Expand All @@ -493,7 +489,6 @@ wxBitmapBundle *BitmapCache::from_png_of_login(const std::string &bitmap_name, u
return this->insert_bndl(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
}


wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/)
{
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/BitmapComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "format.hpp"

// A workaround for a set of issues related to text fitting into gtk widgets:
// See e.g.: https://github.com/qidi3d/QIDISlicer/issues/4584
// See e.g.: https://github.com/QIDITECH/QIDISlicer/issues/4584
#if defined(__WXGTK20__) || defined(__WXGTK3__)
#include <glib-2.0/glib-object.h>
#include <pango-1.0/pango/pango-layout.h>
Expand Down
65 changes: 31 additions & 34 deletions src/slic3r/GUI/BonjourDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "slic3r/Utils/Bonjour.hpp"
#include "slic3r/Utils/Udp.hpp"


namespace Slic3r {


Expand All @@ -46,7 +45,8 @@ class UdpReplyEvent : public wxEvent
public:
UdpReply reply;

UdpReplyEvent(wxEventType eventType, int winid, UdpReply &&reply) : wxEvent(winid, eventType), reply(std::move(reply)) {}
UdpReplyEvent(wxEventType eventType, int winid, UdpReply &&reply)
: wxEvent(winid, eventType), reply(std::move(reply)) {}

virtual wxEvent *Clone() const { return new UdpReplyEvent(*this); }
};
Expand All @@ -62,7 +62,7 @@ wxDECLARE_EVENT(EVT_BONJOUR_COMPLETE, wxCommandEvent);
wxDEFINE_EVENT(EVT_BONJOUR_COMPLETE, wxCommandEvent);

class ReplySet: public std::set<BonjourReply> {};
class UdpReplySet : public std::set<UdpReply> {};
class UdpReplySet: public std::set<UdpReply> {};

struct LifetimeGuard
{
Expand All @@ -75,8 +75,8 @@ struct LifetimeGuard
BonjourDialog::BonjourDialog(wxWindow *parent, Slic3r::PrinterTechnology tech)
: wxDialog(parent, wxID_ANY, _(L("Network lookup")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
, list(new wxListView(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSIMPLE_BORDER))
, replies(new ReplySet)
, udp_replies(new UdpReplySet)
, replies(new ReplySet)
, udp_replies(new UdpReplySet)
, label(new wxStaticText(this, wxID_ANY, ""))
, timer(new wxTimer())
, timer_state(0)
Expand Down Expand Up @@ -111,12 +111,12 @@ BonjourDialog::BonjourDialog(wxWindow *parent, Slic3r::PrinterTechnology tech)

Bind(EVT_BONJOUR_REPLY, &BonjourDialog::on_reply, this);

Bind(EVT_UDP_REPLY, &BonjourDialog::on_udp_reply, this);
Bind(EVT_UDP_REPLY, &BonjourDialog::on_udp_reply, this);

// B29
Bind(EVT_BONJOUR_COMPLETE, [this](wxCommandEvent &) {
this->timer_state = 0;
});
Bind(EVT_BONJOUR_COMPLETE, [this](wxCommandEvent &) {
this->timer_state = 0;
});

Bind(wxEVT_TIMER, &BonjourDialog::on_timer, this);
GUI::wxGetApp().UpdateDlgDarkUI(this);
Expand All @@ -143,31 +143,30 @@ bool BonjourDialog::show_and_lookup()
// so that both threads can access it safely.
auto dguard = std::make_shared<LifetimeGuard>(this);

// B29
Udp::TxtKeys udp_txt_keys{"version", "model"};
// B29
Udp::TxtKeys udp_txt_keys{"version", "model"};

udp = Udp("octoprint")
.set_txt_keys(std::move(udp_txt_keys))
.set_retries(3)
.set_timeout(4)
.on_udp_reply([dguard](UdpReply &&reply) {
std::lock_guard<std::mutex> lock_guard(dguard->mutex);
auto dialog = dguard->dialog;
if (dialog != nullptr) {
auto evt = new UdpReplyEvent(EVT_UDP_REPLY, dialog->GetId(), std::move(reply));
wxQueueEvent(dialog, evt);
}
})
.on_complete([dguard]() {
std::lock_guard<std::mutex> lock_guard(dguard->mutex);
auto dialog = dguard->dialog;
if (dialog != nullptr) {
auto evt = new wxCommandEvent(EVT_UDP_COMPLETE, dialog->GetId());
wxQueueEvent(dialog, evt);
}
})
.lookup();

.set_retries(3)
.set_timeout(4)
.on_udp_reply([dguard](UdpReply &&reply) {
std::lock_guard<std::mutex> lock_guard(dguard->mutex);
auto dialog = dguard->dialog;
if (dialog != nullptr) {
auto evt = new UdpReplyEvent(EVT_UDP_REPLY, dialog->GetId(), std::move(reply));
wxQueueEvent(dialog, evt);
}
})
.on_complete([dguard]() {
std::lock_guard<std::mutex> lock_guard(dguard->mutex);
auto dialog = dguard->dialog;
if (dialog != nullptr) {
auto evt = new wxCommandEvent(EVT_UDP_COMPLETE, dialog->GetId());
wxQueueEvent(dialog, evt);
}
})
.lookup();

// Note: More can be done here when we support discovery of hosts other than Octoprint and SL1
Bonjour::TxtKeys txt_keys { "version", "model" };
Expand Down Expand Up @@ -265,8 +264,7 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e)
}

// B29
void BonjourDialog::on_udp_reply(UdpReplyEvent &e)
{
void BonjourDialog::on_udp_reply(UdpReplyEvent &e) {
if (udp_replies->find(e.reply) != udp_replies->end()) {
// We already have this reply
return;
Expand Down Expand Up @@ -313,7 +311,6 @@ void BonjourDialog::on_udp_reply(UdpReplyEvent &e)
}
}


void BonjourDialog::on_timer(wxTimerEvent &)
{
on_timer_process();
Expand Down
1 change: 0 additions & 1 deletion src/slic3r/GUI/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ void Camera::set_default_orientation()
const double theta_rad = Geometry::deg2rad(-(double)m_zenit);
//B3
const double phi_rad = Geometry::deg2rad(0.0);
// const double phi_rad = Geometry::deg2rad(45.0);
const double sin_theta = ::sin(theta_rad);
const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad));
m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ());
Expand Down
Loading

0 comments on commit 971cc58

Please sign in to comment.