//---------------------------------------------------------------------------

#ifndef Capture_FormH
#define Capture_FormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "Capture_Frame.h"
#include <ExtCtrls.hpp>
#include <Buttons.hpp>

#include "Common.h"
#include "TntButtons.hpp"
#include "TntExtCtrls.hpp"
#include "TntStdCtrls.hpp"
#include "TntForms.hpp"
#include <Graphics.hpp>
#include <ComCtrls.hpp>
#include "Calibration_Form.h"

//---------------------------------------------------------------------------
class TCaptureForm : public TTntForm
{
__published:	// IDE-managed Components
	TTntImage *CaptureImage;
	TTntPanel *ImagePanel;
	TTntPanel *Panel1;
	TTntGroupBox *GroupBox1;
  TTntLabel *ShutterSpeedCLabel1;
	TTntEdit *ShutterSpeedEdit1;
  TTntLabel *ShutterSpeedCLabel2;
	TTntEdit *ShutterSpeedEdit2;
  TTntLabel *ShutterSpeedCLabel3;
	TTntEdit *ShutterSpeedEdit3;
  TTntLabel *ShutterSpeedCLabel4;
	TTntEdit *ShutterSpeedEdit4;
  TTntLabel *ShutterSpeedCLabel5;
	TTntEdit *ShutterSpeedEdit5;
  TTntLabel *ShutterSpeedCLabel6;
	TTntEdit *ShutterSpeedEdit6;
  TTntLabel *ShutterSpeedCLabel7;
	TTntEdit *ShutterSpeedEdit7;
  TTntLabel *ShutterSpeedCLabel8;
	TTntEdit *ShutterSpeedEdit8;
  TTntLabel *ShutterSpeedCLabel9;
	TTntEdit *ShutterSpeedEdit9;
  TTntLabel *ShutterSpeedCLabel10;
	TTntEdit *ShutterSpeedEdit10;
	TTntPanel *SingleModePanel;
	TTntGroupBox *GroupBox2;
	TTntLabel *Label12;
	TTntLabel *Label13;
	TTntLabel *Label14;
	TTntButton *HCBCaptureFrameButton;
	TTntButton *HCBCaptureButton;
	TTntEdit *FrameTimeEdit;
	TTntEdit *LedOnTimeEdit;
	TTntEdit *ShutterDelayEdit;
	TTntGroupBox *GroupBox4;
	TTntCheckBox *LEDCheckBox1;
	TTntCheckBox *LEDCheckBox2;
	TTntCheckBox *LEDCheckBox3;
	TTntCheckBox *LEDCheckBox4;
	TTntCheckBox *LEDCheckBox5;
	TTntCheckBox *LEDCheckBox6;
	TTntCheckBox *LEDCheckBox7;
	TTntCheckBox *LEDCheckBox8;
	TTntCheckBox *LEDCheckBox9;
	TTntCheckBox *LEDCheckBox10;
	TTntCheckBox *LEDCheckBox11;
	TTntCheckBox *LEDCheckBox12;
	TTntGroupBox *GroupBox8;
	TTntButton *SensorCaptureStartButton;
	TTntButton *SensorCaptureStopButton;
	TTntLabel *ShutterSpeedLabel1;
	TTntLabel *ShutterSpeedLabel2;
	TTntLabel *ShutterSpeedLabel3;
	TTntLabel *ShutterSpeedLabel4;
	TTntLabel *ShutterSpeedLabel5;
	TTntLabel *ShutterSpeedLabel6;
	TTntLabel *ShutterSpeedLabel7;
	TTntLabel *ShutterSpeedLabel8;
	TTntLabel *ShutterSpeedLabel9;
	TTntLabel *ShutterSpeedLabel10;
	TTntButton *SaveDefaultShutterSpeedButton;
	TTntButton *SaveProductShutterSpeedButton;
  TTntPanel *ImageInfoPanel;
	TTntPanel *Panel3;
	TTntButton *CaptureSettingButton;
	TTntButton *LoadDefaultButton;
	TTntButton *SaveColorShutterSpeedButton;
	TTntButton *LoadSystemDefaultButton;
	TTntButton *CameraMappingButton;
	TTntButton *CameraSettingButton;
  TTntButton *CloseButton;
	TTntButton *CameraSetting_3D_Button;
	TTntPanel *Panel2;
	TTntPanel *Panel5;
	TCaptureFrame *SubCaptureFrame;
	TTntButton *SPBCaptureStartButton;
	TTntButton *SPBCaptureEndButton;
	TTntPanel *Panel6;
	TTntImage *EnlargeImage;
	TTntImage *RedImage;
	TTntImage *GreenImage;
	TTntImage *BlueImage;
	TTntPanel *Panel7;
  TTntGroupBox *TntGroupBox1;
  TImage *Image1;
  TImage *Image2;
  TStaticText *StaticText1;
  TStaticText *StaticText2;
  TTntSpeedButton *CameraSpeedButton1;
  TTntSpeedButton *CameraSpeedButton5;
  TTntSpeedButton *CameraSpeedButton2;
  TTntSpeedButton *CameraSpeedButton3;
  TTntSpeedButton *CameraSpeedButton4;
  TTntSpeedButton *CameraSpeedButton6;
  TTntSpeedButton *CameraSpeedButton7;
  TTntSpeedButton *CameraSpeedButton8;
  TTntSpeedButton *CameraSpeedButton16;
  TTntSpeedButton *CameraSpeedButton13;
  TTntSpeedButton *CameraSpeedButton9;
  TTntSpeedButton *CameraSpeedButton15;
  TTntSpeedButton *CameraSpeedButton14;
  TTntSpeedButton *CameraSpeedButton10;
  TTntSpeedButton *CameraSpeedButton11;
  TTntSpeedButton *CameraSpeedButton12;
  TTntLabel *ShutterSpeedCLabel11;
  TTntEdit *ShutterSpeedEdit11;
  TTntLabel *ShutterSpeedLabel11;
  TTntEdit *ShutterSpeedEdit12;
  TTntLabel *ShutterSpeedLabel12;
  TTntEdit *ShutterSpeedEdit13;
  TTntLabel *ShutterSpeedLabel13;
  TTntEdit *ShutterSpeedEdit14;
  TTntLabel *ShutterSpeedLabel14;
  TTntEdit *ShutterSpeedEdit15;
  TTntLabel *ShutterSpeedLabel15;
  TTntEdit *ShutterSpeedEdit16;
  TTntLabel *ShutterSpeedLabel16;
  TTntLabel *ShutterSpeedCLabel12;
  TTntLabel *ShutterSpeedCLabel13;
  TTntLabel *ShutterSpeedCLabel14;
  TTntLabel *ShutterSpeedCLabel15;
  TTntLabel *ShutterSpeedCLabel16;
  TGroupBox *GroupBox5;
  TTrackBar *WhiteBalanceBValue;
  TTrackBar *WhiteBalanceGValue;
  TTrackBar *WhiteBalanceRValue;
  TLabel *CameraNumberLabel;
  TTntLabel *TntLabel2;
  TTntLabel *TntLabel4;
  TTntLabel *TntLabel6;
  TTntEdit *WhiteBalanceBValueEdit;
  TTntEdit *WhiteBalanceGValueEdit;
  TTntEdit *WhiteBalanceRValueEdit;
  TEdit *Edit1;
  TTntPanel *MachineControlPanel;
  TTntLabel *Label19;
  TTntGroupBox *GroupBox6;
  TTntLabel *TabletColorLabelR;
  TTntLabel *TabletColorLabelG;
  TTntLabel *TabletColorLabelB;
  TTntLabel *Label16;
  TTntShape *TabletColorShape;
  TTntEdit *ColorCodeEdit;
  TTntButton *AdvMachineControlButton;
  TTntEdit *SPBFrameCountEdit;
  TTntPanel *SPBImagePanel;
  TImage *SPBImage1;
  TImage *SPBImage2;
  TImage *SPBImage4;
  TImage *SPBImage3;
  TLabel *Label20;
  TLabel *Label21;
  TLabel *Label22;
  TLabel *Label23;
  TTimer *SPBImageLoadTimer;
  TProgressBar *ImageLoadProgressBar1;
  TProgressBar *ImageLoadProgressBar2;
  TProgressBar *ImageLoadProgressBar4;
  TProgressBar *ImageLoadProgressBar3;
  TTntEdit *CameraGainEdit1;
  TTntEdit *CameraGainEdit9;
  TTntEdit *CameraGainEdit2;
  TTntEdit *CameraGainEdit10;
  TTntEdit *CameraGainEdit3;
  TTntEdit *CameraGainEdit11;
  TTntEdit *CameraGainEdit4;
  TTntEdit *CameraGainEdit12;
  TTntEdit *CameraGainEdit6;
  TTntEdit *CameraGainEdit14;
  TTntEdit *CameraGainEdit15;
  TTntEdit *CameraGainEdit7;
  TTntEdit *CameraGainEdit8;
  TTntEdit *CameraGainEdit16;
  TTntGroupBox *TntGroupBox2;
  TTntLabel *TntLabel8;
  TTntLabel *TntLabel10;
  TTntButton *SystemGainSaveBtn;
  TTntEdit *SystemAnalogGainEdit;
  TGroupBox *GroupBox7;
  TLabel *Label24;
  TLabel *Label25;
  TLabel *Label26;
  TLabel *Label27;
  TTntSpeedButton *ShowFovGridLineSpeedButton;
  TEdit *FOVEdit;
  TEdit *ProductLengthEdit;
  TLabel *Label28;
  TEdit *TabletLengthEdit;
  TLabel *Label29;
        TTntRadioGroup *ImageLoadRadioBtn;
        TTntRadioGroup *ResolutionRadioGroup;
  TTntGroupBox *ThreeDOptionGroupBox;
  TCheckBox *ThreeDOption1CheckBox;
  TEdit *ThreeDCameraGainEdit;
  TEdit *ThreeDExposureTimeEdit;
  TLabel *Label11;
  TLabel *Label15;
  TTntLabel *Label17;
  TTntEdit *TriggerFreqEdit;
  TCheckBox *ThreeDOption2CheckBox;
  TTntButton *AutoThreeDImageStudyBtn;
  TTntGroupBox *LaserTestGroupBox;
  TTntButton *LaserTestCaptureStartButton;
  TTntButton *LaserTestCaptureStopButton;
  TTntPanel *LaserTestImagePanel;
  TImage *LaserTestImageCamera1;
  TImage *LaserTestImageCamera5;
  TLabel *Label18;
  TProgressBar *LaserTestProgressBarCamera1;
  TProgressBar *LaserTestProgressBarCamera5;
  TLabel *Label30;
  TTimer *LaserTestTimer;
  TLabel *LaserTestProgressLabelCamera1;
  TLabel *LaserTestProgressLabelCamera5;
  TGroupBox *GroupBox3;
  TLabel *Label31;
  TLabel *Label32;
  TTimer *MachineStatusCheckTimer;
  TLabel *Disk1RPMLabel;
  TLabel *Disk2RPMLabel;
  TTntButton *EnabledDisk1SensorBtn;
  TTntButton *EnabledDisk2SensorBtn;
  TTntButton *TntButton1;
  TTntButton *TwoDCalibrationGuideButton;
  TImage *Image3;
  TImage *Image4;
  TImage *Image5;
  TGroupBox *ScaleSumGroupBox;
  TButton *ImageConversionBtn;
  TGroupBox *GroupBox9;
  TGroupBox *GroupBox10;
  TGroupBox *GroupBox11;
  TButton *Button1;
  TImage *AImage2;
  TImage *AImage3;
  TImage *AImage1;
  TTrackBar *TrackBar1;
  TCheckBox *CheckBox1;
  TEdit *Edit2;
  TTntButton *TntButton2;
  TButton *sLaseronBtn;
  TTntButton *TPBCameraSettingButton;
	TTntButton *LaserPositionCalBtn;
	TPanel *LaserPosCalPanel;
	TTntGroupBox *TntGroupBox3;
	TTntLabel *TntLabel1;
	TTntEdit *EditInputX;
	TTntGroupBox *TntGroupBox4;
	TTntLabel *TntLabel5;
	TTntLabel *TntLabel7;
	TTntEdit *EditXoutputX;
	TTntEdit *EditXoutputY;
	TTntGroupBox *TntGroupBox5;
	TTntLabel *TntLabel9;
	TTntLabel *TntLabel11;
	TTntLabel *EditCalXX;
	TTntLabel *EditCalXY;
	TTntButton *PositionSaveBtn;
	TTntGroupBox *TntGroupBox6;
	TTntGroupBox *TntGroupBox7;
	TTntLabel *TntLabel14;
	TTntLabel *TntLabel15;
	TTntEdit *EditYoutputX;
	TTntEdit *EditYoutputY;
	TTntGroupBox *TntGroupBox8;
	TTntLabel *TntLabel16;
	TTntLabel *TntLabel17;
	TTntLabel *EditCalYX;
	TTntLabel *EditCalYY;
	TTntEdit *EditInputY;
	TTntLabel *TntLabel3;
	TButton *Button2;
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall CameraSpeedButton1Click(TObject *Sender);
	void __fastcall ShutterSpeedEditChange(TObject *Sender);
	void __fastcall HCBCaptureFrameButtonClick(TObject *Sender);
	void __fastcall HCBCaptureButtonClick(TObject *Sender);
	void __fastcall SensorCaptureStartButtonClick(TObject *Sender);
	void __fastcall SensorCaptureStopButtonClick(TObject *Sender);
	void __fastcall SaveDefaultShutterSpeedButtonClick(TObject *Sender);
	void __fastcall SaveProductShutterSpeedButtonClick(TObject *Sender);
	void __fastcall CaptureSettingButtonClick(TObject *Sender);
	void __fastcall LEDCheckBoxClick(TObject *Sender);
	void __fastcall CaptureImageMouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
	void __fastcall LoadDefaultButtonClick(TObject *Sender);
	void __fastcall ColorCodeEditClick(TObject *Sender);
	void __fastcall SaveColorShutterSpeedButtonClick(TObject *Sender);
	void __fastcall LoadSystemDefaultButtonClick(TObject *Sender);
	void __fastcall CameraMappingButtonClick(TObject *Sender);
	void __fastcall CameraSettingButtonClick(TObject *Sender);
    void __fastcall CloseButtonClick(TObject *Sender);
	void __fastcall NumEditClick(TObject *Sender);
	void __fastcall SubCaptureFrameCaptureCheckTimerTimer(TObject *Sender);
	void __fastcall CameraSetting_3D_ButtonClick(TObject *Sender);
	void __fastcall SPBCaptureStartButtonClick(TObject *Sender);
	void __fastcall SPBCaptureEndButtonClick(TObject *Sender);
	void __fastcall AdvMachineControlButtonClick(TObject *Sender);
  void __fastcall SubCaptureFrameStopTimerButtonClick(TObject *Sender);
  void __fastcall WhiteBalanceBValueChange(TObject *Sender);
  void __fastcall WhiteBalanceBValueEditClick(TObject *Sender);
  void __fastcall WhiteBalanceGValueChange(TObject *Sender);
  void __fastcall WhiteBalanceRValueChange(TObject *Sender);
  void __fastcall Edit1Change(TObject *Sender);
  void __fastcall SPBImageLoadTimerTimer(TObject *Sender);
  void __fastcall CameraGainEdit1Change(TObject *Sender);
  void __fastcall SystemGainSaveBtnClick(TObject *Sender);
  void __fastcall TntFormShow(TObject *Sender);
  void __fastcall CaptureImageDblClick(TObject *Sender);
  void __fastcall FOVEditClick(TObject *Sender);
  void __fastcall CaptureImageMouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall ImageLoadRadioBtnClick(TObject *Sender);
        void __fastcall ResolutionRadioGroupClick(TObject *Sender);
  void __fastcall ThreeDOption1CheckBoxClick(TObject *Sender);
  void __fastcall TriggerFreqEditClick(TObject *Sender);
  void __fastcall ThreeDExposureTimeEditClick(TObject *Sender);
  void __fastcall ThreeDCameraGainEditClick(TObject *Sender);
  void __fastcall ThreeDOption2CheckBoxClick(TObject *Sender);
  void __fastcall AutoThreeDImageStudyBtnClick(TObject *Sender);
  void __fastcall LaserTestCaptureStartButtonClick(TObject *Sender);
  void __fastcall LaserTestCaptureStopButtonClick(TObject *Sender);
  void __fastcall LaserTestTimerTimer(TObject *Sender);
  void __fastcall MachineStatusCheckTimerTimer(TObject *Sender);
  void __fastcall EnabledDisk1SensorBtnClick(TObject *Sender);
  void __fastcall EnabledDisk2SensorBtnClick(TObject *Sender);
  void __fastcall TntButton1Click(TObject *Sender);
  void __fastcall TwoDCalibrationGuideButtonClick(TObject *Sender);
  void __fastcall Image5Click(TObject *Sender);
  void __fastcall ImageConversionBtnClick(TObject *Sender);
  void __fastcall Button1Click(TObject *Sender);
  void __fastcall TrackBar1Change(TObject *Sender);
  void __fastcall CheckBox1Click(TObject *Sender);
  void __fastcall TntButton2Click(TObject *Sender);
  void __fastcall sLaseronBtnClick(TObject *Sender);
  void __fastcall TntFormActivate(TObject *Sender);
  void __fastcall TPBCameraSettingButtonClick(TObject *Sender);
	void __fastcall LaserPositionCalBtnClick(TObject *Sender);
	void __fastcall PositionSaveBtnClick(TObject *Sender);
	void __fastcall EditInputXChange(TObject *Sender);
	void __fastcall EditInputYChange(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
private:	// User declarations
	bool bOnCapture;
  int GlobalCameraIndex;
  int ShutterSpeedList[SYSTEM_TOTAL_CAMERA_COUNT];
  int DigitalGainList[SYSTEM_TOTAL_CAMERA_COUNT];
  unsigned char SubsamplingModeList[SYSTEM_TOTAL_CAMERA_COUNT];

  unsigned int LEDOnMask[SYSTEM_TOTAL_CAMERA_COUNT];
  TColor CaptureTabletColor;
  TPoint MousePos;

  bool LaserCaptureSW;

  unsigned char ColorImage[SYSTEM_CAMERA_HD_WIDTH * SYSTEM_CAMERA_HD_HEIGHT * 3];

  int CAM_Width;
  int CAM_Height;


  void __fastcall ChangeCamera(void);
  void __fastcall LoadSystemInfor(void);
  bool __fastcall SendSPBCaptureSetup(void);
  void __fastcall RefreshLEDCheckBox(void);
  void __fastcall SendLEDInfor(void);
  void __fastcall RefreshSubImage(void);
  void __fastcall RefreshPixelInfo(int X, int Y);
  void __fastcall GetDefaultString();
  void __fastcall RefreshCameraInfo(int cameraIndex);
  void __fastcall AreaSelectPositionDisplay(void);
  void __fastcall SetApplyThreeDParams(int cameraIndex);
  void __fastcall ImageConversion();

  int measureStartPos;
  int measureEndPos;

  bool bLockRefreshOffsetInfo;

public:		// User declarations
	__fastcall TCaptureForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TCaptureForm *CaptureForm;
//---------------------------------------------------------------------------
#endif
