DlgLineAttSet.cpp
资源名称:QGIS.rar [点击查看]
上传用户:oybseng
上传日期:2015-04-27
资源大小:7831k
文件大小:5k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // DlgLineAttSet.cpp : implementation file
- //
- #include "stdafx.h"
- #include "..qgis.h"
- #include "DlgLineAttSet.h"
- #include "..QObjectsincludeQBaseObj.h"
- #include "..QObjectsincludeQLineObj.h"
- #include "..QObjectsincludeQLayerObj.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgLineAttSet dialog
- CDlgLineAttSet::CDlgLineAttSet(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgLineAttSet::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgLineAttSet)
- m_fLineWidth = 0.0;
- m_bLineShowPt = FALSE;
- m_lLineID = 0;
- m_szLineLayer = _T("");
- m_fLineLength = 0.0;
- m_szLineName = _T("");
- m_nLineClosed = -1;
- m_pLayerObj = NULL;
- m_pLineObj = NULL;
- m_nOpFlag = 2;
- //}}AFX_DATA_INIT
- }
- CDlgLineAttSet::CDlgLineAttSet(CQLayerObj * pLyrObj,int nOpflag /* = 2 */,CQLineObj * pLineObj /* = NULL */,CWnd * pParent /* = NULL */)
- : CDialog(CDlgLineAttSet::IDD,pParent)
- {
- m_nOpFlag = nOpflag;
- if(pLyrObj) m_pLayerObj = pLyrObj;
- if(pLineObj) m_pLineObj= pLineObj;
- if(m_pLineObj && m_pLayerObj)
- {
- if(m_pLineObj->GetObjLayerID() != m_pLayerObj->GetLayerID())
- return; // 假如选中的线条跟图层参数不是同一个 则返回
- }
- }
- void CDlgLineAttSet::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgLineAttSet)
- DDX_Control(pDX, IDC_COMBO_LINE_STYLE_NEW, m_ctLineStyle);
- DDX_Text(pDX, IDC_EDIT_LINE_WIDTH_QGIS, m_fLineWidth);
- DDV_MinMaxDouble(pDX, m_fLineWidth, 0., 20.);
- DDX_Check(pDX, IDC_CHECK_LINE_SHOWPT_QGIS, m_bLineShowPt);
- DDX_Text(pDX, IDC_EDIT_LINE_ID_QGIS, m_lLineID);
- DDX_Text(pDX, IDC_EDIT_LINE_LAYER_QGIS, m_szLineLayer);
- DDX_Text(pDX, IDC_EDIT_LINE_LENGTH_QGIS, m_fLineLength);
- DDX_Text(pDX, IDC_EDIT_LINE_NAME_QGIS, m_szLineName);
- DDX_Radio(pDX, IDC_RADIO_LINE_CLOSE_QGIS, m_nLineClosed);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgLineAttSet, CDialog)
- //{{AFX_MSG_MAP(CDlgLineAttSet)
- ON_BN_CLICKED(IDC_STATIC_COLOR_SHOW_QGIS, OnStaticColorShowQgis)
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgLineAttSet message handlers
- BOOL CDlgLineAttSet::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- UpdateData(TRUE);
- if(m_nOpFlag == 1 && m_pLineObj) //对选中的线对象进行操作
- {
- m_bLineShowPt = m_pLineObj->GetShowPointFlag();
- m_fLineLength = m_pLineObj->GetLineLength();
- m_fLineWidth = m_pLineObj->GetObjLineWidth();
- m_lLineID = m_pLineObj->GetObjID();
- m_nLineClosed = m_pLineObj->IsClosed()?0:1;
- m_szLineLayer = m_pLayerObj->GetLayerName();
- m_szLineName = m_pLineObj->GetObjName();
- m_crLine = m_pLineObj->GetObjPenColor();
- short m_b = GetBValue(m_crLine);
- short m_g = GetGValue(m_crLine);
- short m_r = GetRValue(m_crLine);
- m_nLineStyle = m_pLineObj->GetObjLineType();
- ((CComboBox *)GetDlgItem(IDC_COMBO_LINE_STYLE_NEW))->SetCurSel(m_nLineStyle);
- }
- else if(m_nOpFlag == 2 && m_pLayerObj) // 对图层进行设置
- {
- }
- GetDlgItem(IDC_EDIT_LINE_ID_QGIS)->EnableWindow(FALSE); //将该EDIT控件设置为只读属性
- GetDlgItem(IDC_EDIT_LINE_LAYER_QGIS)->EnableWindow(FALSE);
- InitComboBox();
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgLineAttSet::InitComboBox()
- {
- m_ctLineStyle.AddString("SOLID_LINE_________________");
- m_ctLineStyle.AddString("DASH_LINE_ _ _ _ _ _ _ _ _ ");
- m_ctLineStyle.AddString("DOT_LINE . . . . . . . . . ");
- m_ctLineStyle.AddString("DASHDOT_LINE_ . _ . _ . _ .");
- m_ctLineStyle.AddString("DASHDOTDOT_LINE_ .. _ .. _ ");
- m_ctLineStyle.AddString("NULL_LINE ");
- m_ctLineStyle.AddString("INSIDEFRAME_LINE ");
- m_ctLineStyle.AddString("GEOMETRIC_LINE ");
- m_ctLineStyle.AddString("COSMETIC_LINE ");
- m_ctLineStyle.AddString("ALTERNATE_LINE ");
- m_ctLineStyle.SetCurSel(0);
- }
- int CDlgLineAttSet::GetLineTypeFromCom()
- {
- m_nLineStyle = ((CComboBox *)GetDlgItem(IDC_COMBO_LINE_STYLE_NEW))->GetCurSel();
- return m_nLineStyle;
- }
- void CDlgLineAttSet::OnStaticColorShowQgis()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- CColorDialog dlg;
- dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT;
- //dlg.SetCurrentColor(RGB(m_r,m_g,m_b));
- if(dlg.DoModal() == IDOK)
- {
- m_crLine = dlg.GetColor();
- CDC * pDC = GetDlgItem(IDC_STATIC_COLOR_SHOW_QGIS)->GetDC();
- CBrush brush(m_crLine);
- CBrush * pOldBrush = pDC->SelectObject(&brush);
- CRect rectStatic;
- GetDlgItem(IDC_STATIC_COLOR_SHOW_QGIS)->GetClientRect(&rectStatic);
- pDC->Rectangle(rectStatic);
- pDC->SelectObject(pOldBrush);
- }
- UpdateData(FALSE);
- }
- void CDlgLineAttSet::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(TRUE);
- m_nLineStyle = m_ctLineStyle.GetCurSel();
- UpdateData(FALSE);
- CDialog::OnOK();
- }
- void CDlgLineAttSet::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- CRect rect;
- GetDlgItem(IDC_STATIC_COLOR_SHOW_QGIS)->GetWindowRect(&rect);
- // ClientToScreen(&rect);
- CBrush brush(m_crLine);
- CBrush * pOldBrush = dc.SelectObject(&brush);
- dc.Rectangle(rect);
- dc.SelectObject(pOldBrush);
- // Do not call CDialog::OnPaint() for painting messages
- }