00001 00004 00005 // 00006 // Copyright (c) 2002-2004 California Institute of Technology 00007 // Copyright (c) 2004-2007 University of Southern California 00008 // Rob Peters <rjpeters at usc dot edu> 00009 // 00010 // created: Wed Nov 13 12:58:27 2002 00011 // commit: $Id: gxaligner.h 10065 2007-04-12 05:54:56Z rjpeters $ 00012 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxaligner.h $ 00013 // 00014 // -------------------------------------------------------------------- 00015 // 00016 // This file is part of GroovX. 00017 // [http://ilab.usc.edu/rjpeters/groovx/] 00018 // 00019 // GroovX is free software; you can redistribute it and/or modify it 00020 // under the terms of the GNU General Public License as published by 00021 // the Free Software Foundation; either version 2 of the License, or 00022 // (at your option) any later version. 00023 // 00024 // GroovX is distributed in the hope that it will be useful, but 00025 // WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00027 // General Public License for more details. 00028 // 00029 // You should have received a copy of the GNU General Public License 00030 // along with GroovX; if not, write to the Free Software Foundation, 00031 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00032 // 00034 00035 #ifndef GROOVX_GFX_GXALIGNER_H_UTC20050626084023_DEFINED 00036 #define GROOVX_GFX_GXALIGNER_H_UTC20050626084023_DEFINED 00037 00038 #include "geom/vec2.h" 00039 00040 #include "gfx/gbvec.h" 00041 #include "gfx/gxbin.h" 00042 00043 // ####################################################### 00044 // ======================================================= 00045 00047 class GxAligner : public GxBin 00048 { 00049 public: 00050 00052 // 00053 // Alignment modes 00054 // 00056 00061 typedef int Mode; 00062 00066 static const Mode NATIVE_ALIGNMENT = 1; 00067 00069 static const Mode CENTER_ON_CENTER = 2; 00070 00072 static const Mode NW_ON_CENTER = 3; 00073 00075 static const Mode NE_ON_CENTER = 4; 00076 00078 static const Mode SW_ON_CENTER = 5; 00079 00081 static const Mode SE_ON_CENTER = 6; 00082 00084 static const Mode ARBITRARY_ON_CENTER = 7; 00085 00086 00088 GxAligner(nub::soft_ref<GxNode> child); 00089 00091 virtual ~GxAligner() throw(); 00092 00094 geom::vec2<double> getCenter(const geom::rect<double>& bounds) const; 00095 00097 Mode getMode() const { return itsMode; } 00098 00100 void setMode(Mode new_mode) { itsMode = new_mode; } 00101 00102 virtual void read_from(io::reader& reader); 00103 virtual void write_to(io::writer& writer) const; 00104 00105 virtual void draw(Gfx::Canvas& canvas) const; 00106 00107 virtual void getBoundingCube(Gfx::Bbox& bbox) const; 00108 00109 private: 00110 void doAlignment(Gfx::Canvas& canvas, 00111 const geom::rect<double>& native) const; 00112 00113 public: 00114 Mode itsMode; 00115 GbVec2<double> itsCenter; 00116 }; 00117 00118 00119 static const char __attribute__((used)) vcid_groovx_gfx_gxaligner_h_utc20050626084023[] = "$Id: gxaligner.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file: 00120 #endif // !GROOVX_GFX_GXALIGNER_H_UTC20050626084023_DEFINED