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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/gMocren/src/G4GMocrenFileViewer.cc (Version 11.3.0) and /visualization/gMocren/src/G4GMocrenFileViewer.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 //                                                 28 //
 29 // Created:  Mar. 31, 2009  Akinori Kimura         29 // Created:  Mar. 31, 2009  Akinori Kimura  
 30 //                                                 30 //
 31                                                    31 
 32                                                    32 
 33 #define __G_ANSI_C__                               33 #define __G_ANSI_C__
 34 #define G4GMocrenFile_STRUCTURE_PRIORITY  1.       34 #define G4GMocrenFile_STRUCTURE_PRIORITY  1.
 35                                                    35 
 36 #include "G4ios.hh"                                36 #include "G4ios.hh"
 37 #include <cstdio>                                  37 #include <cstdio>
 38 #include <cstring>                                 38 #include <cstring>
 39 #include <cassert>                                 39 #include <cassert>
 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                                                    47 
 48 #include "G4GMocrenFile.hh"                        48 #include "G4GMocrenFile.hh"
 49 #include "G4GMocrenFileSceneHandler.hh"            49 #include "G4GMocrenFileSceneHandler.hh"
 50 #include "G4GMocrenFileViewer.hh"                  50 #include "G4GMocrenFileViewer.hh"
 51 #include "G4GMocrenMessenger.hh"                   51 #include "G4GMocrenMessenger.hh"
 52                                                    52 
 53                                                    53 
 54 //----- constants                                  54 //----- constants
 55                                                    55 
 56 //-- for a debugging                               56 //-- for a debugging
 57 const G4bool GFDEBUG = false;                      57 const G4bool GFDEBUG = false;
 58                                                    58 
 59 //----- G4GMocrenFileViewer, constructor           59 //----- G4GMocrenFileViewer, constructor
 60 G4GMocrenFileViewer::G4GMocrenFileViewer (G4GM     60 G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandler,
 61             G4GMocrenMessenger &,                  61             G4GMocrenMessenger &,
 62             const G4String& name)                  62             const G4String& name)
 63   : G4VViewer (sceneHandler, sceneHandler.Incr     63   : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
 64     kSceneHandler (sceneHandler)                   64     kSceneHandler (sceneHandler)
 65 {                                                  65 {
 66   // Set a g4.gdd-file viewer                      66   // Set a g4.gdd-file viewer 
 67   std::strncpy( kG4GddViewer, "gMocren", 8);       67   std::strncpy( kG4GddViewer, "gMocren", 8);
 68   if( std::getenv( "G4GMocrenFile_VIEWER" ) !=     68   if( std::getenv( "G4GMocrenFile_VIEWER" ) != NULL ) {
 69     char * env = std::getenv( "G4GMocrenFile_V     69     char * env = std::getenv( "G4GMocrenFile_VIEWER" );
 70     G4int len = (G4int)std::strlen(env);           70     G4int len = (G4int)std::strlen(env);
 71     if(len >= 32) {                                71     if(len >= 32) {
 72       G4Exception("G4GMocrenFileViewer::G4GMoc     72       G4Exception("G4GMocrenFileViewer::G4GMocrenFileViewer(*)",
 73                   "gMocren1000", FatalExceptio     73                   "gMocren1000", FatalException,
 74                   "Invalid length of string se     74                   "Invalid length of string set in G4GMocrenFile_VIEWER");
 75     }                                              75     }
 76     std::strncpy( kG4GddViewer, env, sizeof(kG     76     std::strncpy( kG4GddViewer, env, sizeof(kG4GddViewer) - 1);
 77     kG4GddViewer[sizeof(kG4GddViewer) - 1] = '     77     kG4GddViewer[sizeof(kG4GddViewer) - 1] = '\0';
 78     //std::strcpy( kG4GddViewer, getenv( "G4GM     78     //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;       
 79   }                                                79   } 
 80                                                    80 
 81   // string for viewer invocation                  81   // string for viewer invocation
 82   if ( !std::strcmp( kG4GddViewer, "NONE" ) )      82   if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
 83                                                    83     
 84     //std::strcpy( kG4GddViewerInvocation, ""      84     //std::strcpy( kG4GddViewerInvocation, "" );
 85     kG4GddViewerInvocation[0] = '\0';              85     kG4GddViewerInvocation[0] = '\0';
 86   } else {                                         86   } else {
 87                                                    87 
 88     std::strncpy( kG4GddViewerInvocation, kG4G     88     std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
 89                  sizeof(kG4GddViewerInvocation     89                  sizeof(kG4GddViewerInvocation) - 1);
 90     kG4GddViewerInvocation[sizeof(kG4GddViewer     90     kG4GddViewerInvocation[sizeof(kG4GddViewerInvocation) - 1] = '\0';
 91     G4int n = sizeof(kG4GddViewerInvocation)       91     G4int n = sizeof(kG4GddViewerInvocation)
 92             - (G4int)std::strlen(kG4GddViewerI     92             - (G4int)std::strlen(kG4GddViewerInvocation) - 1;
 93     std::strncat( kG4GddViewerInvocation, " ",     93     std::strncat( kG4GddViewerInvocation, " ", n);
 94     const char * gddfname = kSceneHandler.GetG     94     const char * gddfname = kSceneHandler.GetGddFileName();
 95     G4int len = (G4int)std::strlen(gddfname);      95     G4int len = (G4int)std::strlen(gddfname);
 96     if(len >= 64) {                                96     if(len >= 64) {
 97       G4Exception("G4GMocrenFileViewer::G4GMoc     97       G4Exception("G4GMocrenFileViewer::G4GMocrenFileViewer(*)",
 98                   "gMocren1001", FatalExceptio     98                   "gMocren1001", FatalException,
 99                   "Invalid length of the GDD f     99                   "Invalid length of the GDD file name");
100     }                                             100     }
101     n = sizeof(kG4GddViewerInvocation)            101     n = sizeof(kG4GddViewerInvocation)
102       - (G4int)std::strlen(kG4GddViewerInvocat    102       - (G4int)std::strlen(kG4GddViewerInvocation) - 1;
103     std::strncat( kG4GddViewerInvocation, gddf    103     std::strncat( kG4GddViewerInvocation, gddfname, n);
104   }                                               104   }
105                                                   105 
106 }                                                 106 }
107                                                   107 
108 //----- G4GMocrenFileViewer, destructor           108 //----- G4GMocrenFileViewer, destructor
109 G4GMocrenFileViewer::~G4GMocrenFileViewer ()      109 G4GMocrenFileViewer::~G4GMocrenFileViewer () 
110 {}                                                110 {}
111                                                   111 
112 //----- G4GMocrenFileViewer::SetView ()           112 //----- G4GMocrenFileViewer::SetView () 
113 void G4GMocrenFileViewer::SetView ()              113 void G4GMocrenFileViewer::SetView () 
114 {                                                 114 {
115   if(GFDEBUG)                                     115   if(GFDEBUG)
116     if (G4VisManager::GetVerbosity() >= G4VisM    116     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
117       G4cout << "***** G4GMocrenFileViewer::Se    117       G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
118                                                   118 
119   // Do nothing, since DAWN is running as a di    119   // Do nothing, since DAWN is running as a different process.
120   // SendViewParameters () will do this job in    120   // SendViewParameters () will do this job instead.
121 }                                                 121 }
122                                                   122 
123                                                   123 
124 //----- G4GMocrenFileViewer::ClearView()          124 //----- G4GMocrenFileViewer::ClearView()
125 void                                              125 void
126 G4GMocrenFileViewer::ClearView( void )            126 G4GMocrenFileViewer::ClearView( void )
127 {                                                 127 {
128   if(GFDEBUG) {                                   128   if(GFDEBUG) {
129     if (G4VisManager::GetVerbosity() >= G4VisM    129     if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
130       G4cout << "***** G4GMocrenFileViewer::Cl    130       G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
131     }                                             131     }
132   }                                               132   }  
133   //if(kSceneHandler.kGddDest) {                  133   //if(kSceneHandler.kGddDest) {
134     //kSceneHandler.kGddDest.close();             134     //kSceneHandler.kGddDest.close();
135     // Re-open with same filename...              135     // Re-open with same filename...
136     //kSceneHandler.kGddDest.open(kSceneHandle    136     //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
137     kSceneHandler.kFlagInModeling = false;        137     kSceneHandler.kFlagInModeling = false;
138     kSceneHandler.GFBeginModeling();              138     kSceneHandler.GFBeginModeling();
139     //}                                           139     //}
140 }                                                 140 }
141                                                   141 
142                                                   142 
143 //----- G4GMocrenFileViewer::DrawView ()          143 //----- G4GMocrenFileViewer::DrawView () 
144 void G4GMocrenFileViewer::DrawView ()             144 void G4GMocrenFileViewer::DrawView () 
145 {                                                 145 {
146   if(GFDEBUG)                                     146   if(GFDEBUG)
147     if (G4VisManager::GetVerbosity() >= G4VisM    147     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
148       G4cout << "***** G4GMocrenFileViewer::Dr    148       G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
149                                                   149 
150   //-----                                         150   //----- 
151   kSceneHandler.GFBeginModeling() ;               151   kSceneHandler.GFBeginModeling() ;
152                                                   152 
153   //----- Always visit G4 kernel                  153   //----- Always visit G4 kernel 
154   NeedKernelVisit ();                             154   NeedKernelVisit ();
155                                                   155                              
156   //----- Draw                                    156   //----- Draw
157   G4VViewer::ProcessView () ;                     157   G4VViewer::ProcessView () ;
158                                                   158 
159 } // G4GMocrenFileViewer::DrawView ()             159 } // G4GMocrenFileViewer::DrawView () 
160                                                   160 
161                                                   161 
162                                                   162 
163 //----- G4GMocrenFileViewer::ShowView()           163 //----- G4GMocrenFileViewer::ShowView()
164 void G4GMocrenFileViewer::ShowView( void )        164 void G4GMocrenFileViewer::ShowView( void )
165 {                                                 165 {
166   if(GFDEBUG)                                     166   if(GFDEBUG)
167     if (G4VisManager::GetVerbosity() >= G4VisM    167     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
168       G4cout << "***** G4GMocrenFileViewer::Sh    168       G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
169                                                   169 
170   if( kSceneHandler.GFIsInModeling() )            170   if( kSceneHandler.GFIsInModeling() ) 
171     {                                             171     {
172       //----- End of modeling                     172       //----- End of modeling
173       // !EndModeling, !DrawAll, !CloseDevice,    173       // !EndModeling, !DrawAll, !CloseDevice,
174       // close g4.gdd                             174       // close g4.gdd
175       kSceneHandler.GFEndModeling();              175       kSceneHandler.GFEndModeling();
176                                                   176 
177       //----- Output DAWN GUI file                177       //----- Output DAWN GUI file 
178       //SendViewParameters();                     178       //SendViewParameters(); 
179                                                   179 
180       //----- string for viewer invocation        180       //----- string for viewer invocation
181       if ( !strcmp( kG4GddViewer, "NONE" ) ) {    181       if ( !strcmp( kG4GddViewer, "NONE" ) ) {
182                                                   182     
183   kG4GddViewerInvocation[0] = '\0';               183   kG4GddViewerInvocation[0] = '\0';
184   //std::strcpy( kG4GddViewerInvocation, "" );    184   //std::strcpy( kG4GddViewerInvocation, "" );
185       } else {                                    185       } else {
186                                                   186 
187         std::strncpy( kG4GddViewerInvocation,     187         std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
188                      sizeof(kG4GddViewerInvoca    188                      sizeof(kG4GddViewerInvocation) - 1);
189         kG4GddViewerInvocation[sizeof(kG4GddVi    189         kG4GddViewerInvocation[sizeof(kG4GddViewerInvocation) - 1] = '\0';
190         G4int n = sizeof(kG4GddViewerInvocatio    190         G4int n = sizeof(kG4GddViewerInvocation)
191                 - (G4int)std::strlen(kG4GddVie    191                 - (G4int)std::strlen(kG4GddViewerInvocation) - 1;
192         std::strncat( kG4GddViewerInvocation,     192         std::strncat( kG4GddViewerInvocation, " ", n);
193         const char * gddfname = kSceneHandler.    193         const char * gddfname = kSceneHandler.GetGddFileName();
194         G4int len = (G4int)std::strlen(gddfnam    194         G4int len = (G4int)std::strlen(gddfname);
195         if(len >= 64) {                           195         if(len >= 64) {
196           G4Exception("G4GMocrenFileViewer::Sh    196           G4Exception("G4GMocrenFileViewer::ShowView()",
197                       "gMocren1002", FatalExce    197                       "gMocren1002", FatalException,
198                       "Invalid length of the G    198                       "Invalid length of the GDD file name");
199         }                                         199         }
200         n = sizeof(kG4GddViewerInvocation)        200         n = sizeof(kG4GddViewerInvocation)
201           - (G4int)std::strlen(kG4GddViewerInv    201           - (G4int)std::strlen(kG4GddViewerInvocation) - 1;
202         std::strncat( kG4GddViewerInvocation,     202         std::strncat( kG4GddViewerInvocation, gddfname, n);
203       }                                           203       }
204                                                   204 
205     }                                             205     }
206                                                   206 
207 } // G4GMocrenFileViewer::ShowView()              207 } // G4GMocrenFileViewer::ShowView()
208                                                   208 
209                                                   209