Overture
Version 25
Main Page
Namespaces
Classes
Files
File List
File Members
Overture.v25.d
include
GL_GraphicsInterface.h
Go to the documentation of this file.
1
#ifndef GL_GRAPHICS_INTERFACE_H
2
#define GL_GRAPHICS_INTERFACE_H
3
4
//============================================================================================
5
// -----------------------------------
6
// ------GL_GraphicsInterface---------
7
// -----------------------------------
8
//
9
// This class is a graphics interface based on OpenGL. It uses OpenGL for graphics
10
// and MOTIF to manage windows and menues. Command files are
11
// supported through the base class, GenericGraphicsInterface
12
//
13
//
14
// This class can plot
15
// o points and lines
16
// All high-level Overture plotting is done by the class PlotIt.
17
//
18
// Optional plotting parameters are passed using an object of the GraphicsParameters class.
19
// An object of this class can be used to set many parameters such as the labels on the
20
// plots, whether to plot axes, whether to plot line contours etc.
21
//
22
//
23
//===========================================================================================
24
25
#include "
GenericGraphicsInterface.h
"
26
#include "
GraphicsParameters.h
"
27
#include <stdlib.h>
28
#include <stdio.h>
29
#include <ctype.h>
30
#include <math.h>
31
#include <GL/gl.h>
32
#include <GL/glu.h>
33
#include "
mogl.h
"
34
#include "
GUIState.h
"
35
#include "
ColourBar.h
"
36
37
// extern intArray Overture::nullIntegerDistributedArray();
38
39
// define these for the sgi
40
#if defined(__sgi) && defined(GL_EXT_polygon_offset)
41
#define glPolygonOffset glPolygonOffsetEXT
42
#ifndef GL_POLYGON_OFFSET_FILL
43
#define GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_EXT
44
#endif
45
#define OFFSET_FACTOR .00001
46
#else
47
#define OFFSET_FACTOR 1.
48
#endif
49
50
// define single and double precision versions of the OpenGL functions
51
#ifndef OV_USE_DOUBLE
52
// here are single precision definitions:
53
#define glColor3 glColor3f
54
#define glMultMatrix glMultMatrixf
55
#define glNormal3v glNormal3fv
56
#define glNormal3 glNormal3f
57
#define glRotate glRotatef
58
#define glScale glScalef
59
#define glTranslate glTranslatef
60
#define glVertex2 glVertex2f
61
#define glVertex3 glVertex3f
62
#define glVertex2v glVertex2fv
63
#define glVertex3v glVertex3fv
64
#else
65
#define glColor3 glColor3d
66
#define glMultMatrix glMultMatrixd
67
#define glNormal3v glNormal3dv
68
#define glNormal3 glNormal3d
69
#define glRotate glRotated
70
#define glScale glScaled
71
#define glTranslate glTranslated
72
#define glVertex2 glVertex2d
73
#define glVertex3 glVertex3d
74
#define glVertex2v glVertex2dv
75
#define glVertex3v glVertex3dv
76
#endif
77
78
// More feed back tokens for pass through tokens:
79
enum
GLenum2
80
{
81
GL_DISABLE_TOKEN
= 0x0701,
82
GL_ENABLE_TOKEN
= 0x0702,
83
GL_LINE_WIDTH_TOKEN
= 0x0703,
84
GL_POINT_SIZE_TOKEN
= 0x0704,
85
GL_LINE_STIPPLE_TOKEN
= 0x0705
86
};
87
88
// forward declarations
89
class
UnstructuredMapping
;
90
class
AdvancingFront
;
91
class
TrimmedMapping
;
92
class
NurbsMapping
;
93
class
HyperbolicMapping
;
94
95
class
GL_GraphicsInterface
:
public
GenericGraphicsInterface
96
{
97
friend
class
ColourBar
;
// *AP* at this point, making ColourBar a friend seems to be the easiest solution.
98
// It might be better to absorb class ColourBar into GL_GraphicsInterface
99
100
public
:
101
102
// Default constructor (will open a window)
103
GL_GraphicsInterface
(
const
aString
& windowTitle =
"Your Slogan Here"
);
104
105
// Constructor that takes argc and argv from main program and strips away Motif parameters
106
GL_GraphicsInterface
(
int
& argc,
char
*argv[],
const
aString
& windowTitle =
"Your Slogan Here"
);
107
108
// This Constructor will only create a window if the the argument initialize=TRUE
109
// To create a window later, call createWindow()
110
GL_GraphicsInterface
(
const
bool
initialize,
const
aString
& windowTitle =
"Your Slogan Here"
);
111
112
virtual
~GL_GraphicsInterface
();
113
114
// Open another graphics window (and also a command window if it isn't already opened)
115
virtual
int
116
createWindow
(
const
aString
& windowTitle =
nullString
,
117
int
argc=0,
118
char
*argv[] =
NULL
);
119
120
// display help on a topic in the help pull-down menu
121
virtual
bool
122
displayHelp
(
const
aString
& topic );
123
124
// destroy the window
125
virtual
int
126
destroyWindow
(
int
win_number);
127
128
// Put up a menu and wait for a response, return the menu item chosen as answer,
129
// The return value is the item number (0,1,2,... ) (return -1 if there is an error)
130
// An error can occur if we are reading a command file
131
virtual
int
132
getMenuItem
(
const
aString
*menu,
aString
& answer,
const
aString
& prompt=
nullString
);
133
134
// Erase all graphics display lists and delete the ones that aren't hidable
135
virtual
void
136
erase
();
137
138
// erases all display lists in window win_number.
139
virtual
void
140
erase
(
const
int
win_number,
bool
forceDelete =
false
);
141
142
// erase a list of display lists
143
virtual
void
144
erase
(
const
IntegerArray
& displayList);
145
146
// input a filename through a file selection dialog
147
virtual
void
148
inputFileName
(
aString
&answer,
const
aString
& prompt=
nullString
,
const
aString
&extension=
nullString
);
149
150
// Input a string after displaying an optional prompt
151
virtual
void
152
inputString
(
aString
&answer,
const
aString
& prompt=
nullString
);
153
154
// output a string in the message window
155
virtual
void
156
outputString
(
const
aString
& message,
int
messageLevel =2 );
157
158
// Redraw all graphics display list
159
virtual
void
160
redraw
(
bool
immediate=
FALSE
);
161
162
// Initialize the view to default
163
virtual
void
164
initView
(
int
win_number=-1);
165
166
virtual
void
167
resetView
(
int
win_number=-1);
168
169
// // Stop reading the command file (and close the file)
170
virtual
void
171
stopReadingCommandFile
();
172
173
// convert normalized coordinates [-1,+1] to world (globalBound) coordinates
174
virtual
int
175
normalizedToWorldCoordinates
(
const
RealArray
&
r
,
RealArray
& x )
const
;
176
177
// convert world to normalized coordinates [-1,+1]
178
virtual
int
179
worldToNormalizedCoordinates
(
const
RealArray
& x,
RealArray
&
r
)
const
;
180
181
// functions for setting the bounding box and the rotation center
182
virtual
void
183
setGlobalBound
(
const
RealArray
&xBound);
184
185
virtual
RealArray
186
getGlobalBound
()
const
;
187
188
virtual
void
189
resetGlobalBound
(
const
int
win_number);
190
191
virtual
int
192
setKeepAspectRatio
(
bool
trueOrFalse=
true
);
193
194
//\begin{>>GL_GraphicsInterfaceInclude.tex}{\subsection{getKeepAspectRatio}}
195
virtual
bool
196
getKeepAspectRatio
(){
return
keepAspectRatio
[
currentWindow
];};
197
//----------------------------------------------------------------------
198
// /Description:
199
// Return true if the aspect ratio is preserved in the current window, otherwise return false.
200
// /Author: AP
201
//\end{GL_GraphicsInterfaceInclude.tex}
202
//----------------------------------------------------------------------
203
204
// plot points
205
virtual
void
206
plotPoints
(
const
realArray
&
points
,
207
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
208
int
dList = 0 );
209
210
#ifdef USE_PPP
211
// Version to use in parallel that takes serial arrays as input and forms the aggregate
212
virtual
void
213
plotPoints
(
const
RealArray
& points,
214
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
215
int
dList = 0);
216
#endif
217
218
virtual
void
219
plotPoints
(
const
realArray
& points,
220
const
realArray
& value,
221
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
222
int
dList = 0 );
223
224
#ifdef USE_PPP
225
// Version to use in parallel that takes serial arrays as input and forms the aggregate
226
virtual
void
227
plotPoints
(
const
RealArray
& points,
228
const
RealArray
& value,
229
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
230
int
dList = 0);
231
#endif
232
233
virtual
void
234
plotLines
(
const
realArray
& arrows,
235
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
236
int
dList = 0 );
237
238
// choose a colour
239
virtual
aString
240
chooseAColour
();
241
242
// get the name of the colour for backGroundColour, textColour, ...
243
virtual
aString
244
getColour
(
ItemColourEnum
item );
245
246
// set the colour for subsequent objects that are plotted
247
virtual
int
248
setColour
(
const
aString
& colourName );
249
250
// set colour to default for a given type of item
251
virtual
int
252
setColour
(
ItemColourEnum
item );
253
254
virtual
void
255
setColourFromTable
(
const
GUITypes::real
value,
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
() );
256
257
virtual
void
258
setColourName
(
int
i,
aString
newColourName )
const
;
259
260
virtual
aString
261
getColourName
(
int
i )
const
;
262
263
// Draw coloured squares with a number inside them to label colours on the plot
264
virtual
void
265
drawColouredSquares
(
const
IntegerArray
& numberList,
266
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
267
const
int
&
numberOfColourNames
= -1 ,
// use default colours by default
268
aString
*
colourNames
=
NULL
);
269
270
virtual
void
271
displayColourBar
(
const
int
& numberOfContourLevels,
272
RealArray
& contourLevels,
273
GUITypes::real
uMin,
274
GUITypes::real
uMax,
275
GraphicsParameters
& parameters);
276
277
// erase the colour bar.
278
virtual
void
279
eraseColourBar
();
280
281
// Save the graphics window in hard-copy form
282
virtual
int
283
hardCopy
(
const
aString
& fileName=
nullString
,
284
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
285
int
win_number=-1);
286
287
aString
*
colourNames
;
288
aString
*
fileMenuItems
;
289
aString
*
helpMenuItems
;
290
aString
*
graphicsFileMenuItems
;
291
aString
*
graphicsHelpMenuItems
;
292
aString
*
menuBarItems
;
293
294
virtual
void
295
setView
(
ViewLocation
& loc,
int
win_number = -1);
// win_number = -1 == currentWindow
296
297
virtual
void
298
getView
(
ViewLocation
& loc,
int
win_number = -1);
299
300
virtual
int
301
generateNewDisplayList
(
bool
lit =
false
,
bool
plotIt =
true
,
bool
hideable =
false
,
302
bool
interactive =
true
);
303
304
virtual
int
305
getNewLabelList
(
int
win = -1 );
306
307
virtual
void
308
deleteList
(
int
dList);
309
310
virtual
void
311
setLighting
(
int
list,
bool
lit);
312
313
virtual
void
314
setPlotDL
(
int
list,
bool
plot);
315
316
virtual
void
317
setInteractiveDL
(
int
list,
bool
interactive);
318
319
// access functions for display lists
320
virtual
int
321
getFirstDL
(
const
int
win){
return
topLabelList
[win]; }
322
323
virtual
int
324
getFirstFixedDL
(
const
int
win){
return
topLabelList
[win]; }
325
326
virtual
int
327
getTopLabelDL
(
const
int
win){
return
topLabelList
[win]; }
328
329
virtual
int
330
getTopLabel1DL
(
const
int
win){
return
topLabel1List
[win]; }
331
332
virtual
int
333
getTopLabel2DL
(
const
int
win){
return
topLabel2List
[win]; }
334
335
virtual
int
336
getTopLabel3DL
(
const
int
win){
return
topLabel3List
[win]; }
337
338
virtual
int
339
getBottomLabelDL
(
const
int
win){
return
bottomLabelList
[win]; }
340
341
virtual
int
342
getBottomLabel1DL
(
const
int
win){
return
bottomLabel1List
[win]; }
343
344
virtual
int
345
getBottomLabel2DL
(
const
int
win){
return
bottomLabel2List
[win]; }
346
347
virtual
int
348
getBottomLabel3DL
(
const
int
win){
return
bottomLabel3List
[win]; }
349
350
virtual
int
351
getColouredSquaresDL
(
const
int
win){
return
colouredSquaresList
[win]; }
352
353
virtual
int
354
getColourBarDL
(
const
int
win){
return
colourBarList
[win]; }
355
356
virtual
int
357
getFirstUserLabelDL
(
const
int
win){
return
firstUserLabelList
[win]; }
358
359
virtual
int
360
getLastUserLabelDL
(
const
int
win){
return
lastUserLabelList
[win]; }
361
362
virtual
int
363
getLastFixedDL
(
const
int
win){
return
lastUserLabelList
[win]; }
364
365
virtual
int
366
getFirstRotableDL
(
const
int
win){
return
axesList
[win]; }
367
368
virtual
int
369
getAxesDL
(
const
int
win){
return
axesList
[win]; }
370
371
virtual
int
372
getFirstUserRotableDL
(
const
int
win){
return
firstUserRotableList
[win]; }
373
374
virtual
int
375
getLastUserRotableDL
(
const
int
win){
return
lastUserRotableList
[win]; }
376
377
virtual
int
378
getLastRotableDL
(
const
int
win){
return
lastUserRotableList
[win]; }
379
380
virtual
int
381
getLastDL
(
const
int
win){
return
lastUserRotableList
[win]; }
382
383
virtual
int
384
getMaxNOfDL
(
const
int
win){
return
maximumNumberOfDisplayLists
[win]; }
385
386
virtual
int
387
getCurrentWindow
();
388
389
virtual
void
390
setCurrentWindow
(
const
int
& w);
391
392
// New way of setting plotTheAxes.
393
virtual
void
394
setPlotTheAxes
(
bool
newState,
int
win_number=-1);
395
396
virtual
bool
397
getPlotTheAxes
(
int
win_number=-1);
398
399
virtual
void
400
setAxesDimension
(
int
dim,
int
win_number=-1);
401
402
virtual
void
403
setPlotTheLabels
(
bool
newState,
int
win_number = -1);
404
405
virtual
bool
406
getPlotTheLabels
(
int
win_number = -1);
407
408
virtual
void
409
setPlotTheRotationPoint
(
bool
newState,
int
win_number = -1);
410
411
virtual
bool
412
getPlotTheRotationPoint
(
int
win_number = -1);
413
414
virtual
void
415
setPlotTheColourBar
(
bool
newState,
int
win_number = -1);
416
417
virtual
bool
418
getPlotTheColourBar
(
int
win_number = -1);
419
420
virtual
void
421
setPlotTheColouredSquares
(
bool
newState,
int
win_number = -1);
422
423
virtual
bool
424
getPlotTheColouredSquares
(
int
win_number = -1);
425
426
virtual
void
427
setPlotTheBackgroundGrid
(
bool
newState,
int
win_number = -1);
428
429
virtual
bool
430
getPlotTheBackgroundGrid
(
int
win_number = -1);
431
432
virtual
void
433
pollEvents
();
434
435
virtual
int
436
getAnswer
(
aString
& answer,
const
aString
& prompt);
437
438
virtual
int
439
getAnswer
(
aString
& answer,
const
aString
& prompt,
440
SelectionInfo
&selection);
441
442
virtual
int
443
getAnswerNoBlock
(
aString
& answer,
const
aString
& prompt);
444
445
446
virtual
int
447
pickPoints
(
RealArray
& x,
448
bool
plotPoints
=
TRUE
,
449
int
win_number = -1 );
450
451
virtual
void
452
setUserButtonSensitive
(
int
btn,
int
trueOrFalse );
453
454
virtual
void
455
pushGUI
(
GUIState
&newState );
456
457
virtual
void
458
popGUI
();
459
460
virtual
int
461
beginRecordDisplayLists
(
IntegerArray
& displayLists);
462
463
virtual
int
464
endRecordDisplayLists
(
IntegerArray
& displayLists);
465
466
virtual
void
467
createMessageDialog
(
aString
msg,
MessageTypeEnum
type);
468
469
virtual
int
470
pause
();
471
472
virtual
void
473
appendCommandHistory
(
const
aString
&answer);
474
475
virtual
int
476
processSpecialMenuItems
(
aString
& answer);
477
478
// plot and erase title labels
479
virtual
void
480
plotLabels
(
GraphicsParameters
& parameters,
481
const
GUITypes::real
& labelSize=-1.,
// <0 means use default in parameters
482
const
GUITypes::real
& topLabelHeight=.925,
483
const
GUITypes::real
& bottomLabelHeight=-.925,
484
int
win_number = -1);
485
486
virtual
void
487
eraseLabels
(
GraphicsParameters
& parameters,
int
win_number = -1);
488
489
virtual
int
490
setAxesLabels
(
const
aString
&
xAxisLabel
=
blankString
,
491
const
aString
&
yAxisLabel
=
blankString
,
492
const
aString
&
zAxisLabel
=
blankString
);
493
494
virtual
aString
495
getXAxisLabel
(){
return
xAxisLabel
[
currentWindow
];};
496
497
virtual
aString
498
getYAxisLabel
(){
return
yAxisLabel
[
currentWindow
];};
499
500
virtual
aString
501
getZAxisLabel
(){
return
zAxisLabel
[
currentWindow
];};
502
503
virtual
void
504
setXAxisLabel
(
const
aString
& xAxisLabel_=
blankString
){
xAxisLabel
[
currentWindow
]=xAxisLabel_;};
505
506
virtual
void
507
setYAxisLabel
(
const
aString
& yAxisLabel_=
blankString
){
yAxisLabel
[
currentWindow
]=yAxisLabel_;};
508
509
virtual
void
510
setZAxisLabel
(
const
aString
& zAxisLabel_=
blankString
){
zAxisLabel
[
currentWindow
]=zAxisLabel_;};
511
512
virtual
int
513
setAxesOrigin
(
const
GUITypes::real
x0=
defaultOrigin
,
const
GUITypes::real
y0=
defaultOrigin
,
const
GUITypes::real
z0=
defaultOrigin
);
514
515
virtual
void
516
getAxesOrigin
(
GUITypes::real
& x0,
GUITypes::real
& y0,
GUITypes::real
& z0 ){
517
x0=
axesOrigin
[
currentWindow
](0); y0=
axesOrigin
[
currentWindow
](1); z0=
axesOrigin
[
currentWindow
](2);
518
};
519
520
// return the aspect ratio of a window
521
virtual
GUITypes::real
522
getAspectRatio
(
const
int
win=0){
return
aspectRatio
[win];}
523
524
// Set scale factor for line widths (this can be used to increase the line widths for
525
// high-res off screen rendering.
526
virtual
void
527
setLineWidthScaleFactor
(
const
GUITypes::real
&
lineWidthScaleFactor
= 1,
int
win_number = -1 );
528
529
virtual
GUITypes::real
530
getLineWidthScaleFactor
(
int
window = -1 );
531
532
virtual
int
533
psToRaster
(
const
aString
& fileName,
534
const
aString
& ppmFileName );
535
536
537
// This utility routines plots a label, this label does NOT rotate or scale with the plot
538
virtual
void
539
label
(
const
aString
&
string
,
540
GUITypes::real
xPosition,
541
GUITypes::real
yPosition,
542
GUITypes::real
size=.1,
543
int
centering=0,
544
GUITypes::real
angle=0.,
545
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
546
const
aString
& colour =
nullString
,
547
GUITypes::real
zOffset =.99 );
548
549
// Plot a label in 2D world coordinates
550
// This label DOES rotate and scale with the plot
551
virtual
void
552
xLabel
(
const
aString
&
string
,
553
const
GUITypes::real
xPosition,
554
const
GUITypes::real
yPosition,
555
const
GUITypes::real
size=.1,
556
const
int
centering=0,
// -1=left justify, 0=center, 1=right justify
557
const
GUITypes::real
angle=0.,
558
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
559
int
win_number = -1);
560
561
// Plot a label in 3D world coordinates
562
// This label DOES rotate and scale with the plot
563
virtual
void
564
xLabel
(
const
aString
&
string
,
565
const
RealArray
& x,
// supply 3 position coordinates
566
const
GUITypes::real
size=.1,
567
const
int
centering=0,
568
const
GUITypes::real
angle=0.,
569
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
570
int
win_number = -1);
571
572
virtual
void
573
xLabel
(
const
aString
&
string
,
574
const
GUITypes::real
x[3],
575
const
GUITypes::real
size =.1,
576
const
int
centering = 0,
577
const
GUITypes::real
angle = 0.,
578
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
579
int
win_number = -1 );
580
581
// Plot a label with position and size in World coordinates,
582
// This label DOES rotate and scale with the plot. This version of xLabel
583
// plots the string in the plane formed by the vectors {\ff rightVector}
584
// and {\ff upVector}.
585
virtual
void
586
xLabel
(
const
aString
&
string
,
587
const
RealArray
& x,
// supply 3 position coordinates
588
const
GUITypes::real
size,
// size in world coordinates
589
const
int
centering,
590
const
RealArray
& rightVector,
// string lies parallel to this vector
591
const
RealArray
& upVector,
// in the plane of these two vectors
592
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
593
int
win_number = -1);
594
595
virtual
void
596
xLabel
(
const
aString
&
string
,
597
const
GUITypes::real
x[3],
598
const
GUITypes::real
size,
599
const
int
centering,
600
const
GUITypes::real
rightVector[3],
601
const
GUITypes::real
upVector[3],
602
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
(),
603
int
win_number = -1);
604
605
virtual
void
606
drawColourBar
(
const
int
& numberOfContourLevels,
607
RealArray
& contourLevels,
608
GUITypes::real
uMin=0.,
609
GUITypes::real
uMax=1.,
610
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
611
GUITypes::real
xLeft=.775,
// .8
612
GUITypes::real
xRight=.825,
// .85
613
GUITypes::real
yBottom=-.75,
614
GUITypes::real
yTop=.75);
615
616
// update the colour bar.
617
virtual
void
618
updateColourBar
(
GraphicsParameters
& parameters,
int
window=0);
619
620
// the following three routines need to be here so they are accessible by the callbacks
621
// initialize the screen, not normally called by a user.
622
void
623
init
(
const
int
& win_number);
624
625
void
626
changeView
(
const
int
& win_number,
627
const
real
& dx,
628
const
real
& dy ,
629
const
real
& dz,
630
const
real
& dThetaX=0.,
631
const
real
& dThetaY=0.,
632
const
real
& dThetaZ=0.,
633
const
real
& magnify=1. );
634
635
// display the screen, not normally called by a user.
636
void
637
display
(
const
int
& win_number);
638
639
protected
:
640
641
// reset rotation point to default
642
void
643
resetRotationPoint
(
int
win_number=-1);
644
645
// This routine sets the projection and modelview to a normalized system on [-1,1]x[-1,1]
646
void
647
setNormalizedCoordinates
();
648
649
// This routine un-does the previous function
650
void
651
unsetNormalizedCoordinates
();
652
653
// convert pick [0,1] + zBuffer [0,2**m] coordinates to world coordinates.
654
int
655
pickToWorldCoordinates
(
const
RealArray
&
r
,
RealArray
& x,
const
int
& win_number )
const
;
656
657
void
658
setRotationCenter
(
GUITypes::real
rotationPoint[3],
int
win_number=-1);
659
660
// This utility routines plot Axes
661
void
662
plotAxes
(
const
RealArray
& xBound,
663
const
int
numberOfDimensions,
664
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
(),
665
int
win_number = -1);
666
667
// erase the axes
668
void
669
eraseAxes
(
int
win_number);
670
671
// This label uses raster fonts **** this is not finished *****
672
void
673
labelR
(
const
aString
&
string
,
674
const
GUITypes::real
xPosition,
675
const
GUITypes::real
yPosition,
676
const
GUITypes::real
size=.1,
677
const
int
centering=0,
678
const
GUITypes::real
angle=0.,
679
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
());
680
681
// render directly to post-script without a raster
682
int
683
renderPS
(
const
char
* fileName,
684
GraphicsParameters
& parameters =
Overture::defaultGraphicsParameters
() );
685
686
void
687
setRotationTransformation
(
int
win_number);
688
689
virtual
void
690
setView
(
const
ViewParameters
& viewParameter,
const
GUITypes::real
& value);
691
692
void
693
getWindowShape
(
int
window,
GUITypes::real
&
leftSide
,
GUITypes::real
&
rightSide
,
GUITypes::real
&
top
,
GUITypes::real
&
bottom
)
const
;
694
695
GUIState
*
696
getCurrentGUI
(){
return
currentGUI
;}
697
698
// set the model view matrix for the current bounds
699
void
700
setModelViewMatrix
();
701
702
void
703
setFractionOfScreen
(
const
GUITypes::real
&
fraction
= .75,
int
win_number = -1 );
704
705
void
706
lightsOn
(
int
win_number);
707
708
void
709
lightsOff
(
int
win_number);
710
711
WindowProperties
wProp
;
712
713
int
currentWindow
;
714
715
// plotting routines should only use display lists up to numberOfAvailableDisplayLists.
716
// a few more are reserved for labels and other stuff
717
int
topLabelList
[
MAX_WINDOWS
],
// display list number for the top label
718
topLabel1List
[
MAX_WINDOWS
],
// display list number for the top label sub 1
719
topLabel2List
[
MAX_WINDOWS
],
720
topLabel3List
[
MAX_WINDOWS
],
721
bottomLabelList
[
MAX_WINDOWS
],
722
bottomLabel1List
[
MAX_WINDOWS
],
723
bottomLabel2List
[
MAX_WINDOWS
],
724
bottomLabel3List
[
MAX_WINDOWS
],
725
colouredSquaresList
[
MAX_WINDOWS
],
726
colourBarList
[
MAX_WINDOWS
],
727
firstUserLabelList
[
MAX_WINDOWS
],
728
lastUserLabelList
[
MAX_WINDOWS
],
/* = firstUserLabelList+100 */
729
axesList
[
MAX_WINDOWS
],
// axes are rotated
730
firstUserRotableList
[
MAX_WINDOWS
],
731
lastUserRotableList
[
MAX_WINDOWS
],
732
maximumNumberOfDisplayLists
[
MAX_WINDOWS
];
// this is the actual number that we have
733
734
// is the lighting on in the list?
735
// should the list be plotted?
736
// should the list be erased or just not plotted?
737
// should the list be display during interactive rotation?
738
IntegerArray
plotInfo
[
MAX_WINDOWS
];
739
740
public
:
// do this for now *wdh* 080123
741
742
bool
keepAspectRatio
[
MAX_WINDOWS
];
// usually we keep the aspect ratio for plots.
743
744
bool
viewHasChanged
[
MAX_WINDOWS
];
745
746
// global bounding box and rotation center
747
RealArray
globalBound
[
MAX_WINDOWS
];
748
GUITypes::real
rotationCenter
[
MAX_WINDOWS
][3];
749
750
GUITypes::real
magnificationFactor
[
MAX_WINDOWS
],
magnificationIncrement
[
MAX_WINDOWS
];
751
GUITypes::real
aspectRatio
[
MAX_WINDOWS
],
fractionOfScreen
[
MAX_WINDOWS
];
752
753
aString
wTitle
[
MAX_WINDOWS
];
754
755
aString
defaultWindowTitle
;
756
GraphicsParameters::HardCopyType
hardCopyType
[
MAX_WINDOWS
];
757
GraphicsParameters::OutputFormat
outputFormat
[
MAX_WINDOWS
];
758
759
aString
hardCopyFile
[
MAX_WINDOWS
];
760
int
rasterResolution
[
MAX_WINDOWS
];
// resolution for off screen renderer
761
int
horizontalRasterResolution
[
MAX_WINDOWS
];
// resolution for off screen renderer
762
763
// *wdh* removed 100912
764
// aString movieBaseName[MAX_WINDOWS];
765
// bool saveMovie[MAX_WINDOWS];
766
// int numberOfMovieFrames[MAX_WINDOWS], movieFirstFrame[MAX_WINDOWS];
767
// GUITypes::real movieDxRot[MAX_WINDOWS], movieDyRot[MAX_WINDOWS], movieDzRot[MAX_WINDOWS];
768
// GUITypes::real movieDxTrans[MAX_WINDOWS], movieDyTrans[MAX_WINDOWS], movieDzTrans[MAX_WINDOWS];
769
// GUITypes::real movieRelZoom[MAX_WINDOWS];
770
771
// hardcopy dialog window:
772
DialogData
hardCopyDialog
[
MAX_WINDOWS
];
773
774
// *wdh* removed 100912
775
// DialogData movieDialog[MAX_WINDOWS];
776
777
// option pulldown menu
778
PullDownMenu
optionMenu
[
MAX_WINDOWS
];
779
780
int
userLabel
[
MAX_WINDOWS
];
// current number of userLabels;
781
int
labelsPlotted
[
MAX_WINDOWS
];
// true if the top/bottom labels have been plotted.
782
783
GUITypes::real
xEyeCoordinate
,
yEyeCoordinate
,
zEyeCoordinate
;
// position of the eye
784
GUITypes::real
dtx
[
MAX_WINDOWS
],
dty
[
MAX_WINDOWS
],
dtz
[
MAX_WINDOWS
];
785
GUITypes::real
xShift
[
MAX_WINDOWS
],
yShift
[
MAX_WINDOWS
],
zShift
[
MAX_WINDOWS
];
786
787
GUITypes::real
deltaX
[
MAX_WINDOWS
],
deltaY
[
MAX_WINDOWS
],
deltaZ
[
MAX_WINDOWS
],
deltaAngle
[
MAX_WINDOWS
];
788
GUITypes::real
defaultNear
[
MAX_WINDOWS
],
defaultFar
[
MAX_WINDOWS
];
789
790
GUITypes::real
leftSide
[
MAX_WINDOWS
],
rightSide
[
MAX_WINDOWS
];
791
GUITypes::real
bottom
[
MAX_WINDOWS
],
top
[
MAX_WINDOWS
],
near
[
MAX_WINDOWS
],
far
[
MAX_WINDOWS
];
792
793
RealArray
rotationMatrix
[
MAX_WINDOWS
],
matrix
[
MAX_WINDOWS
];
794
#ifndef NO_APP
795
Index
I4
;
796
#endif
797
798
GUITypes::real
windowScaleFactor
[
MAX_WINDOWS
][3];
// current scale factors for the plotting window.
799
bool
userDefinedRotationPoint
[
MAX_WINDOWS
];
// TRUE if the user has defined the rotation center
800
801
int
axesOriginOption
[
MAX_WINDOWS
];
// indicates where to place the axes origin
802
RealArray
axesOrigin
[
MAX_WINDOWS
];
803
804
aString
xAxisLabel
[
MAX_WINDOWS
];
805
aString
yAxisLabel
[
MAX_WINDOWS
];
806
aString
zAxisLabel
[
MAX_WINDOWS
];
807
808
GUITypes::real
shiftCorrection
[
MAX_WINDOWS
][3];
// default correction for changing the rotation center
809
810
GUITypes::real
backGround
[
MAX_WINDOWS
][4];
// back ground colour (RGBA)
811
GUITypes::real
foreGround
[
MAX_WINDOWS
][4];
// text colour (not presently used) (RGBA)
812
813
// we can change the back-ground and text colour
814
// replace this by
815
aString
backGroundName
[
MAX_WINDOWS
],
foreGroundName
[
MAX_WINDOWS
];
816
817
bool
saveTransformationInfo
;
818
GLdouble
modelMatrix
[
MAX_WINDOWS
][16],
projectionMatrix
[
MAX_WINDOWS
][16];
819
GLint
viewPort
[
MAX_WINDOWS
][4];
820
821
GUITypes::real
homeViewParameters
[
MAX_WINDOWS
][14];
// holds the view parameters for the "home" view.
822
823
// here are default values for lights
824
int
lightIsOn
[
MAX_WINDOWS
][
numberOfLights
];
// which lights are on
825
GLfloat
ambient
[
MAX_WINDOWS
][
numberOfLights
][4];
826
GLfloat
diffuse
[
MAX_WINDOWS
][
numberOfLights
][4];
827
GLfloat
specular
[
MAX_WINDOWS
][
numberOfLights
][4];
828
GLfloat
position
[
MAX_WINDOWS
][
numberOfLights
][4];
829
GLfloat
globalAmbient
[
MAX_WINDOWS
][4];
830
831
// default material properties, these values are used for surfaces in 3D when we give them
832
// different colours
833
GLfloat
materialAmbient
[
MAX_WINDOWS
][4];
// AP: this variable is no longer used
834
GLfloat
materialDiffuse
[
MAX_WINDOWS
][4];
// AP: this variable is no longer used
835
GLfloat
materialSpecular
[
MAX_WINDOWS
][4];
836
GLfloat
materialShininess
[
MAX_WINDOWS
];
837
GLfloat
materialScaleFactor
[
MAX_WINDOWS
];
// AP: this variable is no longer used
838
839
// view characteristics structure, used to communicate with mogl
840
ViewCharacteristics
viewChar
[
MAX_WINDOWS
];
841
842
int
lighting
[
MAX_WINDOWS
];
843
bool
plotTheAxes
[
MAX_WINDOWS
];
// false=no axes
844
bool
plotBackGroundGrid
[
MAX_WINDOWS
];
// false =no grid
845
846
int
axesDimension
[
MAX_WINDOWS
];
// 1,2,3 = 1D, 2D, 3D axes
847
bool
plotTheRotationPoint
[
MAX_WINDOWS
];
848
bool
plotTheLabels
[
MAX_WINDOWS
];
849
bool
plotTheColouredSquares
[
MAX_WINDOWS
];
850
bool
plotTheColourBar
[
MAX_WINDOWS
];
851
852
// Scale line widths/ point sizes by this amount (for high-res off-screen render)
853
GUITypes::real
lineWidthScaleFactor
[
MAX_WINDOWS
];
854
855
// clipping planes
856
enum
857
{
858
maximumNumberOfClippingPlanes
=6,
859
maximumNumberOfTextStrings
=25
860
};
861
862
// number of clipping planes that have been turned on
863
int
numberOfClippingPlanes
[
MAX_WINDOWS
];
864
865
// TRUE if a clipping plane is turned on
866
// each clipping plane is defined by four constants c0*x+c1*y+c2*z+c3
867
int
clippingPlaneIsOn
[
MAX_WINDOWS
][
maximumNumberOfClippingPlanes
];
868
double
clippingPlaneEquation
[
MAX_WINDOWS
][
maximumNumberOfClippingPlanes
][4];
869
// store the clipping plane names in a array (for convenience)
870
GLenum
clip
[
MAX_WINDOWS
][
maximumNumberOfClippingPlanes
];
871
ClippingPlaneInfo
clippingPlaneInfo
[
MAX_WINDOWS
];
872
873
int
textIsOn
[
maximumNumberOfTextStrings
];
874
875
ColourBar
colourBar
;
876
877
void
setProjection
(
const
int
& win_number);
878
879
// for displaying user labels (defined interactively)
880
void
881
annotate
(
const
aString
& answer);
882
883
void
884
constructor
();
// int & argc, char *argv[], const aString & windowTitle = "Your Slogan Here");
885
886
bool
887
readOvertureRC
();
888
889
int
890
getAnswerSelectPick
(
aString
& answer,
const
aString
& prompt,
891
SelectionInfo
*selection_ =
NULL
,
892
int
blocking = 1);
893
894
int
895
interactiveAnswer
(
aString
& answer,
896
const
aString
& prompt,
897
SelectionInfo
* selection_,
898
int
blocking = 1);
899
900
// int
901
// select(const float xPick[], IntegerArray & selection, const int & selectOption=0 );
902
903
void
904
parseCommandLine
(
const
aString
& line,
aString
& command,
int
& windowNumber,
aString
& arg )
const
;
905
906
void
907
pickNew
(
PickInfo
&xPick,
SelectionInfo
& select);
908
909
int
910
selectNew
(
PickInfo
& xPick,
SelectionInfo
*select);
911
912
int
913
offScreenRender
(
const
char
* fileName,
914
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
() );
915
916
// This version uses X pixmaps
917
int
918
offScreenRenderX
(
const
char
* fileName,
919
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
() );
920
921
// This version uses the OSMesa library
922
int
923
offScreenRenderMesa
(
const
char
* fileName,
924
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
() );
925
926
int
927
saveRasterInAFile
(
const
aString
& fileName,
928
void
*buffer,
929
const
GLint & width,
930
const
GLint & height,
931
const
int
& rgbType =0,
932
GraphicsParameters
& parameters=
Overture::defaultGraphicsParameters
() );
933
934
void
935
rleCompress
(
const
int
num, GLubyte *xBuffer, FILE *outFile,
const
int
numPerLine = 30 );
936
937
void
938
setMaterialProperties
(
float
ambr,
float
ambg,
float
ambb,
939
float
difr,
float
difg,
float
difb,
940
float
specr,
float
specg,
float
specb,
float
shine);
941
942
void
943
setupHardCopy
(
DialogData
&hcd,
int
win);
944
945
// void
946
// setupMovie(DialogData &mov, int win);
947
948
void
949
hardcopyCommands
(
aString
&longAnswer,
int
win_number);
950
951
// void
952
// movieCommands(aString &longAnswer, int win_number);
953
954
void
955
optionCommands
(
aString
&answer,
int
win_number);
956
957
void
958
openGUI
();
959
960
void
961
disableGUI
();
962
963
// void
964
// getNormal( const MappedGrid & mg, const IntegerArray & iv, const int axis, RealArray & normal);
965
966
967
// these variables used to be in the class PlotStuff
968
// for grid plots
969
//IntegerArray boundaryConditionList;
970
//int numberOfBoundaryConditions;
971
972
// for streamlines:
973
// IntegerArray maskForStreamLines;
974
// IntegerArray componentsToInterpolate;
975
976
};
977
978
// define some macros to add extra info to the feed-back array
979
// Each macro will replace a single OpenGL call by 3 calls, adding extra info to the feedback array.
980
981
#define glEnable(stuff) glEnable(stuff), glPassThrough(GL_ENABLE_TOKEN), glPassThrough(stuff)
982
#define glDisable(stuff) glDisable(stuff), glPassThrough(GL_DISABLE_TOKEN), glPassThrough(stuff)
983
#define glLineWidth(size) glLineWidth(size), glPassThrough(GL_LINE_WIDTH_TOKEN), glPassThrough(size)
984
#define glLineStipple(num,pattern) glLineStipple(num,pattern), \
985
glPassThrough(GL_LINE_STIPPLE_TOKEN), glPassThrough(num), glPassThrough(pattern)
986
#define glPointSize(size) glPointSize(size), glPassThrough(GL_POINT_SIZE_TOKEN), glPassThrough(size)
987
988
#endif
Generated on Fri Jan 4 2013 10:17:52 for Overture by
1.8.3