gxnode.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 2000-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 Nov  1 18:27:15 2000
00010 // commit: $Id: gxnode.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxnode.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_GXNODE_CC_UTC20050626084025_DEFINED
00035 #define GROOVX_GFX_GXNODE_CC_UTC20050626084025_DEFINED
00036 
00037 #include "gxnode.h"
00038 
00039 #include "geom/box.h"
00040 
00041 #include "gfx/bbox.h"
00042 #include "gfx/canvas.h"
00043 
00044 #include "nub/ref.h"
00045 
00046 #include "rutz/iter.h"
00047 
00048 #include "rutz/trace.h"
00049 
00050 using rutz::shared_ptr;
00051 
00052 class GxNodeIter : public rutz::fwd_iter_ifx<const nub::ref<GxNode> >
00053 {
00054   nub::ref<GxNode> itsNode;
00055   bool isItValid;
00056 
00057 public:
00058   GxNodeIter(GxNode* node) :
00059     itsNode(node), isItValid(true) {}
00060 
00061   typedef const nub::ref<GxNode> ValType;
00062 
00063   virtual rutz::fwd_iter_ifx<ValType>* clone() const
00064   {
00065     return new GxNodeIter(*this);
00066   }
00067 
00068   virtual bool     at_end() const { return !isItValid; }
00069   virtual ValType&    get() const { return itsNode; }
00070   virtual void       next()       { isItValid = false; }
00071 };
00072 
00073 GxNode::GxNode() : sigNodeChanged()
00074 {
00075 GVX_TRACE("GxNode::GxNode");
00076 }
00077 
00078 GxNode::~GxNode() throw()
00079 {
00080 GVX_TRACE("GxNode::~GxNode");
00081 }
00082 
00083 bool GxNode::contains(GxNode* other) const
00084 {
00085 GVX_TRACE("GxNode::contains");
00086   return (this == other);
00087 }
00088 
00089 rutz::fwd_iter<const nub::ref<GxNode> > GxNode::deepChildren()
00090 {
00091 GVX_TRACE("GxNode::deepChildren");
00092 
00093   return rutz::fwd_iter<const nub::ref<GxNode> >
00094     (shared_ptr<GxNodeIter>(new GxNodeIter(this)));
00095 }
00096 
00097 geom::rect<double> GxNode::getBoundingBox(Gfx::Canvas& canvas) const
00098 {
00099 GVX_TRACE("GxNode::getBoundingBox");
00100 
00101   Gfx::Bbox bbox(canvas);
00102   getBoundingCube(bbox);
00103 
00104   return bbox.rect();
00105 }
00106 
00107 void GxNode::undraw(Gfx::Canvas& canvas) const
00108 {
00109 GVX_TRACE("GxNode::undraw");
00110 
00111   const geom::rect<double> world_box = getBoundingBox(canvas);
00112 
00113   geom::rect<int> screen_box = canvas.screenBoundsFromWorldRect(world_box);
00114 
00115   screen_box.set_width(screen_box.width()+4);
00116   screen_box.set_height(screen_box.height()+4);
00117 
00118   canvas.clearColorBuffer(screen_box);
00119 }
00120 
00121 static const char __attribute__((used)) vcid_groovx_gfx_gxnode_cc_utc20050626084025[] = "$Id: gxnode.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00122 #endif // !GROOVX_GFX_GXNODE_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.