mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Merge remote-tracking branch 'origin/master' into gui_translate_to_cpp
This commit is contained in:
commit
867e867cdd
80 changed files with 14632 additions and 2807 deletions
File diff suppressed because it is too large
Load diff
|
@ -7,12 +7,15 @@
|
|||
#include "../../libslic3r/TriangleMesh.hpp"
|
||||
#include "../../libslic3r/Utils.hpp"
|
||||
|
||||
class wxBitmap;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class Print;
|
||||
class PrintObject;
|
||||
class Model;
|
||||
class ModelObject;
|
||||
class GCodePreviewData;
|
||||
|
||||
// A container for interleaved arrays of 3D vertices and normals,
|
||||
// possibly indexed by triangles and / or quads.
|
||||
|
@ -106,6 +109,10 @@ public:
|
|||
push_geometry(float(x), float(y), float(z), float(nx), float(ny), float(nz));
|
||||
}
|
||||
|
||||
inline void push_geometry(const Pointf3& p, const Vectorf3& n) {
|
||||
push_geometry(p.x, p.y, p.z, n.x, n.y, n.z);
|
||||
}
|
||||
|
||||
inline void push_triangle(int idx1, int idx2, int idx3) {
|
||||
if (this->triangle_indices.size() + 3 > this->vertices_and_normals_interleaved.capacity())
|
||||
this->triangle_indices.reserve(next_highest_power_of_2(this->triangle_indices.size() + 3));
|
||||
|
@ -207,6 +214,7 @@ public:
|
|||
select_group_id(-1),
|
||||
drag_group_id(-1),
|
||||
selected(false),
|
||||
is_active(true),
|
||||
hover(false),
|
||||
tverts_range(0, size_t(-1)),
|
||||
qverts_range(0, size_t(-1))
|
||||
|
@ -243,6 +251,8 @@ public:
|
|||
int drag_group_id;
|
||||
// Is this object selected?
|
||||
bool selected;
|
||||
// Whether or not this volume is active for rendering
|
||||
bool is_active;
|
||||
// Boolean: Is mouse over this object?
|
||||
bool hover;
|
||||
|
||||
|
@ -258,6 +268,7 @@ public:
|
|||
// Offset into qverts & tverts, or offsets into indices stored into an OpenGL name_index_buffer.
|
||||
std::vector<size_t> offsets;
|
||||
|
||||
|
||||
int object_idx() const { return this->composite_id / 1000000; }
|
||||
int volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
||||
int instance_idx() const { return this->composite_id % 1000; }
|
||||
|
@ -299,6 +310,28 @@ public:
|
|||
|
||||
class GLVolumeCollection
|
||||
{
|
||||
public:
|
||||
struct RenderInterleavedOnlyVolumes
|
||||
{
|
||||
bool enabled;
|
||||
float alpha; // [0..1]
|
||||
|
||||
RenderInterleavedOnlyVolumes()
|
||||
: enabled(false)
|
||||
, alpha(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
RenderInterleavedOnlyVolumes(bool enabled, float alpha)
|
||||
: enabled(enabled)
|
||||
, alpha(alpha)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
RenderInterleavedOnlyVolumes _render_interleaved_only_volumes;
|
||||
|
||||
public:
|
||||
std::vector<GLVolume*> volumes;
|
||||
|
||||
|
@ -334,6 +367,8 @@ public:
|
|||
bool empty() const { return volumes.empty(); }
|
||||
void set_range(double low, double high) { for (GLVolume *vol : this->volumes) vol->set_range(low, high); }
|
||||
|
||||
void set_render_interleaved_only_volumes(const RenderInterleavedOnlyVolumes& render_interleaved_only_volumes) { _render_interleaved_only_volumes = render_interleaved_only_volumes; }
|
||||
|
||||
private:
|
||||
GLVolumeCollection(const GLVolumeCollection &other);
|
||||
GLVolumeCollection& operator=(const GLVolumeCollection &);
|
||||
|
@ -341,9 +376,86 @@ private:
|
|||
|
||||
class _3DScene
|
||||
{
|
||||
struct GCodePreviewVolumeIndex
|
||||
{
|
||||
enum EType
|
||||
{
|
||||
Extrusion,
|
||||
Travel,
|
||||
Retraction,
|
||||
Unretraction,
|
||||
Shell,
|
||||
Num_Geometry_Types
|
||||
};
|
||||
|
||||
struct FirstVolume
|
||||
{
|
||||
EType type;
|
||||
unsigned int flag;
|
||||
// Index of the first volume in a GLVolumeCollection.
|
||||
unsigned int id;
|
||||
|
||||
FirstVolume(EType type, unsigned int flag, unsigned int id) : type(type), flag(flag), id(id) {}
|
||||
};
|
||||
|
||||
std::vector<FirstVolume> first_volumes;
|
||||
|
||||
void reset() { first_volumes.clear(); }
|
||||
};
|
||||
|
||||
static GCodePreviewVolumeIndex s_gcode_preview_volume_index;
|
||||
|
||||
class LegendTexture
|
||||
{
|
||||
static const unsigned int Px_Title_Offset = 5;
|
||||
static const unsigned int Px_Text_Offset = 5;
|
||||
static const unsigned int Px_Square = 20;
|
||||
static const unsigned int Px_Square_Contour = 1;
|
||||
static const unsigned int Px_Border = Px_Square / 2;
|
||||
static const unsigned char Squares_Border_Color[3];
|
||||
static const unsigned char Background_Color[3];
|
||||
static const unsigned char Opacity;
|
||||
|
||||
unsigned int m_tex_id;
|
||||
unsigned int m_tex_width;
|
||||
unsigned int m_tex_height;
|
||||
|
||||
public:
|
||||
LegendTexture() : m_tex_id(0), m_tex_width(0), m_tex_height(0) {}
|
||||
~LegendTexture() { _destroy_texture(); }
|
||||
|
||||
// Generate a texture data, but don't load it into the GPU yet, as the glcontext may not be valid yet.
|
||||
bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||
// If not loaded, load the texture data into the GPU. Return a texture ID or 0 if the texture has zero size.
|
||||
unsigned int finalize();
|
||||
|
||||
unsigned int get_texture_id() const { return m_tex_id; }
|
||||
unsigned int get_texture_width() const { return m_tex_width; }
|
||||
unsigned int get_texture_height() const { return m_tex_height; }
|
||||
|
||||
void reset_texture() { _destroy_texture(); }
|
||||
|
||||
private:
|
||||
bool _create_texture(const GCodePreviewData& preview_data, const wxBitmap& bitmap);
|
||||
void _destroy_texture();
|
||||
// generate() fills in m_data with the pixels, while finalize() moves the data to the GPU before rendering.
|
||||
std::vector<unsigned char> m_data;
|
||||
};
|
||||
|
||||
static LegendTexture s_legend_texture;
|
||||
|
||||
public:
|
||||
static void _glew_init();
|
||||
|
||||
static void load_gcode_preview(const Print* print, const GCodePreviewData* preview_data, GLVolumeCollection* volumes, const std::vector<std::string>& str_tool_colors, bool use_VBOs);
|
||||
|
||||
static unsigned int get_legend_texture_id();
|
||||
static unsigned int get_legend_texture_width();
|
||||
static unsigned int get_legend_texture_height();
|
||||
|
||||
static void reset_legend_texture();
|
||||
static unsigned int finalize_legend_texture();
|
||||
|
||||
static void _load_print_toolpaths(
|
||||
const Print *print,
|
||||
GLVolumeCollection *volumes,
|
||||
|
@ -356,12 +468,30 @@ public:
|
|||
const std::vector<std::string> &tool_colors,
|
||||
bool use_VBOs);
|
||||
|
||||
|
||||
static void _load_wipe_tower_toolpaths(
|
||||
const Print *print,
|
||||
GLVolumeCollection *volumes,
|
||||
const std::vector<std::string> &tool_colors_str,
|
||||
bool use_VBOs);
|
||||
|
||||
private:
|
||||
// generates gcode extrusion paths geometry
|
||||
static void _load_gcode_extrusion_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
||||
// generates gcode travel paths geometry
|
||||
static void _load_gcode_travel_paths(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors, bool use_VBOs);
|
||||
static bool _travel_paths_by_type(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
|
||||
static bool _travel_paths_by_feedrate(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
|
||||
static bool _travel_paths_by_tool(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, const std::vector<float>& tool_colors);
|
||||
// generates gcode retractions geometry
|
||||
static void _load_gcode_retractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
|
||||
// generates gcode unretractions geometry
|
||||
static void _load_gcode_unretractions(const GCodePreviewData& preview_data, GLVolumeCollection& volumes, bool use_VBOs);
|
||||
// sets gcode geometry visibility according to user selection
|
||||
static void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data, GLVolumeCollection& volumes);
|
||||
// generates the legend texture in dependence of the current shown view type
|
||||
static void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
|
||||
// generates objects and wipe tower geometry
|
||||
static void _load_shells(const Print& print, GLVolumeCollection& volumes, bool use_VBOs);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
|
||||
#if __APPLE__
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#elif _WIN32
|
||||
|
@ -25,19 +28,22 @@
|
|||
|
||||
#include <wx/app.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/combo.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
#include "Tab.hpp"
|
||||
#include "TabIface.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include <wx/config.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/filename.h>
|
||||
#include "Utils.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
@ -473,4 +479,49 @@ wxApp* get_app(){
|
|||
return g_wxApp;
|
||||
}
|
||||
|
||||
void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value)
|
||||
{
|
||||
if (comboCtrl == nullptr)
|
||||
return;
|
||||
|
||||
wxCheckListBoxComboPopup* popup = new wxCheckListBoxComboPopup;
|
||||
if (popup != nullptr)
|
||||
{
|
||||
comboCtrl->SetPopupControl(popup);
|
||||
popup->SetStringValue(text);
|
||||
popup->Connect(wxID_ANY, wxEVT_CHECKLISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnCheckListBox), nullptr, popup);
|
||||
popup->Connect(wxID_ANY, wxEVT_LISTBOX, wxCommandEventHandler(wxCheckListBoxComboPopup::OnListBoxSelection), nullptr, popup);
|
||||
|
||||
std::vector<std::string> items_str;
|
||||
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
|
||||
|
||||
for (const std::string& item : items_str)
|
||||
{
|
||||
popup->Append(item);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < popup->GetCount(); ++i)
|
||||
{
|
||||
popup->Check(i, initial_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int combochecklist_get_flags(wxComboCtrl* comboCtrl)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
wxCheckListBoxComboPopup* popup = wxDynamicCast(comboCtrl->GetPopupControl(), wxCheckListBoxComboPopup);
|
||||
if (popup != nullptr)
|
||||
{
|
||||
for (unsigned int i = 0; i < popup->GetCount(); ++i)
|
||||
{
|
||||
if (popup->IsChecked(i))
|
||||
flags |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
@ -10,6 +10,7 @@ class wxFrame;
|
|||
class wxWindow;
|
||||
class wxMenuBar;
|
||||
class wxNotebook;
|
||||
class wxComboCtrl;
|
||||
class wxString;
|
||||
class wxArrayString;
|
||||
class wxArrayLong;
|
||||
|
@ -88,6 +89,16 @@ std::vector<Tab *>& get_tabs_list();
|
|||
bool checked_tab(Tab* tab);
|
||||
void delete_tab_from_list(Tab* tab);
|
||||
|
||||
} }
|
||||
// Creates a wxCheckListBoxComboPopup inside the given wxComboCtrl, filled with the given text and items.
|
||||
// Items are all initialized to the given value.
|
||||
// Items must be separated by '|', for example "Item1|Item2|Item3", and so on.
|
||||
void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string items, bool initial_value);
|
||||
|
||||
// Returns the current state of the items listed in the wxCheckListBoxComboPopup contained in the given wxComboCtrl,
|
||||
// encoded inside an int.
|
||||
int combochecklist_get_flags(wxComboCtrl* comboCtrl);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -280,8 +280,8 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
if (boost::iends_with(path, ".gcode") || boost::iends_with(path, ".g")) {
|
||||
DynamicPrintConfig config;
|
||||
config.apply(FullPrintConfig::defaults());
|
||||
config.load_from_gcode(path);
|
||||
Preset::normalize(config);
|
||||
config.load_from_gcode_file(path);
|
||||
Preset::normalize(config);
|
||||
load_config_file_config(path, true, std::move(config));
|
||||
return;
|
||||
}
|
||||
|
@ -320,6 +320,18 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
}
|
||||
}
|
||||
|
||||
void PresetBundle::load_config_string(const char* str, const char* source_filename)
|
||||
{
|
||||
if (str != nullptr)
|
||||
{
|
||||
DynamicPrintConfig config;
|
||||
config.apply(FullPrintConfig::defaults());
|
||||
config.load_from_gcode_string(str);
|
||||
Preset::normalize(config);
|
||||
load_config_file_config((source_filename == nullptr) ? "" : source_filename, true, std::move(config));
|
||||
}
|
||||
}
|
||||
|
||||
// Load a config file from a boost property_tree. This is a private method called from load_config_file.
|
||||
void PresetBundle::load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,11 @@ public:
|
|||
// If the file is loaded successfully, its print / filament / printer profiles will be activated.
|
||||
void load_config_file(const std::string &path);
|
||||
|
||||
// Load an external config source containing the print, filament and printer presets.
|
||||
// The given string must contain the full set of parameters (same as those exported to gcode).
|
||||
// If the string is parsed successfully, its print / filament / printer profiles will be activated.
|
||||
void load_config_string(const char* str, const char* source_filename = nullptr);
|
||||
|
||||
// Load a config bundle file, into presets and store the loaded presets into separate files
|
||||
// of the local configuration directory.
|
||||
// Load settings into the provided settings instance.
|
||||
|
|
|
@ -238,6 +238,9 @@ std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &pre
|
|||
bool thin_walls = print_config.opt_bool("thin_walls");
|
||||
float nozzle_diameter = float(printer_config.opt_float("nozzle_diameter", 0));
|
||||
|
||||
if (layer_height <= 0.f)
|
||||
return "Recommended object thin wall thickness: Not available due to invalid layer height.";
|
||||
|
||||
Flow external_perimeter_flow = Flow::new_from_config_width(
|
||||
frExternalPerimeter,
|
||||
*print_config.opt<ConfigOptionFloatOrPercent>("external_perimeter_extrusion_width"),
|
||||
|
|
68
xs/src/slic3r/GUI/wxExtensions.cpp
Normal file
68
xs/src/slic3r/GUI/wxExtensions.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
#include "wxExtensions.hpp"
|
||||
|
||||
const unsigned int wxCheckListBoxComboPopup::Height = 210;
|
||||
|
||||
bool wxCheckListBoxComboPopup::Create(wxWindow* parent)
|
||||
{
|
||||
return wxCheckListBox::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0));
|
||||
}
|
||||
|
||||
wxWindow* wxCheckListBoxComboPopup::GetControl()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void wxCheckListBoxComboPopup::SetStringValue(const wxString& value)
|
||||
{
|
||||
m_text = value;
|
||||
}
|
||||
|
||||
wxString wxCheckListBoxComboPopup::GetStringValue() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
wxSize wxCheckListBoxComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
|
||||
{
|
||||
// matches owner wxComboCtrl's width
|
||||
|
||||
wxComboCtrl* cmb = GetComboCtrl();
|
||||
if (cmb != nullptr)
|
||||
{
|
||||
wxSize size = GetComboCtrl()->GetSize();
|
||||
size.SetHeight(Height);
|
||||
return size;
|
||||
}
|
||||
else
|
||||
return wxSize(200, Height);
|
||||
}
|
||||
|
||||
void wxCheckListBoxComboPopup::OnCheckListBox(wxCommandEvent& evt)
|
||||
{
|
||||
// forwards the checklistbox event to the owner wxComboCtrl
|
||||
|
||||
wxComboCtrl* cmb = GetComboCtrl();
|
||||
if (cmb != nullptr)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, cmb->GetId());
|
||||
event.SetEventObject(cmb);
|
||||
cmb->ProcessWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void wxCheckListBoxComboPopup::OnListBoxSelection(wxCommandEvent& evt)
|
||||
{
|
||||
// transforms list box item selection event into checklistbox item toggle event
|
||||
|
||||
int selId = GetSelection();
|
||||
if (selId != wxNOT_FOUND)
|
||||
{
|
||||
Check((unsigned int)selId, !IsChecked((unsigned int)selId));
|
||||
SetSelection(wxNOT_FOUND);
|
||||
|
||||
wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
|
||||
event.SetInt(selId);
|
||||
event.SetEventObject(this);
|
||||
ProcessEvent(event);
|
||||
}
|
||||
}
|
24
xs/src/slic3r/GUI/wxExtensions.hpp
Normal file
24
xs/src/slic3r/GUI/wxExtensions.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef slic3r_GUI_wxExtensions_hpp_
|
||||
#define slic3r_GUI_wxExtensions_hpp_
|
||||
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/combo.h>
|
||||
|
||||
class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
|
||||
{
|
||||
static const unsigned int Height;
|
||||
|
||||
wxString m_text;
|
||||
|
||||
public:
|
||||
virtual bool Create(wxWindow* parent);
|
||||
virtual wxWindow* GetControl();
|
||||
virtual void SetStringValue(const wxString& value);
|
||||
virtual wxString GetStringValue() const;
|
||||
virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
|
||||
|
||||
void OnCheckListBox(wxCommandEvent& evt);
|
||||
void OnListBoxSelection(wxCommandEvent& evt);
|
||||
};
|
||||
|
||||
#endif // slic3r_GUI_wxExtensions_hpp_
|
Loading…
Add table
Add a link
Reference in a new issue