ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
UserPlot.hh
[詳解]
1
8//
9// Copyright (C) 2011-2024 Yokokura, Yuki
10// This program is free software;
11// you can redistribute it and/or modify it under the terms of the FreeBSD License.
12// For details, see the License.txt file.
13
14#ifndef USERPLOT
15#define USERPLOT
16
17#include <cassert>
18#include <functional>
19#include "ARCSassert.hh"
20#include "ARCSeventlog.hh"
21#include "ARCSgraphics.hh"
22#include "CuiPlot.hh"
23
24namespace ARCS { // ARCS名前空間
26class UserPlot {
27 public:
30 : // 以下でグラフ描画に使用するクラスと変数を初期化
31 Plot(GP.GetFGrefs() , PLOT_LEFT, PLOT_TOP, PLOT_WIDTH, PLOT_HEIGHT), // キュイプロットの設定(例)
32 X1(0), Y1(0), // プロット変数(例)
33
34 // 以下は編集しないこと
35 Graph(GP), DrawPlaneFobj(), DrawPlotFobj() // 初期化子
36 {
37 Initialize(); // 初期化
38 }
39
41 void SetVars(const double x, const double y){
42 // 以下にグラフ描画したい変数値を設定(例)
43 X1 = x;
44 Y1 = y;
45 }
46
47 private:
48 // ユーザカスタムプロットの設定(例)
49 static constexpr bool PLOT_VISIBLE = false;
50 static constexpr int PLOT_LEFT = 1015;
51 static constexpr int PLOT_TOP = 97;
52 static constexpr int PLOT_WIDTH = 300;
53 static constexpr int PLOT_HEIGHT = 270;
54 static constexpr char PLOT_XLABEL[] = "X AXIS [-]";
55 static constexpr char PLOT_YLABEL[] = "Y AXIS [-]";
56 static constexpr double PLOT_XMAX = 10;
57 static constexpr double PLOT_XMIN = -10;
58 static constexpr double PLOT_YMAX = 10;
59 static constexpr double PLOT_YMIN = -10;
60 static constexpr unsigned int PLOT_XGRID = 4;
61 static constexpr unsigned int PLOT_YGRID = 4;
62 static constexpr FGcolors PLOT_AXIS_COLOR = FGcolors::WHITE;
63 static constexpr FGcolors PLOT_GRID_COLOR = FGcolors::GRAY25;
64 static constexpr FGcolors PLOT_BACK_COLOR = FGcolors::BLACK;
65 static constexpr FGcolors PLOT_TEXT_COLOR = FGcolors::WHITE;
66 static constexpr FGcolors PLOT_CURS_COLOR = FGcolors::GRAY50;
67
68 // 以下にグラフ描画に使用するクラスと変数を定義
69 CuiPlot Plot;
70 double X1, Y1;
71
74 void DrawPlotPlane(void){
75 // ユーザカスタムプロットのグラフパラメータの設定&描画(例)
76 Plot.Visible(PLOT_VISIBLE); // 可視化設定
77 Plot.SetColors(
78 PLOT_AXIS_COLOR, // 軸の色の設定
79 PLOT_GRID_COLOR, // グリッドの色の設定
80 PLOT_TEXT_COLOR, // 文字色の設定
81 PLOT_BACK_COLOR, // 背景色の設定
82 PLOT_CURS_COLOR // カーソルの色の設定
83 );
84 Plot.SetAxisLabels(PLOT_XLABEL, PLOT_YLABEL); // 軸ラベルの設定
85 Plot.SetRanges(PLOT_XMIN, PLOT_XMAX, PLOT_YMIN, PLOT_YMAX); // 軸の範囲設定
86 Plot.SetGridDivision(PLOT_XGRID, PLOT_YGRID); // グリッドの分割数の設定
87 Plot.DrawAxis(); // 軸の描画
88 Plot.StorePlaneInBuffer(); // プロット平面の描画データをバッファに保存しておく
89 Plot.Disp(); // プロット平面を画面表示
90 }
91
94 void DrawPlot(void){
95 // ユーザカスタムプロットの描画動作(例)
96 //Plot.LoadPlaneFromBuffer(); // 背景のプロット平面をバッファから読み出す
97
98 // ここに時間で変動するプロットを記述する
99 Plot.Plot(X1, Y1, CuiPlotTypes::PLOT_CROSS, FGcolors::ORANGE); // データ点を1点プロット(例)
100
101 Plot.Disp(); // プロット平面+プロットの描画
102 }
103
104 // ここから下は編集しないこと
105 public:
108 PassedLog();
109 }
110
111 private:
112 UserPlot(const UserPlot&) = delete;
113 UserPlot(UserPlot&&) = delete;
114 const UserPlot& operator=(const UserPlot&) = delete;
115 ARCSgraphics& Graph;
116 std::function<void(void)> DrawPlaneFobj;
117 std::function<void(void)> DrawPlotFobj;
118
120 void Initialize(void){
121 PassedLog();
122 DrawPlaneFobj = [&](void){ return DrawPlotPlane(); }; // プロット平面描画関数への関数オブジェクトをラムダ式で格納
123 DrawPlotFobj = [&](void){ return DrawPlot(); }; // プロット描画関数への関数オブジェクトをラムダ式で格納
124 Graph.SetUserPlotFuncs(DrawPlaneFobj, DrawPlotFobj); // 描画関数オブジェクトをグラフプロットへ渡す
125 }
126};
127}
128
129#endif
130
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
CuiPlot(新型きゅいプロットV2)
FGcolors
色の定義
Definition FrameGraphics.hh:60
グラフィッククラス
Definition ARCSgraphics.hh:23
void SetUserPlotFuncs(const std::function< void(void)> &DrawPlaneFobj, const std::function< void(void)> &DrawPlotFobj)
ユーザカスタムプロット描画関数への関数オブジェクトを設定する関数
Definition ARCSgraphics.cc:84
CuiPlot(新型きゅいプロットV2)
Definition CuiPlot.hh:54
void Disp(void)
画面に表示する関数
Definition CuiPlot.hh:426
void Visible(bool visible)
グラフを表示するかどうか
Definition CuiPlot.hh:445
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 SetColors(FGcolors Axis, FGcolors Grid, FGcolors Text, FGcolors Back, FGcolors Cursor)
グラフの各部の色を設定する関数
Definition CuiPlot.hh:116
void SetAxisLabels(const std::string &xlabel, const std::string &ylabel)
軸ラベルを設定する関数
Definition CuiPlot.hh:145
void StorePlaneInBuffer(void)
現在のプロット平面の状態を背景バッファに保存する関数
Definition CuiPlot.hh:432
void DrawAxis(void)
グラフの軸を描画する関数
Definition CuiPlot.hh:170
void SetGridDivision(size_t xdiv, size_t ydiv)
グリッドの分割数を設定する関数
Definition CuiPlot.hh:161
ユーザカスタムプロットクラス
Definition UserPlot.hh:26
~UserPlot()
デストラクタ
Definition UserPlot.hh:107
UserPlot(ARCSgraphics &GP)
コンストラクタ
Definition UserPlot.hh:29
void SetVars(const double x, const double y)
プロット変数設定関数(例)
Definition UserPlot.hh:41