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_GFX_GXCYLINDER_CC_UTC20050626084024_DEFINED
00035 #define GROOVX_GFX_GXCYLINDER_CC_UTC20050626084024_DEFINED
00036
00037 #include "gxcylinder.h"
00038
00039 #include "geom/box.h"
00040
00041 #include "gfx/bbox.h"
00042 #include "gfx/canvas.h"
00043
00044 #include "io/reader.h"
00045 #include "io/writer.h"
00046
00047 #include "rutz/trace.h"
00048
00049 namespace
00050 {
00051 const int GXCYLINDER_SVID = 0;
00052 }
00053
00054 const FieldMap& GxCylinder::classFields()
00055 {
00056 GVX_TRACE("GxCylinder::classFields");
00057 static const Field FIELD_ARRAY[] =
00058 {
00059 Field("base", &GxCylinder::itsBase, 1.0, 0.0, 10.0, 0.1,
00060 Field::NEW_GROUP),
00061 Field("top", &GxCylinder::itsTop, 1.0, 0.0, 10.0, 0.1),
00062 Field("height", &GxCylinder::itsHeight, 1.0, 0.0, 10.0, 0.1),
00063 Field("slices", &GxCylinder::itsSlices, 10, 1, 100, 1),
00064 Field("stacks", &GxCylinder::itsStacks, 10, 1, 100, 1),
00065 Field("filled", &GxCylinder::itsFilled, true, false, true, true,
00066 Field::BOOLEAN)
00067 };
00068
00069 static FieldMap FIELD_MAP(FIELD_ARRAY);
00070
00071 return FIELD_MAP;
00072 }
00073
00074 GxCylinder* GxCylinder::make()
00075 {
00076 GVX_TRACE("GxCylinder::make");
00077 return new GxCylinder;
00078 }
00079
00080 GxCylinder::GxCylinder() :
00081 FieldContainer(&sigNodeChanged),
00082 itsBase(1.0),
00083 itsTop(1.0),
00084 itsHeight(1.0),
00085 itsSlices(75),
00086 itsStacks(20),
00087 itsFilled(true)
00088 {
00089 GVX_TRACE("GxCylinder::GxCylinder");
00090 setFieldMap(GxCylinder::classFields());
00091 }
00092
00093 GxCylinder::~GxCylinder() throw()
00094 {
00095 GVX_TRACE("GxCylinder::~GxCylinder");
00096 }
00097
00098 io::version_id GxCylinder::class_version_id() const
00099 {
00100 GVX_TRACE("GxCylinder::class_version_id");
00101 return GXCYLINDER_SVID;
00102 }
00103
00104 void GxCylinder::read_from(io::reader& reader)
00105 {
00106 GVX_TRACE("GxCylinder::read_from");
00107 readFieldsFrom(reader, classFields());
00108 }
00109
00110 void GxCylinder::write_to(io::writer& writer) const
00111 {
00112 GVX_TRACE("GxCylinder::write_to");
00113 writeFieldsTo(writer, classFields(), GXCYLINDER_SVID);
00114 }
00115
00117
00119
00120 void GxCylinder::getBoundingCube(Gfx::Bbox& bbox) const
00121 {
00122 GVX_TRACE("GxCylinder::getBoundingCube");
00123
00124 geom::box<double> mybox;
00125
00126 const double maxr = itsBase > itsTop ? itsBase : itsTop;
00127
00128 mybox.set_xx_yy_zz(-maxr, maxr,
00129 -maxr, maxr,
00130 0.0, itsHeight);
00131
00132 bbox.drawBox(mybox);
00133 }
00134
00135 void GxCylinder::draw(Gfx::Canvas& canvas) const
00136 {
00137 GVX_TRACE("GxCylinder::draw");
00138
00139 canvas.drawCylinder(itsBase, itsTop, itsHeight,
00140 itsSlices, itsStacks, itsFilled);
00141 }
00142
00143 static const char __attribute__((used)) vcid_groovx_gfx_gxcylinder_cc_utc20050626084024[] = "$Id: gxcylinder.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00144 #endif // !GROOVX_GFX_GXCYLINDER_CC_UTC20050626084024_DEFINED