Main Page   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

DContrast.cpp

00001 //---------------------------------------------------------------------------
00002 
00003 #include <vcl.h>
00004 #pragma hdrstop
00005 
00006 #include "DContrast.h"
00007 #include "MDIEdit.h"
00008 #include "MDISlice.h"
00009 //---------------------------------------------------------------------------
00010 #pragma package(smart_init)
00011 #pragma resource "*.dfm"
00012 TContrastForm *ContrastForm;
00013 //---------------------------------------------------------------------------
00014 __fastcall TContrastForm::TContrastForm(TComponent* Owner,
00015                                         THistogram *h,
00016                                         TContrast *c)
00017         : TForm(Owner),
00018           _histo(h),
00019           _contrast(c),
00020           _created(false),
00021           _lower(0),
00022           _upper(1),
00023           _selLower(false),
00024           _selUpper(false)
00025 {
00026 }
00027 //---------------------------------------------------------------------------
00028 void __fastcall TContrastForm::HistoAreaPaint(TObject *Sender)
00029 {
00030         _draw();
00031 }
00032 //---------------------------------------------------------------------------
00033 void __fastcall TContrastForm::BCloseClick(TObject *Sender)
00034 {
00035         Close();
00036 }
00037 //---------------------------------------------------------------------------
00038 void __fastcall TContrastForm::FormCreate(TObject *Sender)
00039 {
00040         if (histo->horizontal) {
00041                 TBHorizontal->Min = 1;
00042                 TBHorizontal->Max = (int)(histo->getHMaxZoom(HistoArea)*100.0);
00043                 TBHorizontal->Position = (int)(histo->histoZoom*100.0);
00044                 TBVertical->Min = 1;
00045                 TBVertical->Max = 1000;
00046                 TBVertical->Position = (int)(histo->valZoom*100.0);
00047         } else {
00048                 TBVertical->Min = 1;
00049                 TBVertical->Max = (int)(histo->getHMaxZoom(HistoArea)*100.0);
00050                 TBVertical->Position = (int)(histo->histoZoom*100.0);
00051                 TBHorizontal->Min = 1;
00052                 TBHorizontal->Max = 1000;
00053                 TBHorizontal->Position = (int)(histo->valZoom*100.0);
00054         }
00055         _lower = (int)(contr->Lower*(float)histo->size/histo->getHPP(HistoArea));
00056         _upper = (int)(contr->Upper*(float)histo->size/histo->getHPP(HistoArea));
00057         _created = true;
00058 }
00059 //---------------------------------------------------------------------------
00060 void __fastcall TContrastForm::TBHorizontalChange(TObject *Sender)
00061 {
00062         if (!_created) return;
00063         if (histo->horizontal)
00064                 histo->histoZoom = (float)TBHorizontal->Position / 100.0;
00065         else
00066                 histo->valZoom = (float)TBHorizontal->Position / 100.0;
00067         _draw();
00068 }
00069 //---------------------------------------------------------------------------
00070 
00071 void __fastcall TContrastForm::TBVerticalChange(TObject *Sender)
00072 {
00073         if (!_created) return;
00074         if (histo->horizontal)
00075                 histo->valZoom = (float)TBVertical->Position / 100.0;
00076         else
00077                 histo->histoZoom = (float)TBVertical->Position / 100.0;
00078         _draw();
00079 }
00080 //---------------------------------------------------------------------------
00081 void __fastcall TContrastForm::_draw()
00082 {
00083         histo->drawTo(HistoArea);
00084         //histo->drawTo(SliceForm->HistoArea);
00085         LValZoom->Caption = AnsiString::FormatFloat("##.000", histo->valZoom);
00086         LHistoZoom->Caption = AnsiString::FormatFloat("##.000", histo->histoZoom);
00087         _contrast->Lower = _lower*_histo->getHPP(HistoArea)/_histo->size;
00088         _contrast->Upper = _upper*_histo->getHPP(HistoArea)/_histo->size;
00089 
00090         HistoArea->Canvas->Pen->Color = clBlack;
00091         if (histo->horizontal) {
00092                 HistoArea->Canvas->MoveTo(_lower, 0);
00093                 HistoArea->Canvas->LineTo(_lower, HistoArea->Height);
00094                 HistoArea->Canvas->MoveTo(_upper, 0);
00095                 HistoArea->Canvas->LineTo(_upper, HistoArea->Height);
00096         } else {
00097                 HistoArea->Canvas->MoveTo(0, _lower);
00098                 HistoArea->Canvas->LineTo(HistoArea->Width, _lower);
00099                 HistoArea->Canvas->MoveTo(0, _upper);
00100                 HistoArea->Canvas->LineTo(HistoArea->Width, _upper);
00101         }
00102         SliceForm->HistoAreaPaint(this);
00103         SliceForm->TrackBarChange(this);
00104 }
00105 //---------------------------------------------------------------------------
00106 void __fastcall TContrastForm::HistoAreaMouseDown(TObject *Sender,
00107       TMouseButton Button, TShiftState Shift, int X, int Y)
00108 {
00109         if (histo->horizontal) {
00110                 _selLower = abs(X-_lower)<=5;
00111                 _selUpper = abs(X-_upper)<=5;
00112         } else {
00113                 _selLower = abs(Y-_lower)<=5;
00114                 _selUpper = abs(Y-_upper)<=5;
00115         }
00116 }
00117 //---------------------------------------------------------------------------
00118 void __fastcall TContrastForm::HistoAreaMouseMove(TObject *Sender,
00119       TShiftState Shift, int X, int Y)
00120 {
00121         int pos;
00122         if (histo->horizontal)  pos=X;
00123         else                    pos=Y;
00124         if (_selLower) {
00125                 _lower = pos;
00126                 _draw();
00127         } else if (_selUpper) {
00128                 _upper = pos;
00129                 _draw();
00130         }
00131 }
00132 //---------------------------------------------------------------------------
00133 void __fastcall TContrastForm::HistoAreaMouseUp(TObject *Sender,
00134       TMouseButton Button, TShiftState Shift, int X, int Y)
00135 {
00136         _selUpper = _selLower = false;
00137 }
00138 //---------------------------------------------------------------------------
00139 

Generated on Thu Jan 23 06:17:37 2003 for Vol by doxygen1.2.18