OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
coord_source.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_MOL_COORD_SOURCE_HH
20 #define OST_MOL_COORD_SOURCE_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 #include <boost/shared_ptr.hpp>
26 #include <ost/mol/module_config.hh>
27 #include <ost/mol/coord_frame.hh>
28 #include <ost/mol/entity_handle.hh>
29 
30 namespace geom {
31  // we should really have fw headers...
32  class Transform;
33 }
34 
35 namespace ost { namespace mol {
36 
38 
39 typedef boost::shared_ptr<CoordSource> CoordSourcePtr;
40 
47 public:
48  CoordSource(const AtomHandleList& atoms);
49 
50  virtual ~CoordSource() {}
51 
52  virtual uint GetFrameCount() const =0;
53 
54  virtual CoordFramePtr GetFrame(uint frame_id) const = 0;
55 
56  CoordSourcePtr Extract(int start=0, int stop=-1, int step=1);
57 
58  // time in ps between frames
59  float GetFrameDelta() const {return delta_;}
60  void SetFrameDelta(float d) {delta_=d;}
61 
62  // start time in ps
63  float GetStartTime() const {return start_time_;}
64  void SetStartTime(float t) {start_time_=t;}
65 
66  int GetAtomCount() const;
67 
68  EntityHandle GetEntity() const;
69 
70  const AtomHandleList& GetAtomList() const;
71 
72  void SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos);
73 
74  geom::Vec3 GetAtomPos(uint frame, AtomHandle atom) const;
75 
77  void CopyFrame(uint frame);
78  bool IsMutable() const;
79 
80  void Capture();
81  void CaptureInto(int pos);
82  void Capture(uint f);
83 
84  virtual void AddFrame(const std::vector<geom::Vec3>& coords) = 0;
85  virtual void AddFrame(const std::vector<geom::Vec3>& coords,const geom::Vec3& cell_size,const geom::Vec3& cell_angles) = 0;
86  virtual void InsertFrame(int pos, const std::vector<geom::Vec3>& coords) = 0;
87 
88  void ApplyTransform(const geom::Transform& tf);
89 
90 protected:
91  void SetMutable(bool flag);
92 private:
93  AtomHandleList atoms_;
94  EntityHandle entity_;
95  bool mutable_;
96  std::map<long,uint> atom_dict_;
97  float delta_,start_time_;
98 };
99 
100 }}
101 
102 #endif