OSDN Git Service

cache
[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:\r
78                 enum FOURCC { AUTO, DIB, HFYU, PIM1, MP4V, MJPG, DIVX, XVID };
79                 //static std::string bin_path;
80                 Rectangle source_area;
81
82                 Movie();
83                 virtual ~Movie();
84
85                 Movie &clear();
86                 Movie &set(Image* frames, int frame_num);
87                 Movie &reserveFrames(int frame_num);
88                 int getCurrentIndex();
89                 int setCurrentIndex(int new_current);
90                 Image& operator[](int frame_num);
91 \r
92                 virtual Movie& nextFrame();
93                 virtual Movie& draw(Drawable& target = *Drawable::prime);
94
95                 virtual Movie& captureThisFrame();
96                 virtual Movie& captureThisFrame(const Rectangle &source_area_);
97                 virtual Movie& captureThisFrame(int target_frame);
98                 virtual Movie& captureThisFrame(const Rectangle &source_area_, int target_frame);
99                 virtual Movie& save(std::string filename, const double fps = -1, const FOURCC codec = AUTO);
100                 virtual Movie& saveFramesAsImages(std::string filename);
101
102         };
103
104         class ProgressBar : public FigureDatum
105         {
106                 private:
107                 Rectangle frame_, bar_;
108                 double ratio;
109
110                 public:
111                 Color fgcolor, bgcolor;
112                 ProgressBar(const Rectangle &rect);
113                 ProgressBar(const double width, const double height);
114                 virtual ~ProgressBar();
115                 ProgressBar & set(Rectangle rect);
116                 ProgressBar & set(const double width, const double height);
117                 virtual ProgressBar & draw(Drawable& target = *Drawable::prime);
118                 virtual ProgressBar & draw(const double x, const double y, const double z = 0, Drawable& target = *Drawable::prime) const;
119
120                 ProgressBar & operator()(double ratio);
121                 ProgressBar & operator()(double now, double max);
122         };
123
124
125
126
127 }       /*      <- namespace Figure     */
128 }       /*      <- namespace Psycholops         */
129
130
131 #endif