23#include "RingBuffer.hh"
33 #define arcs_assert(a) (assert(a))
36 #define EventLogVar(a)
67 PLOT_LEFT(LEFT + 3*MARGIN_WIDTH/2),
68 PLOT_TOP(TOP + MARGIN_TOP),
69 PLOT_WIDTH(WIDTH - MARGIN_WIDTH_X2),
70 PLOT_HEIGHT(HEIGHT - MARGIN_TOP - MARGIN_BOTTOM),
89 Xlabel(
"X AXIS [unit]"),
90 Ylabel(
"Y AXIS [unit]"),
121 CursorColor = Cursor;
130 void SetRanges(
double xmin,
double xmax,
double ymin,
double ymax){
137 Xwidth = Xmax - Xmin;
138 Yheight = Ymax - Ymin;
171 if(VisibleFlag ==
false)
return;
173 FG.
DrawRect(PLOT_LEFT, PLOT_TOP, PLOT_WIDTH, PLOT_HEIGHT, AxisColor);
180 if(VisibleFlag ==
false)
return;
189 if(VisibleFlag ==
false)
return;
190 FG.
PrintText(LEFT + LEGEND_LEFT + i*LEGEND_INTERVAL, TOP + LEGEND_TOP, FGalign::ALIGN_LEFT, name);
192 LEFT + LEGEND_LEFT + i*LEGEND_INTERVAL - LEGEND_LINE_WIDTH - 3, TOP + LEGEND_TOP,
193 LEGEND_LINE_WIDTH, LEGEND_LINE_HEIGHT,
202 void DrawLegends(
const std::array<std::string, N>& names,
const std::array<FGcolors, N>& colors){
203 for(
size_t i = 0; i < N; ++i){
213 void DrawLegends(
const std::array<std::string, N>& names,
const std::array<FGcolors, N>& colors,
size_t num){
214 for(
size_t i = 0; i < num; ++i){
222 if(VisibleFlag ==
false)
return;
223 FG.
DrawLine(XtoPixel(x), YtoPixel(Ymax) + 1, XtoPixel(x), YtoPixel(Ymin) - 1, CursorColor);
230 void DrawText(
const double x,
const double y,
const std::string& text){
231 if(VisibleFlag ==
false)
return;
232 FG.
PrintText(XtoPixel(x), YtoPixel(y), FGalign::ALIGN_LEFT, text);
240 void DrawValue(
const double x,
const double y,
const std::string& format,
const double val){
241 if(VisibleFlag ==
false)
return;
242 FG.
PrintValue(XtoPixel(x), YtoPixel(y), FGalign::ALIGN_LEFT, format, val);
251 PlotSingleData(x, y, x, y, type, color);
259 void Plot(
const double x,
const double y,
const CuiPlotTypes type,
const double r,
const double g,
const double b){
277 void Plot(
const double x1,
const double y1,
const double x2,
const double y2,
const CuiPlotTypes type,
const uint32_t color){
278 PlotSingleData(x1, y1, x2, y2, type, color);
286 void Plot(
const double x1,
const double y1,
const double x2,
const double y2,
const CuiPlotTypes type,
const double r,
const double g,
const double b){
306 void Plot(
const std::array<double, N>& x,
const std::array<double, N>& y,
const CuiPlotTypes type,
const uint32_t color){
307 for(
size_t i = 1; i < N; ++i){
308 PlotSingleData(x[i-1], y[i-1], x[i], y[i], type, color);
319 void Plot(
const std::array<double, N>& x,
const std::array<double, N>& y,
const CuiPlotTypes type,
const double r,
const double g,
const double b){
342 for(
size_t i = 2; i <= N; ++i){
343 PlotSingleData(x[i-1], y[i-1], x[i], y[i], type, color);
374 template <
unsigned long N,
bool M = false>
377 double t1, t2, y1, y2;
378 bool LeapZero =
false;
381 for(
size_t i = 1; i < N; ++i){
388 if(LeapZero ==
true && t1 <= Tnow)
break;
389 if(LeapZero ==
true && t2 < t1)
break;
393 PlotSingleData(t1, y1, t2, y2, type, color);
409 template <
unsigned long N,
bool M = false>
420 template <
unsigned long N,
bool M = false>
427 if(VisibleFlag ==
false)
return;
433 if(VisibleFlag ==
false)
return;
439 if(VisibleFlag ==
false)
return;
446 VisibleFlag = visible;
452 static constexpr int MARGIN_TOP = 14;
453 static constexpr int MARGIN_BOTTOM = 23;
454 static constexpr int MARGIN_WIDTH = 30;
455 static constexpr int MARGIN_WIDTH_X2 = MARGIN_WIDTH*2;
456 static constexpr int GRID_AXISLEN = 5;
457 static constexpr int LABEL_VERTICAL_ALIGN = 4;
458 static constexpr int LABEL_MARGIN_X = 3;
459 static constexpr int LABEL_MARGIN_Y = 5;
460 static constexpr int LEGEND_LEFT = 100;
461 static constexpr int LEGEND_TOP = 3;
462 static constexpr int LEGEND_INTERVAL = 70;
463 static constexpr int LEGEND_LINE_WIDTH = 9;
464 static constexpr int LEGEND_LINE_HEIGHT = 9;
465 static constexpr size_t XGRID_MAX = 16;
466 static constexpr size_t YGRID_MAX = 16;
473 const int PLOT_WIDTH;
474 const int PLOT_HEIGHT;
488 std::array<double, XGRID_MAX> Xgrid;
489 std::array<double, YGRID_MAX> Ygrid;
499 void CalcGridNumbers(
void){
501 for(
size_t i = 0; i < XgridNum; ++i){
502 Xgrid[i] = (Xmax - Xmin)/(
double)XgridNum*(double)(i + 1) + Xmin;
505 for(
size_t i = 0; i < YgridNum; ++i){
506 Ygrid[i] = (Ymax - Ymin)/(
double)YgridNum*(double)(i + 1) + Ymin;
511 int XtoPixel(
double x)
const{
512 if(Xmax < x) x = Xmax;
513 if(x < Xmin) x = Xmin;
514 return (
int)((double)PLOT_WIDTH/Xwidth*(x - Xmin)) + PLOT_LEFT;
518 int YtoPixel(
double y)
const{
519 if(Ymax < y) y = Ymax;
520 if(y < Ymin) y = Ymin;
521 return (
int)((double)PLOT_HEIGHT/Yheight*(-y + Ymax)) + PLOT_TOP;
526 if(VisibleFlag ==
false)
return;
528 for(
size_t i = 0; i < XgridNum - 1; ++i){
529 FG.
DrawLine(XtoPixel(Xgrid[i]), YtoPixel(Ymin), XtoPixel(Xgrid[i]), YtoPixel(Ymax), GridColor);
530 FG.
DrawLine(XtoPixel(Xgrid[i]), YtoPixel(Ymin), XtoPixel(Xgrid[i]), YtoPixel(Ymin) - GRID_AXISLEN, AxisColor);
531 FG.
DrawLine(XtoPixel(Xgrid[i]), YtoPixel(Ymax), XtoPixel(Xgrid[i]), YtoPixel(Ymax) + GRID_AXISLEN, AxisColor);
534 for(
size_t i = 0; i < YgridNum - 1; ++i){
535 FG.
DrawLine(XtoPixel(Xmin), YtoPixel(Ygrid[i]), XtoPixel(Xmax), YtoPixel(Ygrid[i]), GridColor);
536 FG.
DrawLine(XtoPixel(Xmin), YtoPixel(Ygrid[i]), XtoPixel(Xmin) + GRID_AXISLEN, YtoPixel(Ygrid[i]), AxisColor);
537 FG.
DrawLine(XtoPixel(Xmax), YtoPixel(Ygrid[i]), XtoPixel(Xmax) - GRID_AXISLEN, YtoPixel(Ygrid[i]), AxisColor);
542 void DrawLabels(
void){
543 if(VisibleFlag ==
false)
return;
545 for(
size_t i = 0; i < XgridNum - 1; ++i){
546 FG.
PrintValue(XtoPixel(Xgrid[i]), YtoPixel(Ymin) + LABEL_MARGIN_X, FGalign::ALIGN_CENTER, Xform, Xgrid[i]);
548 for(
size_t i = 0; i < YgridNum - 1; ++i){
549 FG.
PrintValue(XtoPixel(Xmin) - LABEL_MARGIN_Y, YtoPixel(Ygrid[i]) - LABEL_VERTICAL_ALIGN, FGalign::ALIGN_RIGHT, Yform, Ygrid[i]);
552 FG.
PrintValue(XtoPixel(Xmax), YtoPixel(Ymin) + LABEL_MARGIN_X, FGalign::ALIGN_CENTER, Xform, Xmax);
553 FG.
PrintValue(XtoPixel(Xmin), YtoPixel(Ymin) + LABEL_MARGIN_X, FGalign::ALIGN_CENTER, Xform, Xmin);
555 FG.
PrintValue(XtoPixel(Xmin) - LABEL_MARGIN_Y, YtoPixel(Ymax), FGalign::ALIGN_RIGHT, Yform, Ymax);
556 FG.
PrintValue(XtoPixel(Xmin) - LABEL_MARGIN_Y, YtoPixel(Ymin) - LABEL_VERTICAL_ALIGN*2, FGalign::ALIGN_RIGHT, Yform, Ymin);
558 FG.
PrintText(XtoPixel(Xwidth/2.0 + Xmin), YtoPixel(Ymin) + LABEL_VERTICAL_ALIGN*2 + LABEL_MARGIN_X*2, FGalign::ALIGN_CENTER, Xlabel);
559 FG.
PrintText(LEFT + 2, TOP + 2, FGalign::ALIGN_LEFT, Ylabel);
569 void PlotSingleData(
const double x1,
const double y1,
const double x2,
const double y2,
const CuiPlotTypes type,
const uint32_t color){
570 if(VisibleFlag ==
false)
return;
572 case CuiPlotTypes::PLOT_LINE:
573 FG.
DrawLine(XtoPixel(x1), YtoPixel(y1), XtoPixel(x2), YtoPixel(y2), color);
575 case CuiPlotTypes::PLOT_BOLDLINE:
576 FG.
DrawLine<FGsize::PX_2>(XtoPixel(x1), YtoPixel(y1), XtoPixel(x2), YtoPixel(y2), color);
578 case CuiPlotTypes::PLOT_DOT:
579 FG.
DrawPoint(XtoPixel(x1), YtoPixel(y1), color);
581 case CuiPlotTypes::PLOT_BOLDDOT:
582 FG.
DrawPoint<FGsize::PX_3>(XtoPixel(x1), YtoPixel(y1), color);
584 case CuiPlotTypes::PLOT_CROSS:
585 FG.
DrawCross(XtoPixel(x1), YtoPixel(y1), color);
587 case CuiPlotTypes::PLOT_STAIRS:
588 FG.
DrawStairs(XtoPixel(x1), YtoPixel(y1), XtoPixel(x2), YtoPixel(y2), color);
590 case CuiPlotTypes::PLOT_BOLDSTAIRS:
591 FG.
DrawStairs<FGsize::PX_2>(XtoPixel(x1), YtoPixel(y1), XtoPixel(x2), YtoPixel(y2), color);
593 case CuiPlotTypes::PLOT_LINEANDDOT:
594 FG.
DrawLine(XtoPixel(x1), YtoPixel(y1), XtoPixel(x2), YtoPixel(y2), color);
595 FG.
DrawPoint<FGsize::PX_3>(XtoPixel(x1), YtoPixel(y1), color);
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
#define arcs_assert(a)
ARCS用assertマクロ a : assert条件
Definition ARCSassert.hh:17
CuiPlotTypes
プロットタイプの定義
Definition CuiPlot.hh:42
@ PLOT_LINEANDDOT
線と点の複合プロット
@ PLOT_BOLDSTAIRS
太線階段プロット
フレームグラフィックスクラスV2(新型テンプレート版)
FGcolors
色の定義
Definition FrameGraphics.hh:60
CuiPlot(新型きゅいプロットV2)
Definition CuiPlot.hh:54
void DrawCursorX(const double x)
x軸カーソルを描画する関数
Definition CuiPlot.hh:221
void Plot(const std::array< double, N > &x, const std::array< double, N > &y, const CuiPlotTypes type, const double r, const double g, const double b)
std::array配列データをプロットする関数(RGB輝度値版)
Definition CuiPlot.hh:319
void Disp(void)
画面に表示する関数
Definition CuiPlot.hh:426
void TimeSeriesPlot(RingBuffer< double, N, M > &t, RingBuffer< double, N, M > &y, const CuiPlotTypes type, const FGcolors color)
リングバッファの時系列データをプロットする関数(色の名前版)
Definition CuiPlot.hh:421
void Visible(bool visible)
グラフを表示するかどうか
Definition CuiPlot.hh:445
void Plot(const std::array< double, N > &x, const std::array< double, N > &y, const CuiPlotTypes type, const FGcolors color)
std::array配列データをプロットする関数(色の名前版)
Definition CuiPlot.hh:330
void Plot(const double x1, const double y1, const double x2, const double y2, const CuiPlotTypes type, const uint32_t color)
2点のデータをプロットする関数(バイナリ色データ版)
Definition CuiPlot.hh:277
void Plot(const double x1, const double y1, const double x2, const double y2, const CuiPlotTypes type, const double r, const double g, const double b)
2点のデータをプロットする関数(RGB輝度値版)
Definition CuiPlot.hh:286
void SetRanges(double xmin, double xmax, double ymin, double ymax)
グラフの範囲を設定する関数
Definition CuiPlot.hh:130
void Plot(const double x, const double y, const CuiPlotTypes type, const uint32_t color)
1点のデータをプロットする関数(バイナリ色データ版)
Definition CuiPlot.hh:250
void Plot(const Matrix< 1, N > &x, const Matrix< 1, N > &y, const CuiPlotTypes type, const double r, const double g, const double b)
Matrix縦ベクトルデータをプロットする関数(RGB輝度値版)
Definition CuiPlot.hh:354
void SetGridLabelFormat(const std::string &xformat, const std::string &yformat)
グリッドラベルの書式を設定する関数
Definition CuiPlot.hh:153
void ClearAxis(void)
グラフの軸をクリアする関数
Definition CuiPlot.hh:179
void LoadPlaneFromBuffer(void)
背景バッファからプロット平面の状態を読み込む関数
Definition CuiPlot.hh:438
void Plot(const double x1, const double y1, const double x2, const double y2, const CuiPlotTypes type, const FGcolors color)
2点のデータをプロットする関数(色の名前版)
Definition CuiPlot.hh:295
void Plot(const std::array< double, N > &x, const std::array< double, N > &y, const CuiPlotTypes type, const uint32_t color)
std::array配列データをプロットする関数(バイナリ色データ版)
Definition CuiPlot.hh:306
void TimeSeriesPlot(RingBuffer< double, N, M > &t, RingBuffer< double, N, M > &y, const CuiPlotTypes type, const uint32_t color)
リングバッファの時系列データをプロットする関数(バイナリ色データ版)
Definition CuiPlot.hh:375
void SetColors(FGcolors Axis, FGcolors Grid, FGcolors Text, FGcolors Back, FGcolors Cursor)
グラフの各部の色を設定する関数
Definition CuiPlot.hh:116
void TimeSeriesPlot(RingBuffer< double, N, M > &t, RingBuffer< double, N, M > &y, const CuiPlotTypes type, const double r, const double g, const double b)
リングバッファの時系列データをプロットする関数(RGB輝度値版)
Definition CuiPlot.hh:410
void SetAxisLabels(const std::string &xlabel, const std::string &ylabel)
軸ラベルを設定する関数
Definition CuiPlot.hh:145
CuiPlot(FrameGraphics &Frame, int Left, int Top, int Width, int Height)
コンストラクタ
Definition CuiPlot.hh:62
void Plot(const double x, const double y, const CuiPlotTypes type, const FGcolors color)
1点のデータをプロットする関数(色の名前版)
Definition CuiPlot.hh:268
~CuiPlot()
デストラクタ
Definition CuiPlot.hh:106
void StorePlaneInBuffer(void)
現在のプロット平面の状態を背景バッファに保存する関数
Definition CuiPlot.hh:432
void Plot(const Matrix< 1, N > &x, const Matrix< 1, N > &y, const CuiPlotTypes type, const uint32_t color)
Matrix縦ベクトルデータをプロットする関数(バイナリ色データ版)
Definition CuiPlot.hh:341
CuiPlot(CuiPlot &&r)=delete
ムーブコンストラクタ
void DrawText(const double x, const double y, const std::string &text)
文字列を描画する関数
Definition CuiPlot.hh:230
void DrawAxis(void)
グラフの軸を描画する関数
Definition CuiPlot.hh:170
void DrawValue(const double x, const double y, const std::string &format, const double val)
数値を描画する関数
Definition CuiPlot.hh:240
void Plot(const double x, const double y, const CuiPlotTypes type, const double r, const double g, const double b)
1点のデータをプロットする関数(RGB輝度値版)
Definition CuiPlot.hh:259
void DrawLegends(const std::array< std::string, N > &names, const std::array< FGcolors, N > &colors)
凡例を描画する関数(std::array版)
Definition CuiPlot.hh:202
void Plot(const Matrix< 1, N > &x, const Matrix< 1, N > &y, const CuiPlotTypes type, const FGcolors color)
Matrix縦ベクトルデータをプロットする関数(色の名前版)
Definition CuiPlot.hh:365
void DrawLegends(const std::array< std::string, N > &names, const std::array< FGcolors, N > &colors, size_t num)
凡例を描画する関数(std::array, 個数指定版)
Definition CuiPlot.hh:213
void SetGridDivision(size_t xdiv, size_t ydiv)
グリッドの分割数を設定する関数
Definition CuiPlot.hh:161
void DrawLegend(size_t i, const std::string &name, const FGcolors &color)
凡例を描画する関数
Definition CuiPlot.hh:188
フレームグラフィックスクラス(新型テンプレート版)
Definition FrameGraphics.hh:91
void DrawPoint(int x, int y, uint32_t ColorData)
点(x,y)を描画する関数(バイナリデータ版)
Definition FrameGraphics.hh:334
void DrawRect(int x, int y, int w, int h, uint32_t ColorData)
長方形の描画をする関数(バイナリ色データ版)(色は塗らない)
Definition FrameGraphics.hh:577
void DrawCross(int x, int y, uint32_t ColorData)
十字(x,y)を描画する関数(バイナリデータ版)
Definition FrameGraphics.hh:397
void DrawStairs(int x1, int y1, int x2, int y2, uint32_t ColorData)
階段直線(x1,y1)ー(x2,y2)を引く関数(バイナリデータ版)
Definition FrameGraphics.hh:546
uint32_t ColorNameToData(FGcolors color)
色の名前からバイナリ色データに変換する関数
Definition FrameGraphics.hh:797
void RefreshFrame(void)
フレームバッファを更新する関数
Definition FrameGraphics.hh:237
void PrepareFontData(FGcolors fore_color, FGcolors back_color)
指定した色のフォントデータを準備する関数
Definition FrameGraphics.hh:678
void LoadBackgroundToScreen(void)
背景バッファを画面バッファへ読み込む関数
Definition FrameGraphics.hh:273
void DrawLine(int x1, int y1, int x2, int y2, uint32_t ColorData)
直線(x1,y1)ー(x2,y2)を引く関数(バイナリデータ版)
Definition FrameGraphics.hh:431
void PrintText(int x, int y, FGalign align, std::string text)
文字列を描画する関数 x:[px]横位置,y:[px] 縦位置,align:揃え位置,text:所望の文字列
Definition FrameGraphics.hh:699
uint32_t RGBcolorToData(double Red, double Green, double Blue)
0~1の浮動小数点で表現された赤緑青色の輝度値をバイナリ色データに変える
Definition FrameGraphics.hh:803
void DrawRectFill(int x, int y, int w, int h, uint32_t ColorData)
長方形の範囲内に色を塗る関数(バイナリ色データ版) (色を塗る)
Definition FrameGraphics.hh:608
void StoreScreenAsBackground(void)
現在の画面バッファを背景バッファとして保存する関数
Definition FrameGraphics.hh:255
void PrintValue(int x, int y, FGalign align, std::string format, double val)
指定した書式で文字列を描画する関数 x:[px] 横位置,y:[px] 縦位置,align:揃え位置,format:書式指定子,val:所望の数値 formatの書式指定子は printf関数 の場合の...
Definition FrameGraphics.hh:724
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
リングバッファクラス
Definition RingBuffer.hh:51
T GetRelativeValueFromFirst(const unsigned long k)
バッファの最先端から k だけ後方側に戻ったところの値を取り出す関数
Definition RingBuffer.hh:100
T GetFirstValue(void)
値をバッファの現在の先頭から取り出す関数
Definition RingBuffer.hh:90