COIN-OR::LEMON - Graph Library

Changeset 1971:9a59a6cacfd9 in lemon-0.x


Ignore:
Timestamp:
02/20/06 07:41:12 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2555
Message:
  • RGB color related stuff is in color.h now
  • eps.h: A simple class to create .eps figures (demo: eps_demo.h)
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • demo/Makefile.am

    r1920 r1971  
    99        reader_writer_demo \
    1010        dim_to_lgf \
     11        eps_demo \
    1112        graph_to_eps_demo \
    1213        graph_orientation \
     
    3233
    3334dijkstra_demo_SOURCES = dijkstra_demo.cc
     35
     36eps_demo_SOURCES = eps_demo.cc
    3437
    3538reader_writer_demo_SOURCES = reader_writer_demo.cc
  • lemon/Makefile.am

    r1968 r1971  
    99        lp_base.cc \
    1010        lp_skeleton.cc \
    11         base.cc
     11        base.cc \
     12        eps.cc
    1213libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
    1314libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS)
     
    2728        dfs.h \
    2829        bin_heap.h \
     30        color.h \
    2931        config.h \
    3032        counter.h \
     
    3436        edge_set.h \
    3537        error.h \
     38        eps.h \
    3639        fib_heap.h \
    3740        floyd_warshall.h \
  • lemon/graph_to_eps.h

    r1956 r1971  
    3434#include<lemon/xy.h>
    3535#include<lemon/maps.h>
     36#include<lemon/color.h>
    3637#include<lemon/bezier.h>
    3738
     
    4445
    4546namespace lemon {
    46 
    47 ///Data structure representing RGB colors.
    48 
    49 ///Data structure representing RGB colors.
    50 ///\ingroup misc
    51 class Color
    52 {
    53   double _r,_g,_b;
    54 public:
    55   ///Default constructor
    56   Color() {}
    57   ///Constructor
    58   Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
    59   ///Returns the red component
    60   double & red() {return _r;}
    61   ///Returns the red component
    62   const double & red() const {return _r;}
    63   ///Returns the green component
    64   double & green() {return _g;}
    65   ///Returns the green component
    66   const double & green() const {return _g;}
    67   ///Returns the blue component
    68   double & blue() {return _b;}
    69   ///Returns the blue component
    70   const double & blue() const {return _b;}
    71   ///Set the color components
    72   void set(double r,double g,double b) { _r=r;_g=g;_b=b; };
    73 };
    74 
    75 ///Maps <tt>int</tt>s to different \ref Color "Color"s
    76 
    77 ///This map assigns one of the predefined \ref Color "Color"s
    78 ///to each <tt>int</tt>. It is possible to change the colors as well as their
    79 ///number. The integer range is cyclically mapped to the provided set of colors.
    80 ///
    81 ///This is a true \ref concept::ReferenceMap "reference map", so you can also
    82 ///change the actual colors.
    83 
    84 class ColorSet : public MapBase<int,Color>
    85 {
    86   std::vector<Color> colors;
    87 public:
    88   ///Constructor
    89 
    90   ///Constructor
    91   ///\param have_white indicates whether white is
    92   ///amongst the provided color (\c true) or not (\c false). If it is true,
    93   ///white will be assigned to \c 0.
    94   ///\param num the number of the allocated colors. If it is \c 0
    95   ///the default color configuration is set up (26 color plus the while).
    96   ///If \c num is less then 26/27 then the default color list is cut. Otherwise
    97   ///the color list is filled repeatedly with the default color list.
    98   ///(The colors can be changed later on.)
    99   ColorSet(bool have_white=false,int num=0)
    100   {
    101     do {
    102       if(have_white) colors.push_back(Color(1,1,1));
    103 
    104       colors.push_back(Color(0,0,0));
    105       colors.push_back(Color(1,0,0));
    106       colors.push_back(Color(0,1,0));
    107       colors.push_back(Color(0,0,1));
    108       colors.push_back(Color(1,1,0));
    109       colors.push_back(Color(1,0,1));
    110       colors.push_back(Color(0,1,1));
    111      
    112       colors.push_back(Color(.5,0,0));
    113       colors.push_back(Color(0,.5,0));
    114       colors.push_back(Color(0,0,.5));
    115       colors.push_back(Color(.5,.5,0));
    116       colors.push_back(Color(.5,0,.5));
    117       colors.push_back(Color(0,.5,.5));
    118      
    119       colors.push_back(Color(.5,.5,.5));
    120       colors.push_back(Color(1,.5,.5));
    121       colors.push_back(Color(.5,1,.5));
    122       colors.push_back(Color(.5,.5,1));
    123       colors.push_back(Color(1,1,.5));
    124       colors.push_back(Color(1,.5,1));
    125       colors.push_back(Color(.5,1,1));
    126      
    127       colors.push_back(Color(1,.5,0));
    128       colors.push_back(Color(.5,1,0));
    129       colors.push_back(Color(1,0,.5));
    130       colors.push_back(Color(0,1,.5));
    131       colors.push_back(Color(0,.5,1));
    132       colors.push_back(Color(.5,0,1));
    133     } while(int(colors.size())<num);
    134     //    colors.push_back(Color(1,1,1));
    135     if(num>0) colors.resize(num);
    136   }
    137   ///\e
    138   Color &operator[](int i)
    139   {
    140     return colors[i%colors.size()];
    141   }
    142   ///\e
    143   const Color &operator[](int i) const
    144   {
    145     return colors[i%colors.size()];
    146   }
    147   ///\e
    148   void set(int i,const Color &c)
    149   {
    150     colors[i%colors.size()]=c;
    151   }
    152   ///Sets the number of the exiting colors.
    153   void resize(int s) { colors.resize(s);}
    154   ///Returns the number of the existing colors.
    155   std::size_t size() const { return colors.size();}
    156 };
    157 
    158 ///Returns a visible distinct \ref Color
    159 
    160 ///Returns a \ref Color which is as different from the given parameter
    161 ///as it is possible.
    162 inline Color distantColor(const Color &c)
    163 {
    164   return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
    165 }
    166 ///Returns black for light colors and white for the dark ones.
    167 
    168 ///Returns black for light colors and white for the dark ones.
    169 inline Color distantBW(const Color &c){
    170   double v=(.2125*c.red()+.7154*c.green()+.0721*c.blue())<.5?1:0;
    171   return Color(v,v,v);
    172 }
    17347
    17448template<class MT>
Note: See TracChangeset for help on using the changeset viewer.