Changeset 539 for trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
- Timestamp:
- Jul 5, 2007, 5:54:48 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r538 r539 45 45 #include "G4Normal3D.hh" 46 46 47 #include "G4Qt.hh" 48 #include "G4UIManager.hh" 49 #include <QtGui/qboxlayout.h> 50 #include <QtGui/qdialog.h> 51 #include <QtGui/qpushbutton.h> 47 52 48 53 ////////////////////////////////////////////////////////////////////////////// … … 131 136 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 132 137 { 133 printf("G4OpenGLQtViewer::CreateMainWindow \n");134 138 135 139 if(fWindow) return; //Done. 140 printf("G4OpenGLQtViewer::CreateMainWindow 2\n"); 141 142 // launch Qt if not 143 G4Qt* interactorManager = G4Qt::getInstance (); 144 // G4UImanager* UI = G4UImanager::GetUIpointer(); 145 printf("G4OpenGLQtViewer::CreateMainWindow 3\n"); 146 147 QPushButton hello("Hello world!"); 148 hello.resize(100, 30); 149 hello.show(); 136 150 137 151 fWindow = new QGLWidget() ; 138 152 fWindow->makeCurrent(); 153 154 // create window 155 QDialog* GLWindow ; 156 if (qApp) { 157 GLWindow = new QDialog();//qApp->mainWidget()); 158 } else { 159 GLWindow = new QDialog(); 160 } 161 162 QHBoxLayout *mainLayout = new QHBoxLayout; 163 mainLayout->addWidget(fWindow); 164 GLWindow->setLayout(mainLayout); 165 GLWindow->setWindowTitle("QGl Viewer"); 166 GLWindow->resize(100, 30); 167 GLWindow->show(); 168 139 169 140 170 // // Bill Gates stuff... … … 157 187 // } 158 188 159 //WinSize_x = 400;160 //WinSize_y = 400;161 //if (WinSize_x < fVP.GetWindowSizeHintX ())162 //WinSize_x = fVP.GetWindowSizeHintX ();163 //if (WinSize_y < fVP.GetWindowSizeHintY ())164 //WinSize_y = fVP.GetWindowSizeHintY ();189 WinSize_x = 400; 190 WinSize_y = 400; 191 if (WinSize_x < fVP.GetWindowSizeHintX ()) 192 WinSize_x = fVP.GetWindowSizeHintX (); 193 if (WinSize_y < fVP.GetWindowSizeHintY ()) 194 WinSize_y = fVP.GetWindowSizeHintY (); 165 195 166 196 // fWindow = ::CreateWindow(className,fName.c_str(), … … 193 223 194 224 ////////////////////////////////////////////////////////////////////////////// 225 void G4OpenGLQtViewer::CreateMainWindow ( 226 QGLWidget* glWidget 227 ) 228 ////////////////////////////////////////////////////////////////////////////// 229 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 230 { 231 232 if(fWindow) return; //Done. 233 printf("G4OpenGLQtViewer::CreateMainWindow glWidget\n"); 234 235 // launch Qt if not 236 G4Qt* interactorManager = G4Qt::getInstance (); 237 // G4UImanager* UI = G4UImanager::GetUIpointer(); 238 printf("G4OpenGLQtViewer::CreateMainWindow 3\n"); 239 240 fWindow = glWidget ; 241 fWindow->makeCurrent(); 242 243 // create window 244 QDialog* GLWindow ; 245 if (qApp) { 246 GLWindow = new QDialog();//qApp->mainWidget()); 247 } else { 248 GLWindow = new QDialog(); 249 } 250 251 QHBoxLayout *mainLayout = new QHBoxLayout; 252 mainLayout->addWidget(fWindow); 253 GLWindow->setLayout(mainLayout); 254 GLWindow->setWindowTitle("QGl Viewer"); 255 GLWindow->resize(300, 300); 256 GLWindow->show(); 257 258 259 // // Bill Gates stuff... 260 // static const char className[] = "G4OpenGLQt"; 261 // static bool done = false; 262 // if(done==false) { 263 // WNDCLASS wc; 264 // wc.style = CS_HREDRAW | CS_VREDRAW; 265 // wc.lpfnWndProc = (WNDPROC)WindowProc; 266 // wc.cbClsExtra = 0; 267 // wc.cbWndExtra = 0; 268 // wc.hInstance = ::GetModuleHandle(NULL); 269 // wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); 270 // wc.hCursor = LoadCursor(NULL,IDC_CROSS); 271 // wc.hbrBackground = NULL; 272 // wc.lpszMenuName = className; 273 // wc.lpszClassName = className; 274 // ::RegisterClass(&wc); 275 // done = true; 276 // } 277 278 WinSize_x = 400; 279 WinSize_y = 400; 280 if (WinSize_x < fVP.GetWindowSizeHintX ()) 281 WinSize_x = fVP.GetWindowSizeHintX (); 282 if (WinSize_y < fVP.GetWindowSizeHintY ()) 283 WinSize_y = fVP.GetWindowSizeHintY (); 284 285 // fWindow = ::CreateWindow(className,fName.c_str(), 286 // WS_OVERLAPPEDWINDOW, 287 // //WS_CHILD | WS_VISIBLE, 288 // 0,0, 289 // WinSize_x,WinSize_y, 290 // NULL, NULL, 291 // ::GetModuleHandle(NULL), 292 // NULL); 293 // if(!fWindow) return; 294 295 // ::SetWindowLong(fWindow,GWL_USERDATA,LONG(this)); 296 297 // // initialize OpenGL rendering : 298 // fHDC = ::GetDC(fWindow); 299 // if( fHDC && (SetWindowPixelFormat(fHDC)==TRUE) ) { 300 // fHGLRC = ::wglCreateContext(fHDC); 301 // } 302 303 // if(fHDC && fHGLRC) { 304 // ::wglMakeCurrent(fHDC,fHGLRC); 305 // } 306 307 // ::SetForegroundWindow(fWindow); 308 // ::ShowWindow(fWindow,SW_SHOWDEFAULT); 309 // ::UpdateWindow(fWindow); 310 // ::DrawMenuBar(fWindow); 311 } 312 313 ////////////////////////////////////////////////////////////////////////////// 195 314 G4OpenGLQtViewer::G4OpenGLQtViewer ( 196 315 G4OpenGLSceneHandler& scene … … 198 317 :G4VViewer (scene, -1) 199 318 ,G4OpenGLViewer (scene) 200 //,fWindow(0)319 ,fWindow(0) 201 320 //,fHDC(0) 202 321 //,fHGLRC(0)
Note: See TracChangeset
for help on using the changeset viewer.