//===========================================================================//
// File:    traceline.hpp                                                     
// Project: LabRat                                                 		 
// Contents: 				  
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 03/20/96  JSE  Initial coding.                                             
//---------------------------------------------------------------------------//
// Copyright (C) 1996, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//
 
#if !defined (TRACELINE_HPP)
#	define TRACELINE_HPP

class TraceLine;

#include "style.hpp"
#include "storage.hpp"
#include "LabRatDoc.h"


#include "ChildFrm.h"

#define BORDER_SIZE    10
#define TOGGLE_SIZE    25
#define DEFAULT_SIZE    15
#define INTEGER_SIZE   35
#define SCALAR_SIZE   35
#define SCALER_SIZE    35
#define MIN_TRACE_SIZE 15
#define BOX_MINIMUM     3


#define TOGGLE_ARRAY_SIZE  MAX_WIDTH * 3
#define MARKER_ARRAY_SIZE  MAX_WIDTH * 3
#define INTEGER_ARRAY_SIZE  MAX_WIDTH * 3
#define SCALAR_ARRAY_SIZE  MAX_WIDTH * 3


//##########################################################################
//#######################    TraceLine    
//##########################################################################

	class TraceLine :
		public CObject
	{
		
	public:

		Time 
			startTime,
			endTime,
			timeToPixel;
		
	   int
			firstTraceIndex,
			lastTraceIndex;

		int
			realFirstTraceIndex,
			realLastTraceIndex;
		
		CString
			traceName;
		int
			traceNumber;

		Logical
			alreadyWorking;

		Logical
			traceMade;

		BOOL
			on;

		BOOL
			selected;

		Time
			startSelection,
			endSelection;
		
		MY_RGB
			traceColor;

		int 
			traceHeight;
		
		CLabRatDoc
			*document;

		CChildFrame
			*myParent;

		CObarrayHolder 
			*dataHolder;
		
	public:
		TraceLine();
		virtual ~TraceLine();

		virtual int GetTraceType();

		virtual void
			Draw(int offset);

		virtual void
			DrawName(int offset);

		virtual void
			DrawLine(int offset);
	
		virtual void
			DrawCurrentValue(int offset, Time timeOfValue);

		virtual int
			CalculateSize(void);

		virtual Logical
			MakeTrace(
				Time start_time, 
				Time end_time,
				Time time_to_pixel
				);

		virtual void
			AdjustHeight()
				{;}

		
		virtual void
			SetMinMax(void)
				{;}
		
	};

//##########################################################################
//#######################    ToggleTraceLine    
//##########################################################################

	class ToggleTraceLine :
		public TraceLine
	{
		
	
	public:

		enum {
			DrawTrace,
			DoubleTrace,
			StartBox,
			EndBox
		};

		int drawtype;

		int 
			traceArray[TOGGLE_ARRAY_SIZE];

		BYTE 
			traceMode[TOGGLE_ARRAY_SIZE];

		ToggleTraceLine(void);
		~ToggleTraceLine(void);

		int GetTraceType();

		void
			Draw(int offset);

		void
			DrawCurrentValue(int offset, Time timeOfValue);

		int 
			CalculateSize(void);

		Logical
			MakeTrace(
				Time start_time, 
				Time end_time,
				Time timeToPixel);
	};

//##########################################################################
//#######################    MarkerTraceLine    
//##########################################################################

	class MarkerTraceLine :
		public TraceLine
	{
		
	
	public:
		MarkerTraceLine(void);
		~MarkerTraceLine(void);

		int GetTraceType();

		void
			Draw(int offset);
		
		void
			DrawName(int /*offset*/)
				{ }

		void
			DrawCurrentValue(int /*offset*/, Time /*timeOfValue*/)
				{ }

		int 
			traceArray[MAX_WIDTH];
		
		BYTE 
			traceMode[MAX_WIDTH];

		Logical
			MakeTrace(
				Time start_time, 
				Time end_time,
				Time timeToPixel);
	};


//##########################################################################
//#######################    IntegerTraceLine    
//##########################################################################

	class IntegerTraceLine :
		public TraceLine
	{
		
	
	public:
		int min, max, adjustToZero;
		float valueToPixel;

		enum {
			DrawTrace,
			StartDouble,
			MinTrace,
			MaxTrace,
			EndDouble
		};

		int 
			traceArray[INTEGER_ARRAY_SIZE];

		BYTE 
			traceMode[INTEGER_ARRAY_SIZE];


		IntegerTraceLine(void);
		~IntegerTraceLine(void);

		int GetTraceType();

		void
			DrawCurrentValue(int offset, Time timeOfValue);

		void
			Draw(int offset);

		int 
			CalculateSize(void);
	
		void
			SetMinMax(void);

		Logical
			MakeTrace(
				Time start_time, 
				Time end_time,
				Time timeToPixel);

		void
			AdjustHeight()
				{
					adjustToZero = 0 - min;
					if (max == min) 
						valueToPixel = 0.0f;
					else
						valueToPixel = (float)traceHeight / (float)(max - min);
				}

	};

//##########################################################################
//#######################    ScalarTraceLine    
//##########################################################################

	class ScalarTraceLine :
		public TraceLine
	{
		
	
public:
		Scalar min, max, adjustToZero;
		float valueToPixel;

		enum {
			DrawTrace,
			StartDouble,
			MinTrace,
			MaxTrace,
			EndDouble
		};

		int 
			traceArray[SCALAR_ARRAY_SIZE];

		BYTE 
			traceMode[SCALAR_ARRAY_SIZE];


		ScalarTraceLine(void);
		~ScalarTraceLine(void);

		int GetTraceType();

		void
			DrawCurrentValue(int offset, Time timeOfValue);

		void
			Draw(int offset);

		int 
			CalculateSize(void);
	
		void
			SetMinMax(void);

		Logical
			MakeTrace(
				Time start_time, 
				Time end_time,
				Time timeToPixel);

		void
			AdjustHeight()
				{
					adjustToZero = 0 - min;
					if (max == min) 
						valueToPixel = 0.0f;
					else
						valueToPixel = (float)traceHeight / (float)(max - min);
				}
	};

//##########################################################################
//#######################    EntityTraceLine
//##########################################################################


class ReceiverMessageTraceLine :
	public ScalarTraceLine
{
public:
	enum CurrentValueDrawModes{
		DrawID,
		DrawName,
		DrawPosition
	};

	int drawMode;

	ReceiverMessageTraceLine::ReceiverMessageTraceLine(void)
	{ ScalarTraceLine(); drawMode = DrawName; }

	int GetTraceType();

	void
		DrawCurrentValue(int offset, Time timeOfValue);

};
#endif
