00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_RESIDUE_VIEW_HH 00020 #define OST_RESIDUE_VIEW_HH 00021 00022 #include <ost/mol/query.hh> 00023 #include <ost/mol/module_config.hh> 00024 #include <ost/geom/geom.hh> 00025 #include <ost/mol/residue_base.hh> 00026 #include <ost/mol/view_type_fw.hh> 00027 #include <ost/mol/impl/residue_impl_fw.hh> 00028 #include <ost/mol/entity_visitor_fw.hh> 00029 #include <ost/mol/handle_type_fw.hh> 00030 00031 namespace ost { namespace mol { 00032 00039 class DLLEXPORT_OST_MOL ResidueView : public ResidueBase { 00040 00041 friend class ChainView; 00042 00043 public: 00045 ResidueView(); 00046 00052 ResidueView(const ChainView& chain, 00053 const ResidueHandle& residue); 00054 00055 public: 00056 00058 00059 00060 00061 00062 00063 00064 00065 operator bool() const { return this->IsValid(); } 00068 bool IsValid() const { return data_.get()!=0; } 00070 00072 00073 00074 00075 00076 ResidueView(const ResidueViewDataPtr& data, 00077 const impl::ResidueImplPtr& impl); 00078 00080 const ResidueViewDataPtr& ViewData() const { 00081 return data_; 00082 } 00084 ResidueViewDataPtr& ViewData() { 00085 return data_; 00086 } 00088 public: 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 AtomView AddAtom(const AtomView& atom_view, 00102 ViewAddFlags flags=0); 00103 00113 AtomView AddAtom(const AtomHandle& atom_handle, 00114 ViewAddFlags flags=0); 00116 00118 AtomView FindAtom(const String& atom_name) const; 00119 00121 AtomView ViewForHandle(const AtomHandle& handle) const; 00122 AtomView FindAtom(const AtomHandle& handle) const; 00123 00125 bool IsAtomIncluded(const AtomHandle& handle) const; 00126 00130 void RemoveAtom(AtomView view); 00131 00136 void RemoveAtoms(); 00137 00139 void Apply(EntityVisitor& visitor); 00140 void Apply(EntityViewVisitor& visitor); 00141 00143 int GetAtomCount() const; 00144 00146 const AtomViewList& GetAtomList() const; 00147 00149 ResidueHandle GetHandle() const; 00150 00152 EntityView GetEntity() const; 00153 00155 int GetIndex() const; 00157 ChainView GetChain() const; 00158 00160 double GetMass() const; 00161 00163 geom::Vec3 GetCenterOfMass() const; 00164 00169 geom::Vec3 GetCenterOfAtoms() const; 00170 00172 geom::AlignedCuboid GetBounds() const; 00173 00176 EntityView Select(const Query& q, QueryFlags flags=0) const; 00177 00180 EntityView Select(const String& query_string, QueryFlags flags=0) const; 00181 00182 bool operator==(const ResidueView& rhs) const; 00183 00184 bool operator!=(const ResidueView& rhs) const; 00185 00186 bool HasAtoms() const; 00187 protected: 00190 void SetIndex(int index); 00191 00192 private: 00193 ResidueViewDataPtr data_; 00194 }; 00195 00196 }} // ns 00197 00198 #endif // OST_RESIDUE_VIEW_HH 00199