📄 vcexampledlg.cpp
字号:
// VCExampleDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VCExample.h"
#include "VCExampleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCExampleDlg dialog
CVCExampleDlg::CVCExampleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVCExampleDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVCExampleDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVCExampleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVCExampleDlg)
DDX_Control(pDX, IDC_CHECK3, m_ShowValueCheck);
DDX_Control(pDX, IDC_EDIT12, m_SmoothParaEdit);
DDX_Control(pDX, IDC_EDIT11, m_RandomPointCountEdit);
DDX_Control(pDX, IDC_CHECK2, m_RestrictCheck);
DDX_Control(pDX, IDC_CHECK1, m_InterposeCheck);
DDX_Control(pDX, IDC_STATICPIC2, m_Picture2);
DDX_Control(pDX, IDC_EDIT3, m_StepEdit);
DDX_Control(pDX, IDC_EDIT8, m_PolygonPropertyEdit);
DDX_Control(pDX, IDC_EDIT10, m_m_FlashBorderColorEdit);
DDX_Control(pDX, IDC_EDIT9, m_FlashFillColorEdit);
DDX_Control(pDX, IDC_LIST1, m_PolyList);
DDX_Control(pDX, IDC_EDIT7, m_YInterceptEdit);
DDX_Control(pDX, IDC_EDIT6, m_YSlopeEdit);
DDX_Control(pDX, IDC_EDIT5, m_XInterceptEdit);
DDX_Control(pDX, IDC_EDIT4, m_XSlopeEdit);
DDX_Control(pDX, IDC_EDIT2, m_Col);
DDX_Control(pDX, IDC_EDIT1, m_Row);
DDX_Control(pDX, IDC_STATICPIC, m_Picture1);
DDX_Control(pDX, IDC_CONTOUROCXCTRL1, ContourOCX1);
DDX_Control(pDX, IDC_COMMONDIALOG1, m_SaveDialog);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVCExampleDlg, CDialog)
//{{AFX_MSG_MAP(CVCExampleDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCExampleDlg message handlers
BOOL CVCExampleDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CButton*pButton=(CButton*)this->GetDlgItem(IDC_RADIO1);//+pDoc->DisplayConfigue.ValueType);
pButton->SetCheck(1);
pButton=(CButton*)this->GetDlgItem(IDC_RADIO4);
pButton->SetCheck(1);
OnCheck1() ;
m_Row.SetWindowText("8");
m_Col.SetWindowText("9");
this->m_StepEdit.SetWindowText("1");
this->m_XSlopeEdit.SetWindowText("1");
this->m_XInterceptEdit.SetWindowText("0");
this->m_YSlopeEdit.SetWindowText("1");
this->m_YInterceptEdit.SetWindowText("0");
this->m_FlashFillColorEdit.SetWindowText("7777777");
this->m_m_FlashBorderColorEdit.SetWindowText("888888");
this->m_RandomPointCountEdit.SetWindowText("99");
this->m_SmoothParaEdit.SetWindowText("2");
pButton=(CButton*)this->GetDlgItem(IDC_RADIO6);
pButton->SetCheck(1);
pButton=(CButton*)this->GetDlgItem(IDC_RADIO9);
pButton->SetCheck(1);
m_ShowValueCheck.SetCheck(0);
return TRUE; // return TRUE unless you set the focus to a control
}
void CVCExampleDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVCExampleDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
template<class T>
T EditToValue(CEdit*pControl)
{
CString s;
pControl->GetWindowText(s);
double value(atof(s));
return (T)value;
}
HCURSOR CVCExampleDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int ValidateData(const float&value)
{
if(value<0) return 0;
if(value>254) return 254;
return int(value);
}
void CVCExampleDlg::DrawContourSurface()
{
long polygonCount, pointCount;
float minValue, maxValue , minArea, maxArea;
CString s;
ContourOCX1.GetPolygonCount(&polygonCount);
if(polygonCount<1)
return;
ContourOCX1.ResetPolyPostion(EditToValue<float>(&m_XSlopeEdit),EditToValue<float>(&m_XInterceptEdit),
EditToValue<float>(&m_YSlopeEdit),EditToValue<float>(&m_YInterceptEdit));
for(long int i= 0;i<polygonCount;i++)
{
ContourOCX1.GetPolygonPointCountValueArea(i, &pointCount, &minValue, &maxValue, &maxArea, &minArea);
long int color =ValidateData(minValue * 20);
ContourOCX1.ResetOnePolygonColor(i, color, 255 - color);
s.Format("%d",i);
m_PolyList.AddString(s);
}
HDC dc=::GetDC(m_Picture2.m_hWnd );
ContourOCX1.DrawAllPolygons((long)dc);
::ReleaseDC(m_Picture2.m_hWnd,dc);
}
void CVCExampleDlg::DrawContourLines()///画等高线
{
//'''''''''''''''''''''''''''''
long linecount,PointCount;
double PreX, PreY, CurX, CurY, z;
FILE *pfile;
pfile = fopen("等高线上的点.txt","a+");
CString str;
CDC *pDC=m_Picture1.GetDC();
ContourOCX1.GetLineCount(&linecount);
for(long int i = 0 ;i< linecount ;i++)
{
ContourOCX1.GetCtrlPointCount(i, &PointCount);
for(long int j = 0 ;j<PointCount;j++)
{
ContourOCX1.GetCtrlPoint(i, j, &CurX, &CurY, &z);
//取出等高线上的点,保存到文本
str.Format("%f %f %f",CurX,CurY,z);
fprintf(pfile,"%s\n",str);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -