Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandViewerColourByDensity Class Reference

#include <G4VisCommandsViewer.hh>

+ Inheritance diagram for G4VisCommandViewerColourByDensity:

Public Member Functions

 G4VisCommandViewerColourByDensity ()
 
virtual ~G4VisCommandViewerColourByDensity ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static G4VisManagerGetVisManager ()
 
static void SetVisManager (G4VisManager *pVisManager)
 
static const G4ColourGetCurrentTextColour ()
 
- Protected Member Functions inherited from G4VVisCommand
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="")
 
void Twinkle (G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
 
const G4StringConvertToColourGuidance ()
 
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
 
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
 
void CopyCameraParameters (G4ViewParameters &target, const G4ViewParameters &from)
 
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
 
G4bool CheckView ()
 
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 &)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = nullptr
 
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
 
static G4VisExtent fCurrentExtentForField
 
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
 
static G4bool fThereWasAViewer = false
 
static G4ViewParameters fExistingVP
 
static G4SceneTreeItem fExistingSceneTree
 

Detailed Description

Definition at line 143 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerColourByDensity()

G4VisCommandViewerColourByDensity::G4VisCommandViewerColourByDensity ( )

Definition at line 716 of file G4VisCommandsViewer.cc.

716 {
717 G4bool omitable;
718 fpCommand = new G4UIcommand ("/vis/viewer/colourByDensity", this);
719 fpCommand -> SetGuidance
720 ("If a volume has no vis attributes, colour it by density.");
721 fpCommand -> SetGuidance
722 ("Provide algorithm number, e.g., \"1\" (or \"0\" to switch off)."
723 "\nThen a unit of density, e.g., \"g/cm3\"."
724 "\nThen parameters for the algorithm assumed to be densities in that unit.");
725 fpCommand -> SetGuidance
726 ("Algorithm 1: Simple algorithm takes 3 parameters: d0, d1 and d2."
727 "\n Volumes with density < d0 are invisible."
728 "\n Volumes with d0 <= density < d1 have colour on range red->green."
729 "\n Volumes with d1 <= density < d2 have colour on range green->blue."
730 "\n Volumes with density > d2 are blue.");
731 G4UIparameter* parameter;
732 parameter = new G4UIparameter("n",'i',omitable = true);
733 parameter -> SetGuidance ("Algorithm number (or \"0\" to switch off).");
734 parameter -> SetDefaultValue (1);
735 fpCommand->SetParameter(parameter);
736 parameter = new G4UIparameter("unit",'s',omitable = true);
737 parameter -> SetGuidance ("Unit of following densities, e.g., \"g/cm3\".");
738 parameter -> SetDefaultValue ("g/cm3");
739 fpCommand->SetParameter(parameter);
740 parameter = new G4UIparameter("d0",'d',omitable = true);
741 parameter -> SetGuidance ("Density parameter 0");
742 parameter -> SetDefaultValue (0.5);
743 fpCommand->SetParameter(parameter);
744 parameter = new G4UIparameter("d1",'d',omitable = true);
745 parameter -> SetGuidance ("Density parameter 1");
746 parameter -> SetDefaultValue (3.0);
747 fpCommand->SetParameter(parameter);
748 parameter = new G4UIparameter("d2",'d',omitable = true);
749 parameter -> SetGuidance ("Density parameter 2.");
750 parameter -> SetDefaultValue (10.0);
751 fpCommand->SetParameter(parameter);
752}
bool G4bool
Definition G4Types.hh:86
void SetParameter(G4UIparameter *const newParameter)

◆ ~G4VisCommandViewerColourByDensity()

G4VisCommandViewerColourByDensity::~G4VisCommandViewerColourByDensity ( )
virtual

Definition at line 754 of file G4VisCommandsViewer.cc.

754 {
755 delete fpCommand;
756}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerColourByDensity::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 758 of file G4VisCommandsViewer.cc.

758 {
759 return "";
760}

◆ SetNewValue()

void G4VisCommandViewerColourByDensity::SetNewValue ( G4UIcommand * command,
G4String newValue )
virtual

Reimplemented from G4UImessenger.

Definition at line 762 of file G4VisCommandsViewer.cc.

762 {
763
765
766 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
767 if (!viewer) {
768 if (verbosity >= G4VisManager::errors) {
769 G4warn <<
770 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
771 << G4endl;
772 }
773 return;
774 }
775 G4ViewParameters vp = viewer->GetViewParameters();
776
777 G4int algorithmNumber;
778 G4double d0, d1, d2;
779 G4String unit;
780 std::istringstream is (newValue);
781 is >> algorithmNumber >> unit >> d0 >> d1 >> d2;
782
783 if (algorithmNumber < 0 || algorithmNumber > 1) {
784 if (verbosity >= G4VisManager::errors) {
785 G4warn <<
786 "ERROR: Unrecognised algorithm number: " << algorithmNumber
787 << G4endl;
788 }
789 return;
790 }
791
792 std::vector<G4double> parameters;
793 if (algorithmNumber > 0) {
794 const G4String where = "G4VisCommandViewerColourByDensity::SetNewValue";
795 G4double valueOfUnit;
796 // "Volumic Mass" is Michel's phrase for "Density"
797 if (ProvideValueOfUnit(where,unit,"Volumic Mass",valueOfUnit)) {
798 // Successful outcome of unit search
799 d0 *= valueOfUnit; d1 *= valueOfUnit; d2 *= valueOfUnit;
800 } else {
801 if (verbosity >= G4VisManager::errors) {
802 G4warn <<
803 "ERROR: Unrecognised or inappropriate unit: " << unit
804 << G4endl;
805 }
806 return;
807 }
808 parameters.push_back(d0);
809 parameters.push_back(d1);
810 parameters.push_back(d2);
811 }
812 vp.SetCBDAlgorithmNumber(algorithmNumber);
813 vp.SetCBDParameters(parameters);
814
815 if (verbosity >= G4VisManager::confirmations) {
816 if (vp.GetCBDAlgorithmNumber() == 0) {
817 G4cout << "Colour by density deactivated" << G4endl;
818 } else {
819 G4cout << "Colour by density algorithm " << vp.GetCBDAlgorithmNumber()
820 << " selected for viewer \"" << viewer->GetName()
821 << "\n Parameters:";
822 for (auto p: vp.GetCBDParameters()) {
823 G4cout << ' ' << G4BestUnit(p,"Volumic Mass");
824 }
825 G4cout << G4endl;
826 }
827 }
828
829 SetViewParameters(viewer, vp);
830}
#define G4warn
Definition G4Scene.cc:41
#define G4BestUnit(a, b)
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
static G4VisManager * fpVisManager
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
G4bool ProvideValueOfUnit(const G4String &where, const G4String &unit, const G4String &category, G4double &value)
void SetCBDParameters(const std::vector< G4double > &)
void SetCBDAlgorithmNumber(G4int)
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
static Verbosity GetVerbosity()

The documentation for this class was generated from the following files: