83aa8a1776cee32b3346da8ce6126ed4d784d8cc
[occt.git] / samples / mfc / standard / 06_Ocaf / src / NewCylDlg.cpp
1 // NewCylDlg.cpp : implementation file
2 //
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #undef THIS_FILE
7 static char THIS_FILE[] = __FILE__;
8 #endif
9
10 #include "stdafx.h"
11
12 #include "NewCylDlg.h"
13
14 //#include "OcafApp.h"
15
16 /////////////////////////////////////////////////////////////////////////////
17 // CNewCylDlg dialog
18
19 CNewCylDlg::CNewCylDlg(CWnd* pParent /*=NULL*/)
20         : CDialog(CNewCylDlg::IDD, pParent)
21 {
22         //{{AFX_DATA_INIT(CNewCylDlg)
23         m_h = 20.0;
24         m_Name = _T("Cylinder");
25         m_r = 10.0;
26         m_x = 0.0;
27         m_y = 0.0;
28         m_z = 0.0;
29         //}}AFX_DATA_INIT
30 }
31
32 void CNewCylDlg::DoDataExchange(CDataExchange* pDX)
33 {
34         CDialog::DoDataExchange(pDX);
35         //{{AFX_DATA_MAP(CNewCylDlg)
36         DDX_Text(pDX, IDC_H, m_h);
37         DDX_Text(pDX, IDC_NAME, m_Name);
38         DDX_Text(pDX, IDC_R, m_r);
39         DDX_Text(pDX, IDC_X, m_x);
40         DDX_Text(pDX, IDC_Y, m_y);
41         DDX_Text(pDX, IDC_Z, m_z);
42         //}}AFX_DATA_MAP
43 }
44
45
46 BEGIN_MESSAGE_MAP(CNewCylDlg, CDialog)
47         //{{AFX_MSG_MAP(CNewCylDlg)
48         //}}AFX_MSG_MAP
49 END_MESSAGE_MAP()
50
51 /////////////////////////////////////////////////////////////////////////////
52 // CNewCylDlg message handlers
53
54 void CNewCylDlg::OnOK() 
55 {
56         UpdateData(TRUE);
57         if( (m_h<=Precision::Confusion()) || (m_r<=Precision::Confusion()) )
58         {
59                 MessageBox("Radius and height of a cylinder should be srictly positives.", "New box",MB_ICONEXCLAMATION);
60                 return;
61         }
62         
63         CDialog::OnOK();
64 }
65
66 void CNewCylDlg::InitFields(Standard_Real x, Standard_Real y, Standard_Real z, Standard_Real r, Standard_Real h, const TCollection_ExtendedString &Name)
67 {
68         m_x=x;
69         m_y=y;
70         m_z=z;
71         m_r=r;
72         m_h=h;
73         TCollection_AsciiString AsciiName(Name);
74         m_Name=AsciiName.ToCString();
75 }