00001
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
00033
00034 #ifndef GROOVX_VISX_FIXPT_CC_UTC20050626084016_DEFINED
00035 #define GROOVX_VISX_FIXPT_CC_UTC20050626084016_DEFINED
00036
00037 #include "visx/fixpt.h"
00038
00039 #include "geom/vec2.h"
00040
00041 #include "gfx/bbox.h"
00042 #include "gfx/canvas.h"
00043
00044 #include "io/ioproxy.h"
00045 #include "io/reader.h"
00046 #include "io/writer.h"
00047
00048 #include "rutz/trace.h"
00049 #include "rutz/debug.h"
00050 GVX_DBG_REGISTER
00051
00053
00054
00055
00057
00058 namespace
00059 {
00060 const io::version_id FIXPT_SVID = 3;
00061 }
00062
00064
00065
00066
00068
00069 const FieldMap& FixPt::classFields()
00070 {
00071 static const Field FIELD_ARRAY[] =
00072 {
00073 Field("length", &FixPt::itsLength, 0.1, 0.0, 10.0, 0.1, Field::NEW_GROUP),
00074 Field("width", &FixPt::itsWidth, 1, 1, 100, 1)
00075 };
00076
00077 static FieldMap FIXPT_FIELDS(FIELD_ARRAY, &GxShapeKit::classFields());
00078
00079 return FIXPT_FIELDS;
00080 }
00081
00082 FixPt* FixPt::make()
00083 {
00084 GVX_TRACE("FixPt::make");
00085 return new FixPt;
00086 }
00087
00088 FixPt::FixPt(double len, int wid) :
00089 itsLength(len), itsWidth(wid)
00090 {
00091 setFieldMap(FixPt::classFields());
00092 }
00093
00094 FixPt::~FixPt() throw() {}
00095
00096 io::version_id FixPt::class_version_id() const
00097 {
00098 GVX_TRACE("FixPt::class_version_id");
00099 return FIXPT_SVID;
00100 }
00101
00102 void FixPt::read_from(io::reader& reader)
00103 {
00104 GVX_TRACE("FixPt::read_from");
00105
00106 reader.ensure_version_id("FixPt", 3,
00107 "Try cvs tag xml_conversion_20040526",
00108 SRC_POS);
00109
00110 readFieldsFrom(reader, classFields());
00111
00112 reader.read_base_class("GxShapeKit", io::make_proxy<GxShapeKit>(this));
00113 }
00114
00115 void FixPt::write_to(io::writer& writer) const
00116 {
00117 GVX_TRACE("FixPt::write_to");
00118
00119 writer.ensure_output_version_id("FixPt", FIXPT_SVID, 3,
00120 "Try groovx0.8a4", SRC_POS);
00121
00122 writeFieldsTo(writer, classFields(), FIXPT_SVID);
00123
00124 writer.write_base_class("GxShapeKit", io::make_const_proxy<GxShapeKit>(this));
00125 }
00126
00127 void FixPt::grGetBoundingBox(Gfx::Bbox& bbox) const
00128 {
00129 GVX_TRACE("FixPt::grGetBoundingBox");
00130
00131 bbox.vertex2(geom::vec2<double>(-itsLength/2.0, -itsLength/2.0));
00132 bbox.vertex2(geom::vec2<double>(+itsLength/2.0, +itsLength/2.0));
00133 }
00134
00135 void FixPt::grRender(Gfx::Canvas& canvas) const
00136 {
00137 GVX_TRACE("FixPt::grRender");
00138
00139 Gfx::AttribSaver saver(canvas);
00140
00141 canvas.setLineWidth(itsWidth);
00142
00143 {
00144 Gfx::LinesBlock block(canvas);
00145
00146 canvas.vertex2(geom::vec2<double>(0.0, -itsLength/2.0));
00147 canvas.vertex2(geom::vec2<double>(0.0, itsLength/2.0));
00148
00149 canvas.vertex2(geom::vec2<double>(-itsLength/2.0, 0.0));
00150 canvas.vertex2(geom::vec2<double>(itsLength/2.0, 0.0));
00151 }
00152 }
00153
00154 static const char __attribute__((used)) vcid_groovx_visx_fixpt_cc_utc20050626084016[] = "$Id: fixpt.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00155 #endif // !GROOVX_VISX_FIXPT_CC_UTC20050626084016_DEFINED