Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://visualizationlibrary.org */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #ifndef Atom_INCLUDE_ONCE 00033 #define Atom_INCLUDE_ONCE 00034 00035 #include <vlCore/Object.hpp> 00036 #include <vlCore/Vector4.hpp> 00037 #include <vlMolecule/chem_database.hpp> 00038 #include <vector> 00039 00040 namespace vl 00041 { 00042 00051 class Atom: public Object 00052 { 00053 VL_INSTRUMENT_CLASS(vl::Atom, Object) 00054 00055 public: 00056 Atom() 00057 { 00058 VL_DEBUG_SET_OBJECT_NAME() 00059 mId = 0; 00060 mAtomType = AT_Unknown; 00061 mCoordinates = fvec3(0,0,0); 00062 mColor = fvec4(1.0f,1.0f,1.0f,1.0f); 00063 mRadius = 0.25f; 00064 mVisited = false; 00065 mVisible = true; 00066 mShowAtomName= false; 00067 /*mAtomName = nothing*/ 00068 } 00069 00070 Atom(const Atom& other): Object(other) { *this = other; } 00071 00073 Atom& operator=(const Atom& other) 00074 { 00075 mId = other.mId; 00076 mAtomType = other.mAtomType; 00077 mCoordinates = other.mCoordinates; 00078 mRadius = other.mRadius; 00079 mColor = other.mColor; 00080 mVisible = other.mVisible; 00081 mShowAtomName= other.mShowAtomName; 00082 // mAdjacentAtoms = other.mAdjacentAtoms; // do not copy 00083 // mVisited = other.mVisited; // do not copy 00084 mAtomName = other.mAtomName; 00085 return *this; 00086 } 00087 00088 // Returns true if \p atom is adjacent to an Atom 00089 bool isAtomAdjacent(Atom* atom) const 00090 { 00091 for(unsigned i=0; i<adjacentAtoms().size(); ++i) 00092 if (adjacentAtoms()[i] == atom) 00093 return true; 00094 return false; 00095 } 00096 00097 const std::vector< Atom* >& adjacentAtoms() const { return mAdjacentAtoms; } 00098 std::vector< Atom* >& adjacentAtoms() { return mAdjacentAtoms; } 00099 00100 EAtomType atomType() const { return mAtomType; } 00101 void setAtomType(EAtomType type) { mAtomType = type; } 00102 00103 unsigned int id() const { return mId; } 00104 void setId(unsigned int id) { mId = id; } 00105 00106 const fvec3& coordinates() const { return mCoordinates; } 00107 void setCoordinates(const fvec3& coordinates) { mCoordinates = coordinates; } 00108 00109 float radius() const { return mRadius; } 00110 void setRadius(float radius) { mRadius = radius; } 00111 00112 void setVisited(bool visited) { mVisited = visited; } 00113 bool visited() const { return mVisited; } 00114 00115 void setAtomName(const std::string& name) { mAtomName = name; } 00116 const std::string& atomName() const { return mAtomName; } 00117 00118 const fvec4& color() const { return mColor; } 00119 void setColor(const fvec4& color) { mColor = color; } 00120 00121 bool visible() const { return mVisible; } 00122 void setVisible(bool visible) { mVisible = visible; } 00123 00125 void setShowAtomName(bool show) { mShowAtomName = show; } 00127 bool showAtomName() const { return mShowAtomName; } 00128 00129 protected: 00130 fvec4 mColor; 00131 fvec3 mCoordinates; 00132 EAtomType mAtomType; 00133 float mRadius; 00134 std::vector< Atom* > mAdjacentAtoms; 00135 std::string mAtomName; 00136 unsigned int mId; 00137 // Aid to visit a molecule. 00138 bool mVisited; 00139 // Whether is visible or not 00140 bool mVisible; 00141 // Display atom name 00142 bool mShowAtomName; 00143 }; 00144 } 00145 00146 #endif