Replaced "Simple shorthands for smart pointers" shptr, uqptr, wkptr
with their original names. Using weird shorthands makes the code unreadable for anyone but the original author. template<class T> using shptr = std::shared_ptr<T>; template<class T> using uqptr = std::unique_ptr<T>; template<class T> using wkptr = std::weak_ptr<T>;
This commit is contained in:
parent
b028e169c8
commit
e185bf58b7
@ -65,7 +65,7 @@ void CSGDisplay::render_scene()
|
|||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::set_print(uqptr<SLAPrint> &&print)
|
void Scene::set_print(std::unique_ptr<SLAPrint> &&print)
|
||||||
{
|
{
|
||||||
m_print = std::move(print);
|
m_print = std::move(print);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ void CSGDisplay::SceneCache::clear()
|
|||||||
primitives.clear();
|
primitives.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
shptr<Primitive> CSGDisplay::SceneCache::add_mesh(const TriangleMesh &mesh)
|
std::shared_ptr<Primitive> CSGDisplay::SceneCache::add_mesh(const TriangleMesh &mesh)
|
||||||
{
|
{
|
||||||
auto p = std::make_shared<Primitive>();
|
auto p = std::make_shared<Primitive>();
|
||||||
p->load_mesh(mesh);
|
p->load_mesh(mesh);
|
||||||
@ -94,7 +94,7 @@ shptr<Primitive> CSGDisplay::SceneCache::add_mesh(const TriangleMesh &mesh)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
shptr<Primitive> CSGDisplay::SceneCache::add_mesh(const TriangleMesh &mesh,
|
std::shared_ptr<Primitive> CSGDisplay::SceneCache::add_mesh(const TriangleMesh &mesh,
|
||||||
OpenCSG::Operation o,
|
OpenCSG::Operation o,
|
||||||
unsigned c)
|
unsigned c)
|
||||||
{
|
{
|
||||||
|
@ -17,11 +17,6 @@ class SLAPrint;
|
|||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
||||||
// Simple shorthands for smart pointers
|
|
||||||
template<class T> using shptr = std::shared_ptr<T>;
|
|
||||||
template<class T> using uqptr = std::unique_ptr<T>;
|
|
||||||
template<class T> using wkptr = std::weak_ptr<T>;
|
|
||||||
|
|
||||||
template<class T, class A = std::allocator<T>> using vector = std::vector<T, A>;
|
template<class T, class A = std::allocator<T>> using vector = std::vector<T, A>;
|
||||||
|
|
||||||
// remove empty weak pointers from a vector
|
// remove empty weak pointers from a vector
|
||||||
@ -61,7 +56,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<wkptr<Listener>> m_listeners;
|
vector<std::weak_ptr<Listener>> m_listeners;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~MouseInput() = default;
|
virtual ~MouseInput() = default;
|
||||||
@ -95,7 +90,7 @@ public:
|
|||||||
call(&Listener::on_moved_to, m_listeners, x, y);
|
call(&Listener::on_moved_to, m_listeners, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_listener(shptr<Listener> listener)
|
void add_listener(std::shared_ptr<Listener> listener)
|
||||||
{
|
{
|
||||||
m_listeners.emplace_back(listener);
|
m_listeners.emplace_back(listener);
|
||||||
cleanup(m_listeners);
|
cleanup(m_listeners);
|
||||||
@ -322,7 +317,7 @@ public:
|
|||||||
// The scene is a wrapper around SLAPrint which holds the data to be visualized.
|
// The scene is a wrapper around SLAPrint which holds the data to be visualized.
|
||||||
class Scene
|
class Scene
|
||||||
{
|
{
|
||||||
uqptr<SLAPrint> m_print;
|
std::unique_ptr<SLAPrint> m_print;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Subscribers will be notified if the model is changed. This might be a
|
// Subscribers will be notified if the model is changed. This might be a
|
||||||
@ -340,19 +335,19 @@ public:
|
|||||||
Scene();
|
Scene();
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|
||||||
void set_print(uqptr<SLAPrint> &&print);
|
void set_print(std::unique_ptr<SLAPrint> &&print);
|
||||||
const SLAPrint * get_print() const { return m_print.get(); }
|
const SLAPrint * get_print() const { return m_print.get(); }
|
||||||
|
|
||||||
BoundingBoxf3 get_bounding_box() const;
|
BoundingBoxf3 get_bounding_box() const;
|
||||||
|
|
||||||
void add_listener(shptr<Listener> listener)
|
void add_listener(std::shared_ptr<Listener> listener)
|
||||||
{
|
{
|
||||||
m_listeners.emplace_back(listener);
|
m_listeners.emplace_back(listener);
|
||||||
cleanup(m_listeners);
|
cleanup(m_listeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<wkptr<Listener>> m_listeners;
|
vector<std::weak_ptr<Listener>> m_listeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The basic Display. This is almost just an interface but will do all the
|
// The basic Display. This is almost just an interface but will do all the
|
||||||
@ -366,20 +361,20 @@ protected:
|
|||||||
Vec2i m_size;
|
Vec2i m_size;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
|
||||||
shptr<Camera> m_camera;
|
std::shared_ptr<Camera> m_camera;
|
||||||
FpsCounter m_fps_counter;
|
FpsCounter m_fps_counter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Display(shptr<Camera> camera = nullptr)
|
explicit Display(std::shared_ptr<Camera> camera = nullptr)
|
||||||
: m_camera(camera ? camera : std::make_shared<PerspectiveCamera>())
|
: m_camera(camera ? camera : std::make_shared<PerspectiveCamera>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~Display() override;
|
~Display() override;
|
||||||
|
|
||||||
shptr<const Camera> get_camera() const { return m_camera; }
|
std::shared_ptr<const Camera> get_camera() const { return m_camera; }
|
||||||
shptr<Camera> get_camera() { return m_camera; }
|
std::shared_ptr<Camera> get_camera() { return m_camera; }
|
||||||
void set_camera(shptr<Camera> cam) { m_camera = cam; }
|
void set_camera(std::shared_ptr<Camera> cam) { m_camera = cam; }
|
||||||
|
|
||||||
virtual void swap_buffers() = 0;
|
virtual void swap_buffers() = 0;
|
||||||
virtual void set_active(long width, long height);
|
virtual void set_active(long width, long height);
|
||||||
@ -410,14 +405,14 @@ protected:
|
|||||||
// Cache the renderable primitives. These will be fetched when the scene
|
// Cache the renderable primitives. These will be fetched when the scene
|
||||||
// is modified.
|
// is modified.
|
||||||
struct SceneCache {
|
struct SceneCache {
|
||||||
vector<shptr<Primitive>> primitives;
|
vector<std::shared_ptr<Primitive>> primitives;
|
||||||
vector<Primitive *> primitives_free;
|
vector<Primitive *> primitives_free;
|
||||||
vector<OpenCSG::Primitive *> primitives_csg;
|
vector<OpenCSG::Primitive *> primitives_csg;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
shptr<Primitive> add_mesh(const TriangleMesh &mesh);
|
std::shared_ptr<Primitive> add_mesh(const TriangleMesh &mesh);
|
||||||
shptr<Primitive> add_mesh(const TriangleMesh &mesh,
|
std::shared_ptr<Primitive> add_mesh(const TriangleMesh &mesh,
|
||||||
OpenCSG::Operation op,
|
OpenCSG::Operation op,
|
||||||
unsigned covexity);
|
unsigned covexity);
|
||||||
} m_scene_cache;
|
} m_scene_cache;
|
||||||
@ -446,13 +441,13 @@ class Controller : public std::enable_shared_from_this<Controller>,
|
|||||||
Vec2i m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
|
Vec2i m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
|
||||||
bool m_left_btn = false, m_right_btn = false;
|
bool m_left_btn = false, m_right_btn = false;
|
||||||
|
|
||||||
shptr<Scene> m_scene;
|
std::shared_ptr<Scene> m_scene;
|
||||||
vector<wkptr<Display>> m_displays;
|
vector<std::weak_ptr<Display>> m_displays;
|
||||||
|
|
||||||
// Call a method of Camera on all the cameras of the attached displays
|
// Call a method of Camera on all the cameras of the attached displays
|
||||||
template<class F, class...Args>
|
template<class F, class...Args>
|
||||||
void call_cameras(F &&f, Args&&... args) {
|
void call_cameras(F &&f, Args&&... args) {
|
||||||
for (wkptr<Display> &l : m_displays)
|
for (std::weak_ptr<Display> &l : m_displays)
|
||||||
if (auto disp = l.lock()) if (auto cam = disp->get_camera())
|
if (auto disp = l.lock()) if (auto cam = disp->get_camera())
|
||||||
(cam.get()->*f)(std::forward<Args>(args)...);
|
(cam.get()->*f)(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
@ -460,7 +455,7 @@ class Controller : public std::enable_shared_from_this<Controller>,
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// Set the scene that will be controlled.
|
// Set the scene that will be controlled.
|
||||||
void set_scene(shptr<Scene> scene)
|
void set_scene(std::shared_ptr<Scene> scene)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_scene->add_listener(shared_from_this());
|
m_scene->add_listener(shared_from_this());
|
||||||
@ -468,7 +463,7 @@ public:
|
|||||||
|
|
||||||
const Scene * get_scene() const { return m_scene.get(); }
|
const Scene * get_scene() const { return m_scene.get(); }
|
||||||
|
|
||||||
void add_display(shptr<Display> disp)
|
void add_display(std::shared_ptr<Display> disp)
|
||||||
{
|
{
|
||||||
m_displays.emplace_back(disp);
|
m_displays.emplace_back(disp);
|
||||||
cleanup(m_displays);
|
cleanup(m_displays);
|
||||||
|
@ -12,7 +12,7 @@ class CSGVolume: public Volume
|
|||||||
|
|
||||||
class ShaderCSGDisplay: public Display {
|
class ShaderCSGDisplay: public Display {
|
||||||
protected:
|
protected:
|
||||||
vector<shptr<CSGVolume>> m_volumes;
|
vector<std::shared_ptr<CSGVolume>> m_volumes;
|
||||||
|
|
||||||
void add_mesh(const TriangleMesh &mesh);
|
void add_mesh(const TriangleMesh &mesh);
|
||||||
public:
|
public:
|
||||||
|
@ -34,7 +34,7 @@ using namespace Slic3r::GL;
|
|||||||
class Renderer {
|
class Renderer {
|
||||||
protected:
|
protected:
|
||||||
wxGLCanvas *m_canvas;
|
wxGLCanvas *m_canvas;
|
||||||
shptr<wxGLContext> m_context;
|
std::shared_ptr<wxGLContext> m_context;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Renderer(wxGLCanvas *c): m_canvas{c} {
|
Renderer(wxGLCanvas *c): m_canvas{c} {
|
||||||
@ -86,16 +86,16 @@ public:
|
|||||||
class Canvas: public wxGLCanvas
|
class Canvas: public wxGLCanvas
|
||||||
{
|
{
|
||||||
// One display is active at a time, the OCSGRenderer by default.
|
// One display is active at a time, the OCSGRenderer by default.
|
||||||
shptr<Slic3r::GL::Display> m_display;
|
std::shared_ptr<Slic3r::GL::Display> m_display;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<class...Args>
|
template<class...Args>
|
||||||
Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...) {}
|
Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...) {}
|
||||||
|
|
||||||
shptr<Slic3r::GL::Display> get_display() const { return m_display; }
|
std::shared_ptr<Slic3r::GL::Display> get_display() const { return m_display; }
|
||||||
|
|
||||||
void set_display(shptr<Slic3r::GL::Display> d) { m_display = d; }
|
void set_display(std::shared_ptr<Slic3r::GL::Display> d) { m_display = d; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enumerate possible mouse events, we will record them.
|
// Enumerate possible mouse events, we will record them.
|
||||||
@ -197,14 +197,14 @@ public:
|
|||||||
class MyFrame: public wxFrame
|
class MyFrame: public wxFrame
|
||||||
{
|
{
|
||||||
// Instantiate the 3D engine.
|
// Instantiate the 3D engine.
|
||||||
shptr<Scene> m_scene; // Model
|
std::shared_ptr<Scene> m_scene; // Model
|
||||||
shptr<Canvas> m_canvas; // Views store
|
std::shared_ptr<Canvas> m_canvas; // Views store
|
||||||
shptr<OCSGRenderer> m_ocsgdisplay; // View
|
std::shared_ptr<OCSGRenderer> m_ocsgdisplay; // View
|
||||||
shptr<ShaderCSGRenderer> m_shadercsg_display; // Another view
|
std::shared_ptr<ShaderCSGRenderer> m_shadercsg_display; // Another view
|
||||||
shptr<Controller> m_ctl; // Controller
|
std::shared_ptr<Controller> m_ctl; // Controller
|
||||||
|
|
||||||
// Add a status bar with progress indication.
|
// Add a status bar with progress indication.
|
||||||
shptr<Slic3r::GUI::ProgressStatusBar> m_stbar;
|
std::shared_ptr<Slic3r::GUI::ProgressStatusBar> m_stbar;
|
||||||
|
|
||||||
RecorderMouseInput m_mouse;
|
RecorderMouseInput m_mouse;
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ class MyFrame: public wxFrame
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
uqptr<SLAJob> m_ui_job;
|
std::unique_ptr<SLAJob> m_ui_job;
|
||||||
|
|
||||||
// To keep track of the running average of measured fps values.
|
// To keep track of the running average of measured fps values.
|
||||||
double m_fps_avg = 0.;
|
double m_fps_avg = 0.;
|
||||||
|
@ -423,7 +423,7 @@ void fill_slicerconf(ConfMap &m, const SLAPrint &print)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
uqptr<sla::RasterBase> SL1Archive::create_raster() const
|
std::unique_ptr<sla::RasterBase> SL1Archive::create_raster() const
|
||||||
{
|
{
|
||||||
sla::RasterBase::Resolution res;
|
sla::RasterBase::Resolution res;
|
||||||
sla::RasterBase::PixelDim pxdim;
|
sla::RasterBase::PixelDim pxdim;
|
||||||
|
@ -12,7 +12,7 @@ class SL1Archive: public SLAArchive {
|
|||||||
SLAPrinterConfig m_cfg;
|
SLAPrinterConfig m_cfg;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uqptr<sla::RasterBase> create_raster() const override;
|
std::unique_ptr<sla::RasterBase> create_raster() const override;
|
||||||
sla::RasterEncoder get_encoder() const override;
|
sla::RasterEncoder get_encoder() const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -13,10 +13,6 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
template<class T> using uqptr = std::unique_ptr<T>;
|
|
||||||
template<class T> using shptr = std::shared_ptr<T>;
|
|
||||||
template<class T> using wkptr = std::weak_ptr<T>;
|
|
||||||
|
|
||||||
namespace sla {
|
namespace sla {
|
||||||
|
|
||||||
// Raw byte buffer paired with its size. Suitable for compressed image data.
|
// Raw byte buffer paired with its size. Suitable for compressed image data.
|
||||||
@ -112,7 +108,7 @@ struct PPMRasterEncoder {
|
|||||||
std::ostream& operator<<(std::ostream &stream, const EncodedRaster &bytes);
|
std::ostream& operator<<(std::ostream &stream, const EncodedRaster &bytes);
|
||||||
|
|
||||||
// If gamma is zero, thresholding will be performed which disables AA.
|
// If gamma is zero, thresholding will be performed which disables AA.
|
||||||
uqptr<RasterBase> create_raster_grayscale_aa(
|
std::unique_ptr<RasterBase> create_raster_grayscale_aa(
|
||||||
const RasterBase::Resolution &res,
|
const RasterBase::Resolution &res,
|
||||||
const RasterBase::PixelDim & pxdim,
|
const RasterBase::PixelDim & pxdim,
|
||||||
double gamma = 1.0,
|
double gamma = 1.0,
|
||||||
|
@ -391,7 +391,7 @@ class SLAArchive {
|
|||||||
protected:
|
protected:
|
||||||
std::vector<sla::EncodedRaster> m_layers;
|
std::vector<sla::EncodedRaster> m_layers;
|
||||||
|
|
||||||
virtual uqptr<sla::RasterBase> create_raster() const = 0;
|
virtual std::unique_ptr<sla::RasterBase> create_raster() const = 0;
|
||||||
virtual sla::RasterEncoder get_encoder() const = 0;
|
virtual sla::RasterEncoder get_encoder() const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user