Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/FukuiRenderer/src/G4DAWNFILEViewer.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/FukuiRenderer/src/G4DAWNFILEViewer.cc (Version 11.3.0) and /visualization/FukuiRenderer/src/G4DAWNFILEViewer.cc (Version 11.2.1)


  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 //                                                 27 //
 28 // Satoshi TANAKA                                  28 // Satoshi TANAKA
 29 // DAWNFILE view - opens window, hard copy, et     29 // DAWNFILE view - opens window, hard copy, etc.
 30                                                    30 
 31 #define __G_ANSI_C__                               31 #define __G_ANSI_C__
 32 #define G4DAWNFILE_STRUCTURE_PRIORITY 1.           32 #define G4DAWNFILE_STRUCTURE_PRIORITY 1.
 33                                                    33 
 34 // #define DEBUG_FR_VIEW                           34 // #define DEBUG_FR_VIEW
 35                                                    35 
 36 #include "G4ios.hh"                                36 #include "G4ios.hh"
 37 #include <stdio.h>                                 37 #include <stdio.h>
 38 #include <string.h>                                38 #include <string.h>
 39 #include <assert.h>                                39 #include <assert.h>
 40                                                    40 
 41 #include "G4VisManager.hh"                         41 #include "G4VisManager.hh"
 42 #include "G4Scene.hh"                              42 #include "G4Scene.hh"
 43 #include "G4Vector3D.hh"                           43 #include "G4Vector3D.hh"
 44 #include "G4VisExtent.hh"                          44 #include "G4VisExtent.hh"
 45 #include "G4LogicalVolume.hh"                      45 #include "G4LogicalVolume.hh"
 46 #include "G4VSolid.hh"                             46 #include "G4VSolid.hh"
 47 #include "G4PhysicalConstants.hh"                  47 #include "G4PhysicalConstants.hh"
 48                                                    48 
 49 #include "G4FRConst.hh"                            49 #include "G4FRConst.hh"
 50 #include "G4DAWNFILE.hh"                           50 #include "G4DAWNFILE.hh"
 51 #include "G4DAWNFILESceneHandler.hh"               51 #include "G4DAWNFILESceneHandler.hh"
 52 #include "G4DAWNFILEViewer.hh"                     52 #include "G4DAWNFILEViewer.hh"
 53                                                    53 
 54 //----- constants                                  54 //----- constants
 55 const char FR_ENV_MULTI_WINDOW[]  = "G4DAWN_MU     55 const char FR_ENV_MULTI_WINDOW[]  = "G4DAWN_MULTI_WINDOW";
 56 const char FR_ENV_MULTI_WINDOW2[] = "G4DAWNFIL     56 const char FR_ENV_MULTI_WINDOW2[] = "G4DAWNFILE_MULTI_WINDOW";
 57                                                    57 
 58 //----- G4DAWNFILEViewer, constructor              58 //----- G4DAWNFILEViewer, constructor
 59 G4DAWNFILEViewer::G4DAWNFILEViewer(G4DAWNFILES     59 G4DAWNFILEViewer::G4DAWNFILEViewer(G4DAWNFILESceneHandler& sceneHandler,
 60                                    const G4Str     60                                    const G4String& name)
 61   : G4VViewer(sceneHandler, sceneHandler.Incre     61   : G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
 62   , fSceneHandler(sceneHandler)                    62   , fSceneHandler(sceneHandler)
 63 {                                                  63 {
 64   // Set a g4.prim-file viewer                     64   // Set a g4.prim-file viewer
 65   strcpy(fG4PrimViewer, "dawn");                   65   strcpy(fG4PrimViewer, "dawn");
 66   if(std::getenv("G4DAWNFILE_VIEWER") != NULL)     66   if(std::getenv("G4DAWNFILE_VIEWER") != NULL)
 67   {                                                67   {
 68     strcpy(fG4PrimViewer, std::getenv("G4DAWNF     68     strcpy(fG4PrimViewer, std::getenv("G4DAWNFILE_VIEWER"));
 69   }                                                69   }
 70                                                    70 
 71   // string for viewer invocation                  71   // string for viewer invocation
 72   if(!strcmp(fG4PrimViewer, "NONE"))               72   if(!strcmp(fG4PrimViewer, "NONE"))
 73   {                                                73   {
 74     strcpy(fG4PrimViewerInvocation, "");           74     strcpy(fG4PrimViewerInvocation, "");
 75   }                                                75   }
 76   else                                             76   else
 77   {                                                77   {
 78     strcpy(fG4PrimViewerInvocation, fG4PrimVie     78     strcpy(fG4PrimViewerInvocation, fG4PrimViewer);
 79     strcat(fG4PrimViewerInvocation, " ");          79     strcat(fG4PrimViewerInvocation, " ");
 80     strcat(fG4PrimViewerInvocation, fSceneHand     80     strcat(fG4PrimViewerInvocation, fSceneHandler.GetG4PrimFileName());
 81   }                                                81   }
 82                                                    82 
 83   // Set a PostScript Viewer                       83   // Set a PostScript Viewer
 84   //  strcpy( fPSViewer, "ghostview" );            84   //  strcpy( fPSViewer, "ghostview" );
 85   strcpy(fPSViewer, "gv");                         85   strcpy(fPSViewer, "gv");
 86   if(std::getenv("G4DAWNFILE_PS_VIEWER") != NU     86   if(std::getenv("G4DAWNFILE_PS_VIEWER") != NULL)
 87   {                                                87   {
 88     strcpy(fPSViewer, std::getenv("G4DAWNFILE_     88     strcpy(fPSViewer, std::getenv("G4DAWNFILE_PS_VIEWER"));
 89   }                                                89   }
 90 }                                                  90 }
 91                                                    91 
 92 //----- G4DAWNFILEViewer, destructor               92 //----- G4DAWNFILEViewer, destructor
 93 G4DAWNFILEViewer::~G4DAWNFILEViewer() {}           93 G4DAWNFILEViewer::~G4DAWNFILEViewer() {}
 94                                                    94 
 95 //----- G4DAWNFILEViewer::SetView ()               95 //----- G4DAWNFILEViewer::SetView ()
 96 void G4DAWNFILEViewer::SetView()                   96 void G4DAWNFILEViewer::SetView()
 97 {                                                  97 {
 98 #if defined DEBUG_FR_VIEW                          98 #if defined DEBUG_FR_VIEW
 99   if(G4VisManager::GetVerbosity() >= G4VisMana     99   if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
100     G4cout << "***** G4DAWNFILEViewer::SetView    100     G4cout << "***** G4DAWNFILEViewer::SetView(): No effects" << G4endl;
101 #endif                                            101 #endif
102   // Do nothing, since DAWN is running as a di    102   // Do nothing, since DAWN is running as a different process.
103   // SendViewParameters () will do this job in    103   // SendViewParameters () will do this job instead.
104 }                                                 104 }
105                                                   105 
106 //----- G4DAWNFILEViewer::ClearView()             106 //----- G4DAWNFILEViewer::ClearView()
107 void G4DAWNFILEViewer::ClearView(void)            107 void G4DAWNFILEViewer::ClearView(void)
108 {                                                 108 {
109 #if defined DEBUG_FR_VIEW                         109 #if defined DEBUG_FR_VIEW
110   if(G4VisManager::GetVerbosity() >= G4VisMana    110   if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
111     G4cout << "***** G4DAWNFILEViewer::ClearVi    111     G4cout << "***** G4DAWNFILEViewer::ClearView (): No effects " << G4endl;
112 #endif                                            112 #endif
113   if(fSceneHandler.fPrimDest.IsOpen())            113   if(fSceneHandler.fPrimDest.IsOpen())
114   {                                               114   {
115     fSceneHandler.fPrimDest.Close();              115     fSceneHandler.fPrimDest.Close();
116     // Re-open with same filename...              116     // Re-open with same filename...
117     fSceneHandler.fPrimDest.Open(fSceneHandler    117     fSceneHandler.fPrimDest.Open(fSceneHandler.fG4PrimFileName);
118     fSceneHandler.SendStr(FR_G4_PRIM_HEADER);     118     fSceneHandler.SendStr(FR_G4_PRIM_HEADER);
119     fSceneHandler.FRflag_in_modeling = false;     119     fSceneHandler.FRflag_in_modeling = false;
120     fSceneHandler.FRBeginModeling();              120     fSceneHandler.FRBeginModeling();
121   }                                               121   }
122 }                                                 122 }
123                                                   123 
124 //----- G4DAWNFILEViewer::DrawView ()             124 //----- G4DAWNFILEViewer::DrawView ()
125 void G4DAWNFILEViewer::DrawView()                 125 void G4DAWNFILEViewer::DrawView()
126 {                                                 126 {
127 #if defined DEBUG_FR_VIEW                         127 #if defined DEBUG_FR_VIEW
128   if(G4VisManager::GetVerbosity() >= G4VisMana    128   if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
129     G4cout << "***** G4DAWNFILEViewer::DrawVie    129     G4cout << "***** G4DAWNFILEViewer::DrawView () " << G4endl;
130 #endif                                            130 #endif
131   //-----                                         131   //-----
132   fSceneHandler.FRBeginModeling();                132   fSceneHandler.FRBeginModeling();
133                                                   133 
134   //----- Always visit G4 kernel                  134   //----- Always visit G4 kernel
135   NeedKernelVisit();                              135   NeedKernelVisit();
136                                                   136 
137   //----- Draw                                    137   //----- Draw
138   ProcessView();                                  138   ProcessView();
139                                                   139 
140 }  // G4DAWNFILEViewer::DrawView ()               140 }  // G4DAWNFILEViewer::DrawView ()
141                                                   141 
142 //----- G4DAWNFILEViewer::ShowView()              142 //----- G4DAWNFILEViewer::ShowView()
143 void G4DAWNFILEViewer::ShowView(void)             143 void G4DAWNFILEViewer::ShowView(void)
144 {                                                 144 {
145 #if defined DEBUG_FR_VIEW                         145 #if defined DEBUG_FR_VIEW
146   if(G4VisManager::GetVerbosity() >= G4VisMana    146   if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
147     G4cout << "***** G4DAWNFILEViewer::ShowVie    147     G4cout << "***** G4DAWNFILEViewer::ShowView () " << G4endl;
148 #endif                                            148 #endif
149                                                   149 
150   if(fSceneHandler.FRIsInModeling())              150   if(fSceneHandler.FRIsInModeling())
151   {                                               151   {
152     //----- End of modeling                       152     //----- End of modeling
153     // !EndModeling, !DrawAll, !CloseDevice,      153     // !EndModeling, !DrawAll, !CloseDevice,
154     // close g4.prim                              154     // close g4.prim
155     fSceneHandler.FREndModeling();                155     fSceneHandler.FREndModeling();
156                                                   156 
157     //----- Output DAWN GUI file                  157     //----- Output DAWN GUI file
158     SendViewParameters();                         158     SendViewParameters();
159                                                   159 
160     //----- string for viewer invocation          160     //----- string for viewer invocation
161     if(!strcmp(fG4PrimViewer, "NONE"))            161     if(!strcmp(fG4PrimViewer, "NONE"))
162     {                                             162     {
163       strcpy(fG4PrimViewerInvocation, "");        163       strcpy(fG4PrimViewerInvocation, "");
164     }                                             164     }
165     else                                          165     else
166     {                                             166     {
167       strcpy(fG4PrimViewerInvocation, fG4PrimV    167       strcpy(fG4PrimViewerInvocation, fG4PrimViewer);
168       strcat(fG4PrimViewerInvocation, " ");       168       strcat(fG4PrimViewerInvocation, " ");
169       strcat(fG4PrimViewerInvocation, fSceneHa    169       strcat(fG4PrimViewerInvocation, fSceneHandler.GetG4PrimFileName());
170     }                                             170     }
171                                                   171 
172     //----- Invoke DAWN                           172     //----- Invoke DAWN
173     G4cout << G4endl;                             173     G4cout << G4endl;
174     if(false == G4FRofstream::DoesFileExist(fS    174     if(false == G4FRofstream::DoesFileExist(fSceneHandler.GetG4PrimFileName()))
175     {                                             175     {
176       G4cout << "ERROR: Failed to generate fil    176       G4cout << "ERROR: Failed to generate file  ";
177       G4cout << fSceneHandler.GetG4PrimFileNam    177       G4cout << fSceneHandler.GetG4PrimFileName() << G4endl;
178     }                                             178     }
179     else if(strcmp(GetG4PrimViewerInvocation()    179     else if(strcmp(GetG4PrimViewerInvocation(), ""))
180     {                                             180     {
181       G4cout << "File  " << fSceneHandler.GetG    181       G4cout << "File  " << fSceneHandler.GetG4PrimFileName();
182       G4cout << "  is generated." << G4endl;      182       G4cout << "  is generated." << G4endl;
183       G4cout << GetG4PrimViewerInvocation() <<    183       G4cout << GetG4PrimViewerInvocation() << G4endl;
184       int iErr = system(GetG4PrimViewerInvocat    184       int iErr = system(GetG4PrimViewerInvocation());
185       if(iErr != 0)                               185       if(iErr != 0)
186       {                                           186       {
187         G4ExceptionDescription ed;                187         G4ExceptionDescription ed;
188         ed << "Error " << iErr << " when calli    188         ed << "Error " << iErr << " when calling system with \""
189            << GetG4PrimViewerInvocation() << "    189            << GetG4PrimViewerInvocation() << "\".";
190         G4Exception("G4DAWNFILEViewer::ShowVie    190         G4Exception("G4DAWNFILEViewer::ShowView()", "dawn0005", JustWarning,
191                     ed);                          191                     ed);
192       }                                           192       }
193     }                                             193     }
194     else                                          194     else
195     {  // no view, i.e., only file generation     195     {  // no view, i.e., only file generation
196       G4cout << "File  " << fSceneHandler.GetG    196       G4cout << "File  " << fSceneHandler.GetG4PrimFileName();
197       G4cout << "  is generated." << G4endl;      197       G4cout << "  is generated." << G4endl;
198       G4cout << "No viewer is invoked." << G4e    198       G4cout << "No viewer is invoked." << G4endl;
199     }                                             199     }
200   }                                               200   }
201                                                   201 
202 }  // G4DAWNFILEViewer::ShowView()                202 }  // G4DAWNFILEViewer::ShowView()
203                                                   203 
204 //----- G4DAWNFILEViewer::SendDrawingStyleToDA    204 //----- G4DAWNFILEViewer::SendDrawingStyleToDAWNGUI( std::ostream& out )
205 void G4DAWNFILEViewer::SendDrawingStyleToDAWNG    205 void G4DAWNFILEViewer::SendDrawingStyleToDAWNGUI(std::ostream& out)
206 {                                                 206 {
207   ///////////////////////                         207   ///////////////////////
208   //#if defined DEBUG_FR_VIEW                     208   //#if defined DEBUG_FR_VIEW
209   //  G4cout << "***** G4DAWNFILEViewer::SendD    209   //  G4cout << "***** G4DAWNFILEViewer::SendDrawingStyleToDAWNGUI()" << G4endl;
210   //#endif                                        210   //#endif
211   //////////////////////                          211   //////////////////////
212                                                   212 
213   G4int style = fVP.GetDrawingStyle();            213   G4int style = fVP.GetDrawingStyle();
214                                                   214 
215   enum                                            215   enum
216   {                                               216   {
217     FR_WIREFRAME_STYLE        = 1,                217     FR_WIREFRAME_STYLE        = 1,
218     FR_WF_STORED_STYLE        = 2,                218     FR_WF_STORED_STYLE        = 2,
219     FR_HID_STYLE              = 3,                219     FR_HID_STYLE              = 3,
220     FR_HID2_STYLE             = 4,                220     FR_HID2_STYLE             = 4,
221     FR_HID3_STYLE             = 5,                221     FR_HID3_STYLE             = 5,
222     FR_DRAWING_MODE_END_STYLE = 6                 222     FR_DRAWING_MODE_END_STYLE = 6
223   };                                              223   };
224                                                   224 
225   switch(style)                                   225   switch(style)
226   {                                               226   {
227     case G4ViewParameters::wireframe:             227     case G4ViewParameters::wireframe:
228       out << FR_WIREFRAME_STYLE << G4endl;        228       out << FR_WIREFRAME_STYLE << G4endl;
229       break;                                      229       break;
230     case G4ViewParameters::hlr:                   230     case G4ViewParameters::hlr:
231       out << FR_HID2_STYLE << G4endl;  // LINE    231       out << FR_HID2_STYLE << G4endl;  // LINE
232       break;                                      232       break;
233     case G4ViewParameters::hsr:                   233     case G4ViewParameters::hsr:
234     case G4ViewParameters::hlhsr:                 234     case G4ViewParameters::hlhsr:
235       out << FR_HID_STYLE << G4endl;  // SURFA    235       out << FR_HID_STYLE << G4endl;  // SURFACE
236       break;                                      236       break;
237     default:                                      237     default:
238       out << FR_WIREFRAME_STYLE << G4endl;        238       out << FR_WIREFRAME_STYLE << G4endl;
239       break;                                      239       break;
240   }                                               240   }
241                                                   241 
242 }  // G4DAWNFILEViewer::SendDrawingStyle()        242 }  // G4DAWNFILEViewer::SendDrawingStyle()
243                                                   243 
244 //-----                                           244 //-----
245 void G4DAWNFILEViewer::SendViewParameters()       245 void G4DAWNFILEViewer::SendViewParameters()
246 {                                                 246 {
247   // Calculates view representation based on e    247   // Calculates view representation based on extent of object being
248   // viewed and (initial) direction of camera.    248   // viewed and (initial) direction of camera.  (Note: it can change
249   // later due to user interaction via visuali    249   // later due to user interaction via visualization system's GUI.)
250                                                   250 
251 #if defined DEBUG_FR_VIEW                         251 #if defined DEBUG_FR_VIEW
252   if(G4VisManager::GetVerbosity() >= G4VisMana    252   if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
253   {                                               253   {
254     G4cout << "***** G4DAWNFILEViewer::SendVie    254     G4cout << "***** G4DAWNFILEViewer::SendViewParameters()  ";
255     G4cout << "(GUI parameters)" << G4endl;       255     G4cout << "(GUI parameters)" << G4endl;
256   }                                               256   }
257 #endif                                            257 #endif
258                                                   258 
259   //----- Magic number to decide camera distan    259   //----- Magic number to decide camera distance automatically
260   const G4double HOW_FAR        = 1000.0;  //     260   const G4double HOW_FAR        = 1000.0;  // to define "infinity"
261   const G4double MIN_HALF_ANGLE = 0.01;           261   const G4double MIN_HALF_ANGLE = 0.01;
262   const G4double MAX_HALF_ANGLE = 0.499 * pi;     262   const G4double MAX_HALF_ANGLE = 0.499 * pi;
263                                                   263 
264   //----- CALC camera distance                    264   //----- CALC camera distance
265   //..... Note: Camera cannot enter inside obj    265   //..... Note: Camera cannot enter inside object
266   G4double camera_distance;                       266   G4double camera_distance;
267   G4double radius = fSceneHandler.GetScene()->    267   G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
268                                                   268 
269   G4double half_view_angle = std::fabs(fVP.Get    269   G4double half_view_angle = std::fabs(fVP.GetFieldHalfAngle());
270   if(half_view_angle > MAX_HALF_ANGLE)            270   if(half_view_angle > MAX_HALF_ANGLE)
271   {                                               271   {
272     half_view_angle = MAX_HALF_ANGLE;             272     half_view_angle = MAX_HALF_ANGLE;
273   }                                               273   }
274                                                   274 
275   if(half_view_angle < MIN_HALF_ANGLE)            275   if(half_view_angle < MIN_HALF_ANGLE)
276   {                                               276   {
277     //----- infinity (or ortho projection)        277     //----- infinity (or ortho projection)
278     camera_distance = radius * HOW_FAR;           278     camera_distance = radius * HOW_FAR;
279   }                                               279   }
280   else                                            280   else
281   {                                               281   {
282     //----- Calc camera distance from half vie    282     //----- Calc camera distance from half view angle
283     camera_distance = radius / std::sin(half_v    283     camera_distance = radius / std::sin(half_view_angle);
284     camera_distance -= fVP.GetDolly();            284     camera_distance -= fVP.GetDolly();
285   }                                               285   }
286                                                   286 
287   if(camera_distance < radius)                    287   if(camera_distance < radius)
288   {                                               288   {
289     if(G4VisManager::GetVerbosity() >= G4VisMa    289     if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
290     {                                             290     {
291       G4cout << "WARNING from DAWNFILE driver:    291       G4cout << "WARNING from DAWNFILE driver:" << G4endl;
292       G4cout << "  Camera cannot enter inside     292       G4cout << "  Camera cannot enter inside objects" << G4endl;
293     }                                             293     }
294     camera_distance = radius;                     294     camera_distance = radius;
295   }                                               295   }
296                                                   296 
297   //----- CALC camera direction                   297   //----- CALC camera direction
298   const G4Vector3D& camera_direction = fVP.Get    298   const G4Vector3D& camera_direction = fVP.GetViewpointDirection().unit();
299   const G4double v_angle             = (180.0     299   const G4double v_angle             = (180.0 / pi) * camera_direction.theta();
300   const G4double h_angle             = (180.0     300   const G4double h_angle             = (180.0 / pi) * camera_direction.phi();
301                                                   301 
302   //########### Generation of the file .DAWN.h    302   //########### Generation of the file .DAWN.history for DAWN GUI
303   //-----                                         303   //-----
304   std::ofstream gui_out(".DAWN_1.history");       304   std::ofstream gui_out(".DAWN_1.history");
305                                                   305 
306   // ######### P1                                 306   // ######### P1
307                                                   307 
308   //----- camera position                         308   //----- camera position
309   gui_out << camera_distance << G4endl;           309   gui_out << camera_distance << G4endl;
310   gui_out << v_angle << G4endl;                   310   gui_out << v_angle << G4endl;
311   gui_out << h_angle << G4endl;                   311   gui_out << h_angle << G4endl;
312   gui_out << "0" << G4endl;  // auto target       312   gui_out << "0" << G4endl;  // auto target
313                                                   313 
314   //----- target point                            314   //----- target point
315   const G4Point3D& target_point =                 315   const G4Point3D& target_point =
316     fSceneHandler.GetScene()->GetStandardTarge    316     fSceneHandler.GetScene()->GetStandardTargetPoint() +
317     fVP.GetCurrentTargetPoint();                  317     fVP.GetCurrentTargetPoint();
318   gui_out << target_point.x() << G4endl;          318   gui_out << target_point.x() << G4endl;
319   gui_out << target_point.y() << G4endl;          319   gui_out << target_point.y() << G4endl;
320   gui_out << target_point.z() << G4endl;          320   gui_out << target_point.z() << G4endl;
321                                                   321 
322   //----- Magnification                           322   //----- Magnification
323   const G4double zoom_factor = fVP.GetZoomFact    323   const G4double zoom_factor = fVP.GetZoomFactor();
324   if(half_view_angle < MIN_HALF_ANGLE)            324   if(half_view_angle < MIN_HALF_ANGLE)
325   {                                               325   {
326     gui_out << zoom_factor << G4endl;             326     gui_out << zoom_factor << G4endl;
327   }                                               327   }
328   else                                            328   else
329   {                                               329   {
330     const G4double FR_HALF_SCREEN_SIZE = 0.5;     330     const G4double FR_HALF_SCREEN_SIZE = 0.5;
331     G4double focal_distance = FR_HALF_SCREEN_S    331     G4double focal_distance = FR_HALF_SCREEN_SIZE / std::tan(half_view_angle);
332     focal_distance *= zoom_factor;                332     focal_distance *= zoom_factor;
333                                                   333 
334     gui_out << "fd" << focal_distance << G4end    334     gui_out << "fd" << focal_distance << G4endl;
335   }                                               335   }
336   SendDrawingStyleToDAWNGUI(gui_out);  // gui_    336   SendDrawingStyleToDAWNGUI(gui_out);  // gui_out, viewing mode
337   gui_out << "0.001" << G4endl;        // 3D T    337   gui_out << "0.001" << G4endl;        // 3D Tolerance
338   gui_out << "0" << G4endl;            // not     338   gui_out << "0" << G4endl;            // not display parameters
339                                                   339 
340   // ######### P2                                 340   // ######### P2
341   gui_out << 1 << G4endl;  // Source light        341   gui_out << 1 << G4endl;  // Source light
342   gui_out << 1 << G4endl;                         342   gui_out << 1 << G4endl;
343   gui_out << 1 << G4endl;                         343   gui_out << 1 << G4endl;
344   gui_out << 0.5 << G4endl;  // Ambient light     344   gui_out << 0.5 << G4endl;  // Ambient light
345   gui_out << 0.5 << G4endl;                       345   gui_out << 0.5 << G4endl;
346   gui_out << 0.5 << G4endl;                       346   gui_out << 0.5 << G4endl;
347   gui_out << 19.0 << G4endl;  // Light directi    347   gui_out << 19.0 << G4endl;  // Light direction (Polar)
348   gui_out << 71.0 << G4endl;  // Light directi    348   gui_out << 71.0 << G4endl;  // Light direction (Azimuthal)
349                                                   349 
350   // ######### P3                                 350   // ######### P3
351   gui_out << 0.1 << G4endl;   // Real edge wid    351   gui_out << 0.1 << G4endl;   // Real edge width
352   gui_out << 0.1 << G4endl;   // outline   wid    352   gui_out << 0.1 << G4endl;   // outline   width
353   gui_out << 0.1 << G4endl;   // aux edge  wid    353   gui_out << 0.1 << G4endl;   // aux edge  width
354   gui_out << 3 << G4endl;     // aux edge  sty    354   gui_out << 3 << G4endl;     // aux edge  style
355   gui_out << 70.0 << G4endl;  // aux-edge thre    355   gui_out << 70.0 << G4endl;  // aux-edge threshold angle
356   gui_out << 0.1 << G4endl;   // line width       356   gui_out << 0.1 << G4endl;   // line width
357   gui_out << 0 << G4endl;     // haloing          357   gui_out << 0 << G4endl;     // haloing
358   gui_out << 1 << G4endl;     // Dashed edged     358   gui_out << 1 << G4endl;     // Dashed edged for back faces
359                                                   359 
360   //######### P4                                  360   //######### P4
361   //----- drawing device                          361   //----- drawing device
362   //  enum {PS=1, XWIN=2, PS2=3, XWIN2=4, OPEN    362   //  enum {PS=1, XWIN=2, PS2=3, XWIN2=4, OPEN_GL=5, DEVICE_END=6};
363   if(((std::getenv(FR_ENV_MULTI_WINDOW) != NUL    363   if(((std::getenv(FR_ENV_MULTI_WINDOW) != NULL) &&
364       (strcmp(std::getenv(FR_ENV_MULTI_WINDOW)    364       (strcmp(std::getenv(FR_ENV_MULTI_WINDOW), "0"))) ||
365      ((std::getenv(FR_ENV_MULTI_WINDOW2) != NU    365      ((std::getenv(FR_ENV_MULTI_WINDOW2) != NULL) &&
366       (strcmp(std::getenv(FR_ENV_MULTI_WINDOW2    366       (strcmp(std::getenv(FR_ENV_MULTI_WINDOW2), "0"))))
367   {                                               367   {
368     gui_out << 2 << G4endl;  // OpenWindow        368     gui_out << 2 << G4endl;  // OpenWindow
369   }                                               369   }
370   else                                            370   else
371   {                                               371   {
372     gui_out << 1 << G4endl;  // Invoke PS view    372     gui_out << 1 << G4endl;  // Invoke PS viewer
373   }                                               373   }
374                                                   374 
375   gui_out << GetPSViewer() << G4endl;  // PS v    375   gui_out << GetPSViewer() << G4endl;  // PS viewer
376   gui_out << 1 << G4endl;              // Do n    376   gui_out << 1 << G4endl;              // Do not add showpage
377   gui_out << 0 << G4endl;              // Non-    377   gui_out << 0 << G4endl;              // Non-append mode
378                                                   378 
379   gui_out.close();                                379   gui_out.close();
380   //########### end of generating file .DAWN.h    380   //########### end of generating file .DAWN.history
381 }                                                 381 }
382                                                   382