/****************************************************************** * * * Nest version 2 - 3D Wasp Nest Simulator * * Copyright (C) 1997 Sylvain GUERIN * * LIASC, ENST Bretagne & Santa Fe Institute * * * ****************************************************************** E-mail: Sylvain.Guerin@enst-bretagne.fr or: Sylvain Guerin 13 rue des Monts Lorgeaux, 51460 L'EPINE, FRANCE ****************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************** Name : view3d.h Component : 3D visualisation (View object) Fonctionality : contains specifications for the View object (used in view and edition interfaces) ******************************************************************/ #ifndef __view3d_H #define __view3d_H #include #include #include #include #include #include "algo.h" #include "tools.h" #include "graphical.h" #define pi 3.1415926535 #define max(a,b) ( (amax(b,c)) ? a:max(b,c)) #define absf(a) ( (a>0) ? (float)a: (float)(- 1.0 * (float)a)) struct viewIconLineType { unsigned int p1; unsigned int p2; }; #define ROTATION_SPEED 360 enum type_tr_dir { UP, RIGHT, LEFT, DOWN }; class View { public: plan work_plan; View (Display* aDisplay, Window aWin, GC aGC, Window aIconWin, unsigned long* manyColor, displayModeType aDisplayMode, unsigned int aWidth, unsigned int aHeight, XFontStruct *aFontInfo, unsigned int defaultDepth, Architecture* anArch, SimulationType aSimuType, Window aPreviewWindow); ~View (); void changeWindows (Window aWin, Window aIconWin); void print (); void init_view (position init_viewed_point, position init_org, double initZoom, double initIconZoom, int iconTx, int iconTy); void drawNet(int alreadyComputed, int isCut); void change_zoom (int up_down); void translate_view (type_tr_dir tr_dir); void translate (int dx, int dy); void setTxTy (int newTx, int newTy); void setViewCut (int newZCut, double newTetaCut, double newPhiCut); void change_phi (int up_down); void change_teta (int up_down); void change_alpha (int up_down); void set_alpha (double newAlpha); void changeTetaCut (int up_down); void changePhiCut (int up_down); void changeZCut (int up_down); void up_down (); /* retourne la vue */ double get_teta (); double get_phi (); double get_alpha (); double get_zoom (); int getZCut (); double getTetaCut (); double getPhiCut (); int get_tx (); int get_ty (); position get_org (); position get_real_coords (position_plan pos); position_plan_double get_view_coords (position pos); void setAxes (); void unsetAxes (); void drawLine (double x1, double y1, double x2, double y2); void displayViewIcon (); void displayViewIconLine (position p1, position p2, unsigned int col, char c, unsigned int index); void recenter (void); // reinit zoom, position and alpha void memorize (void); // memorize zoom, angles, position void settings_1 (void); /* set viewed_direction, eye_plan, work_plan, teta, phi, rotation_matrix, inverse_rotation_matrix, tx, ty, tx0, ty0 from zoom, org, viewed_point, view_mode, alpha init also phi0 and teta0 */ void settings_2 (void); /* same as settings_1 (), but don't change tx, ty , don't init phi0 teta0*/ void settings_3 (position sv_org, double sv_teta, double sv_phi, double sv_alpha, double sv_zoom); /* set viewed_point, viewed_direction, eye_plan, work_plan, rotation_matrix, inverse_rotation_matrix, tx, ty, tx0, ty0 from zoom, org, teta, phi, alpha init also phi0 and teta0 */ void resize (); /* resize the view in the window */ void savePreview (); /* method used for saving the preview */ void clearTempScreen (); void displayTempScreen (); Pixmap getTempScreen (); void setArchitecture (Architecture* anArch); protected: Architecture* anArchitecture; SimulationType simuType; Display* display; Window win; Window iconWin; GC gc; XFontStruct* fontInfo; Pixmap tempScreen; unsigned int depth; unsigned long* color; int width, height; /* size of graphic window */ displayModeType displayMode; position viewed_point; position org; direction viewed_direction; double zoom; // only used in PERSPECTIV_MODE double zoom0; // memory for zoom double viewIconZoom; plan eye_plan; // only used in REAL_WORLD_MODE double teta; // between -pi and pi double phi; // between -pi/2 and pi/2 double alpha; // betweem -pi and pi double teta0, phi0, alpha0; Matrix rotation_matrix; Matrix inverse_rotation_matrix; Matrix2 alpha_matrix; int tx, ty; int tx0, ty0; int viewIconTx, viewIconTy; int mx[33]; /* coords save for view_fig */ int my[33]; position_plan cubePoint[3][4]; /* num facette, points */ unsigned long cubeFacetteColor[2][3]; /* typeCube, num facette */ position* viewIconPosition; viewIconLineType* viewIconLine; int showAxes; double hexaRoundSize; double zLenght; /* parameters for view cut */ int zCut; double tetaCut; double phiCut; Window previewWindow; /* fenetre sur laquelle on affiche la previsualisation */ void loadViewIconDatas (); void loadViewIconPosition (position pos, unsigned int index); void loadViewIconLine (unsigned int ext1, unsigned int ext2, unsigned int index); void drawViewIconLine (position_plan p1, position_plan p2, unsigned int col); void drawViewIconAxe (position_plan p, char c, unsigned int col); void set_tx_ty_with_vp (void); /* last setting to be done */ void set_all_with_new_teta_phi (void); void adjust_teta_phi (void); void drawFacette (Facette aFacette, typeOfCell cellType); void putCube (typeOfCell cellType, int i, int j, int k); void putHexa (typeOfCell cellType, int i, int j, int k); void computeCubeDatas (); void computeFacetteDatas (Facette aFacette, int* facetteNb); void fastPutCube (typeOfCell cellType, int i, int j, int k); void setCut (position* aPosition, double aY, double aZ, double a, double b, double c); }; #endif