0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / samples / mfc / standard / Common / AISDialogs.cpp
1 // AISDialogs.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5
6 #include "AISDialogs.h"
7
8 #define DEFAULT_DEVIATIONCOEFFICIENT 0.001
9 #define DEFAULT_DCBIG 0.005
10 #define DEFAULT_DCVBIG 0.01
11 #define DEFAULT_DCSMALL 0.0002
12 #define DEFAULT_DCVSMALL 0.00004
13 #define DEFAULT_COLOR Quantity_NOC_CYAN1
14 #define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
15 #define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
16 #define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW
17
18
19 /////////////////////////////////////////////////////////////////////////////
20 // CAISNbrIsosDialog dialog
21
22 //CAISNbrIsosDialog::CAISNbrIsosDialog(Handle(AIS_InteractiveContext) CurrentIC,
23 //                                                                       CWnd* pParent /*=NULL*/)
24 //      : CDialog(CAISNbrIsosDialog::IDD, pParent)
25 /*
26 {
27         //{{AFX_DATA_INIT(CAISNbrIsosDialog)
28         m_Isosu = 0;
29         m_Isosv = 0;
30         //}}AFX_DATA_INIT
31
32         myCurrentIC = CurrentIC;
33         Handle (Prs3d_Drawer) ICDrawer = myCurrentIC->DefaultDrawer();
34     m_Isosu = ICDrawer->UIsoAspect()->Number();
35     m_Isosv = ICDrawer->VIsoAspect()->Number();
36
37 }
38
39
40 void CAISNbrIsosDialog::DoDataExchange(CDataExchange* pDX)
41 {
42         CDialog::DoDataExchange(pDX);
43         //{{AFX_DATA_MAP(CAISNbrIsosDialog)
44         DDX_Text(pDX, IDC_EDITAISISOSU, m_Isosu);
45         DDX_Text(pDX, IDC_EDITAISISOSV, m_Isosv);
46         //}}AFX_DATA_MAP
47 }
48
49
50 BEGIN_MESSAGE_MAP(CAISNbrIsosDialog, CDialog)
51         //{{AFX_MSG_MAP(CAISNbrIsosDialog)
52         ON_NOTIFY(UDN_DELTAPOS, IDC_SPINAISISOSU, OnDeltaposSpinaisisosu)
53         ON_NOTIFY(UDN_DELTAPOS, IDC_SPINAISISOSV, OnDeltaposSpinaisisosv)
54         //}}AFX_MSG_MAP
55 END_MESSAGE_MAP()
56
57 /////////////////////////////////////////////////////////////////////////////
58 // CAISNbrIsosDialog message handlers
59
60 void CAISNbrIsosDialog::OnDeltaposSpinaisisosu(NMHDR* pNMHDR, LRESULT* pResult) 
61 {
62         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
63         // TODO: Add your control notification handler code here
64
65         if ((pNMUpDown->iDelta < 0)) 
66                 m_Isosu = m_Isosu + 1;
67         if ((pNMUpDown->iDelta > 0) && (m_Isosu > 0)) 
68                 m_Isosu = m_Isosu - 1;
69
70         UpdateIsos ();
71         
72         *pResult = 0;
73 }
74
75 void CAISNbrIsosDialog::OnDeltaposSpinaisisosv(NMHDR* pNMHDR, LRESULT* pResult) 
76 {
77         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
78         // TODO: Add your control notification handler code here
79
80         if ((pNMUpDown->iDelta < 0)) 
81                 m_Isosv = m_Isosv + 1;
82         if ((pNMUpDown->iDelta > 0) && (m_Isosu > 0)) 
83                 m_Isosv = m_Isosv - 1;
84
85         UpdateIsos ();
86         
87         *pResult = 0;
88 }
89
90
91 #include <AIS_InteractiveObject.hxx>
92 #include <Prs3d_Drawer.hxx>
93
94 void CAISNbrIsosDialog::UpdateIsos ()
95 {
96     UpdateData (false);
97
98         for (myCurrentIC->InitCurrent(); 
99              myCurrentIC->MoreCurrent ();
100                  myCurrentIC->NextSelected ())
101         {       
102                 Handle(AIS_InteractiveObject) CurObject;
103                 Handle(Prs3d_Drawer) CurDrawer;
104
105                 
106                 CurObject = myCurrentIC->Current();
107                 CurDrawer = CurObject->Attributes();
108
109                 CurDrawer->UIsoAspect()->SetNumber(m_Isosu);
110         CurDrawer->VIsoAspect()->SetNumber(m_Isosv);
111
112                 myCurrentIC->SetLocalAttributes(CurObject, CurDrawer);
113         
114         myCurrentIC->Redisplay(CurObject);
115     }   
116
117 }
118 */
119 /////////////////////////////////////////////////////////////////////////////
120 // CDevCoeffDialog dialog
121
122
123 //CDevCoeffDialog::CDevCoeffDialog(Handle(AIS_InteractiveContext) CurrentIC,
124 //                                                               CWnd* pParent /*=NULL*/)
125 //      : CDialog(CDevCoeffDialog::IDD, pParent)
126 /*
127 {
128         //{{AFX_DATA_INIT(CDevCoeffDialog)
129                 // NOTE: the ClassWizard will add member initialization here
130         //}}AFX_DATA_INIT
131         myCurrentIC = CurrentIC;
132 }
133
134
135 void CDevCoeffDialog::DoDataExchange(CDataExchange* pDX)
136 {
137         CDialog::DoDataExchange(pDX);
138         //{{AFX_DATA_MAP(CDevCoeffDialog)
139                 // NOTE: the ClassWizard will add DDX and DDV calls here
140         //}}AFX_DATA_MAP
141 }
142
143
144 BEGIN_MESSAGE_MAP(CDevCoeffDialog, CDialog)
145         //{{AFX_MSG_MAP(CDevCoeffDialog)
146         ON_BN_CLICKED(IDC_DC_BIG, OnDcBig)
147         ON_BN_CLICKED(IDC_DC_DEFAULT, OnDcDefault)
148         ON_BN_CLICKED(IDC_DC_SMALL, OnDcSmall)
149         ON_BN_DOUBLECLICKED(IDC_DC_BIG, OnDoubleclickedDcBig)
150         ON_BN_DOUBLECLICKED(IDC_DC_DEFAULT, OnDoubleclickedDcDefault)
151         ON_BN_DOUBLECLICKED(IDC_DC_SMALL, OnDoubleclickedDcSmall)
152         ON_BN_CLICKED(IDC_DC_VBIG, OnDcVbig)
153         ON_BN_DOUBLECLICKED(IDC_DC_VBIG, OnDoubleclickedDcVbig)
154         ON_BN_CLICKED(IDC_DC_VSMALL, OnDcVsmall)
155         ON_BN_DOUBLECLICKED(IDC_DC_VSMALL, OnDoubleclickedDcVsmall)
156         //}}AFX_MSG_MAP
157 END_MESSAGE_MAP()
158
159 /////////////////////////////////////////////////////////////////////////////
160 // CDevCoeffDialog message handlers
161
162
163
164 void CDevCoeffDialog::OnDcDefault() 
165 {
166         // TODO: Add your control notification handler code here
167         myCurrentIC->SetDeviationCoefficient (DEFAULT_DEVIATIONCOEFFICIENT);            
168 }
169
170 void CDevCoeffDialog::OnDcSmall() 
171 {
172         // TODO: Add your control notification handler code here
173         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCSMALL); 
174 }
175
176 void CDevCoeffDialog::OnDcVsmall() 
177 {
178         // TODO: Add your control notification handler code here
179         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCVSMALL);                
180 }
181
182
183 void CDevCoeffDialog::OnDcBig() 
184 {
185         // TODO: Add your control notification handler code here
186         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCBIG);   
187 }
188
189 void CDevCoeffDialog::OnDcVbig() 
190 {
191         // TODO: Add your control notification handler code here
192         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCVBIG);          
193 }
194
195
196
197 void CDevCoeffDialog::OnDoubleclickedDcDefault() 
198 {
199         // TODO: Add your control notification handler code here
200         myCurrentIC->SetDeviationCoefficient (DEFAULT_DEVIATIONCOEFFICIENT);            
201         RedisplaySelected();    
202 }
203
204 void CDevCoeffDialog::OnDoubleclickedDcSmall() 
205 {
206         // TODO: Add your control notification handler code here
207         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCSMALL); 
208         RedisplaySelected();    
209 }
210
211 void CDevCoeffDialog::OnDoubleclickedDcVsmall() 
212 {
213         // TODO: Add your control notification handler code here
214         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCVSMALL);        
215         RedisplaySelected();    
216 }
217
218 void CDevCoeffDialog::OnDoubleclickedDcBig() 
219 {
220         // TODO: Add your control notification handler code here
221         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCBIG);   
222         RedisplaySelected();    
223 }
224
225 void CDevCoeffDialog::OnDoubleclickedDcVbig() 
226 {
227         // TODO: Add your control notification handler code here
228         myCurrentIC->SetDeviationCoefficient (DEFAULT_DCVBIG);  
229         RedisplaySelected();    
230 }
231
232
233
234 void CDevCoeffDialog::RedisplaySelected ()
235 {
236         for (myCurrentIC->InitCurrent(); 
237              myCurrentIC->MoreCurrent ();
238                  myCurrentIC->NextSelected ())
239         {       
240             myCurrentIC->Redisplay(myCurrentIC->Current());
241     }           
242 }
243
244 */
245
246 /////////////////////////////////////////////////////////////////////////////
247 // CDialogMaterial dialog
248
249
250 CDialogMaterial::CDialogMaterial(Handle(AIS_InteractiveContext) CurrentIC,
251                                                                  CWnd* pParent /*=NULL*/)
252         : CDialog(CDialogMaterial::IDD, pParent)
253 {
254         //{{AFX_DATA_INIT(CDialogMaterial)
255                 // NOTE: the ClassWizard will add member initialization here
256         //}}AFX_DATA_INIT
257         myCurrentIC = CurrentIC;
258 /*
259         for (myCurrentIC->InitCurrent();myCurrentIC->MoreCurrent ();myCurrentIC->NextCurrent ()){
260                 for(int i = ID_OBJECT_MATERIAL_BRASS; i <= ID_OBJECT_MATERIAL_DEFAULT; i++){
261                         if (myCurrentIC->Current()->Material() - (i - ID_OBJECT_MATERIAL_BRASS) == 0) 
262                                 //GotoDlgCtrl(GetDlgItem(i));
263                 }
264         }
265 */
266
267 }
268
269
270 void CDialogMaterial::DoDataExchange(CDataExchange* pDX)
271 {
272         CDialog::DoDataExchange(pDX);
273         //{{AFX_DATA_MAP(CDialogMaterial)
274                 // NOTE: the ClassWizard will add DDX and DDV calls here
275         //}}AFX_DATA_MAP
276 }
277
278
279 BEGIN_MESSAGE_MAP(CDialogMaterial, CDialog)
280         //{{AFX_MSG_MAP(CDialogMaterial)
281         ON_BN_CLICKED(ID_OBJECT_MATERIAL_ALUMINIUM, OnObjectMaterialAluminium)
282         ON_BN_CLICKED(ID_OBJECT_MATERIAL_BRASS, OnObjectMaterialBrass)
283         ON_BN_CLICKED(ID_OBJECT_MATERIAL_BRONZE, OnObjectMaterialBronze)
284         ON_BN_CLICKED(ID_OBJECT_MATERIAL_CHROME, OnObjectMaterialChrome)
285         ON_BN_CLICKED(ID_OBJECT_MATERIAL_COPPER, OnObjectMaterialCopper)
286         ON_BN_CLICKED(ID_OBJECT_MATERIAL_GOLD, OnObjectMaterialGold)
287         ON_BN_CLICKED(ID_OBJECT_MATERIAL_JADE, OnObjectMaterialJade)
288         ON_BN_CLICKED(ID_OBJECT_MATERIAL_METALIZED, OnObjectMaterialMetalized)
289         ON_BN_CLICKED(ID_OBJECT_MATERIAL_NEON_GNC, OnObjectMaterialNeonGNC)
290         ON_BN_CLICKED(ID_OBJECT_MATERIAL_NEON_PHC, OnObjectMaterialNeonPHC)
291         ON_BN_CLICKED(ID_OBJECT_MATERIAL_OBSIDIAN, OnObjectMaterialObsidian)
292         ON_BN_CLICKED(ID_OBJECT_MATERIAL_PEWTER, OnObjectMaterialPewter)
293         ON_BN_CLICKED(ID_OBJECT_MATERIAL_PLASTER, OnObjectMaterialPlaster)
294         ON_BN_CLICKED(ID_OBJECT_MATERIAL_PLASTIC, OnObjectMaterialPlastic)
295         ON_BN_CLICKED(ID_OBJECT_MATERIAL_SATIN, OnObjectMaterialSatin)
296         ON_BN_CLICKED(ID_OBJECT_MATERIAL_SHINY_PLASTIC, OnObjectMaterialShinyPlastic)
297         ON_BN_CLICKED(ID_OBJECT_MATERIAL_SILVER, OnObjectMaterialSilver)
298         ON_BN_CLICKED(ID_OBJECT_MATERIAL_STEEL, OnObjectMaterialSteel)
299         ON_BN_CLICKED(ID_OBJECT_MATERIAL_STONE, OnObjectMaterialStone)
300         ON_BN_CLICKED(ID_OBJECT_MATERIAL_DEFAULT, OnObjectMaterialDefault)
301         //}}AFX_MSG_MAP
302 END_MESSAGE_MAP()
303
304 /////////////////////////////////////////////////////////////////////////////
305 // CDialogMaterial message handlers
306 /*
307 void CDialogMaterial::OnMaterial(UINT nID) 
308 {
309         SetMaterial ((Graphic3d_NameOfMaterial)(nID-ID_OBJECT_MATERIAL_BRASS));
310 }
311 */
312 void CDialogMaterial::SetMaterial(Graphic3d_NameOfMaterial Material) 
313 {
314   Standard_Real aTransparency;
315   for (myCurrentIC->InitCurrent();myCurrentIC->MoreCurrent ();myCurrentIC->NextCurrent ()){
316         aTransparency = myCurrentIC->Current()->Transparency();
317         myCurrentIC->SetMaterial (myCurrentIC->Current(),(Graphic3d_NameOfMaterial)(Material));
318         myCurrentIC->SetTransparency (myCurrentIC->Current(),aTransparency);
319   }
320 }
321
322 void CDialogMaterial::OnObjectMaterialAluminium     () { SetMaterial ( Graphic3d_NOM_ALUMINIUM     ) ; }
323 void CDialogMaterial::OnObjectMaterialBrass     () { SetMaterial ( Graphic3d_NOM_BRASS     ) ; }
324 void CDialogMaterial::OnObjectMaterialBronze    () { SetMaterial ( Graphic3d_NOM_BRONZE    ) ; }
325 void CDialogMaterial::OnObjectMaterialChrome    () { SetMaterial ( Graphic3d_NOM_CHROME     ) ; }
326 void CDialogMaterial::OnObjectMaterialCopper    () { SetMaterial ( Graphic3d_NOM_COPPER    ) ; }
327 void CDialogMaterial::OnObjectMaterialGold      () { SetMaterial ( Graphic3d_NOM_GOLD      ) ; }
328 void CDialogMaterial::OnObjectMaterialJade     () { SetMaterial ( Graphic3d_NOM_JADE     ) ; }
329 void CDialogMaterial::OnObjectMaterialMetalized     () { SetMaterial ( Graphic3d_NOM_METALIZED     ) ; }
330 void CDialogMaterial::OnObjectMaterialNeonGNC     () { SetMaterial ( Graphic3d_NOM_NEON_GNC     ) ; }
331 void CDialogMaterial::OnObjectMaterialNeonPHC     () { SetMaterial ( Graphic3d_NOM_NEON_PHC     ) ; }
332 void CDialogMaterial::OnObjectMaterialObsidian     () { SetMaterial ( Graphic3d_NOM_OBSIDIAN     ) ; }
333 void CDialogMaterial::OnObjectMaterialPewter    () { SetMaterial ( Graphic3d_NOM_PEWTER    ) ; }
334 void CDialogMaterial::OnObjectMaterialPlaster   () { SetMaterial ( Graphic3d_NOM_PLASTER   ) ; }
335 void CDialogMaterial::OnObjectMaterialPlastic   () { SetMaterial ( Graphic3d_NOM_PLASTIC   ) ; }
336 void CDialogMaterial::OnObjectMaterialSatin     () { SetMaterial ( Graphic3d_NOM_SATIN     ) ; }
337 void CDialogMaterial::OnObjectMaterialShinyPlastic     () { SetMaterial ( Graphic3d_NOM_SHINY_PLASTIC     ) ; }
338 void CDialogMaterial::OnObjectMaterialSilver    () { SetMaterial ( Graphic3d_NOM_SILVER    ) ; }
339 void CDialogMaterial::OnObjectMaterialSteel    () { SetMaterial ( Graphic3d_NOM_STEEL    ) ; }
340 void CDialogMaterial::OnObjectMaterialStone    () { SetMaterial ( Graphic3d_NOM_STONE    ) ; }
341 void CDialogMaterial::OnObjectMaterialDefault    () { SetMaterial ( Graphic3d_NOM_DEFAULT     ) ; }
342
343
344 /////////////////////////////////////////////////////////////////////////////
345 // CDialogTransparency dialog
346
347 CDialogTransparency::CDialogTransparency(Handle(AIS_InteractiveContext) CurrentIC,
348                                                                                  CWnd* pParent /*=NULL*/)
349         : CDialog(CDialogTransparency::IDD, pParent)
350 {
351         
352         //{{AFX_DATA_INIT(CDialogTransparency)
353         m_TransValue = 0;
354         //}}AFX_DATA_INIT
355
356         myCurrentIC = CurrentIC;
357
358         Standard_Real temp = 10;
359         Standard_Real t;
360
361         for (myCurrentIC->InitCurrent(); 
362              myCurrentIC->MoreCurrent ();
363                  myCurrentIC->NextCurrent ())
364         {       
365                 t = CurrentIC->Current()->Transparency();
366                 if (temp > t)
367                         temp = t;
368             //myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue);
369     }   
370
371         m_TransValue = int (temp * 10);
372         if (Abs(m_TransValue - temp * 10) > 0.01)
373                 m_TransValue = int (temp * 10) + 1;
374
375         for (myCurrentIC->InitCurrent(); 
376              myCurrentIC->MoreCurrent ();
377                  myCurrentIC->NextCurrent ())
378         {       
379             myCurrentIC->SetTransparency (myCurrentIC->Current(), temp);
380     }   
381
382
383 }
384
385
386 void CDialogTransparency::DoDataExchange(CDataExchange* pDX)
387 {
388         CDialog::DoDataExchange(pDX);
389         //{{AFX_DATA_MAP(CDialogTransparency)
390         DDX_Text(pDX, IDC_EDITAISTRANSP, m_TransValue);
391         DDV_MinMaxInt(pDX, m_TransValue, 0, 10);
392         //}}AFX_DATA_MAP
393 }
394
395
396 BEGIN_MESSAGE_MAP(CDialogTransparency, CDialog)
397         //{{AFX_MSG_MAP(CDialogTransparency)
398         ON_NOTIFY(UDN_DELTAPOS, IDC_SPINAISTRANSP, OnDeltaposSpinaistransp)
399         ON_EN_CHANGE(IDC_EDITAISTRANSP, OnChangeEditaistransp)
400         //}}AFX_MSG_MAP
401 END_MESSAGE_MAP()
402
403 /////////////////////////////////////////////////////////////////////////////
404 // CDialogTransparency message handlers
405
406 void CDialogTransparency::OnDeltaposSpinaistransp(NMHDR* pNMHDR, LRESULT* pResult) 
407 {
408         NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
409         // TODO: Add your control notification handler code here
410         if ((pNMUpDown->iDelta < 0) && (m_TransValue < 10)) 
411                 m_TransValue = m_TransValue + 1;
412         if ((pNMUpDown->iDelta > 0) && (m_TransValue > 0)) 
413                 m_TransValue = m_TransValue - 1;
414
415     UpdateData (false);
416
417         for (myCurrentIC->InitCurrent(); 
418              myCurrentIC->MoreCurrent ();
419                  myCurrentIC->NextCurrent())
420         {       
421             myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue/10.0);
422     }   
423
424         *pResult = 0;
425
426 }
427
428
429 void CDialogTransparency::OnChangeEditaistransp() 
430 {
431         // TODO: Add your control notification handler code here
432         int temp = m_TransValue;
433     if (UpdateData (true)){
434                 for (myCurrentIC->InitCurrent(); 
435                          myCurrentIC->MoreCurrent ();
436                          myCurrentIC->NextCurrent())
437                 {       
438                         myCurrentIC->SetTransparency (myCurrentIC->Current(), m_TransValue/10.0);
439                 }       
440         }
441         else{
442                 m_TransValue = temp;
443             UpdateData (false);
444         }
445
446 }