Merge branch 'et_gcode_viewer' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
enricoturri1966 2020-05-27 16:31:26 +02:00
commit 0e018e6690
110 changed files with 852 additions and 1379 deletions

View file

@ -95,8 +95,6 @@ set(SLIC3R_GUI_SOURCES
GUI/GUI_ObjectSettings.hpp
GUI/GUI_ObjectLayers.cpp
GUI/GUI_ObjectLayers.hpp
GUI/LambdaObjectDialog.cpp
GUI/LambdaObjectDialog.hpp
GUI/MeshUtils.cpp
GUI/MeshUtils.hpp
GUI/Tab.cpp

View file

@ -692,7 +692,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
glsafe(::glDisable(GL_BLEND));
}
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state)
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state)
{
if (config == nullptr)
return false;
@ -706,7 +706,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M
// Allow the objects to protrude below the print bed
print_volume.min(2) = -1e10;
ModelInstance::EPrintVolumeState state = ModelInstance::PVS_Inside;
ModelInstanceEPrintVolumeState state = ModelInstancePVS_Inside;
bool contained_min_one = false;
@ -725,11 +725,11 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M
if (contained)
contained_min_one = true;
if ((state == ModelInstance::PVS_Inside) && volume->is_outside)
state = ModelInstance::PVS_Fully_Outside;
if ((state == ModelInstancePVS_Inside) && volume->is_outside)
state = ModelInstancePVS_Fully_Outside;
if ((state == ModelInstance::PVS_Fully_Outside) && volume->is_outside && print_volume.intersects(bb))
state = ModelInstance::PVS_Partly_Outside;
if ((state == ModelInstancePVS_Fully_Outside) && volume->is_outside && print_volume.intersects(bb))
state = ModelInstancePVS_Partly_Outside;
}
if (out_state != nullptr)

View file

@ -6,7 +6,7 @@
#include "libslic3r/Line.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Geometry.hpp"
#include <functional>
@ -34,6 +34,9 @@ class ExtrusionMultiPath;
class ExtrusionLoop;
class ExtrusionEntity;
class ExtrusionEntityCollection;
class ModelObject;
class ModelVolume;
enum ModelInstanceEPrintVolumeState : unsigned char;
// A container for interleaved arrays of 3D vertices and normals,
// possibly indexed by triangles and / or quads.
@ -572,7 +575,7 @@ public:
// returns true if all the volumes are completely contained in the print volume
// returns the containment state in the given out_state, if non-null
bool check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state);
bool check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state);
void reset_outside_state();
void update_colors_by_extruder(const DynamicPrintConfig* config);

View file

@ -300,13 +300,13 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe
std::vector<std::string> AppConfig::get_mouse_device_names() const
{
static constexpr char *prefix = "mouse_device:";
static constexpr size_t prefix_len = 13; // strlen(prefix); reports error C2131: expression did not evaluate to a constant on VS2019
std::vector<std::string> out;
static constexpr const char *prefix = "mouse_device:";
static const size_t prefix_len = strlen(prefix);
std::vector<std::string> out;
for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
if (boost::starts_with(key_value_pair.first, "mouse_device:") && key_value_pair.first.size() > prefix_len)
if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
out.emplace_back(key_value_pair.first.substr(prefix_len));
return out;
return out;
}
void AppConfig::update_config_dir(const std::string &dir)

View file

@ -1,6 +1,7 @@
#include "BackgroundSlicingProcess.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "MainFrame.hpp"
#include <wx/app.h>
#include <wx/panel.h>
@ -36,6 +37,7 @@
#include "RemovableDriveManager.hpp"
#include "slic3r/Utils/Thread.hpp"
#include "slic3r/GUI/Plater.hpp"
namespace Slic3r {

View file

@ -5,15 +5,19 @@
#include <condition_variable>
#include <mutex>
#include <boost/filesystem/path.hpp>
#include <wx/event.h>
#include "libslic3r/Print.hpp"
#include "libslic3r/PrintBase.hpp"
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/Format/SL1.hpp"
#include "slic3r/Utils/PrintHost.hpp"
#if ENABLE_GCODE_VIEWER
#include "libslic3r/GCode/GCodeProcessor.hpp"
#endif // ENABLE_GCODE_VIEWER
namespace boost { namespace filesystem { class path; } }
namespace Slic3r {
class DynamicPrintConfig;
@ -22,7 +26,6 @@ class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
class Model;
class SLAPrint;
class SL1Archive;
class SlicingStatusEvent : public wxEvent
{
@ -92,7 +95,7 @@ public:
// Apply config over the print. Returns false, if the new config values caused any of the already
// processed steps to be invalidated, therefore the task will need to be restarted.
Print::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
// After calling the apply() function, set_task() may be called to limit the task to be processed by process().
// This is useful for calculating SLA supports for a single object only.
void set_task(const PrintBase::TaskParams &params);

View file

@ -1,4 +1,6 @@
#include "BedShapeDialog.hpp"
#include "GUI_App.hpp"
#include "OptionsGroup.hpp"
#include <wx/wx.h>
#include <wx/numformatter.h>

View file

@ -3,7 +3,7 @@
// The bed shape dialog.
// The dialog opens from Print Settins tab->Bed Shape : Set...
#include "OptionsGroup.hpp"
#include "GUI_Utils.hpp"
#include "2DBed.hpp"
#include "I18N.hpp"
@ -13,6 +13,8 @@
namespace Slic3r {
namespace GUI {
class ConfigOptionsGroup;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class BedShapePanel : public wxPanel
{

View file

@ -425,9 +425,6 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double
if ((dx <= 0.0) || (dy <= 0.0))
return -1.0f;
double med_x = 0.5 * (max_x + min_x);
double med_y = 0.5 * (max_y + min_y);
dx *= margin_factor;
dy *= margin_factor;

View file

@ -27,6 +27,7 @@
#include "libslic3r/Utils.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "GUI_Utils.hpp"
#include "slic3r/Config/Snapshot.hpp"
#include "slic3r/Utils/PresetUpdater.hpp"

View file

@ -24,6 +24,9 @@
#include "AppConfig.hpp"
#include "PresetBundle.hpp"
#include "BedShapeDialog.hpp"
#include "GUI.hpp"
#include "wxExtensions.hpp"
namespace fs = boost::filesystem;

View file

@ -8,6 +8,7 @@
#endif // ENABLE_GCODE_VIEWER
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "I18N.hpp"
#include "ExtruderSequenceDialog.hpp"
#include "libslic3r/Print.hpp"
@ -272,14 +273,14 @@ wxCoord Control::get_position_from_value(const int value)
return wxCoord(SLIDER_MARGIN + int(val*step + 0.5));
}
wxSize Control::get_size()
wxSize Control::get_size() const
{
int w, h;
get_size(&w, &h);
return wxSize(w, h);
}
void Control::get_size(int *w, int *h)
void Control::get_size(int* w, int* h) const
{
GetSize(w, h);
is_horizontal() ? *w -= m_lock_icon_dim : *h -= m_lock_icon_dim;
@ -574,11 +575,32 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, bool right_
dc.GetMultiLineTextExtent(label, &text_width, &text_height);
wxPoint text_pos;
if (right_side)
text_pos = is_horizontal() ? wxPoint(pos.x + 1, pos.y + m_thumb_size.x / 2 + 1) :
wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1);
{
if (is_horizontal())
{
int width;
int height;
get_size(&width, &height);
int x_right = pos.x + 1 + text_width;
int xx = (x_right < width) ? pos.x + 1 : pos.x - text_width - 1;
text_pos = wxPoint(xx, pos.y + m_thumb_size.x / 2 + 1);
}
else
text_pos = wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1);
}
else
text_pos = is_horizontal() ? wxPoint(pos.x - text_width - 1, pos.y - m_thumb_size.x / 2 - text_height - 1) :
wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1);
{
if (is_horizontal())
{
int x = pos.x - text_width - 1;
int xx = (x > 0) ? x : pos.x + 1;
text_pos = wxPoint(xx, pos.y - m_thumb_size.x / 2 - text_height - 1);
}
else
text_pos = wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1);
}
dc.DrawText(label, text_pos);
}
@ -1323,6 +1345,15 @@ void Control::move_current_thumb(const bool condition)
if (is_horizontal())
delta *= -1;
// accelerators
int accelerator = 0;
if (wxGetKeyState(WXK_SHIFT))
accelerator += 5;
if (wxGetKeyState(WXK_CONTROL))
accelerator += 5;
if (accelerator > 0)
delta *= accelerator;
if (m_selection == ssLower) {
m_lower_value -= delta;
correct_lower_value();
@ -1366,6 +1397,22 @@ void Control::OnWheel(wxMouseEvent& event)
void Control::OnKeyDown(wxKeyEvent &event)
{
const int key = event.GetKeyCode();
#if ENABLE_GCODE_VIEWER
if (m_draw_mode != dmSequentialGCodeView && key == WXK_NUMPAD_ADD) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of add_tick() twice.
// To avoid this case we should suppress second add_tick() call.
m_ticks.suppress_plus(true);
add_current_tick(true);
}
else if (m_draw_mode != dmSequentialGCodeView && (key == WXK_NUMPAD_SUBTRACT || key == WXK_DELETE || key == WXK_BACK)) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of delete_tick() twice.
// To avoid this case we should suppress second delete_tick() call.
m_ticks.suppress_minus(true);
delete_current_tick();
}
else if (m_draw_mode != dmSequentialGCodeView && event.GetKeyCode() == WXK_SHIFT)
UseDefaultColors(false);
#else
if (key == WXK_NUMPAD_ADD) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of add_tick() twice.
// To avoid this case we should suppress second add_tick() call.
@ -1380,6 +1427,7 @@ void Control::OnKeyDown(wxKeyEvent &event)
}
else if (event.GetKeyCode() == WXK_SHIFT)
UseDefaultColors(false);
#endif // ENABLE_GCODE_VIEWER
else if (is_horizontal())
{
#if ENABLE_GCODE_VIEWER
@ -1430,14 +1478,21 @@ void Control::OnKeyUp(wxKeyEvent &event)
void Control::OnChar(wxKeyEvent& event)
{
const int key = event.GetKeyCode();
if (key == '+' && !m_ticks.suppressed_plus()) {
add_current_tick(true);
m_ticks.suppress_plus(false);
}
else if (key == '-' && !m_ticks.suppressed_minus()) {
delete_current_tick();
m_ticks.suppress_minus(false);
#if ENABLE_GCODE_VIEWER
if (m_draw_mode != dmSequentialGCodeView)
{
#endif // ENABLE_GCODE_VIEWER
if (key == '+' && !m_ticks.suppressed_plus()) {
add_current_tick(true);
m_ticks.suppress_plus(false);
}
else if (key == '-' && !m_ticks.suppressed_minus()) {
delete_current_tick();
m_ticks.suppress_minus(false);
}
#if ENABLE_GCODE_VIEWER
}
#endif // ENABLE_GCODE_VIEWER
if (key == 'G')
#if ENABLE_GCODE_VIEWER
jump_to_value();

View file

@ -24,7 +24,7 @@ namespace DoubleSlider {
/* For exporting GCode in GCodeWriter is used XYZF_NUM(val) = PRECISION(val, 3) for XYZ values.
* So, let use same value as a permissible error for layer height.
*/
static double epsilon() { return 0.0011;}
constexpr double epsilon() { return 0.0011; }
// custom message the slider sends to its parent to notify a tick-change:
wxDECLARE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent);
@ -301,8 +301,8 @@ private:
int get_value_from_position(const wxCoord x, const wxCoord y);
int get_value_from_position(const wxPoint pos) { return get_value_from_position(pos.x, pos.y); }
wxCoord get_position_from_value(const int value);
wxSize get_size();
void get_size(int *w, int *h);
wxSize get_size() const;
void get_size(int* w, int* h) const;
double get_double_value(const SelectedSlider& selection);
wxString get_tooltip(int tick = -1);
int get_edited_tick_for_position(wxPoint pos, const std::string& gcode = ColorChangeCode);

View file

@ -3,6 +3,8 @@
#include "I18N.hpp"
#include "Field.hpp"
#include "wxExtensions.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include "libslic3r/PrintConfig.hpp"

View file

@ -5,6 +5,7 @@
#include "libslic3r/Print.hpp"
#include "libslic3r/Geometry.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "PresetBundle.hpp"
#include "Camera.hpp"
#include "I18N.hpp"

View file

@ -11,6 +11,7 @@
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Layer.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Technologies.hpp"
#include "libslic3r/Tesselate.hpp"
@ -24,6 +25,8 @@
#include "slic3r/GUI/OpenGLManager.hpp"
#include "slic3r/GUI/3DBed.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
@ -1679,7 +1682,7 @@ void GLCanvas3D::reset_volumes()
int GLCanvas3D::check_volumes_outside_state() const
{
ModelInstance::EPrintVolumeState state;
ModelInstanceEPrintVolumeState state;
m_volumes.check_outside_state(m_config, &state);
return (int)state;
}
@ -2609,15 +2612,15 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// checks for geometry outside the print volume to render it accordingly
if (!m_volumes.empty())
{
ModelInstance::EPrintVolumeState state;
ModelInstanceEPrintVolumeState state;
const bool contained_min_one = m_volumes.check_outside_state(m_config, &state);
_set_warning_texture(WarningTexture::ObjectClashed, state == ModelInstance::PVS_Partly_Outside);
_set_warning_texture(WarningTexture::ObjectOutside, state == ModelInstance::PVS_Fully_Outside);
_set_warning_texture(WarningTexture::ObjectClashed, state == ModelInstancePVS_Partly_Outside);
_set_warning_texture(WarningTexture::ObjectOutside, state == ModelInstancePVS_Fully_Outside);
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS,
contained_min_one && !m_model->objects.empty() && state != ModelInstance::PVS_Partly_Outside));
contained_min_one && !m_model->objects.empty() && state != ModelInstancePVS_Partly_Outside));
}
else
{

View file

@ -5,7 +5,6 @@
#include <memory>
#include <chrono>
#include "3DScene.hpp"
#include "GLToolbar.hpp"
#include "Event.hpp"
#include "Selection.hpp"
@ -18,6 +17,8 @@
#include "GCodeViewer.hpp"
#endif // ENABLE_GCODE_VIEWER
#include "libslic3r/Slicing.hpp"
#include <float.h>
#include <wx/timer.h>
@ -36,15 +37,18 @@ class wxGLContext;
namespace Slic3r {
class Bed3D;
struct Camera;
class BackgroundSlicingProcess;
#if !ENABLE_GCODE_VIEWER
class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
struct ThumbnailData;
struct SlicingParameters;
enum LayerHeightEditActionType : unsigned int;
class ModelObject;
class ModelInstance;
class PrintObject;
class Print;
class SLAPrint;
namespace CustomGCode { struct Item; }
namespace GUI {

View file

@ -3,6 +3,7 @@
#include "3DScene.hpp"
#include "GLCanvas3D.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include <GL/glew.h>

View file

@ -6,6 +6,7 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include <wx/event.h>
#include <wx/bitmap.h>

View file

@ -1,13 +1,11 @@
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "WipeTowerDialog.hpp"
#include <assert.h>
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/any.hpp>
#if __APPLE__
#import <IOKit/pwr_mgt/IOPMLib.h>
@ -18,22 +16,16 @@
#include "boost/nowide/convert.hpp"
#endif
#include <wx/display.h>
#include "wxExtensions.hpp"
#include "GUI_Preview.hpp"
#include "AboutDialog.hpp"
#include "AppConfig.hpp"
#include "ConfigWizard.hpp"
#include "PresetBundle.hpp"
#include "UpdateDialogs.hpp"
#include "MsgDialog.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Print.hpp"
#include "Tab.hpp"
#include "GUI_ObjectList.hpp"
namespace Slic3r { namespace GUI {
namespace Slic3r {
class AppConfig;
namespace GUI {
#if __APPLE__
IOPMAssertionID assertionID;

View file

@ -36,6 +36,9 @@
#include "GUI_Utils.hpp"
#include "AppConfig.hpp"
#include "PresetBundle.hpp"
#include "3DScene.hpp"
#include "MainFrame.hpp"
#include "Plater.hpp"
#include "../Utils/PresetUpdater.hpp"
#include "../Utils/PrintHost.hpp"

View file

@ -3,8 +3,7 @@
#include <memory>
#include <string>
#include "libslic3r/PrintConfig.hpp"
#include "MainFrame.hpp"
#include "Preset.hpp"
#include "ImGuiWrapper.hpp"
#include "ConfigWizard.hpp"
#include "OpenGLManager.hpp"
@ -30,11 +29,21 @@ class PresetBundle;
class PresetUpdater;
class ModelObject;
class PrintHostJobQueue;
class Model;
namespace GUI{
class RemovableDriveManager;
class OtherInstanceMessageHandler;
class MainFrame;
class Sidebar;
class ObjectManipulation;
class ObjectSettings;
class ObjectList;
class ObjectLayers;
class Plater;
enum FileType
{
FT_STL,

View file

@ -2,9 +2,11 @@
#include "GUI_ObjectList.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "PresetBundle.hpp"
#include "libslic3r/Model.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <boost/algorithm/string.hpp>

View file

@ -4,13 +4,13 @@
#include "GUI_ObjectLayers.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "Plater.hpp"
#include "OptionsGroup.hpp"
#include "PresetBundle.hpp"
#include "Tab.hpp"
#include "wxExtensions.hpp"
#include "libslic3r/Model.hpp"
#include "LambdaObjectDialog.hpp"
#include "GLCanvas3D.hpp"
#include "Selection.hpp"
@ -1781,6 +1781,22 @@ void ObjectList::append_menu_items_convert_unit(wxMenu* menu)
[](wxCommandEvent&) { wxGetApp().plater()->convert_unit(false); }, "", menu);
}
void ObjectList::append_menu_item_merge_to_multipart_object(wxMenu* menu)
{
menu->AppendSeparator();
append_menu_item(menu, wxID_ANY, _L("Merge"), _L("Merge objects to the one multipart object"),
[this](wxCommandEvent&) { merge(true); }, "", menu,
[this]() { return this->can_merge_to_multipart_object(); }, wxGetApp().plater());
}
void ObjectList::append_menu_item_merge_to_single_object(wxMenu* menu)
{
menu->AppendSeparator();
append_menu_item(menu, wxID_ANY, _L("Merge"), _L("Merge objects to the one single object"),
[this](wxCommandEvent&) { merge(false); }, "", menu,
[this]() { return this->can_merge_to_single_object(); }, wxGetApp().plater());
}
void ObjectList::create_object_popupmenu(wxMenu *menu)
{
#ifdef __WXOSX__
@ -1795,6 +1811,10 @@ void ObjectList::create_object_popupmenu(wxMenu *menu)
// Split object to parts
append_menu_item_split(menu);
// menu->AppendSeparator();
// Merge multipart object to the single object
// append_menu_item_merge_to_single_object(menu);
menu->AppendSeparator();
// Layers Editing for object
@ -2365,6 +2385,107 @@ void ObjectList::split()
changed_object(obj_idx);
}
void ObjectList::merge(bool to_multipart_object)
{
// merge selected objects to the multipart object
if (to_multipart_object)
{
std::vector<int> obj_idxs;
wxDataViewItemArray sels;
GetSelections(sels);
assert(!sels.IsEmpty());
for (wxDataViewItem item : sels) {
const ItemType type = m_objects_model->GetItemType(item);
assert(type & (itObject/* | itInstance*/));
obj_idxs.emplace_back(type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)));
}
std::sort(obj_idxs.begin(), obj_idxs.end());
obj_idxs.erase(std::unique(obj_idxs.begin(), obj_idxs.end()), obj_idxs.end());
if (obj_idxs.size() <= 1)
return;
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Merge"));
Model* model = (*m_objects)[0]->get_model();
ModelObject* new_object = model->add_object();
new_object->name = _u8L("Merged");
DynamicPrintConfig* new_config = &new_object->config;
const Vec3d& main_offset = (*m_objects)[0]->instances[0]->get_offset();
for (int obj_idx : obj_idxs)
{
ModelObject* object = (*m_objects)[obj_idx];
Vec3d offset = object->instances[0]->get_offset();
if (object->id() == (*m_objects)[0]->id())
new_object->add_instance(*object->instances[0]);
auto new_opt_keys = new_config->keys();
const DynamicPrintConfig& from_config = object->config;
auto opt_keys = from_config.keys();
// merge settings
for (auto& opt_key : opt_keys) {
if (find(new_opt_keys.begin(), new_opt_keys.end(), opt_key) == new_opt_keys.end()) {
const ConfigOption* option = from_config.option(opt_key);
if (!option) {
// if current option doesn't exist in prints.get_edited_preset(),
// get it from default config values
option = DynamicPrintConfig::new_from_defaults_keys({ opt_key })->option(opt_key);
}
new_config->set_key_value(opt_key, option->clone());
}
}
// merge volumes
for (const ModelVolume* volume : object->volumes) {
ModelVolume* new_volume = new_object->add_volume(*volume);
Vec3d vol_offset = offset - main_offset + new_volume->get_offset();
new_volume->set_offset(vol_offset);
}
// save extruder value if it was set
if (object->volumes.size() == 1 && find(opt_keys.begin(), opt_keys.end(), "extruder") != opt_keys.end()) {
ModelVolume* volume = new_object->volumes.back();
const ConfigOption* option = from_config.option("extruder");
if (option)
volume->config.set_key_value("extruder", option->clone());
}
// merge layers
for (const auto& range : object->layer_config_ranges)
new_object->layer_config_ranges.emplace(range);
}
// remove selected objects
remove();
// Add new object(merged) to the object_list
add_object_to_list(m_objects->size() - 1);
}
// merge all parts to the one single object
// all part's settings will be lost
else
{
wxDataViewItem item = GetSelection();
if (!item)
return;
const int obj_idx = m_objects_model->GetIdByItem(item);
if (obj_idx == -1)
return;
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Merge all parts to the one single object"));
ModelObject* model_object = (*m_objects)[obj_idx];
model_object->merge();
m_objects_model->DeleteVolumeChildren(item);
changed_object(obj_idx);
}
}
void ObjectList::layers_editing()
{
const Selection& selection = scene_selection();
@ -2490,6 +2611,31 @@ bool ObjectList::can_split_instances()
return selection.is_multiple_full_instance() || selection.is_single_full_instance();
}
bool ObjectList::can_merge_to_multipart_object() const
{
wxDataViewItemArray sels;
GetSelections(sels);
if (sels.IsEmpty())
return false;
// should be selected just objects
for (wxDataViewItem item : sels)
if (!(m_objects_model->GetItemType(item) & (itObject/* | itInstance*/)))
return false;
return true;
}
bool ObjectList::can_merge_to_single_object() const
{
int obj_idx = get_selected_obj_idx();
if (obj_idx < 0)
return false;
// selected object should be multipart
return (*m_objects)[obj_idx]->volumes.size() > 1;
}
// NO_PARAMETERS function call means that changed object index will be determine from Selection()
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
{
@ -4111,6 +4257,7 @@ void ObjectList::show_multi_selection_menu()
}, wxGetApp().plater());
append_menu_items_convert_unit(menu);
append_menu_item_merge_to_multipart_object(menu);
wxGetApp().plater()->PopupMenu(menu);
}

View file

@ -254,6 +254,8 @@ public:
void append_menu_item_delete(wxMenu* menu);
void append_menu_item_scale_selection_to_fit_print_volume(wxMenu* menu);
void append_menu_items_convert_unit(wxMenu* menu);
void append_menu_item_merge_to_multipart_object(wxMenu *menu);
void append_menu_item_merge_to_single_object(wxMenu *menu);
void create_object_popupmenu(wxMenu *menu);
void create_sla_object_popupmenu(wxMenu*menu);
void create_part_popupmenu(wxMenu*menu);
@ -277,6 +279,7 @@ public:
void del_layers_from_object(const int obj_idx);
bool del_subobject_from_object(const int obj_idx, const int idx, const int type);
void split();
void merge(bool to_multipart_object);
void layers_editing();
wxDataViewItem add_layer_root_item(const wxDataViewItem obj_item);
@ -287,6 +290,8 @@ public:
bool is_splittable();
bool selected_instances_of_same_object();
bool can_split_instances();
bool can_merge_to_multipart_object() const;
bool can_merge_to_single_object() const;
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
wxBoxSizer* get_sizer() {return m_sizer;}

View file

@ -2,12 +2,16 @@
#include "GUI_ObjectList.hpp"
#include "I18N.hpp"
#include "GLCanvas3D.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "wxExtensions.hpp"
#include "PresetBundle.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Geometry.hpp"
#include "Selection.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include <boost/algorithm/string.hpp>
#include "slic3r/Utils/FixModelByWin10.hpp"

View file

@ -4,7 +4,8 @@
#include <memory>
#include "GUI_ObjectSettings.hpp"
#include "GLCanvas3D.hpp"
#include "libslic3r/Point.hpp"
#include <float.h>
class wxBitmapComboBox;
class wxStaticText;

View file

@ -2,8 +2,10 @@
#include "GUI_ObjectList.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "wxExtensions.hpp"
#include "PresetBundle.hpp"
#include "Plater.hpp"
#include "libslic3r/Model.hpp"
#include <boost/algorithm/string.hpp>

View file

@ -6,13 +6,13 @@
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "I18N.hpp"
#include "AppConfig.hpp"
#include "3DScene.hpp"
#include "BackgroundSlicingProcess.hpp"
#include "OpenGLManager.hpp"
#include "GLCanvas3D.hpp"
#include "PresetBundle.hpp"
#include "DoubleSlider.hpp"
#include "Plater.hpp"
#include <wx/notebook.h>
#include <wx/glcanvas.h>

View file

@ -2,10 +2,11 @@
#define slic3r_GUI_Preview_hpp_
#include <wx/panel.h>
#include "libslic3r/Point.hpp"
#include "libslic3r/CustomGCode.hpp"
#include <string>
#include "libslic3r/Model.hpp"
#if ENABLE_GCODE_VIEWER
#include "libslic3r/GCode/GCodeProcessor.hpp"
#endif // ENABLE_GCODE_VIEWER

View file

@ -4,14 +4,9 @@
#include <GL/glew.h>
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
// TODO: Display tooltips quicker on Linux
namespace Slic3r {
namespace GUI {

View file

@ -4,7 +4,6 @@
#include "libslic3r/Point.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/Selection.hpp"
#include <cereal/archives/binary.hpp>
@ -31,9 +30,9 @@ static const float CONSTRAINED_COLOR[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
class ImGuiWrapper;
class GLCanvas3D;
class ClippingPlane;
enum class CommonGizmosDataID;
class CommonGizmosDataPool;
class Selection;
class GLGizmoBase
{

View file

@ -12,6 +12,7 @@
#include <algorithm>
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
namespace Slic3r {

View file

@ -8,6 +8,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "libslic3r/Model.hpp"

View file

@ -5,6 +5,8 @@
#include "slic3r/GUI/3DScene.hpp"
#include "libslic3r/ObjectID.hpp"
#include <cereal/types/vector.hpp>
@ -15,6 +17,7 @@ enum class FacetSupportType : int8_t;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;
class ClippingPlane;
class GLGizmoFdmSupports : public GLGizmoBase
{

View file

@ -3,6 +3,8 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "libslic3r/Model.hpp"
#include <numeric>
#include <GL/glew.h>

View file

@ -2,9 +2,14 @@
#define slic3r_GLGizmoFlatten_hpp_
#include "GLGizmoBase.hpp"
#include "slic3r/GUI/3DScene.hpp"
namespace Slic3r {
enum class ModelVolumeType : int;
namespace GUI {

View file

@ -11,6 +11,8 @@
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "libslic3r/Model.hpp"
namespace Slic3r {
namespace GUI {

View file

@ -5,12 +5,17 @@
#include "slic3r/GUI/GLSelectionRectangle.hpp"
#include <libslic3r/SLA/Hollowing.hpp>
#include <libslic3r/ObjectID.hpp>
#include <wx/dialog.h>
#include <cereal/types/vector.hpp>
namespace Slic3r {
class ConfigOption;
class ConfigOptionDef;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;

View file

@ -26,7 +26,6 @@ std::string GLGizmoScale3D::get_tooltip() const
bool single_instance = selection.is_single_full_instance();
bool single_volume = selection.is_single_modifier() || selection.is_single_volume();
bool single_selection = single_instance || single_volume;
Vec3f scale = 100.0f * Vec3f::Ones();
if (single_instance)

View file

@ -3,6 +3,8 @@
#include "GLGizmoBase.hpp"
#include "libslic3r/BoundingBox.hpp"
namespace Slic3r {
namespace GUI {

View file

@ -3,6 +3,7 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include <GL/glew.h>

View file

@ -4,13 +4,17 @@
#include "GLGizmoBase.hpp"
#include "slic3r/GUI/GLSelectionRectangle.hpp"
#include "libslic3r/SLA/Common.hpp"
#include "libslic3r/SLA/SupportPoint.hpp"
#include "libslic3r/ObjectID.hpp"
#include <wx/dialog.h>
#include <cereal/types/vector.hpp>
namespace Slic3r {
class ConfigOption;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;

View file

@ -6,6 +6,7 @@
#include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include <GL/glew.h>

View file

@ -6,6 +6,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoMove.hpp"
@ -17,6 +18,8 @@
#include "slic3r/GUI/Gizmos/GLGizmoCut.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoHollow.hpp"
#include "libslic3r/Model.hpp"
#include <wx/glcanvas.h>
namespace Slic3r {

View file

@ -6,6 +6,8 @@
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "libslic3r/ObjectID.hpp"
#include <map>
namespace Slic3r {

View file

@ -1,5 +1,10 @@
#include "GUI_App.hpp"
#include "InstanceCheck.hpp"
#include "Plater.hpp"
#ifdef _WIN32
#include "MainFrame.hpp"
#endif
#include "libslic3r/Utils.hpp"
#include "libslic3r/Config.hpp"

View file

@ -1,6 +1,7 @@
#include "ArrangeJob.hpp"
#include "libslic3r/MTUtils.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"

View file

@ -3,6 +3,7 @@
#include "libslic3r/MTUtils.hpp"
#include "libslic3r/SLA/Rotfinder.hpp"
#include "libslic3r/MinAreaBoundingBox.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/Plater.hpp"

View file

@ -8,6 +8,8 @@
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/Utils/SLAImport.hpp"
#include "libslic3r/Model.hpp"
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/combobox.h>

View file

@ -25,15 +25,6 @@
#include <wx/choicebk.h>
#endif // BOOK_TYPE
#if ENABLE_SCROLLABLE
static wxSize get_screen_size(wxWindow* window)
{
const auto idx = wxDisplay::GetFromWindow(window);
wxDisplay display(idx != wxNOT_FOUND ? idx : 0u);
return display.GetClientArea().GetSize();
}
#endif // ENABLE_SCROLLABLE
namespace Slic3r {
namespace GUI {

View file

@ -1,200 +0,0 @@
#include "LambdaObjectDialog.hpp"
#include <wx/window.h>
#include <wx/button.h>
#include "OptionsGroup.hpp"
#include "I18N.hpp"
namespace Slic3r
{
namespace GUI
{
LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent,
const wxString type_name):
m_type_name(type_name)
{
Create(parent, wxID_ANY, _(L("Lambda Object")),
parent->GetScreenPosition(), wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
// instead of double dim[3] = { 1.0, 1.0, 1.0 };
object_parameters.dim[0] = 1.0;
object_parameters.dim[1] = 1.0;
object_parameters.dim[2] = 1.0;
sizer = new wxBoxSizer(wxVERTICAL);
// modificator options
if (m_type_name == wxEmptyString) {
m_modificator_options_book = new wxChoicebook( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxCHB_TOP);
sizer->Add(m_modificator_options_book, 1, wxEXPAND | wxALL, 10);
}
else {
m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
sizer->Add(m_panel, 1, wxEXPAND | wxALL, 10);
}
ConfigOptionDef def;
def.width = 70;
auto optgroup = init_modificator_options_page(_(L("Box")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
int opt_id = opt_key == "l" ? 0 :
opt_key == "w" ? 1 :
opt_key == "h" ? 2 : -1;
if (opt_id < 0) return;
object_parameters.dim[opt_id] = boost::any_cast<double>(value);
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Length");
Option option(def, "l");
optgroup->append_single_option_line(option);
def.label = L("Width");
option = Option(def, "w");
optgroup->append_single_option_line(option);
def.label = L("Height");
option = Option(def, "h");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Cylinder")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
int val = boost::any_cast<int>(value);
if (opt_key == "cyl_r")
object_parameters.cyl_r = val;
else if (opt_key == "cyl_h")
object_parameters.cyl_h = val;
else return;
};
def.type = coInt;
def.set_default_value(new ConfigOptionInt{ 1 });
def.label = L("Radius");
auto option = Option(def, "cyl_r");
optgroup->append_single_option_line(option);
def.label = L("Height");
option = Option(def, "cyl_h");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Sphere")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if (opt_key == "sph_rho")
object_parameters.sph_rho = boost::any_cast<double>(value);
else return;
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Rho");
auto option = Option(def, "sph_rho");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Slab")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
double val = boost::any_cast<double>(value);
if (opt_key == "slab_z")
object_parameters.slab_z = val;
else if (opt_key == "slab_h")
object_parameters.slab_h = val;
else return;
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Height");
auto option = Option(def, "slab_h");
optgroup->append_single_option_line(option);
def.label = L("Initial Z");
option = Option(def, "slab_z");
optgroup->append_single_option_line(option);
}
Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e)
{
auto page_idx = m_modificator_options_book->GetSelection();
if (page_idx < 0) return;
switch (page_idx)
{
case 0:
object_parameters.type = LambdaTypeBox;
break;
case 1:
object_parameters.type = LambdaTypeCylinder;
break;
case 2:
object_parameters.type = LambdaTypeSphere;
break;
case 3:
object_parameters.type = LambdaTypeSlab;
break;
default:
break;
}
}));
const auto button_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
wxButton* btn_OK = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
btn_OK->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
// validate user input
if (!CanClose())return;
EndModal(wxID_OK);
Destroy();
});
wxButton* btn_CANCEL = static_cast<wxButton*>(FindWindowById(wxID_CANCEL, this));
btn_CANCEL->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
// validate user input
if (!CanClose())return;
EndModal(wxID_CANCEL);
Destroy();
});
sizer->Add(button_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
SetSizer(sizer);
sizer->Fit(this);
sizer->SetSizeHints(this);
}
// Called from the constructor.
// Create a panel for a rectangular / circular / custom bed shape.
ConfigOptionsGroupShp LambdaObjectDialog::init_modificator_options_page(const wxString& title)
{
if (!m_type_name.IsEmpty() && m_type_name != title)
return nullptr;
auto panel = m_type_name.IsEmpty() ? new wxPanel(m_modificator_options_book) : m_panel;
ConfigOptionsGroupShp optgroup;
optgroup = std::make_shared<ConfigOptionsGroup>(panel, _(L("Add")) + " " +title + " " +dots);
optgroup->label_width = 100;
m_optgroups.push_back(optgroup);
if (m_type_name.IsEmpty()) {
panel->SetSizerAndFit(optgroup->sizer);
m_modificator_options_book->AddPage(panel, title);
}
else
panel->SetSizer(optgroup->sizer);
return optgroup;
}
} //namespace GUI
} //namespace Slic3r

View file

@ -1,59 +0,0 @@
#ifndef slic3r_LambdaObjectDialog_hpp_
#define slic3r_LambdaObjectDialog_hpp_
#include <vector>
#include <memory>
#include <wx/dialog.h>
#include <wx/sizer.h>
#include <wx/choicebk.h>
class wxPanel;
namespace Slic3r
{
namespace GUI
{
enum LambdaTypeIDs{
LambdaTypeBox,
LambdaTypeCylinder,
LambdaTypeSphere,
LambdaTypeSlab
};
struct OBJECT_PARAMETERS
{
LambdaTypeIDs type = LambdaTypeBox;
double dim[3];// = { 1.0, 1.0, 1.0 };
int cyl_r = 1;
int cyl_h = 1;
double sph_rho = 1.0;
double slab_h = 1.0;
double slab_z = 0.0;
};
class ConfigOptionsGroup;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class LambdaObjectDialog : public wxDialog
{
wxChoicebook* m_modificator_options_book = nullptr;
std::vector <ConfigOptionsGroupShp> m_optgroups;
wxString m_type_name;
wxPanel* m_panel = nullptr;
public:
LambdaObjectDialog(wxWindow* parent,
const wxString type_name = wxEmptyString);
~LambdaObjectDialog() {}
bool CanClose() { return true; } // ???
OBJECT_PARAMETERS& ObjectParameters() { return object_parameters; }
ConfigOptionsGroupShp init_modificator_options_page(const wxString& title);
// Note whether the window was already closed, so a pending update is not executed.
bool m_already_closed = false;
OBJECT_PARAMETERS object_parameters;
wxBoxSizer* sizer = nullptr;
};
} //namespace GUI
} //namespace Slic3r
#endif //slic3r_LambdaObjectDialog_hpp_

View file

@ -29,6 +29,7 @@
#include "InstanceCheck.hpp"
#include "I18N.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <fstream>
#include "GUI_App.hpp"

View file

@ -12,7 +12,6 @@
#include <map>
#include "GUI_Utils.hpp"
#include "Plater.hpp"
#include "Event.hpp"
class wxNotebook;
@ -27,6 +26,8 @@ namespace GUI
class Tab;
class PrintHostQueueDialog;
class Plater;
class MainFrame;
enum QuickSlice
{

View file

@ -104,8 +104,8 @@ private:
// whether certain points are visible or obscured by the mesh etc.
class MeshRaycaster {
public:
// The class makes a copy of the mesh as EigenMesh3D.
// The pointer can be invalidated after constructor returns.
// The class references extern TriangleMesh, which must stay alive
// during MeshRaycaster existence.
MeshRaycaster(const TriangleMesh& mesh)
: m_emesh(mesh)
{

View file

@ -6,6 +6,7 @@
#include "PresetBundle.hpp"
#include "AppConfig.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <wx/glcanvas.h>

View file

@ -1,5 +1,7 @@
#include "OptionsGroup.hpp"
#include "ConfigExceptions.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include <utility>
#include <wx/numformatter.h>
@ -100,6 +102,36 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
return field;
}
OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
bool is_tab_opt /* = false */,
column_t extra_clmn /* = nullptr */) :
m_parent(_parent), title(title),
m_show_modified_btns(is_tab_opt),
staticbox(title!=""), extra_column(extra_clmn)
{
if (staticbox) {
stb = new wxStaticBox(_parent, wxID_ANY, _(title));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
} else
stb = nullptr;
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
auto num_columns = 1U;
if (label_width != 0) num_columns++;
if (extra_column != nullptr) num_columns++;
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 );
#if 0//#ifdef __WXGTK__
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sizer->Fit(m_panel);
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#else
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#endif /* __WXGTK__ */
}
void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& field)
{
if (!m_show_modified_btns) {

View file

@ -11,7 +11,6 @@
#include "libslic3r/PrintConfig.hpp"
#include "Field.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
// Translate the ifdef
@ -171,32 +170,7 @@ public:
}
OptionsGroup( wxWindow* _parent, const wxString& title, bool is_tab_opt = false,
column_t extra_clmn = nullptr) :
m_parent(_parent), title(title),
m_show_modified_btns(is_tab_opt),
staticbox(title!=""), extra_column(extra_clmn) {
if (staticbox) {
stb = new wxStaticBox(_parent, wxID_ANY, _(title));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
} else
stb = nullptr;
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
auto num_columns = 1U;
if (label_width != 0) num_columns++;
if (extra_column != nullptr) num_columns++;
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 );
#if 0//#ifdef __WXGTK__
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sizer->Fit(m_panel);
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#else
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#endif /* __WXGTK__ */
}
column_t extra_clmn = nullptr);
wxGridSizer* get_grid_sizer() { return m_grid_sizer; }

View file

@ -2320,9 +2320,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
if (imperial_units)
convert_from_imperial_units(model);
else if (model.looks_like_imperial_units()) {
wxMessageDialog msg_dlg(q, _L(
"This model looks like saved in inches.\n"
"Should I consider this model as a saved in inches and convert it?") + "\n",
wxMessageDialog msg_dlg(q, format_wxstr(_L(
"Some object(s) in file %s looks like saved in inches.\n"
"Should I consider them as a saved in inches and convert them?"), from_path(filename)) + "\n",
_L("Saved in inches object detected"), wxICON_WARNING | wxYES | wxNO);
if (msg_dlg.ShowModal() == wxID_YES)
convert_from_imperial_units(model);
@ -2649,7 +2649,7 @@ void Plater::priv::object_list_changed()
{
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
// XXX: is this right?
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstance::PVS_Inside;
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstancePVS_Inside;
sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits);
}
@ -3345,7 +3345,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
// see: Plater::priv::object_list_changed()
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
bool export_in_progress = this->background_process.is_export_scheduled();
bool model_fits = view3D->check_volumes_outside_state() != ModelInstance::PVS_Partly_Outside;
bool model_fits = view3D->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
if (!model.objects.empty() && !export_in_progress && model_fits)
this->q->reslice();
// keeps current gcode preview, if any

View file

@ -25,10 +25,13 @@ namespace Slic3r {
class Model;
class ModelObject;
class ModelInstance;
class Print;
class SLAPrint;
enum SLAPrintObjectStep : unsigned int;
using ModelInstancePtrs = std::vector<ModelInstance*>;
namespace UndoRedo {
class Stack;
struct Snapshot;

View file

@ -1,6 +1,7 @@
#include "Preferences.hpp"
#include "AppConfig.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
namespace Slic3r {
@ -364,4 +365,4 @@ void PreferencesDialog::create_settings_mode_widget()
} // GUI
} // Slic3r
} // Slic3r

View file

@ -962,7 +962,7 @@ void PresetCollection::load_bitmap_add(const std::string &file_name)
const Preset* PresetCollection::get_selected_preset_parent() const
{
if (this->get_selected_idx() == -1)
if (this->get_selected_idx() == size_t(-1))
// This preset collection has no preset activated yet. Only the get_edited_preset() is valid.
return nullptr;

View file

@ -296,9 +296,8 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund
double bottom_solid_min_thickness = print_config.opt_float("bottom_solid_min_thickness");
double layer_height = print_config.opt_float("layer_height");
bool variable_layer_height = printer_config.opt_bool("variable_layer_height");
//FIXME the following lines take into account the 1st extruder only.
//FIXME the following line takes into account the 1st extruder only.
double min_layer_height = variable_layer_height ? Slicing::min_layer_height_from_nozzle(printer_config, 1) : layer_height;
double max_layer_height = variable_layer_height ? Slicing::max_layer_height_from_nozzle(printer_config, 1) : layer_height;
if (layer_height <= 0.f) {
out += _utf8(L("Top / bottom shell thickness hint: Not available due to invalid layer height."));

View file

@ -10,6 +10,7 @@
#include "libslic3r/PrintConfig.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "Tab.hpp"
#include "PresetBundle.hpp"

View file

@ -228,11 +228,11 @@ public:
// implementation of base class virtuals to define model
virtual unsigned int GetColumnCount() const wxOVERRIDE { return colMax; }
virtual wxString GetColumnType(unsigned int col) const wxOVERRIDE;
virtual void GetValueByRow(wxVariant& variant, unsigned int row, unsigned int col) const wxOVERRIDE;
virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr& attr) const wxOVERRIDE { return true; }
virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, unsigned int col) wxOVERRIDE { return false; }
virtual unsigned int GetColumnCount() const override { return colMax; }
virtual wxString GetColumnType(unsigned int col) const override;
virtual void GetValueByRow(wxVariant& variant, unsigned int row, unsigned int col) const override;
virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr& attr) const override { return true; }
virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, unsigned int col) override { return false; }
};

View file

@ -1,14 +1,17 @@
#include "libslic3r/libslic3r.h"
#include "Selection.hpp"
#include "3DScene.hpp"
#include "GLCanvas3D.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "GUI_ObjectManipulation.hpp"
#include "GUI_ObjectList.hpp"
#include "Gizmos/GLGizmoBase.hpp"
#include "3DScene.hpp"
#include "Camera.hpp"
#include "Plater.hpp"
#include "libslic3r/Model.hpp"
#include <GL/glew.h>
@ -57,7 +60,7 @@ bool Selection::Clipboard::is_sla_compliant() const
if (m_mode == Selection::Volume)
return false;
for (const ModelObject* o : m_model.objects)
for (const ModelObject* o : m_model->objects)
{
if (o->is_multiparts())
return false;
@ -72,6 +75,35 @@ bool Selection::Clipboard::is_sla_compliant() const
return true;
}
Selection::Clipboard::Clipboard()
{
m_model.reset(new Model);
}
void Selection::Clipboard::reset() {
m_model->clear_objects();
}
bool Selection::Clipboard::is_empty() const
{
return m_model->objects.empty();
}
ModelObject* Selection::Clipboard::add_object()
{
return m_model->add_object();
}
ModelObject* Selection::Clipboard::get_object(unsigned int id)
{
return (id < (unsigned int)m_model->objects.size()) ? m_model->objects[id] : nullptr;
}
const ModelObjectPtrs& Selection::Clipboard::get_objects() const
{
return m_model->objects;
}
Selection::Selection()
: m_volumes(nullptr)
, m_model(nullptr)
@ -79,11 +111,13 @@ Selection::Selection()
, m_mode(Instance)
, m_type(Empty)
, m_valid(false)
#if !ENABLE_GCODE_VIEWER
, m_curved_arrow(16)
#endif // !ENABLE_GCODE_VIEWER
, m_scale_factor(1.0f)
{
#if !ENABLE_GCODE_VIEWER
m_arrow.reset(new GLArrow);
m_curved_arrow.reset(new GLCurvedArrow(16));
#endif // !ENABLE_GCODE_VIEWER
this->set_bounding_boxes_dirty();
#if ENABLE_RENDER_SELECTION_CENTER
m_quadric = ::gluNewQuadric();
@ -113,17 +147,16 @@ bool Selection::init()
m_arrow.init_from(straight_arrow(10.0f, 5.0f, 5.0f, 10.0f, 1.0f));
m_curved_arrow.init_from(circular_arrow(16, 10.0f, 5.0f, 10.0f, 5.0f, 1.0f));
#else
if (!m_arrow.init())
if (!m_arrow->init())
return false;
m_arrow.set_scale(5.0 * Vec3d::Ones());
m_arrow->set_scale(5.0 * Vec3d::Ones());
if (!m_curved_arrow.init())
if (!m_curved_arrow->init())
return false;
m_curved_arrow.set_scale(5.0 * Vec3d::Ones());
m_curved_arrow->set_scale(5.0 * Vec3d::Ones());
#endif //ENABLE_GCODE_VIEWER
return true;
}
@ -1959,17 +1992,23 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
shader->set_uniform("uniform_color", AXES_COLOR[axis], 4);
};
auto render_sidebar_rotation_hint = [this]() {
m_curved_arrow.render();
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_curved_arrow.render();
};
if (boost::ends_with(sidebar_field, "x")) {
set_color(X);
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
render_sidebar_rotation_hint(X);
render_sidebar_rotation_hint();
} else if (boost::ends_with(sidebar_field, "y")) {
set_color(Y);
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
render_sidebar_rotation_hint(Y);
render_sidebar_rotation_hint();
} else if (boost::ends_with(sidebar_field, "z")) {
set_color(Z);
render_sidebar_rotation_hint(Z);
render_sidebar_rotation_hint();
}
}
#else
@ -1994,6 +2033,19 @@ void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) con
{
bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", uniform_scale ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis], 4);
glsafe(::glTranslated(0.0, 5.0, 0.0));
m_arrow.render();
glsafe(::glTranslated(0.0, -10.0, 0.0));
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_arrow.render();
};
if (boost::ends_with(sidebar_field, "x") || uniform_scale)
{
glsafe(::glPushMatrix());
@ -2093,38 +2145,31 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
#if !ENABLE_GCODE_VIEWER
void Selection::render_sidebar_position_hint(Axis axis) const
{
m_arrow.set_color(AXES_COLOR[axis], 3);
m_arrow.render();
m_arrow->set_color(AXES_COLOR[axis], 3);
m_arrow->render();
}
#endif // !ENABLE_GCODE_VIEWER
void Selection::render_sidebar_rotation_hint(Axis axis) const
{
#if !ENABLE_GCODE_VIEWER
m_curved_arrow.set_color(AXES_COLOR[axis], 3);
#endif // !ENABLE_GCODE_VIEWER
m_curved_arrow.render();
m_curved_arrow->set_color(AXES_COLOR[axis], 3);
m_curved_arrow->render();
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_curved_arrow.render();
m_curved_arrow->render();
}
void Selection::render_sidebar_scale_hint(Axis axis) const
{
#if ENABLE_GCODE_VIEWER
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", (requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis], 4);
#else
m_arrow.set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
#endif // ENABLE_GCODE_VIEWER
m_arrow->set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
glsafe(::glTranslated(0.0, 5.0, 0.0));
m_arrow.render();
m_arrow->render();
glsafe(::glTranslated(0.0, -10.0, 0.0));
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_arrow.render();
m_arrow->render();
}
#endif // !ENABLE_GCODE_VIEWER
#ifndef NDEBUG
static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)

View file

@ -3,7 +3,6 @@
#include <set>
#include "libslic3r/Geometry.hpp"
#include "3DScene.hpp"
#if ENABLE_GCODE_VIEWER
#include "GLModel.hpp"
#endif // ENABLE_GCODE_VIEWER
@ -14,10 +13,20 @@ typedef class GLUquadric GLUquadricObj;
#endif // ENABLE_RENDER_SELECTION_CENTER
namespace Slic3r {
#if !ENABLE_GCODE_VIEWER
class Shader;
#endif // !ENABLE_GCODE_VIEWER
class Model;
class ModelObject;
class GLVolume;
class GLArrow;
class GLCurvedArrow;
class DynamicPrintConfig;
class GLShaderProgram;
using GLVolumePtrs = std::vector<GLVolume*>;
using ModelObjectPtrs = std::vector<ModelObject*>;
namespace GUI {
class TransformationType
{
@ -151,18 +160,23 @@ public:
class Clipboard
{
Model m_model;
// Model is stored through a pointer to avoid including heavy Model.hpp.
// It is created in constructor.
std::unique_ptr<Model> m_model;
Selection::EMode m_mode;
public:
void reset() { m_model.clear_objects(); }
bool is_empty() const { return m_model.objects.empty(); }
Clipboard();
void reset();
bool is_empty() const;
bool is_sla_compliant() const;
ModelObject* add_object() { return m_model.add_object(); }
ModelObject* get_object(unsigned int id) { return (id < (unsigned int)m_model.objects.size()) ? m_model.objects[id] : nullptr; }
const ModelObjectPtrs& get_objects() const { return m_model.objects; }
ModelObject* add_object();
ModelObject* get_object(unsigned int id);
const ModelObjectPtrs& get_objects() const;
Selection::EMode get_mode() const { return m_mode; }
void set_mode(Selection::EMode mode) { m_mode = mode; }
@ -206,12 +220,15 @@ private:
#if ENABLE_RENDER_SELECTION_CENTER
GLUquadricObj* m_quadric;
#endif // ENABLE_RENDER_SELECTION_CENTER
#if ENABLE_GCODE_VIEWER
GLModel m_arrow;
GLModel m_curved_arrow;
#else
mutable GLArrow m_arrow;
mutable GLCurvedArrow m_curved_arrow;
// Arrows are saved through pointers to avoid including 3DScene.hpp.
// It also allows mutability.
std::unique_ptr<GLArrow> m_arrow;
std::unique_ptr<GLCurvedArrow> m_curved_arrow;
#endif // ENABLE_GCODE_VIEWER
mutable float m_scale_factor;
@ -371,9 +388,9 @@ private:
void render_sidebar_layers_hints(const std::string& sidebar_field) const;
#if !ENABLE_GCODE_VIEWER
void render_sidebar_position_hint(Axis axis) const;
#endif // !ENABLE_GCODE_VIEWER
void render_sidebar_rotation_hint(Axis axis) const;
void render_sidebar_scale_hint(Axis axis) const;
#endif // !ENABLE_GCODE_VIEWER
public:
enum SyncRotationType {

View file

@ -3,6 +3,7 @@
#include "3DScene.hpp"
#include "GUI.hpp"
#include "../Utils/UndoRedo.hpp"
#include "Plater.hpp"
#include <string>

View file

@ -32,6 +32,8 @@
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
#include "ConfigWizard.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include "format.hpp"
namespace Slic3r {
@ -3297,28 +3299,28 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
wxGetApp().plater()->force_filament_colors_update();
{
// Profile compatiblity is updated first when the profile is saved.
// Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility.
std::vector<Preset::Type> dependent;
switch (m_type) {
case Preset::TYPE_PRINT:
dependent = { Preset::TYPE_FILAMENT };
break;
case Preset::TYPE_SLA_PRINT:
dependent = { Preset::TYPE_SLA_MATERIAL };
break;
case Preset::TYPE_PRINTER:
// Profile compatiblity is updated first when the profile is saved.
// Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility.
std::vector<Preset::Type> dependent;
switch (m_type) {
case Preset::TYPE_PRINT:
dependent = { Preset::TYPE_FILAMENT };
break;
case Preset::TYPE_SLA_PRINT:
dependent = { Preset::TYPE_SLA_MATERIAL };
break;
case Preset::TYPE_PRINTER:
if (static_cast<const TabPrinter*>(this)->m_printer_technology == ptFFF)
dependent = { Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
else
dependent = { Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
break;
break;
default:
break;
}
for (Preset::Type preset_type : dependent)
wxGetApp().get_tab(preset_type)->update_tab_ui();
}
break;
}
for (Preset::Type preset_type : dependent)
wxGetApp().get_tab(preset_type)->update_tab_ui();
}
}
// Called for a currently selected preset.
@ -3582,6 +3584,18 @@ void Tab::set_tooltips_text()
"Click to reset current value to the last saved preset."));
}
Page::Page(wxWindow* parent, const wxString& title, const int iconID, const std::vector<ScalableBitmap>& mode_bmp_cache) :
m_parent(parent),
m_title(title),
m_iconID(iconID),
m_mode_bitmap_cache(mode_bmp_cache)
{
Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_vsizer = new wxBoxSizer(wxVERTICAL);
m_item_color = &wxGetApp().get_label_clr_default();
SetSizer(m_vsizer);
}
void Page::reload_config()
{
for (auto group : m_optgroups)

View file

@ -33,11 +33,12 @@
#include "Event.hpp"
#include "wxExtensions.hpp"
#include "ConfigManipulation.hpp"
#include "Preset.hpp"
#include "OptionsGroup.hpp"
namespace Slic3r {
namespace GUI {
// Single Tab page containing a{ vsizer } of{ optgroups }
// package Slic3r::GUI::Tab::Page;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
@ -49,17 +50,8 @@ class Page : public wxScrolledWindow
wxBoxSizer* m_vsizer;
bool m_show = true;
public:
Page(wxWindow* parent, const wxString& title, const int iconID, const std::vector<ScalableBitmap>& mode_bmp_cache) :
m_parent(parent),
m_title(title),
m_iconID(iconID),
m_mode_bitmap_cache(mode_bmp_cache)
{
Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_vsizer = new wxBoxSizer(wxVERTICAL);
m_item_color = &wxGetApp().get_label_clr_default();
SetSizer(m_vsizer);
}
Page(wxWindow* parent, const wxString& title, const int iconID,
const std::vector<ScalableBitmap>& mode_bmp_cache);
~Page() {}
bool m_is_modified_values{ false };

View file

@ -120,7 +120,7 @@ namespace fts {
char *end = Slic3r::fold_to_ascii(*str, tmp);
char *c = tmp;
for (const wchar_t* d = pattern; c != end && *d != 0 && wchar_t(std::tolower(*c)) == std::tolower(*d); ++c, ++d);
if (c == end) {
if (c == end) {
folded_match = true;
num_matched = end - tmp;
}

View file

@ -13,6 +13,7 @@
#include "GUI_ObjectList.hpp"
#include "I18N.hpp"
#include "GUI_Utils.hpp"
#include "Plater.hpp"
#include "../Utils/MacDarkMode.hpp"
#ifndef __WXGTK__// msw_menuitem_bitmaps is used for MSW and OSX

View file

@ -25,6 +25,7 @@
#include "slic3r/GUI/UpdateDialogs.hpp"
#include "slic3r/GUI/ConfigWizard.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/format.hpp"
#include "slic3r/Utils/Http.hpp"
#include "slic3r/Config/Version.hpp"

View file

@ -4,7 +4,6 @@
#include <functional>
#include <libslic3r/Point.hpp>
#include <libslic3r/TriangleMesh.hpp>
#include <libslic3r/PrintConfig.hpp>
namespace Slic3r {