Changeset 928 for trunk/lib


Ignore:
Timestamp:
Dec 2, 2009, 8:43:57 AM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #413. Same colour for authors for all blame output and plots. Colours from config used.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Colours.cc

    r921 r928  
    2222#include "Colours.h"
    2323
     24#include "Configuration.h"
     25
    2426#include <cstdlib>
     27#include <ctype.h>
    2528
    2629namespace theplu {
     
    6063    colour_map_[12].label="black";
    6164    colour_map_[12].r=  0; colour_map_[12].g=  0; colour_map_[12].b=  0;
     65
     66    typedef std::map<std::string, std::string> ACmap;
     67    const ACmap& authcols=Configuration::instance().author_colors();
     68    std::map<std::string,std::vector<colour>::iterator>::iterator j;
     69    for (ACmap::const_iterator i=authcols.begin(); i!=authcols.end(); i++) {
     70      colour c;
     71      c.label=i->first;
     72      c.r= 16*to_decimal(i->second[0]) + to_decimal(i->second[1]);
     73      c.g= 16*to_decimal(i->second[2]) + to_decimal(i->second[3]);
     74      c.b= 16*to_decimal(i->second[4]) + to_decimal(i->second[5]);
     75      next_colour_=colour_map_.insert(next_colour_,c);
     76      author_map_.insert(std::make_pair(c.label, next_colour_++));
     77    }
    6278  }
    6379
     
    88104  }
    89105
     106
     107  int Colours::to_decimal(int hex)
     108  {
     109    hex=toupper(hex);
     110    if (hex>47 && hex<58) // 0--9
     111      return hex-48;
     112    if (hex>64 && hex<71) // A--F
     113      return hex-55;
     114    return -1;
     115  }
     116
    90117}} // end of namespace svndigest and namespace theplu
  • trunk/lib/Colours.h

    r919 r928  
    6565    Colours(const Colours&);
    6666
     67    // Convert char from hexadecimal to decimal, if char is out of
     68    // range -1 is returned.
     69    int to_decimal(int);
     70
    6771    // Assignment not implemented because assignment is always self-assignment
    6872    Colours& operator=(const Colours&);
  • trunk/lib/Configuration.cc

    r908 r928  
    22
    33/*
    4   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009 Peter Johansson
     4  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    65
    76  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    6059  }
    6160
     61
     62  const std::map<std::string, std::string>&
     63  Configuration::author_colors(void) const
     64  {
     65    return author_color_;
     66  }
    6267
    6368  std::string Configuration::author_str_color(const std::string& author) const
  • trunk/lib/Configuration.h

    r847 r928  
    55
    66/*
    7   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009 Peter Johansson
     7  Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    98
    109  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4645
    4746    /**
    48        \return hexadecimal color code (e.g. 5aee4a) that is used in
    49        blame output. If no color is configured for \a author, an empty
    50        string is returned.
     47       \return Hexadecimal color code (e.g. 5aee4a) that is used in
     48       blame output and as line colors in plots. If no color is
     49       configured for \a author, an empty string is returned.
    5150     */
    5251    std::string author_str_color(const std::string& author) const;
     52
     53    /**
     54       The map to lookup the author-color mapping set in the
     55       configuration file. The color code is a six digit hexadecimal
     56       number rrggbb.
     57
     58       \return The author-color map
     59    */
     60    const std::map<std::string, std::string>& author_colors(void) const;
    5361
    5462    /**
Note: See TracChangeset for help on using the changeset viewer.