GME  13
AggregateOptions.cpp
Go to the documentation of this file.
00001 // AggregateOptions.cpp: implementation of the CAggregateOptions class.
00002 //
00004 
00005 #include "stdafx.h"
00006 #include "gmeactivebrowser.h"
00007 #include "AggregateOptions.h"
00008 
00009 #ifdef _DEBUG
00010 #undef THIS_FILE
00011 static char THIS_FILE[]=__FILE__;
00012 #define new DEBUG_NEW
00013 #endif
00014 
00016 // Construction/Destruction
00018 
00019 CAggregateOptions::CAggregateOptions()
00020 {
00021         // Defaults for the first run or in case of registry problems
00022         m_bDispModel=TRUE;
00023         m_bDispAtom=TRUE;
00024         m_bDispReference=TRUE;
00025         m_bDispSet=TRUE;
00026         m_bDispConnections=FALSE;
00027 
00028         m_soSortOptions=SORT_BYNAME;
00029         m_bStoreTreeInRegistry=FALSE;
00030 
00031         // This is not set by the user interface only stored in the registry
00032         m_bIsDynamicLoading=TRUE;
00033 
00034         LoadFromRegistry();
00035 }
00036 
00037 CAggregateOptions::~CAggregateOptions()
00038 {
00039         SaveToRegistry();
00040 }
00041 
00042 void CAggregateOptions::SaveToRegistry()
00043 {
00044                 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
00045                 pApp->WriteProfileInt(_T("Settings"),_T("Display Models"),m_bDispModel);
00046                 pApp->WriteProfileInt(_T("Settings"),_T("Display Atoms"),m_bDispAtom);
00047                 pApp->WriteProfileInt(_T("Settings"),_T("Display References"),m_bDispReference);
00048                 pApp->WriteProfileInt(_T("Settings"),_T("Display Sets"),m_bDispSet);
00049                 pApp->WriteProfileInt(_T("Settings"),_T("Display Connections"),m_bDispConnections);
00050 
00051                 pApp->WriteProfileInt(_T("Settings"),_T("Sort Option"),m_soSortOptions);
00052                 pApp->WriteProfileInt(_T("Settings"),_T("Store Tree In Registry"),m_bStoreTreeInRegistry);
00053 
00054                 pApp->WriteProfileInt(_T("Settings"),_T("Dynamic Loading"),m_bIsDynamicLoading);
00055 }
00056 
00057 void CAggregateOptions::LoadFromRegistry()
00058 {
00059                 #define NO_VALUE 1000
00060 
00061                 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp();
00062                 
00063                 int nValue=pApp->GetProfileInt(_T("Settings"),_T("Display Models"),NO_VALUE);
00064                 if(nValue!=NO_VALUE)
00065                 {
00066                         m_bDispModel=nValue;
00067                 }
00068 
00069                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Display Atoms"),NO_VALUE);
00070                 if(nValue!=NO_VALUE)
00071                 {
00072                         m_bDispAtom=nValue;
00073                 }
00074 
00075                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Display Connections"),NO_VALUE);
00076                 if(nValue!=NO_VALUE)
00077                 {
00078                         m_bDispConnections=nValue;
00079                 }
00080 
00081                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Display References"),NO_VALUE);
00082                 if(nValue!=NO_VALUE)
00083                 {
00084                         m_bDispReference=nValue;
00085                 }
00086 
00087                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Display Sets"),NO_VALUE);
00088                 if(nValue!=NO_VALUE)
00089                 {
00090                         m_bDispSet=nValue;
00091                 }
00092 
00093                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Store Tree In Registry"),NO_VALUE);
00094                 if(nValue!=NO_VALUE)
00095                 {
00096                         m_bStoreTreeInRegistry=nValue;
00097                 }
00098 
00099                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Dynamic Loading"),NO_VALUE);
00100                 if(nValue!=NO_VALUE)
00101                 {
00102                         m_bIsDynamicLoading=nValue;
00103                 }
00104 
00105 
00106                 nValue=pApp->GetProfileInt(_T("Settings"),_T("Sort Option"),NO_VALUE);
00107                 if(nValue!=NO_VALUE)
00108                 {
00109                         m_soSortOptions=(eSortOptions)nValue;
00110                 }
00111 
00112 }
00113 
00114 BOOL CAggregateOptions::IsDisplayedType(objtype_enum otType)
00115 {
00116 
00117         switch(otType)
00118         {
00119                 case OBJTYPE_FOLDER: return TRUE;
00120                 case OBJTYPE_MODEL: return m_bDispModel;
00121                 case OBJTYPE_ATOM: return m_bDispAtom;
00122                 case OBJTYPE_CONNECTION: return m_bDispConnections;
00123                 case OBJTYPE_REFERENCE: return m_bDispReference;
00124                 case OBJTYPE_SET: return  m_bDispSet;
00125                 default: return FALSE;
00126         }
00127 }