Stg::WorldGui Class Reference

#include <stage.hh>

Inheritance diagram for Stg::WorldGui:

Public Member Functions

virtual std::string ClockString () const
 
void DrawBoundingBoxTree ()
 
std::string EnergyString (void) const
 
CanvasGetCanvas (void) const
 
virtual bool IsGUI () const
 
bool IsTopView ()
 
virtual bool Load (const std::string &worldfile_path)
 
virtual bool Load (std::istream &world_content, const std::string &worldfile_path=std::string())
 
usec_t RealTimeNow (void) const
 
virtual ModelRecentlySelectedModel () const
 
virtual void Redraw (void)
 
virtual void RemoveChild (Model *mod)
 
virtual bool Save (const char *filename)
 
void Show ()
 
virtual void Start ()
 
virtual void Stop ()
 
virtual void UnLoad ()
 
virtual bool Update ()
 
 WorldGui (int width, int height, const char *caption=NULL)
 
 ~WorldGui ()
 
- Public Member Functions inherited from Stg::World
virtual void AddModel (Model *mod)
 
void AddModelName (Model *mod, const std::string &name)
 
void AddPowerPack (PowerPack *pp)
 
SuperRegionAddSuperRegion (const point_int_t &coord)
 
void AddUpdateCallback (world_callback_t cb, void *user)
 
void CancelQuit ()
 
void CancelQuitAll ()
 
void ClearRays ()
 
virtual std::string ClockString (void) const
 
void ConsumeQueue (unsigned int queue_num)
 
ModelCreateModel (Model *parent, const std::string &typestr)
 
SuperRegionCreateSuperRegion (point_int_t origin)
 
void DestroySuperRegion (SuperRegion *sr)
 
void DisableEnergy (Model *m)
 
void EnableEnergy (Model *m)
 
void Enqueue (unsigned int queue_num, usec_t delay, Model *mod, model_callback_t cb, void *arg)
 
void Extend (point3_t pt)
 
const std::set< Model * > GetAllModels () const
 
unsigned int GetEventQueue (Model *mod) const
 
const bounds3d_tGetExtent () const
 
ModelGetGround ()
 
ModelGetModel (const std::string &name) const
 
SuperRegionGetSuperRegion (const point_int_t &org)
 
SuperRegionGetSuperRegionCreate (const point_int_t &org)
 
uint64_t GetUpdateCount () const
 
WorldfileGetWorldFile ()
 
virtual bool IsGUI () const
 
virtual bool Load (const std::string &worldfile_path)
 
virtual bool Load (std::istream &world_content, const std::string &worldfile_path=std::string())
 
void LoadBlock (Worldfile *wf, int entity)
 
void LoadBlockGroup (Worldfile *wf, int entity)
 
void LoadModel (Worldfile *wf, int entity)
 
void LoadSensor (Worldfile *wf, int entity)
 
void Log (Model *mod)
 
void MapPoly (const std::vector< point_int_t > &poly, Block *block, unsigned int layer)
 
point_int_t MetersToPixels (const point_t &pt) const
 
int32_t MetersToPixels (meters_t x) const
 
void NeedRedraw ()
 
bool PastQuitTime ()
 
bool Paused () const
 
virtual void PopColor ()
 
virtual void PushColor (Color col)
 dummy implementations to be overloaded by GUI subclasses
 
virtual void PushColor (double r, double g, double b, double a)
 
void Quit ()
 
void QuitAll ()
 
void Raytrace (const Pose &gpose, const meters_t range, const radians_t fov, const ray_test_func_t func, const Model *model, const void *arg, const bool ztest, std::vector< RaytraceResult > &results)
 
RaytraceResult Raytrace (const Pose &pose, const meters_t range, const ray_test_func_t func, const Model *finder, const void *arg, const bool ztest)
 
RaytraceResult Raytrace (const Ray &ray)
 
virtual ModelRecentlySelectedModel () const
 
void RecordRay (double x1, double y1, double x2, double y2)
 
virtual void Redraw (void)
 
void RegisterOption (Option *opt)
 Register an Option for pickup by the GUI.
 
virtual void Reload ()
 
virtual void RemoveModel (Model *mod)
 
void RemovePowerPack (PowerPack *pp)
 
int RemoveUpdateCallback (world_callback_t cb, void *user)
 
double Resolution () const
 
virtual bool Save (const char *filename)
 
void ShowClock (bool enable)
 Control printing time to stdout.
 
usec_t SimTimeNow (void) const
 
virtual void Start ()
 
virtual void Stop ()
 
bool TestQuit () const
 
virtual void TogglePause ()
 
void TryCharge (PowerPack *pp, const Pose &pose)
 
virtual void UnLoad ()
 
virtual bool Update (void)
 
uint64_t UpdateCount ()
 
 World (const std::string &name="MyWorld", double ppm=DEFAULT_PPM)
 
virtual ~World ()
 
- Public Member Functions inherited from Stg::Ancestor
virtual void AddChild (Model *mod)
 
 Ancestor ()
 
void ForEachDescendant (model_callback_t func, void *arg)
 
std::vector< Model * > & GetChildren ()
 
virtual Pose GetGlobalPose () const
 
void * GetProperty (std::string &key)
 
virtual void RemoveChild (Model *mod)
 
void SetProperty (std::string &key, void *value)
 
virtual void SetToken (const std::string &str)
 
const char * Token () const
 
const std::string & TokenStr () const
 
virtual ~Ancestor ()
 

Protected Member Functions

void DrawOccupancy () const
 
void DrawVoxels () const
 
virtual void PopColor ()
 
virtual void PushColor (Color col)
 dummy implementations to be overloaded by GUI subclasses
 
virtual void PushColor (double r, double g, double b, double a)
 
- Protected Member Functions inherited from Stg::World
void CallUpdateCallbacks ()
 Call all calbacks in cb_list, removing any that return true;.
 
- Protected Member Functions inherited from Stg::Ancestor
AncestorLoad (Worldfile *wf, int section)
 
void Save (Worldfile *wf, int section)
 

Additional Inherited Members

- Static Public Member Functions inherited from Stg::World
static void Run ()
 
static void * update_thread_entry (std::pair< World *, int > *info)
 
static bool UpdateAll ()
 
- Public Attributes inherited from Stg::World
std::set< Model * > active_energy
 
std::set< ModelPosition * > active_velocity
 
std::vector< std::priority_queue< Event > > event_queues
 
Modelground
 
bool paused
 if true, the simulation is stopped
 
std::vector< std::queue< Model * > > pending_update_callbacks
 
std::vector< point_int_trt_candidate_cells
 
std::vector< point_int_trt_cells
 
usec_t sim_interval
 
int update_cb_count
 
- Static Public Attributes inherited from Stg::World
static std::vector< std::string > args
 
static std::string ctrlargs
 
static const int DEFAULT_PPM = 50
 
- Protected Attributes inherited from Stg::World
std::list< std::pair< world_callback_t, void * > > cb_list
 List of callback functions and arguments.
 
bounds3d_t extent
 Describes the 3D volume of the world.
 
bool graphics
 true iff we have a GUI
 
std::set< Option * > option_table
 GUI options (toggles) registered by models.
 
std::list< PowerPack * > powerpack_list
 List of all the powerpacks attached to models in the world.
 
usec_t quit_time
 
std::list< float * > ray_list
 List of rays traced for debug visualization.
 
usec_t sim_time
 the current sim time in this world in microseconds
 
std::map< point_int_t, SuperRegion * > superregions
 
uint64_t updates
 the number of simulated time steps executed so far
 
Worldfilewf
 If set, points to the worldfile used to create this world.
 
- Protected Attributes inherited from Stg::Ancestor
std::map< std::string, unsigned int > child_type_counts
 
std::vector< Model * > children
 
bool debug
 
std::map< std::string, void * > props
 
std::string token
 

Detailed Description

Extends World to implement an FLTK / OpenGL graphical user interface.

Constructor & Destructor Documentation

◆ WorldGui()

WorldGui::WorldGui ( int  width,
int  height,
const char *  caption = NULL 
)

◆ ~WorldGui()

WorldGui::~WorldGui ( )

Member Function Documentation

◆ ClockString()

std::string WorldGui::ClockString ( void  ) const
virtual

Get human readable string that describes the current simulation time.

Reimplemented from Stg::World.

◆ DrawBoundingBoxTree()

void WorldGui::DrawBoundingBoxTree ( )

◆ DrawOccupancy()

void WorldGui::DrawOccupancy ( ) const
protected

◆ DrawVoxels()

void WorldGui::DrawVoxels ( ) const
protected

◆ EnergyString()

std::string WorldGui::EnergyString ( void  ) const

Get human readable string that describes the current global energy state.

◆ GetCanvas()

Canvas * Stg::WorldGui::GetCanvas ( void  ) const
inline

◆ IsGUI()

virtual bool Stg::WorldGui::IsGUI ( ) const
inlinevirtual

Returns true iff this World implements a GUI. The base World class returns false, but subclasses can override this behaviour.

Reimplemented from Stg::World.

◆ IsTopView()

bool WorldGui::IsTopView ( )

◆ Load() [1/2]

bool WorldGui::Load ( const std::string &  worldfile_path)
virtual

Open the file at the specified location, create a Worldfile object, read the file and configure the world from the contents, creating models as necessary. The created object persists, and can be retrieved later with World::GetWorldFile().

Returns
true if load was successful, false otherwise

Reimplemented from Stg::World.

◆ Load() [2/2]

bool WorldGui::Load ( std::istream &  world_content,
const std::string &  worldfile_path = std::string() 
)
virtual

Read the world content from the given stream, create a Worldfile object and configure the world from the contents, creating models as necessary. The created object persists, and can be retrieved later with World::GetWorldFile(). world_content can be any valid std::istream object. If it's a file (std::ifstream), worldfile_path can be specified to be able to resolve relative includes. If worldfile_path is empty, relative includes are not supported (if they are encountered, loading will fail), although includes (and even paths in general, e. g., for "bitmap") with a absolute path are supported.

Returns
true if load was successful, false otherwise

Reimplemented from Stg::World.

◆ PopColor()

void WorldGui::PopColor ( )
protectedvirtual

Reimplemented from Stg::World.

◆ PushColor() [1/2]

void WorldGui::PushColor ( Color  col)
protectedvirtual

dummy implementations to be overloaded by GUI subclasses

Reimplemented from Stg::World.

◆ PushColor() [2/2]

void WorldGui::PushColor ( double  r,
double  g,
double  b,
double  a 
)
protectedvirtual

Reimplemented from Stg::World.

◆ RealTimeNow()

usec_t WorldGui::RealTimeNow ( void  ) const

◆ RecentlySelectedModel()

Model * WorldGui::RecentlySelectedModel ( ) const
virtual

Reimplemented from Stg::World.

◆ Redraw()

void WorldGui::Redraw ( void  )
virtual

Forces the window to be redrawn, even if paused.

Reimplemented from Stg::World.

◆ RemoveChild()

void WorldGui::RemoveChild ( Model mod)
virtual

Reimplemented from Stg::Ancestor.

◆ Save()

bool WorldGui::Save ( const char *  filename)
virtual

Save the current world state into a worldfile with the given filename.

Parameters
Filenameto save as.

Reimplemented from Stg::World.

◆ Show()

void WorldGui::Show ( )

show the window - need to call this if you don't Load().

◆ Start()

void WorldGui::Start ( )
virtual

Reimplemented from Stg::World.

◆ Stop()

void WorldGui::Stop ( )
virtual

Reimplemented from Stg::World.

◆ UnLoad()

void WorldGui::UnLoad ( )
virtual

Reimplemented from Stg::World.

◆ Update()

bool WorldGui::Update ( void  )
virtual

Run one simulation timestep. Advances the simulation clock, executes all simulation updates due at the current time, then queues up future events.

Reimplemented from Stg::World.


The documentation for this class was generated from the following files: