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.
398 lines
11 KiB
C++
398 lines
11 KiB
C++
#include "StdAfx.h"
|
|
#include ".\itemnet.h"
|
|
#include "SigmaDoc.h"
|
|
#include ".\itemframe.h"
|
|
|
|
CItemEditNet::CItemEditNet(CSigmaDoc * ppDoc)
|
|
: CItemEditFrame(ppDoc)
|
|
, m_pNet(NULL)
|
|
, DisplayIdea(0)
|
|
, MarkText(0)
|
|
, TextFormat(0)
|
|
, color(0)
|
|
, m_dThickness(0)
|
|
{
|
|
this->SetType(ITEM_NET);
|
|
}
|
|
|
|
CItemEditNet::~CItemEditNet(void)
|
|
{
|
|
}
|
|
|
|
void CItemEditNet::DoLButtonUp(CDC* pDC)
|
|
{
|
|
CRect8 rect=this->GetRect();
|
|
|
|
m_pNet=new CNet;
|
|
*(CRect8*)m_pNet=rect;
|
|
if(!GetDoc()->GetDraw()->GetProjection().IsEmpty())
|
|
{
|
|
m_pNet->SetProjection(&(GetDoc()->GetDraw()->m_ExchangeXYZ));
|
|
|
|
//自动计算步长
|
|
rect=m_pNet->GetRangeBL();
|
|
double step=min(rect.Width()/5, rect.Height()/5);
|
|
step*=60; //转换为分单位
|
|
step=AfxGetPublicFunction()->GetLBStep(step);
|
|
m_pNet->m_step.SetSize(step, step);
|
|
}
|
|
//自动根据单位设置文字大小
|
|
//double scale=GetDoc()->GetCurrentUnitScale(); //TOFIX:关键函数.要实现.
|
|
//m_pNet->ScaleProperty(scale, scale);
|
|
|
|
/*
|
|
CPropertiesSheet sheet(IDS_STRING_NET,GetView(),0,FALSE);
|
|
sheet.SetItem(this);
|
|
if(sheet.DoModal()==IDOK)
|
|
{
|
|
if(GetDoc()->GetDraw()->GetProjection().IsEmpty())
|
|
{
|
|
::AfxMessageBox(IDS_PROJECTION_IS_EMPTY);
|
|
delete m_pNet;
|
|
m_pNet=NULL;
|
|
GetDoc()->EnableDefaultTool();
|
|
}
|
|
else
|
|
{
|
|
POSITION pos=AddElement(m_pNet,DOUBLEFOX_NET);
|
|
GetDoc()->GetDraw()->SetElementColor(pos,color);
|
|
|
|
m_pNet=NULL;
|
|
COne* pOne=GetDoc()->GetDraw()->GetAt(pos);
|
|
if(pOne->IsCanEdit() && pOne->IsView())
|
|
GetView()->Select(pos);
|
|
else
|
|
GetDoc()->EnableDefaultTool();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
delete m_pNet;
|
|
m_pNet=NULL;
|
|
GetDoc()->EnableDefaultTool();
|
|
}
|
|
*/
|
|
}
|
|
|
|
void NItem::CItemEditNet::CreateFrame(CNet* pNet)
|
|
{
|
|
CFrame* pFrame=new CFrame();
|
|
CItemEditFrame item(GetDoc());
|
|
COLORREF col=color;
|
|
if(item.CreateFrame(*pFrame, pNet, col))
|
|
{
|
|
POSITION pos=item.AddElement(pFrame,DOUBLEFOX_FRAME);
|
|
GetDoc()->GetDraw()->SetElementColor(pos,item.color);
|
|
//Select(pos);
|
|
}
|
|
else
|
|
delete pFrame;
|
|
}
|
|
|
|
/*
|
|
BOOL CItemEditNet::InitPropertyGrid(CXTPPropertyGrid& grid)
|
|
{
|
|
BOOL brt=FALSE;
|
|
if(this->IsEditState())
|
|
{
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
color=pOne->color;
|
|
CNet* pValue=(CNet*)pOne->GetValue();
|
|
brt=InitPropertyGrid(grid,pValue);
|
|
}
|
|
else if(m_pNet)
|
|
brt=InitPropertyGrid(grid,m_pNet);
|
|
|
|
CItem::InitPropertyGrid(grid);
|
|
return brt;
|
|
}
|
|
|
|
BOOL CItemEditNet::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
{
|
|
if(this->IsEditState())
|
|
{
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CNet* pValue=(CNet*)pOne->GetValue();
|
|
return OnGridItemChangeValue(pItem,pValue);
|
|
}
|
|
return OnGridItemChangeValue(pItem,m_pNet);
|
|
}
|
|
|
|
BOOL CItemEditNet::InitPropertyGrid(CXTPPropertyGrid& grid, CNet* pValue)
|
|
{
|
|
if(pValue==NULL) return FALSE;
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
CXTPPropertyGridItem* pItem;
|
|
CString strFormat=GetFloatFormatString();
|
|
|
|
GetDisplayIdea(pValue);
|
|
GetMarkText(pValue);
|
|
|
|
//网格//IDS_STRING_NET//经纬网
|
|
pItem=grid.AddCategory(IDS_STRING_NET); ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
ItemAdd.AddItemSize8(IDS_GI_GRID_STEP_GRID, pValue->m_step, NULL, IDS_GI_NET_STEP_LONGITUDE, IDS_GI_NET_STEP_LATITUDE);
|
|
ItemAdd.AddItemCombo(IDS_GI_NET_VIEW_IDEA, IDS_GI_NET_VIEW_COMBO, DisplayIdea,&DisplayIdea);
|
|
ItemAdd.AddItemDouble(IDS_GI_NET_SCALE, pValue->scale, strFormat, NULL); //刻度
|
|
ItemAdd.AddItemColor(IDS_GI_COLOR, color, NULL);
|
|
|
|
//文字
|
|
pItem=grid.AddCategory(IDS_STRING_Text); ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
m_szText = GetUnitMode().toPrintUnit(pValue->m_szText);
|
|
ItemAdd.AddItemUnitDouble(IDS_STRING_TEXT_HEIGHT, GetUnit(), m_szText.cy, strFormat, &m_szText.cy);
|
|
|
|
ItemAdd.AddItemCombo(IDS_GI_NET_MARK, IDS_GI_NET_MARK_COMBO, MarkText, &MarkText);
|
|
|
|
//高级设置
|
|
pItem=grid.AddCategory(IDS_STRING_SETTING); ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
ItemAdd.AddItemRect(IDS_GI_COORDINATE_RECT, *(CRect8*)pValue, NULL); //大地坐标范围
|
|
m_rect=pValue->GetRangeBL();
|
|
if(!GetDoc()->GetDraw()->GetProjection().IsEmpty()) ToDMS(m_rect);
|
|
CCustomItemRect* pRect=(CCustomItemRect*)ItemAdd.AddItemRect(IDS_GI_NET_RECT, m_rect,&m_rect);//经纬度范围
|
|
pRect->SetCaptionNetting();
|
|
pItem=ItemAdd.AddItemString(IDS_GI_NET_PROJECTION, GetDoc()->GetDraw()->GetProjection()); pItem->SetReadOnly(TRUE); //投影
|
|
|
|
//边框
|
|
return InitPropertyGrid_Frame(grid, pValue);
|
|
}
|
|
|
|
BOOL CItemEditNet::InitPropertyGrid_Frame(CXTPPropertyGrid& grid, CNet* pNet)
|
|
{
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(IDS_STRING_Frame);
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
CString strFormat=GetFloatFormatString();
|
|
|
|
CFrame* pFrame=pNet->GetOutFrame();
|
|
|
|
m_bShowOutFrame = pNet->IsHasOutFrame();
|
|
ItemAdd.AddItemBool(IDS_STRING_SHOW_FRAME, m_bShowOutFrame, &m_bShowOutFrame);
|
|
|
|
CString name;if(!pFrame->IsEmpty()) name=pFrame->GetName();
|
|
m_bBlackLine=pFrame->IsBlackLine();
|
|
pItem=ItemAdd.AddItemMark(IDS_GI_MARK_NAME, name, pFrame->pDraw); pItem->SetReadOnly(m_bBlackLine);
|
|
|
|
m_dThickness = GetUnitMode().toPrintUnit(pFrame->thickness);
|
|
ItemAdd.AddItemUnitDouble(IDS_GI_FRAME_THICKNESS, GetUnit(), m_dThickness, strFormat, &m_dThickness);
|
|
|
|
ItemAdd.AddItemBool(IDS_GI_FRAME_BLACK, m_bBlackLine, &m_bBlackLine);
|
|
|
|
m_colFrame=pNet->GetFrameColor();
|
|
ItemAdd.AddItemColor(IDS_STRING_COLOR, m_colFrame, &m_colFrame);
|
|
|
|
return TRUE;
|
|
}
|
|
*/
|
|
|
|
bool CItemEditNet::ChangeSetting(ItemEditNetData * pData, CNet* pNet)
|
|
{
|
|
if (pData == NULL || pNet == NULL)
|
|
return false;
|
|
|
|
m_bShowOutFrame = pData->isShowOutBorder;
|
|
pNet->EnableOutFrame(m_bShowOutFrame?true:false);
|
|
|
|
COLORREF color = RGB(pData->borderColorR, pData->borderColorG, pData->borderColorB);
|
|
m_colFrame = color;
|
|
pNet->SetFrameColor(m_colFrame);
|
|
|
|
m_bBlackLine = pData->blackOutterBorder;
|
|
pNet->GetOutFrame()->EnableBlackLine(m_bBlackLine);
|
|
pNet->GetOutFrame()->thickness = GetUnitMode().toRealUnit(pData->borderThickness);
|
|
|
|
return true;
|
|
//{
|
|
// CXTPPropertyGridItem* pp=FindItem(pItem,IDS_GI_MARK_NAME);
|
|
// if(pp)pp->SetReadOnly(m_bBlackLine);
|
|
//}
|
|
//case IDS_GI_MARK_NAME:
|
|
// {
|
|
// CString name=pItem->GetValue();
|
|
// CString txt=pNet->GetOutFrame()->GetName();
|
|
// if(name.CollateNoCase(txt)!=0)
|
|
// {
|
|
// AfxGetGlobalMark()->BackupMark();
|
|
// AfxGetGlobalMark()->SetMark(GetDoc()->GetDraw()->GetMark());
|
|
// pNet->GetOutFrame()->SetName(name);
|
|
// pNet->GetOutFrame()->PositionNew(0);
|
|
// AfxGetGlobalMark()->RestoreMark();
|
|
// }
|
|
// else
|
|
// bUpdate=FALSE;
|
|
// }
|
|
// bUpdate=TRUE;
|
|
// break;
|
|
}
|
|
|
|
/*
|
|
BOOL CItemEditNet::OnGridItemChangeValue(CXTPPropertyGridItem* pItem, CNet* pValue)
|
|
{
|
|
if(pValue==NULL) return FALSE;
|
|
|
|
COne* pOne=NULL;
|
|
if(IsEditState()) pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
|
|
BOOL bUpdate=FALSE;
|
|
switch(pItem->GetID())
|
|
{
|
|
case IDS_GI_COLOR:
|
|
color=atol(pItem->GetValue());;
|
|
if(pOne) pOne->color=color;
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_GRID_STEP_GRID:
|
|
{
|
|
CSize8 sz=((CCustomItemPoint*)pItem)->GetValuePoint();
|
|
pValue->SetStep(sz);
|
|
}
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_NET_SCALE:
|
|
pValue->scale=((CXTPPropertyGridItemDouble*)pItem)->GetDouble();
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_STRING_TEXT_HEIGHT:
|
|
pValue->m_szText.cy = GetUnitMode().toRealUnit(m_szText.cy);
|
|
pValue->m_szText.cx=pValue->m_szText.cy*0.4;
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_NET_RECT:
|
|
{
|
|
//转换为分
|
|
CRect8 rt=m_rect;
|
|
if(!GetDoc()->GetDraw()->GetProjection().IsEmpty())
|
|
{
|
|
ToDegree(rt);
|
|
rt.left*=60;
|
|
rt.bottom*=60;
|
|
rt.right*=60;
|
|
rt.top*=60;
|
|
pValue->ChangeToXY_M(rt.left, rt.bottom);
|
|
pValue->ChangeToXY_M(rt.right, rt.top);
|
|
}
|
|
*(CRect8*)pValue=rt;
|
|
{
|
|
CCustomItemRect* pp=(CCustomItemRect*)((CXTPPropertyGridView*)(pItem->GetGrid()))->GetPropertyGrid()->FindItem(IDS_GI_COORDINATE_RECT);
|
|
rt.NormalizeRect();
|
|
if(pp)pp->SetRectValue(rt);
|
|
}
|
|
pValue->ClearCurve();
|
|
}
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_COORDINATE_RECT:
|
|
*(CRect8*)pValue=((CCustomItemRect*)pItem)->GetValueRect8();
|
|
{
|
|
CCustomItemRect* pp=(CCustomItemRect*)((CXTPPropertyGridView*)(pItem->GetGrid()))->GetPropertyGrid()->FindItem(IDS_GI_NET_RECT);
|
|
m_rect=pValue->GetRangeBL();
|
|
if(pp)pp->SetRectValue(m_rect);
|
|
}
|
|
pValue->ClearCurve();
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_NET_VIEW_IDEA:
|
|
SetDisplayIdea(pValue);
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_NET_MARK:
|
|
SetMarkText(pValue);
|
|
bUpdate=TRUE;
|
|
break;
|
|
default:
|
|
bUpdate=OnGridItemChangeValue_Frame(pItem, pValue);
|
|
break;
|
|
}
|
|
return bUpdate | CItem::OnGridItemChangeValue(pItem);
|
|
}
|
|
*/
|
|
|
|
void CItemEditNet::GetDisplayIdea(CNet* pValue)
|
|
{
|
|
switch(pValue->GetDisplayMode())
|
|
{
|
|
default:
|
|
case CNet::showLine: DisplayIdea=0; break;
|
|
case CNet::showCrossPoint: DisplayIdea=1; break;
|
|
case CNet::showNull: DisplayIdea=2; break;
|
|
}
|
|
}
|
|
|
|
void CItemEditNet::SetDisplayIdea(CNet* pValue)
|
|
{
|
|
switch(DisplayIdea)
|
|
{
|
|
default:
|
|
case 0: pValue->SetDisplayMode(CNet::showLine); break;//显示曲线
|
|
case 1: pValue->SetDisplayMode(CNet::showCrossPoint); break;//显示交点
|
|
case 2: pValue->SetDisplayMode(CNet::showNull); break;//显示为空1
|
|
}
|
|
}
|
|
|
|
void CItemEditNet::GetMarkText(CNet* pValue)
|
|
{
|
|
switch(pValue->GetSideMode())
|
|
{
|
|
default:
|
|
case CNet::markAllSide: MarkText=0; break;//所有边
|
|
case CNet::markLeftTop: MarkText=1; break;//左边+上边
|
|
case CNet::markTopRight: MarkText=2; break;//上边+右边
|
|
case CNet::markRightBottom: MarkText=3; break;//右边+下边
|
|
case CNet::markBottomLeft: MarkText=4; break;//下边+左边
|
|
}
|
|
}
|
|
|
|
void CItemEditNet::SetMarkText(CNet* pValue)
|
|
{
|
|
switch(MarkText)
|
|
{
|
|
default:
|
|
case 0: pValue->SetSideMode(CNet::markAllSide); break;
|
|
case 1: pValue->SetSideMode(CNet::markLeftTop); break;
|
|
case 2: pValue->SetSideMode(CNet::markTopRight); break;
|
|
case 3: pValue->SetSideMode(CNet::markRightBottom); break;
|
|
case 4: pValue->SetSideMode(CNet::markBottomLeft); break;
|
|
}
|
|
}
|
|
|
|
void CItemEditNet::GetTextFormat(CNet* pValue)
|
|
{
|
|
switch(pValue->GetTextMode())
|
|
{
|
|
case CNet::textGeography: TextFormat=0; break;
|
|
case CNet::textMath: TextFormat=1; break;
|
|
case CNet::textGeography1: TextFormat=2; break;
|
|
default:
|
|
case CNet::textGeography2: TextFormat=3; break;
|
|
}
|
|
}
|
|
|
|
void CItemEditNet::SetTextFormat(CNet* pValue)
|
|
{
|
|
switch(TextFormat)
|
|
{
|
|
case 0: pValue->SetTextMode(CNet::textGeography); break;//地理
|
|
case 1: pValue->SetTextMode(CNet::textMath); break;//数学
|
|
case 2: pValue->SetTextMode(CNet::textGeography1); break;//地理1
|
|
default:
|
|
case 3: pValue->SetTextMode(CNet::textGeography2); break;//地理2(all)
|
|
}
|
|
}
|
|
|
|
void NItem::CItemEditNet::ToDMS(CRect8& rect)
|
|
{
|
|
rect.left=AfxGetPublicFunction()->ToDMS(rect.left);
|
|
rect.top=AfxGetPublicFunction()->ToDMS(rect.top);
|
|
rect.right=AfxGetPublicFunction()->ToDMS(rect.right);
|
|
rect.bottom=AfxGetPublicFunction()->ToDMS(rect.bottom);
|
|
}
|
|
|
|
void NItem::CItemEditNet::ToDegree(CRect8& rect) //由度分秒转换为度格式
|
|
{
|
|
rect.left=AfxGetPublicFunction()->ToDegree(rect.left);
|
|
rect.top=AfxGetPublicFunction()->ToDegree(rect.top);
|
|
rect.right=AfxGetPublicFunction()->ToDegree(rect.right);
|
|
rect.bottom=AfxGetPublicFunction()->ToDegree(rect.bottom);
|
|
}
|