// UnsDisDoc.h : interface of the CUnsDisDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_UNSDISDOC_H__5D8C8C1C_111E_11D3_AAFE_DF5ABD9FD035__INCLUDED_)
#define AFX_UNSDISDOC_H__5D8C8C1C_111E_11D3_AAFE_DF5ABD9FD035__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CTimeStep;
class CLayer;
class CElement;

class CUnsDisDoc : public CDocument
{
protected: // create from serialization only
	CUnsDisDoc();
	DECLARE_DYNCREATE(CUnsDisDoc)

// Attributes
public:
	CObArray Layers,Elements,TimeInt;
	CArray <float,float>Tim;
	CString name;
	int lemarg,rimarg,topmarg,botmarg,meas,bcfup,bcflo,bccup,bcclo,maxit;
	float vfup,vflo,vcup,vclo;
	float deltin,dtmax,errt,eps;
	float pmin,pmax,cmin,cmax,pstp,cstp,pstl,cstl;
	LOGFONT ftyp;

// Operations
public:
	CTimeStep* GetTime(int i);
	CTimeStep* AddTime(float tim);
	CLayer* GetLayer(int i);
	CElement* GetElement(int i);
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CUnsDisDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	virtual void DeleteContents();
	//}}AFX_VIRTUAL

// Implementation
public:
	void PrintRes(CDC& td,RECT r,int ist,int ien);
	void Font();
	void DelLayer(int nl);
	void PlotTime (CDC &td,RECT rct,int istart,int iend);
	void FormAxes();
	void PlotAxes (CDC& td,RECT rct);
	void yax (CDC& td,float ymin,float ymax,float ytic,RECT r,int tlen);
	void ylabel (CDC& td,float ymin,float ymax,float ytic,RECT r,int tlen,int dp);
	void SolvEq (int n,float *a,float *b,float *c,float *d,float *rs);
	float Diff (float th);
	void EditBC();
	void OpenInitCon();
	void PlotElems (CDC& td,RECT r);
	void PlotLay (CDC& td,RECT r);
	void EditLayer (int nlay);
	void Solve(CDC& td,RECT rct);
	void Generate();
	void AddLayer();
	CSize GetDocSize();
	virtual ~CUnsDisDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CUnsDisDoc)
	afx_msg void OnTime();
	afx_msg void OnSaveTxt();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

class CLayer:public CObject
{
protected:
	CLayer();
  	DECLARE_SERIAL (CLayer);

public:
	CLayer (float z1, float z2, int nel, float ths,float thr, float n, float alf, float ks);
	float Theta (float psi);
	float Kuns (float psi);
	float Capac (float psi);
	float Diffus (float psi);
	float Se (float psi);

public:
	float alpha,wn,ths,thr,ksat;
	float disp,ro,stn,kd,efpo,potin,conin;
	float zbeg,zend;
	int nel;
public:
	virtual void Serialize (CArchive& ar);  	
};

class CResult:public CObject
{
protected:
	CResult();
  	DECLARE_SERIAL (CResult);

public:
	CResult (float ps);
	virtual void Serialize (CArchive& ar);  	

public:
	float psi, theta, conc, cons;
};

class CElement:public CObject
{
protected:
	CElement();
  	DECLARE_SERIAL (CElement);

public:
	CElement (float z1,float z2);
	float leng();
	virtual void Serialize (CArchive& ar);  	

public:
	float z1,z2;
	int nlay;
};

class CTimeStep:public CObject
{
protected:
	CTimeStep();
  	DECLARE_SERIAL (CTimeStep);

public:
	CTimeStep (float tim);
	~CTimeStep();
	CResult* GetResult (int i);
	virtual void Serialize (CArchive& ar);  	

public:
	CObArray Results;
	float time,pmax,cmax,pmin,cmin;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_UNSDISDOC_H__5D8C8C1C_111E_11D3_AAFE_DF5ABD9FD035__INCLUDED_)
