10 #include <condition_variable>
97 mutable std::mutex cameraMutex;
113 mutable std::atomic_bool refreshPending;
116 std::thread renderThread;
119 std::atomic_bool needsRefresh;
122 std::mutex renderThreadMutex;
123 std::condition_variable renderThreadVar;
130 void initialize(
const Project& project);
132 bool isInitialized();
141 std::mutex continueMutex;
142 std::condition_variable continueVar;
144 std::mutex updateMutex;
145 std::condition_variable updateVar;
260 void open(
const Path&
path,
const bool sequence =
false);
280 void stop(
const bool waitForFinish =
false);
291 void quit(
const bool waitForFinish =
false);
297 virtual void onStart(
const IJob& job)
override;
307 virtual bool shouldAbortRun()
const override;
317 void startRunThread();
319 void startRenderThread();
ColorizerId
Special colorizers that do not directly correspond to quantities.
RunStatus
Status of the code.
@ STOPPED
Run has been stopped by the user.
@ RUNNING
Simulation in progress.
@ QUITTING
quit has been called, waiting for threads to finish
@ PAUSED
Run is paused, can be continued or stopped.
Array< ExtColorizerId > getColorizerIds()
Returns IDs of all colorizers available in the application.
Basic interface defining a single run.
#define NAMESPACE_SPH_END
Object representing a path on a filesystem, similar to std::filesystem::path in c++17.
Generic dynamically allocated resizable storage.
Main GUI class connection the simulation with UI controls.
bool isRunning() const
Returns true if a simulation is running.
Controller(wxWindow *parent)
Initialize the controller.
void setRenderer(AutoPtr< IRenderer > &&newRenderer)
Sets a new renderer used to draw particles.
void setAutoZoom(const bool enable)
Enables or disables auto-zoom during the simulation.
RawPtr< RunPage > getPage() const
AutoPtr< ICamera > getCurrentCamera() const
Returns the camera currently used for the rendering.
std::atomic_bool shouldContinue
Flag read by the simulation; the run is stopped if this is set to zero.
SharedPtr< INode > run
Root node of the simulation.
void quit(const bool waitForFinish=false)
Closes down the model, clears all allocated resources. Must be called only once.
Array< SharedPtr< IColorizer > > getColorizerList(const Storage &storage) const
void saveState(const Path &path)
Saves the state of the current run to the disk.
const wxBitmap & getRenderedBitmap() const
Renders a bitmap of current view.
void restart()
Starts the simulation with current setup.
SharedPtr< IColorizer > getCurrentColorizer() const
Returns the colorizer currently used for rendering into the window.
RunStatus getStatus() const
Returns the current status of the run.
Path path
Path to the loaded file, if used.
void open(const Path &path, const bool sequence=false)
Opens a simulation snapshot from given file.
void stop(const bool waitForFinish=false)
Stops the current simulation.
void redrawOnNextTimeStep()
Redraws the image on the following timestep.
void setPaletteOverride(const Palette palette)
Modifies the color palette for current colorizer.
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 pause()
Pause the current simulation.
void start(SharedPtr< INode > run, const RunSettings &globals)
Sets up and starts a new simulation.
void refresh(AutoPtr< ICamera > &&camera)
Re-renders the particles with given camera.
Optional< Size > getSelectedParticle() const
void update(const Storage &storage, const Statistics &stats)
Updates the colorizer list, reset the camera and the renderer, etc.
bool tryRedraw()
If possible, redraws the particles with data from storage.
RawPtr< const Storage > storage
Locking< Array< TimeStepCallback > > onTimeStepCallbacks
GuiSettings & getParams()
Returns the settings object.
void setColorizer(const SharedPtr< IColorizer > &newColorizer)
Sets a new colorizer to be displayed.
std::thread thread
Thread running the simulation.
const Storage & getStorage() const
Helper type allowing to "derive" from enum class.
Interface defining a camera or view, used by a renderer.
Interface for objects assigning colors to particles.
Interface used during job evaluation.
Base class for all object performing an operation in a simulation hierarchy.
Interface used to implement renderers.
Building block of a simulation hierarchy.
Wraps given object together with a mutex, locking it every time the object is accessed.
Represents a color palette, used for mapping arbitrary number to a color.
Object representing a path on a filesystem.
Main frame of the application.
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
Basic time-measuring tool. Starts automatically when constructed.
Generic storage and input/output routines of settings.
Vector position(const Float a, const Float e, const Float u)
Computes the position on the elliptic trajectory.