From fb9d8b2025a2d44f53c3c044f95dcca716485870 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Sun, 24 May 2020 00:01:34 +0200 Subject: [PATCH] Include cleanup: do not include Model.hpp from 3DScene.hpp --- src/libslic3r/Model.cpp | 4 ++-- src/libslic3r/Model.hpp | 29 +++++++++++++++-------------- src/slic3r/GUI/3DScene.cpp | 12 ++++++------ src/slic3r/GUI/3DScene.hpp | 8 ++++++-- src/slic3r/GUI/GLCanvas3D.cpp | 10 +++++----- src/slic3r/GUI/GLCanvas3D.hpp | 8 +++++--- src/slic3r/GUI/GUI_Preview.hpp | 2 +- src/slic3r/GUI/Plater.cpp | 4 ++-- src/slic3r/GUI/Selection.hpp | 2 ++ 9 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index aabc44f28f..5e940b842f 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1383,8 +1383,8 @@ unsigned int ModelObject::check_instances_print_volume_state(const BoundingBoxf3 inside_outside |= OUTSIDE; } model_instance->print_volume_state = - (inside_outside == (INSIDE | OUTSIDE)) ? ModelInstance::PVS_Partly_Outside : - (inside_outside == INSIDE) ? ModelInstance::PVS_Inside : ModelInstance::PVS_Fully_Outside; + (inside_outside == (INSIDE | OUTSIDE)) ? ModelInstancePVS_Partly_Outside : + (inside_outside == INSIDE) ? ModelInstancePVS_Inside : ModelInstancePVS_Fully_Outside; if (inside_outside == INSIDE) ++ num_printable; } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index e3a136e11a..f7b63bff49 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -3,7 +3,6 @@ #include "libslic3r.h" #include "Geometry.hpp" -#include "Layer.hpp" #include "ObjectID.hpp" #include "Point.hpp" #include "PrintConfig.hpp" @@ -641,25 +640,26 @@ private: } }; + +enum ModelInstanceEPrintVolumeState : unsigned char +{ + ModelInstancePVS_Inside, + ModelInstancePVS_Partly_Outside, + ModelInstancePVS_Fully_Outside, + ModelInstanceNum_BedStates +}; + + // A single instance of a ModelObject. // Knows the affine transformation of an object. class ModelInstance final : public ObjectBase { -public: - enum EPrintVolumeState : unsigned char - { - PVS_Inside, - PVS_Partly_Outside, - PVS_Fully_Outside, - Num_BedStates - }; - private: Geometry::Transformation m_transformation; public: // flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state()) - EPrintVolumeState print_volume_state; + ModelInstanceEPrintVolumeState print_volume_state; // Whether or not this instance is printable bool printable; @@ -706,7 +706,7 @@ public: const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const { return m_transformation.get_matrix(dont_translate, dont_rotate, dont_scale, dont_mirror); } - bool is_printable() const { return object->printable && printable && (print_volume_state == PVS_Inside); } + bool is_printable() const { return object->printable && printable && (print_volume_state == ModelInstancePVS_Inside); } // Getting the input polygon for arrange arrangement::ArrangePolygon get_arrange_polygon() const; @@ -735,10 +735,10 @@ private: ModelObject* object; // Constructor, which assigns a new unique ID. - explicit ModelInstance(ModelObject* object) : print_volume_state(PVS_Inside), printable(true), object(object) { assert(this->id().valid()); } + explicit ModelInstance(ModelObject* object) : print_volume_state(ModelInstancePVS_Inside), printable(true), object(object) { assert(this->id().valid()); } // Constructor, which assigns a new unique ID. explicit ModelInstance(ModelObject *object, const ModelInstance &other) : - m_transformation(other.m_transformation), print_volume_state(PVS_Inside), printable(other.printable), object(object) { assert(this->id().valid() && this->id() != other.id()); } + m_transformation(other.m_transformation), print_volume_state(ModelInstancePVS_Inside), printable(other.printable), object(object) { assert(this->id().valid() && this->id() != other.id()); } explicit ModelInstance(ModelInstance &&rhs) = delete; ModelInstance& operator=(const ModelInstance &rhs) = delete; @@ -753,6 +753,7 @@ private: } }; + class ModelWipeTower final : public ObjectBase { public: diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index c28c937526..2fee7050af 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -724,7 +724,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; @@ -738,7 +738,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; @@ -757,11 +757,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) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 07c5cd53e3..b6decf6c8d 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -6,7 +6,8 @@ #include "libslic3r/Line.hpp" #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Utils.hpp" -#include "libslic3r/Model.hpp" +//#include "libslic3r/Model.hpp" +#include "libslic3r/Geometry.hpp" #include @@ -40,6 +41,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. @@ -578,7 +582,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); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 03e95b8a95..90a82f76d9 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1694,7 +1694,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; } @@ -2578,15 +2578,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(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 { diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 0317eb0b37..499c9f85b3 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -15,6 +15,8 @@ #include "GLSelectionRectangle.hpp" #include "MeshUtils.hpp" +#include "libslic3r/Slicing.hpp" + #include #include @@ -33,13 +35,13 @@ class wxGLContext; namespace Slic3r { -class Bed3D; struct Camera; class BackgroundSlicingProcess; class GCodePreviewData; struct ThumbnailData; -struct SlicingParameters; -enum LayerHeightEditActionType : unsigned int; +class ModelObject; +class ModelInstance; +class PrintObject; namespace GUI { diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 9d7c6c0313..5df3e38c6c 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -3,9 +3,9 @@ #include #include "libslic3r/Point.hpp" +#include "libslic3r/CustomGCode.hpp" #include -#include "libslic3r/Model.hpp" class wxNotebook; class wxGLCanvas; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index cea671c4f6..a9bfcfbac7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2626,7 +2626,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); } @@ -3318,7 +3318,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 diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index c27b4cc29d..fb93bef644 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -3,8 +3,10 @@ #include #include "libslic3r/Geometry.hpp" +#include "libslic3r/Model.hpp" #include "3DScene.hpp" + #if ENABLE_RENDER_SELECTION_CENTER class GLUquadric; typedef class GLUquadric GLUquadricObj;