DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Board2D.ih
1 
29 
30 // IMPLEMENTATION of inline methods.
32 
34 #include <cstdlib>
35 #include "DGtal/io/boards/CDrawableWithBoard2D.h"
36 
38 
39 
40 
42 // Implementation of inline methods //
43 
48 inline
49 std::string
50 DGtal::Board2D::getMode( const std::string & objectName ) const
51 {
52  ModeMapping::const_iterator itm = myModes.find( objectName );
53  return itm == myModes.end() ? "" : itm->second;
54 }
55 
64 template <typename TDrawableWithBoard2D>
65 inline
67 DGtal::Board2D::operator<<( const TDrawableWithBoard2D & object )
68 {
69 
70  BOOST_CONCEPT_ASSERT((CDrawableWithBoard2D<TDrawableWithBoard2D>));
71 
72  CountedPtr<DrawableWithBoard2D> style( defaultStyle(object) );
73 #ifdef DEBUG_VERBOSE
74  trace.info() << "[operator<<] " << object.className();
75 #endif
76 
77  // Apply default style
78  if ( style.get() )
79  {
80 #ifdef DEBUG_VERBOSE
81  trace.info() << " [default style]";
82 #endif
83  DGtal::Style2DFactory::draw(*this, style.get());
84  }
85  // Apply Customized style
86  StyleMapping::const_iterator it = myStyles.find( object.className() );
87  if ( it != myStyles.end() )
88  if ( it->second.get() != 0 )
89  {
90 #ifdef DEBUG_VERBOSE
91  trace.info() << " [specific style]";
92 #endif
93  DGtal::Style2DFactory::draw(*this, it->second.get());
94  }
95  // Check for specific mode.
96  ModeMapping::const_iterator itm = myModes.find( object.className() );
97  if ( itm != myModes.end() )
98  {
99  #ifdef DEBUG_VERBOSE
100  trace.info() << " [mode]";
101  #endif
102 
103  // Apply default style for specific mode.
105  ( defaultStyle(object, itm->second) );
106  if ( style_mode.get() )
107  {
108 #ifdef DEBUG_VERBOSE
109  trace.info() << " [default style for mode]";
110 #endif
111  DGtal::Style2DFactory::draw(*this, style_mode.get());
112  }
113  // Apply customized style for specific mode.
114  std::string specific_style = object.className() + "/" + itm->second;
115  it = myStyles.find( specific_style );
116  if ( it != myStyles.end() )
117  if ( it->second.get() != 0 )
118  {
119 #ifdef DEBUG_VERBOSE
120  trace.info() << " [specific style for mode: "
121  << specific_style << "]";
122 #endif
123  DGtal::Style2DFactory::draw(*this, it->second.get());
124  }
125  }
126 #ifdef DEBUG_VERBOSE
127  trace.info() << " [draw]";
128 #endif
129 
130  DGtal::Display2DFactory::draw(*this, object);
131 #ifdef DEBUG_VERBOSE
132  std::cerr << std::endl;
133 #endif
134  return *this;
135 }
136 
137 
139 // Implementation of inline functions and external operators //
140 
147 inline
148 std::ostream&
149 DGtal::operator<< ( std::ostream & out,
150  const Board2D & object )
151 {
152  object.selfDisplay ( out );
153  return out;
154 }
155 
156 // //
158 
159