[531] | 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: G4VViewer.hh,v 1.18 2006/06/29 21:28:14 gunter Exp $ |
---|
[954] | 28 | // GEANT4 tag $Name: $ |
---|
[531] | 29 | // |
---|
| 30 | // |
---|
| 31 | // John Allison 27th March 1996 |
---|
| 32 | // |
---|
| 33 | // Class description |
---|
| 34 | // |
---|
| 35 | // Abstract interface class for graphics viewers. |
---|
| 36 | |
---|
| 37 | #ifndef G4VVIEWER_HH |
---|
| 38 | #define G4VVIEWER_HH |
---|
| 39 | |
---|
| 40 | #include "globals.hh" |
---|
| 41 | |
---|
| 42 | #include "G4ViewParameters.hh" |
---|
| 43 | |
---|
| 44 | class G4VSceneHandler; |
---|
| 45 | |
---|
| 46 | class G4VViewer { |
---|
| 47 | |
---|
| 48 | public: // With description |
---|
| 49 | |
---|
| 50 | friend std::ostream& operator << (std::ostream& os, const G4VViewer& v); |
---|
| 51 | |
---|
| 52 | G4VViewer (G4VSceneHandler&, G4int id, const G4String& name = ""); |
---|
| 53 | virtual ~G4VViewer (); |
---|
| 54 | |
---|
| 55 | virtual void Initialise (); |
---|
| 56 | // Called immediately after construction for those operations that |
---|
| 57 | // must await complete contruction of viewer and all its bases. For |
---|
| 58 | // example, if this class (G4VViewer) is inherited virtually, as in |
---|
| 59 | // the OpenGL sub-category, it will not be fully constructed until |
---|
| 60 | // *after* the the derived viewer (this is the rule about order of |
---|
| 61 | // construction for virtual inheritance), so the derived viewer may |
---|
| 62 | // not use information in G4VViewer in its contructor. Hence such |
---|
| 63 | // code must be in Initialise(). |
---|
| 64 | |
---|
| 65 | ////////////////////////////////////////////////////////////// |
---|
| 66 | // View manipulation functions. |
---|
| 67 | |
---|
| 68 | virtual void SetView () = 0; |
---|
| 69 | // Take view parameters and work out model/view transformation, |
---|
| 70 | // projection transformation, lighting, etc. |
---|
| 71 | |
---|
| 72 | virtual void ClearView () = 0; |
---|
| 73 | // Clear screen/viewing buffers. |
---|
| 74 | |
---|
| 75 | virtual void DrawView () = 0; |
---|
| 76 | // Draw view of the scene currently attached to the scene handler - |
---|
| 77 | // see example of a minimal function at end of this file. |
---|
| 78 | |
---|
| 79 | virtual void ShowView (); |
---|
| 80 | // Show view (for graphics systems which require to process |
---|
| 81 | // all drawn objects before finalising the view). |
---|
| 82 | |
---|
| 83 | virtual void FinishView (); |
---|
| 84 | // Called at the end of drawing scene. Used to flush streams, or |
---|
| 85 | // swap buffers. (Perhaps it is inappropriately named, perhaps its |
---|
| 86 | // function could be incorporated into EndModeling (). It marks the |
---|
| 87 | // end of scene drawing; be aware hits and digi drawing may Follow. |
---|
| 88 | // It is not yet the end of all drawing; that is signalled by |
---|
| 89 | // ShowView ().) |
---|
| 90 | |
---|
| 91 | ////////////////////////////////////////////////////////////// |
---|
| 92 | // Access functions. |
---|
| 93 | const G4String& GetName () const; |
---|
| 94 | const G4String& GetShortName () const; |
---|
| 95 | void SetName (const G4String&); |
---|
| 96 | G4int GetViewId () const; |
---|
| 97 | G4VSceneHandler* GetSceneHandler () const; |
---|
| 98 | const G4ViewParameters& GetViewParameters () const; |
---|
| 99 | const G4ViewParameters& GetDefaultViewParameters () const; |
---|
| 100 | void SetViewParameters (const G4ViewParameters& vp); |
---|
| 101 | void SetDefaultViewParameters (const G4ViewParameters& vp); |
---|
| 102 | |
---|
| 103 | ////////////////////////////////////////////////////////////// |
---|
| 104 | // Public utility functions. |
---|
| 105 | |
---|
| 106 | const G4VisAttributes* GetApplicableVisAttributes |
---|
| 107 | (const G4VisAttributes*) const; |
---|
| 108 | |
---|
| 109 | void SetNeedKernelVisit (G4bool need); |
---|
| 110 | // Sets individual need-visit flag. |
---|
| 111 | |
---|
| 112 | void NeedKernelVisit (); |
---|
| 113 | // Flags all views the need to re-visit the GEANT4 kernel to refresh |
---|
| 114 | // the scene. |
---|
| 115 | |
---|
| 116 | void ProcessView (); |
---|
| 117 | // Used by DrawView (). Invokes SetView (). The basic logic is here. |
---|
| 118 | |
---|
| 119 | protected: |
---|
| 120 | |
---|
| 121 | ////////////////////////////////////////////////////////////// |
---|
| 122 | // Data members |
---|
| 123 | G4VSceneHandler& fSceneHandler; // Abstract scene for this view. |
---|
| 124 | G4int fViewId; // Id of this instance. |
---|
| 125 | G4String fName; |
---|
| 126 | G4String fShortName; // Up to first ' ' character, if any. |
---|
| 127 | G4ViewParameters fVP; // View parameters. |
---|
| 128 | G4ViewParameters fDefaultVP; // Default view parameters. |
---|
| 129 | |
---|
| 130 | ////////////////////////////////////////////////////////////// |
---|
| 131 | // Other parameters. |
---|
| 132 | G4bool fNeedKernelVisit; // See DrawView() for comments. |
---|
| 133 | }; |
---|
| 134 | |
---|
| 135 | #include "G4VViewer.icc" |
---|
| 136 | |
---|
| 137 | /********************************************* |
---|
| 138 | |
---|
| 139 | Here is a minimal DrawView () as it might be implemented in the |
---|
| 140 | concrete viewer. |
---|
| 141 | |
---|
| 142 | void G4VViewer::DrawView () { // Default - concrete view usually overrides. |
---|
| 143 | |
---|
| 144 | // First, a view should decide when to re-visit the G4 kernel. |
---|
| 145 | // Sometimes it might not be necessary, e.g., if the scene is stored |
---|
| 146 | // in a graphical database (e.g., OpenGL's display lists) and only |
---|
| 147 | // the viewing angle has changed. But graphics systems without a |
---|
| 148 | // graphical database will always need to visit the G4 kernel. |
---|
| 149 | |
---|
| 150 | NeedKernelVisit (); // Default is - always visit G4 kernel. |
---|
| 151 | // Note: this routine sets the fNeedKernelVisit flag of *all* the views of |
---|
| 152 | // the scene. |
---|
| 153 | |
---|
| 154 | ProcessView (); // The basic logic is here. |
---|
| 155 | |
---|
| 156 | // Then a view may have more to do, e.g., display the graphical |
---|
| 157 | // database. That code should come here before finally... |
---|
| 158 | |
---|
| 159 | FinishView (); // Flush streams and/or swap buffers. |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | *********************************************/ |
---|
| 163 | |
---|
| 164 | #endif |
---|