NCBI C++ ToolKit
gl_demo_dlg.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gl_demo_dlg.cpp
3 // Purpose:
4 // Author: Roman Katargin
5 // Modified by:
6 // Created: 07/08/2007 12:04:04
7 // RCS-ID:
8 // Copyright:
9 // Licence:
10 /////////////////////////////////////////////////////////////////////////////
11 
12 #include <ncbi_pch.hpp>
13 
14 ////@begin includes
15 #include "wx/imaglist.h"
16 ////@end includes
17 
18 #include <wx/bitmap.h>
19 #include <wx/icon.h>
20 #include <wx/button.h>
21 #include <wx/sizer.h>
22 
23 #include "gl_demo_dlg.hpp"
24 #include "ruler_demo_panel.hpp"
25 #include "font_demo_panel.hpp"
26 #include "gl3d_demo_panel.hpp"
27 #include "glinfo_demo_panel.hpp"
29 
31 #include <gui/opengl/glresmgr.hpp>
34 
35 ////@begin XPM images
36 ////@end XPM images
37 
39 
40 /*!
41  * CGLDemoDlg type definition
42  */
43 
44 IMPLEMENT_DYNAMIC_CLASS( CGLDemoDlg, wxDialog )
45 
46 
47 /*!
48  * CGLDemoDlg event table definition
49  */
50 
51 BEGIN_EVENT_TABLE( CGLDemoDlg, wxDialog )
52 
53 ////@begin CGLDemoDlg event table entries
54  EVT_CLOSE( CGLDemoDlg::OnCloseWindow )
55 
56  EVT_BUTTON( wxID_CLOSE, CGLDemoDlg::OnCloseClick )
57 
58 ////@end CGLDemoDlg event table entries
59 
61 
62 
63 /*!
64  * CGLDemoDlg constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CGLDemoDlg::CGLDemoDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
73 {
74  Init();
75  Create(parent, id, caption, pos, size, style);
76 }
77 
78 
79 /*!
80  * CGLDemoDlg creator
81  */
82 
83 bool CGLDemoDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
84 {
85 ////@begin CGLDemoDlg creation
86  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
87  wxDialog::Create( parent, id, caption, pos, size, style );
88 
90  if (GetSizer())
91  {
92  GetSizer()->SetSizeHints(this);
93  }
94  Centre();
95 ////@end CGLDemoDlg creation
96  return true;
97 }
98 
99 
100 /*!
101  * CGLDemoDlg destructor
102  */
103 
105 {
106 ////@begin CGLDemoDlg destruction
107 ////@end CGLDemoDlg destruction
108 }
109 
110 
111 /*!
112  * Member initialisation
113  */
114 
116 {
117 ////@begin CGLDemoDlg member initialisation
118 ////@end CGLDemoDlg member initialisation
119 
120  wxSize ppi = wxGetDisplayPPI();
123 }
124 
125 
126 class CMetalWindow : public C3DCanvas
127 {
128 public:
129  CMetalWindow(wxWindow* parent) : C3DCanvas(parent, wxID_ANY) {}
130 
131 protected:
132  virtual void x_Render();
133 };
134 
136 {
137  IRender& gl = GetGl();
138  wxSize sz = GetClientSize();
139  gl.Viewport(0, 0, sz.x, sz.y);
140  gl.MatrixMode(GL_PROJECTION);
141  gl.LoadIdentity();
142  gl.Ortho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
143  gl.Begin(GL_LINE_STRIP);
144  gl.ColorC(CRgbaColor(1.0f, 0.0f, 0.0f));
145  gl.Vertex2f(-0.9f, -0.9f);
146  gl.Vertex2f(0.9f, -0.9f);
147  gl.Vertex2f(0.0f, 0.9f);
148  gl.Vertex2f(-0.9f, -0.9f);
149  gl.End();
150 
151  gl.Begin(GL_LINE_STRIP);
152  gl.ColorC(CRgbaColor(0.0f, 1.0f, 0.0f));
153  gl.Vertex2f(0.0f, -0.9f);
154  gl.Vertex2f(-0.9f, 0.9f);
155  gl.Vertex2f(0.9f, 0.9f);
156  gl.Vertex2f(0.0f, -0.9f);
157  gl.End();
158 }
159 
160 
161 /*!
162  * Control creation for CGLDemoDlg
163  */
164 
166 {
167 ////@begin CGLDemoDlg content construction
168  CGLDemoDlg* itemDialog1 = this;
169 
170  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
171  itemDialog1->SetSizer(itemBoxSizer2);
172 
173  wxNotebook* itemNotebook3 = new wxNotebook( itemDialog1, ID_NOTEBOOK1, wxDefaultPosition, wxSize(512, 384), wxBK_DEFAULT|wxCLIP_CHILDREN );
174 
175  itemBoxSizer2->Add(itemNotebook3, 1, wxGROW|wxALL, 5);
176 
177  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
178  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_RIGHT|wxALL, 5);
179 
180  wxButton* itemButton5 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
181  itemBoxSizer4->Add(itemButton5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
182 
183 ////@end CGLDemoDlg content construction
184 
185  wxNotebook* itemNotebook = (wxNotebook*)FindWindow(ID_NOTEBOOK1);
186 
187  wxWindow* itemPane = new CRulerDemoPanel(itemNotebook, wxID_ANY);
188  itemNotebook->AddPage(itemPane, wxT("CRuler"));
189 
190  itemPane = new CFontDemoPanel(itemNotebook, wxID_ANY);
191  itemNotebook->AddPage(itemPane, wxT("OpenGL Fonts"));
192 
193  itemPane = new CGl3dDemoPanel(itemNotebook, wxID_ANY);
194  itemNotebook->AddPage(itemPane, wxT("Gl3d"));
195 
196  itemPane = new CGlInfoDemoPanel(itemNotebook, wxID_ANY);
197  itemNotebook->AddPage(itemPane, wxT("GlSysInfo"));
198 
199  itemPane = new CGlPaneWidgetDemoPanel(itemNotebook, wxID_ANY);
200  itemNotebook->AddPage(itemPane, wxT("GlPaneWidget"));
201 
202 #ifdef __WXOSX_COCOA__
203  itemNotebook->AddPage(new CMetalWindow(itemNotebook), wxT("Metal View"));
204 #endif
205 }
206 
207 
208 /*!
209  * Should we show tooltips?
210  */
211 
213 {
214  return true;
215 }
216 
217 /*!
218  * Get bitmap resources
219  */
220 
221 wxBitmap CGLDemoDlg::GetBitmapResource( const wxString& name )
222 {
223  // Bitmap retrieval
224 ////@begin CGLDemoDlg bitmap retrieval
225  wxUnusedVar(name);
226  return wxNullBitmap;
227 ////@end CGLDemoDlg bitmap retrieval
228 }
229 
230 /*!
231  * Get icon resources
232  */
233 
234 wxIcon CGLDemoDlg::GetIconResource( const wxString& name )
235 {
236  // Icon retrieval
237 ////@begin CGLDemoDlg icon retrieval
238  wxUnusedVar(name);
239  return wxNullIcon;
240 ////@end CGLDemoDlg icon retrieval
241 }
242 
243 /*!
244  * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
245  */
246 
247 void CGLDemoDlg::OnCloseClick( wxCommandEvent& WXUNUSED(event) )
248 {
249  Close();
250 }
251 
252 
253 /*!
254  * wxEVT_CLOSE_WINDOW event handler for ID_CGLDEMODLG
255  */
256 
257 void CGLDemoDlg::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
258 {
259  Destroy();
260 }
261 
262 
264 
CGLCanvas.
Definition: glcanvas.hpp:55
void CreateControls()
Creates the controls and sizers.
void OnCloseClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
CGLDemoDlg()
Constructors.
Definition: gl_demo_dlg.cpp:67
void OnCloseWindow(wxCloseEvent &event)
wxEVT_CLOSE_WINDOW event handler for ID_CGLDEMODLG
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
static bool ShowToolTips()
Should we show tooltips?
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("wxWidgets GL Demo"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX)
Creation.
Definition: gl_demo_dlg.cpp:83
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
~CGLDemoDlg()
Destructor.
virtual void x_Render()
CMetalWindow(wxWindow *parent)
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
static wxString GetResourcePath(void)
the shared resource path corresponds to the <res> alias above.
Definition: sys_path.cpp:189
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define ID_NOTEBOOK1
Definition: gl_demo_dlg.hpp:40
virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)=0
virtual void Begin(GLenum mode)=0
Start rendering.
virtual void MatrixMode(GLenum mode)=0
void SetDeviceResolution(unsigned int res)
Get/set device resolution in pixels per inch (defaults to 72) You can get this value from wxWidgets v...
IRender & GetGl()
convenience function for getting current render manager
void SetFontPath(const string &p)
This path will be prepended to filename when calling GetFont It should be set to "ToStdString(CSysPat...
virtual void LoadIdentity()=0
static CFtglFontManager & Instance()
Get an instance of the manager so you can retrieve fonts.
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Vertex2f(GLfloat x, GLfloat y)
Definition: irender.hpp:182
virtual void Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)=0
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
Modified on Sun Mar 03 03:14:48 2024 by modify_doxy.py rev. 669887