source: trigger/gui/t72/tempsens.cpp@ 1022

Last change on this file since 1022 was 78, checked in by daqct3, 15 years ago
remove exe from repos
File size: 1.3 KB
Line 
1#include <QColor>
2
3#include <QVBoxLayout>
4#include <QPainter>
5 #include "tempsens.h"
6
7
8Tempsens::Tempsens( QWidget *parent ) : QWidget( parent)
9{
10 //setPalette( QPalette( QColor( 250, 250, 200) ) );
11 //this->setPalette( QPalette( QColor( 250, 250, 200) ) );
12 bgColor= new QColor(200,200,200);
13 this->setAutoFillBackground (1);
14}
15float Tempsens::value()
16{
17 return val;
18
19}
20void Tempsens::paintEvent( QPaintEvent * )
21{
22
23 QString s = QString( "%1c" ).arg((double)(val),0,'g',3);
24 QFont sansFont( "Helvetica [Cronyx]", 12 );
25
26 QPainter p( this );
27 p.setFont(sansFont);
28 p.setPen(Qt::white);
29 int width=this->width();
30 int height=this->height();
31 p.drawText(width/4 , height/2, s );
32}
33
34void Tempsens::setValue( float vall )
35{
36 val=vall;
37 int rred= (int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
38
39 int bblue=255-(int)(((float)(val-MinVal)/(float)(MaxVal-MinVal))*255.);
40 //printf("%d \n",val);
41 bgColor->setRgb(rred,0,bblue);
42 //QPalette::ColorRole
43 QPalette *mypalette=new QPalette();
44 // mypalette->setColor ( mypalette->Base, *bgColor );
45 mypalette->setColor ( mypalette->Base, Qt::red);
46 //this->setBackgroundRole (mypalette->Shadow);
47 //this->setBackgroundColor(*bgColor);
48 repaint();
49 this->setPalette( QPalette( *bgColor ) );
50 emit valueChanged(val);
51
52}
Note: See TracBrowser for help on using the repository browser.