#ifndef DEF_TEMPLATES
 #define DEF_TEMPLATES
//------------------------------------------//
//				TKA4 Templates				//
//				22. 04. 2007				//
//------------------------------------------//


//--- Includes
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>

#include "TX_Engine.h"
#include "TX_Primitives.h"
#include "TX_Templates.h"
//=== Includes 


//--- Pragma 
#pragma comment (lib, "opengl32.lib")  
#pragma comment (lib, "glu32.lib")     
//=== Pragma 


//--- Class declarations
class txTmp_GridPlot;
//=== Class declarations

//--- Grid Plot (Axes, Backgrn, grid)
class txTmp_GridPlot : public txObject {
	protected:	
		txpoint3d min, max;

		//---
		txObj_Axes *o_axes;
		txObj_SuperBegin *o_superbegin;
		txObj_Grid2d *o_grid;
		txObj_Begin *o_begin;

	public:
		
		virtual void default_constr ()
		{
			o_superbegin = new txObj_SuperBegin ();
			o_begin = new txObj_Begin();	
			o_axes = new txObj_Axes();	
			o_grid = new txObj_Grid2d();
					
		};
		
		txTmp_GridPlot() { default_constr(); dir=d_both_super; };
		~txTmp_GridPlot() 
			{ delete o_superbegin; delete o_grid; delete o_begin; };


		
		virtual void  Execute_Forward();
		virtual void  Execute_Backward();

		inline virtual void SetMinMax(txpoint3d min_, txpoint3d max_);
};



//------------------------- :: Functions :: ---------------------------
//--- txTmp_GridPlot :: Execute_Forward
void txTmp_GridPlot :: Execute_Forward()
{	
	o_begin->Execute_Forward();
	o_superbegin->Execute_Forward();

	o_axes->Execute_Forward();	
	o_grid->Execute_Forward();
};


//--- txTmp_GridPlot :: Execute_Backward
void txTmp_GridPlot :: Execute_Backward()
{
	o_superbegin->Execute_Backward();
	o_begin->Execute_Backward();
};


//--- txTmp_GridPlot ::SetMinMax
void txTmp_GridPlot :: SetMinMax(txpoint3d min_, txpoint3d max_) 
{
		//--- Axes 
		o_axes->SetAxesMirror(min_, max_);
		max = o_axes->GetMax(); min = o_axes->GetMin();
		
		o_superbegin->SetMinMax(min, max);
		o_grid->SetMaxMin(min, max);
		
		//--- Begin 2
		txview_matrix m;
			m.scale.r.x = 0.98;
			m.scale.r.y = 0.98;
			m.scale.r.z = 0.98;
		o_begin->SetMatrix(m);
};


#endif



