00001 #ifndef JOT_CAM_PV_H
00002 #define JOT_CAM_PV_H
00003
00004 #include "disp/cam_focus.H"
00005 #include "manip/manip.H"
00006 #include "base_jotapp/base_jotapp.H"
00007
00008
00009
00010
00011 class CamIcon {
00012 protected:
00013 static CamIcon *_orig_icon;
00014 virtual CamIcon *copy_icon(mlib::CXYpt &where, CCAMptr &cam) = 0;
00015 static ARRAY<CamIcon *> _icons;
00016 public:
00017 enum RESULT {
00018 RESIZE,
00019 FOCUS,
00020 MOVE
00021 };
00022 CamIcon() { _orig_icon = this; }
00023 virtual ~CamIcon() {}
00024 virtual RESULT test_down(CEvent &e, State *&s) = 0;
00025 virtual int icon_move(CEvent &e, State *&s) = 0;
00026 virtual int resize_up(CEvent &e, State *&s) = 0;
00027 virtual CCAMptr &cam () const = 0;
00028 virtual void set_icon_loc(mlib::CXYpt &pt) = 0;
00029 virtual bool intersect_icon(mlib::CXYpt &pt) = 0;
00030 virtual void remove_icon () = 0;
00031 static CamIcon *intersect_all(mlib::CXYpt &pt);
00032 static CamIcon *create (mlib::CXYpt &where, CCAMptr &cam) {
00033 if (_orig_icon) return _orig_icon->copy_icon(where, cam);
00034 return 0;
00035 }
00036 };
00037
00038
00039
00040
00041
00042
00043 class REF_CLASS(CamPhys) {
00044 protected:
00045 mlib::Wpt _com;
00046
00047 public :
00048 virtual ~CamPhys() { }
00049 CamPhys() { }
00050
00051 mlib::CWpt &com() const { return _com; }
00052 void set_com(mlib::CWpt &c) { _com = c; }
00053 };
00054
00055
00056
00057
00058
00059
00060 class Cam_int : public Interactor<Cam_int,Event,State>,
00061 public UPobs {
00062 private:
00063 static void schedule_in_view(VIEWptr v, CamFocus* cf);
00064
00065 protected:
00066
00067
00068 class REF_CLASS(CAMwidget) {
00069 protected:
00070 GEOMptr _anchor;
00071 int _a_displayed;
00072 public:
00073 CAMwidget();
00074 int anchor_displayed(){ return _a_displayed; }
00075 mlib::Wpt anchor_wpt() { return mlib::Wpt(_anchor->xform()); }
00076 mlib::XYpt anchor_pos() { return mlib::XYpt(anchor_wpt()); }
00077 double anchor_size() { return _anchor->xform().X().length(); }
00078 void undisplay_anchor();
00079 void display_anchor(mlib::CWpt &p);
00080 void drag_anchor (mlib::CXYpt &p2d);
00081 };
00082
00083 CamPhys _phys_cam;
00084 CAMwidget _camwidg;
00085 double _dtime;
00086 double _dist;
00087 mlib::PIXEL _start_pix;
00088 mlib::XYpt _scale_pt;
00089 mlib::Wpt _down_pt;
00090 mlib::XYpt _down_pt_2d;
00091 VIEWptr _view;
00092 State _cam_pan, _cam_zoom, _cam_rot, _cam_choose, _cam_drag;
00093 State _move_view, _icon_click;
00094
00095 State _entry2, _but_trans, _but_rot, _but_zoom, _but_drag, _phys;
00096
00097 ARRAY<UPobs*> _up_obs;
00098 int _do_reset;
00099 GEOMptr _geom;
00100 bool _resizing;
00101 CamIcon *_icon;
00102
00103 public:
00104 void add_up_obs(UPobs *o) { _up_obs += o; }
00105 virtual int predown(CEvent &e,State *&s);
00106 virtual int down (CEvent &e,State *&s);
00107 virtual int down2 (CEvent &e,State *&s);
00108 virtual int drag (CEvent &e,State *&s);
00109 virtual int choose (CEvent &e,State *&s);
00110 virtual int rot (CEvent &e,State *&s);
00111 virtual int zoom (CEvent &e,State *&s);
00112 virtual int pan (CEvent &e,State *&s);
00113 virtual int rot2 (CEvent &e,State *&s);
00114 virtual int zoom2 (CEvent &e,State *&s);
00115 virtual int pan2 (CEvent &e,State *&s);
00116 virtual int focus (CEvent &e,State *&s);
00117 virtual int move (CEvent &e,State *&s);
00118
00119
00120
00121 virtual int moveup (CEvent &e,State *&s);
00122 virtual int iconmove(CEvent &e,State *&s);
00123 virtual int iconup (CEvent &e,State *&s);
00124 virtual int up (CEvent &e,State *&s);
00125 virtual int dragup (CEvent &e,State *&s);
00126 virtual int noop (CEvent & ,State *&) { return 0; }
00127
00128 virtual ~Cam_int() {}
00129 Cam_int(CEvent &d, CEvent &m, CEvent &u, CEvent &d2, CEvent &u2,
00130 CEvent &dt, CEvent &dr, CEvent &dz,
00131 CEvent &ut, CEvent &ur, CEvent &uz);
00132 void make_view (mlib::CXYpt &);
00133 virtual void reset(int rst);
00134 State *entry2 () { return &_entry2; }
00135 };
00136
00137
00138
00139
00140
00141
00142
00143 class Screen_pan_int : public Simple_int
00144 {
00145 public:
00146 virtual ~Screen_pan_int() {}
00147 Screen_pan_int(CEvent &d,
00148 CEvent &m,
00149 CEvent &u): Simple_int(d,m,u)
00150 { _entry += Arc(m,Cb((_callb::_method)&Screen_pan_int::idle)); }
00151
00152 int idle(CEvent &e,State *&) {
00153 DEVice_2d *dev = (DEVice_2d *)e._d;
00154 CAMdataptr data(e.view()->cam()->data());
00155 mlib::Wpt dpt(data->from() + data->at_v() * data->distance());
00156 data->translate(-(mlib::Wpt(dev->cur(),dpt) - mlib::Wpt(dev->old(),dpt)));
00157
00158 return 0;
00159 }
00160 };
00161
00162 #endif // JOT_CAM_PV_H
00163