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

Go to the SVN repository for this file.

1 /* $Id: gl3d_demo_panel.cpp 25560 2012-04-09 14:28:39Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  */
30 
31 #include <ncbi_pch.hpp>
32 
33 #include <wx/sizer.h>
34 #include <wx/stattext.h>
35 #include <wx/textctrl.h>
36 #include <wx/valtext.h>
37 #include <wx/choice.h>
38 
39 #include "gl3d_demo_panel.hpp"
40 #include "gl3d_window.hpp"
41 
43 
44 #define ID_GL3D_WINDOW wxID_HIGHEST + 1
45 #define ID_X_ROTATION wxID_HIGHEST + 2
46 #define ID_Y_ROTATION wxID_HIGHEST + 3
47 #define ID_Z_ROTATION wxID_HIGHEST + 4
48 #define ID_CHOICE_PROJ wxID_HIGHEST + 5
49 
50 BEGIN_EVENT_TABLE(CGl3dDemoPanel, wxPanel)
56 
58 {
59 }
60 
61 CGl3dDemoPanel::CGl3dDemoPanel(wxWindow* parent, wxWindowID id)
62 {
63  Create(parent, id);
64 }
65 
66 bool CGl3dDemoPanel::Create(wxWindow* parent, wxWindowID id)
67 {
68  wxPanel::Create(parent, id, wxDefaultPosition, wxSize(0,0), 0);
70  return true;
71 }
72 
74 {
75  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
76  wxBoxSizer *barSizer = new wxBoxSizer(wxHORIZONTAL);
77 
78  wxArrayString projChoiceStrings;
79  projChoiceStrings.Add(wxT("Perspective"));
80  projChoiceStrings.Add(wxT("Orthographic"));
81  wxChoice *projChoice = new wxChoice(this, ID_CHOICE_PROJ,
82  wxDefaultPosition, wxDefaultSize,
83  projChoiceStrings, 0);
84  projChoice->SetSelection(0);
85  barSizer->Add(projChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
86 
87  wxTextValidator validator(wxFILTER_NUMERIC);
88 
89  barSizer->Add(new wxStaticText(this, wxID_ANY, wxT("X Rot")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 1);
90  wxTextCtrl* itemTextXRot = new wxTextCtrl(this, ID_X_ROTATION, wxT("0"), wxDefaultPosition, wxSize(-1, -1), wxTE_PROCESS_ENTER, validator);
91  itemTextXRot->SetMaxLength(7);
92  barSizer->Add(itemTextXRot, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
93 
94  barSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Y Rot")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 1);
95  wxTextCtrl* itemTextYRot = new wxTextCtrl(this, ID_Y_ROTATION, wxT("0"), wxDefaultPosition, wxSize(-1, -1), wxTE_PROCESS_ENTER, validator);
96  itemTextYRot->SetMaxLength(7);
97  barSizer->Add(itemTextYRot, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
98 
99  barSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Z Rot")), 0, wxALL|wxALIGN_CENTER_VERTICAL, 1);
100  wxTextCtrl* itemTextZRot = new wxTextCtrl(this, ID_Z_ROTATION, wxT("0"), wxDefaultPosition, wxSize(-1, -1), wxTE_PROCESS_ENTER, validator);
101  itemTextZRot->SetMaxLength(7);
102  barSizer->Add(itemTextZRot, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
103 
104  topSizer->Add(barSizer, 0, wxALIGN_RIGHT);
105 
106  CGl3dWindow *gl3dWindow = new CGl3dWindow(this, ID_GL3D_WINDOW);
107  topSizer->Add(gl3dWindow, 1, wxEXPAND);
108 
109  wxCoord w, h;
110  itemTextXRot->GetTextExtent(wxT("WWWWWW"), &w, &h);
111  wxSize textSize(w, wxDefaultCoord);
112  itemTextXRot->SetMinSize(textSize);
113  itemTextYRot->SetMinSize(textSize);
114  itemTextZRot->SetMinSize(textSize);
115 
116  SetSizer(topSizer);
117 }
118 
119 void CGl3dDemoPanel::OnXRotationEnter(wxCommandEvent& WXUNUSED(event))
120 {
121  wxTextCtrl* itemText = (wxTextCtrl*)FindWindow(ID_X_ROTATION);
122  wxString str = itemText->GetValue();
123  double value;
124  if (str.ToDouble(&value)) {
125  CGl3dWindow *gl3dWindow = (CGl3dWindow*)FindWindow(ID_GL3D_WINDOW);
126  gl3dWindow->SetXRot((float)value);
127  }
128 }
129 
130 void CGl3dDemoPanel::OnYRotationEnter(wxCommandEvent& WXUNUSED(event))
131 {
132  wxTextCtrl* itemText = (wxTextCtrl*)FindWindow(ID_Y_ROTATION);
133  wxString str = itemText->GetValue();
134  double value;
135  if (str.ToDouble(&value)) {
136  CGl3dWindow *gl3dWindow = (CGl3dWindow*)FindWindow(ID_GL3D_WINDOW);
137  gl3dWindow->SetYRot((float)value);
138  }
139 }
140 
141 void CGl3dDemoPanel::OnZRotationEnter(wxCommandEvent& WXUNUSED(event))
142 {
143  wxTextCtrl* itemText = (wxTextCtrl*)FindWindow(ID_Z_ROTATION);
144  wxString str = itemText->GetValue();
145  double value;
146  if (str.ToDouble(&value)) {
147  CGl3dWindow *gl3dWindow = (CGl3dWindow*)FindWindow(ID_GL3D_WINDOW);
148  gl3dWindow->SetZRot((float)value);
149  }
150 }
151 
152 void CGl3dDemoPanel::OnProjSelected(wxCommandEvent& event)
153 {
154  CGl3dWindow *gl3dWindow = (CGl3dWindow*)FindWindow(ID_GL3D_WINDOW);
155  int value = event.GetSelection();
156  if (value == 0)
157  gl3dWindow->SetPerspective();
158  else
159  gl3dWindow->SetOrtho();
160 }
161 
163 
bool Create(wxWindow *parent, wxWindowID id)
Creation.
void OnXRotationEnter(wxCommandEvent &event)
void OnZRotationEnter(wxCommandEvent &event)
void CreateControls()
Creates the controls and sizers.
void OnYRotationEnter(wxCommandEvent &event)
void OnProjSelected(wxCommandEvent &event)
CGl3dDemoPanel()
Constructors.
void SetZRot(float rot)
Definition: gl3d_window.cpp:88
void SetOrtho()
void SetYRot(float rot)
Definition: gl3d_window.cpp:81
void SetPerspective()
Definition: gl3d_window.cpp:94
void SetXRot(float rot)
Definition: gl3d_window.cpp:74
static const char * str(char *buf, int n)
Definition: stats.c:84
#define ID_Z_ROTATION
#define ID_Y_ROTATION
#define ID_GL3D_WINDOW
#define ID_CHOICE_PROJ
#define ID_X_ROTATION
#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 GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static static static wxID_ANY
Modified on Sun Apr 21 03:42:44 2024 by modify_doxy.py rev. 669887