Options.cpp
上传用户:szb0815
上传日期:2007-06-13
资源大小:338k
文件大小:9k
- /*
- Software and source code Copyright (C) 1998-2000 Stanford University
- Written by Michael Eisen (eisen@genome.stanford.edu)
- This software is copyright under the following conditions:
- Permission to use, copy, and modify this software and its documentation
- is hereby granted to all academic and not-for-profit institutions
- without fee, provided that the above copyright notice and this permission
- notice appear in all copies of the software and related documentation.
- Permission to distribute the software or modified or extended versions
- thereof on a not-for-profit basis is explicitly granted, under the above
- conditions. However, the right to use this software in conjunction with
- for profit activities, and the right to distribute the software or modified or
- extended versions thereof for profit are *NOT* granted except by prior
- arrangement and written consent of the copyright holders.
- Use of this source code constitutes an agreement not to criticize, in any
- way, the code-writing style of the author, including any statements regarding
- the extent of documentation and comments present.
- The software is provided "AS-IS" and without warranty of ank kind, express,
- implied or otherwise, including without limitation, any warranty of
- merchantability or fitness for a particular purpose.
- In no event shall Stanford University or the authors be liable for any special,
- incudental, indirect or consequential damages of any kind, or any damages
- whatsoever resulting from loss of use, data or profits, whether or not
- advised of the possibility of damage, and on any theory of liability,
- arising out of or in connection with the use or performance of this software.
- This code was written using Borland C++ Builder 4 (Inprise Inc., www.inprise.com)
- and may be subject to certain additional restrictions as a result.
- */
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Options.h"
- #include "TreeViewMain.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TOptionsForm *OptionsForm;
- //---------------------------------------------------------------------------
- __fastcall TOptionsForm::TOptionsForm(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::FormShow(TObject *Sender)
- {
- ThumbXPixelEdit->Text = TreeViewMainForm->ImageScaleX;
- ThumbYPixelEdit->Text = TreeViewMainForm->ImageScaleY;
- ZoomXPixelEdit->Text = TreeViewMainForm->ZoomImageScaleX;
- ZoomYPixelEdit->Text = TreeViewMainForm->ZoomImageScaleY;
- ImageContrastEdit->Text = TreeViewMainForm->ImageContrast;
- MaskValEdit->Text = TreeViewMainForm->MaskVal;
- CorrSelectCutoffEdit->Text = TreeViewMainForm->CorrSelectCutoff;
- NegativeShape->Brush->Color = TreeViewMainForm->NegativeColor;
- PositiveShape->Brush->Color = TreeViewMainForm->PositiveColor;
- ZeroShape->Brush->Color = TreeViewMainForm->ZeroColor;
- MissingShape->Brush->Color = TreeViewMainForm->MissingColor;
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::Button2Click(TObject *Sender)
- {
- try
- {
- TreeViewMainForm->ImageScaleX = ThumbXPixelEdit->Text.ToDouble();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->ImageScaleY = ThumbYPixelEdit->Text.ToDouble();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->ZoomImageScaleX = ZoomXPixelEdit->Text.ToInt();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->ZoomImageScaleY = ZoomYPixelEdit->Text.ToInt();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->CorrSelectCutoff = CorrSelectCutoffEdit->Text.ToDouble();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->ImageContrast = ImageContrastEdit->Text.ToDouble();
- }
- catch (EConvertError &E)
- {
- }
- try
- {
- TreeViewMainForm->MaskVal = MaskValEdit->Text.ToDouble();
- }
- catch (EConvertError &E)
- {
- }
- TreeViewMainForm->NegativeColor = NegativeShape->Brush->Color;
- TreeViewMainForm->PositiveColor = PositiveShape->Brush->Color;
- TreeViewMainForm->ZeroColor = ZeroShape->Brush->Color;
- TreeViewMainForm->MissingColor = MissingShape->Brush->Color;
- TreeViewMainForm->Reset();
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::NegativeShapeMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- NegativeColorDialog->Color = NegativeShape->Brush->Color;
- NegativeColorDialog->Execute();
- NegativeShape->Brush->Color = NegativeColorDialog->Color;
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::ZeroShapeMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- ZeroColorDialog->Color = ZeroShape->Brush->Color;
- ZeroColorDialog->Execute();
- ZeroShape->Brush->Color = ZeroColorDialog->Color;
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::PositiveShapeMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- PositiveColorDialog->Color = PositiveShape->Brush->Color;
- PositiveColorDialog->Execute();
- PositiveShape->Brush->Color = PositiveColorDialog->Color;
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::MissingShapeMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- MissingColorDialog->Color = MissingShape->Brush->Color;
- MissingColorDialog->Execute();
- MissingShape->Brush->Color = MissingColorDialog->Color;
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::Button3Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::Button4Click(TObject *Sender)
- {
- if (SaveColorDialog1->Execute())
- {
- TFileStream *ColorFile =
- new TFileStream(SaveColorDialog1->FileName, fmCreate);
- ColorFile->Position = 0;
- TreeViewMainForm->NegativeColor = NegativeShape->Brush->Color;
- TreeViewMainForm->PositiveColor = PositiveShape->Brush->Color;
- TreeViewMainForm->ZeroColor = ZeroShape->Brush->Color;
- TreeViewMainForm->MissingColor = MissingShape->Brush->Color;
- ColorFile->Write(&TreeViewMainForm->PositiveColor,
- sizeof(TreeViewMainForm->PositiveColor));
- ColorFile->Write(&TreeViewMainForm->ZeroColor,
- sizeof(TreeViewMainForm->ZeroColor));
- ColorFile->Write(&TreeViewMainForm->NegativeColor,
- sizeof(TreeViewMainForm->NegativeColor));
- ColorFile->Write(&TreeViewMainForm->MissingColor,
- sizeof(MissingShape->Brush->Color));
- delete ColorFile;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TOptionsForm::Button5Click(TObject *Sender)
- {
- if (OpenColorDialog1->Execute())
- {
- TFileStream *ColorFile =
- new TFileStream(OpenColorDialog1->FileName, fmOpenRead);
- ColorFile->Position = 0;
- ColorFile->Read(&TreeViewMainForm->PositiveColor,
- sizeof(TreeViewMainForm->PositiveColor));
- ColorFile->Read(&TreeViewMainForm->ZeroColor,
- sizeof(TreeViewMainForm->ZeroColor));
- ColorFile->Read(&TreeViewMainForm->NegativeColor,
- sizeof(TreeViewMainForm->NegativeColor));
- ColorFile->Read(&TreeViewMainForm->MissingColor,
- sizeof(MissingShape->Brush->Color));
- delete ColorFile;
- NegativeShape->Brush->Color = TreeViewMainForm->NegativeColor;
- PositiveShape->Brush->Color = TreeViewMainForm->PositiveColor;
- ZeroShape->Brush->Color = TreeViewMainForm->ZeroColor;
- MissingShape->Brush->Color = TreeViewMainForm->MissingColor;
- }
- }
- //---------------------------------------------------------------------------