#pragma once
#include "CommonObject.h"
#include "Node.h"
#include <vector>
using namespace std;

class CGate : public CCommonObject
{
public:
	CGate(int nIn, int nOut, CPoint TopLeftOrigin, CString strName, CStringA strOrigin);
	//CGate(int nIn, int nOut, CPoint TopLeftOrigin, CString strName, CStringA strOrigin, GraphicsPath *gp, CRect *rectIn, CRect *rectOut, bool *bInvIn, bool*bInvOut);
	CGate(int nIn, int nOut, CPoint TopLeftOrigin, CString strName, CStringA strOrigin, GraphicsPath *gp, CPoint *pntIn, CPoint *pntOut, bool *bInvIn, bool*bInvOut, int *dirIn, int *dirOut);
	CGate(CPoint TopLeftOrigin, CString strName, CStringA strOrigin, GraphicsPath *gp, 
				  vector<CPoint> pntIn, vector<CPoint> pntOut, vector<bool> bInvIn, vector<bool> bInvOut, vector<int> dirIn, vector<int> dirOut);
	~CGate();

	virtual void OutScreen(Graphics &g);
	virtual void OutXml(stringstream &ss);
	virtual bool HitTest(CPoint point);
	virtual CCommonObject* Clone(CPoint TopLeftOrigin, CString strNewName, int nRotation);
	virtual CString GetObjectName(){return m_strUniqueName;}
	virtual void SetConnection(bool bIn, int nPos, CCommonObject* pConnectTo);
	virtual void DisconnectCObject(CCommonObject *pObject);
	virtual void Disconnect();
	virtual vector<CNode *> CreatePinNodes();	
	virtual void SetRotation(int nRotation);
	virtual std::vector<CCommonObject *> GetConnectedObjs(bool in);
protected:
	virtual void TransformCObject(Matrix* pMat);
	void Init(CPoint TopLeftOrigin, CString strName, CStringA strOrigin, GraphicsPath *gp, 
				  vector<CPoint> pntIn, vector<CPoint> pntOut, vector<bool> bInvIn, vector<bool> bInvOut, vector<int> dirIn, vector<int> dirOut);
public:
	vector<CNode *> m_PinNodes;
public:
	vector<bool> m_vInvIn;
	vector<bool> m_vInvOut;
	vector<CPoint> m_vPntIn;
	vector<CPoint> m_vPntOut;
	vector<int> m_vDirIn;
	vector<int> m_vDirOut;
};