// GUILattice.h: interface for the GUILattice class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GUILATTICE_H__4F55C919_68FB_4659_8AC5_FFEB14C9AC33__INCLUDED_)
#define AFX_GUILATTICE_H__4F55C919_68FB_4659_8AC5_FFEB14C9AC33__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GUIObjectList.h"

namespace MW4AI
{
class CRailNode;
class CRailGraph;
class CRailLink;
};

class GUILatticeNode:public EdGUIObject
{
protected:
	MW4AI::CRailNode *MyNode;
	void UpdateMat();
	int RadiusPen;
public:
	EdGUIObject *Clone();
	void RotateBy(UnitQuaternion &pnt); //Used for Node Radius in this case makes UI easier
	bool CanTakeChildren() {return false;}

	GUILatticeNode(MW4AI::CRailNode *node);
	void SetNode(MW4AI::CRailNode *node);
	MW4AI::CRailLink *GetLinkTo(GUILatticeNode *node);
	int GetNodeID(); 
	void Dissociate() { MyNode=NULL; EdGUIObject::Dissociate();}
	void Draw(DrawInfo &dinf);
	virtual ~GUILatticeNode();
};

class GUILattice:public GUIObjectList
{
protected:
	MW4AI::CRailGraph *MyGraph;
	void SyncNodesToData();
	void SetGraph(MW4AI::CRailGraph *graph);
	int GetActualNodeCount();
public:
	EdGUIObject *Clone();
	static float GUILattice::PercentDone;
	
	GUILattice(MW4AI::CRailGraph *path);

	void UpdateVisibility(DWORD visflag);

	void SortChildren() {} 
	void SaveTextInfo(NotationFile *not_file);
	EdGUIObject *AddNode(Point3D &pnt);
	void Dissociate() {  MyGraph=NULL; GUIObjectList::Dissociate();}
	void CreateLattice(int num);
	void CalcLinksOnSelected();
	bool UnGroupSelected(UndoCommand **cmd);
	int GroupSelected(UndoCommand **cmd);
	void MoveToGroup(EdGUIObject *gobj) {}
	bool DeleteSelected(UndoCommand **delcom) { return GUIObjectList::DeleteSelected(); } 
	void CopySelectionToList(GUIObjectList *list) { return;}

	void Draw(DrawInfo &dinf);
	EdGUIObject *AddNodeIfSelected(Point3D &pnt,bool insert);	
	void RemoveObject(int idx);

	HTREEITEM AddToBranch(CTreeCtrl *tree,HTREEITEM itm);
	int GetUnSelIcon() {return ICON_LATTICE; }
	int GetSelIcon()   {return ICON_LATTICE; }
	CString GetTypeName() {return ("Lattice");} 

virtual ~GUILattice();

};


#endif // !defined(AFX_GUILATTICE_H__4F55C919_68FB_4659_8AC5_FFEB14C9AC33__INCLUDED_)
