#include <G4XXXStoredViewer.hh>
Inheritance diagram for G4XXXStoredViewer:
Public Member Functions | |
G4XXXStoredViewer (G4VSceneHandler &, const G4String &name) | |
virtual | ~G4XXXStoredViewer () |
void | SetView () |
void | ClearView () |
void | DrawView () |
void | ShowView () |
Protected Member Functions | |
void | KernelVisitDecision () |
G4bool | CompareForKernelVisit (G4ViewParameters &) |
void | DrawFromStore () |
Protected Attributes | |
G4ViewParameters | fLastVP |
Definition at line 39 of file G4XXXStoredViewer.hh.
G4XXXStoredViewer::G4XXXStoredViewer | ( | G4VSceneHandler & | , | |
const G4String & | name | |||
) |
Definition at line 43 of file G4XXXStoredViewer.cc.
00043 : 00044 G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name) 00045 {}
G4XXXStoredViewer::~G4XXXStoredViewer | ( | ) | [virtual] |
void G4XXXStoredViewer::ClearView | ( | ) | [virtual] |
G4bool G4XXXStoredViewer::CompareForKernelVisit | ( | G4ViewParameters & | ) | [protected] |
Definition at line 114 of file G4XXXStoredViewer.cc.
References G4VViewer::fVP, G4ViewParameters::GetBackgroundColour(), G4VisAttributes::GetColour(), G4ViewParameters::GetDefaultTextVisAttributes(), G4ViewParameters::GetDefaultVisAttributes(), G4ViewParameters::GetDrawingStyle(), G4ViewParameters::GetExplodeFactor(), G4ViewParameters::GetNoOfSides(), G4ViewParameters::GetRepStyle(), G4ViewParameters::GetVisAttributesModifiers(), G4ViewParameters::GetVisibleDensity(), G4ViewParameters::IsAuxEdgeVisible(), G4ViewParameters::IsCulling(), G4ViewParameters::IsCullingCovered(), G4ViewParameters::IsCullingInvisible(), G4ViewParameters::IsDensityCulling(), G4ViewParameters::IsExplode(), and G4ViewParameters::IsMarkerNotHidden().
Referenced by KernelVisitDecision().
00115 { 00116 // Typical comparison. Taken from OpenGL. 00117 if ( 00118 (lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) || 00119 (lastVP.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) || 00120 (lastVP.GetRepStyle () != fVP.GetRepStyle ()) || 00121 (lastVP.IsCulling () != fVP.IsCulling ()) || 00122 (lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) || 00123 (lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) || 00124 (lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) || 00125 // No need to visit kernel if section plane changes. 00126 // No need to visit kernel if cutaway planes change. 00127 (lastVP.IsExplode () != fVP.IsExplode ()) || 00128 (lastVP.GetNoOfSides () != fVP.GetNoOfSides ()) || 00129 (lastVP.IsMarkerNotHidden () != fVP.IsMarkerNotHidden ()) || 00130 (lastVP.GetDefaultVisAttributes()->GetColour() != 00131 fVP.GetDefaultVisAttributes()->GetColour()) || 00132 (lastVP.GetDefaultTextVisAttributes()->GetColour() != 00133 fVP.GetDefaultTextVisAttributes()->GetColour()) || 00134 (lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())|| 00135 (lastVP.GetVisAttributesModifiers().size() != 00136 fVP.GetVisAttributesModifiers().size()) 00137 ) { 00138 return true; 00139 } 00140 00141 if (lastVP.IsDensityCulling () && 00142 (lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ())) 00143 return true; 00144 00145 if (lastVP.IsExplode () && 00146 (lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ())) 00147 return true; 00148 00149 return false; 00150 }
void G4XXXStoredViewer::DrawFromStore | ( | ) | [protected] |
Definition at line 152 of file G4XXXStoredViewer.cc.
References G4VViewer::fName, and G4VViewer::fSceneHandler.
Referenced by DrawView().
00152 { 00153 typedef std::list<G4String> Store; 00154 typedef std::list<G4String>::iterator StoreIterator; 00155 Store& store = 00156 static_cast<G4XXXStoredSceneHandler&>(fSceneHandler).fStore; 00157 // Write to a file for testing... 00158 static G4int iCount = 0; 00159 std::ostringstream oss; 00160 oss << fName << '.' << iCount++ << ".out"; 00161 std::ofstream ofs(oss.str().c_str()); 00162 for (StoreIterator i = store.begin(); i != store.end(); ++i) { 00163 ofs << *i; 00164 } 00165 ofs.close(); 00166 }
void G4XXXStoredViewer::DrawView | ( | ) | [virtual] |
Implements G4VViewer.
Definition at line 61 of file G4XXXStoredViewer.cc.
References DrawFromStore(), G4VViewer::FinishView(), G4VViewer::fNeedKernelVisit, G4cout, G4endl, KernelVisitDecision(), and G4VViewer::ProcessView().
00061 { 00062 #ifdef G4XXXStoredDEBUG 00063 G4cout << "G4XXXStoredViewer::DrawView() called." << G4endl; 00064 #endif 00065 00066 // First, a view should decide when to re-visit the G4 kernel. 00067 // Sometimes it might not be necessary, e.g., if the scene is stored 00068 // in a graphical database (e.g., OpenGL's display lists) and only 00069 // the viewing angle has changed. But graphics systems without a 00070 // graphical database will always need to visit the G4 kernel. 00071 00072 // The fNeedKernelVisit flag might have been set by the user in 00073 // /vis/viewer/rebuild, but if not, make decision and set flag only 00074 // if necessary... 00075 if (!fNeedKernelVisit) KernelVisitDecision(); 00076 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets). 00077 00078 ProcessView (); // Clears store and processes scene only if necessary. 00079 00080 if (kernelVisitWasNeeded) { 00081 // Some systems, notably OpenGL, can draw while re-building, so 00082 // there might not be a need to draw from store again here. But 00083 // in this case... 00084 DrawFromStore(); 00085 } else { 00086 DrawFromStore(); 00087 } 00088 00089 // ...before finally... 00090 FinishView (); // Flush streams and/or swap buffers. 00091 }
void G4XXXStoredViewer::KernelVisitDecision | ( | ) | [protected] |
Definition at line 99 of file G4XXXStoredViewer.cc.
References CompareForKernelVisit(), fLastVP, G4VViewer::fSceneHandler, G4VViewer::fVP, and G4VViewer::NeedKernelVisit().
Referenced by DrawView().
00099 { 00100 00101 // If there's a significant difference with the last view parameters 00102 // of either the scene handler or this viewer, trigger a rebuild. 00103 00104 typedef std::list<G4String> Store; 00105 typedef std::list<G4String>::iterator StoreIterator; 00106 Store& store = 00107 static_cast<G4XXXStoredSceneHandler&>(fSceneHandler).fStore; 00108 if (store.empty() || CompareForKernelVisit(fLastVP)) { 00109 NeedKernelVisit (); // Sets fNeedKernelVisit. 00110 } 00111 fLastVP = fVP; 00112 }
void G4XXXStoredViewer::SetView | ( | ) | [virtual] |
void G4XXXStoredViewer::ShowView | ( | ) | [virtual] |
G4ViewParameters G4XXXStoredViewer::fLastVP [protected] |