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

Bond.h

Go to the documentation of this file.
00001 #ifndef BondH
00002 #define BondH
00003 /*******************************************************************************
00004 Copyright 1998,1999,2000,2001,2002 Petr Kulhanek
00005 
00006     This file is part of Core plugin.
00007 
00008     Core plugin is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Core plugin is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Core plugin; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 *******************************************************************************/
00022 /*******************************************************************************
00023 ** PROJEKT:             Projekt NEMESIS
00024 ** SOUBOR:              Bond
00025 ** ůČEL:                popisuje vazbu v molekule
00026 ** VERZE:               4.0
00027 ** JAZYK:               CBuilder C++
00028 ** CÍLOVÝ POČÍTAČ:      IBM PC
00029 ** PROGRAMÁTOR:         Petr Kulhánek
00030 ** HISTORIE ÚPRAV:
00031 VERZE   DATUM       POZNÁMKA
00032 2.2     05.06.1998
00033 3.0     30.01.2000  zahrnutí všech tříd týkajících se záznamu změn do
00034                     tohoto modulu
00035 3.1     27.05.2000  převedení vykreslování do CStandardModel
00036 4.0     2000-11-15  redistribuce části třídy atom a úprava modularity
00037                 2000-11-15      zavedení třídy CAtomType pro popis atomového typu v molekulové
00038                                 mechanice
00039 *******************************************************************************/
00040 
00045 /* HLAVIČKOVÉ SOUBORY  ********************************************************/
00046 
00047 #include "CoreMainHeader.h"
00048 #include "ExtObject.h"
00049 #include "ContainerEnumerator.h"
00050 
00051 /* KONEC HLAVIČKOVÝCH SOUBORů *************************************************/
00052 
00053 /* DEFINICE TŘÍD **************************************************************/
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,                     // řád vazby
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 /* TŘÍDA: CBondData
00086    ÚČEL:  shromažduje data vazby, popisující její vlastnosti
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  // inicializace dat a obnova dat ----------------------------------------------
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  // sekce veřejných dat -------------------------------------------------------
00108     public:
00109     int                                         AtomIndex1;     // index prvního atomu
00110     int                                         AtomIndex2;     // index druhého atomu
00111     CSmallString                        Name;                   // jméno objektu
00112     CSmallString                        Description;    // popis objektu
00113     CExtObject::CStatus         Status;                 // grafický status
00114     EBondOrder                          Order;          // řád vazby
00115     int                                         BondIndex;      // index vazby
00116     };
00117 
00118 // ----------------------------------------------------------------------------
00119 
00121 
00124 class NEMESIS_CORE_PACKAGE CBond : public CExtObject{
00125     public:
00126  // metody - konstruktor / destruktor
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  // metody - změnové operace ukládané do history listu
00132     bool __fastcall Delete(bool virtual_as_normal=false);                  // zruší vazbu
00133     bool __fastcall Break(bool virtual_as_normal=false);                   // zlomí vazbu
00134     bool __fastcall ChangeOrder(EBondOrder order);
00135 
00136  // metody - nastavovací operace
00137     inline void __fastcall SetOrder(EBondOrder order);
00138 
00139  // metody - pomocné funkce pro mapování fragmentů -----------------------------
00140     void __fastcall     SetWorkForFragment(bool set_status);    // používá se pro mapování fragmentů
00141     bool __fastcall GetWorkForFragment(void);
00142 
00143  // metody - zjištovací funkce
00144         __property CMolecule* Molecule = {read = GetMolecule};
00145 
00146     inline EBondOrder   __fastcall      GetOrder(void) const;
00147     inline CAtom*               __fastcall  GetFirstAtom(void) const;  // první atom vazby
00148     inline CAtom*               __fastcall  GetSecondAtom(void) const; // druhý atom vazby
00149     inline CMolecule*   __fastcall  GetMolecule(void) const;   // molekula
00150     inline CBondsList*  __fastcall  GetBondsList(void) const;  // seznam vazeb
00151 
00152                                                    // vektor kolmý k vazbě, ležící v rovině vazby
00153     CPoint      __fastcall  GetMainVector(void) const;
00154     double      __fastcall  GetLength(void) const;                      // délka vazby
00155     CAtom* __fastcall   GetOppositeAtom(CAtom* p_a) const;    // vratí odkaz na druhý atom,který tvoří
00156     CAtom* __fastcall   GetConectAtom(void) const;  // vrací valenční atom (Vir) vazby
00157 
00158     virtual CGeoDescriptor __fastcall GetGeoDescriptor(void);
00159 
00160  // metody - uložení a načtení vazby -------------------------------------------
00161     bool __fastcall Load(CXMLElement* p_el);
00162     bool __fastcall Save(CXMLElement* p_el);
00163 
00164  // funkce sloužící pro registraci objektů -------------------------------------
00165     virtual void __fastcall RemoveFromRegistered(CExtObject* object,CElementsRecord* history=NULL);
00166 
00167  // ............. SEKCE PRIVÁTNÍCH DAT .........................................
00168     private:
00169     CBondsList*                                         BaseList;   // seznam, pod který vazba patří
00170     CAtom*                                              A1;         // atomy, které tvoří vazbu
00171     CAtom*                                              A2;
00172     EBondOrder                                          Order;      // řád vazby
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  // metody - konstruktor / destruktor
00189     __fastcall CBondsList(CMolecule *own);
00190 
00191  // metody se záznamem do history listu
00192     CBond* __fastcall CreateBond(const CBondData& bonddata);
00193 
00194  // metody - výkonové operace
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  // metody - operace se seznamem -----------------------------------------------
00199     CBond* __fastcall SearchByName(const CSmallString& name);
00200     CBond* __fastcall SearchByDescription(const CSmallString& descrip);
00201 
00202  // metody - uložení a načtení vazeb -------------------------------------------
00203     bool __fastcall Load(CXMLElement* p_el);
00204     bool __fastcall Save(CXMLElement* p_el);
00205 
00206  // metody - zjišťovací operace ------------------------------------------------
00207     __property CMolecule*   Molecule= {read = FMolecule};
00208 
00209  // ............. SEKCE PRIVÁTNÍCH DAT .........................................
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  // funkce pro rozšířený popis objektů a kontejnerů ----------------------------
00246     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00247     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00248     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
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 /*  TŘÍDA: CDeleteBondHistory
00285     ÚČEL:  slouží pro záznam smazání vazby
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 /*  TŘÍDA: CBreakBondHistory
00300     ÚČEL:  slouží pro záznam zlomení vazby
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 /*  TŘÍDA: CBondOrderHistory
00315     ÚČEL:  slouží pro záznam změny řádu vazby
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 /* TŘÍDA:   CBondDataHistory
00338    ÚČEL:    popisuje vazbu, používá history list
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 /* KONEC DEFINICE TŘÍD ********************************************************/
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 /* KONEC HLAVIČKOVÉHO SOUBORU *************************************************/
00405 
00406 #endif

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