-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample-ortho.cpp
More file actions
129 lines (103 loc) · 3 KB
/
example-ortho.cpp
File metadata and controls
129 lines (103 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include<dslab.h>
#include<iostream>
using namespace std;
enum {
MENU_ZOOMFIT=500,
MENU_ZOOMIN,
MENU_ZOOMOUT
};
class MyDataEngine :public DataEngine
{
private:
double theta[3];
dsOrthoZoomPan zoompan;
public:
virtual void Init()
{
cout << "Initialization" << endl;
zoompan.setMBR(0,10,0,10);
glEnable(GL_DEPTH_TEST);
wxToolBar *toolbar;
toolbar = new wxToolBar(getFrame(),-1);
toolbar->AddTool(MENU_ZOOMIN,wxT("Zoom In"),wxBitmap((const char *const *) &xpm_viewmagp));
toolbar->AddTool(MENU_ZOOMOUT,wxT("Zoom Out"),wxBitmap((const char *const *) &xpm_viewmagm));
toolbar->AddTool(MENU_ZOOMFIT,wxT("Zoom Fit"),wxBitmap((const char *const *) &xpm_viewmag1));
toolbar->AddSeparator();
toolbar->AddTool(wxID_ABOUT,wxT("About"),wxBitmap((const char *const *) &xpm_mdsg));
toolbar->Realize();
getFrame()->SetToolBar(toolbar);
}
virtual void think(double iElapsed)
{
theta[0] += 0.1*3.1415926*(iElapsed / 1E12);
theta[1] += 0.06*3.1415926*(iElapsed / 1E12);
}
virtual void createMenu(wxMenu *menuDataEngine)
{
// start of from 500
menuDataEngine->Append(500,wxT("First"),wxT("Help"));
menuDataEngine->Append(501,wxT("Second"),wxT("Help2"));
}
virtual void extendViewMenu(wxMenu *menuDataEngine)
{
// start of from 500
menuDataEngine->Append(502,wxT("First View"),wxT("Help"));
menuDataEngine->Append(503,wxT("Second View"),wxT("Help2"));
DS_start_rendering();
}
virtual void handleMenu(int id)
{
switch (id)
{
case MENU_ZOOMFIT:
zoompan.zoomFit(); break;
case MENU_ZOOMIN:
zoompan.zoom(1); break;
case MENU_ZOOMOUT:
zoompan.zoom(-1); break;
default:
cout << "Menu Item " << id << " ignored" << endl;
break;
}
}
virtual void beforeQuit(){
// Do some data cleanup / file sync / close
cout << "Preparing DataEngine for exit" << endl;
};
virtual void render(size_t width, size_t height)
{
zoompan.setViewport(0,0,width,height);
zoompan.glViewport();
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
zoompan.glProject();
glMatrixMode( GL_MODELVIEW );
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f( 1.0, 0.0, 0.0 );
glBegin(GL_POLYGON);
glColor3f( 1.0, 1.0, 0 );
glVertex2f( 1,1 );
glVertex2f( 8,1 );
glVertex2f( 8,8 );
glEnd();
}
virtual void mouseClick(size_t x, size_t y)
{
std::pair<double,double> p = zoompan.clientProject(x,y);
zoompan.setPos(p.first,p.second);
//cout << "Click @" << x <<","<< y << endl;
//cout << "Projected @" << p.first << "," << p.second << endl;
}
virtual void mouseWheel(size_t x, size_t y, int steps) {
//std::pair<double,double> p = zoompan.clientProject(x,y);
//cout << steps << " at " << p.first <<"/" << p.second << endl;
zoompan.zoom(steps);
};
};
/*Instantiate it and make it available to the library*/
MyDataEngine eng;
DataEngine *getDataEngineImplementation()
{
return (DataEngine*) ŋ
}