Apollo 10.0
自动驾驶开放平台
Screen类 参考final

#include <screen.h>

Screen 的协作图:

Public 类型

enum  ColorPair {
  INVALID = 0 , GREEN_BLACK = 1 , YELLOW_BLACK , RED_BLACK ,
  WHITE_BLACK , BLACK_WHITE
}
 

Public 成员函数

 ~Screen (void)
 
void Init (void)
 
void Run (void)
 
void Resize ()
 
void Stop (void)
 
int Width (void) const
 
int Height (void) const
 
void AddStr (int x, int y, ColorPair color, const char *str) const
 
ColorPair Color (void) const
 
void SetCurrentColor (ColorPair color) const
 
void AddStr (int x, int y, const char *str) const
 
void AddStr (const char *str) const
 
void MoveOffsetXY (int offsetX, int offsetY) const
 
void ClearCurrentColor (void) const
 
void SetCurrentRenderMessage (RenderableMessage *const render_obj)
 

静态 Public 成员函数

static ScreenInstance (void)
 

静态 Public 属性

static const char InteractiveCmdStr []
 

详细描述

在文件 screen.h30 行定义.

成员枚举类型说明

◆ ColorPair

枚举值
INVALID 
GREEN_BLACK 
YELLOW_BLACK 
RED_BLACK 
WHITE_BLACK 
BLACK_WHITE 

在文件 screen.h34 行定义.

34 { // foreground color - background color
35 INVALID = 0,
36 GREEN_BLACK = 1,
41 };
@ BLACK_WHITE
Definition screen.h:40
@ INVALID
Definition screen.h:35
@ WHITE_BLACK
Definition screen.h:39
@ GREEN_BLACK
Definition screen.h:36
@ YELLOW_BLACK
Definition screen.h:37
@ RED_BLACK
Definition screen.h:38

构造及析构函数说明

◆ ~Screen()

Screen::~Screen ( void  )

在文件 screen.cc87 行定义.

87 {
88 current_render_obj_ = nullptr;
89 endwin();
90}

成员函数说明

◆ AddStr() [1/3]

void Screen::AddStr ( const char *  str) const

在文件 screen.cc139 行定义.

139 {
140 if (IsInit()) {
141 addstr(str);
142 }
143}

◆ AddStr() [2/3]

void Screen::AddStr ( int  x,
int  y,
ColorPair  color,
const char *  str 
) const

在文件 screen.cc152 行定义.

152 {
153 if (IsInit()) {
154 attron(COLOR_PAIR(color));
155 mvaddstr(y, x, str);
156 attroff(COLOR_PAIR(color));
157 }
158}

◆ AddStr() [3/3]

void Screen::AddStr ( int  x,
int  y,
const char *  str 
) const

在文件 screen.cc133 行定义.

133 {
134 if (IsInit()) {
135 mvaddstr(y, x, str);
136 }
137}

◆ ClearCurrentColor()

void Screen::ClearCurrentColor ( void  ) const

在文件 screen.cc145 行定义.

145 {
146 if (IsInit()) {
147 attroff(COLOR_PAIR(current_color_pair_));
148 current_color_pair_ = INVALID;
149 }
150}

◆ Color()

ColorPair Screen::Color ( void  ) const
inline

在文件 screen.h56 行定义.

56{ return current_color_pair_; }

◆ Height()

int Screen::Height ( void  ) const

在文件 screen.cc122 行定义.

122{ return LINES; }

◆ Init()

void Screen::Init ( void  )

在文件 screen.cc94 行定义.

94 {
95 initscr();
96 if (stdscr == nullptr) {
97 return;
98 }
99 nodelay(stdscr, true);
100 keypad(stdscr, true);
101 meta(stdscr, true);
102 curs_set(0);
103 noecho();
104
105 bkgd(COLOR_BLACK);
106
107 start_color();
108 init_pair(GREEN_BLACK, COLOR_GREEN, COLOR_BLACK);
109 init_pair(YELLOW_BLACK, COLOR_YELLOW, COLOR_BLACK);
110 init_pair(RED_BLACK, COLOR_RED, COLOR_BLACK);
111 init_pair(WHITE_BLACK, COLOR_WHITE, COLOR_BLACK);
112 init_pair(BLACK_WHITE, COLOR_BLACK, COLOR_WHITE);
113
114 refresh();
115 clear();
116
117 canRun_ = true;
118}

◆ Instance()

Screen * Screen::Instance ( void  )
static

在文件 screen.cc39 行定义.

39 {
40 static Screen s;
41 return &s;
42}

◆ MoveOffsetXY()

void Screen::MoveOffsetXY ( int  offsetX,
int  offsetY 
) const

在文件 screen.cc160 行定义.

160 {
161 if (IsInit()) {
162 int x, y;
163 getyx(stdscr, y, x);
164 move(y + offsetY, x + offsetX);
165 }
166}

◆ Resize()

void Screen::Resize ( void  )

在文件 screen.cc242 行定义.

242 {
243 if (IsInit()) {
244 clear();
245 refresh();
246 }
247}

◆ Run()

void Screen::Run ( void  )

在文件 screen.cc210 行定义.

210 {
211 if (stdscr == nullptr || current_render_obj_ == nullptr) {
212 return;
213 }
214
215 highlight_direction_ = 0;
216
217 void (Screen::*showFuncs[])(int) = {&Screen::ShowRenderMessage,
218 &Screen::ShowInteractiveCmd};
219
220 do {
221 int ch = getch();
222
223 if (ch == 'q' || ch == 'Q' || ch == 27) {
224 canRun_ = false;
225 break;
226 }
227
228 ch = SwitchState(ch);
229
230 (this->*showFuncs[static_cast<int>(current_state_)])(ch);
231
232 double fr = current_render_obj_->frame_ratio();
233 if (fr < MinHalfFrameRatio) {
234 fr = MinHalfFrameRatio;
235 }
236 int period = static_cast<int>(1000.0 / fr);
237 period >>= 1;
238 std::this_thread::sleep_for(std::chrono::milliseconds(period));
239 } while (canRun_);
240}
virtual double frame_ratio(void)

◆ SetCurrentColor()

void Screen::SetCurrentColor ( ColorPair  color) const

在文件 screen.cc124 行定义.

124 {
125 if (color == INVALID) {
126 return;
127 }
128 if (IsInit()) {
129 current_color_pair_ = color;
130 attron(COLOR_PAIR(color));
131 }
132}

◆ SetCurrentRenderMessage()

void Screen::SetCurrentRenderMessage ( RenderableMessage *const  render_obj)
inline

在文件 screen.h63 行定义.

63 {
64 if (render_obj) {
65 current_render_obj_ = render_obj;
66 }
67 }

◆ Stop()

void Screen::Stop ( void  )
inline

在文件 screen.h49 行定义.

49{ canRun_ = false; }

◆ Width()

int Screen::Width ( void  ) const

在文件 screen.cc120 行定义.

120{ return COLS; }

类成员变量说明

◆ InteractiveCmdStr

const char Screen::InteractiveCmdStr
static

在文件 screen.h32 行定义.


该类的文档由以下文件生成: