mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Add ctl and fix applying opencsg params on the fly.
This commit is contained in:
parent
d14ff000e0
commit
bb3b39016f
4 changed files with 205 additions and 154 deletions
|
@ -223,8 +223,8 @@ public:
|
|||
|
||||
private:
|
||||
OpenCSG::Algorithm m_csgalg = OpenCSG::Algorithm::Automatic;
|
||||
OpenCSG::DepthComplexityAlgorithm m_depth_algo = OpenCSG::DepthComplexityAlgorithm::NoDepthComplexitySampling;
|
||||
OpenCSG::Optimization m_optim = OpenCSG::Optimization::OptimizationDefault;
|
||||
OpenCSG::DepthComplexityAlgorithm m_depth_algo = OpenCSG::NoDepthComplexitySampling;
|
||||
OpenCSG::Optimization m_optim = OpenCSG::OptimizationDefault;
|
||||
bool m_enable = true;
|
||||
unsigned int m_convexity = DEFAULT_CONVEXITY;
|
||||
|
||||
|
@ -244,21 +244,44 @@ public:
|
|||
unsigned get_convexity() const { return m_convexity; }
|
||||
void set_convexity(unsigned c) { m_convexity = c; }
|
||||
};
|
||||
|
||||
class Display : public std::enable_shared_from_this<Display>,
|
||||
public MouseInput::Listener
|
||||
|
||||
class Scene
|
||||
{
|
||||
uqptr<SLAPrint> m_print;
|
||||
public:
|
||||
|
||||
class Listener {
|
||||
public:
|
||||
virtual ~Listener() = default;
|
||||
virtual void on_scene_updated(const Scene &scene) = 0;
|
||||
};
|
||||
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
void set_print(uqptr<SLAPrint> &&print);
|
||||
const SLAPrint * get_print() const { return m_print.get(); }
|
||||
|
||||
BoundingBoxf3 get_bounding_box() const;
|
||||
|
||||
void add_listener(shptr<Listener> listener)
|
||||
{
|
||||
m_listeners.emplace_back(listener);
|
||||
cleanup(m_listeners);
|
||||
}
|
||||
|
||||
private:
|
||||
Collection<wkptr<Listener>> m_listeners;
|
||||
};
|
||||
|
||||
class Display : public Scene::Listener
|
||||
{
|
||||
protected:
|
||||
shptr<Scene> m_scene;
|
||||
long m_wheel_pos = 0;
|
||||
Vec2i m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
|
||||
Vec2i m_size;
|
||||
bool m_initialized = false, m_left_btn = false, m_right_btn = false;
|
||||
bool m_initialized = false;
|
||||
|
||||
CSGSettings m_csgsettings;
|
||||
|
||||
shptr<Camera> m_camera;
|
||||
|
||||
struct SceneCache {
|
||||
Collection<shptr<Primitive>> primitives;
|
||||
Collection<Primitive *> primitives_free;
|
||||
|
@ -272,64 +295,79 @@ protected:
|
|||
unsigned covexity);
|
||||
} m_scene_cache;
|
||||
|
||||
shptr<Camera> m_camera;
|
||||
|
||||
public:
|
||||
Display(shptr<Scene> scene = nullptr, shptr<Camera> camera = nullptr)
|
||||
: m_scene(scene)
|
||||
, m_camera(camera ? camera : std::make_shared<PerspectiveCamera>())
|
||||
|
||||
explicit Display(shptr<Camera> camera = nullptr)
|
||||
: m_camera(camera ? camera : std::make_shared<PerspectiveCamera>())
|
||||
{}
|
||||
|
||||
|
||||
Camera * camera() { return m_camera.get(); }
|
||||
|
||||
virtual void swap_buffers() = 0;
|
||||
|
||||
virtual void set_active(long width, long height);
|
||||
virtual void set_screen_size(long width, long height);
|
||||
Vec2i get_screen_size() const { return m_size; }
|
||||
|
||||
virtual void repaint(long width, long height);
|
||||
void repaint() { repaint(m_size.x(), m_size.y()); }
|
||||
|
||||
void set_scene(shptr<Scene> scene);
|
||||
shptr<Scene> get_scene() { return m_scene; }
|
||||
virtual void repaint();
|
||||
|
||||
bool is_initialized() const { return m_initialized; }
|
||||
|
||||
void on_scroll(long v, long d, MouseInput::WheelAxis wa) override;
|
||||
void on_moved_to(long x, long y) override;
|
||||
void on_left_click_down() override { m_left_btn = true; }
|
||||
void on_left_click_up() override { m_left_btn = false; }
|
||||
void on_right_click_down() override { m_right_btn = true; }
|
||||
void on_right_click_up() override { m_right_btn = false; }
|
||||
|
||||
void move_clip_plane(double z) { m_camera->set_clip_z(z); }
|
||||
|
||||
const CSGSettings & get_csgsettings() const { return m_csgsettings; }
|
||||
void apply_csgsettings(const CSGSettings &settings);
|
||||
|
||||
virtual void on_scene_updated();
|
||||
void on_scene_updated(const Scene &scene) override;
|
||||
|
||||
virtual void clear_screen();
|
||||
virtual void render_scene();
|
||||
};
|
||||
|
||||
class Scene: public MouseInput::Listener
|
||||
class Controller : public std::enable_shared_from_this<Controller>,
|
||||
public MouseInput::Listener,
|
||||
public Scene::Listener
|
||||
{
|
||||
uqptr<SLAPrint> m_print;
|
||||
long m_wheel_pos = 0;
|
||||
Vec2i m_mouse_pos, m_mouse_pos_rprev, m_mouse_pos_lprev;
|
||||
bool m_left_btn = false, m_right_btn = false;
|
||||
|
||||
shptr<Scene> m_scene;
|
||||
Collection<wkptr<Display>> m_displays;
|
||||
|
||||
template<class F, class...Args>
|
||||
void call_cameras(F &&f, Args&&... args) {
|
||||
for (wkptr<Display> &l : m_displays)
|
||||
if (auto disp = l.lock()) if (disp->camera())
|
||||
(disp->camera()->*f)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Scene();
|
||||
~Scene();
|
||||
void set_scene(shptr<Scene> scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene->add_listener(shared_from_this());
|
||||
}
|
||||
|
||||
const Scene * get_scene() const { return m_scene.get(); }
|
||||
|
||||
void add_display(shptr<Display> disp)
|
||||
{
|
||||
m_displays.emplace_back(disp);
|
||||
cleanup(m_displays);
|
||||
}
|
||||
|
||||
void set_print(uqptr<SLAPrint> &&print);
|
||||
const SLAPrint * get_print() const { return m_print.get(); }
|
||||
void on_scene_updated(const Scene &scene) override;
|
||||
|
||||
BoundingBoxf3 get_bounding_box() const;
|
||||
void on_left_click_down() override { m_left_btn = true; }
|
||||
void on_left_click_up() override { m_left_btn = false; }
|
||||
void on_right_click_down() override { m_right_btn = true; }
|
||||
void on_right_click_up() override { m_right_btn = false; }
|
||||
|
||||
void on_scroll(long v, long d, MouseInput::WheelAxis wa) override;
|
||||
void on_moved_to(long x, long y) override;
|
||||
|
||||
private:
|
||||
|
||||
Collection<wkptr<Display>> m_displays;
|
||||
void move_clip_plane(double z) { call_cameras(&Camera::set_clip_z, z); }
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GL
|
||||
#endif // GLSCENE_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue