Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 // 29 // John Allison 19th July 1996 30 // 31 // Class description 32 // 33 // View parameters and options. 34 // 35 // THE STANDARD VIEW AND ALL THAT. 36 // 37 // In GEANT4 visualization, we have the concep 38 // View". This is the view when the complete 39 // viewed is comfortably in view from any view 40 // the "Bounding Extent" of "visible" objects 41 // registered in the scene, and by the View Pa 42 // 43 // There is also the "Standard Target Point", 44 // the Bounding Extent (note that this belongs 45 // stored in the G4Scene object). The "Curren 46 // relative to the Standard Target Point, is c 47 // "dolly" and "zoom" commands, and can be res 48 // Target Point with the "/vis/viewer/reset" c 49 // 50 // Also, the "Standard Camera Position" is the 51 // Distance" along the Viewpoint Direction vec 52 // Target Point. The Standard Camera Distance 53 // Bounding Extent divided by fFieldHalfAngle. 54 // explicitly because of the singularity at fF 55 // which implies parallel projection. 56 // 57 // Similarly, the "Current Camera Position" is 58 // Distance" along the Viewpoint Direction vec 59 // Target Point. The Current Camera Distance 60 // below, but note that it can be negative, me 61 // has moved *beyond* the Current Target Point 62 // conceptually possible, but which might give 63 // setting up the view matrix - see, for examp 64 // 65 // All viewers are expected to keep the "Up Ve 66 // RotationStyle is freeRotation. 67 // 68 // Finally, the view is magnified by the "Zoom 69 // reset to 1 by the "/vis/viewer/reset" comma 70 // 71 // The algorithms for calculating various usef 72 // View Parameters, such as GetCameraDistance, 73 74 #ifndef G4VIEWPARAMETERS_HH 75 #define G4VIEWPARAMETERS_HH 76 77 #include <CLHEP/Units/SystemOfUnits.h> 78 #include "G4Vector3D.hh" 79 #include "G4Point3D.hh" 80 #include "G4Plane3D.hh" 81 #include "G4VisAttributes.hh" 82 #include "G4VMarker.hh" 83 #include "G4ModelingParameters.hh" 84 85 #include <vector> 86 #include <utility> 87 88 typedef std::vector<G4Plane3D> G4Planes; 89 90 class G4ViewParameters { 91 92 public: // With description 93 94 enum DrawingStyle { 95 wireframe, // Draw edges - no hidden l 96 hlr, // Draw edges - hidden line 97 hsr, // Draw surfaces - hidden surf 98 hlhsr, // Draw surfaces and edges - h 99 cloud // Draw volume as a cloud of d 100 }; 101 102 enum CutawayMode { 103 cutawayUnion, // Union (addition) of 104 cutawayIntersection // Intersection (multi 105 }; 106 107 enum RotationStyle { 108 constrainUpDirection, // Standard, HEP co 109 freeRotation // Free, Google-lik 110 }; 111 112 enum SMROption { // Special Mesh Rendering 113 meshAsDefault, 114 meshAsDots, 115 meshAsSurfaces 116 }; 117 118 friend std::ostream& operator << 119 (std::ostream&, DrawingStyle); 120 121 friend std::ostream& operator << 122 (std::ostream&, SMROption); 123 124 friend std::ostream& operator << 125 (std::ostream&, const G4ViewParameters&); 126 127 G4ViewParameters (); 128 ~G4ViewParameters (); 129 130 // Note: uses default assignment operator an 131 132 G4bool operator != (const G4ViewParameters&) 133 134 // Get and Is functions. 135 DrawingStyle GetDrawingStyle 136 G4int GetNumberOfCloudPoint 137 G4bool IsAuxEdgeVisible 138 G4bool IsCulling 139 G4bool IsCullingInvisible 140 G4bool IsDensityCulling 141 G4double GetVisibleDensity 142 G4bool IsCullingCovered 143 G4int GetCBDAlgorithmNumber 144 const std::vector<G4double>& GetCBDParameter 145 G4bool IsSection 146 const G4Plane3D& GetSectionPlane 147 G4bool IsCutaway 148 CutawayMode GetCutawayMode 149 const G4Planes& GetCutawayPlanes 150 G4bool IsExplode 151 G4double GetExplodeFactor 152 const G4Point3D& GetExplodeCentre 153 G4int GetNoOfSides 154 const G4Vector3D& GetViewpointDirection 155 const G4Vector3D& GetUpVector 156 G4double GetFieldHalfAngle 157 G4double GetZoomFactor 158 const G4Vector3D& GetScaleFactor 159 const G4Point3D& GetCurrentTargetPoint 160 G4double GetDolly 161 G4bool GetLightsMoveWithCame 162 const G4Vector3D& GetLightpointDirectio 163 G4Vector3D& GetActualLightpointDi 164 // ... depending on GetLightsMoveWithCamera. 165 const G4VisAttributes* GetDefaultVisAttribut 166 const G4VisAttributes* GetDefaultTextVisAttr 167 const G4VMarker& GetDefaultMarker 168 G4double GetGlobalMarkerScale 169 G4double GetGlobalLineWidthSca 170 G4bool IsMarkerNotHidden 171 unsigned int GetWindowSizeHintX 172 unsigned int GetWindowSizeHintY 173 G4int GetWindowAbsoluteLoca 174 G4int GetWindowAbsoluteLoca 175 G4int GetWindowLocationHint 176 G4int GetWindowLocationHint 177 G4bool IsWindowLocationHintX 178 G4bool IsWindowLocationHintY 179 const G4String& GetXGeometryString 180 // GetXGeometryString is intended to be pars 181 // It contains the size information, as in G 182 // may also contain the window position, e.g 183 // viewer should use this in preference to G 184 // it contains more information. (The size 185 // GetXGeometryString and GetWindowSizeHint 186 // identical.) 187 bool IsWindowSizeHintX 188 bool IsWindowSizeHintY 189 bool IsWindowLocationHintX 190 bool IsWindowLocationHintY 191 G4bool IsAutoRefresh 192 const G4Colour& GetBackgroundColour 193 G4bool IsPicking 194 RotationStyle GetRotationStyle 195 const std::vector<G4ModelingParameters::VisA 196 GetVisAttributesModif 197 G4double GetStartTime 198 G4double GetEndTime 199 G4double GetFadeFactor 200 G4bool IsDisplayHeadTime 201 G4double GetDisplayHeadTimeX 202 G4double GetDisplayHeadTimeY 203 G4double GetDisplayHeadTimeSiz 204 G4double GetDisplayHeadTimeRed 205 G4double GetDisplayHeadTimeGre 206 G4double GetDisplayHeadTimeBlu 207 G4bool IsDisplayLightFront 208 G4double GetDisplayLightFrontX 209 G4double GetDisplayLightFrontY 210 G4double GetDisplayLightFrontZ 211 G4double GetDisplayLightFrontT 212 G4double GetDisplayLightFrontR 213 G4double GetDisplayLightFrontG 214 G4double GetDisplayLightFrontB 215 G4bool IsSpecialMeshRenderin 216 SMROption GetSpecialMeshRenderi 217 const std::vector<G4ModelingParameters::PVNa 218 219 // Here Follow functions to evaluate useful 220 // function of the radius of the Bounding Ex 221 // viewed. Call them in the order given - f 222 // functions depend on the results of earlie 223 // results of earlier functions in your own 224 // see, for example, G4OpenGLView::SetView ( 225 G4double GetCameraDistance (G4double radius 226 G4double GetNearDistance (G4double camera 227 G4double GetFarDistance (G4double camera 228 G4double nearDistance, G4double r 229 G4double GetFrontHalfHeight (G4double nearDi 230 231 // Set, Add, Multiply, Increment, Unset and 232 void SetDrawingStyle (G4ViewParamete 233 G4int SetNumberOfCloudPoints (G4int); // Re 234 void SetAuxEdgeVisible (G4bool); 235 void SetCulling (G4bool); 236 void SetCullingInvisible (G4bool); 237 void SetDensityCulling (G4bool); 238 void SetVisibleDensity (G4double visib 239 void SetCullingCovered (G4bool); 240 void SetCBDAlgorithmNumber (G4int); 241 void SetCBDParameters (const std::vec 242 void SetSectionPlane (const G4Plane3 243 void UnsetSectionPlane (); 244 void SetCutawayMode (CutawayMode); 245 void AddCutawayPlane (const G4Plane3 246 void ChangeCutawayPlane (size_t index, 247 void ClearCutawayPlanes (); 248 void SetExplodeFactor (G4double explo 249 void UnsetExplodeFactor (); 250 void SetExplodeCentre (const G4Point3 251 G4int SetNoOfSides (G4int nSides); 252 void SetViewpointDirection (const G4Vector 253 // Calls the following to get lightpoint dir 254 void SetViewAndLights (const G4Vector 255 // Also sets lightpoint direction according 256 void SetUpVector (const G4Vector 257 void SetFieldHalfAngle (G4double field 258 void SetOrthogonalProjection (); // This an 259 void SetPerspectiveProjection(G4double field 260 void SetZoomFactor (G4double zoomF 261 void MultiplyZoomFactor (G4double zoomF 262 void SetScaleFactor (const G4Vector 263 void MultiplyScaleFactor (const G4Vector 264 void SetCurrentTargetPoint (const G4Point3 265 void SetDolly (G4double dolly 266 void IncrementDolly (G4double dolly 267 void SetLightpointDirection (const G4Vector 268 void SetLightsMoveWithCamera (G4bool moves); 269 void SetPan (G4double right 270 void IncrementPan (G4double right 271 // Increment currentTarget point perpendicul 272 void IncrementPan (G4double right 273 // Increment currentTarget point also along 274 void SetDefaultVisAttributes (const G4VisAtt 275 void SetDefaultColour (const G4Colour 276 void SetDefaultTextVisAttributes (const G4Vi 277 void SetDefaultTextColour (const G4Colour 278 void SetDefaultMarker (const G4VMarke 279 void SetGlobalMarkerScale (G4double globa 280 void SetGlobalLineWidthScale (G4double globa 281 void SetMarkerHidden (); 282 void SetMarkerNotHidden (); 283 void SetWindowSizeHint (G4int xHint, G 284 void SetWindowLocationHint (G4int xHint, G 285 void SetXGeometryString (const G4String 286 void SetAutoRefresh (G4bool); 287 void SetBackgroundColour (const G4Colour 288 void SetPicking (G4bool); 289 void SetRotationStyle (RotationStyle) 290 void ClearVisAttributesModifiers (); 291 void AddVisAttributesModifier(const G4Modeli 292 void SetStartTime (G4double); 293 void SetEndTime (G4double); 294 void SetFadeFactor (G4double); 295 void SetDisplayHeadTime (G4bool); 296 void SetDisplayHeadTimeX (G4double); 297 void SetDisplayHeadTimeY (G4double); 298 void SetDisplayHeadTimeSize (G4double); 299 void SetDisplayHeadTimeRed (G4double); 300 void SetDisplayHeadTimeGreen (G4double); 301 void SetDisplayHeadTimeBlue (G4double); 302 void SetDisplayLightFront (G4bool); 303 void SetDisplayLightFrontX (G4double); 304 void SetDisplayLightFrontY (G4double); 305 void SetDisplayLightFrontZ (G4double); 306 void SetDisplayLightFrontT (G4double); 307 void SetDisplayLightFrontRed (G4double); 308 void SetDisplayLightFrontGreen (G4double); 309 void SetDisplayLightFrontBlue (G4double); 310 void SetSpecialMeshRendering (G4bool); 311 void SetSpecialMeshRenderingOption (SMROptio 312 void SetSpecialMeshVolumes (const std::vec 313 314 // Command dumping functions. 315 // For camera commands we need to provide th 316 // the current scene. 317 G4String CameraAndLightingCommands(const G4P 318 G4String DrawingStyleCommands () const; 319 G4String SceneModifyingCommands() const; 320 G4String TouchableCommands () const; 321 G4String TimeWindowCommands () const; 322 323 // Other functions. 324 void PrintDifferences (const G4ViewParameter 325 326 // Interpolation 327 // Returns a null pointer when no more to be 328 // do { 329 // G4ViewParameters* vp = 330 // G4ViewParameters::CatmullRomCubicSpline 331 // if (!vp) break; 332 // ... 333 // } while (true); 334 // Assumes equal intervals 335 static G4ViewParameters* CatmullRomCubicSpli 336 (const std::vector<G4ViewParameters>& views, 337 G4int nInterpolationPoints = 50); // No of 338 339 private: 340 341 G4int ParseGeometry ( const char *string, G4 342 G4int ReadInteger(char *string, char **NextS 343 344 DrawingStyle fDrawingStyle; // Drawing st 345 G4int fNumberOfCloudPoints; // For dr 346 // <= 0 m 347 G4bool fAuxEdgeVisible; // Auxiliary 348 G4bool fCulling; // Culling re 349 G4bool fCullInvisible; // Cull (don' 350 G4bool fDensityCulling; // Density cu 351 G4double fVisibleDensity; // ...density 352 G4bool fCullCovered; // Cull daugh 353 G4int fCBDAlgorithmNumber; // Colour 354 std::vector<G4double> fCBDParameters; // Col 355 G4bool fSection; // Section dr 356 G4Plane3D fSectionPlane; // Cut plane 357 CutawayMode fCutawayMode; // Cutaway mo 358 G4Planes fCutawayPlanes; // Set of pla 359 G4double fExplodeFactor; // Explode al 360 G4Point3D fExplodeCentre; // ...about t 361 G4int fNoOfSides; // ...if poly 362 G4Vector3D fViewpointDirection; 363 G4Vector3D fUpVector; // Up vector. 364 // to fViewpo 365 G4double fFieldHalfAngle; // Radius / c 366 G4double fZoomFactor; // Magnificat 367 G4Vector3D fScaleFactor; // (Non-unifo 368 G4Point3D fCurrentTargetPoint; // Relati 369 G4double fDolly; // Distance t 370 G4bool fLightsMoveWithCamera; 371 G4Vector3D fRelativeLightpointDirection; 372 // i.e., rel. to object or camera accoding t 373 G4Vector3D fActualLightpointDirection; 374 G4VisAttributes fDefaultVisAttributes; 375 G4VisAttributes fDefaultTextVisAttributes; 376 G4VMarker fDefaultMarker; 377 G4double fGlobalMarkerScale; 378 G4double fGlobalLineWidthScale; 379 G4bool fMarkerNotHidden; 380 // True if transients are to be drawn and no 381 // hidden-line-hidden-surface removal algori 382 // testing; false if they are to be hidden-l 383 // removed. 384 G4int fWindowSizeHintX; // Size hints 385 G4int fWindowSizeHintY; 386 G4int fWindowLocationHintX; // Locati 387 G4int fWindowLocationHintY; 388 G4bool fWindowLocationHintXNegative; / 389 G4bool fWindowLocationHintYNegative; 390 G4String fXGeometryString; // If non-nul 391 G4int fGeometryMask; // Correspond 392 G4bool fAutoRefresh; // ...after c 393 G4Colour fBackgroundColour; 394 G4bool fPicking; // Request pi 395 RotationStyle fRotationStyle; // Rotation s 396 std::vector<G4ModelingParameters::VisAttribu 397 G4double fStartTime, fEndTime; // Time 398 G4double fFadeFactor; // 0: no fade; 1: 399 G4bool fDisplayHeadTime; // Display h 400 G4double fDisplayHeadTimeX, fDisplayHead 401 G4double fDisplayHeadTimeSize; // Scree 402 G4double fDisplayHeadTimeRed, fDisplayHe 403 G4bool fDisplayLightFront;// Display l 404 G4double fDisplayLightFrontX, fDisplayLi 405 fDisplayLightFrontT; 406 G4double fDisplayLightFrontRed, fDisplay 407 G4bool fSpecialMeshRendering; // Requ 408 SMROption fSpecialMeshRenderingOption; / 409 std::vector<G4ModelingParameters::PVNameCopy 410 411 enum { // Constants for geometry mask in Par 412 fNoValue = 0, 413 fXValue = 0x0001, 414 fYValue = 0x0002, 415 fWidthValue = 0x0004, 416 fHeightValue = 0x0008, 417 fAllValues = 0x000F, 418 fXNegative = 0x0010, 419 fYNegative = 0x0020 420 }; 421 }; 422 423 #include "G4ViewParameters.icc" 424 425 #endif 426