Merge remote-tracking branch 'origin/master' into ys_new_features

This commit is contained in:
YuSanka 2019-06-13 16:18:39 +02:00
commit 7da9d2f66d
16 changed files with 99 additions and 116 deletions

View File

@ -240,17 +240,34 @@ if(NOT WIN32)
set(MINIMUM_BOOST_VERSION "1.64.0")
endif()
find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS system filesystem thread log locale regex)
if(Boost_FOUND)
# message("Boost include dir: ${Boost_INCLUDE_DIRS}")
# message("Boost library dirs: ${Boost_LIBRARY_DIRS}")
# message("Boost libraries: ${Boost_LIBRARIES}")
if (APPLE)
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE)
endif()
if(NOT SLIC3R_STATIC)
add_definitions(-DBOOST_LOG_DYN_LINK)
endif()
add_library(boost_libs INTERFACE)
add_library(boost_headeronly INTERFACE)
if (APPLE)
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
target_compile_definitions(boost_headeronly INTERFACE BOOST_ASIO_DISABLE_KQUEUE)
endif()
if(NOT SLIC3R_STATIC)
target_compile_definitions(boost_headeronly INTERFACE BOOST_LOG_DYN_LINK)
endif()
if(TARGET Boost::system)
message(STATUS "Boost::boost exists")
target_link_libraries(boost_headeronly INTERFACE Boost::boost)
target_link_libraries(boost_libs INTERFACE
boost_headeronly # includes the custom compile definitions as well
Boost::system
Boost::filesystem
Boost::thread
Boost::log
Boost::locale
Boost::regex
)
else()
target_include_directories(boost_headeronly INTERFACE ${Boost_INCLUDE_DIRS})
target_link_libraries(boost_libs INTERFACE boost_headeronly ${Boost_LIBRARIES})
endif()
# Find and configure intel-tbb

View File

@ -139,7 +139,7 @@ if (MSVC)
target_compile_definitions(PrusaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
add_dependencies(PrusaSlicer_app_gui PrusaSlicer)
set_target_properties(PrusaSlicer_app_gui PROPERTIES OUTPUT_NAME "prusa-slicer")
target_include_directories(PrusaSlicer_app_gui SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(PrusaSlicer_app_gui PRIVATE boost_headeronly)
add_executable(PrusaSlicer_app_console PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
# Generate debug symbols even in release mode.
@ -147,7 +147,7 @@ if (MSVC)
target_compile_definitions(PrusaSlicer_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE)
add_dependencies(PrusaSlicer_app_console PrusaSlicer)
set_target_properties(PrusaSlicer_app_console PROPERTIES OUTPUT_NAME "prusa-slicer-console")
target_include_directories(PrusaSlicer_app_console SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(PrusaSlicer_app_console PRIVATE boost_headeronly)
endif ()
# Link the resources dir to where Slic3r GUI expects it

View File

@ -11,4 +11,4 @@ add_library(admesh STATIC
util.cpp
)
target_include_directories(admesh SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(admesh PRIVATE boost_headeronly)

View File

@ -19,6 +19,6 @@ add_library(nowide STATIC
nowide/windows.hpp
)
target_include_directories(nowide SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(nowide PUBLIC boost_headeronly)

View File

@ -56,12 +56,12 @@ endif()
# Clipper backend is not enough on its own, it still needs some functions
# from Boost geometry
if(NOT Boost_INCLUDE_DIRS_FOUND)
if(NOT Boost_FOUND)
find_package(Boost 1.58 REQUIRED)
# TODO automatic download of boost geometry headers
endif()
target_include_directories(clipperBackend SYSTEM INTERFACE ${Boost_INCLUDE_DIRS} )
target_link_libraries(clipperBackend INTERFACE Boost::boost )
#target_sources(ClipperBackend INTERFACE
# ${CMAKE_CURRENT_SOURCE_DIR}/geometries.hpp
# ${CMAKE_CURRENT_SOURCE_DIR}/clipper_polygon.hpp

View File

@ -182,13 +182,12 @@ if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
endif ()
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB)
target_include_directories(libslic3r SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(libslic3r
libnest2d
admesh
miniz
${Boost_LIBRARIES}
boost_libs
clipper
nowide
${EXPAT_LIBRARIES}

View File

@ -19,8 +19,6 @@ wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(25 * wxGetApp().em_unit(), -
m_user_drawn_background = false;
#endif /*__APPLE__*/
Bind(wxEVT_PAINT, ([this](wxPaintEvent &/* e */) { repaint(); }));
Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent &event) { mouse_event(event); }));
Bind(wxEVT_MOTION, ([this](wxMouseEvent &event) { mouse_event(event); }));
Bind(wxEVT_SIZE, ([this](wxSizeEvent & /* e */) { Refresh(); }));
}
void Bed_2D::repaint()
@ -43,22 +41,14 @@ void Bed_2D::repaint()
dc.DrawRectangle(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
}
// turn cw and ch from sizes to max coordinates
cw--;
ch--;
if (m_bed_shape.empty())
return;
// reduce size to have some space around the drawn shape
cw -= (2 * Border);
ch -= (2 * Border);
auto cbb = BoundingBoxf(Vec2d(0, 0),Vec2d(cw, ch));
// leave space for origin point
cbb.min(0) += 4;
cbb.max -= Vec2d(4., 4.);
// leave space for origin label
cbb.max(1) -= 13;
// read new size
cw = cbb.size()(0);
ch = cbb.size()(1);
auto ccenter = cbb.center();
// get bounding box of bed shape in G - code coordinates
@ -76,17 +66,17 @@ void Bed_2D::repaint()
ccenter(0) - bcenter(0) * sfactor,
ccenter(1) - bcenter(1) * sfactor
);
m_scale_factor = sfactor;
m_shift = Vec2d(shift(0) + cbb.min(0),
shift(1) - (cbb.max(1) - GetSize().GetHeight()));
m_shift = Vec2d(shift(0) + cbb.min(0), shift(1) - (cbb.max(1) - ch));
// draw bed fill
dc.SetBrush(wxBrush(wxColour(255, 255, 255), wxBRUSHSTYLE_SOLID));
wxPointList pt_list;
for (auto pt: m_bed_shape)
{
Point pt_pix = to_pixels(pt);
pt_list.push_back(new wxPoint(pt_pix(0), pt_pix(1)));
Point pt_pix = to_pixels(pt, ch);
pt_list.push_back(new wxPoint(pt_pix(0), pt_pix(1)));
}
dc.DrawPolygon(&pt_list, 0, 0);
@ -105,9 +95,9 @@ void Bed_2D::repaint()
for (auto pl : polylines)
{
for (size_t i = 0; i < pl.points.size()-1; i++) {
Point pt1 = to_pixels(unscale(pl.points[i]));
Point pt2 = to_pixels(unscale(pl.points[i+1]));
dc.DrawLine(pt1(0), pt1(1), pt2(0), pt2(1));
Point pt1 = to_pixels(unscale(pl.points[i]), ch);
Point pt2 = to_pixels(unscale(pl.points[i + 1]), ch);
dc.DrawLine(pt1(0), pt1(1), pt2(0), pt2(1));
}
}
@ -116,7 +106,7 @@ void Bed_2D::repaint()
dc.SetBrush(wxBrush(wxColour(0, 0, 0), wxBRUSHSTYLE_TRANSPARENT));
dc.DrawPolygon(&pt_list, 0, 0);
auto origin_px = to_pixels(Vec2d(0, 0));
auto origin_px = to_pixels(Vec2d(0, 0), ch);
// draw axes
auto axes_len = 50;
@ -153,7 +143,7 @@ void Bed_2D::repaint()
// draw current position
if (m_pos!= Vec2d(0, 0)) {
auto pos_px = to_pixels(m_pos);
auto pos_px = to_pixels(m_pos, ch);
dc.SetPen(wxPen(wxColour(200, 0, 0), 2, wxPENSTYLE_SOLID));
dc.SetBrush(wxBrush(wxColour(200, 0, 0), wxBRUSHSTYLE_TRANSPARENT));
dc.DrawCircle(pos_px(0), pos_px(1), 5);
@ -161,35 +151,14 @@ void Bed_2D::repaint()
dc.DrawLine(pos_px(0) - 15, pos_px(1), pos_px(0) + 15, pos_px(1));
dc.DrawLine(pos_px(0), pos_px(1) - 15, pos_px(0), pos_px(1) + 15);
}
m_painted = true;
}
// convert G - code coordinates into pixels
Point Bed_2D::to_pixels(Vec2d point)
Point Bed_2D::to_pixels(Vec2d point, int height)
{
auto p = point * m_scale_factor + m_shift;
return Point(p(0), GetSize().GetHeight() - p(1));
}
void Bed_2D::mouse_event(wxMouseEvent event)
{
if (!m_interactive) return;
if (!m_painted) return;
auto pos = event.GetPosition();
auto point = to_units(Point(pos.x, pos.y));
if (event.LeftDown() || event.Dragging()) {
if (m_on_move)
m_on_move(point) ;
Refresh();
}
}
// convert pixels into G - code coordinates
Vec2d Bed_2D::to_units(Point point)
{
return (Vec2d(point(0), GetSize().GetHeight() - point(1)) - m_shift) * (1. / m_scale_factor);
return Point(p(0) + Border, height - p(1) + Border);
}
void Bed_2D::set_pos(Vec2d pos)

View File

@ -9,20 +9,17 @@ namespace GUI {
class Bed_2D : public wxPanel
{
static const int Border = 10;
bool m_user_drawn_background = true;
bool m_painted = false;
bool m_interactive = false;
double m_scale_factor;
double m_scale_factor;
Vec2d m_shift = Vec2d::Zero();
Vec2d m_pos = Vec2d::Zero();
std::function<void(Vec2d)> m_on_move = nullptr;
Point to_pixels(Vec2d point);
Vec2d to_units(Point point);
void repaint();
void mouse_event(wxMouseEvent event);
void set_pos(Vec2d pos);
Point to_pixels(Vec2d point, int height);
void repaint();
void set_pos(Vec2d pos);
public:
Bed_2D(wxWindow* parent);

View File

@ -30,11 +30,9 @@ void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt)
SetMinSize(GetSize());
main_sizer->SetSizeHints(this);
// needed to actually free memory
this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent e) {
EndModal(wxID_OK);
Destroy();
}));
this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) {
EndModal(wxID_CANCEL);
}));
}
void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect)
@ -135,7 +133,7 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
// Called from the constructor.
// Create a panel for a rectangular / circular / custom bed shape.
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title)
ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(const wxString& title)
{
auto panel = new wxPanel(m_shape_options_book);
@ -305,8 +303,9 @@ void BedShapePanel::update_shape()
}
m_canvas->m_bed_shape = points;
}
else if (page_idx == SHAPE_CUSTOM)
m_canvas->m_bed_shape = m_loaded_bed_shape;
// $self->{on_change}->();
update_preview();
}
@ -351,8 +350,9 @@ void BedShapePanel::load_stl()
std::vector<Vec2d> points;
for (auto pt : polygon.points)
points.push_back(unscale(pt));
m_canvas->m_bed_shape = points;
update_preview();
m_loaded_bed_shape = points;
update_shape();
}
} // GUI

View File

@ -16,7 +16,8 @@ namespace GUI {
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class BedShapePanel : public wxPanel
{
Bed_2D* m_canvas;
Bed_2D* m_canvas;
std::vector<Vec2d> m_loaded_bed_shape;
public:
BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) {}
@ -24,8 +25,8 @@ public:
void build_panel(ConfigOptionPoints* default_pt);
ConfigOptionsGroupShp init_shape_options_page(wxString title);
void set_shape(ConfigOptionPoints* points);
ConfigOptionsGroupShp init_shape_options_page(const wxString& title);
void set_shape(ConfigOptionPoints* points);
void update_preview();
void update_shape();
void load_stl();

View File

@ -56,9 +56,9 @@ public:
Vec3d get_dir_right() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(0); }
Vec3d get_dir_up() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(1); }
Vec3d get_dir_forward() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(2); }
Vec3d get_dir_forward() const { return -m_view_matrix.matrix().block(0, 0, 3, 3).row(2); }
Vec3d get_position() const { return m_view_matrix.matrix().block(0, 3, 3, 1); }
Vec3d get_position() const { return m_view_matrix.matrix().inverse().block(0, 3, 3, 1); }
void apply_viewport(int x, int y, unsigned int w, unsigned int h) const;
void apply_view_matrix() const;

View File

@ -550,7 +550,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
const Selection& selection = m_parent.get_selection();
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d& instance_matrix_no_translation_no_scaling = volume->get_instance_transformation().get_matrix(true,false,true);
Vec3f direction_to_camera = camera.get_dir_forward().cast<float>();
Vec3f direction_to_camera = -camera.get_dir_forward().cast<float>();
Vec3f direction_to_camera_mesh = (instance_matrix_no_translation_no_scaling.inverse().cast<float>() * direction_to_camera).normalized().eval();
Vec3f scaling = volume->get_instance_scaling_factor().cast<float>();
direction_to_camera_mesh = Vec3f(direction_to_camera_mesh(0)*scaling(0), direction_to_camera_mesh(1)*scaling(1), direction_to_camera_mesh(2)*scaling(2));

View File

@ -3,6 +3,7 @@
#include <memory>
#include <functional>
#include <string>
class wxTimer;
class wxGauge;

View File

@ -296,6 +296,9 @@ void Selection::clear()
if (!m_valid)
return;
if (m_list.empty())
return;
for (unsigned int i : m_list)
{
(*m_volumes)[i]->selected = false;

View File

@ -1854,13 +1854,17 @@ void TabPrinter::build_fff()
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
{
auto dlg = new BedShapeDialog(this);
dlg->build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
if (dlg->ShowModal() == wxID_OK) {
load_key_value("bed_shape", dlg->GetValue());
update_changed_ui();
}
}));
BedShapeDialog dlg(this);
dlg.build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
if (dlg.ShowModal() == wxID_OK) {
std::vector<Vec2d> shape = dlg.GetValue();
if (!shape.empty())
{
load_key_value("bed_shape", shape);
update_changed_ui();
}
}
}));
return sizer;
};
@ -2056,11 +2060,15 @@ void TabPrinter::build_sla()
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
{
auto dlg = new BedShapeDialog(this);
dlg->build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
if (dlg->ShowModal() == wxID_OK) {
load_key_value("bed_shape", dlg->GetValue());
update_changed_ui();
BedShapeDialog dlg(this);
dlg.build_dialog(m_config->option<ConfigOptionPoints>("bed_shape"));
if (dlg.ShowModal() == wxID_OK) {
std::vector<Vec2d> shape = dlg.GetValue();
if (!shape.empty())
{
load_key_value("bed_shape", shape);
update_changed_ui();
}
}
}));

View File

@ -119,8 +119,6 @@ target_include_directories(XS PRIVATE src ${LIBDIR}/libslic3r)
target_compile_definitions(XS PRIVATE -DSLIC3RXS)
set_target_properties(XS PROPERTIES PREFIX "") # Prevent cmake from generating libXS.so instead of XS.so
target_link_libraries(XS ${Boost_LIBRARIES})
if (APPLE)
# -liconv: boost links to libiconv by default
target_link_libraries(XS "-liconv -framework IOKit" "-framework CoreFoundation" -lc++)
@ -156,12 +154,6 @@ if (WIN32)
target_link_libraries(XS ${PERL_LIBRARY})
endif()
target_link_libraries(XS ${Boost_LIBRARIES})
target_link_libraries(XS ${TBB_LIBRARIES})
# target_link_libraries(XS ${wxWidgets_LIBRARIES})
target_link_libraries(XS ${EXPAT_LIBRARIES})
# target_link_libraries(XS ${GLEW_LIBRARIES})
# Install the XS.pm and XS.{so,dll,bundle} into the local-lib directory.
set(PERL_LOCAL_LIB_DIR "../../local-lib/lib/perl5/${PerlEmbed_ARCHNAME}")
add_custom_command(
@ -181,10 +173,6 @@ if(APPLE)
)
endif()
if(SLIC3R_PROFILE)
target_link_libraries(Shiny)
endif()
if (MSVC)
# Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box.
get_filename_component(PROPS_PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)