[1142] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1228] | 27 | // $Id: G4GMocrenFileViewer.cc,v 1.3 2009/12/03 11:44:42 akimura Exp $ |
---|
[1142] | 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // Created: Mar. 31, 2009 Akinori Kimura |
---|
| 32 | // |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | #define __G_ANSI_C__ |
---|
| 36 | #define G4GMocrenFile_STRUCTURE_PRIORITY 1. |
---|
| 37 | |
---|
| 38 | #include "G4ios.hh" |
---|
| 39 | #include <cstdio> |
---|
| 40 | #include <cstring> |
---|
| 41 | #include <cassert> |
---|
| 42 | |
---|
| 43 | #include "G4Scene.hh" |
---|
| 44 | #include "G4Vector3D.hh" |
---|
| 45 | #include "G4VisExtent.hh" |
---|
| 46 | #include "G4LogicalVolume.hh" |
---|
| 47 | #include "G4VSolid.hh" |
---|
| 48 | |
---|
| 49 | #include "G4GMocrenFile.hh" |
---|
| 50 | #include "G4GMocrenFileSceneHandler.hh" |
---|
| 51 | #include "G4GMocrenFileViewer.hh" |
---|
| 52 | #include "G4GMocrenMessenger.hh" |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | //----- constants |
---|
| 56 | |
---|
| 57 | //-- for a debugging |
---|
| 58 | const bool GFDEBUG = false; |
---|
| 59 | |
---|
| 60 | //----- G4GMocrenFileViewer, constructor |
---|
| 61 | G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandler, |
---|
| 62 | G4GMocrenMessenger & messenger, |
---|
| 63 | const G4String& name) |
---|
| 64 | : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name), |
---|
| 65 | kSceneHandler (sceneHandler), |
---|
| 66 | kMessenger(messenger) |
---|
| 67 | { |
---|
| 68 | // Set a g4.gdd-file viewer |
---|
| 69 | std::strcpy( kG4GddViewer, "gMocren" ); |
---|
| 70 | if( getenv( "G4GMocrenFile_VIEWER" ) != NULL ) { |
---|
| 71 | std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | // string for viewer invocation |
---|
| 75 | if ( !std::strcmp( kG4GddViewer, "NONE" ) ) { |
---|
| 76 | |
---|
| 77 | std::strcpy( kG4GddViewerInvocation, "" ); |
---|
| 78 | } else { |
---|
| 79 | |
---|
| 80 | std::strcpy( kG4GddViewerInvocation, kG4GddViewer ); |
---|
| 81 | std::strcat( kG4GddViewerInvocation, " "); |
---|
| 82 | std::strcat( kG4GddViewerInvocation, kSceneHandler.GetGddFileName() ); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | //----- G4GMocrenFileViewer, destructor |
---|
| 88 | G4GMocrenFileViewer::~G4GMocrenFileViewer () |
---|
| 89 | {} |
---|
| 90 | |
---|
| 91 | //----- G4GMocrenFileViewer::SetView () |
---|
| 92 | void G4GMocrenFileViewer::SetView () |
---|
| 93 | { |
---|
| 94 | if(GFDEBUG) |
---|
| 95 | G4cerr << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl; |
---|
| 96 | |
---|
| 97 | // Do nothing, since DAWN is running as a different process. |
---|
| 98 | // SendViewParameters () will do this job instead. |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | //----- G4GMocrenFileViewer::ClearView() |
---|
| 103 | void |
---|
| 104 | G4GMocrenFileViewer::ClearView( void ) |
---|
| 105 | { |
---|
| 106 | if(GFDEBUG) |
---|
| 107 | G4cerr << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl; |
---|
| 108 | |
---|
[1228] | 109 | //if(kSceneHandler.kGddDest) { |
---|
| 110 | //kSceneHandler.kGddDest.close(); |
---|
[1142] | 111 | // Re-open with same filename... |
---|
[1228] | 112 | //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName); |
---|
[1142] | 113 | kSceneHandler.kFlagInModeling = false; |
---|
| 114 | kSceneHandler.GFBeginModeling(); |
---|
[1228] | 115 | //} |
---|
[1142] | 116 | } |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | //----- G4GMocrenFileViewer::DrawView () |
---|
| 120 | void G4GMocrenFileViewer::DrawView () |
---|
| 121 | { |
---|
| 122 | if(GFDEBUG) |
---|
| 123 | G4cerr << "***** G4GMocrenFileViewer::DrawView () " << G4endl; |
---|
| 124 | |
---|
| 125 | //----- |
---|
| 126 | kSceneHandler.GFBeginModeling() ; |
---|
| 127 | |
---|
| 128 | //----- Always visit G4 kernel |
---|
| 129 | NeedKernelVisit (); |
---|
| 130 | |
---|
| 131 | //----- Draw |
---|
| 132 | G4VViewer::ProcessView () ; |
---|
| 133 | |
---|
| 134 | } // G4GMocrenFileViewer::DrawView () |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | //----- G4GMocrenFileViewer::ShowView() |
---|
| 139 | void G4GMocrenFileViewer::ShowView( void ) |
---|
| 140 | { |
---|
| 141 | if(GFDEBUG) |
---|
| 142 | G4cerr << "***** G4GMocrenFileViewer::ShowView () " << G4endl; |
---|
| 143 | |
---|
| 144 | if( kSceneHandler.GFIsInModeling() ) |
---|
| 145 | { |
---|
| 146 | //----- End of modeling |
---|
| 147 | // !EndModeling, !DrawAll, !CloseDevice, |
---|
| 148 | // close g4.gdd |
---|
| 149 | kSceneHandler.GFEndModeling(); |
---|
| 150 | |
---|
| 151 | //----- Output DAWN GUI file |
---|
| 152 | //SendViewParameters(); |
---|
| 153 | |
---|
| 154 | //----- string for viewer invocation |
---|
| 155 | if ( !strcmp( kG4GddViewer, "NONE" ) ) { |
---|
| 156 | |
---|
| 157 | std::strcpy( kG4GddViewerInvocation, "" ); |
---|
| 158 | } else { |
---|
| 159 | |
---|
| 160 | std::strcpy( kG4GddViewerInvocation, kG4GddViewer ); |
---|
| 161 | std::strcat( kG4GddViewerInvocation, " "); |
---|
| 162 | std::strcat( kG4GddViewerInvocation, kSceneHandler.GetGddFileName() ); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | } // G4GMocrenFileViewer::ShowView() |
---|
| 168 | |
---|