Program Listing for File ModelVis.h
↰ Return to documentation for file (include/flamegpu/visualiser/ModelVis.h
)
#ifndef INCLUDE_FLAMEGPU_VISUALISER_MODELVIS_H_
#define INCLUDE_FLAMEGPU_VISUALISER_MODELVIS_H_
#ifdef FLAMEGPU_VISUALISATION
#include <string>
#include <unordered_map>
#include <thread>
#include <memory>
#include <climits>
// @todo - All vis headers should live in the vis repo.
#include "flamegpu/visualiser/AgentVis.h"
#include "flamegpu/visualiser/EnvironmentGraphVis.h"
#include "flamegpu/visualiser/StaticModelVis.h"
#include "flamegpu/visualiser/LineVis.h"
#include "flamegpu/visualiser/PanelVis.h"
#include "flamegpu/visualiser/color/AutoPalette.h"
#include "flamegpu/visualiser/config/ModelConfig.h"
namespace flamegpu {
struct ModelData;
class CUDASimulation;
class FLAMEGPU_Visualisation;
namespace visualiser {
struct ModelVisData {
explicit ModelVisData(const CUDASimulation& model/*TBD*/);
void hookVis(std::shared_ptr<visualiser::ModelVisData> &vis, std::unordered_map<std::string, std::shared_ptr<detail::CUDAEnvironmentDirectedGraphBuffers>> &map);
ModelConfig modelCfg;
std::shared_ptr<AutoPalette> autoPalette;
std::unordered_map<std::string, std::shared_ptr<AgentVisData>> agents;
std::unordered_map<std::string, std::shared_ptr<EnvironmentGraphVisData>> graphs;
const CUDASimulation& model;
const ModelData& modelData;
std::unique_ptr<FLAMEGPU_Visualisation> visualiser;
bool env_registered = false;
void updateBuffers(const unsigned int& sc = UINT_MAX);
void registerEnvProperties();
void updateRandomSeed();
void buildEnvGraphs();
void rebuildEnvGraph(const std::string& graph_name);
};
class ModelVis {
public:
explicit ModelVis(std::shared_ptr<ModelVisData> data, bool _isSWIG);
~ModelVis() = default;
void setAutoPalette(const Palette &palette);
void clearAutoPalette();
AgentVis addAgent(const std::string &agent_name);
AgentVis Agent(const std::string &agent_name);
EnvironmentGraphVis addGraph(const std::string &graph_name);
EnvironmentGraphVis Graph(const std::string& graph_name);
void setWindowTitle(const std::string &title);
void setWindowDimensions(const unsigned int& width, const unsigned int& height);
void setClearColor(const float& red, const float& green, const float& blue);
void setFPSVisible(const bool& showFPS);
void setFPSColor(const float& red, const float& green, const float& blue);
void setInitialCameraLocation(const float &x, const float &y, const float &z);
void setInitialCameraTarget(const float &x, const float &y, const float &z);
void setInitialCameraRoll(const float &roll);
void setCameraSpeed(const float &speed, const float &shiftMultiplier = 5.0f);
void setViewClips(const float &nearClip, const float &farClip);
void setOrthographic(const bool& isOrtho);
void setOrthographicZoomModifier(const float& zoomMod);
void setStepVisible(const bool& showStep);
void setSimulationSpeed(const unsigned int& stepsPerSecond);
void setBeginPaused(const bool& beginPaused);
StaticModelVis newStaticModel(const std::string &modelPath, const std::string &texturePath = "");
LineVis newLineSketch(float r, float g, float b, float a = 1.0f);
LineVis newPolylineSketch(float r, float g, float b, float a = 1.0f);
PanelVis newUIPanel(const std::string& panel_title);
void activate();
void deactivate();
void join();
bool isRunning() const;
private:
const bool isSWIG;
std::shared_ptr<ModelVisData> data;
};
} // namespace visualiser
} // namespace flamegpu
#endif // FLAMEGPU_VISUALISATION
#endif // INCLUDE_FLAMEGPU_VISUALISER_MODELVIS_H_