Support tree interface extended with mouse event handling and refresh callback.

This commit is contained in:
tamasmeszaros 2018-11-08 10:21:13 +01:00
parent f6591f000e
commit 91a79e0343
2 changed files with 31 additions and 0 deletions

View file

@ -1635,6 +1635,12 @@ SlicedSupports SLASupportTree::slice(float layerh, float init_layerh) const
return {};
}
// Here we should implement the support editing
void SLASupportTree::mouse_event(const MouseEvent &)
{
}
SLASupportTree::SLASupportTree(const Model& model,
const SupportConfig& cfg,
const Controller& ctl): m_impl(new Impl())

View file

@ -106,10 +106,25 @@ public:
SLASupportsStoppedException(): std::runtime_error("") {}
};
/// A simple type carrying mouse event info. For support editing purposes
struct MouseEvent {
enum Buttons {
M_RIGHT, M_LEFT, M_MIDDLE
} button;
enum Type {
ENGAGE, RELEASE, MOVE
} type;
Vec3d coords;
};
/// The class containing mesh data for the generated supports.
class SLASupportTree {
class Impl;
std::unique_ptr<Impl> m_impl;
std::function<void()> m_vcallback;
Impl& get() { return *m_impl; }
const Impl& get() const { return *m_impl; }
@ -144,6 +159,16 @@ public:
/// Get the sliced 2d layers of the support geometry.
SlicedSupports slice(float layerh, float init_layerh = -1.0) const;
/// The function to call when mouse events should be propagated to the
/// supports for editing
void mouse_event(const MouseEvent&);
/// The provided callback will be called if the supports change their shape
/// or need to be repainted
inline void on_supports_changed(std::function<void()> callback) {
m_vcallback = callback;
}
};
}