Click here to Skip to main content
15,881,882 members
Articles / Multimedia / GDI

Curve representation by ICAS (Inner Centered Arcs)

Rate me:
Please Sign up or sign in to vote.
4.80/5 (13 votes)
13 Nov 2011CPOL7 min read 30.1K   1.7K   25  
Suggestion about another curve representation
#pragma once

#include "IcasFig.h" 

// CIcasTriDlg dialog
#pragma warning( disable : 4996 )//sscanf

class CIcasTriDlg : public CDialog
{
	DECLARE_DYNAMIC(CIcasTriDlg)

public:
	CIcasTriDlg(int x, int y, ICASTRI *pT, CWnd* pParent = NULL);
	CIcasTriDlg(int x, int y, int typ, CWnd* pParent = NULL);
	CIcasTriDlg(int x, int y, CWnd* pParent = NULL);
	virtual ~CIcasTriDlg();
	BOOL Create();

protected:
	CWnd* m_pParent;
	int   m_nID;

// Dialog Data
	enum { IDD = IDD_ICASTRIDLG };

public:
	int m_x;//
	int m_y;
	int m_nIcasTriType;//
	int m_nNormal;
	int m_nBridge;
	int m_nLine;
	int	m_nIdentDir;
	int m_nLeftTan;
	int m_nRightTan;
	int m_nLeftTan2;
	int m_nRightTan2;
	int m_nAutoLeft;
	int m_nAutoRight;
	int m_nMultStart;
	int m_nMultEnd;
	//
	int m_Typ;
	int m_P0typ;
	int m_P1typ;
	int m_P2typ;
	CString m_sP0typ;
	CString m_sP1typ;
	CString m_sP2typ;
	double m_P0x;
	double m_P0y;
	double m_P1x;
	double m_P1y;
	double m_P2x;
	double m_P2y;
	//
	ICASTRI* m_pT;

	void SetType(int type) {
		if (type & L_NORMAL)     m_nNormal    = 1;
		else                     m_nNormal    = 0;
		if (type & L_BRIDGE)     m_nBridge    = 1;
		else                     m_nBridge    = 0;
		if (type & L_LINE)       m_nLine      = 1;
		else                     m_nLine      = 0;
		if (type & L_IDENTDIR)   m_nIdentDir  = 1;
		else                     m_nIdentDir  = 0;
		if (type & L_LEFT_TAN)   m_nLeftTan   = 1;
		else                     m_nLeftTan   = 0;
		if (type & L_RIGHT_TAN)  m_nRightTan  = 1;
		else                     m_nRightTan  = 0;
		if (type & L_LEFT_TAN2)  m_nLeftTan2  = 1;
		else                     m_nLeftTan2  = 0;
		if (type & L_RIGHT_TAN2) m_nRightTan2 = 1;
		else                     m_nRightTan2 = 0;
		if (type & L_AUTO_L)     m_nAutoLeft  = 1;
		else                     m_nAutoLeft  = 0;
		if (type & L_AUTO_R)     m_nAutoRight = 1;
		else                     m_nAutoRight = 0;
		if (type & L_MLTSTART)   m_nMultStart = 1;
		else                     m_nMultStart = 0;
		if (type & L_MLTEND)     m_nMultEnd   = 1;
		else                     m_nMultEnd   = 0;
	}
	int GetType() {
		int type = 0;
		if (m_nNormal)     type |= L_NORMAL;
		if (m_nBridge)     type |= L_BRIDGE;
		if (m_nLine)       type |= L_LINE;
		if (m_nIdentDir)   type |= L_IDENTDIR;
		if (m_nLeftTan)    type |= L_LEFT_TAN;
		if (m_nRightTan)   type |= L_RIGHT_TAN;
		if (m_nLeftTan2)   type |= L_LEFT_TAN2;
		if (m_nRightTan2)  type |= L_RIGHT_TAN2;
		if (m_nAutoLeft)   type |= L_AUTO_L;
		if (m_nAutoRight)  type |= L_AUTO_R;
		if (m_nMultStart)  type |= L_MLTSTART;
		if (m_nMultEnd)    type |= L_MLTEND;
		return type;
	}
	void SetTri(ICASTRI* pT) {
		if (NULL == pT) return;
		SetType(pT->Typ);
		m_P0typ = pT->P[0].typ;
		m_sP0typ.Format("0x%x",m_P0typ);
		m_P0x   = pT->P[0].x;
		m_P0y   = pT->P[0].y;
		m_P1typ = pT->P[1].typ;
		m_sP1typ.Format("0x%x",m_P1typ);
		m_P1x   = pT->P[1].x;
		m_P1y   = pT->P[1].y;
		m_P2typ = pT->P[2].typ;
		m_sP2typ.Format("0x%x",m_P2typ);
		m_P2x   = pT->P[2].x;
		m_P2y   = pT->P[2].y;
	}
	int SetHitTri() {
		if (NULL == m_pT) return 0;
		m_pT->Typ = GetType();
		sscanf(m_sP0typ,"0x%x", &m_P0typ);
		m_pT->P[0].typ = m_P0typ;
		m_pT->P[0].x   = m_P0x;
		m_pT->P[0].y   = m_P0y;
		sscanf(m_sP1typ,"0x%x", &m_P1typ);
		m_pT->P[1].typ = m_P1typ;
		m_pT->P[1].x   = m_P1x;
		m_pT->P[1].y   = m_P1y;
		sscanf(m_sP2typ,"0x%x", &m_P2typ);
		m_pT->P[2].typ = m_P2typ;
		m_pT->P[2].x   = m_P2x;
		m_pT->P[2].y   = m_P2y;
		return m_pT->Typ;
	}

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnBnClickedChkNormal();
	afx_msg void OnBnClickedChkBridge();
	afx_msg void OnBnClickedChkLine();
	afx_msg void OnBnClickedChkIdentdir();
	afx_msg void OnBnClickedChkLtan();
	afx_msg void OnBnClickedChkRtan();
	afx_msg void OnBnClickedChkLtan2();
	afx_msg void OnBnClickedChkRtan2();
	afx_msg void OnBnClickedChkLauto();
	afx_msg void OnBnClickedChkRauto();
	afx_msg void OnBnClickedChkMltstart();
	afx_msg void OnBnClickedChkMltend();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Japan Japan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions