First commit 26/10/1998
This commit is contained in:
138
TPropiedades.cpp
Normal file
138
TPropiedades.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <registry.hpp>
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "TPropiedades.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma link "DialUp"
|
||||
#pragma link "DigitNum"
|
||||
#pragma resource "*.dfm"
|
||||
TPropiedades *Propiedades;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TPropiedades::TPropiedades(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
PosHistorica = 0;
|
||||
Temp = 0;
|
||||
Tmin = 1000; Tmax = 0;
|
||||
|
||||
try {
|
||||
mHistorial -> Lines -> LoadFromFile("Historial.log");
|
||||
}catch(...){
|
||||
// do nothing
|
||||
}
|
||||
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Inicio de sesi<73>n ");
|
||||
|
||||
HCalorValues = new int [ HCalor->Width + 2 ];
|
||||
for ( int i=0; i<HCalor->Width; i++ ) HCalorValues[i] = 0;
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TPropiedades::BorrarHistorialClick(TObject *Sender)
|
||||
{
|
||||
mHistorial -> Lines -> Clear();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TPropiedades::FormDestroy(TObject *Sender)
|
||||
{
|
||||
mHistorial -> Lines -> Add( TDateTime::CurrentDateTime().DateTimeString() + " Fin de sesi<73>n ");
|
||||
delete [] HCalorValues;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TPropiedades::mHistorialChange(TObject *Sender)
|
||||
{
|
||||
try {
|
||||
if ( Historial -> Checked )
|
||||
mHistorial -> Lines -> SaveToFile("Historial.log");
|
||||
} catch(...) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
void __fastcall TPropiedades::FormKeyPress(TObject *Sender, char &Key)
|
||||
{
|
||||
switch( Key )
|
||||
{
|
||||
case 'a':
|
||||
Temp++;
|
||||
break;
|
||||
case 's':
|
||||
Temp--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TPropiedades::ProcesarCuanto(TObject *Sender)
|
||||
{
|
||||
int shTemp;
|
||||
|
||||
shTemp = Temp >= HCalor->Height ? HCalor->Height : Temp;
|
||||
shTemp = shTemp <= 0 ? 0 : shTemp;
|
||||
shTemp *= 2;
|
||||
|
||||
// Borrado de la linea a imprimir
|
||||
HCalor -> Canvas -> MoveTo ( PosHistorica, 0 );
|
||||
HCalor -> Canvas -> LineTo ( PosHistorica, HCalor->Height);
|
||||
|
||||
PosHistorica++;
|
||||
if ( PosHistorica > HCalor->Width ) PosHistorica = 0;
|
||||
|
||||
// Linea de calor
|
||||
HCalorValues[PosHistorica] = shTemp;
|
||||
PintaLinea( PosHistorica, shTemp );
|
||||
|
||||
// Linea indicaci<63>n de estado
|
||||
HCalor -> Canvas -> Pen -> Mode = pmXor;
|
||||
HCalor -> Canvas -> Pen -> Color = clGreen;
|
||||
HCalor -> Canvas -> MoveTo ( PosHistorica, 0 );
|
||||
HCalor -> Canvas -> LineTo ( PosHistorica, HCalor->Height );
|
||||
|
||||
|
||||
// Calculo de minimos y maximos
|
||||
Tmin = Temp < Tmin ? Temp : Tmin;
|
||||
Tmax = Temp > Tmax ? Temp : Tmax;
|
||||
StatusBar1->Panels->Items[0]->Text = Format( "Min. %02d --- Max. %02d", ARRAYOFCONST(((int)Tmin, (int)Tmax)));
|
||||
DigitNum1 -> Value = Temp;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TPropiedades::HCalorPaint(TObject *Sender)
|
||||
{
|
||||
int i;
|
||||
// Redibujamos el contenido del histograma...
|
||||
for ( i=0; i<HCalor->Width; i++ )
|
||||
PintaLinea( i, HCalorValues[i] );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TPropiedades::PintaLinea(int x, int y)
|
||||
{
|
||||
int i, maxi;
|
||||
HCalor -> Canvas -> Pen -> Mode = pmCopy;
|
||||
/*
|
||||
maxi = max( (HCalor->Height-(HCalor->Height/3)), (HCalor->Height-y) );
|
||||
for ( i=HCalor->Height; i>maxi && i != 0; i-- )
|
||||
{
|
||||
HCalor -> Canvas -> Pixels[x][i] = (Graphics::TColor)( ( ( i * 0xFF ) / HCalor->Height )<<16);
|
||||
}
|
||||
*/
|
||||
for ( i=HCalor->Height; i>(HCalor->Height-y) && i != 0; i-- )
|
||||
{
|
||||
HCalor -> Canvas -> Pixels[x][i] = (Graphics::TColor)(0xFF - (( i * 0xFF ) / HCalor->Height ));
|
||||
}
|
||||
|
||||
/*
|
||||
HCalor -> Canvas -> Pen -> Color = clRed;
|
||||
HCalor -> Canvas -> MoveTo ( x, HCalor->Height );
|
||||
HCalor -> Canvas -> LineTo ( x, HCalor->Height - y );
|
||||
*/
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user