// DepthCtrl.h: interface for the CDepthCtrl class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DEPTHCTRL_H__90664EDC_90D2_4AA7_8B85_55899D24D7C6__INCLUDED_)
#define AFX_DEPTHCTRL_H__90664EDC_90D2_4AA7_8B85_55899D24D7C6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <math.h>
#include <deque>
using namespace std;  

#define PERCENT_OFFSET      75    //determines x position of ship object from left
#define DEFAULT_DQ_SIZE     1000  //inital number of depth points to track
#define DEFAULT_MAX_DEPTH	30	  //initial max depth on display
#define	DEFAULT_MIN_DEPTH	0	  //initial min depth = surface 

#define POLYGON_VERTICES    10

//FOR WATER COLOR
#define FRAME_SIZE			100   //Gives us 30 shades of blue to 3000m
#define R 165
#define G 200
#define B 255

class CDepthCtrl  
{
///////////////////////////
public://CONSTRUCTION
///////////////////////////

	//Create the Ctrl Object
						CDepthCtrl			();
	virtual				~CDepthCtrl			();

///////////////////////////
public://FUNCTIONS
///////////////////////////
	
	//Initialize the Ctrl - later this will be overloaded to 
	//support an isolated CWnd 
	BOOL				InitCtrl			(	CWnd		*pWnd, 
												CRect		area );	
	void				Cleanup				(	void );

	//The primary functions
	void				AddDepth			(	double		value,
												double		altitude );

	void				SetBottomDepth		(	int			value);

	//Support functions
	void				Resize				(	CRect		rect);

	void				Refresh				(	void );
	
	//Settings functions
	void				SetWindowOffsets	(	int			X, 
												int			Y );			//Set offsets from rect boundaries
	
	void				SetScaleUnits		(	int			type );			//Set the units (0feet/1meters)
	
	void				SetWaterColor		(	COLORREF	water );			//Set water color

	void				SetShipMarker		(	COLORREF	crFill );		    //Set Ship object color / shape

	void				SetAxisColor		(	COLORREF	crAxis );		//Set axis colors
	
	void				SetHistoryColor		(	COLORREF	crHistory );	//Set line color
	
	void				SetDepthTextColor	(	COLORREF	crText );
		
	void				SetCrossLineColor	(	COLORREF	crLines );

	void				SetBackgroundBmp	(	HBITMAP		bmp );			//Optional background image

///////////////////////////
private://VARIABLES
///////////////////////////
	
	//GDI
	CDC					m_DC1;									//A compatible DC to blt from 
	CWnd				*m_pParentWnd;								//The output DC ptr
	CBitmap				m_bmpMain;								//The main BMP to draw on
	CBitmap				m_bmpCopy;								//Used to draw on, pre-Blt()							//Use for background bmp
	BITMAP				m_BmpMain;								//Info about bitmap
	CBrush				m_brWater, m_brShip, m_brBottom;			//Brushes 								
	CPen				m_penData, m_penShip, m_penGrid;			//Pens
	CPen				m_penAxis, m_penAxisMarkers;				//Pens
	CFont				m_ftAxis, m_ftDepth;						//Text Attributes

	//Attributes
	CRect				m_Rect;									//The rect in client coordinates
	int					offsetX, offsetY;							//Offsets from rect
	int					m_dMaxDepth, m_dMinDepth;					//The range of depths to display
	enum				{English = 0, Metric} EUnitSystem;		//Define Units
	enum				{ROV = 0, SQUARE, OVAL} EMarkerType;				//Define depth marker object shape
	COLORREF			crWater, crAxes,  crData, crGrid;		    //Colors of display items
	COLORREF			crShip, crShipFill, crBottom;				//Colors of display items
	BOOL				bkColorSet;

	//History
	deque<float>		m_qHistory;								//History que of depths

	int					m_maxDQSize;							//Max history size
	
	POINT				*m_PolyLine;							//Polyline = array of POINT structs
	int					m_nPoints;								//How many POINTS are stored

	POINT				m_Polygon[POLYGON_VERTICES];			//The AUV marker vertices array
	int					m_nVertices	;							//The number of marker vertices (constant)

	int					m_posX;									//Where the ship is displayed & How many POINTS to show 															
	float				m_nLastDepth;
	float				m_fLastAlt;
	int					m_nCurrentFrame;
	float				m_nBottomDepth;

///////////////////////////
private://FUNCTIONS
///////////////////////////

	//GDI SUPPORT
	void				InitGDI				(	void );
	
	void				CreatePlane			(	void );									//Creates the main bitmap
	
	void				FillPlane			(	void );									//Fill th background
	
	void				DrawAxes			(	void );									//Draw the two sided depth axis
	
	void				DrawShip			(	int			y);							//Draws the ship on bmp, y pixels down from top
	
	void				DrawDepthLine		(	void );									//Draw the depths from history
	
	void				Render				(	void );									//Stretch blt to screen
	
	void				ShiftFrameColor		(	void );

	//WINDOW RANGE FUNCTIONS
	void				ShiftRangeDown		(	int			newMinDepth);				//Shift the depth range to deeper
	
	void				ShiftRangeUp		(	int			newMaxDepth );				//Shift the depth range to shallow
	
	void				UpdateShift			(	void );									//Redraw

};

#endif // !defined(AFX_DEPTHCTRL_H__90664EDC_90D2_4AA7_8B85_55899D24D7C6__INCLUDED_)
