OpenStructure
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 
224  ResidueView FindResidue(const ResidueHandle& residue) const;
225 
227  AtomView FindAtom(const AtomHandle& atom) const;
228 
229  AtomView FindAtom(const String& chain_name, const ResNum& num,
230  const String& atom_name) const;
232  ChainView FindChain(const ChainHandle& chain) const;
233 
236  bool IsChainIncluded(const ChainHandle& chain) const;
237 
239  void RemoveAtom(AtomView view);
240 
242  void RemoveResidue(ResidueView view);
243 
245  void RemoveChain(ChainView view);
246 
249  void AddAllInclusiveBonds();
250 
251  const BondHandleList& GetBondList() const;
252 
254  AtomViewList FindWithin(const geom::Vec3& center, Real radius) const;
255 
257  int GetBondCount() const;
258 
259  const ChainViewList& GetChainList() const;
260 
262  AtomViewIter AtomsBegin() const;
263 
265  AtomViewIter AtomsEnd() const;
266 
269  ResidueViewIter ResiduesBegin() const;
270 
273  ResidueViewIter ResiduesEnd() const;
274 
276  ResidueViewList GetResidueList() const;
277 
279  AtomViewList GetAtomList() const;
280 
282  void Apply(EntityVisitor& visitor);
283 
285  void Apply(EntityViewVisitor& visitor);
286 
288  EntityHandle GetHandle() const;
289 
291  std::pair<Real,Real> GetMinMax(const String& prop,
292  Prop::Level hint=Prop::UNSPECIFIED) const;
293 
295  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2,
296  const AtomHandle& a3) const;
297 
299  Real GetAngle(const AtomView& a1, const AtomView& a2,
300  const AtomView& a3) const;
301 
304  EntityView ExtendViewToResidues() const;
305 
310  EntityView ExtendViewToSurrounding(Real gap) const;
311 
314  String Dump() const;
318  EntityView CreateFullView() const;
320  EntityView CreateEmptyView() const;
321 #ifdef _MSC_VER
322  // alternative routines for msvc
323  AtomView AddXAtom(const AtomHandle& ah, ViewAddFlags flags=0);
324  AtomView FindXAtom(const AtomHandle& ah);
325 #endif
326  void RemoveBond(const BondHandle& bond);
327 protected:
329  void AddAtomInternal(const AtomView& av);
330  void RemoveAtomInternal(const AtomView& av);
331 
332 private:
333 
334 
335  EntityViewDataPtr data_;
336 };
337 
338 }} // ns
339 
340 #endif // OST_ENTITY_VIEW_HH
341