Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Atom.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2017, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Atom_INCLUDE_ONCE
33 #define Atom_INCLUDE_ONCE
34 
35 #include <vlCore/Object.hpp>
36 #include <vlCore/Vector4.hpp>
38 #include <vector>
39 
40 namespace vl
41 {
42 
51  class Atom: public Object
52  {
54 
55  public:
56  Atom()
57  {
58  VL_DEBUG_SET_OBJECT_NAME()
59  mId = 0;
61  mCoordinates = fvec3(0,0,0);
62  mColor = fvec4(1.0f,1.0f,1.0f,1.0f);
63  mRadius = 0.25f;
64  mVisited = false;
65  mVisible = true;
66  mShowAtomName= false;
67  /*mAtomName = nothing*/
68  }
69 
70  Atom(const Atom& other): Object(other) { *this = other; }
71 
73  Atom& operator=(const Atom& other)
74  {
75  mId = other.mId;
76  mAtomType = other.mAtomType;
77  mCoordinates = other.mCoordinates;
78  mRadius = other.mRadius;
79  mColor = other.mColor;
80  mVisible = other.mVisible;
82  // mAdjacentAtoms = other.mAdjacentAtoms; // do not copy
83  // mVisited = other.mVisited; // do not copy
84  mAtomName = other.mAtomName;
85  return *this;
86  }
87 
88  // Returns true if \p atom is adjacent to an Atom
89  bool isAtomAdjacent(Atom* atom) const
90  {
91  for(unsigned i=0; i<adjacentAtoms().size(); ++i)
92  if (adjacentAtoms()[i] == atom)
93  return true;
94  return false;
95  }
96 
97  const std::vector< Atom* >& adjacentAtoms() const { return mAdjacentAtoms; }
98  std::vector< Atom* >& adjacentAtoms() { return mAdjacentAtoms; }
99 
100  EAtomType atomType() const { return mAtomType; }
101  void setAtomType(EAtomType type) { mAtomType = type; }
102 
103  unsigned int id() const { return mId; }
104  void setId(unsigned int id) { mId = id; }
105 
106  const fvec3& coordinates() const { return mCoordinates; }
108 
109  float radius() const { return mRadius; }
110  void setRadius(float radius) { mRadius = radius; }
111 
112  void setVisited(bool visited) { mVisited = visited; }
113  bool visited() const { return mVisited; }
114 
115  void setAtomName(const std::string& name) { mAtomName = name; }
116  const std::string& atomName() const { return mAtomName; }
117 
118  const fvec4& color() const { return mColor; }
119  void setColor(const fvec4& color) { mColor = color; }
120 
121  bool visible() const { return mVisible; }
122  void setVisible(bool visible) { mVisible = visible; }
123 
125  void setShowAtomName(bool show) { mShowAtomName = show; }
127  bool showAtomName() const { return mShowAtomName; }
128 
129  protected:
133  float mRadius;
134  std::vector< Atom* > mAdjacentAtoms;
135  std::string mAtomName;
136  unsigned int mId;
137  // Aid to visit a molecule.
138  bool mVisited;
139  // Whether is visible or not
140  bool mVisible;
141  // Display atom name
143  };
144 }
145 
146 #endif
const std::string & atomName() const
Definition: Atom.hpp:116
bool mShowAtomName
Definition: Atom.hpp:142
Vector3< float > fvec3
A 3 components vector with float precision.
Definition: Vector3.hpp:252
void setAtomName(const std::string &name)
Definition: Atom.hpp:115
void setRadius(float radius)
Definition: Atom.hpp:110
fvec4 mColor
Definition: Atom.hpp:130
Vector4< float > fvec4
A 4 components vector with float precision.
Definition: Vector4.hpp:279
void setCoordinates(const fvec3 &coordinates)
Definition: Atom.hpp:107
bool visited() const
Definition: Atom.hpp:113
void setId(unsigned int id)
Definition: Atom.hpp:104
bool showAtomName() const
Defines whether the atom name should be rendered or not. See also Molecule::setShowAtomNames().
Definition: Atom.hpp:127
bool mVisible
Definition: Atom.hpp:140
void setShowAtomName(bool show)
Defines whether the atom name should be rendered or not. See also Molecule::setShowAtomNames().
Definition: Atom.hpp:125
float radius() const
Definition: Atom.hpp:109
void setVisible(bool visible)
Definition: Atom.hpp:122
unsigned int id() const
Definition: Atom.hpp:103
std::string mAtomName
Definition: Atom.hpp:135
std::vector< Atom *> mAdjacentAtoms
Definition: Atom.hpp:134
bool isAtomAdjacent(Atom *atom) const
Definition: Atom.hpp:89
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
bool visible() const
Definition: Atom.hpp:121
float mRadius
Definition: Atom.hpp:133
Atom(const Atom &other)
Definition: Atom.hpp:70
const fvec3 & coordinates() const
Definition: Atom.hpp:106
Visualization Library main namespace.
void setVisited(bool visited)
Definition: Atom.hpp:112
Atom & operator=(const Atom &other)
Assignment operator: does not assign the adjacent atoms.
Definition: Atom.hpp:73
void setColor(const fvec4 &color)
Definition: Atom.hpp:119
The base class for all the reference counted objects.
Definition: Object.hpp:158
std::vector< Atom *> & adjacentAtoms()
Definition: Atom.hpp:98
const std::vector< Atom *> & adjacentAtoms() const
Definition: Atom.hpp:97
unsigned int mId
Definition: Atom.hpp:136
const fvec4 & color() const
Definition: Atom.hpp:118
EAtomType atomType() const
Definition: Atom.hpp:100
void setAtomType(EAtomType type)
Definition: Atom.hpp:101
bool mVisited
Definition: Atom.hpp:138
EAtomType
Element types.
The Atom class represents an atom to be used with the Molecule class.
Definition: Atom.hpp:51
Atom()
Definition: Atom.hpp:56
EAtomType mAtomType
Definition: Atom.hpp:132
fvec3 mCoordinates
Definition: Atom.hpp:131