-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutgr.cpp
300 lines (255 loc) · 8.34 KB
/
butgr.cpp
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
//
// Button Group Class
//
#include "butgr.h"
#include <stdio.h>
ButGr::ButGr( QWidget *parent, const char *name )
: QWidget( parent, name )
{
#include "fonts.h"
QFontMetrics fontm4(font4);
long posy,lengthx,lengthy;
lengthx=fontm4.width("RR")+7;
lengthy=fontm4.height()*2/3+12;
posy=2;
// Create and setup the zoom buttons
zoom_plus= new QPushButton( "Z+", this );
zoom_minus= new QPushButton( "Z-", this );
zoom_plus ->resize( lengthx , lengthy );
zoom_minus ->resize( lengthx , lengthy );
zoom_plus->move( 2, posy );
zoom_minus->move( 2+lengthx, posy );
zoom_plus->setFont(font4);
zoom_minus->setFont(font4);
connect( zoom_plus, SIGNAL(clicked()), SLOT(butzoomplus()) );
connect( zoom_minus, SIGNAL(clicked()), SLOT(butzoomminus()) );
// Create and setup the ijk buttons
posy=posy+lengthy+2;
ijk_i=new QPushButton( "i", this );
ijk_j= new QPushButton( "j", this );
ijk_k= new QPushButton( "k", this );
ijk_i ->resize( (long)(lengthx*2/3) , lengthy );
ijk_j ->resize( (long)(lengthx*2/3) , lengthy );
ijk_k ->resize( (long)(lengthx*2/3) , lengthy );
ijk_i->move( 2, posy );
ijk_j->move( 2+(long)(lengthx*2/3) , posy );
ijk_k->move( 2+(long)(lengthx*4/3), posy );
ijk_i->setFont(font4);
ijk_j->setFont(font4);
ijk_k->setFont(font4);
connect( ijk_i, SIGNAL(clicked()), SLOT(buti()) );
connect( ijk_j, SIGNAL(clicked()), SLOT(butj()) );
connect( ijk_k, SIGNAL(clicked()), SLOT(butk()) );
// Create and setup the resolution button
posy=posy+lengthy+2;
res_plus= new QPushButton( "R+", this );
res_minus= new QPushButton( "R-", this );
res_plus ->resize( lengthx , lengthy );
res_minus ->resize( lengthx , lengthy );
res_plus->move( 2, posy );
res_minus->move( 2+lengthx, posy );
res_plus->setFont(font4);
res_minus->setFont(font4);
connect( res_plus, SIGNAL(clicked()), SLOT(butresplus()) );
connect( res_minus, SIGNAL(clicked()), SLOT(butresminus()) );
// Create and setup the shownode button
posy=posy+lengthy+2;
sn_plus= new QPushButton( "N+", this );
sn_minus= new QPushButton( "N-", this );
sn_plus ->resize( lengthx , lengthy );
sn_minus ->resize( lengthx , lengthy );
sn_plus->move( 2, posy );
sn_minus->move( 2+lengthx, posy );
sn_plus->setFont(font4);
sn_minus->setFont(font4);
connect( sn_plus, SIGNAL(clicked()), SLOT(butsnplus()) );
connect( sn_minus, SIGNAL(clicked()), SLOT(butsnminus()) );
resize(2*lengthx+4,posy+lengthy+2);
}
void ButGr::linkcanvas(typecanvas *cv2, Canvas *canvas2)
{
canvas=canvas2;
cv=cv2;
}
void ButGr::butresplus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the R+ PushButton",
"The R+ (Resolution Plus) push button increases by a factor of 4 the\n"
"total number of rectangles used to draw the canvas.\n");
cv->instanthelp=FALSE;
}
else {
cv->resfact=cv->resfact*4.0;
canvas->drawxy();
}
}
void ButGr::butresminus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the R- PushButton",
"The R- (Resolution Minus) push button decreases by a factor of 4 the\n"
"total number of rectangles used to draw the canvas.\n");
cv->instanthelp=FALSE;
}
else {
cv->resfact=cv->resfact/4.0;
//if (cv->resfact<100) cv->resfact=100;
canvas->drawxy();
}
}
void ButGr::butsnminus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the N- PushButton",
"The N- (Nodes Minus) push button results in less visible nodes.\n");
cv->instanthelp=FALSE;
}
else {
cv->shownode=cv->shownode-1;
if (cv->shownode < 0) cv->shownode=0;
canvas->drawxy();
}
}
void ButGr::butsnplus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the N+ PushButton",
"The N+ (Nodes Plus) push button results in more visible nodes.\n");
cv->instanthelp=FALSE;
}
else {
cv->shownode=cv->shownode+1;
if (cv->shownode > 2) cv->shownode=2;
canvas->drawxy();
}
}
void ButGr::butzoomplus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the Z+ PushButton",
"The Z+ (Zoom Plus) push button multiplies by 2 both the zoom factor \n"
"along x and the zoom factor along y. \n"
"\n"
"The zoom takes place at the center of the xy canvas where the cross is\n"
"shown\n");
cv->instanthelp=FALSE;
}
else {
transfo.zoomtrans(&(cv->zoomfactx), &(cv->decalx), &(cv->resfact),2.);
transfo.zoomtrans(&(cv->zoomfacty), &(cv->decaly), &(cv->resfact),2.);
cv->zoomfactref=cv->zoomfactref*2.;
canvas->drawxy();
}
}
void ButGr::butzoomminus()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the Z- PushButton",
"The Z- (Zoom Minus) push button divides by 2 both the zoom factor \n"
"along x and the zoom factor along y. \n"
"\n"
"The zoom takes place at the center of the xy canvas, where the\n"
"cross is shown\n");
cv->instanthelp=FALSE;
}
else {
transfo.zoomtrans(&(cv->zoomfactx), &(cv->decalx), &(cv->resfact),.5);
transfo.zoomtrans(&(cv->zoomfacty), &(cv->decaly), &(cv->resfact),.5);
cv->zoomfactref=cv->zoomfactref*.5;
canvas->drawxy();
}
}
void ButGr::buti()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the i PushButton",
"The i push button enables to view the 3D data at a constant i.\n"
"\n"
"The rotation is centered around the nearest node to the middle\n"
"of the xy canvas, where the cross is located. \n");
cv->instanthelp=FALSE;
}
else {
long ci,cj,ck;
transfo.find_center_node(*cv,&ci,&cj,&ck);
// printf("i=%ld j=%ld k=%ld\n",ci,cj,ck);
cv->is=cv->kso;
cv->ie=cv->keo;
cv->js=cv->jso;
cv->je=cv->jeo;
cv->ks=cv->iso;
cv->ke=cv->ieo;
cv->kk=ci;
if (cv->kk>cv->ke) cv->kk=cv->ke;
if (cv->kk<cv->ks) cv->kk=cv->ks;
strcpy(cv->upaxis, "ikj");
transfo.find_decal_from_node_pixel(cv,ck, cj,
(long)((cv->posxe+cv->posxs)/2.+0.5),
(long)((cv->posye+cv->posys)/2.+0.5));
if (cv->proportional) transfo.find_zoom_proportional(cv);
canvas->drawxy();
}
}
void ButGr::butj()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the j PushButton",
"The j push button enables to view the 3D data at a constant j\n"
"\n"
"The rotation is centered around the nearest node to the middle\n"
"of the xy canvas, where the cross is shown.\n");
cv->instanthelp=FALSE;
}
else {
long ci,cj,ck;
transfo.find_center_node(*cv,&ci,&cj,&ck);
// printf("i=%ld j=%ld k=%ld\n",ci,cj,ck);
cv->is=cv->kso;
cv->ie=cv->keo;
cv->js=cv->iso;
cv->je=cv->ieo;
cv->ks=cv->jso;
cv->ke=cv->jeo;
cv->kk=cj;
if (cv->kk>cv->ke) cv->kk=cv->ke;
if (cv->kk<cv->ks) cv->kk=cv->ks;
strcpy(cv->upaxis, "jki");
transfo.find_decal_from_node_pixel(cv,ck, ci,
(long)((cv->posxe+cv->posxs)/2.+0.5),
(long)((cv->posye+cv->posys)/2.+0.5));
if (cv->proportional) transfo.find_zoom_proportional(cv);
canvas->drawxy();
}
}
void ButGr::butk()
{
if (cv->instanthelp) {
QMessageBox::about( this, "NodPlot: Help on the k PushButton",
"The k push button enables to view the 3D data at a constant k.\n"
"\n"
"The rotation is centered around the nearest node to the middle\n"
"of the xy canvas, where the cross is located. \n");
cv->instanthelp=FALSE;
}
else {
long ci,cj,ck;
transfo.find_center_node(*cv,&ci,&cj,&ck);
// printf("i=%ld j=%ld k=%ld\n",ci,cj,ck);
cv->is=cv->iso;
cv->ie=cv->ieo;
cv->js=cv->jso;
cv->je=cv->jeo;
cv->ks=cv->kso;
cv->ke=cv->keo;
cv->kk=ck;
if (cv->kk>cv->ke) cv->kk=cv->ke;
if (cv->kk<cv->ks) cv->kk=cv->ks;
strcpy(cv->upaxis, "kij");
transfo.find_decal_from_node_pixel(cv, ci, cj,
(long)((cv->posxe+cv->posxs)/2.+0.5),
(long)((cv->posye+cv->posys)/2.+0.5));
if (cv->proportional) transfo.find_zoom_proportional(cv);
canvas->drawxy();
}
}