You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/Module/GeoSigmaDraw/ItemSelectCurve.cpp

140 lines
2.9 KiB
C++

#include "StdAfx.h"
#include "ItemTracker.h"
#include "itemselectcurve.h"
#include "SigmaDoc.h"
#include "SigmaView.h"
CItemSelectCurve::CItemSelectCurve(CSigmaDoc * ppDoc)
: CItemSelectElement(ppDoc)
{
m_SelectType=DOUBLEFOX_CURVE;
m_SelectID=IDS_STRING_IS_NOT_CURVE;
m_nCompareIdea=0;
m_bDrawSelectPoint=FALSE;
m_bEnableOtherType=FALSE;
}
CItemSelectCurve::~CItemSelectCurve(void)
{
}
void CItemSelectCurve::DrawSelectItem(SELECT_ITEM& item)
{
if(m_bDrawSelectPoint && item.pos!=NULL)
{
CCurveEx* pc=(CCurveEx*)GetDoc()->GetDraw()->GetAtValue(item.pos);
double l0;
pc->PointDistance(item.point.x0, item.point.y0, l0);
CPoint3D pt;
pc->GetCoordinate(l0, pt.x0, pt.y0, pt.z0);
DrawCrossPoint(GetDC(), pt.x0, pt.y0);
//DrawCrossPoint(GetDC(), item.point.x0, item.point.y0);
}
}
void CItemSelectCurve::EnableDrawSelectPoint(BOOL bEnable)
{
m_bDrawSelectPoint=bEnable;
}
CCurveEx* GetRangeCurve(CXy* pxy, POSITION pos, BOOL& bDeleteCurve)
{
if(pxy==NULL || pos==NULL) return NULL;
COne* pOne = pxy->GetAt(pos);
bDeleteCurve=FALSE;
CCurveEx* pRgn=NULL;
switch(pOne->GetType())
{
case DOUBLEFOX_CURVE:
pRgn=(CCurveEx*)pOne->GetValue();
break;
case DOUBLEFOX_ARC:
pRgn=((CArc*)pOne->GetValue())->GetCurve();
break;
case DOUBLEFOX_CRECT:
pRgn=new CCurveEx;
((CCurveRect*)pOne->GetValue())->GetCurve(*pRgn);
bDeleteCurve=TRUE;
break;
case DOUBLEFOX_CIRCLE:
case DOUBLEFOX_ELLIPSE:
pRgn=((CEllipse*)pOne->GetValue())->ToCurve(2.0);
bDeleteCurve=TRUE;
break;
default:
return NULL;
}
return pRgn;
}
CCurveEx* NItem::CItemSelectCurve::GetRangeCurve(POSITION pos, BOOL& bDeleteCurve)
{
return ::GetRangeCurve(GetDoc()->GetDraw(), pos, bDeleteCurve);
}
void CItemSelectCurve::DrawSelectItem(POSITION pos)
{
ASSERT(pos!=NULL);
BOOL bDeleteCurve=FALSE;
CCurveEx* pRgn=GetRangeCurve(pos, bDeleteCurve);
if(pRgn==NULL) return;
if(pRgn!=NULL)
Draw(GetDC(),pRgn,RGB(255,0,0));
if(bDeleteCurve) delete pRgn;
}
void CItemSelectCurve::Draw(CXyDC* pDC, CCurveEx* pCurve, COLORREF color)
{
DrawCurveHandle(pDC, pCurve, color, TRACKER_NO_EDIT, TRUE, 2);
}
void CItemSelectCurve::EnableSelectOtherType(BOOL bEnable)
{
m_bEnableOtherType=bEnable;
}
void CItemSelectCurve::AddOtherType(int type)
{
m_arrOtherType.Add(type);
}
BOOL CItemSelectCurve::IsSelectItem(POSITION pos)
{
ASSERT(pos);
if(pos==NULL) return FALSE;
int type=m_SelectType;
UINT nTypeID=m_SelectID;
if(type==0) return FALSE;
if(m_bEnableOtherType)
{
if(!IsElementType(pos, type) && !IsOtherType(pos))
{
//::AfxMessageBox(nTypeID);
return FALSE;
}
}
else if(!IsElementType(pos, type))
{
//::AfxMessageBox(nTypeID);
return FALSE;
}
return IsCanSelected(pos);
}
BOOL NItem::CItemSelectCurve::IsOtherType(POSITION pos)
{
int type=GetDoc()->GetDraw()->GetElementType(pos);
for(int i=0;i<m_arrOtherType.GetCount();i++)
{
if(m_arrOtherType[i]==type)
return TRUE;
}
return FALSE;
}