FineKernelToolKit 4.2.13
読み取り中…
検索中…
一致する文字列を見つけられません
Window.h
[詳解]
1#if !defined(__FK_WINDOW_HEADER__)
2#define __FK_WINDOW_HEADER__
3
4#include <stdarg.h>
5#include <map>
6
7// for Graphics Header.
8#include <FL/Fl_Gl_Window.H>
9#include <FL/Fl_Multi_Browser.H>
10
11// for FK Header.
12#include <FK/FrameController.h>
13#include <FK/Plane.h>
14#include <FK/Image.h>
15#include <FK/Model.h>
16
17// for Graphics Routine
18
19namespace FK {
20 class fk_GraphicsEngine;
21 class fk_Scene;
22
24 enum class fk_Key {
25 SHIFT_R,
26 SHIFT_L,
27 CTRL_R,
28 CTRL_L,
29 ALT_R,
30 ALT_L,
31 ENTER,
32 BACKSPACE,
33 DEL,
34 CAPS_LOCK,
35 TAB,
36 PAGE_UP,
37 PAGE_DOWN,
38 HOME,
39 END,
40 INSERT,
41 LEFT,
42 RIGHT,
43 UP,
44 DOWN,
45 F1,
46 F2,
47 F3,
48 F4,
49 F5,
50 F6,
51 F7,
52 F8,
53 F9,
54 F10,
55 F11,
56 F12,
57 SPACE
58 };
59
61 enum class fk_MouseButton {
62 M1,
63 M2,
64 M3
65 };
66
68 enum class fk_PutStrMode {
69 NONE,
70 CONSOLE,
72 BROWSER,
73 FILE
74 };
75
77 enum class fk_Switch {
78 RELEASE,
79 UP,
80 DOWN,
81 PRESS
82 };
83
85
120 class fk_Window : public Fl_Gl_Window {
121
122#if !defined(FK_DOXYGEN_USER_PROCESS)
123 class Member {
124 public:
125 fk_Image snapBuffer;
126 bool winOpenFlag;
127 int GLWinXPosition;
128 int GLWinYPosition;
129 int GLWinWSize;
130 int GLWinHSize;
131 char lastKey;
132 std::map<char, bool> keyStatus;
133 std::map<fk_Key, bool> specialKeyStatus;
134 std::map<fk_MouseButton, bool> mouseStatus;
135 double frameTime, prevTime;
136 double frameInterval;
137 int skipCount;
138 fk_FrameController fps_admin;
139 int fps;
140#if !defined(FK_OLD_NONSUPPORT)
141 bool stereoMode;
142#endif
143
144 Member(int, int, int, int);
145 };
146#endif
147
148 public:
149
151
158 fk_Window(int x = 0, int y = 0, int w = 300, int h = 300, std::string name = "FK Window");
159
161 virtual ~fk_Window();
162
163
166
168
173 void setScene(fk_Scene *scene);
175
178
180
195 int drawWindow(bool drawFlag = true);
196
198
207 bool winOpenStatus(void);
208
210
218 void resizeWindow(int x, int y, int w, int h);
219
221
257 bool getKeyStatus(char key, fk_Switch status, bool insideFlag = true);
258
260
287 bool getKeyStatus(char key, bool insideFlag = true);
288
290
327 bool getSpecialKeyStatus(fk_Key key, fk_Switch status, bool insideFlag = true);
328
330
357 bool getSpecialKeyStatus(fk_Key key, bool insideFlag = true);
358
360
379 bool getKeyStatus(fk_Key key, fk_Switch status, bool insideFlag = true);
380
382
398 bool getKeyStatus(fk_Key key, bool insideFlag = true);
399
401
419 char getLastKey(void);
420
422
448 std::tuple<int, int> getMousePosition(bool insideFlag = true);
449
450#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
451 void getMousePosition(int *, int *, bool = true);
452#endif
453
455
482 bool getMouseStatus(fk_MouseButton button, fk_Switch status, bool insideFlag = true);
483
484#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
485 bool getMouseStatus(fk_MouseButton, bool = true);
486#endif
487
489
505
508
517 void setFPS(int fps);
518
520
523
525
544 std::tuple<bool, fk_Vector> getProjectPosition(double x, double y, fk_Plane &plane);
545
546#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
547 bool getProjectPosition(double x, double y, fk_Plane *plane, fk_Vector *pos);
548#endif
550
566 std::tuple<bool, fk_Vector> getProjectPosition(double x, double y, double dist);
567
568#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
569 bool getProjectPosition(double x, double y, double dist, fk_Vector *pos);
570#endif
572
592 std::tuple<bool, fk_Vector> getWindowPosition(fk_Vector &pos_3D);
593
594#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
596#endif
598
601
603
613 virtual void preInit(void) {}
614
616
626 virtual void postInit(void) {}
627
629
637 virtual void preDraw(void) {}
638
640
648 virtual void postDraw(void) {}
650
651#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
652 virtual void preDrawLeft(void) {}
653 virtual void postDrawLeft(void) {}
654 virtual void preDrawRight(void) {}
655 virtual void postDrawRight(void) {}
656#endif
657
658#if !defined(FK_DOXYGEN_USER_PROCESS)
659 std::list<fk_funcSet> preDrawList;
660 std::list<fk_funcSet> postDrawList;
661#endif
662
665
667
683 bool snapImage(std::string fileName,
686
688
703
706
708
731 static void setPutStrMode(const fk_PutStrMode mode);
732
734
742
744
761 static bool setPutFile(const std::string &fileName);
762
764
778 static void putString(const std::string &str);
779
780#if !defined(FK_CLI_CODE)
782
796 static void printf(const char *format, ...);
797#endif
798
800
813 static void clearBrowser(void);
814
816
827 static void fontInit(void);
828
830
831#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
834
836
856 void setOGLStereoMode(bool mode);
857
859
872 bool getOGLStereoMode(void);
874#endif
875
876#if !defined(FK_DOXYGEN_USER_PROCESS)
877 fk_GraphicsEngine * GetEngine(void);
878#endif
879
880 private:
881 std::unique_ptr<Member> _m;
882
883 static inline std::unique_ptr<Fl_Window> _s_putWin;
884 static inline Fl_Multi_Browser * _s_browser;
885 static inline std::unique_ptr<fk_PutStrMode> _s_putStrMode;
886 static inline std::unique_ptr<std::ofstream> _s_putStrOFS;
887 static inline std::unique_ptr<int> _s_winNum;
888
889 static inline std::unique_ptr<Fl_Window> _s_error_win;
890 static inline std::map<fk_Key, int> _keyMap;
891
892 bool IsInsideWindow(void);
893 Fl_Group * GetInhParentWindow(void);
894 void PushPrevStatus(void);
895
896 void draw(); // virtual Function from Fl_Gl_Window class
897
898 static void PutBrowser(const std::string &);
899
900#if defined(WIN32)
901 bool SnapImageGDI(fk_Image *);
902#endif
903 static void ErrorInit(void);
904 static void MakeKeyMap(void);
905
906 static void StaticInit(void);
907 bool GetMouseStatus(fk_MouseButton, bool);
908
909 protected:
910
911#if !defined(FK_DOXYGEN_USER_PROCESS)
912 std::unique_ptr<fk_GraphicsEngine> _m_engine;
913
914 void drawScene(void);
915 void drawSceneLeft(void);
916 void drawSceneRight(void);
917#endif
918
919 };
920}
921
922#endif /* !__FK_WINDOW_HEADER__ */
923
924/****************************************************************************
925 *
926 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
927 *
928 * Redistribution and use in source and binary forms,
929 * with or without modification, are permitted provided that the
930 * following conditions are met:
931 *
932 * - Redistributions of source code must retain the above
933 * copyright notice, this list of conditions and the
934 * following disclaimer.
935 *
936 * - Redistributions in binary form must reproduce the above
937 * copyright notice, this list of conditions and the
938 * following disclaimer in the documentation and/or
939 * other materials provided with the distribution.
940 *
941 * - Neither the name of the copyright holders nor the names
942 * of its contributors may be used to endorse or promote
943 * products derived from this software without specific
944 * prior written permission.
945 *
946 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
947 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
948 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
949 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
950 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
951 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
952 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
953 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
954 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
955 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
956 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
957 * POSSIBILITY OF SUCH DAMAGE.
958 *
959 ****************************************************************************/
960/****************************************************************************
961 *
962 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
963 *
964 * 本ソフトウェアおよびソースコードのライセンスは、基本的に
965 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
966 *
967 * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
968 * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
969 *
970 * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
971 * および下記免責条項を含めること。
972 *
973 * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
974 * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
975 * 含めること。
976 *
977 * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
978 * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
979 * コントリビューターの名前を使用してはならない。
980 *
981 * 本ソフトウェアは、著作権者およびコントリビューターによって「現
982 * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
983 * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
984 * に限定されない、いかなる保証もないものとします。著作権者もコン
985 * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
986 * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
987 * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
988 * 能性を知らされていたとしても、本ソフトウェアの使用によって発生
989 * した(代替品または代用サービスの調達、使用の喪失、データの喪失、
990 * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
991 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
992 * ついて、一切責任を負わないものとします。
993 *
994 ****************************************************************************/
フレームレート制御クラス
Definition FrameController.h:28
画像を生成、管理するクラス
Definition Image.h:260
幾何平面を管理するクラス
Definition Plane.h:32
シーンを制御するクラス
Definition Scene.h:48
3次元ベクトルを管理するクラス
Definition Vector.h:45
FLTK 用シーン描画ウィジェットクラス
Definition Window.h:120
char getLastKey(void)
最終押下キー取得関数
bool getKeyStatus(fk_Key key, fk_Switch status, bool insideFlag=true)
特殊キー状態取得関数3
virtual ~fk_Window()
デストラクタ
bool snapImage(fk_Image *image, fk_SnapProcMode mode=fk_SnapProcMode::FRONT)
描画画像データ出力関数
int getMouseWheelStatus(void)
マウスホイール回転量取得関数
int drawWindow(bool drawFlag=true)
描画更新関数
bool getSpecialKeyStatus(fk_Key key, fk_Switch status, bool insideFlag=true)
特殊キー状態取得関数1
bool winOpenStatus(void)
描画状態取得関数
std::tuple< bool, fk_Vector > getProjectPosition(double x, double y, fk_Plane &plane)
投影平面から任意平面への射影点算出関数
bool getKeyStatus(char key, fk_Switch status, bool insideFlag=true)
標準キー状態取得関数1
static bool setPutFile(const std::string &fileName)
メッセージ出力用ファイル設定関数
static void printf(const char *format,...)
メッセージ出力書式付き設定関数
virtual void preDraw(void)
描画前処理関数
Definition Window.h:637
fk_Window(int x=0, int y=0, int w=300, int h=300, std::string name="FK Window")
コンストラクタ
void setFPS(int fps)
std::tuple< bool, fk_Vector > getWindowPosition(fk_Vector &pos_3D)
空間座標から投影座標への射影点算出関数
virtual void postInit(void)
初期化後処理関数
Definition Window.h:626
static void clearBrowser(void)
メッセージ出力用ブラウザ初期化関数
static void putString(const std::string &str)
メッセージ出力文字列設定関数
bool getKeyStatus(fk_Key key, bool insideFlag=true)
特殊キー状態取得関数4
virtual void postDraw(void)
描画後処理関数
Definition Window.h:648
bool snapImage(std::string fileName, fk_ImageType format=fk_ImageType::BMP, fk_SnapProcMode mode=fk_SnapProcMode::FRONT)
描画画像ファイル出力関数
bool getMouseStatus(fk_MouseButton button, fk_Switch status, bool insideFlag=true)
マウスボタン状態取得関数
void resizeWindow(int x, int y, int w, int h)
描画領域寸法変更関数
bool getKeyStatus(char key, bool insideFlag=true)
標準キー状態取得関数2
bool getSpecialKeyStatus(fk_Key key, bool insideFlag=true)
特殊キー状態取得関数2
virtual void preInit(void)
初期化前処理関数
Definition Window.h:613
static fk_PutStrMode getPutStrMode(void)
メッセージ出力モード参照関数
static void setPutStrMode(const fk_PutStrMode mode)
メッセージ出力モード設定関数
std::tuple< int, int > getMousePosition(bool insideFlag=true)
マウスポインタ位置取得関数
void setScene(fk_Scene *scene)
シーン登録関数
static void fontInit(void)
フォント初期化関数
std::tuple< bool, fk_Vector > getProjectPosition(double x, double y, double dist)
投影平面から任意距離での射影点算出関数
Fine Kernel Toolkit 名前空間
Definition Angle.h:6
fk_PutStrMode
メッセージ出力タイプを表す列挙型
Definition Window.h:68
@ CONSOLE
コンソール標準出力
@ ERR_CONSOLE
コンソールエラー出力
@ BROWSER
専用ブラウザ出力
@ FILE
ファイル出力
@ NONE
未定義境界
fk_Key
特殊キーを表す列挙型
Definition Window.h:24
@ F6
F6 ファンクションキー
@ DEL
デリート(削除)キー
@ CTRL_R
右コントロールキー
@ ENTER
エンター(改行、リターン)キー
@ F5
F5 ファンクションキー
@ F7
F7 ファンクションキー
@ F8
F8 ファンクションキー
@ F3
F3 ファンクションキー
@ ALT_R
右オルトキー
@ SHIFT_R
右シフトキー
@ INSERT
インサートキー
@ SHIFT_L
左シフトキー
@ F11
F11 ファンクションキー
@ SPACE
スペースキー
@ BACKSPACE
バックスペース(後退)キー
@ HOME
ホームキー
@ F9
F9 ファンクションキー
@ ALT_L
左オルトキー
@ END
エンドキー
@ F10
F10 ファンクションキー
@ DOWN
下矢印キー
@ F1
F1 ファンクションキー
@ CAPS_LOCK
キャップスロックキー
@ PAGE_UP
ページアップキー
@ F4
F4 ファンクションキー
@ F12
F12 ファンクションキー
@ PAGE_DOWN
ページダウンキー
@ CTRL_L
左コントロールキー
@ TAB
タブキー
@ UP
上矢印キー
@ F2
F2 ファンクションキー
fk_SnapProcMode
画像取り込み方法を表す列挙型
Definition Image.h:56
@ FRONT
OpenGL フロントバッファ
fk_ImageType
画像フォーマットを表す列挙型
Definition Image.h:49
@ BMP
Windows Bitmap (BMP) 形式
fk_Switch
ボタン系デバイス状態を表す列挙型
Definition Window.h:77
@ RELEASE
離しっぱなしの状態
@ PRESS
押しっぱなしの状態
fk_MouseButton
マウスボタンを表す列挙型
Definition Window.h:61
@ M2
マウス中クリック、あるいはホイールクリック(第2ボタン)
@ M3
マウス右クリック(第3ボタン)
@ M1
マウス左クリック(第1ボタン)