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

Fragment.h

Go to the documentation of this file.
00001 #ifndef FragmentH
00002 #define FragmentH
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:              Fragment
00025 ** úČEL:                slouží pro popis částí molekuly
00026 ** VERZE:               2.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 1.0             ????-??-??      vznik třídy, zahrnuje i CBondManipulateFragment a
00033                                         CTemporaryFragment
00034 2.0             2000-12-01      zůstalo pouze jádro definující fragment, ostatní třídy byly
00035                                         přesunuty a upraveny tak aby pracovaly přes CGraphicsObject
00036                     dale byla zavedena třída CFragmentsList
00037 *******************************************************************************/
00038 
00042 /* HLAVIČKOVÉ SOUBORY *********************************************************/
00043 
00044 #include "CoreMainHeader.h"
00045 #include "ExtObject.h"
00046 #include "Atom.h"
00047 #include "Bond.h"
00048 #include "HistoryList.h"
00049 #include "ContainerEnumerator.h"
00050 
00051 /* KONEC HLAVIČKOVÝCH SOUBORů *************************************************/
00052 
00053 // -----------------------------------------------------------------------------
00054 
00055 extern CPluginObjectInfo FragmentObjectInfo;
00056 
00057 class CFragmentsList;
00058 
00059 // -----------------------------------------------------------------------------
00060 
00062 
00065 class NEMESIS_CORE_PACKAGE CFragmentData{
00066         public:
00067  // konstruktor a destruktor ---------------------------------------------------
00068         __fastcall CFragmentData(void);
00069         __fastcall ~CFragmentData(void);
00070 
00071  // inicializační a rekonstrukční operace --------------------------------------
00072         void            __fastcall GetFromFragment(CFragment* p_fragment);
00073     CFragment*  __fastcall MakeFragment(CMolecule* molecule,CElementsRecord* history=NULL) const;
00074     inline int  __fastcall GetFragmentIndex(void) const;
00075 
00076  // sekce soukromých dat -------------------------------------------------------
00077     public:
00078     int                                         FragmentIndex;  // index fragmentu
00079     CSmallString                        Name;           // jméno fragmentu
00080     CSmallString                        Description;    // popis fragmentu
00081     CExtObject::CStatus         Status;         // status fragmentu
00082     int                                         NumOfAtoms;     // počet atomů fragmentu
00083     int                     NumOfBonds;         // počet vazeb fragmentu
00084     int                     NumOfHalfBonds; // počet hraničních vazeb
00085     int*                                        Atoms;                  // seznam indexů atomů
00086     int*                                        Bonds;          // seznam indexů vazeb
00087     int*                    HalfBonds;      // seznam hraničních vazeb
00088     };
00089 
00090 // -----------------------------------------------------------------------------
00091 
00093 
00096 class NEMESIS_CORE_PACKAGE CFragment : public CExtObject{
00097     public:
00098  // konstruktor a destruktor ---------------------------------------------------
00099                         __fastcall CFragment(CFragmentsList* own);
00100     void        __fastcall RemoveFromBaseList(CElementsRecord* history=NULL);
00101 
00102  // operace pro mapování fragmentů ---------------------------------------------
00103     void __fastcall MapAtoms(CAtom* atom1,CAtom* atom2=NULL,CElementsRecord* history=NULL);
00104     void __fastcall MapBonds(CElementsRecord* history=NULL);
00105     void __fastcall EndMap(void);
00106 
00107  // metody - operace zaznamenané do seznamu změn -------------------------------
00108     bool __fastcall Delete(void);
00109     bool __fastcall DeleteContents(void);
00110     bool __fastcall SaveChangePositionOfAtoms(void);
00111     bool __fastcall MapAtomsFromSelection(CSelection* p_selection);
00112     bool __fastcall AddObject(CExtObject* p_object);
00113     bool __fastcall RemoveObject(CExtObject* p_object);
00114 
00115  // metody - zjištovací operace ------------------------------------------------
00116     CPoint __fastcall GetCentrum(void);
00117     inline CMolecule* __fastcall GetMolecule(void);
00118 
00119  // metody - uložení a načtení fragmentu -------------------------------------------
00120     bool __fastcall Load(CXMLElement* p_el);
00121     bool __fastcall Save(CXMLElement* p_el);
00122     bool __fastcall SaveInStructureFormat(CXMLElement* p_el);
00123 
00124  // metody - pomocné funkce ----------------------------------------------------
00125     bool __fastcall RegisterAtom(CAtom* atom,CElementsRecord* history=NULL);
00126     bool __fastcall UnregisterAtom(CAtom* atom,CElementsRecord* history=NULL);
00127     bool __fastcall RegisterBond(CBond* bond,CElementsRecord* history=NULL);
00128     bool __fastcall UnregisterBond(CBond* bond,CElementsRecord* history=NULL);
00129     bool __fastcall RegisterHalfBond(CBond* bond,CElementsRecord* history=NULL);
00130     bool __fastcall UnregisterHalfBond(CBond* bond,CElementsRecord* history=NULL);
00131 
00132  // metody
00133     virtual void __fastcall RemoveFromRegistered(CExtObject* object,CElementsRecord* history=NULL);
00134 
00135  // sekce veřejných dat --------------------------------------------------------
00136     CSimpleList<CAtom>           Atoms;           // seznam atomů
00137     CSimpleList<CBond>           Bonds;           // seznam vazeb
00138     CSimpleList<CBond>           HalfBonds;       // seznam okrajových vazeb, není vlastníkem
00139 
00140     private:
00141     CFragmentsList*                              BaseList;                // seznam fragmentů
00142     bool                         HighlightStatus;
00143     virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00144     };
00145     
00146 // ----------------------------------------------------------------------------
00147 
00148 DECLARE_EVENT(Fragment_RegisterObject);
00149 DECLARE_EVENT(Fragment_UnregisterObject);
00150 
00151 // -----------------------------------------------------------------------------
00152 
00154 
00157 class NEMESIS_CORE_PACKAGE CFragmentsList : public CExtObject, public CTemplList<CFragment> {
00158     public:
00159         __fastcall CFragmentsList(CMolecule* own);
00160 
00161  // metody se záznamem do history listu ----------------------------------------
00162     CFragment* __fastcall CreateFragment(CFragmentData& fragmentdata);
00163 
00164  // metody - operace se seznamem -----------------------------------------------
00165     CFragment* __fastcall SearchByName(const CSmallString& name);
00166     CFragment* __fastcall SearchByDescription(const CSmallString& descrip);
00167 
00168  // metody - výkonové operace --------------------------------------------------
00169         CFragment* __fastcall MakeNewFragment(CElementsRecord* history=NULL);
00170     CFragment* __fastcall AddFragment(CFragmentData& fd,CElementsRecord* history=NULL);
00171 
00172  // metody - uložení a načtení fragmentů -------------------------------------------
00173     bool __fastcall Load(CXMLElement* p_el);
00174     bool __fastcall Save(CXMLElement* p_el);
00175 
00176  // zjišťovací operace ---------------------------------------------------------
00177     __property CMolecule* Molecule = {read = FMolecule};
00178 
00179  // sekce soukromých dat -------------------------------------------------------
00180     private:
00181     CMolecule* FMolecule; // odkaz na molekulu
00182     };
00183 
00184 
00185 // -----------------------------------------------------------------------------
00186 
00187 DECLARE_EVENT(FragmentsList_AddFragment);
00188 DECLARE_EVENT(FragmentsList_RemoveFragment);
00189 
00190 // ----------------------------------------------------------------------------
00191 // ############################################################################
00192 // ----------------------------------------------------------------------------
00193 
00194 extern CPluginObjectInfo FragmentEnumObjectInfo;
00195 extern CExtUUID          ID_FragmentEnum;
00196 
00197 // ----------------------------------------------------------------------------
00198 
00200 
00203 class CFragmentEnumerator : public CContainerEnumerator {
00204     public:
00205         __fastcall CFragmentEnumerator(CComObject* owner,CMolecule* molecule);
00206 
00207     virtual int __fastcall NumOfCommands(void);
00208     virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00209     virtual bool __fastcall DoCommand(int i);
00210 
00211     virtual int         __fastcall NumOfObjects(void);
00212     virtual bool        __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00213     virtual CExtObject* __fastcall GetObject(int pos);
00214 
00215  // funkce pro rozšířený popis objektů a kontejnerů ----------------------------
00216     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00217     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00218     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00219     virtual int __fastcall GetObjectImageIndex(void);
00220 
00221     virtual CExtObject* __fastcall GetCurrentObject(void);
00222     virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00223 
00224     private:
00225     CFragmentsList*             Fragments;
00226     CTemplIterator<CFragment>   Pointer;
00227     CFragment*                  CurrentObject;
00228     int                         StartPos;
00229     int                         EndPos;
00230     bool                        Changed;
00231     CSimpleList<CFragment>      CurrentView;
00232 
00233     virtual void __fastcall CFragmentEnumerator::ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00234 
00235     };
00236 
00237 // ----------------------------------------------------------------------------
00238 // ############################################################################
00239 // ----------------------------------------------------------------------------
00240 
00241 /* TŘÍDA:   CBondDataHistory
00242    ÚČEL:    popisuje fragment, používá history list
00243 */
00244 
00245 class CFragmentDataHistory : public CElementData{
00246     public:
00247                                 __fastcall CFragmentDataHistory(CFragment* p_fragment,bool create);
00248     private:
00249     virtual void        __fastcall Forward(void);
00250     virtual void        __fastcall Backward(void);
00251 
00252     CMolecule*          Molecule;
00253     CFragmentData   Data;
00254     };
00255 
00256 
00257 // ----------------------------------------------------------------------------
00258 
00259 class CFragmentsListCreateFragmentHistory:public CCoreElementsRecord{
00260     public:
00261         __fastcall CFragmentsListCreateFragmentHistory(const CSmallString& name);
00262         private:
00263     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00264     CSmallString    FragmentName;
00265     };
00266 
00267 // -----------------------------------------------------------------------------
00268 // #############################################################################
00269 // -----------------------------------------------------------------------------
00270 
00271 
00272 /*  TŘÍDA: CFragmentDeleteHistory
00273     ÚČEL:  slouží pro záznam odstranění fragmentu
00274 */
00275 
00276 class CFragmentDeleteHistory:public CCoreElementsRecord{
00277         public:
00278         __fastcall CFragmentDeleteHistory(CFragment* p_fragment);
00279 
00280     private:
00281     CSmallString  Name;
00282     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00283     };
00284 
00285 // -----------------------------------------------------------------------------
00286 
00287 class CFragmentDeleteContentsHistory:public CCoreElementsRecord{
00288         public:
00289         __fastcall CFragmentDeleteContentsHistory(CFragment* p_fragment);
00290     private:
00291     CSmallString  Name;
00292     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00293     };
00294 
00295 // -----------------------------------------------------------------------------
00296 // #############################################################################
00297 // -----------------------------------------------------------------------------
00298 
00299 /*  TŘÍDA: CFragmentPositionHistory
00300     ÚČEL:  slouží pro záznam změny polohy fragmentu
00301 */
00302 
00303 class CFragmentPositionHistory:public CCoreElementsRecord{
00304     public:
00305     __fastcall CFragmentPositionHistory(void);
00306     __fastcall ~CFragmentPositionHistory(void);
00307     bool __fastcall ConstructFromList(CSimpleList<CAtom> &atoms);
00308 
00309     private:
00310     CMolecule* Molecule;
00311     CPoint  *Area;
00312     int     *Indexs;
00313     int     Size;
00314     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00315     virtual void __fastcall Forward(void);
00316     virtual void __fastcall Backward(void);
00317     };
00318 
00319 // -----------------------------------------------------------------------------
00320 // #############################################################################
00321 // -----------------------------------------------------------------------------
00322 
00323 class CFragmentObjectUnregHistory: public CElementData{
00324     public:
00325     __fastcall CFragmentObjectUnregHistory(CFragment* p_fr,CExtObject* p_obj,bool regobject,bool half=false);
00326 
00327     private:
00328     CMolecule*  Molecule;
00329     int         FragmentIndex;
00330     int         ObjectIndex;
00331     bool        IsAtom;
00332     bool        Half;
00333 
00334     virtual void __fastcall Forward(void);
00335     virtual void __fastcall Backward(void);
00336     };
00337 
00338 // -----------------------------------------------------------------------------
00339 // #############################################################################
00340 // -----------------------------------------------------------------------------
00341 
00342 class CMapAtomsFromSelectionHistory : public CCoreElementsRecord{
00343     public:
00344     __fastcall CMapAtomsFromSelectionHistory(CFragment* p_fra);
00345 
00346     private:
00347     CSmallString    FragmentName;
00348     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00349     };
00350 
00351 // -----------------------------------------------------------------------------
00352 
00353 class CMapObjectHistory : public CCoreElementsRecord{
00354     public:
00355     __fastcall CMapObjectHistory(CFragment* p_fra,CExtObject* p_object,bool add);
00356 
00357     private:
00358     CSmallString    FragmentName;
00359     CSmallString    ObjectName;
00360     CSmallString    ObjectType;
00361     virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00362     };
00363 
00364 // -----------------------------------------------------------------------------
00365 // #############################################################################
00366 // -----------------------------------------------------------------------------
00367 
00368 inline int      __fastcall CFragmentData::GetFragmentIndex(void) const
00369 {
00370  return(FragmentIndex);
00371 }
00372 
00373 //---------------------------------------------------------------------------
00374 
00375 inline CMolecule* __fastcall CFragment::GetMolecule(void)
00376 {
00377  return(BaseList->Molecule);
00378 }
00379 
00380 //---------------------------------------------------------------------------
00381 
00382 
00383 #endif

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