00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_ATOM_IMPL_HH
00020 #define OST_ATOM_IMPL_HH
00021
00022 #include <boost/enable_shared_from_this.hpp>
00023
00024 #include <ost/mol/module_config.hh>
00025 #include <ost/geom/geom.hh>
00026 #include <ost/mol/entity_visitor_fw.hh>
00027 #include <ost/mol/atom_prop.hh>
00028
00029 #include <ost/mol/impl/atom_impl_fw.hh>
00030 #include <ost/mol/impl/residue_impl_fw.hh>
00031 #include <ost/mol/impl/connector_impl_fw.hh>
00032 #include <ost/mol/impl/fragment_impl_fw.hh>
00033 #include <ost/mol/impl/entity_impl_fw.hh>
00034
00035 #include <ost/generic_property.hh>
00036 #include <ost/mol/property_id.hh>
00037
00038 namespace ost { namespace mol { namespace impl {
00039
00049 class AtomImpl: public GenericPropContainerImpl,
00050 public boost::enable_shared_from_this<AtomImpl> {
00051 public:
00052 AtomImpl(const EntityImplPtr& ent, const ResidueImplPtr& res,
00053 const String& name, const geom::Vec3& pos, const AtomProp& prop,
00054 unsigned long index);
00055
00056 ~AtomImpl();
00057 void Apply(EntityVisitor& h);
00058
00059 const String& GetName() const {return name_;}
00060
00061 void SetName(const String& atom_name) {
00062 name_=atom_name;
00063 }
00064
00065
00066 const geom::Vec3& GetPos() const {return tf_pos_;}
00067
00068 const geom::Vec3& GetOriginalPos() const {return pos_;}
00069
00070 void SetTransformedPos(const geom::Vec3& pos) { tf_pos_=pos; }
00071
00072 void SetOriginalPos(const geom::Vec3& pos) { pos_=pos; }
00073
00074 const AtomProp& GetAtomProps() const {return prop_;}
00075
00076 AtomProp& GetAtomProps() {return prop_;}
00077
00078 ResidueImplPtr GetResidue() const;
00079
00080 void SetPrimaryConnector(const ConnectorImplP& bp) {
00081 prim_connector_=bp;
00082 }
00083
00084 const ConnectorImplP& GetPrimaryConnector() const {
00085 return prim_connector_;
00086 }
00087
00088 const ConnectorImplList& GetSecondaryConnectors() const {
00089 return connector_list_;
00090 }
00091
00092 void AddSecondaryConnector(const ConnectorImplP& bp);
00093
00094
00095 void UpdateFromICS();
00096
00097
00098 void UpdateFromXCS();
00099
00100 String GetQualifiedName() const;
00101
00102 EntityImplPtr GetEntity() const;
00103
00104 int GetConnectorCount() const {
00105 return connector_list_.size()+(prim_connector_ ? 1 : 0);
00106 }
00107
00108 void SetVisited(bool f) {set_state_bit(0,f);}
00109 bool IsVisited() const {return get_state_bit(0);}
00110
00111 void SetTraced(bool f) {set_state_bit(1,f);}
00112 bool IsTraced() const {return get_state_bit(1);}
00113
00114 unsigned int GetState() const {
00115 return state_;
00116 }
00117
00118 void SetState(int state) {
00119 state_=state;
00120 }
00121
00122 void ClearDirectionality();
00124 void TraceDirectionality(FragmentImplP frag, ConnectorImplP conn,
00125 int n, unsigned int& c);
00126
00127 bool HasPrevious() const {return prim_connector_.get()!=NULL;}
00128
00129 void DeleteAllConnectors();
00130
00131 void DeleteConnector(const ConnectorImplP& conn,
00132 bool delete_other=true);
00133
00134 void DeleteAllTorsions();
00135
00136 String GetStringProperty(Prop::ID prop_id) const;
00137
00138 Real GetFloatProperty(Prop::ID prop_id) const;
00139
00140 int GetIntProperty(Prop::ID prop_id) const;
00141
00142 unsigned long GetIndex() const {return index_;}
00143 void SetIndex(unsigned long index) {index_=index;}
00144
00145 private:
00146 ResidueImplW res_;
00147 String name_;
00148 geom::Vec3 pos_;
00149 geom::Vec3 tf_pos_;
00150 AtomProp prop_;
00151
00152 ConnectorImplP prim_connector_;
00153 ConnectorImplList connector_list_;
00154 FragmentImplP fragment_;
00155
00158 geom::Mat3 total_rot_;
00159
00162 unsigned int state_;
00163
00164 void set_state_bit(unsigned int bit, bool state)
00165 {
00166 unsigned int mask = 0x1<<bit;
00167 if(state) {
00168 state_ |= mask;
00169 } else {
00170 state_ &= ~mask;
00171 }
00172 }
00173
00174 bool get_state_bit(unsigned int bit) const {
00175 unsigned int mask = 0x1<<bit;
00176 return (state_ & mask)!=0;
00177 }
00178
00179 unsigned long index_;
00180 };
00181
00183 std::ostream& operator<<(std::ostream& o, const AtomImplPtr ap);
00184
00186 bool ConnectorExists(const AtomImplPtr& a, const AtomImplPtr& b);
00187
00189 ConnectorImplP GetConnector(const AtomImplPtr& a, const AtomImplPtr& b);
00190
00191 }}}
00192
00193 #endif
00194