00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef FIELD_VIEW_H 00012 #define FIELD_VIEW_H 00013 00014 //---------------------------------------------------------------------- 00015 00016 // class FieldView 00017 // 00018 // The FieldView class produces object which provide a viewing port for the 00019 // contents of a 2D Field through the GDL interface. A FielView object must 00020 // be constructed with a 2D Field object. Thie FieldView instantiation must 00021 // have the same template parameters as the Field being used to construct 00022 // the FieldView object. The FieldView runs in parallel by coalescing all 00023 // the Field data onto a parent node and redering from that node. The 00024 // parent node may be chosen with a constructor argument (the default is 00025 // process zero). For small Fields, the data may be scaled up by repeating 00026 // values across pixels in the GDL window, the number of pixels to repeat 00027 // for a given data point in the field can be set with the scaleX and 00028 // scaleY arguments in the constructor. The minSizeX and minSizeY arguments 00029 // to the constructor specifies a minimum number of pixels in the x and y 00030 // direction. If the data set is small, the scale factors will be increased 00031 // to the smallest integer satisfying the requirements specifiec by 00032 // minSizeX and minSizeY. 00033 // 00034 // FieldView objects can also be constructed from 3D Fields given 00035 // an axis which is considered perpendicular to the desired 2D plane 00036 // of view. For 3D, the view member function requires an unsigned to 00037 // specify which slice along the perpendicular axis to slice. 00038 // 00039 // J.V.W. Reynders - ACL/LANL July 15, 1996 00040 00041 // forward declarations 00042 template<class T, unsigned D> class LField; 00043 template<class T, unsigned D, class M, class C> class Field; 00044 template<unsigned D, class T> class UniformCartesian; 00045 00046 00047 //---------------------------------------------------------------------- 00048 template<class T, unsigned Dim, 00049 class Mesh=UniformCartesian<Dim,double>, 00050 class Centering=typename Mesh::DefaultCentering> 00051 class FieldView { 00052 00053 public: 00054 00055 // attach a 2D Field to a FieldView 00056 FieldView(Field<T,Dim,Mesh,Centering>& f, 00057 unsigned scaleX = 4, unsigned scaleY = 4, 00058 unsigned minSizeX = 200, 00059 unsigned minSizeY = 200, 00060 unsigned parent = 0); 00061 00062 // attach a 3D Field to a FieldView 00063 FieldView(unsigned sliceDim, Field<T,Dim,Mesh,Centering>& f, 00064 unsigned scaleX = 4, unsigned scaleY = 4, 00065 unsigned minSizeX = 200, 00066 unsigned minSizeY = 200, 00067 unsigned parent = 0); 00068 00069 ~FieldView(); 00070 void void_view(int& r); 00071 void void_view(unsigned, int& r); 00072 int view() { int r = 0; void_view(r); return r; } 00073 int view(unsigned s) { int r = 0; void_view(s,r); return r; } 00074 00075 private: 00076 T* Data; 00077 int* MapX; 00078 int* MapY; 00079 int dummy; 00080 Field<T,Dim,Mesh,Centering>& MyField; 00081 LField<T,2U>* MyLField; 00082 00083 unsigned SliceDim; // for 3D - select the axis 00084 unsigned ScaleX, ScaleY; 00085 unsigned MinSizeX, MinSizeY; 00086 unsigned Parent; 00087 unsigned SizeX, SizeY; 00088 00089 // draw all the data together onto the Parent process for viewing 00090 void update_2D_data(); 00091 void update_3D_data(unsigned slice); 00092 00093 // form map to fit the data into the viewing port 00094 void init_map(); 00095 00096 // form map to fit the data into the viewing port 00097 void void_apply_map(int& r); 00098 int apply_map() { int r; void_apply_map(r); return r; } 00099 00100 }; 00101 //---------------------------------------------------------------------- 00102 00103 #include "Utility/FieldView.cpp" 00104 00105 #endif // FIELD_VIEW_H 00106 00107 /*************************************************************************** 00108 * $RCSfile: FieldView.h,v $ $Author: adelmann $ 00109 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $ 00110 * IPPL_VERSION_ID: $Id: FieldView.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $ 00111 ***************************************************************************/