// VD_GUIDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "IniReader.h"
#include "IniWriter.h"

#define NUMBER_OF_LANES	6
#define VIEW_WIDTH		704
#define VIEW_HEIGHT		288

#define CARCONTOURS		1
#define CARRECTS		1<<1
#define ROADCONTOURS	1<<2
#define ROADSIGNS		1<<3
#define SHADOWMASK		1<<4
#define PATH			1<<5
#define SPEED			1<<6
#define LENGTH			1<<7
#define SHADOWANAL		1<<8
#define LANES			1<<9

#define RELOADINI		1<<10
#define USELANES		1<<11
#define FIXEDLANES		1<<12

struct Results{
	int vehCount;
	int carCount;
	int trCount;
	int actCount;
	int avgSpeed[NUMBER_OF_LANES];
	int density[NUMBER_OF_LANES];
	int flow[NUMBER_OF_LANES];
	CString LOS[NUMBER_OF_LANES];
	SYSTEMTIME time;
};

extern "C" __declspec(dllimport) IplImage* VD_Core(char *FileName, Results &results, int settings);
extern "C" __declspec(dllimport) int VD_Initialize(CStringList &files, CString ini);

// CVD_GUIDlg dialog
class CVD_GUIDlg : public CDialog
{
private:
	CRect	m_iRect;
	IplImage *m_Image;
	int m_fni;
	TCHAR* m_pszFile;
	int	m_settings;
	bool m_showWelcome;
	
	CString m_FileName;
	CStringList m_slFiles;
	CString iniFile;
	CString m_date;
	CString m_time;

	struct {
		double height;
		double ver_angle;	//radians
		double angle_range_y;	//radians
		double angle_range_x;	//radians
	} cs;

	struct {
		BOOL carContours;
		BOOL carRects;
		BOOL roadContours;
		BOOL roadSigns;
		BOOL shadowMask;
		BOOL path;
		BOOL speed;
		BOOL length;
		BOOL lanes;
		BOOL useLanes;
		int fixedLanes;
	} algs;

	Results results;

protected:
	BITMAPINFO* bmi; 
    BITMAPINFOHEADER* bmih;
    RGBQUAD* palette;
    unsigned int buffer[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256];


// Construction
public:
	CVD_GUIDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_VD_GUI_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnDestroy();
public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
public:
	afx_msg void OnBnClickedAdd();
public:
	afx_msg void OnLbnSelchangeList();
public:
	afx_msg void OnBnClickedAddfolder();
public:
	void SaveIniFile();
	void LoadSettings();
	void ShowSettings();
public:
	afx_msg void OnBnClickedSaveIni();
	afx_msg void OnBnClickedUselanes();
};





