Changeset 919
- Timestamp:
- Dec 1, 2009, 12:03:31 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Colours.cc
r916 r919 31 31 32 32 Colours::Colours(void) 33 : colour_map_(14) 33 : colour_map_(13), next_colour_(colour_map_.begin()) 34 34 35 { 35 36 colour_map_[ 0].label="green"; … … 59 60 colour_map_[12].label="black"; 60 61 colour_map_[12].r= 0; colour_map_[12].g= 0; colour_map_[12].b= 0; 61 colour_map_[13].label="white";62 colour_map_[13].r=255; colour_map_[13].g=255; colour_map_[13].b=255;63 64 // temporary until proper configuration is implemented65 std::vector<colour>::iterator i=colour_map_.begin();66 author_map_["jari"]=i++;67 author_map_["peter"]=i++;68 62 } 69 63 70 64 71 65 void Colours::get_colour(const std::string& label, unsigned char& r, 72 unsigned char& g, unsigned char& b) const66 unsigned char& g, unsigned char& b) 73 67 { 74 r=g=b=0;75 68 std::map<std::string,std::vector<colour>::iterator>::const_iterator i; 76 if ((i=author_map_.find(label)) == author_map_.end()) 77 // no colour defined for label 78 return; 79 r=i->second->r; g=i->second->g; b=i->second->b; 69 if ((i=author_map_.find(label)) == author_map_.end()) { 70 // no colour defined for label, set colour for label 71 author_map_[label]=next_colour_++; 72 if (next_colour_==colour_map_.end()) 73 // end of colour map reach, start over 74 next_colour_=colour_map_.begin(); 75 } 76 r=author_map_[label]->r; 77 g=author_map_[label]->g; 78 b=author_map_[label]->b; 80 79 } 81 80 -
trunk/lib/Colours.h
r916 r919 30 30 namespace svndigest { 31 31 32 /** 33 The author-colour mapping is provided by the Colours class. 34 35 Colours use the singleton design pattern. 36 */ 32 37 class Colours 33 38 { 34 39 public: 35 40 41 /** 42 \brief Get RGB colour for \a label 43 44 If \a label has no assigned colour, the next unused colour is 45 automatically assigned to \a label. The number of available 46 unique colours is low, when all colours are used mapped with a 47 \a label once, the colours are reused. 48 49 \see To be written. If a specific colour is to be assigned for 50 a label, use function TBA. 51 */ 36 52 void get_colour(const std::string& label, unsigned char& r, 37 unsigned char& g, unsigned char& b) const;53 unsigned char& g, unsigned char& b); 38 54 55 /** 56 \brief Get an instance of Colour 57 */ 39 58 static Colours& instance(void); 40 59 … … 57 76 }; 58 77 78 std::map<std::string, std::vector<colour>::iterator> author_map_; 79 std::vector<colour> colour_map_; 59 80 static Colours* instance_; 60 std::vector<colour> colour_map_; 61 std::map<std::string, std::vector<colour>::iterator> author_map_; 81 std::vector<colour>::iterator next_colour_; 62 82 }; 63 83 -
trunk/test/Makefile.am
r912 r919 22 22 check_SCRIPTS = svn_update.sh 23 23 24 check_PROGRAMS = cache_partial_test \24 check_PROGRAMS = cache_partial_test colour_test \ 25 25 config_test copyright_test date_test \ 26 26 parser_test stats_test trac_test utility_test … … 54 54 55 55 cache_partial_test_SOURCES = cache_partial_test.cc 56 colour_test_SOURCES = colour_test.cc 56 57 config_test_SOURCES = config_test.cc 57 58 copyright_test_SOURCES = copyright_test.cc
Note: See TracChangeset
for help on using the changeset viewer.