qdlgptattset.cpp
资源名称:QGIS.rar [点击查看]
上传用户:oybseng
上传日期:2015-04-27
资源大小:7831k
文件大小:5k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // qdlgptattset.cpp : implementation file
- //
- #include "stdafx.h"
- #include "..qgis.h"
- #include "qdlgptattset.h"
- #include "..QObjectsincludeQLayerObj.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CQDlgPtAttSet dialog
- CQDlgPtAttSet::CQDlgPtAttSet(CWnd* pParent /*=NULL*/)
- : CDialog(CQDlgPtAttSet::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CQDlgPtAttSet)
- m_fXPt = 0.0;
- m_fYPt = 0.0;
- m_fElevationPt = 0.0;
- m_bReset = FALSE;
- m_lPtID = 0;
- m_szPtLyrName = _T("");
- m_szPtName = _T("");
- m_pWndDC = NULL;
- m_nShowPt = -1;
- //}}AFX_DATA_INIT
- }
- CQDlgPtAttSet::CQDlgPtAttSet(CQMapObj * pMap,CQPointObj * pPoint,CWnd* pParent /* = NULL */)
- : CDialog(CQDlgPtAttSet::IDD,pParent)
- {
- if(!pMap)return;
- if(!pPoint)return;
- m_pPoint = pPoint; //让指针指向当前的点对象
- m_pMap = pMap;
- m_pWndDC = NULL;
- m_bReset = FALSE;
- m_nShowPt = 0;
- m_szOldPtName = m_pPoint->GetObjName();
- m_pPoint->GetPointPos(m_fOldX,m_fOldY);
- }
- void CQDlgPtAttSet::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CQDlgPtAttSet)
- DDX_Text(pDX, IDC_EDIT_X_COOR_PT_ATTSET_DLG, m_fXPt);
- DDX_Text(pDX, IDC_EDIT_Y_COOR_PT_ATTSET_DLG, m_fYPt);
- DDX_Text(pDX, IDC_EDIT_ELEVATION_PT_ATTSET_DLG, m_fElevationPt);
- DDX_Check(pDX, IDC_CHECK_PT_COOR_PTATT_DLG, m_bReset);
- DDX_Text(pDX, IDC_EDIT_ID_PT_ATTSET_DLG, m_lPtID);
- DDX_Text(pDX, IDC_EDIT_LAYER_NAME_PT_ATTSET_DLG, m_szPtLyrName);
- DDX_Text(pDX, IDC_EDIT_NAME_PT_ATTSET_DLG, m_szPtName);
- DDX_Radio(pDX, IDC_RADIO_SHOW_PT_DLG, m_nShowPt);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CQDlgPtAttSet, CDialog)
- //{{AFX_MSG_MAP(CQDlgPtAttSet)
- ON_BN_CLICKED(IDC_CHECK_PT_COOR_PTATT_DLG, OnCheckPtCoorPtattDlg)
- ON_BN_CLICKED(IDC_STATIC_COLOR_SHOW_CLICK_PT_DLG, OnStaticColorShowClickPtDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CQDlgPtAttSet message handlers
- BOOL CQDlgPtAttSet::OnInitDialog()
- {
- CDialog::OnInitDialog();
- UpdateData(TRUE);
- m_pPoint->GetPointPos(m_fXPt,m_fYPt);
- m_fElevationPt = m_pPoint->GetPtElevation(); // 获取点的高程
- m_ptColor = m_pPoint->GetObjBrushColor();
- //图层名称的显示
- long lLayerID = m_pPoint->GetObjLayerID();
- CQLayerObj * pLayer = m_pMap->FindLayer(lLayerID);
- m_szPtLyrName = pLayer->GetLayerName();
- m_szOldLyrName = m_szPtLyrName; //旧的图层名称
- m_lPtID = m_pPoint->GetObjID();
- m_szPtName = m_pPoint->GetObjName();
- UpdateData(FALSE);
- EnableCtl(FALSE);
- m_pWndDC = GetDlgItem(IDC_STATIC_COLOR_SHOW_CLICK_PT_DLG)->GetDC();
- CBrush brush(m_ptColor);
- CBrush * pOldBrush = m_pWndDC->SelectObject(&brush);
- CRect recttemp;
- GetDlgItem(IDC_STATIC_COLOR_SHOW_CLICK_PT_DLG)->GetClientRect(&recttemp);
- m_pWndDC->Rectangle(recttemp);
- m_pWndDC->SelectObject(pOldBrush);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CQDlgPtAttSet::EnableCtl(BOOL bEnable)
- {
- GetDlgItem(IDC_EDIT_X_COOR_PT_ATTSET_DLG)->EnableWindow(bEnable);
- GetDlgItem(IDC_EDIT_Y_COOR_PT_ATTSET_DLG)->EnableWindow(bEnable);
- }
- void CQDlgPtAttSet::OnCheckPtCoorPtattDlg()
- {
- // TODO: Add your control notification handler code here
- m_bReset = !m_bReset; //初始值假
- EnableCtl(m_bReset);
- }
- void CQDlgPtAttSet::OnStaticColorShowClickPtDlg()
- {
- // TODO: Add your control notification handler code here
- CColorDialog clDlg;
- clDlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT;
- clDlg.m_cc.rgbResult = m_ptColor;
- m_pPoint->SetObjBrushColor(m_ptColor);
- m_pPoint->SetObjPenColor(m_ptColor);
- CRect rect;
- GetDlgItem(IDC_STATIC_COLOR_SHOW_CLICK_PT_DLG)->GetClientRect(&rect);
- if(clDlg.DoModal() == IDOK)
- {
- m_ptColor = clDlg.GetColor();
- CBrush brush(m_ptColor);
- CBrush * pOldBrush = m_pWndDC->SelectObject(&brush);
- m_pWndDC->Rectangle(rect);
- m_pWndDC->SelectObject(pOldBrush);
- m_pPoint->SetObjPenColor(m_ptColor);
- m_pPoint->SetObjBrushColor(m_ptColor);
- }
- }
- void CQDlgPtAttSet::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(TRUE);
- if(m_fXPt == 0.0 && m_fYPt == 0.0)
- {
- AfxMessageBox("该点对象的坐标有问题,请确认!");
- GetDlgItem(IDC_EDIT_X_COOR_PT_ATTSET_DLG)->SetFocus(); //设置焦点
- m_fXPt = m_fOldX;
- m_fYPt = m_fOldY;
- UpdateData(FALSE);
- return;
- }
- if(m_szPtName.IsEmpty())
- {
- AfxMessageBox("图元的名称不能为空!");
- GetDlgItem(IDC_EDIT_NAME_PT_ATTSET_DLG)->SetFocus(); //设置焦点供用户进行编辑
- m_szPtName = m_szOldPtName;
- UpdateData(FALSE);
- return;
- }
- if(m_szPtLyrName.IsEmpty())
- {
- AfxMessageBox("图元的图层名称不能为空!");
- GetDlgItem(IDC_EDIT_LAYER_NAME_PT_ATTSET_DLG)->SetFocus(); //设置焦点供用户进行编辑
- m_szPtLyrName = m_szOldLyrName;
- UpdateData(FALSE);
- return;
- }
- m_pPoint->SetObjName(m_szPtName);
- m_pPoint->SetPtElevation(m_fElevationPt);
- m_pPoint->SetPointPos(m_fXPt,m_fYPt);
- m_pPoint->SetObjHided(m_nShowPt);
- CDialog::OnOK();
- }