view.h

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 #ifndef __VIEW_H
00029 #define __VIEW_H
00030 
00031 class ScanEvent;
00032 class ViewControl;
00033 class ProfileControl;
00034 class V3dControl;
00035 
00036 #include "gnome-res.h"
00037 
00038 #include "mem2d.h"
00039 #include "xshmimg.h"
00040 #include <stdlib.h>
00041 
00042 #include <GL/gl.h>
00043 #include <GL/glx.h>
00044 #include <GL/glu.h>
00045 #include <GL/glut.h>
00046 
00047 #define TOPO_BORDER_WIDTH 14
00048 #define TOPO_MINSIZE      400 // Default Wert
00049 
00050 #define NUM_TRACE_VALUES 4
00051 typedef struct{
00052         double x,y,z;
00053         double v[NUM_TRACE_VALUES];
00054         int mode;
00055         clock_t t;
00056 } Trace_Data;
00057 
00058 /*
00059  * XSM View Basis-Objekt:
00060  * Basis aller Arten von View's
00061  * ============================================================
00062  */
00063 
00064 class View{
00065 public:
00066   View();
00067   View(Scan *sc, int ChNo);
00068   virtual ~View();
00069 
00070   virtual void hide();
00071   virtual int draw(int zoomoverride=FALSE);
00072   virtual int update(int y1, int y2);
00073   virtual void add_object(int type, gpointer data){};
00074   virtual void setup_data_transformation(){};
00075 
00076   virtual void update_mxyz_from_points ();
00077 
00078   virtual void ZoomIn(){};
00079   virtual void ZoomOut(){};
00080   
00081 
00082 // manipulation visualisation
00083   void abs_move_tip(double xa, double ya, int mode=0);
00084   void rel_move_tip(double dxa, double dya, int mode=0);
00085   virtual void show_tip(){};
00086   virtual void hide_tip(){};
00087 
00088   void update_position(Trace_Data *td);
00089   void add_to_trace(Trace_Data *td);
00090   void print_trace();
00091   void save_trace();
00092   void reset_trace();
00093   static void print_td(Trace_Data *td, gpointer data);
00094   static void delete_td(Trace_Data *td, gpointer data) { delete td; };
00095   virtual void show_trace(){};
00096   virtual void hide_trace(){};
00097 
00098   virtual void update_trace(){};
00099 
00100   virtual void update_events(){};
00101   virtual void remove_events(){};
00102 
00103   virtual void update_event_info(ScanEvent *se){};
00104 
00105   int ZoomFac;
00106   int QuenchFac;
00107 protected:
00108   Scan *scan;
00109   SCAN_DATA *data;
00110   Mem2d *mem2d;
00111   int ChanNo;
00112   GSList *trace;
00113 private:
00114   Trace_Data current_td;
00115   clock_t trace_t0;
00116 };
00117 
00118 /*
00119  *
00120  * Folgende Viewing-Modelle sind geplant:
00121  * ========================================
00122  * 2D Graubild, Darstellungsmode "Quick"/"Direct" über mem2d-Mapping
00123  * class Grey2D    : public View{};
00124  *
00125  * Linien-Profil-Dartsellung aus 2D Z Daten
00126  * class Line      : public View{};
00127  *
00128  * Schnelle Profil-Dartsellung aus 2D Z Daten, Höhenprofilen untereinander
00129  * class Profiles  : public View{};
00130  *
00131  * Echte-3D-Dartsellung ... + povray Unterstützung, etc....
00132  * class Surface3D : public View{};
00133  *
00134  */
00135 
00136 
00137 /*
00138  * Grey2D Ableitung
00139  * ============================================================
00140  */
00141 
00142 class Grey2D : public View{
00143 public:
00144   Grey2D();
00145   Grey2D(Scan *sc, int ChNo);
00146   virtual ~Grey2D();
00147 
00148   virtual void hide();
00149   virtual int draw(int zoomoverride=FALSE);
00150   virtual int update(int y1, int y2);
00151   virtual void add_object(int type, gpointer data);
00152   virtual void setup_data_transformation();
00153   static int SetZF(int zf, int qf, Grey2D *p);
00154 
00155   virtual void ZoomIn();
00156   virtual void ZoomOut();
00157 
00158 // manipulation visualisation
00159   virtual void show_tip();
00160   virtual void hide_tip();
00161 
00162   virtual void show_trace();
00163   virtual void hide_trace();
00164 
00165   virtual void update_trace();
00166 
00167   virtual void update_events();
00168   virtual void remove_events();
00169 
00170   virtual void update_event_info(ScanEvent* se);
00171 
00172 private:  
00173   int  MaxColor;
00174   int  XPM_x, XPM_y;
00175   int  oXPMx,oXPMy,oZ,oQ,oMC; /* old Values */
00176   int  oVm;
00177   int  userzoom;
00178                          
00179   ViewControl *viewcontrol;
00180   ShmImage2D *XImg;
00181 };
00182 
00183 
00184 class Profiles  : public View{
00185 public:
00186   Profiles();
00187   Profiles(Scan *sc, int ChNo);
00188   virtual ~Profiles();
00189 
00190   virtual void hide();
00191   virtual int draw(int zoomoverride=FALSE);
00192   virtual int update(int y1, int y2);
00193   virtual void ZoomIn(){};
00194   virtual void ZoomOut(){};
00195 
00196 private:  
00197   ProfileControl *profile;
00198 };
00199 
00200 
00201 typedef struct{
00202         float trans[3];
00203         float rot[3];
00204         float fov;
00205         float dist;
00206         float Zfar;
00207         float Znear;
00208 
00209         float hskl;
00210 
00211         float light_global_ambient[4];
00212         gchar light[3][8];
00213         float light_position[3][4];
00214         float light_ambient[3][4];
00215         float light_specular[3][4];
00216         float light_diffuse[3][4];
00217         int   light_spot[3];    
00218         float light_spot_direction[3][3];
00219         float light_spot_cutoff[3];
00220         float light_spot_exponent[3];
00221 
00222         float surf_mat_color[4];
00223         float surf_mat_ambient[4];
00224         float surf_mat_specular[4];
00225         float surf_mat_diffuse[4];
00226         float surf_mat_shininess[1];
00227 
00228         float box_mat_color[4];
00229         float box_mat_ambient[4];
00230         float box_mat_specular[4];
00231         float box_mat_diffuse[4];
00232         float box_mat_shininess[1];
00233 
00234         int Fog;
00235         float fog_color[4];
00236         float fog_density;
00237 
00238         float clear_color[4];
00239 
00240         int Texture;
00241         int Mesh;
00242         int Cull;
00243         int Smooth;
00244         int Ortho;
00245         int Ticks;
00246         
00247         float preV;
00248 
00249         gchar ColorMode[20];
00250         gchar ColorSrc[20];     
00251 
00252         float ColorContrast, ColorOffset, ColorSat;
00253 
00254         int ZeroPlane;
00255         int InstantUpdate;
00256 
00257 } Surf3d_GLview_data;
00258 
00259 class Surf3d  : public View{
00260 public:
00261   Surf3d();
00262   Surf3d(Scan *sc, int ChNo);
00263   virtual ~Surf3d();
00264 
00265   virtual void hide();
00266   virtual int draw(int zoomoverride=FALSE);
00267   virtual int update(int y1, int y2);
00268   virtual void ZoomIn(){};
00269   virtual void ZoomOut(){};
00270   virtual void setup_data_transformation();
00271 
00272   gboolean GLdrawscene(int y_to_update=-1, int refresh_all=FALSE);
00273   gboolean reshape(GtkWidget *widget, GdkEventConfigure *event);
00274   static void GLupdate(void* data);
00275 
00276   void Rotate(int n, double dphi);
00277   void RotateAbs(int n, double phi);
00278   double RotateX(double dphi);
00279   double RotateY(double dphi);
00280   double RotateZ(double dphi);
00281 
00282   void Translate(int n, double delta);
00283   double Zoom(double x);
00284   double HeightSkl(double x);
00285 
00286   void ColorSrc();
00287   void GLModes(int n, int m);
00288 
00289   void preferences();
00290 
00291 private: 
00292   void PutPointMode(int k, int j);
00293   void ReadPalette(char *name);
00294 
00295   int   XPM_x, XPM_y;
00296   Mem2d *mem2d_x;
00297 
00298   GnomeResPreferences *v3dControl_pref_dlg;
00299   GnomeResEntryInfoType *v3dControl_pref_def;
00300 
00301   void GLvarinit ();
00302   int  GetSmem ();
00303   int  DelSmem ();
00304   void GLdrawsurface (int y_to_update=-1, int refresh_all=FALSE);
00305   void GLdrawGimmicks ();
00306   void printstring (void *font, char *string);
00307   void calccolor (GLfloat height, GLfloat c[3]);
00308 
00309   GLfloat *surface;
00310   GLfloat **surfacecolor;
00311   GLubyte *surfacepic;
00312   GLuint glZeroFrameList, glSurfaceList, glSurfaceListRange;
00313   GLfloat ColorLookup[1024][3];
00314 
00315   int valid;
00316   unsigned long size;
00317 
00318   int scrwidth;
00319   int scrheight;
00320 
00321  public:
00322   int GL_realized;
00323   Surf3d_GLview_data GLv_data;
00324 
00325  private:
00326   V3dControl *v3dcontrol;
00327 };
00328 
00329 #endif
00330 
00331 
00332 

Generated on Sat Apr 1 09:04:06 2006 for GXSM by  doxygen 1.4.6