[1920] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // classe pour tracer des flow chart (champs de vecteurs) 2d
|
---|
| 3 | // NB herite de PIDrawer
|
---|
| 4 | // O. Perdereau 01/2002
|
---|
| 5 | //
|
---|
| 6 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 7 |
|
---|
| 8 | #include "machdefs.h"
|
---|
| 9 | #include <stdio.h>
|
---|
| 10 | #include <stdlib.h>
|
---|
| 11 | #include <iostream.h>
|
---|
| 12 | #include <math.h>
|
---|
| 13 |
|
---|
| 14 | #include "histos.h"
|
---|
| 15 | #include "ntuple.h"
|
---|
| 16 |
|
---|
| 17 | #include "nbtri.h"
|
---|
| 18 |
|
---|
| 19 | #include "pi2dvec.h"
|
---|
| 20 |
|
---|
| 21 | #include <sys/time.h>
|
---|
| 22 | #include <sys/resource.h>
|
---|
| 23 |
|
---|
| 24 | //++
|
---|
| 25 | // Class PI2dVecDrawer
|
---|
| 26 | // Lib PIGcont
|
---|
| 27 | // include pigncont.h2dvec.h
|
---|
| 28 | //
|
---|
| 29 | //
|
---|
| 30 | // Classe de trace d'un champ de vecteurs (flow chart) en 2 dimensions
|
---|
| 31 | //
|
---|
| 32 | //
|
---|
| 33 | //--
|
---|
| 34 | //++
|
---|
| 35 | // Links Parents
|
---|
| 36 | // PIDrawer
|
---|
| 37 | //--
|
---|
| 38 | //
|
---|
| 39 | //++
|
---|
| 40 | // Titre Constructeurs et Méthodes
|
---|
| 41 | //--
|
---|
| 42 |
|
---|
| 43 | //++
|
---|
| 44 | // PI2dVecDrawer::PI2dVecDrawer(NTupleInterface* nti,bool autodel)
|
---|
| 45 | // Constructeur
|
---|
| 46 | //
|
---|
| 47 | //--
|
---|
| 48 | PI2dVecDrawer::PI2dVecDrawer(NTupleInterface* nti,bool autodel)
|
---|
| 49 | {
|
---|
| 50 | _nti = nti;
|
---|
| 51 |
|
---|
| 52 | _autodel = autodel;
|
---|
| 53 | SelectXY(NULL, NULL);
|
---|
| 54 | SelectVW(NULL, NULL);
|
---|
| 55 |
|
---|
| 56 | // This drawer has *NO* specific control tools
|
---|
| 57 | mFgSpecContWind = false;
|
---|
| 58 |
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | /* --Methode-- */
|
---|
| 63 | PI2dVecDrawer::~PI2dVecDrawer()
|
---|
| 64 | {
|
---|
| 65 |
|
---|
| 66 | if(_autodel){ //cout << " destructeur de PI2dVecDrawer / autodel "<<endl;
|
---|
| 67 | if(_nti!=NULL){delete _nti ; _nti=NULL;}
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /* --Methode-- */
|
---|
| 73 | void PI2dVecDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax){
|
---|
| 74 |
|
---|
| 75 | if(_nti==NULL){cout << " PI2dVecDrawer::Draw : null ntuple "<<endl; return;}
|
---|
| 76 | if ( (xK < 0) || (yK < 0) ){cout << " PI2dVecDrawer::Draw : no X/Y "<<endl; return;}
|
---|
| 77 | if ( (vK < 0) || (wK < 0) ){cout << " PI2dVecDrawer::Draw : no VX/VY "<<endl; return;}
|
---|
| 78 |
|
---|
| 79 | int npt = _nti->NbLines();
|
---|
| 80 | int i=0;
|
---|
| 81 | double x,y,vx,vy;
|
---|
| 82 | double xa[2];
|
---|
| 83 | double ya[2];
|
---|
| 84 | g->SaveGraphicAtt();
|
---|
| 85 |
|
---|
| 86 | // choix de la couleur
|
---|
| 87 | g->SelForeground(GetGraphicAtt().GetFgColor());
|
---|
| 88 |
|
---|
| 89 | // choix de la ligne
|
---|
| 90 | PILineAtt mlatt = GetGraphicAtt().GetLineAtt() ;
|
---|
| 91 | if(mlatt==PI_NotDefLineAtt) GetGraphicAtt().SetLineAtt(PI_NormalLine);
|
---|
| 92 |
|
---|
| 93 | g->SelLine(GetGraphicAtt().GetLineAtt() );
|
---|
| 94 |
|
---|
| 95 | // choix du marker
|
---|
| 96 | if(GetGraphicAtt().GetMarker()==PI_NotDefMarker)
|
---|
| 97 | GetGraphicAtt().SetMarkerAtt(5,PI_FCircleMarker);
|
---|
| 98 | g->SelMarker(GetGraphicAtt().GetMarkerSize(),GetGraphicAtt().GetMarker());
|
---|
| 99 |
|
---|
| 100 | // choix de la fleche
|
---|
| 101 |
|
---|
| 102 | if(GetGraphicAtt().GetArrowMarker()==PI_NotDefArrowMarker)
|
---|
| 103 | GetGraphicAtt().SetArrowMarkerAtt(5,PI_BasicArrowMarker);
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | g->SelArrowMarker(GetGraphicAtt().GetArrowMarkerSize(),GetGraphicAtt().GetArrowMarker());
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | for(i=0 ; i<npt ; i++){
|
---|
| 112 | x = _nti->GetCell(i,xK) ;
|
---|
| 113 | y = _nti->GetCell(i,yK) ;
|
---|
| 114 | vx = _nti->GetCell(i,vK) + x;
|
---|
| 115 | vy = _nti->GetCell(i,wK) + y;
|
---|
| 116 | g->DrawMarker(x,y);
|
---|
| 117 |
|
---|
| 118 | //g->DrawLine(x,y,vx,vy);
|
---|
| 119 |
|
---|
| 120 | g->DrawArrowMarker(x,y,vx,vy);
|
---|
| 121 |
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | g->RestoreGraphicAtt();
|
---|
| 125 |
|
---|
| 126 | }
|
---|
| 127 | /* --Methode-- */
|
---|
| 128 | void PI2dVecDrawer::UpdateLimits()
|
---|
| 129 | {
|
---|
| 130 | // Doit calculer les limites
|
---|
| 131 |
|
---|
| 132 | double xmn,xmx,ymn,ymx;
|
---|
| 133 | double vmn,vmx;
|
---|
| 134 |
|
---|
| 135 | _nti->GetMinMax(0,xmn,xmx);
|
---|
| 136 | _nti->GetMinMax(1,ymn,ymx);
|
---|
| 137 |
|
---|
| 138 | SetLimits(xmn, xmx, ymn, ymx);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | /* --Methode-- */
|
---|
| 142 | int PI2dVecDrawer::SelectXY(const char* px, const char* py)
|
---|
| 143 | {
|
---|
| 144 | string name;
|
---|
| 145 | if (_nti == NULL) xK = yK = -1;
|
---|
| 146 | if (px == NULL) xK = -1;
|
---|
| 147 | else { name = px; xK = _nti->ColumnIndex(name); }
|
---|
| 148 | if (py == NULL) yK = -1;
|
---|
| 149 | else { name = py; yK = _nti->ColumnIndex(name); }
|
---|
| 150 |
|
---|
| 151 | int ret = xK;
|
---|
| 152 | if( ret > yK) ret = yK;
|
---|
| 153 | return(ret);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | /* --Methode-- */
|
---|
| 157 | int PI2dVecDrawer::SelectVW(const char* px, const char* py)
|
---|
| 158 | {
|
---|
| 159 | string name;
|
---|
| 160 | if (_nti == NULL) vK = vK = -1;
|
---|
| 161 | if (px == NULL) vK = -1;
|
---|
| 162 | else { name = px; vK = _nti->ColumnIndex(name); }
|
---|
| 163 | if (py == NULL) wK = -1;
|
---|
| 164 | else { name = py; wK = _nti->ColumnIndex(name); }
|
---|
| 165 |
|
---|
| 166 | int ret = vK;
|
---|
| 167 | if( ret > wK) ret = wK;
|
---|
| 168 | return(ret);
|
---|
| 169 | }
|
---|
| 170 |
|
---|