OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
entity_view.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_ENTITY_VIEW_HN
20 #define OST_ENTITY_VIEW_HN
21 /*
22  Author: Marco Biasini
23  */
24 #include <ost/mol/module_config.hh>
25 
26 #include <ost/mol/residue_prop.hh>
27 #include <ost/mol/entity_base.hh>
28 #include <ost/mol/view_type_fw.hh>
32 #include <ost/mol/query.hh>
33 #include <ost/mol/iterator_fw.hh>
34 #include <ost/mol/property_id.hh>
35 #include <ost/geom/geom.hh>
36 
37 #ifdef _MSC_VER
38 # ifdef FindAtom
39 # undef FindAtom
40 # endif
41 # ifdef AddAtom
42 # undef AddAtom
43 # endif
44 #endif
45 
46 namespace ost { namespace mol {
47 
88  friend class AtomView;
89  friend class ResidueView;
90 public:
91  EntityView();
96  explicit EntityView(const EntityHandle& entity,
97  ViewAddFlags flags=0);
98 
100 
101 
102 
103 
104 
105 
106 
107  operator bool() const { return this->IsValid(); }
110  bool IsValid() const { return data_.get()!=0; }
112 
113  Real GetMass() const;
114 
116  geom::Vec3 GetCenterOfMass() const;
117 
122  geom::Vec3 GetCenterOfAtoms() const;
123 
124  geom::AlignedCuboid GetBounds() const;
125 
126 public:
128 
129 
130  EntityView(const EntityViewDataPtr& data,
131  const impl::EntityImplPtr impl);
132 
134  const EntityViewDataPtr& ViewData() const;
136  EntityViewDataPtr& ViewData();
138 public:
142  EntityView Copy() const;
152  ChainView AddChain(const ChainHandle& chain_handle,
153  ViewAddFlags flags=0);
154 
164  ChainView AddChain(const ChainView& chain_view,
165  ViewAddFlags flags=0);
166 
175  ResidueView AddResidue(const ResidueHandle& residue_handle,
176  ViewAddFlags flags=0);
184  ResidueView AddResidue(const ResidueView& residue_view,
185  ViewAddFlags flags=0);
195  AtomView AddAtom(const AtomHandle& atom_handle,
196  ViewAddFlags flags=0);
197 
198  AtomView AddAtom(const AtomView& atom_view,
199  ViewAddFlags flags=0);
202  EntityView Select(const String& query_string, QueryFlags flags=0) const;
203 
206  EntityView Select(const Query& query, QueryFlags flags=0) const;
207 
209  bool AddBond(const BondHandle& bond_handle);
210 
212  int GetAtomCount() const;
213 
215  int GetResidueCount() const;
216 
218  int GetChainCount() const;
219 
221  ChainView FindChain(const String& chain_name) const;
222 
226  ResidueView FindResidue(const ResidueHandle& residue) const;
227 
228  ResidueView FindResidue(const String& chain, const ResNum& num) const;
229 
234  ResidueView ViewForHandle(const ResidueHandle& residue) const;
238  AtomView FindAtom(const AtomHandle& atom) const;
239  AtomView ViewForHandle(const AtomHandle& atom) const;
240 
245  AtomView FindAtom(const String& chain_name, const ResNum& num,
246  const String& atom_name) const;
250 
251  ChainView FindChain(const ChainHandle& chain) const;
256  ChainView ViewForHandle(const ChainHandle& chain) const;
259  bool IsChainIncluded(const ChainHandle& chain) const;
260 
262  void RemoveAtom(AtomView view);
263 
265  void RemoveResidue(ResidueView view);
266 
268  void RemoveChain(ChainView view);
269 
272  void AddAllInclusiveBonds();
273 
274  const BondHandleList& GetBondList() const;
275 
277  AtomViewList FindWithin(const geom::Vec3& center, Real radius) const;
278 
280  int GetBondCount() const;
281 
282  const ChainViewList& GetChainList() const;
283 
285  AtomViewIter AtomsBegin() const;
286 
288  AtomViewIter AtomsEnd() const;
289 
292  ResidueViewIter ResiduesBegin() const;
293 
296  ResidueViewIter ResiduesEnd() const;
297 
299  ResidueViewList GetResidueList() const;
300 
302  AtomViewList GetAtomList() const;
303 
305  void Apply(EntityVisitor& visitor);
306 
308  void Apply(EntityViewVisitor& visitor);
309 
311  EntityHandle GetHandle() const;
312 
314  std::pair<Real,Real> GetMinMax(const String& prop,
315  Prop::Level hint=Prop::UNSPECIFIED) const;
316 
318  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2,
319  const AtomHandle& a3) const;
320 
322  Real GetAngle(const AtomView& a1, const AtomView& a2,
323  const AtomView& a3) const;
324 
327  EntityView ExtendViewToResidues() const;
328 
333  EntityView ExtendViewToSurrounding(Real gap) const;
334 
337  String Dump() const;
341  EntityView CreateFullView() const;
343  EntityView CreateEmptyView() const;
344 #ifdef _MSC_VER
345  // alternative routines for msvc
346  AtomView AddXAtom(const AtomHandle& ah, ViewAddFlags flags=0);
347  AtomView FindXAtom(const AtomHandle& ah);
348 #endif
349  void RemoveBond(const BondHandle& bond);
350 protected:
352  void AddAtomInternal(const AtomView& av);
353  void RemoveAtomInternal(const AtomView& av);
354 
355 private:
356 
357 
358  EntityViewDataPtr data_;
359 };
360 
361 typedef std::pair<EntityView, EntityView> EntityViewPair;
362 
363 }} // ns
364 
365 #endif // OST_ENTITY_VIEW_HH
366