lemon/graph_to_eps.h
changeset 1574 697ed4dd309a
parent 1573 b76a0af36f44
child 1575 438bc5defad1
equal deleted inserted replaced
4:cfa306139f4a 5:fb5e39f31832
    53   ///Default constructor
    53   ///Default constructor
    54   Color() {}
    54   Color() {}
    55   ///Constructor
    55   ///Constructor
    56   Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
    56   Color(double r,double g,double b) :_r(r),_g(g),_b(b) {};
    57   ///Returns the red component
    57   ///Returns the red component
    58 
    58  
    59   ///\todo \c red() could be a better name...
    59   ///\todo \c red() could be a better name...
       
    60   ///
    60   double getR() const {return _r;}
    61   double getR() const {return _r;}
    61   ///Returns the green component
    62   ///Returns the green component
    62   double getG() const {return _g;}
    63   double getG() const {return _g;}
    63   ///Returns the blue component
    64   ///Returns the blue component
    64   double getB() const {return _b;}
    65   double getB() const {return _b;}
    80   std::vector<Color> colors;
    81   std::vector<Color> colors;
    81 public:
    82 public:
    82   ///Constructor
    83   ///Constructor
    83 
    84 
    84   ///Constructor
    85   ///Constructor
    85   ///\param have_white indicates wheter white is
    86   ///\param have_white indicates whether white is
    86   ///amongst the provided color (\c true) or not (\c false). If it is true,
    87   ///amongst the provided color (\c true) or not (\c false). If it is true,
    87   ///white will be assigned to \c 0.
    88   ///white will be assigned to \c 0.
    88   ///\param num the number of the allocated colors. If it is \c 0
    89   ///\param num the number of the allocated colors. If it is \c 0
    89   ///the default color configuration is set up (26 color plus the while).
    90   ///the default color configuration is set up (26 color plus the while).
    90   ///If \c num is less then 26/27 then the default color list is cut. Otherwise
    91   ///If \c num is less then 26/27 then the default color list is cut. Otherwise
    91   ///the color list is filled repeatedly with the default color list.
    92   ///the color list is filled repeatedly with the default color list.
       
    93   ///(The colors can be changed later on.)
    92   ColorSet(bool have_white=false,int num=0)
    94   ColorSet(bool have_white=false,int num=0)
    93   {
    95   {
    94     do {
    96     do {
    95       if(have_white) colors.push_back(Color(1,1,1));
    97       if(have_white) colors.push_back(Color(1,1,1));
    96 
    98 
   142   {
   144   {
   143     colors[i%colors.size()]=c;
   145     colors[i%colors.size()]=c;
   144   }
   146   }
   145   ///Sets the number of the exiting colors.
   147   ///Sets the number of the exiting colors.
   146   void resize(int s) { colors.resize(s);}
   148   void resize(int s) { colors.resize(s);}
   147   ///Returns the munber of the existing colors.
   149   ///Returns the number of the existing colors.
   148   std::size_t size() const { return colors.size();}
   150   std::size_t size() const { return colors.size();}
   149 };
   151 };
   150 
   152 
   151 ///Returns a visible distinct \ref Color
   153 ///Returns a visible distinct \ref Color
   152 
   154 
   157   return Color(c.getR()<.5?1:0,c.getG()<.5?1:0,c.getB()<.5?1:0);
   159   return Color(c.getR()<.5?1:0,c.getG()<.5?1:0,c.getB()<.5?1:0);
   158 }
   160 }
   159 ///Returns black for light colors and white for the dark ones.
   161 ///Returns black for light colors and white for the dark ones.
   160 
   162 
   161 ///Returns black for light colors and white for the dark ones.
   163 ///Returns black for light colors and white for the dark ones.
   162 ///\todo weighted average would be better
       
   163 inline Color distantBW(const Color &c){
   164 inline Color distantBW(const Color &c){
   164   double v=(.2125*c.getR()+.7154*c.getG()+.0721*c.getB())<.5?1:0;
   165   double v=(.2125*c.getR()+.7154*c.getG()+.0721*c.getB())<.5?1:0;
   165   return Color(v,v,v);
   166   return Color(v,v,v);
   166 }
   167 }
   167 
   168 
   595   GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;}
   596   GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;}
   596   
   597   
   597   ///Enables parallel edges
   598   ///Enables parallel edges
   598 
   599 
   599   ///Enables parallel edges
   600   ///Enables parallel edges
   600   ///\todo Partially implemented
       
   601   GraphToEps<T> &enableParallel(bool b=true) {_enableParallel=b;return *this;}
   601   GraphToEps<T> &enableParallel(bool b=true) {_enableParallel=b;return *this;}
   602   
   602   
   603   ///Sets the distance 
   603   ///Sets the distance 
   604   
   604   
   605   ///Sets the distance 
   605   ///Sets the distance