Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Guy Barrand 12 October 2021
0027 //
0028 
0029 #ifndef G4PLOTTERMANAGER_HH
0030 #define G4PLOTTERMANAGER_HH
0031 
0032 #include "G4Plotter.hh"
0033 #include "G4UImessenger.hh"
0034 
0035 #include <vector>
0036 #include <utility>
0037 
0038 class G4PlotterManager {
0039 public:
0040   static G4PlotterManager& GetInstance ();
0041   G4Plotter& GetPlotter(const G4String& a_name);
0042   void List() const;
0043 
0044   using StyleItem = std::pair<G4String,G4String>;
0045   using Style = std::vector<StyleItem>;
0046   using NamedStyle = std::pair<G4String,Style>;
0047   using Styles = std::vector<NamedStyle>;
0048   const Styles& GetStyles() const {return fStyles;}
0049   Styles& GetStyles() {return fStyles;}
0050 
0051 private:
0052   G4PlotterManager();
0053   virtual ~G4PlotterManager();
0054   G4PlotterManager (const G4PlotterManager&);
0055   G4PlotterManager& operator = (const G4PlotterManager&);
0056 
0057   void ListStyles() const;
0058   Style* FindStyle(const G4String& name);
0059   void SelectStyle(const G4String& style);
0060   void RemoveStyle(const G4String& name);
0061   void PrintStyle(const G4String&) const;
0062   void AddStyleParameter(const G4String& param,const G4String& value);
0063 
0064   typedef std::pair<G4String,G4Plotter> NamedPlotter;
0065   std::vector<NamedPlotter> fPlotters;
0066 
0067   G4String fCurrentStyle;
0068   Styles fStyles;
0069 
0070   class Messenger: public G4UImessenger {
0071   public:  
0072     Messenger(G4PlotterManager& aPlotterManager):fPlotterManager(aPlotterManager) {
0073       G4UIparameter* parameter;
0074       //////////////////////////////////////////////////////////
0075       //////////////////////////////////////////////////////////
0076       //////////////////////////////////////////////////////////
0077       remove_style = new G4UIcommand("/vis/plotter/style/remove",this);
0078       remove_style->SetGuidance("Remove a named style.");
0079 
0080       parameter = new G4UIparameter("name",'s',false);
0081       remove_style->SetParameter(parameter);
0082 
0083       //////////////////////////////////////////////////////////
0084       //////////////////////////////////////////////////////////
0085       select_style = new G4UIcommand("/vis/plotter/style/select",this);
0086       select_style->SetGuidance("Select a named style for further style/add commands.");
0087       select_style->SetGuidance("If not existing, the named style is created.");
0088 
0089       parameter = new G4UIparameter("name",'s',false);
0090       select_style->SetParameter(parameter);
0091 
0092       //////////////////////////////////////////////////////////
0093       //////////////////////////////////////////////////////////
0094       add_style_parameter = new G4UIcommand("/vis/plotter/style/add",this);
0095       add_style_parameter->SetGuidance("Add a (parameter,value) to the current named style.");
0096 
0097       parameter = new G4UIparameter("parameter",'s',false);
0098       add_style_parameter->SetParameter (parameter);
0099   
0100       parameter = new G4UIparameter("value",'s',false);
0101       add_style_parameter->SetParameter (parameter);
0102 
0103       //////////////////////////////////////////////////////////
0104       //////////////////////////////////////////////////////////
0105       list_styles = new G4UIcommand("/vis/plotter/style/list", this);
0106       list_styles->SetGuidance("List known not embedded styles.");
0107       
0108       //////////////////////////////////////////////////////////
0109       //////////////////////////////////////////////////////////
0110       print_style = new G4UIcommand("/vis/plotter/style/print", this);
0111       print_style->SetGuidance("Print a style.");
0112 
0113       parameter = new G4UIparameter("style",'s',false);
0114       print_style->SetParameter (parameter);
0115     }
0116     virtual ~Messenger() {
0117       delete remove_style;
0118       delete select_style;
0119       delete add_style_parameter;
0120       delete list_styles;
0121       delete print_style;
0122     }
0123     virtual void SetNewValue(G4UIcommand*,G4String);
0124   private:  
0125     G4PlotterManager& fPlotterManager;
0126     G4UIcommand* remove_style; 
0127     G4UIcommand* select_style;
0128     G4UIcommand* add_style_parameter;
0129     G4UIcommand* list_styles;
0130     G4UIcommand* print_style;
0131   };
0132   
0133   Messenger* fMessenger;
0134 };
0135 
0136 #endif