Import Geant4 10.4.0 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 104093 2017-05-11 07:29:45Z gcosmo $
|
||||
$Id: History 106385 2017-10-09 09:36:33Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -20,6 +20,22 @@ committal in the CVS repository !
|
||||
History file for graphics_reps category
|
||||
---------------------------------------
|
||||
|
||||
6th October 2017 John Allison (greps-V10-03-07)
|
||||
- Rationalised:
|
||||
o Colour map no longer G4ThreadLocal (no need). May be used from
|
||||
non-master threads.
|
||||
o Move InitialiseColourMap from private to public. In future vis tags
|
||||
the map will be initialised from the vis manager.
|
||||
|
||||
13th September 2017 John Allison (greps-V10-03-06)
|
||||
- HepPolyhedron.h: Reverted default number of line segments per circle:
|
||||
#define DEFAULT_NUMBER_OF_STEPS 24
|
||||
(72 lines per circle gives trouble in the Boolean Processor, so until that
|
||||
is fixed we revert to 24.)
|
||||
|
||||
1st August 2017 John Allison (greps-V10-03-05)
|
||||
- G4AttDefStore: Shared (i.e., no longer thread local). Added mutex.
|
||||
|
||||
10th May 2017 John Allison (greps-V10-03-04)
|
||||
- G4Colour: Added Set functions for components.
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4AttDefStore.hh 78306 2013-12-11 10:53:30Z gcosmo $
|
||||
// $Id: G4AttDefStore.hh 105754 2017-08-16 13:47:18Z gcosmo $
|
||||
|
||||
#ifndef G4ATTDEFSTORE_HH
|
||||
#define G4ATTDEFSTORE_HH
|
||||
@@ -49,8 +49,7 @@ namespace G4AttDefStore {
|
||||
// Returns true and assigns key if definitions are amongst those
|
||||
// maintained in the store.
|
||||
|
||||
extern G4ThreadLocal
|
||||
std::map<G4String,std::map<G4String,G4AttDef>*> *m_defsmaps;
|
||||
extern std::map<G4String,std::map<G4String,G4AttDef>*> *m_defsmaps;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Colour.hh 104093 2017-05-11 07:29:45Z gcosmo $
|
||||
// $Id: G4Colour.hh 106385 2017-10-09 09:36:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// John Allison 20th October 1996
|
||||
@@ -127,24 +127,25 @@ public: // With description
|
||||
static G4Colour Magenta();
|
||||
static G4Colour Yellow();
|
||||
|
||||
static G4bool GetColour(const G4String& key, G4Colour& result);
|
||||
// Get colour for given key, placing it in result.
|
||||
// The key is usually the name of the colour.
|
||||
// The key is not case sensitive.
|
||||
// Returns false if key doesn't exist, leaving result unchanged.
|
||||
|
||||
static void AddToMap(const G4String& key, const G4Colour& colour);
|
||||
// Add user defined colour to colour map with given key. Standard
|
||||
// colours are added to map by default.
|
||||
|
||||
static G4bool GetColour(const G4String& key, G4Colour& result);
|
||||
// Get colour for given key. Returns false if key doesn't exist
|
||||
// in colour map, leaving result unchanged. Colour map
|
||||
// is not sensitive to key case.
|
||||
|
||||
static void InitialiseColourMap();
|
||||
static const std::map<G4String, G4Colour>& GetMap();
|
||||
|
||||
|
||||
private:
|
||||
G4double red, green, blue, alpha;
|
||||
|
||||
static G4ThreadLocal std::map<G4String, G4Colour> *fColourMap;
|
||||
static G4ThreadLocal G4bool fInitColourMap;
|
||||
static void InitialiseColourMap();
|
||||
|
||||
static std::map<G4String, G4Colour> fColourMap;
|
||||
static G4bool fInitColourMap;
|
||||
|
||||
};
|
||||
|
||||
inline G4double G4Colour::GetRed () const {return red;}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: HepPolyhedron.h 101022 2016-11-04 08:25:50Z gcosmo $
|
||||
// $Id: HepPolyhedron.h 106123 2017-09-13 12:53:03Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Class Description:
|
||||
@@ -174,7 +174,7 @@
|
||||
#include "G4Transform3D.hh"
|
||||
|
||||
#ifndef DEFAULT_NUMBER_OF_STEPS
|
||||
#define DEFAULT_NUMBER_OF_STEPS 72
|
||||
#define DEFAULT_NUMBER_OF_STEPS 24
|
||||
#endif
|
||||
|
||||
class G4Facet {
|
||||
|
||||
@@ -24,20 +24,24 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4AttDefStore.cc 78955 2014-02-05 09:45:46Z gcosmo $
|
||||
// $Id: G4AttDefStore.cc 105754 2017-08-16 13:47:18Z gcosmo $
|
||||
|
||||
#include "G4AttDefStore.hh"
|
||||
|
||||
#include "G4AttDef.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace G4AttDefStore {
|
||||
|
||||
G4ThreadLocal
|
||||
std::map<G4String,std::map<G4String,G4AttDef>*> *m_defsmaps = 0;
|
||||
|
||||
G4Mutex mutex = G4MUTEX_INITIALIZER;
|
||||
|
||||
std::map<G4String,G4AttDef>*
|
||||
GetInstance(const G4String& storeKey, G4bool& isNew)
|
||||
{
|
||||
G4AutoLock al(&mutex);
|
||||
|
||||
if (!m_defsmaps)
|
||||
m_defsmaps = new std::map<G4String,std::map<G4String,G4AttDef>*>;
|
||||
|
||||
@@ -65,6 +69,8 @@ GetInstance(const G4String& storeKey, G4bool& isNew)
|
||||
G4bool GetStoreKey
|
||||
(const std::map<G4String,G4AttDef>* definitions, G4String& key)
|
||||
{
|
||||
G4AutoLock al(&mutex);
|
||||
|
||||
if (!m_defsmaps)
|
||||
m_defsmaps = new std::map<G4String,std::map<G4String,G4AttDef>*>;
|
||||
std::map<G4String,std::map<G4String,G4AttDef>*>::const_iterator i;
|
||||
|
||||
@@ -24,13 +24,15 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Colour.cc 104093 2017-05-11 07:29:45Z gcosmo $
|
||||
// $Id: G4Colour.cc 106385 2017-10-09 09:36:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// John Allison 20th October 1996
|
||||
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4Threading.hh"
|
||||
|
||||
G4Colour::G4Colour (G4double r, G4double gr, G4double b, G4double a):
|
||||
red (r), green (gr), blue (b), alpha (a)
|
||||
{
|
||||
@@ -103,25 +105,34 @@ G4bool G4Colour::operator != (const G4Colour& c) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
G4ThreadLocal std::map<G4String, G4Colour> *G4Colour::fColourMap = 0;
|
||||
G4ThreadLocal bool G4Colour::fInitColourMap = false;
|
||||
std::map<G4String, G4Colour> G4Colour::fColourMap;
|
||||
G4bool G4Colour::fInitColourMap = false;
|
||||
|
||||
void
|
||||
G4Colour::AddToMap(const G4String& key, const G4Colour& colour)
|
||||
void G4Colour::AddToMap(const G4String& key, const G4Colour& colour)
|
||||
{
|
||||
if (!fColourMap)
|
||||
fColourMap = new std::map<G4String, G4Colour>;
|
||||
// Allow only master thread to populate the map
|
||||
if (!G4Threading::IsMasterThread()) {
|
||||
static G4bool first = true;
|
||||
if (first) {
|
||||
first = false;
|
||||
G4Exception
|
||||
("G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
|
||||
"greps0002", JustWarning,
|
||||
"Attempt to add to colour map from non-master thread.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert to lower case since colour map is case insensitive
|
||||
G4String myKey(key);
|
||||
myKey.toLower();
|
||||
|
||||
std::map<G4String, G4Colour>::iterator iter = fColourMap->find(myKey);
|
||||
std::map<G4String, G4Colour>::iterator iter = fColourMap.find(myKey);
|
||||
|
||||
if (iter == fColourMap->end()) (*fColourMap)[myKey] = colour;
|
||||
if (iter == fColourMap.end()) fColourMap[myKey] = colour;
|
||||
else {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "G4Colour with key "<<myKey<<" already exists."<<G4endl;
|
||||
ed << "G4Colour with key " << myKey << " already exists." << G4endl;
|
||||
G4Exception
|
||||
("G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
|
||||
"greps0001", JustWarning, ed,
|
||||
@@ -129,9 +140,12 @@ G4Colour::AddToMap(const G4String& key, const G4Colour& colour)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4Colour::InitialiseColourMap()
|
||||
void G4Colour::InitialiseColourMap()
|
||||
{
|
||||
if (fInitColourMap) return;
|
||||
|
||||
fInitColourMap = true;
|
||||
|
||||
// Standard colours
|
||||
AddToMap("white", G4Colour::White());
|
||||
AddToMap("grey", G4Colour::Grey());
|
||||
@@ -146,22 +160,18 @@ G4Colour::InitialiseColourMap()
|
||||
AddToMap("yellow", G4Colour::Yellow());
|
||||
}
|
||||
|
||||
bool
|
||||
G4Colour::GetColour(const G4String& key, G4Colour& result)
|
||||
G4bool G4Colour::GetColour(const G4String& key, G4Colour& result)
|
||||
{
|
||||
if (false == fInitColourMap) {
|
||||
fInitColourMap = true;
|
||||
// Add standard colours to map
|
||||
InitialiseColourMap();
|
||||
}
|
||||
|
||||
// Add standard colours to map
|
||||
InitialiseColourMap(); // Initialises if not already initialised
|
||||
|
||||
G4String myKey(key);
|
||||
myKey.toLower();
|
||||
|
||||
std::map<G4String, G4Colour>::iterator iter = fColourMap->find(myKey);
|
||||
std::map<G4String, G4Colour>::iterator iter = fColourMap.find(myKey);
|
||||
|
||||
// Don't modify "result" if colour was not found in map
|
||||
if (iter == fColourMap->end()) return false;
|
||||
if (iter == fColourMap.end()) return false;
|
||||
|
||||
result = iter->second;
|
||||
|
||||
@@ -170,11 +180,8 @@ G4Colour::GetColour(const G4String& key, G4Colour& result)
|
||||
|
||||
const std::map<G4String, G4Colour>& G4Colour::GetMap()
|
||||
{
|
||||
if (false == fInitColourMap) {
|
||||
fInitColourMap = true;
|
||||
// Add standard colours to map
|
||||
InitialiseColourMap();
|
||||
}
|
||||
// Add standard colours to map
|
||||
InitialiseColourMap(); // Initialises if not already initialised
|
||||
|
||||
return *fColourMap;
|
||||
return fColourMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user