FineKernelToolKit 4.3.0
読み取り中…
検索中…
一致する文字列を見つけられません
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
59
61 enum class fk_MouseButton {
65 };
66
75
77 enum class fk_Switch {
82 };
83
85
119
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<char, bool> keyPrev;
134 std::map<fk_Key, bool> specialKeyStatus;
135 std::map<fk_Key, bool> specialKeyPrev;
136 std::map<fk_MouseButton, bool> mouseStatus;
137 std::map<fk_MouseButton, bool> mousePrev;
138 double frameTime, prevTime;
139 double frameInterval;
140 int skipCount;
141 fk_FrameController fps_admin;
142 int fps;
143#if !defined(FK_OLD_NONSUPPORT)
144 bool stereoMode;
145#endif
146
147 Member(int, int, int, int);
148 };
149#endif
150
151 public:
152
154
161 fk_Window(int x = 0, int y = 0, int w = 300, int h = 300, std::string name = "FK Window");
162
164 virtual ~fk_Window();
165
166
169
171
176 void setScene(fk_Scene *scene);
178
181
183
198 int drawWindow(bool drawFlag = true);
199
201
210 bool winOpenStatus(void);
211
213
221 void resizeWindow(int x, int y, int w, int h);
222
224
260 bool getKeyStatus(char key, fk_Switch status, bool insideFlag = true);
261
263
290 bool getKeyStatus(char key, bool insideFlag = true);
291
293
330 bool getSpecialKeyStatus(fk_Key key, fk_Switch status, bool insideFlag = true);
331
333
360 bool getSpecialKeyStatus(fk_Key key, bool insideFlag = true);
361
363
382 bool getKeyStatus(fk_Key key, fk_Switch status, bool insideFlag = true);
383
385
401 bool getKeyStatus(fk_Key key, bool insideFlag = true);
402
404
422 char getLastKey(void);
423
425
451 std::tuple<int, int> getMousePosition(bool insideFlag = true);
452
453#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
454 void getMousePosition(int *, int *, bool = true);
455#endif
456
458
485 bool getMouseStatus(fk_MouseButton button, fk_Switch status, bool insideFlag = true);
486
487#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
488 bool getMouseStatus(fk_MouseButton, bool = true);
489#endif
490
492
508
511
520 void setFPS(int fps);
521
523
526
528
547 std::tuple<bool, fk_Vector> getProjectPosition(double x, double y, fk_Plane &plane);
548
549#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
550 bool getProjectPosition(double x, double y, fk_Plane *plane, fk_Vector *pos);
551#endif
553
569 std::tuple<bool, fk_Vector> getProjectPosition(double x, double y, double dist);
570
571#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
572 bool getProjectPosition(double x, double y, double dist, fk_Vector *pos);
573#endif
575
595 std::tuple<bool, fk_Vector> getWindowPosition(fk_Vector &pos_3D);
596
597#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
599#endif
601
604
606
616 virtual void preInit(void) {}
617
619
629 virtual void postInit(void) {}
630
632
640 virtual void preDraw(void) {}
641
643
651 virtual void postDraw(void) {}
653
654#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
655 virtual void preDrawLeft(void) {}
656 virtual void postDrawLeft(void) {}
657 virtual void preDrawRight(void) {}
658 virtual void postDrawRight(void) {}
659#endif
660
661#if !defined(FK_DOXYGEN_USER_PROCESS)
662 std::list<fk_funcSet> preDrawList;
663 std::list<fk_funcSet> postDrawList;
664#endif
665
668
670
686 bool snapImage(std::string fileName,
689
691
706
709
711
734 static void setPutStrMode(const fk_PutStrMode mode);
735
737
745
747
764 static bool setPutFile(const std::string &fileName);
765
767
781 static void putString(const std::string &str);
782
783#if !defined(FK_CLI_CODE)
785
799 static void printf(const char *format, ...);
800#endif
801
803
816 static void clearBrowser(void);
817
819
830 static void fontInit(void);
831
833
834#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
837
839
859 void setOGLStereoMode(bool mode);
860
862
875 bool getOGLStereoMode(void);
877#endif
878
879#if !defined(FK_DOXYGEN_USER_PROCESS)
880 fk_GraphicsEngine * GetEngine(void);
881#endif
882
883 private:
884 std::unique_ptr<Member> _m;
885
886 static inline std::unique_ptr<Fl_Window> _s_putWin;
887 static inline Fl_Multi_Browser * _s_browser;
888 static inline std::unique_ptr<fk_PutStrMode> _s_putStrMode;
889 static inline std::unique_ptr<std::ofstream> _s_putStrOFS;
890 static inline std::unique_ptr<int> _s_winNum;
891
892 static inline std::unique_ptr<Fl_Window> _s_error_win;
893 static inline std::map<fk_Key, int> _keyMap;
894
895 bool IsInsideWindow(void);
896 Fl_Group * GetInhParentWindow(void);
897 void PushPrevStatus(void);
898
899 void draw(); // virtual Function from Fl_Gl_Window class
900
901 static void PutBrowser(const std::string &);
902
903#if defined(WIN32)
904 bool SnapImageGDI(fk_Image *);
905#endif
906 static void ErrorInit(void);
907 static void MakeKeyMap(void);
908
909 static void StaticInit(void);
910 bool GetMouseStatus(fk_MouseButton, bool);
911
912 protected:
913
914#if !defined(FK_DOXYGEN_USER_PROCESS)
915 std::unique_ptr<fk_GraphicsEngine> _m_engine;
916
917 void drawScene(void);
918 void drawSceneLeft(void);
919 void drawSceneRight(void);
920#endif
921
922 };
923}
924
925#endif /* !__FK_WINDOW_HEADER__ */
926
927/****************************************************************************
928 *
929 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
930 *
931 * Redistribution and use in source and binary forms,
932 * with or without modification, are permitted provided that the
933 * following conditions are met:
934 *
935 * - Redistributions of source code must retain the above
936 * copyright notice, this list of conditions and the
937 * following disclaimer.
938 *
939 * - Redistributions in binary form must reproduce the above
940 * copyright notice, this list of conditions and the
941 * following disclaimer in the documentation and/or
942 * other materials provided with the distribution.
943 *
944 * - Neither the name of the copyright holders nor the names
945 * of its contributors may be used to endorse or promote
946 * products derived from this software without specific
947 * prior written permission.
948 *
949 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
950 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
951 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
952 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
953 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
954 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
955 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
956 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
957 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
958 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
959 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
960 * POSSIBILITY OF SUCH DAMAGE.
961 *
962 ****************************************************************************/
963/****************************************************************************
964 *
965 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
966 *
967 * 本ソフトウェアおよびソースコードのライセンスは、基本的に
968 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
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 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
995 * ついて、一切責任を負わないものとします。
996 *
997 ****************************************************************************/
フレームレート制御クラス
Definition FrameController.h:28
画像を生成、管理するクラス
Definition Image.h:260
幾何平面を管理するクラス
Definition Plane.h:32
シーンを制御するクラス
Definition Scene.h:48
3次元ベクトルを管理するクラス
Definition Vector.h:45
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:640
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:629
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:651
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:616
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
コンソール標準出力
Definition Window.h:70
@ ERR_CONSOLE
コンソールエラー出力
Definition Window.h:71
@ BROWSER
専用ブラウザ出力
Definition Window.h:72
@ FILE
ファイル出力
Definition Window.h:73
@ NONE
未定義境界
Definition Boundary.h:19
fk_Key
特殊キーを表す列挙型
Definition Window.h:24
@ F6
F6 ファンクションキー
Definition Window.h:50
@ DEL
デリート(削除)キー
Definition Window.h:33
@ CTRL_R
右コントロールキー
Definition Window.h:27
@ ENTER
エンター(改行、リターン)キー
Definition Window.h:31
@ F5
F5 ファンクションキー
Definition Window.h:49
@ F7
F7 ファンクションキー
Definition Window.h:51
@ F8
F8 ファンクションキー
Definition Window.h:52
@ F3
F3 ファンクションキー
Definition Window.h:47
@ ALT_R
右オルトキー
Definition Window.h:29
@ SHIFT_R
右シフトキー
Definition Window.h:25
@ INSERT
インサートキー
Definition Window.h:40
@ SHIFT_L
左シフトキー
Definition Window.h:26
@ F11
F11 ファンクションキー
Definition Window.h:55
@ SPACE
スペースキー
Definition Window.h:57
@ BACKSPACE
バックスペース(後退)キー
Definition Window.h:32
@ HOME
ホームキー
Definition Window.h:38
@ F9
F9 ファンクションキー
Definition Window.h:53
@ ALT_L
左オルトキー
Definition Window.h:30
@ END
エンドキー
Definition Window.h:39
@ F10
F10 ファンクションキー
Definition Window.h:54
@ DOWN
下矢印キー
Definition Window.h:44
@ F1
F1 ファンクションキー
Definition Window.h:45
@ CAPS_LOCK
キャップスロックキー
Definition Window.h:34
@ PAGE_UP
ページアップキー
Definition Window.h:36
@ F4
F4 ファンクションキー
Definition Window.h:48
@ F12
F12 ファンクションキー
Definition Window.h:56
@ PAGE_DOWN
ページダウンキー
Definition Window.h:37
@ CTRL_L
左コントロールキー
Definition Window.h:28
@ TAB
タブキー
Definition Window.h:35
@ UP
上矢印キー
Definition Window.h:43
@ F2
F2 ファンクションキー
Definition Window.h:46
fk_SnapProcMode
画像取り込み方法を表す列挙型
Definition Image.h:56
@ FRONT
OpenGL フロントバッファ
Definition Image.h:57
fk_ImageType
画像フォーマットを表す列挙型
Definition Image.h:49
@ BMP
Windows Bitmap (BMP) 形式
Definition Image.h:50
fk_Switch
ボタン系デバイス状態を表す列挙型
Definition Window.h:77
@ RELEASE
離しっぱなしの状態
Definition Window.h:78
@ PRESS
押しっぱなしの状態
Definition Window.h:81
@ RIGHT
右目側
Definition DList.h:15
@ LEFT
左目側
Definition DList.h:14
fk_MouseButton
マウスボタンを表す列挙型
Definition Window.h:61
@ M2
マウス中クリック、あるいはホイールクリック(第2ボタン)
Definition Window.h:63
@ M3
マウス右クリック(第3ボタン)
Definition Window.h:64
@ M1
マウス左クリック(第1ボタン)
Definition Window.h:62