24 #include "ElementiGrafici.h" 31 :QWidget(parent,name){
45 RatioWidthHeight = 1.3;
53 stringa =
new char[256];
66 setPalette( QPalette( QColor( 250, 250, 200) ) );
69 ErrPrima =
new QErrorMessage(
this);
70 Messaggio =
new QMessageBox(
this,
"Messaggio");
71 Stampante =
new QPrinter(QPrinter::PrinterResolution);
72 Stampante->setFullPage(TRUE);
73 Stampante->setOutputToFile(TRUE);
74 Stampante->setOutputFileName(QString(
nomeSalva));
75 Stampante->setOrientation(QPrinter::Landscape);
76 Stampante->setPageSize(QPrinter::A4);
77 Font.setFamily(
"Helvetica");
78 Font.setWeight(QFont::Bold);
80 IfRiscala = RIS_TUTTI;
97 GrLinee =
new QColor[INIT_NUM];
98 GrLabel =
new QString[INIT_NUM];
99 Colors =
new QColor[INIT_NUM];
100 LineaCome =
new int[INIT_NUM];
101 LineaQuale =
new char*[INIT_NUM];
102 for(
int c=0;c<10;c++) LineaQuale[c] =
new char[INIT_NUM];
104 QColor Colors1[INIT_NUM] = {QColor(157,128,43,255),
105 QColor(180,40,43,255),
106 QColor(20,180,70,255),
107 QColor(60,100,180,255),
108 QColor(180,50,180,255),
109 QColor(200,200,50,255),
110 QColor(50,180,180,255),
111 QColor(120,70,120,255),
112 QColor(180,10,240,255),
113 QColor(125,180,113,255),
114 QColor(160,110,110,255),
115 QColor(230,60,220,255),
116 QColor(132,20,220,255),
117 QColor(180,110,170,255),
118 QColor(225,0,143,255)};
120 for(
int c=0;c<10;c++){
121 Colors[c] = Colors1[c];
143 delete [] LineaQuale;
149 NomeEntrata(QString(FileName));
152 NomeConf(QString(FileName));
154 void ElementiGrafici::Apri(){
156 char **argv = (
char **)calloc(NFile,
sizeof(
char));
158 for(
int f=0;f<NFile;f++){
159 argv[f] = (
char *)calloc(120,
sizeof(
char));
162 Apri(argv,&FileList,NFile);
163 for(
int f=0;f<NFile;f++){
168 void ElementiGrafici::Apri(
char **argv,
int *FileList,
int NFile){
173 NomeFile(QString(argv[FileList[0]]));
182 GrLinee = (QColor *)realloc(GrLinee,NVar*
sizeof(QColor));
184 GrLabel =
new QString[NVar];
186 LineaCome = (
int *)realloc(LineaCome,NVar*
sizeof(
int));
189 for(
int c=0,cc=0,init=0;c<NVar;c++,cc++){
190 if(!(c%10)) cc = init++;
191 if(init > 10) init = 0;
192 GrLinee[c] = Colors[cc];
193 LineaCome[c] = LINEA_TRATTO;
200 ImpInter(NVisMax=
NMax);
201 ImpInterEl(NElMax=
NMax);
213 sprintf(stringa,
"Caricati %d vettori da %d Punti da %s",NVar,
NMax,
nomeFile);
219 DIS_ADD_TYPE(IfDisegna,DIS_TUTTI);
221 DIS_ADD_TYPE(IfRiscala,RIS_TUTTI);
224 void ElementiGrafici::ApriExt(
double **ExtSt,
int ExtNMax,
int ExtNVar,
int ExtNBin){
236 GrLinee = (QColor *)realloc(GrLinee,NVar*
sizeof(QColor));
238 GrLabel =
new QString[NVar];
240 LineaCome = (
int *)realloc(LineaCome,NVar*
sizeof(
int));
243 for(
int c=0;c<NVar;c++){
245 GrLinee[c] = Colors[c];
247 GrLinee[c] = Colors[0];
248 LineaCome[c] = LINEA_TRATTO;
253 ImpInter(NVisMax=
NMax);
254 ImpInterEl(NElMax=
NMax);
259 sprintf(stringa,
"Caricati %d vettori da %d Punti da %s",NVar,
NMax,
nomeFile);
265 printf(
"%d %d %d\n",
NMax,NVar,NBin);
268 void ElementiGrafici::ApriExt(
VarDatFile *v1Ext){
280 GrLinee = (QColor *)realloc(GrLinee,NVar*
sizeof(QColor));
282 GrLabel =
new QString[NVar];
284 LineaCome = (
int *)realloc(LineaCome,NVar*
sizeof(
int));
287 for(
int c=0;c<NVar;c++){
289 GrLinee[c] = Colors[c];
291 GrLinee[c] = Colors[0];
292 LineaCome[c] = LINEA_TRATTO;
299 ImpInter(NVisMax=
NMax);
300 ImpInterEl(NElMax=
NMax);
305 if(
NMax > 10000) Griglia = 0;
306 sprintf(stringa,
"Caricati %d vettori da %d Punti da %s",NVar,
NMax,
nomeFile);
311 IfRiscala = RIS_TUTTI;
314 printf(
"%d %d %d\n",
NMax,NVar,NBin);
317 void ElementiGrafici::Aggiungi(){
319 ErrPrima->message(QString(
"Aprire un file .dat prima"));
327 sprintf(stringa,
"Caricato un vettore da %d Punti da %s",
NMax,
nomeFile);
330 GrLinee = (QColor *)realloc(GrLinee,NVar*
sizeof(QColor));
332 GrLabel =
new QString[NVar];
334 LineaCome = (
int *)realloc(LineaCome,NVar*
sizeof(
int));
337 for(
int c=0;c<NVar;c++){
339 GrLinee[c] = Colors[c];
341 GrLinee[c] = Colors[0];
342 LineaCome[c] = LINEA_TRATTO;
350 void ElementiGrafici::mouseMoveEvent(QMouseEvent *Topo){
351 sprintf(cPos,
"%.3g : %.3g",
352 (
double)(Topo->x())/(
double)width()*ScalaTopoX+xMin,
353 (height()-Topo->y())/(
double)height()*ScalaTopoY+yMin);
354 QString Info = QString(cPos);
355 emit StatoSequenza(QString(cPos));
357 void ElementiGrafici::DisegnaTesto(QPainter *p){
358 p->setBrush( Qt::blue );
359 p->setPen( Qt::blue );
360 p->drawText(width()/2,height()/2,QString(
"L'autocorrelazione di un rumore non bianco\n `e lorentziano e decade come \nr^-2"));
361 p->drawImage(QPoint(width()/2,height()/2),QImage(QString(
"Prova.png"),0),QRect(0,0,300,200),0);
362 p->drawRect(QRect(width()/2-100,height()/2-50,200,100));
363 p->drawText(0,height()/2,QString(
"L'autocorrelazione di un rumore non bianco\n `e lorentziano e decade come \nr^-2"));
365 QRect ElementiGrafici::PuntiRett(QPoint P)
const{
366 QRect r(0,0,2*PointSize,2*PointSize);
370 ImpostaNBin::ImpostaNBin(QWidget *parent,
const char *name)
371 :Q3VBox(parent,name){
372 title =
new QLabel(name,
this,
"title");
373 title->setAlignment( Qt::AlignCenter );
374 Qt::Orientation Orientazione = Qt::Horizontal;
376 slider =
new QSlider(Orientazione,
this ,
"slider");
377 slider->setRange(0,100);
380 slider->setTickPosition(QSlider::TicksBelow);
384 label =
new QLabel(
" ",
this,
"label");
385 label->setAlignment( Qt::AlignCenter );
386 connect(slider,SIGNAL(valueChanged(
int)),label,SLOT(setNum(
int)) );
387 connect(slider,SIGNAL(valueChanged(
int)),SIGNAL(ValoreCambiato(
int)) );
389 void ImpostaNBin::ImpNumero(
int n){
394 void ImpostaNBin::ImpInter(
int Max){
396 slider->setRange(0,Max);
399 void ImpostaNBin::ImpInter(
int Min,
int Max){
401 slider->setRange(Min,Max);
404 int ImpostaNBin::Numero()
const{
405 return slider->value();
char * nomeFile
Name of the current file opened.
ElementiGrafici(QWidget *parent=0, const char *name=0)
General constructor.
int pNMax()
Print the maximum number of data in the array.
char * nomeConf
Name of the config file.
int NMax
Number of points per array.
char * nomeSalva
Name of the output file.
void ChooseConfFile(char *FileName)
Choose the configuration file.
QString nomeTit
Title name.
char * PrintHeader()
Print the header.
void ImpNElMin(int n)
Set the minimum elaboration point.
void ImpNVisMax(int n)
Set the maximum visualisation point.
QString nomeEtY
Y axis label.
int NDis
Current number of visualisation (debugging)
QString nomeEtX
X axis label.
void ChooseDataFile(char *FileName)
Choose the input file.
void ImpNVisMin(int n)
Set the minimum visualisation point.
int pNVar()
Print the number of variables.
int NBin
Number of point of the distribution.
Reads and stores a data file to be elaborated via Matematica.
void ImpNElMax(int n)
Set the maximum elaboration point.
~ElementiGrafici()
Destructor.
int Aggiungi(char *file)
Add the content of the file into the memory.
void ImpNVarX(int n, int m)
Type for coordinate change.
VarDatFile * v1
Class for the file handle.