source: trunk/src/testing/app/mframes/init_code/initf.h @ 4

Revision 4, 7.8 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1
2/******************************************************************************
3 * SAGE - Scalable Adaptive Graphics Environment
4 *
5 * Copyright (C) 2004 Electronic Visualization Laboratory,
6 * University of Illinois at Chicago
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 *  * Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 *  * Redistributions in binary form must reproduce the above
16 *    copyright notice, this list of conditions and the following disclaimer
17 *    in the documentation and/or other materials provided with the distribution.
18 *  * Neither the name of the University of Illinois at Chicago nor
19 *    the names of its contributors may be used to endorse or promote
20 *    products derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
35 *
36 *****************************************************************************/
37#ifndef ANIMVIEWER_H
38#define ANIMVIEWER_H
39
40//#include "vtkXOpenGLOffScreenRenderWindow.h"
41
42#include <iostream>
43#include <sstream>
44#include <string>
45#include <vector>
46#include <stdlib.h>
47#include <stdio.h>
48#include <pthread.h>
49#include <sys/types.h>
50#include <sys/mman.h>
51#include <sys/stat.h>
52#include <unistd.h>
53#include <sys/mman.h>
54#include <fcntl.h>
55
56using namespace std;
57
58/************************/
59
60#include "tile_config.h"
61#include "file_parsers.h"
62
63// SAGE related headers
64#include <sail.h>
65#include <misc.h>
66
67/************************/
68
69
70/* MPI */
71#include <mpi.h>
72
73/* VTK */
74#include <vtk/vtkActor.h>
75#include <vtk/vtkCamera.h>
76#include <vtk/vtkLight.h>
77#include <vtk/vtkRenderWindow.h>
78#include <vtk/vtkRenderer.h>
79#include <vtk/vtkImageImport.h>
80#include <vtk/vtkTexture.h>
81#include <vtk/vtkTransformTextureCoords.h>
82#include <vtk/vtkTextureMapToPlane.h>
83#include <vtk/vtkPlaneSource.h>
84#include <vtk/vtkMergeFilter.h>
85#include <vtk/vtkPolyDataMapper.h>
86#include <vtk/vtkImageFlip.h>
87#include <vtk/vtkProperty.h>
88#include <vtk/vtkSphereSource.h>
89#include <vtk/vtkTextSource.h>
90#include <vtk/vtkFrustumCoverageCuller.h>
91#include <vtk/vtkTextActor.h>
92#include <vtk/vtkTextProperty.h>
93
94#include <vtk/vtkSphereSource.h>
95#include <vtk/vtkCubeSource.h>
96#include <vtk/vtkConeSource.h>
97#include <vtk/vtkJPEGReader.h>
98#include <vtk/vtkImageMapper.h>
99#include <vtk/vtkActor2D.h>
100
101/* QUANTA */
102#include <QUANTA/QUANTAinit.hxx>
103#include <QUANTA/QUANTAnet_tcp_c.hxx>
104#include <QUANTA/QUANTAnet_datapack_c.hxx>
105
106#define PANLEFT "panleft"
107#define PANRIGHT "panright"
108#define PANUP "panup"
109#define PANDOWN "pandown"
110#define BROWSERIGHT "browseright"
111#define BROWSELEFT "browseleft"
112#define ZOOMIN "zoomin"
113#define ZOOMOUT "zoomout"
114#define SELECT "select"
115#define RELEASE "release"
116#define PRESS "press"
117#define SLIDER1 "slider1"
118#define SLIDER2 "slider2"
119#define SLIDER3 "slider3"
120#define QUIT "quit"
121#define CENTER "center"
122
123int PORT= 5678;
124#define TRANSMISSION_SIZE 16
125
126#define ZIN 1
127#define ZOUT 0
128
129QUANTAnet_tcpServer_c* server;
130QUANTAnet_tcpClient_c* client;
131char* recmsg;
132
133double CamPosition[3];
134double Fpoint[3];
135double PanAmount;
136
137double Zoom = 7;
138double ZoomAmount;
139
140double StartingZ;
141
142//SAGE STUFF
143int winWidth, winHeight;
144sail sageInf;
145
146int rank;
147int size;
148
149int xWindowPos = 0;
150int yWindowPos = 0;
151
152vtkRenderer* renA = vtkRenderer::New();
153vtkRenderer* renB = vtkRenderer::New();
154vtkRenderWindow* renWin = vtkRenderWindow::New();
155vtkLight* light = vtkLight::New();
156vtkFrustumCoverageCuller* culler = vtkFrustumCoverageCuller::New();
157vtkTextActor *text = vtkTextActor::New();
158
159vtkConeSource *cone = vtkConeSource::New();
160vtkCubeSource *cube = vtkCubeSource::New();
161vtkSphereSource *sphere = vtkSphereSource::New();
162vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
163vtkActor *pointer = vtkActor::New();
164
165vtkJPEGReader *splash = vtkJPEGReader::New();
166vtkImageMapper *splashMapper = vtkImageMapper::New();
167vtkActor2D *splashScreen = vtkActor2D::New();
168
169#define PANSUBDIVISIONS 10
170
171#define GRAYSCALE 1
172#define RGB 3
173#define RGBA 4
174int MODE;
175
176int start = 0;
177int end = 0;
178
179#define LEFT -1
180#define RIGHT 1
181#define UP -2
182#define DOWN 2
183#define ACCEPT 0
184
185#define X 0
186#define Y 1
187
188int CurrentLevel = 0;
189
190//#define DEBUG
191
192struct ZBound {
193        double bound;
194};
195
196struct Viewable {
197        long level;
198        bool virgin;
199        unsigned char*** pixels;
200};
201
202struct Point {
203        long l;
204        long c;
205        long r;
206};
207
208struct Geometry {
209        vtkImageImport *importer;
210        vtkTexture* texture;
211        vtkPolyDataMapper *mapper;
212        vtkActor* actor;
213        vtkPlaneSource *plane;
214        vtkImageFlip *flip;
215
216        vtkTextSource *textSource;
217        vtkPolyDataMapper *textMapper;
218        vtkActor *textActor;
219
220
221        int fd;
222};
223
224struct Info {
225
226        double scale[2];
227        double position[3];
228        double depth[1];
229};
230
231
232
233
234
235class AnimViewer {
236
237
238public:
239
240        AnimViewer();
241        ~AnimViewer();
242
243        string IntToString(long);
244        void CopyBuffer(unsigned char*, unsigned char*);
245        long GetNumOfCols(long, long);
246        long GetNumOfRows(long, long);
247        long GetLevelBlockWidth(long);
248        long GetLevelBlockHeight(long);
249        long GetLevelNumOfCols(long);
250        long GetLevelNumOfRows(long);
251        void InitViewer(char*);
252        void GetAnimFiles();
253        unsigned char* GetPixelsFromFile(long, long, long);
254        unsigned char* MMap(long, long, long);
255        void InitRendering();
256        void SetUpPipeline();
257        void UpdateBlock(long, long, long);
258        void ImportQueryWindowPixels();
259        void FindStartingQueryWindow();
260        void GivePixelsToVTK();
261        void QueryWindowPanRight();
262        void QueryWindowPanLeft();
263        void QueryWindowPanUp();
264        void QueryWindowPanDown();
265        void QueryWindowZoomIn();
266        void QueryWindowZoomOut();
267        void PositionAndScaleBlocks();
268        void ComputeStartingBlockSize();
269        double GetRowPositionAtLevel(long, long);
270        double GetColPositionAtLevel(long, long);
271        double GetBlockWidthAtLevel(long);
272        double GetBlockHeightAtLevel(long);
273        void AddBlock(long, long, long);
274        void RemoveBlock(long, long, long);
275
276        void AdjustLevelMovement(int, int);
277        int AdjustZoomMovement(int);
278        long GetQueryWindowLevel();
279        int BlockOutOfBounds(long, long, long, long);
280
281        void ZoomIn();
282        void ZoomOut();
283        void PanLeft();
284        void PanRight();
285        void PanUp();
286        void PanDown();
287        void UpdateCamera(double[], double[]);
288        double GetCenterX();
289        double GetCenterY();
290        void RepositionCamera();
291
292        void RemoveRegion(long, long, long, long, long);
293        void AddRegion(long, long, long, long, long);
294
295        void GetCamProjection(double, double);
296        void BuildMainQueryWindow();
297
298        void BringUpStartingImage();
299
300        bool NeedToUpdateMainWindow();
301
302        void CleanUpMainWindow();
303
304        void SetTimeStep(int);
305
306        void CreateZoomBounds();
307
308        void GetZProjection(double);
309
310        void SetCurrentLevel(int);
311
312        void SetInitialCamPosition();
313
314
315private:
316
317        int BlockDimensions[2];
318        int GlobalDimensions[2];
319
320
321        int Colorspace;
322
323        string AnimDir;
324
325        int NumOfLevels;
326
327        int StartingLevel;
328
329        unsigned char* pixelbuff;
330
331        string*** AnimFiles;
332
333        Geometry*** Block;
334
335        Viewable QueryWindow;
336        Info** BlockInfo;
337        double BlockInitSize[2];
338
339        Point CamProjection;
340
341        ZBound* ZoomBounds;
342        int NumOfZBounds;
343
344        unsigned char* Blank;
345
346
347        int NumOfCols;
348        int NumOfRows;
349};
350
351
352#endif
Note: See TracBrowser for help on using the repository browser.