00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 char des_vect_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $" ;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include"headcpp.h"
00056
00057
00058 #include <math.h>
00059
00060
00061 #include <cpgplot.h>
00062
00063
00064
00065 void des_vect(float* vvx, float* vvy, int nx, int ny, float xmin, float xmax,
00066 float ymin, float ymax, double scale, double sizefl,
00067 const char* nomx, const char* nomy, const char* title, const char* device,
00068 int newgraph, int nxpage, int nypage) {
00069
00070
00071
00072
00073
00074 float hx = (xmax - xmin)/float(nx-1) ;
00075 float hy = (ymax - ymin)/float(ny-1) ;
00076
00077 float tr[6] ;
00078 tr[0] = xmin - hx ;
00079 tr[1] = hx ;
00080 tr[2] = 0 ;
00081 tr[3] = ymin - hy ;
00082 tr[4] = 0 ;
00083 tr[5] = hy ;
00084
00085
00086
00087
00088
00089 if (scale < 0) {
00090
00091 double norme_max = 0 ;
00092 for(int ix = 0; ix < nx; ix++) {
00093 for(int iy = 0; iy < ny; iy++) {
00094 double xxx = sqrt( vvx[iy*nx+ix]*vvx[iy*nx+ix] +
00095 vvy[iy*nx+ix]*vvy[iy*nx+ix] ) ;
00096 norme_max = (xxx > norme_max) ? xxx : norme_max ;
00097 }
00098 }
00099
00100 if (norme_max < 1.e-14) {
00101 scale = 1 ;
00102 }
00103 else{
00104 double pas_max = (hx > hy) ? hx : hy ;
00105 scale = fabs(scale) * pas_max / norme_max ;
00106 }
00107 cout << "des_vect: norme_max = " << norme_max << endl ;
00108 cout << "des_vect: scale = " << scale << endl ;
00109 }
00110
00111
00112
00113
00114
00115 if ( (newgraph == 1) || (newgraph == 3) ) {
00116
00117 if (device == 0x0) device = "?" ;
00118
00119 int ier = cpgbeg(0, device, nxpage, nypage) ;
00120 if (ier != 1) {
00121 cout << "des_vect: problem in opening PGPLOT display !" << endl ;
00122 }
00123
00124 }
00125
00126
00127 float size = float(1.3) ;
00128 cpgsch(size) ;
00129
00130
00131 int lepais = 1 ;
00132 cpgslw(lepais) ;
00133
00134
00135 cpgscf(2) ;
00136
00137
00138 cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ;
00139 cpglab(nomx,nomy,title) ;
00140
00141
00142
00143 float sizefl1 = float(sizefl) ;
00144 cpgsch(sizefl1) ;
00145
00146 float blank = 0 ;
00147 float scale1 = float(scale) ;
00148 int nc = 1 ;
00149
00150 cpgvect(vvx, vvy, nx, ny, 1, nx, 1, ny, scale1, nc, tr, blank) ;
00151
00152 cpgsch(size) ;
00153
00154
00155
00156
00157
00158
00159 if ( (newgraph == 2) || (newgraph == 3) ) {
00160 cpgend() ;
00161 }
00162
00163
00164 }