canvas.hh
Go to the documentation of this file.
1 
2 #include "stage.hh"
3 #include "option.hh"
4 
5 #include <map>
6 #include <stack>
7 
8 namespace Stg
9 {
10  class Canvas : public Fl_Gl_Window
11  {
12  friend class WorldGui; // allow access to private members
13  friend class Model;
14 
15  private:
16 
18  {
19  public:
22 
23  void Push( double r, double g, double b, double a=1.0 )
24  {
25  Push( Color(r,g,b,a) );
26  }
27 
28  void Push( Color col )
29  {
30  colorstack.push( col );
31  glColor4f( col.r, col.g, col.b, col.a );
32  }
33 
34  void Pop()
35  {
36  if( colorstack.size() < 1 )
37  PRINT_WARN1( "Attempted to ColorStack.Pop() but ColorStack %p is empty",
38  this );
39  else
40  {
41  Color& old = colorstack.top();
42  colorstack.pop();
43  glColor4f( old.r, old.g, old.b, old.a );
44  }
45  }
46 
47  unsigned int Length()
48  { return colorstack.size(); }
49 
50  private:
51  std::stack<Color> colorstack;
52  } colorstack;
53 
54  std::list<Model*> models_sorted;
55 
61 
62  int startx, starty;
66  std::list<Model*> selected_models;
68 
70  msec_t interval; // window refresh interval in ms
71 
72  void RecordRay( double x1, double y1, double x2, double y2 );
73  void DrawRays();
74  void ClearRays();
75  void DrawGlobalGrid();
76 
77  void AddModel( Model* mod );
78  void RemoveModel( Model* mod );
79 
80  Option //showBlinken,
82  showBlocks,
83  showBlur,
84  showClock,
85  showData,
86  showFlags,
87  showFollow,
89  showGrid,
92  showStatus,
95  showTrails,
96  showVoxels,
97  pCamOn,
99 
100  public:
101  Canvas( WorldGui* world, int x, int y, int width, int height);
102  ~Canvas();
103 
104  bool graphics;
106  unsigned long frames_rendered_count;
108 
109  std::map< std::string, Option* > _custom_options;
110 
111  void Screenshot();
112  void InitGl();
113  void InitTextures();
114  void createMenuItems( Fl_Menu_Bar* menu, std::string path );
115 
116  void FixViewport(int W,int H);
117  void DrawFloor(); //simpler floor compared to grid
118  void DrawBlocks();
119  void DrawBoundingBoxes();
120  void resetCamera();
121  virtual void renderFrame();
122  virtual void draw();
123  virtual int handle( int event );
124  void resize(int X,int Y,int W,int H);
125 
126  void CanvasToWorld( int px, int py,
127  double *wx, double *wy, double* wz );
128 
129  Model* getModel( int x, int y );
130  bool selected( Model* mod );
131  void select( Model* mod );
132  void unSelect( Model* mod );
133  void unSelectAll();
134 
135  inline void setDirtyBuffer( void ) { dirty_buffer = true; }
136  inline bool dirtyBuffer( void ) const { return dirty_buffer; }
137 
138  void PushColor( Color col )
139  { colorstack.Push( col ); }
140 
141  void PushColor( double r, double g, double b, double a )
142  { colorstack.Push( r,g,b,a ); }
143 
144  void PopColor(){ colorstack.Pop(); }
145 
146  void InvertView( uint32_t invertflags );
147 
148  bool VisualizeAll(){ return ! visualizeAll; }
149 
150  static void TimerCallback( Canvas* canvas );
151  static void perspectiveCb( Fl_Widget* w, void* p );
152 
153  void EnterScreenCS();
154  void LeaveScreenCS();
155 
156  void Load( Worldfile* wf, int section );
157  void Save( Worldfile* wf, int section );
158 
159  bool IsTopView(){ return( (fabs( camera.yaw() ) < 0.1) &&
160  (fabs( camera.pitch() ) < 0.1) ); }
161  };
162 
163 } // namespace Stg
Model class
Definition: stage.hh:1742
int starty
Definition: canvas.hh:62
bool selectedModel
Definition: canvas.hh:63
double a
Definition: stage.hh:200
Option showClock
Definition: canvas.hh:81
WorldGui * world
Definition: canvas.hh:105
OrthoCamera camera
Definition: canvas.hh:57
The Stage library uses its own namespace.
Definition: canvas.hh:8
void InitTextures()
Definition: canvas.cc:144
void select(Model *mod)
Definition: canvas.cc:301
std::list< Model * > models_sorted
Definition: canvas.hh:54
void EnterScreenCS()
Definition: canvas.cc:1087
void ClearRays()
void setDirtyBuffer(void)
Definition: canvas.hh:135
Option showScreenshots
Definition: canvas.hh:81
void DrawRays()
void DrawFloor()
Definition: canvas.cc:697
Option showStatus
Definition: canvas.hh:81
void DrawGlobalGrid()
Definition: canvas.cc:618
virtual int handle(int event)
Definition: canvas.cc:364
bool dirty_buffer
Definition: canvas.hh:59
void createMenuItems(Fl_Menu_Bar *menu, std::string path)
Definition: canvas.cc:1188
Model * last_selection
Definition: canvas.hh:67
void DrawBoundingBoxes()
Definition: canvas.cc:720
double yaw(void) const
Definition: stage.hh:1378
Canvas(WorldGui *world, int x, int y, int width, int height)
Definition: canvas.cc:56
PerspectiveCamera perspective_camera
Definition: canvas.hh:58
void DrawBlocks()
Definition: canvas.cc:714
bool graphics
Definition: canvas.hh:104
Option visualizeAll
Definition: canvas.hh:81
void resetCamera()
Definition: canvas.cc:734
void PushColor(Color col)
Definition: canvas.hh:138
Camera * current_camera
Definition: canvas.hh:56
std::map< std::string, Option * > _custom_options
Definition: canvas.hh:109
void Push(Color col)
Definition: canvas.hh:28
void Screenshot()
Definition: canvas.cc:1111
void FixViewport(int W, int H)
Definition: canvas.cc:600
int screenshot_frame_skip
Definition: canvas.hh:107
std::stack< Color > colorstack
Definition: canvas.hh:51
void CanvasToWorld(int px, int py, double *wx, double *wy, double *wz)
Definition: canvas.cc:327
double r
Definition: stage.hh:200
Option showTrailRise
Definition: canvas.hh:81
Option showFootprints
Definition: canvas.hh:81
void unSelectAll()
Definition: canvas.cc:321
void RemoveModel(Model *mod)
Definition: canvas.cc:612
virtual void draw()
Definition: canvas.cc:1276
int empty_space_starty
Definition: canvas.hh:65
Option showBBoxes
Definition: canvas.hh:81
int startx
Definition: canvas.hh:62
bool dirtyBuffer(void) const
Definition: canvas.hh:136
double b
Definition: stage.hh:200
Worldfile * wf
Definition: canvas.hh:60
double g
Definition: stage.hh:200
void LeaveScreenCS()
Definition: canvas.cc:1101
Option showTrails
Definition: canvas.hh:81
unsigned long msec_t
Definition: stage.hh:183
Option showFollow
Definition: canvas.hh:81
Option showBlur
Definition: canvas.hh:81
void Push(double r, double g, double b, double a=1.0)
Definition: canvas.hh:23
double pitch(void) const
Definition: stage.hh:1379
Model * getModel(int x, int y)
Definition: canvas.cc:223
void AddModel(Model *mod)
Definition: canvas.cc:606
Option showData
Definition: canvas.hh:81
void PopColor()
Definition: canvas.hh:144
static void perspectiveCb(Fl_Widget *w, void *p)
Definition: canvas.cc:1173
void Save(Worldfile *wf, int section)
Definition: canvas.cc:1250
void PushColor(double r, double g, double b, double a)
Definition: canvas.hh:141
Option showTrailArrows
Definition: canvas.hh:81
Option showGrid
Definition: canvas.hh:81
std::list< Model * > selected_models
Definition: canvas.hh:66
void Load(Worldfile *wf, int section)
Definition: canvas.cc:1212
Option showFlags
Definition: canvas.hh:81
Option showBlocks
Definition: canvas.hh:81
void InitGl()
Definition: canvas.cc:111
unsigned long frames_rendered_count
Definition: canvas.hh:106
Option showVoxels
Definition: canvas.hh:81
bool VisualizeAll()
Definition: canvas.hh:148
Option pCamOn
Definition: canvas.hh:81
msec_t interval
(even if it is now unselected).
Definition: canvas.hh:70
bool selected(Model *mod)
Definition: canvas.cc:296
void resize(int X, int Y, int W, int H)
Definition: canvas.cc:1324
virtual void renderFrame()
Definition: canvas.cc:787
#define PRINT_WARN1(m, a)
Definition: stage.hh:634
void RecordRay(double x1, double y1, double x2, double y2)
unsigned int Length()
Definition: canvas.hh:47
bool IsTopView()
Definition: canvas.hh:159
Option showOccupancy
Definition: canvas.hh:81
static void TimerCallback(Canvas *canvas)
Definition: canvas.cc:42
void InvertView(uint32_t invertflags)
bool clicked_empty_space
Definition: canvas.hh:64
void unSelect(Model *mod)
Definition: canvas.cc:312
int empty_space_startx
Definition: canvas.hh:65


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09