File indexing completed on 2024-04-06 12:11:30
0001 #ifndef Fireworks_Core_FWColorManager_h
0002 #define Fireworks_Core_FWColorManager_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <vector>
0023 #include "sigc++/signal.h"
0024 #include "Rtypes.h"
0025
0026
0027
0028
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 kFWMtdBarrelColorIndex,
0043 kFWMtdEndcapColorIndex,
0044 kFWGeomColorSize
0045 };
0046
0047 class FWColorManager {
0048 public:
0049 enum EPalette { kPaletteFirst = 0, kClassic = 0, kPurple, kFall, kSpring, kArctic, kPaletteLast };
0050
0051 FWColorManager(FWModelChangeManager*);
0052 virtual ~FWColorManager();
0053
0054 void initialize();
0055
0056
0057 Color_t background() const { return m_background; }
0058 Color_t foreground() const { return m_foreground; }
0059 Bool_t isColorSetDark() const { return m_background == kBlackIndex; }
0060 Bool_t isColorSetLight() const { return m_background == kWhiteIndex; }
0061
0062 int numberOfLimitedColors() const { return m_numColorIndices; }
0063 int offsetOfLimitedColors() const { return m_startColorIndex; }
0064 int borderOfLimitedColors() const { return m_startColorIndex + m_numColorIndices; }
0065
0066 void fillLimitedColors(std::vector<Color_t>& cv) const;
0067
0068
0069 Color_t oldColorToIndex(Color_t, int version) const;
0070
0071 bool colorHasIndex(Color_t) const;
0072
0073 Color_t geomColor(FWGeomColorIndex) const;
0074
0075 enum BackgroundColorIndex { kWhiteIndex = kWhite, kBlackIndex = kBlack };
0076
0077 BackgroundColorIndex backgroundColorIndex() const;
0078 EPalette getPalette() const { return m_paletteId; }
0079
0080
0081
0082 static Bool_t setColorSetViewer(TGLViewer*, Color_t);
0083
0084 static Color_t getDefaultStartColorIndex();
0085
0086
0087
0088 void defaultBrightness();
0089 void setBrightness(int);
0090 int brightness();
0091 void setBackgroundColorIndex(BackgroundColorIndex);
0092 void setBackgroundAndBrightness(BackgroundColorIndex, int);
0093 void switchBackground();
0094
0095 void setPalette(long long);
0096
0097 void setGeomColor(FWGeomColorIndex, Color_t);
0098 void setGeomTransparency(Color_t idx, bool projectedType);
0099 Color_t geomTransparency(bool projected) const { return projected ? m_geomTransparency2D : m_geomTransparency3D; }
0100
0101 void setDefaultGeomColors();
0102 void propagatePaletteChanges() const;
0103 mutable sigc::signal<void()> colorsHaveChanged_;
0104 mutable sigc::signal<void()> geomColorsHaveChanged_;
0105 mutable sigc::signal<void(bool)> geomTransparencyHaveChanged_;
0106
0107
0108 mutable sigc::signal<void()> colorsHaveChangedFinished_;
0109
0110 FWColorManager(const FWColorManager&) = delete;
0111
0112 const FWColorManager& operator=(const FWColorManager&) = delete;
0113
0114 public:
0115 void updateColors();
0116 void initColorTable();
0117
0118
0119 EPalette m_paletteId;
0120
0121 Float_t m_gammaOff;
0122
0123 Color_t m_background;
0124 Color_t m_foreground;
0125 FWModelChangeManager* m_changeManager;
0126
0127 Color_t m_startColorIndex;
0128 Color_t m_numColorIndices;
0129
0130 Color_t m_geomColor[kFWGeomColorSize];
0131 Char_t m_geomTransparency2D;
0132 Char_t m_geomTransparency3D;
0133
0134 static const Color_t s_defaultStartColorIndex;
0135 };
0136
0137 #endif