0025269: Make parallel version of boolean operations avaible from DRAW
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / ZClippingDlg.cpp
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
12 static char THIS_FILE[] = __FILE__;
13 #endif
14
15 /////////////////////////////////////////////////////////////////////////////
16 // ZClippingDlg dialog
17
18 ZClippingDlg::ZClippingDlg(Handle_V3d_View Current_V3d_View, CViewer3dDoc* pDoc, CWnd* pParent /*=NULL*/)
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
30 void 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
44 BOOL ZClippingDlg::OnInitDialog() 
45 {
46         CDialog::OnInitDialog();
47         
48 // Initializing the ComboBox
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");
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
84 BEGIN_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
91 END_MESSAGE_MAP()
92
93 /////////////////////////////////////////////////////////////////////////////
94 // ZClippingDlg message handlers
95
96 void 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("\
108 myCurrent_V3d_View->SetZClippingDepth( (const Quantity_Length) m_ZClippingDepth);\n\
109 \n\
110 myCurrent_V3d_View->Update();\n\
111   ");
112
113   // Update The Result Message Dialog
114         myDoc->UpdateResultMessageDlg("SetZClippingDepth",Message);
115 }
116
117 void 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("\
136 myCurrent_V3d_View->SetZClippingWidth( (const Quantity_Length) m_ZClippingWidth);\n\
137 \n\
138 myCurrent_V3d_View->Update();\n\
139   ");
140
141   // Update The Result Message Dialog
142         myDoc->UpdateResultMessageDlg("SetZClippingDepth",Message);
143 }
144
145 void 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("\
152 myCurrent_V3d_View->SetZClippingType(V3d_TypeOfZclipping myTypeOfZclipping);\n\
153 \n\
154 myCurrent_V3d_View->Update();\n\
155   ");
156
157   // Update The Result Message Dialog
158         myDoc->UpdateResultMessageDlg("SetZClippingType",Message);
159 }
160
161 void 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("\
183 myCurrent_V3d_View->SetZClippingWidth( (const Quantity_Length) m_ZClippingWidth);\n\
184 \n\
185 myCurrent_V3d_View->SetZClippingDepth( (const Quantity_Length) m_ZClippingDepth);\n\
186 \n\
187 myCurrent_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