OSDN Git Service

first
[psychlops/cpp.git] / psychlops / extension / standard / figure / psychlops_figure_standard.h
1 /*
2  *  psychlops_figure_standard.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2005/10/05 by Kenchi HOSOKAWA
6  *  (C) 2005 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
7  */
8
9 #ifndef HEADER_PSYCHLOPS_FIGURE_STANDARD
10 #define HEADER_PSYCHLOPS_FIGURE_STANDARD
11
12 #include "../../../core/graphic/psychlops_g_fundamental.h"
13 #include "../../../psychlops_core.h"
14 #include "../../../core/ApplicationInterfaces/psychlops_app_thread.h"
15
16
17
18
19 namespace Psychlops {
20 namespace Figures {
21
22         class Arrow : virtual public Line
23         {
24         private:
25                 static Polygon default_head;
26                 void createDefaultHead();
27                 void setDefaultHead();
28         protected:
29                 Group gr;
30                 Polygon* head;
31         public:
32                 Arrow();
33                 Arrow(const double x1, const double y1, const double x2, const double y2);
34                 Arrow(const Point &dbegin, const Point &dend);
35                 Arrow& set(const double x1, const double y1, const double x2, const double y2);
36                 Arrow& set(const Point &dbegin, const Point &dend);
37                 virtual Arrow& draw(Drawable &target = *Drawable::prime);
38                 virtual Arrow& draw(const Color &col, Drawable &target = *Drawable::prime);
39                 virtual Arrow& draw(const Stroke &strk, Drawable &target = *Drawable::prime);
40         };
41
42
43         class Cross : virtual public Shape, virtual public FigureDatum
44         {
45         public:
46                 //using FigureDatum::datum; using FigureDatum::shift;
47                 //using Shape::centering;
48
49                 double width, height;
50
51                 Cross();
52                 Cross(const Rectangle& rect, Stroke dstrk = Stroke::hair_line);
53                 Cross(double wid, double hei, Stroke dstrk = Stroke::hair_line);
54                 virtual ~Cross();
55                 Cross& set(const Rectangle& rect, Stroke dstrk = Stroke::hair_line);
56                 Cross& set(double wid, double hei, Stroke dstrk = Stroke::hair_line);
57                 virtual Cross& centering();
58                 virtual Cross& centering(const Point &p);
59                 virtual Cross& draw(Drawable &target = *Drawable::prime);
60                 virtual Cross& draw(const Color &col, Drawable &target = *Drawable::prime);
61                 virtual Cross& draw(const Stroke &strk, Drawable &target = *Drawable::prime);
62         };
63
64
65         class MovieSequence : public FigureDatum\r
66         {\r
67                 virtual MovieSequence& nextFrame() = 0;\r
68                 virtual MovieSequence& draw(Drawable& target = *Drawable::prime) = 0;\r
69         };\r
70
71         class Movie : public MovieSequence
72         {
73                 protected:
74                 int current_frame_index;
75                 std::deque<Image*> frames;
76
77                 public:
78                 //static std::string bin_path;
79                 Rectangle source_area;
80
81                 Movie();
82                 virtual ~Movie();
83
84                 Movie &clear();
85                 Movie &set(Image* frames, int frame_num);
86                 Movie &reserveFrames(int frame_num);
87                 int getCurrentIndex();
88                 int setCurrentIndex(int new_current);
89                 Image& operator[](int frame_num);
90 \r
91                 virtual Movie& nextFrame();
92                 virtual Movie& draw(Drawable& target = *Drawable::prime);
93
94                 virtual Movie& captureOnce();
95                 virtual Movie& captureOnce(const Rectangle &source_area_);
96                 virtual Movie& captureOnce(int target_frame);
97                 virtual Movie& captureOnce(const Rectangle &source_area_, int target_frame);
98                 virtual Movie& save(std::string filename, const double fps = -1);
99                 virtual Movie& saveEachFrames(std::string filename);
100
101         };
102
103         class ProgressBar : public FigureDatum
104         {
105                 private:
106                 Rectangle frame_, bar_;
107                 double ratio;
108
109                 public:
110                 Color fgcolor, bgcolor;
111                 ProgressBar(const Rectangle &rect);
112                 ProgressBar(const double width, const double height);
113                 virtual ~ProgressBar();
114                 ProgressBar & set(Rectangle rect);
115                 ProgressBar & set(const double width, const double height);
116                 virtual ProgressBar & draw(Drawable& target = *Drawable::prime);
117                 virtual ProgressBar & draw(const double x, const double y, const double z = 0, Drawable& target = *Drawable::prime) const;
118
119                 ProgressBar & operator()(double ratio);
120                 ProgressBar & operator()(double now, double max);
121         };
122
123
124
125
126 }       /*      <- namespace Figure     */
127 }       /*      <- namespace Psycholops         */
128
129
130 #endif