0027756: Visualization - add Draw() method taking Graphic3d_Group to tools Prs3d_Arro...
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / ZCueingDlg.cpp
CommitLineData
7fd59977 1// ZCueingDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "Viewer3dApp.h"
6#include "Viewer3dDoc.h"
7#include "ZCueingDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// ZCueingDlg dialog
17
18
92efcf78 19ZCueingDlg::ZCueingDlg(Handle(V3d_View) Current_V3d_View, CViewer3dDoc* pDoc, CWnd* pParent /*=NULL*/)
7fd59977 20 : CDialog(ZCueingDlg::IDD, pParent)
21{
22 //{{AFX_DATA_INIT(ZCueingDlg)
23 myCurrent_V3d_View = Current_V3d_View;
24 myDoc=pDoc;
25 m_Cueing = FALSE;
26 m_ZCueingDepth = 0.0;
27 m_ZCueingWidth = 0.0;
28 //}}AFX_DATA_INIT
29}
30
31
32void ZCueingDlg::DoDataExchange(CDataExchange* pDX)
33{
34 CDialog::DoDataExchange(pDX);
35 //{{AFX_DATA_MAP(ZCueingDlg)
36 DDX_Control(pDX, IDC_SLIDER_ZCUEINGWIDTH, m_ZCueingWidthSlidCtrl);
37 DDX_Control(pDX, IDC_SLIDER_ZCUEINGDEPTH, m_ZCueingDepthSlidCtrl);
38 DDX_Check(pDX, IDC_CHECK_CUEINGONOFF, m_Cueing);
39 DDX_Text(pDX, IDC_EDIT_ZCUEINGDEPTH, m_ZCueingDepth);
40 DDV_MinMaxDouble(pDX, m_ZCueingDepth, -1500., 1500.);
41 DDX_Text(pDX, IDC_EDIT_ZCUEINGWIDTH, m_ZCueingWidth);
42 DDV_MinMaxDouble(pDX, m_ZCueingWidth, 0., 1500.);
43 //}}AFX_DATA_MAP
44}
45
46BOOL ZCueingDlg::OnInitDialog()
47{
48 CDialog::OnInitDialog();
49
50 Quantity_Length Depth, Width;
51
52// Getting the ZCueing state (ON or OFF) and check (or not) the check button
53 if(myCurrent_V3d_View->ZCueing(Depth, Width))
54 m_Cueing=TRUE;
55 else
56 m_Cueing=FALSE;
57
58// Setting the m_ZCueingWidth value at ZCueing Width
59 m_ZCueingWidth=Width;
60 m_ZCueingWidthSlidCtrl.SetRange(0, 1500, TRUE);
61// Setting the m_ZCueingWidthSlidCtrl position at floor(Width) value (because slider position is an integer)
62 m_ZCueingWidthSlidCtrl.SetPos( (int) floor(Width));
63
64// Setting the m_ZCueingWidth value at ZCueing Width
65 m_ZCueingDepth=Depth;
66 m_ZCueingDepthSlidCtrl.SetRange(-1500, 1500, TRUE);
67// Setting the m_ZCueingDepthSlidCtrl position at floor(Depth) value (because slider position is an integer)
68 m_ZCueingDepthSlidCtrl.SetPos( (int) floor(Depth));
69
70 UpdateData(FALSE);
71
72 return TRUE; // return TRUE unless you set the focus to a control
73 // EXCEPTION: OCX Property Pages should return FALSE
74}
75
76BEGIN_MESSAGE_MAP(ZCueingDlg, CDialog)
77 //{{AFX_MSG_MAP(ZCueingDlg)
78 ON_BN_CLICKED(IDC_CHECK_CUEINGONOFF, OnCheckCueingonoff)
79 ON_EN_CHANGE(IDC_EDIT_ZCUEINGDEPTH, OnChangeEditZcueingdepth)
80 ON_EN_CHANGE(IDC_EDIT_ZCUEINGWIDTH, OnChangeEditZcueingwidth)
81 ON_WM_HSCROLL()
82 //}}AFX_MSG_MAP
83END_MESSAGE_MAP()
84
85/////////////////////////////////////////////////////////////////////////////
86// ZCueingDlg message handlers
87
88void ZCueingDlg::OnCheckCueingonoff()
89{
90 Quantity_Length Depth, Width;
91 UpdateData(TRUE);
92
93 if(m_Cueing)
94 {
95 if(!myCurrent_V3d_View->ZCueing(Depth, Width))
96// Setting the ZCueing on if it's not yet
97 myCurrent_V3d_View->SetZCueingOn();
98 }
99 else
100 {
101 if(myCurrent_V3d_View->ZCueing(Depth, Width))
102// Setting the ZCueing off if it's not yet
103 myCurrent_V3d_View->SetZCueingOff();
104 }
105
106 myCurrent_V3d_View->Update();
107
108
109 TCollection_AsciiString Message("\
110if(!myCurrent_V3d_View->ZCueing(Depth, Width));\n\
111 myCurrent_V3d_View->SetZCueingOn();\n\
112else\n\
113 myCurrent_V3d_View->SetZCueingOff();\n\
114\n\
115myCurrent_V3d_View->Update();\n\
116 ");
117
118 // Update The Result Message Dialog
119 myDoc->UpdateResultMessageDlg("SetZCueingWidth",Message);
120}
121
122void ZCueingDlg::OnChangeEditZcueingdepth()
123{
124 UpdateData(TRUE);
125
126// Setting the m_ZCueingDepthSlidCtrl position at floor(m_ZCueingDepth) value (because slider position is an integer)
127 m_ZCueingDepthSlidCtrl.SetPos( (int) floor(m_ZCueingDepth));
128// Setting the ZCueing depth at m_ZCueingDepth value
129 myCurrent_V3d_View->SetZCueingDepth( (const Quantity_Length) m_ZCueingDepth);
130
131 myCurrent_V3d_View->Update();
132
133 TCollection_AsciiString Message("\
134myCurrent_V3d_View->SetZCueingDepth( (const Quantity_Length) m_ZCueingDepth);\n\
135\n\
136myCurrent_V3d_View->Update();\n\
137 ");
138
139 // Update The Result Message Dialog
140 myDoc->UpdateResultMessageDlg("SetZCueingDepth",Message);
141}
142
143void ZCueingDlg::OnChangeEditZcueingwidth()
144{
145 UpdateData(TRUE);
146
147 if(m_ZCueingWidth<=0)
148 {
149 m_ZCueingWidth=1;
150 UpdateData(FALSE);
151 }
152
153// Setting the m_ZCueingWidthSlidCtrl position at floor(m_ZCueingWidth) value (because slider position is an integer)
154 m_ZCueingWidthSlidCtrl.SetPos( (int) floor(m_ZCueingWidth));
155// Setting the ZCueing width at m_ZCueingWidth value
156 myCurrent_V3d_View->SetZCueingWidth( (const Quantity_Length) m_ZCueingWidth);
157
158 myCurrent_V3d_View->Update();
159
160 TCollection_AsciiString Message("\
161myCurrent_V3d_View->SetZCueingWidth( (const Quantity_Length) m_ZCueingWidth);\n\
162\n\
163myCurrent_V3d_View->Update();\n\
164 ");
165
166 // Update The Result Message Dialog
167 myDoc->UpdateResultMessageDlg("SetZCueingWidth",Message);
168}
169
170void ZCueingDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
171{
172// Setting the m_ZCueingDepth value at m_ZCueingDepthSlidCtrl position
173 m_ZCueingDepth = m_ZCueingDepthSlidCtrl.GetPos();
174// Setting the m_ZCueingWidth value at m_ZCueingWidthSlidCtrl position
175 m_ZCueingWidth = m_ZCueingWidthSlidCtrl.GetPos();
176
177 if(m_ZCueingWidth<=0)
178 {
179 m_ZCueingWidth=1;
180 m_ZCueingWidthSlidCtrl.SetPos( 1 );
181 }
182
183 UpdateData(FALSE);
184
185// Setting the ZCueing depth at m_ZCueingDepth value
186 myCurrent_V3d_View->SetZCueingDepth( (const Quantity_Length) m_ZCueingDepth);
187// Setting the ZCueing width at m_ZCueingWidth value
188 myCurrent_V3d_View->SetZCueingWidth( (const Quantity_Length) m_ZCueingWidth);
189 myCurrent_V3d_View->Update();
190
191 TCollection_AsciiString Message("\
192myCurrent_V3d_View->SetZCueingDepth( (const Quantity_Length) m_ZCueingDepth);\n\
193\n\
194myCurrent_V3d_View->SetZCueingWidth( (const Quantity_Length) m_ZCueingWidth);\n\
195\n\
196myCurrent_V3d_View->Update();\n\
197 ");
198
199 // Update The Result Message Dialog
200 myDoc->UpdateResultMessageDlg("SetZCueingDepth/SetZCueingWidth",Message);
201
202 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
203}
204