Import Geant4 11.4.0.beta source tree
This commit is contained in:
@@ -6,6 +6,97 @@ It must **not** be used as a substitute for writing good git commit messages!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
## 2025-04-13 John Allison (modeling-V11-03-08)
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
- Fix typo in ModelType.
|
||||
|
||||
## 2025-02-28 John Allison (modeling-V11-03-07)
|
||||
- G4TrajectoryDrawerUtils.cc:
|
||||
- Trap trajectories with very long global times, e.g, products of long-lived
|
||||
radioactive isotopes.
|
||||
- Draw as non-time-sliced trajectories.
|
||||
|
||||
## 2025-02-24 John Allison (modeling-V11-03-06)
|
||||
- G4ModelingParameters.hh:
|
||||
- Implement G4ModelingParameters::TimeParameters::operaator!=.
|
||||
- G4TrajectoryDrawerUtils.cc"
|
||||
- Fix bug in fade algorithm.
|
||||
|
||||
## 2025-02-22 John Allison (modeling-V11-03-05)
|
||||
- G4ModelingParameters.hh:
|
||||
- TimeParameters:
|
||||
- Adjust defaul values:
|
||||
- Set fade factor to 1 (maximum fading) - see G4TrajectoryDrawerUtils.cc.
|
||||
- Set head time display 2D x-coordinate to zero (centre).
|
||||
- 2D y-coordinate remains at -0.9 (bottom).
|
||||
- G4TrajectoriesModel.cc:
|
||||
- DescribeYourselfTo(sceneHandler):
|
||||
- Draw display head time if requested and if time windowing is active.
|
||||
- This is outside the loop over trajectories - it is drawn only once per
|
||||
processing of the scene.
|
||||
- Remove Begin/EndDraw around the trajectories loop.
|
||||
- It restricted what could be drawn inside the loop, for example 2D text,
|
||||
and anyway doesn't seem to make much speed improvement.
|
||||
- G4TrajectoryDrawerUtils.cc:
|
||||
- Add fading of trajectory slices if time windowing is active.
|
||||
- Makes trajectory slices look like little meteors streaking across
|
||||
the screen.
|
||||
|
||||
## 2025-02-10 John Allison (modeling-V11-03-04)
|
||||
- G4TrajectoryDrawerUtils.cc:
|
||||
- First version of generic time windowing of trajectory slices.
|
||||
- Draws only slices within the viewer time window.
|
||||
- Takes advantage of recent ability to access modeling parameters via
|
||||
static GetCurrentModelingParameters().
|
||||
- Also of recently added G4RichTrajectoryPoint::GetPre/PostStepPointGlobalTime().
|
||||
- Note: unless the viewer can handled time-sliced trajectories (only OGLS can
|
||||
do this at present), the viewer must request a kernel visit on change of
|
||||
viewer time window.
|
||||
- G4TrajectoryDrawByEncounteredVolume.cc, G4TrajectoryEncounteredVolumeFilter.cc:
|
||||
- Use G4VTrajectory::GetAttValues() instead of CreateAttValues().
|
||||
- GetAttValues() caches the att values and so speeds repeated visits.
|
||||
|
||||
## 2025-02-04 John Allison (modeling-V11-03-03)
|
||||
- G4VModel:
|
||||
- Introduce static data member const G4ModelinParameters* fpCurrentMP
|
||||
and its static accessor, GetCurrentModelingParameters().
|
||||
- Its value is expected to be identical to fpMP set in the scene
|
||||
handler, but to avoid linking problems, it must *not* be set on
|
||||
the vis side; it must be set in modeling by any model that
|
||||
requires it, G4TrajectoriesModel.
|
||||
- G4TrajectoriesModel.cc:
|
||||
- Call SetCurrentModelingParameters.
|
||||
|
||||
## 2025-02-01 John Allison (modeling-V11-03-02)
|
||||
- G4TrajectoryDrawerUtils.cc:
|
||||
- Clang format (just formatting - no other changes).
|
||||
- G4ModelingParameters.cc:
|
||||
- Coverity fix: uninitialised data member.
|
||||
|
||||
## 2025-01-28 John Allison (modeling-V11-03-01)
|
||||
- G4ModelingParameters.hh and .icc:
|
||||
- Add struct TimeParameters to G4ModelingParameters.
|
||||
- This is a prerequisite for "Generic Time-Slicing" for the display of the time
|
||||
evolution of event(s). With that feature, the display of tracks moving through
|
||||
time will be available to all vis drivers. (Drivers will still be alllowed to
|
||||
implement their own time evolution.)
|
||||
- This MR simply adds the structure to modeling parameters and implements access
|
||||
functions for the use of future MRs.
|
||||
|
||||
## 2025-01-06 John Allison (modeling-V11-03-00)
|
||||
- Co-works: visman-V11-03-00, interfaces-V11-03-00, opengl-V11-03-00,
|
||||
visQt3D-V11-03-00, vis_toolssg-V11-03-00, openinventor-V11-03-00,
|
||||
greps-V11-03-00.
|
||||
- Re-instate the transparency slider (see lengthy explanation in management/History).
|
||||
- G4ModelingParameters:
|
||||
- Add TransparencyByDepth and TransparencyByDepthOption.
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
- Rename some data members and access functions for clarity.
|
||||
- Distinguish fTotalDrawnTouchables and fTotalAllTouchables.
|
||||
- Add fMaxFullDepth (includes base path, i.e., from world volume).
|
||||
- Add code for processing transparency by depth.
|
||||
- Tidy - mainly improved indentation.
|
||||
|
||||
## 2024-10-22 John Allison (modeling-V11-02-05)
|
||||
- G4PhysicalVolumeModel.cc:
|
||||
- Fixed some ragged indentations.
|
||||
|
||||
@@ -144,6 +144,49 @@ public: // With description
|
||||
PVNameCopyNoPath fPVNameCopyNoPath;
|
||||
};
|
||||
|
||||
struct TimeParameters {
|
||||
G4double fStartTime = -G4VisAttributes::fVeryLongTime; // ) Start and end time of drawn range,
|
||||
G4double fEndTime = G4VisAttributes::fVeryLongTime; // ) e.g., for trajectory steps.
|
||||
G4double fFadeFactor = 1.; // 0: no fade; 1: maximum fade with time within range.
|
||||
G4bool fDisplayHeadTime = false; // Display head time (fEndTime) in 2D text.
|
||||
G4double fDisplayHeadTimeX = 0.0; // ) 2D screen coords of head time,
|
||||
G4double fDisplayHeadTimeY = -0.9; // ) bottom-middle of view.
|
||||
G4double fDisplayHeadTimeSize = 24.; // Screen size (pixels) of the head time writing.
|
||||
G4double fDisplayHeadTimeRed = 0.; // )
|
||||
G4double fDisplayHeadTimeGreen = 1.; // ) Default colour of head time writing (cyan)
|
||||
G4double fDisplayHeadTimeBlue = 1.; // )
|
||||
G4bool fDisplayLightFront = false; // Display light front at head time originating at...
|
||||
G4double fDisplayLightFrontX = 0.; // )
|
||||
G4double fDisplayLightFrontY = 0.; // ) ...default coordinates and time of origin
|
||||
G4double fDisplayLightFrontZ = 0.; // ) of light front drawing...
|
||||
G4double fDisplayLightFrontT = 0.; // )
|
||||
G4double fDisplayLightFrontRed = 0.; // )
|
||||
G4double fDisplayLightFrontGreen = 1.; // ) ...in this default colour (green)
|
||||
G4double fDisplayLightFrontBlue = 0.; // )
|
||||
G4bool operator != (const TimeParameters& rhs) const {
|
||||
if (fStartTime != rhs.fStartTime ||
|
||||
fEndTime != rhs.fEndTime ||
|
||||
fFadeFactor != rhs.fFadeFactor ||
|
||||
fDisplayHeadTime != rhs.fDisplayHeadTime ||
|
||||
fDisplayHeadTimeX != rhs.fDisplayHeadTimeX ||
|
||||
fDisplayHeadTimeY != rhs.fDisplayHeadTimeY ||
|
||||
fDisplayHeadTimeSize != rhs.fDisplayHeadTimeSize ||
|
||||
fDisplayHeadTimeRed != rhs.fDisplayHeadTimeRed ||
|
||||
fDisplayHeadTimeGreen != rhs.fDisplayHeadTimeGreen ||
|
||||
fDisplayHeadTimeBlue != rhs.fDisplayHeadTimeBlue ||
|
||||
fDisplayLightFront != rhs.fDisplayLightFront ||
|
||||
fDisplayLightFrontX != rhs.fDisplayLightFrontX ||
|
||||
fDisplayLightFrontY != rhs.fDisplayLightFrontY ||
|
||||
fDisplayLightFrontZ != rhs.fDisplayLightFrontZ ||
|
||||
fDisplayLightFrontT != rhs.fDisplayLightFrontT ||
|
||||
fDisplayLightFrontRed != rhs.fDisplayLightFrontRed ||
|
||||
fDisplayLightFrontGreen != rhs.fDisplayLightFrontGreen ||
|
||||
fDisplayLightFrontBlue != rhs.fDisplayLightFrontBlue
|
||||
) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
G4ModelingParameters ();
|
||||
|
||||
G4ModelingParameters (const G4VisAttributes* pDefaultVisAttributes,
|
||||
@@ -183,8 +226,11 @@ public: // With description
|
||||
G4DisplacedSolid* GetCutawaySolid () const;
|
||||
const G4Event* GetEvent () const;
|
||||
const std::vector<VisAttributesModifier>& GetVisAttributesModifiers() const;
|
||||
const TimeParameters& GetTimeParameters () const;
|
||||
G4bool IsSpecialMeshRendering () const;
|
||||
const std::vector<PVNameCopyNo>& GetSpecialMeshVolumes() const;
|
||||
const std::vector<PVNameCopyNo>& GetSpecialMeshVolumes () const;
|
||||
G4double GetTransparencyByDepth () const;
|
||||
G4int GetTransparencyByDepthOption () const;
|
||||
|
||||
// Set functions...
|
||||
void SetWarning (G4bool);
|
||||
@@ -206,8 +252,11 @@ public: // With description
|
||||
void SetCutawaySolid (G4DisplacedSolid* pCutawaySolid);
|
||||
void SetEvent (const G4Event* pEvent);
|
||||
void SetVisAttributesModifiers(const std::vector<VisAttributesModifier>&);
|
||||
void SetTimeParameters (const TimeParameters&);
|
||||
void SetSpecialMeshRendering (G4bool);
|
||||
void SetSpecialMeshVolumes (const std::vector<PVNameCopyNo>&);
|
||||
void SetTransparencyByDepth (G4double);
|
||||
void SetTransparencyByDepthOption(G4int);
|
||||
|
||||
friend std::ostream& operator <<
|
||||
(std::ostream& os, const G4ModelingParameters&);
|
||||
@@ -245,8 +294,11 @@ private:
|
||||
G4DisplacedSolid* fpCutawaySolid; // For generic cutaways.
|
||||
const G4Event* fpEvent; // Event being processed.
|
||||
std::vector<VisAttributesModifier> fVisAttributesModifiers;
|
||||
TimeParameters fTimeParameters; // Time parameters (for time-slicing).
|
||||
G4bool fSpecialMeshRendering; // Request special rendering of parameterised volumes
|
||||
std::vector<PVNameCopyNo> fSpecialMeshVolumes; // If empty, all meshes.
|
||||
G4double fTransparencyByDepth; // Transparency ~= (geometry depth) - fTransparencyByDepth
|
||||
G4int fTransparencyByDepthOption; // Its option
|
||||
};
|
||||
|
||||
std::ostream& operator <<
|
||||
|
||||
@@ -108,6 +108,10 @@ G4ModelingParameters::GetVisAttributesModifiers() const {
|
||||
return fVisAttributesModifiers;
|
||||
}
|
||||
|
||||
inline const G4ModelingParameters::TimeParameters&
|
||||
G4ModelingParameters::GetTimeParameters () const
|
||||
{return fTimeParameters;}
|
||||
|
||||
inline G4bool G4ModelingParameters::IsSpecialMeshRendering () const
|
||||
{return fSpecialMeshRendering;}
|
||||
|
||||
@@ -115,6 +119,14 @@ inline const std::vector<G4ModelingParameters::PVNameCopyNo>&
|
||||
G4ModelingParameters::GetSpecialMeshVolumes() const
|
||||
{return fSpecialMeshVolumes;}
|
||||
|
||||
inline G4double G4ModelingParameters::GetTransparencyByDepth () const {
|
||||
return fTransparencyByDepth;
|
||||
}
|
||||
|
||||
inline G4int G4ModelingParameters::GetTransparencyByDepthOption () const {
|
||||
return fTransparencyByDepthOption;
|
||||
}
|
||||
|
||||
inline void G4ModelingParameters::SetWarning (G4bool value) {
|
||||
fWarning = value;
|
||||
}
|
||||
@@ -181,9 +193,22 @@ inline void G4ModelingParameters::SetVisAttributesModifiers
|
||||
fVisAttributesModifiers = vams;
|
||||
}
|
||||
|
||||
inline void G4ModelingParameters::SetTimeParameters
|
||||
(const G4ModelingParameters::TimeParameters& timeParameters) {
|
||||
fTimeParameters = timeParameters;
|
||||
}
|
||||
|
||||
inline void G4ModelingParameters::SetSpecialMeshRendering (G4bool smr)
|
||||
{fSpecialMeshRendering = smr;}
|
||||
|
||||
inline void G4ModelingParameters::SetSpecialMeshVolumes
|
||||
(const std::vector<G4ModelingParameters::PVNameCopyNo>& smvs)
|
||||
{fSpecialMeshVolumes = smvs;}
|
||||
|
||||
inline void G4ModelingParameters::SetTransparencyByDepth (G4double transparencyByDepth) {
|
||||
fTransparencyByDepth = transparencyByDepth;
|
||||
}
|
||||
|
||||
inline void G4ModelingParameters::SetTransparencyByDepthOption (G4int option) {
|
||||
fTransparencyByDepthOption = option;
|
||||
}
|
||||
|
||||
@@ -242,11 +242,20 @@ public: // With description
|
||||
// G4VTrajectory::ShowTrajectory for an example of the use of
|
||||
// G4Atts.
|
||||
|
||||
const std::map<G4int,G4int>& GetNumberOfTouchables() const {return fNTouchables;}
|
||||
const std::map<G4int,G4int>& GetMapOfDrawnTouchables() const {return fMapDrawnTouchables;}
|
||||
// Number of touchables drawn at each depth.
|
||||
|
||||
G4int GetTotalTouchables () {return fTotalTouchables;}
|
||||
// Total numbere of touchables.
|
||||
G4int GetTotalDrawnTouchables () {return fTotalDrawnTouchables;}
|
||||
// Total number of touchables drawn.
|
||||
|
||||
G4int GetMaxFullDepth () const {return fMaxFullDepth;}
|
||||
// Including base path, i.e., from the world volume
|
||||
|
||||
const std::map<G4int,G4int>& GetMapOfAllTouchables() const {return fMapAllTouchables;}
|
||||
// Number of all touchables at each depth.
|
||||
|
||||
G4int GetTotalAllTouchables () {return fTotalAllTouchables;}
|
||||
// Total number of touchables.
|
||||
|
||||
void SetRequestedDepth (G4int requestedDepth) {
|
||||
fRequestedDepth = requestedDepth;
|
||||
@@ -315,8 +324,12 @@ protected:
|
||||
G4VSolid* fpClippingSolid;
|
||||
ClippingMode fClippingMode;
|
||||
G4int fNClippers; // No of clipping/cutting solids - only 0 or 1 allowed
|
||||
std::map<G4int,G4int> fNTouchables; // No of touchables at each depth
|
||||
G4int fTotalTouchables;
|
||||
std::map<G4int,G4int> fMapDrawnTouchables; // No of touchables drawn at each depth
|
||||
G4int fTotalDrawnTouchables;
|
||||
std::map<G4int,G4int> fMapAllTouchables; // No of all touchables at each depth
|
||||
G4int fTotalAllTouchables;
|
||||
G4int fMaxFullDepth; // Including base path, i.e., from the world volume
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -34,6 +34,13 @@
|
||||
// graphics-system-indepedent description of a Geant4 component.
|
||||
// The key fuctionality of a model is to know how to describe itself
|
||||
// to a scene handler. A scene is a collection of models.
|
||||
//
|
||||
// The static data member const fpCurrentMP is provided so that it
|
||||
// can be access statically: G4VModel::GetCurrentModelingParameters().
|
||||
// Its value is expected to be identical to fpMP set in the scene
|
||||
// handler, but to avoid linking problems, it must *not* be set on
|
||||
// the vis side; it must be set in modeling by any model that
|
||||
// requires it, G4TrajectoriesModel.
|
||||
|
||||
#ifndef G4VMODEL_HH
|
||||
#define G4VMODEL_HH
|
||||
@@ -58,6 +65,8 @@ public: // With description
|
||||
// The main task of a model is to describe itself to the graphics scene.
|
||||
|
||||
const G4ModelingParameters* GetModelingParameters () const;
|
||||
static const G4ModelingParameters* GetCurrentModelingParameters ();
|
||||
// The latter for static access
|
||||
|
||||
const G4String& GetType() const;
|
||||
// The sub-class should set its type, which could be the class
|
||||
@@ -81,6 +90,7 @@ public: // With description
|
||||
|
||||
// Set methods for above...
|
||||
void SetModelingParameters (const G4ModelingParameters*);
|
||||
static void SetCurrentModelingParameters (const G4ModelingParameters*);
|
||||
void SetExtent (const G4VisExtent&);
|
||||
void SetType (const G4String&);
|
||||
void SetGlobalDescription (const G4String&);
|
||||
@@ -103,6 +113,8 @@ private:
|
||||
// assignment not allowed. Keeps CodeWizard happy.
|
||||
G4VModel (const G4VModel&);
|
||||
G4VModel& operator = (const G4VModel&);
|
||||
|
||||
static const G4ModelingParameters* fpCurrentMP;
|
||||
};
|
||||
|
||||
#include "G4VModel.icc"
|
||||
|
||||
@@ -60,7 +60,9 @@ G4ModelingParameters::G4ModelingParameters ():
|
||||
fCutawayMode (cutawayUnion),
|
||||
fpCutawaySolid (0),
|
||||
fpEvent (0),
|
||||
fSpecialMeshRendering (false)
|
||||
fSpecialMeshRendering (false),
|
||||
fTransparencyByDepth (0.),
|
||||
fTransparencyByDepthOption (1)
|
||||
{}
|
||||
|
||||
G4ModelingParameters::G4ModelingParameters
|
||||
@@ -89,7 +91,9 @@ G4ModelingParameters::G4ModelingParameters
|
||||
fCutawayMode (cutawayUnion),
|
||||
fpCutawaySolid (0),
|
||||
fpEvent (0),
|
||||
fSpecialMeshRendering (false)
|
||||
fSpecialMeshRendering (false),
|
||||
fTransparencyByDepth (0.),
|
||||
fTransparencyByDepthOption (1)
|
||||
{}
|
||||
|
||||
G4ModelingParameters::~G4ModelingParameters ()
|
||||
@@ -255,11 +259,14 @@ std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp)
|
||||
} else {
|
||||
os << "selected meshes";
|
||||
for (const auto& vol: mp.fSpecialMeshVolumes) {
|
||||
os << "\n " << vol.GetName() << ':' << vol.GetCopyNo();
|
||||
os << "\n " << vol.GetName() << ':' << vol.GetCopyNo();
|
||||
}
|
||||
}
|
||||
} else os << "off";
|
||||
|
||||
os << "\nTransparency by depth: " << mp.fTransparencyByDepth
|
||||
<< ", option: " << mp.fTransparencyByDepthOption;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -283,7 +290,9 @@ G4bool G4ModelingParameters::operator !=
|
||||
(fCutawayMode != mp.fCutawayMode) ||
|
||||
(fpCutawaySolid != mp.fpCutawaySolid) ||
|
||||
(fpEvent != mp.fpEvent) ||
|
||||
(fSpecialMeshRendering != mp.fSpecialMeshRendering)
|
||||
(fSpecialMeshRendering != mp.fSpecialMeshRendering) ||
|
||||
(fTransparencyByDepth != mp.fTransparencyByDepth) ||
|
||||
(fTransparencyByDepthOption != mp.fTransparencyByDepthOption)
|
||||
)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#define G4warn G4cout
|
||||
|
||||
@@ -83,7 +85,9 @@ G4PhysicalVolumeModel::G4PhysicalVolumeModel
|
||||
, fpClippingSolid (0)
|
||||
, fClippingMode (subtraction)
|
||||
, fNClippers (0)
|
||||
, fTotalTouchables (0)
|
||||
, fTotalDrawnTouchables (0)
|
||||
, fTotalAllTouchables(0)
|
||||
, fMaxFullDepth (0)
|
||||
{
|
||||
fType = "G4PhysicalVolumeModel";
|
||||
|
||||
@@ -221,7 +225,8 @@ void G4PhysicalVolumeModel::DescribeYourselfTo
|
||||
|
||||
G4Transform3D startingTransformation = fTransform;
|
||||
|
||||
fNTouchables.clear(); // Keeps count of touchable drawn at each depth
|
||||
fMapDrawnTouchables.clear(); // Keeps count of touchables drawn at each depth
|
||||
fMapAllTouchables.clear(); // Keeps count of all touchables at each depth
|
||||
|
||||
VisitGeometryAndGetVisReps
|
||||
(fpTopPV,
|
||||
@@ -229,9 +234,14 @@ void G4PhysicalVolumeModel::DescribeYourselfTo
|
||||
startingTransformation,
|
||||
sceneHandler);
|
||||
|
||||
fTotalTouchables = 0;
|
||||
for (const auto& entry : fNTouchables) {
|
||||
fTotalTouchables += entry.second;
|
||||
fTotalDrawnTouchables = 0;
|
||||
for (const auto& entry : fMapDrawnTouchables) {
|
||||
fTotalDrawnTouchables += entry.second;
|
||||
}
|
||||
|
||||
fTotalAllTouchables = 0;
|
||||
for (const auto& entry : fMapAllTouchables) {
|
||||
fTotalAllTouchables += entry.second;
|
||||
}
|
||||
|
||||
// Reset or clear data...
|
||||
@@ -520,7 +530,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// Create a vis atts object for the modified vis atts.
|
||||
// It is static so that we may return a reliable pointer to it.
|
||||
static G4VisAttributes modifiedVisAtts;
|
||||
// Initialise it with the current vis atts and reset the pointer.
|
||||
// Initialise it with the current operational vis atts and reset the pointer.
|
||||
modifiedVisAtts = *pVisAttribs;
|
||||
pVisAttribs = &modifiedVisAtts;
|
||||
const G4VisAttributes& transVisAtts = vam.GetVisAttributes();
|
||||
@@ -629,6 +639,50 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
}
|
||||
}
|
||||
|
||||
auto currentFullDepth = fCurrentDepth + (G4int)fBaseFullPVPath.size();
|
||||
|
||||
// Respect transparency by depth set by user
|
||||
const auto& transparencyByDepthParameter = fpMP->GetTransparencyByDepth();
|
||||
const auto& maxDepth = sceneHandler.GetMaxGeometryDepth();
|
||||
if (transparencyByDepthParameter > 0 && maxDepth > 0) {
|
||||
const auto& option = fpMP->GetTransparencyByDepthOption();
|
||||
G4double alpha = 1.; // Multiplies pre-existing opacity
|
||||
switch (option) {
|
||||
case 1: { // Unwrap - simply make invisible by depth
|
||||
if (currentFullDepth <= transparencyByDepthParameter) alpha = 0.;
|
||||
break;
|
||||
}
|
||||
case 2: { // Fade a layer at a time
|
||||
alpha = currentFullDepth - transparencyByDepthParameter;
|
||||
alpha = std::min(1.,std::max(0.,alpha));
|
||||
break;
|
||||
}
|
||||
case 3: { // X-ray: progressive transparancy throughout depth
|
||||
// Algorithm by Andrea Barresi January 2025.
|
||||
// Linear function from 0 to 1 in the [0,maxdepth] range
|
||||
// Shift according to k value so that:
|
||||
// alpha = 1 for all volumes when k = 0,
|
||||
// alpha = 0 for all volumes when k = maxDepth.
|
||||
const auto& k = transparencyByDepthParameter;
|
||||
alpha = G4double(currentFullDepth) / maxDepth - 2 * k / maxDepth + 1;
|
||||
alpha = std::min(1., std::max(0., alpha));
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
if (alpha < 1.) {
|
||||
// As above, create a vis atts object for the modified vis atts.
|
||||
// It is static so that we may return a reliable pointer to it.
|
||||
static G4VisAttributes transparencyByDepthVisAtts;
|
||||
// Initialise it with the current operational vis atts and reset the pointer.
|
||||
transparencyByDepthVisAtts = *pVisAttribs;
|
||||
pVisAttribs = &transparencyByDepthVisAtts;
|
||||
// Adjust the transparency (multiply any existing opacity)
|
||||
auto colour = pVisAttribs->GetColour();
|
||||
colour.SetAlpha(colour.GetAlpha()*alpha);
|
||||
transparencyByDepthVisAtts.SetColour(colour);
|
||||
}
|
||||
}
|
||||
|
||||
// Make decision to draw...
|
||||
G4bool thisToBeDrawn = true;
|
||||
|
||||
@@ -661,11 +715,16 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// Set "drawn" flag (it was true by default) - thisToBeDrawn may be false
|
||||
nodeID.SetDrawn(thisToBeDrawn);
|
||||
|
||||
fMapAllTouchables[currentFullDepth]++; // Increment for every touchable at each depth
|
||||
if (fMaxFullDepth < currentFullDepth) fMaxFullDepth = currentFullDepth;
|
||||
|
||||
if (thisToBeDrawn) {
|
||||
|
||||
// Update path of drawn physical volumes...
|
||||
fDrawnPVPath.push_back(nodeID);
|
||||
|
||||
fMapDrawnTouchables[currentFullDepth]++; // Increment for every touchable drawn at each depth
|
||||
|
||||
if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
|
||||
// For top-level drawn volumes, explode along radius...
|
||||
G4Transform3D centering = G4Translate3D(fpMP->GetExplodeCentre());
|
||||
@@ -676,15 +735,12 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
centred.getDecomposition(oldScale, oldRotation, oldTranslation);
|
||||
G4double explodeFactor = fpMP->GetExplodeFactor();
|
||||
G4Translate3D newTranslation =
|
||||
G4Translate3D(explodeFactor * oldTranslation.dx(),
|
||||
explodeFactor * oldTranslation.dy(),
|
||||
explodeFactor * oldTranslation.dz());
|
||||
G4Translate3D(explodeFactor * oldTranslation.dx(),
|
||||
explodeFactor * oldTranslation.dy(),
|
||||
explodeFactor * oldTranslation.dz());
|
||||
theNewAT = centering * newTranslation * oldRotation * oldScale;
|
||||
}
|
||||
|
||||
auto fullDepth = fCurrentDepth + (G4int)fBaseFullPVPath.size();
|
||||
fNTouchables[fullDepth]++; // Increment for every touchable drawn at each depth
|
||||
|
||||
DescribeSolid (theNewAT, pSol, pVisAttribs, sceneHandler);
|
||||
|
||||
}
|
||||
@@ -712,13 +768,13 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// parameters...
|
||||
G4bool cullingCovered = fpMP->IsCullingCovered();
|
||||
G4bool surfaceDrawing =
|
||||
fpMP->GetDrawingStyle() == G4ModelingParameters::hsr ||
|
||||
fpMP->GetDrawingStyle() == G4ModelingParameters::hlhsr;
|
||||
fpMP->GetDrawingStyle() == G4ModelingParameters::hsr ||
|
||||
fpMP->GetDrawingStyle() == G4ModelingParameters::hlhsr;
|
||||
if (pVisAttribs->IsForceDrawingStyle()) {
|
||||
switch (pVisAttribs->GetForcedDrawingStyle()) {
|
||||
default:
|
||||
case G4VisAttributes::wireframe: surfaceDrawing = false; break;
|
||||
case G4VisAttributes::solid: surfaceDrawing = true; break;
|
||||
default:
|
||||
case G4VisAttributes::wireframe: surfaceDrawing = false; break;
|
||||
case G4VisAttributes::solid: surfaceDrawing = true; break;
|
||||
}
|
||||
}
|
||||
G4bool opaque = pVisAttribs->GetColour().GetAlpha() >= 1.;
|
||||
@@ -726,19 +782,19 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
if (culling) {
|
||||
// 6) ..and culling of invisible volumes is on...
|
||||
if (cullingInvisible) {
|
||||
// 7) ...and the mother requests daughters invisible
|
||||
if (daughtersInvisible) daughtersToBeDrawn = false;
|
||||
// 7) ...and the mother requests daughters invisible
|
||||
if (daughtersInvisible) daughtersToBeDrawn = false;
|
||||
}
|
||||
// 8) Or culling of covered daughters is requested...
|
||||
if (cullingCovered) {
|
||||
// 9) ...and surface drawing is operating...
|
||||
if (surfaceDrawing) {
|
||||
// 10) ...but only if mother is visible...
|
||||
if (thisToBeDrawn) {
|
||||
// 11) ...and opaque...
|
||||
if (opaque) daughtersToBeDrawn = false;
|
||||
}
|
||||
}
|
||||
// 9) ...and surface drawing is operating...
|
||||
if (surfaceDrawing) {
|
||||
// 10) ...but only if mother is visible...
|
||||
if (thisToBeDrawn) {
|
||||
// 11) ...and opaque...
|
||||
if (opaque) daughtersToBeDrawn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -750,7 +806,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
// Descend the geometry structure recursively...
|
||||
fCurrentDepth++;
|
||||
VisitGeometryAndGetVisReps
|
||||
(pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
|
||||
(pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
|
||||
fCurrentDepth--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include "G4AttCheck.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Text.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
G4TrajectoriesModel::G4TrajectoriesModel ()
|
||||
:fpCurrentTrajectory(0)
|
||||
@@ -80,17 +84,15 @@ void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
|
||||
return;
|
||||
}
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (!pVVisManager) return;
|
||||
|
||||
G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
|
||||
if (!TC) return;
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (!pVVisManager) return;
|
||||
|
||||
pVVisManager->BeginDraw();
|
||||
// The use of Begin/EndDraw (optional methods to improve drawing
|
||||
// speed) assumes all trajectories are drawn with the same
|
||||
// transformation. If not, a fatal exception with be raised in
|
||||
// G4VisManager::DrawT.
|
||||
// Need to set the static "current" modeling parameters separately
|
||||
G4VModel::SetCurrentModelingParameters(fpMP);
|
||||
|
||||
for (std::size_t iT = 0; iT < TC->entries(); ++iT) {
|
||||
fpCurrentTrajectory = (*TC) [iT];
|
||||
// Debug trajectory:
|
||||
@@ -100,7 +102,22 @@ void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
|
||||
if (fpCurrentTrajectory)
|
||||
sceneHandler.AddCompound (*fpCurrentTrajectory);
|
||||
}
|
||||
pVVisManager->EndDraw();
|
||||
|
||||
// If time windowing is active, display head time if requested
|
||||
const auto& timeParameters = fpMP->GetTimeParameters();
|
||||
if (timeParameters.fDisplayHeadTime && timeParameters.fStartTime >= 0.) {
|
||||
const auto& tp = timeParameters; // Alias
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::setprecision(2) << timeParameters.fEndTime/ns << " ns";
|
||||
G4Text headTime(oss.str());
|
||||
headTime.SetLayout(G4Text::centre);
|
||||
headTime.SetScreenSize(tp.fDisplayHeadTimeSize);
|
||||
headTime.SetPosition(G4Point3D(tp.fDisplayHeadTimeX, tp.fDisplayHeadTimeY, 0.));
|
||||
G4VisAttributes headTimeVisAtts
|
||||
(G4Colour(tp.fDisplayHeadTimeRed, tp.fDisplayHeadTimeGreen, tp.fDisplayHeadTimeBlue));
|
||||
headTime.SetVisAttributes(&headTimeVisAtts);
|
||||
pVVisManager->Draw2D(headTime);
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<G4String,G4AttDef>* G4TrajectoriesModel::GetAttDefs() const
|
||||
|
||||
@@ -61,7 +61,7 @@ G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj, const G4boo
|
||||
for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
|
||||
G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
|
||||
if (!point) continue;
|
||||
std::vector<G4AttValue>* attValues = point->CreateAttValues();
|
||||
const auto attValues = point->GetAttValues();
|
||||
std::vector<G4AttValue>::const_iterator iAtt;
|
||||
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
|
||||
if (iAtt->GetName() == "PostVPath" &&
|
||||
|
||||
@@ -27,326 +27,324 @@
|
||||
// Jane Tinslay, John Allison, Joseph Perl November 2005
|
||||
//
|
||||
#include "G4TrajectoryDrawerUtils.hh"
|
||||
|
||||
#include "G4AttValue.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4Polyline.hh"
|
||||
#include "G4Polymarker.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4VTrajectory.hh"
|
||||
#include "G4VTrajectoryPoint.hh"
|
||||
#include "G4RichTrajectoryPoint.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4VisTrajContext.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4AttValue.hh"
|
||||
#include "G4VModel.hh"
|
||||
#include "G4ModelingParameters.hh"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#define G4warn G4cout
|
||||
|
||||
namespace G4TrajectoryDrawerUtils {
|
||||
namespace G4TrajectoryDrawerUtils
|
||||
{
|
||||
|
||||
enum TimesValidity {InvalidTimes, ValidTimes};
|
||||
enum TimesValidity
|
||||
{
|
||||
InvalidTimes,
|
||||
ValidTimes
|
||||
};
|
||||
|
||||
TimesValidity GetPointsAndTimes
|
||||
(const G4VTrajectory& traj,
|
||||
const G4VisTrajContext& context,
|
||||
G4Polyline& trajectoryLine,
|
||||
G4Polymarker& auxiliaryPoints,
|
||||
G4Polymarker& stepPoints,
|
||||
std::vector<G4double>& trajectoryLineTimes,
|
||||
std::vector<G4double>& auxiliaryPointTimes,
|
||||
std::vector<G4double>& stepPointTimes)
|
||||
{
|
||||
TimesValidity validity = InvalidTimes;
|
||||
if (context.GetTimeSliceInterval()) validity = ValidTimes;
|
||||
TimesValidity GetPointsAndTimes(const G4VTrajectory& traj, const G4VisTrajContext& context,
|
||||
G4Polyline& trajectoryLine, G4Polymarker& auxiliaryPoints,
|
||||
G4Polymarker& stepPoints,
|
||||
std::vector<G4double>& trajectoryLineTimes,
|
||||
std::vector<G4double>& auxiliaryPointTimes,
|
||||
std::vector<G4double>& stepPointTimes)
|
||||
{
|
||||
TimesValidity validity = InvalidTimes;
|
||||
if (context.GetTimeSliceInterval()) validity = ValidTimes;
|
||||
|
||||
// Memory for last trajectory point position for auxiliary point
|
||||
// time interpolation algorithm. There are no auxiliary points
|
||||
// for the first trajectory point, so its initial value is
|
||||
// immaterial.
|
||||
G4ThreeVector lastTrajectoryPointPosition;
|
||||
// Memory for last trajectory point position for auxiliary point
|
||||
// time interpolation algorithm. There are no auxiliary points
|
||||
// for the first trajectory point, so its initial value is
|
||||
// immaterial.
|
||||
G4ThreeVector lastTrajectoryPointPosition;
|
||||
|
||||
// Keep positions. Don't store unless first or different.
|
||||
std::vector<G4ThreeVector> positions;
|
||||
// Keep positions. Don't store unless first or different.
|
||||
std::vector<G4ThreeVector> positions;
|
||||
|
||||
for (G4int iPoint=0; iPoint<traj.GetPointEntries(); iPoint++) {
|
||||
for (G4int iPoint = 0; iPoint < traj.GetPointEntries(); iPoint++) {
|
||||
G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(iPoint);
|
||||
const G4ThreeVector& trajectoryPointPosition = aTrajectoryPoint->GetPosition();
|
||||
|
||||
G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(iPoint);
|
||||
const G4ThreeVector& trajectoryPointPosition =
|
||||
aTrajectoryPoint->GetPosition();
|
||||
// Only store if first or if different
|
||||
if (positions.size() == 0 || trajectoryPointPosition != positions[positions.size() - 1]) {
|
||||
// Pre- and Post-Point times from the trajectory point...
|
||||
G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
|
||||
G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
|
||||
|
||||
// Only store if first or if different
|
||||
if (positions.size() == 0 ||
|
||||
trajectoryPointPosition != positions[positions.size()-1]) {
|
||||
if (context.GetTimeSliceInterval() && validity == ValidTimes) {
|
||||
|
||||
// Pre- and Post-Point times from the trajectory point...
|
||||
G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
|
||||
G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
|
||||
|
||||
if (context.GetTimeSliceInterval() && validity == ValidTimes) {
|
||||
|
||||
std::vector<G4AttValue>* trajectoryPointAttValues =
|
||||
aTrajectoryPoint->CreateAttValues();
|
||||
if (!trajectoryPointAttValues) {
|
||||
static G4bool warnedNoAttValues = false;
|
||||
if (!warnedNoAttValues) {
|
||||
G4warn <<
|
||||
"*************************************************************************"
|
||||
"\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
|
||||
"\n*************************************************************************"
|
||||
<< G4endl;
|
||||
warnedNoAttValues = true;
|
||||
}
|
||||
validity = InvalidTimes;
|
||||
} else {
|
||||
G4bool foundPreTime = false, foundPostTime = false;
|
||||
for (std::vector<G4AttValue>::iterator i =
|
||||
trajectoryPointAttValues->begin();
|
||||
i != trajectoryPointAttValues->end(); ++i) {
|
||||
if (i->GetName() == "PreT") {
|
||||
trajectoryPointPreTime =
|
||||
G4UIcommand::ConvertToDimensionedDouble(i->GetValue());
|
||||
foundPreTime = true;
|
||||
}
|
||||
if (i->GetName() == "PostT") {
|
||||
trajectoryPointPostTime =
|
||||
G4UIcommand::ConvertToDimensionedDouble(i->GetValue());
|
||||
foundPostTime = true;
|
||||
}
|
||||
}
|
||||
if (!foundPreTime || !foundPostTime) {
|
||||
static G4bool warnedTimesNotFound = false;
|
||||
if (!warnedTimesNotFound) {
|
||||
G4warn <<
|
||||
"*************************************************************************"
|
||||
"\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
|
||||
"\n You need to specify \"/vis/scene/add/trajectories rich\""
|
||||
"\n*************************************************************************"
|
||||
<< G4endl;
|
||||
warnedTimesNotFound = true;
|
||||
}
|
||||
validity = InvalidTimes;
|
||||
}
|
||||
}
|
||||
delete trajectoryPointAttValues; // (Must be deleted after use.)
|
||||
}
|
||||
|
||||
const std::vector<G4ThreeVector>* auxiliaries
|
||||
= aTrajectoryPoint->GetAuxiliaryPoints();
|
||||
if (0 != auxiliaries) {
|
||||
for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
|
||||
const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
|
||||
if (positions.size() == 0 ||
|
||||
auxPointPosition != positions[positions.size()-1]) {
|
||||
// Only store if first or if different
|
||||
positions.push_back(trajectoryPointPosition);
|
||||
trajectoryLine.push_back(auxPointPosition);
|
||||
auxiliaryPoints.push_back(auxPointPosition);
|
||||
if (validity == ValidTimes) {
|
||||
// Interpolate time for auxiliary points...
|
||||
G4double s1 =
|
||||
(auxPointPosition - lastTrajectoryPointPosition).mag();
|
||||
G4double s2 =
|
||||
(trajectoryPointPosition - auxPointPosition).mag();
|
||||
G4double t = trajectoryPointPreTime +
|
||||
(trajectoryPointPostTime - trajectoryPointPreTime) *
|
||||
(s1 / (s1 + s2));
|
||||
trajectoryLineTimes.push_back(t);
|
||||
auxiliaryPointTimes.push_back(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
positions.push_back(trajectoryPointPosition);
|
||||
trajectoryLine.push_back(trajectoryPointPosition);
|
||||
stepPoints.push_back(trajectoryPointPosition);
|
||||
if (validity == ValidTimes) {
|
||||
trajectoryLineTimes.push_back(trajectoryPointPostTime);
|
||||
stepPointTimes.push_back(trajectoryPointPostTime);
|
||||
}
|
||||
lastTrajectoryPointPosition = trajectoryPointPosition;
|
||||
const auto richTrajectoryPoint = dynamic_cast<G4RichTrajectoryPoint*>(aTrajectoryPoint);
|
||||
if (richTrajectoryPoint) {
|
||||
trajectoryPointPreTime = richTrajectoryPoint->GetPreStepPointGlobalTime();
|
||||
trajectoryPointPostTime = richTrajectoryPoint->GetPostStepPointGlobalTime();
|
||||
if (trajectoryPointPostTime > 1000000. * context.GetTimeSliceInterval()) {
|
||||
static G4bool warnedTimeExceeded = false;
|
||||
if (!warnedTimeExceeded) {
|
||||
G4Exception("G4TrajectoryUtils::GetPointsAndTimes", "modeling0128", JustWarning,
|
||||
"Trajectory point times exceed limit (>1000000 time slice)."
|
||||
"\nNormal trajectory will be drawn.");
|
||||
warnedTimeExceeded = true;
|
||||
}
|
||||
validity = InvalidTimes;
|
||||
}
|
||||
} else {
|
||||
static G4bool warnedNoAttValues = false;
|
||||
if (!warnedNoAttValues) {
|
||||
G4Exception("G4TrajectoryUtils::GetPointsAndTimes", "modeling0127", JustWarning,
|
||||
"Trajectory point times not found. Use G4RichTrajectory:"
|
||||
"\n /vis/scene/add/trajectories rich");
|
||||
warnedNoAttValues = true;
|
||||
}
|
||||
validity = InvalidTimes;
|
||||
}
|
||||
}
|
||||
}
|
||||
return validity;
|
||||
}
|
||||
|
||||
static void SliceLine(G4double timeIncrement,
|
||||
G4Polyline& trajectoryLine,
|
||||
std::vector<G4double>& trajectoryLineTimes)
|
||||
{
|
||||
// Assumes valid arguments from GetPoints and GetTimes.
|
||||
|
||||
G4Polyline newTrajectoryLine;
|
||||
std::vector<G4double> newTrajectoryLineTimes;
|
||||
|
||||
newTrajectoryLine.push_back(trajectoryLine[0]);
|
||||
newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
|
||||
size_t lineSize = trajectoryLine.size();
|
||||
if (lineSize > 1) {
|
||||
for (size_t i = 1; i < trajectoryLine.size(); ++i) {
|
||||
G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
|
||||
if (deltaT > 0.) {
|
||||
G4double practicalTimeIncrement =
|
||||
std::max(timeIncrement, deltaT / 100.);
|
||||
for (G4double t =
|
||||
(int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
|
||||
practicalTimeIncrement;
|
||||
t <= trajectoryLineTimes[i];
|
||||
t += practicalTimeIncrement) {
|
||||
G4ThreeVector pos = trajectoryLine[i - 1] +
|
||||
(trajectoryLine[i] - trajectoryLine[i - 1]) *
|
||||
((t - trajectoryLineTimes[i - 1]) / deltaT);
|
||||
newTrajectoryLine.push_back(pos);
|
||||
newTrajectoryLineTimes.push_back(t);
|
||||
}
|
||||
}
|
||||
newTrajectoryLine.push_back(trajectoryLine[i]);
|
||||
newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
|
||||
const std::vector<G4ThreeVector>* auxiliaries = aTrajectoryPoint->GetAuxiliaryPoints();
|
||||
if (0 != auxiliaries) {
|
||||
for (size_t iAux = 0; iAux < auxiliaries->size(); ++iAux) {
|
||||
const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
|
||||
if (positions.size() == 0 || auxPointPosition != positions[positions.size() - 1]) {
|
||||
// Only store if first or if different
|
||||
positions.push_back(trajectoryPointPosition);
|
||||
trajectoryLine.push_back(auxPointPosition);
|
||||
auxiliaryPoints.push_back(auxPointPosition);
|
||||
if (validity == ValidTimes) {
|
||||
// Interpolate time for auxiliary points...
|
||||
G4double s1 = (auxPointPosition - lastTrajectoryPointPosition).mag();
|
||||
G4double s2 = (trajectoryPointPosition - auxPointPosition).mag();
|
||||
G4double t = trajectoryPointPreTime
|
||||
+ (trajectoryPointPostTime - trajectoryPointPreTime) * (s1 / (s1 + s2));
|
||||
trajectoryLineTimes.push_back(t);
|
||||
auxiliaryPointTimes.push_back(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trajectoryLine = std::move(newTrajectoryLine);
|
||||
trajectoryLineTimes = std::move(newTrajectoryLineTimes);
|
||||
positions.push_back(trajectoryPointPosition);
|
||||
trajectoryLine.push_back(trajectoryPointPosition);
|
||||
stepPoints.push_back(trajectoryPointPosition);
|
||||
if (validity == ValidTimes) {
|
||||
trajectoryLineTimes.push_back(trajectoryPointPostTime);
|
||||
stepPointTimes.push_back(trajectoryPointPostTime);
|
||||
}
|
||||
lastTrajectoryPointPosition = trajectoryPointPosition;
|
||||
}
|
||||
}
|
||||
return validity;
|
||||
}
|
||||
|
||||
static void DrawWithoutTime(const G4VisTrajContext& myContext,
|
||||
G4Polyline& trajectoryLine,
|
||||
G4Polymarker& auxiliaryPoints,
|
||||
G4Polymarker& stepPoints)
|
||||
{
|
||||
// Draw without time slice information
|
||||
static void SliceLine(G4double timeIncrement, G4Polyline& trajectoryLine,
|
||||
std::vector<G4double>& trajectoryLineTimes)
|
||||
{
|
||||
// Assumes valid arguments from GetPoints and GetTimes.
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (0 == pVVisManager) return;
|
||||
|
||||
if (myContext.GetDrawLine() && myContext.GetLineVisible()) {
|
||||
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
|
||||
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
|
||||
trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
|
||||
G4Polyline newTrajectoryLine;
|
||||
std::vector<G4double> newTrajectoryLineTimes;
|
||||
|
||||
pVVisManager->Draw(trajectoryLine);
|
||||
}
|
||||
|
||||
if (myContext.GetDrawAuxPts() && myContext.GetAuxPtsVisible()
|
||||
&& (auxiliaryPoints.size() > 0)) {
|
||||
auxiliaryPoints.SetMarkerType(myContext.GetAuxPtsType());
|
||||
auxiliaryPoints.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
|
||||
auxiliaryPoints.SetFillStyle(myContext.GetAuxPtsFillStyle());
|
||||
|
||||
G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());
|
||||
auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
|
||||
|
||||
pVVisManager->Draw(auxiliaryPoints);
|
||||
}
|
||||
|
||||
if (myContext.GetDrawStepPts() && myContext.GetStepPtsVisible()
|
||||
&& (stepPoints.size() > 0)) {
|
||||
stepPoints.SetMarkerType(myContext.GetStepPtsType());
|
||||
stepPoints.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
|
||||
stepPoints.SetFillStyle(myContext.GetStepPtsFillStyle());
|
||||
|
||||
G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour());
|
||||
stepPoints.SetVisAttributes(&stepPointsAttribs);
|
||||
|
||||
pVVisManager->Draw(stepPoints);
|
||||
newTrajectoryLine.push_back(trajectoryLine[0]);
|
||||
newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
|
||||
size_t lineSize = trajectoryLine.size();
|
||||
if (lineSize > 1) {
|
||||
for (size_t i = 1; i < trajectoryLine.size(); ++i) {
|
||||
G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
|
||||
if (deltaT > 0.) {
|
||||
G4double practicalTimeIncrement = std::max(timeIncrement, deltaT / 100.);
|
||||
for (G4double t = (int(trajectoryLineTimes[i - 1] / practicalTimeIncrement) + 1)
|
||||
* practicalTimeIncrement;
|
||||
t <= trajectoryLineTimes[i]; t += practicalTimeIncrement)
|
||||
{
|
||||
G4ThreeVector pos = trajectoryLine[i - 1]
|
||||
+ (trajectoryLine[i] - trajectoryLine[i - 1])
|
||||
* ((t - trajectoryLineTimes[i - 1]) / deltaT);
|
||||
newTrajectoryLine.push_back(pos);
|
||||
newTrajectoryLineTimes.push_back(t);
|
||||
}
|
||||
}
|
||||
newTrajectoryLine.push_back(trajectoryLine[i]);
|
||||
newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawWithTime(const G4VisTrajContext& myContext,
|
||||
G4Polyline& trajectoryLine,
|
||||
G4Polymarker& auxiliaryPoints,
|
||||
G4Polymarker& stepPoints,
|
||||
std::vector<G4double>& trajectoryLineTimes,
|
||||
std::vector<G4double>& auxiliaryPointTimes,
|
||||
std::vector<G4double>& stepPointTimes)
|
||||
{
|
||||
// Draw with time slice information
|
||||
trajectoryLine = std::move(newTrajectoryLine);
|
||||
trajectoryLineTimes = std::move(newTrajectoryLineTimes);
|
||||
}
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (0 == pVVisManager) return;
|
||||
static void DrawWithoutTime(const G4VisTrajContext& myContext, G4Polyline& trajectoryLine,
|
||||
G4Polymarker& auxiliaryPoints, G4Polymarker& stepPoints)
|
||||
{
|
||||
// Draw without time slice information
|
||||
|
||||
if (myContext.GetDrawLine() && myContext.GetLineVisible()) {
|
||||
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
|
||||
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (0 == pVVisManager) return;
|
||||
|
||||
for (size_t i = 1; i < trajectoryLine.size(); ++i ) {
|
||||
G4Polyline slice;
|
||||
slice.push_back(trajectoryLine[i -1]);
|
||||
slice.push_back(trajectoryLine[i]);
|
||||
trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
|
||||
trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
|
||||
slice.SetVisAttributes(&trajectoryLineAttribs);
|
||||
pVVisManager->Draw(slice);
|
||||
}
|
||||
}
|
||||
if (myContext.GetDrawLine() && myContext.GetLineVisible()) {
|
||||
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
|
||||
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
|
||||
trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
|
||||
|
||||
if (myContext.GetDrawAuxPts() && myContext.GetAuxPtsVisible()
|
||||
&& (auxiliaryPoints.size() > 0)) {
|
||||
G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());
|
||||
pVVisManager->Draw(trajectoryLine);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
|
||||
G4Polymarker point;
|
||||
point.push_back(auxiliaryPoints[i]);
|
||||
point.SetMarkerType(myContext.GetAuxPtsType());
|
||||
point.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
|
||||
point.SetFillStyle(myContext.GetAuxPtsFillStyle());
|
||||
auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
|
||||
auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
|
||||
point.SetVisAttributes(&auxiliaryPointsAttribs);
|
||||
pVVisManager->Draw(point);
|
||||
}
|
||||
}
|
||||
if (myContext.GetDrawAuxPts() && myContext.GetAuxPtsVisible() && (auxiliaryPoints.size() > 0)) {
|
||||
auxiliaryPoints.SetMarkerType(myContext.GetAuxPtsType());
|
||||
auxiliaryPoints.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
|
||||
auxiliaryPoints.SetFillStyle(myContext.GetAuxPtsFillStyle());
|
||||
|
||||
if (myContext.GetDrawStepPts() && myContext.GetStepPtsVisible()
|
||||
&& (stepPoints.size() > 0)) {
|
||||
G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour());
|
||||
G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());
|
||||
auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
|
||||
|
||||
for (size_t i = 0; i < stepPoints.size(); ++i ) {
|
||||
G4Polymarker point;
|
||||
point.push_back(stepPoints[i]);
|
||||
point.SetMarkerType(myContext.GetStepPtsType());
|
||||
point.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
|
||||
point.SetFillStyle(myContext.GetStepPtsFillStyle());
|
||||
stepPointsAttribs.SetStartTime(stepPointTimes[i]);
|
||||
stepPointsAttribs.SetEndTime(stepPointTimes[i]);
|
||||
point.SetVisAttributes(&stepPointsAttribs);
|
||||
pVVisManager->Draw(point);
|
||||
pVVisManager->Draw(auxiliaryPoints);
|
||||
}
|
||||
|
||||
if (myContext.GetDrawStepPts() && myContext.GetStepPtsVisible() && (stepPoints.size() > 0)) {
|
||||
stepPoints.SetMarkerType(myContext.GetStepPtsType());
|
||||
stepPoints.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
|
||||
stepPoints.SetFillStyle(myContext.GetStepPtsFillStyle());
|
||||
|
||||
G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour());
|
||||
stepPoints.SetVisAttributes(&stepPointsAttribs);
|
||||
|
||||
pVVisManager->Draw(stepPoints);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawWithTime(const G4VisTrajContext& myContext, G4Polyline& trajectoryLine,
|
||||
G4Polymarker& auxiliaryPoints, G4Polymarker& stepPoints,
|
||||
std::vector<G4double>& trajectoryLineTimes,
|
||||
std::vector<G4double>& auxiliaryPointTimes,
|
||||
std::vector<G4double>& stepPointTimes)
|
||||
{
|
||||
// Draw with time slice information
|
||||
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (0 == pVVisManager) return;
|
||||
|
||||
const auto& timeParameters = G4VModel::GetCurrentModelingParameters()->GetTimeParameters();
|
||||
const auto& viewerStartTime = timeParameters.fStartTime;
|
||||
const auto& viewerEndTime = timeParameters.fEndTime;
|
||||
const auto& viewerFadeFactor = timeParameters.fFadeFactor;
|
||||
|
||||
if (myContext.GetDrawLine() && myContext.GetLineVisible()) {
|
||||
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
|
||||
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
|
||||
|
||||
for (size_t i = 1; i < trajectoryLine.size(); ++i) {
|
||||
const auto& sliceStartTime = trajectoryLineTimes[i - 1];
|
||||
const auto& sliceEndTime = trajectoryLineTimes[i];
|
||||
if (sliceStartTime >= viewerStartTime && sliceEndTime <= viewerEndTime) {
|
||||
G4Polyline slice;
|
||||
slice.push_back(trajectoryLine[i - 1]);
|
||||
slice.push_back(trajectoryLine[i]);
|
||||
trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
|
||||
trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
|
||||
if (viewerStartTime >= 0.) {
|
||||
auto opacityMultiplier = 1. - viewerFadeFactor
|
||||
* (viewerEndTime - trajectoryLineTimes[i]) / (viewerEndTime - viewerStartTime);
|
||||
auto colour = myContext.GetLineColour();
|
||||
colour.SetAlpha(opacityMultiplier * colour.GetAlpha());
|
||||
trajectoryLineAttribs.SetColour(colour);
|
||||
}
|
||||
slice.SetVisAttributes(&trajectoryLineAttribs);
|
||||
pVVisManager->Draw(slice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context)
|
||||
{
|
||||
// Return if don't need to do anything
|
||||
if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
|
||||
|
||||
// Get points and times (times are returned only if time-slicing
|
||||
// is requested).
|
||||
G4Polyline trajectoryLine;
|
||||
G4Polymarker stepPoints;
|
||||
G4Polymarker auxiliaryPoints;
|
||||
std::vector<G4double> trajectoryLineTimes;
|
||||
std::vector<G4double> stepPointTimes;
|
||||
std::vector<G4double> auxiliaryPointTimes;
|
||||
if (myContext.GetDrawAuxPts() && myContext.GetAuxPtsVisible() && (auxiliaryPoints.size() > 0)) {
|
||||
G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());
|
||||
|
||||
TimesValidity validity = GetPointsAndTimes
|
||||
(traj, context,
|
||||
trajectoryLine, auxiliaryPoints, stepPoints,
|
||||
trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
|
||||
|
||||
if (validity == ValidTimes) {
|
||||
for (size_t i = 0; i < auxiliaryPoints.size(); ++i) {
|
||||
const auto& auxStartTime = auxiliaryPointTimes[i];
|
||||
const auto& auxEndTime = auxiliaryPointTimes[i];
|
||||
if (auxStartTime >= viewerStartTime && auxEndTime <= viewerEndTime) {
|
||||
G4Polymarker point;
|
||||
point.push_back(auxiliaryPoints[i]);
|
||||
point.SetMarkerType(myContext.GetAuxPtsType());
|
||||
point.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
|
||||
point.SetFillStyle(myContext.GetAuxPtsFillStyle());
|
||||
auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
|
||||
auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
|
||||
if (viewerStartTime >= 0.) {
|
||||
auto opacityMultiplier = 1. - viewerFadeFactor
|
||||
* (viewerEndTime - auxiliaryPointTimes[i] ) / (viewerEndTime - viewerStartTime);
|
||||
auto colour = myContext.GetAuxPtsColour();
|
||||
colour.SetAlpha(opacityMultiplier * colour.GetAlpha());
|
||||
auxiliaryPointsAttribs.SetColour(colour);
|
||||
}
|
||||
point.SetVisAttributes(&auxiliaryPointsAttribs);
|
||||
pVVisManager->Draw(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SliceLine(context.GetTimeSliceInterval(),
|
||||
trajectoryLine, trajectoryLineTimes);
|
||||
|
||||
DrawWithTime(context,
|
||||
trajectoryLine, auxiliaryPoints, stepPoints,
|
||||
trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
|
||||
|
||||
} else {
|
||||
|
||||
DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
|
||||
if (myContext.GetDrawStepPts() && myContext.GetStepPtsVisible() && (stepPoints.size() > 0)) {
|
||||
G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour());
|
||||
|
||||
for (size_t i = 0; i < stepPoints.size(); ++i) {
|
||||
const auto& pointStartTime = stepPointTimes[i];
|
||||
const auto& pointEndTime = stepPointTimes[i];
|
||||
if (pointStartTime >= viewerStartTime && pointEndTime <= viewerEndTime) {
|
||||
G4Polymarker point;
|
||||
point.push_back(stepPoints[i]);
|
||||
point.SetMarkerType(myContext.GetStepPtsType());
|
||||
point.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
|
||||
point.SetFillStyle(myContext.GetStepPtsFillStyle());
|
||||
stepPointsAttribs.SetStartTime(stepPointTimes[i]);
|
||||
stepPointsAttribs.SetEndTime(stepPointTimes[i]);
|
||||
if (viewerStartTime >= 0.) {
|
||||
auto opacityMultiplier = 1. - viewerFadeFactor
|
||||
* (viewerEndTime - stepPointTimes[i]) / (viewerEndTime - viewerStartTime);
|
||||
auto colour = myContext.GetStepPtsColour();
|
||||
colour.SetAlpha(opacityMultiplier * colour.GetAlpha());
|
||||
stepPointsAttribs.SetColour(colour);
|
||||
}
|
||||
point.SetVisAttributes(&stepPointsAttribs);
|
||||
pVVisManager->Draw(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context)
|
||||
{
|
||||
// Return if don't need to do anything
|
||||
if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
|
||||
|
||||
// Get points and times (times are returned only if time-slicing
|
||||
// is requested).
|
||||
G4Polyline trajectoryLine;
|
||||
G4Polymarker stepPoints;
|
||||
G4Polymarker auxiliaryPoints;
|
||||
std::vector<G4double> trajectoryLineTimes;
|
||||
std::vector<G4double> stepPointTimes;
|
||||
std::vector<G4double> auxiliaryPointTimes;
|
||||
|
||||
TimesValidity validity =
|
||||
GetPointsAndTimes(traj, context, trajectoryLine, auxiliaryPoints, stepPoints,
|
||||
trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
|
||||
|
||||
if (validity == ValidTimes) {
|
||||
SliceLine(context.GetTimeSliceInterval(), trajectoryLine, trajectoryLineTimes);
|
||||
|
||||
DrawWithTime(context, trajectoryLine, auxiliaryPoints, stepPoints, trajectoryLineTimes,
|
||||
auxiliaryPointTimes, stepPointTimes);
|
||||
}
|
||||
else {
|
||||
DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
|
||||
}
|
||||
}
|
||||
} // namespace G4TrajectoryDrawerUtils
|
||||
|
||||
@@ -55,7 +55,7 @@ G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
|
||||
for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
|
||||
G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
|
||||
if (!point) continue;
|
||||
std::vector<G4AttValue>* attValues = point->CreateAttValues();
|
||||
const auto attValues = point->GetAttValues();
|
||||
std::vector<G4AttValue>::const_iterator iAtt;
|
||||
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
|
||||
if (iAtt->GetName() == "PostVPath" &&
|
||||
|
||||
@@ -34,15 +34,22 @@
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ModelingParameters.hh"
|
||||
|
||||
const G4ModelingParameters* G4VModel::fpCurrentMP = nullptr;
|
||||
|
||||
G4VModel::G4VModel (const G4ModelingParameters* pMP):
|
||||
fType ("Other"),
|
||||
fGlobalTag ("Empty"),
|
||||
fGlobalDescription ("Empty"),
|
||||
fpMP (pMP)
|
||||
{}
|
||||
fGlobalDescription ("Empty")
|
||||
{
|
||||
fpMP = pMP;
|
||||
}
|
||||
|
||||
G4VModel::~G4VModel () {}
|
||||
|
||||
const G4ModelingParameters* G4VModel::GetCurrentModelingParameters () {
|
||||
return fpCurrentMP;
|
||||
}
|
||||
|
||||
G4String G4VModel::GetCurrentTag () const {
|
||||
// Override in concrete class if concept of "current" is meaningful.
|
||||
return fGlobalTag;
|
||||
@@ -53,6 +60,10 @@ G4String G4VModel::GetCurrentDescription () const {
|
||||
return fGlobalDescription;
|
||||
}
|
||||
|
||||
void G4VModel::SetCurrentModelingParameters (const G4ModelingParameters* pMP) {
|
||||
fpCurrentMP = pMP;
|
||||
}
|
||||
|
||||
G4bool G4VModel::Validate (G4bool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user