11 #include <wx/dcclient.h>
18 , controller(controller) {
19 this->SetMinSize(wxSize(300, 300));
20 this->Connect(wxEVT_PAINT, wxPaintEventHandler(OrthoPane::onPaint));
21 this->Connect(wxEVT_MOTION, wxMouseEventHandler(OrthoPane::onMouseMotion));
22 this->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(OrthoPane::onMouseWheel));
23 this->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(OrthoPane::onRightDown));
24 this->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(OrthoPane::onRightUp));
25 this->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(OrthoPane::onLeftUp));
26 this->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(OrthoPane::onDoubleClick));
27 this->Connect(wxEVT_SIZE, wxSizeEventHandler(OrthoPane::onResize));
32 particle.lastIdx = -1;
34 const wxSize size = this->GetSize();
51 void OrthoPane::onPaint(wxPaintEvent&
UNUSED(evt)) {
60 dc.DrawBitmap(bitmap, wxPoint(0, 0));
63 void OrthoPane::onMouseMotion(wxMouseEvent& evt) {
68 if (evt.RightIsDown()) {
71 camera->
transform(dragging.initialMatrix * matrix);
81 void OrthoPane::onRightDown(wxMouseEvent& evt) {
86 void OrthoPane::onRightUp(wxMouseEvent& evt) {
89 dragging.initialMatrix = dragging.initialMatrix * matrix;
92 void OrthoPane::onDoubleClick(wxMouseEvent& evt) {
94 const wxPoint
position = evt.GetPosition();
96 const Pixel origin(this->GetSize().x - 50, 231);
97 const Pixel size(30, 201);
107 this->GetParent(), wxSize(300, 240), palette.
value(), [
this](
const Palette& selected) {
108 controller->setPaletteOverride(selected);
110 paletteDialog->Show();
114 void OrthoPane::onLeftUp(wxMouseEvent& evt) {
118 if (selectedIdx.
valueOr(-1) != particle.lastIdx.valueOr(-1)) {
119 particle.lastIdx = selectedIdx;
125 void OrthoPane::onMouseWheel(wxMouseEvent& evt) {
127 const float spin = evt.GetWheelRotation();
128 const float amount = (spin > 0.f) ? 1.2f : 1.f / 1.2f;
129 Pixel fixedPoint(evt.GetPosition());
130 camera->
zoom(fixedPoint, amount);
135 void OrthoPane::onResize(wxSizeEvent& evt) {
136 const Pixel newSize(
max(10, evt.GetSize().x),
max(10, evt.GetSize().y));
Wrapper of wxBitmap, will be possibly replaced by custom implementation.
Defines projection transforming 3D particles onto 2D screen.
Helper functions to check the internal consistency of the code.
@ MAIN_THREAD
Function can only be executed from main thread.
#define CHECK_FUNCTION(flags)
Object converting quantity values of particles into colors.
constexpr INLINE T max(const T &f1, const T &f2)
#define NAMESPACE_SPH_END
Tool to measure time spent in functions and profile the code.
Random utility functions for drawing stuff to DC.
BasicVector< Float > Vector
static AffineMatrix identity()
void resize(const Pixel newSize)
void click(const Pixel point)
Called on mouse click, starting the rotation.
AffineMatrix drag(const Pixel point, const Vector &pivot)
Called when mouse moves, rotating the object.
Main GUI class connection the simulation with UI controls.
void setAutoZoom(const bool enable)
Enables or disables auto-zoom during the simulation.
AutoPtr< ICamera > getCurrentCamera() const
Returns the camera currently used for the rendering.
const wxBitmap & getRenderedBitmap() const
Renders a bitmap of current view.
SharedPtr< IColorizer > getCurrentColorizer() const
Returns the colorizer currently used for rendering into the window.
Optional< Size > getIntersectedParticle(const Pixel position, const float toleranceEps)
Returns the particle under given image position, or NOTHING if such particle exists.
void setSelectedParticle(const Optional< Size > &particleIdx)
Sets a selected particle or changes the current selection.
void refresh(AutoPtr< ICamera > &&camera)
Re-renders the particles with given camera.
bool tryRedraw()
If possible, redraws the particles with data from storage.
GuiSettings & getParams()
Returns the settings object.
INLINE TValue get(const GuiSettingsId id) const
virtual void autoSetup(const Storage &storage)=0
Initializes the camera, using the provided particle storage.
virtual void pan(const Pixel offset)=0
Moves the camera by relative offset in image space.
virtual void zoom(const Pixel fixedPoint, const float magnitude)=0
virtual AutoPtr< ICamera > clone() const =0
virtual void transform(const AffineMatrix &matrix)=0
Transforms the current view by given matrix.
virtual void resize(const Pixel newSize)=0
Changes the image size.
virtual Optional< Palette > getPalette() const =0
Returns recommended palette for drawing this colorizer.
Object representing a 1D interval of real numbers.
INLINE bool contains(const Float &value) const
Checks whether value is inside the interval.
INLINE Type & value()
Returns the reference to the stored value.
INLINE Type valueOr(const TOther &other) const
Returns the stored value if the object has been initialized, otherwise returns provided parameter.
virtual void resetView() override
OrthoPane(wxWindow *parent, Controller *controller, const GuiSettings &gui)
Pixel position
Cached last mouse position when dragging the window.
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Represents a color palette, used for mapping arbitrary number to a color.
Object holding various statistics about current run.
Container storing all quantities used within the simulations.