00001 #ifndef AtomH
00002 #define AtomH
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
00041
00042
00043
00044
00045
00050
00051
00052 #include "CoreMainHeader.h"
00053 #include "ExtObject.h"
00054 #include "SimpleList.h"
00055 #include "Point.h"
00056 #include "Bond.h"
00057 #include "ContainerEnumerator.h"
00058
00059
00060
00061 class CStructureUnit;
00062 class CMolecule;
00063 class CSmallString;
00064 class CFragment;
00065 class CAtomsList;
00066 class CXMLElement;
00067
00068
00069
00070 extern CPluginObjectInfo AtomObjectInfo;
00071
00072
00073
00075
00078 class NEMESIS_CORE_PACKAGE CAtomType{
00079 public:
00080 const CSmallString& __fastcall GetStringForm(void) const;
00081 void __fastcall SetFromStringForm(const CSmallString& set);
00082
00083
00084 friend ostream& __fastcall operator << (ostream& str,const CAtomType& sa);
00085 friend istream& __fastcall operator >> (istream& str,CAtomType& sa);
00086 private:
00087 CSmallString MMType;
00088 };
00089
00090
00091
00093
00096 class NEMESIS_CORE_PACKAGE CAtomData{
00097 public:
00098
00099 __fastcall CAtomData(void);
00100
00101
00102 friend ostream& __fastcall operator << (ostream& str,const CAtomData& sa);
00103 friend istream& __fastcall operator >> (istream& str,CAtomData& sa);
00104
00105 bool __fastcall Load(CXMLElement* p_el);
00106 bool __fastcall Save(CXMLElement* p_el);
00107
00108
00109 void __fastcall GetFromAtom(const CAtom* p_atom);
00110 CAtom* __fastcall MakeAtom(CMolecule* molecule,CElementsRecord* history=NULL) const;
00111 inline int __fastcall GetAtomIndex(void) const;
00112
00113
00114
00115 public:
00116 int Z;
00117 CPoint Pos;
00118 CSmallString Name;
00119 CSmallString Description;
00120 CExtObject::CStatus Status;
00121 CAtomType AtomType;
00122 int AtomIndex;
00123 };
00124
00125
00126
00127
00128
00129
00130
00131
00133
00136 class NEMESIS_CORE_PACKAGE CAtom : public CExtObject{
00137 public:
00138
00139 __fastcall CAtom(CAtomsList *bl);
00140 __fastcall CAtom(CAtomsList *bl,int Z,const CPoint& pos);
00141 __fastcall ~CAtom(void);
00142 void __fastcall RemoveFromBaseList(CElementsRecord* history=NULL);
00143
00144
00145 bool __fastcall ChangePos(const CPoint& pos);
00146 bool __fastcall ChangeZ(int newz);
00147 bool __fastcall Delete(void);
00148 bool __fastcall MakeBondWith(CAtom *atom,EBondOrder order);
00149
00150
00151
00152 virtual CGeoDescriptor __fastcall GetGeoDescriptor(void);
00153
00154
00155 __property CMolecule* Molecule = {read = GetMolecule};
00156
00157 inline CMolecule* __fastcall GetMolecule(void) const;
00158 inline CAtomsList* __fastcall GetAtomsList(void) const;
00159 inline const CPoint& __fastcall GetPos(void) const;
00160 inline int __fastcall GetZ(void) const;
00161 inline const CAtomType& __fastcall GetAtomType(void) const;
00162
00163 inline CSimpleList<CBond>& __fastcall GetBonds(void);
00164 inline CStructureUnit* __fastcall GetStructureUnit(void) const;
00165
00166 inline bool __fastcall IsVirtual(void);
00167 CBond* __fastcall IsFixedWith(const CAtom *a2);
00168 CBond* __fastcall GetConectBond(void);
00169
00170
00171 inline void __fastcall SetPos(const CPoint& pos);
00172 inline void __fastcall SetZ(int z);
00173 inline void __fastcall SetAtomType(const CAtomType& atomtype);
00174 void __fastcall SetStructureUnit(CStructureUnit* su);
00175
00176 void __fastcall SetWorkForFragment(bool set_status);
00177 bool __fastcall GetWorkForFragment(void);
00178
00179
00180 inline int __fastcall GetMolInfoIndex(void);
00181 inline void __fastcall SetMolInfoIndex(int index);
00182
00183
00184
00185
00186 inline void __fastcall RegisterBond(CBond *b);
00187 inline void __fastcall UnregisterBond(CBond *b);
00188
00189
00190 bool __fastcall Load(CXMLElement* p_el);
00191 bool __fastcall Save(CXMLElement* p_el);
00192
00193
00194 private:
00195 int Z;
00196 CPoint Pos;
00197 CAtomType AtomType;
00198 CSimpleList<CBond> Bonds;
00199 CAtomsList* BaseList;
00200 CStructureUnit* StructureUnit;
00201 int MolInfoIndex;
00202
00203 friend class CAtomData;
00204 };
00205
00206
00207
00208
00209 DECLARE_EVENT(Atom_SetPosition);
00210 DECLARE_EVENT(Atom_SetZ);
00211 DECLARE_EVENT(Atom_SetAtomType);
00212
00213
00214
00215
00216
00218
00221 class NEMESIS_CORE_PACKAGE CAtomsList : public CExtObject, public CTemplList<CAtom>{
00222 public:
00223 __fastcall CAtomsList(CMolecule* own);
00224
00225
00226 bool __fastcall Center(void);
00227 CAtom* __fastcall CreateAtom(const CAtomData& atomdata);
00228
00229
00230 CAtom* __fastcall SearchByName(const CSmallString& name);
00231 CAtom* __fastcall SearchByDescription(const CSmallString& descrip);
00232
00233
00234 CAtom* __fastcall AddAtom(int z,const CPoint& pos,CElementsRecord* history=NULL);
00235 CAtom* __fastcall AddAtom(const CAtomData& sa,CElementsRecord* history=NULL);
00236 void __fastcall SetCenter(const CPoint& center);
00237
00238
00239 bool __fastcall Load(CXMLElement* p_el);
00240 bool __fastcall Save(CXMLElement* p_el);
00241
00242
00243 __property CMolecule* Molecule = {read = FMolecule};
00244
00245
00246 private:
00247 CMolecule* FMolecule;
00248 };
00249
00250
00251
00252 DECLARE_EVENT(AtomsList_AddAtom);
00253 DECLARE_EVENT(AtomsList_RemoveAtom);
00254
00255
00256 extern CPluginObjectInfo AtomEnumObjectInfo;
00257 extern CExtUUID ID_AtomEnum;
00258
00259
00260
00262
00265 class CAtomEnumerator : public CContainerEnumerator {
00266 public:
00267 __fastcall CAtomEnumerator(CComObject* owner,CMolecule* molecule);
00268 virtual __fastcall ~CAtomEnumerator(void);
00269
00270 virtual int __fastcall NumOfCommands(void);
00271 virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00272 virtual bool __fastcall DoCommand(int i);
00273
00274 virtual int __fastcall NumOfObjects(void);
00275 virtual bool __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00276 virtual CExtObject* __fastcall GetObject(int pos);
00277
00278
00279 virtual int __fastcall NumOfColumns(void);
00280 virtual const CSmallString __fastcall GetColumnCaption(int index);
00281 virtual const CSmallString __fastcall GetObjectProperty(int index);
00282 virtual int __fastcall GetObjectImageIndex(void);
00283
00284
00285 virtual CExtObject* __fastcall GetCurrentObject(void);
00286 virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00287
00288
00289 private:
00290 CAtomsList* Atoms;
00291 CTemplIterator<CAtom> Pointer;
00292 CEventReciever Receiver;
00293 CAtom* CurrentObject;
00294 int StartPos;
00295 int EndPos;
00296 bool Changed;
00297 CSimpleList<CAtom> CurrentView;
00298
00299 virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00300 void __fastcall RecieveEvent(const CEventIdentifier& EventType,void* Data,void* Sender);
00301 void __fastcall TestCondition(EEventCondition CondType,bool& Result);
00302 };
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 class CAtomDataHistory: public CElementData{
00320 public:
00321 __fastcall CAtomDataHistory(CAtom* p_atom,bool create);
00322
00323 private:
00324 CMolecule* Molecule;
00325 CAtomData Data;
00326
00327 virtual void __fastcall Forward(void);
00328 virtual void __fastcall Backward(void);
00329 };
00330
00331
00332
00333
00334
00335
00336
00337 class CAtomsListCenterHistory:public CCoreElementsRecord{
00338 public:
00339
00340 __fastcall CAtomsListCenterHistory(CMolecule* molecule,const CPoint& center);
00341
00342
00343 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00344
00345
00346 private:
00347 CMolecule* Molecule;
00348 CPoint Center;
00349 virtual void __fastcall Forward(void);
00350 virtual void __fastcall Backward(void);
00351 };
00352
00353
00354
00355 class CAtomsListCreateAtomHistory:public CCoreElementsRecord{
00356 public:
00357 __fastcall CAtomsListCreateAtomHistory(const CSmallString& name);
00358 private:
00359 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00360 CSmallString AtomName;
00361 };
00362
00363
00364
00365
00366
00367
00368
00369 class CAtomZHistory:public CCoreElementsRecord{
00370 public:
00371
00372 __fastcall CAtomZHistory(CAtom* p_atom,int newz);
00373
00374
00375 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00376
00377
00378 private:
00379 CMolecule* Molecule;
00380 CSmallString Name;
00381 CSmallString Description;
00382 int NewZ;
00383 int OldZ;
00384 int AtomIndex;
00385 virtual void __fastcall Forward(void);
00386 virtual void __fastcall Backward(void);
00387 };
00388
00389
00390
00391 class CAtomPosHistory:public CCoreElementsRecord{
00392 public:
00393
00394 __fastcall CAtomPosHistory(CAtom* p_atom,const CPoint& newpos);
00395
00396
00397 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00398
00399
00400 private:
00401 CMolecule* Molecule;
00402 CSmallString Name;
00403 CSmallString Description;
00404 CPoint NewPos;
00405 CPoint OldPos;
00406 int AtomIndex;
00407 virtual void __fastcall Forward(void);
00408 virtual void __fastcall Backward(void);
00409 };
00410
00411
00412
00413 class CDeleteAtomHistory:public CCoreElementsRecord{
00414 public:
00415 __fastcall CDeleteAtomHistory(CAtom* atom);
00416 private:
00417 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00418 CSmallString AtomName;
00419 };
00420
00421
00422
00423 class CMakeBondHistory:public CCoreElementsRecord{
00424 public:
00425 __fastcall CMakeBondHistory(CAtom* atom1,CAtom* atom2,EBondOrder order);
00426 private:
00427 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00428 CSmallString AtomName1;
00429 CSmallString AtomName2;
00430 };
00431
00432
00433
00434 inline int __fastcall CAtomData::GetAtomIndex(void) const
00435 {
00436 return(AtomIndex);
00437 }
00438
00439
00440
00441 inline CMolecule* __fastcall CAtom::GetMolecule(void) const
00442 {
00443 return(BaseList->Molecule);
00444 }
00445
00446
00447
00448 inline CAtomsList* __fastcall CAtom::GetAtomsList(void) const
00449 {
00450 return(BaseList);
00451 }
00452
00453
00454
00455 inline const CPoint& __fastcall CAtom::GetPos(void) const
00456 {
00457 return(Pos);
00458 }
00459
00460
00461
00462 inline int __fastcall CAtom::GetZ(void) const
00463 {
00464 return(Z);
00465 }
00466
00467
00468
00469 inline const CAtomType& __fastcall CAtom::GetAtomType(void) const
00470 {
00471 return(AtomType);
00472 }
00473
00474
00475
00476 inline CSimpleList<CBond>& __fastcall CAtom::GetBonds(void)
00477 {
00478 return(Bonds);
00479 }
00480
00481
00482
00483 inline void __fastcall CAtom::SetPos(const CPoint& pos)
00484 {
00485 Pos = pos;
00486 ThrowEvent(Atom_SetPosition);
00487 ThrowEvent(ExtObject_SetGeoDescriptor);
00488 }
00489
00490
00491
00492 inline void __fastcall CAtom::SetZ(int z)
00493 {
00494 Z = z;
00495 ThrowEvent(Atom_SetZ);
00496 }
00497
00498
00499
00500 inline bool __fastcall CAtom::IsVirtual(void)
00501 {
00502 return((Z==0)||(Z==1));
00503 }
00504
00505
00506
00507 inline void __fastcall CAtom::SetAtomType(const CAtomType& atomtype)
00508 {
00509 AtomType = atomtype;
00510 ThrowEvent(Atom_SetAtomType);
00511 }
00512
00513
00514
00515 inline void __fastcall CAtom::RegisterBond(CBond *b)
00516 {
00517 Bonds.InsertToEnd(b);
00518 }
00519
00520
00521
00522 inline void __fastcall CAtom::UnregisterBond(CBond *b)
00523 {
00524 Bonds.Remove(b);
00525 }
00526
00527
00528
00529 inline CStructureUnit* __fastcall CAtom::GetStructureUnit(void) const
00530 {
00531 return(StructureUnit);
00532 }
00533
00534
00535
00536 inline int __fastcall CAtom::GetMolInfoIndex(void)
00537 {
00538 return(MolInfoIndex);
00539 }
00540
00541
00542
00543 inline void __fastcall CAtom::SetMolInfoIndex(int index)
00544 {
00545 MolInfoIndex = index;
00546 }
00547
00548
00549
00550 #endif