00001 #ifndef BondH
00002 #define BondH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00045
00046
00047 #include "CoreMainHeader.h"
00048 #include "ExtObject.h"
00049 #include "ContainerEnumerator.h"
00050
00051
00052
00053
00054
00055
00056
00057 class CMolecule;
00058 class CAtom;
00059 class CBond;
00060 class CBondsList;
00061 class CFragment;
00062 class CXMLElement;
00063
00064
00065
00066 extern CPluginObjectInfo BondObjectInfo;
00067
00068
00069
00071
00072 enum EBondOrder{
00073 BO_NONE = -1,
00074 BO_WEAK =0,
00075 BO_H=1,
00076 BO_SINGLE = 2,
00077 BO_SINGLE_H = 3,
00078 BO_DOUBLE = 4,
00079 BO_DOUBLE_H =5,
00080 BO_TRIPLE =6,
00081 };
00082
00083
00084
00085
00086
00087
00088
00090
00093 class NEMESIS_CORE_PACKAGE CBondData{
00094 public:
00095 __fastcall CBondData(void);
00096 friend ostream& __fastcall operator << (ostream& str,const CBondData& sb);
00097 friend istream& __fastcall operator >> (istream& str,CBondData& sb);
00098
00099 bool __fastcall Load(CXMLElement* p_el);
00100 bool __fastcall Save(CXMLElement* p_el);
00101
00102
00103 void __fastcall GetFromBond(CBond* p_bond);
00104 CBond* __fastcall MakeBond(CMolecule* molecule,CElementsRecord* history=NULL) const;
00105 inline int __fastcall GetBondIndex(void) const;
00106
00107
00108 public:
00109 int AtomIndex1;
00110 int AtomIndex2;
00111 CSmallString Name;
00112 CSmallString Description;
00113 CExtObject::CStatus Status;
00114 EBondOrder Order;
00115 int BondIndex;
00116 };
00117
00118
00119
00121
00124 class NEMESIS_CORE_PACKAGE CBond : public CExtObject{
00125 public:
00126
00127 __fastcall CBond(CBondsList* bl);
00128 __fastcall CBond(CBondsList* bl,CAtom* p_a1,CAtom* p_a2,EBondOrder o);
00129 void __fastcall RemoveFromBaseList(CElementsRecord* history=NULL);
00130
00131
00132 bool __fastcall Delete(bool virtual_as_normal=false);
00133 bool __fastcall Break(bool virtual_as_normal=false);
00134 bool __fastcall ChangeOrder(EBondOrder order);
00135
00136
00137 inline void __fastcall SetOrder(EBondOrder order);
00138
00139
00140 void __fastcall SetWorkForFragment(bool set_status);
00141 bool __fastcall GetWorkForFragment(void);
00142
00143
00144 __property CMolecule* Molecule = {read = GetMolecule};
00145
00146 inline EBondOrder __fastcall GetOrder(void) const;
00147 inline CAtom* __fastcall GetFirstAtom(void) const;
00148 inline CAtom* __fastcall GetSecondAtom(void) const;
00149 inline CMolecule* __fastcall GetMolecule(void) const;
00150 inline CBondsList* __fastcall GetBondsList(void) const;
00151
00152
00153 CPoint __fastcall GetMainVector(void) const;
00154 double __fastcall GetLength(void) const;
00155 CAtom* __fastcall GetOppositeAtom(CAtom* p_a) const;
00156 CAtom* __fastcall GetConectAtom(void) const;
00157
00158 virtual CGeoDescriptor __fastcall GetGeoDescriptor(void);
00159
00160
00161 bool __fastcall Load(CXMLElement* p_el);
00162 bool __fastcall Save(CXMLElement* p_el);
00163
00164
00165 virtual void __fastcall RemoveFromRegistered(CExtObject* object,CElementsRecord* history=NULL);
00166
00167
00168 private:
00169 CBondsList* BaseList;
00170 CAtom* A1;
00171 CAtom* A2;
00172 EBondOrder Order;
00173 virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00174 };
00175
00176
00177
00178 DECLARE_EVENT(Bond_SetOrder);
00179
00180
00181
00183
00186 class NEMESIS_CORE_PACKAGE CBondsList: public CExtObject, public CTemplList<CBond>{
00187 public:
00188
00189 __fastcall CBondsList(CMolecule *own);
00190
00191
00192 CBond* __fastcall CreateBond(const CBondData& bonddata);
00193
00194
00195 CBond* __fastcall AddBond(CAtom *a1,CAtom *a2,EBondOrder order,CElementsRecord* history=NULL);
00196 CBond* __fastcall AddBond(const CBondData& sb,CElementsRecord* history=NULL);
00197
00198
00199 CBond* __fastcall SearchByName(const CSmallString& name);
00200 CBond* __fastcall SearchByDescription(const CSmallString& descrip);
00201
00202
00203 bool __fastcall Load(CXMLElement* p_el);
00204 bool __fastcall Save(CXMLElement* p_el);
00205
00206
00207 __property CMolecule* Molecule= {read = FMolecule};
00208
00209
00210 private:
00211 CMolecule *FMolecule;
00212 };
00213
00214
00215
00216 DECLARE_EVENT(BondsList_AddBond);
00217 DECLARE_EVENT(BondsList_RemoveBond);
00218
00219
00220
00221
00222
00223 extern CPluginObjectInfo BondEnumObjectInfo;
00224 extern CExtUUID ID_BondEnum;
00225
00226
00227
00229
00232 class CBondEnumerator : public CContainerEnumerator {
00233 public:
00234 __fastcall CBondEnumerator(CComObject* owner,CMolecule* molecule);
00235 virtual __fastcall ~CBondEnumerator(void);
00236
00237 virtual int __fastcall NumOfCommands(void);
00238 virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00239 virtual bool __fastcall DoCommand(int i);
00240
00241 virtual int __fastcall NumOfObjects(void);
00242 virtual bool __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00243 virtual CExtObject* __fastcall GetObject(int pos);
00244
00245
00246 virtual int __fastcall NumOfColumns(void);
00247 virtual const CSmallString __fastcall GetColumnCaption(int index);
00248 virtual const CSmallString __fastcall GetObjectProperty(int index);
00249 virtual int __fastcall GetObjectImageIndex(void);
00250 virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00251 virtual CExtObject* __fastcall GetCurrentObject(void);
00252 virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00253
00254 private:
00255 CBondsList* Bonds;
00256 CTemplIterator<CBond> Pointer;
00257 CBond* CurrentObject;
00258 CEventReciever Receiver;
00259 int StartPos;
00260 int EndPos;
00261 bool Changed;
00262 CSimpleList<CBond> CurrentView;
00263
00264 void __fastcall RecieveEvent(const CEventIdentifier& EventType,void* Data,void* Sender);
00265 void __fastcall TestCondition(EEventCondition CondType,bool& Result);
00266 };
00267
00268
00269
00270
00271
00272
00273
00274 class CBondsListCreateBondHistory:public CCoreElementsRecord{
00275 public:
00276 __fastcall CBondsListCreateBondHistory(const CSmallString& name);
00277 private:
00278 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00279 CSmallString BondName;
00280 };
00281
00282
00283
00284
00285
00286
00287
00288 class CDeleteBondHistory : public CCoreElementsRecord{
00289 public:
00290 __fastcall CDeleteBondHistory(CBond* bond);
00291 private:
00292 CSmallString Name;
00293 CSmallString Description;
00294 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00295 };
00296
00297
00298
00299
00300
00301
00302
00303 class CBreakBondHistory : public CCoreElementsRecord{
00304 public:
00305 __fastcall CBreakBondHistory(CBond* bond);
00306 private:
00307 CSmallString Name;
00308 CSmallString Description;
00309 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00310 };
00311
00312
00313
00314
00315
00316
00317
00318 class CBondOrderHistory : public CCoreElementsRecord{
00319 public:
00320 __fastcall CBondOrderHistory(CBond* bond,EBondOrder order);
00321
00322 private:
00323 EBondOrder OldOrder;
00324 EBondOrder NewOrder;
00325 int BondIndex;
00326 CSmallString Name;
00327 CSmallString Description;
00328 CMolecule* Molecule;
00329
00330 virtual void __fastcall Forward(void);
00331 virtual void __fastcall Backward(void);
00332 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00333 };
00334
00335
00336
00337
00338
00339
00340
00341 class CBondDataHistory : public CElementData{
00342 public:
00343 __fastcall CBondDataHistory(CBond* p_bond,bool create);
00344 private:
00345 virtual void __fastcall Forward(void);
00346 virtual void __fastcall Backward(void);
00347
00348 CMolecule* Molecule;
00349 CBondData Data;
00350 };
00351
00352
00353
00354
00355 inline int __fastcall CBondData::GetBondIndex(void) const
00356 {
00357 return(BondIndex);
00358 }
00359
00360
00361
00362 inline void __fastcall CBond::SetOrder(EBondOrder order)
00363 {
00364 if( Order == order ) return;
00365 Order = order;
00366 ThrowEvent(Bond_SetOrder);
00367 }
00368
00369
00370
00371 inline EBondOrder __fastcall CBond::GetOrder(void) const
00372 {
00373 return(Order);
00374 }
00375
00376
00377
00378 inline CAtom* __fastcall CBond::GetFirstAtom(void) const
00379 {
00380 return(A1);
00381 }
00382
00383
00384
00385 inline CAtom* __fastcall CBond::GetSecondAtom(void) const
00386 {
00387 return(A2);
00388 }
00389
00390
00391
00392 inline CMolecule* __fastcall CBond::GetMolecule(void) const
00393 {
00394 return(BaseList->Molecule);
00395 }
00396
00397
00398
00399 inline CBondsList* __fastcall CBond::GetBondsList(void) const
00400 {
00401 return(BaseList);
00402 }
00403
00404
00405
00406 #endif