00001 #ifndef sceneview_h
00002 #define sceneview_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #include <InterViews/tformsetter.h>
00074 #include <InterViews/observe.h>
00075 #include "apwindow.h"
00076 #include "ocglyph.h"
00077 #include <ivstream.h>
00078
00079 #undef Scene
00080
00081 class Scene;
00082 class SceneInfo_List;
00083 class SceneInfo;
00084 class XYView;
00085 class XYView_PtrList;
00086 class ScenePicker;
00087 class GLabel;
00088 class GPolyLine;
00089 struct Object;
00090
00091 class OcViewGlyph : public OcGlyph {
00092 public:
00093 OcViewGlyph(XYView*);
00094 virtual ~OcViewGlyph();
00095 XYView* view() {return v_;}
00096 virtual void save(ostream&);
00097 void viewmenu(Glyph*);
00098 private:
00099 XYView* v_;
00100 Glyph* g_;
00101 };
00102
00103
00104
00105 class XYView : public TransformSetter , public Observable{
00106 public:
00107 XYView(Scene*, Coord xsize=200, Coord ysize=200);
00108 XYView(Coord x1, Coord y1, Coord x_span, Coord y_span, Scene*,
00109 Coord xsize=200, Coord ysize=200);
00110 virtual ~XYView();
00111
00112 virtual Scene* scene() const;
00113 virtual Coord left() const, right() const, top() const, bottom() const;
00114 virtual Coord width() const, height() const;
00115
00116 virtual void damage(Glyph*, const Allocation&,
00117 boolean fixed = false, boolean viewfixed = false);
00118 virtual void damage(Coord x1, Coord y1, Coord x2, Coord y2);
00119 virtual void damage_all();
00120
00121
00122 virtual void damage_area(Coord& x1, Coord& y1, Coord& x2, Coord& y2) const;
00123 virtual void set_damage_area(Canvas*);
00124
00125 virtual void request(Requisition&)const;
00126 virtual void allocate(Canvas*, const Allocation&, Extension&);
00127 virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
00128 virtual void undraw();
00129
00130 Canvas* canvas();
00131
00132 const Transformer& s2o()const {return scene2viewparent_;}
00133 void canvas(Canvas*);
00134
00135 void size(Coord x1, Coord y1, Coord x2, Coord y2);
00136 void origin(Coord x1, Coord y1);
00137 void x_span(Coord);
00138 void y_span(Coord);
00139 virtual void box_size(Coord x1, Coord y1, Coord x2, Coord y2);
00140
00141 static XYView* current_pick_view();
00142 static void current_pick_view(XYView*);
00143 static XYView* current_draw_view();
00144 Coord x_pick_epsilon() {return x_pick_epsilon_;}
00145 Coord y_pick_epsilon() {return y_pick_epsilon_;}
00146 virtual void move_view(Coord dx, Coord dy);
00147 virtual void scale_view(Coord xorg, Coord yorg, float dxscale, float dyscale);
00148 virtual XYView* new_view(Coord x1, Coord y1, Coord x2, Coord y2);
00149 void rebind();
00150 virtual void save(ostream&);
00151 OcViewGlyph* parent() { return parent_;}
00152 virtual void printfile(const char*);
00153 virtual void zout(Coord& x1, Coord& y1, Coord& x2, Coord& y2)const;
00154 virtual void zin(Coord& x1, Coord& y1, Coord& x2, Coord& y2)const;
00155 Coord view_margin() const {return view_margin_;}
00156 virtual void view_ratio(float xratio, float yratio, Coord& x, Coord& y) const;
00157 virtual void ratio_view(Coord x, Coord y, float& xratio, float& yratio) const;
00158 virtual void stroke(Canvas*, const Color*, const Brush*);
00159 protected:
00160 virtual void transform(
00161 Transformer&, const Allocation&, const Allocation& natural
00162 ) const;
00163 void scene2view(const Allocation& parent) const;
00164 void csize(Coord x0, Coord xsize, Coord y0, Coord ysize) const;
00165 private:
00166 void init(Coord x1, Coord y1, Coord x_span, Coord y_span, Scene*,
00167 Coord xsize, Coord ysize);
00168 void append_view(Scene*);
00169 protected:
00170 Coord x_pick_epsilon_, y_pick_epsilon_;
00171 private:
00172 Coord x1_, y1_, x_span_, y_span_;
00173 Canvas* canvas_;
00174 Transformer scene2viewparent_;
00175 Coord xsize_, ysize_, xsize_orig_, ysize_orig_, xc0_, yc0_;
00176 friend class OcViewGlyph;
00177 OcViewGlyph* parent_;
00178 Coord xd1_, xd2_, yd1_, yd2_;
00179 static Coord view_margin_;
00180 };
00181
00182
00183
00184
00185 class View : public XYView {
00186 public:
00187 View(Scene*);
00188 View(Coord x, Coord y, Coord span, Scene*,
00189 Coord xsize = 200, Coord ysize = 200);
00190 View(Coord left, Coord bottom, Coord x_span, Coord y_span, Scene*,
00191 Coord xsize=200, Coord ysize=200);
00192 virtual ~View();
00193
00194 virtual Coord x() const, y() const;
00195 virtual Coord view_width() const, view_height() const;
00196
00197 void origin(Coord x, Coord y);
00198 virtual void box_size(Coord x1, Coord y1, Coord x2, Coord y2);
00199 virtual void move_view(Coord dx, Coord dy);
00200 virtual void scale_view(Coord xorg, Coord yorg, float dxscale, float dyscale);
00201 virtual XYView* new_view(Coord x1, Coord y1, Coord x2, Coord y2);
00202 protected:
00203 virtual void transform(
00204 Transformer&, const Allocation&, const Allocation& natural
00205 ) const;
00206 private:
00207 Coord x_span_, y_span_;
00208 };
00209
00210 class Scene : public Glyph , public Observable{
00211 public:
00212 Scene(Coord x1, Coord y1, Coord x2, Coord y2, Glyph* background=nil);
00213 virtual ~Scene();
00214 virtual void background(Glyph* bg=nil);
00215 virtual Coord x1() const, y1() const, x2() const, y2() const;
00216 virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2);
00217 virtual void wholeplot(Coord& x1, Coord& y1, Coord& x2, Coord& y2)const;
00218 virtual int view_count() const;
00219 virtual XYView* sceneview(int) const;
00220 virtual void dismiss();
00221 virtual void printfile(const char*);
00222
00223 virtual void modified(GlyphIndex);
00224 void move(GlyphIndex, Coord x, Coord y);
00225 void location(GlyphIndex, Coord& x, Coord& y)const;
00226 void show(GlyphIndex, boolean);
00227 boolean showing(GlyphIndex) const;
00228
00229 virtual void damage(GlyphIndex);
00230 virtual void damage(Coord x1, Coord y1, Coord x2, Coord y2);
00231 virtual void damage_all();
00232
00233 enum {NOTOOL=0, MOVE, DELETE, CHANGECOLOR, EXTRATOOL};
00234 virtual void tool(int);
00235 virtual int tool();
00236 virtual void help();
00237 virtual void delete_label(GLabel*);
00238 virtual void change_label_color(GLabel*);
00239 virtual void change_line_color(GPolyLine*);
00240 virtual void request(Requisition&) const;
00241 virtual void allocate(Canvas*, const Allocation&, Extension&);
00242 virtual void draw(Canvas*, const Allocation&) const;
00243 virtual void print(Printer*, const Allocation&) const;
00244 virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
00245
00246 virtual void append(Glyph*);
00247 virtual void append_fixed(Glyph*);
00248 virtual void append_viewfixed(Glyph*);
00249 virtual void prepend(Glyph*);
00250 virtual void insert(GlyphIndex, Glyph*);
00251 virtual void remove(GlyphIndex);
00252 virtual void replace(GlyphIndex, Glyph*);
00253 virtual void change(GlyphIndex);
00254 virtual void change_to_fixed(GlyphIndex, XYView*);
00255 virtual void change_to_vfixed(GlyphIndex, XYView*);
00256
00257 virtual GlyphIndex count() const;
00258 virtual Glyph* component(GlyphIndex) const;
00259 virtual void allotment(GlyphIndex, DimensionName, Allotment&) const;
00260 virtual GlyphIndex glyph_index(const Glyph*);
00261 boolean drawing_fixed_item()const { return drawing_fixed_item_;}
00262
00263 static void save_all(ostream&);
00264 static long scene_list_index(Scene*);
00265 boolean mark() {return mark_;}
00266 void mark(boolean m) {mark_ = m;}
00267 virtual void save_phase1(ostream&);
00268 virtual void save_phase2(ostream&);
00269 virtual Coord mbs() const;
00270
00271 static const Color* default_background();
00272 static const Color* default_foreground();
00273
00274 ScenePicker* picker();
00275 Object* hoc_obj_ptr() { return hoc_obj_ptr_;}
00276 void hoc_obj_ptr(Object* o) { hoc_obj_ptr_ = o;}
00277 boolean menu_picked() { return menu_picked_;}
00278 protected:
00279 virtual void save_class(ostream&, const char*);
00280 private:
00281 #if 1
00282 friend class XYView;
00283 #else
00284
00285 friend void XYView::append_view(Scene*);
00286 friend XYView::~XYView();
00287 #endif
00288 virtual void damage(GlyphIndex, const Allocation&);
00289 void append_view(XYView*);
00290 void remove_view(XYView*);
00291 void check_allocation(GlyphIndex);
00292 private:
00293 Coord x1_, y1_, x2_, y2_;
00294 SceneInfo_List* info_;
00295 XYView_PtrList* views_;
00296 Glyph* background_;
00297 ScenePicker* picker_;
00298 int tool_;
00299 boolean mark_;
00300 static Scene* current_scene_;
00301 static Coord mbs_;
00302 boolean drawing_fixed_item_;
00303 Object* hoc_obj_ptr_;
00304 boolean menu_picked_;
00305
00306 Coord x1_orig_, x2_orig_, y1_orig_, y2_orig_;
00307 };
00308
00309 class ViewWindow : public PrintableWindow , public Observer {
00310 public:
00311 ViewWindow(XYView*, const char* name);
00312 virtual ~ViewWindow();
00313 virtual void update(Observable*);
00314 virtual void reconfigured();
00315 };
00316
00317 inline Coord Scene::x1() const { return x1_; }
00318 inline Coord Scene::x2() const { return x2_; }
00319 inline Coord Scene::y1() const { return y1_; }
00320 inline Coord Scene::y2() const { return y2_; }
00321
00322
00323 #endif