00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // John Allison 5th April 2001 00031 // A template for a simplest possible graphics driver. 00032 //?? Lines or sections marked like this require specialisation for your driver. 00033 00034 #include "G4XXXSceneHandler.hh" 00035 00036 #include "G4PhysicalVolumeModel.hh" 00037 #include "G4LogicalVolumeModel.hh" 00038 #include "G4VPhysicalVolume.hh" 00039 #include "G4LogicalVolume.hh" 00040 #include "G4Polyline.hh" 00041 #include "G4Text.hh" 00042 #include "G4Circle.hh" 00043 #include "G4Square.hh" 00044 #include "G4Polyhedron.hh" 00045 #include "G4UnitsTable.hh" 00046 00047 G4int G4XXXSceneHandler::fSceneIdCount = 0; 00048 // Counter for XXX scene handlers. 00049 00050 G4XXXSceneHandler::G4XXXSceneHandler(G4VGraphicsSystem& system, 00051 const G4String& name): 00052 G4VSceneHandler(system, fSceneIdCount++, name) 00053 {} 00054 00055 G4XXXSceneHandler::~G4XXXSceneHandler() {} 00056 00057 #ifdef G4XXXDEBUG 00058 void G4XXXSceneHandler::PrintThings() { 00059 G4cout << 00060 " with transformation " 00061 << (void*)fpObjectTransformation; 00062 if (fpModel) { 00063 G4cout << " from " << fpModel->GetCurrentDescription() 00064 << " (tag " << fpModel->GetCurrentTag() 00065 << ')'; 00066 } else { 00067 G4cout << "(not from a model)"; 00068 } 00069 G4PhysicalVolumeModel* pPVModel = 00070 dynamic_cast<G4PhysicalVolumeModel*>(fpModel); 00071 if (pPVModel) { 00072 G4cout << 00073 "\n current physical volume: " 00074 << pPVModel->GetCurrentPV()->GetName() << 00075 "\n current logical volume: " 00076 // There might be a problem with the LV pointer if this is a G4LogicalVolumeModel 00077 << pPVModel->GetCurrentLV()->GetName() << 00078 "\n current depth of geometry tree: " 00079 << pPVModel->GetCurrentDepth(); 00080 } 00081 G4cout << G4endl; 00082 } 00083 #endif 00084 00085 void G4XXXSceneHandler::AddPrimitive(const G4Polyline& 00086 #ifdef G4XXXDEBUG 00087 polyline 00088 #endif 00089 ) { 00090 #ifdef G4XXXDEBUG 00091 G4cout << 00092 "G4XXXSceneHandler::AddPrimitive(const G4Polyline& polyline) called.\n" 00093 << polyline 00094 << G4endl; 00095 PrintThings(); 00096 #endif 00097 // Get vis attributes - pick up defaults if none. 00098 //const G4VisAttributes* pVA = 00099 // fpViewer -> GetApplicableVisAttributes (polyline.GetVisAttributes ()); 00100 //?? Process polyline. 00101 } 00102 00103 void G4XXXSceneHandler::AddPrimitive(const G4Text& 00104 #ifdef G4XXXDEBUG 00105 text 00106 #endif 00107 ) { 00108 #ifdef G4XXXDEBUG 00109 G4cout << 00110 "G4XXXSceneHandler::AddPrimitive(const G4Text& text) called.\n" 00111 << text 00112 << G4endl; 00113 PrintThings(); 00114 #endif 00115 // Get text colour - special method since default text colour is 00116 // determined by the default text vis attributes, which may be 00117 // specified independent of default vis attributes of other types of 00118 // visible objects. 00119 //const G4Colour& c = GetTextColour (text); // Picks up default if none. 00120 //?? Process text. 00121 } 00122 00123 void G4XXXSceneHandler::AddPrimitive(const G4Circle& 00124 #ifdef G4XXXDEBUG 00125 circle 00126 #endif 00127 ) { 00128 #ifdef G4XXXDEBUG 00129 G4cout << 00130 "G4XXXSceneHandler::AddPrimitive(const G4Circle& circle) called.\n" 00131 << circle 00132 << G4endl; 00133 MarkerSizeType sizeType; 00134 G4double size = GetMarkerSize (circle, sizeType); 00135 switch (sizeType) { 00136 default: 00137 case screen: 00138 // Draw in screen coordinates. 00139 G4cout << "screen"; 00140 break; 00141 case world: 00142 // Draw in world coordinates. 00143 G4cout << "world"; 00144 break; 00145 } 00146 G4cout << " size: " << size << G4endl; 00147 PrintThings(); 00148 #endif 00149 // Get vis attributes - pick up defaults if none. 00150 //const G4VisAttributes* pVA = 00151 // fpViewer -> GetApplicableVisAttributes (circle.GetVisAttributes ()); 00152 //?? Process circle. 00153 } 00154 00155 void G4XXXSceneHandler::AddPrimitive(const G4Square& 00156 #ifdef G4XXXDEBUG 00157 square 00158 #endif 00159 ) { 00160 #ifdef G4XXXDEBUG 00161 G4cout << 00162 "G4XXXSceneHandler::AddPrimitive(const G4Square& square) called.\n" 00163 << square 00164 << G4endl; 00165 MarkerSizeType sizeType; 00166 G4double size = GetMarkerSize (square, sizeType); 00167 switch (sizeType) { 00168 default: 00169 case screen: 00170 // Draw in screen coordinates. 00171 G4cout << "screen"; 00172 break; 00173 case world: 00174 // Draw in world coordinates. 00175 G4cout << "world"; 00176 break; 00177 } 00178 G4cout << " size: " << size << G4endl; 00179 PrintThings(); 00180 #endif 00181 // Get vis attributes - pick up defaults if none. 00182 //const G4VisAttributes* pVA = 00183 // fpViewer -> GetApplicableVisAttributes (square.GetVisAttributes ()); 00184 //?? Process square. 00185 } 00186 00187 void G4XXXSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) { 00188 #ifdef G4XXXDEBUG 00189 G4cout << 00190 "G4XXXSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called.\n" 00191 << polyhedron 00192 << G4endl; 00193 PrintThings(); 00194 #endif 00195 //?? Process polyhedron. Here are some ideas... 00196 //Assume all facets are convex quadrilaterals. 00197 //Draw each G4Facet individually 00198 00199 //Get colour, etc.. 00200 if (polyhedron.GetNoFacets() == 0) return; 00201 00202 // Get vis attributes - pick up defaults if none. 00203 const G4VisAttributes* pVA = 00204 fpViewer -> GetApplicableVisAttributes (polyhedron.GetVisAttributes ()); 00205 00206 // Get view parameters that the user can force through the vis 00207 // attributes, thereby over-riding the current view parameter. 00208 G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle (pVA); 00209 //G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA); 00210 00211 //Get colour, etc.. 00212 //const G4Colour& c = pVA -> GetColour (); 00213 00214 // Initial action depending on drawing style. 00215 switch (drawing_style) { 00216 case (G4ViewParameters::hsr): 00217 { 00218 break; 00219 } 00220 case (G4ViewParameters::hlr): 00221 { 00222 break; 00223 } 00224 case (G4ViewParameters::wireframe): 00225 { 00226 break; 00227 } 00228 default: 00229 { 00230 break; 00231 } 00232 } 00233 00234 // Loop through all the facets... 00235 00236 // Look at G4OpenGLSceneHandler::AddPrimitive(const G4Polyhedron&) 00237 // for an example of how to get facets out of a G4Polyhedron, 00238 // including how to cope with triangles if that's a problem. 00239 } 00240 00241 void G4XXXSceneHandler::AddPrimitive(const G4NURBS&) { 00242 #ifdef G4XXXDEBUG 00243 G4cout << 00244 "G4XXXSceneHandler::AddPrimitive(const G4NURBS& nurbs) called." 00245 << G4endl; 00246 PrintThings(); 00247 #endif 00248 //?? Don't bother implementing this. NURBS are not functional. 00249 }