Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2019-12-17 12:19:46 +0300
committertamasmeszaros <meszaros.q@gmail.com>2019-12-17 12:19:46 +0300
commit695950b2e6f9ae534c5568b52500c643d10cb257 (patch)
tree2decdd9477aa9c4567c9d1483fa833b50ac1c046 /sandboxes
parentbb3b39016fa9381506e1594cd46f361c6d348fd6 (diff)
further simplification
Diffstat (limited to 'sandboxes')
-rw-r--r--sandboxes/opencsg/CMakeLists.txt2
-rw-r--r--sandboxes/opencsg/Canvas.hpp48
-rw-r--r--sandboxes/opencsg/GLScene.hpp25
-rw-r--r--sandboxes/opencsg/main.cpp29
4 files changed, 42 insertions, 62 deletions
diff --git a/sandboxes/opencsg/CMakeLists.txt b/sandboxes/opencsg/CMakeLists.txt
index 9a216a7dc..651fbe82f 100644
--- a/sandboxes/opencsg/CMakeLists.txt
+++ b/sandboxes/opencsg/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
project(OpenCSG-example)
-add_executable(opencsg_example main.cpp GLScene.hpp GLScene.cpp Canvas.hpp
+add_executable(opencsg_example main.cpp GLScene.hpp GLScene.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/ProgressStatusBar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.cpp)
diff --git a/sandboxes/opencsg/Canvas.hpp b/sandboxes/opencsg/Canvas.hpp
deleted file mode 100644
index 424579945..000000000
--- a/sandboxes/opencsg/Canvas.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef CANVAS_HPP
-#define CANVAS_HPP
-
-#include <memory>
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include <wx/wxprec.h>
-#ifndef WX_PRECOMP
-#include <wx/wx.h>
-#endif
-
-#include <wx/glcanvas.h>
-#include <wx/msgdlg.h>
-
-#include "GLScene.hpp"
-
-namespace Slic3r { namespace GL {
-
-class Canvas: public wxGLCanvas, public Slic3r::GL::Display
-{
- std::unique_ptr<wxGLContext> m_context;
-public:
-
- void set_active(long w, long h) override
- {
- SetCurrent(*m_context);
- Slic3r::GL::Display::set_active(w, h);
- }
-
- void swap_buffers() override { SwapBuffers(); }
-
- template<class...Args>
- Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...)
- {
- auto ctx = new wxGLContext(this);
- if (!ctx || !ctx->IsOK()) {
- wxMessageBox("Could not create OpenGL context.", "Error",
- wxOK | wxICON_ERROR);
- return;
- }
-
- m_context.reset(ctx);
- }
-};
-
-}} // namespace Slic3r::GL
-
-#endif // CANVAS_HPP
diff --git a/sandboxes/opencsg/GLScene.hpp b/sandboxes/opencsg/GLScene.hpp
index 5a4afb396..68cc59b01 100644
--- a/sandboxes/opencsg/GLScene.hpp
+++ b/sandboxes/opencsg/GLScene.hpp
@@ -21,16 +21,16 @@ 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 Collection = std::vector<T, A>;
+using vector = std::vector<T, A>;
-template<class L> void cleanup(Collection<std::weak_ptr<L>> &listeners) {
+template<class L> void cleanup(vector<std::weak_ptr<L>> &listeners) {
auto it = std::remove_if(listeners.begin(), listeners.end(),
[](auto &l) { return !l.lock(); });
listeners.erase(it, listeners.end());
}
template<class F, class L, class...Args>
-void call(F &&f, Collection<std::weak_ptr<L>> &listeners, Args&&... args) {
+void call(F &&f, vector<std::weak_ptr<L>> &listeners, Args&&... args) {
for (auto &l : listeners)
if (auto p = l.lock()) ((p.get())->*f)(std::forward<Args>(args)...);
}
@@ -57,7 +57,7 @@ public:
};
private:
- Collection<wkptr<Listener>> m_listeners;
+ vector<wkptr<Listener>> m_listeners;
public:
virtual ~MouseInput() = default;
@@ -104,9 +104,9 @@ public:
// Vertices and their normals, interleaved to be used by void
// glInterleavedArrays(GL_N3F_V3F, 0, x)
- Collection<float> vertices_and_normals_interleaved;
- Collection<int> triangle_indices;
- Collection<int> quad_indices;
+ vector<float> vertices_and_normals_interleaved;
+ vector<int> triangle_indices;
+ vector<int> quad_indices;
// When the geometry data is loaded into the graphics card as Vertex
// Buffer Objects, the above mentioned std::vectors are cleared and the
@@ -271,7 +271,7 @@ public:
}
private:
- Collection<wkptr<Listener>> m_listeners;
+ vector<wkptr<Listener>> m_listeners;
};
class Display : public Scene::Listener
@@ -283,9 +283,9 @@ protected:
CSGSettings m_csgsettings;
struct SceneCache {
- Collection<shptr<Primitive>> primitives;
- Collection<Primitive *> primitives_free;
- Collection<OpenCSG::Primitive *> primitives_csg;
+ vector<shptr<Primitive>> primitives;
+ vector<Primitive *> primitives_free;
+ vector<OpenCSG::Primitive *> primitives_csg;
void clear();
@@ -332,8 +332,9 @@ class Controller : public std::enable_shared_from_this<Controller>,
bool m_left_btn = false, m_right_btn = false;
shptr<Scene> m_scene;
- Collection<wkptr<Display>> m_displays;
+ vector<wkptr<Display>> m_displays;
+ // Call a method of Camera on all the cameras of the attached displays
template<class F, class...Args>
void call_cameras(F &&f, Args&&... args) {
for (wkptr<Display> &l : m_displays)
diff --git a/sandboxes/opencsg/main.cpp b/sandboxes/opencsg/main.cpp
index d01687428..c2f8a74aa 100644
--- a/sandboxes/opencsg/main.cpp
+++ b/sandboxes/opencsg/main.cpp
@@ -15,9 +15,9 @@
#include <wx/tglbtn.h>
#include <wx/combobox.h>
#include <wx/spinctrl.h>
+#include <wx/msgdlg.h>
#include <wx/glcanvas.h>
-#include "Canvas.hpp"
#include "GLScene.hpp"
#include "libslic3r/Model.hpp"
@@ -29,6 +29,33 @@
using namespace Slic3r::GL;
+class Canvas: public wxGLCanvas, public Slic3r::GL::Display
+{
+ std::unique_ptr<wxGLContext> m_context;
+public:
+
+ void set_active(long w, long h) override
+ {
+ SetCurrent(*m_context);
+ Slic3r::GL::Display::set_active(w, h);
+ }
+
+ void swap_buffers() override { SwapBuffers(); }
+
+ template<class...Args>
+ Canvas(Args &&...args): wxGLCanvas(std::forward<Args>(args)...)
+ {
+ auto ctx = new wxGLContext(this);
+ if (!ctx || !ctx->IsOK()) {
+ wxMessageBox("Could not create OpenGL context.", "Error",
+ wxOK | wxICON_ERROR);
+ return;
+ }
+
+ m_context.reset(ctx);
+ }
+};
+
class MyFrame: public wxFrame
{
shptr<Scene> m_scene; // Model