Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Atom.h

Go to the documentation of this file.
00001 #ifndef AtomH
00002 #define AtomH
00003 
00004 /*******************************************************************************
00005 Copyright 1998,1999,2000,2001,2002 Petr Kulhanek
00006 
00007     This file is part of Core plugin.
00008 
00009     Core plugin is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     Core plugin is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with Core plugin; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 *******************************************************************************/
00023 /*******************************************************************************
00024 ** PROJEKT:             Projekt NEMESIS
00025 ** SOUBOR:              Atom
00026 ** ÚČEL:                třída popisující atom v molekule
00027 ** VERZE:               4.0
00028 ** JAZYK:               CBuilder C++
00029 ** CÍLOVÝ POČÍTAČ:      IBM PC
00030 ** PROGRAMÁTOR:         Petr Kulhánek
00031 ** HISTORIE ÚPRAV:
00032 VERZE   DATUM       POZNÁMKA
00033 1.0     ?????       vytvoření koncepce třídy, atomy vázané vazbou k atomu, byly
00034                     řazeny do pole o konstantní velikosti
00035 2.0     ?????       použití třídy CList pro registraci atomů tvořících vazbu
00036 2.1     30.04.1998  změna jmen (C...)
00037 2.1     01.09.1998  doplnění o nové modely
00038 3.0     24.07.1999  doplnění o history list
00039 3.0     30.01.2000  přenesení všech tříd pro záznam změn do tohoto modulu
00040 3.1     27.05.2000  přenesení vykreslování do CStandardModel
00041 4.0     02.09.2000  redistribuce části třídy atom a úprava modularity
00042                 2000-11-15      zavedení třídy CAtomType pro popis atomového typu v molekulové
00043                                 mechanice
00044 *******************************************************************************/
00045 
00050 /* HLAVIČKOVÉ SOUBORY  ********************************************************/
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 /* KONEC HLAVIČKOVÝCH SOUBORů *************************************************/
00060 
00061 class CStructureUnit;
00062 class CMolecule;
00063 class CSmallString;
00064 class CFragment;
00065 class CAtomsList;
00066 class CXMLElement;
00067 
00068 /* DEFINICE TŘÍD **************************************************************/
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  // konstruktor ----------------------------------------------------------------
00099         __fastcall CAtomData(void);
00100 
00101  // extraktor a inserter pro proudové operace ----------------------------------
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  // inicializační a rekonstrukční operace --------------------------------------
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  // sekce verejných dat -------------------------------------------------------
00114 
00115     public:
00116     int                          Z;             // protonové číslo
00117     CPoint                       Pos;           // poloha atomu
00118     CSmallString         Name;          // jméno objektu
00119     CSmallString                 Description;   // popis atomu
00120     CExtObject::CStatus  Status;        // status atomu
00121     CAtomType            AtomType;              // typ pro molekulovou mechaniku
00122     int                          AtomIndex;     // jednoznačný identifikátor atomu
00123     };
00124 
00125 // ----------------------------------------------------------------------------
00126 // ############################################################################
00127 // ----------------------------------------------------------------------------
00128 // ----------------------------------------------------------------------------
00129 // ############################################################################
00130 // ----------------------------------------------------------------------------
00131 
00133 
00136 class NEMESIS_CORE_PACKAGE CAtom : public CExtObject{
00137  public:
00138  // konstruktor a destruktor ---------------------------------------------------
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  // metody - změny registrované do seznamu změn --------------------------------
00145     bool __fastcall   ChangePos(const CPoint& pos);
00146     bool __fastcall   ChangeZ(int newz);
00147     bool __fastcall   Delete(void);   // odstraní atom z molekuly, odstraňuje konstrejny
00148     bool __fastcall   MakeBondWith(CAtom *atom,EBondOrder order);
00149 
00150  // metody - zjišťovací operace ------------------------------------------------
00151     // redefinované virtuální funkce
00152     virtual CGeoDescriptor      __fastcall GetGeoDescriptor(void);
00153 
00154     // nově definované funkce
00155     __property CMolecule* Molecule = {read = GetMolecule};
00156 
00157     inline CMolecule*           __fastcall      GetMolecule(void) const;   // molekula, pod kterou patří
00158     inline CAtomsList*      __fastcall  GetAtomsList(void) const;  // seznam atomů
00159     inline const CPoint&    __fastcall  GetPos(void) const;        // poloha atomu
00160     inline int              __fastcall  GetZ(void) const;          // protonové číslo
00161     inline const CAtomType& __fastcall  GetAtomType(void) const;   // atomový typ
00162 
00163     inline CSimpleList<CBond>& __fastcall GetBonds(void); // vrátí seznam vazeb
00164     inline CStructureUnit*        __fastcall GetStructureUnit(void) const;
00165 
00166     inline bool   __fastcall       IsVirtual(void);
00167     CBond* __fastcall       IsFixedWith(const CAtom *a2); // určí zda je vázán s atomem
00168     CBond* __fastcall       GetConectBond(void);    // určí valenční vazbu
00169 
00170  // metody - změnové operace neregistrované do seznamu změn --------------------
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);    // používá se pro mapování fragmentů
00177     bool __fastcall GetWorkForFragment(void);
00178 
00179  // mol info methods -----------------------------------------------------------
00180     inline int  __fastcall GetMolInfoIndex(void);
00181     inline void __fastcall SetMolInfoIndex(int index);
00182 
00183  // pomocné funkce -------------------------------------------------------------
00184     // tyto funkce slouží pro registraci jednotlivých objektů a to speciálně
00185     // vazeb (z důvodu strukturních)
00186     inline void __fastcall RegisterBond(CBond *b);
00187     inline void __fastcall UnregisterBond(CBond *b);
00188 
00189  // metody - uložení a načtení atomu -------------------------------------------
00190     bool __fastcall Load(CXMLElement* p_el);
00191     bool __fastcall Save(CXMLElement* p_el);
00192 
00193  // ............. SEKCE PRIVÁTNÍCH DAT .........................................
00194  private:
00195     int                 Z;               // protonové číslo
00196     CPoint              Pos;             // poloha
00197     CAtomType           AtomType;        // typ atomu
00198     CSimpleList<CBond>  Bonds;                  // seznam vazeb vychazejicích z atomu
00199     CAtomsList*                 BaseList;               // seznam, pod který patří
00200     CStructureUnit*     StructureUnit;      // strukturní jednotka
00201     int                 MolInfoIndex;    // index in MoleculeInfo structure
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  // metody - změny registrované do seznamu změn --------------------------------
00226     bool  __fastcall  Center(void);
00227     CAtom* __fastcall CreateAtom(const CAtomData& atomdata);
00228 
00229  // metody - operace se seznamem -----------------------------------------------
00230     CAtom* __fastcall SearchByName(const CSmallString& name);
00231     CAtom* __fastcall SearchByDescription(const CSmallString& descrip);
00232 
00233  // metody - výkonové operace --------------------------------------------------
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  // metody - uložení a načtení atomů -------------------------------------------
00239     bool __fastcall Load(CXMLElement* p_el);
00240     bool __fastcall Save(CXMLElement* p_el);
00241 
00242  // zjišťovací operace ---------------------------------------------------------
00243     __property CMolecule* Molecule = {read = FMolecule};
00244 
00245  // sekce soukromých dat -------------------------------------------------------
00246     private:
00247     CMolecule* FMolecule; // odkaz na molekulu
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  // funkce pro rozšířený popis objektů a kontejnerů ----------------------------
00279     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00280     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00281     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00282     virtual int __fastcall GetObjectImageIndex(void);
00283 
00284 
00285     virtual CExtObject* __fastcall GetCurrentObject(void);
00286     virtual bool        __fastcall SetCurrentObject(CExtObject* p_object);
00287 
00288  // private data section -------------------------------------------------------
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 v této části jsou definovány třídy sloužící pro záznam změn do history listu
00312 */
00313 
00314 /*  TŘÍDA:  CAtomElementData
00315     ÚČEL:   obsahuje elementární data popisující atom, slouží pro záznam
00316                 strukturních změn
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 /*  TŘÍDA: CAtomsListCenterHistory
00334     ÚČEL:  třída sloužící pro záznam změny těžiště molekuly
00335 */
00336 
00337 class CAtomsListCenterHistory:public CCoreElementsRecord{
00338     public:
00339  // konstruktor a destruktor třídy ---------------------------------------------
00340     __fastcall CAtomsListCenterHistory(CMolecule* molecule,const CPoint& center);
00341 
00342                 // zjištění celého řetězce popisujícího změnu
00343     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00344 
00345  // sekce soukromých dat -------------------------------------------------------
00346     private:
00347     CMolecule*  Molecule;  // molekula
00348     CPoint      Center;    // původní poloha těžiště
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 /*  TŘÍDA: CAtomZHistory
00366     ÚČEL:  slouží pro záznam změny protonového čísla atomu
00367 */
00368 
00369 class CAtomZHistory:public CCoreElementsRecord{
00370     public:
00371  // konstruktor a destruktor ---------------------------------------------------
00372         __fastcall CAtomZHistory(CAtom* p_atom,int newz);
00373 
00374                 // zjištění celého řetězce popisujícího změnu
00375     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00376 
00377  // sekce soukromých dat -------------------------------------------------------
00378     private:
00379     CMolecule*      Molecule;  // vlastník atomu
00380     CSmallString    Name;
00381     CSmallString    Description;
00382     int                     NewZ;      // nová hodnota
00383     int                     OldZ;      // původní hodnota Z
00384     int                 AtomIndex; // index atomu
00385     virtual void __fastcall Forward(void);
00386     virtual void __fastcall Backward(void);
00387     };
00388 
00389 // ----------------------------------------------------------------------------
00390 
00391 class CAtomPosHistory:public CCoreElementsRecord{
00392     public:
00393  // konstruktor a destruktor ---------------------------------------------------
00394         __fastcall CAtomPosHistory(CAtom* p_atom,const CPoint& newpos);
00395 
00396                 // zjištění celého řetězce popisujícího změnu
00397     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00398 
00399  // sekce soukromých dat -------------------------------------------------------
00400     private:
00401     CMolecule*      Molecule;  // vlastník atomu
00402     CSmallString    Name;
00403     CSmallString    Description;
00404     CPoint                  NewPos;      // nová hodnota
00405     CPoint          OldPos;      // původní hodnota Z
00406     int                     AtomIndex; // index atomu
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 /* KONEC DEFINICE TŘÍD ********************************************************/
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

Generated on Sun Feb 9 12:53:50 2003 for NemesisCore by doxygen1.3-rc2