Greens-code
A modular quantum transport code
pencils.hpp
1 #ifndef PENCILS_H_WATCH
2 #define PENCILS_H_WATCH
3 
4 #include "rectangle.hpp"
5 #include <memory>
6 
7 #include "iterators.hpp"
8 #include "my_mkl.hpp"
9 
10 class Bild;
11 
14 public:
15 
16  image_slice_coloring(const Rectangle::const_ref&,
17  const size_t drawing_layer,
18  const complex*,
19  Bild* b);
20 
22  template <class Pencil>
23  void coloring( Pencil& );
25  template <class Pencil>
26  void color_one_slice( const Pencil& );
27 
29  bool working() const { return (pos.position() != end);};
30 
32  const geometry_const_Iterator current() const { return pos.position();};
33 
36 
37 private:
38 
39  slice_Position pos;
40 
41  int drawing_layer_;
42 
44 
45  Bild* bild;
46 
47  size_t bild_nx;
48  size_t bild_ny;
49 
50  const complex* wv;
51 
52  void advance_slice();
53 
54  template <class Pencil>
55  void paint_slice( Pencil&);
56 
57 };
58 
59 class loadable_Object;
60 
61 class pencil{
62 public:
63  typedef std::unique_ptr<pencil> ref;
64 
65  pencil(){};
66  virtual ~pencil(){};
67 
68  void init_params( const STD_TR1::shared_ptr<const loadable_Object>& o)
69  { init_params_(o);};
70 
71  void coloring( image_slice_coloring& isc,
72  double min_x = -1.,
73  double max_x = -1.)
74  { coloring_(isc);};
75 
76  const std::string& name() const { return name_();};
77 
79  bool should_draw( int point_layer, int drawing_layer) const {
80  return should_draw_( point_layer, drawing_layer );};
81 
83  size_t number_of_drawing_layers() const {
84  return number_of_drawing_layers_();};
85 
86  template <class pencil_impl>
87  static std::unique_ptr<pencil> get_pencil(const pencil_impl& p);
88 
89 private:
90 
91  virtual void init_params_( const STD_TR1::shared_ptr<const loadable_Object>& o ) = 0;
92 
93  virtual void coloring_( image_slice_coloring& ) = 0;
94  virtual const std::string& name_() const = 0;
95 
96  virtual bool should_draw_( int point_layer,
97  int drawing_layer) const = 0;
98 
99  virtual size_t number_of_drawing_layers_() const = 0;
100 
101 };
102 
103 
105 
137 template <class pencil_impl>
138 class concrete_pencil: public pencil{
139 
140  friend class pencil;
141 
142 private:
143 
144  pencil_impl pen;
145 
146  void coloring_( image_slice_coloring& isc ){
147  isc.coloring<pencil_impl>( pen );
148  };
149 
150  void init_params_( const STD_TR1::shared_ptr<const loadable_Object>& o ){
151  pen.init_params(o);
152  };
153 
154 // default: we draw if point_layer equals drawing layer
155  bool should_draw_( int point_layer, int drawing_layer) const
156  {
157  return pen.should_draw( point_layer, drawing_layer);
158  };
159 
160  size_t number_of_drawing_layers_() const
161  {
162  return pen.number_of_drawing_layers();
163  };
164 
165  const std::string& name_() const { return pen.name();};
166 
167  concrete_pencil( const pencil_impl& p ) : pen( p ) {};
168  concrete_pencil();
170 
171 };
172 
173 template <class pencil_impl>
174 std::unique_ptr<pencil> pencil::get_pencil(const pencil_impl& p){
175  return std::unique_ptr<pencil>(new concrete_pencil<pencil_impl>(p));
176 }
177 
178 #endif
Definition: points.hpp:43
Definition: pencils.hpp:61
bool should_draw(int point_layer, int drawing_layer) const
should I draw a point on layer point_layer when drawing drawing_layer?
Definition: pencils.hpp:79
Definitions of abstract Rectangle base class.
Definition: iterators.hpp:13
Class to contain wave-function image data.
Definition: generate_wavefunction.hpp:25
void color_one_slice(const Pencil &)
paint current slice
Helper class to draw images efficiently.
Definition: pencils.hpp:13
bool working() const
are we finished?
Definition: pencils.hpp:29
size_t number_of_drawing_layers() const
how many drawing layers are there?
Definition: pencils.hpp:83
void coloring(Pencil &)
paint image as long as pen is valid
const geometry_const_Iterator current() const
get current slice
Definition: pencils.hpp:32
An abstract base class supporting xml_file_reading of input parameters.
Definition: input_file.hpp:79
void forward_to_specific_slice(const geometry_const_Iterator &)
forward to slice specified by pos
Definition: pencils.cpp:18
pencil_impl is the base class for all pencils
Definition: pencils.hpp:138