Merging with master for having minz png compression.

Much greater performance boost from better compression algorithm than that from the merged polygons.
This commit is contained in:
tamasmeszaros 2019-03-29 15:21:46 +01:00
commit 725f115756
344 changed files with 786 additions and 116524 deletions

View file

@ -32,7 +32,7 @@
#include "GUI.hpp"
#ifdef HAS_GLSAFE
void glAssertRecentCallImpl()
void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name)
{
GLenum err = glGetError();
if (err == GL_NO_ERROR)
@ -47,7 +47,7 @@ void glAssertRecentCallImpl()
case GL_OUT_OF_MEMORY: sErr = "Out Of Memory"; break;
default: sErr = "Unknown"; break;
}
BOOST_LOG_TRIVIAL(error) << "OpenGL error " << (int)err << ": " << sErr;
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
assert(false);
}
#endif

View file

@ -16,9 +16,9 @@
#endif
#ifdef HAS_GLSAFE
extern void glAssertRecentCallImpl();
inline void glAssertRecentCall() { glAssertRecentCallImpl(); }
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(); } while (false)
extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name);
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
#else
inline void glAssertRecentCall() { }
#define glsafe(cmd) cmd

View file

@ -92,64 +92,13 @@ void BackgroundSlicingProcess::process_fff()
}
}
// Pseudo type for specializing LayerWriter trait class
struct SLAZipFmt {};
// The implementation of creating zipped archives with wxWidgets
template<> class LayerWriter<SLAZipFmt> {
wxFileName fpath;
wxFFileOutputStream zipfile;
wxZipOutputStream zipstream;
wxStdOutputStream pngstream;
public:
inline LayerWriter(const std::string& zipfile_path):
fpath(zipfile_path),
zipfile(zipfile_path),
zipstream(zipfile),
pngstream(zipstream)
{
if(!is_ok())
throw std::runtime_error("Cannot create zip file.");
}
~LayerWriter() {
// In case of an error (disk space full) zipstream destructor would
// crash.
pngstream.clear();
zipstream.CloseEntry();
}
inline void next_entry(const std::string& fname) {
zipstream.PutNextEntry(fname);
}
inline std::string get_name() const {
return fpath.GetName().ToUTF8().data();
}
template<class T> inline LayerWriter& operator<<(const T& arg) {
pngstream << arg; return *this;
}
bool is_ok() const {
return pngstream.good() && zipstream.IsOk() && zipfile.IsOk();
}
inline void close() {
zipstream.Close();
zipfile.Close();
}
};
void BackgroundSlicingProcess::process_sla()
{
assert(m_print == m_sla_print);
m_print->process();
if (this->set_step_started(bspsGCodeFinalize)) {
if (! m_export_path.empty()) {
m_sla_print->export_raster<SLAZipFmt>(m_export_path);
m_sla_print->export_raster(m_export_path);
m_print->set_status(100, "Masked SLA file exported to " + m_export_path);
} else if (! m_upload_job.empty()) {
prepare_upload();
@ -449,8 +398,8 @@ void BackgroundSlicingProcess::prepare_upload()
}
run_post_process_scripts(source_path.string(), m_fff_print->config());
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
} else {
m_sla_print->export_raster<SLAZipFmt>(source_path.string());
} else {
m_sla_print->export_raster(source_path.string());
// TODO: Also finalize upload path like with FFF when there are statistics for SLA print
}

View file

@ -540,13 +540,26 @@ void Choice::BUILD() {
else{
for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) {
const wxString& str = _(el);//m_opt_id == "support" ? _(el) : el;
//FIXME Vojtech: Why is the single column empty icon necessary? It is a workaround of some kind, but what for?
// Please document such workarounds by comments!
// temp->Append(str, create_scaled_bitmap("empty_icon.png"));
temp->Append(str, wxNullBitmap);
temp->Append(str);
}
set_selection();
}
#ifndef __WXGTK__
/* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX):
*
* 1. We should create small Bitmap to fill Bitmaps RefData,
* ! in this case wxBitmap.IsOK() return true.
* 2. But then set width to 0 value for no using of bitmap left and right spacing
* 3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
*
* Note: Set bitmap height to the Font size because of OSX rendering.
*/
wxBitmap empty_bmp(1, temp->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
temp->SetItemBitmap(0, empty_bmp);
#endif
// temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
temp->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
@ -571,6 +584,11 @@ void Choice::BUILD() {
void Choice::set_selection()
{
/* To prevent earlier control updating under OSX set m_disable_change_event to true
* (under OSX wxBitmapComboBox send wxEVT_COMBOBOX even after SetSelection())
*/
m_disable_change_event = true;
wxString text_value = wxString("");
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);

View file

@ -2114,6 +2114,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
wxDEFINE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent);
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar)
: m_canvas(canvas)
@ -2227,7 +2228,7 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (useVBOs && !m_shader.init("gouraud.vs", "gouraud.fs"))
return false;
if (useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
if (m_toolbar.is_enabled() && useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
return false;
m_use_VBOs = useVBOs;
@ -2248,7 +2249,7 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
if (!_init_toolbar())
return false;
if (!m_selection.init(m_use_VBOs))
if (m_selection.is_enabled() && !m_selection.init(m_use_VBOs))
return false;
post_event(SimpleEvent(EVT_GLCANVAS_INIT));
@ -2432,6 +2433,11 @@ void GLCanvas3D::enable_gizmos(bool enable)
m_gizmos.set_enabled(enable);
}
void GLCanvas3D::enable_selection(bool enable)
{
m_selection.set_enabled(enable);
}
void GLCanvas3D::enable_toolbar(bool enable)
{
m_toolbar.set_enabled(enable);
@ -3767,8 +3773,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// of the scene with the background processing data should be performed.
post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
}
else if (evt.LeftUp() && !m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.is_dragging()
&& !is_layers_editing_enabled())
else if (evt.LeftUp() && !m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.grabber_contains_mouse() && !m_gizmos.is_dragging()
&& !is_layers_editing_enabled())
{
// deselect and propagate event through callback
if (!evt.ShiftDown() && m_picking_enabled && !m_mouse.ignore_up_event)

View file

@ -116,6 +116,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_GEOMETRY, Vec3dsEvent<2>);
wxDECLARE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_UPDATE_BED_SHAPE, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_TAB, SimpleEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_RESETGIZMOS, SimpleEvent);
// this describes events being passed from GLCanvas3D to SlaSupport gizmo
enum class SLAGizmoEventType {
@ -652,6 +653,7 @@ public:
void enable_picking(bool enable);
void enable_moving(bool enable);
void enable_gizmos(bool enable);
void enable_selection(bool enable);
void enable_toolbar(bool enable);
void enable_dynamic_background(bool enable);
void allow_multisample(bool allow);
@ -712,6 +714,7 @@ public:
void set_camera_zoom(float zoom);
void update_gizmos_on_off_state();
void reset_all_gizmos() { m_gizmos.reset_all_states(); }
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);

View file

@ -649,20 +649,16 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
}
case ConfigMenuLanguage:
{
/* Before change application language, let's check unsaved changes
/* Before change application language, let's check unsaved changes on 3D-Scene
* and draw user's attention to the application restarting after a language change
*/
wxMessageDialog dialog(nullptr,
_(L("Application will be restarted after language change, "
"and 3D-Scene will be cleaned.")) + "\n" +
_(L("Please, check your changes before.")) + "\n\n" +
_(L("Continue anyway?")),
_(L("Application will be restarted after language change.")) + "\n" +
_(L("3D-Scene will be cleaned.")) + "\n\n" +
_(L("Please, check your changes before.")),
_(L("Attention!")),
wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
if ( dialog.ShowModal() != wxID_YES)
return;
if (!wxGetApp().check_unsaved_changes())
wxICON_QUESTION | wxOK | wxCANCEL);
if ( dialog.ShowModal() == wxID_CANCEL)
return;
wxArrayString names;

View file

@ -228,6 +228,21 @@ int ObjectList::get_selected_obj_idx() const
return -1;
}
DynamicPrintConfig& ObjectList::get_item_config(const wxDataViewItem& item) const
{
assert(item);
const ItemType type = m_objects_model->GetItemType(item);
const int obj_idx = type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item));
const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1;
assert(obj_idx >= 0 || ((type & itVolume) && vol_idx >=0));
return type & itObject|itInstance ? (*m_objects)[obj_idx]->config :
(*m_objects)[obj_idx]->volumes[vol_idx]->config;
}
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count)
{
wxArrayString choices;
@ -910,8 +925,10 @@ wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
{
PrusaMenu* menu = dynamic_cast<PrusaMenu*>(menu_);
const wxString menu_name = _(L("Add settings"));
// Delete old items from settings popupmenu
auto settings_id = menu->FindItem(_("Add settings"));
auto settings_id = menu->FindItem(menu_name);
if (settings_id != wxNOT_FOUND)
menu->Destroy(settings_id);
@ -966,14 +983,10 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
menu->m_separator_scnd = menu->AppendSeparator();
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(L("Add settings")));
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
menu_item->SetBitmap(m_bmp_cog);
// const auto sel_vol = get_selected_model_volume();
// if (sel_vol && sel_vol->type() >= ModelVolumeType::SUPPORT_ENFORCER)
// menu_item->Enable(false);
// else
menu_item->SetSubMenu(create_settings_popupmenu(menu));
menu_item->SetSubMenu(create_settings_popupmenu(menu));
return menu->Append(menu_item);
}
@ -1018,6 +1031,37 @@ void ObjectList::append_menu_item_export_stl(wxMenu* menu) const
menu->AppendSeparator();
}
void ObjectList::append_menu_item_change_extruder(wxMenu* menu) const
{
const wxString name = _(L("Change extruder"));
// Delete old menu item
const int item_id = menu->FindItem(name);
if (item_id != wxNOT_FOUND)
menu->Destroy(item_id);
const int extruders_cnt = extruders_count();
const wxDataViewItem item = GetSelection();
if (item && extruders_cnt > 1)
{
DynamicPrintConfig& config = get_item_config(item);
const int initial_extruder = !config.has("extruder") ? 0 :
config.option<ConfigOptionInt>("extruder")->value;
wxMenu* extruder_selection_menu = new wxMenu();
for (int i = 0; i <= extruders_cnt; i++)
{
const wxString& item_name = i == 0 ? _(L("Default")) : wxString::Format("%d", i);
append_menu_radio_item(extruder_selection_menu, wxID_ANY, item_name, "",
[this, i](wxCommandEvent&) { set_extruder_for_selected_items(i); }, menu)->Check(i == initial_extruder);
}
menu->AppendSubMenu(extruder_selection_menu, name, _(L("Select new extruder for the object/part")));
}
}
void ObjectList::create_object_popupmenu(wxMenu *menu)
{
#ifdef __WXOSX__
@ -1989,7 +2033,7 @@ void ObjectList::update_selections_on_canvas()
return;
}
auto add_to_selection = [this](const wxDataViewItem& item, Selection& selection, bool as_single_selection)
auto add_to_selection = [this](const wxDataViewItem& item, Selection& selection, int instance_idx, bool as_single_selection)
{
if (m_objects_model->GetParent(item) == wxDataViewItem(0)) {
selection.add_object(m_objects_model->GetIdByItem(item), as_single_selection);
@ -1999,7 +2043,7 @@ void ObjectList::update_selections_on_canvas()
if (m_objects_model->GetItemType(item) == itVolume) {
const int obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetParent(item));
const int vol_idx = m_objects_model->GetVolumeIdByItem(item);
selection.add_volume(obj_idx, vol_idx, 0, as_single_selection);
selection.add_volume(obj_idx, vol_idx, std::max(instance_idx, 0), as_single_selection);
}
else if (m_objects_model->GetItemType(item) == itInstance) {
const int obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item));
@ -2011,10 +2055,10 @@ void ObjectList::update_selections_on_canvas()
if (sel_cnt == 1) {
wxDataViewItem item = GetSelection();
if (m_objects_model->GetItemType(item) & (itSettings|itInstanceRoot))
add_to_selection(m_objects_model->GetParent(item), selection, true);
add_to_selection(m_objects_model->GetParent(item), selection, -1, true);
else
add_to_selection(item, selection, true);
add_to_selection(item, selection, -1, true);
wxGetApp().plater()->canvas3D()->update_gizmos_on_off_state();
return;
}
@ -2022,9 +2066,11 @@ void ObjectList::update_selections_on_canvas()
wxDataViewItemArray sels;
GetSelections(sels);
// stores current instance idx before to clear the selection
int instance_idx = selection.get_instance_idx();
selection.clear();
for (auto item: sels)
add_to_selection(item, selection, false);
add_to_selection(item, selection, instance_idx, false);
wxGetApp().plater()->canvas3D()->update_gizmos_on_off_state();
}
@ -2425,15 +2471,7 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const
for (const wxDataViewItem& item : sels)
{
const ItemType type = m_objects_model->GetItemType(item);
const int obj_idx = type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item));
const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1;
DynamicPrintConfig& config = type & itObject ? (*m_objects)[obj_idx]->config :
(*m_objects)[obj_idx]->volumes[vol_idx]->config;
DynamicPrintConfig& config = get_item_config(item);
if (config.has("extruder")) {
if (extruder == 0)
@ -2446,7 +2484,16 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const
const wxString extruder_str = extruder == 0 ? wxString ("default") :
wxString::Format("%d", config.option<ConfigOptionInt>("extruder")->value);
m_objects_model->SetValue(extruder_str, item, 1);
auto const type = m_objects_model->GetItemType(item);
/* We can change extruder for Object/Volume only.
* So, if Instance is selected, get its Object item and change it
*/
m_objects_model->SetValue(extruder_str, type & itInstance ? m_objects_model->GetTopParent(item) : item, 1);
const int obj_idx = type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item));
wxGetApp().plater()->canvas3D()->ensure_on_bed(obj_idx);
}

View file

@ -187,6 +187,7 @@ public:
void append_menu_items_osx(wxMenu* menu);
void append_menu_item_fix_through_netfabb(wxMenu* menu);
void append_menu_item_export_stl(wxMenu* menu) const ;
void append_menu_item_change_extruder(wxMenu* menu) const;
void create_object_popupmenu(wxMenu *menu);
void create_sla_object_popupmenu(wxMenu*menu);
void create_part_popupmenu(wxMenu*menu);
@ -213,12 +214,13 @@ public:
wxPoint get_mouse_position_in_control();
wxBoxSizer* get_sizer() {return m_sizer;}
int get_selected_obj_idx() const;
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
bool is_parts_changed() const { return m_parts_changed; }
bool is_part_settings_changed() const { return m_part_settings_changed; }
void part_settings_changed();
void parts_changed(int obj_idx);
void part_selection_changed();
void parts_changed(int obj_idx);
void part_selection_changed();
// Add object to the list
void add_object_to_list(size_t obj_idx);

View file

@ -123,8 +123,8 @@ void ObjectSettings::update_settings_list()
continue;
auto optgroup = std::make_shared<ConfigOptionsGroup>(m_og->ctrl_parent(), cat.first, config, false, extra_column);
optgroup->label_width = 15 * wxGetApp().em_unit();//150;
optgroup->sidetext_width = 7 * wxGetApp().em_unit();//70;
optgroup->label_width = 15 * wxGetApp().em_unit();
optgroup->sidetext_width = 5.5 * wxGetApp().em_unit();
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
wxGetApp().obj_list()->part_settings_changed(); };
@ -134,7 +134,7 @@ void ObjectSettings::update_settings_list()
if (opt == "extruder")
continue;
Option option = optgroup->get_option(opt);
option.opt.width = 7 * wxGetApp().em_unit();//70;
option.opt.width = 12 * wxGetApp().em_unit();
optgroup->append_single_option_line(option);
}
optgroup->reload_config();

View file

@ -62,6 +62,7 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_
m_canvas->set_process(process);
m_canvas->set_config(config);
m_canvas->enable_gizmos(true);
m_canvas->enable_selection(true);
m_canvas->enable_toolbar(true);
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);

View file

@ -103,7 +103,7 @@ public:
}
void unbind() { event_storage.reset(nullptr); }
explicit operator bool() const noexcept { return !!event_storage; }
explicit operator bool() const { return !!event_storage; }
};

View file

@ -21,7 +21,7 @@ GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& ic
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id)
: GLGizmoBase(parent, sprite_id)
#endif // ENABLE_SVG_ICONS
, m_starting_center(Vec3d::Zero()), m_quadric(nullptr)
, m_quadric(nullptr)
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
@ -44,12 +44,14 @@ bool GLGizmoSlaSupports::on_init()
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection)
{
m_starting_center = Vec3d::Zero();
if (selection.is_empty()) {
m_model_object = nullptr;
m_old_model_object = nullptr;
return;
}
m_old_model_object = m_model_object;
m_model_object = model_object;
if (selection.is_empty())
m_old_instance_id = -1;
m_active_instance = selection.get_instance_idx();
if (model_object && selection.is_from_single_instance())
@ -74,6 +76,14 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
void GLGizmoSlaSupports::on_render(const Selection& selection) const
{
// If current m_model_object does not match selection, ask GLCanvas3D to turn us off
if (m_state == On
&& (m_model_object != selection.get_model()->objects[selection.get_object_idx()]
|| m_active_instance != selection.get_instance_idx())) {
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_RESETGIZMOS));
return;
}
::glEnable(GL_BLEND);
::glEnable(GL_DEPTH_TEST);
@ -717,6 +727,7 @@ std::string GLGizmoSlaSupports::on_get_name() const
void GLGizmoSlaSupports::on_set_state()
{
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
if (is_mesh_update_necessary())
update_mesh();

View file

@ -22,7 +22,6 @@ private:
ModelObject* m_model_object = nullptr;
ModelObject* m_old_model_object = nullptr;
int m_active_instance = -1;
int m_old_instance_id = -1;
std::pair<Vec3f, Vec3f> unproject_on_mesh(const Vec2d& mouse_pos);
const float RenderPointScale = 1.f;
@ -32,10 +31,6 @@ private:
Eigen::MatrixXi m_F; // facets indices
igl::AABB<Eigen::MatrixXf,3> m_AABB;
struct SourceDataSummary {
Geometry::Transformation transformation;
};
class CacheEntry {
public:
CacheEntry(const sla::SupportPoint& point, bool sel, const Vec3f& norm = Vec3f::Zero()) :
@ -46,11 +41,6 @@ private:
Vec3f normal;
};
// This holds information to decide whether recalculation is necessary:
SourceDataSummary m_source_data;
mutable Vec3d m_starting_center;
public:
#if ENABLE_SVG_ICONS
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);

View file

@ -28,7 +28,7 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he
{}
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) :
wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER),
wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
boldfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)),
content_sizer(new wxBoxSizer(wxVERTICAL)),
btn_sizer(new wxBoxSizer(wxHORIZONTAL))

View file

@ -427,7 +427,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
option = m_og->get_option("fill_density");
option.opt.label = L("Infill");
option.opt.width = 7 * wxGetApp().em_unit();
option.opt.width = 6 * wxGetApp().em_unit();
option.opt.sidetext = " ";
line.append_option(option);
@ -1191,6 +1191,7 @@ struct Plater::priv
void select_view(const std::string& direction);
void select_view_3D(const std::string& name);
void select_next_view_3D();
void reset_all_gizmos();
void update_ui_from_settings();
ProgressStatusBar* statusbar();
std::string get_config(const std::string &key) const;
@ -1396,6 +1397,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
view3D_canvas->Bind(EVT_GLCANVAS_UPDATE_GEOMETRY, &priv::on_update_geometry, this);
view3D_canvas->Bind(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, &priv::on_3dcanvas_mouse_dragging_finished, this);
view3D_canvas->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
view3D_canvas->Bind(EVT_GLCANVAS_RESETGIZMOS, [this](SimpleEvent&) { reset_all_gizmos(); });
// 3DScene/Toolbar:
view3D_canvas->Bind(EVT_GLTOOLBAR_ADD, &priv::on_action_add, this);
view3D_canvas->Bind(EVT_GLTOOLBAR_DELETE, [q](SimpleEvent&) { q->remove_selected(); });
@ -1414,8 +1416,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_UPDATE_BED_SHAPE, [this](SimpleEvent&) { set_bed_shape(config->option<ConfigOptionPoints>("bed_shape")->values); });
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); });
view3D_canvas->Bind(EVT_GLCANVAS_INIT, [this](SimpleEvent&) { init_view_toolbar(); });
q->Bind(EVT_SLICING_COMPLETED, &priv::on_slicing_completed, this);
q->Bind(EVT_PROCESS_COMPLETED, &priv::on_process_completed, this);
q->Bind(EVT_GLVIEWTOOLBAR_3D, [q](SimpleEvent&) { q->select_view_3D("3D"); });
@ -1478,6 +1478,11 @@ void Plater::priv::select_next_view_3D()
set_current_panel(view3D);
}
void Plater::priv::reset_all_gizmos()
{
view3D->get_canvas3d()->reset_all_gizmos();
}
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void Plater::priv::update_ui_from_settings()
@ -2619,29 +2624,35 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
sidebar->obj_list()->append_menu_item_settings(menu);
/* Remove/Prepend "increase/decrease instances" menu items according to the view mode.
* Suppress to show those items for a Simple mode
*/
const MenuIdentifier id = printer_technology == ptSLA ? miObjectSLA : miObjectFFF;
if (wxGetApp().get_mode() == comSimple) {
if (menu->FindItem(_(L("Increase copies"))) != wxNOT_FOUND)
{
/* Detach an items from the menu, but don't delete them
* so that they can be added back later
* (after switching to the Advanced/Expert mode)
*/
menu->Remove(items_increase[id]);
menu->Remove(items_decrease[id]);
menu->Remove(items_set_number_of_copies[id]);
if (printer_technology != ptSLA)
sidebar->obj_list()->append_menu_item_change_extruder(menu);
if (menu != &part_menu)
{
/* Remove/Prepend "increase/decrease instances" menu items according to the view mode.
* Suppress to show those items for a Simple mode
*/
const MenuIdentifier id = printer_technology == ptSLA ? miObjectSLA : miObjectFFF;
if (wxGetApp().get_mode() == comSimple) {
if (menu->FindItem(_(L("Increase copies"))) != wxNOT_FOUND)
{
/* Detach an items from the menu, but don't delete them
* so that they can be added back later
* (after switching to the Advanced/Expert mode)
*/
menu->Remove(items_increase[id]);
menu->Remove(items_decrease[id]);
menu->Remove(items_set_number_of_copies[id]);
}
}
}
else {
if (menu->FindItem(_(L("Increase copies"))) == wxNOT_FOUND)
{
// Prepend items to the menu, if those aren't not there
menu->Prepend(items_set_number_of_copies[id]);
menu->Prepend(items_decrease[id]);
menu->Prepend(items_increase[id]);
else {
if (menu->FindItem(_(L("Increase copies"))) == wxNOT_FOUND)
{
// Prepend items to the menu, if those aren't not there
menu->Prepend(items_set_number_of_copies[id]);
menu->Prepend(items_decrease[id]);
menu->Prepend(items_increase[id]);
}
}
}

View file

@ -35,7 +35,7 @@ void PreferencesDialog::build()
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will prompt the last output directory "
"instead of the one containing the input files.");
def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path")[0] == '1' : true }; // 1;
def.default_value = new ConfigOptionBool{ app_config->has("remember_output_path") ? app_config->get("remember_output_path") == "1" : true };
Option option(def, "remember_output_path");
m_optgroup->append_single_option_line(option);
@ -43,7 +43,7 @@ void PreferencesDialog::build()
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will auto-center objects "
"around the print bed center.");
def.default_value = new ConfigOptionBool{ app_config->get("autocenter")[0] == '1' }; // 1;
def.default_value = new ConfigOptionBool{ app_config->get("autocenter") == "1" };
option = Option (def,"autocenter");
m_optgroup->append_single_option_line(option);
@ -51,7 +51,7 @@ void PreferencesDialog::build()
def.type = coBool;
def.tooltip = L("If this is enabled, Slic3r will pre-process objects as soon "
"as they\'re loaded in order to save time when exporting G-code.");
def.default_value = new ConfigOptionBool{ app_config->get("background_processing")[0] == '1' }; // 1;
def.default_value = new ConfigOptionBool{ app_config->get("background_processing") == "1" };
option = Option (def,"background_processing");
m_optgroup->append_single_option_line(option);
@ -75,7 +75,7 @@ void PreferencesDialog::build()
def.type = coBool;
def.tooltip = L("Suppress \" - default - \" presets in the Print / Filament / Printer "
"selections once there are any other valid presets available.");
def.default_value = new ConfigOptionBool{ app_config->get("no_defaults")[0] == '1' }; // 1;
def.default_value = new ConfigOptionBool{ app_config->get("no_defaults") == "1" };
option = Option (def,"no_defaults");
m_optgroup->append_single_option_line(option);
@ -83,7 +83,7 @@ void PreferencesDialog::build()
def.type = coBool;
def.tooltip = L("When checked, the print and filament presets are shown in the preset editor "
"even if they are marked as incompatible with the active printer");
def.default_value = new ConfigOptionBool{ app_config->get("show_incompatible_presets")[0] == '1' }; // 1;
def.default_value = new ConfigOptionBool{ app_config->get("show_incompatible_presets") == "1" };
option = Option (def,"show_incompatible_presets");
m_optgroup->append_single_option_line(option);
@ -93,7 +93,7 @@ void PreferencesDialog::build()
def.tooltip = L("If you have rendering issues caused by a buggy OpenGL 2.0 driver, "
"you may try to check this checkbox. This will disable the layer height "
"editing and anti aliasing, so it is likely better to upgrade your graphics driver.");
def.default_value = new ConfigOptionBool{ app_config->get("use_legacy_opengl")[0] == '1' }; // 1;
def.default_value = new ConfigOptionBool{ app_config->get("use_legacy_opengl") == "1" };
option = Option (def,"use_legacy_opengl");
m_optgroup->append_single_option_line(option);

View file

@ -49,6 +49,7 @@ Selection::VolumeCache::VolumeCache(const Geometry::Transformation& volume_trans
Selection::Selection()
: m_volumes(nullptr)
, m_model(nullptr)
, m_enabled(false)
, m_mode(Instance)
, m_type(Empty)
, m_valid(false)

View file

@ -154,6 +154,7 @@ private:
// Model, not owned.
Model* m_model;
bool m_enabled;
bool m_valid;
EMode m_mode;
EType m_type;
@ -180,6 +181,9 @@ public:
void set_volumes(GLVolumePtrs* volumes);
bool init(bool useVBOs);
bool is_enabled() const { return m_enabled; }
void set_enabled(bool enable) { m_enabled = enable; }
Model* get_model() const { return m_model; }
void set_model(Model* model);

View file

@ -1,4 +1,5 @@
// #include "libslic3r/GCodeSender.hpp"
#include "slic3r/Utils/Serial.hpp"
#include "Tab.hpp"
#include "PresetBundle.hpp"
#include "PresetHints.hpp"
@ -6,7 +7,6 @@
#include "slic3r/Utils/Http.hpp"
#include "slic3r/Utils/PrintHost.hpp"
#include "slic3r/Utils/Serial.hpp"
#include "BonjourDialog.hpp"
#include "WipeTowerDialog.hpp"
#include "ButtonsDescription.hpp"
@ -542,7 +542,10 @@ void Tab::update_changed_tree_ui()
auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item || !m_treectrl->IsVisible(cur_item))
return;
auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection());
auto selected_item = m_treectrl->GetSelection();
auto selection = selected_item ? m_treectrl->GetItemText(selected_item) : "";
while (cur_item) {
auto title = m_treectrl->GetItemText(cur_item);
for (auto page : m_pages)
@ -924,31 +927,26 @@ void Tab::update_frequently_changed_parameters()
auto og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(supports_printer_technology(ptFFF));
if (!og_freq_chng_params) return;
if (m_type == Preset::TYPE_SLA_PRINT)
{
for (auto opt_key : { "supports_enable", "pad_enable" })
{
boost::any val = og_freq_chng_params->get_config_value(*m_config, opt_key);
og_freq_chng_params->set_value(opt_key, val);
}
return;
}
const bool is_fff = supports_printer_technology(ptFFF);
// for m_type == Preset::TYPE_PRINT
boost::any value = og_freq_chng_params->get_config_value(*m_config, "fill_density");
og_freq_chng_params->set_value("fill_density", value);
const std::string support = is_fff ? "support_material" : "supports_enable";
const std::string buildplate_only = is_fff ? "support_material_buildplate_only" : "support_buildplate_only";
wxString new_selection = !m_config->opt_bool("support_material") ?
_("None") :
m_config->opt_bool("support_material_buildplate_only") ?
_("Support on build plate only") :
_("Everywhere");
wxString new_selection = !m_config->opt_bool(support) ? _("None") :
m_config->opt_bool(buildplate_only) ? _("Support on build plate only") :
_("Everywhere");
og_freq_chng_params->set_value("support", new_selection);
bool val = m_config->opt_float("brim_width") > 0.0 ? true : false;
og_freq_chng_params->set_value("brim", val);
const std::string updated_value_key = is_fff ? "fill_density" : "pad_enable";
update_wiping_button_visibility();
const boost::any val = og_freq_chng_params->get_config_value(*m_config, updated_value_key);
og_freq_chng_params->set_value(updated_value_key, val);
if (is_fff)
{
og_freq_chng_params->set_value("brim", bool(m_config->opt_float("brim_width") > 0.0));
update_wiping_button_visibility();
}
}
void TabPrint::build()
@ -2497,7 +2495,10 @@ void Tab::rebuild_page_tree()
if (!have_selection) {
// this is triggered on first load, so we don't disable the sel change event
m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem));
auto item = m_treectrl->GetFirstVisibleItem();
if (item) {
m_treectrl->SelectItem(item);
}
}
// Thaw();
}
@ -2524,7 +2525,10 @@ void Tab::update_page_tree_visibility()
if (!have_selection) {
// this is triggered on first load, so we don't disable the sel change event
m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem));
auto item = m_treectrl->GetFirstVisibleItem();
if (item) {
m_treectrl->SelectItem(item);
}
}
}

View file

@ -61,6 +61,24 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
return item;
}
wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, wxEvtHandler* event_handler)
{
if (id == wxID_ANY)
id = wxNewId();
wxMenuItem* item = menu->AppendRadioItem(id, string, description);
#ifdef __WXMSW__
if (event_handler != nullptr && event_handler != menu)
event_handler->Bind(wxEVT_MENU, cb, id);
else
#endif // __WXMSW__
menu->Bind(wxEVT_MENU, cb, id);
return item;
}
const unsigned int wxCheckListBoxComboPopup::DefaultWidth = 200;
const unsigned int wxCheckListBoxComboPopup::DefaultHeight = 200;
const unsigned int wxCheckListBoxComboPopup::DefaultItemHeight = 18;

View file

@ -25,7 +25,11 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "", wxEvtHandler* event_handler = nullptr);
wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxString& string, const wxString& description, const std::string& icon = "");
wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxString& string, const wxString& description,
const std::string& icon = "");
wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, wxEvtHandler* event_handler);
wxBitmap create_scaled_bitmap(const std::string& bmp_name);