SPH
ParticleRenderer.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "gui/Settings.h"
9 #include "gui/objects/Bitmap.h"
10 #include "gui/objects/Palette.h"
12 #include "system/Timer.h"
13 #include <atomic>
14 
16 
17 class IRenderContext;
18 
20 void drawPalette(IRenderContext& context,
21  const Pixel origin,
22  const Pixel size,
23  const Rgba& lineColor,
24  const Palette& palette);
25 
26 class ParticleRenderer : public IRenderer {
27 private:
29  float grid;
30 
32  struct {
35 
38 
41 
44 
47 
50 
51  } cached;
52 
53  mutable std::atomic_bool shouldContinue;
54 
55  mutable Timer lastRenderTimer;
56 
57 public:
58  explicit ParticleRenderer(const GuiSettings& settings);
59 
60  virtual void initialize(const Storage& storage,
61  const IColorizer& colorizer,
62  const ICamera& camera) override;
63 
64  virtual bool isInitialized() const override;
65 
66  virtual void render(const RenderParams& params, Statistics& stats, IRenderOutput& output) const override;
67 
68  virtual void cancelRender() override;
69 };
70 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Wrapper of wxBitmap, will be possibly replaced by custom implementation.
Interface for renderers.
#define NAMESPACE_SPH_END
Definition: Object.h:12
void drawPalette(IRenderContext &context, const Pixel origin, const Pixel size, const Rgba &lineColor, const Palette &palette)
Measuring time intervals and executing periodic events.
Generic dynamically allocated resizable storage.
Definition: Array.h:43
Interface defining a camera or view, used by a renderer.
Definition: Camera.h:62
Interface for objects assigning colors to particles.
Definition: Colorizer.h:34
Abstraction of a device used for rendering.
Definition: RenderContext.h:22
virtual Pixel size() const =0
Returns the size of the canvas associated with the context.
Interface used to implement renderers.
Definition: IRenderer.h:166
Represents a color palette, used for mapping arbitrary number to a color.
Definition: Palette.h:25
Array< Rgba > colors
Colors of particles assigned by the colorizer.
ParticleRenderer(const GuiSettings &settings)
Array< Vector > positions
Positions of particles.
Vector cameraDir
Camera direction for which the cached values have been sorted.
Optional< Palette > palette
Color palette or NOTHING if no palette is drawn.
virtual bool isInitialized() const override
Checks if the renderer has been initialized.
virtual void initialize(const Storage &storage, const IColorizer &colorizer, const ICamera &camera) override
Prepares the objects for rendering and updates its data.
virtual void render(const RenderParams &params, Statistics &stats, IRenderOutput &output) const override
Draws particles into the bitmap, given the data provided in initialize.
Array< Vector > vectors
Vectors representing the colorized quantity. May be empty.
virtual void cancelRender() override
Stops the rendering if it is currently in progress.
Array< Size > idxs
Indices (in parent storage) of particles.
Definition: Color.h:8
Object holding various statistics about current run.
Definition: Statistics.h:22
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Basic time-measuring tool. Starts automatically when constructed.
Definition: Timer.h:27
Definition: Point.h:101
Parameters of the rendered image.
Definition: IRenderer.h:60