Allink  v0.1
ElementiGraficiEl.cpp
00001 /***********************************************************************
00002 ElementiGrafici: Class that interface the VarData, VarElementiGrafici 
00003 and Matematica classes function for comunicating with main window of 
00004 Visualizza. The main function is the plotting function DisegnaPunti() 
00005 that provides the visualisation of two set of data. The bars at the 
00006 bottom permits to change the visualisation and the limit for the analisys
00007  Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it>
00008 
00009 
00010 This program is free software; you can redistribute it and/or modify
00011 it under the terms of the GNU General Public License as published by
00012 the Free Software Foundation; either version 2 of the License, or
00013 (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 ***********************************************************************/
00024 #include "ElementiGrafici.h"
00025 #include <qpainter.h>
00026 #include <Q3PaintDeviceMetrics>
00027 ;
00028 void ElementiGrafici::PuntiSegnale(){
00029   PuntiMax = NMax;
00030   v1->ImpCoordY(CoordY);
00031   //v1->ImpCoordX(CoordX,CoordY);
00032   sprintf(stringa,"Mostro i %d Punti Coord %d %d/%d",PuntiMax,CoordX,CoordY,NVar);
00033   IfDisegna = DIS_SEGNALE;
00034   InfoStato(stringa);
00035   ImpInter(PuntiMax);
00036   ImpInter(0,PuntiMax);
00037   ImpNVisMin(0); ImpNVisMax(PuntiMax);
00038   ImpNElMin(0); ImpNElMax(PuntiMax);
00039   Ridisegna();
00040 }
00041 void ElementiGrafici::PuntiSommaSegnali(){
00042   if(PrimaVolta){
00043     ErrPrima->message(QString("Aprire un file prima"));
00044     return;
00045   }
00046   v1->SommaSegnali();
00047   sprintf(stringa,"Somma di tutti i segnali\n");
00048   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00049   IfDisegna = DIS_PUNTI;
00050   ImpNMobile(1);
00051   InfoStato(stringa);
00052   repaint();
00053 }
00054 void ElementiGrafici::PuntiDistribuzione(){
00055   if(PrimaVolta){
00056     ErrPrima->message(QString("Aprire un file prima"));
00057     return;
00058   }
00059   m1 = v1->DistrGaussSegnale(NElMin,NElMax,IfNorm);
00060   sprintf(stringa,"Distribuzione per %d NBin di %d Punti",NBin,NElMax-NElMin);
00061   DIS_ADD_TYPE(IfDisegna,DIS_MOMENTI);
00062   ImpNVisMin(0);
00063   ImpNVisMax(NBin);
00064   ImpInter(NBin);
00065   InfoStato(stringa);
00066   repaint();
00067 }
00068 void ElementiGrafici::PuntiSpettro(){
00069   if(PrimaVolta){
00070     ErrPrima->message(QString("Aprire un file prima"));
00071     return;
00072   }
00073   //  QMessageBox::information(this,"Visualizza","Sto calcolando\n","Attendere");
00074   PuntiMax = v1->SpettroSegnale(NElMin,NElMax);
00075   sprintf(stringa,"Spettro da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00076   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00077   IfDisegna = DIS_PUNTI;
00078   ImpNMobile(1);
00079   InfoStato(stringa);
00080   repaint();
00081 }
00082 void ElementiGrafici::PuntiNormalizza(){
00083   if(PrimaVolta){
00084     ErrPrima->message(QString("Aprire un file prima"));
00085     return;
00086   }
00087   int Campioni=0;
00088   //  QMessageBox::information(this,"Visualizza","Sto calcolando\n","Attendere");
00089   Campioni = v1->NormalizzaSegnale(NElMin,NElMax);
00090   sprintf(stringa,"Normalizzazione del segnale da %d campioni",Campioni);
00091   IfDisegna = DIS_PUNTI;
00092   ImpNMobile(1);
00093   InfoStato(stringa);
00094   repaint();
00095 }
00096 void ElementiGrafici::PuntiModulo(){
00097   if(PrimaVolta){
00098     ErrPrima->message(QString("Aprire un file prima"));
00099     return;
00100   }
00101   int Campioni=0;
00102   //  QMessageBox::information(this,"Visualizza","Sto calcolando\n","Attendere");
00103   v1->ModuloSegnale();
00104   Campioni = v1->ElabSegnale(NElMin,NElMax);
00105   sprintf(stringa,"Modulo del segnale da %d campioni",Campioni);
00106   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00107   IfDisegna = DIS_PUNTI;
00108   ImpNMobile(1);
00109   InfoStato(stringa);
00110   repaint();
00111 }
00112 void ElementiGrafici::PuntiRadice(){
00113   if(PrimaVolta){
00114     ErrPrima->message(QString("Aprire un file prima"));
00115     return;
00116   }
00117   //  QMessageBox::information(this,"Visualizza","Sto calcolando\n","Attendere");
00118   v1->RadiceSegnale();
00119   PuntiMax = NMax;
00120   sprintf(stringa,"Radice di %d NBin",PuntiMax);
00121   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00122   IfDisegna = DIS_PUNTI;
00123   ImpNMobile(1);
00124   InfoStato(stringa);
00125   repaint();
00126 }
00127 void ElementiGrafici::PuntiAutocor(){
00128   if(PrimaVolta){
00129     ErrPrima->message(QString("Aprire un file prima"));
00130     return;
00131   }
00132   PuntiMax = v1->AutocorSegnale(NElMin,NElMax);
00133   sprintf(stringa,"Autocorrelazione da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00134   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00135   IfDisegna = DIS_PUNTI;
00136   ImpNMobile(1);
00137   InfoStato(stringa);
00138   repaint();
00139 }
00140 void ElementiGrafici::PuntiSum(){
00141   if(PrimaVolta){
00142     ErrPrima->message(QString("Aprire un file prima"));
00143     return;
00144   }
00145   double Resp = v1->SumSegnale(CoordY,NElMin,NElMax);
00146   sprintf(stringa,"Somma %lf da %d a %d di %d Punti",Resp,NElMin,NElMax,NElMax-NElMin);
00147   //  IfDisegna = DIS_SEGNALE;
00148   ImpNMobile(1);
00149   InfoStato(stringa);
00150   repaint();
00151 }
00152 void ElementiGrafici::PuntiInterRett(){
00153   if(PrimaVolta){
00154     ErrPrima->message(QString("Aprire un file prima"));
00155     return;
00156   }
00157   r1 = v1->InterRettSegnale(CoordY,NElMin,NElMax,LogLog);
00158   PuntiMax = NMax;
00159   sprintf(stringa,"Interpolazione lineare da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00160   DIS_ADD_TYPE(IfDisegna,DIS_RETTA);
00161   DIS_REM_TYPE(IfDisegna,DIS_GAUSS);
00162   DIS_REM_TYPE(IfDisegna,DIS_PARABOLA);
00163   DIS_REM_TYPE(IfDisegna,DIS_EXP);
00164   DIS_ADD_TYPE(IfDisegna,DIS_BLU);
00165   InfoStato(stringa);
00166   repaint();
00167 }  
00168 void ElementiGrafici::PuntiInterExp(){
00169   if(PrimaVolta){
00170     ErrPrima->message(QString("Aprire un file prima"));
00171     return;
00172   }
00173   r1 =  v1->InterExpSegnale(CoordY,NElMin,NElMax,LogLog);
00174   PuntiMax = NMax;
00175   sprintf(stringa,"Interpolazione lineare da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00176   DIS_REM_TYPE(IfDisegna,DIS_RETTA);
00177   DIS_REM_TYPE(IfDisegna,DIS_GAUSS);
00178   DIS_REM_TYPE(IfDisegna,DIS_PARABOLA);
00179   DIS_ADD_TYPE(IfDisegna,DIS_EXP);
00180   DIS_ADD_TYPE(IfDisegna,DIS_BLU);
00181   InfoStato(stringa);
00182   repaint();
00183 }  
00184 void ElementiGrafici::PuntiParabola(){
00185   if(PrimaVolta){
00186     ErrPrima->message(QString("Aprire un file prima"));
00187     return;
00188   }
00189   p1 = v1->ParabolaSegnale(CoordY,NElMin,NElMax,LogLog);
00190   printf("%.2g + %.2g x + %.2g x^2",p1.a0,p1.a1,p1.a2);
00191   PuntiMax = NMax;
00192   sprintf(stringa,"Interpolazione parabolica da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00193   DIS_REM_TYPE(IfDisegna,DIS_RETTA);
00194   DIS_REM_TYPE(IfDisegna,DIS_GAUSS);
00195   DIS_ADD_TYPE(IfDisegna,DIS_PARABOLA);
00196   DIS_REM_TYPE(IfDisegna,DIS_EXP);
00197   DIS_ADD_TYPE(IfDisegna,DIS_BLU);
00198   InfoStato(stringa);
00199   repaint();
00200 }
00201 void ElementiGrafici::PuntiInterGauss(){
00202   if(PrimaVolta){
00203     ErrPrima->message(QString("Aprire un file prima"));
00204     return;
00205   }
00206   m1 = v1->InterGaussSegnale(CoordY,NElMin,NElMax,LogLog);
00207   PuntiMax = NMax;
00208   sprintf(stringa,"Interpolazione gaussiana da %d a %d di %d Punti",NElMin,NElMax,NElMax-NElMin);
00209   DIS_REM_TYPE(IfDisegna,DIS_RETTA);
00210   DIS_ADD_TYPE(IfDisegna,DIS_GAUSS);
00211   DIS_REM_TYPE(IfDisegna,DIS_PARABOLA);
00212   DIS_REM_TYPE(IfDisegna,DIS_EXP);
00213   DIS_ADD_TYPE(IfDisegna,DIS_BLU);
00214   InfoStato(stringa);
00215   repaint();
00216 }
00217 void ElementiGrafici::PuntiMediaMob(){
00218   if(PrimaVolta){
00219     ErrPrima->message(QString("Aprire un file prima"));
00220     return;
00221   }
00222   PuntiMax = NVisMax = v1->MediaMobSegnale(NMobile);
00223   sprintf(stringa,"MediaMobile di %d Punti divisi in %d Parti",PuntiMax,NMobile);
00224   InfoStato(stringa);
00225   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00226   IfDisegna = DIS_PUNTI;
00227   ImpNVisMin(0);
00228   ImpInter(NVisMax);
00229   ImpNVisMax(NVisMax);
00230   repaint();
00231 }
00232 void ElementiGrafici::PuntiCorrelaADue(){
00233   if(PrimaVolta){
00234     ErrPrima->message(QString("Aprire un file prima"));
00235     return;
00236   }
00237   PuntiMax = v1->CorrelaADuePunti(NCorrela);
00238   ImpNCorrela(NCorrela);
00239   sprintf(stringa,"MediaMobile di %d Punti divisi in %d Parti",PuntiMax,NCorrela);
00240   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00241   IfDisegna = DIS_PUNTI;
00242   ImpNMobile(1);
00243   InfoStato(stringa);
00244   repaint();
00245 }
00246 void ElementiGrafici::PuntiAutosimilarita(){
00247   if(PrimaVolta){
00248     ErrPrima->message(QString("Aprire un file prima"));
00249     return;
00250   }
00251   PuntiMax = 10;
00252   v1->AutosimilaritaSegnale(PuntiMax);
00253   sprintf(stringa,"Autosimilarita di %d Punti su %d Potenze",NMax,PuntiMax);
00254   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00255   IfDisegna = DIS_PUNTI;
00256   ImpNMobile(1);
00257   InfoStato(stringa);
00258   repaint();
00259 }
00260 void ElementiGrafici::PuntiIntegrale(){
00261   if(PrimaVolta){
00262     ErrPrima->message(QString("Aprire un file prima"));
00263     return;
00264   }
00265   //void (Matematica::*Qui)(double *,double *,int) = &Matematica::Integrazione;
00266   //v1->Elab = &Matematica::Integrazione;
00267   //v1->ElabSegnale(NElMin,NElMax);
00268   double Int = v1->IntSegnale();
00269   PuntiMax = NMax;
00270   sprintf(stringa,"Integrale su %d Punti= %lf",PuntiMax,Int);
00271   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00272   IfDisegna = DIS_PUNTI;
00273   ImpNMobile(1);
00274   InfoStato(stringa);
00275   repaint();
00276 }
00277 void ElementiGrafici::PuntiDerivata(){
00278   if(PrimaVolta){
00279     ErrPrima->message(QString("Aprire un file prima"));
00280     return;
00281   }
00282   v1->DerivataSegnale();
00283   v1->ElabSegnale(NElMin,NElMax);
00284   PuntiMax = NElMax - NElMin - 2;
00285   sprintf(stringa,"Derivata su %d Punti",PuntiMax);
00286   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00287   IfDisegna = DIS_PUNTI;
00288   ImpNMobile(1);
00289   InfoStato(stringa);
00290   repaint();
00291 }
00292 void ElementiGrafici::PuntiVarie(){
00293   if(PrimaVolta){
00294     ErrPrima->message(QString("Aprire un file prima"));
00295     return;
00296   }
00297   //v1->VarieSegnale();
00298   //v1->ElabSegnale(NElMin,NElMax);
00299   double Integr = v1->VarieSegnale(NElMin,NElMax)*32./200.;
00300   PuntiMax = NElMax - NElMin -2;
00301   NVisMax = PuntiMax;
00302   NVisMin = 0;
00303   double Volume = NMax/(32.*32.*32.);
00304   for(int n=0;n<PuntiMax;n++){
00305     //Punti[n] *= Volume;
00306   }
00307   sprintf(stringa,"Surface tension %lf",Integr);
00308   DIS_ADD_TYPE(IfDisegna,DIS_PUNTI);
00309   IfDisegna = DIS_PUNTI;
00310   ImpNMobile(1);
00311   InfoStato(stringa);
00312   repaint();
00313 }
00314 void ElementiGrafici::StampaFile(){
00315   QPainter paint;
00316   InfoStato("Stampando...");
00317   Stampante->setOutputFileName(QString(nomeSalva));
00318   if(Stampante->setup(this))
00319     if(!paint.begin(Stampante) )
00320       return;
00321   IfStampa = 1;
00322   DisegnaPunti(&paint);
00323   InfoStato("Stampato");
00324   IfStampa = 0;
00325 }
00326 void ElementiGrafici::PuntaExt(double **ExtSt,int NVar){
00327   v1->Punta(ExtSt,NVar);
00328 }