Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:01

0001 #ifndef Fireworks_Core_FWColorManager_h
0002 #define Fireworks_Core_FWColorManager_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Core
0006 // Class  :     FWColorManager
0007 //
0008 /**\class FWColorManager FWColorManager.h Fireworks/Core/interface/FWColorManager.h
0009 
0010  Description: <one line class summary>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Tue Mar 24 10:07:58 CET 2009
0019 //
0020 
0021 // system include files
0022 #include <vector>
0023 #include "sigc++/signal.h"
0024 #include "Rtypes.h"
0025 
0026 // user include files
0027 
0028 // forward declarations
0029 class FWModelChangeManager;
0030 class TGLViewer;
0031 
0032 enum FWGeomColorIndex {
0033   kFWPixelBarrelColorIndex,
0034   kFWPixelEndcapColorIndex,
0035   kFWTrackerBarrelColorIndex,
0036   kFWTrackerEndcapColorIndex,
0037   kFWMuonBarrelLineColorIndex,
0038   kFWMuonEndcapLineColorIndex,
0039   kFwHGCalEEColorIndex,
0040   kFwHGCalHSiColorIndex,
0041   kFwHGCalHScColorIndex,
0042   kFWGeomColorSize
0043 };
0044 
0045 class FWColorManager {
0046 public:
0047   enum EPalette { kPaletteFirst = 0, kClassic = 0, kPurple, kFall, kSpring, kArctic, kPaletteLast };
0048 
0049   FWColorManager(FWModelChangeManager*);
0050   virtual ~FWColorManager();
0051 
0052   void initialize();
0053 
0054   // ---------- const member functions ---------------------
0055   Color_t background() const { return m_background; }
0056   Color_t foreground() const { return m_foreground; }
0057   Bool_t isColorSetDark() const { return m_background == kBlackIndex; }
0058   Bool_t isColorSetLight() const { return m_background == kWhiteIndex; }
0059 
0060   int numberOfLimitedColors() const { return m_numColorIndices; }
0061   int offsetOfLimitedColors() const { return m_startColorIndex; }
0062   int borderOfLimitedColors() const { return m_startColorIndex + m_numColorIndices; }
0063 
0064   void fillLimitedColors(std::vector<Color_t>& cv) const;
0065 
0066   //help with backward compatibility with old config files
0067   Color_t oldColorToIndex(Color_t, int version) const;
0068 
0069   bool colorHasIndex(Color_t) const;
0070 
0071   Color_t geomColor(FWGeomColorIndex) const;
0072 
0073   enum BackgroundColorIndex { kWhiteIndex = kWhite, kBlackIndex = kBlack };
0074 
0075   BackgroundColorIndex backgroundColorIndex() const;
0076   EPalette getPalette() const { return m_paletteId; }
0077 
0078   // ---------- static member functions --------------------
0079 
0080   static Bool_t setColorSetViewer(TGLViewer*, Color_t);
0081 
0082   static Color_t getDefaultStartColorIndex();
0083 
0084   // ---------- member functions ---------------------------
0085 
0086   void defaultBrightness();
0087   void setBrightness(int);
0088   int brightness();
0089   void setBackgroundColorIndex(BackgroundColorIndex);
0090   void setBackgroundAndBrightness(BackgroundColorIndex, int);
0091   void switchBackground();
0092 
0093   void setPalette(long long);
0094 
0095   void setGeomColor(FWGeomColorIndex, Color_t);
0096   void setGeomTransparency(Color_t idx, bool projectedType);
0097   Color_t geomTransparency(bool projected) const { return projected ? m_geomTransparency2D : m_geomTransparency3D; }
0098 
0099   void setDefaultGeomColors();
0100   void propagatePaletteChanges() const;
0101   mutable sigc::signal<void()> colorsHaveChanged_;
0102   mutable sigc::signal<void()> geomColorsHaveChanged_;
0103   mutable sigc::signal<void(bool)> geomTransparencyHaveChanged_;
0104 
0105   //called after all the slots attached to colorsHaveChanged_ are done
0106   mutable sigc::signal<void()> colorsHaveChangedFinished_;
0107 
0108   FWColorManager(const FWColorManager&) = delete;  // stop default
0109 
0110   const FWColorManager& operator=(const FWColorManager&) = delete;  // stop default
0111 
0112 public:
0113   void updateColors();
0114   void initColorTable();
0115 
0116   // ---------- member data --------------------------------
0117   EPalette m_paletteId;
0118 
0119   Float_t m_gammaOff;
0120 
0121   Color_t m_background;
0122   Color_t m_foreground;
0123   FWModelChangeManager* m_changeManager;
0124 
0125   Color_t m_startColorIndex;
0126   Color_t m_numColorIndices;
0127 
0128   Color_t m_geomColor[kFWGeomColorSize];
0129   Char_t m_geomTransparency2D;
0130   Char_t m_geomTransparency3D;
0131 
0132   static const Color_t s_defaultStartColorIndex;
0133 };
0134 
0135 #endif