Geant4 11.4.0
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, const 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 (const 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 715 of file G4VisCommandsViewer.cc.

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

◆ ~G4VisCommandViewerColourByDensity()

G4VisCommandViewerColourByDensity::~G4VisCommandViewerColourByDensity ( )
virtual

Definition at line 753 of file G4VisCommandsViewer.cc.

753 {
754 delete fpCommand;
755}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerColourByDensity::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 757 of file G4VisCommandsViewer.cc.

757 {
758 return "";
759}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 761 of file G4VisCommandsViewer.cc.

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

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