2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
24 * Implementation of inline methods defined in Board2D.h
26 * This file is part of the DGtal library.
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
33 //////////////////////////////////////////////////////////////////////////////
35 #include "DGtal/io/boards/CDrawableWithBoard2D.h"
36 //////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////
41 // Implementation of inline methods //
44 * @return the current mode for the given object name or "" if no
45 * specific mode has been set.
49 DGtal::Board2D::getMode( const std::string & objectName ) const
51 ModeMapping::const_iterator itm = myModes.find( objectName );
52 return itm == myModes.end() ? "" : itm->second;
56 * Draws the drawable [object] in this board. It should satisfy
57 * the concept CDrawableWithBoard2D, which requires for instance a
58 * method setStyle( LibBoard::Board ).
60 * @param object the drawable object.
61 * @return a reference on 'this'.
63 template <typename TDrawableWithBoard2D>
66 DGtal::Board2D::operator<<( const TDrawableWithBoard2D & object )
69 BOOST_CONCEPT_ASSERT((concepts::CDrawableWithBoard2D<TDrawableWithBoard2D>));
71 CountedPtr<DrawableWithBoard2D> style( defaultStyle(object) );
73 trace.info() << "[operator<<] " << object.className();
76 // Apply default style
80 trace.info() << " [default style]";
82 DGtal::Style2DFactory::draw(*this, style.get());
84 // Apply Customized style
85 StyleMapping::const_iterator it = myStyles.find( object.className() );
86 if ( it != myStyles.end() )
87 if ( it->second.get() != 0 )
90 trace.info() << " [specific style]";
92 DGtal::Style2DFactory::draw(*this, it->second.get());
94 // Check for specific mode.
95 ModeMapping::const_iterator itm = myModes.find( object.className() );
96 if ( itm != myModes.end() )
99 trace.info() << " [mode]";
102 // Apply default style for specific mode.
103 CountedPtr<DrawableWithBoard2D> style_mode
104 ( defaultStyle(object, itm->second) );
105 if ( style_mode.get() )
108 trace.info() << " [default style for mode]";
110 DGtal::Style2DFactory::draw(*this, style_mode.get());
112 // Apply customized style for specific mode.
113 std::string specific_style = object.className() + "/" + itm->second;
114 it = myStyles.find( specific_style );
115 if ( it != myStyles.end() )
116 if ( it->second.get() != 0 )
119 trace.info() << " [specific style for mode: "
120 << specific_style << "]";
122 DGtal::Style2DFactory::draw(*this, it->second.get());
126 trace.info() << " [draw]";
129 DGtal::Display2DFactory::draw(*this, object);
131 std::cerr << std::endl;
137 ///////////////////////////////////////////////////////////////////////////////
138 // Implementation of inline functions and external operators //
141 * Overloads 'operator<<' for displaying objects of class 'Board2D'.
142 * @param out the output stream where the object is written.
143 * @param object the object of class 'Board2D' to write.
144 * @return the output stream after the writing.
148 DGtal::operator<< ( std::ostream & out,
149 const Board2D & object )
151 object.selfDisplay ( out );
156 ///////////////////////////////////////////////////////////////////////////////