gxdisk.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 2002-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Tue Nov 26 18:44:29 2002
00010 // commit: $Id: gxdisk.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxdisk.cc $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_GFX_GXDISK_CC_UTC20050626084024_DEFINED
00035 #define GROOVX_GFX_GXDISK_CC_UTC20050626084024_DEFINED
00036 
00037 #include "gxdisk.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 GXDISK_SVID = 0;
00052 }
00053 
00054 const FieldMap& GxDisk::classFields()
00055 {
00056 GVX_TRACE("GxDisk::classFields");
00057   static const Field FIELD_ARRAY[] =
00058   {
00059     Field("innerRadius", &GxDisk::itsInnerRadius, 0.0, 0.0, 100.0, 1.0,
00060           Field::NEW_GROUP),
00061     Field("outerRadius", &GxDisk::itsOuterRadius, 1.0, 0.0, 100.0, 1.0),
00062     Field("slices", &GxDisk::itsNumSlices, 20u, 1u, 100u, 1u),
00063     Field("loops", &GxDisk::itsNumLoops, 1u, 1u, 100u, 1u),
00064     Field("filled", &GxDisk::itsFilled, true, false, true, true,
00065           Field::BOOLEAN)
00066   };
00067 
00068   static FieldMap FIELD_MAP(FIELD_ARRAY);
00069 
00070   return FIELD_MAP;
00071 }
00072 
00073 GxDisk* GxDisk::make()
00074 {
00075 GVX_TRACE("GxDisk::make");
00076  return new GxDisk;
00077 }
00078 
00079 GxDisk::GxDisk() :
00080   FieldContainer(&sigNodeChanged),
00081   itsInnerRadius(0.0),
00082   itsOuterRadius(1.0),
00083   itsNumSlices(20),
00084   itsNumLoops(1),
00085   itsFilled(true)
00086 {
00087 GVX_TRACE("GxDisk::GxDisk");
00088   setFieldMap(GxDisk::classFields());
00089 }
00090 
00091 GxDisk::~GxDisk() throw()
00092 {
00093 GVX_TRACE("GxDisk::~GxDisk");
00094 }
00095 
00096 io::version_id GxDisk::class_version_id() const
00097 {
00098 GVX_TRACE("GxDisk::class_version_id");
00099   return GXDISK_SVID;
00100 }
00101 
00102 void GxDisk::read_from(io::reader& reader)
00103 {
00104 GVX_TRACE("GxDisk::read_from");
00105   readFieldsFrom(reader, classFields());
00106 }
00107 
00108 void GxDisk::write_to(io::writer& writer) const
00109 {
00110 GVX_TRACE("GxDisk::write_to");
00111   writeFieldsTo(writer, classFields(), GXDISK_SVID);
00112 }
00113 
00115 // actions //
00117 
00118 void GxDisk::getBoundingCube(Gfx::Bbox& bbox) const
00119 {
00120 GVX_TRACE("GxDisk::getBoundingCube");
00121 
00122   geom::box<double> mybox;
00123 
00124   mybox.set_xx_yy_zz(-itsOuterRadius, itsOuterRadius,
00125                      -itsOuterRadius, itsOuterRadius,
00126                      0.0, 0.0);
00127 
00128   bbox.drawBox(mybox);
00129 }
00130 
00131 void GxDisk::draw(Gfx::Canvas& canvas) const
00132 {
00133 GVX_TRACE("GxDisk::draw");
00134 
00135   canvas.drawCircle(itsInnerRadius, itsOuterRadius, itsFilled,
00136                     itsNumSlices, itsNumLoops);
00137 }
00138 
00139 static const char __attribute__((used)) vcid_groovx_gfx_gxdisk_cc_utc20050626084024[] = "$Id: gxdisk.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00140 #endif // !GROOVX_GFX_GXDISK_CC_UTC20050626084024_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:38 2008 by Doxygen version 1.5.5.