Import Geant4 8.0.0 source tree
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4GraphicsSystemList.cc,v 1.3 2001/07/11 10:09:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
#include "G4GraphicsSystemList.hh"
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Scene.cc,v 1.14 2003/11/27 11:48:14 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Scene.cc,v 1.15 2005/09/16 01:26:19 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// Scene data John Allison 19th July 1996.
|
||||
@@ -44,12 +44,13 @@ G4Scene::G4Scene (const G4String& name):
|
||||
G4Scene::~G4Scene () {}
|
||||
|
||||
G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn) {
|
||||
G4int i, nModels = fRunDurationModelList.size ();
|
||||
for (i = 0; i < nModels; i++) {
|
||||
std::vector<G4VModel*>::const_iterator i;
|
||||
for (i = fRunDurationModelList.begin ();
|
||||
i != fRunDurationModelList.end (); ++i) {
|
||||
if (pModel -> GetGlobalDescription () ==
|
||||
fRunDurationModelList [i] -> GetGlobalDescription ()) break;
|
||||
(*i) -> GetGlobalDescription ()) break;
|
||||
}
|
||||
if (i < nModels) {
|
||||
if (i != fRunDurationModelList.end ()) {
|
||||
if (warn) {
|
||||
G4cout << "G4Scene::AddRunDurationModel: model \""
|
||||
<< pModel -> GetGlobalDescription ()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4SceneHandlerList.cc,v 1.3 2001/07/11 10:09:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
#include "G4SceneHandlerList.hh"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4SceneList.cc,v 1.5 2001/07/11 10:09:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
#include "G4SceneList.hh"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VGraphicsSystem.cc,v 1.10 2003/06/16 17:14:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 27th March 1996
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VSceneHandler.cc,v 1.40 2005/06/07 17:03:17 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VSceneHandler.cc,v 1.45 2005/11/22 17:09:12 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 19th July 1996
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "G4VSceneHandler.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "G4VisManager.hh"
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
@@ -75,10 +75,12 @@ G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4S
|
||||
fViewCount (0),
|
||||
fpViewer (0),
|
||||
fpScene (0),
|
||||
fMarkForClearingTransientStore (true), // Always clear and refesh first time.
|
||||
fReadyForTransients (false),
|
||||
fMarkForClearingTransientStore (false),
|
||||
fSecondPassRequested (false),
|
||||
fSecondPass (false),
|
||||
fReadyForTransients (true), // Only false while processing scene.
|
||||
fpModel (0),
|
||||
fpObjectTransformation (&G4Transform3D::Identity),
|
||||
fpObjectTransformation (0),
|
||||
fNestingDepth (0),
|
||||
fpVisAttribs (0),
|
||||
fCurrentDepth (0),
|
||||
@@ -88,10 +90,9 @@ G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4S
|
||||
G4VisManager* pVMan = G4VisManager::GetInstance ();
|
||||
fpScene = pVMan -> GetCurrentScene ();
|
||||
if (name == "") {
|
||||
char charname [50];
|
||||
std::ostrstream ost (charname, 50);
|
||||
ost << fSystem.GetName () << '-' << fSceneHandlerId << std::ends;
|
||||
fName = charname;
|
||||
std::ostringstream ost;
|
||||
ost << fSystem.GetName () << '-' << fSceneHandlerId;
|
||||
fName = ost.str();
|
||||
}
|
||||
else {
|
||||
fName = name;
|
||||
@@ -114,7 +115,7 @@ void G4VSceneHandler::PreAddSolid (const G4Transform3D& objectTransformation,
|
||||
}
|
||||
|
||||
void G4VSceneHandler::PostAddSolid () {
|
||||
fpObjectTransformation = &G4Transform3D::Identity;
|
||||
fpObjectTransformation = 0;
|
||||
fpVisAttribs = 0;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ void G4VSceneHandler::EndPrimitives () {
|
||||
if (fNestingDepth <= 0)
|
||||
G4Exception("G4VSceneHandler::EndPrimitives: Nesting error");
|
||||
fNestingDepth--;
|
||||
fpObjectTransformation = &G4Transform3D::Identity;
|
||||
fpObjectTransformation = 0;
|
||||
}
|
||||
|
||||
void G4VSceneHandler::AddPrimitive (const G4Scale& scale) {
|
||||
@@ -439,10 +440,6 @@ void G4VSceneHandler::ProcessScene (G4VViewer&) {
|
||||
|
||||
const std::vector<G4VModel*>& runDurationModelList =
|
||||
fpScene -> GetRunDurationModelList ();
|
||||
/*
|
||||
const std::vector<G4VModel*>& endOfEventModelList =
|
||||
fpScene -> GetEndOfEventModelList ();
|
||||
*/
|
||||
|
||||
if (runDurationModelList.size ()) {
|
||||
G4VisManager::Verbosity verbosity =
|
||||
@@ -450,8 +447,12 @@ void G4VSceneHandler::ProcessScene (G4VViewer&) {
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Traversing scene data..." << G4endl;
|
||||
}
|
||||
|
||||
BeginModeling ();
|
||||
|
||||
// Create modeling parameters from view parameters...
|
||||
G4ModelingParameters* pMP = CreateModelingParameters ();
|
||||
|
||||
for (size_t i = 0; i < runDurationModelList.size (); i++) {
|
||||
G4VModel* pModel = runDurationModelList[i];
|
||||
// Note: this is not the place to take action on
|
||||
@@ -475,22 +476,28 @@ void G4VSceneHandler::ProcessScene (G4VViewer&) {
|
||||
pModel -> DescribeYourselfTo (*this);
|
||||
pModel -> SetModelingParameters (tempMP);
|
||||
}
|
||||
/*
|
||||
for (size_t i = 0; i < endOfEventModelList.size (); i++) {
|
||||
G4VModel* pModel = endOfEventModelList[i];
|
||||
const G4ModelingParameters* tempMP =
|
||||
pModel -> GetModelingParameters ();
|
||||
pModel -> SetModelingParameters (pMP);
|
||||
SetModel (pModel); // Store for use by derived class.
|
||||
pModel -> DescribeYourselfTo (*this);
|
||||
pModel -> SetModelingParameters (tempMP);
|
||||
|
||||
// Repeat if required...
|
||||
if (fSecondPassRequested) {
|
||||
fSecondPass = true;
|
||||
for (size_t i = 0; i < runDurationModelList.size (); i++) {
|
||||
G4VModel* pModel = runDurationModelList[i];
|
||||
const G4ModelingParameters* tempMP =
|
||||
pModel -> GetModelingParameters ();
|
||||
pModel -> SetModelingParameters (pMP);
|
||||
SetModel (pModel); // Store for use by derived class.
|
||||
pModel -> DescribeYourselfTo (*this);
|
||||
pModel -> SetModelingParameters (tempMP);
|
||||
}
|
||||
fSecondPass = false;
|
||||
fSecondPassRequested = false;
|
||||
}
|
||||
*/
|
||||
|
||||
delete pMP;
|
||||
SetModel (0); // Flags invalid model.
|
||||
EndModeling ();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
G4VisManager::Verbosity verbosity =
|
||||
G4VisManager::GetInstance()->GetVerbosity();
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
@@ -550,9 +557,9 @@ G4ModelingParameters* G4VSceneHandler::CreateModelingParameters () {
|
||||
|
||||
const G4Colour& G4VSceneHandler::GetColour (const G4Visible& visible) {
|
||||
// Colour is determined by the applicable vis attributes.
|
||||
return fpViewer ->
|
||||
GetApplicableVisAttributes (visible.GetVisAttributes ()) ->
|
||||
GetColour ();
|
||||
const G4Colour& colour = fpViewer ->
|
||||
GetApplicableVisAttributes (visible.GetVisAttributes ()) -> GetColour ();
|
||||
return colour;
|
||||
}
|
||||
|
||||
const G4Colour& G4VSceneHandler::GetTextColour (const G4Text& text) {
|
||||
@@ -560,7 +567,8 @@ const G4Colour& G4VSceneHandler::GetTextColour (const G4Text& text) {
|
||||
if (!pVA) {
|
||||
pVA = fpViewer -> GetViewParameters (). GetDefaultTextVisAttributes ();
|
||||
}
|
||||
return pVA -> GetColour ();
|
||||
const G4Colour& colour = pVA -> GetColour ();
|
||||
return colour;
|
||||
}
|
||||
|
||||
G4ViewParameters::DrawingStyle G4VSceneHandler::GetDrawingStyle
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VViewer.cc,v 1.18 2005/02/23 11:35:58 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VViewer.cc,v 1.20 2005/11/13 15:31:51 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 27th March 1996
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "G4VViewer.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "G4VisManager.hh"
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
@@ -48,10 +48,9 @@ fModified (true),
|
||||
fNeedKernelVisit (true)
|
||||
{
|
||||
if (name == "") {
|
||||
char charname [50];
|
||||
std::ostrstream ost (charname, 50);
|
||||
ost << fSceneHandler.GetName () << '-' << fViewId << std::ends;
|
||||
fName = charname;
|
||||
std::ostringstream ost;
|
||||
ost << fSceneHandler.GetName () << '-' << fViewId;
|
||||
fName = ost.str();
|
||||
}
|
||||
else {
|
||||
fName = name;
|
||||
@@ -62,8 +61,11 @@ fNeedKernelVisit (true)
|
||||
G4VisManager* pVisMan = G4VisManager::GetInstance();
|
||||
G4int xHint, yHint;
|
||||
pVisMan->GetWindowSizeHint(xHint, yHint);
|
||||
const G4String& XGeometryString = pVisMan->GetXGeometryString();
|
||||
fVP.SetWindowSizeHint(xHint,yHint);
|
||||
fVP.SetXGeometryString(XGeometryString);
|
||||
fDefaultVP.SetWindowSizeHint(xHint,yHint);
|
||||
fDefaultVP.SetXGeometryString(XGeometryString);
|
||||
}
|
||||
|
||||
G4VViewer::~G4VViewer () {}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VVisCommand.cc,v 1.15 2005/03/09 23:48:15 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VVisCommand.cc,v 1.17 2005/11/22 17:12:43 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// Base class for visualization commands - John Allison 9th August 1998
|
||||
// It is really a messenger - we have one command per messenger.
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
G4VVisCommand::~G4VVisCommand () {}
|
||||
|
||||
@@ -43,11 +43,9 @@ G4String G4VVisCommand::ConvertToString
|
||||
{
|
||||
G4double uv = G4UIcommand::ValueOf(unitName);
|
||||
|
||||
char st[50];
|
||||
std::ostrstream os(st,50);
|
||||
os << x/uv << " " << y/uv << " " << unitName << std::ends;
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
std::ostringstream oss;
|
||||
oss << x/uv << " " << y/uv << " " << unitName;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
|
||||
@@ -57,7 +55,7 @@ void G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
|
||||
G4double x, y;
|
||||
char unts[30];
|
||||
|
||||
std::istrstream is(paramString);
|
||||
std::istringstream is(paramString);
|
||||
is >> x >> y >> unts;
|
||||
G4String unt = unts;
|
||||
|
||||
@@ -72,7 +70,7 @@ void G4VVisCommand::UpdateVisManagerScene
|
||||
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
|
||||
|
||||
G4int iScene, nScenes = sceneList.size ();
|
||||
for (iScene = 0; iScene < nScenes; iScene++) {
|
||||
@@ -94,11 +92,12 @@ void G4VVisCommand::UpdateVisManagerScene
|
||||
|
||||
fpVisManager -> SetCurrentScene (pScene);
|
||||
|
||||
// Scene has changed. Trigger a rebuild of graphical database...
|
||||
// Scene has changed. Refresh viewers of all sceneHandlers using
|
||||
// this scene...
|
||||
G4VViewer* pViewer = fpVisManager -> GetCurrentViewer();
|
||||
G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler();
|
||||
if (sceneHandler && sceneHandler -> GetScene ()) {
|
||||
if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
|
||||
if (pViewer) {
|
||||
G4UImanager::GetUIpointer () ->
|
||||
ApplyCommand ("/vis/scene/notifyHandlers");
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ViewParameters.cc,v 1.20 2005/05/31 16:54:01 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4ViewParameters.cc,v 1.23 2005/11/13 15:26:18 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 19th July 1996
|
||||
@@ -54,6 +54,7 @@ G4ViewParameters::G4ViewParameters ():
|
||||
fUpVector (G4Vector3D (0., 1., 0.)), // y-axis up.
|
||||
fFieldHalfAngle (0.), // Orthogonal projection.
|
||||
fZoomFactor (1.),
|
||||
fScaleFactor (G4Vector3D (1., 1., 1.)),
|
||||
fCurrentTargetPoint (),
|
||||
fDolly (0.),
|
||||
fLightsMoveWithCamera (false),
|
||||
@@ -69,14 +70,20 @@ G4ViewParameters::G4ViewParameters ():
|
||||
fMarkerNotHidden (true),
|
||||
fWindowSizeHintX (600),
|
||||
fWindowSizeHintY (600),
|
||||
fAutoRefresh (false)
|
||||
fAutoRefresh (false),
|
||||
fBackgroundColour (G4Colour(0.,0.,0.)) // Black
|
||||
{
|
||||
fDefaultMarker.SetScreenSize (5.);
|
||||
// Markers are 5 pixels "overall" size, i.e., diameter.
|
||||
}
|
||||
|
||||
G4ViewParameters::~G4ViewParameters () {
|
||||
// Clear cutaway planes? Rogue Wave probably destroys OK.
|
||||
G4ViewParameters::~G4ViewParameters () {}
|
||||
|
||||
void G4ViewParameters::MultiplyScaleFactor
|
||||
(const G4Vector3D& scaleFactorMultiplier) {
|
||||
fScaleFactor.setX(fScaleFactor.x() * scaleFactorMultiplier.x());
|
||||
fScaleFactor.setY(fScaleFactor.y() * scaleFactorMultiplier.y());
|
||||
fScaleFactor.setZ(fScaleFactor.z() * scaleFactorMultiplier.z());
|
||||
}
|
||||
|
||||
G4Vector3D& G4ViewParameters::GetActualLightpointDirection () {
|
||||
@@ -247,6 +254,7 @@ void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const {
|
||||
(fUpVector != v.fUpVector) ||
|
||||
(fFieldHalfAngle != v.fFieldHalfAngle) ||
|
||||
(fZoomFactor != v.fZoomFactor) ||
|
||||
(fScaleFactor != v.fScaleFactor) ||
|
||||
(fCurrentTargetPoint != v.fCurrentTargetPoint) ||
|
||||
(fDolly != v.fDolly) ||
|
||||
(fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
|
||||
@@ -259,8 +267,11 @@ void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const {
|
||||
(fDefaultMarker != v.fDefaultMarker) ||
|
||||
(fGlobalMarkerScale != v.fGlobalMarkerScale) ||
|
||||
(fMarkerNotHidden != v.fMarkerNotHidden) ||
|
||||
(fWindowSizeHintX != v.fWindowSizeHintX) ||
|
||||
(fWindowSizeHintY != v.fWindowSizeHintY) ||
|
||||
(fAutoRefresh != v.fAutoRefresh))
|
||||
(fXGeometryString != v.fXGeometryString) ||
|
||||
(fAutoRefresh != v.fAutoRefresh) ||
|
||||
(fBackgroundColour != v.fBackgroundColour))
|
||||
G4cout << "Difference in 1st batch." << G4endl;
|
||||
|
||||
if (fSection) {
|
||||
@@ -369,6 +380,8 @@ std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) {
|
||||
|
||||
os << "\n Zoom factor: " << v.fZoomFactor;
|
||||
|
||||
os << "\n Scale factor: " << v.fScaleFactor;
|
||||
|
||||
os << "\n Current target point: " << v.fCurrentTargetPoint;
|
||||
|
||||
os << "\n Dolly distance: " << v.fDolly;
|
||||
@@ -427,10 +440,14 @@ std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) {
|
||||
os << "\n Window size hint: "
|
||||
<< v.fWindowSizeHintX << 'x'<< v.fWindowSizeHintX;
|
||||
|
||||
os << "\n X geometry string: " << v.fXGeometryString;
|
||||
|
||||
os << "\n Auto refresh: ";
|
||||
if (v.fAutoRefresh) os << "true";
|
||||
else os << "false";
|
||||
|
||||
os << "\n Background colour: " << v.fBackgroundColour;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -456,6 +473,7 @@ G4bool G4ViewParameters::operator != (const G4ViewParameters& v) const {
|
||||
(fUpVector != v.fUpVector) ||
|
||||
(fFieldHalfAngle != v.fFieldHalfAngle) ||
|
||||
(fZoomFactor != v.fZoomFactor) ||
|
||||
(fScaleFactor != v.fScaleFactor) ||
|
||||
(fCurrentTargetPoint != v.fCurrentTargetPoint) ||
|
||||
(fDolly != v.fDolly) ||
|
||||
(fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
|
||||
@@ -470,7 +488,9 @@ G4bool G4ViewParameters::operator != (const G4ViewParameters& v) const {
|
||||
(fMarkerNotHidden != v.fMarkerNotHidden) ||
|
||||
(fWindowSizeHintX != v.fWindowSizeHintX) ||
|
||||
(fWindowSizeHintY != v.fWindowSizeHintY) ||
|
||||
(fAutoRefresh != v.fAutoRefresh))
|
||||
(fXGeometryString != v.fXGeometryString) ||
|
||||
(fAutoRefresh != v.fAutoRefresh) ||
|
||||
(fBackgroundColour != v.fBackgroundColour))
|
||||
return true;
|
||||
|
||||
if (fDensityCulling &&
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ViewerList.cc,v 1.3 2001/07/11 10:09:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
#include "G4ViewerList.hh"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommands.cc,v 1.9 2005/03/03 16:13:08 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// /vis/ top level commands - John Allison 5th February 2001
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsCompound.cc,v 1.28 2005/03/03 16:13:08 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsCompound.cc,v 1.30 2005/11/13 15:34:41 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// Compound /vis/ commands - John Allison 15th May 2000
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
////////////// /vis/drawTree ///////////////////////////////////////
|
||||
|
||||
G4VisCommandDrawTree::G4VisCommandDrawTree() {
|
||||
@@ -57,7 +59,7 @@ G4VisCommandDrawTree::~G4VisCommandDrawTree() {
|
||||
void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
|
||||
G4String pvname, system;
|
||||
std::istrstream is(newValue);
|
||||
std::istringstream is(newValue);
|
||||
is >> pvname >> system;
|
||||
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
@@ -133,7 +135,7 @@ void G4VisCommandDrawView::SetNewValue(G4UIcommand*, G4String newValue) {
|
||||
G4String zoomFactor;
|
||||
G4String dolly;
|
||||
G4String dollyUnit;
|
||||
std::istrstream is(newValue);
|
||||
std::istringstream is(newValue);
|
||||
is >> thetaDeg >> phiDeg >> panRight >> panUp >> panUnit
|
||||
>> zoomFactor >> dolly >> dollyUnit;
|
||||
|
||||
@@ -227,9 +229,11 @@ G4VisCommandOpen::G4VisCommandOpen() {
|
||||
candidates = candidates.strip();
|
||||
parameter->SetParameterCandidates(candidates);
|
||||
fpCommand->SetParameter(parameter);
|
||||
parameter = new G4UIparameter("window-size-hint", 'i', omitable = true);
|
||||
parameter->SetGuidance("pixels");
|
||||
parameter->SetDefaultValue(600);
|
||||
parameter = new G4UIparameter("window-size-hint", 's', omitable = true);
|
||||
parameter->SetGuidance
|
||||
("integer (pixels) for square window placed by window manager or"
|
||||
" X-Windows-type geometry string, e.g. 600x600-100+100");
|
||||
parameter->SetDefaultValue("600");
|
||||
fpCommand->SetParameter(parameter);
|
||||
}
|
||||
|
||||
@@ -239,7 +243,7 @@ G4VisCommandOpen::~G4VisCommandOpen() {
|
||||
|
||||
void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4String systemName, windowSizeHint;
|
||||
std::istrstream is(newValue);
|
||||
std::istringstream is(newValue);
|
||||
is >> systemName >> windowSizeHint;
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
G4int keepVerbose = UImanager->GetVerboseLevel();
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsScene.cc,v 1.42 2005/06/07 17:00:59 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsScene.cc,v 1.44 2005/11/22 17:14:44 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// /vis/scene commands - John Allison 9th August 1998
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
G4VVisCommandScene::G4VVisCommandScene () {}
|
||||
|
||||
@@ -66,10 +66,9 @@ G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneCreate::NextName () {
|
||||
char nextName [20];
|
||||
std::ostrstream ost (nextName, 20);
|
||||
ost << "scene-" << fId << std::ends;
|
||||
return nextName;
|
||||
std::ostringstream oss;
|
||||
oss << "scene-" << fId;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand*) {
|
||||
@@ -143,7 +142,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String action;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> action;
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
@@ -219,7 +218,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String action;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> action;
|
||||
|
||||
G4Scene* pScene = fpVisManager->GetCurrentScene();
|
||||
@@ -289,7 +288,7 @@ G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) {
|
||||
|
||||
void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4String name, verbosityString;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> name >> verbosityString;
|
||||
G4VisManager::Verbosity verbosity =
|
||||
fpVisManager->GetVerbosityValue(verbosityString);
|
||||
@@ -363,8 +362,8 @@ G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
|
||||
"\n The default action \"refresh\" does not issue \"update\" (see"
|
||||
"\n /vis/viewer/update)."
|
||||
"\nIf \"flush\" is specified, it issues an \"update\" as well as"
|
||||
"\n \"refresh\" - useful for refreshing and initiating post-processing"
|
||||
"\n for graphics systems which need post-processing.");
|
||||
"\n \"refresh\" - \"update\" and initiates post-processing"
|
||||
"\n for graphics systems which need it.");
|
||||
fpCommand -> SetGuidance
|
||||
("The default for <scene-name> is the current scene name.");
|
||||
fpCommand -> SetGuidance
|
||||
@@ -395,7 +394,7 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String sceneName, refresh_flush;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> sceneName >> refresh_flush;
|
||||
G4bool flush(false);
|
||||
if (refresh_flush(0) == 'f') flush = true;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsSceneAdd.cc,v 1.56 2005/06/27 15:32:46 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsSceneAdd.cc,v 1.59 2005/11/22 17:17:37 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
// /vis/scene commands - John Allison 9th August 1998
|
||||
|
||||
#include "G4VisCommandsSceneAdd.hh"
|
||||
@@ -49,13 +49,14 @@
|
||||
#include "G4UnionSolid.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
// Local function with some frequently used error printing...
|
||||
static void G4VisCommandsSceneAddUnsuccessful
|
||||
@@ -117,7 +118,7 @@ void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
|
||||
G4String unitString;
|
||||
G4double x0, y0, z0, length;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> x0 >> y0 >> z0 >> length >> unitString;
|
||||
|
||||
G4double unit = G4UIcommand::ValueOf(unitString);
|
||||
@@ -355,7 +356,7 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
|
||||
G4String name;
|
||||
G4int requestedDepthOfDescent;
|
||||
G4bool booleans, voxels, readout;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> name >> requestedDepthOfDescent >> booleans >> voxels >> readout;
|
||||
|
||||
G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
|
||||
@@ -374,6 +375,30 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<G4VModel*>& rdModelList = pScene -> GetRunDurationModelList();
|
||||
std::vector<G4VModel*>::const_iterator i;
|
||||
for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
|
||||
if ((*i) -> GetGlobalDescription().find("Volume") != std::string::npos) break;
|
||||
}
|
||||
if (i != rdModelList.end()) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout << "There is already a volume, \""
|
||||
<< (*i) -> GetGlobalDescription()
|
||||
<< "\",\n in the run-duration model list of scene \""
|
||||
<< pScene -> GetName()
|
||||
<< "\".\n Your logical volume must be the only volume in the scene."
|
||||
<< "\n Create a new scene and try again:"
|
||||
<< "\n /vis/specify " << name
|
||||
<< "\n or"
|
||||
<< "\n /vis/scene/create"
|
||||
<< "\n /vis/scene/add/logicalVolume " << name
|
||||
<< "\n /vis/sceneHandler/attach"
|
||||
<< "\n (and also, if necessary, /vis/viewer/flush)"
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4VModel* model = new G4LogicalVolumeModel
|
||||
(pLV, requestedDepthOfDescent, booleans, voxels, readout);
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
@@ -471,7 +496,7 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
|
||||
G4double userHeight, red, green, blue, xmid, ymid, zmid;
|
||||
G4String userHeightUnit, direction, auto_manual, positionUnit;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> userHeight >> userHeightUnit >> direction
|
||||
>> red >> green >> blue
|
||||
>> auto_manual
|
||||
@@ -797,7 +822,7 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
|
||||
G4double userLength, red, green, blue, xmid, ymid, zmid;
|
||||
G4String userLengthUnit, direction, auto_manual, positionUnit;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> userLength >> userLengthUnit >> direction
|
||||
>> red >> green >> blue
|
||||
>> auto_manual
|
||||
@@ -807,10 +832,9 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4double unit = G4UIcommand::ValueOf(positionUnit);
|
||||
xmid *= unit; ymid *= unit; zmid *= unit;
|
||||
|
||||
char tempcharstring [50];
|
||||
std::ostrstream ost (tempcharstring, 50);
|
||||
ost << userLength << ' ' << userLengthUnit << std::ends;
|
||||
G4String annotation(tempcharstring);
|
||||
std::ostringstream oss;
|
||||
oss << userLength << ' ' << userLengthUnit;
|
||||
G4String annotation(oss.str());
|
||||
|
||||
G4Scale::Direction scaleDirection (G4Scale::x);
|
||||
if (direction(0) == 'y') scaleDirection = G4Scale::y;
|
||||
@@ -1123,11 +1147,22 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
|
||||
}
|
||||
|
||||
G4int drawingMode;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> drawingMode;
|
||||
G4TrajectoriesModel* model = new G4TrajectoriesModel(drawingMode);
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
pScene -> AddEndOfEventModel (model, warn);
|
||||
|
||||
G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
||||
G4int keepVerbose = UImanager->GetVerboseLevel();
|
||||
G4int newVerbose = 0;
|
||||
if (keepVerbose >= 2 ||
|
||||
fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
|
||||
newVerbose = 2;
|
||||
UImanager->SetVerboseLevel(newVerbose);
|
||||
UImanager->ApplyCommand("/tracking/storeTrajectory 1");
|
||||
UImanager->SetVerboseLevel(keepVerbose);
|
||||
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Trajectories will be drawn with mode "
|
||||
<< drawingMode
|
||||
@@ -1135,6 +1170,10 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
|
||||
<< currentSceneName << "\"."
|
||||
<< G4endl;
|
||||
}
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "WARNING: \"/tracking/storeTrajectory 1\" has been executed."
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
////////////// /vis/scene/add/userAction ///////////////////////////////////
|
||||
@@ -1208,7 +1247,7 @@ void G4VisCommandSceneAddUserAction::SetNewValue (G4UIcommand*,
|
||||
|
||||
G4String unitString;
|
||||
G4double xmin, xmax, ymin, ymax, zmin, zmax;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
|
||||
G4double unit = G4UIcommand::ValueOf(unitString);
|
||||
xmin *= unit; xmax *= unit;
|
||||
@@ -1281,7 +1320,8 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
|
||||
parameter -> SetDefaultValue ("none");
|
||||
parameter -> SetGuidance
|
||||
("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
|
||||
"\n Only \"box\" is programmed at present.");
|
||||
// "\n Only \"box\" is programmed at present."); No '\n' for GAG (temp).
|
||||
" Only \"box\" is programmed at present.");
|
||||
fpCommand -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
|
||||
parameter -> SetDefaultValue ("m");
|
||||
@@ -1331,7 +1371,7 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
|
||||
G4String name, clipVolumeType, parameterUnit;
|
||||
G4int copyNo, requestedDepthOfDescent;
|
||||
G4double param1, param2, param3, param4, param5, param6;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> name >> copyNo >> requestedDepthOfDescent
|
||||
>> clipVolumeType >> parameterUnit
|
||||
>> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
|
||||
@@ -1346,6 +1386,31 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
|
||||
G4VPhysicalVolume* foundVolume = 0;
|
||||
G4int foundDepth = 0;
|
||||
|
||||
const std::vector<G4VModel*>& rdModelList = pScene -> GetRunDurationModelList();
|
||||
std::vector<G4VModel*>::const_iterator i;
|
||||
for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
|
||||
if ((*i) -> GetGlobalDescription().find("G4PhysicalVolumeModel")
|
||||
!= std::string::npos) {
|
||||
if (((G4PhysicalVolumeModel*)(*i)) -> GetTopPhysicalVolume () == world) break;
|
||||
}
|
||||
}
|
||||
if (i != rdModelList.end()) {
|
||||
if (verbosity >= G4VisManager::warnings) {
|
||||
G4cout << "WARNING: There is already a volume, \""
|
||||
<< (*i) -> GetGlobalDescription()
|
||||
<< "\",\n in the run-duration model list of scene \""
|
||||
<< pScene -> GetName()
|
||||
<< "\".\n To get a clean scene:"
|
||||
<< "\n /vis/drawVolume " << name
|
||||
<< "\n or"
|
||||
<< "\n /vis/scene/create"
|
||||
<< "\n /vis/scene/add/volume " << name
|
||||
<< "\n /vis/sceneHandler/attach"
|
||||
<< "\n (and also, if necessary, /vis/viewer/flush)"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == "world") {
|
||||
if (world) {
|
||||
model = new G4PhysicalVolumeModel (world,
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsSceneHandler.cc,v 1.27 2005/03/10 19:33:03 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsSceneHandler.cc,v 1.29 2005/11/22 17:23:52 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// /vis/sceneHandler commands - John Allison 10th October 1998
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
////////////// /vis/sceneHandler/attach ///////////////////////////////////////
|
||||
|
||||
@@ -86,8 +86,7 @@ void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
|
||||
return;
|
||||
}
|
||||
|
||||
G4SceneList& sceneList =
|
||||
fpVisManager -> SetSceneList ();
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
|
||||
if (sceneList.empty ()) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
@@ -105,12 +104,22 @@ void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
|
||||
if (iScene < nScenes) {
|
||||
G4Scene* pScene = sceneList [iScene];
|
||||
pSceneHandler -> SetScene (pScene);
|
||||
UpdateVisManagerScene(sceneName);
|
||||
// Make sure scene is current...
|
||||
fpVisManager -> SetCurrentScene (pScene);
|
||||
// Refresh viewer, if any (only if auto-refresh)...
|
||||
G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
|
||||
if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
|
||||
pViewer -> SetView ();
|
||||
pViewer -> ClearView ();
|
||||
pViewer -> DrawView ();
|
||||
}
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Scene \"" << sceneName
|
||||
<< "\" attached to scene handler \""
|
||||
<< pSceneHandler -> GetName ()
|
||||
<< "." << G4endl;
|
||||
<< pSceneHandler -> GetName () <<
|
||||
".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
|
||||
" is not \"auto-refresh\".)"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -164,10 +173,9 @@ G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate () {
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneHandlerCreate::NextName () {
|
||||
char nextName [20];
|
||||
std::ostrstream ost (nextName, 20);
|
||||
ost << "scene-handler-" << fId << std::ends;
|
||||
return nextName;
|
||||
std::ostringstream oss;
|
||||
oss << "scene-handler-" << fId;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneHandlerCreate::GetCurrentValue(G4UIcommand*) {
|
||||
@@ -198,7 +206,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String graphicsSystem, newName;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> graphicsSystem >> newName;
|
||||
|
||||
const G4GraphicsSystemList& gsl =
|
||||
@@ -263,8 +271,19 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
|
||||
|
||||
//Create scene handler.
|
||||
fpVisManager -> CreateSceneHandler (newName);
|
||||
if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName)
|
||||
if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
|
||||
" Curious name mismatch."
|
||||
"\n Current name \""
|
||||
<< fpVisManager -> GetCurrentSceneHandler () -> GetName ()
|
||||
<< "\" is not the new name \""
|
||||
<< newName
|
||||
<< "\".\n Please report to vis coordinator."
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "New scene handler \"" << newName << "\" created." << G4endl;
|
||||
@@ -303,7 +322,7 @@ G4String G4VisCommandSceneHandlerList::GetCurrentValue (G4UIcommand*) {
|
||||
void G4VisCommandSceneHandlerList::SetNewValue (G4UIcommand*,
|
||||
G4String newValue) {
|
||||
G4String name, verbosityString;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> name >> verbosityString;
|
||||
G4VisManager::Verbosity verbosity =
|
||||
fpVisManager->GetVerbosityValue(verbosityString);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsViewer.cc,v 1.45 2005/03/16 17:55:02 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsViewer.cc,v 1.53 2005/11/22 17:00:15 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// /vis/viewer commands - John Allison 25th October 1998
|
||||
|
||||
@@ -36,9 +36,10 @@
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
|
||||
G4VVisCommandViewer::G4VVisCommandViewer () {}
|
||||
|
||||
@@ -127,9 +128,11 @@ G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
|
||||
parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
|
||||
parameter -> SetCurrentAsDefault (true);
|
||||
fpCommand -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("window-size-hint", 'i', omitable = true);
|
||||
parameter -> SetGuidance ("pixels");
|
||||
parameter -> SetDefaultValue (600);
|
||||
parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
|
||||
parameter->SetGuidance
|
||||
("integer (pixels) for square window placed by window manager or"
|
||||
" X-Windows-type geometry string, e.g. 600x600-100+100");
|
||||
parameter->SetDefaultValue("600");
|
||||
fpCommand -> SetParameter (parameter);
|
||||
}
|
||||
|
||||
@@ -138,19 +141,17 @@ G4VisCommandViewerCreate::~G4VisCommandViewerCreate () {
|
||||
}
|
||||
|
||||
G4String G4VisCommandViewerCreate::NextName () {
|
||||
const int charLength = 100;
|
||||
char nextName [charLength];
|
||||
std::ostrstream ost (nextName, charLength);
|
||||
std::ostringstream oss;
|
||||
G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler ();
|
||||
ost << "viewer-" << fId << " (";
|
||||
oss << "viewer-" << fId << " (";
|
||||
if (sceneHandler) {
|
||||
ost << sceneHandler -> GetGraphicsSystem () -> GetName ();
|
||||
oss << sceneHandler -> GetGraphicsSystem () -> GetName ();
|
||||
}
|
||||
else {
|
||||
ost << "no_scene_handlers";
|
||||
oss << "no_scene_handlers";
|
||||
}
|
||||
ost << ")" << std::ends;
|
||||
return nextName;
|
||||
oss << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
G4String G4VisCommandViewerCreate::GetCurrentValue (G4UIcommand*) {
|
||||
@@ -178,8 +179,8 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String sceneHandlerName, newName;
|
||||
G4int windowSizeHint;
|
||||
std::istrstream is (newValue);
|
||||
G4String windowSizeHintString;
|
||||
std::istringstream is (newValue);
|
||||
is >> sceneHandlerName;
|
||||
|
||||
// Now need to handle the possibility that the second string
|
||||
@@ -196,8 +197,8 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
newName = newName.strip (G4String::both, ' ');
|
||||
newName = newName.strip (G4String::both, '"');
|
||||
|
||||
// Now get number of pixels...
|
||||
is >> windowSizeHint;
|
||||
// Now get window size hint...
|
||||
is >> windowSizeHintString;
|
||||
|
||||
const G4SceneHandlerList& sceneHandlerList =
|
||||
fpVisManager -> GetAvailableSceneHandlers ();
|
||||
@@ -257,26 +258,61 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
}
|
||||
}
|
||||
|
||||
// Parse windowSizeHintString to extract first field for backwards
|
||||
// compatibility...
|
||||
std::istringstream issw;
|
||||
G4int windowSizeHint;
|
||||
size_t i;
|
||||
for (i = 0; i < windowSizeHintString.size(); ++i) {
|
||||
char c = windowSizeHintString[i];
|
||||
if (c == 'x' || c == 'X' || c == '+' || c == '-') break;
|
||||
}
|
||||
if (i != windowSizeHintString.size()) {
|
||||
// x or X or + or - found - must be a X-Window-type geometry string...
|
||||
// Pick out the first field for backwards compatibility...
|
||||
issw.str(windowSizeHintString.substr(0,i));
|
||||
issw >> windowSizeHint;
|
||||
} else { // ...old-style integer...
|
||||
issw.str(windowSizeHintString);
|
||||
if (!(issw >> windowSizeHint)) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout << "ERROR: Unrecognised geometry string \""
|
||||
<< windowSizeHintString
|
||||
<< "\". Using 600."
|
||||
<< G4endl;
|
||||
}
|
||||
windowSizeHint = 600;
|
||||
}
|
||||
// Reconstitute windowSizeHintString...
|
||||
std::ostringstream ossw;
|
||||
ossw << windowSizeHint << 'x' << windowSizeHint;
|
||||
windowSizeHintString = ossw.str();
|
||||
}
|
||||
fpVisManager->SetWindowSizeHint (windowSizeHint, windowSizeHint);
|
||||
// These are picked up in the G4VViewer constructor. The problem is
|
||||
// these have to be set *before* construction, i.e., before we have
|
||||
// a viewer.
|
||||
fpVisManager->SetXGeometryString(windowSizeHintString);
|
||||
// WindowSizeHint and XGeometryString are picked up from the vis
|
||||
// manager in the G4VViewer constructor. They have to be held by
|
||||
// the vis manager until the viewer is contructed - next line...
|
||||
|
||||
// Create viewer.
|
||||
fpVisManager -> CreateViewer (newName);
|
||||
G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
|
||||
if (newViewer -> GetName () == newName) {
|
||||
if (newViewer && newViewer -> GetName () == newName) {
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "New viewer \"" << newName << "\" created." << G4endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
|
||||
if (newViewer) {
|
||||
G4cout << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
|
||||
} else {
|
||||
G4cout << "WARNING: No viewer created." << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Refresh if appropriate...
|
||||
SetViewParameters(newViewer, newViewer->GetViewParameters());
|
||||
if (newViewer) SetViewParameters(newViewer, newViewer->GetViewParameters());
|
||||
}
|
||||
|
||||
////////////// /vis/viewer/dolly and dollyTo ////////////////////////////
|
||||
@@ -446,7 +482,7 @@ G4String G4VisCommandViewerList::GetCurrentValue (G4UIcommand*) {
|
||||
|
||||
void G4VisCommandViewerList::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4String name, verbosityString;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> name >> verbosityString;
|
||||
G4String shortName = fpVisManager -> ViewerShortName (name);
|
||||
G4VisManager::Verbosity verbosity =
|
||||
@@ -614,6 +650,53 @@ void G4VisCommandViewerPan::SetNewValue (G4UIcommand* command,
|
||||
SetViewParameters(currentViewer, vp);
|
||||
}
|
||||
|
||||
////////////// /vis/viewer/rebuild ///////////////////////////////////////
|
||||
|
||||
G4VisCommandViewerRebuild::G4VisCommandViewerRebuild () {
|
||||
G4bool omitable, currentAsDefault;
|
||||
fpCommand = new G4UIcmdWithAString ("/vis/viewer/rebuild", this);
|
||||
fpCommand -> SetGuidance ("Forces rebuild of graphical database.");
|
||||
fpCommand -> SetGuidance
|
||||
("By default, acts on current viewer. \"/vis/viewer/list\""
|
||||
"\nto see possible viewers. Viewer becomes current.");
|
||||
fpCommand -> SetParameterName ("viewer-name",
|
||||
omitable = true,
|
||||
currentAsDefault = true);
|
||||
}
|
||||
|
||||
G4VisCommandViewerRebuild::~G4VisCommandViewerRebuild () {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
G4String G4VisCommandViewerRebuild::GetCurrentValue (G4UIcommand*) {
|
||||
G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
|
||||
if (viewer) {
|
||||
return viewer -> GetName ();
|
||||
}
|
||||
else {
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
void G4VisCommandViewerRebuild::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String& rebuildName = newValue;
|
||||
G4VViewer* viewer = fpVisManager -> GetViewer (rebuildName);
|
||||
if (!viewer) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout << "ERROR: Viewer \"" << rebuildName
|
||||
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
viewer->SetNeedKernelVisit(true);
|
||||
SetViewParameters(viewer, viewer->GetDefaultViewParameters());
|
||||
}
|
||||
|
||||
////////////// /vis/viewer/refresh ///////////////////////////////////////
|
||||
|
||||
G4VisCommandViewerRefresh::G4VisCommandViewerRefresh () {
|
||||
@@ -691,8 +774,8 @@ void G4VisCommandViewerRefresh::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4cout << "Refreshing viewer \"" << viewer -> GetName () << "\"..."
|
||||
<< G4endl;
|
||||
}
|
||||
//??viewer -> SetView ();
|
||||
//??viewer -> ClearView ();
|
||||
viewer -> SetView ();
|
||||
viewer -> ClearView ();
|
||||
viewer -> DrawView ();
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Viewer \"" << viewer -> GetName () << "\"" << " refreshed."
|
||||
@@ -746,6 +829,86 @@ void G4VisCommandViewerReset::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
SetViewParameters(viewer, viewer->GetDefaultViewParameters());
|
||||
}
|
||||
|
||||
////////////// /vis/viewer/scale and scaleTo ////////////////////////////
|
||||
|
||||
G4VisCommandViewerScale::G4VisCommandViewerScale ():
|
||||
fScaleMultiplier (G4Vector3D (1., 1., 1.)),
|
||||
fScaleTo (G4Vector3D (1., 1., 1.))
|
||||
{
|
||||
G4bool omitable, currentAsDefault;
|
||||
|
||||
fpCommandScale = new G4UIcmdWith3Vector
|
||||
("/vis/viewer/scale", this);
|
||||
fpCommandScale -> SetGuidance ("Incremental (non-uniform) scaling.");
|
||||
fpCommandScale -> SetGuidance
|
||||
("Multiplies components of current scaling by components of this factor."
|
||||
"\n Scales (x,y,z) by corresponding components of the resulting factor.");
|
||||
fpCommandScale -> SetGuidance
|
||||
("");
|
||||
fpCommandScale -> SetParameterName
|
||||
("x-scale-multiplier","y-scale-multiplier","z-scale-multiplier",
|
||||
omitable=true, currentAsDefault=true);
|
||||
|
||||
fpCommandScaleTo = new G4UIcmdWith3Vector
|
||||
("/vis/viewer/scaleTo", this);
|
||||
fpCommandScaleTo -> SetGuidance ("Absolute (non-uniform) scaling.");
|
||||
fpCommandScaleTo -> SetGuidance
|
||||
("Scales (x,y,z) by corresponding components of this factor.");
|
||||
fpCommandScaleTo -> SetParameterName
|
||||
("x-scale-factor","y-scale-factor","z-scale-factor",
|
||||
omitable=true, currentAsDefault=true);
|
||||
}
|
||||
|
||||
G4VisCommandViewerScale::~G4VisCommandViewerScale () {
|
||||
delete fpCommandScale;
|
||||
delete fpCommandScaleTo;
|
||||
}
|
||||
|
||||
G4String G4VisCommandViewerScale::GetCurrentValue (G4UIcommand* command) {
|
||||
G4String currentValue;
|
||||
if (command == fpCommandScale) {
|
||||
currentValue = fpCommandScale->ConvertToString(G4ThreeVector(fScaleMultiplier));
|
||||
}
|
||||
else if (command == fpCommandScaleTo) {
|
||||
currentValue = fpCommandScaleTo->ConvertToString(G4ThreeVector(fScaleTo));
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
void G4VisCommandViewerScale::SetNewValue (G4UIcommand* command,
|
||||
G4String newValue) {
|
||||
|
||||
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
|
||||
if (!currentViewer) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout <<
|
||||
"ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4ViewParameters vp = currentViewer->GetViewParameters();
|
||||
|
||||
if (command == fpCommandScale) {
|
||||
fScaleMultiplier = fpCommandScale->GetNew3VectorValue(newValue);
|
||||
vp.MultiplyScaleFactor(fScaleMultiplier);
|
||||
}
|
||||
else if (command == fpCommandScaleTo) {
|
||||
fScaleTo = fpCommandScale->GetNew3VectorValue(newValue);
|
||||
vp.SetScaleFactor(fScaleTo);
|
||||
}
|
||||
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Scale factor changed to " << vp.GetScaleFactor() << G4endl;
|
||||
}
|
||||
|
||||
SetViewParameters(currentViewer, vp);
|
||||
}
|
||||
|
||||
////////////// /vis/viewer/select ///////////////////////////////////////
|
||||
|
||||
G4VisCommandViewerSelect::G4VisCommandViewerSelect () {
|
||||
@@ -830,7 +993,16 @@ void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand*, G4String newValue) {
|
||||
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
||||
|
||||
G4String& updateName = newValue;
|
||||
|
||||
G4VViewer* viewer = fpVisManager -> GetViewer (updateName);
|
||||
if (!viewer) {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout <<
|
||||
"ERROR: G4VisCommandsViewerUpdate::SetNewValue: no current viewer."
|
||||
<< G4endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
|
||||
if (!sceneHandler) {
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisCommandsViewerSet.cc,v 1.34 2005/05/06 08:46:50 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisCommandsViewerSet.cc,v 1.38 2005/11/13 15:37:24 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
// /vis/viewer/set commands - John Allison 16th May 2000
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
#include "G4VisManager.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
|
||||
G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
|
||||
fLightsVector (G4ThreeVector(1.,1.,1.)),
|
||||
fUpVector (G4ThreeVector(0.,1.,0.)),
|
||||
@@ -299,6 +302,29 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
|
||||
parameter = new G4UIparameter ("z", 'd', omitable = true);
|
||||
parameter -> SetDefaultValue (1.);
|
||||
fpCommandViewpointVector -> SetParameter (parameter);
|
||||
|
||||
fpCommandBackground = new G4UIcommand
|
||||
("/vis/viewer/set/background",this);
|
||||
fpCommandBackground->SetGuidance
|
||||
("Set background colour and transparency (default black and opaque).");
|
||||
fpCommandBackground->SetGuidance
|
||||
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
|
||||
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
|
||||
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
|
||||
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
|
||||
"\n e.g. \"! ! ! 0.\" for a transparent background.");
|
||||
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
|
||||
parameter -> SetDefaultValue ("0.");
|
||||
fpCommandBackground -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter("green", 'd', omitable = true);
|
||||
parameter -> SetDefaultValue (0.);
|
||||
fpCommandBackground -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("blue", 'd', omitable = true);
|
||||
parameter -> SetDefaultValue (0.);
|
||||
fpCommandBackground -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
|
||||
parameter -> SetDefaultValue (1.);
|
||||
fpCommandBackground -> SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
|
||||
@@ -321,6 +347,7 @@ G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
|
||||
delete fpCommandUpVector;
|
||||
delete fpCommandViewpointThetaPhi;
|
||||
delete fpCommandViewpointVector;
|
||||
delete fpCommandBackground;
|
||||
}
|
||||
|
||||
G4String G4VisCommandsViewerSet::GetCurrentValue(G4UIcommand*) {
|
||||
@@ -401,7 +428,7 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
G4String cullingOption, stringFlag, unit;
|
||||
G4double density;
|
||||
G4bool boolFlag;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> cullingOption >> stringFlag >> density >> unit;
|
||||
boolFlag = G4UIcommand::ConvertToBool(stringFlag);
|
||||
if (cullingOption == "global") {
|
||||
@@ -617,14 +644,14 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
|
||||
else if (command == fpCommandProjection) {
|
||||
G4double fieldHalfAngle;
|
||||
size_t iPos = 0;
|
||||
if (newValue[iPos] == 'o') { // "orthogonal"
|
||||
const size_t iPos0 = 0;
|
||||
if (newValue[iPos0] == 'o') { // "orthogonal"
|
||||
fieldHalfAngle = 0.;
|
||||
}
|
||||
else if (newValue[iPos] == 'p') { // "perspective"
|
||||
else if (newValue[iPos0] == 'p') { // "perspective"
|
||||
G4String dummy;
|
||||
G4String unit;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> dummy >> fieldHalfAngle >> unit;
|
||||
fieldHalfAngle *= G4UIcommand::ValueOf(unit);
|
||||
if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
|
||||
@@ -661,7 +688,7 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
else if (command == fpCommandSectionPlane) {
|
||||
G4String choice, unit;
|
||||
G4double x, y, z, nx, ny, nz;
|
||||
std::istrstream is (newValue);
|
||||
std::istringstream is (newValue);
|
||||
is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
|
||||
|
||||
G4int iSelector = -1;
|
||||
@@ -712,8 +739,8 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
|
||||
else if (command == fpCommandStyle) {
|
||||
G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
|
||||
size_t iPos = 0;
|
||||
if (newValue[iPos] == 'w') { // "wireframe"
|
||||
const size_t iPos0 = 0;
|
||||
if (newValue[iPos0] == 'w') { // "wireframe"
|
||||
switch (existingStyle) {
|
||||
case G4ViewParameters::wireframe:
|
||||
break;
|
||||
@@ -727,7 +754,7 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (newValue[iPos] == 's') { // "surface"
|
||||
else if (newValue[iPos0] == 's') { // "surface"
|
||||
switch (existingStyle) {
|
||||
case G4ViewParameters::wireframe:
|
||||
vp.SetDrawingStyle(G4ViewParameters::hsr);
|
||||
@@ -807,6 +834,29 @@ void G4VisCommandsViewerSet::SetNewValue
|
||||
}
|
||||
}
|
||||
|
||||
else if (command == fpCommandBackground) {
|
||||
G4String redOrString;
|
||||
G4double green, blue, opacity;
|
||||
std::istringstream iss(newValue);
|
||||
iss >> redOrString >> green >> blue >> opacity;
|
||||
G4Colour colour(0.,0.,0.); // Default black and opaque.
|
||||
const size_t iPos0 = 0;
|
||||
if (std::isalpha(redOrString[iPos0])) {
|
||||
G4Colour::GetColour(redOrString, colour); // Remains default (black) if
|
||||
// not found.
|
||||
} else {
|
||||
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
|
||||
}
|
||||
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
|
||||
vp.SetBackgroundColour(colour);
|
||||
if (verbosity >= G4VisManager::confirmations) {
|
||||
G4cout << "Background colour "
|
||||
<< vp.GetBackgroundColour()
|
||||
<< " requested."
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
if (verbosity >= G4VisManager::errors) {
|
||||
G4cout <<
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisFeaturesOfDAWNFILE.cc,v 1.5 2001/07/11 10:09:19 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
#include "G4VisFeaturesOfDAWNFILE.hh"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisFeaturesOfFukuiRenderer.cc,v 1.4 2001/07/11 10:09:19 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisFeaturesOfOpenGL.cc,v 1.4 2001/07/11 10:09:19 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisFeaturesOfOpenInventor.cc,v 1.4 2001/07/11 10:09:19 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VisManager.cc,v 1.63 2005/03/09 23:48:15 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4VisManager.cc,v 1.78 2005/12/04 01:36:17 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
|
||||
@@ -58,6 +57,13 @@
|
||||
#include "G4NullModel.hh"
|
||||
#include "G4ModelingParameters.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VisListManager.hh"
|
||||
#include "G4VisCommandModelCreate.hh"
|
||||
#include "G4VisCommandsListManager.hh"
|
||||
#include "G4VModelFactory.hh"
|
||||
#include "G4VTrajectoryModel.hh"
|
||||
#include "G4TrajectoryDrawByCharge.hh"
|
||||
#include <sstream>
|
||||
|
||||
G4VisManager* G4VisManager::fpInstance = 0;
|
||||
|
||||
@@ -70,7 +76,10 @@ G4VisManager::G4VisManager ():
|
||||
fpViewer (0),
|
||||
fVerbosity (warnings),
|
||||
fVerbose (1),
|
||||
fpStateDependent (0) // All other objects use default constructors.
|
||||
fpStateDependent (0),
|
||||
fTrajectoryPlacement("/vis/modeling/trajectories"),
|
||||
fpTrajectoryModelMgr(new G4TrajectoryModelManager())
|
||||
// All other objects use default constructors.
|
||||
{
|
||||
VerbosityGuidanceStrings.push_back
|
||||
("Simple graded message scheme - digit or string (1st character defines):");
|
||||
@@ -96,6 +105,7 @@ G4VisManager::G4VisManager ():
|
||||
else {
|
||||
|
||||
fpInstance = this;
|
||||
SetConcreteInstance(this);
|
||||
|
||||
fpStateDependent = new G4VisStateDependent (this);
|
||||
// No need to delete this; G4StateManager does this.
|
||||
@@ -108,20 +118,21 @@ G4VisManager::G4VisManager ():
|
||||
// higher level library to avoid circular dependencies. Also,
|
||||
// some specifically need additional external libararies that the
|
||||
// user must supply. Therefore we ask the user to implement
|
||||
// RegisterGraphicsSystems() in a subclass. We have to wait for
|
||||
// the subclass to instantiate so RegisterGraphicsSystems() cannot
|
||||
// be called from this constructor; it is called from
|
||||
// Initialise(). So we ask the user:
|
||||
// (a) to write a subclass and implement
|
||||
// RegisterGraphicsSystems(). See
|
||||
// visualization/include/MyVisManager.hh/cc as an example.
|
||||
// RegisterGraphicsSystems() and RegisterModelFactories()
|
||||
// in a subclass. We have to wait for the subclass to instantiate
|
||||
// so RegisterGraphicsSystems() cannot be called from this
|
||||
// constructor; it is called from Initialise(). So we ask the
|
||||
// user:
|
||||
// (a) to write a subclass and implement RegisterGraphicsSystems()
|
||||
// and RegisterModelFactories(). See
|
||||
// visualization/include/G4VisExecutive.hh/icc as an example.
|
||||
// (b) instantiate the subclass.
|
||||
// (c) invoke the Initialise() method of the subclass.
|
||||
// For example:
|
||||
// ...
|
||||
// #ifdef G4VIS_USE
|
||||
// // Instantiate and initialise Visualization Manager.
|
||||
// G4VisManager* visManager = new MyVisManager;
|
||||
// G4VisManager* visManager = new G4VisExecutive;
|
||||
// visManager -> SetVerboseLevel (Verbose);
|
||||
// visManager -> Initialise ();
|
||||
// #endif
|
||||
@@ -152,6 +163,12 @@ G4VisManager::~G4VisManager () {
|
||||
for (i = 0; i < fDirectoryList.size (); ++i) {
|
||||
delete fDirectoryList[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < fTrajectoryModelFactoryList.size(); ++i) {
|
||||
delete fTrajectoryModelFactoryList[i];
|
||||
}
|
||||
|
||||
delete fpTrajectoryModelMgr;
|
||||
}
|
||||
|
||||
G4VisManager* G4VisManager::GetInstance () {
|
||||
@@ -175,14 +192,16 @@ void G4VisManager::Initialise () {
|
||||
"\n you should, normally, instantiate drivers which do not need"
|
||||
"\n external packages or libraries, and, optionally, drivers under"
|
||||
"\n control of environment variables."
|
||||
"\n See visualization/include/MyVisManager.hh/cc, for example."
|
||||
"\n Also you should implement RegisterModelFactories()."
|
||||
"\n See visualization/include/G4VisExecutive.hh/icc, for example."
|
||||
"\n In your main() you will have something like:"
|
||||
"\n #ifdef G4VIS_USE"
|
||||
"\n G4VisManager* visManager = new MyVisManager;"
|
||||
"\n G4VisManager* visManager = new G4VisExecutive;"
|
||||
"\n visManager -> SetVerboseLevel (Verbose);"
|
||||
"\n visManager -> Initialize ();"
|
||||
"\n #endif"
|
||||
"\n (Don't forget to delete visManager;)"
|
||||
"\n"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
@@ -192,15 +211,40 @@ void G4VisManager::Initialise () {
|
||||
|
||||
RegisterGraphicsSystems ();
|
||||
|
||||
if (fVerbosity >= confirmations) {
|
||||
if (fVerbosity >= startup) {
|
||||
G4cout <<
|
||||
"\nYou have successfully chosen to use the following graphics systems."
|
||||
<< G4endl;
|
||||
PrintAvailableGraphicsSystems ();
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
// Make top level directory...
|
||||
G4UIcommand* directory;
|
||||
directory = new G4UIdirectory ("/vis/");
|
||||
directory -> SetGuidance ("Visualization commands.");
|
||||
fDirectoryList.push_back (directory);
|
||||
|
||||
// ... and make command directory for commands instantiated in the
|
||||
// modeling subcategory...
|
||||
directory = new G4UIdirectory ("/vis/modeling/");
|
||||
directory -> SetGuidance ("Modeling commands.");
|
||||
fDirectoryList.push_back (directory);
|
||||
directory = new G4UIdirectory ("/vis/modeling/trajectories/");
|
||||
directory -> SetGuidance ("Trajectory model commands.");
|
||||
fDirectoryList.push_back (directory);
|
||||
directory = new G4UIdirectory ("/vis/modeling/trajectories/create/");
|
||||
directory -> SetGuidance ("Create trajectory models and messengers.");
|
||||
fDirectoryList.push_back (directory);
|
||||
|
||||
RegisterMessengers ();
|
||||
|
||||
if (fVerbosity >= startup) {
|
||||
G4cout << "Registering model factories..." << G4endl;
|
||||
}
|
||||
|
||||
RegisterModelFactories();
|
||||
|
||||
fInitialised = true;
|
||||
}
|
||||
|
||||
@@ -226,6 +270,7 @@ void G4VisManager::Disable() {
|
||||
if (fVerbosity >= confirmations) {
|
||||
G4cout <<
|
||||
"G4VisManager::Disable: visualization disabled."
|
||||
"\n The pointer returned by GetConcreteInstance will be zero."
|
||||
"\n Note that it will become enabled after some valid vis commands."
|
||||
<< G4endl;
|
||||
}
|
||||
@@ -252,7 +297,7 @@ const G4GraphicsSystemList& G4VisManager::GetAvailableGraphicsSystems () {
|
||||
}
|
||||
|
||||
G4bool G4VisManager::RegisterGraphicsSystem (G4VGraphicsSystem* pSystem) {
|
||||
G4bool happy(true);
|
||||
G4bool happy = true;
|
||||
if (pSystem) {
|
||||
fAvailableGraphicsSystems.push_back (pSystem);
|
||||
if (fVerbosity >= confirmations) {
|
||||
@@ -267,13 +312,33 @@ G4bool G4VisManager::RegisterGraphicsSystem (G4VGraphicsSystem* pSystem) {
|
||||
else {
|
||||
if (fVerbosity >= errors) {
|
||||
G4cout << "G4VisManager::RegisterGraphicsSystem: null pointer!"
|
||||
<<G4endl;
|
||||
<< G4endl;
|
||||
}
|
||||
happy=false;
|
||||
}
|
||||
return happy;
|
||||
}
|
||||
|
||||
void G4VisManager::RegisterModel(G4VTrajectoryModel* model)
|
||||
{
|
||||
fpTrajectoryModelMgr->Register(model);
|
||||
}
|
||||
|
||||
void
|
||||
G4VisManager::RegisterModelFactory(G4TrajectoryModelFactory* factory)
|
||||
{
|
||||
// vis manager takes ownership
|
||||
fTrajectoryModelFactoryList.push_back(factory);
|
||||
|
||||
// Create messenger for this factory
|
||||
RegisterMessenger(new G4VisCommandModelCreate<G4TrajectoryModelFactory>(factory, fTrajectoryPlacement));
|
||||
}
|
||||
|
||||
void G4VisManager::SelectTrajectoryModel(const G4String& model)
|
||||
{
|
||||
fpTrajectoryModelMgr->SetCurrent(model);
|
||||
}
|
||||
|
||||
void G4VisManager::Draw (const G4Circle& circle,
|
||||
const G4Transform3D& objectTransform) {
|
||||
if (IsValidView ()) {
|
||||
@@ -441,8 +506,6 @@ void G4VisManager::CreateViewer (G4String name) {
|
||||
fpViewer -> Initialise ();
|
||||
fpSceneHandler -> AddViewerToList (fpViewer);
|
||||
fpSceneHandler -> SetCurrentViewer (fpViewer);
|
||||
// Make it possible for user action code to Draw.
|
||||
SetConcreteInstance(this);
|
||||
|
||||
const G4ViewParameters& vp = fpViewer->GetViewParameters();
|
||||
G4bool warn = false;
|
||||
@@ -572,6 +635,29 @@ void G4VisManager::GeometryHasChanged () {
|
||||
|
||||
}
|
||||
|
||||
void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode)
|
||||
{
|
||||
assert (0 != fpTrajectoryModelMgr);
|
||||
|
||||
const G4VTrajectoryModel* model = fpTrajectoryModelMgr->Current();
|
||||
|
||||
if (0 == model) {
|
||||
// No model was registered with the trajectory model manager.
|
||||
// Use G4TrajectoryDrawByCharge as a default.
|
||||
fpTrajectoryModelMgr->Register(new G4TrajectoryDrawByCharge());
|
||||
|
||||
if (fVerbosity >= warnings) {
|
||||
G4cout<<"G4VisManager: Using G4TrajectoryDrawByCharge as default trajectory model."<<G4endl;
|
||||
G4cout<<"See commands in /vis/modeling/trajectories/ for other options."<<G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
model = fpTrajectoryModelMgr->Current();
|
||||
assert (0 != model); // Should definitely exist now
|
||||
|
||||
model->Draw(trajectory, i_mode);
|
||||
}
|
||||
|
||||
void G4VisManager::SetUserAction
|
||||
(G4VUserVisAction* pVisAction,
|
||||
const G4VisExtent& extent) {
|
||||
@@ -625,15 +711,11 @@ void G4VisManager::SetCurrentGraphicsSystem (G4VGraphicsSystem* pSystem) {
|
||||
}
|
||||
else {
|
||||
fpViewer = 0;
|
||||
// Make it impossible for user action code to Draw.
|
||||
SetConcreteInstance(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fpSceneHandler = 0;
|
||||
fpViewer = 0;
|
||||
// Make it impossible for user action code to Draw.
|
||||
SetConcreteInstance(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -676,8 +758,6 @@ void G4VisManager::SetCurrentSceneHandler (G4VSceneHandler* pSceneHandler) {
|
||||
}
|
||||
else {
|
||||
fpViewer = 0;
|
||||
// Make it impossible for user action code to Draw.
|
||||
SetConcreteInstance(0);
|
||||
if (fVerbosity >= warnings) {
|
||||
G4cout <<
|
||||
"WARNING: No viewers for this scene handler - please create one."
|
||||
@@ -709,70 +789,75 @@ void G4VisManager::RegisterMessengers () {
|
||||
|
||||
G4UIcommand* directory;
|
||||
|
||||
directory = new G4UIdirectory ("/vis/");
|
||||
directory -> SetGuidance ("Visualization commands.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandEnable);
|
||||
fMessengerList.push_back (new G4VisCommandVerbose);
|
||||
RegisterMessenger(new G4VisCommandEnable);
|
||||
RegisterMessenger(new G4VisCommandVerbose);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/scene/");
|
||||
directory -> SetGuidance ("Operations on Geant4 scenes.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandSceneCreate);
|
||||
fMessengerList.push_back (new G4VisCommandSceneEndOfEventAction);
|
||||
fMessengerList.push_back (new G4VisCommandSceneEndOfRunAction);
|
||||
fMessengerList.push_back (new G4VisCommandSceneList);
|
||||
fMessengerList.push_back (new G4VisCommandSceneNotifyHandlers);
|
||||
fMessengerList.push_back (new G4VisCommandSceneSelect);
|
||||
RegisterMessenger(new G4VisCommandSceneCreate);
|
||||
RegisterMessenger(new G4VisCommandSceneEndOfEventAction);
|
||||
RegisterMessenger(new G4VisCommandSceneEndOfRunAction);
|
||||
RegisterMessenger(new G4VisCommandSceneList);
|
||||
RegisterMessenger(new G4VisCommandSceneNotifyHandlers);
|
||||
RegisterMessenger(new G4VisCommandSceneSelect);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/scene/add/");
|
||||
directory -> SetGuidance ("Add model to current scene.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddAxes);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddGhosts);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddHits);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddLogicalVolume);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddLogo);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddScale);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddText);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddTrajectories);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddUserAction);
|
||||
fMessengerList.push_back (new G4VisCommandSceneAddVolume);
|
||||
RegisterMessenger(new G4VisCommandSceneAddAxes);
|
||||
RegisterMessenger(new G4VisCommandSceneAddGhosts);
|
||||
RegisterMessenger(new G4VisCommandSceneAddHits);
|
||||
RegisterMessenger(new G4VisCommandSceneAddLogicalVolume);
|
||||
RegisterMessenger(new G4VisCommandSceneAddLogo);
|
||||
RegisterMessenger(new G4VisCommandSceneAddScale);
|
||||
RegisterMessenger(new G4VisCommandSceneAddText);
|
||||
RegisterMessenger(new G4VisCommandSceneAddTrajectories);
|
||||
RegisterMessenger(new G4VisCommandSceneAddUserAction);
|
||||
RegisterMessenger(new G4VisCommandSceneAddVolume);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/sceneHandler/");
|
||||
directory -> SetGuidance ("Operations on Geant4 scene handlers.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandSceneHandlerAttach);
|
||||
fMessengerList.push_back (new G4VisCommandSceneHandlerCreate);
|
||||
fMessengerList.push_back (new G4VisCommandSceneHandlerList);
|
||||
fMessengerList.push_back (new G4VisCommandSceneHandlerSelect);
|
||||
RegisterMessenger(new G4VisCommandSceneHandlerAttach);
|
||||
RegisterMessenger(new G4VisCommandSceneHandlerCreate);
|
||||
RegisterMessenger(new G4VisCommandSceneHandlerList);
|
||||
RegisterMessenger(new G4VisCommandSceneHandlerSelect);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/viewer/");
|
||||
directory -> SetGuidance ("Operations on Geant4 viewers.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandViewerClear);
|
||||
fMessengerList.push_back (new G4VisCommandViewerCreate);
|
||||
fMessengerList.push_back (new G4VisCommandViewerDolly);
|
||||
fMessengerList.push_back (new G4VisCommandViewerFlush);
|
||||
fMessengerList.push_back (new G4VisCommandViewerList);
|
||||
fMessengerList.push_back (new G4VisCommandViewerPan);
|
||||
fMessengerList.push_back (new G4VisCommandViewerRefresh);
|
||||
fMessengerList.push_back (new G4VisCommandViewerReset);
|
||||
fMessengerList.push_back (new G4VisCommandViewerSelect);
|
||||
fMessengerList.push_back (new G4VisCommandViewerUpdate);
|
||||
fMessengerList.push_back (new G4VisCommandViewerZoom);
|
||||
RegisterMessenger(new G4VisCommandViewerClear);
|
||||
RegisterMessenger(new G4VisCommandViewerCreate);
|
||||
RegisterMessenger(new G4VisCommandViewerDolly);
|
||||
RegisterMessenger(new G4VisCommandViewerFlush);
|
||||
RegisterMessenger(new G4VisCommandViewerList);
|
||||
RegisterMessenger(new G4VisCommandViewerPan);
|
||||
RegisterMessenger(new G4VisCommandViewerRebuild);
|
||||
RegisterMessenger(new G4VisCommandViewerRefresh);
|
||||
RegisterMessenger(new G4VisCommandViewerReset);
|
||||
RegisterMessenger(new G4VisCommandViewerScale);
|
||||
RegisterMessenger(new G4VisCommandViewerSelect);
|
||||
RegisterMessenger(new G4VisCommandViewerUpdate);
|
||||
RegisterMessenger(new G4VisCommandViewerZoom);
|
||||
|
||||
directory = new G4UIdirectory ("/vis/viewer/set/");
|
||||
directory -> SetGuidance ("Set view parameters of current viewer.");
|
||||
fDirectoryList.push_back (directory);
|
||||
fMessengerList.push_back (new G4VisCommandsViewerSet);
|
||||
RegisterMessenger(new G4VisCommandsViewerSet);
|
||||
|
||||
// Compound commands...
|
||||
fMessengerList.push_back (new G4VisCommandDrawTree);
|
||||
fMessengerList.push_back (new G4VisCommandDrawView);
|
||||
fMessengerList.push_back (new G4VisCommandDrawVolume);
|
||||
fMessengerList.push_back (new G4VisCommandOpen);
|
||||
fMessengerList.push_back (new G4VisCommandSpecify);
|
||||
RegisterMessenger(new G4VisCommandDrawTree);
|
||||
RegisterMessenger(new G4VisCommandDrawView);
|
||||
RegisterMessenger(new G4VisCommandDrawVolume);
|
||||
RegisterMessenger(new G4VisCommandOpen);
|
||||
RegisterMessenger(new G4VisCommandSpecify);
|
||||
|
||||
// List manager commands
|
||||
RegisterMessenger(new G4VisCommandListManagerList<G4TrajectoryModelManager>
|
||||
(fpTrajectoryModelMgr, fTrajectoryPlacement));
|
||||
RegisterMessenger(new G4VisCommandListManagerSelect<G4TrajectoryModelManager>
|
||||
(fpTrajectoryModelMgr, fTrajectoryPlacement));
|
||||
}
|
||||
|
||||
void G4VisManager::PrintAvailableGraphicsSystems () const {
|
||||
@@ -800,11 +885,19 @@ void G4VisManager::PrintInvalidPointers () const {
|
||||
G4cout << "\n null graphics system pointer.";
|
||||
}
|
||||
else {
|
||||
G4cout << "\n graphics system is " << fpGraphicsSystem -> GetName ()
|
||||
G4cout << "\n Graphics system is " << fpGraphicsSystem -> GetName ()
|
||||
<< " but:";
|
||||
if (!fpScene) G4cout << "\nNull scene pointer. ";
|
||||
if (!fpSceneHandler) G4cout << "\nNull scene handler pointer. ";
|
||||
if (!fpViewer ) G4cout << "\nNull viewer pointer. ";
|
||||
if (!fpScene)
|
||||
G4cout <<
|
||||
"\n Null scene pointer. Use \"/vis/drawVolume\" or"
|
||||
" \"/vis/scene/create\".";
|
||||
if (!fpSceneHandler)
|
||||
G4cout <<
|
||||
"\n Null scene handler pointer. Use \"/vis/open\" or"
|
||||
" \"/vis/sceneHandler/create\".";
|
||||
if (!fpViewer )
|
||||
G4cout <<
|
||||
"\n Null viewer pointer. Use \"/vis/viewer/create\".";
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
@@ -820,12 +913,15 @@ void G4VisManager::BeginOfEvent () {
|
||||
|
||||
void G4VisManager::EndOfEvent () {
|
||||
//G4cout << "G4VisManager::EndOfEvent" << G4endl;
|
||||
if (GetConcreteInstance() && IsValidView ()) {
|
||||
// Don't call IsValidView unless there is a scene handler. This
|
||||
// avoids ERROR messages at end of event and run when the user has
|
||||
// not instantiated a scene handler, e.g., in batch mode.
|
||||
if (GetConcreteInstance() && fpSceneHandler && IsValidView()) {
|
||||
const std::vector<G4VModel*>& EOEModelList =
|
||||
fpScene -> GetEndOfEventModelList ();
|
||||
size_t nModels = EOEModelList.size();
|
||||
ClearTransientStoreIfMarked();
|
||||
if (nModels) {
|
||||
ClearTransientStoreIfMarked();
|
||||
fVisManagerModelingParameters
|
||||
= *(fpSceneHandler -> CreateModelingParameters ());
|
||||
for (size_t i = 0; i < nModels; i++) {
|
||||
@@ -845,7 +941,10 @@ void G4VisManager::EndOfEvent () {
|
||||
|
||||
void G4VisManager::EndOfRun () {
|
||||
//G4cout << "G4VisManager::EndOfRun" << G4endl;
|
||||
if (GetConcreteInstance() && IsValidView ()) {
|
||||
// Don't call IsValidView unless there is a scene handler. This
|
||||
// avoids ERROR messages at end of event and run when the user has
|
||||
// not instantiated a scene handler, e.g., in batch mode.
|
||||
if (GetConcreteInstance() && fpSceneHandler && IsValidView()) {
|
||||
if (!fpSceneHandler->GetMarkForClearingTransientStore()) {
|
||||
if (fpScene->GetRefreshAtEndOfRun()) {
|
||||
fpViewer->ShowView(); // ...for systems needing post processing.
|
||||
@@ -932,7 +1031,7 @@ G4VisManager::GetVerbosityValue(const G4String& verbosityString) {
|
||||
else if (s(0) == 'a') verbosity = all;
|
||||
else {
|
||||
G4int intVerbosity;
|
||||
std::istrstream is(s);
|
||||
std::istringstream is(s);
|
||||
is >> intVerbosity;
|
||||
if (!is) {
|
||||
G4cout << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
|
||||
@@ -971,12 +1070,22 @@ G4bool G4VisManager::IsValidView () {
|
||||
|
||||
if (!fInitialised) Initialise ();
|
||||
|
||||
SetConcreteInstance(0);
|
||||
// Unless we survive a few preliminary tests, users must not use.
|
||||
|
||||
if (!fpGraphicsSystem) return false;
|
||||
// Simply return without printing - we do not want printing if the
|
||||
// user simply does not want to use graphics, e.g., in batch mode.
|
||||
static G4bool noGSPrinting = true;
|
||||
if (!fpGraphicsSystem) {
|
||||
// Limit printing - we do not want printing if the user simply does
|
||||
// not want to use graphics, e.g., in batch mode.
|
||||
if (noGSPrinting) {
|
||||
noGSPrinting = false;
|
||||
if (fVerbosity >= errors) {
|
||||
G4cout <<
|
||||
"ERROR: G4VisManager::IsValidView(): Vis manager but no graphics system."
|
||||
"\n Suppress instantiation of vis manager (G4VisExecutive) or"
|
||||
"\n use \"/vis/open\" or \"/vis/sceneHandler/create\"."
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) {
|
||||
if (fVerbosity >= errors) {
|
||||
@@ -1035,7 +1144,6 @@ G4bool G4VisManager::IsValidView () {
|
||||
return false;
|
||||
}
|
||||
|
||||
SetConcreteInstance(this); // Unless we find another problem, users can use!
|
||||
G4bool isValid = true;
|
||||
if (fpScene -> IsEmpty ()) { // Add world by default if possible...
|
||||
G4bool warn(fVerbosity >= warnings);
|
||||
@@ -1050,7 +1158,6 @@ G4bool G4VisManager::IsValidView () {
|
||||
<< G4endl;
|
||||
}
|
||||
isValid = false;
|
||||
SetConcreteInstance(0); // Users must not use!
|
||||
}
|
||||
else {
|
||||
G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/viewer/reset");
|
||||
@@ -1062,5 +1169,16 @@ G4bool G4VisManager::IsValidView () {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isValid) SetConcreteInstance(this);
|
||||
return isValid;
|
||||
}
|
||||
|
||||
void
|
||||
G4VisManager::RegisterModelFactories()
|
||||
{
|
||||
if (fVerbosity >= warnings) {
|
||||
G4cout<<"G4VisManager: No model factories registered with G4VisManager."<<G4endl;
|
||||
G4cout<<"G4VisManager::RegisterModelFactories() should be overridden in derived"<<G4endl;
|
||||
G4cout<<"class. See G4VisExecutive for an example."<<G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4VisStateDependent.cc,v 1.5 2002/12/05 01:37:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
|
||||
#include "G4VisStateDependent.hh"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user