0028316: Coding Rules - Elimilate confusing aliases of Standard_Real type in V3d_View
[occt.git] / samples / mfc / standard / Common / OCC_2dViewRD.cpp
1 // OCC_2dViewRDRD.cpp: implementation of the OCC_2dViewRDRD class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include <stdafx.h>
6 #include <res/OCC_Resource.h>
7 #include "OCC_2dViewRD.h"
8
9 #ifdef _DEBUG
10 #undef THIS_FILE
11 static char THIS_FILE[]=__FILE__;
12 #define new DEBUG_NEW
13 #endif
14
15 //////////////////////////////////////////////////////////////////////
16 // Construction/Destruction
17 //////////////////////////////////////////////////////////////////////
18
19 BEGIN_MESSAGE_MAP(OCC_2dViewRD, CView)
20         //{{AFX_MSG_MAP(OCC_2dViewRD)
21                 // NOTE - the ClassWizard will add and remove mapping macros here.
22                 //    DO NOT EDIT what you see in these blocks of generated code!
23     ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage)
24     ON_COMMAND(ID_BUTTON2DGridRectLines, OnBUTTONGridRectLines)
25         ON_COMMAND(ID_BUTTON2DGridRectPoints, OnBUTTONGridRectPoints)
26         ON_COMMAND(ID_BUTTON2DGridCircLines, OnBUTTONGridCircLines)
27         ON_COMMAND(ID_BUTTON2DGridCircPoints, OnBUTTONGridCircPoints)
28         ON_COMMAND(ID_BUTTON2DGridValues, OnBUTTONGridValues)
29         ON_COMMAND(ID_BUTTON2DGridCancel, OnBUTTONGridCancel)
30         //}}AFX_MSG_MAP
31 END_MESSAGE_MAP()
32
33 void OCC_2dViewRD::OnFileExportImage()
34 {
35         OCC_2dViewRD::OnFileExportImage();
36   // Update Get information to update Result dialog
37
38   UINT anID=ID_FILE_EXPORT_IMAGE;
39   TCollection_AsciiString Message(" \
40   CFileDialog dlg(FALSE,_T(\"*.BMP\"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, \n\
41                                              _T(\"BMP Files (*.BMP)|*.bmp |GIF Files (*.GIF)|*.gif | XWD Files (*.XWD)|*.xwd||\"), \n\
42                                              NULL );                                                \n\
43                                                                          \n\
44   if (dlg.DoModal() == IDOK)                                             \n\
45   {                                                                      \n\
46     SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));                \n\
47     CString filename = dlg.GetPathName();                                \n\
48     Handle(WNT_Window) aWNTWindow=                                       \n\
49     Handle(WNT_Window)::DownCast(myV2dView->Driver()->Window());         \n\
50     CString ext = dlg.GetFileExt();                                      \n\
51     if (ext == \"bmp\")     aWNTWindow->SetOutputFormat ( WNT_TOI_BMP ); \n\
52     if (ext == \"gif\")        aWNTWindow->SetOutputFormat ( WNT_TOI_GIF ); \n\
53     if (ext == \"xwd\")     aWNTWindow->SetOutputFormat ( WNT_TOI_XWD ); \n\
54     aWNTWindow->Dump ((Standard_CString)(LPCTSTR)filename);              \n\
55     SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));               \n\
56   }                                                                      \n");
57
58   // Update The Result Dialog
59   GetDocument()->UpdateResultDialog(anID,Message);
60 }
61
62
63 void OCC_2dViewRD::OnBUTTONGridRectLines() 
64 {
65         OCC_2dViewRD::OnBUTTONGridRectLines();
66   // Update Get information to update Result dialog
67
68   UINT anID=ID_BUTTON2DGridRectLines;
69   TCollection_AsciiString Message;
70   Message += "\
71   Handle(V2d_Viewer) aViewer = myV2dView->Viewer();  \n\
72   aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE)); \n\
73   aViewer->ActivateGrid(Aspect_GT_Rectangular, \n\
74                                       Aspect_GDM_Lines);  \n\
75   if (TheCircularGridDialog.IsWindowVisible())       \n\
76   {                                                  \n\
77     TheCircularGridDialog.ShowWindow(SW_HIDE);       \n\
78     TheRectangularGridDialog.UpdateValues();         \n\
79     TheRectangularGridDialog.ShowWindow(SW_SHOW);    \n\
80   }                                                  \n\
81   \n";
82
83   // Update The Result Dialog
84   GetDocument()->UpdateResultDialog(anID,Message);
85
86 }
87
88 void OCC_2dViewRD::OnBUTTONGridRectPoints() 
89 {
90         OCC_2dViewRD::OnBUTTONGridRectPoints();
91   // Update Get information to update Result dialog
92
93   UINT anID=ID_BUTTON2DGridRectPoints;
94   TCollection_AsciiString Message;
95 Message = "\
96   Handle(V2d_Viewer) aViewer = myV2dView->Viewer();  \n\
97   aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE)); \n\
98   aViewer->ActivateGrid(Aspect_GT_Rectangular, \n\
99                                       Aspect_GDM_Points); \n\
100   if (TheCircularGridDialog.IsWindowVisible())       \n\
101   {                                                  \n\
102     TheCircularGridDialog.ShowWindow(SW_HIDE);       \n\
103     TheRectangularGridDialog.UpdateValues();         \n\
104     TheRectangularGridDialog.ShowWindow(SW_SHOW);    \n\
105   }                                                  \n\
106 ";
107   // Update The Result Dialog
108   GetDocument()->UpdateResultDialog(anID,Message);
109
110
111 }
112
113 void OCC_2dViewRD::OnBUTTONGridCircLines() 
114 {
115         OCC_2dViewRD::OnBUTTONGridCircLines();
116   // Update Get information to update Result dialog
117
118   UINT anID=ID_BUTTON2DGridCircLines;
119   TCollection_AsciiString Message("\
120   Handle(V2d_Viewer) aViewer = myV2dView->Viewer(); \n\
121   aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE)); \n\
122   aViewer->ActivateGrid(Aspect_GT_Circular,   \n\
123                                       Aspect_GDM_Lines); \n\
124   if (TheRectangularGridDialog.IsWindowVisible())   \n\
125   {                                                 \n\
126     TheRectangularGridDialog.ShowWindow(SW_HIDE);   \n\
127     TheCircularGridDialog.UpdateValues();           \n\
128     TheCircularGridDialog.ShowWindow(SW_SHOW);      \n\
129   } \n");                                             
130     // Update The Result Dialog
131   GetDocument()->UpdateResultDialog(anID,Message);
132
133 }
134
135 void OCC_2dViewRD::OnBUTTONGridCircPoints() 
136 {
137         OCC_2dViewRD::OnBUTTONGridCircPoints();
138   // Update Get information to update Result dialog
139
140   UINT anID=ID_BUTTON2DGridCircPoints;
141   TCollection_AsciiString Message("\
142   Handle(V2d_Viewer) aViewer = myV2dView->Viewer();  \n\
143   aViewer->SetGridColor(Quantity_Color(Quantity_NOC_WHITE), Quantity_Color(Quantity_NOC_WHITE)); \n\
144   aViewer->ActivateGrid(Aspect_GT_Circular,    \n\
145                                       Aspect_GDM_Points); \n\
146   if (TheRectangularGridDialog.IsWindowVisible())    \n\
147   {                                                  \n\
148     TheRectangularGridDialog.ShowWindow(SW_HIDE);    \n\
149     TheCircularGridDialog.UpdateValues();            \n\
150     TheCircularGridDialog.ShowWindow(SW_SHOW);       \n\
151   }                                                  \n\
152   \n");
153
154   // Update The Result Dialog
155   GetDocument()->UpdateResultDialog(anID,Message);
156
157 }
158
159 void OCC_2dViewRD::OnBUTTONGridValues() 
160 {
161         OCC_2dViewRD::OnBUTTONGridValues();
162   // Update Get information to update Result dialog
163
164   UINT anID=ID_BUTTON2DGridValues;
165   TCollection_AsciiString Message("\
166   Handle(V2d_Viewer) aViewer = myV2dView->Viewer();               \n\
167   Aspect_GridType  TheGridtype = aViewer->GridType();       \n\
168                                                                   \n\
169   switch( TheGridtype )                                           \n\
170   {                                                               \n\
171     case  Aspect_GT_Rectangular:                            \n\
172       TheRectangularGridDialog.UpdateValues();                    \n\
173       TheRectangularGridDialog.ShowWindow(SW_SHOW);               \n\
174     break;                                                        \n\
175     case  Aspect_GT_Circular:                               \n\
176       TheCircularGridDialog.UpdateValues();                       \n\
177       TheCircularGridDialog.ShowWindow(SW_SHOW);                  \n\
178     break;                                                        \n\
179     default :                                                     \n\
180       throw Standard_Failure(\"invalid Aspect_GridType\"); \n\
181   }                                                               \n\
182 \n");
183   // Update The Result Dialog
184   GetDocument()->UpdateResultDialog(anID,Message);
185
186 }
187
188 void OCC_2dViewRD::OnBUTTONGridCancel() 
189 {       
190         OCC_2dViewRD::OnBUTTONGridCancel();
191   // Update Get information to update Result dialog
192
193   UINT anID=ID_BUTTON2DGridCancel;
194   TCollection_AsciiString Message("\
195   Handle(V2d_Viewer) aViewer = myV2dView->Viewer(); \n\
196   aViewer->DeactivateGrid();                        \n\
197   TheRectangularGridDialog.ShowWindow(SW_HIDE);     \n\
198   TheCircularGridDialog.ShowWindow(SW_HIDE);        \n\
199   aViewer->Update();                                \n\
200   \n");
201
202   // Update The Result Dialog
203   GetDocument()->UpdateResultDialog(anID,Message);
204
205 }
206
207
208 OCC_2dViewRD::OCC_2dViewRD()
209 {
210
211 }
212
213 OCC_2dViewRD::~OCC_2dViewRD()
214 {
215 }
216
217
218 OCC_2dDoc* OCC_2dViewRD::GetDocument()
219 {
220         return (OCC_2dDoc*)m_pDocument;
221 }