163 lines
4.0 KiB
C++
163 lines
4.0 KiB
C++
|
#include "stdafx.h"
|
|||
|
|
|||
|
#include "BlockOut.h"
|
|||
|
|
|||
|
#define PIN_RADIUS 8 //Pin<69>b<EFBFBD>|
|
|||
|
|
|||
|
#define GOLD RGB (255, 215, 0) //Pin<69>}<7D>C<EFBFBD><43>
|
|||
|
#define BLACK RGB (0, 0, 0) //<2F>s<EFBFBD>u<EFBFBD>C<EFBFBD><43>
|
|||
|
|
|||
|
#define NO_VALUE -10 //<2F><><EFBFBD>s<EFBFBD>b<EFBFBD><62><EFBFBD>J<EFBFBD>T<EFBFBD><54>
|
|||
|
#define NO_BLOCK_HEAD -14 //<2F><><EFBFBD>s<EFBFBD>b<EFBFBD>s<EFBFBD><73>Block
|
|||
|
|
|||
|
#define BLK_OUT 2 //Block<63><6B><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73>
|
|||
|
|
|||
|
CBlockOut::CBlockOut ()
|
|||
|
{
|
|||
|
m_rcPinIn = CRect ();
|
|||
|
|
|||
|
m_iBlkHeadSize = (int) m_vcBlkHeadPtr.size ();
|
|||
|
}
|
|||
|
|
|||
|
CBlockOut::~CBlockOut ()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::SetBlkRect (CPoint ptCenter, int iWidth, int iHeight)
|
|||
|
{
|
|||
|
CBlockBasis::SetBlkRect (ptCenter, iWidth, iHeight);
|
|||
|
|
|||
|
m_rcPinIn.left = m_rcBlk.CenterPoint ().x - PIN_RADIUS;
|
|||
|
m_rcPinIn.top = m_rcBlk.top - PIN_RADIUS;
|
|||
|
m_rcPinIn.right = m_rcBlk.CenterPoint ().x + PIN_RADIUS;
|
|||
|
m_rcPinIn.bottom = m_rcBlk.top + PIN_RADIUS;
|
|||
|
}
|
|||
|
|
|||
|
CRect CBlockOut::GetPinIn1Rect () const
|
|||
|
{
|
|||
|
return m_rcPinIn;
|
|||
|
}
|
|||
|
|
|||
|
CBlockBasis* CBlockOut::GetBlkHead1Ptr (int iIndex) const
|
|||
|
{
|
|||
|
//<2F>^<5E>ǫ<EFBFBD><C7AB>windex<65><78><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (iIndex < m_iBlkHeadSize)
|
|||
|
return m_vcBlkHeadPtr[iIndex];
|
|||
|
else
|
|||
|
return NULL;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::SetBlkHead1Ptr (CBlockBasis* pBlkHead)
|
|||
|
{
|
|||
|
m_vcBlkHeadPtr.push_back (pBlkHead); //<2F>s<EFBFBD>W<EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::DeleteBlkHead1Ptr (int iIndex)
|
|||
|
{
|
|||
|
m_vcBlkHeadPtr.erase (m_vcBlkHeadPtr.begin () + iIndex); //<2F>M<EFBFBD><4D><EFBFBD><EFBFBD><EFBFBD>windex<65><78><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
int CBlockOut::GetBlkHead1Num (int iIndex) const
|
|||
|
{
|
|||
|
//<2F>^<5E>ǫ<EFBFBD><C7AB>windex<65><78><EFBFBD>s<EFBFBD><73>Block<63>s<EFBFBD><73>
|
|||
|
if (iIndex < m_iBlkHeadSize)
|
|||
|
return m_vcBlkHeadNum[iIndex];
|
|||
|
else
|
|||
|
return NO_BLOCK_HEAD;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::SetBlkHead1Num (int iHeadBlkNum)
|
|||
|
{
|
|||
|
m_vcBlkHeadNum.push_back (iHeadBlkNum); //<2F>s<EFBFBD>W<EFBFBD>s<EFBFBD><73>Block<63>s<EFBFBD><73>
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::ClearBlkHead1Num ()
|
|||
|
{
|
|||
|
std::vector <int> ().swap (m_vcBlkHeadNum); //<2F>M<EFBFBD>ųs<C5B3><73><EFBFBD>s<EFBFBD><73>vector
|
|||
|
}
|
|||
|
|
|||
|
int CBlockOut::GetBlkHeadSize () const
|
|||
|
{
|
|||
|
return m_iBlkHeadSize; //<2F>^<5E>ǿ<EFBFBD><C7BF>Jchannel<65>ƥ<EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::SetBlkHeadSize (int iFlag)
|
|||
|
{
|
|||
|
//<2F>]<5D>w<EFBFBD><77><EFBFBD>Jchannel<65>ƥ<EFBFBD>
|
|||
|
if (iFlag == FALSE) //<2F><>flag<61><67>FALSE<53>ɡA<C9A1>̳s<CCB3><73><EFBFBD>s<EFBFBD><73>vector<6F>j<EFBFBD>p<EFBFBD>]<5D>w
|
|||
|
m_iBlkHeadSize = (int) m_vcBlkHeadNum.size ();
|
|||
|
else if (iFlag == TRUE) //<2F><>flag<61><67>TRUE<55>ɡA<C9A1>̳s<CCB3><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vector<6F>j<EFBFBD>p<EFBFBD>]<5D>w
|
|||
|
m_iBlkHeadSize = (int) m_vcBlkHeadPtr.size ();
|
|||
|
}
|
|||
|
|
|||
|
double CBlockOut::GetBlkValue (int iIndex) const
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>o<EFBFBD><6F><EFBFBD>wchannel<65><6C>Block<63><6B>
|
|||
|
if (!m_vcBlkHeadPtr.empty () && iIndex < m_iBlkHeadSize)
|
|||
|
return m_vcBlkHeadPtr[iIndex]->GetBlkValue ();
|
|||
|
else
|
|||
|
return NO_VALUE;
|
|||
|
}
|
|||
|
|
|||
|
int CBlockOut::GetValueFlag (int iIndex) const
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>o<EFBFBD><6F><EFBFBD>wchannel<65><6C>Value<75>X<EFBFBD><58>
|
|||
|
if (!m_vcBlkHeadPtr.empty () && iIndex < m_iBlkHeadSize)
|
|||
|
return m_vcBlkHeadPtr[iIndex]->GetValueFlag ();
|
|||
|
else
|
|||
|
return NO_VALUE;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::Move (CPoint ptCursor)
|
|||
|
{
|
|||
|
CBlockBasis::Move (ptCursor);
|
|||
|
|
|||
|
m_rcPinIn.left = m_rcBlk.CenterPoint ().x - PIN_RADIUS;
|
|||
|
m_rcPinIn.top = m_rcBlk.top - PIN_RADIUS;
|
|||
|
m_rcPinIn.right = m_rcBlk.CenterPoint ().x + PIN_RADIUS;
|
|||
|
m_rcPinIn.bottom = m_rcBlk.top + PIN_RADIUS;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::Draw (CDC* pDC)
|
|||
|
{
|
|||
|
CBrush brushPin (GOLD), * pbrushOld;
|
|||
|
pbrushOld = pDC->SelectObject (&brushPin);
|
|||
|
pDC->Ellipse (m_rcPinIn);
|
|||
|
pDC->SelectObject (pbrushOld);
|
|||
|
|
|||
|
CBlockBasis::Draw (pDC);
|
|||
|
pDC->DrawTextA (_T ("OUT"), -1, &m_rcBlk, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
|||
|
}
|
|||
|
|
|||
|
void CBlockOut::DrawLine (CDC* pDC)
|
|||
|
{
|
|||
|
if (!m_vcBlkHeadPtr.empty ())
|
|||
|
{
|
|||
|
CPen penLine (PS_SOLID, 5, BLACK);
|
|||
|
CPen* pOldPen;
|
|||
|
|
|||
|
pOldPen = pDC->SelectObject (&penLine);
|
|||
|
|
|||
|
for (int i = 0; i < m_iBlkHeadSize; i++)
|
|||
|
{
|
|||
|
CPoint ptStart = m_vcBlkHeadPtr[i]->GetPinOutRect ().CenterPoint (); //<2F>s<EFBFBD>u<EFBFBD>_<EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD>JBlock<63><6B><EFBFBD><EFBFBD><EFBFBD>XPin<69>}<7D><><EFBFBD><EFBFBD><EFBFBD>I
|
|||
|
CPoint ptEnd = m_rcPinIn.CenterPoint (); //<2F>s<EFBFBD>u<EFBFBD><75><EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD>Block<63><6B><EFBFBD><EFBFBD><EFBFBD>JPin<69>}<7D><><EFBFBD><EFBFBD><EFBFBD>I
|
|||
|
int iGrid = (int) (m_rcBlk.Height () / 2. + 0.5); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD>j
|
|||
|
int iCornerGridY = (int) (((ptStart.y + ptEnd.y) / 2. - ptStart.y) / iGrid + 0.5); //<2F>p<EFBFBD><70><EFBFBD>s<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD>Z<EFBFBD><5A><EFBFBD><EFBFBD><EFBFBD>JBlock<63>X<EFBFBD>ӹj<D3B9>I
|
|||
|
int iCornerY = iCornerGridY * iGrid + ptStart.y; //<2F>s<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD>BY<42>y<EFBFBD>Ц<EFBFBD><D0A6>m
|
|||
|
pDC->MoveTo (ptStart);
|
|||
|
pDC->LineTo (CPoint (ptStart.x, iCornerY));
|
|||
|
pDC->MoveTo (CPoint (ptStart.x, iCornerY));
|
|||
|
pDC->LineTo (CPoint (ptEnd.x, iCornerY));
|
|||
|
pDC->MoveTo (CPoint (ptEnd.x, iCornerY));
|
|||
|
pDC->LineTo (ptEnd);
|
|||
|
}
|
|||
|
|
|||
|
pDC->SelectObject (pOldPen);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
int CBlockOut::BlkTypeIs () const
|
|||
|
{
|
|||
|
return BLK_OUT;
|
|||
|
}
|