CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
FWColorManager Class Reference

#include <Fireworks/Core/interface/FWColorManager.h>

Public Types

enum  BackgroundColorIndex { kWhiteIndex = kWhite, kBlackIndex = kBlack }
 
enum  EPalette {
  kPaletteFirst = 0, kClassic = 0, kPurple, kFall,
  kSpring, kArctic, kPaletteLast
}
 

Public Member Functions

Color_t background () const
 
BackgroundColorIndex backgroundColorIndex () const
 
int borderOfLimitedColors () const
 
int brightness ()
 
bool colorHasIndex (Color_t) const
 
void defaultBrightness ()
 
void fillLimitedColors (std::vector< Color_t > &cv) const
 
Color_t foreground () const
 
 FWColorManager (FWModelChangeManager *)
 
Color_t geomColor (FWGeomColorIndex) const
 
Color_t geomTransparency (bool projected) const
 
EPalette getPalette () const
 
void initialize ()
 
Bool_t isColorSetDark () const
 
Bool_t isColorSetLight () const
 
int numberOfLimitedColors () const
 
int offsetOfLimitedColors () const
 
Color_t oldColorToIndex (Color_t, int version) const
 
void propagatePaletteChanges () const
 
void setBackgroundAndBrightness (BackgroundColorIndex, int)
 
void setBackgroundColorIndex (BackgroundColorIndex)
 
void setBrightness (int)
 
void setDefaultGeomColors ()
 
void setGeomColor (FWGeomColorIndex, Color_t)
 
void setGeomTransparency (Color_t idx, bool projectedType)
 
void setPalette (long long)
 
void switchBackground ()
 
virtual ~FWColorManager ()
 

Static Public Member Functions

static Color_t getDefaultStartColorIndex ()
 
static Bool_t setColorSetViewer (TGLViewer *, Color_t)
 

Public Attributes

sigc::signal< void > colorsHaveChanged_
 
sigc::signal< void > colorsHaveChangedFinished_
 
sigc::signal< void > geomColorsHaveChanged_
 
sigc::signal< void, bool > geomTransparencyHaveChanged_
 

Private Member Functions

 FWColorManager (const FWColorManager &)=delete
 
void initColorTable ()
 
const FWColorManageroperator= (const FWColorManager &)=delete
 
void updateColors ()
 

Private Attributes

Color_t m_background
 
FWModelChangeManagerm_changeManager
 
Color_t m_foreground
 
Float_t m_gammaOff
 
Color_t m_geomColor [kFWGeomColorSize]
 
Char_t m_geomTransparency2D
 
Char_t m_geomTransparency3D
 
Color_t m_numColorIndices
 
EPalette m_paletteId
 
Color_t m_startColorIndex
 

Static Private Attributes

static const Color_t s_defaultStartColorIndex = 1000
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 47 of file FWColorManager.h.

Member Enumeration Documentation

Enumerator
kWhiteIndex 
kBlackIndex 

Definition at line 76 of file FWColorManager.h.

Constructor & Destructor Documentation

FWColorManager::FWColorManager ( FWModelChangeManager iManager)

Definition at line 78 of file FWColorManager.cc.

References setDefaultGeomColors().

78  :
80  m_gammaOff(0),
81  m_background(kBlack),
82  m_foreground(kWhite),
83  m_changeManager(iManager),
88 {
90 }
void setDefaultGeomColors()
EPalette m_paletteId
Char_t m_geomTransparency2D
FWModelChangeManager * m_changeManager
Char_t m_geomTransparency3D
Color_t m_numColorIndices
Color_t m_foreground
Color_t m_startColorIndex
Color_t m_background
FWColorManager::~FWColorManager ( )
virtual

Definition at line 92 of file FWColorManager.cc.

93 {
94 }
FWColorManager::FWColorManager ( const FWColorManager )
privatedelete

Member Function Documentation

Color_t FWColorManager::background ( ) const
inline
FWColorManager::BackgroundColorIndex FWColorManager::backgroundColorIndex ( ) const
int FWColorManager::borderOfLimitedColors ( ) const
inline
int FWColorManager::brightness ( )

Definition at line 221 of file FWColorManager.cc.

References m_gammaOff.

Referenced by getPalette().

222 {
223  return TMath::FloorNint(-m_gammaOff*10);
224 }
bool FWColorManager::colorHasIndex ( Color_t  iColor) const

Definition at line 319 of file FWColorManager.cc.

References m_numColorIndices, and m_startColorIndex.

Referenced by FWEventItemsManager::add(), and borderOfLimitedColors().

320 {
321  return iColor > 0 && iColor < m_startColorIndex + m_numColorIndices;
322 }
Color_t m_numColorIndices
Color_t m_startColorIndex
void FWColorManager::defaultBrightness ( )

Definition at line 227 of file FWColorManager.cc.

References m_gammaOff, and updateColors().

Referenced by getPalette().

228 {
229  m_gammaOff = 0;
230  updateColors();
231 }
void FWColorManager::fillLimitedColors ( std::vector< Color_t > &  cv) const
Color_t FWColorManager::foreground ( ) const
inline

Definition at line 59 of file FWColorManager.h.

References m_foreground.

Referenced by FWTableView::resetColors().

59 {return m_foreground;}
Color_t m_foreground
Color_t FWColorManager::geomColor ( FWGeomColorIndex  iIndex) const
Color_t FWColorManager::geomTransparency ( bool  projected) const
inline
Color_t FWColorManager::getDefaultStartColorIndex ( )
static

Definition at line 39 of file FWColorManager.cc.

References s_defaultStartColorIndex.

Referenced by FWEventItemsManager::add(), and getPalette().

39 { return s_defaultStartColorIndex; }
static const Color_t s_defaultStartColorIndex
EPalette FWColorManager::getPalette ( ) const
inline
void FWColorManager::initColorTable ( )
private

Definition at line 171 of file FWColorManager.cc.

References ev, objects.autophobj::float, fireworks::GetColorValuesForPaletteExtra(), isColorSetLight(), m_gammaOff, m_paletteId, m_startColorIndex, and resetColors().

Referenced by setPalette(), and updateColors().

172 {
173  const float(* colValues)[3];
174  colValues = isColorSetLight() ? fireworks::s_forWhite : fireworks::s_forBlack;
175  if (m_paletteId == EPalette::kClassic)
176  {
177  // std::cout << "initColorTable classic \n";
178  resetColors(colValues, fireworks::s_size, m_startColorIndex, m_gammaOff);
179  }
180  else {
181  // std::cout << "initColorTable extra \n";
182  float (*ev)[3] = (float (*)[3])calloc(3*fireworks::s_size, sizeof (float));
183  for (int ci = 0; ci < 34; ++ci) {
184  for (int j = 0; j < 3; ++j)
185  ev[ci][j] = colValues[ci][j];
186 
187  }
189  resetColors(ev, fireworks::s_size, m_startColorIndex, m_gammaOff);
190  }
191 
192  // AMT: Commented out ... Why this is necessary ?
193  //float eveGamma = isColorSetLight() ? 1.666*m_gammaOff - 2.5 : 1.666*m_gammaOff;
194  //TEveUtil::SetColorBrightness(eveGamma);
195 }
Bool_t isColorSetLight() const
static void resetColors(const float(*iColors)[3], unsigned int iSize, unsigned int iStart, float gammaOff)
bool ev
EPalette m_paletteId
void GetColorValuesForPaletteExtra(float(*iColors)[3], unsigned int iSize, FWColorManager::EPalette id, bool isWhiteBg)
Color_t m_startColorIndex
void FWColorManager::initialize ( )

Definition at line 136 of file FWColorManager.cc.

References objects.autophobj::float, m_numColorIndices, m_startColorIndex, and s_defaultStartColorIndex.

137 {
139  m_numColorIndices = fireworks::s_size;
140 
141  int index = m_startColorIndex;
142  //std::cout <<"start color index "<<m_startColorIndex<<std::endl;
143 
144  const float(* itEnd)[3] = fireworks::s_forBlack+fireworks::s_size;
145  for(const float(* it)[3] = fireworks::s_forBlack;
146  it != itEnd;
147  ++it) {
148  //NOTE: this constructor automatically places this color into the gROOT color list
149  //std::cout <<" color "<< index <<" "<<(*it)[0]<<" "<<(*it)[1]<<" "<<(*it)[2]<<std::endl;
150  if ( index <= gROOT->GetListOfColors()->GetLast())
151  gROOT->GetListOfColors()->RemoveAt(index);
152  new TColor(index++,(*it)[0],(*it)[1],(*it)[2]);
153  }
154 
155  // Save default ROOT colors.
156  TEveUtil::SetColorBrightness(0, kFALSE);
157 }
Color_t m_numColorIndices
static const Color_t s_defaultStartColorIndex
Color_t m_startColorIndex
Bool_t FWColorManager::isColorSetDark ( ) const
inline
Bool_t FWColorManager::isColorSetLight ( ) const
inline
int FWColorManager::numberOfLimitedColors ( ) const
inline

Definition at line 63 of file FWColorManager.h.

References m_numColorIndices.

63 {return m_numColorIndices;}
Color_t m_numColorIndices
int FWColorManager::offsetOfLimitedColors ( ) const
inline

Definition at line 64 of file FWColorManager.h.

References m_startColorIndex.

64 {return m_startColorIndex;}
Color_t m_startColorIndex
Color_t FWColorManager::oldColorToIndex ( Color_t  iColor,
int  version 
) const

Definition at line 335 of file FWColorManager.cc.

Referenced by borderOfLimitedColors(), and FWEventItemsManager::setFrom().

336 {
337  enum {
338  kFWRed = 1008,
339  kFWBlue = 1005,
340  kFWCyan = 1007,
341  kFWGreen = 1009,
342  kFWMagenta = 1001,
343  kFWOrange = 1004,
344  kFWYellow = 1000
345  };
346 
347  if (version < 3)
348  {
349  if(nullptr==m_oldColorToIndexMap.get()) {
350  m_oldColorToIndexMap = std::make_shared<std::map<Color_t,Color_t> >();
351  (*m_oldColorToIndexMap)[kRed]=kFWRed;
352  (*m_oldColorToIndexMap)[kBlue]=kFWBlue;
353  (*m_oldColorToIndexMap)[kYellow]=kFWYellow;
354  (*m_oldColorToIndexMap)[kGreen]=kFWGreen;
355  (*m_oldColorToIndexMap)[kCyan]=kFWCyan;
356  (*m_oldColorToIndexMap)[kTeal]=kFWCyan;
357  (*m_oldColorToIndexMap)[kMagenta]=kFWMagenta;
358  (*m_oldColorToIndexMap)[kViolet]=kFWMagenta;
359  (*m_oldColorToIndexMap)[kOrange]=kFWOrange;
360  (*m_oldColorToIndexMap)[3]=kFWGreen;
361 
362  }
363  return (*m_oldColorToIndexMap)[iColor];
364  }
365  else if (version == 3)
366  {
367  return iColor+ 1000;
368  }
369  else
370  {
371  const static unsigned int s_version45offset = 5;
372  return iColor < 1011 ? iColor : iColor + s_version45offset ;
373  }
374 }
static std::shared_ptr< std::map< Color_t, Color_t > > m_oldColorToIndexMap
const FWColorManager& FWColorManager::operator= ( const FWColorManager )
privatedelete
void FWColorManager::propagatePaletteChanges ( ) const

Definition at line 203 of file FWColorManager.cc.

References colorsHaveChanged_, colorsHaveChangedFinished_, geomColorsHaveChanged_, and m_changeManager.

Referenced by geomTransparency(), CmsShowCommon::setPalette(), and updateColors().

204 {
209 }
sigc::signal< void > geomColorsHaveChanged_
FWModelChangeManager * m_changeManager
sigc::signal< void > colorsHaveChangedFinished_
sigc::signal< void > colorsHaveChanged_
void FWColorManager::setBackgroundAndBrightness ( BackgroundColorIndex  iIndex,
int  b 
)

Definition at line 255 of file FWColorManager.cc.

References m_gammaOff, and setBackgroundColorIndex().

Referenced by getPalette(), and CmsShowCommon::setFrom().

256 {
257  m_gammaOff = -b*0.1f;
258  setBackgroundColorIndex(iIndex);
259 }
void setBackgroundColorIndex(BackgroundColorIndex)
double b
Definition: hdecay.h:120
void FWColorManager::setBackgroundColorIndex ( BackgroundColorIndex  iIndex)
void FWColorManager::setBrightness ( int  b)

Definition at line 212 of file FWColorManager.cc.

References m_gammaOff, and updateColors().

Referenced by getPalette(), and CmsShowCommon::setGamma().

213 {
214  // Called from CmsShowBrightnessPopup slider where range is set
215  // to: -15, 15.
216  m_gammaOff = -b*0.1f;
217  updateColors();
218 }
double b
Definition: hdecay.h:120
Bool_t FWColorManager::setColorSetViewer ( TGLViewer *  v,
Color_t  iColor 
)
static

Definition at line 262 of file FWColorManager.cc.

References kBlackIndex, and kWhiteIndex.

Referenced by FWEveViewManager::finishViewCreate(), getPalette(), FWTrackHitsDetailView::setBackgroundColor(), and FWEveView::setBackgroundColor().

263 {
264  if ( (iColor == kBlackIndex && !v->IsColorSetDark()) ||
265  (iColor == kWhiteIndex && v->IsColorSetDark()) )
266  {
267  v->SwitchColorSet();
268  return kTRUE;
269  }
270  return kFALSE;
271 }
void FWColorManager::setDefaultGeomColors ( )

Definition at line 100 of file FWColorManager.cc.

References kArctic, kFall, kFwHGCalEEColorIndex, kFwHGCalHScColorIndex, kFwHGCalHSiColorIndex, kFWMuonBarrelLineColorIndex, kFWMuonEndcapLineColorIndex, kFWPixelBarrelColorIndex, kFWPixelEndcapColorIndex, kFWTrackerBarrelColorIndex, kFWTrackerEndcapColorIndex, kPurple, kSpring, m_geomColor, and m_paletteId.

Referenced by FWColorManager(), geomTransparency(), and setPalette().

101 {
104 
107 
110 
114 
115  switch (m_paletteId) {
116  case (kArctic):
117  // m_geomColor[kFWMuonBarrelLineColorIndex] = 1027;
118  //m_geomColor[kFWMuonEndcapLineColorIndex] = 1027;
119  break;
120  case (kFall):
122  break;
123  case (kSpring):
126  break;
127  case (kPurple):
128  m_geomColor[kFWMuonBarrelLineColorIndex] = 1027; //kBlue -1;
130  break;
131  default:
132  break;
133  }
134 }
EPalette m_paletteId
Color_t m_geomColor[kFWGeomColorSize]
void FWColorManager::setGeomColor ( FWGeomColorIndex  idx,
Color_t  iColor 
)

Definition at line 274 of file FWColorManager.cc.

References geomColorsHaveChanged_, training_settings::idx, and m_geomColor.

Referenced by getPalette(), CmsShowCommon::setFrom(), and CmsShowCommon::setGeomColor().

275 {
276  // printf("set geom color %d \n", iColor);
277  m_geomColor[idx] = iColor;
279  gEve->Redraw3D();
280 }
sigc::signal< void > geomColorsHaveChanged_
Color_t m_geomColor[kFWGeomColorSize]
void FWColorManager::setGeomTransparency ( Color_t  idx,
bool  projectedType 
)

Definition at line 282 of file FWColorManager.cc.

References geomTransparencyHaveChanged_, m_geomTransparency2D, and m_geomTransparency3D.

Referenced by getPalette(), FW3DViewBase::setFrom(), CmsShowCommon::setFrom(), and CmsShowCommon::setGeomTransparency().

283 {
284  if (projectedType)
285  m_geomTransparency2D = iTransp;
286  else
287  m_geomTransparency3D = iTransp;
288 
289  geomTransparencyHaveChanged_.emit(projectedType);
290 
291  gEve->Redraw3D();
292 }
sigc::signal< void, bool > geomTransparencyHaveChanged_
Char_t m_geomTransparency2D
Char_t m_geomTransparency3D
void FWColorManager::setPalette ( long long  x)
void FWColorManager::switchBackground ( )
void FWColorManager::updateColors ( )
private

Definition at line 197 of file FWColorManager.cc.

References initColorTable(), and propagatePaletteChanges().

Referenced by defaultBrightness(), setBackgroundColorIndex(), and setBrightness().

198 {
199  initColorTable();
201 }
void propagatePaletteChanges() const

Member Data Documentation

sigc::signal<void> FWColorManager::colorsHaveChanged_
mutable
sigc::signal<void> FWColorManager::colorsHaveChangedFinished_
mutable

Definition at line 109 of file FWColorManager.h.

Referenced by FWGUIManager::FWGUIManager(), and propagatePaletteChanges().

sigc::signal<void> FWColorManager::geomColorsHaveChanged_
mutable
sigc::signal<void, bool> FWColorManager::geomTransparencyHaveChanged_
mutable
Color_t FWColorManager::m_background
private
FWModelChangeManager* FWColorManager::m_changeManager
private

Definition at line 125 of file FWColorManager.h.

Referenced by propagatePaletteChanges(), and setPalette().

Color_t FWColorManager::m_foreground
private

Definition at line 124 of file FWColorManager.h.

Referenced by foreground(), and setBackgroundColorIndex().

Float_t FWColorManager::m_gammaOff
private
Color_t FWColorManager::m_geomColor[kFWGeomColorSize]
private

Definition at line 130 of file FWColorManager.h.

Referenced by geomColor(), setDefaultGeomColors(), and setGeomColor().

Char_t FWColorManager::m_geomTransparency2D
private

Definition at line 131 of file FWColorManager.h.

Referenced by geomTransparency(), and setGeomTransparency().

Char_t FWColorManager::m_geomTransparency3D
private

Definition at line 132 of file FWColorManager.h.

Referenced by geomTransparency(), and setGeomTransparency().

Color_t FWColorManager::m_numColorIndices
private
EPalette FWColorManager::m_paletteId
private

Definition at line 119 of file FWColorManager.h.

Referenced by getPalette(), initColorTable(), setDefaultGeomColors(), and setPalette().

Color_t FWColorManager::m_startColorIndex
private
const Color_t FWColorManager::s_defaultStartColorIndex = 1000
staticprivate

Definition at line 134 of file FWColorManager.h.

Referenced by getDefaultStartColorIndex(), and initialize().