gxdrawstyle.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 2001-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: Wed Aug 29 10:19:31 2001
00010 // commit: $Id: gxdrawstyle.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxdrawstyle.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_GXDRAWSTYLE_CC_UTC20050626084025_DEFINED
00035 #define GROOVX_GFX_GXDRAWSTYLE_CC_UTC20050626084025_DEFINED
00036 
00037 #include "gfx/gxdrawstyle.h"
00038 
00039 #include "gfx/canvas.h"
00040 
00041 #include "io/reader.h"
00042 #include "io/writer.h"
00043 
00044 namespace
00045 {
00046   const io::version_id GXDRAWSTYLE_SVID = 1;
00047 }
00048 
00049 GxDrawStyle::GxDrawStyle() :
00050   FieldContainer(&sigNodeChanged),
00051   polygonFill(false),
00052   pointSize(1.0),
00053   lineWidth(1.0),
00054   linePattern(0xFFFF)
00055 {
00056   setFieldMap(GxDrawStyle::classFields());
00057 }
00058 
00059 GxDrawStyle::~GxDrawStyle() throw() {}
00060 
00061 io::version_id GxDrawStyle::class_version_id() const
00062 {
00063   return GXDRAWSTYLE_SVID;
00064 }
00065 
00066 void GxDrawStyle::read_from(io::reader& reader)
00067 {
00068   reader.ensure_version_id("GxDrawStyle", 1,
00069                            "Try groovx0.8a7", SRC_POS);
00070 
00071   readFieldsFrom(reader, classFields());
00072 }
00073 
00074 void GxDrawStyle::write_to(io::writer& writer) const
00075 {
00076   writer.ensure_output_version_id("GxDrawStyle", GXDRAWSTYLE_SVID, 1,
00077                               "Try groovx0.8a7", SRC_POS);
00078 
00079   writeFieldsTo(writer, classFields(), GXDRAWSTYLE_SVID);
00080 }
00081 
00082 const FieldMap& GxDrawStyle::classFields()
00083 {
00084   static const Field FIELD_ARRAY[] =
00085   {
00086     Field("polygonFill", &GxDrawStyle::polygonFill, false, false, true, true,
00087           Field::NEW_GROUP),
00088     Field("pointSize", &GxDrawStyle::pointSize, 1.0, 0.1, 10.0, 0.1),
00089     Field("lineWidth", &GxDrawStyle::lineWidth, 1.0, 0.1, 10.0, 0.1),
00090     Field("linePattern", &GxDrawStyle::linePattern, 0xFFFF, 0, 0xFFFF, 1)
00091   };
00092 
00093   static FieldMap GXDRAWSTYLE_FIELDS(FIELD_ARRAY);
00094 
00095   return GXDRAWSTYLE_FIELDS;
00096 }
00097 
00098 void GxDrawStyle::getBoundingCube(Gfx::Bbox&) const
00099 {
00100   ; // do nothing, since GxDrawStyle doesn't actually draw anything on-screen
00101 }
00102 
00103 void GxDrawStyle::draw(Gfx::Canvas& canvas) const
00104 {
00105   canvas.setPolygonFill(polygonFill);
00106   canvas.setPointSize(pointSize);
00107   canvas.setLineWidth(lineWidth);
00108   canvas.setLineStipple(static_cast<unsigned short>(linePattern));
00109 }
00110 
00111 static const char __attribute__((used)) vcid_groovx_gfx_gxdrawstyle_cc_utc20050626084025[] = "$Id: gxdrawstyle.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00112 #endif // !GROOVX_GFX_GXDRAWSTYLE_CC_UTC20050626084025_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.