1 /* 2 * paint_style.cc -- ePiX's current line and fill style. 3 * 4 * This file is part of ePiX, a C++ library for creating high-quality 5 * figures in LaTeX 6 * 7 * Version 1.1.21 8 * Last Change: September 22, 2007 9 */ 10 11 /* 12 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 13 * Andrew D. Hwang <rot 13 nujnat at zngupf dot ubylpebff dot rqh> 14 * Department of Mathematics and Computer Science 15 * College of the Holy Cross 16 * Worcester, MA, 01610-2395, USA 17 */ 18 19 /* 20 * ePiX is free software; you can redistribute it and/or modify it 21 * under the terms of the GNU General Public License as published by 22 * the Free Software Foundation; either version 2 of the License, or 23 * (at your option) any later version. 24 * 25 * ePiX is distributed in the hope that it will be useful, but WITHOUT 26 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 27 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 28 * License for more details. 29 * 30 * You should have received a copy of the GNU General Public License 31 * along with ePiX; if not, write to the Free Software Foundation, Inc., 32 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 33 */ 34 #include "camera.h" 35 #include "length.h" 36 #include "pen_data.h" 37 #include "paint_style.h" 38 39 namespace ePiX { 40 41 // Magic numbers: initialization constants paint_state()42 paint_state::paint_state() 43 : m_line(pen_data()), m_base(Xfine()), 44 m_tint(Neutral()), m_filling(false) { } 45 clone() const46 paint_state* paint_state::clone() const 47 { 48 return new paint_state(*this); 49 } 50 51 // set line_pen(const pen_data & pen)52 void paint_state::line_pen(const pen_data& pen) 53 { 54 m_line = pen; 55 } 56 line_color(const Color & col)57 void paint_state::line_color(const Color& col) 58 { 59 m_line.color(col); 60 } 61 line_width(const length & len)62 void paint_state::line_width(const length& len) 63 { 64 m_line.width(len); 65 } 66 base_pen(const pen_data & pen)67 void paint_state::base_pen(const pen_data& pen) 68 { 69 m_base = pen; 70 } 71 base_color(const Color & col)72 void paint_state::base_color(const Color& col) 73 { 74 m_base.color(col); 75 } 76 base_width(const length & len)77 void paint_state::base_width(const length& len) 78 { 79 m_base.width(len); 80 } 81 fill_color(const Color & col)82 void paint_state::fill_color(const Color& col) 83 { 84 m_tint = col; 85 } 86 fill_flag(bool fill)87 void paint_state::fill_flag(bool fill) 88 { 89 m_filling = fill; 90 } 91 92 93 // get line_pen() const94 pen_data paint_state::line_pen() const 95 { 96 return m_line; 97 } line_color() const98 Color paint_state::line_color() const 99 { 100 return m_line.color(); 101 } line_width() const102 length paint_state::line_width() const 103 { 104 return m_line.width(); 105 } 106 base_pen() const107 pen_data paint_state::base_pen() const 108 { 109 return m_base; 110 } base_color() const111 Color paint_state::base_color() const 112 { 113 return m_base.color(); 114 } base_width() const115 length paint_state::base_width() const 116 { 117 return m_base.width(); 118 } 119 fill_color() const120 Color paint_state::fill_color() const 121 { 122 return m_tint; 123 } fill_flag() const124 bool paint_state::fill_flag() const 125 { 126 return m_filling; 127 } 128 seen_through(const Camera & mycam) const129 paint_state paint_state::seen_through(const Camera& mycam) const 130 { 131 return paint_state(m_line.seen_through(mycam), m_base.seen_through(mycam), 132 mycam(m_tint), m_filling); 133 } 134 paint_state(const pen_data & lp,const pen_data & bp,const Color & fc,bool ff)135 paint_state::paint_state(const pen_data& lp, const pen_data& bp, 136 const Color& fc, bool ff) 137 : m_line(lp), m_base(bp), m_tint(fc), m_filling(ff) { } 138 139 the_paint_style()140 paint_state& the_paint_style() 141 { 142 static paint_state* the_paint_state(new paint_state()); 143 return *the_paint_state; 144 } 145 } // end of namespace 146