source: trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc@ 531

Last change on this file since 531 was 530, checked in by garnier, 18 years ago

r659@mac-90108: laurentgarnier | 2007-06-25 15:26:57 +0200
premieres modofs

  • Property svn:mime-type set to text/cpp
File size: 10.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4OpenGLQtViewer.cc,v 1.17 2006/06/29 21:19:36 gunter Exp $
28// GEANT4 tag $Name: geant4-08-01-patch-01 $
29//
30//
31// G4OpenGLQtViewer : Class to provide Qt specific
32// functionality for OpenGL in GEANT4
33//
34// 27/06/2003 : G.Barrand : implementation (at last !).
35
36#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
37
38#include "G4OpenGLQtViewer.hh"
39
40#include "G4ios.hh"
41#include "G4VisExtent.hh"
42#include "G4LogicalVolume.hh"
43#include "G4VSolid.hh"
44#include "G4Point3D.hh"
45#include "G4Normal3D.hh"
46
47
48//////////////////////////////////////////////////////////////////////////////
49/**
50 Implementation of virtual method of G4VViewer
51 */
52void G4OpenGLQtViewer::SetView (
53)
54//////////////////////////////////////////////////////////////////////////////
55//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
56{
57 printf("G4OpenGLQtViewer::SetView \n");
58// if(!fHDC) return;
59// if(!fHGLRC) return;
60// ::wglMakeCurrent(fHDC,fHGLRC);
61// G4OpenGLViewer::SetView ();
62}
63
64//////////////////////////////////////////////////////////////////////////////
65/**
66 Implementation of virtual method of G4VViewer
67 */
68void G4OpenGLQtViewer::ClearView (
69)
70//////////////////////////////////////////////////////////////////////////////
71//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
72{
73 printf("G4OpenGLQtViewer::ClearView \n");
74}
75
76
77//////////////////////////////////////////////////////////////////////////////
78/**
79 Implementation of virtual method of G4VViewer
80 */
81void G4OpenGLQtViewer::DrawView (
82)
83//////////////////////////////////////////////////////////////////////////////
84//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
85{
86 printf("G4OpenGLQtViewer::DrawView \n");
87}
88
89//////////////////////////////////////////////////////////////////////////////
90/**
91 Implementation of virtual method of G4VViewer
92 */
93void G4OpenGLQtViewer::ShowView (
94)
95//////////////////////////////////////////////////////////////////////////////
96//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
97{
98 printf("G4OpenGLQtViewer::ShowView \n");
99// if(!fHDC) return;
100// glFlush ();
101// // Empty the Windows message queue :
102// MSG event;
103// while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
104// ::TranslateMessage(&event);
105// ::DispatchMessage (&event);
106// }
107}
108
109
110// //////////////////////////////////////////////////////////////////////////////
111// void G4OpenGLQtViewer::GetQtConnection (
112// )
113// //////////////////////////////////////////////////////////////////////////////
114// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
115// {
116// }
117
118//////////////////////////////////////////////////////////////////////////////
119void G4OpenGLQtViewer::CreateGLQtContext (
120)
121//////////////////////////////////////////////////////////////////////////////
122//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
123{
124 printf("G4OpenGLQtViewer::CreateGLQtContext \n");
125}
126
127//////////////////////////////////////////////////////////////////////////////
128void G4OpenGLQtViewer::CreateMainWindow (
129)
130//////////////////////////////////////////////////////////////////////////////
131//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
132{
133 printf("G4OpenGLQtViewer::CreateMainWindow \n");
134// if(fWindow) return; //Done.
135
136// // Bill Gates stuff...
137// static const char className[] = "G4OpenGLQt";
138// static bool done = false;
139// if(done==false) {
140// WNDCLASS wc;
141// wc.style = CS_HREDRAW | CS_VREDRAW;
142// wc.lpfnWndProc = (WNDPROC)WindowProc;
143// wc.cbClsExtra = 0;
144// wc.cbWndExtra = 0;
145// wc.hInstance = ::GetModuleHandle(NULL);
146// wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
147// wc.hCursor = LoadCursor(NULL,IDC_CROSS);
148// wc.hbrBackground = NULL;
149// wc.lpszMenuName = className;
150// wc.lpszClassName = className;
151// ::RegisterClass(&wc);
152// done = true;
153// }
154
155// WinSize_x = 400;
156// WinSize_y = 400;
157// if (WinSize_x < fVP.GetWindowSizeHintX ())
158// WinSize_x = fVP.GetWindowSizeHintX ();
159// if (WinSize_y < fVP.GetWindowSizeHintY ())
160// WinSize_y = fVP.GetWindowSizeHintY ();
161
162// fWindow = ::CreateWindow(className,fName.c_str(),
163// WS_OVERLAPPEDWINDOW,
164// //WS_CHILD | WS_VISIBLE,
165// 0,0,
166// WinSize_x,WinSize_y,
167// NULL, NULL,
168// ::GetModuleHandle(NULL),
169// NULL);
170// if(!fWindow) return;
171
172// ::SetWindowLong(fWindow,GWL_USERDATA,LONG(this));
173
174// // initialize OpenGL rendering :
175// fHDC = ::GetDC(fWindow);
176// if( fHDC && (SetWindowPixelFormat(fHDC)==TRUE) ) {
177// fHGLRC = ::wglCreateContext(fHDC);
178// }
179
180// if(fHDC && fHGLRC) {
181// ::wglMakeCurrent(fHDC,fHGLRC);
182// }
183
184// ::SetForegroundWindow(fWindow);
185// ::ShowWindow(fWindow,SW_SHOWDEFAULT);
186// ::UpdateWindow(fWindow);
187// ::DrawMenuBar(fWindow);
188}
189
190//////////////////////////////////////////////////////////////////////////////
191G4OpenGLQtViewer::G4OpenGLQtViewer (
192 G4OpenGLSceneHandler& scene
193)
194:G4VViewer (scene, -1)
195,G4OpenGLViewer (scene)
196 //,fWindow(0)
197 //,fHDC(0)
198 //,fHGLRC(0)
199//////////////////////////////////////////////////////////////////////////////
200//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
201{
202 printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n");
203}
204
205//////////////////////////////////////////////////////////////////////////////
206G4OpenGLQtViewer::~G4OpenGLQtViewer (
207)
208//////////////////////////////////////////////////////////////////////////////
209//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
210{
211 printf("G4OpenGLQtViewer::~G4OpenGLQtViewer \n");
212// // This is the end (Jim Morisson).
213// if (fViewId >= 0) {
214// if(wglGetCurrentContext()!=NULL) wglMakeCurrent(NULL,NULL);
215// if(fHGLRC) {
216// wglDeleteContext(fHGLRC);
217// fHGLRC = NULL;
218// }
219
220// if(fWindow) {
221// ::SetWindowLong(fWindow,GWL_USERDATA,LONG(NULL));
222// if(fHDC) ::ReleaseDC(fWindow,fHDC);
223// ::DestroyWindow(fWindow);
224// }
225// }
226}
227
228// //////////////////////////////////////////////////////////////////////////////
229// LRESULT CALLBACK G4OpenGLQtViewer::WindowProc (
230// HWND aWindow
231// ,UINT aMessage
232// ,WPARAM aWParam
233// ,LPARAM aLParam
234// )
235// //////////////////////////////////////////////////////////////////////////////
236// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
237// {
238/*
239 switch (aMessage) {
240 case WM_PAINT:{
241 printf("debug : PAINT\n");
242 HDC hDC;
243 PAINTSTRUCT ps;
244 hDC = BeginPaint(aWindow,&ps);
245 if(This) {
246 // FIXME : To have an automatic refresh someone have to redraw here.
247 }
248 EndPaint(aWindow, &ps);
249
250 //FIXME : have to handle WM_RESIZE
251 //pView->WinSize_x = (G4int) width;
252 //pView->WinSize_y = (G4int) height;
253 G4OpenGLQtViewer* This =
254 (G4OpenGLQtViewer*)::GetWindowLong(aWindow,GWL_USERDATA);
255 if(This) {
256 This->SetView();
257 glViewport(0,0,This->WinSize_x,This->WinSize_y);
258 This->ClearView();
259 This->DrawView();
260 // WARNING : the below empty the Windows message queue...
261 This->FinishView();
262 }
263 } return 0;
264 default:
265 return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
266 }
267*/
268// return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
269// }
270
271// //////////////////////////////////////////////////////////////////////////////
272// bool G4OpenGLQtViewer::SetWindowPixelFormat(
273// HDC aHdc
274// )
275// //////////////////////////////////////////////////////////////////////////////
276// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
277// {
278// // The ungessable...
279
280// PIXELFORMATDESCRIPTOR pfd;
281// pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
282// pfd.nVersion = 1;
283// pfd.dwFlags =
284// PFD_DRAW_TO_WINDOW |
285// PFD_SUPPORT_OPENGL |
286// PFD_DOUBLEBUFFER |
287// PFD_STEREO_DONTCARE;
288// pfd.iPixelType = PFD_TYPE_RGBA;
289// pfd.cColorBits = 32;
290// pfd.cRedBits = 8;
291// pfd.cRedShift = 16;
292// pfd.cGreenBits = 8;
293// pfd.cGreenShift = 8;
294// pfd.cBlueBits = 8;
295// pfd.cBlueShift = 0;
296// pfd.cAlphaBits = 0;
297// pfd.cAlphaShift = 0;
298// pfd.cAccumBits = 64;
299// pfd.cAccumRedBits = 16;
300// pfd.cAccumGreenBits = 16;
301// pfd.cAccumBlueBits = 16;
302// pfd.cAccumAlphaBits = 0;
303// pfd.cDepthBits = 32;
304// pfd.cStencilBits = 8;
305// pfd.cAuxBuffers = 0;
306// pfd.iLayerType = PFD_MAIN_PLANE;
307// pfd.bReserved = 0;
308// pfd.dwLayerMask = 0;
309// pfd.dwVisibleMask = 0;
310// pfd.dwDamageMask = 0;
311
312// int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd);
313// if (pixelIndex==0) {
314// pixelIndex = 1;
315// if (::DescribePixelFormat(aHdc,
316// pixelIndex,
317// sizeof(PIXELFORMATDESCRIPTOR),
318// &pfd)==0) {
319// return false;
320// }
321// }
322// if (::SetPixelFormat(aHdc,pixelIndex,&pfd)==FALSE) return false;
323// return true;
324//}
325
326
327#endif
Note: See TracBrowser for help on using the repository browser.