SPH
Plots.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gui/Settings.h"
4 #include "gui/objects/Color.h"
6 #include "post/Plot.h"
7 
9 
10 class IColorizer;
11 
12 struct PlotData {
15 
18 };
19 
20 
26 class SelectedParticlePlot : public IPlot {
27 private:
28  Float initialPeriod;
29 
30  // Currently used plot (actual implementation); may be nullptr
31  SharedPtr<TemporalPlot> currentPlot;
32 
33  // Selected particle; if NOTHING, no plot is drawn
34  Optional<Size> selectedIdx;
35 
36  // Colorizer used to get the scalar value of the selected particle
37  SharedPtr<IColorizer> colorizer;
38 
39  // Cache of previously selected particles. Cleared every time a new colorizer is selected.
41 
42 public:
43  explicit SelectedParticlePlot(const Float initialPeriod);
44 
46 
47  void selectParticle(const Optional<Size> idx);
48 
49  void setColorizer(const SharedPtr<IColorizer>& newColorizer);
50 
51  virtual std::string getCaption() const override;
52 
53  virtual void onTimeStep(const Storage& storage, const Statistics& stats) override;
54 
55  virtual void clear() override;
56 
57  virtual void plot(IDrawingContext& dc) const override;
58 
59 private:
61  void syncRanges() {
62  if (currentPlot) {
63  ranges.x = currentPlot->rangeX();
64  ranges.y = currentPlot->rangeY();
65  }
66  }
67 };
68 
70 
71 AutoPtr<IPlot> getDataPlot(const Path& path, const std::string& name = "reference");
72 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
Smart pointer associated with a mutex.
#define NAMESPACE_SPH_END
Definition: Object.h:12
Drawing quantity values as functions of time or spatial coordinates.
Array< PlotData > getPlotList(const GuiSettings &gui)
Definition: Plots.cpp:130
AutoPtr< IPlot > getDataPlot(const Path &path, const std::string &name="reference")
Definition: Plots.cpp:275
Generic dynamically allocated resizable storage.
Definition: Array.h:43
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
Container of key-value pairs.
Definition: FlatMap.h:19
Interface for objects assigning colors to particles.
Definition: Colorizer.h:34
Abstraction of a drawing context.
Definition: Plot.h:34
Interface for constructing generic plots from quantities stored in storage.
Definition: Plot.h:75
struct IPlot::@12 ranges
Interval rangeX() const
Returns the plotted range in x-coordinate.
Definition: Plot.h:84
Interval rangeY() const
Returns the plotted range in y-coordinate.
Definition: Plot.h:89
Object representing a path on a filesystem.
Definition: Path.h:17
Definition: Color.h:8
Temporal plot of currently selected particle.
Definition: Plots.h:26
void selectParticle(const Optional< Size > idx)
Definition: Plots.cpp:34
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plots.cpp:74
SelectedParticlePlot(const Float initialPeriod)
Definition: Plots.cpp:29
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plots.cpp:103
virtual std::string getCaption() const override
Returns the caption of the plot.
Definition: Plots.cpp:66
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plots.cpp:87
void setColorizer(const SharedPtr< IColorizer > &newColorizer)
Definition: Plots.cpp:58
Object holding various statistics about current run.
Definition: Statistics.h:22
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Definition: Plots.h:12
Rgba color
Color of the plot.
Definition: Plots.h:17
LockingPtr< IPlot > plot
Plot to be drawn with associated mutex.
Definition: Plots.h:14