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());
207 fViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_ADD);
210 G4OpenInventorWinViewer::~G4OpenInventorWinViewer () {
211 if(fShell) fInteractorManager->RemoveShell(fShell);
213 fViewer->setSceneGraph(0);
217 ::SetWindowLongPtr((HWND)fShell,GWLP_USERDATA,LONG(0));
218 ::DestroyWindow((HWND)fShell);
222 void G4OpenInventorWinViewer::FinishView () {
225 fViewer->saveHomePosition();
228 void G4OpenInventorWinViewer::SetView () {
229 G4OpenInventorViewer::SetView ();
232 G4Colour b = fVP.GetBackgroundColour ();
233 fViewer->setBackgroundColor
236 void G4OpenInventorWinViewer::ViewerRender () {
241 SoCamera* G4OpenInventorWinViewer::GetCamera () {
242 if(!fViewer)
return 0;
243 return fViewer->getCamera();
248 LRESULT CALLBACK G4OpenInventorWinViewer::WindowProc (
263 int width = LOWORD(aLParam);
264 int height = HIWORD(aLParam);
266 G4OpenInventorWinViewer* This =
267 (G4OpenInventorWinViewer*)::GetWindowLongPtr(aWindow,GWLP_USERDATA);
268 if(This && This->fViewer) {
269 This->fViewer->sizeChanged(SbVec2s(width,height));
273 HWND hwnd = ::GetFirstChild(aWindow);
274 if(hwnd!=0) ::SetFocus(hwnd);
282 G4OpenInventorWinViewer* This =
283 (G4OpenInventorWinViewer*)::GetWindowLongPtr(aWindow,GWLP_USERDATA);
287 if(aWParam==ID_FILE_POSTSCRIPT) {
288 This->WritePostScript();
289 }
else if(aWParam==ID_FILE_PIXMAP_POSTSCRIPT) {
290 This->WritePixmapPostScript();
291 }
else if(aWParam==ID_FILE_INVENTOR) {
292 This->WriteInventor();
293 }
else if(aWParam==ID_FILE_ESCAPE) {
296 }
else if(aWParam==ID_ETC_ERASE_DETECTOR) {
297 This->EraseDetector();
298 }
else if(aWParam==ID_ETC_ERASE_EVENT) {
300 }
else if(aWParam==ID_ETC_SET_SOLID) {
302 }
else if(aWParam==ID_ETC_SET_WIRE_FRAME) {
303 This->SetWireFrame();
304 }
else if(aWParam==ID_ETC_SET_REDUCED_WIRE_FRAME) {
305 This->SetReducedWireFrame(
true);
306 }
else if(aWParam==ID_ETC_SET_FULL_WIRE_FRAME) {
307 This->SetReducedWireFrame(
false);
308 }
else if(aWParam==ID_ETC_SET_PREVIEW) {
310 }
else if(aWParam==ID_ETC_SET_PREVIEW_AND_FULL) {
311 This->SetPreviewAndFull();
312 }
else if(aWParam==ID_ETC_UPDATE_SCENE) {
314 }
else if(aWParam==ID_ETC_STATS) {
315 This->SceneGraphStatistics();
317 }
else if(aWParam==ID_HELP_CONTROLS) {
324 return (::DefWindowProc(aWindow,aMessage,aWParam,aLParam));
static Verbosity GetVerbosity()
G4GLOB_DLL std::ostream G4cout
G4double GetGreen() const