Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/G4OpenInventorWinViewer.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenInventor/src/G4OpenInventorWinViewer.cc (Version 11.3.0) and /visualization/OpenInventor/src/G4OpenInventorWinViewer.cc (Version 9.4.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpenInventorWinViewer.cc,v 1.27 2010-11-10 17:53:22 allison Exp $
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
 27 //                                                 29 //
 28 /*                                                 30 /*
 29  * jck : 05 Feb 1997 : Initial Implementation      31  * jck : 05 Feb 1997 : Initial Implementation
 30  * jck : 21 Apr 1997 : Mods for SoXtHepViewer      32  * jck : 21 Apr 1997 : Mods for SoXtHepViewer
 31  * gb : on Win32 use an SoXtExaminerViewer.        33  * gb : on Win32 use an SoXtExaminerViewer.
 32  * gb : 05 April 2004 : creation.                  34  * gb : 05 April 2004 : creation.
 33  * gb : 09 November 2004 : Pulldown menu with      35  * gb : 09 November 2004 : Pulldown menu with the escape menu item.
 34  * gb 14 November 2004 : inherit G4OpenInvento     36  * gb 14 November 2004 : inherit G4OpenInventorViewer.
 35  */                                                37  */
 36                                                    38 
                                                   >>  39 #ifdef G4VIS_BUILD_OIWIN32_DRIVER
                                                   >>  40 
 37 // this :                                          41 // this :
 38 #include "G4OpenInventorWinViewer.hh"              42 #include "G4OpenInventorWinViewer.hh"
 39                                                    43 
 40 #include <Inventor/nodes/SoSelection.h>            44 #include <Inventor/nodes/SoSelection.h>
 41                                                    45 
 42 #include <Inventor/Win/SoWin.h>                    46 #include <Inventor/Win/SoWin.h>
 43 #include <Inventor/Win/viewers/SoWinExaminerVi     47 #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
 44                                                    48 
 45 #include "HEPVis/actions/SoGL2PSAction.h"          49 #include "HEPVis/actions/SoGL2PSAction.h"
 46                                                    50 
 47 #include "G4OpenInventor.hh"                       51 #include "G4OpenInventor.hh"
 48 #include "G4OpenInventorSceneHandler.hh"           52 #include "G4OpenInventorSceneHandler.hh"
 49 #include "G4VInteractorManager.hh"                 53 #include "G4VInteractorManager.hh"
 50 #include "G4VisManager.hh"                         54 #include "G4VisManager.hh"
 51                                                    55 
 52 #include <windowsx.h>                              56 #include <windowsx.h>
 53                                                    57 
 54 // To have sizeChanged public :                    58 // To have sizeChanged public :
 55 class Geant4_SoWinExaminerViewer : public SoWi     59 class Geant4_SoWinExaminerViewer : public SoWinExaminerViewer {
 56 public:                                            60 public:
 57   Geant4_SoWinExaminerViewer(HWND parent,const     61   Geant4_SoWinExaminerViewer(HWND parent,const char* name,SbBool embed)
 58   :SoWinExaminerViewer(parent,name,embed){}        62   :SoWinExaminerViewer(parent,name,embed){}
 59   virtual void sizeChanged(const SbVec2s & siz     63   virtual void sizeChanged(const SbVec2s & size){
 60     SoWinExaminerViewer::sizeChanged(size);        64     SoWinExaminerViewer::sizeChanged(size);
 61   }                                                65   }
 62 };                                                 66 };
 63                                                    67 
 64 // File :                                          68 // File : 
 65 #define ID_FILE_POSTSCRIPT 1                       69 #define ID_FILE_POSTSCRIPT 1
 66 #define ID_FILE_PIXMAP_POSTSCRIPT 2                70 #define ID_FILE_PIXMAP_POSTSCRIPT 2
 67 #define ID_FILE_INVENTOR 3                         71 #define ID_FILE_INVENTOR 3
 68 #define ID_FILE_ESCAPE 4                           72 #define ID_FILE_ESCAPE 4
 69 // Etc :                                           73 // Etc : 
 70 #define ID_ETC_ERASE_DETECTOR 101                  74 #define ID_ETC_ERASE_DETECTOR 101
 71 #define ID_ETC_ERASE_EVENT 102                     75 #define ID_ETC_ERASE_EVENT 102
 72 #define ID_ETC_SET_SOLID 103                       76 #define ID_ETC_SET_SOLID 103
 73 #define ID_ETC_SET_WIRE_FRAME 104                  77 #define ID_ETC_SET_WIRE_FRAME 104
 74 #define ID_ETC_SET_REDUCED_WIRE_FRAME 105          78 #define ID_ETC_SET_REDUCED_WIRE_FRAME 105
 75 #define ID_ETC_SET_FULL_WIRE_FRAME 106             79 #define ID_ETC_SET_FULL_WIRE_FRAME 106
 76 #define ID_ETC_SET_PREVIEW 107                     80 #define ID_ETC_SET_PREVIEW 107
 77 #define ID_ETC_SET_PREVIEW_AND_FULL 108            81 #define ID_ETC_SET_PREVIEW_AND_FULL 108
 78 #define ID_ETC_UPDATE_SCENE 109                    82 #define ID_ETC_UPDATE_SCENE 109
 79 #define ID_ETC_STATS 110                           83 #define ID_ETC_STATS 110
 80 // Help :                                          84 // Help :
 81 #define ID_HELP_CONTROLS 201                       85 #define ID_HELP_CONTROLS 201
 82                                                    86 
 83 //static void SecondaryLoopPostAction ();          87 //static void SecondaryLoopPostAction ();
 84                                                    88 
 85 static const char className[] = "G4OpenInvento     89 static const char className[] = "G4OpenInventorShellWindow";
 86                                                    90 
 87 G4OpenInventorWinViewer::G4OpenInventorWinView     91 G4OpenInventorWinViewer::G4OpenInventorWinViewer(
 88  G4OpenInventorSceneHandler& sceneHandler          92  G4OpenInventorSceneHandler& sceneHandler
 89 ,const G4String& name)                             93 ,const G4String& name)
 90 :G4OpenInventorViewer (sceneHandler, name)         94 :G4OpenInventorViewer (sceneHandler, name)
 91 ,fShell(0)                                         95 ,fShell(0)
 92 ,fViewer(0)                                        96 ,fViewer(0)
 93 {                                                  97 {
 94   if (G4VisManager::GetVerbosity() >= G4VisMan     98   if (G4VisManager::GetVerbosity() >= G4VisManager::confirmations)
 95     G4cout << "Window name: " << fName << G4en     99     G4cout << "Window name: " << fName << G4endl;
 96 }                                                 100 }
 97                                                   101 
 98                                                   102 
 99 void G4OpenInventorWinViewer::Initialise() {      103 void G4OpenInventorWinViewer::Initialise() {
100                                                   104 
101   G4String wName = fName;                         105   G4String wName = fName;
102                                                   106 
103   int width = fVP.GetWindowSizeHintX();        << 107   int width = 600;
104   int height = fVP.GetWindowSizeHintY();;      << 108   int height = 600;
105                                                   109 
106   HWND parent = (HWND)fInteractorManager->GetP    110   HWND parent = (HWND)fInteractorManager->GetParentInteractor ();
107   if(!parent) {                                   111   if(!parent) {
108     //Create a shell window :                     112     //Create a shell window :
109     G4String shellName = wName;                   113     G4String shellName = wName;
110     shellName += "_shell";                        114     shellName += "_shell"; 
111     static SbBool done = FALSE;                   115     static SbBool done = FALSE;
112     if(done==FALSE) {                             116     if(done==FALSE) {
113       HBRUSH brush = (HBRUSH) GetSysColorBrush    117       HBRUSH brush = (HBRUSH) GetSysColorBrush(COLOR_BTNFACE);
114       WNDCLASS wc;                                118       WNDCLASS wc;
115       wc.style = CS_HREDRAW | CS_VREDRAW;         119       wc.style = CS_HREDRAW | CS_VREDRAW;
116       wc.lpfnWndProc = (WNDPROC)WindowProc;       120       wc.lpfnWndProc = (WNDPROC)WindowProc;
117       wc.cbClsExtra = 0;                          121       wc.cbClsExtra = 0;
118       wc.cbWndExtra = 0;                          122       wc.cbWndExtra = 0;
119       wc.hInstance = ::GetModuleHandle(0);        123       wc.hInstance = ::GetModuleHandle(0);
120       wc.hIcon = ::LoadIcon(0, IDI_APPLICATION    124       wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
121       wc.hCursor = ::LoadCursor(0, IDC_ARROW);    125       wc.hCursor = ::LoadCursor(0, IDC_ARROW);
122       wc.hbrBackground = brush;                   126       wc.hbrBackground = brush;
123       wc.lpszMenuName = className;                127       wc.lpszMenuName = className;
124       wc.lpszClassName = className;               128       wc.lpszClassName = className;
125       ::RegisterClass(&wc);                       129       ::RegisterClass(&wc);
126       done = TRUE;                                130       done = TRUE;
127     }                                             131     }
128                                                   132     
129     width = fVP.GetWindowSizeHintX();             133     width = fVP.GetWindowSizeHintX();
130     height = fVP.GetWindowSizeHintX();            134     height = fVP.GetWindowSizeHintX();
131                                                   135     
132     HMENU menuBar = CreateMenu();                 136     HMENU menuBar = CreateMenu();
133                                                   137 
134    {HMENU casc = CreatePopupMenu();               138    {HMENU casc = CreatePopupMenu();
135     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"    139     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"File");
136     ::AppendMenu(casc,MF_STRING,ID_FILE_POSTSC    140     ::AppendMenu(casc,MF_STRING,ID_FILE_POSTSCRIPT,"PS (gl2ps)");
137     ::AppendMenu(casc,MF_STRING,ID_FILE_PIXMAP    141     ::AppendMenu(casc,MF_STRING,ID_FILE_PIXMAP_POSTSCRIPT,"PS (pixmap)");
138     ::AppendMenu(casc,MF_STRING,ID_FILE_INVENT    142     ::AppendMenu(casc,MF_STRING,ID_FILE_INVENTOR,"IV");
139     ::AppendMenu(casc,MF_STRING,ID_FILE_ESCAPE    143     ::AppendMenu(casc,MF_STRING,ID_FILE_ESCAPE,"Escape");}
140                                                   144 
141    {HMENU casc = CreatePopupMenu();               145    {HMENU casc = CreatePopupMenu();
142     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"    146     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"Etc");
143     ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_D    147     ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_DETECTOR,"Erase detector");
144     ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_E    148     ::AppendMenu(casc,MF_STRING,ID_ETC_ERASE_EVENT,"Erase event");
145     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_SOL    149     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_SOLID,"Set solid");
146     //::AppendMenu(casc,MF_STRING,ID_ETC_SET_W    150     //::AppendMenu(casc,MF_STRING,ID_ETC_SET_WIRE_FRAME,"Set (G4) wire frame");
147     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_RED    151     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_REDUCED_WIRE_FRAME,
148                       "Set (G4) reduced wire f    152                       "Set (G4) reduced wire frame");
149     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_FUL    153     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_FULL_WIRE_FRAME,
150                       "Set (G4) full wire fram    154                       "Set (G4) full wire frame");
151     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PRE    155     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PREVIEW,
152                       "Visible mothers + invis    156                       "Visible mothers + invisible daughters");
153     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PRE    157     ::AppendMenu(casc,MF_STRING,ID_ETC_SET_PREVIEW_AND_FULL,
154                       "Visible mothers + visib    158                       "Visible mothers + visible daughters");
155     ::AppendMenu(casc,MF_STRING,ID_ETC_UPDATE_    159     ::AppendMenu(casc,MF_STRING,ID_ETC_UPDATE_SCENE,"Update scene");
156     ::AppendMenu(casc,MF_STRING,ID_ETC_STATS,"    160     ::AppendMenu(casc,MF_STRING,ID_ETC_STATS,"Scene graph stats");}
157                                                   161 
158    {HMENU casc = CreatePopupMenu();               162    {HMENU casc = CreatePopupMenu();
159     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"    163     ::AppendMenu(menuBar,MF_POPUP,(UINT)casc,"Help");
160     ::AppendMenu(casc,MF_STRING,ID_HELP_CONTRO    164     ::AppendMenu(casc,MF_STRING,ID_HELP_CONTROLS,"Controls");}
161                                                   165 
162     fShell = ::CreateWindow(className, shellNa    166     fShell = ::CreateWindow(className, shellName.c_str(), 
163                             WS_OVERLAPPEDWINDO    167                             WS_OVERLAPPEDWINDOW |
164                             WS_VISIBLE | WS_CL    168                             WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
165                             CW_USEDEFAULT, CW_    169                             CW_USEDEFAULT, CW_USEDEFAULT, 
166                             width,height,         170                             width,height,
167                             0,menuBar,::GetMod    171                             0,menuBar,::GetModuleHandle(0),0);
168     // Retreive window and client sizez :         172     // Retreive window and client sizez :
169     RECT wrect,crect;                             173     RECT wrect,crect;
170     GetWindowRect((HWND)fShell,&wrect);           174     GetWindowRect((HWND)fShell,&wrect);
171     GetClientRect((HWND)fShell,&crect);           175     GetClientRect((HWND)fShell,&crect);
172     int ww = wrect.right-wrect.left;              176     int ww = wrect.right-wrect.left;
173     int wh = wrect.bottom-wrect.top;              177     int wh = wrect.bottom-wrect.top;
174     int cw = crect.right-crect.left;              178     int cw = crect.right-crect.left;
175     int ch = crect.bottom-crect.top;              179     int ch = crect.bottom-crect.top;
176     // Compell client rect to be width height     180     // Compell client rect to be width height :
177     MoveWindow((HWND)fShell,wrect.left,wrect.t    181     MoveWindow((HWND)fShell,wrect.left,wrect.top,width+ww-cw,height+wh-ch,TRUE);
178     ::SetWindowLongPtr((HWND)fShell,GWLP_USERD << 182     ::SetWindowLong((HWND)fShell,GWL_USERDATA,LONG(this));
179     ::SetWindowText((HWND)fShell,shellName.c_s    183     ::SetWindowText((HWND)fShell,shellName.c_str());
180     parent = fShell;                              184     parent = fShell;
181     fInteractorManager->AddShell(fShell);         185     fInteractorManager->AddShell(fShell);
182   } else {                                        186   } else {
183     char* str = fInteractorManager->GetCreatio    187     char* str = fInteractorManager->GetCreationString();
184     if(str!=0) wName = str;                       188     if(str!=0) wName = str;
185   }                                               189   }
186   fViewer = new Geant4_SoWinExaminerViewer(par    190   fViewer = new Geant4_SoWinExaminerViewer(parent,wName.c_str(),TRUE);
187                                                   191 
188   // Have a GL2PS render action :                 192   // Have a GL2PS render action :
189   const SbViewportRegion& vpRegion = fViewer->    193   const SbViewportRegion& vpRegion = fViewer->getViewportRegion();
190   fGL2PSAction = new SoGL2PSAction(vpRegion);     194   fGL2PSAction = new SoGL2PSAction(vpRegion);
191   fViewer->setGLRenderAction(fGL2PSAction);       195   fViewer->setGLRenderAction(fGL2PSAction);
192                                                   196 
193   fViewer->setSize(SbVec2s(width,height));        197   fViewer->setSize(SbVec2s(width,height));
194   fViewer->setSceneGraph(fSoSelection);           198   fViewer->setSceneGraph(fSoSelection);
195   fViewer->viewAll();                             199   fViewer->viewAll();
196   fViewer->saveHomePosition();                    200   fViewer->saveHomePosition();
197   fViewer->setTitle(fName);                       201   fViewer->setTitle(fName);
198   fViewer->show();                                202   fViewer->show();
199   if(fShell) {                                    203   if(fShell) {
200     SoWin::show(fShell);                          204     SoWin::show(fShell);
201     fInteractorManager->FlushAndWaitExecution     205     fInteractorManager->FlushAndWaitExecution ();
202   }                                               206   }
203   fInteractorManager->SetCreatedInteractor (fV    207   fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
204   fViewer->setTransparencyType(SoGLRenderActio << 
205 }                                                 208 }
206                                                   209 
207 G4OpenInventorWinViewer::~G4OpenInventorWinVie    210 G4OpenInventorWinViewer::~G4OpenInventorWinViewer () {
208   if(fShell) fInteractorManager->RemoveShell(f    211   if(fShell) fInteractorManager->RemoveShell(fShell);
209   if(fViewer) {                                   212   if(fViewer) {
210     fViewer->setSceneGraph(0);                    213     fViewer->setSceneGraph(0);
211     delete fViewer;                               214     delete fViewer;
212   }                                               215   }
213   if(fShell) {                                    216   if(fShell) {
214     ::SetWindowLongPtr((HWND)fShell,GWLP_USERD << 217     ::SetWindowLong((HWND)fShell,GWL_USERDATA,LONG(0));
215     ::DestroyWindow((HWND)fShell);                218     ::DestroyWindow((HWND)fShell);
216   }                                               219   }
217 }                                                 220 }
218                                                   221 
219 void G4OpenInventorWinViewer::FinishView () {     222 void G4OpenInventorWinViewer::FinishView () {
220   if(!fViewer) return;                            223   if(!fViewer) return;
221   fViewer->viewAll();                             224   fViewer->viewAll();
222   fViewer->saveHomePosition();                    225   fViewer->saveHomePosition();
223 }                                                 226 }
224                                                   227 
225 void G4OpenInventorWinViewer::SetView () {        228 void G4OpenInventorWinViewer::SetView () {
226   G4OpenInventorViewer::SetView ();               229   G4OpenInventorViewer::SetView ();
227   if(!fViewer) return;                            230   if(!fViewer) return;
228   // Background.                                  231   // Background.
229   G4Colour b = fVP.GetBackgroundColour ();        232   G4Colour b = fVP.GetBackgroundColour ();
230   fViewer->setBackgroundColor                     233   fViewer->setBackgroundColor
231     (SbColor((float)b.GetRed(),(float)b.GetGre    234     (SbColor((float)b.GetRed(),(float)b.GetGreen(),(float)b.GetBlue()));
232 }                                                 235 }
233 void G4OpenInventorWinViewer::ViewerRender ()     236 void G4OpenInventorWinViewer::ViewerRender () {
234   if(!fViewer) return;                            237   if(!fViewer) return;
235   fViewer->render();                              238   fViewer->render();
236 }                                                 239 }
237                                                   240 
238 SoCamera* G4OpenInventorWinViewer::GetCamera (    241 SoCamera* G4OpenInventorWinViewer::GetCamera () {
239   if(!fViewer) return 0;                          242   if(!fViewer) return 0;
240   return fViewer->getCamera();                    243   return fViewer->getCamera();
241 }                                                 244 }
242                                                   245 
243                                                   246 
244 //////////////////////////////////////////////    247 //////////////////////////////////////////////////////////////////////////////
245 LRESULT CALLBACK G4OpenInventorWinViewer::Wind    248 LRESULT CALLBACK G4OpenInventorWinViewer::WindowProc ( 
246  HWND   aWindow                                   249  HWND   aWindow
247 ,UINT   aMessage                                  250 ,UINT   aMessage
248 ,WPARAM aWParam                                   251 ,WPARAM aWParam
249 ,LPARAM aLParam                                   252 ,LPARAM aLParam
250 )                                                 253 )
251 //////////////////////////////////////////////    254 //////////////////////////////////////////////////////////////////////////////
252 //  Below treatment of WM_SIZE, WM_SETFOCUS no    255 //  Below treatment of WM_SIZE, WM_SETFOCUS not necessary 
253 // with TGS, but needed with SoFree. WM_DESTRO    256 // with TGS, but needed with SoFree. WM_DESTROY needed for 
254 // 'main top level window' so that 'Close wind    257 // 'main top level window' so that 'Close window' induces
255 // the end of the task.                           258 // the end of the task.
256 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    259 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
257 {                                                 260 {
258   switch (aMessage) {                             261   switch (aMessage) { 
259   case WM_SIZE:{ // Assume one child window !     262   case WM_SIZE:{ // Assume one child window !
260     int width = LOWORD(aLParam);                  263     int width = LOWORD(aLParam);
261     int height = HIWORD(aLParam);                 264     int height = HIWORD(aLParam);
262     //printf("debug : G4SoWindow : WMS_SIZE :     265     //printf("debug : G4SoWindow : WMS_SIZE : %d %d\n",width,height);
263     G4OpenInventorWinViewer* This =               266     G4OpenInventorWinViewer* This = 
264       (G4OpenInventorWinViewer*)::GetWindowLon << 267       (G4OpenInventorWinViewer*)::GetWindowLong(aWindow,GWL_USERDATA);
265     if(This && This->fViewer) {                   268     if(This && This->fViewer) {
266       This->fViewer->sizeChanged(SbVec2s(width    269       This->fViewer->sizeChanged(SbVec2s(width,height));
267     }                                             270     }
268   }return 0;                                      271   }return 0;
269   case WM_SETFOCUS:{ // Assume one child windo    272   case WM_SETFOCUS:{ // Assume one child window !
270     HWND hwnd = ::GetFirstChild(aWindow);         273     HWND hwnd = ::GetFirstChild(aWindow);
271     if(hwnd!=0) ::SetFocus(hwnd);                 274     if(hwnd!=0) ::SetFocus(hwnd);
272   }return 0;                                      275   }return 0;
273   case WM_DESTROY:{                               276   case WM_DESTROY:{
274     //G4OpenInventorWinViewer* This =             277     //G4OpenInventorWinViewer* This = 
275     //  (G4OpenInventorWinViewer*)::GetWindowL << 278     //  (G4OpenInventorWinViewer*)::GetWindowLong(aWindow,GWL_USERDATA);
276     //::PostQuitMessage(0);                       279     //::PostQuitMessage(0);
277   }return 0;                                      280   }return 0;
278   case WM_COMMAND:{                               281   case WM_COMMAND:{
279     G4OpenInventorWinViewer* This =               282     G4OpenInventorWinViewer* This = 
280       (G4OpenInventorWinViewer*)::GetWindowLon << 283       (G4OpenInventorWinViewer*)::GetWindowLong(aWindow,GWL_USERDATA);
281     if(This) {                                    284     if(This) {
282       if(aLParam==0) { //From menu.               285       if(aLParam==0) { //From menu.
283         // File :                                 286         // File :
284         if(aWParam==ID_FILE_POSTSCRIPT) {         287         if(aWParam==ID_FILE_POSTSCRIPT) {
285           This->WritePostScript();                288           This->WritePostScript();
286         } else if(aWParam==ID_FILE_PIXMAP_POST    289         } else if(aWParam==ID_FILE_PIXMAP_POSTSCRIPT) {
287           This->WritePixmapPostScript();          290           This->WritePixmapPostScript();
288         } else if(aWParam==ID_FILE_INVENTOR) {    291         } else if(aWParam==ID_FILE_INVENTOR) {
289           This->WriteInventor();                  292           This->WriteInventor();
290         } else if(aWParam==ID_FILE_ESCAPE) {      293         } else if(aWParam==ID_FILE_ESCAPE) {
291           This->Escape();                         294           This->Escape();
292         // Etc :                                  295         // Etc :
293         } else if(aWParam==ID_ETC_ERASE_DETECT    296         } else if(aWParam==ID_ETC_ERASE_DETECTOR) {
294           This->EraseDetector();                  297           This->EraseDetector();
295         } else if(aWParam==ID_ETC_ERASE_EVENT)    298         } else if(aWParam==ID_ETC_ERASE_EVENT) {
296           This->EraseEvent();                     299           This->EraseEvent();
297         } else if(aWParam==ID_ETC_SET_SOLID) {    300         } else if(aWParam==ID_ETC_SET_SOLID) {
298           This->SetSolid();                       301           This->SetSolid();
299         } else if(aWParam==ID_ETC_SET_WIRE_FRA    302         } else if(aWParam==ID_ETC_SET_WIRE_FRAME) {
300           This->SetWireFrame();                   303           This->SetWireFrame();
301         } else if(aWParam==ID_ETC_SET_REDUCED_    304         } else if(aWParam==ID_ETC_SET_REDUCED_WIRE_FRAME) {
302           This->SetReducedWireFrame(true);        305           This->SetReducedWireFrame(true);
303         } else if(aWParam==ID_ETC_SET_FULL_WIR    306         } else if(aWParam==ID_ETC_SET_FULL_WIRE_FRAME) {
304           This->SetReducedWireFrame(false);       307           This->SetReducedWireFrame(false);
305         } else if(aWParam==ID_ETC_SET_PREVIEW)    308         } else if(aWParam==ID_ETC_SET_PREVIEW) {
306           This->SetPreview();                     309           This->SetPreview();
307         } else if(aWParam==ID_ETC_SET_PREVIEW_    310         } else if(aWParam==ID_ETC_SET_PREVIEW_AND_FULL) {
308           This->SetPreviewAndFull();              311           This->SetPreviewAndFull();
309         } else if(aWParam==ID_ETC_UPDATE_SCENE    312         } else if(aWParam==ID_ETC_UPDATE_SCENE) {
310           This->UpdateScene();                    313           This->UpdateScene();
311         } else if(aWParam==ID_ETC_STATS) {        314         } else if(aWParam==ID_ETC_STATS) {
312           This->SceneGraphStatistics();           315           This->SceneGraphStatistics();
313         // Help :                                 316         // Help :
314         } else if(aWParam==ID_HELP_CONTROLS) {    317         } else if(aWParam==ID_HELP_CONTROLS) {
315           G4cout << This->Help() << G4endl;       318           G4cout << This->Help() << G4endl;
316         }                                         319         }
317       }                                           320       }
318     }                                             321     }
319   }return 0;                                      322   }return 0;
320   default:                                        323   default:
321     return (::DefWindowProc(aWindow,aMessage,a    324     return (::DefWindowProc(aWindow,aMessage,aWParam,aLParam));
322   }                                               325   }
323 }                                                 326 }
                                                   >> 327 
                                                   >> 328 #endif
324                                                   329