00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "std/support.H"
00010 #include "net/rtti.H"
00011 #include "mlib/points.H"
00012
00013 using namespace mlib;
00014
00015 #include "geom/world.H"
00016 #include "geom/text2d.H"
00017
00018 #include "mode_name.H"
00019
00020
00021
00022
00023
00024
00025
00026
00027 class MODE_TEXT : public TEXT2D {
00028
00029 public:
00030
00031 MODE_TEXT()
00032 : TEXT2D("mode", "", XYpt(-0.95,0.93)) { }
00033
00034
00035
00036 DEFINE_RTTI_METHODS3("MODE_TEXT", MODE_TEXT*, GEOM, CDATA_ITEM*);
00037
00038 int interactive(CEvent &e, State *&s, RAYhit *r) const
00039 {
00040 return 0;
00041 }
00042
00043 RAYhit &intersect(RAYhit &r, CWtransf&, int) const
00044 {
00045
00046
00047
00048
00049
00050
00051
00052 XYpt p = r.screen_point();
00053 BBOX2D bbox = bbox2d(0, 0, 1);
00054 if( bbox.contains(p) ){
00055 Wpt nearpt;
00056 Wvec n;
00057 XYpt uvc;
00058 Wpt obj_pt;
00059
00060 r.check(1.0, 0, 0.0, (GEOM*)this, n, nearpt, obj_pt, NULL, uvc);
00061
00062 }
00063
00064 return r;
00065 }
00066
00067 };
00068
00069 TEXT2Dptr ModeName::_mode_name;
00070 LIST<str_ptr> ModeName::_names;
00071
00072 void
00073 ModeName::init()
00074 {
00075 if (_mode_name)
00076 return;
00077 _mode_name = new MODE_TEXT();
00078 NETWORK .set(_mode_name, 0);
00079 NO_COLOR_MOD.set(_mode_name, 1);
00080 NO_XFORM_MOD.set(_mode_name, 1);
00081 NO_DISP_MOD .set(_mode_name, 1);
00082 NO_COPY .set(_mode_name, 1);
00083
00084 WORLD::create(_mode_name, false);
00085 }
00086
00087 void
00088 ModeName::push_name(Cstr_ptr& n)
00089 {
00090 _names += n;
00091 set_name(n);
00092 }
00093
00094 void
00095 ModeName::pop_name()
00096 {
00097 if (_names.empty()) {
00098 cerr << "ModeName::pop_name: error: empty stack" << endl;
00099 return;
00100 }
00101 _names.pop();
00102 set_name(_names.empty() ? NULL_STR : _names.last());
00103 }