38 #ifdef G4VIS_BUILD_OIWIN32_DRIVER
43 #include <Inventor/nodes/SoSelection.h>
45 #include <Inventor/Win/SoWin.h>
46 #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
58 class Geant4_SoWinExaminerViewer :
public SoWinExaminerViewer {
60 Geant4_SoWinExaminerViewer(HWND parent,
const char*
name,SbBool embed)
61 :SoWinExaminerViewer(parent,name,embed){}
62 virtual void sizeChanged(
const SbVec2s & size){
63 SoWinExaminerViewer::sizeChanged(size);
68 #define ID_FILE_POSTSCRIPT 1
69 #define ID_FILE_PIXMAP_POSTSCRIPT 2
70 #define ID_FILE_INVENTOR 3
71 #define ID_FILE_ESCAPE 4
73 #define ID_ETC_ERASE_DETECTOR 101
74 #define ID_ETC_ERASE_EVENT 102
75 #define ID_ETC_SET_SOLID 103
76 #define ID_ETC_SET_WIRE_FRAME 104
77 #define ID_ETC_SET_REDUCED_WIRE_FRAME 105
78 #define ID_ETC_SET_FULL_WIRE_FRAME 106
79 #define ID_ETC_SET_PREVIEW 107
80 #define ID_ETC_SET_PREVIEW_AND_FULL 108
81 #define ID_ETC_UPDATE_SCENE 109
82 #define ID_ETC_STATS 110
84 #define ID_HELP_CONTROLS 201
88 static const char className[] =
"G4OpenInventorShellWindow";
90 G4OpenInventorWinViewer::G4OpenInventorWinViewer(
91 G4OpenInventorSceneHandler& sceneHandler
93 :G4OpenInventorViewer (sceneHandler, name)
102 void G4OpenInventorWinViewer::Initialise() {
109 HWND parent = (HWND)fInteractorManager->GetParentInteractor ();
113 shellName +=
"_shell";
114 static SbBool done =
FALSE;
116 HBRUSH brush = (HBRUSH) GetSysColorBrush(COLOR_BTNFACE);
118 wc.style = CS_HREDRAW | CS_VREDRAW;
119 wc.lpfnWndProc = (WNDPROC)WindowProc;
122 wc.hInstance = ::GetModuleHandle(0);
123 wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
124 wc.hCursor = ::LoadCursor(0, IDC_ARROW);
125 wc.hbrBackground = brush;
126 wc.lpszMenuName = className;
127 wc.lpszClassName = className;
128 ::RegisterClass(&wc);
132 width = fVP.GetWindowSizeHintX();
133 height = fVP.GetWindowSizeHintX();
135 HMENU menuBar = CreateMenu();
137 {HMENU casc = CreatePopupMenu();
138 ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,
"File");
139 ::AppendMenu(casc,MF_STRING,ID_FILE_POSTSCRIPT,
"PS (gl2ps)");
140 ::AppendMenu(casc,MF_STRING,ID_FILE_PIXMAP_POSTSCRIPT,
"PS (pixmap)");
141 ::AppendMenu(casc,MF_STRING,ID_FILE_INVENTOR,
"IV");
142 ::AppendMenu(casc,MF_STRING,ID_FILE_ESCAPE,
"Escape");}
144 {HMENU casc = CreatePopupMenu();
145 ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,
"Etc");
146 ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_DETECTOR,
"Erase detector");
147 ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_EVENT,
"Erase event");
148 ::AppendMenu(casc,MF_STRING,ID_ETC_SET_SOLID,
"Set solid");
150 ::AppendMenu(casc,MF_STRING,ID_ETC_SET_REDUCED_WIRE_FRAME,
151 "Set (G4) reduced wire frame");
152 ::AppendMenu(casc,MF_STRING,ID_ETC_SET_FULL_WIRE_FRAME,
153 "Set (G4) full wire frame");
154 ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PREVIEW,
155 "Visible mothers + invisible daughters");
156 ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PREVIEW_AND_FULL,
157 "Visible mothers + visible daughters");
158 ::AppendMenu(casc,MF_STRING,ID_ETC_UPDATE_SCENE,
"Update scene");
159 ::AppendMenu(casc,MF_STRING,ID_ETC_STATS,
"Scene graph stats");}
161 {HMENU casc = CreatePopupMenu();
162 ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,
"Help");
163 ::AppendMenu(casc,MF_STRING,ID_HELP_CONTROLS,
"Controls");}
165 fShell = ::CreateWindow(className, shellName.c_str(),
166 WS_OVERLAPPEDWINDOW |
167 WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
168 CW_USEDEFAULT, CW_USEDEFAULT,
170 0,menuBar,::GetModuleHandle(0),0);
173 GetWindowRect((HWND)fShell,&wrect);
174 GetClientRect((HWND)fShell,&crect);
175 int ww = wrect.right-wrect.left;
176 int wh = wrect.bottom-wrect.top;
177 int cw = crect.right-crect.left;
178 int ch = crect.bottom-crect.top;
180 MoveWindow((HWND)fShell,wrect.left,wrect.top,width+ww-cw,height+wh-ch,
TRUE);
181 ::SetWindowLongPtr((HWND)fShell,GWLP_USERDATA,LONG(
this));
182 ::SetWindowText((HWND)fShell,shellName.c_str());
184 fInteractorManager->AddShell(fShell);
186 char* str = fInteractorManager->GetCreationString();
187 if(str!=0) wName = str;
189 fViewer =
new Geant4_SoWinExaminerViewer(parent,wName.c_str(),
TRUE);
192 const SbViewportRegion& vpRegion = fViewer->getViewportRegion();
194 fViewer->setGLRenderAction(fGL2PSAction);
196 fViewer->setSize(SbVec2s(width,height));
197 fViewer->setSceneGraph(fSoSelection);
199 fViewer->saveHomePosition();
200 fViewer->setTitle(
fName);
204 fInteractorManager->FlushAndWaitExecution ();
206 fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
209 G4OpenInventorWinViewer::~G4OpenInventorWinViewer () {
210 if(fShell) fInteractorManager->RemoveShell(fShell);
212 fViewer->setSceneGraph(0);
216 ::SetWindowLongPtr((HWND)fShell,GWLP_USERDATA,LONG(0));
217 ::DestroyWindow((HWND)fShell);
221 void G4OpenInventorWinViewer::FinishView () {
224 fViewer->saveHomePosition();
227 void G4OpenInventorWinViewer::SetView () {
228 G4OpenInventorViewer::SetView ();
232 fViewer->setBackgroundColor
235 void G4OpenInventorWinViewer::ViewerRender () {
240 SoCamera* G4OpenInventorWinViewer::GetCamera () {
241 if(!fViewer)
return 0;
242 return fViewer->getCamera();
247 LRESULT CALLBACK G4OpenInventorWinViewer::WindowProc (
262 int width = LOWORD(aLParam);
263 int height = HIWORD(aLParam);
265 G4OpenInventorWinViewer* This =
266 (G4OpenInventorWinViewer*)::GetWindowLongPtr(aWindow,GWLP_USERDATA);
267 if(This && This->fViewer) {
268 This->fViewer->sizeChanged(SbVec2s(width,height));
272 HWND hwnd = ::GetFirstChild(aWindow);
273 if(hwnd!=0) ::SetFocus(hwnd);
281 G4OpenInventorWinViewer* This =
282 (G4OpenInventorWinViewer*)::GetWindowLongPtr(aWindow,GWLP_USERDATA);
286 if(aWParam==ID_FILE_POSTSCRIPT) {
287 This->WritePostScript();
288 }
else if(aWParam==ID_FILE_PIXMAP_POSTSCRIPT) {
289 This->WritePixmapPostScript();
290 }
else if(aWParam==ID_FILE_INVENTOR) {
291 This->WriteInventor();
292 }
else if(aWParam==ID_FILE_ESCAPE) {
295 }
else if(aWParam==ID_ETC_ERASE_DETECTOR) {
296 This->EraseDetector();
297 }
else if(aWParam==ID_ETC_ERASE_EVENT) {
299 }
else if(aWParam==ID_ETC_SET_SOLID) {
301 }
else if(aWParam==ID_ETC_SET_WIRE_FRAME) {
302 This->SetWireFrame();
303 }
else if(aWParam==ID_ETC_SET_REDUCED_WIRE_FRAME) {
304 This->SetReducedWireFrame(
true);
305 }
else if(aWParam==ID_ETC_SET_FULL_WIRE_FRAME) {
306 This->SetReducedWireFrame(
false);
307 }
else if(aWParam==ID_ETC_SET_PREVIEW) {
309 }
else if(aWParam==ID_ETC_SET_PREVIEW_AND_FULL) {
310 This->SetPreviewAndFull();
311 }
else if(aWParam==ID_ETC_UPDATE_SCENE) {
313 }
else if(aWParam==ID_ETC_STATS) {
314 This->SceneGraphStatistics();
316 }
else if(aWParam==ID_HELP_CONTROLS) {
323 return (::DefWindowProc(aWindow,aMessage,aWParam,aLParam));
G4GLOB_DLL std::ostream G4cout
G4double GetGreen() const
static Verbosity GetVerbosity()