gxcylinder.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: Fri Jul  5 12:46:27 2002
00010 // commit: $Id: gxcylinder.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxcylinder.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_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 // actions //
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

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.