| 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 | //
|
|---|
| 27 | // $Id: G4XXXSceneHandler.cc,v 1.32 2006/07/03 16:52:49 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: HEAD $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // John Allison 5th April 2001
|
|---|
| 32 | // A template for a simplest possible graphics driver.
|
|---|
| 33 | //?? Lines or sections marked like this require specialisation for your driver.
|
|---|
| 34 |
|
|---|
| 35 | #include "G4XXXSceneHandler.hh"
|
|---|
| 36 |
|
|---|
| 37 | #include "G4PhysicalVolumeModel.hh"
|
|---|
| 38 | #include "G4VPhysicalVolume.hh"
|
|---|
| 39 | #include "G4LogicalVolume.hh"
|
|---|
| 40 | #include "G4Polyline.hh"
|
|---|
| 41 | #include "G4Text.hh"
|
|---|
| 42 | #include "G4Circle.hh"
|
|---|
| 43 | #include "G4Square.hh"
|
|---|
| 44 | #include "G4Polyhedron.hh"
|
|---|
| 45 | #include "G4UnitsTable.hh"
|
|---|
| 46 |
|
|---|
| 47 | G4int G4XXXSceneHandler::fSceneIdCount = 0;
|
|---|
| 48 | // Counter for XXX scene handlers.
|
|---|
| 49 |
|
|---|
| 50 | G4XXXSceneHandler::G4XXXSceneHandler(G4VGraphicsSystem& system,
|
|---|
| 51 | const G4String& name):
|
|---|
| 52 | G4VSceneHandler(system, fSceneIdCount++, name)
|
|---|
| 53 | {}
|
|---|
| 54 |
|
|---|
| 55 | G4XXXSceneHandler::~G4XXXSceneHandler() {}
|
|---|
| 56 |
|
|---|
| 57 | #ifdef G4XXXDEBUG
|
|---|
| 58 | void G4XXXSceneHandler::PrintThings() {
|
|---|
| 59 | G4cout <<
|
|---|
| 60 | " with transformation "
|
|---|
| 61 | << (void*)fpObjectTransformation;
|
|---|
| 62 | if (fpModel) {
|
|---|
| 63 | G4cout << " from " << fpModel->GetCurrentDescription()
|
|---|
| 64 | << " (tag " << fpModel->GetCurrentTag()
|
|---|
| 65 | << ')';
|
|---|
| 66 | } else {
|
|---|
| 67 | G4cout << "(not from a model)";
|
|---|
| 68 | }
|
|---|
| 69 | G4PhysicalVolumeModel* pPVModel =
|
|---|
| 70 | dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
|
|---|
| 71 | if (pPVModel) {
|
|---|
| 72 | G4cout <<
|
|---|
| 73 | "\n current physical volume: "
|
|---|
| 74 | << pPVModel->GetCurrentPV()->GetName() <<
|
|---|
| 75 | "\n current logical volume: "
|
|---|
| 76 | << pPVModel->GetCurrentLV()->GetName() <<
|
|---|
| 77 | "\n current depth of geometry tree: "
|
|---|
| 78 | << pPVModel->GetCurrentDepth();
|
|---|
| 79 | }
|
|---|
| 80 | G4cout << G4endl;
|
|---|
| 81 | }
|
|---|
| 82 | #endif
|
|---|
| 83 |
|
|---|
| 84 | void G4XXXSceneHandler::AddPrimitive(const G4Polyline&
|
|---|
| 85 | #ifdef G4XXXDEBUG
|
|---|
| 86 | polyline
|
|---|
| 87 | #endif
|
|---|
| 88 | ) {
|
|---|
| 89 | #ifdef G4XXXDEBUG
|
|---|
| 90 | G4cout <<
|
|---|
| 91 | "G4XXXSceneHandler::AddPrimitive(const G4Polyline& polyline) called.\n"
|
|---|
| 92 | << polyline
|
|---|
| 93 | << G4endl;
|
|---|
| 94 | PrintThings();
|
|---|
| 95 | #endif
|
|---|
| 96 | // Get vis attributes - pick up defaults if none.
|
|---|
| 97 | //const G4VisAttributes* pVA =
|
|---|
| 98 | // fpViewer -> GetApplicableVisAttributes (polyline.GetVisAttributes ());
|
|---|
| 99 | //?? Process polyline.
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | void G4XXXSceneHandler::AddPrimitive(const G4Text&
|
|---|
| 103 | #ifdef G4XXXDEBUG
|
|---|
| 104 | text
|
|---|
| 105 | #endif
|
|---|
| 106 | ) {
|
|---|
| 107 | #ifdef G4XXXDEBUG
|
|---|
| 108 | G4cout <<
|
|---|
| 109 | "G4XXXSceneHandler::AddPrimitive(const G4Text& text) called.\n"
|
|---|
| 110 | << text
|
|---|
| 111 | << G4endl;
|
|---|
| 112 | PrintThings();
|
|---|
| 113 | #endif
|
|---|
| 114 | // Get text colour - special method since default text colour is
|
|---|
| 115 | // determined by the default text vis attributes, which may be
|
|---|
| 116 | // specified independent of default vis attributes of other types of
|
|---|
| 117 | // visible objects.
|
|---|
| 118 | //const G4Colour& c = GetTextColour (text); // Picks up default if none.
|
|---|
| 119 | //?? Process text.
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | void G4XXXSceneHandler::AddPrimitive(const G4Circle&
|
|---|
| 123 | #ifdef G4XXXDEBUG
|
|---|
| 124 | circle
|
|---|
| 125 | #endif
|
|---|
| 126 | ) {
|
|---|
| 127 | #ifdef G4XXXDEBUG
|
|---|
| 128 | G4cout <<
|
|---|
| 129 | "G4XXXSceneHandler::AddPrimitive(const G4Circle& circle) called.\n"
|
|---|
| 130 | << circle
|
|---|
| 131 | << G4endl;
|
|---|
| 132 | MarkerSizeType sizeType;
|
|---|
| 133 | G4double size = GetMarkerSize (circle, sizeType);
|
|---|
| 134 | switch (sizeType) {
|
|---|
| 135 | default:
|
|---|
| 136 | case screen:
|
|---|
| 137 | // Draw in screen coordinates.
|
|---|
| 138 | G4cout << "screen";
|
|---|
| 139 | break;
|
|---|
| 140 | case world:
|
|---|
| 141 | // Draw in world coordinates.
|
|---|
| 142 | G4cout << "world";
|
|---|
| 143 | break;
|
|---|
| 144 | }
|
|---|
| 145 | G4cout << " size: " << size << G4endl;
|
|---|
| 146 | PrintThings();
|
|---|
| 147 | #endif
|
|---|
| 148 | // Get vis attributes - pick up defaults if none.
|
|---|
| 149 | //const G4VisAttributes* pVA =
|
|---|
| 150 | // fpViewer -> GetApplicableVisAttributes (circle.GetVisAttributes ());
|
|---|
| 151 | //?? Process circle.
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | void G4XXXSceneHandler::AddPrimitive(const G4Square&
|
|---|
| 155 | #ifdef G4XXXDEBUG
|
|---|
| 156 | square
|
|---|
| 157 | #endif
|
|---|
| 158 | ) {
|
|---|
| 159 | #ifdef G4XXXDEBUG
|
|---|
| 160 | G4cout <<
|
|---|
| 161 | "G4XXXSceneHandler::AddPrimitive(const G4Square& square) called.\n"
|
|---|
| 162 | << square
|
|---|
| 163 | << G4endl;
|
|---|
| 164 | MarkerSizeType sizeType;
|
|---|
| 165 | G4double size = GetMarkerSize (square, sizeType);
|
|---|
| 166 | switch (sizeType) {
|
|---|
| 167 | default:
|
|---|
| 168 | case screen:
|
|---|
| 169 | // Draw in screen coordinates.
|
|---|
| 170 | G4cout << "screen";
|
|---|
| 171 | break;
|
|---|
| 172 | case world:
|
|---|
| 173 | // Draw in world coordinates.
|
|---|
| 174 | G4cout << "world";
|
|---|
| 175 | break;
|
|---|
| 176 | }
|
|---|
| 177 | G4cout << " size: " << size << G4endl;
|
|---|
| 178 | PrintThings();
|
|---|
| 179 | #endif
|
|---|
| 180 | // Get vis attributes - pick up defaults if none.
|
|---|
| 181 | //const G4VisAttributes* pVA =
|
|---|
| 182 | // fpViewer -> GetApplicableVisAttributes (square.GetVisAttributes ());
|
|---|
| 183 | //?? Process square.
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | void G4XXXSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) {
|
|---|
| 187 | #ifdef G4XXXDEBUG
|
|---|
| 188 | G4cout <<
|
|---|
| 189 | "G4XXXSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called.\n"
|
|---|
| 190 | << polyhedron
|
|---|
| 191 | << G4endl;
|
|---|
| 192 | PrintThings();
|
|---|
| 193 | #endif
|
|---|
| 194 | //?? Process polyhedron. Here are some ideas...
|
|---|
| 195 | //Assume all facets are convex quadrilaterals.
|
|---|
| 196 | //Draw each G4Facet individually
|
|---|
| 197 |
|
|---|
| 198 | //Get colour, etc..
|
|---|
| 199 | if (polyhedron.GetNoFacets() == 0) return;
|
|---|
| 200 |
|
|---|
| 201 | // Get vis attributes - pick up defaults if none.
|
|---|
| 202 | const G4VisAttributes* pVA =
|
|---|
| 203 | fpViewer -> GetApplicableVisAttributes (polyhedron.GetVisAttributes ());
|
|---|
| 204 |
|
|---|
| 205 | // Get view parameters that the user can force through the vis
|
|---|
| 206 | // attributes, thereby over-riding the current view parameter.
|
|---|
| 207 | G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle (pVA);
|
|---|
| 208 | //G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
|
|---|
| 209 |
|
|---|
| 210 | //Get colour, etc..
|
|---|
| 211 | //const G4Colour& c = pVA -> GetColour ();
|
|---|
| 212 |
|
|---|
| 213 | // Initial action depending on drawing style.
|
|---|
| 214 | switch (drawing_style) {
|
|---|
| 215 | case (G4ViewParameters::hsr):
|
|---|
| 216 | {
|
|---|
| 217 | break;
|
|---|
| 218 | }
|
|---|
| 219 | case (G4ViewParameters::hlr):
|
|---|
| 220 | {
|
|---|
| 221 | break;
|
|---|
| 222 | }
|
|---|
| 223 | case (G4ViewParameters::wireframe):
|
|---|
| 224 | {
|
|---|
| 225 | break;
|
|---|
| 226 | }
|
|---|
| 227 | default:
|
|---|
| 228 | {
|
|---|
| 229 | break;
|
|---|
| 230 | }
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | // Loop through all the facets...
|
|---|
| 234 |
|
|---|
| 235 | // Look at G4OpenGLSceneHandler::AddPrimitive(const G4Polyhedron&)
|
|---|
| 236 | // for an example of how to get facets out of a G4Polyhedron,
|
|---|
| 237 | // including how to cope with triangles if that's a problem.
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | void G4XXXSceneHandler::AddPrimitive(const G4NURBS&) {
|
|---|
| 241 | #ifdef G4XXXDEBUG
|
|---|
| 242 | G4cout <<
|
|---|
| 243 | "G4XXXSceneHandler::AddPrimitive(const G4NURBS& nurbs) called."
|
|---|
| 244 | << G4endl;
|
|---|
| 245 | PrintThings();
|
|---|
| 246 | #endif
|
|---|
| 247 | //?? Don't bother implementing this. NURBS are not functional.
|
|---|
| 248 | }
|
|---|