Import Geant4 10.6.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2019-06-28 11:59:04 +02:00
parent 28a70706e0
commit d0f911957d
1056 changed files with 95168 additions and 78160 deletions
+191 -1
View File
@@ -25,9 +25,199 @@ committal in the CVS repository !
History file for visualization management sub-category
------------------------------------------------------
21 January 2019 John Allison (visman-V10-04-29)
13 June 2019 John Allison (visman-V10-05-06)
- Part of vis-V10-05-20.
- G4VSceneHandler:
o Final changes for introduction of cloud drawing.
o Add GetNumberOfCloudPoints:
Returns no of cloud points from current view parameters, unless the user
has forced through the vis attributes, thereby over-riding the
current view parameter.
- G4ViewParameters:
o Add accessors for number of cloud points.
- G4VisCommandsGeometrySet: Tidy.
- G4VisCommandsTouchableSet: Add commands for cloud style.
- G4VisCommandsViewerSet: Add commands for cloud style.
- G4VisCommandsCompound.cc: Tidy.
- G4VisCommandsGeometrySet.cc: Tidy.
- G4VisCommandsTouchable.cc: Improve printing.
29 May 2019 John Allison (visman-V10-05-05)
- G4VisManager.cc:
o Removed the word "WARNING" from message about number of events
kept for refreshing and/or reviewing.
04 April 2019 John Allison (visman-V10-05-04)
- Co-works modeling-V10-05-01.
- Final (for now) corrections to /vis/viewer/set/sectionPlane.
Still some strange behaviour in small fraction of cases. See
comments in G4PhysicalVolumeModel::DescribeSolid around line 748.
29 March 2019 John Allison (visman-V10-05-03)
- G4VSceneHandler.hh:
o BeginPrimitives/2D: Added default argument G4Transform3D() to
correspond to base class G4VGraphicsScene.
- G4ViewParameters.hh:
o Improved comments.
- G4Scene.cc: Improved operator<<.
24 March 2019 John Allison (visman-V10-05-02)
- Fix bug in /vis/viewer/set/sectionPlane.
Involves using G4DisplacedSolid instead of plain G4VSolid.
18 March 2019 Gabriele Cosmo (visman-V10-05-01)
- Corrected few typos in printout/comments.
10 March 2019 John Allison (visman-V10-05-00)
- Introduce cloud drawing style:
New parameter candidate in /vis/viewer/set/style:
/vis/viewer/set/style cloud
Cloud drawing uses solid->GetPointOnSurface, i.e., it uses kernel
algorithms and by-passes polyhedral representations. The solid is
represented by a polymarker of dots. The default number of points
is 1000. This can be changed with
/vis/viewer/set/numberOfCloudPoints
(The minimum number is 100.)
Note that OpenGL has a fast algorithm for polymarker.
- This allows us to use cloud style both as a choice or as fallback when the
polyhedral representation fails, for example, when BooleanProcessor fails.
- Many files affected:
o G4ViewParameters.hh/icc/cc
enum DrawingStyle {
wireframe, // Draw edges - no hidden line removal.
hlr, // Draw edges - hidden lines removed.
hsr, // Draw surfaces - hidden surfaces removed.
hlhsr, // Draw surfaces and edges - hidden removed.
cloud // Draw volume as a cloud of dots.
};
and consequential augmentation of access function, test functions and
stream output functions.
o G4VisCommandsViewerSet.hh/cc
. Add /vis/viewer/set/numberOfCloudPoints.
. Augment /vis/viewer/set/style to handle "c[loud]".
. Note: G4VisCommandsViewerSet.cc: Indentations recomputed (Xcode has
a slightly different algorithm to emacs). Many hundreds of lines changed.
o G4VSceneHandler::RequestPrimitives: Augmented to handle cloud.
o G4VisCommandsCompound.cc: Augment message from /vis/drawLogicalVolume.
o G4VisCommandsViewerDefault: Augment /vis/viewer/default/style.
- Other developments:
o void G4VSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
Functionally unchanged but algorithmetically improved.
Note, as stated above, OpenGL does not use this default function -
it has its own version.
24 February 2019 John Allison
- Included in vis-V10-05-13
- Add /vis/touchable/extentForField and volumeForField.
19 February 2019 John Allison
- Included in vis-V10-05-12
- G4VVisCommand:
o Introduced fCurrrentPVFindingsForField.
o Added DrawExtent to utility functions.
- G4VisCommandsScene: Add /vis/scene/showExtents.
- G4VisCommandsSet: Add /vis/set/volumeForField.
- G4VisCommandsTouchable:
o Add /vis/touchable/showExtent.
o Add copy number parameter to /vis/touchable/findPath.
- G4Scene:
o Use G4BoundingExtentScene instead of G4BoundingSphereScene.
o Use G4VisExtent::GetTransformedExtent to correct for fix to bug in
G4PhysicalVolumeModel - see modeling/History.
- G4ViewParameters: Improve message.
- G4VisManager: Register the new commands.
13 February 2019 John Allison
- Included in vis-V10-05-11
- Implement /vis/set/extentForField - see visualisation/History.
10 February 2019 John Allison
- Included in vis-V10-05-10
- G4VisCommandsViewer:
o Improved /vis/viewer/centreOn (it does not zoom).
o Introduced /vis/viewer/centreAndZoomInOn.
- G4VisCommandsTouchable:
o Improved /vis/touchable/centreOn (it does not zoom).
o Introduced /vis/touchable/centreAndZoomInOn.
- G4VVisCommand:
o Introduced utility functions CopyGuidanceFrom and CopyParametersFrom.
- G4VisCommandsCompound:
o Made use of above-mentioned utility functions.
08 February 2019 John Allison
- Included in vis-V10-05-09
- Fix Coverity warnings.
31 January 2019 Michael Kelsey
- Included in vis-V10-05-08
- Provide ability to draw electric fields, and eventually any other field.
Refactor G4MagneticFieldModel to have an intermediate base class, which
implements DescribeYourselfTo(). Concrete class only implements a utility
function to get value from field. Add new G4ElectricFieldModel which does
the same thing. Add commands for the latter.
29 January 2019 John Allison
- Included in vis-V10-05-06
- G4VisCommandsTochable:
o Add /vis/touchable/draw.
- G4VisCommandsViewer: /vis/viewer/centreOn:
o Add copy number to parameter list.
- CheckSceneAndNotifyHandlers: move from xx to G4VVisCommand so that it
can be used by any messenger.
26 January 2019 John Allison
- Included in vis-V10-05-06
- Fix calculation of vis extent for parameterisations.
- Some minor tidying.
25 January 2019 John Allison
- Included in vis-V10-05-06
- Rationalise view interpolation
Encapsulate algorithm into base class G4VVisCommand. The commands
/vis/viewer/interpolate
/vis/viewer/centreOn
/vis/touchable/centerOn
now use this. Might consider use by all view changing commands.
25 January 2019 John Allison
- Included in vis-V10-05-05
- Include parameterised volumes in overlap checking and visualisation
in G4LogicalVolumeModel (in addition to ordinary placements).
22 January 2019 John Allison
- Included in vis-V10-05-04
- Introduce /vis/viewer/centreOn and /vis/touchable/centreOn
This allows one to centre the view (zoom in) on a volume.
Reset with /vis/viewer/reset.
- Moved
void SetViewParameters(G4VViewer* viewer, const G4ViewParameters& viewParams);
void RefreshIfRequired(G4VViewer* viewer);
from G4VisCommandsViewer to the higher level G4VVisCommand so that all
vis commands may make use. In so doing eliminated the intermediate class
G4VVisCommandViewer (which did not have a .hh file of its own and was anyhow
obscurely buried in G4VisComandsViewer). Much cleaner now.
21 January 2019 John Allison
- Included in vis-V10-05-03.
- Pick up default number of line-segments-per-circle from G4Polyhedron.
08 January 2019 John Allison
- Correct History files after merge
02 January 2019 John Allison
- Included in vis-V10-05-01.
- Minor improvements to vis manager.
- Added confirmation printing when registering models with the scene.
- At start of run:
// Check to see if the user has created a trajectory model. If not, create
// a default one. To avoid code duplication the following function is used
// and its result (a const G4VTrajectoryModel*) is thrown away at this point.
// The function is called again later when needed.
02 January 2019 John Allison
- Included in vis-V10-05-00.
- G4VisCommandsSceneAdd.cc: Improve guidance for /vis/scene/add/volume.
14 November 2018 John Allison (visman-V10-04-28)
- G4VisCommandsSceneAdd.cc: /vis/scene/add/userAction:
o Fix bug whereby success was branded unsuccessful when verbosity <= warnings.
@@ -56,6 +56,7 @@ class G4VPhysicalVolume;
class G4Material;
class G4Event;
class G4AttHolder;
class G4DisplacedSolid;
class G4VSceneHandler: public G4VGraphicsScene {
@@ -156,7 +157,7 @@ public: // With description
// }
virtual void BeginPrimitives
(const G4Transform3D& objectTransformation);
(const G4Transform3D& objectTransformation = G4Transform3D());
// IMPORTANT: invoke this from your polymorphic versions, e.g.:
// void MyXXXSceneHandler::BeginPrimitives
// (const G4Transform3D& objectTransformation) {
@@ -172,7 +173,7 @@ public: // With description
// }
virtual void BeginPrimitives2D
(const G4Transform3D& objectTransformation);
(const G4Transform3D& objectTransformation = G4Transform3D());
// The x,y coordinates of the primitives passed to AddPrimitive are
// intrepreted as screen coordinates, -1 < x,y < 1. The
// z-coordinate is ignored.
@@ -249,6 +250,11 @@ public: // With description
// has forced through the vis attributes, thereby over-riding the
// current view parameter.
G4int GetNumberOfCloudPoints (const G4VisAttributes*) const;
// Returns no of cloud points from current view parameters, unless the user
// has forced through the vis attributes, thereby over-riding the
// current view parameter.
G4bool GetAuxEdgeVisible (const G4VisAttributes*);
// Returns auxiliary edge visibility from current view parameters,
// unless the user has forced through the vis attributes, thereby
@@ -315,8 +321,8 @@ protected:
//////////////////////////////////////////////////////////////
// Other internal routines...
virtual G4VSolid* CreateSectionSolid ();
virtual G4VSolid* CreateCutawaySolid ();
virtual G4DisplacedSolid* CreateSectionSolid ();
virtual G4DisplacedSolid* CreateCutawaySolid ();
// Generic clipping using the BooleanProcessor in graphics_reps is
// implemented in this class. Subclasses that implement their own
// clipping should provide an override that returns zero.
@@ -38,28 +38,49 @@
#include "G4VisAttributes.hh"
#include "G4VMarker.hh"
#include "G4ModelingParameters.hh"
#include "G4PhysicalVolumesSearchScene.hh"
#include <vector>
class G4UIcommand;
class G4UIcmdWithAString;
class G4VVisCommand: public G4UImessenger {
class G4VVisCommand: public G4UImessenger
{
public:
// Uses compiler defaults for copy constructor and assignment.
G4VVisCommand ();
virtual ~G4VVisCommand ();
static void SetVisManager (G4VisManager*);
static const G4Colour& GetCurrentColour() {return fCurrentColour;}
//static G4VMarker::FillStyle GetCurrentFillStyle() {return fCurrentFillStyle;}
//static G4VMarker::SizeType GetCurrentSizeType() {return fCurrentSizeType;}
static G4double GetCurrentLineWidth() {return fCurrentLineWidth;}
//static G4VisAttributes::LineStyle GetCurrentLineStyle() {return fCurrentLineStyle;}
static const G4Colour& GetCurrentTextColour() {return fCurrentTextColour;}
static G4Text::Layout GetCurrentTextLayout() {return fCurrentTextLayout;}
static G4double GetCurrentTextSize() {return fCurrentTextSize;}
static void SetVisManager (G4VisManager* pVisManager)
{fpVisManager = pVisManager;}
static const G4Colour& GetCurrentTextColour()
{return fCurrentTextColour;}
protected:
// Utility functions
void SetViewParameters(G4VViewer* viewer, const G4ViewParameters& viewParams);
void RefreshIfRequired(G4VViewer* viewer);
void InterpolateViews
(G4VViewer* currentViewer,
std::vector<G4ViewParameters> viewVector,
const G4int nInterpolationPoints = 50,
const G4int waitTimePerPointmilliseconds = 20,
const G4String exportString = "");
void InterpolateToNewView
(G4VViewer* currentViewer,
const G4ViewParameters& oldVP,
const G4ViewParameters& newVP,
const G4int nInterpolationPoints = 50,
const G4int waitTimePerPointmilliseconds = 20,
const G4String exportString = "");
// Conversion routines augmenting those in G4UIcommand.
static G4String ConvertToString(G4double x, G4double y,
@@ -93,13 +114,24 @@ protected:
G4double& value);
// Return false if there's a problem
// Other utilities.
// Other utilities
void CheckSceneAndNotifyHandlers (G4Scene* = nullptr);
// Data members.
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity);
void CopyGuidanceFrom
(const G4UIcommand* fromCmd, G4UIcommand* toCmd, G4int startLine = 0);
void CopyParametersFrom
(const G4UIcommand* fromCmd, G4UIcommand* toCmd);
void DrawExtent(const G4VisExtent&);
// Data members
static G4VisManager* fpVisManager;
// Error management
static G4int fErrorCode;
// Current quantities for use in appropriate commands
@@ -113,8 +145,8 @@ protected:
static G4Text::Layout fCurrentTextLayout;
static G4double fCurrentTextSize;
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties;
static G4VisExtent fCurrentExtentForField;
static std::vector<G4PhysicalVolumesSearchScene::Findings> fCurrrentPVFindingsForField;
};
#include "G4VVisCommand.icc"
#endif
@@ -1,33 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Base class for visualization commands - John Allison 9th August 1998
// It is really a messenger - we have one command per messenger.
inline void G4VVisCommand::SetVisManager (G4VisManager* pVisManager) {
fpVisManager = pVisManager;
}
@@ -37,11 +37,11 @@
// In GEANT4 visualization, we have the concept of a "Standard
// View". This is the view when the complete set of objects being
// viewed is comfortably in view from any viewpoint. It is defined by
// the "Bounding Sphere" of "visible" objects when initially
// the "Bounding Extent" of "visible" objects when initially
// registered in the scene, and by the View Parameters.
//
// There is also the "Standard Target Point", which is the centre of
// the Bounding Sphere (note that this belongs to the scene and is
// the Bounding Extent (note that this belongs to the scene and is
// stored in the G4Scene object). The "Current Target Point", defined
// relative to the Standard Target Point, is changed by the
// "dolly" and "zoom" commands, and can be reset to the Standard
@@ -50,7 +50,7 @@
// Also, the "Standard Camera Position" is the "Standard Camera
// Distance" along the Viewpoint Direction vector from the Standard
// Target Point. The Standard Camera Distance is the radius of the
// Bounding Sphere divided by fFieldHalfAngle. It is not stored
// Bounding Extent divided by fFieldHalfAngle. It is not stored
// explicitly because of the singularity at fFieldHalfAngle = 0,
// which implies parallel projection.
//
@@ -62,7 +62,8 @@
// conceptually possible, but which might give some problems when
// setting up the view matrix - see, for example, G4OpenGLView::SetView ().
//
// All viewers are expected to keep the "Up Vector" vertical.
// All viewers are expected to keep the "Up Vector" vertical unless
// RotationStyle is freeRotation.
//
// Finally, the view is magnified by the "Zoom Factor" which is
// reset to 1 by the "/vis/viewer/reset" command.
@@ -94,7 +95,8 @@ public: // With description
wireframe, // Draw edges - no hidden line removal.
hlr, // Draw edges - hidden lines removed.
hsr, // Draw surfaces - hidden surfaces removed.
hlhsr // Draw surfaces and edges - hidden removed.
hlhsr, // Draw surfaces and edges - hidden removed.
cloud // Draw volume as a cloud of dots.
};
enum CutawayMode {
@@ -122,6 +124,7 @@ public: // With description
// Get and Is functions.
DrawingStyle GetDrawingStyle () const;
G4int GetNumberOfCloudPoints () const;
G4bool IsAuxEdgeVisible () const;
G4bool IsCulling () const;
G4bool IsCullingInvisible () const;
@@ -200,7 +203,7 @@ public: // With description
G4double GetDisplayLightFrontBlue () const;
// Here Follow functions to evaluate useful quantities as a
// function of the radius of the Bounding Sphere of the object being
// function of the radius of the Bounding Extent of the object being
// viewed. Call them in the order given - for efficiency, later
// functions depend on the results of earlier ones (Store the
// results of earlier functions in your own temporary variables -
@@ -213,6 +216,7 @@ public: // With description
// Set, Add, Multiply, Increment, Unset and Clear functions.
void SetDrawingStyle (G4ViewParameters::DrawingStyle style);
G4int SetNumberOfCloudPoints (G4int); // Returns number actually set.
void SetAuxEdgeVisible (G4bool);
void SetCulling (G4bool);
void SetCullingInvisible (G4bool);
@@ -230,7 +234,7 @@ public: // With description
void SetExplodeFactor (G4double explodeFactor);
void UnsetExplodeFactor ();
void SetExplodeCentre (const G4Point3D& explodeCentre);
G4int SetNoOfSides (G4int nSides); // Returns actual number set.
G4int SetNoOfSides (G4int nSides); // Returns number actually set.
void SetViewpointDirection (const G4Vector3D& viewpointDirection);
// Calls the following to get lightpoint direction right too.
void SetViewAndLights (const G4Vector3D& viewpointDirection);
@@ -321,6 +325,8 @@ private:
G4int ReadInteger(char *string, char **NextString);
DrawingStyle fDrawingStyle; // Drawing style.
G4int fNumberOfCloudPoints; // For drawing in cloud style.
// <= 0 means use viewer default.
G4bool fAuxEdgeVisible; // Auxiliary edge visibility.
G4bool fCulling; // Culling requested.
G4bool fCullInvisible; // Cull (don't Draw) invisible objects.
@@ -291,6 +291,10 @@ inline G4double G4ViewParameters::GetDisplayLightFrontBlue () const {
return fDisplayLightFrontBlue;
}
inline G4int G4ViewParameters::GetNumberOfCloudPoints () const {
return fNumberOfCloudPoints;
}
inline void
G4ViewParameters::SetDrawingStyle (G4ViewParameters::DrawingStyle style) {
fDrawingStyle = style;
@@ -74,13 +74,13 @@ class G4VisCommandGeometrySetForceAuxEdgeVisibleFunction:
public:
virtual ~G4VisCommandGeometrySetForceAuxEdgeVisibleFunction() {}
G4VisCommandGeometrySetForceAuxEdgeVisibleFunction
(G4bool forceAuxEdgeVisible):
fForceAuxEdgeVisible(forceAuxEdgeVisible) {}
(G4bool force):
fForce(force) {}
void operator()
(G4VisAttributes* visAtts) const
{visAtts->SetForceAuxEdgeVisible(fForceAuxEdgeVisible);}
{visAtts->SetForceAuxEdgeVisible(fForce);}
private:
G4bool fForceAuxEdgeVisible;
G4bool fForce;
};
class G4VisCommandGeometrySetForceLineSegmentsPerCircleFunction:
@@ -102,13 +102,13 @@ class G4VisCommandGeometrySetForceSolidFunction:
public:
virtual ~G4VisCommandGeometrySetForceSolidFunction() {}
G4VisCommandGeometrySetForceSolidFunction
(G4bool forceSolid):
fForceSolid(forceSolid) {}
(G4bool force):
fForce(force) {}
void operator()
(G4VisAttributes* visAtts) const
{visAtts->SetForceSolid(fForceSolid);}
{visAtts->SetForceSolid(fForce);}
private:
G4bool fForceSolid;
G4bool fForce;
};
class G4VisCommandGeometrySetForceWireframeFunction:
@@ -116,13 +116,13 @@ class G4VisCommandGeometrySetForceWireframeFunction:
public:
virtual ~G4VisCommandGeometrySetForceWireframeFunction() {}
G4VisCommandGeometrySetForceWireframeFunction
(G4bool forceWireframe):
fForceWireframe(forceWireframe) {}
(G4bool force):
fForce(force) {}
void operator()
(G4VisAttributes* visAtts) const
{visAtts->SetForceWireframe(fForceWireframe);}
{visAtts->SetForceWireframe(fForce);}
private:
G4bool fForceWireframe;
G4bool fForce;
};
class G4VisCommandGeometrySetLineStyleFunction:
@@ -137,4 +137,16 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandSceneShowExtents: public G4VVisCommandScene {
public:
G4VisCommandSceneShowExtents ();
virtual ~G4VisCommandSceneShowExtents ();
G4String GetCurrentValue (G4UIcommand* command);
void SetNewValue (G4UIcommand* command, G4String newValue);
private:
G4VisCommandSceneShowExtents (const G4VisCommandSceneShowExtents&);
G4VisCommandSceneShowExtents& operator = (const G4VisCommandSceneShowExtents&);
G4UIcmdWithoutParameter* fpCommand;
};
#endif
@@ -26,6 +26,7 @@
//
// /vis/scene commands - John Allison 9th August 1998
// Michael Kelsey 31 Jan 2019 -- Add new command for electric field
#ifndef G4VISCOMMANDSSCENEADD_HH
#define G4VISCOMMANDSSCENEADD_HH
@@ -169,6 +170,18 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandSceneAddElectricField: public G4VVisCommandScene {
public:
G4VisCommandSceneAddElectricField ();
virtual ~G4VisCommandSceneAddElectricField ();
G4String GetCurrentValue (G4UIcommand* command);
void SetNewValue (G4UIcommand* command, G4String newValue);
private:
G4VisCommandSceneAddElectricField (const G4VisCommandSceneAddElectricField&);
G4VisCommandSceneAddElectricField& operator = (const G4VisCommandSceneAddElectricField&);
G4UIcommand* fpCommand;
};
class G4VisCommandSceneAddFrame: public G4VVisCommandScene {
public:
G4VisCommandSceneAddFrame ();
@@ -62,6 +62,18 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandSetExtentForField: public G4VVisCommand {
public:
G4VisCommandSetExtentForField ();
virtual ~G4VisCommandSetExtentForField ();
G4String GetCurrentValue (G4UIcommand* command);
void SetNewValue (G4UIcommand* command, G4String newValue);
private:
G4VisCommandSetExtentForField (const G4VisCommandSetExtentForField&);
G4VisCommandSetExtentForField& operator = (const G4VisCommandSetExtentForField&);
G4UIcommand* fpCommand;
};
class G4VisCommandSetLineWidth: public G4VVisCommand {
public:
G4VisCommandSetLineWidth ();
@@ -122,4 +134,16 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandSetVolumeForField: public G4VVisCommand {
public:
G4VisCommandSetVolumeForField ();
virtual ~G4VisCommandSetVolumeForField ();
G4String GetCurrentValue (G4UIcommand* command);
void SetNewValue (G4UIcommand* command, G4String newValue);
private:
G4VisCommandSetVolumeForField (const G4VisCommandSetVolumeForField&);
G4VisCommandSetVolumeForField& operator = (const G4VisCommandSetVolumeForField&);
G4UIcommand* fpCommand;
};
#endif
@@ -34,6 +34,7 @@
class G4UIcmdWithAString;
class G4UIcmdWithoutParameter;
class G4UIcmdWithABool;
class G4VisCommandsTouchable: public G4VVisCommand {
public:
@@ -44,8 +45,14 @@ public:
private:
G4VisCommandsTouchable (const G4VisCommandsTouchable&);
G4VisCommandsTouchable& operator = (const G4VisCommandsTouchable&);
G4UIcmdWithoutParameter* fpCommandCentreOn;
G4UIcmdWithoutParameter* fpCommandCentreAndZoomInOn;
G4UIcmdWithoutParameter* fpCommandDraw;
G4UIcmdWithoutParameter* fpCommandDump;
G4UIcmdWithAString* fpCommandFindPath;
G4UIcmdWithABool* fpCommandExtentForField;
G4UIcommand* fpCommandFindPath;
G4UIcmdWithABool* fpCommandShowExtent;
G4UIcmdWithABool* fpCommandVolumeForField;
};
#endif
@@ -38,7 +38,7 @@ class G4UIcmdWithADouble;
class G4UIcmdWithAnInteger;
class G4UIcmdWithAString;
class G4VisCommandsTouchableSet: public G4VVisCommandViewer {
class G4VisCommandsTouchableSet: public G4VVisCommand {
public:
G4VisCommandsTouchableSet ();
virtual ~G4VisCommandsTouchableSet ();
@@ -51,10 +51,12 @@ private:
G4UIcmdWithABool* fpCommandSetDaughtersInvisible;
G4UIcmdWithABool* fpCommandSetForceAuxEdgeVisible;
G4UIcmdWithAnInteger* fpCommandSetLineSegmentsPerCircle;
G4UIcmdWithABool* fpCommandSetForceCloud;
G4UIcmdWithABool* fpCommandSetForceSolid;
G4UIcmdWithABool* fpCommandSetForceWireframe;
G4UIcmdWithAString* fpCommandSetLineStyle;
G4UIcmdWithADouble* fpCommandSetLineWidth;
G4UIcmdWithAnInteger* fpCommandSetNumberOfCloudPoints;
G4UIcmdWithABool* fpCommandSetVisibility;
};
@@ -41,19 +41,7 @@ class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWith3Vector;
class G4VVisCommandViewer: public G4VVisCommand {
public:
G4VVisCommandViewer ();
virtual ~G4VVisCommandViewer ();
protected:
void SetViewParameters(G4VViewer*, const G4ViewParameters&);
void RefreshIfRequired(G4VViewer*);
private:
G4VVisCommandViewer (const G4VVisCommandViewer&);
G4VVisCommandViewer& operator = (const G4VVisCommandViewer&);
};
class G4VisCommandViewerAddCutawayPlane: public G4VVisCommandViewer {
class G4VisCommandViewerAddCutawayPlane: public G4VVisCommand {
public:
G4VisCommandViewerAddCutawayPlane ();
virtual ~G4VisCommandViewerAddCutawayPlane ();
@@ -65,7 +53,20 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerChangeCutawayPlane: public G4VVisCommandViewer {
class G4VisCommandViewerCentreOn: public G4VVisCommand {
public:
G4VisCommandViewerCentreOn ();
virtual ~G4VisCommandViewerCentreOn ();
G4String GetCurrentValue (G4UIcommand* command);
void SetNewValue (G4UIcommand* command, G4String newValue);
private:
G4VisCommandViewerCentreOn (const G4VisCommandViewerCentreOn&);
G4VisCommandViewerCentreOn& operator = (const G4VisCommandViewerCentreOn&);
G4UIcommand* fpCommandCentreOn;
G4UIcommand* fpCommandCentreAndZoomInOn;
};
class G4VisCommandViewerChangeCutawayPlane: public G4VVisCommand {
public:
G4VisCommandViewerChangeCutawayPlane ();
virtual ~G4VisCommandViewerChangeCutawayPlane ();
@@ -77,7 +78,7 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerClear: public G4VVisCommandViewer {
class G4VisCommandViewerClear: public G4VVisCommand {
public:
G4VisCommandViewerClear ();
virtual ~G4VisCommandViewerClear ();
@@ -89,7 +90,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerClearCutawayPlanes: public G4VVisCommandViewer {
class G4VisCommandViewerClearCutawayPlanes: public G4VVisCommand {
public:
G4VisCommandViewerClearCutawayPlanes ();
virtual ~G4VisCommandViewerClearCutawayPlanes ();
@@ -101,7 +102,7 @@ private:
G4UIcmdWithoutParameter* fpCommand;
};
class G4VisCommandViewerClearTransients: public G4VVisCommandViewer {
class G4VisCommandViewerClearTransients: public G4VVisCommand {
public:
G4VisCommandViewerClearTransients ();
virtual ~G4VisCommandViewerClearTransients ();
@@ -114,7 +115,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerClearVisAttributesModifiers: public G4VVisCommandViewer {
class G4VisCommandViewerClearVisAttributesModifiers: public G4VVisCommand {
public:
G4VisCommandViewerClearVisAttributesModifiers ();
virtual ~G4VisCommandViewerClearVisAttributesModifiers ();
@@ -126,7 +127,7 @@ private:
G4UIcmdWithoutParameter* fpCommand;
};
class G4VisCommandViewerClone: public G4VVisCommandViewer {
class G4VisCommandViewerClone: public G4VVisCommand {
public:
G4VisCommandViewerClone ();
virtual ~G4VisCommandViewerClone ();
@@ -139,7 +140,7 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerColourByDensity: public G4VVisCommandViewer {
class G4VisCommandViewerColourByDensity: public G4VVisCommand {
public:
G4VisCommandViewerColourByDensity ();
virtual ~G4VisCommandViewerColourByDensity ();
@@ -151,7 +152,7 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerCopyViewFrom: public G4VVisCommandViewer {
class G4VisCommandViewerCopyViewFrom: public G4VVisCommand {
public:
G4VisCommandViewerCopyViewFrom ();
virtual ~G4VisCommandViewerCopyViewFrom ();
@@ -164,7 +165,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerCreate: public G4VVisCommandViewer {
class G4VisCommandViewerCreate: public G4VVisCommand {
public:
G4VisCommandViewerCreate ();
virtual ~G4VisCommandViewerCreate ();
@@ -178,7 +179,7 @@ private:
G4int fId;
};
class G4VisCommandViewerDolly: public G4VVisCommandViewer {
class G4VisCommandViewerDolly: public G4VVisCommand {
public:
G4VisCommandViewerDolly ();
virtual ~G4VisCommandViewerDolly ();
@@ -193,7 +194,7 @@ private:
G4double fDollyTo;
};
class G4VisCommandViewerFlush: public G4VVisCommandViewer {
class G4VisCommandViewerFlush: public G4VVisCommand {
public:
G4VisCommandViewerFlush ();
virtual ~G4VisCommandViewerFlush ();
@@ -205,7 +206,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerInterpolate: public G4VVisCommandViewer {
class G4VisCommandViewerInterpolate: public G4VVisCommand {
public:
G4VisCommandViewerInterpolate ();
virtual ~G4VisCommandViewerInterpolate ();
@@ -217,7 +218,7 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerList: public G4VVisCommandViewer {
class G4VisCommandViewerList: public G4VVisCommand {
public:
G4VisCommandViewerList ();
virtual ~G4VisCommandViewerList ();
@@ -229,7 +230,7 @@ private:
G4UIcommand* fpCommand;
};
class G4VisCommandViewerPan: public G4VVisCommandViewer {
class G4VisCommandViewerPan: public G4VVisCommand {
public:
G4VisCommandViewerPan ();
virtual ~G4VisCommandViewerPan ();
@@ -244,7 +245,7 @@ private:
G4double fPanToRight, fPanToUp;
};
class G4VisCommandViewerReset: public G4VVisCommandViewer {
class G4VisCommandViewerReset: public G4VVisCommand {
public:
G4VisCommandViewerReset ();
virtual ~G4VisCommandViewerReset ();
@@ -256,7 +257,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerRefresh: public G4VVisCommandViewer {
class G4VisCommandViewerRefresh: public G4VVisCommand {
public:
G4VisCommandViewerRefresh ();
virtual ~G4VisCommandViewerRefresh ();
@@ -268,7 +269,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerRebuild: public G4VVisCommandViewer {
class G4VisCommandViewerRebuild: public G4VVisCommand {
public:
G4VisCommandViewerRebuild ();
virtual ~G4VisCommandViewerRebuild ();
@@ -280,7 +281,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerSave: public G4VVisCommandViewer {
class G4VisCommandViewerSave: public G4VVisCommand {
public:
G4VisCommandViewerSave ();
virtual ~G4VisCommandViewerSave ();
@@ -292,7 +293,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerScale: public G4VVisCommandViewer {
class G4VisCommandViewerScale: public G4VVisCommand {
public:
G4VisCommandViewerScale ();
virtual ~G4VisCommandViewerScale ();
@@ -307,7 +308,7 @@ private:
G4Vector3D fScaleTo;
};
class G4VisCommandViewerSelect: public G4VVisCommandViewer {
class G4VisCommandViewerSelect: public G4VVisCommand {
public:
G4VisCommandViewerSelect ();
virtual ~G4VisCommandViewerSelect ();
@@ -319,7 +320,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerUpdate: public G4VVisCommandViewer {
class G4VisCommandViewerUpdate: public G4VVisCommand {
public:
G4VisCommandViewerUpdate ();
virtual ~G4VisCommandViewerUpdate ();
@@ -331,7 +332,7 @@ private:
G4UIcmdWithAString* fpCommand;
};
class G4VisCommandViewerZoom: public G4VVisCommandViewer {
class G4VisCommandViewerZoom: public G4VVisCommand {
public:
G4VisCommandViewerZoom ();
virtual ~G4VisCommandViewerZoom ();
@@ -42,7 +42,7 @@ class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWith3VectorAndUnit;
class G4VisCommandsViewerSet: public G4VVisCommandViewer {
class G4VisCommandsViewerSet: public G4VVisCommand {
public:
G4VisCommandsViewerSet ();
virtual ~G4VisCommandsViewerSet ();
@@ -65,11 +65,12 @@ private:
G4UIcmdWithADouble* fpCommandGlobalLineWidthScale;
G4UIcmdWithABool* fpCommandHiddenEdge;
G4UIcmdWithABool* fpCommandHiddenMarker;
G4UIcmdWithAnInteger* fpCommandLineSegments;
G4UIcmdWithAString* fpCommandLightsMove;
G4UIcommand* fpCommandLightsThetaPhi;
G4UIcommand* fpCommandLightsVector;
G4ThreeVector fLightsVector;
G4UIcmdWithAnInteger* fpCommandLineSegments;
G4UIcmdWithAnInteger* fpCommandNumberOfCloudPoints;
G4UIcmdWithABool* fpCommandPicking;
G4UIcommand* fpCommandProjection;
G4UIcmdWithAString* fpCommandRotationStyle;
@@ -63,7 +63,6 @@ GEANT4_DEFINE_MODULE(NAME G4vis_management
G4VViewer.hh
G4VViewer.icc
G4VVisCommand.hh
G4VVisCommand.icc
G4ViewParameters.hh
G4ViewParameters.icc
G4ViewerList.hh
+34 -43
View File
@@ -31,7 +31,7 @@
#include "G4Scene.hh"
#include "G4Vector3D.hh"
#include "G4BoundingSphereScene.hh"
#include "G4BoundingExtentScene.hh"
#include "G4VisAttributes.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4TransportationManager.hh"
@@ -94,28 +94,30 @@ G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn)
return true;
}
namespace {
void PrintInvalidModel(const G4VModel* model)
{
G4ExceptionDescription ed;
ed << "Invalid model \"" << model->GetGlobalDescription()
<< "\".\n Not included in extent calculation.";
G4Exception
("G4Scene::CalculateExtent",
"visman0201", JustWarning, ed);
}
}
void G4Scene::CalculateExtent ()
{
G4BoundingSphereScene boundingSphereScene;
G4BoundingExtentScene boundingExtentScene;
for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
if (fRunDurationModelList[i].fActive) {
G4VModel* model = fRunDurationModelList[i].fpModel;
if (model -> Validate()) { // Validates and also recomputes extent.
const G4VisExtent& thisExtent = model -> GetExtent ();
G4double thisRadius = thisExtent.GetExtentRadius ();
if (thisRadius > 0.) {
G4Point3D thisCentre = thisExtent.GetExtentCentre ();
thisCentre.transform (model -> GetTransformation ());
boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
}
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
boundingExtentScene.AccrueBoundingExtent(thisExtent);
} else {
G4ExceptionDescription ed;
ed << "Invalid model \"" << model->GetGlobalDescription()
<< "\".\n Not included in extent calculation.";
G4Exception
("G4Scene::CalculateExtent",
"visman0201", JustWarning, ed);
PrintInvalidModel(model);
}
}
}
@@ -124,20 +126,10 @@ void G4Scene::CalculateExtent ()
if (fEndOfEventModelList[i].fActive) {
G4VModel* model = fEndOfEventModelList[i].fpModel;
if (model -> Validate()) { // Validates and also recomputes extent.
const G4VisExtent& thisExtent = model -> GetExtent ();
G4double thisRadius = thisExtent.GetExtentRadius ();
if (thisRadius > 0.) {
G4Point3D thisCentre = thisExtent.GetExtentCentre ();
thisCentre.transform (model -> GetTransformation ());
boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
}
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
boundingExtentScene.AccrueBoundingExtent(thisExtent);
} else {
G4ExceptionDescription ed;
ed << "Invalid model \"" << model->GetGlobalDescription()
<< "\".\n Not included in extent calculation.";
G4Exception
("G4Scene::CalculateExtent",
"visman0201", JustWarning, ed);
PrintInvalidModel(model);
}
}
}
@@ -146,25 +138,15 @@ void G4Scene::CalculateExtent ()
if (fEndOfRunModelList[i].fActive) {
G4VModel* model = fEndOfRunModelList[i].fpModel;
if (model -> Validate()) { // Validates and also recomputes extent.
const G4VisExtent& thisExtent = model -> GetExtent ();
G4double thisRadius = thisExtent.GetExtentRadius ();
if (thisRadius > 0.) {
G4Point3D thisCentre = thisExtent.GetExtentCentre ();
thisCentre.transform (model -> GetTransformation ());
boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
}
const G4VisExtent& thisExtent = model -> GetTransformedExtent ();
boundingExtentScene.AccrueBoundingExtent(thisExtent);
} else {
G4ExceptionDescription ed;
ed << "Invalid model \"" << model->GetGlobalDescription()
<< "\".\n Not included in extent calculation.";
G4Exception
("G4Scene::CalculateExtent",
"visman0201", JustWarning, ed);
PrintInvalidModel(model);
}
}
}
fExtent = boundingSphereScene.GetBoundingSphereExtent ();
fExtent = boundingExtentScene.GetBoundingExtent ();
fStandardTargetPoint = fExtent.GetExtentCentre ();
if (fExtent.GetExtentRadius() <= 0.) {
G4Exception
@@ -261,6 +243,9 @@ std::ostream& operator << (std::ostream& os, const G4Scene& scene) {
os << "Scene data:";
os << "\n Run-duration model list:";
if (scene.fRunDurationModelList.size () == 0) {
os << " none";
}
for (i = 0; i < scene.fRunDurationModelList.size (); i++) {
if (scene.fRunDurationModelList[i].fActive) os << "\n Active: ";
else os << "\n Inactive: ";
@@ -268,6 +253,9 @@ std::ostream& operator << (std::ostream& os, const G4Scene& scene) {
}
os << "\n End-of-event model list:";
if (scene.fEndOfEventModelList.size () == 0) {
os << " none";
}
for (i = 0; i < scene.fEndOfEventModelList.size (); i++) {
if (scene.fEndOfEventModelList[i].fActive) os << "\n Active: ";
else os << "\n Inactive: ";
@@ -275,13 +263,16 @@ std::ostream& operator << (std::ostream& os, const G4Scene& scene) {
}
os << "\n End-of-run model list:";
if (scene.fEndOfRunModelList.size () == 0) {
os << " none";
}
for (i = 0; i < scene.fEndOfRunModelList.size (); i++) {
if (scene.fEndOfRunModelList[i].fActive) os << "\n Active: ";
else os << "\n Inactive: ";
os << *(scene.fEndOfRunModelList[i].fpModel);
}
os << "\n Extent or bounding box: " << scene.fExtent;
os << "\n Overall extent or bounding box: " << scene.fExtent;
os << "\n Standard target point: " << scene.fStandardTargetPoint;
@@ -90,6 +90,8 @@
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include <set>
G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4String& name):
fSystem (system),
fSceneHandlerId (id),
@@ -526,36 +528,36 @@ void G4VSceneHandler::AddPrimitive (const G4Scale& scale) {
void G4VSceneHandler::AddPrimitive (const G4Polymarker& polymarker) {
switch (polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:
default:
case G4Polymarker::dots:
{
G4Circle dot (polymarker);
dot.SetWorldSize (0.);
dot.SetScreenSize (0.1); // Very small circle.
for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
G4Circle dot (polymarker);
dot.SetPosition (polymarker[iPoint]);
dot.SetWorldSize (0.);
dot.SetScreenSize (0.1); // Very small circle.
AddPrimitive (dot);
AddPrimitive (dot);
}
}
break;
case G4Polymarker::circles:
break;
case G4Polymarker::circles:
{
G4Circle circle (polymarker); // Default circle
for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
G4Circle circle (polymarker);
circle.SetPosition (polymarker[iPoint]);
AddPrimitive (circle);
circle.SetPosition (polymarker[iPoint]);
AddPrimitive (circle);
}
}
break;
case G4Polymarker::squares:
break;
case G4Polymarker::squares:
{
G4Square square (polymarker); // Default square
for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
G4Square square (polymarker);
square.SetPosition (polymarker[iPoint]);
AddPrimitive (square);
square.SetPosition (polymarker[iPoint]);
AddPrimitive (square);
}
}
break;
break;
}
}
@@ -572,38 +574,79 @@ void G4VSceneHandler::SetScene (G4Scene* pScene) {
}
}
void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid) {
G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (fpVisAttribs));
G4Polyhedron* pPolyhedron = solid.GetPolyhedron ();
G4Polyhedron::ResetNumberOfRotationSteps ();
if (pPolyhedron) {
pPolyhedron -> SetVisAttributes (fpVisAttribs);
BeginPrimitives (fObjectTransformation);
AddPrimitive (*pPolyhedron);
EndPrimitives ();
}
else {
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: G4VSceneHandler::RequestPrimitives"
"\n Polyhedron not available for " << solid.GetName () <<
"\n Touchable path: ";
G4PhysicalVolumeModel* pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
if (pPVModel) {
G4cerr << pPVModel->GetFullPVPath();
void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
{
const G4ViewParameters::DrawingStyle style = GetDrawingStyle(fpVisAttribs);
const G4ViewParameters& vp = fpViewer->GetViewParameters();
switch (style) {
default:
case G4ViewParameters::wireframe:
case G4ViewParameters::hlr:
case G4ViewParameters::hsr:
case G4ViewParameters::hlhsr:
{
// Use polyhedral representation
G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (fpVisAttribs));
G4Polyhedron* pPolyhedron = solid.GetPolyhedron ();
G4Polyhedron::ResetNumberOfRotationSteps ();
if (pPolyhedron) {
pPolyhedron -> SetVisAttributes (fpVisAttribs);
BeginPrimitives (fObjectTransformation);
AddPrimitive (*pPolyhedron);
EndPrimitives ();
break;
} else { // Print warnings and drop through to cloud
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
static std::set<const G4VSolid*> problematicSolids;
if (verbosity >= G4VisManager::errors &&
problematicSolids.find(&solid) == problematicSolids.end()) {
problematicSolids.insert(&solid);
G4cerr <<
"ERROR: G4VSceneHandler::RequestPrimitives"
"\n Polyhedron not available for " << solid.GetName ();
G4PhysicalVolumeModel* pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
if (pPVModel) {
G4cerr << "\n Touchable path: " << pPVModel->GetFullPVPath();
}
static G4bool explanation = false;
if (!explanation) {
explanation = true;
G4cerr <<
"\n This means it cannot be visualized in the usual way on most systems."
"\n 1) The solid may not have implemented the CreatePolyhedron method."
"\n 2) For Boolean solids, the BooleanProcessor, which attempts to create"
"\n the resultant polyhedron, may have failed."
"\n Try RayTracer. It uses Geant4's tracking algorithms instead.";
}
G4cerr << "\n Drawing solid with cloud of points.";
G4cerr << G4endl;
}
}
static G4bool explanation = false;
if (!explanation) {
explanation = true;
G4cerr <<
"\n This means it cannot be visualized on most systems (try RayTracer)."
"\n 1) The solid may not have implemented the CreatePolyhedron method."
"\n 2) For Boolean solids, the BooleanProcessor, which attempts to create"
"\n the resultant polyhedron, may have failed.";
} // fallthrough
case G4ViewParameters::cloud:
{
// Form solid out of cloud of dots
G4Polymarker dots;
// Note: OpenGL has a fast implementation of polymarker so it's better
// to build a polymarker rather than add a succession of circles.
// And anyway, in Qt, in the latter case each circle would be a scene-tree
// entry, something we would want to avoid.
dots.SetVisAttributes(fpVisAttribs);
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
G4int numberOfCloudPoints = GetNumberOfCloudPoints(fpVisAttribs);
if (numberOfCloudPoints <= 0) numberOfCloudPoints = vp.GetNumberOfCloudPoints();
for (G4int i = 0; i < numberOfCloudPoints; ++i) {
G4ThreeVector p = solid.GetPointOnSurface();
dots.push_back(p);
}
G4cerr << G4endl;
BeginPrimitives (fObjectTransformation);
AddPrimitive(dots);
EndPrimitives ();
}
break;
}
}
@@ -790,21 +833,24 @@ G4ModelingParameters* G4VSceneHandler::CreateModelingParameters ()
// Convert drawing styles...
G4ModelingParameters::DrawingStyle modelDrawingStyle =
G4ModelingParameters::wf;
G4ModelingParameters::wf;
switch (vp.GetDrawingStyle ()) {
default:
case G4ViewParameters::wireframe:
modelDrawingStyle = G4ModelingParameters::wf;
break;
case G4ViewParameters::hlr:
modelDrawingStyle = G4ModelingParameters::hlr;
break;
case G4ViewParameters::hsr:
modelDrawingStyle = G4ModelingParameters::hsr;
break;
case G4ViewParameters::hlhsr:
modelDrawingStyle = G4ModelingParameters::hlhsr;
break;
default:
case G4ViewParameters::wireframe:
modelDrawingStyle = G4ModelingParameters::wf;
break;
case G4ViewParameters::hlr:
modelDrawingStyle = G4ModelingParameters::hlr;
break;
case G4ViewParameters::hsr:
modelDrawingStyle = G4ModelingParameters::hsr;
break;
case G4ViewParameters::hlhsr:
modelDrawingStyle = G4ModelingParameters::hlhsr;
break;
case G4ViewParameters::cloud:
modelDrawingStyle = G4ModelingParameters::cloud;
break;
}
// Decide if covered daughters are really to be culled...
@@ -825,6 +871,7 @@ G4ModelingParameters* G4VSceneHandler::CreateModelingParameters ()
vp.GetNoOfSides ()
);
pModelingParams->SetNumberOfCloudPoints(vp.GetNumberOfCloudPoints());
pModelingParams->SetWarning
(G4VisManager::GetVerbosity() >= G4VisManager::warnings);
@@ -843,34 +890,44 @@ G4ModelingParameters* G4VSceneHandler::CreateModelingParameters ()
return pModelingParams;
}
G4VSolid* G4VSceneHandler::CreateSectionSolid()
G4DisplacedSolid* G4VSceneHandler::CreateSectionSolid()
{
G4VSolid* sectioner = 0;
G4DisplacedSolid* sectioner = 0;
const G4ViewParameters& vp = fpViewer->GetViewParameters();
if (vp.IsSection () ) {
G4double radius = fpScene->GetExtent().GetExtentRadius();
G4double safe = radius + fpScene->GetExtent().GetExtentCentre().mag();
G4VSolid* sectionBox =
new G4Box("_sectioner", safe, safe, 1.e-5 * radius); // Thin in z-plane.
new G4Box("_sectioner", safe, safe, 1.e-5 * radius); // Thin in z-plane...
const G4Normal3D originalNormal(0,0,1); // ...so this is original normal.
const G4Plane3D& sp = vp.GetSectionPlane ();
G4double a = sp.a();
G4double b = sp.b();
G4double c = sp.c();
G4double d = sp.d();
G4Transform3D transform = G4TranslateZ3D(-d);
const G4Normal3D normal(a,b,c);
if (normal != G4Normal3D(0,0,1)) {
const G4double angle = std::acos(normal.dot(G4Normal3D(0,0,1)));
const G4Vector3D axis = G4Normal3D(0,0,1).cross(normal);
transform = G4Rotate3D(angle, axis) * transform;
const G4double& a = sp.a();
const G4double& b = sp.b();
const G4double& c = sp.c();
const G4double& d = sp.d();
const G4Normal3D newNormal(a,b,c);
G4Transform3D requiredTransform;
// Rotate
if (newNormal != originalNormal) {
const G4double& angle = std::acos(newNormal.dot(originalNormal));
const G4Vector3D& axis = originalNormal.cross(newNormal);
requiredTransform = G4Rotate3D(angle, axis);
}
// Translate
requiredTransform = requiredTransform * G4TranslateZ3D(-d);
sectioner = new G4DisplacedSolid
("_displaced_sectioning_box", sectionBox, transform);
("_displaced_sectioning_box", sectionBox, requiredTransform);
}
return sectioner;
}
G4VSolid* G4VSceneHandler::CreateCutawaySolid()
G4DisplacedSolid* G4VSceneHandler::CreateCutawaySolid()
{
// To be reviewed.
return 0;
@@ -882,7 +939,7 @@ G4VSolid* G4VSceneHandler::CreateCutawaySolid()
main geometry tree (material world) is added. If "worlds", the
top of all worlds - material world and parallel worlds, if any - are
added. Otherwise a search of all worlds is made, taking the first
matching occurence only. To see a representation of the geometry
matching occurrence only. To see a representation of the geometry
hierarchy of the worlds, try "/vis/drawTree [worlds]" or one of the
driver/browser combinations that have the required functionality, e.g., HepRep.
If clip-volume-type is specified, the subsequent parameters are used to
@@ -983,41 +1040,58 @@ G4ViewParameters::DrawingStyle G4VSceneHandler::GetDrawingStyle
// Drawing style is normally determined by the view parameters, but
// it can be overriddden by the ForceDrawingStyle flag in the vis
// attributes.
G4ViewParameters::DrawingStyle style =
fpViewer->GetViewParameters().GetDrawingStyle();
const G4ViewParameters& vp = fpViewer->GetViewParameters();
G4ViewParameters::DrawingStyle style = vp.GetDrawingStyle();
if (pVisAttribs -> IsForceDrawingStyle ()) {
G4VisAttributes::ForcedDrawingStyle forcedStyle =
pVisAttribs -> GetForcedDrawingStyle ();
pVisAttribs -> GetForcedDrawingStyle ();
// This is complicated because if hidden line and surface removal
// has been requested we wish to preserve this sometimes.
switch (forcedStyle) {
case (G4VisAttributes::solid):
switch (style) {
case (G4ViewParameters::hlr):
style = G4ViewParameters::hlhsr;
break;
case (G4ViewParameters::wireframe):
style = G4ViewParameters::hsr;
break;
case (G4ViewParameters::hlhsr):
case (G4ViewParameters::hsr):
case (G4VisAttributes::solid):
switch (style) {
case (G4ViewParameters::hlr):
style = G4ViewParameters::hlhsr;
break;
case (G4ViewParameters::wireframe):
style = G4ViewParameters::hsr;
break;
case (G4ViewParameters::cloud):
style = G4ViewParameters::hsr;
break;
case (G4ViewParameters::hlhsr):
case (G4ViewParameters::hsr):
break;
}
break;
case (G4VisAttributes::cloud):
style = G4ViewParameters::cloud;
break;
case (G4VisAttributes::wireframe):
default:
break;
}
break;
case (G4VisAttributes::wireframe):
default:
// But if forced style is wireframe, do it, because one of its
// main uses is in displaying the consituent solids of a Boolean
// solid and their surfaces overlap with the resulting Booean
// solid, making a mess if hlr is specified.
style = G4ViewParameters::wireframe;
break;
// But if forced style is wireframe, do it, because one of its
// main uses is in displaying the consituent solids of a Boolean
// solid and their surfaces overlap with the resulting Booean
// solid, making a mess if hlr is specified.
style = G4ViewParameters::wireframe;
break;
}
}
return style;
}
G4int G4VSceneHandler::GetNumberOfCloudPoints
(const G4VisAttributes* pVisAttribs) const {
// Returns no of cloud points from current view parameters, unless the user
// has forced through the vis attributes, thereby over-riding the
// current view parameter.
G4int numberOfCloudPoints = fpViewer->GetViewParameters().GetNumberOfCloudPoints();
if (pVisAttribs -> GetForcedNumberOfCloudPoints() > 0) {
numberOfCloudPoints = pVisAttribs -> GetForcedNumberOfCloudPoints();
}
return numberOfCloudPoints;
}
G4bool G4VSceneHandler::GetAuxEdgeVisible (const G4VisAttributes* pVisAttribs) {
G4bool isAuxEdgeVisible = fpViewer->GetViewParameters().IsAuxEdgeVisible ();
if (pVisAttribs -> IsForceAuxEdgeVisible()) {
@@ -47,7 +47,9 @@ G4double G4VVisCommand::fCurrentLineWidth = 1.; // pixels
// Not yet used: G4VisAttributes::LineStyle G4VVisCommand::fCurrentLineStyle = G4VisAttributes::unbroken;
// Not yet used: G4VMarker::FillStyle G4VVisCommand::fCurrentFillStyle = G4VMarker::filled;
// Not yet used: G4VMarker::SizeType G4VVisCommand::fCurrentSizeType = G4VMarker::screen;
G4PhysicalVolumeModel::TouchableProperties G4VVisCommand::fCurrentTouchableProperties;
G4PhysicalVolumeModel::TouchableProperties G4VVisCommand::fCurrentTouchableProperties;
G4VisExtent G4VVisCommand::fCurrentExtentForField;
std::vector<G4PhysicalVolumesSearchScene::Findings> G4VVisCommand::fCurrrentPVFindingsForField;
G4VVisCommand::G4VVisCommand () {}
@@ -216,3 +218,126 @@ void G4VVisCommand::CheckSceneAndNotifyHandlers(G4Scene* pScene)
}
}
void G4VVisCommand::G4VisCommandsSceneAddUnsuccessful
(G4VisManager::Verbosity verbosity) {
// Some frequently used error printing...
if (verbosity >= G4VisManager::warnings) {
G4cout <<
"WARNING: For some reason, possibly mentioned above, it has not been"
"\n possible to add to the scene."
<< G4endl;
}
}
void G4VVisCommand::SetViewParameters
(G4VViewer* viewer, const G4ViewParameters& viewParams) {
viewer->SetViewParameters(viewParams);
RefreshIfRequired(viewer);
}
void G4VVisCommand::RefreshIfRequired(G4VViewer* viewer) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
const G4ViewParameters& viewParams = viewer->GetViewParameters();
if (sceneHandler && sceneHandler->GetScene()) {
if (viewParams.IsAutoRefresh()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
}
else {
if (verbosity >= G4VisManager::warnings) {
G4cout << "Issue /vis/viewer/refresh or flush to see effect."
<< G4endl;
}
}
}
}
void G4VVisCommand::InterpolateViews
(G4VViewer* currentViewer,
std::vector<G4ViewParameters> viewVector,
const G4int nInterpolationPoints,
const G4int waitTimePerPointmilliseconds,
const G4String exportString)
{
const G4int safety = viewVector.size()*nInterpolationPoints;
G4int safetyCount = 0;
do {
G4ViewParameters* vp =
G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
if (!vp) break; // Finished.
currentViewer->SetViewParameters(*vp);
currentViewer->RefreshView();
if (exportString == "export" &&
currentViewer->GetName().contains("OpenGL")) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/ogl/export");
}
// File-writing viewers need to close the file
currentViewer->ShowView();
#ifdef G4VIS_USE_STD11
if (waitTimePerPointmilliseconds > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
#endif
} while (safetyCount++ < safety); // Loop checking, 16.02.2016, J.Allison
}
void G4VVisCommand::InterpolateToNewView
(G4VViewer* currentViewer,
const G4ViewParameters& oldVP,
const G4ViewParameters& newVP,
const G4int nInterpolationPoints,
const G4int waitTimePerPointmilliseconds,
const G4String exportString)
{
std::vector<G4ViewParameters> viewVector;
viewVector.push_back(oldVP);
viewVector.push_back(oldVP);
viewVector.push_back(newVP);
viewVector.push_back(newVP);
InterpolateViews
(currentViewer,
viewVector,
nInterpolationPoints,
waitTimePerPointmilliseconds,
exportString);
}
void G4VVisCommand::CopyGuidanceFrom
(const G4UIcommand* fromCmd, G4UIcommand* toCmd, G4int startLine)
{
if (fromCmd && toCmd) {
const G4int nGuideEntries = fromCmd->GetGuidanceEntries();
for (G4int i = startLine; i < nGuideEntries; ++i) {
const G4String& guidance = fromCmd->GetGuidanceLine(i);
toCmd->SetGuidance(guidance);
}
}
}
void G4VVisCommand::CopyParametersFrom
(const G4UIcommand* fromCmd, G4UIcommand* toCmd)
{
if (fromCmd && toCmd) {
const G4int nParEntries = fromCmd->GetParameterEntries();
for (G4int i = 0; i < nParEntries; ++i) {
G4UIparameter* parameter = new G4UIparameter(*(fromCmd->GetParameter(i)));
toCmd->SetParameter(parameter);
}
}
}
void G4VVisCommand::DrawExtent(const G4VisExtent& extent)
{
if (fpVisManager) {
const G4double halfX = (extent.GetXmax() - extent.GetXmin()) / 2.;
const G4double halfY = (extent.GetYmax() - extent.GetYmin()) / 2.;
const G4double halfZ = (extent.GetZmax() - extent.GetZmin()) / 2.;
if (halfX > 0. && halfY > 0. && halfZ > 0.) {
const G4Box box("vis_extent",halfX,halfY,halfZ);
const G4VisAttributes visAtts(G4Color::Red());
const G4Point3D& centre = extent.GetExtentCenter();
fpVisManager->Draw(box,visAtts,G4Translate3D(centre));
}
}
}
@@ -41,6 +41,7 @@
G4ViewParameters::G4ViewParameters ():
fDrawingStyle (wireframe),
fNumberOfCloudPoints(10000),
fAuxEdgeVisible (false),
fCulling (true),
fCullInvisible (true),
@@ -219,13 +220,25 @@ G4int G4ViewParameters::SetNoOfSides (G4int nSides) {
if (nSides < nSidesMin) {
nSides = nSidesMin;
G4cout << "G4ViewParameters::SetNoOfSides: attempt to set the"
"\nnumber of sides per circle < " << nSidesMin
<< "; forced to " << nSides << G4endl;
"\nnumber of sides per circle < " << nSidesMin
<< "; forced to " << nSides << G4endl;
}
fNoOfSides = nSides;
return fNoOfSides;
}
G4int G4ViewParameters::SetNumberOfCloudPoints(G4int nPoints) {
const G4int nPointsMin = 100;
if (nPoints < nPointsMin) {
nPoints = nPointsMin;
G4cout << "G4ViewParameters::SetNumberOfCloudPoints:"
"\nnumber of points per cloud set to minimum " << nPoints
<< G4endl;
}
fNumberOfCloudPoints = nPoints;
return fNumberOfCloudPoints;
}
void G4ViewParameters::SetViewAndLights
(const G4Vector3D& viewpointDirection) {
@@ -239,7 +252,7 @@ void G4ViewParameters::SetViewAndLights
firstTime = false;
G4cout <<
"WARNING: Viewpoint direction is very close to the up vector direction."
"\n Consider setting the up vector to obtain definable behaviour."
"\n Change the up vector or \"/vis/viewer/set/rotationStyle freeRotation\"."
<< G4endl;
}
}
@@ -393,12 +406,20 @@ G4String G4ViewParameters::DrawingStyleCommands() const
oss << "#\n# Drawing style commands";
oss << "\n/vis/viewer/set/style ";
if (fDrawingStyle == wireframe || fDrawingStyle == hlr) {
oss << "wireframe";
} else {
oss << "surface";
switch (fDrawingStyle) {
case wireframe:
case hlr:
oss << "wireframe";
break;
case hsr:
case hlhsr:
oss << "surface";
break;
case cloud:
oss << "cloud";
break;
}
oss << "\n/vis/viewer/set/hiddenEdge ";
if (fDrawingStyle == hlr || fDrawingStyle == hlhsr) {
oss << "true";
@@ -425,7 +446,10 @@ G4String G4ViewParameters::DrawingStyleCommands() const
oss << "\n/vis/viewer/set/globalMarkerScale "
<< fGlobalMarkerScale;
oss << "\n/vis/viewer/set/numberOfCloudPoints "
<< fNumberOfCloudPoints;
oss << std::endl;
return oss.str();
@@ -619,6 +643,18 @@ G4String G4ViewParameters::TouchableCommands() const
}
}
break;
case G4ModelingParameters::VASForceCloud:
if (vamVisAtts.IsForceDrawingStyle()) {
if (vamVisAtts.GetForcedDrawingStyle() == G4VisAttributes::cloud) {
oss << "\n/vis/touchable/set/forceCloud ";
if (vamVisAtts.IsForceDrawingStyle()) {
oss << "true";
} else {
oss << "false";
}
}
}
break;
case G4ModelingParameters::VASForceAuxEdgeVisible:
if (vamVisAtts.IsForceAuxEdgeVisible()) {
oss << "\n/vis/touchable/set/forceAuxEdgeVisible ";
@@ -630,10 +666,12 @@ G4String G4ViewParameters::TouchableCommands() const
}
break;
case G4ModelingParameters::VASForceLineSegmentsPerCircle:
if (vamVisAtts.GetForcedLineSegmentsPerCircle() > 0) {
oss << "\n/vis/touchable/set/lineSegmentsPerCircle "
<< vamVisAtts.GetForcedLineSegmentsPerCircle();
}
oss << "\n/vis/touchable/set/lineSegmentsPerCircle "
<< vamVisAtts.GetForcedLineSegmentsPerCircle();
break;
case G4ModelingParameters::VASForceNumberOfCloudPoints:
oss << "\n/vis/touchable/set/numberOfCloudPoints "
<< vamVisAtts.GetForcedNumberOfCloudPoints();
break;
}
}
@@ -707,6 +745,7 @@ void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const {
// No particular order from here on.
(fDrawingStyle != v.fDrawingStyle) ||
(fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
(fAuxEdgeVisible != v.fAuxEdgeVisible) ||
(fCulling != v.fCulling) ||
(fCullInvisible != v.fCullInvisible) ||
@@ -826,6 +865,8 @@ std::ostream& operator <<
os << "hsr - hidden surfaces removed"; break;
case G4ViewParameters::hlhsr:
os << "hlhsr - hidden line, hidden surface removed"; break;
case G4ViewParameters::cloud:
os << "cloud - draw volume as a cloud of dots"; break;
default: os << "unrecognised"; break;
}
return os;
@@ -834,18 +875,9 @@ std::ostream& operator <<
std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) {
os << "View parameters and options:";
os << "\n Drawing style: ";
switch (v.fDrawingStyle) {
case G4ViewParameters::wireframe:
os << "edges, wireframe"; break;
case G4ViewParameters::hlr:
os << "edges, hidden line removal"; break;
case G4ViewParameters::hsr:
os << "surfaces, hidden surface removal"; break;
case G4ViewParameters::hlhsr:
os << "surfaces and edges, hidden line and surface removal"; break;
default: os << "unrecognised"; break;
}
os << "\n Drawing style: " << v.fDrawingStyle;
os << "\n Number of cloud points: " << v.fNumberOfCloudPoints;
os << "\n Auxiliary edges: ";
if (!v.fAuxEdgeVisible) os << "in";
@@ -1029,6 +1061,7 @@ G4bool G4ViewParameters::operator != (const G4ViewParameters& v) const {
// No particular order from here on.
(fDrawingStyle != v.fDrawingStyle) ||
(fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
(fAuxEdgeVisible != v.fAuxEdgeVisible) ||
(fCulling != v.fCulling) ||
(fCullInvisible != v.fCullInvisible) ||
@@ -212,17 +212,9 @@ G4VisCommandDrawLogicalVolume::G4VisCommandDrawLogicalVolume() {
const G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
const G4UIcommand* addLogVolCmd = tree->FindPath("/vis/scene/add/logicalVolume");
// Pick up guidance from /vis/scene/add/logicalVolume
G4int nGuideEntries = addLogVolCmd->GetGuidanceEntries();
for (G4int i = 0; i < nGuideEntries; ++i) {
const G4String& guidance = addLogVolCmd->GetGuidanceLine(i);
fpCommand->SetGuidance(guidance);
}
CopyGuidanceFrom(addLogVolCmd,fpCommand);
// Pick up parameters from /vis/scene/add/logicalVolume
G4int nParEntries = addLogVolCmd->GetParameterEntries();
for (G4int i = 0; i < nParEntries; ++i) {
G4UIparameter* parameter = new G4UIparameter(*(addLogVolCmd->GetParameter(i)));
fpCommand->SetParameter(parameter);
}
CopyParametersFrom(addLogVolCmd,fpCommand);
}
G4VisCommandDrawLogicalVolume::~G4VisCommandDrawLogicalVolume() {
@@ -245,7 +237,8 @@ void G4VisCommandDrawLogicalVolume::SetNewValue(G4UIcommand*, G4String newValue)
UImanager->ApplyCommand(G4String("/vis/scene/add/logicalVolume " + newValue));
UImanager->ApplyCommand("/vis/sceneHandler/attach");
G4ViewParameters::DrawingStyle keepDrawingStyle = currentViewParams.GetDrawingStyle();
if(keepDrawingStyle != G4ViewParameters::wireframe) UImanager->ApplyCommand("/vis/viewer/set/style wireframe");
if(keepDrawingStyle != G4ViewParameters::wireframe)
UImanager->ApplyCommand("/vis/viewer/set/style wireframe");
G4bool keepMarkerNotHidden = currentViewParams.IsMarkerNotHidden();
if (!keepMarkerNotHidden) UImanager->ApplyCommand("/vis/viewer/set/hiddenMarker false");
if (keepAutoRefresh) UImanager->ApplyCommand("/vis/viewer/set/autoRefresh true");
@@ -264,11 +257,12 @@ void G4VisCommandDrawLogicalVolume::SetNewValue(G4UIcommand*, G4String newValue)
style = "surface"; edge = "false"; break;
case G4ViewParameters::hlhsr:
style = "surface"; edge = "true"; break;
case G4ViewParameters::cloud:
style = "cloud"; edge = ""; break;
}
G4cout
<< "\n /vis/viewer/set/style " + style
<< "\n /vis/viewer/set/hiddenEdge " + edge
<< G4endl;
G4cout << "\n /vis/viewer/set/style " + style;
if (!edge.empty()) G4cout << "\n /vis/viewer/set/hiddenEdge " + edge;
G4cout << G4endl;
}
if (keepMarkerNotHidden != currentViewParams.IsMarkerNotHidden()) {
G4cout
@@ -297,17 +291,9 @@ G4VisCommandDrawVolume::G4VisCommandDrawVolume() {
const G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
const G4UIcommand* addVolCmd = tree->FindPath("/vis/scene/add/volume");
// Pick up guidance from /vis/scene/add/volume
G4int nGuideEntries = addVolCmd->GetGuidanceEntries();
for (G4int i = 0; i < nGuideEntries; ++i) {
const G4String& guidance = addVolCmd->GetGuidanceLine(i);
fpCommand->SetGuidance(guidance);
}
CopyGuidanceFrom(addVolCmd,fpCommand);
// Pick up parameters from /vis/scene/add/volume
G4int nParEntries = addVolCmd->GetParameterEntries();
for (G4int i = 0; i < nParEntries; ++i) {
G4UIparameter* parameter = new G4UIparameter(*(addVolCmd->GetParameter(i)));
fpCommand->SetParameter(parameter);
}
CopyParametersFrom(addVolCmd,fpCommand);
}
G4VisCommandDrawVolume::~G4VisCommandDrawVolume() {
@@ -356,7 +356,7 @@ G4VisCommandGeometrySetForceSolid::G4VisCommandGeometrySetForceSolid()
parameter->SetGuidance
("Depth of propagation (-1 means unlimited depth).");
fpCommand->SetParameter(parameter);
parameter = new G4UIparameter("forceSolid", 'b', omitable = true);
parameter = new G4UIparameter("force", 'b', omitable = true);
parameter->SetDefaultValue(true);
fpCommand->SetParameter(parameter);
}
@@ -377,12 +377,12 @@ void G4VisCommandGeometrySetForceSolid::SetNewValue
{
G4String name;
G4int requestedDepth;
G4String forceSolidString;
G4String forceString;
std::istringstream iss(newValue);
iss >> name >> requestedDepth >> forceSolidString;
G4bool forceSolid = G4UIcommand::ConvertToBool(forceSolidString);
iss >> name >> requestedDepth >> forceString;
G4bool force = G4UIcommand::ConvertToBool(forceString);
G4VisCommandGeometrySetForceSolidFunction setForceSolid(forceSolid);
G4VisCommandGeometrySetForceSolidFunction setForceSolid(force);
Set(name, setForceSolid, requestedDepth);
}
@@ -41,6 +41,7 @@
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4ios.hh"
#include <sstream>
@@ -780,9 +781,9 @@ G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
fpCommand -> SetGuidance ("Selects a scene");
fpCommand -> SetGuidance
("Makes the scene current. \"/vis/scene/list\" to see"
"\n possible scene names.");
fpCommand -> SetGuidance
("Makes the scene current. \"/vis/scene/list\" to see"
"\n possible scene names.");
fpCommand -> SetParameterName ("scene-name", omitable = false);
}
@@ -807,16 +808,111 @@ void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) {
if (iScene >= nScenes) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Scene \"" << selectName
<< "\" not found - \"/vis/scene/list\" to see possibilities."
<< G4endl;
<< "\" not found - \"/vis/scene/list\" to see possibilities."
<< G4endl;
}
return;
}
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Scene \"" << selectName
<< "\" selected." << G4endl;
<< "\" selected." << G4endl;
}
CheckSceneAndNotifyHandlers (sceneList [iScene]);
}
////////////// /vis/scene/showExtents ///////////////////////////////////////
G4VisCommandSceneShowExtents::G4VisCommandSceneShowExtents () {
fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/showExtents", this);
fpCommand -> SetGuidance ("Prints and draws extents of models in a scene");
}
G4VisCommandSceneShowExtents::~G4VisCommandSceneShowExtents () {
delete fpCommand;
}
G4String G4VisCommandSceneShowExtents::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneShowExtents::SetNewValue (G4UIcommand*, G4String) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4VSceneHandler* pCurrentSceneHandler =
fpVisManager -> GetCurrentSceneHandler();
if (!pCurrentSceneHandler) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: No current scene handler."
<< G4endl;
}
return;
}
G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
if (!pCurrentViewer) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: No current viewer."
<< G4endl;
}
return;
}
G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
if (!pCurrentScene) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: No current scene."
<< G4endl;
}
return;
}
G4cout << "\n Run-duration models:";
G4int nRunModels = pCurrentScene -> GetRunDurationModelList ().size ();
if (nRunModels == 0) {
G4cout << " none.";
}
for (G4int i = 0; i < nRunModels; i++) {
if (pCurrentScene -> GetRunDurationModelList()[i].fActive)
G4cout << "\n Active: ";
else G4cout << "\n Inactive: ";
G4VModel* pModel = pCurrentScene -> GetRunDurationModelList()[i].fpModel;
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
G4cout << pModel -> GetGlobalDescription ()
<< "\n" << transformedExtent;
DrawExtent(transformedExtent);
}
G4cout << "\n End-of-event models:";
G4int nEOEModels = pCurrentScene -> GetEndOfEventModelList ().size ();
if (nEOEModels == 0) {
G4cout << " none.";
}
for (G4int i = 0; i < nEOEModels; i++) {
if (pCurrentScene -> GetEndOfEventModelList()[i].fActive)
G4cout << "\n Active: ";
else G4cout << "\n Inactive: ";
G4VModel* pModel = pCurrentScene -> GetEndOfEventModelList()[i].fpModel;
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
G4cout << pModel -> GetGlobalDescription ()
<< "\n" << transformedExtent;
DrawExtent(transformedExtent);
}
G4cout << "\n End-of-run models:";
G4int nEORModels = pCurrentScene -> GetEndOfRunModelList ().size ();
if (nEORModels == 0) {
G4cout << " none.";
}
for (G4int i = 0; i < nEORModels; i++) {
if (pCurrentScene -> GetEndOfRunModelList()[i].fActive)
G4cout << "\n Active: ";
else G4cout << "\n Inactive: ";
G4VModel* pModel = pCurrentScene -> GetEndOfRunModelList()[i].fpModel;
const G4VisExtent& transformedExtent = pModel -> GetTransformedExtent();
G4cout << pModel -> GetGlobalDescription ()
<< "\n" << transformedExtent;
DrawExtent(transformedExtent);
}
G4cout << "Overall extent:\n";
DrawExtent(pCurrentScene->GetExtent());
G4cout << G4endl;
}
@@ -36,6 +36,7 @@
#include "G4HitsModel.hh"
#include "G4DigiModel.hh"
#include "G4GPSModel.hh"
#include "G4ElectricFieldModel.hh"
#include "G4MagneticFieldModel.hh"
#include "G4PSHitsModel.hh"
#include "G4TrajectoriesModel.hh"
@@ -53,6 +54,7 @@
#include "G4SubtractionSolid.hh"
#include "G4Polyhedron.hh"
#include "G4UImanager.hh"
#include "G4UIcommandTree.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
@@ -81,17 +83,6 @@
#include <sstream>
// Local function with some frequently used error printing...
static void G4VisCommandsSceneAddUnsuccessful
(G4VisManager::Verbosity verbosity) {
if (verbosity >= G4VisManager::warnings) {
G4cout <<
"WARNING: For some reason, possibly mentioned above, it has not been"
"\n possible to add to the scene."
<< G4endl;
}
}
////////////// /vis/scene/add/arrow ///////////////////////////////////////
G4VisCommandSceneAddArrow::G4VisCommandSceneAddArrow () {
@@ -536,6 +527,100 @@ void G4VisCommandSceneAddDigis::SetNewValue (G4UIcommand*, G4String) {
CheckSceneAndNotifyHandlers (pScene);
}
////////////// /vis/scene/add/electricField ///////////////////////////////////////
G4VisCommandSceneAddElectricField::G4VisCommandSceneAddElectricField () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/scene/add/electricField", this);
fpCommand -> SetGuidance
("Adds electric field representation to current scene.");
fpCommand -> SetGuidance
("The first parameter is no. of data points per half scene. So, possibly, at"
"\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
"\nlarge--be warned!"
"\nThe default value is 10, i.e., a 21x21x21 array, i.e., 9,261 sampling points."
"\nThat may swamp you scene, but usually, a field is limited to a small part of"
"\nthe scene, so it's not a problem. But if it is, here are some of the things"
"\nyou can do:"
"\n- reduce the number of data points per half scene (first parameter);"
"\n- specify \"lightArrow\" (second parameter);"
"\n- restrict the region sampled with \"/vis/set/extentForField\";"
"\n- restrict the drawing to a specific volume with"
"\n \"/vis/set/volumeForField\" or \"/vis/touchable/volumeForField\"."
"\nNote: you may have to deactivate existing field models with"
"\n \"/vis/scene/activateModel Field false\" and re-issue"
"\n \"/vis/scene/add/...Field\" command again.");
fpCommand -> SetGuidance
("In the arrow representation, the length of the arrow is proportional"
"\nto the magnitude of the field and the colour is mapped onto the range"
"\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("nDataPointsPerHalfScene", 'i', omitable = true);
parameter -> SetDefaultValue (10);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("representation", 's', omitable = true);
parameter -> SetParameterCandidates("fullArrow lightArrow");
parameter -> SetDefaultValue ("fullArrow");
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddElectricField::~G4VisCommandSceneAddElectricField () {
delete fpCommand;
}
G4String G4VisCommandSceneAddElectricField::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneAddElectricField::SetNewValue
(G4UIcommand*, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn(verbosity >= G4VisManager::warnings);
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
G4int nDataPointsPerHalfScene;
G4String representation;
std::istringstream iss(newValue);
iss >> nDataPointsPerHalfScene >> representation;
G4ElectricFieldModel::Representation
modelRepresentation = G4ElectricFieldModel::fullArrow;
if (representation == "lightArrow") {
modelRepresentation = G4ElectricFieldModel::lightArrow;
}
G4VModel* model;
model = new G4ElectricFieldModel
(nDataPointsPerHalfScene,modelRepresentation,
fCurrentArrow3DLineSegmentsPerCircle,
fCurrentExtentForField,
fCurrrentPVFindingsForField);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout
<< "Electric field, if any, will be drawn in scene \""
<< currentSceneName
<< "\"\n with "
<< nDataPointsPerHalfScene
<< " data points per half scene and with representation \""
<< representation
<< '\"'
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
CheckSceneAndNotifyHandlers (pScene);
}
////////////// /vis/scene/add/eventID ///////////////////////////////////////
G4VisCommandSceneAddEventID::G4VisCommandSceneAddEventID () {
@@ -869,75 +954,75 @@ void G4VisCommandSceneAddFrame::Frame::operator()
sceneHandler.EndPrimitives2D();
}
////////////// /vis/scene/add/gps ///////////////////////////////////////
////////////// /vis/scene/add/gps ///////////////////////////////////////
G4VisCommandSceneAddGPS::G4VisCommandSceneAddGPS () {
G4bool omitable;
G4UIparameter* parameter;
fpCommand = new G4UIcommand ("/vis/scene/add/gps", this);
fpCommand -> SetGuidance
("A representation of the source(s) of the General Particle Source"
"\nwill be added to current scene and drawn, if applicable.");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: red and transparent.");
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
parameter -> SetDefaultValue (0.3);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddGPS::G4VisCommandSceneAddGPS () {
G4bool omitable;
G4UIparameter* parameter;
fpCommand = new G4UIcommand ("/vis/scene/add/gps", this);
fpCommand -> SetGuidance
("A representation of the source(s) of the General Particle Source"
"\nwill be added to current scene and drawn, if applicable.");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: red and transparent.");
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
parameter -> SetDefaultValue (0.3);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddGPS::~G4VisCommandSceneAddGPS () {
delete fpCommand;
}
G4VisCommandSceneAddGPS::~G4VisCommandSceneAddGPS () {
delete fpCommand;
}
G4String G4VisCommandSceneAddGPS::GetCurrentValue (G4UIcommand*) {
return "";
}
G4String G4VisCommandSceneAddGPS::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneAddGPS::SetNewValue (G4UIcommand*, G4String newValue) {
void G4VisCommandSceneAddGPS::SetNewValue (G4UIcommand*, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn(verbosity >= G4VisManager::warnings);
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn(verbosity >= G4VisManager::warnings);
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
G4String redOrString;
G4double green, blue, opacity;
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,0.,0.,0.3); // Default red and transparent.
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VModel* model = new G4GPSModel(colour);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"A representation of the source(s) of the General Particle Source will be drawn"
"\n in colour " << colour << " for scene \""
<< currentSceneName << "\" if applicable."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
CheckSceneAndNotifyHandlers (pScene);
return;
}
G4String redOrString;
G4double green, blue, opacity;
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,0.,0.,0.3); // Default red and transparent.
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VModel* model = new G4GPSModel(colour);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"A representation of the source(s) of the General Particle Source will be drawn"
"\n in colour " << colour << " for scene \""
<< currentSceneName << "\" if applicable."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
CheckSceneAndNotifyHandlers (pScene);
}
////////////// /vis/scene/add/hits ///////////////////////////////////////
@@ -1828,31 +1913,15 @@ void G4VisCommandSceneAddLogo2D::Logo2D::operator()
////////////// /vis/scene/add/magneticField ///////////////////////////////////////
G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/scene/add/magneticField", this);
fpCommand -> SetGuidance
("Adds magnetic field representation to current scene.");
fpCommand -> SetGuidance
("The first parameter is no. of data points per half scene. So, possibly, at"
"\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
"\nlarge--be warned!"
"\nYou might find that your scene is cluttered by thousands of arrows for"
"\nthe default number of data points, so try reducing to 2 or 3, e.g:"
"\n /vis/scene/add/magneticField 3"
"\nor, if only a small part of the scene has a field:"
"\n /vis/scene/add/magneticField 50 or more");
fpCommand -> SetGuidance
("In the arrow representation, the length of the arrow is proportional"
"\nto the magnitude of the field and the colour is mapped onto the range"
"\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("nDataPointsPerHalfScene", 'i', omitable = true);
parameter -> SetDefaultValue (10);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("representation", 's', omitable = true);
parameter -> SetParameterCandidates("fullArrow lightArrow");
parameter -> SetDefaultValue ("fullArrow");
fpCommand -> SetParameter (parameter);
const G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
const G4UIcommand* addElecFieldCmd = tree->FindPath("/vis/scene/add/electricField");
// Pick up additional guidance from /vis/scene/add/electricField
CopyGuidanceFrom(addElecFieldCmd,fpCommand,1);
// Pick up parameters from /vis/scene/add/electricField
CopyParametersFrom(addElecFieldCmd,fpCommand);
}
G4VisCommandSceneAddMagneticField::~G4VisCommandSceneAddMagneticField () {
@@ -1872,7 +1941,7 @@ void G4VisCommandSceneAddMagneticField::SetNewValue
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -1881,23 +1950,27 @@ void G4VisCommandSceneAddMagneticField::SetNewValue
G4String representation;
std::istringstream iss(newValue);
iss >> nDataPointsPerHalfScene >> representation;
G4MagneticFieldModel::Representation
modelRepresentation = G4MagneticFieldModel::fullArrow;
G4ElectricFieldModel::Representation
modelRepresentation = G4ElectricFieldModel::fullArrow;
if (representation == "lightArrow") {
modelRepresentation = G4MagneticFieldModel::lightArrow;
modelRepresentation = G4ElectricFieldModel::lightArrow;
}
G4VModel* model =
new G4MagneticFieldModel(nDataPointsPerHalfScene,modelRepresentation,
fCurrentArrow3DLineSegmentsPerCircle);
G4VModel* model;
model = new G4MagneticFieldModel
(nDataPointsPerHalfScene,modelRepresentation,
fCurrentArrow3DLineSegmentsPerCircle,
fCurrentExtentForField,
fCurrrentPVFindingsForField);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Magnetic field, if any, will be drawn in scene \""
G4cout
<< "Magnetic field, if any, will be drawn in scene \""
<< currentSceneName
<< "\"\n with "
<< nDataPointsPerHalfScene
<< " data points per half scene and with representation \""
<< " data points per half extent and with representation \""
<< representation
<< '\"'
<< G4endl;
@@ -2320,7 +2393,6 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
transform = G4Translate3D(sxmid,symid,szmid) * transform;
///////// G4VisExtent scaleExtent(sxmin, sxmax, symin, symax, szmin, szmax);
model->SetTransformation(transform);
// Note: it is the responsibility of the model to act upon this, but
// the extent is in local coordinates...
@@ -2830,32 +2902,32 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
("Adds a physical volume to current scene, with optional clipping volume.");
fpCommand -> SetGuidance
("If physical-volume-name is \"world\" (the default), the top of the"
"\nmain geometry tree (material world) is added. If \"worlds\", the"
"\ntop of all worlds - material world and parallel worlds, if any - are"
"\nadded. Otherwise a search of all worlds is made.");
"\nmain geometry tree (material world) is added. If \"worlds\", the"
"\ntops of all worlds - material world and parallel worlds, if any - are"
"\nadded. Otherwise a search of all worlds is made.");
fpCommand -> SetGuidance
("In the last case (a search of all worlds) all physical volume names are"
"\nmatched against the first argument of this command. If this is of the"
"\nform \"/regexp/\", where regexp is a regular expression (see C++ regex),"
"\nthe physical volume name is matched against regexp by the usual rules"
"\nof regular expression matching. Otherwise an exact match is required."
"\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
("In the last case the names of all volumes in all worlds are matched"
"\nagainst physical-volume-name. If this is of the form \"/regexp/\","
"\nwhere regexp is a regular expression (see C++ regex), the match uses"
"\nthe usual rules of regular expression matching. Otherwise an exact"
"\nmatch is required."
"\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
fpCommand -> SetGuidance
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRep.");
"\ncombinations that have the required functionality, e.g., HepRepFile.");
fpCommand -> SetGuidance
("If clip-volume-type is specified, the subsequent parameters are used to"
"\nto define a clipping volume. For example,"
"\nto define a clipping volume. For example,"
"\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
"\nwith the positive octant cut away. (If the Boolean Processor issues"
"\nwith the positive octant cut away. (If the Boolean Processor issues"
"\nwarnings try replacing 0 by 0.000000001 or something.)");
fpCommand -> SetGuidance
("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
"\n(cutaway). (This is the default if there is no prepended character.)"
"\nIf '*' is prepended, the intersection of the physical-volume and the"
"\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
"\nexample).");
"\nclip-volume is made. (You can make a section through the detector with"
"\na thin box, for example).");
fpCommand -> SetGuidance
("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
"\nOnly \"box\" is programmed at present.");
@@ -2864,8 +2936,7 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
parameter -> SetDefaultValue ("world");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
parameter -> SetGuidance
("If negative, matches any copy no. First name match is taken.");
parameter -> SetGuidance ("If negative, matches any copy no.");
parameter -> SetDefaultValue (-1);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
@@ -3037,7 +3108,7 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
}
for (const auto& findings: findingsVector) {
// Set copy number from search findings to cope with replicas.
// Set copy number from search findings for replicas and parameterisations.
findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
// Create a physical volume model...
G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
@@ -3051,7 +3122,8 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
foundPVModel->SetClippingSolid(clippingSolid);
foundPVModel->SetClippingMode(clippingMode);
}
// ...and add it to the scene.
if (!foundPVModel->Validate(warn)) return; // Calculates extent
// ...so add it to the scene.
G4bool successful = pScene->AddRunDurationModel(foundPVModel,warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
@@ -34,8 +34,10 @@
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4TouchablePropertiesScene.hh"
#include "G4TransportationManager.hh"
#include "G4BoundingExtentScene.hh"
#include <sstream>
////////////// /vis/set/arrow3DLineSegmentsPerCircle ////////////////////////////////////
@@ -84,15 +86,15 @@ G4VisCommandSetColour::G4VisCommandSetColour ()
G4bool omitable;
fpCommand = new G4UIcommand("/vis/set/colour", this);
fpCommand->SetGuidance
("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
fpCommand->SetGuidance
("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: white and opaque.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("red", 's', omitable = true);
parameter->SetGuidance
("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
parameter->SetDefaultValue ("1.");
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("green", 'd', omitable = true);
@@ -130,10 +132,80 @@ void G4VisCommandSetColour::SetNewValue (G4UIcommand*, G4String newValue)
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Colour for future \"/vis/scene/add/\" commands has been set to "
<< fCurrentColour <<
".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)"
<< G4endl;
"Colour for future \"/vis/scene/add/\" commands has been set to "
<< fCurrentColour <<
".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)"
<< G4endl;
}
}
////////////// /vis/set/extentForField ////////////////////////////////////
G4VisCommandSetExtentForField::G4VisCommandSetExtentForField ()
{
G4bool omitable;
fpCommand = new G4UIcommand("/vis/set/extentForField", this);
fpCommand->SetGuidance
("Sets an extent for future \"/vis/scene/add/*Field\" commands.");
fpCommand->SetGuidance
("The default is a null extent, which is interpreted by the commands as the"
"\nextent of the whole scene.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("xmin", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("xmax", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("ymin", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("ymax", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("zmin", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("zmax", 'd', omitable = true);
parameter->SetDefaultValue (0.);
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter->SetDefaultValue ("m");
fpCommand->SetParameter (parameter);
}
G4VisCommandSetExtentForField::~G4VisCommandSetExtentForField ()
{
delete fpCommand;
}
G4String G4VisCommandSetExtentForField::GetCurrentValue (G4UIcommand*)
{
return G4String();
}
void G4VisCommandSetExtentForField::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4double xmin, xmax, ymin, ymax, zmin, zmax;
G4String unitString;
std::istringstream iss(newValue);
iss >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
G4double unit = G4UIcommand::ValueOf(unitString);
xmin *= unit; xmax *= unit;
ymin *= unit; ymax *= unit;
zmin *= unit; zmax *= unit;
fCurrentExtentForField = G4VisExtent(xmin,xmax,ymin,ymax,zmin,zmax);
fCurrrentPVFindingsForField.clear();
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Extent for future \"/vis/scene/add/*Field\" commands has been set to "
<< fCurrentExtentForField
<< "\nVolume for field has been cleared."
<< G4endl;
}
}
@@ -289,7 +361,7 @@ G4VisCommandSetTextSize::G4VisCommandSetTextSize ()
("Defines text size (pixels) for future \"/vis/scene/add/\" commands.");
fpCommand->SetParameterName ("textSize", omitable = true);
fpCommand->SetDefaultValue (12.); // pixels
fpCommand->SetRange("textSize >= 1.");
fpCommand->SetRange("textSize >= 8.");
}
G4VisCommandSetTextSize::~G4VisCommandSetTextSize ()
@@ -331,7 +403,7 @@ G4VisCommandSetTouchable::G4VisCommandSetTouchable ()
"\n /vis/set/touchable World 0 Envelope 0 Shape1 0"
"\n(To get list of touchables, use \"/vis/drawTree\")"
"\n(To save, use \"/vis/viewer/save\")");
parameter = new G4UIparameter ("list", 's', omitable = false);
parameter = new G4UIparameter ("list", 's', omitable = true);
parameter->SetGuidance
("List of physical volume names and copy number pairs");
fpCommand->SetParameter (parameter);
@@ -350,9 +422,19 @@ G4String G4VisCommandSetTouchable::GetCurrentValue (G4UIcommand*)
void G4VisCommandSetTouchable::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
if (newValue.isNull()) {
fCurrentTouchableProperties = G4PhysicalVolumeModel::TouchableProperties();
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Current touchable reset to: " << fCurrentTouchableProperties.fTouchablePath
<< G4endl;
}
return;
}
G4ModelingParameters::PVNameCopyNoPath currentTouchablePath;
// Algorithm from Josuttis p.476.
G4String::size_type iBegin, iEnd;
iBegin = newValue.find_first_not_of(' ');
@@ -431,3 +513,105 @@ void G4VisCommandSetTouchable::SetNewValue (G4UIcommand*, G4String newValue)
}
}
}
////////////// /vis/set/volumeForField ////////////////////////////////////
G4VisCommandSetVolumeForField::G4VisCommandSetVolumeForField ()
{
G4bool omitable;
G4UIparameter* parameter;
fpCommand = new G4UIcommand("/vis/set/volumeForField", this);
fpCommand->SetGuidance
("Sets a volume and optional copy number \"/vis/scene/add/*Field\" commands.");
parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
parameter -> SetDefaultValue ("none");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
parameter -> SetGuidance ("If negative, matches any copy no.");
parameter -> SetDefaultValue (-1);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("draw", 'b', omitable = true);
parameter -> SetGuidance ("If true, draw extent of found volumes.");
parameter -> SetDefaultValue (false);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSetVolumeForField::~G4VisCommandSetVolumeForField ()
{
delete fpCommand;
}
G4String G4VisCommandSetVolumeForField::GetCurrentValue (G4UIcommand*)
{
return G4String();
}
void G4VisCommandSetVolumeForField::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String name, drawString;
G4int copyNo;
std::istringstream is (newValue);
is >> name >> copyNo >> drawString;
G4bool draw = G4UIcmdWithABool::ConvertToBool(drawString);
if (name == "none") {
fCurrrentPVFindingsForField.clear();
fCurrentExtentForField = G4VisExtent();
if (verbosity >= G4VisManager::warnings) {
G4cout << "Volume for field cleared" << G4endl;
}
return;
}
G4TransportationManager* transportationManager =
G4TransportationManager::GetTransportationManager ();
size_t nWorlds = transportationManager->GetNoWorlds();
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
transportationManager->GetWorldsIterator();
fCurrrentPVFindingsForField.clear();
G4BoundingExtentScene extentScene;
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
G4ModelingParameters mp; // Default - no culling.
searchModel.SetModelingParameters (&mp);
G4PhysicalVolumesSearchScene searchScene (&searchModel, name, copyNo);
searchModel.DescribeYourselfTo (searchScene); // Initiate search.
for (const auto& findings: searchScene.GetFindings()) {
fCurrrentPVFindingsForField.push_back(findings);
G4VisExtent extent = findings.fpFoundPV->GetLogicalVolume()->GetSolid()->GetExtent();
extent.Transform(findings.fFoundObjectTransformation);
extentScene.AccrueBoundingExtent(extent);
}
}
if (fCurrrentPVFindingsForField.empty()) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: Volume \"" << name << "\"";
if (copyNo >= 0) {
G4cerr << ", copy no. " << copyNo << ",";
}
G4cerr << " not found." << G4endl;
}
return;
}
fCurrentExtentForField = extentScene.GetExtent();
if (draw) DrawExtent(fCurrentExtentForField);
if (verbosity >= G4VisManager::confirmations) {
for (const auto& findings: fCurrrentPVFindingsForField) {
G4cout
<< "\"" << findings.fpFoundPV->GetName()
<< "\", copy no. " << findings.fFoundPVCopyNo
<< ", found\nin searched volume \""
<< findings.fpSearchPV->GetName()
<< "\" at depth " << findings.fFoundDepth
<< ",\nbase path: \"" << findings.fFoundBasePVPath
<< "\",\nand has been set as volume for field."
<< G4endl;
}
}
}
@@ -29,8 +29,10 @@
#include "G4VisCommandsTouchable.hh"
#include "G4UImanager.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithABool.hh"
#include "G4TransportationManager.hh"
#include "G4TouchableUtils.hh"
#include "G4PhysicalVolumesSearchScene.hh"
@@ -40,17 +42,44 @@
G4VisCommandsTouchable::G4VisCommandsTouchable()
{
fpCommandDump = new G4UIcmdWithoutParameter("/vis/touchable/dump",this);
fpCommandDump->SetGuidance("Dump touchable attributes.");
fpCommandDump->SetGuidance
G4bool omitable;
fpCommandCentreAndZoomInOn = new G4UIcmdWithoutParameter("/vis/touchable/centreAndZoomInOn",this);
fpCommandCentreAndZoomInOn->SetGuidance ("Centre and zoom in on the current touchable.");
fpCommandCentreAndZoomInOn->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
fpCommandDump->SetGuidance
fpCommandCentreAndZoomInOn->SetGuidance
("You may also need \"/vis/touchable/findPath\".");
fpCommandCentreAndZoomInOn->SetGuidance
("Use \"/vis/touchable/set\" to set attributes.");
fpCommandFindPath = new G4UIcmdWithAString("/vis/touchable/findPath",this);
fpCommandCentreOn = new G4UIcmdWithoutParameter("/vis/touchable/centreOn",this);
fpCommandCentreOn->SetGuidance ("Centre the view on the current touchable.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandCentreOn,1);
fpCommandDraw = new G4UIcmdWithoutParameter("/vis/touchable/draw",this);
fpCommandDraw->SetGuidance("Draw touchable.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandDraw,1);
fpCommandDump = new G4UIcmdWithoutParameter("/vis/touchable/dump",this);
fpCommandDump->SetGuidance("Dump touchable attributes.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandDump,1);
fpCommandExtentForField = new G4UIcmdWithABool("/vis/touchable/extentForField",this);
fpCommandExtentForField->SetGuidance("Set extent for field.");
fpCommandExtentForField->SetGuidance("If parameter == true, also draw.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandExtentForField,1);
fpCommandExtentForField->SetParameterName("draw", omitable = true);
fpCommandExtentForField->SetDefaultValue(false);
fpCommandFindPath = new G4UIcommand("/vis/touchable/findPath",this);
fpCommandFindPath->SetGuidance
("Prints the path to touchable and its logical volume mother"
"\ngiven a physical volume name.");
"\ngiven a physical volume name and copy no.");
fpCommandFindPath -> SetGuidance
("A search of all worlds is made and all physical volume names are"
"\nmatched against the argument of this command. If this is of the"
@@ -62,10 +91,41 @@ G4VisCommandsTouchable::G4VisCommandsTouchable()
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRep.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
parameter -> SetDefaultValue ("world");
fpCommandFindPath -> SetParameter (parameter);
parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
parameter -> SetGuidance ("If negative, matches any copy no.");
parameter -> SetDefaultValue (-1);
fpCommandFindPath -> SetParameter (parameter);
fpCommandShowExtent = new G4UIcmdWithABool("/vis/touchable/showExtent",this);
fpCommandShowExtent->SetGuidance("Print extent of touchable.");
fpCommandShowExtent->SetGuidance("If parameter == true, also draw.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandShowExtent,1);
fpCommandShowExtent->SetParameterName("draw", omitable = true);
fpCommandShowExtent->SetDefaultValue(false);
fpCommandVolumeForField = new G4UIcmdWithABool("/vis/touchable/volumeForField",this);
fpCommandVolumeForField->SetGuidance("Set volume for field.");
fpCommandVolumeForField->SetGuidance("If parameter == true, also draw.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandVolumeForField,1);
fpCommandVolumeForField->SetParameterName("draw", omitable = true);
fpCommandVolumeForField->SetDefaultValue(false);
}
G4VisCommandsTouchable::~G4VisCommandsTouchable() {
delete fpCommandVolumeForField;
delete fpCommandShowExtent;
delete fpCommandFindPath;
delete fpCommandExtentForField;
delete fpCommandDump;
delete fpCommandDraw;
delete fpCommandCentreAndZoomInOn;
delete fpCommandCentreOn;
}
G4String G4VisCommandsTouchable::GetCurrentValue(G4UIcommand*) {
@@ -76,6 +136,9 @@ void G4VisCommandsTouchable::SetNewValue
(G4UIcommand* command, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn = verbosity >= G4VisManager::warnings;
G4UImanager* UImanager = G4UImanager::GetUIpointer();
G4TransportationManager* transportationManager =
G4TransportationManager::GetTransportationManager ();
@@ -94,26 +157,144 @@ void G4VisCommandsTouchable::SetNewValue
return;
}
if (command == fpCommandDump) {
G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
return;
}
G4Scene* currentScene = fpVisManager->GetCurrentScene();
if (!currentScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: No current scene - \"/vis/scene/list\" to see possibilities."
<< G4endl;
}
return;
}
if (command == fpCommandCentreOn || command == fpCommandCentreAndZoomInOn) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
G4PhysicalVolumeModel pvModel
// To handle parameterisations, set copy number
properties.fpTouchablePV->SetCopyNo(properties.fCopyNo);
G4PhysicalVolumeModel tempPVModel
(properties.fpTouchablePV,
G4PhysicalVolumeModel::UNLIMITED,
properties.fTouchableGlobalTransform,
nullptr, // Modelling parameters (not used)
true, // use full extent (prevents calculating own extent, which crashes)
properties.fTouchableBaseFullPVPath);
const std::map<G4String,G4AttDef>* attDefs = pvModel.GetAttDefs();
std::vector<G4AttValue>* attValues = pvModel.CreateCurrentAttValues();
// Use a temporary scene in order to find vis extent
G4Scene tempScene("Centre Scene");
G4bool successful = tempScene.AddRunDurationModel(&tempPVModel,warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout
<< "Touchable " << fCurrentTouchableProperties.fTouchablePath
<< ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
<< G4endl;
}
}
const G4VisExtent& newExtent = tempScene.GetExtent();
const G4ThreeVector& newTargetPoint = newExtent.GetExtentCentre();
G4ViewParameters saveVP = currentViewer->GetViewParameters();
G4ViewParameters newVP = saveVP;
if (command == fpCommandCentreAndZoomInOn) {
// Calculate the new zoom factor
const G4double zoomFactor
= currentScene->GetExtent().GetExtentRadius()/newExtent.GetExtentRadius();
newVP.SetZoomFactor(zoomFactor);
}
// Change the target point
const G4Point3D& standardTargetPoint = currentScene->GetStandardTargetPoint();
newVP.SetCurrentTargetPoint(newTargetPoint - standardTargetPoint);
// Interpolate
InterpolateToNewView(currentViewer, saveVP, newVP);
if (verbosity >= G4VisManager::confirmations) {
G4cout
<< "Viewer \"" << currentViewer->GetName()
<< "\" centred ";
if (fpCommandCentreAndZoomInOn) {
G4cout << "and zoomed in";
}
G4cout << " on touchable\n" << fCurrentTouchableProperties.fTouchablePath
<< G4endl;
}
SetViewParameters(currentViewer, newVP);
} else {
G4cout << "Touchable not found." << G4endl;
}
return;
} else if (command == fpCommandDraw) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
// To handle paramaterisations we have to set the copy number
properties.fpTouchablePV->SetCopyNo(properties.fCopyNo);
G4PhysicalVolumeModel* pvModel = new G4PhysicalVolumeModel
(properties.fpTouchablePV,
G4PhysicalVolumeModel::UNLIMITED,
properties.fTouchableGlobalTransform,
nullptr, // Modelling parameters (not used)
true, // use full extent (prevents calculating own extent, which crashes)
properties.fTouchableBaseFullPVPath);
G4int keepVerbose = UImanager->GetVerboseLevel();
G4int newVerbose(0);
if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
newVerbose = 2;
UImanager->SetVerboseLevel(newVerbose);
UImanager->ApplyCommand("/vis/scene/create");
currentScene = fpVisManager->GetCurrentScene(); // New current scene
G4bool successful = currentScene->AddRunDurationModel(pvModel,warn);
UImanager->ApplyCommand("/vis/sceneHandler/attach");
UImanager->SetVerboseLevel(keepVerbose);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "\"" << properties.fpTouchablePV->GetName()
<< "\", copy no. " << properties.fCopyNo << " drawn"
<< G4endl;
}
} else {
G4VisCommandsSceneAddUnsuccessful(verbosity);
}
} else {
G4cout << "Touchable not found." << G4endl;
}
return;
} else if (command == fpCommandDump) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
// To handle paramaterisations we have to set the copy number
properties.fpTouchablePV->SetCopyNo(properties.fCopyNo);
G4PhysicalVolumeModel tempPVModel
(properties.fpTouchablePV,
G4PhysicalVolumeModel::UNLIMITED,
properties.fTouchableGlobalTransform,
nullptr, // Modelling parameters (not used)
true, // use full extent (prevents calculating own extent, which crashes)
properties.fTouchableBaseFullPVPath);
const std::map<G4String,G4AttDef>* attDefs = tempPVModel.GetAttDefs();
std::vector<G4AttValue>* attValues = tempPVModel.CreateCurrentAttValues();
G4cout << G4AttCheck(attValues,attDefs);
delete attValues;
G4Polyhedron* polyhedron =
properties.fpTouchablePV->GetLogicalVolume()->GetSolid()->GetPolyhedron();
G4cout << "\nLocal polyhedron coordinates:\n" << *polyhedron;
G4Transform3D* transform = pvModel.GetCurrentTransform();
G4Transform3D* transform = tempPVModel.GetCurrentTransform();
polyhedron->Transform(*transform);
G4cout << "\nGlobal polyhedron coordinates:\n" << *polyhedron;
} else {
@@ -121,8 +302,35 @@ void G4VisCommandsTouchable::SetNewValue
}
return;
} else if (command == fpCommandExtentForField) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
G4VisExtent extent
= properties.fpTouchablePV->GetLogicalVolume()->GetSolid()->GetExtent();
extent.Transform(properties.fTouchableGlobalTransform);
fCurrentExtentForField = extent;
fCurrrentPVFindingsForField.clear();
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Extent for field set to " << extent
<< "\nVolume for field has been cleared."
<< G4endl;
}
if (fpCommandExtentForField->GetNewBoolValue(newValue)) {
DrawExtent(extent);
}
} else {
G4cout << "Touchable not found." << G4endl;
}
return;
} else if (command == fpCommandFindPath) {
G4String pvName;
G4int copyNo;
std::istringstream iss(newValue);
iss >> pvName >> copyNo;
std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
transportationManager->GetWorldsIterator();
@@ -130,7 +338,7 @@ void G4VisCommandsTouchable::SetNewValue
G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
G4ModelingParameters mp; // Default - no culling.
searchModel.SetModelingParameters (&mp);
G4PhysicalVolumesSearchScene searchScene (&searchModel, newValue);
G4PhysicalVolumesSearchScene searchScene (&searchModel, pvName, copyNo);
searchModel.DescribeYourselfTo (searchScene); // Initiate search.
for (const auto& findings: searchScene.GetFindings()) {
findingsVector.push_back(findings);
@@ -152,9 +360,53 @@ void G4VisCommandsTouchable::SetNewValue
<< "\nor to see overlaps: \"/vis/drawLogicalVolume <mother-logical-volume-name>\""
<< G4endl;
} else {
G4cout << newValue << " not found" << G4endl;
G4cout << pvName;
if (copyNo >= 0) G4cout << ':' << copyNo;
G4cout << " not found" << G4endl;
}
} else if (command == fpCommandShowExtent) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
G4VisExtent extent
= properties.fpTouchablePV->GetLogicalVolume()->GetSolid()->GetExtent();
extent.Transform(properties.fTouchableGlobalTransform);
G4cout << extent << G4endl;
if (fpCommandShowExtent->GetNewBoolValue(newValue)) DrawExtent(extent);
} else {
G4cout << "Touchable not found." << G4endl;
}
return;
} else if (command == fpCommandVolumeForField) {
G4PhysicalVolumeModel::TouchableProperties properties =
G4TouchableUtils::FindTouchableProperties(fCurrentTouchableProperties.fTouchablePath);
if (properties.fpTouchablePV) {
G4VisExtent extent
= properties.fpTouchablePV->GetLogicalVolume()->GetSolid()->GetExtent();
extent.Transform(properties.fTouchableGlobalTransform);
fCurrentExtentForField = extent;
fCurrrentPVFindingsForField.clear();
fCurrrentPVFindingsForField.push_back
(G4PhysicalVolumesSearchScene::Findings(properties));
if (verbosity >= G4VisManager::confirmations) {
G4cout
<< "Volume for field set to " << properties.fpTouchablePV->GetName()
<< ':' << properties.fCopyNo
<< " at " << properties.fTouchableBaseFullPVPath
<< G4endl;
}
if (fpCommandVolumeForField->GetNewBoolValue(newValue)) {
DrawExtent(extent);
}
} else {
G4cout << "Touchable not found." << G4endl;
}
return;
} else {
if (verbosity >= G4VisManager::errors) {
@@ -94,13 +94,22 @@ G4VisCommandsTouchableSet::G4VisCommandsTouchableSet()
fpCommandSetLineSegmentsPerCircle->SetParameterName("lineSegmentsPerCircle", omitable = true);
fpCommandSetLineSegmentsPerCircle->SetDefaultValue(0);
fpCommandSetForceCloud = new G4UIcmdWithABool
("/vis/touchable/set/forceCloud", this);
fpCommandSetForceCloud->SetGuidance
("Force current touchable always to be drawn as a cloud.");
fpCommandSetForceCloud->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
fpCommandSetForceCloud->SetParameterName("force", omitable = true);
fpCommandSetForceCloud->SetDefaultValue(true);
fpCommandSetForceSolid = new G4UIcmdWithABool
("/vis/touchable/set/forceSolid", this);
fpCommandSetForceSolid->SetGuidance
("Force current touchable always to be drawn solid (surface drawing).");
fpCommandSetForceSolid->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
fpCommandSetForceSolid->SetParameterName("forceSolid", omitable = true);
fpCommandSetForceSolid->SetParameterName("force", omitable = true);
fpCommandSetForceSolid->SetDefaultValue(true);
fpCommandSetForceWireframe = new G4UIcmdWithABool
@@ -129,6 +138,18 @@ G4VisCommandsTouchableSet::G4VisCommandsTouchableSet()
fpCommandSetLineWidth->SetParameterName("lineWidth", omitable = true);
fpCommandSetLineWidth->SetDefaultValue(1.);
fpCommandSetNumberOfCloudPoints = new G4UIcmdWithAnInteger
("/vis/touchable/set/numberOfCloudPoints", this);
fpCommandSetNumberOfCloudPoints->SetGuidance
("For current touchable, set number of line segments per circle, the"
"\nprecision with which a curved line or surface is represented by a"
"\npolygon or polyhedron, regardless of the view parameters."
"\nNegative to pick up G4Polyhedron default value.");
fpCommandSetNumberOfCloudPoints->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
fpCommandSetNumberOfCloudPoints->SetParameterName("lineSegmentsPerCircle", omitable = true);
fpCommandSetNumberOfCloudPoints->SetDefaultValue(0);
fpCommandSetVisibility = new G4UIcmdWithABool
("/vis/touchable/set/visibility", this);
fpCommandSetVisibility->SetGuidance
@@ -141,10 +162,12 @@ G4VisCommandsTouchableSet::G4VisCommandsTouchableSet()
G4VisCommandsTouchableSet::~G4VisCommandsTouchableSet() {
delete fpCommandSetVisibility;
delete fpCommandSetNumberOfCloudPoints;
delete fpCommandSetLineWidth;
delete fpCommandSetLineStyle;
delete fpCommandSetForceWireframe;
delete fpCommandSetForceSolid;
delete fpCommandSetForceCloud;
delete fpCommandSetLineSegmentsPerCircle;
delete fpCommandSetForceAuxEdgeVisible;
delete fpCommandSetDaughtersInvisible;
@@ -217,6 +240,15 @@ void G4VisCommandsTouchableSet::SetNewValue
fCurrentTouchableProperties.fTouchablePath));
}
else if (command == fpCommandSetForceCloud) {
workingVisAtts.SetForceCloud(G4UIcommand::ConvertToBool(newValue));
workingVP.AddVisAttributesModifier
(G4ModelingParameters::VisAttributesModifier
(workingVisAtts,
G4ModelingParameters::VASForceCloud,
fCurrentTouchableProperties.fTouchablePath));
}
else if (command == fpCommandSetForceSolid) {
workingVisAtts.SetForceSolid(G4UIcommand::ConvertToBool(newValue));
workingVP.AddVisAttributesModifier
@@ -225,7 +257,7 @@ void G4VisCommandsTouchableSet::SetNewValue
G4ModelingParameters::VASForceSolid,
fCurrentTouchableProperties.fTouchablePath));
}
else if (command == fpCommandSetForceWireframe) {
workingVisAtts.SetForceWireframe(G4UIcommand::ConvertToBool(newValue));
workingVP.AddVisAttributesModifier
@@ -260,6 +292,16 @@ void G4VisCommandsTouchableSet::SetNewValue
fCurrentTouchableProperties.fTouchablePath));
}
else if (command == fpCommandSetNumberOfCloudPoints) {
workingVisAtts.SetForceNumberOfCloudPoints
(G4UIcommand::ConvertToInt(newValue));
workingVP.AddVisAttributesModifier
(G4ModelingParameters::VisAttributesModifier
(workingVisAtts,
G4ModelingParameters::VASForceNumberOfCloudPoints,
fCurrentTouchableProperties.fTouchablePath));
}
else if (command == fpCommandSetVisibility) {
workingVisAtts.SetVisibility(G4UIcommand::ConvertToBool(newValue));
workingVP.AddVisAttributesModifier
@@ -39,6 +39,8 @@
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4PhysicalVolumesSearchScene.hh"
#include "G4TransportationManager.hh"
#include "G4Point3D.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
@@ -57,33 +59,6 @@
#include <filesystem>
#endif //WIN32
G4VVisCommandViewer::G4VVisCommandViewer () {}
G4VVisCommandViewer::~G4VVisCommandViewer () {}
void G4VVisCommandViewer::SetViewParameters
(G4VViewer* viewer, const G4ViewParameters& viewParams) {
viewer->SetViewParameters(viewParams);
RefreshIfRequired(viewer);
}
void G4VVisCommandViewer::RefreshIfRequired(G4VViewer* viewer) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
const G4ViewParameters& viewParams = viewer->GetViewParameters();
if (sceneHandler && sceneHandler->GetScene()) {
if (viewParams.IsAutoRefresh()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
}
else {
if (verbosity >= G4VisManager::warnings) {
G4cout << "Issue /vis/viewer/refresh or flush to see effect."
<< G4endl;
}
}
}
}
////////////// /vis/viewer/addCutawayPlane ///////////////////////////////////////
G4VisCommandViewerAddCutawayPlane::G4VisCommandViewerAddCutawayPlane () {
@@ -164,6 +139,173 @@ void G4VisCommandViewerAddCutawayPlane::SetNewValue (G4UIcommand*, G4String newV
SetViewParameters(viewer, vp);
}
////////////// /vis/viewer/centreOn ///////////////////////////////////////
G4VisCommandViewerCentreOn::G4VisCommandViewerCentreOn () {
G4bool omitable;
fpCommandCentreAndZoomInOn = new G4UIcommand ("/vis/viewer/centreAndZoomInOn", this);
fpCommandCentreAndZoomInOn->SetGuidance
("Centre and zoom in on the given physical volume.");
fpCommandCentreAndZoomInOn->SetGuidance
("The names of all volumes in all worlds are matched against pv-name. If"
"\ncopy-no is supplied, it matches the copy number too. If pv-name is of the"
"\nform \"/regexp/\", where regexp is a regular expression (see C++ regex),"
"\nthe match uses the usual rules of regular expression matching."
"\nOtherwise an exact match is required."
"\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
fpCommandCentreAndZoomInOn->SetGuidance
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRepFile.");
fpCommandCentreAndZoomInOn->SetGuidance
("If there are more than one matching physical volumes they will all be"
"\nincluded. If this is not what you want, and what you want is to centre on a"
"\nparticular touchable, then select the touchable (\"/vis/set/touchable\") and"
"\nuse \"/vis/touchable/centreOn\". (You may need \"/vis/touchable/findPath\".)");
G4UIparameter* parameter;
parameter = new G4UIparameter("pv-name",'s',omitable = false);
parameter->SetGuidance ("Physical volume name.");
fpCommandCentreAndZoomInOn->SetParameter(parameter);
parameter = new G4UIparameter("copy-no",'i',omitable = true);
parameter->SetDefaultValue (-1);
parameter->SetGuidance ("Copy number. -1 means any or all copy numbers");
fpCommandCentreAndZoomInOn->SetParameter(parameter);
fpCommandCentreOn = new G4UIcommand ("/vis/viewer/centreOn", this);
fpCommandCentreOn->SetGuidance ("Centre the view on the given physical volume.");
// Pick up additional guidance from /vis/viewer/centreAndZoomInOn
CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandCentreOn,1);
// Pick up parameters from /vis/viewer/centreAndZoomInOn
CopyParametersFrom(fpCommandCentreAndZoomInOn,fpCommandCentreOn);
}
G4VisCommandViewerCentreOn::~G4VisCommandViewerCentreOn () {
delete fpCommandCentreAndZoomInOn;
delete fpCommandCentreOn;
}
G4String G4VisCommandViewerCentreOn::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandViewerCentreOn::SetNewValue (G4UIcommand* command, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn = verbosity >= G4VisManager::warnings;
G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
return;
}
G4String pvName;
G4int copyNo;
std::istringstream is (newValue);
is >> pvName >> copyNo;
// Find physical volumes
G4TransportationManager* transportationManager =
G4TransportationManager::GetTransportationManager ();
size_t nWorlds = transportationManager->GetNoWorlds();
std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
transportationManager->GetWorldsIterator();
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
G4ModelingParameters mp; // Default - no culling.
searchModel.SetModelingParameters (&mp);
G4PhysicalVolumesSearchScene searchScene (&searchModel, pvName, copyNo);
searchModel.DescribeYourselfTo (searchScene); // Initiate search.
for (const auto& findings: searchScene.GetFindings()) {
findingsVector.push_back(findings);
}
}
if (findingsVector.empty()) {
if (verbosity >= G4VisManager::warnings) {
G4cerr
<< "WARNING: Volume \"" << pvName << "\" ";
if (copyNo > 0) {
G4cerr << "copy number " << copyNo;
}
G4cerr << " not found." << G4endl;
}
return;
}
// Use a temporary scene in order to find vis extent
G4Scene tempScene("Centre Scene");
for (const auto& findings: findingsVector) {
// To handle paramaterisations we have to set the copy number
findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
// Create a temporary physical volume model.
// They have to be created on the heap because they have
// to hang about long enough to be conflated.
G4PhysicalVolumeModel* tempPVModel = new G4PhysicalVolumeModel
(findings.fpFoundPV,
0, // Only interested in top volume
findings.fFoundObjectTransformation,
0, // No modelling parameters (these are set later by the scene handler).
true, // Use full extent
findings.fFoundBasePVPath);
// ...and add it to the scene.
G4bool successful = tempScene.AddRunDurationModel(tempPVModel,warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "\"" << findings.fpFoundPV->GetName()
<< "\", copy no. " << findings.fFoundPVCopyNo
<< ",\n found in searched volume \""
<< findings.fpSearchPV->GetName()
<< "\" at depth " << findings.fFoundDepth
<< ",\n base path: \"" << findings.fFoundBasePVPath
<< ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
<< G4endl;
}
}
}
// Delete temporary physical volume models
for (const auto& sceneModel: tempScene.GetRunDurationModelList()) {
delete sceneModel.fpModel;
}
// Relevant results
const G4VisExtent& newExtent = tempScene.GetExtent();
const G4ThreeVector& newTargetPoint = newExtent.GetExtentCentre();
G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
G4ViewParameters saveVP = currentViewer->GetViewParameters();
G4ViewParameters newVP = saveVP;
if (command == fpCommandCentreAndZoomInOn) {
// Calculate the new zoom factor
const G4double zoomFactor
= currentScene->GetExtent().GetExtentRadius()/newExtent.GetExtentRadius();
newVP.SetZoomFactor(zoomFactor);
}
// Change the target point
const G4Point3D& standardTargetPoint = currentScene->GetStandardTargetPoint();
newVP.SetCurrentTargetPoint(newTargetPoint - standardTargetPoint);
// Interpolate
InterpolateToNewView(currentViewer, saveVP, newVP);
if (verbosity >= G4VisManager::confirmations) {
G4cout
<< "Viewer \"" << currentViewer->GetName()
<< "\" centred ";
if (fpCommandCentreAndZoomInOn) {
G4cout << "and zoomed in";
}
G4cout << " on physical volume(s) \"" << pvName << '\"'
<< G4endl;
}
SetViewParameters(currentViewer, newVP);
}
////////////// /vis/viewer/changeCutawayPlane ///////////////////////////////////////
G4VisCommandViewerChangeCutawayPlane::G4VisCommandViewerChangeCutawayPlane () {
@@ -1211,7 +1353,10 @@ void G4VisCommandViewerInterpolate::SetNewValue (G4UIcommand*, G4String newValue
while (fileliststream >> pathname
&& safetyCount++ < safety) { // Loop checking, 16.02.2016, J.Allison
uiManager->ApplyCommand("/control/execute " + pathname);
viewVector.push_back(currentViewer->GetViewParameters());
G4ViewParameters vp = currentViewer->GetViewParameters();
// Set original auto-refresh status.
vp.SetAutoRefresh(saveVP.IsAutoRefresh());
viewVector.push_back(vp);
}
}
pclose(filelist);
@@ -1267,7 +1412,10 @@ void G4VisCommandViewerInterpolate::SetNewValue (G4UIcommand*, G4String newValue
if (std::regex_match(filename, result_pattern_regex))
{
uiManager->ApplyCommand("/control/execute " + filename);
viewVector.push_back(currentViewer->GetViewParameters());
G4ViewParameters vp = currentViewer->GetViewParameters();
// Set original auto-refresh status.
vp.SetAutoRefresh(saveVP.IsAutoRefresh());
viewVector.push_back(vp);
}
}
@@ -1283,27 +1431,9 @@ void G4VisCommandViewerInterpolate::SetNewValue (G4UIcommand*, G4String newValue
return;
}
// Interpolate views
safetyCount = 0;
do {
G4ViewParameters* vp =
G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
if (!vp) break; // Finished.
// Set original auto-refresh status.
vp->SetAutoRefresh(saveVP.IsAutoRefresh());
currentViewer->SetViewParameters(*vp);
currentViewer->RefreshView();
if (exportString == "export" &&
currentViewer->GetName().contains("OpenGL")) {
uiManager->ApplyCommand("/vis/ogl/export");
}
// File-writing viewers need to close the file
currentViewer->ShowView();
#ifdef G4VIS_USE_STD11
if (waitTimePerPointmilliseconds > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
#endif
} while (safetyCount++ < safety); // Loop checking, 16.02.2016, J.Allison
InterpolateViews
(currentViewer,viewVector,
nInterpolationPoints,waitTimePerPointmilliseconds,exportString);
// Restore original verbosities
uiManager->SetVerboseLevel(keepUIVerbosity);
@@ -65,31 +65,37 @@ void G4VisCommandViewerDefaultHiddenEdge::SetNewValue(G4UIcommand*, G4String new
G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
if (G4UIcommand::ConvertToBool(newValue)) {
switch (existingStyle) {
case G4ViewParameters::wireframe:
vp.SetDrawingStyle(G4ViewParameters::hlr);
break;
case G4ViewParameters::hlr:
break;
case G4ViewParameters::hsr:
vp.SetDrawingStyle(G4ViewParameters::hlhsr);
break;
case G4ViewParameters::hlhsr:
break;
switch (existingStyle) { // true
case G4ViewParameters::wireframe:
vp.SetDrawingStyle(G4ViewParameters::hlr);
break;
case G4ViewParameters::hlr:
break;
case G4ViewParameters::hsr:
vp.SetDrawingStyle(G4ViewParameters::hlhsr);
break;
case G4ViewParameters::hlhsr:
break;
case G4ViewParameters::cloud:
G4cout << "No effect in cloud style" << G4endl;
break;
}
}
else {
switch (existingStyle) {
case G4ViewParameters::wireframe:
break;
case G4ViewParameters::hlr:
vp.SetDrawingStyle(G4ViewParameters::wireframe);
break;
case G4ViewParameters::hsr:
break;
case G4ViewParameters::hlhsr:
vp.SetDrawingStyle(G4ViewParameters::hsr);
break;
switch (existingStyle) { // false
case G4ViewParameters::wireframe:
break;
case G4ViewParameters::hlr:
vp.SetDrawingStyle(G4ViewParameters::wireframe);
break;
case G4ViewParameters::hsr:
break;
case G4ViewParameters::hlhsr:
vp.SetDrawingStyle(G4ViewParameters::hsr);
break;
case G4ViewParameters::cloud:
G4cout << "No effect in cloud style" << G4endl;
break;
}
}
@@ -109,11 +115,11 @@ G4VisCommandViewerDefaultStyle::G4VisCommandViewerDefaultStyle()
fpCommand = new G4UIcmdWithAString("/vis/viewer/default/style", this);
fpCommand->SetGuidance("Default drawing style for future viewers.");
fpCommand->SetGuidance
("Set style of drawing - w[ireframe] or s[urface].");
("Set style of drawing - w[ireframe] or s[urface] or c[loud].");
fpCommand->SetGuidance
("(Default hidden line drawing is controlled by \"/vis/viewer/default/hiddenEdge\".)");
fpCommand->SetParameterName ("style",omitable = false);
fpCommand->SetCandidates("w wireframe s surface");
fpCommand->SetCandidates("w wireframe s surface c cloud");
}
G4VisCommandViewerDefaultStyle::~G4VisCommandViewerDefaultStyle()
@@ -137,36 +143,60 @@ void G4VisCommandViewerDefaultStyle::SetNewValue(G4UIcommand*, G4String newValue
const size_t iPos0 = 0;
if (newValue[iPos0] == 'w') { // "wireframe"
switch (existingStyle) {
case G4ViewParameters::wireframe:
break;
case G4ViewParameters::hlr:
break;
case G4ViewParameters::hsr:
vp.SetDrawingStyle(G4ViewParameters::wireframe);
break;
case G4ViewParameters::hlhsr:
vp.SetDrawingStyle(G4ViewParameters::hlr);
break;
case G4ViewParameters::wireframe:
break;
case G4ViewParameters::hlr:
break;
case G4ViewParameters::hsr:
vp.SetDrawingStyle(G4ViewParameters::wireframe);
break;
case G4ViewParameters::hlhsr:
vp.SetDrawingStyle(G4ViewParameters::hlr);
break;
case G4ViewParameters::cloud:
vp.SetDrawingStyle(G4ViewParameters::wireframe);
break;
}
}
else if (newValue[iPos0] == 's') { // "surface"
switch (existingStyle) {
case G4ViewParameters::wireframe:
vp.SetDrawingStyle(G4ViewParameters::hsr);
break;
case G4ViewParameters::hlr:
vp.SetDrawingStyle(G4ViewParameters::hlhsr);
break;
case G4ViewParameters::hsr:
break;
case G4ViewParameters::hlhsr:
break;
case G4ViewParameters::wireframe:
vp.SetDrawingStyle(G4ViewParameters::hsr);
break;
case G4ViewParameters::hlr:
vp.SetDrawingStyle(G4ViewParameters::hlhsr);
break;
case G4ViewParameters::hsr:
break;
case G4ViewParameters::hlhsr:
break;
case G4ViewParameters::cloud:
vp.SetDrawingStyle(G4ViewParameters::hsr);
break;
}
}
else if (newValue[iPos0] == 'c') { // "cloud"
switch (existingStyle) {
case G4ViewParameters::wireframe:
vp.SetDrawingStyle(G4ViewParameters::cloud);
break;
case G4ViewParameters::hlr:
vp.SetDrawingStyle(G4ViewParameters::cloud);
break;
case G4ViewParameters::hsr:
vp.SetDrawingStyle(G4ViewParameters::cloud);
break;
case G4ViewParameters::hlhsr:
vp.SetDrawingStyle(G4ViewParameters::cloud);
break;
case G4ViewParameters::cloud:
break;
}
}
else {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: \"" << newValue << "\" not recognised."
" Looking for 'w' or 's' first character." << G4endl;
" Looking for 'w' or 's' or 'c' first character." << G4endl;
}
return;
}
File diff suppressed because it is too large Load Diff
@@ -26,6 +26,7 @@
//
//
// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
// Michael Kelsey 31 Jan 2019 -- Add new command for electric field
#include "G4VisManager.hh"
@@ -496,12 +497,14 @@ void G4VisManager::RegisterMessengers () {
fDirectoryList.push_back (directory);
RegisterMessenger(new G4VisCommandSetArrow3DLineSegmentsPerCircle);
RegisterMessenger(new G4VisCommandSetColour);
RegisterMessenger(new G4VisCommandSetExtentForField);
RegisterMessenger(new G4VisCommandSetLineWidth);
RegisterMessenger(new G4VisCommandSetTextColour);
RegisterMessenger(new G4VisCommandSetTextLayout);
RegisterMessenger(new G4VisCommandSetTextSize);
RegisterMessenger(new G4VisCommandSetTouchable);
RegisterMessenger(new G4VisCommandSetVolumeForField);
directory = new G4UIdirectory ("/vis/scene/");
directory -> SetGuidance ("Operations on Geant4 scenes.");
fDirectoryList.push_back (directory);
@@ -512,7 +515,8 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSceneList);
RegisterMessenger(new G4VisCommandSceneNotifyHandlers);
RegisterMessenger(new G4VisCommandSceneSelect);
RegisterMessenger(new G4VisCommandSceneShowExtents);
directory = new G4UIdirectory ("/vis/scene/add/");
directory -> SetGuidance ("Add model to current scene.");
fDirectoryList.push_back (directory);
@@ -523,6 +527,7 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSceneAddDigis);
RegisterMessenger(new G4VisCommandSceneAddEventID);
RegisterMessenger(new G4VisCommandSceneAddExtent);
RegisterMessenger(new G4VisCommandSceneAddElectricField);
RegisterMessenger(new G4VisCommandSceneAddFrame);
RegisterMessenger(new G4VisCommandSceneAddGPS);
RegisterMessenger(new G4VisCommandSceneAddHits);
@@ -562,6 +567,7 @@ void G4VisManager::RegisterMessengers () {
directory -> SetGuidance ("Operations on Geant4 viewers.");
fDirectoryList.push_back (directory);
RegisterMessenger(new G4VisCommandViewerAddCutawayPlane);
RegisterMessenger(new G4VisCommandViewerCentreOn);
RegisterMessenger(new G4VisCommandViewerChangeCutawayPlane);
RegisterMessenger(new G4VisCommandViewerClear);
RegisterMessenger(new G4VisCommandViewerClearCutawayPlanes);
@@ -1404,6 +1410,11 @@ void G4VisManager::RegisterRunDurationUserVisAction
<< G4endl;
}
}
if (fVerbosity >= confirmations) {
G4cout
<< "Run duration user vis action \"" << name << "\" registered"
<< G4endl;
}
}
void G4VisManager::RegisterEndOfEventUserVisAction
@@ -1420,6 +1431,11 @@ void G4VisManager::RegisterEndOfEventUserVisAction
<< G4endl;
}
}
if (fVerbosity >= confirmations) {
G4cout
<< "End of event user vis action \"" << name << "\" registered"
<< G4endl;
}
}
void G4VisManager::RegisterEndOfRunUserVisAction
@@ -1436,6 +1452,11 @@ void G4VisManager::RegisterEndOfRunUserVisAction
<< G4endl;
}
}
if (fVerbosity >= confirmations) {
G4cout
<< "End of run user vis action \"" << name << "\" registered"
<< G4endl;
}
}
void G4VisManager::SetCurrentScene (G4Scene* pScene) {
@@ -1884,6 +1905,12 @@ void G4VisManager::BeginOfRun ()
if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisRun(false);
fNoOfEventsDrawnThisRun = 0;
// Check to see if the user has created a trajectory model. If not, create
// a default one. To avoid code duplication the following function is used
// and its result (a const G4VTrajectoryModel*) is thrown away at this point.
// The function is called again later when needed.
CurrentTrajDrawModel();
#ifdef G4MULTITHREADED
// There is a static method G4Threading::IsMultithreadedApplication()
// that returns true only if G4MTRunManager is instantiated with MT
@@ -2206,7 +2233,7 @@ void G4VisManager::EndOfRun ()
if (events) nKeptEvents = events->size();
if (nKeptEvents && !fKeptLastEvent) {
if (fVerbosity >= warnings) {
G4cout << "WARNING: " << nKeptEvents;
G4cout << nKeptEvents;
if (nKeptEvents == 1) G4cout << " event has";
else G4cout << " events have";
G4cout << " been kept for refreshing and/or reviewing." << G4endl;