Geant4 10.7.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 ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
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="")
 
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 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 DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (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 = 0
 
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
 

Detailed Description

Definition at line 143 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerColourByDensity()

G4VisCommandViewerColourByDensity::G4VisCommandViewerColourByDensity ( )

Definition at line 704 of file G4VisCommandsViewer.cc.

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

◆ ~G4VisCommandViewerColourByDensity()

G4VisCommandViewerColourByDensity::~G4VisCommandViewerColourByDensity ( )
virtual

Definition at line 742 of file G4VisCommandsViewer.cc.

742 {
743 delete fpCommand;
744}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerColourByDensity::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 746 of file G4VisCommandsViewer.cc.

746 {
747 return "";
748}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 750 of file G4VisCommandsViewer.cc.

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