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