GME  13
GMEDoc.h
Go to the documentation of this file.
00001 // GMEDoc.h : interface of the CGMEDoc class
00002 //
00004 
00005 #if !defined(AFX_GMEDOC_H__BD235B53_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_)
00006 #define AFX_GMEDOC_H__BD235B53_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include "GMEStd.h"
00013 #include "GuiObject.h"
00014 #include "GMEOLEData.h"
00015 #include "MgaUtil.h"
00016 #include <list>
00017 #include <string>
00018 
00019 class CGMEChildFrame;
00020 
00021 class CGMEDoc : public CDocument
00022 {
00023 friend class CGMEView;
00024 
00025 protected: // create from serialization only
00026         CGMEDoc();
00027         DECLARE_DYNCREATE(CGMEDoc)
00028 
00029 // Attributes
00030 public:
00031         static CGMEDoc *theInstance;
00032 protected:
00033         bool     m_isClosing;
00034         GMEModeCode editMode;
00035 
00036         CComPtr<IMgaModel> nextToView;
00037         CComPtr<IMgaFCO> initialCenterObj;
00038         CString nextAspect;
00039         CComPtr<IMgaResolver> resolver;
00040 
00041 // Operations
00042 public:
00043         GMEModeCode GetEditMode() const;
00044         void SetEditMode(GMEModeCode mode, const CString& statusMsg);
00045         int  HowManyViewsAreOpen();
00046         void InvalidateAllViews(bool thorough = false, bool fullAutoRoute = false);
00047         void ResetAllViews();
00048         void ViewModeChange();
00049 #if !defined (ACTIVEXGMEVIEW)
00050         CGMEView *FindView(CComPtr<IMgaModel> model);
00051 #else
00052         CGMEChildFrame *FindView(CComPtr<IMgaModel> model);
00053 #endif
00054         void DoOnViewRefresh(void);
00055 
00056         class Historian
00057         {
00058         public:
00059 
00060                 class HistoryElem 
00061                 {
00062                 public:
00063                         HistoryElem()
00064                         {
00065                         }
00066 
00067                         HistoryElem( const std::wstring& p_id
00068                                    , const std::wstring& p_aspect)
00069                                 : m_id( p_id)
00070                                 , m_an( p_aspect)
00071                         {
00072                         }
00073 
00074                         HistoryElem( const HistoryElem& peer)
00075                                 : m_id( peer.m_id)
00076                                 , m_an( peer.m_an)
00077                         {
00078                         }
00079 
00080                         const HistoryElem& operator=( const HistoryElem& peer)
00081                         {
00082                                 if( this == &peer) return *this;
00083 
00084                                 m_id = peer.m_id;
00085                                 m_an = peer.m_an;
00086 
00087                                 return *this;
00088                         }
00089                         
00090                         const std::wstring& id() const { return m_id; }
00091                         const std::wstring& aspect() const { return m_an; }
00092 
00093                         bool operator==( const HistoryElem& peer) const
00094                         {
00095                                 return id() == peer.id() && aspect() == peer.aspect();
00096                         }
00097 
00098                         bool operator!=( const HistoryElem& peer) const
00099                         {
00100                                 return !( *this == peer);
00101                         }
00102 
00103                 private:
00104                         std::wstring m_id;
00105                         std::wstring m_an; // aspect name
00106                 };
00107 
00108         public:
00109                 bool isEmptyB() const;
00110                 bool isEnabledBack() const;
00111                 bool isEnabledFrwd() const;
00112                 bool isEnabledHome() const;
00113 
00114                 void totalBrainWash();
00115                 void frwdBrainWash();
00116 
00117                 void pushB( const HistoryElem& e);
00118                 void pushF( const HistoryElem& e);
00119 
00120                 void popB( HistoryElem& e, HistoryElem& c);
00121                 void popF( HistoryElem& e);
00122                 void frontB( HistoryElem& e);
00123 
00124                 void eraseOccurences( const std::wstring& p_id);
00125                 void erasePrevOccurencesB( const HistoryElem& e);
00126 
00127         private:
00128                 typedef std::list< HistoryElem >   HISTLIST;
00129                 typedef HISTLIST::iterator         HISTLIST_ITER;
00130                 HISTLIST                           m_backStack;
00131                 HISTLIST                           m_frwdStack;
00132 
00133         } m_historian;
00134 
00135         void SetNextToView(CComPtr<IMgaModel> &model,CString aspName, CComPtr<IMgaFCO> &centerObj)                      { nextToView = model; nextAspect = aspName; initialCenterObj = centerObj; }
00136         void ShowObject(CComPtr<IUnknown> alienObject, BOOL inParent = FALSE);
00137         void ShowObject(LPCTSTR objectID);
00138         void ResetNextToView()                                                                                                  { nextToView = 0; }
00139         void ChangeAspects(int index, CString aspName);
00140         void ConvertPathToCustom(CComPtr<IUnknown>& pMgaObject);
00141 
00142         static bool CreateFcoList(CGuiObjectList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view);
00143         static bool CreateFcoList2(CGuiFcoList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view, long *howmany, bool* array[8]);
00144         static bool CreateAnnotationList(CGuiAnnotatorList* list,CComPtr<IMgaRegNodes> &anns,CGMEView *view);
00145         static void CopyClosureToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
00146         static void CopySmartToClipboard(CGuiFcoList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
00147         static void CopyToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
00148         static DROPEFFECT DoDragDrop(CGuiObjectList* list, CGuiAnnotatorList *annList, CGMEDataDescriptor* desc,
00149                                                                         DWORD dwEffects, LPCRECT lpRectStartDrag,CGMEView *view);
00150         static DROPEFFECT DoDragDrop(CGuiObject *guiObj, CGMEDataDescriptor* desc,
00151                                                                         DWORD dwEffects, LPCRECT lpRectStartDrag);
00152 
00153 // Overrides
00154         // ClassWizard generated virtual function overrides
00155         //{{AFX_VIRTUAL(CGMEDoc)
00156         public:
00157         virtual BOOL OnNewDocument();
00158         virtual void OnCloseDocument(bool suppressErrors = false);
00159         virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
00160         //}}AFX_VIRTUAL
00161 
00162 // Implementation
00163 public:
00164         virtual ~CGMEDoc();
00165 #ifdef _DEBUG
00166         virtual void AssertValid() const;
00167         virtual void Dump(CDumpContext& dc) const;
00168 #endif
00169 
00170 public:
00171 void SetMode(long mode);
00172 
00173         // history related
00174         void back();
00175         void forw();
00176         void home();
00177         void clearTotalHistory();
00178         void clearForwHistory();
00179         void tellHistorian( CComBSTR&           modid, CString asp);
00180         void tellHistorian( CComPtr<IMgaModel>& model, CString asp);
00181         void presentModel( LPCTSTR objectID, LPCTSTR aspectNM);
00182         void eraseFromHistory( LPCTSTR p_id);
00183 
00184         void closeActiveWnd();
00185         void closeAllWnd();
00186         void closeAllButActiveWnd();
00187         void cycleAspect();
00188         void cycleAllAspects();
00189         void cycleViews();
00190 
00191 // Generated message map functions
00192 protected:
00193         //{{AFX_MSG(CGMEDoc)
00194         afx_msg void OnModeAutoconnect();
00195         afx_msg void OnUpdateModeAutoconnect(CCmdUI* pCmdUI);
00196         afx_msg void OnModeDisconnect();
00197         afx_msg void OnUpdateModeDisconnect(CCmdUI* pCmdUI);
00198         afx_msg void OnModeEdit();
00199         afx_msg void OnUpdateModeEdit(CCmdUI* pCmdUI);
00200         afx_msg void OnModeSet();
00201         afx_msg void OnUpdateModeSet(CCmdUI* pCmdUI);
00202         afx_msg void OnModeVisualize();
00203         afx_msg void OnUpdateModeVisualize(CCmdUI* pCmdUI);
00204         afx_msg void OnModeZoom();
00205         afx_msg void OnUpdateModeZoom(CCmdUI* pCmdUI);
00206         afx_msg void OnModeShortConnect();
00207         afx_msg void OnUpdateModeShortConnect(CCmdUI* pCmdUI);
00208         afx_msg void OnModeShortDisconnect();
00209         afx_msg void OnUpdateModeShortDisconnect(CCmdUI* pCmdUI);
00210         afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI);
00211         afx_msg void OnViewRefresh();
00212         afx_msg void OnBtnBack();
00213         afx_msg void OnBtnFrwd();
00214         afx_msg void OnBtnHome();
00215         afx_msg void OnUpdateBtnFrwd(CCmdUI* pCmdUI);
00216         afx_msg void OnUpdateBtnBack(CCmdUI* pCmdUI);
00217         afx_msg void OnUpdateBtnHome(CCmdUI* pCmdUI);
00218         afx_msg void OnBtnCloseActive();
00219         afx_msg void OnBtnCloseAll();
00220         afx_msg void OnBtnCloseAllButOne();
00221         afx_msg void OnBtnCycleAspect();
00222         afx_msg void OnBtnCycleAllAspects();
00223         afx_msg void OnBtnCycleViews();
00224         //}}AFX_MSG
00225         DECLARE_MESSAGE_MAP()
00226 
00227 };
00228 
00230 
00231 //{{AFX_INSERT_LOCATION}}
00232 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00233 
00234 #endif // !defined(AFX_GMEDOC_H__BD235B53_BD3F_11D3_91E2_00104B98EAD9__INCLUDED_)