├── .gitignore ├── ChangeLog.txt ├── Compiling.txt ├── README.md ├── ReadTest ├── ReadMe.txt ├── ReadTest.cpp ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── Release_vs2005 └── txdviewerdbcfg ├── TXDViewer2.sln ├── TXDViewer2 ├── AboutDlg.h ├── ConnectDBDlg.h ├── DataParser │ ├── BigFileReader.cpp │ ├── BigFileReader.h │ ├── IDataReader.h │ ├── ParseFeatureSet.cpp │ ├── ParseFeatureSet.h │ ├── PostGISReader.h │ ├── ShapefileReader.h │ └── TXDTypes.h ├── DropFileHandler.h ├── ErrorCode.h ├── FileManagerDlg.h ├── FindDlg.h ├── GeoData │ ├── Feature.h │ ├── FeatureSet.cpp │ ├── FeatureSet.h │ ├── PostGISFeatureSet.cpp │ ├── PostGISFeatureSet.h │ ├── SHPFeatureSet.cpp │ ├── SHPFeatureSet.h │ ├── TXDFeatureSet.cpp │ └── TXDFeatureSet.h ├── GeoRender │ └── GDIRender.h ├── IdentifyDlg.h ├── LegendTreeCtrl.h ├── LocateDlg.h ├── MainFrm.h ├── Maindlg.h ├── MapManager │ ├── Layer.cpp │ ├── Layer.h │ ├── MapManager.cpp │ └── MapManager.h ├── MetaInfoDlg.h ├── MruList.h ├── SplitterBar.h ├── TXDViewer2.cpp ├── TXDViewer2.h ├── TXDViewer2.rc ├── TXDViewer2.vcproj ├── TXDViewer2.vcxproj ├── TXDViewer2.vcxproj.filters ├── TXDViewer2View.h ├── TXDViewer2_vs2005.vcproj ├── Thread.h ├── atlres.h ├── atlwfile.h ├── dbprops.h ├── gdal192 │ └── include │ │ ├── cpl_config.h │ │ ├── cpl_port.h │ │ ├── gdal_version.h │ │ ├── libpq-fe.h │ │ ├── ogr_core.h │ │ ├── ogr_geometry.h │ │ ├── ogr_spatialref.h │ │ ├── ogr_srs_api.h │ │ ├── postgres_ext.h │ │ └── shapefil.h ├── res │ ├── Checked.ico │ ├── Data_25.png │ ├── Data_26.png │ ├── Data_6.png │ ├── Data_7.png │ ├── Find.ico │ ├── HandClose.cur │ ├── Identify.ico │ ├── Layers.ico │ ├── TXDViewer2.ico │ ├── Unchecked.ico │ ├── ZoomIn.cur │ ├── ZoomInl.cur │ ├── ZoomOut.cur │ ├── ZoomOutl.cur │ ├── ico3.ico │ ├── ico4.ico │ ├── ico5.ico │ └── toolbar.bmp ├── resource.h ├── stdafx.cpp ├── stdafx.h ├── strtk.hpp └── wtl81_12085 │ ├── CPL.TXT │ └── Include │ ├── atlapp.h │ ├── atlcrack.h │ ├── atlctrls.h │ ├── atlctrlw.h │ ├── atlctrlx.h │ ├── atlddx.h │ ├── atldlgs.h │ ├── atldwm.h │ ├── atlfind.h │ ├── atlframe.h │ ├── atlgdi.h │ ├── atlmisc.h │ ├── atlprint.h │ ├── atlresce.h │ ├── atlribbon.h │ ├── atlscrl.h │ ├── atlsplit.h │ ├── atltheme.h │ ├── atluser.h │ ├── atlwince.h │ └── atlwinx.h ├── TXDViewer2_vs2005.sln └── x64 └── Release_vs2005 └── txdviewerdbcfg /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | *.dll 11 | 12 | # Compiled Static libraries 13 | *.lai 14 | *.la 15 | *.a 16 | *.lib 17 | 18 | # User special files 19 | *.user 20 | 21 | # log files 22 | *.log 23 | *.tlog 24 | 25 | # others 26 | *.suo 27 | *.lastbuildstate 28 | *.unsuccessfulbuild 29 | *.pch 30 | *.res 31 | *.sdf 32 | *.htm 33 | *.XML 34 | *.ipch 35 | *.exe 36 | *.res 37 | *.idb 38 | *.pdb 39 | *.ilk 40 | *.opensdf 41 | *.zip 42 | *.orig 43 | *.ncb 44 | *.dep 45 | *.manifest 46 | *.exp 47 | *.suo -------------------------------------------------------------------------------- /ChangeLog.txt: -------------------------------------------------------------------------------- 1 | 2013-6-08 v2.2.7 2 | 1. FIX Bug: database cursor can't scroll back 3 | 2013-5-10 v2.2.6 4 | 1. tidying up code, commit to SVN. 5 | 2013-4-22 v2.2.5 6 | 1. Add support for SP record 7 | 2013-4-17 v2.2.4 8 | 1. Optimize for record which has lots of points. 9 | 2013-4-13 v2.2.3 10 | 1. Support SQL query for PostGIS 11 | 2013-4-03 v2.2.2 12 | 1. Support 'GEOMETRY' in PostGIS 13 | 2. Fix Bug: can't add/edit a connection 14 | 15 | 2013-4-01 v2.2.1 16 | 1. Support URI hostname when connect PostGIS 17 | 2. Fix Bug: crash when not set id column. 18 | 19 | 2013-3-31 Add PostGIS support (Partly), Skip version to 2.2.0 20 | 21 | 2013-3-24 Initial version 2.0.1 -------------------------------------------------------------------------------- /Compiling.txt: -------------------------------------------------------------------------------- 1 | How to compile the project 2 | ========================== 3 | 4 | 5 | These are generic compilation instructions. 6 | 7 | The solution compiles with Microsoft Visual Studio 2012, and also with the VS2005. 8 | If use VS2012 express, you need to install VS2012 update1 and Windows SDK. 9 | We turn off C++ exception handler (/EHsc, we don't need it ;-) ) to produce faster and small code. 10 | 11 | Links 12 | The folllowing links are needed or useful for compiling the projects: 13 | 14 | Microsoft WTL library 15 | http://wtl.sourceforge.net 16 | 17 | If you familiar with MFC, you will find WTL is very easy. 18 | 19 | qtxie 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SimpleGISViewer 2 | =============== 3 | 4 | A simple GIS viewer. Very fast and low memory usage. 5 | 6 | 7 | 8 | ## Features 9 | 10 | 1. In 'Pan' Mode, Mouse left button down to move map 11 | 2. In 'Identify' Mode, 12 | - Mouse left button click to select one feature, 13 | - Mouse right button click to draw a rectangle, select features in the rectangle. 14 | 3. Mouse wheel to zoom in and zoom Out 15 | 4. Now support Shapefile and PostGIS (File -> Connect DB) 16 | 5. Show feature's ID 17 | 6. Search by coordinates and feature ID 18 | 7. Support drag & drop 19 | 8. Loading data asynchronously 20 | 9. Support SQL when loading PostGIS data 21 | 22 | ## Shortcut Keys 23 | 1. Ctrl + F Find a feature by ID 24 | 2. Ctrl + L Locate to a coordinates 25 | 3. Ctrl + D Pan Mode 26 | 4. Ctrl + E Identify Mode 27 | 5. ESC Close sub window, such as Locate Window and Identify Window 28 | -------------------------------------------------------------------------------- /ReadTest/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : ReadTest Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this ReadTest application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your ReadTest application. 9 | 10 | 11 | ReadTest.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | ReadTest.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | ReadTest.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named ReadTest.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /ReadTest/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ReadTest.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /ReadTest/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /ReadTest/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #define _WIN32_WINNT 0x0501 9 | #include 10 | #include 11 | -------------------------------------------------------------------------------- /Release_vs2005/txdviewerdbcfg: -------------------------------------------------------------------------------- 1 | DevTest 2 | 172.16.102.142 3 | 5432 4 | dev_test 5 | public 6 | postgres 7 | postgres 8 | 102.146 9 | 172.16.102.146 10 | 5432 11 | NA13M3 12 | usauc1 13 | postgres 14 | 15 | OSM 16 | 10.224.75.96 17 | 5432 18 | OSM_ODBL 19 | %% 20 | postgres 21 | postgres 22 | -------------------------------------------------------------------------------- /TXDViewer2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TXDViewer2", "TXDViewer2\TXDViewer2.vcxproj", "{CAF02B44-6FD3-418B-94F8-B0AA22A473BE}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadTest", "ReadTest\ReadTest.vcxproj", "{29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | StatisticRelease|Win32 = StatisticRelease|Win32 15 | StatisticRelease|x64 = StatisticRelease|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Debug|Win32.Build.0 = Debug|Win32 20 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Debug|x64.ActiveCfg = Debug|x64 21 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Debug|x64.Build.0 = Debug|x64 22 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Release|Win32.ActiveCfg = Release|Win32 23 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Release|Win32.Build.0 = Release|Win32 24 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Release|x64.ActiveCfg = Release|x64 25 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.Release|x64.Build.0 = Release|x64 26 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.StatisticRelease|Win32.ActiveCfg = StatisticRelease|Win32 27 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.StatisticRelease|Win32.Build.0 = StatisticRelease|Win32 28 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.StatisticRelease|x64.ActiveCfg = StatisticRelease|x64 29 | {CAF02B44-6FD3-418B-94F8-B0AA22A473BE}.StatisticRelease|x64.Build.0 = StatisticRelease|x64 30 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Debug|Win32.Build.0 = Debug|Win32 32 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Debug|x64.ActiveCfg = Debug|x64 33 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Debug|x64.Build.0 = Debug|x64 34 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Release|Win32.ActiveCfg = Release|Win32 35 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Release|Win32.Build.0 = Release|Win32 36 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Release|x64.ActiveCfg = Release|x64 37 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.Release|x64.Build.0 = Release|x64 38 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.StatisticRelease|Win32.ActiveCfg = StatisticRelease|Win32 39 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.StatisticRelease|Win32.Build.0 = StatisticRelease|Win32 40 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.StatisticRelease|x64.ActiveCfg = StatisticRelease|x64 41 | {29D1CFE8-2A0B-467E-BA17-192AADD3CBFD}.StatisticRelease|x64.Build.0 = StatisticRelease|x64 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /TXDViewer2/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 24 | { 25 | CenterWindow(GetParent()); 26 | return TRUE; 27 | } 28 | 29 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 30 | { 31 | EndDialog(wID); 32 | return 0; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /TXDViewer2/DataParser/BigFileReader.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "BigFileReader.h" 3 | 4 | int BigFileReader::Open(UINT mode) 5 | { 6 | if (m_bOpened) 7 | return VIEWER_OK; 8 | 9 | m_hFile = CreateFile( 10 | m_strFileName, // name of the read 11 | GENERIC_READ, // open for reading 12 | FILE_SHARE_READ, // share read 13 | NULL, // default security 14 | OPEN_EXISTING, // open exist file only 15 | FILE_ATTRIBUTE_NORMAL | mode, // normal file 16 | NULL); // no attr. template 17 | 18 | if (m_hFile == INVALID_HANDLE_VALUE) 19 | { 20 | return VIEWER_OPEN_FILE_FAILED; 21 | } 22 | 23 | m_bOpened = true; 24 | m_pBuffer = (char*)malloc(m_nBufSize); 25 | 26 | return VIEWER_OK; 27 | } 28 | 29 | 30 | int BigFileReader::Open(LPCTSTR lpstrFileName, UINT mode) 31 | { 32 | BOOL bResult; 33 | 34 | m_hFile = CreateFile( 35 | lpstrFileName, // name of the read 36 | GENERIC_READ, // open for reading 37 | FILE_SHARE_READ, // share read 38 | NULL, // default security 39 | OPEN_EXISTING, // open exist file only 40 | FILE_ATTRIBUTE_NORMAL | mode, // normal file, sequential scan 41 | NULL); // no attr. template 42 | 43 | if (m_hFile == INVALID_HANDLE_VALUE) 44 | { 45 | return VIEWER_OPEN_FILE_FAILED; 46 | } 47 | 48 | LARGE_INTEGER lFileSize = {0}; 49 | if (GetFileSizeEx(m_hFile, &lFileSize)) 50 | { 51 | m_nFileSize = lFileSize.QuadPart; 52 | } 53 | else 54 | { 55 | m_nFileSize = 1024*1024*1024; // 1GB 56 | } 57 | m_pBuffer = (char*)malloc(m_nBufSize); 58 | m_pStart = m_pBuffer; 59 | bResult = ReadFile(m_hFile, m_pBuffer, m_nBufSize, &m_dwBytesRead, NULL); 60 | if (!bResult) 61 | { 62 | free(m_pBuffer); 63 | m_pBuffer = NULL; 64 | return VIEWER_READ_FILE_FAILED; 65 | } 66 | 67 | return VIEWER_OK; 68 | } 69 | -------------------------------------------------------------------------------- /TXDViewer2/DataParser/BigFileReader.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // simple wrap win32 api in order to get max reading performance. 4 | // 5 | // Created 2013/1/13 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #ifndef _BIG_FILE_READER_H_ 10 | #define _BIG_FILE_READER_H_ 11 | 12 | #include "ErrorCode.h" 13 | #include "IDataReader.h" 14 | 15 | #define BUFFER_SIZE 1024 * 1024 * 4 16 | #define BUFFER_KEEP 1024 * 32 17 | 18 | class BigFileReader : public IDataReader 19 | { 20 | public: 21 | BigFileReader() : m_hFile(NULL), m_nBufSize(BUFFER_SIZE), m_dwStart(0), 22 | m_dwBytesRead(0), m_nOffset(0), m_nCurPos(0), m_pBuffer(NULL), m_pStart(NULL) 23 | {} 24 | 25 | explicit BigFileReader(CString strFileName) : m_hFile(NULL), m_nBufSize(BUFFER_SIZE), m_dwStart(0), 26 | m_dwBytesRead(0), m_nOffset(0), m_nCurPos(0), m_pBuffer(NULL), m_pStart(NULL) 27 | { 28 | m_bInteger = true; 29 | m_bOpened = false; 30 | m_strFileName = strFileName; 31 | } 32 | 33 | ~BigFileReader() 34 | { 35 | if (m_pBuffer != NULL) 36 | free(m_pBuffer); 37 | if (m_hFile != NULL) 38 | { 39 | CloseHandle(m_hFile); // we can close a NULL handle safely. 40 | } 41 | } 42 | virtual int Open(UINT mode); 43 | virtual void Close() 44 | { 45 | if (m_pBuffer != NULL) 46 | { 47 | free(m_pBuffer); 48 | m_pBuffer = NULL; 49 | } 50 | if (m_hFile != NULL) 51 | { 52 | CloseHandle(m_hFile); // we can close a NULL handle safely. 53 | m_hFile = NULL; 54 | } 55 | m_bOpened = false; 56 | } 57 | int Open(LPCTSTR lpstrFileName, UINT mode); 58 | 59 | size_t GetFileSize() 60 | { 61 | return m_nFileSize; 62 | } 63 | virtual void* GetData(size_t Idx) 64 | { 65 | Open(FILE_FLAG_RANDOM_ACCESS); 66 | LARGE_INTEGER nIdx; 67 | nIdx.QuadPart = Idx; 68 | DWORD dwRet = SetFilePointerEx(m_hFile, nIdx, NULL, FILE_BEGIN); 69 | if (dwRet == 0xFFFFFFFF) // Test for failure. 70 | { 71 | // Obtain the error code. 72 | DWORD dwError = GetLastError(); 73 | return NULL; 74 | // Resolve the failure. 75 | } // End of error handler. 76 | 77 | while (true) 78 | { 79 | char* pEnd = m_pBuffer; 80 | BOOL bResult = ReadFile(m_hFile, m_pBuffer, m_nBufSize, &m_dwBytesRead, NULL); 81 | if (!bResult) 82 | { 83 | free(m_pBuffer); 84 | m_pBuffer = NULL; 85 | return NULL; 86 | } 87 | 88 | pEnd = strchr(pEnd, '\n'); 89 | if (pEnd != NULL) 90 | { 91 | *pEnd = '\0'; 92 | break; 93 | } 94 | else 95 | { 96 | m_nBufSize += 1024*512; 97 | realloc(m_pBuffer, m_nBufSize); 98 | } 99 | } 100 | return m_pBuffer; 101 | } 102 | 103 | int GetLine(char*& pLine) 104 | { 105 | pLine = m_pBuffer; 106 | m_nOffset = m_nCurPos; 107 | while (true) 108 | { 109 | if (m_dwStart == m_dwBytesRead) 110 | { 111 | DWORD nReserve = m_pBuffer - pLine; 112 | char cLast = *(m_pBuffer - 1); 113 | m_pBuffer = m_pStart; 114 | memcpy(m_pBuffer, pLine, nReserve); 115 | 116 | if ((m_nBufSize - nReserve) < BUFFER_KEEP) 117 | { 118 | m_nBufSize *= 2; 119 | m_pBuffer = (char*)realloc(m_pBuffer, m_nBufSize); 120 | m_pStart = m_pBuffer; 121 | } 122 | 123 | pLine = m_pBuffer; 124 | m_pBuffer += nReserve; 125 | BOOL bResult = ReadFile(m_hFile, m_pBuffer, m_nBufSize - nReserve, &m_dwBytesRead, NULL); 126 | if (!bResult) 127 | { 128 | m_pBuffer -= nReserve; 129 | free(m_pBuffer); 130 | m_pBuffer = NULL; 131 | return VIEWER_READ_FILE_FAILED; 132 | } 133 | 134 | m_dwStart = 0; 135 | if (!m_dwBytesRead) // End of file, but the last line no '\n' 136 | { 137 | if (cLast == '\n') 138 | { 139 | return VIEWER_EOF; 140 | } 141 | 142 | if (m_dwBytesRead == m_nBufSize) 143 | { 144 | pLine = (char*)realloc(pLine, m_nBufSize + 16); 145 | } 146 | *m_pBuffer = '\n'; 147 | ++m_pBuffer; 148 | break; 149 | } 150 | } 151 | 152 | ++m_dwStart; 153 | ++m_nCurPos; 154 | 155 | if (*m_pBuffer == '\n') 156 | { 157 | ++m_pBuffer; 158 | break; 159 | } 160 | ++m_pBuffer; 161 | } 162 | 163 | return VIEWER_OK; 164 | } 165 | 166 | size_t GetOffset() const 167 | { 168 | return m_nOffset; 169 | } 170 | 171 | bool FindInBuffer(const char* pStr) const 172 | { 173 | return (NULL != strstr(m_pBuffer, pStr)); 174 | } 175 | private: 176 | HANDLE m_hFile; 177 | int m_nBufSize; 178 | DWORD m_dwStart; 179 | DWORD m_dwBytesRead; 180 | size_t m_nOffset; 181 | size_t m_nCurPos; 182 | char* m_pBuffer; 183 | char* m_pStart; 184 | size_t m_nFileSize; 185 | }; 186 | 187 | #endif -------------------------------------------------------------------------------- /TXDViewer2/DataParser/IDataReader.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTERFACE_FILE_READER_H_ 2 | #define _INTERFACE_FILE_READER_H_ 3 | 4 | class IDataReader 5 | { 6 | public: 7 | IDataReader() : m_bOpened(false) 8 | { 9 | } 10 | 11 | virtual int Open(UINT mode) = 0; 12 | virtual void Close() = 0; 13 | 14 | virtual void* GetData(size_t Idx) 15 | { 16 | return NULL; 17 | } 18 | 19 | virtual void* GetData(size_t nOffset, UINT nLen) 20 | { 21 | return NULL; 22 | } 23 | 24 | virtual void* GetFeatureID(size_t Idx) 25 | { 26 | return NULL; 27 | } 28 | 29 | virtual bool GetAllFeaturesID(std::vector& vID) 30 | { 31 | return false; 32 | } 33 | 34 | protected: 35 | CString m_strFileName; 36 | bool m_bOpened; 37 | public: 38 | bool m_bInteger; 39 | }; 40 | #endif -------------------------------------------------------------------------------- /TXDViewer2/DataParser/ParseFeatureSet.h: -------------------------------------------------------------------------------- 1 | #ifndef _PARSE_FEATURE_SET_H 2 | #define _PARSE_FEATURE_SET_H 3 | 4 | const char SPLIT_ATRRIBUTE = ','; 5 | const char SPLIT_POINT = ','; 6 | const char SPLIT_FIELD = ';'; 7 | const char SPLIT_SUB_ATRR = '|'; 8 | 9 | enum TXD_TYPE 10 | { 11 | #define TYPECODE(code, str) code, 12 | #include "TXDTypes.h" 13 | #undef TYPECODE 14 | }; 15 | 16 | enum DB_PARAMS 17 | { 18 | DB_NAME, 19 | DB_HOST, 20 | DB_PORT, 21 | DB_DATABASE, 22 | DB_SCHEMA, 23 | DB_USERNAME, 24 | DB_PWD, 25 | DB_PARAMS_SIZE 26 | }; 27 | 28 | struct ConnectDBParams 29 | { 30 | std::string host; 31 | std::string port; 32 | std::string database; 33 | std::string schema; 34 | std::string table; 35 | std::string geomcolumn; 36 | std::string username; 37 | std::string pwd; 38 | std::string idcolumn; 39 | std::string geotype; 40 | std::string sql; 41 | bool bComplexSQL; 42 | }; 43 | 44 | bool IsAlphaPresent( CString& myString ); 45 | bool IsAlphaPresent(const std::string& myString ); 46 | 47 | std::string Unicode2char(CString strUnicode); 48 | void StrGeoType2Enum(const char* strType, OGRwkbGeometryType& OGRType, GEO_TYPE& viewerType); 49 | 50 | int ParseTXDFeatureSet(LPCTSTR szFilename, MapManager& mapManager, HWND hWnd); 51 | 52 | int ParseTXDFeatureSetInt(LPCTSTR szFilename, MapManager& mapManager, HWND hWnd); 53 | int ParseTXDFeatureSetDouble(LPCTSTR szFilename, MapManager& mapManager, HWND hWnd); 54 | 55 | // Parse SHP Feature Set 56 | int ParseSHPFeatureSet(LPCTSTR szFilename, MapManager& mapManager, HWND hWnd); 57 | 58 | // Parse GDF Feature Set 59 | // TODO 60 | 61 | // Parse PostGIS Feature Set 62 | int ParsePostGISFeatureSet(const ConnectDBParams& db_params, MapManager& mapManager, HWND hWnd); 63 | int ParsePostGISFeatureSetSQL(const ConnectDBParams& db_params, MapManager& mapManager, HWND hWnd); 64 | int ParsePostGISFeatureSetTable(const ConnectDBParams& db_params, MapManager& mapManager, HWND hWnd); 65 | 66 | // More data formats ... 67 | // TODO 68 | 69 | #endif -------------------------------------------------------------------------------- /TXDViewer2/DataParser/PostGISReader.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // PostGIS reader. 4 | // Now it is too simple, need to enhance if have time. 5 | // 6 | // Created 2013/1/13 7 | // 8 | // ******************************************************************************************************** 9 | 10 | #ifndef _POSTGIS_READER_H_ 11 | #define _POSTGIS_READER_H_ 12 | 13 | #include "Feature.h" 14 | #include "ErrorCode.h" 15 | #include "IDataReader.h" 16 | 17 | class PostGISReader : public IDataReader 18 | { 19 | public: 20 | PostGISReader() : m_nCurIdx(-1) 21 | {} 22 | 23 | explicit PostGISReader(ConnectDBParams params) : m_nCurIdx(-1), m_conn(NULL) 24 | { 25 | m_bOpened = false; 26 | m_params = params; 27 | } 28 | 29 | ~PostGISReader() 30 | { 31 | if (m_conn != NULL) 32 | { 33 | /* close the portal ... we don't bother to check for errors ... */ 34 | PGresult* res = PQexec(m_conn, "CLOSE myportal"); 35 | PQclear(res); 36 | 37 | /* end the transaction */ 38 | res = PQexec(m_conn, "END"); 39 | PQclear(res); 40 | PQfinish(m_conn); 41 | } 42 | } 43 | 44 | int Open(LPCTSTR lpstrFileName, UINT mode) 45 | { 46 | return VIEWER_OK; 47 | } 48 | 49 | virtual int Open(UINT mode) 50 | { 51 | if (m_bOpened) 52 | return VIEWER_OK; 53 | const char* fmt_Cursor = "DECLARE myportal SCROLL CURSOR FOR SELECT *,ST_ASTEXT(\"%s\") AS geom from %s.\"%s\""; 54 | const char* fmt_CursorSQL = "DECLARE myportal SCROLL CURSOR FOR SELECT *,ST_ASTEXT(\"%s\") AS geom from %s.\"%s\" %s"; 55 | const char* fmt_CursorComplexSQL = "DECLARE myportal SCROLL CURSOR FOR %s"; 56 | const char* fmt_conninfo = "%s = '%s' port = '%s' \ 57 | dbname = '%s' user = '%s' \ 58 | password = '%s' connect_timeout = '6'"; 59 | char conninfo[256] = {0}; 60 | if (IsAlphaPresent(m_params.host)) 61 | { 62 | sprintf(conninfo, fmt_conninfo, "host", m_params.host.c_str(), m_params.port.c_str(), 63 | m_params.database.c_str(), m_params.username.c_str(), m_params.pwd.c_str()); 64 | } 65 | else 66 | { 67 | sprintf(conninfo, fmt_conninfo, "hostaddr", m_params.host.c_str(), m_params.port.c_str(), 68 | m_params.database.c_str(), m_params.username.c_str(), m_params.pwd.c_str()); 69 | } 70 | m_conn = PQconnectdb(conninfo); 71 | if (PQstatus(m_conn) != CONNECTION_OK) 72 | { 73 | PQfinish(m_conn); 74 | m_conn = NULL; 75 | return VIEWER_OPEN_FILE_FAILED; 76 | } 77 | 78 | /* Start a transaction block */ 79 | PGresult* res = PQexec(m_conn, "BEGIN"); 80 | if (PQresultStatus(res) != PGRES_COMMAND_OK) 81 | { 82 | PQclear(res); 83 | PQfinish(m_conn); 84 | m_conn = NULL; 85 | return VIEWER_OPEN_FILE_FAILED; 86 | } 87 | PQclear(res); 88 | 89 | if (m_params.sql.empty()) 90 | { 91 | sprintf(conninfo, fmt_Cursor, m_params.geomcolumn.c_str(), m_params.schema.c_str(), m_params.table.c_str()); 92 | } 93 | else if (m_params.bComplexSQL) 94 | { 95 | // query all columns 96 | std::string temp = m_params.sql; 97 | std::transform(temp.begin(), temp.end(), temp.begin(), std::tolower); 98 | std::string::size_type idxSelect = temp.find("select"); 99 | std::string::size_type idxFrom = temp.find("from"); 100 | if (idxSelect == std::string::npos || idxFrom == std::string::npos) 101 | { 102 | sprintf(conninfo, fmt_CursorComplexSQL, m_params.sql.c_str()); 103 | } 104 | else 105 | { 106 | idxSelect += strlen("select") + 1; 107 | std::string newSQL = m_params.sql; 108 | newSQL.replace(idxSelect, idxFrom-idxSelect-1, "*"); 109 | sprintf(conninfo, fmt_CursorComplexSQL, newSQL.c_str()); 110 | } 111 | } 112 | else 113 | { 114 | sprintf(conninfo, fmt_CursorSQL, m_params.geomcolumn.c_str(), m_params.schema.c_str(), 115 | m_params.table.c_str(), m_params.sql.c_str()); 116 | } 117 | res = PQexec(m_conn, conninfo); 118 | if (PQresultStatus(res) != PGRES_COMMAND_OK) 119 | { 120 | PQclear(res); 121 | PQfinish(m_conn); 122 | m_conn = NULL; 123 | return VIEWER_OPEN_FILE_FAILED; 124 | } 125 | PQclear(res); 126 | 127 | m_bOpened = true; 128 | return VIEWER_OK; 129 | } 130 | 131 | virtual void Close() 132 | { 133 | if (m_conn != NULL) 134 | { 135 | /* close the portal ... we don't bother to check for errors ... */ 136 | PGresult* res = PQexec(m_conn, "CLOSE myportal"); 137 | PQclear(res); 138 | 139 | /* end the transaction */ 140 | res = PQexec(m_conn, "END"); 141 | PQclear(res); 142 | PQfinish(m_conn); 143 | m_conn = NULL; 144 | } 145 | m_bOpened = false; 146 | } 147 | 148 | virtual void* GetFeatureID(size_t Idx) 149 | { 150 | return NULL; 151 | } 152 | 153 | virtual bool GetAllFeaturesID(std::vector& vID) 154 | { 155 | return false; 156 | } 157 | 158 | virtual void* GetData(size_t Idx) 159 | { 160 | if (VIEWER_OK != Open(0)) 161 | { 162 | return NULL; 163 | } 164 | 165 | const char* fmt_getRecord = "FETCH ABSOLUTE %Iu in myportal"; 166 | char conninfo[64] = {0}; 167 | sprintf(conninfo, fmt_getRecord, (Idx+1)); 168 | PGresult* res = PQexec(m_conn, conninfo); 169 | if (PQresultStatus(res) != PGRES_TUPLES_OK) 170 | { 171 | PQclear(res); 172 | return NULL; 173 | } 174 | 175 | int nFields = PQnfields(res); 176 | m_strData.clear(); 177 | 178 | m_strData += PQfname(res, nFields - 1); 179 | m_strData += ": "; 180 | m_strData += PQgetvalue(res, 0, nFields - 1); 181 | m_strData += "\r\n"; 182 | for (int i = 0; i < nFields - 1; ++i) 183 | { 184 | std::string strFieldName = PQfname(res, i); 185 | if (strFieldName == m_params.geomcolumn) 186 | continue; 187 | m_strData.append(strFieldName); 188 | m_strData.append(": "); 189 | char *pValue = PQgetvalue(res, 0, i); 190 | if (pValue == NULL) 191 | m_strData.append("NULL"); 192 | else 193 | m_strData.append(pValue); 194 | m_strData.append("\r\n"); 195 | } 196 | PQclear(res); 197 | return (void*)m_strData.c_str(); 198 | } 199 | 200 | private: 201 | std::string m_strData; 202 | std::string m_strID; 203 | PGconn* m_conn; 204 | int m_nCurIdx; 205 | ConnectDBParams m_params; 206 | }; 207 | 208 | #endif -------------------------------------------------------------------------------- /TXDViewer2/DataParser/ShapefileReader.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHAPE_FILE_READER_H_ 2 | #define _SHAPE_FILE_READER_H_ 3 | 4 | #include "Feature.h" 5 | #include "ErrorCode.h" 6 | #include "IDataReader.h" 7 | #include "shapefil.h" 8 | 9 | class ShapefileReader : public IDataReader 10 | { 11 | public: 12 | ShapefileReader() : m_hShp(NULL), m_hDbf(NULL), m_curShpObj(NULL), m_nCurIdx(-1), m_nRecordNum(0) 13 | {} 14 | 15 | ShapefileReader(CString strFileName, int nRecords) : m_hShp(NULL), m_hDbf(NULL), m_curShpObj(NULL), m_nCurIdx(-1), m_nRecordNum(nRecords) 16 | { 17 | m_bOpened = false; 18 | m_strFileName = strFileName; 19 | } 20 | 21 | ~ShapefileReader() 22 | { 23 | SHPClose(m_hShp); 24 | DBFClose(m_hDbf); 25 | if (m_curShpObj) 26 | SHPDestroyObject(m_curShpObj); 27 | } 28 | 29 | int Open(LPCTSTR lpstrFileName, UINT mode) 30 | { 31 | m_strFileName = lpstrFileName; 32 | LPCTSTR lpData = lpstrFileName; 33 | DWORD dwNum = WideCharToMultiByte(CP_ACP, 0, lpData, -1, NULL, 0, NULL, NULL); 34 | LPSTR pData = new CHAR[dwNum+4]; 35 | if (!pData) 36 | { 37 | delete []pData; 38 | } 39 | WideCharToMultiByte(CP_ACP, 0, lpData, -1, pData, dwNum, NULL, NULL); 40 | m_hShp = SHPOpen(pData, "rb"); 41 | if (!m_hShp) 42 | return VIEWER_OPEN_FILE_FAILED; 43 | double min[4]; 44 | double max[4]; 45 | SHPGetInfo(m_hShp, &m_nRecordNum, &m_nType, min, max); 46 | m_curShpObj = SHPReadObject(m_hShp, 0); 47 | delete []pData; 48 | m_bOpened = true; 49 | return VIEWER_OK; 50 | } 51 | 52 | virtual int Open(UINT mode) 53 | { 54 | if (m_bOpened) 55 | return VIEWER_OK; 56 | 57 | LPCTSTR lpData = (LPCTSTR)m_strFileName.GetBuffer(m_strFileName.GetLength()); 58 | DWORD dwNum = WideCharToMultiByte(CP_ACP, 0, lpData, -1, NULL, 0, NULL, NULL); 59 | LPSTR pData = new CHAR[dwNum+4]; 60 | if (!pData) 61 | { 62 | delete []pData; 63 | } 64 | WideCharToMultiByte(CP_ACP, 0, lpData, -1, pData, dwNum, NULL, NULL); 65 | strcpy(pData + dwNum-3, "dbf\0"); 66 | m_hDbf = DBFOpen(pData, "rb"); 67 | if (!m_hDbf) 68 | return VIEWER_OPEN_FILE_FAILED; 69 | delete []pData; 70 | m_bOpened = true; 71 | m_nRecordNum = DBFGetRecordCount(m_hDbf); 72 | 73 | return VIEWER_OK; 74 | } 75 | 76 | virtual void Close() 77 | { 78 | SHPClose(m_hShp); 79 | DBFClose(m_hDbf); 80 | if (m_curShpObj) 81 | SHPDestroyObject(m_curShpObj); 82 | m_hDbf = NULL; 83 | m_hShp = NULL; 84 | m_curShpObj = NULL; 85 | m_bOpened = false; 86 | 87 | } 88 | 89 | void GetFeatureExtentForPolygon(CompactEXTENT& cExtent) 90 | { 91 | cExtent.xmax = (short)(m_curShpObj->dfXMax > 0 ? m_curShpObj->dfXMax + 1 : m_curShpObj->dfXMax); 92 | cExtent.xmin = (short)(m_curShpObj->dfXMin > 0 ? m_curShpObj->dfXMin : m_curShpObj->dfXMin - 1); 93 | cExtent.ymax = (short)(m_curShpObj->dfYMax > 0 ? m_curShpObj->dfYMax + 1 : m_curShpObj->dfYMax); 94 | cExtent.ymin = (short)(m_curShpObj->dfYMin > 0 ? m_curShpObj->dfYMin : m_curShpObj->dfYMin - 1); 95 | } 96 | 97 | void GetFeatureExtent(CompactEXTENT& cExtent) 98 | { 99 | cExtent.xmax = (short)(m_curShpObj->dfXMax > 0 ? m_curShpObj->dfXMax * 10 + 1 : m_curShpObj->dfXMax * 10); 100 | cExtent.xmin = (short)(m_curShpObj->dfXMin > 0 ? m_curShpObj->dfXMin * 10 : m_curShpObj->dfXMin * 10 - 1); 101 | cExtent.ymax = (short)(m_curShpObj->dfYMax > 0 ? m_curShpObj->dfYMax * 10 + 1 : m_curShpObj->dfYMax * 10); 102 | cExtent.ymin = (short)(m_curShpObj->dfYMin > 0 ? m_curShpObj->dfYMin * 10 : m_curShpObj->dfYMin * 10 - 1); 103 | } 104 | 105 | void At(int nIdx) 106 | { 107 | SHPDestroyObject(m_curShpObj); 108 | m_curShpObj = SHPReadObject(m_hShp, nIdx); 109 | } 110 | 111 | void GetFeatureSetExtent(EXTENT& extent) 112 | { 113 | double min[4]; 114 | double max[4]; 115 | SHPGetInfo(m_hShp, &m_nRecordNum, &m_nType, min, max); 116 | extent.xmax = (int) (max[0] * 100000); 117 | extent.ymax = (int) (max[1] * 100000); 118 | extent.xmin = (int) (min[0] * 100000); 119 | extent.ymin = (int) (min[1] * 100000); 120 | } 121 | 122 | size_t GetAllPointsNum() 123 | { 124 | HANDLE hFile = CreateFile( 125 | m_strFileName, // name of the read 126 | GENERIC_READ, // open for reading 127 | FILE_SHARE_READ, // share read 128 | NULL, // default security 129 | OPEN_EXISTING, // open exist file only 130 | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, // normal file 131 | NULL); // no attr. template 132 | 133 | if (hFile == INVALID_HANDLE_VALUE) 134 | { 135 | return 0; 136 | } 137 | 138 | size_t nFileSize = GetFileSize(hFile, NULL); 139 | size_t nPointSize = nFileSize - m_nRecordNum * 8; 140 | 141 | if ( m_nType == SHPT_POLYGON 142 | || m_nType == SHPT_POLYGONM 143 | || m_nType == SHPT_POLYGONZ 144 | ||m_nType == SHPT_ARC 145 | || m_nType == SHPT_ARCM 146 | || m_nType == SHPT_ARCZ) 147 | { 148 | nPointSize -= m_nRecordNum * 48; 149 | } 150 | else if (m_nType == SHPT_POINT 151 | || m_nType == SHPT_POINTM 152 | || m_nType == SHPT_POINTZ) 153 | { 154 | nPointSize -= m_nRecordNum * 4; 155 | } 156 | CloseHandle(hFile); 157 | return nPointSize / 2; 158 | } 159 | 160 | SHPObject* GetShpObject() 161 | { 162 | return m_curShpObj; 163 | } 164 | 165 | int GetRecordsNumber() 166 | { 167 | return m_nRecordNum; 168 | } 169 | 170 | virtual void* GetFeatureID(size_t Idx) 171 | { 172 | if (VIEWER_OK != Open(0)) 173 | m_strID = "Can't Open/Find *.dbf"; 174 | else 175 | m_strID = DBFReadStringAttribute(m_hDbf, Idx, 0); 176 | return (void*)m_strID.c_str(); 177 | } 178 | 179 | virtual bool GetAllFeaturesID(std::vector& vID) 180 | { 181 | if (VIEWER_OK != Open(0)) 182 | { 183 | return false; 184 | } 185 | char x = DBFGetNativeFieldType(m_hDbf, 0); 186 | if (DBFGetNativeFieldType(m_hDbf, 0) != 'F') 187 | { 188 | return false; 189 | } 190 | for(int i = 0; i < m_nRecordNum; ++i) 191 | { 192 | vID.push_back(DBFReadDoubleAttribute(m_hDbf, i, 0)); 193 | } 194 | return true; 195 | } 196 | 197 | GEO_TYPE GetGeoType() 198 | { 199 | if ( m_nType == SHPT_POLYGON 200 | || m_nType == SHPT_POLYGONM 201 | || m_nType == SHPT_POLYGONZ ) 202 | { 203 | return POLYGON_TYPE; 204 | } 205 | else if (m_nType == SHPT_ARC 206 | || m_nType == SHPT_ARCM 207 | || m_nType == SHPT_ARCZ) 208 | { 209 | return POLYLINE_TYPE; 210 | } 211 | else if (m_nType == SHPT_POINT 212 | || m_nType == SHPT_POINTM 213 | || m_nType == SHPT_POINTZ) 214 | { 215 | return POINT_TYPE; 216 | } 217 | return GEO_UNKNOWN_TYPE; 218 | } 219 | 220 | virtual void* GetData(size_t Idx) 221 | { 222 | if (VIEWER_OK != Open(0)) 223 | { 224 | return NULL; 225 | } 226 | 227 | m_strID = DBFReadStringAttribute(m_hDbf, Idx, 0); 228 | 229 | char pszFieldName[12]; //the longest possible field name of 11 characters plus a terminating zero character. 230 | int nFields = DBFGetFieldCount(m_hDbf); 231 | m_strData.clear(); 232 | 233 | for (int i = 0; i < nFields; ++i) 234 | { 235 | DBFGetFieldInfo(m_hDbf, i, pszFieldName, NULL, NULL); 236 | m_strData.append(pszFieldName); 237 | m_strData.append(": "); 238 | if (DBFIsAttributeNULL(m_hDbf, Idx, i)) 239 | m_strData.append("NULL"); 240 | else 241 | m_strData.append(DBFReadStringAttribute(m_hDbf, Idx, i)); 242 | m_strData.append("\r\n"); 243 | } 244 | return (void*)m_strData.c_str(); 245 | } 246 | 247 | private: 248 | std::string m_strData; 249 | std::string m_strID; 250 | SHPHandle m_hShp; 251 | DBFHandle m_hDbf; 252 | SHPObject* m_curShpObj; 253 | int m_nCurIdx; 254 | int m_nRecordNum; 255 | int m_nType; 256 | }; 257 | 258 | #endif -------------------------------------------------------------------------------- /TXDViewer2/DataParser/TXDTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPECODE 2 | #error "You must define TYPECODE macro before include this file" 3 | #endif 4 | 5 | TYPECODE(TXD_TYPE_MT, _T("MT")) 6 | TYPECODE(TXD_TYPE_RF, _T("RF")) 7 | TYPECODE(TXD_TYPE_PF, _T("PF")) 8 | TYPECODE(TXD_TYPE_AP, _T("AP")) 9 | //TXD_TYPE_AD, 10 | TYPECODE(TXD_TYPE_AF, _T("AF")) 11 | TYPECODE(TXD_TYPE_LF, _T("LF")) 12 | TYPECODE(TXD_TYPE_LC, _T("LC")) 13 | TYPECODE(TXD_TYPE_LM, _T("LM")) 14 | TYPECODE(TXD_TYPE_CT, _T("CT")) 15 | //TXD_TYPE_CV, 16 | //TXD_TYPE_CN, 17 | TYPECODE(TXD_TYPE_SR, _T("SR")) 18 | TYPECODE(TXD_TYPE_SP, _T("SP")) 19 | TYPECODE(TXD_TYPE_GS, _T("GS")) 20 | TYPECODE(TXD_TYPE_GT, _T("GT")) 21 | TYPECODE(TXD_TYPE_TB, _T("TB")) 22 | TYPECODE(TXD_TYPE_TS, _T("TS")) 23 | TYPECODE(TXD_TYPE_TG, _T("TG")) 24 | TYPECODE(TXD_TYPE_DJ, _T("DJ")) 25 | TYPECODE(TXD_TYPE_BF, _T("BF")) 26 | TYPECODE(TXD_TYPE_JV, _T("JV")) 27 | TYPECODE(TXD_TYPE_VC, _T("VC")) 28 | TYPECODE(TXD_TYPE_VS, _T("VS")) 29 | TYPECODE(TXD_TYPE_END, _T("END")) 30 | TYPECODE(TXD_TYPE_NONE, _T("NONE")) -------------------------------------------------------------------------------- /TXDViewer2/DropFileHandler.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // WM_DROPFILES handler for Microsoft's Windows Template Library. 4 | // 5 | // Author: Pablo Aliskevicius. 6 | // 7 | // The code and information is provided by the author and copyright holder 'as-is', 8 | // and any express or implied warranties, including, but not limited to, the implied 9 | // warranties of merchantability and fitness for a particular purpose are disclaimed. 10 | // In no event shall the author or copyright holders be liable for any direct, indirect, 11 | // incidental, special, exemplary, or consequential damages (including, but not limited 12 | // to, procurement of substitute goods or services; loss of use, data, or profits; or 13 | // business interruption) however caused and on any theory of liability, whether in 14 | // contract, strict liability, or tort (including negligence or otherwise) arising in 15 | // any way out of the use of this software, even if advised of the possibility of such 16 | // damage. 17 | // 18 | ///////////////////////////////////////////////////////////////////////////////////////// 19 | 20 | /* 21 | 22 | Usage: 23 | ====== 24 | 25 | 1. In a dialog: 26 | ------------ 27 | 28 | class CMyDlg : public CDialogImpl, 29 | public CDropFilesHandler // Inherit from the template, as usual... 30 | { 31 | public: 32 | enum { IDD = IDD_MYDIALOG }; // Make sure this one has EXSTYLE WS_EX_ACCEPTFILES defined. 33 | 34 | BEGIN_MSG_MAP(CMyDlg) 35 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) // and others... 36 | ... 37 | CHAIN_MSG_MAP(CDropFilesHandler) 38 | END_MSG_MAP() 39 | 40 | // You can use this function to initialize variables needed for one drop's batch. 41 | // Returning FALSE will avoid handling the drop, with no messages to the user whatsoever. 42 | BOOL IsReadyForDrop(void) 43 | { 44 | // If you're editing some document and the dirty bit is on, ask the user what to do... 45 | // else 46 | return TRUE; 47 | } 48 | BOOL HandleDroppedFile(LPCTSTR szBuff) 49 | { 50 | // Implement this. 51 | // Return TRUE unless you're done handling files (e.g., if you want 52 | // to handle only the first relevant file, and you have already found it). 53 | ATLTRACE("%s\n", szBuff); 54 | DoSomethingWith(szBuff); 55 | return TRUE; 56 | } 57 | void EndDropFiles(void) 58 | { 59 | // Sometimes, if your file handling is not trivial, you might want to add all 60 | // file names to some container (std::list, perhaps), and do the 61 | // handling afterwards, in a worker thread. If so, this function is your choice. 62 | 63 | } 64 | }; // CMyDlg 65 | 66 | 2. In a view: 67 | ---------- 68 | 69 | You can also use this class in a view (SDI, MDI, M-SDI apps), in which case you should create 70 | your window with WS_EX_ACCEPTFILES, or call RegisterDropHandler after creating the view: 71 | 72 | e.g.: 73 | CMainFrame::OnCreate(...) 74 | { 75 | 76 | m_view.Create(...); 77 | m_view.RegisterDropHandler(TRUE); 78 | 79 | } 80 | 81 | Alterations to inheritance list, message map, and the three additional functions are identical 82 | to those done when handling dialogs. 83 | 84 | */ 85 | 86 | #ifndef __DROPFILEHANDLER_H__ 87 | #define __DROPFILEHANDLER_H__ 88 | 89 | 90 | template class CDropFilesHandler 91 | { 92 | public: 93 | // For frame windows: 94 | // You might turn drop handling on or off, depending, for instance, on user's choice. 95 | void RegisterDropHandler(BOOL bTurnOn = TRUE) 96 | { 97 | T* pT = static_cast(this); 98 | ATLASSERT(::IsWindow(pT->m_hWnd)); 99 | /* I'm ashamed; I rewrote an existing API. Luckily, I don't have to cut my small finger off... 100 | CWindow wnd; 101 | wnd.Attach(pT->m_hWnd); 102 | if (bTurnOn) 103 | wnd.ModifyStyleEx(0, WS_EX_ACCEPTFILES); 104 | else // Turn drop handling off. 105 | wnd.ModifyStyleEx(~WS_EX_ACCEPTFILES, 0); 106 | */ 107 | ::DragAcceptFiles(pT->m_hWnd, bTurnOn); 108 | } 109 | protected: 110 | UINT m_nFiles; // Number of dropped files, in case you want to display some kind of progress. 111 | // We'll use a message map here, so future implementations can, if necessary, handle 112 | // more than one message. 113 | BEGIN_MSG_MAP(CDropFilesHandler) 114 | MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles) 115 | END_MSG_MAP() 116 | // WM_DROPFILES handler: it calls a T function, with the path to one dropped file each time. 117 | LRESULT OnDropFiles(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) 118 | { 119 | ATLTRACE("*** Got WM_DROPFILE! *******\n"); 120 | T* pT = static_cast(this); 121 | // Your class should implement a boolean function. It should return TRUE only 122 | // if initialization (whatever is tried) was successful. 123 | if (!pT->IsReadyForDrop()) 124 | { 125 | bHandled = FALSE; 126 | return 0; 127 | } 128 | CHDrop cd(wParam); 129 | // Your class should have a public member of type HWND (like CWindow does). 130 | if (cd.IsInClientRect(pT->m_hWnd)) 131 | { 132 | m_nFiles = cd.GetNumFiles(); 133 | if (0 < m_nFiles) 134 | { 135 | for (UINT i = 0; i < m_nFiles; i++) 136 | { 137 | if (0 < cd.DragQueryFile(i)) 138 | { 139 | ATLTRACE(_T(" Dropped one! %s\n"), (LPCTSTR) cd); 140 | // Your class should return TRUE unless no more files are wanted. 141 | if (!pT->HandleDroppedFile((LPCTSTR) cd)) 142 | i = m_nFiles + 10; // Break the loop 143 | } 144 | } // for 145 | pT->EndDropFiles(); 146 | } 147 | } 148 | else 149 | bHandled = FALSE; 150 | m_nFiles = 0; 151 | return 0; 152 | } 153 | private: 154 | // Helper class for CDropFilesHandler, or any other handler for WM_DROPFILES. 155 | // This one is a template to avoid compiling when not used. 156 | // It is a wrapper for a HDROP. 157 | template class CHDrop 158 | { 159 | HDROP m_hd; 160 | bool bHandled; // Checks if resources should be released. 161 | CHAR m_buff[MAX_PATH + 5]; // DragQueryFile() wants LPTSTR. 162 | public: 163 | // Constructor, destructor 164 | CHDrop(WPARAM wParam) 165 | { 166 | m_hd = (HDROP) wParam; 167 | bHandled = false; 168 | m_buff[0] = '\0'; 169 | } 170 | ~CHDrop() 171 | { 172 | if (bHandled) 173 | ::DragFinish(m_hd); 174 | } 175 | // Helper function, detects if the message is meant for 'this' window. 176 | BOOL IsInClientRect(HWND hw) 177 | { 178 | ATLASSERT(::IsWindow(hw)); 179 | POINT p; 180 | ::DragQueryPoint(m_hd, &p); 181 | RECT rc; 182 | ::GetClientRect(hw, &rc); 183 | return ::PtInRect(&rc, p); 184 | } 185 | // This function returns the number of files dropped on the window by the current operation. 186 | UINT GetNumFiles(void) 187 | { 188 | return ::DragQueryFile(m_hd, 0xffffFFFF, NULL, 0); 189 | } 190 | // This function gets the whole file path for a file, given its ordinal number. 191 | UINT DragQueryFile(UINT iFile) 192 | { 193 | bHandled = true; 194 | return ::DragQueryFile(m_hd, iFile, m_buff, MAX_PATH); 195 | } 196 | #ifdef _WTL_USE_CSTRING 197 | // CString overload for DragQueryFile (not used here, might be used by a handler 198 | // which is implemented outside CDropFilesHandler. 199 | UINT DragQueryFile(UINT iFile, CString &cs) 200 | { 201 | bHandled = true; 202 | UINT ret = ::DragQueryFile(m_hd, iFile, m_buff, MAX_PATH); 203 | cs = m_buff; 204 | return ret; 205 | } 206 | inline operator CString() const { return CString(m_buff); } 207 | #endif 208 | // Other string overloads (such as std::string) might come handy... 209 | 210 | // This class can 'be' the currently held file's path. 211 | inline operator const CHAR *() const { return m_buff; } 212 | }; // class CHDrop 213 | }; 214 | 215 | 216 | 217 | 218 | #endif //__DROPFILEHANDLER_H__ -------------------------------------------------------------------------------- /TXDViewer2/ErrorCode.h: -------------------------------------------------------------------------------- 1 | #ifndef _TXD_VIEWER_ERROR_CODE 2 | #define _TXD_VIEWER_ERROR_CODE 3 | 4 | enum VIEWER_ERR_CODE 5 | { 6 | VIEWER_OK = 1, 7 | VIEWER_EOF, 8 | VIEWER_OPEN_FILE_FAILED, 9 | VIEWER_READ_FILE_FAILED, 10 | VIEWER_SET_FILE_POINTER_FAILED 11 | }; 12 | 13 | #endif -------------------------------------------------------------------------------- /TXDViewer2/FileManagerDlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CFileManagerDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CFileManagerDlg : public CDialogImpl, public CUpdateUI, 8 | public CMessageFilter, public CIdleHandler, public CDialogResize 9 | { 10 | public: 11 | enum { IDD = IDD_FILE_MANAGER }; 12 | HWND m_hwndFrame; 13 | 14 | CListBox m_fileBox; 15 | 16 | virtual BOOL PreTranslateMessage(MSG* pMsg) 17 | { 18 | return CWindow::IsDialogMessage(pMsg); 19 | } 20 | 21 | virtual BOOL OnIdle() 22 | { 23 | return FALSE; 24 | } 25 | 26 | BEGIN_UPDATE_UI_MAP(CFileManagerDlg) 27 | END_UPDATE_UI_MAP() 28 | 29 | BEGIN_MSG_MAP(CFileManagerDlg) 30 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 31 | MSG_WM_SHOWWINDOW(OnShowWindow) 32 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 33 | COMMAND_ID_HANDLER(IDOK, OnOK) 34 | COMMAND_ID_HANDLER(IDC_DEL_ALL, OnDeleteAll) 35 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) 36 | CHAIN_MSG_MAP(CDialogResize) 37 | END_MSG_MAP() 38 | 39 | // This map defines how the controls within the window are resized. 40 | // You can also use DLGRESIZE_GROUP() to group controls together. 41 | BEGIN_DLGRESIZE_MAP(CFileManagerDlg) 42 | DLGRESIZE_CONTROL(IDC_LIST_FILE, DLSZ_SIZE_X|DLSZ_SIZE_Y) 43 | DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X) 44 | DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y) 45 | END_DLGRESIZE_MAP() 46 | 47 | // Handler prototypes (uncomment arguments if needed): 48 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 49 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 50 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 51 | 52 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 53 | { 54 | DlgResize_Init(true); 55 | 56 | // center the dialog on the screen 57 | CenterWindow(); 58 | //MoveWindow(0, 0, 168, 200, True); 59 | // set icons 60 | HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); 61 | SetIcon(hIcon, TRUE); 62 | HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); 63 | SetIcon(hIconSmall, FALSE); 64 | 65 | // register object for message filtering and idle updates 66 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 67 | ATLASSERT(pLoop != NULL); 68 | pLoop->AddMessageFilter(this); 69 | pLoop->AddIdleHandler(this); 70 | 71 | UIAddChildWindowContainer(m_hWnd); 72 | m_fileBox.Attach(GetDlgItem(IDC_LIST_FILE)); 73 | 74 | return TRUE; 75 | } 76 | 77 | void OnShowWindow(BOOL bShow, UINT nStatus) 78 | { 79 | if (bShow == 0) 80 | { 81 | m_fileBox.ResetContent(); 82 | } 83 | else 84 | { 85 | for (UINT i = 0; i < g_MapManager.m_vFilename.size(); ++i) 86 | { 87 | m_fileBox.AddString(g_MapManager.m_vFilename[i]); 88 | } 89 | } 90 | } 91 | 92 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 93 | { 94 | // unregister message filtering and idle updates 95 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 96 | ATLASSERT(pLoop != NULL); 97 | pLoop->RemoveMessageFilter(this); 98 | pLoop->RemoveIdleHandler(this); 99 | return 0; 100 | } 101 | 102 | LRESULT OnDeleteAll(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 103 | { 104 | std::vector& vLayers = g_MapManager.GetAllLayers(); 105 | for (UINT i = 0; i < vLayers.size(); ++i) 106 | { 107 | delete vLayers[i]; 108 | } 109 | vLayers.clear(); 110 | g_MapManager.m_vFilename.clear(); 111 | for (UINT i = 0; i < g_MapManager.m_vDataReader.size(); ++i) 112 | { 113 | delete g_MapManager.m_vDataReader[i]; 114 | } 115 | g_MapManager.m_vDataReader.clear(); 116 | g_MapManager.reset(); 117 | m_fileBox.ResetContent(); 118 | SendMessage(m_hwndFrame, WM_APP + 102, 1, 0L); 119 | CloseDialog(wID); 120 | return 0; 121 | } 122 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 123 | { 124 | int idx = m_fileBox.GetCurSel(); 125 | m_fileBox.DeleteString(idx); 126 | std::vector& vReader = g_MapManager.m_vDataReader; 127 | IDataReader* pReader = vReader[idx]; 128 | std::vector& vLayers = g_MapManager.GetAllLayers(); 129 | std::vector::iterator it = vLayers.begin(); 130 | while (it != vLayers.end()) 131 | { 132 | if (pReader == (*it)->GetFeatureSet()->m_pDataReader) 133 | { 134 | delete *it; 135 | it = vLayers.erase(it); 136 | } 137 | else 138 | { 139 | ++it; 140 | } 141 | } 142 | 143 | vReader.erase(vReader.begin() + idx); 144 | g_MapManager.m_vFilename.erase(g_MapManager.m_vFilename.begin() + idx); 145 | g_MapManager.CaculateExtent(); 146 | if (vLayers.empty()) 147 | { 148 | g_MapManager.reset(); 149 | } 150 | //m_fileBox.GetText(idx, strText); 151 | //std::remove(g_MapManager.m_vFilename.begin(), g_MapManager.m_vFilename.end(), strText); 152 | SendMessage(m_hwndFrame, WM_APP + 102, 1, 0L); 153 | 154 | return 0; 155 | } 156 | 157 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 158 | { 159 | CloseDialog(wID); 160 | return 0; 161 | } 162 | void CloseDialog(int nVal) 163 | { 164 | ShowWindow(SW_HIDE); 165 | } 166 | LRESULT OnEnChangeEdit1(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 167 | }; 168 | -------------------------------------------------------------------------------- /TXDViewer2/FindDlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CFindDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CFindDlg : public CDialogImpl, public CUpdateUI, 8 | public CMessageFilter, public CIdleHandler 9 | { 10 | public: 11 | HWND m_wndView; 12 | 13 | enum { IDD = IDD_FIND }; 14 | 15 | virtual BOOL PreTranslateMessage(MSG* pMsg) 16 | { 17 | return CWindow::IsDialogMessage(pMsg); 18 | } 19 | 20 | virtual BOOL OnIdle() 21 | { 22 | return FALSE; 23 | } 24 | 25 | BEGIN_UPDATE_UI_MAP(CFindDlg) 26 | END_UPDATE_UI_MAP() 27 | 28 | BEGIN_MSG_MAP(CFindDlg) 29 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 30 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 31 | COMMAND_ID_HANDLER(IDOK, OnOK) 32 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) 33 | COMMAND_ID_HANDLER(IDC_FIND, OnStartFind) 34 | COMMAND_ID_HANDLER(IDC_BUTTON1, OnSwapCoords) 35 | END_MSG_MAP() 36 | 37 | // Handler prototypes (uncomment arguments if needed): 38 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 39 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 40 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 41 | 42 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 43 | { 44 | // center the dialog on the screen 45 | CenterWindow(); 46 | // set icons 47 | HICON hIcon = AtlLoadIconImage(IDI_FIND, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); 48 | SetIcon(hIcon, TRUE); 49 | HICON hIconSmall = AtlLoadIconImage(IDI_FIND, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); 50 | SetIcon(hIconSmall, FALSE); 51 | 52 | // register object for message filtering and idle updates 53 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 54 | ATLASSERT(pLoop != NULL); 55 | pLoop->AddMessageFilter(this); 56 | pLoop->AddIdleHandler(this); 57 | UIAddChildWindowContainer(m_hWnd); 58 | return TRUE; 59 | } 60 | 61 | LRESULT OnStartFind(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 62 | { 63 | MessageBox(_T("Sorry, To be done"), _T("Unfinished"), MB_OK|MB_ICONINFORMATION); 64 | return 0; 65 | } 66 | LRESULT OnSwapCoords(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 67 | { 68 | return 0; 69 | } 70 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 71 | { 72 | // unregister message filtering and idle updates 73 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 74 | ATLASSERT(pLoop != NULL); 75 | pLoop->RemoveMessageFilter(this); 76 | pLoop->RemoveIdleHandler(this); 77 | return 0; 78 | } 79 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 80 | { 81 | // TODO: Add validation code 82 | CloseDialog(wID); 83 | return 0; 84 | } 85 | 86 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 87 | { 88 | CloseDialog(wID); 89 | return 0; 90 | } 91 | void CloseDialog(int nVal) 92 | { 93 | g_MapManager.m_bLocate = false; 94 | ShowWindow(SW_HIDE); 95 | } 96 | }; 97 | -------------------------------------------------------------------------------- /TXDViewer2/GeoData/Feature.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // We use a lightweight feature structure, only contain offset of the data. 4 | // All actual geodata (points) store in a continuous memory. 5 | // 6 | // ******************************************************************************************************** 7 | 8 | #ifndef _FEATURE_H 9 | #define _FEATURE_H 10 | 11 | enum GEO_TYPE 12 | { 13 | POINT_TYPE, 14 | POLYLINE_TYPE, 15 | POLYGON_TYPE, 16 | GEO_UNKNOWN_TYPE 17 | }; 18 | 19 | typedef struct tagCompactEXTENT 20 | { 21 | short xmax; 22 | short xmin; 23 | short ymax; 24 | short ymin; 25 | } CompactEXTENT, *PCompactEXTENT; 26 | 27 | class EXTENT 28 | { 29 | public: 30 | EXTENT() : xmax(-18000000), xmin(18000000), ymax(-9000000), ymin(9000000) 31 | { 32 | } 33 | 34 | EXTENT(int xMax, int xMin, int yMax, int yMin) : 35 | xmax(xMax), xmin(xMin), ymax(yMax), ymin(yMin) 36 | { 37 | } 38 | 39 | EXTENT(CompactEXTENT cExtent, int nScale) 40 | { 41 | xmax = cExtent.xmax * nScale; 42 | xmin = cExtent.xmin * nScale; 43 | ymax = cExtent.ymax * nScale; 44 | ymin = cExtent.ymin * nScale; 45 | } 46 | 47 | void Reset() 48 | { 49 | xmax = -18000000; 50 | xmin = 18000000; 51 | ymax = -9000000; 52 | ymin = 9000000; 53 | } 54 | bool operator== (const EXTENT other) const 55 | { 56 | return other.xmax == xmax && other.xmin == xmin && other.ymax == ymax && other.ymin == ymin; 57 | } 58 | 59 | EXTENT operator* (double scale) 60 | { 61 | int halfWidth = (Width() / 2) == 0 ? 1 : Width() / 2; 62 | int halfHeight = (Height() / 2) == 0 ? 1 : Height() / 2; 63 | int centerX = xmin + halfWidth; 64 | int centerY = ymin + halfHeight; 65 | return EXTENT(centerX + halfWidth*scale, centerX - halfWidth*scale, 66 | centerY+halfHeight*scale, centerY-halfHeight*scale); 67 | } 68 | 69 | void Reduce(int nOffset) 70 | { 71 | xmax -= nOffset; 72 | xmin += nOffset; 73 | ymax -= nOffset; 74 | ymin += nOffset; 75 | } 76 | 77 | bool Include(CPoint point) const 78 | { 79 | return point.x >= xmin && point.x <= xmax && point.y >= ymin && point.y <= ymax; 80 | } 81 | 82 | bool Intersect(const EXTENT& extent) const 83 | { 84 | return !( extent.xmin > xmax || extent.xmax < xmin || extent.ymax < ymin || extent.ymin > ymax); 85 | } 86 | 87 | int Width() 88 | { 89 | return xmax - xmin; 90 | } 91 | 92 | int Height() 93 | { 94 | return ymax - ymin; 95 | } 96 | 97 | public: 98 | int xmax; 99 | int xmin; 100 | int ymax; 101 | int ymin; 102 | }; 103 | 104 | struct Feature 105 | { 106 | unsigned int nCoordOffset; 107 | size_t nAttributeOffset; 108 | }; 109 | 110 | inline double DistancePtToPt(int aX, int aY, int bX, int bY) 111 | { 112 | int dx, dy; 113 | dx = aX - bX; 114 | dy = aY - bY; 115 | return sqrt((double)(dx*dx + dy*dy)); 116 | } 117 | 118 | #endif -------------------------------------------------------------------------------- /TXDViewer2/GeoData/FeatureSet.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // A collection of features. 4 | // Core class for manipulate feature 5 | // 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #ifndef _FEATURE_SET_H 10 | #define _FEATURE_SET_H 11 | 12 | #include 13 | #include "Feature.h" 14 | #include "IDataReader.h" 15 | 16 | typedef std::map > mapExtent; 17 | typedef std::map mapID; 18 | 19 | class FeatureSet 20 | { 21 | public: 22 | FeatureSet() : m_nAllCoordsNum(0), m_curFeatureIdx(0), m_nStartPos(0) 23 | {} 24 | 25 | FeatureSet(CString strName, GEO_TYPE eType) : 26 | m_nAllCoordsNum(0), m_curFeatureIdx(0), m_nStartPos(0), 27 | m_strName(strName), m_eFeatureType(eType) 28 | { 29 | } 30 | 31 | virtual ~FeatureSet() 32 | { 33 | for (int i = 0; i < m_vAttrSelected.size(); ++i) 34 | { 35 | delete[] m_vAttrSelected[i]; 36 | } 37 | } 38 | 39 | public: 40 | /* 41 | * Highlight one feature of all selected feature. 42 | */ 43 | virtual bool GetFeaturesPoints(std::vector& vFeatureIdx, 44 | std::vector& vPoints, 45 | std::vector& vPtNum, 46 | bool& bDrawPoint); 47 | /* 48 | * All selected feature's points 49 | */ 50 | virtual bool GetSelectedPoints(std::vector& vPoints, std::vector& vPtNum, bool& bDrawPoint); 51 | 52 | /* 53 | * Iterate All Feature's points. 54 | */ 55 | virtual bool NextFeaturesPoints(size_t nFeatureNum, // the number of features 56 | std::vector& vPoints, 57 | std::vector& vPtNum); 58 | 59 | virtual size_t GetFeatureSize() 60 | { 61 | // Remove the same id, because we split multipolygon to polygon 62 | size_t nSize = 0; 63 | for (std::vector::iterator it = m_vID.begin(); it != m_vID.end(); ++it) 64 | { 65 | if ((it+1) != m_vID.end() && *it == *(it+1)) 66 | { 67 | continue; 68 | } 69 | ++nSize; 70 | } 71 | return nSize; 72 | } 73 | 74 | virtual void* GetData(size_t Idx) = 0; 75 | virtual void* GetRawData(size_t Idx) = 0; 76 | virtual void* GetFeatureID(size_t Idx) = 0; 77 | virtual bool SearchID(UINT64 nID); 78 | 79 | virtual bool SelectFeatures(EXTENT& extent, int xScreen, int yScreen, bool bHit, bool bCtrl); 80 | virtual void CollectFeaturesInView(); 81 | EXTENT GetFeatureExtent(size_t idx); 82 | 83 | virtual EXTENT GetExtent() 84 | { 85 | return m_sExtent; 86 | } 87 | 88 | virtual void SetExtent(const EXTENT& extent) 89 | { 90 | m_sExtent = extent; 91 | } 92 | 93 | virtual void SetWorldExtent(const EXTENT& extent) 94 | { 95 | m_worldExtent = extent; 96 | } 97 | 98 | virtual void SetViewRect(const CRect& viewRect) 99 | { 100 | m_viewRect = viewRect; 101 | } 102 | 103 | virtual bool InView() 104 | { 105 | return m_worldExtent.Intersect(m_sExtent); 106 | } 107 | public: 108 | CString m_strName; 109 | GEO_TYPE m_eFeatureType; 110 | CRect m_viewRect; 111 | EXTENT m_worldExtent; 112 | EXTENT m_sExtent; 113 | EXTENT m_oriExtent; 114 | int* m_pPoints; // All points in memory 115 | std::vector m_vFeatures; 116 | std::vector m_vFeatInViews; 117 | std::vector m_vFeatSelected; 118 | mapExtent m_mapExtent; 119 | std::vector m_vID; 120 | size_t m_nAllCoordsNum; // all the numbers of coordinate. 121 | size_t m_curFeatureIdx; 122 | size_t m_nStartPos; 123 | mapExtent::iterator m_iterCurExent; 124 | IDataReader* m_pDataReader; 125 | std::vector m_vAttrSelected; 126 | size_t m_nFileSize; 127 | }; 128 | 129 | #endif -------------------------------------------------------------------------------- /TXDViewer2/GeoData/PostGISFeatureSet.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "PostGISFeatureSet.h" 3 | 4 | PostGISFeatureSet::PostGISFeatureSet() : m_bHasID(false) 5 | {} 6 | 7 | PostGISFeatureSet::~PostGISFeatureSet() 8 | {} 9 | 10 | void* PostGISFeatureSet::GetData(size_t Idx) 11 | { 12 | UINT i = m_vFeatSelected[Idx]; 13 | Feature feat = m_vFeatures[i]; 14 | return m_pDataReader->GetData(feat.nAttributeOffset); 15 | } 16 | 17 | void* PostGISFeatureSet::GetRawData(size_t Idx) 18 | { 19 | UINT i = m_vFeatSelected[Idx]; 20 | Feature feat = m_vFeatures[i]; 21 | return m_pDataReader->GetData(feat.nAttributeOffset); 22 | } 23 | void* PostGISFeatureSet::GetFeatureID(size_t Idx) 24 | { 25 | if (m_bHasID) 26 | strtk::type_to_string(m_vID[Idx], m_strID); 27 | else 28 | m_strID = "Not set id"; 29 | return (void*)m_strID.c_str(); 30 | } 31 | 32 | bool PostGISFeatureSet::SearchID(UINT64 nID) 33 | { 34 | if (m_bHasID) 35 | return FeatureSet::SearchID(nID); 36 | return true; 37 | } 38 | 39 | size_t PostGISFeatureSet::GetFeatureSize() 40 | { 41 | return m_nFeatureSize; 42 | } 43 | -------------------------------------------------------------------------------- /TXDViewer2/GeoData/PostGISFeatureSet.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSTGIS_FEATURE_SET_H 2 | #define _POSTGIS_FEATURE_SET_H 3 | 4 | #include "FeatureSet.h" 5 | 6 | class PostGISFeatureSet : public FeatureSet 7 | { 8 | public: 9 | PostGISFeatureSet(); 10 | 11 | PostGISFeatureSet(CString strName, GEO_TYPE eType) : FeatureSet(strName, eType), m_bHasID(false) 12 | {} 13 | 14 | ~PostGISFeatureSet(); 15 | 16 | public: 17 | virtual void* GetData(size_t Idx); 18 | virtual void* GetRawData(size_t Idx); 19 | virtual void* GetFeatureID(size_t Idx); 20 | virtual bool SearchID(UINT64 nID); 21 | virtual size_t GetFeatureSize(); 22 | 23 | public: 24 | bool m_bHasID; 25 | std::string m_strID; 26 | size_t m_nFeatureSize; 27 | std::vector m_vPoints; 28 | }; 29 | 30 | #endif -------------------------------------------------------------------------------- /TXDViewer2/GeoData/SHPFeatureSet.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "ShapefileReader.h" 3 | #include "SHPFeatureSet.h" 4 | 5 | SHPFeatureSet::SHPFeatureSet() 6 | {} 7 | 8 | SHPFeatureSet::~SHPFeatureSet() 9 | {} 10 | 11 | void* SHPFeatureSet::GetData(size_t Idx) 12 | { 13 | UINT i = m_vFeatSelected[Idx]; 14 | Feature feat = m_vFeatures[i]; 15 | return m_pDataReader->GetData(feat.nAttributeOffset); 16 | } 17 | 18 | void* SHPFeatureSet::GetRawData(size_t Idx) 19 | { 20 | UINT i = m_vFeatSelected[Idx]; 21 | Feature feat = m_vFeatures[i]; 22 | char* pData = (char*)m_pDataReader->GetData(feat.nAttributeOffset); 23 | pData[strlen(pData)-1] = '\0'; 24 | return pData; 25 | } 26 | 27 | void* SHPFeatureSet::GetFeatureID(size_t Idx) 28 | { 29 | Feature feat = m_vFeatures[Idx]; 30 | return m_pDataReader->GetFeatureID(feat.nAttributeOffset); 31 | } 32 | 33 | size_t SHPFeatureSet::GetFeatureSize() 34 | { 35 | return ((ShapefileReader*)m_pDataReader)->GetRecordsNumber(); 36 | } -------------------------------------------------------------------------------- /TXDViewer2/GeoData/SHPFeatureSet.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHP_FEATURE_SET_H 2 | #define _SHP_FEATURE_SET_H 3 | 4 | #include "FeatureSet.h" 5 | 6 | class SHPFeatureSet : public FeatureSet 7 | { 8 | public: 9 | SHPFeatureSet(); 10 | 11 | SHPFeatureSet(CString strName, GEO_TYPE eType) : FeatureSet(strName, eType) 12 | {} 13 | 14 | ~SHPFeatureSet(); 15 | 16 | public: 17 | virtual void* GetData(size_t Idx); 18 | virtual void* GetRawData(size_t Idx); 19 | virtual void* GetFeatureID(size_t Idx); 20 | virtual size_t GetFeatureSize(); 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /TXDViewer2/GeoData/TXDFeatureSet.cpp: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // A collection of features. 4 | // 5 | // Created 2013/1/13 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #include "stdafx.h" 10 | #include "TXDFeatureSet.h" 11 | 12 | const char* TXDFeatureSet::RF_FIELD[RF_FIELD_SIZE] = { 13 | ("TYPE : "), ("ID : "), ("PTs : ..."), ("FC : "), ("DF : "), 14 | ("RT : "), ("RST : "), ("SP : "), ("LC : "), ("ON : "), 15 | ("HN : "), ("AA : "), ("BD : "), ("ATTR : "), ("SV : "), 16 | ("CS : "), ("MS : "), ("TI : "), ("BP : "), ("TZ : "), 17 | ("LN : "), ("22 : "), ("23 : "), ("24 : "), ("25 : "), 18 | ("26 : "), ("27 : "), ("28 : "), ("29 : "), ("30 : ") 19 | }; 20 | 21 | TXDFeatureSet::TXDFeatureSet() 22 | {} 23 | 24 | TXDFeatureSet::~TXDFeatureSet() 25 | {} 26 | 27 | void* TXDFeatureSet::GetRawData(size_t Idx) 28 | { 29 | UINT i = m_vFeatSelected[Idx]; 30 | Feature feat = m_vFeatures[i]; 31 | return m_pDataReader->GetData(feat.nAttributeOffset); 32 | } 33 | 34 | void* TXDFeatureSet::GetData(size_t Idx) 35 | { 36 | UINT i = m_vFeatSelected[Idx]; 37 | Feature feat = m_vFeatures[i]; 38 | 39 | char* pData = (char*)m_pDataReader->GetData(feat.nAttributeOffset); 40 | if (pData == NULL) 41 | return NULL; 42 | std::string strData(pData); 43 | strtk::std_string::token_list_type token_list; 44 | strtk::single_delimiter_predicate predicate(';'); 45 | strtk::split(predicate,strData,std::back_inserter(token_list)); 46 | strtk::std_string::token_list_type::iterator itr = token_list.begin(); 47 | strtk::std_string::token_list_type::iterator itPoint = itr; 48 | std::ostringstream ss; 49 | if (m_eFeatureType != POLYGON_TYPE) 50 | ss << strData << "\r\n\r\n"; 51 | i = 0; 52 | std::ostringstream ssType; 53 | ssType << (*itr); 54 | if (ssType.str() == "RF") 55 | { 56 | while (token_list.end() != itr) 57 | { 58 | if (i == 2) 59 | { 60 | itPoint = itr++; 61 | ss << RF_FIELD[i++] << "\r\n"; 62 | continue; 63 | } 64 | ss << RF_FIELD[i++] << (*itr) << "\r\n"; 65 | ++itr; 66 | } 67 | } 68 | else 69 | { 70 | while (token_list.end() != itr) 71 | { 72 | if (i == 2) 73 | { 74 | itPoint = itr++; 75 | ss << i++ << ": " << "\r\n"; 76 | continue; 77 | } 78 | ss << i++ << ": " << (*itr) << "\r\n"; 79 | ++itr; 80 | } 81 | } 82 | 83 | ss << "\r\nPoints:\r\n"; 84 | strtk::std_string::token_list_type points_list; 85 | strtk::std_string::token_list_type polygon_list; 86 | strtk::single_delimiter_predicate pred(','); 87 | strtk::single_delimiter_predicate subAttr('|'); 88 | strtk::split(subAttr,*itPoint,std::back_inserter(polygon_list)); 89 | strtk::std_string::token_list_type::iterator iter = polygon_list.begin(); 90 | ss.precision(5); 91 | ss.setf(std::ios::fixed); 92 | int nHole = 1; 93 | bool bInteger = m_pDataReader->m_bInteger; 94 | while (polygon_list.end() != iter) 95 | { 96 | points_list.clear(); 97 | strtk::split(pred, *iter, std::back_inserter(points_list)); 98 | strtk::std_string::token_list_type::iterator iterP = points_list.begin(); 99 | while (points_list.end() != iterP) 100 | { 101 | if (bInteger) 102 | { 103 | int p1, p2; 104 | strtk::string_to_type_converter((*iterP), p1); 105 | ++iterP; 106 | strtk::string_to_type_converter((*iterP), p2); 107 | ++iterP; 108 | ss << p1 / 100000.0 << ", " << p2 / 100000.0 << "\r\n"; 109 | } 110 | else 111 | { 112 | double p1, p2; 113 | strtk::string_to_type_converter((*iterP), p1); 114 | ++iterP; 115 | strtk::string_to_type_converter((*iterP), p2); 116 | ++iterP; 117 | ss << p1 << ", " << p2 << "\r\n"; 118 | } 119 | } 120 | ++iter; 121 | if (polygon_list.end() != iter) 122 | ss << "Hole " << nHole++ << "-----------------------------\r\n"; 123 | } 124 | m_strData = ss.str(); 125 | return (void*)m_strData.c_str(); 126 | } 127 | 128 | void* TXDFeatureSet::GetFeatureID(size_t Idx) 129 | { 130 | strtk::type_to_string(m_vID[Idx], m_strID); 131 | return (void*)m_strID.c_str(); 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /TXDViewer2/GeoData/TXDFeatureSet.h: -------------------------------------------------------------------------------- 1 | #ifndef _TXD_FEATURE_SET_H 2 | #define _TXD_FEATURE_SET_H 3 | 4 | #include "FeatureSet.h" 5 | 6 | static const int RF_FIELD_SIZE = 30; 7 | 8 | class TXDFeatureSet : public FeatureSet 9 | { 10 | public: 11 | TXDFeatureSet(); 12 | 13 | TXDFeatureSet(CString strName, GEO_TYPE eType) : FeatureSet(strName, eType) 14 | { 15 | } 16 | 17 | ~TXDFeatureSet(); 18 | 19 | public: 20 | virtual void* GetData(size_t Idx); 21 | virtual void* GetRawData(size_t Idx); 22 | virtual void* GetFeatureID(size_t Idx); 23 | 24 | public: 25 | static const char* RF_FIELD[RF_FIELD_SIZE]; 26 | std::string m_strData; 27 | std::string m_strID; 28 | std::vector m_vPoints; 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /TXDViewer2/GeoRender/GDIRender.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // No use 4 | // If we want to add other render like GDI+ or something else, 5 | // we may need to put GDI related stuff to this class. 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #ifndef _GDI_RENDER_H 10 | #define _GDI_RENDER_H 11 | 12 | class GDIRender 13 | { 14 | 15 | }; 16 | 17 | #endif -------------------------------------------------------------------------------- /TXDViewer2/IdentifyDlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CIdentifyDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CIdentifyTreeView : public CWindowImpl 8 | { 9 | public: 10 | HWND m_hwndView; 11 | CEdit* m_pEdit; 12 | HTREEITEM m_hItem; 13 | 14 | BEGIN_MSG_MAP(CIdentifyTreeView) 15 | REFLECTED_NOTIFY_CODE_HANDLER_EX(TVN_SELCHANGED, OnItemChanged) 16 | REFLECTED_NOTIFY_CODE_HANDLER_EX(NM_RCLICK, OnRClick) 17 | COMMAND_ID_HANDLER(ID_IDENTIFY_COPY_SELECT, OnCopySelected) 18 | COMMAND_ID_HANDLER(ID_IDENTIFY_COPY_ALL, OnCopyAll) 19 | COMMAND_ID_HANDLER(ID_IDENTIFY_EXPORT, OnExportAll) 20 | DEFAULT_REFLECTION_HANDLER() 21 | END_MSG_MAP() 22 | 23 | LRESULT OnItemChanged ( NMHDR* phdr ) 24 | { 25 | std::vector vLayers = g_MapManager.GetAllLayers(); 26 | if (vLayers.empty()) 27 | return 0; 28 | 29 | TVITEM tvItem = {0}; 30 | tvItem.mask = TVIF_PARAM; 31 | tvItem.hItem = GetSelectedItem(); 32 | 33 | GetItem(&tvItem); 34 | 35 | int nNum = (int)tvItem.lParam; 36 | int nLayer = LOWORD(nNum); 37 | if (nLayer >= vLayers.size()) 38 | return 0; 39 | 40 | int nFeat = HIWORD(nNum); 41 | FeatureSet* pFeatureSet = vLayers[nLayer]->GetFeatureSet(); 42 | g_MapManager.m_nCurSelected = pFeatureSet->m_vFeatSelected[nFeat]; 43 | g_MapManager.m_nCurLayerSelected = nLayer; 44 | LPCSTR lpData = (LPCSTR)pFeatureSet->GetData(nFeat); 45 | if (lpData == NULL) 46 | { 47 | MessageBox(_T("Can't open attribute file or no attribute\r\nOr Not enough memory!"), _T("WARNING"), MB_ICONWARNING); 48 | } 49 | else 50 | { 51 | DWORD dwNum = MultiByteToWideChar(CP_UTF8, 0, lpData, -1, NULL, 0); 52 | LPWSTR pwData = new WCHAR[dwNum]; 53 | if (!pwData) 54 | { 55 | delete []pwData; 56 | m_pEdit->SetWindowText(_T("Get Data Error!!!")); 57 | return 0; 58 | } 59 | MultiByteToWideChar(CP_UTF8, 0, lpData, -1, pwData, dwNum); 60 | m_pEdit->SetWindowText(pwData); 61 | 62 | pFeatureSet->m_vAttrSelected.push_back(pwData); 63 | } 64 | ::InvalidateRect(m_hwndView, NULL, TRUE); 65 | 66 | return 0; 67 | } 68 | 69 | LRESULT OnRClick( LPNMHDR lpNMHDR ) 70 | { 71 | //CMenu menu; 72 | POINT point; 73 | GetCursorPos(&point); 74 | ::ScreenToClient(m_hWnd, &point); 75 | m_hItem = NULL; 76 | m_hItem = HitTest(point, NULL); 77 | if (m_hItem == NULL) 78 | return TRUE; 79 | 80 | GetCursorPos(&point); 81 | m_hItem = this->GetDropHilightItem( ); 82 | if (m_hItem != NULL) 83 | this->Select(m_hItem,TVGN_CARET); 84 | else 85 | m_hItem = this->GetSelectedItem(); 86 | 87 | CMenu menu; 88 | menu.LoadMenu(IDR_IDENTIFYCONTEXTMENU); 89 | CMenuHandle menuPopup = menu.GetSubMenu(0); 90 | menuPopup.TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN, point.x, point.y, m_hWnd); 91 | 92 | return TRUE; 93 | } 94 | 95 | LRESULT OnCopySelected(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 96 | { 97 | TVITEM tvItem = {0}; 98 | tvItem.mask = TVIF_PARAM; 99 | tvItem.hItem = GetSelectedItem(); 100 | 101 | GetItem(&tvItem); 102 | 103 | int nNum = (int)tvItem.lParam; 104 | int nLayer = LOWORD(nNum); 105 | int nFeat = HIWORD(nNum); 106 | 107 | std::vector vLayers = g_MapManager.GetAllLayers(); 108 | if (nLayer >= vLayers.size()) 109 | return 0; 110 | FeatureSet* pFeatureSet = vLayers[nLayer]->GetFeatureSet(); 111 | g_MapManager.m_nCurSelected = pFeatureSet->m_vFeatSelected[nFeat]; 112 | g_MapManager.m_nCurLayerSelected = nLayer; 113 | LPCSTR lpData = (LPCSTR)pFeatureSet->GetRawData(nFeat); 114 | if (lpData == NULL) 115 | { 116 | MessageBox(_T("Can't open attribute file or no attribute\r\nOr Not enough memory!"), _T("WARNING"), MB_ICONWARNING); 117 | } 118 | 119 | LPSTR lptstrCopy; 120 | HGLOBAL hglbCopy; 121 | 122 | // Open the clipboard, and empty it. 123 | if (!OpenClipboard()) 124 | return FALSE; 125 | EmptyClipboard(); 126 | 127 | // Allocate a global memory object for the text. 128 | UINT nLen = strlen(lpData); 129 | hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (nLen+2) * sizeof(CHAR)); 130 | if (hglbCopy == NULL) 131 | { 132 | CloseClipboard(); 133 | return FALSE; 134 | } 135 | 136 | // Lock the handle and copy the text to the buffer. 137 | lptstrCopy = (LPSTR)GlobalLock(hglbCopy); 138 | memcpy(lptstrCopy, lpData, (nLen+2) * sizeof(CHAR)); 139 | lptstrCopy[nLen] = '\n'; 140 | lptstrCopy[nLen+1] = '\0'; 141 | GlobalUnlock(hglbCopy); 142 | 143 | // Place the handle on the clipboard. 144 | SetClipboardData(CF_TEXT, hglbCopy); 145 | CloseClipboard(); 146 | return TRUE; 147 | } 148 | 149 | LRESULT OnCopyAll(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 150 | { 151 | std::string strRecords; 152 | HTREEITEM hRoot = GetRootItem(); 153 | do 154 | { 155 | HTREEITEM hChild = GetChildItem(hRoot); 156 | while (hChild != NULL) 157 | { 158 | TVITEM tvItem = {0}; 159 | tvItem.mask = TVIF_PARAM; 160 | tvItem.hItem = hChild; 161 | 162 | GetItem(&tvItem); 163 | 164 | int nNum = (int)tvItem.lParam; 165 | int nLayer = LOWORD(nNum); 166 | int nFeat = HIWORD(nNum); 167 | std::vector vLayers = g_MapManager.GetAllLayers(); 168 | if (nLayer >= vLayers.size()) 169 | return 0; 170 | FeatureSet* pFeatureSet = vLayers[nLayer]->GetFeatureSet(); 171 | g_MapManager.m_nCurSelected = pFeatureSet->m_vFeatSelected[nFeat]; 172 | g_MapManager.m_nCurLayerSelected = nLayer; 173 | LPCSTR lpData = (LPCSTR)pFeatureSet->GetRawData(nFeat); 174 | strRecords += lpData; 175 | if (strRecords[strRecords.length()-1] != '\n') 176 | strRecords += '\n'; 177 | hChild = GetNextSiblingItem(hChild); 178 | } 179 | hRoot = GetNextSiblingItem(hRoot); 180 | } while(hRoot != NULL); 181 | 182 | LPSTR lptstrCopy; 183 | HGLOBAL hglbCopy; 184 | 185 | // Open the clipboard, and empty it. 186 | if (!OpenClipboard()) 187 | return FALSE; 188 | EmptyClipboard(); 189 | 190 | // Allocate a global memory object for the text. 191 | UINT nLen = strRecords.size(); 192 | hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (nLen+1) * sizeof(CHAR)); 193 | if (hglbCopy == NULL) 194 | { 195 | CloseClipboard(); 196 | return FALSE; 197 | } 198 | 199 | // Lock the handle and copy the text to the buffer. 200 | lptstrCopy = (LPSTR)GlobalLock(hglbCopy); 201 | memcpy(lptstrCopy, strRecords.c_str(), (nLen+1) * sizeof(CHAR)); 202 | GlobalUnlock(hglbCopy); 203 | 204 | // Place the handle on the clipboard. 205 | SetClipboardData(CF_TEXT, hglbCopy); 206 | CloseClipboard(); 207 | return TRUE; 208 | } 209 | 210 | LRESULT OnExportAll(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 211 | { 212 | std::string strRecords; 213 | HTREEITEM hRoot = GetRootItem(); 214 | 215 | if (hRoot == NULL) 216 | return FALSE; 217 | 218 | // Fill the OPENFILENAME structure 219 | TCHAR szFilters[] = _T("Text Files (*.*)\0*.*\0\0"); 220 | TCHAR szFilePathName[_MAX_PATH] = _T(""); 221 | OPENFILENAME ofn = {0}; 222 | ofn.lStructSize = sizeof(OPENFILENAME); 223 | ofn.hwndOwner = m_hWnd; 224 | ofn.lpstrFilter = szFilters; 225 | ofn.lpstrFile = szFilePathName; // This will hold the file name 226 | ofn.lpstrDefExt = _T("txd"); 227 | ofn.nMaxFile = _MAX_PATH; 228 | ofn.lpstrTitle = _T("Export Records"); 229 | ofn.Flags = OFN_OVERWRITEPROMPT; 230 | 231 | // Open the file save dialog, and choose the file name 232 | BOOL nRet = GetSaveFileName(&ofn); 233 | 234 | if(!nRet) 235 | return FALSE; 236 | 237 | do 238 | { 239 | HTREEITEM hChild = GetChildItem(hRoot); 240 | while (hChild != NULL) 241 | { 242 | TVITEM tvItem = {0}; 243 | tvItem.mask = TVIF_PARAM; 244 | tvItem.hItem = hChild; 245 | 246 | GetItem(&tvItem); 247 | 248 | int nNum = (int)tvItem.lParam; 249 | int nLayer = LOWORD(nNum); 250 | int nFeat = HIWORD(nNum); 251 | std::vector vLayers = g_MapManager.GetAllLayers(); 252 | if (nLayer >= vLayers.size()) 253 | return 0; 254 | FeatureSet* pFeatureSet = vLayers[nLayer]->GetFeatureSet(); 255 | g_MapManager.m_nCurSelected = pFeatureSet->m_vFeatSelected[nFeat]; 256 | g_MapManager.m_nCurLayerSelected = nLayer; 257 | LPCSTR lpData = (LPCSTR)pFeatureSet->GetRawData(nFeat); 258 | strRecords += lpData; 259 | if (strRecords[strRecords.length()-1] != '\n') 260 | strRecords += '\n'; 261 | hChild = GetNextSiblingItem(hChild); 262 | } 263 | hRoot = GetNextSiblingItem(hRoot); 264 | } while(hRoot != NULL); 265 | 266 | CFile output; 267 | if (!output.Open(szFilePathName, GENERIC_WRITE, 0, CREATE_ALWAYS)) 268 | return FALSE; 269 | output.Write(strRecords.c_str(), strRecords.length()); 270 | output.Close(); 271 | 272 | return TRUE; 273 | } 274 | }; 275 | 276 | class CIdentifyDlg : public CDialogImpl, 277 | public CMessageFilter, public CDialogResize 278 | { 279 | public: 280 | enum { IDD = IDD_IDENTIFY }; 281 | HWND m_hwndView; 282 | 283 | CEdit m_wndEdit; 284 | CIdentifyTreeView m_wndTreeView; 285 | CHorSplitterCtrl m_ctrlSplit; 286 | 287 | virtual BOOL PreTranslateMessage(MSG* pMsg) 288 | { 289 | return CWindow::IsDialogMessage(pMsg); 290 | } 291 | 292 | BEGIN_MSG_MAP(CIdentifyDlg) 293 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 294 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 295 | COMMAND_ID_HANDLER(IDOK, OnOK) 296 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) 297 | CHAIN_MSG_MAP(CDialogResize) 298 | REFLECT_NOTIFICATIONS() 299 | END_MSG_MAP() 300 | 301 | // This map defines how the controls within the window are resized. 302 | // You can also use DLGRESIZE_GROUP() to group controls together. 303 | BEGIN_DLGRESIZE_MAP(CIdentifyDlg) 304 | DLGRESIZE_CONTROL(IDC_EDIT1, DLSZ_SIZE_X|DLSZ_SIZE_Y) 305 | DLGRESIZE_CONTROL(IDC_SPLIT, DLSZ_SIZE_X) 306 | DLGRESIZE_CONTROL(IDC_TREE1, DLSZ_SIZE_X) 307 | DLGRESIZE_CONTROL(IDC_COMBO_IDENTIFY_LAYERS, DLSZ_SIZE_X) 308 | END_DLGRESIZE_MAP() 309 | 310 | // Handler prototypes (uncomment arguments if needed): 311 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 312 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 313 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 314 | 315 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 316 | { 317 | DlgResize_Init(true); 318 | 319 | int nHeigh= GetSystemMetrics(SM_CYFULLSCREEN); // not include taskbar 320 | 321 | int xLeft = 20; 322 | int yTop = nHeigh - 500; 323 | 324 | // map screen coordinates to child coordinates 325 | //::SetWindowPos(m_hWnd, NULL, xLeft, yTop, -1, -1, 326 | // SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 327 | MoveWindow(xLeft, yTop, 280, 500, FALSE); 328 | // set icons 329 | HICON hIcon = AtlLoadIconImage(IDI_IDENTIFY, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); 330 | SetIcon(hIcon, TRUE); 331 | HICON hIconSmall = AtlLoadIconImage(IDI_IDENTIFY, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); 332 | SetIcon(hIconSmall, FALSE); 333 | 334 | m_ctrlSplit.SubclassWindow(GetDlgItem(IDC_SPLIT)); 335 | m_ctrlSplit.SetSplitterPanes(GetDlgItem(IDC_TREE1), GetDlgItem(IDC_EDIT1)); 336 | 337 | m_wndTreeView.SubclassWindow(GetDlgItem(IDC_TREE1)); 338 | m_wndEdit.Attach(GetDlgItem(IDC_EDIT1)); 339 | 340 | // register object for message filtering and idle updates 341 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 342 | ATLASSERT(pLoop != NULL); 343 | pLoop->AddMessageFilter(this); 344 | 345 | //UIAddChildWindowContainer(m_hWnd); 346 | m_wndTreeView.m_pEdit = &m_wndEdit; 347 | m_wndTreeView.m_hwndView = m_hwndView; 348 | 349 | return TRUE; 350 | } 351 | 352 | void CleanUp() 353 | { 354 | m_wndTreeView.DeleteAllItems(); 355 | m_wndEdit.SetWindowText(_T("")); 356 | } 357 | 358 | void UpdateContent(EXTENT& hitExtent, int xScreen, int yScreen, bool bHit, bool bCtrl) 359 | { 360 | std::vector vLayers = g_MapManager.GetAllLayers(); 361 | HTREEITEM hSelectItem = NULL; 362 | m_wndTreeView.DeleteAllItems(); 363 | for (size_t i = 0; i < vLayers.size(); ++i) 364 | { 365 | HTREEITEM hRoot = NULL; 366 | Layer* pLayer = vLayers[i]; 367 | FeatureSet* pFeatureSet = pLayer->GetFeatureSet(); 368 | for (UINT ii = 0; ii < pFeatureSet->m_vAttrSelected.size(); ++ii) 369 | { 370 | delete[] pFeatureSet->m_vAttrSelected[ii]; 371 | } 372 | pFeatureSet->m_vAttrSelected.clear(); 373 | if (!pLayer->isVisable()) 374 | { 375 | continue; 376 | } 377 | if (!pFeatureSet->InView()) 378 | { 379 | continue; 380 | } 381 | pFeatureSet->SelectFeatures(hitExtent, xScreen, yScreen, bHit, bCtrl); 382 | if (pFeatureSet->m_vFeatSelected.empty()) 383 | continue; 384 | hRoot = m_wndTreeView.InsertItem(pFeatureSet->m_strName, TVI_ROOT, TVI_LAST); 385 | 386 | for (UINT j = 0; j < pFeatureSet->m_vFeatSelected.size(); ++j) 387 | { 388 | LPCSTR lpData = (LPCSTR)pFeatureSet->GetFeatureID(pFeatureSet->m_vFeatSelected[j]); 389 | DWORD dwNum = MultiByteToWideChar(CP_UTF8, 0, lpData, -1, NULL, 0); 390 | LPWSTR pwData = new WCHAR[dwNum]; 391 | if (!pwData) 392 | { 393 | delete []pwData; 394 | MessageBox(_T("Not enough memory"), _T("Error"), MB_OK|MB_ICONERROR); 395 | return; 396 | } 397 | MultiByteToWideChar(CP_UTF8, 0, lpData, -1, pwData, dwNum); 398 | pFeatureSet->m_vAttrSelected.push_back(pwData); 399 | 400 | HTREEITEM hItem = m_wndTreeView.InsertItem(pwData, hRoot, TVI_LAST); 401 | if (hSelectItem == NULL) 402 | hSelectItem = hItem; 403 | m_wndTreeView.SetItemData(hItem, MAKELONG(i, j)); 404 | } 405 | m_wndTreeView.Expand(hRoot); 406 | } 407 | m_wndTreeView.SelectItem(hSelectItem); 408 | } 409 | 410 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 411 | { 412 | // unregister message filtering and idle updates 413 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 414 | ATLASSERT(pLoop != NULL); 415 | pLoop->RemoveMessageFilter(this); 416 | return 0; 417 | } 418 | 419 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 420 | { 421 | // TODO: Add validation code 422 | CloseDialog(wID); 423 | return 0; 424 | } 425 | 426 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 427 | { 428 | CloseDialog(wID); 429 | return 0; 430 | } 431 | void CloseDialog(int nVal) 432 | { 433 | ShowWindow(SW_HIDE); 434 | } 435 | }; 436 | -------------------------------------------------------------------------------- /TXDViewer2/LocateDlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CLocateDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CLocateDlg : public CDialogImpl, public CUpdateUI, 8 | public CMessageFilter 9 | { 10 | public: 11 | HWND m_wndView; 12 | 13 | enum { IDD = IDD_LOCATE }; 14 | CButton m_btnCoords; 15 | CButton m_btnID; 16 | CComboBox m_comboFind; 17 | 18 | virtual BOOL PreTranslateMessage(MSG* pMsg) 19 | { 20 | if (pMsg->wParam == 0x46 && GetKeyState( VK_CONTROL ) & 0x8000) // Key 'Ctrl + F' 21 | { 22 | SetFindID(); 23 | } 24 | else if (pMsg->wParam == 0x4C && GetKeyState( VK_CONTROL ) & 0x8000) // Key 'Ctrl + L' 25 | { 26 | SetFindLocation(); 27 | } 28 | return CWindow::IsDialogMessage(pMsg); 29 | } 30 | 31 | BEGIN_UPDATE_UI_MAP(CLocateDlg) 32 | END_UPDATE_UI_MAP() 33 | 34 | BEGIN_MSG_MAP(CLocateDlg) 35 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 36 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 37 | MSG_WM_SHOWWINDOW(OnShowWindow) 38 | COMMAND_ID_HANDLER(IDOK, OnOK) 39 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) 40 | COMMAND_ID_HANDLER(ID_SWAP_COORDS, OnSwapCoords) 41 | END_MSG_MAP() 42 | 43 | // Handler prototypes (uncomment arguments if needed): 44 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 45 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 46 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 47 | bool Split(std::vector& vSplit, CString str, TCHAR ch) 48 | { 49 | str.TrimLeft(ch); 50 | str.TrimRight(ch); 51 | 52 | int nStart = 0; 53 | int nLastStart = 0; 54 | 55 | while(-1 != (nStart = str.Find(ch, nStart))) 56 | { 57 | if(nLastStart != nStart) 58 | { 59 | vSplit.push_back(str.Mid(nLastStart, nStart - nLastStart)); 60 | } 61 | nStart ++; 62 | nLastStart = nStart; 63 | } 64 | vSplit.push_back(str.Mid(nLastStart)); 65 | return true; 66 | } 67 | 68 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 69 | { 70 | // center the dialog on the screen 71 | CenterWindow(); 72 | // set icons 73 | //HICON hIcon = AtlLoadIconImage(IDI_FIND, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); 74 | //SetIcon(hIcon, TRUE); 75 | //HICON hIconSmall = AtlLoadIconImage(IDI_FIND, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); 76 | //SetIcon(hIconSmall, FALSE); 77 | 78 | m_comboFind.Attach(GetDlgItem(IDC_COMBO_LOCATE)); 79 | m_btnCoords.Attach(GetDlgItem(IDC_RADIO_COORDS)); 80 | m_btnCoords.SetCheck(1); 81 | m_btnID.Attach(GetDlgItem(IDC_RADIO_ID)); 82 | // register object for message filtering and idle updates 83 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 84 | ATLASSERT(pLoop != NULL); 85 | pLoop->AddMessageFilter(this); 86 | UIAddChildWindowContainer(m_hWnd); 87 | return TRUE; 88 | } 89 | 90 | void OnShowWindow(BOOL bShow, UINT nStatus) 91 | { 92 | m_comboFind.SetFocus(); 93 | } 94 | 95 | void SetFindID() 96 | { 97 | m_btnCoords.SetCheck(0); 98 | m_btnID.SetCheck(1); 99 | m_comboFind.SetFocus(); 100 | } 101 | 102 | void SetFindLocation() 103 | { 104 | m_btnCoords.SetCheck(1); 105 | m_btnID.SetCheck(0); 106 | m_comboFind.SetFocus(); 107 | } 108 | 109 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 110 | { 111 | int nLen; 112 | LPTSTR pStrFind; 113 | CString strFind; 114 | nLen = m_comboFind.GetWindowTextLength(); 115 | pStrFind = new TCHAR[nLen + 1]; 116 | m_comboFind.GetWindowText(pStrFind, nLen+1); 117 | 118 | //((CheckRadioButton)GetDlgItem(IDC_RADIO_LOCATE)).AddString(pStrFind); 119 | strFind = pStrFind; 120 | 121 | strFind.Remove(_T('\t')); 122 | 123 | if (m_btnID.GetCheck() == 1) 124 | { 125 | strFind.Remove(_T(' ')); 126 | for (int i = 0; i < strFind.GetLength(); ++i) 127 | { 128 | if (!isdigit(strFind[i])) 129 | { 130 | MessageBox(_T("Not a Record ID"), _T("WARNING"), MB_ICONWARNING); 131 | delete []pStrFind; 132 | return 0; 133 | } 134 | } 135 | UINT64 nID = _tcstoui64(strFind.GetBuffer(strFind.GetLength()), NULL, 10); 136 | std::vector vLayers = g_MapManager.GetAllLayers(); 137 | bool bFind = false; 138 | for (size_t i = 0; i < vLayers.size(); ++i) 139 | { 140 | FeatureSet* pFeatureSet = vLayers[i]->GetFeatureSet(); 141 | bFind = pFeatureSet->SearchID(nID); 142 | if (bFind) 143 | break; 144 | } 145 | if (!bFind) 146 | { 147 | m_comboFind.SetWindowText(_T("Not find or No points in this record")); 148 | } 149 | else 150 | { 151 | ShowWindow(SW_HIDE); 152 | } 153 | 154 | } 155 | else 156 | { 157 | bool bCoords = false; 158 | std::vector vSplit; 159 | CString strLeft; 160 | CString strRight; 161 | if (strFind.Find(_T(',')) != -1) // commas is the delimiter 162 | { 163 | strFind.Remove(_T(' ')); 164 | vSplit.clear(); 165 | Split(vSplit, strFind, _T(',')); 166 | 167 | if (vSplit.size() != 2) 168 | { 169 | MessageBox(_T("Not a Coordinate"), _T("WARNING"), MB_ICONWARNING); 170 | delete []pStrFind; 171 | return 0; 172 | } 173 | strLeft = vSplit[0]; 174 | strRight = vSplit[1]; 175 | } 176 | else 177 | { 178 | Split(vSplit, strFind, _T(' ')); 179 | strLeft = vSplit[0]; 180 | strRight = vSplit[1]; 181 | } 182 | 183 | for (int i = 0; i < strLeft.GetLength(); ++i) 184 | { 185 | if (i == 0) 186 | { 187 | if (strLeft[i] == '-' || strLeft[i] == '+') 188 | continue; 189 | } 190 | if (strLeft[i] == '.') 191 | { 192 | bCoords = true; 193 | continue; 194 | } 195 | if (!isdigit(strLeft[i])) 196 | { 197 | MessageBox(_T("Not a Coordinate"), _T("WARNING"), MB_ICONWARNING); 198 | delete []pStrFind; 199 | return 0; 200 | } 201 | } 202 | for (int i = 0; i < strRight.GetLength(); ++i) 203 | { 204 | if (i == 0) 205 | { 206 | if (strRight[i] == '-' || strRight[i] == '+') 207 | continue; 208 | } 209 | if (strRight[i] == '.') 210 | { 211 | bCoords = true; 212 | continue; 213 | } 214 | if (!isdigit(strRight[i])) 215 | { 216 | MessageBox(_T("Not a Coordinate"), _T("WARNING"), MB_ICONWARNING); 217 | delete []pStrFind; 218 | return 0; 219 | } 220 | } 221 | 222 | m_comboFind.AddString(pStrFind); 223 | 224 | double xPos = _tstof(strRight.GetBuffer(strRight.GetLength())); 225 | double yPos = _tstof(strLeft.GetBuffer(strLeft.GetLength())); 226 | 227 | if (bCoords) 228 | { 229 | xPos *= 100000; 230 | yPos *= 100000; 231 | } 232 | 233 | EXTENT oldExtent = g_MapManager.GetWorldExtent(); 234 | double scale = (double)oldExtent.Height() / oldExtent.Width(); 235 | int nExpand = 800; 236 | if (g_MapManager.m_originalExtent.Width() < 1000000) 237 | { 238 | nExpand = 2200; 239 | } 240 | else if(g_MapManager.m_originalExtent.Width() < 2000000) 241 | { 242 | nExpand = 1400; 243 | } 244 | 245 | int halfWidth = oldExtent.Width() / 2; 246 | int halfHeight = oldExtent.Height() / 2; 247 | if (oldExtent.Width() > nExpand * 2) 248 | g_MapManager.SetWorldExtent(EXTENT(xPos + nExpand, xPos - nExpand, yPos + nExpand * scale, yPos - nExpand * scale)); 249 | else 250 | g_MapManager.SetWorldExtent(EXTENT(xPos + halfWidth, xPos - halfWidth, yPos + halfHeight, yPos - halfHeight)); 251 | 252 | g_MapManager.m_bLocate = true; 253 | 254 | double x_scale = (double) g_MapManager.GetScreenExtent().Width() / g_MapManager.GetWorldExtent().Width(); 255 | double y_scale = (double) g_MapManager.GetScreenExtent().Height() / g_MapManager.GetWorldExtent().Height(); 256 | g_MapManager.m_vLocatePoint.x = (int)((xPos - g_MapManager.GetWorldExtent().xmin) * x_scale); 257 | g_MapManager.m_vLocatePoint.y = (int)((g_MapManager.GetWorldExtent().ymax - yPos) * y_scale); 258 | ShowWindow(SW_HIDE); 259 | } 260 | ::InvalidateRect(m_wndView, NULL, TRUE); 261 | return 0; 262 | } 263 | LRESULT OnSwapCoords(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 264 | { 265 | int nLen; 266 | LPTSTR pStrFind; 267 | CString strFind; 268 | nLen = ((CComboBox)GetDlgItem(IDC_COMBO_LOCATE)).GetWindowTextLength(); 269 | pStrFind = new TCHAR[nLen + 1]; 270 | ((CComboBox)GetDlgItem(IDC_COMBO_LOCATE)).GetWindowText(pStrFind, nLen+1); 271 | 272 | strFind = pStrFind; 273 | TCHAR cSplit = _T(','); 274 | int idx = strFind.Find(_T(',')); 275 | if (idx == -1) 276 | { 277 | idx = strFind.Find(_T(' ')); 278 | cSplit = _T(' '); 279 | } 280 | CString strLeft = strFind.Left(idx); 281 | CString strRight = strFind.Right(nLen - idx - 1); 282 | 283 | strFind = strRight + cSplit + strLeft; 284 | ((CComboBox)GetDlgItem(IDC_COMBO_LOCATE)).SetWindowText(strFind.GetBuffer(strFind.GetLength())); 285 | delete []pStrFind; 286 | 287 | return 0; 288 | } 289 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 290 | { 291 | // unregister message filtering and idle updates 292 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 293 | ATLASSERT(pLoop != NULL); 294 | pLoop->RemoveMessageFilter(this); 295 | return 0; 296 | } 297 | 298 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 299 | { 300 | CloseDialog(wID); 301 | return 0; 302 | } 303 | void CloseDialog(int nVal) 304 | { 305 | g_MapManager.m_bLocate = false; 306 | ShowWindow(SW_HIDE); 307 | } 308 | }; 309 | -------------------------------------------------------------------------------- /TXDViewer2/Maindlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CIdentifyDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CIdentifyDlg : public CDialogImpl, public CUpdateUI, 8 | public CMessageFilter, public CIdleHandler, public CDialogResize 9 | { 10 | public: 11 | enum { IDD = IDD_IDENTIFY }; 12 | 13 | virtual BOOL PreTranslateMessage(MSG* pMsg) 14 | { 15 | return CWindow::IsDialogMessage(pMsg); 16 | } 17 | 18 | virtual BOOL OnIdle() 19 | { 20 | return FALSE; 21 | } 22 | 23 | BEGIN_UPDATE_UI_MAP(CIdentifyDlg) 24 | END_UPDATE_UI_MAP() 25 | 26 | BEGIN_MSG_MAP(CIdentifyDlg) 27 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 28 | MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 29 | COMMAND_ID_HANDLER(IDOK, OnOK) 30 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel) 31 | CHAIN_MSG_MAP(CDialogResize) 32 | END_MSG_MAP() 33 | 34 | // This map defines how the controls within the window are resized. 35 | // You can also use DLGRESIZE_GROUP() to group controls together. 36 | BEGIN_DLGRESIZE_MAP(CIdentifyDlg) 37 | DLGRESIZE_CONTROL(IDC_EDIT1, DLSZ_SIZE_X|DLSZ_SIZE_Y) 38 | DLGRESIZE_CONTROL(IDC_LIST1, DLSZ_SIZE_X) 39 | END_DLGRESIZE_MAP() 40 | 41 | // Handler prototypes (uncomment arguments if needed): 42 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 43 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 44 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 45 | 46 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 47 | { 48 | // center the dialog on the screen 49 | CenterWindow(); 50 | 51 | // set icons 52 | HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); 53 | SetIcon(hIcon, TRUE); 54 | HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); 55 | SetIcon(hIconSmall, FALSE); 56 | 57 | // register object for message filtering and idle updates 58 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 59 | ATLASSERT(pLoop != NULL); 60 | pLoop->AddMessageFilter(this); 61 | pLoop->AddIdleHandler(this); 62 | 63 | UIAddChildWindowContainer(m_hWnd); 64 | DlgResize_Init(true); 65 | return TRUE; 66 | } 67 | 68 | LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 69 | { 70 | // unregister message filtering and idle updates 71 | CMessageLoop* pLoop = _Module.GetMessageLoop(); 72 | ATLASSERT(pLoop != NULL); 73 | pLoop->RemoveMessageFilter(this); 74 | pLoop->RemoveIdleHandler(this); 75 | return 0; 76 | } 77 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 78 | { 79 | // TODO: Add validation code 80 | CloseDialog(wID); 81 | return 0; 82 | } 83 | 84 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 85 | { 86 | CloseDialog(wID); 87 | return 0; 88 | } 89 | void CloseDialog(int nVal) 90 | { 91 | ShowWindow(SW_HIDE); 92 | } 93 | }; 94 | -------------------------------------------------------------------------------- /TXDViewer2/MapManager/Layer.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Layer.h" 3 | 4 | Layer::Layer() : m_pFeatureSet(NULL), bVisable(true) 5 | { 6 | } 7 | 8 | Layer::Layer(FeatureSet* pFeatureSet) : m_pFeatureSet(pFeatureSet), bVisable(true) 9 | { 10 | } 11 | 12 | Layer::~Layer() 13 | { 14 | delete m_pFeatureSet; 15 | m_pFeatureSet = NULL; 16 | } 17 | 18 | FeatureSet* Layer::GetFeatureSet() 19 | { 20 | return m_pFeatureSet; 21 | } 22 | 23 | void Layer::SetFeatureSet(FeatureSet* pFeatureSet) 24 | { 25 | m_pFeatureSet = pFeatureSet; 26 | } 27 | -------------------------------------------------------------------------------- /TXDViewer2/MapManager/Layer.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // Each layer has a featureset(geodata) and attributes (e.g color, visibility) of it. 4 | // 5 | // Created 2013/1/13 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #ifndef _LAYER_H 10 | #define _LAYER_H 11 | 12 | #include "FeatureSet.h" 13 | 14 | class Layer 15 | { 16 | public: 17 | Layer(); 18 | Layer(FeatureSet* pfeatureSet); 19 | ~Layer(); 20 | 21 | public: 22 | FeatureSet* GetFeatureSet(); 23 | 24 | bool isVisable() 25 | { 26 | return bVisable; 27 | } 28 | 29 | void SetFeatureSet(FeatureSet* pfeatureSet); 30 | 31 | COLORREF GetColor() 32 | { 33 | return m_color; 34 | } 35 | 36 | void SetColor(COLORREF color) 37 | { 38 | m_color = color; 39 | } 40 | 41 | public: 42 | bool bVisable; 43 | 44 | private: 45 | FeatureSet* m_pFeatureSet; 46 | COLORREF m_color; 47 | }; 48 | 49 | #endif -------------------------------------------------------------------------------- /TXDViewer2/MapManager/MapManager.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "MapManager.h" 3 | 4 | MapManager::MapManager() 5 | { 6 | m_worldExtent.xmax = -18000000; 7 | m_worldExtent.xmin = 18000000; 8 | m_worldExtent.ymax = -9000000; 9 | m_worldExtent.ymin = 9000000; 10 | m_screenRect.top = 0; 11 | m_screenRect.left = 0; 12 | m_screenRect.bottom = 600; 13 | m_screenRect.right = 800; 14 | m_colorList[0] = RGB(0, 0, 0); 15 | m_colorList[1] = RGB(250, 0, 0); 16 | m_colorList[2] = RGB(0, 250, 0); 17 | m_colorList[3] = RGB(0, 0, 250); 18 | m_colorList[4] = RGB(200, 100, 0); 19 | m_colorList[5] = RGB(0, 200, 100); 20 | m_colorList[6] = RGB(100, 0, 200); 21 | m_colorList[7] = RGB(200, 0, 100); 22 | m_colorList[8] = RGB(100, 200, 0); 23 | m_colorList[9] = RGB(100, 32, 99); 24 | m_colorList[10] = RGB(23, 3, 87); 25 | m_colorList[11] = RGB(11, 138, 0); 26 | m_colorList[12] = RGB(156, 0, 33); 27 | m_colorList[13] = RGB(0, 183, 32); 28 | m_colorList[14] = RGB(0, 1, 23); 29 | m_colorList[15] = RGB(0, 99, 0); 30 | m_curColorIdx = 0; 31 | m_bSelectMode = false; 32 | m_bExtentSelectMode = false; 33 | m_bZoomInMode = false; 34 | m_bZoomOutMode = false; 35 | m_bLocate = false; 36 | m_bShowID = false; 37 | } 38 | 39 | void MapManager::reset() 40 | { 41 | m_curColorIdx = 0; 42 | m_worldExtent.xmax = -18000000; 43 | m_worldExtent.xmin = 18000000; 44 | m_worldExtent.ymax = -9000000; 45 | m_worldExtent.ymin = 9000000; 46 | m_screenRect.top = 0; 47 | m_screenRect.left = 0; 48 | m_screenRect.bottom = 600; 49 | m_screenRect.right = 800; 50 | } 51 | 52 | MapManager::~MapManager() 53 | { 54 | for(UINT i = 0; i < m_vLayers.size(); ++i) 55 | { 56 | delete m_vLayers[i]; 57 | } 58 | for (UINT i = 0; i < m_vDataReader.size(); ++i) 59 | { 60 | delete m_vDataReader[i]; 61 | } 62 | } 63 | 64 | std::vector& MapManager::GetAllLayers() 65 | { 66 | return m_vLayers; 67 | } 68 | 69 | void MapManager::AddLayer(Layer* pLayer) 70 | { 71 | if (m_curColorIdx == 16) 72 | { 73 | m_curColorIdx = 0; 74 | } 75 | pLayer->SetColor(m_colorList[m_curColorIdx++]); 76 | m_vLayers.push_back(pLayer); 77 | } 78 | 79 | void MapManager::ScreenToWorld(int& xlon, int& ylat) 80 | { 81 | double x_scale = (double) xlon / m_screenRect.Width(); 82 | double y_scale = (double) ylat / m_screenRect.Height(); 83 | 84 | xlon = m_worldExtent.xmin + (int)(m_worldExtent.xmax - m_worldExtent.xmin) * x_scale; 85 | ylat = m_worldExtent.ymax - (int)(m_worldExtent.ymax - m_worldExtent.ymin) * y_scale; 86 | } 87 | 88 | void MapManager::SetScreenRect(const CRect& screenRect) 89 | { 90 | m_screenRect = screenRect; 91 | } 92 | 93 | void MapManager::SetWorldExtent(const EXTENT& worldExtent) 94 | { 95 | m_worldExtent = worldExtent; 96 | } -------------------------------------------------------------------------------- /TXDViewer2/MapManager/MapManager.h: -------------------------------------------------------------------------------- 1 | // ******************************************************************************************************** 2 | // Description: 3 | // A collection of layers. 4 | // 5 | // Created 2013/1/13 6 | // 7 | // ******************************************************************************************************** 8 | 9 | #ifndef _MAP_MANAGER_H 10 | #define _MAP_MANAGER_H 11 | 12 | #include "Layer.h" 13 | 14 | class MapManager 15 | { 16 | public: 17 | MapManager(); 18 | ~MapManager(); 19 | 20 | public: 21 | std::vector& GetAllLayers(); 22 | void AddLayer(Layer* pLayer); 23 | void ScreenToWorld(int& xlon, int& ylat); 24 | void reset(); 25 | void SetWorldExtent(const EXTENT& worldExtent); 26 | void SetScreenRect(const CRect& screenRect); 27 | void AdjustWorldExtent() 28 | { 29 | int newWorldHeight = (double) m_screenRect.Height() / m_screenRect.Width() * m_worldExtent.Width(); 30 | if (newWorldHeight > m_worldExtent.Height()) 31 | { 32 | int worldMidHeight = m_worldExtent.ymax - m_worldExtent.Height() / 2; 33 | m_worldExtent.ymax = worldMidHeight + newWorldHeight / 2; 34 | m_worldExtent.ymin = worldMidHeight - newWorldHeight / 2; 35 | } 36 | else 37 | { 38 | int newWorldWidth = (double) m_screenRect.Width() / m_screenRect.Height() * m_worldExtent.Height(); 39 | if (newWorldWidth > m_worldExtent.Width()) 40 | { 41 | int worldMidWidth = m_worldExtent.xmax - m_worldExtent.Width() / 2; 42 | m_worldExtent.xmax = worldMidWidth + newWorldWidth / 2; 43 | m_worldExtent.xmin = worldMidWidth - newWorldWidth / 2; 44 | } 45 | } 46 | } 47 | EXTENT GetWorldExtent() 48 | { 49 | return m_worldExtent; 50 | } 51 | CRect GetScreenExtent() 52 | { 53 | return m_screenRect; 54 | } 55 | void SetFullExtent() 56 | { 57 | m_worldExtent = m_originalExtent; 58 | } 59 | void CaculateExtent() 60 | { 61 | m_worldExtent.Reset(); 62 | for (int i = 0; i < m_vLayers.size(); ++i) 63 | { 64 | Layer* pLayer = m_vLayers[i]; 65 | FeatureSet* pFeatureSet = pLayer->GetFeatureSet(); 66 | EXTENT extent = pFeatureSet->GetExtent(); 67 | if (extent.xmax > m_worldExtent.xmax) 68 | m_worldExtent.xmax = extent.xmax + 1; 69 | if (extent.xmin < m_worldExtent.xmin) 70 | m_worldExtent.xmin = extent.xmin - 1; 71 | if (extent.ymax > m_worldExtent.ymax) 72 | m_worldExtent.ymax = extent.ymax + 1; 73 | if (extent.ymin < m_worldExtent.ymin) 74 | m_worldExtent.ymin = extent.ymin - 1; 75 | } 76 | m_originalExtent = m_worldExtent; 77 | 78 | } 79 | private: 80 | std::vector m_vLayers; 81 | EXTENT m_worldExtent; 82 | CRect m_screenRect; 83 | bool m_bFisrtLayer; 84 | COLORREF m_colorList[16]; 85 | int m_curColorIdx; 86 | public: 87 | EXTENT m_originalExtent; 88 | bool m_bSelectMode; 89 | bool m_bExtentSelectMode; 90 | bool m_bZoomInMode; 91 | bool m_bZoomOutMode; 92 | bool m_bShowID; 93 | std::vector m_vFilename; 94 | std::vector m_vDataReader; 95 | POINT m_vLocatePoint; 96 | bool m_bLocate; 97 | UINT m_nCurSelected; 98 | UINT m_nCurLayerSelected; 99 | }; 100 | 101 | #endif -------------------------------------------------------------------------------- /TXDViewer2/MetaInfoDlg.h: -------------------------------------------------------------------------------- 1 | // MainDlg.h : interface of the CMetaInfoDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CMetaInfoDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_DLG_LAYER_INFO }; 11 | 12 | CString m_strInfo; 13 | 14 | BEGIN_MSG_MAP(CMetaInfoDlg) 15 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 16 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 17 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 18 | END_MSG_MAP() 19 | 20 | // Handler prototypes (uncomment arguments if needed): 21 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 22 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 23 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 24 | 25 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) 26 | { 27 | //CenterWindow(GetParent()); 28 | int nNum = lParam; 29 | std::vector vLayers = g_MapManager.GetAllLayers(); 30 | FeatureSet* pF = vLayers[nNum]->GetFeatureSet(); 31 | m_strInfo += _T("File path: "); 32 | std::vector::iterator it = std::find(g_MapManager.m_vDataReader.begin(), g_MapManager.m_vDataReader.end(), (pF->m_pDataReader)); 33 | if (it == g_MapManager.m_vDataReader.end()) 34 | return false; 35 | 36 | size_t idx = std::distance(g_MapManager.m_vDataReader.begin(), it); 37 | m_strInfo += g_MapManager.m_vFilename[idx]; 38 | m_strInfo += _T("\r\nThe number of features: "); 39 | m_strInfo += strtk::type_to_string(pF->GetFeatureSize()).c_str(); 40 | m_strInfo += _T("\r\nThe number of points: "); 41 | m_strInfo += strtk::type_to_string(pF->m_nAllCoordsNum / 2).c_str(); 42 | GetDlgItem(IDC_EDIT_LAYER_INFO).SetWindowText(m_strInfo); 43 | GetDlgItem(IDC_STATIC).SetFocus(); 44 | return FALSE; 45 | } 46 | 47 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 48 | { 49 | EndDialog(wID); 50 | return 0; 51 | } 52 | }; 53 | -------------------------------------------------------------------------------- /TXDViewer2/MruList.h: -------------------------------------------------------------------------------- 1 | // list.h : interface of the CMruList class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef __LIST_H__ 6 | #define __LIST_H__ 7 | 8 | #if _MSC_VER >= 1000 9 | #pragma once 10 | #endif // _MSC_VER >= 1000 11 | 12 | 13 | class CMruList : public CWindowImpl 14 | { 15 | public: 16 | SIZE m_size; 17 | 18 | 19 | CMruList() 20 | { 21 | m_size.cx = 300; 22 | m_size.cy = 180; 23 | } 24 | 25 | HWND Create(HWND hWndParent) 26 | { 27 | CWindowImpl::Create(hWndParent, rcDefault, NULL, 28 | WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | LBS_NOINTEGRALHEIGHT, 29 | WS_EX_CLIENTEDGE); 30 | if(IsWindow()) 31 | SetFont(AtlGetStockFont(DEFAULT_GUI_FONT)); 32 | return m_hWnd; 33 | } 34 | 35 | BOOL BuildList(CRecentDocumentList& mru) 36 | { 37 | ATLASSERT(IsWindow()); 38 | 39 | ResetContent(); 40 | 41 | int nSize = mru.m_arrDocs.GetSize(); 42 | for(int i = 0; i < nSize; i++) 43 | InsertString(0, mru.m_arrDocs[i].szDocName); // docs are in reversed order in the array 44 | 45 | if(nSize > 0) 46 | { 47 | SetCurSel(0); 48 | SetTopIndex(0); 49 | } 50 | 51 | return TRUE; 52 | } 53 | 54 | BOOL ShowList(int x, int y) 55 | { 56 | return SetWindowPos(NULL, x, y, m_size.cx, m_size.cy, SWP_NOZORDER | SWP_SHOWWINDOW); 57 | } 58 | 59 | void HideList() 60 | { 61 | RECT rect; 62 | GetWindowRect(&rect); 63 | m_size.cx = rect.right - rect.left; 64 | m_size.cy = rect.bottom - rect.top; 65 | ShowWindow(SW_HIDE); 66 | } 67 | 68 | void FireCommand() 69 | { 70 | int nSel = GetCurSel(); 71 | if(nSel != LB_ERR) 72 | { 73 | ::SetFocus(GetParent()); // will hide this window 74 | ::SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM((WORD)(ID_FILE_MRU_FIRST + nSel), LBN_DBLCLK), (LPARAM)m_hWnd); 75 | } 76 | } 77 | 78 | BEGIN_MSG_MAP(CMruList) 79 | MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) 80 | MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk) 81 | MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) 82 | MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest) 83 | END_MSG_MAP() 84 | 85 | LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) 86 | { 87 | if(wParam == VK_RETURN) 88 | FireCommand(); 89 | else 90 | bHandled = FALSE; 91 | return 0; 92 | } 93 | 94 | LRESULT OnLButtonDblClk(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 95 | { 96 | FireCommand(); 97 | return 0; 98 | } 99 | 100 | LRESULT OnKillFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 101 | { 102 | HideList(); 103 | return 0; 104 | } 105 | 106 | LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) 107 | { 108 | LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); 109 | switch(lRet) 110 | { 111 | case HTLEFT: 112 | case HTTOP: 113 | case HTTOPLEFT: 114 | case HTTOPRIGHT: 115 | case HTBOTTOMLEFT: 116 | lRet = HTCLIENT; // don't allow resizing here 117 | break; 118 | default: 119 | break; 120 | } 121 | return lRet; 122 | } 123 | }; 124 | 125 | #endif // __LIST_H__ 126 | -------------------------------------------------------------------------------- /TXDViewer2/SplitterBar.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SPLITTER_H__20030708_C845_A999_1D3A_0080AD509054__INCLUDED_) 2 | #define AFX_SPLITTER_H__20030708_C845_A999_1D3A_0080AD509054__INCLUDED_ 3 | 4 | #pragma once 5 | 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // CSplitterBar - Splitter control (not a container) 8 | // 9 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 10 | // Copyright (c) 2003 Bjarke Viksoe. 11 | // 12 | // This code may be used in compiled form in any way you desire. This 13 | // source file may be redistributed by any means PROVIDING it is 14 | // not sold for profit without the authors written consent, and 15 | // providing that this notice and the authors name is included. 16 | // 17 | // This file is provided "as is" with no expressed or implied warranty. 18 | // The author accepts no liability if it causes any damage to you or your 19 | // computer whatsoever. It's free, so don't hassle me about it. 20 | // 21 | // Beware of bugs. 22 | // 23 | 24 | #ifndef __cplusplus 25 | #error ATL requires C++ compilation (use a .cpp suffix) 26 | #endif 27 | 28 | #ifndef __ATLAPP_H__ 29 | #error This control requires atlapp.h to be included first 30 | #endif 31 | 32 | #ifndef __ATLCTRLS_H__ 33 | #error This control requires atlctrls.h to be included first 34 | #endif 35 | 36 | 37 | template< class T, bool t_bVertical = true, class TBase = CWindow, class TWinTraits = CControlWinTraits > 38 | class ATL_NO_VTABLE CSplitterBarImpl : 39 | public CWindowImpl< T, TBase, TWinTraits > 40 | { 41 | public: 42 | DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName()) 43 | 44 | typedef CSplitterBarImpl thisClass; 45 | 46 | CWindow m_wndTop; 47 | CWindow m_wndBottom; 48 | BOOL m_bFullDrag; 49 | SIZE m_szGutter; 50 | static HCURSOR s_hCursor; 51 | RECT m_rcSplitterPos; 52 | int m_xySplitterPos; 53 | SIZE m_szLimits; 54 | 55 | // Operations 56 | 57 | BOOL SubclassWindow(HWND hWnd) 58 | { 59 | ATLASSERT(m_hWnd==NULL); 60 | ATLASSERT(::IsWindow(hWnd)); 61 | BOOL bRet = CWindowImpl< T, TBase, TWinTraits >::SubclassWindow(hWnd); 62 | if( bRet ) _Init(); 63 | return bRet; 64 | } 65 | 66 | void SetSplitterPanes(HWND hWndTop, HWND hWndBottom) 67 | { 68 | ATLASSERT(::IsWindow(m_hWnd)); 69 | ATLASSERT(::IsWindow(hWndTop)); 70 | ATLASSERT(::IsWindow(hWndBottom)); 71 | m_wndTop = hWndTop; 72 | m_wndBottom = hWndBottom; 73 | RECT rcTop; 74 | RECT rcBottom; 75 | m_wndTop.GetWindowRect(&rcTop); 76 | m_wndBottom.GetWindowRect(&rcBottom); 77 | RECT rcSplitter = { 0 }; 78 | if( t_bVertical ) ::SetRect(&rcSplitter, rcTop.right, rcTop.top, rcBottom.left, rcBottom.bottom); 79 | else ::SetRect(&rcSplitter, rcTop.left, rcTop.bottom, rcTop.right, rcBottom.top); 80 | ::MapWindowPoints(NULL, GetParent(), (LPPOINT) &rcSplitter, 2); 81 | MoveWindow(&rcSplitter); 82 | } 83 | void SetGutterSize(int cxTop, int cxBottom) 84 | { 85 | m_szGutter.cx = cxTop; 86 | m_szGutter.cy = cxBottom: 87 | } 88 | void SetSplitterSize(int cx) 89 | { 90 | ATLASSERT(::IsWindow(m_hWnd)); 91 | ResizeClient(t_bVertical ? cx : -1, t_bVertical ? -1 : cx); 92 | T* pT = static_cast(this); 93 | pT->UpdateSplitterLayout(); 94 | } 95 | 96 | void UpdateSplitterLayout() 97 | { 98 | ATLASSERT(::IsWindow(m_hWnd)); 99 | RECT rcClient; 100 | RECT rcTop; 101 | RECT rcBottom; 102 | GetWindowRect(&rcClient); 103 | m_wndTop.GetWindowRect(&rcTop); 104 | m_wndBottom.GetWindowRect(&rcBottom); 105 | if( t_bVertical ) { 106 | rcTop.right = rcClient.left; 107 | rcBottom.left = rcClient.right; 108 | } 109 | else { 110 | rcTop.bottom = rcClient.top; 111 | rcBottom.top = rcClient.bottom; 112 | } 113 | ::MapWindowPoints(NULL, GetParent(), (LPPOINT) &rcTop, 2); 114 | ::MapWindowPoints(NULL, GetParent(), (LPPOINT) &rcBottom, 2); 115 | m_wndTop.SetWindowPos(NULL, &rcTop, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 116 | m_wndBottom.SetWindowPos(NULL, &rcBottom, SWP_NOACTIVATE | SWP_NOZORDER); 117 | ::UpdateWindow(GetParent()); 118 | } 119 | 120 | // Implementation 121 | 122 | void _Init() 123 | { 124 | ATLASSERT(::IsWindow(m_hWnd)); 125 | 126 | if( s_hCursor == NULL ) { 127 | ::EnterCriticalSection(&_Module.m_csStaticDataInit); 128 | if( s_hCursor == NULL ) s_hCursor = ::LoadCursor(NULL, t_bVertical ? IDC_SIZEWE : IDC_SIZENS); 129 | ::LeaveCriticalSection(&_Module.m_csStaticDataInit); 130 | } 131 | 132 | // HACK: If subclassed as label, we need mouse notifications! 133 | ModifyStyle(0, SS_NOTIFY); 134 | 135 | ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bFullDrag, 0); 136 | 137 | m_szGutter.cx = 14; 138 | m_szGutter.cy = 14; 139 | } 140 | 141 | void _DrawGhostBar() 142 | { 143 | if( m_bFullDrag ) return; 144 | RECT rect; 145 | GetClientRect(&rect); 146 | // Invert the brush pattern (looks just like frame window sizing) 147 | T* pT = static_cast(this); 148 | CWindowDC dc(pT->m_hWnd); 149 | CBrush brush = CDCHandle::GetHalftoneBrush(); 150 | if( !brush.IsNull() ) { 151 | CBrushHandle brushOld = dc.SelectBrush(brush); 152 | dc.PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); 153 | dc.SelectBrush(brushOld); 154 | } 155 | } 156 | 157 | // Message map and handlers 158 | 159 | BEGIN_MSG_MAP( thisClass ) 160 | MESSAGE_HANDLER(WM_CREATE, OnCreate) 161 | MESSAGE_HANDLER(WM_PAINT, OnPaint) 162 | MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) 163 | MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) 164 | MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) 165 | MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) 166 | MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) 167 | END_MSG_MAP() 168 | 169 | LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) 170 | { 171 | LRESULT lRes = DefWindowProc(uMsg, wParam, lParam); 172 | _Init(); 173 | return lRes; 174 | } 175 | LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 176 | { 177 | T* pT = static_cast(this); 178 | CPaintDC dc(pT->m_hWnd); 179 | RECT rcClient; 180 | GetClientRect(&rcClient); 181 | if( (GetStyle() & SS_TYPEMASK) == SS_OWNERDRAW ) { 182 | DRAWITEMSTRUCT dis = { 0 }; 183 | dis.CtlID = GetDlgCtrlID(); 184 | dis.CtlType = ODT_STATIC; 185 | dis.itemAction = ODA_DRAWENTIRE; 186 | dis.hwndItem = m_hWnd; 187 | dis.hDC = dc; 188 | dis.itemID = 0; 189 | dis.itemState = 0; 190 | if( GetCapture() == m_hWnd ) dis.itemState |= ODS_SELECTED; 191 | dis.rcItem = rcClient; 192 | ::SendMessage(GetParent(), WM_DRAWITEM, (WPARAM) dis.CtlID, (LPARAM) &dis); 193 | } 194 | else 195 | { 196 | dc.FillRect(&rcClient, ::GetSysColorBrush(COLOR_3DFACE)); 197 | } 198 | return 0; 199 | } 200 | LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 201 | { 202 | T* pT = static_cast(this); 203 | if( (HWND) wParam == pT->m_hWnd && LOWORD(lParam) == HTCLIENT ) return 1; 204 | bHandled = FALSE; 205 | return 0; 206 | } 207 | LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 208 | { 209 | T* pT = static_cast(this); 210 | if( (wParam & MK_LBUTTON) != 0 && ::GetCapture() == pT->m_hWnd ) { 211 | lParam = ::GetMessagePos(); 212 | int xPos = GET_X_LPARAM(lParam); 213 | int yPos = GET_Y_LPARAM(lParam); 214 | int xyNewSplitPos = t_bVertical ? xPos : yPos; 215 | int cxySplitter = t_bVertical ? (m_rcSplitterPos.right - m_rcSplitterPos.left) : (m_rcSplitterPos.bottom - m_rcSplitterPos.top); 216 | xyNewSplitPos = xyNewSplitPos > m_szLimits.cx ? xyNewSplitPos : m_szLimits.cx; 217 | xyNewSplitPos = xyNewSplitPos < m_szLimits.cy ? xyNewSplitPos : m_szLimits.cy; 218 | if( m_xySplitterPos != xyNewSplitPos ) { 219 | _DrawGhostBar(); 220 | int iDiff = xyNewSplitPos - m_xySplitterPos; 221 | RECT rcClient = m_rcSplitterPos; 222 | ::OffsetRect(&rcClient, t_bVertical ? iDiff : 0, t_bVertical ? 0 : iDiff); 223 | ::MapWindowPoints(NULL, GetParent(), (LPPOINT) &rcClient, 2); 224 | Invalidate(); 225 | SetWindowPos(HWND_TOP, &rcClient, SWP_NOACTIVATE); 226 | Invalidate(); 227 | if( m_bFullDrag ) pT->UpdateSplitterLayout(); 228 | _DrawGhostBar(); 229 | } 230 | } 231 | ::SetCursor(s_hCursor); 232 | bHandled = FALSE; 233 | return 1; 234 | } 235 | LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) 236 | { 237 | T* pT = static_cast(this); 238 | pT->SetCapture(); 239 | ::SetCursor(s_hCursor); 240 | _DrawGhostBar(); 241 | lParam = ::GetMessagePos(); 242 | int xPos = GET_X_LPARAM(lParam); 243 | int yPos = GET_Y_LPARAM(lParam); 244 | GetWindowRect(&m_rcSplitterPos); 245 | m_xySplitterPos = t_bVertical ? xPos : yPos; 246 | RECT rcTop; 247 | RECT rcBottom; 248 | m_wndTop.GetWindowRect(&rcTop); 249 | m_wndBottom.GetWindowRect(&rcBottom); 250 | if( t_bVertical ) { 251 | m_szLimits.cx = rcTop.left + m_szGutter.cx; 252 | m_szLimits.cy = rcBottom.right - m_szGutter.cy; 253 | } 254 | else { 255 | m_szLimits.cx = rcTop.top + m_szGutter.cx; 256 | m_szLimits.cy = rcBottom.bottom - m_szGutter.cy; 257 | } 258 | bHandled = FALSE; 259 | return 1; 260 | } 261 | LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) 262 | { 263 | _DrawGhostBar(); 264 | if( !m_bFullDrag ) { 265 | T* pT = static_cast(this); 266 | pT->UpdateSplitterLayout(); 267 | ::UpdateWindow(GetParent()); 268 | } 269 | ::ReleaseCapture(); 270 | bHandled = FALSE; 271 | return 1; 272 | } 273 | }; 274 | 275 | template< class T, bool t_bVertical, class TBase, class TWinTraits > HCURSOR CSplitterBarImpl< T, t_bVertical, TBase, TWinTraits>::s_hCursor = NULL; 276 | 277 | class CVertSplitterCtrl : public CSplitterBarImpl 278 | { 279 | public: 280 | DECLARE_WND_SUPERCLASS(_T("WTL_VertSplitterBar"), GetWndClassName()) 281 | }; 282 | 283 | class CHorSplitterCtrl : public CSplitterBarImpl 284 | { 285 | public: 286 | DECLARE_WND_SUPERCLASS(_T("WTL_HorSplitterBar"), GetWndClassName()) 287 | }; 288 | 289 | 290 | #endif // !defined(AFX_SPLITTER_H__20030708_C845_A999_1D3A_0080AD509054__INCLUDED_) 291 | 292 | -------------------------------------------------------------------------------- /TXDViewer2/TXDViewer2.cpp: -------------------------------------------------------------------------------- 1 | // TXDViewer2.cpp : main source file for TXDViewer.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "IdentifyDlg.h" 7 | #include "LocateDlg.h" 8 | #include "MetaInfoDlg.h" 9 | #include "FileManagerDlg.h" 10 | #include "dbprops.h" 11 | #include "TXDViewer2View.h" 12 | #include "aboutdlg.h" 13 | #include "ParseFeatureSet.h" 14 | #include "ConnectDBDlg.h" 15 | #include "MruList.h" 16 | #include "MainFrm.h" 17 | 18 | CAppModule _Module; 19 | MapManager g_MapManager; 20 | 21 | int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) 22 | { 23 | CMessageLoop theLoop; 24 | _Module.AddMessageLoop(&theLoop); 25 | 26 | CMainFrame wndMain; 27 | if(wndMain.CreateEx(NULL, NULL, 0, 0, NULL) == NULL) 28 | { 29 | ATLTRACE(_T("Main window creation failed!\n")); 30 | return 0; 31 | } 32 | 33 | wndMain.ShowWindow(nCmdShow); 34 | 35 | int nRet = theLoop.Run(); 36 | 37 | _Module.RemoveMessageLoop(); 38 | return nRet; 39 | } 40 | 41 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) 42 | { 43 | HRESULT hRes = ::CoInitialize(NULL); 44 | // If you are running on NT 4.0 or higher you can use the following call instead to 45 | // make the EXE free threaded. This means that calls come in on a random RPC thread. 46 | // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); 47 | ATLASSERT(SUCCEEDED(hRes)); 48 | 49 | // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used 50 | ::DefWindowProc(NULL, 0, 0, 0L); 51 | 52 | AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls 53 | 54 | hRes = _Module.Init(NULL, hInstance); 55 | ATLASSERT(SUCCEEDED(hRes)); 56 | 57 | int nRet = Run(lpstrCmdLine, nCmdShow); 58 | 59 | _Module.Term(); 60 | ::CoUninitialize(); 61 | return nRet; 62 | } 63 | -------------------------------------------------------------------------------- /TXDViewer2/TXDViewer2.h: -------------------------------------------------------------------------------- 1 | // TXDViewer2.h 2 | -------------------------------------------------------------------------------- /TXDViewer2/TXDViewer2.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 24 | 27 | 30 | 33 | 36 | 48 | 60 | 63 | 69 | 72 | 79 | 82 | 85 | 88 | 91 | 94 | 97 | 100 | 103 | 104 | 112 | 115 | 118 | 121 | 124 | 136 | 145 | 148 | 154 | 157 | 163 | 166 | 169 | 172 | 175 | 178 | 181 | 184 | 187 | 188 | 189 | 190 | 191 | 192 | 196 | 199 | 202 | 206 | 207 | 210 | 214 | 215 | 216 | 219 | 220 | 221 | 225 | 228 | 229 | 232 | 233 | 236 | 237 | 240 | 241 | 244 | 245 | 248 | 249 | 252 | 253 | 256 | 257 | 260 | 261 | 264 | 265 | 268 | 269 | 272 | 273 | 274 | 278 | 281 | 282 | 285 | 286 | 289 | 290 | 291 | 294 | 297 | 298 | 301 | 302 | 305 | 306 | 307 | 310 | 311 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /TXDViewer2/TXDViewer2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {2470a5c0-9bac-4e81-a35e-1004cdab04fa} 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;manifest 7 | 8 | 9 | {a8e4da4b-c405-4ba9-8730-bfc08915b4f5} 10 | 11 | 12 | {c58cb262-09c1-4127-ae8e-379756041a05} 13 | 14 | 15 | {d1365b0b-cb3b-46ef-9e38-8629278b09f3} 16 | 17 | 18 | {db7c94a1-e5b9-4eef-a1e8-70d3d60e50a4} 19 | 20 | 21 | {f65c3190-ca0d-4610-b51c-82e2b48b8ad4} 22 | cpp;c;cxx;def;odl;idl;hpj;bat;asm 23 | 24 | 25 | {813d5cf1-387b-4200-b418-fff6a23c7f8a} 26 | h;hpp;hxx;hm;inl;inc 27 | 28 | 29 | 30 | 31 | Main Files 32 | 33 | 34 | Main Files 35 | 36 | 37 | GeoData 38 | 39 | 40 | MapManager 41 | 42 | 43 | MapManager 44 | 45 | 46 | DataParser 47 | 48 | 49 | DataParser 50 | 51 | 52 | GeoData 53 | 54 | 55 | GeoData 56 | 57 | 58 | GeoData 59 | 60 | 61 | 62 | 63 | UI 64 | 65 | 66 | UI 67 | 68 | 69 | UI 70 | 71 | 72 | UI 73 | 74 | 75 | UI 76 | 77 | 78 | UI 79 | 80 | 81 | UI 82 | 83 | 84 | UI 85 | 86 | 87 | GeoData 88 | 89 | 90 | GeoData 91 | 92 | 93 | GeoData 94 | 95 | 96 | MapManager 97 | 98 | 99 | GeoRender 100 | 101 | 102 | MapManager 103 | 104 | 105 | DataParser 106 | 107 | 108 | DataParser 109 | 110 | 111 | DataParser 112 | 113 | 114 | UI 115 | 116 | 117 | UI 118 | 119 | 120 | DataParser 121 | 122 | 123 | GeoData 124 | 125 | 126 | UI 127 | 128 | 129 | UI 130 | 131 | 132 | UI 133 | 134 | 135 | GeoData 136 | 137 | 138 | DataParser 139 | 140 | 141 | UI 142 | 143 | 144 | UI 145 | 146 | 147 | 148 | 149 | Resource Files 150 | 151 | 152 | Resource Files 153 | 154 | 155 | Resource Files 156 | 157 | 158 | Resource Files 159 | 160 | 161 | Resource Files 162 | 163 | 164 | Resource Files 165 | 166 | 167 | Resource Files 168 | 169 | 170 | Resource Files 171 | 172 | 173 | Resource Files 174 | 175 | 176 | Resource Files 177 | 178 | 179 | 180 | 181 | Resource Files 182 | 183 | 184 | 185 | 186 | Resource Files 187 | 188 | 189 | Resource Files 190 | 191 | 192 | Resource Files 193 | 194 | 195 | -------------------------------------------------------------------------------- /TXDViewer2/Thread.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_THREAD_H__20000927_7992_09B2_A0EF_0080AD509054__INCLUDED_) 2 | #define AFX_THREAD_H__20000927_7992_09B2_A0EF_0080AD509054__INCLUDED_ 3 | 4 | #pragma once 5 | 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // Thread - wrapper for Thread API 8 | // 9 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 10 | // 11 | // This code may be used in compiled form in any way you desire. This 12 | // source file may be redistributed by any means PROVIDING it is 13 | // not sold for profit without the authors written consent, and 14 | // providing that this notice and the authors name is included. 15 | // 16 | // This file is provided "as is" with no expressed or implied warranty. 17 | // The author accepts no liability if it causes any damage to you or your 18 | // computer whatsoever. It's free, so don't hassle me about it. 19 | // 20 | // Beware of bugs. 21 | // 22 | 23 | #if defined(_MT) || defined(_DLL) 24 | // Due to the nature of the multithreaded C runtime lib we 25 | // need to use _beginthreadex() and _endthreadex() instead 26 | // of CreateThread() and ExitThread(). See Q104641. 27 | #include 28 | #endif // _MT 29 | 30 | #ifndef ATLTRY 31 | #define ATLTRY(x) (x) 32 | #endif // ATLTRY 33 | 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | // CThread 37 | 38 | template< bool t_bManaged > 39 | class CThreadT 40 | { 41 | public: 42 | HANDLE m_hThread; // Handle to thread 43 | DWORD m_dwThreadID; // Thread ID 44 | bool m_bSuspended; // Thread currently suspended? 45 | 46 | CThreadT(HANDLE hThread = NULL) : m_hThread(hThread), m_dwThreadID(0), m_bSuspended(false) 47 | { 48 | } 49 | 50 | ~CThreadT() 51 | { 52 | if( t_bManaged ) Release(); 53 | } 54 | 55 | // Operations 56 | 57 | BOOL Create(LPTHREAD_START_ROUTINE pThreadProc, LPVOID pParam = NULL, int iPriority = THREAD_PRIORITY_NORMAL) 58 | { 59 | _ASSERTE(m_hThread==NULL); 60 | _ASSERTE(pThreadProc); 61 | #if defined(_MT) || defined(_DLL) 62 | m_hThread = (HANDLE) _beginthreadex(NULL, 0, (UINT (WINAPI*)(void*)) pThreadProc, pParam, CREATE_SUSPENDED, (UINT*) &m_dwThreadID); 63 | #else 64 | m_hThread = ::CreateThread(NULL, 0, pThreadProc, pParam, CREATE_SUSPENDED, &m_dwThreadID); 65 | #endif // _MT 66 | if( m_hThread == NULL ) return FALSE; 67 | if( iPriority != THREAD_PRIORITY_NORMAL ) { 68 | if( !::SetThreadPriority(m_hThread, iPriority) ) { 69 | _ASSERTE(!"Couldn't set thread priority"); 70 | } 71 | } 72 | return ::ResumeThread(m_hThread) != (DWORD) -1; 73 | } 74 | 75 | BOOL Release() 76 | { 77 | if( m_hThread == NULL ) return TRUE; 78 | if( ::CloseHandle(m_hThread) == FALSE ) return FALSE; 79 | m_hThread = NULL; 80 | return TRUE; 81 | } 82 | 83 | void Attach(HANDLE hThread) 84 | { 85 | _ASSERTE(m_hThread==NULL); 86 | m_hThread = hThread; 87 | } 88 | 89 | HANDLE Detach() 90 | { 91 | HANDLE hThread = m_hThread; 92 | m_hThread = NULL; 93 | return hThread; 94 | } 95 | 96 | BOOL SetPriority(int iPriority) const 97 | { 98 | _ASSERTE(m_hThread); 99 | return ::SetThreadPriority(m_hThread, iPriority); 100 | } 101 | 102 | int GetPriority() const 103 | { 104 | _ASSERTE(m_hThread); 105 | return ::GetThreadPriority(m_hThread); 106 | } 107 | 108 | BOOL Suspend() 109 | { 110 | _ASSERTE(m_hThread); 111 | if( m_bSuspended ) return TRUE; 112 | if( ::SuspendThread(m_hThread) == (DWORD) -1 ) return FALSE; 113 | m_bSuspended = true; 114 | return TRUE; 115 | } 116 | 117 | BOOL Resume() 118 | { 119 | _ASSERTE(m_hThread); 120 | if( !m_bSuspended ) return TRUE; 121 | if( ::ResumeThread(m_hThread) == (DWORD) -1 ) return FALSE; 122 | m_bSuspended = false; 123 | return TRUE; 124 | } 125 | 126 | BOOL IsSuspended() const 127 | { 128 | _ASSERTE(m_hThread); 129 | return m_bSuspended == true; 130 | } 131 | 132 | BOOL IsRunning() const 133 | { 134 | if( m_hThread == NULL ) return FALSE; 135 | DWORD dwCode = 0; 136 | ::GetExitCodeThread(m_hThread, &dwCode); 137 | return dwCode == STILL_ACTIVE; 138 | } 139 | 140 | BOOL WaitForThread(DWORD dwTimeout = INFINITE) const 141 | { 142 | _ASSERTE(m_hThread); 143 | return ::WaitForSingleObject(m_hThread, dwTimeout) == WAIT_OBJECT_0; 144 | } 145 | 146 | BOOL Terminate(DWORD dwExitCode = 0) const 147 | { 148 | // See Q254956 why calling this could be a bad idea! 149 | _ASSERTE(m_hThread); 150 | return ::TerminateThread(m_hThread, dwExitCode); 151 | } 152 | 153 | DWORD GetThreadID() const 154 | { 155 | return m_dwThreadID; 156 | } 157 | 158 | BOOL GetExitCode(DWORD* pExitCode) const 159 | { 160 | _ASSERTE(m_hThread); 161 | _ASSERTE(pExitCode); 162 | return ::GetExitCodeThread(m_hThread, pExitCode); 163 | } 164 | 165 | #if(WINVER >= 0x0500) 166 | 167 | BOOL GetThreadTimes(LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime) const 168 | { 169 | _ASSERTE(m_hThread); 170 | _ASSERTE(lpExitTime!=NULL && lpKernelTime!=NULL && lpUserTime!=NULL); 171 | return ::GetThreadTimes(m_hThread, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime); 172 | } 173 | 174 | #endif // WINVER 175 | 176 | #if(WINVER >= 0x0501) 177 | 178 | BOOL SetThreadAffinityMask(DWORD dwThreadMask) 179 | { 180 | _ASSERTE(m_hThread); 181 | return ::SetThreadAffinityMask(m_hThread, dwThreadMask) != 0; 182 | } 183 | 184 | BOOL SetThreadIdealProcessor(DWORD dwIdealProcessor) 185 | { 186 | _ASSERTE(m_hThread); 187 | return ::SetThreadIdealProcessor(m_hThread, dwIdealProcessor) != (DWORD) -1; 188 | } 189 | 190 | DWORD GetThreadIdealProcessor() const 191 | { 192 | _ASSERTE(m_hThread); 193 | return ::SetThreadIdealProcessor(m_hThread, MAXIMUM_PROCESSORS); 194 | } 195 | 196 | #endif // WINVER 197 | 198 | operator HANDLE() const 199 | { 200 | return m_hThread; 201 | } 202 | }; 203 | 204 | typedef CThreadT CThreadHandle; 205 | typedef CThreadT CThread; 206 | 207 | 208 | ///////////////////////////////////////////////////////////////////////////// 209 | // Thread Stop policy 210 | 211 | class CThreadStopAtBool 212 | { 213 | public: 214 | volatile bool m_bStopped; 215 | CThreadStopAtBool() : m_bStopped(false) { }; 216 | BOOL _ClearAbort() { m_bStopped = false; return TRUE; }; 217 | BOOL _Abort() { m_bStopped = true; return TRUE; }; 218 | BOOL _IsAborted() const { return m_bStopped == true; }; 219 | }; 220 | 221 | class CThreadStopAtEvent 222 | { 223 | public: 224 | HANDLE m_hStopEvent; 225 | CThreadStopAtEvent() { m_hStopEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); }; 226 | ~CThreadStopAtEvent() { ::CloseHandle(m_hStopEvent); }; 227 | BOOL _ClearAbort() { return ::ResetEvent(m_hStopEvent); }; 228 | BOOL _Abort() { return ::SetEvent(m_hStopEvent); }; 229 | BOOL _IsAborted() const { return ::WaitForSingleObject(m_hStopEvent, 0) != WAIT_TIMEOUT; }; 230 | }; 231 | 232 | 233 | ///////////////////////////////////////////////////////////////////////////// 234 | // CThreadImpl 235 | 236 | template< typename T, typename TStopPolicy = CThreadStopAtBool > 237 | class CThreadImpl : public CThread, public TStopPolicy 238 | { 239 | public: 240 | bool m_bAutoDelete; // Thread class will delete itself upon thread exit? 241 | bool m_bAutoCleanup; // Thread class will wait for thread completion upon scope exit? 242 | 243 | CThreadImpl() : m_bAutoDelete(false), m_bAutoCleanup(true) 244 | { 245 | } 246 | 247 | virtual ~CThreadImpl() 248 | { 249 | if( m_bAutoCleanup ) Stop(); 250 | } 251 | 252 | // Operations 253 | 254 | BOOL Start() 255 | { 256 | if( !_ClearAbort() ) return FALSE; 257 | if( !Create(ThreadProc, (LPVOID) static_cast(this)) ) return FALSE; 258 | return TRUE; 259 | } 260 | 261 | void Stop() 262 | { 263 | if( !Abort() ) return; 264 | WaitForThread(); 265 | Release(); 266 | } 267 | 268 | BOOL Abort() 269 | { 270 | if( m_hThread == NULL ) return FALSE; 271 | if( !_Abort() ) return FALSE; 272 | if( m_bSuspended ) Resume(); 273 | return TRUE; 274 | } 275 | 276 | BOOL IsAborted() const 277 | { 278 | _ASSERTE(m_hThread); 279 | return _IsAborted(); 280 | } 281 | 282 | void SetAutoClean(bool bAutoClean = true) 283 | { 284 | m_bAutoCleanup = bAutoClean; 285 | } 286 | 287 | void SetDeleteOnExit(bool bAutoDelete = true) 288 | { 289 | m_bAutoDelete = bAutoDelete; 290 | m_bAutoCleanup = !bAutoDelete; 291 | } 292 | 293 | // Static members 294 | 295 | static DWORD WINAPI ThreadProc(LPVOID pData) 296 | { 297 | T* pThis = static_cast(pData); 298 | DWORD dwRet = 0; 299 | ATLTRY( dwRet = pThis->Run() ); 300 | pThis->m_dwThreadID = 0; 301 | if( pThis->m_bAutoDelete ) delete pThis; 302 | #if defined(_MT) || defined(_DLL) 303 | _endthreadex(dwRet); 304 | #else 305 | ::ExitThread(dwRet); 306 | #endif // _MT 307 | return dwRet; 308 | } 309 | 310 | // Overridables 311 | 312 | DWORD Run() 313 | { 314 | _ASSERTE(false); // must override this 315 | // 316 | // Sample thread loop... 317 | // 318 | // while( !IsAborted() ) { 319 | // ... 320 | // } 321 | // 322 | return 0; 323 | } 324 | }; 325 | 326 | 327 | ///////////////////////////////////////////////////////////////////////////// 328 | // CMessageThreadImpl 329 | 330 | template< typename T > 331 | class CMessageThreadImpl : public CThreadImpl 332 | { 333 | public: 334 | HANDLE m_hStartEvent; 335 | 336 | // Operations 337 | 338 | BOOL Start() 339 | { 340 | m_hStartEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); 341 | BOOL bRes = CThreadImpl::Start(); 342 | if( bRes ) ::WaitForSingleObject(m_hStartEvent, INFINITE); 343 | ::CloseHandle(m_hStartEvent); 344 | return bRes; 345 | } 346 | 347 | BOOL PostQuitMessage() 348 | { 349 | _ASSERTE(m_dwThreadID); 350 | return ::PostThreadMessage(m_dwThreadID, WM_QUIT, 0, 0L); 351 | } 352 | 353 | BOOL PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L) 354 | { 355 | _ASSERTE(m_dwThreadID); 356 | return ::PostThreadMessage(m_dwThreadID, uMsg, wParam, lParam); 357 | } 358 | 359 | // Overridables 360 | 361 | void OnInitQueue() 362 | { 363 | ::SetEvent(m_hStartEvent); 364 | } 365 | 366 | void OnCloseQueue() 367 | { 368 | } 369 | 370 | void ProcessWindowMessage(LPVOID /*pReserved*/, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& /*lResult*/, DWORD /*dwReserved*/) 371 | { 372 | _ASSERTE(false); // must override this; perhaps implement through an ATL message map 373 | } 374 | 375 | // Implementation 376 | 377 | DWORD Run() 378 | { 379 | T* pT = static_cast(this); pT; 380 | MSG msg = { 0 }; 381 | ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); 382 | pT->OnInitQueue(); 383 | while( true ) { 384 | DWORD dwRes = ::MsgWaitForMultipleObjectsEx(1, &m_hStopEvent, INFINITE, QS_ALLINPUT, MWMO_INPUTAVAILABLE); 385 | if( dwRes != WAIT_OBJECT_0 + 1 ) break; 386 | int iRet = (int) ::GetMessage(&msg, NULL, 0, 0); 387 | if( iRet <= 0 ) break; 388 | LRESULT lResult = 0; 389 | pT->ProcessWindowMessage(NULL, msg.message, msg.wParam, msg.lParam, lResult, 0L); 390 | } 391 | pT->OnCloseQueue(); 392 | return 0; 393 | } 394 | }; 395 | 396 | 397 | ///////////////////////////////////////////////////////////////////////////// 398 | // CEvent 399 | 400 | class CEvent 401 | { 402 | public: 403 | HANDLE m_hEvent; 404 | 405 | CEvent(HANDLE hEvent = INVALID_HANDLE_VALUE) : m_hEvent(hEvent) 406 | { 407 | } 408 | 409 | ~CEvent() 410 | { 411 | Close(); 412 | } 413 | 414 | BOOL Create(LPCTSTR pstrName = NULL, BOOL bManualReset = FALSE, BOOL bInitialState = FALSE, LPSECURITY_ATTRIBUTES pEventAttributes = NULL) 415 | { 416 | _ASSERTE(pstrName==NULL || !::IsBadStringPtr(pstrName,(UINT)-1)); 417 | _ASSERTE(m_hEvent==INVALID_HANDLE_VALUE); 418 | m_hEvent = ::CreateEvent(pEventAttributes, bManualReset, bInitialState, pstrName); 419 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 420 | return m_hEvent != INVALID_HANDLE_VALUE; 421 | } 422 | 423 | BOOL Open(LPCTSTR pstrName, DWORD dwDesiredAccess = EVENT_ALL_ACCESS, BOOL bInheritHandle = TRUE) 424 | { 425 | _ASSERTE(!::IsBadStringPtr(pstrName,(UINT)-1)); 426 | _ASSERTE(m_hEvent==INVALID_HANDLE_VALUE); 427 | m_hEvent = ::OpenEvent(dwDesiredAccess, bInheritHandle, pstrName); 428 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 429 | return m_hEvent != INVALID_HANDLE_VALUE; 430 | } 431 | 432 | BOOL IsOpen() const 433 | { 434 | return m_hEvent != INVALID_HANDLE_VALUE; 435 | } 436 | 437 | void Close() 438 | { 439 | if( m_hEvent == INVALID_HANDLE_VALUE ) return; 440 | ::CloseHandle(m_hEvent); 441 | m_hEvent = INVALID_HANDLE_VALUE; 442 | } 443 | 444 | void Attach(HANDLE hEvent) 445 | { 446 | _ASSERTE(m_hEvent==INVALID_HANDLE_VALUE); 447 | m_hEvent= hEvent; 448 | } 449 | 450 | HANDLE Detach() 451 | { 452 | HANDLE hEvent = m_hEvent; 453 | m_hEvent = INVALID_HANDLE_VALUE; 454 | return hEvent; 455 | } 456 | 457 | BOOL ResetEvent() 458 | { 459 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 460 | return ::ResetEvent(m_hEvent); 461 | } 462 | 463 | BOOL SetEvent() 464 | { 465 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 466 | return ::SetEvent(m_hEvent); 467 | } 468 | 469 | BOOL PulseEvent() 470 | { 471 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 472 | return ::PulseEvent(m_hEvent); 473 | } 474 | 475 | BOOL IsSignalled() const 476 | { 477 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 478 | return ::WaitForSingleObject(m_hEvent, 0) == WAIT_OBJECT_0; 479 | } 480 | 481 | BOOL WaitForEvent(DWORD dwTimeout = INFINITE) 482 | { 483 | _ASSERTE(m_hEvent!=INVALID_HANDLE_VALUE); 484 | return ::WaitForSingleObject(m_hEvent, dwTimeout) == WAIT_OBJECT_0; 485 | } 486 | 487 | operator HANDLE() const 488 | { 489 | return m_hEvent; 490 | } 491 | }; 492 | 493 | 494 | ///////////////////////////////////////////////////////////////////////////// 495 | // CCriticalSection 496 | 497 | #ifndef __ATLBASE_H__ 498 | 499 | class CCriticalSection 500 | { 501 | public: 502 | CRITICAL_SECTION m_sec; 503 | 504 | void Init() 505 | { 506 | ::InitializeCriticalSection(&m_sec); 507 | } 508 | 509 | void Term() 510 | { 511 | ::DeleteCriticalSection(&m_sec); 512 | } 513 | 514 | void Lock() 515 | { 516 | ::EnterCriticalSection(&m_sec); 517 | } 518 | 519 | void Unlock() 520 | { 521 | ::LeaveCriticalSection(&m_sec); 522 | } 523 | }; 524 | 525 | class CAutoCriticalSection 526 | { 527 | public: 528 | CRITICAL_SECTION m_sec; 529 | 530 | CAutoCriticalSection() 531 | { 532 | ::InitializeCriticalSection(&m_sec); 533 | } 534 | 535 | ~CAutoCriticalSection() 536 | { 537 | ::DeleteCriticalSection(&m_sec); 538 | } 539 | 540 | void Lock() 541 | { 542 | ::EnterCriticalSection(&m_sec); 543 | } 544 | 545 | void Unlock() 546 | { 547 | ::LeaveCriticalSection(&m_sec); 548 | } 549 | }; 550 | 551 | #endif // __ATLBASE_H__ 552 | 553 | 554 | #endif // !defined(AFX_THREAD_H__20000927_7992_09B2_A0EF_0080AD509054__INCLUDED_) 555 | 556 | -------------------------------------------------------------------------------- /TXDViewer2/atlres.h: -------------------------------------------------------------------------------- 1 | // Windows Template Library - WTL version 8.1 2 | // Copyright (C) Microsoft Corporation. All rights reserved. 3 | // 4 | // This file is a part of the Windows Template Library. 5 | // The use and distribution terms for this software are covered by the 6 | // Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php) 7 | // which can be found in the file CPL.TXT at the root of this distribution. 8 | // By using this software in any fashion, you are agreeing to be bound by 9 | // the terms of this license. You must not remove this notice, or 10 | // any other, from this software. 11 | 12 | #ifndef __ATLRES_H__ 13 | #define __ATLRES_H__ 14 | 15 | #pragma once 16 | 17 | #if defined(_WIN32_WCE) && !defined(__ATLRESCE_H__) 18 | #error Use atlresCE.h instead of atlres.h for Windows CE 19 | #endif 20 | 21 | 22 | #ifdef RC_INVOKED 23 | #ifndef _INC_WINDOWS 24 | 25 | #define _INC_WINDOWS 26 | 27 | #ifndef _WIN32_WCE 28 | #define VS_VERSION_INFO 1 29 | 30 | #ifdef APSTUDIO_INVOKED 31 | #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols 32 | #endif // APSTUDIO_INVOKED 33 | 34 | #ifndef WINVER 35 | #define WINVER 0x0400 // default to Windows Version 4.0 36 | #endif // !WINVER 37 | 38 | #include 39 | 40 | // operation messages sent to DLGINIT 41 | #define LB_ADDSTRING (WM_USER+1) 42 | #define CB_ADDSTRING (WM_USER+3) 43 | #endif // !_WIN32_WCE 44 | 45 | #ifdef APSTUDIO_INVOKED 46 | #undef APSTUDIO_HIDDEN_SYMBOLS 47 | #endif // APSTUDIO_INVOKED 48 | 49 | #ifdef IDC_STATIC 50 | #undef IDC_STATIC 51 | #endif // IDC_STATIC 52 | #define IDC_STATIC (-1) 53 | 54 | #endif // !_INC_WINDOWS 55 | #endif // RC_INVOKED 56 | 57 | #ifdef APSTUDIO_INVOKED 58 | #define APSTUDIO_HIDDEN_SYMBOLS 59 | #endif // APSTUDIO_INVOKED 60 | 61 | /////////////////////////////////////////////////////////////////////////////// 62 | // ATL resource types 63 | 64 | #ifndef RC_INVOKED 65 | #define RT_DLGINIT MAKEINTRESOURCE(240) 66 | #define RT_TOOLBAR MAKEINTRESOURCE(241) 67 | #endif // RC_INVOKED 68 | 69 | /////////////////////////////////////////////////////////////////////////////// 70 | 71 | #ifdef APSTUDIO_INVOKED 72 | #undef APSTUDIO_HIDDEN_SYMBOLS 73 | #endif // APSTUDIO_INVOKED 74 | 75 | /////////////////////////////////////////////////////////////////////////////// 76 | // Standard window components 77 | 78 | #define ID_SEPARATOR 0 // special separator value 79 | #define ID_DEFAULT_PANE 0 // default status bar pane 80 | 81 | #ifndef RC_INVOKED // code only 82 | // standard control bars (IDW = window ID) 83 | #define ATL_IDW_TOOLBAR 0xE800 // main Toolbar for window 84 | #define ATL_IDW_STATUS_BAR 0xE801 // Status bar window 85 | #define ATL_IDW_COMMAND_BAR 0xE802 // Command bar window 86 | 87 | // parts of a frame window 88 | #define ATL_IDW_CLIENT 0xE900 89 | #define ATL_IDW_PANE_FIRST 0xE900 // first pane (256 max) 90 | #define ATL_IDW_PANE_LAST 0xE9FF 91 | #define ATL_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max) 92 | #define ATL_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max) 93 | 94 | #define ATL_IDW_SIZE_BOX 0xEA20 // size box for splitters 95 | #define ATL_IDW_PANE_SAVE 0xEA21 // to shift ATL_IDW_PANE_FIRST 96 | 97 | // bands for a rebar 98 | #define ATL_IDW_BAND_FIRST 0xEB00 99 | #define ATL_IDW_BAND_LAST 0xEBFF 100 | #endif // !RC_INVOKED 101 | 102 | /////////////////////////////////////////////////////////////////////////////// 103 | // Standard Commands 104 | 105 | // File commands 106 | #define ID_FILE_NEW 0xE100 107 | #define ID_FILE_OPEN 0xE101 108 | #define ID_FILE_CLOSE 0xE102 109 | #define ID_FILE_SAVE 0xE103 110 | #define ID_FILE_SAVE_AS 0xE104 111 | #define ID_FILE_PAGE_SETUP 0xE105 112 | #define ID_FILE_PRINT_SETUP 0xE106 113 | #define ID_FILE_PRINT 0xE107 114 | #define ID_FILE_PRINT_DIRECT 0xE108 115 | #define ID_FILE_PRINT_PREVIEW 0xE109 116 | #define ID_FILE_UPDATE 0xE10A 117 | #define ID_FILE_SAVE_COPY_AS 0xE10B 118 | #define ID_FILE_SEND_MAIL 0xE10C 119 | 120 | #define ID_FILE_MRU_FIRST 0xE110 121 | #define ID_FILE_MRU_FILE1 0xE110 // range - 16 max 122 | #define ID_FILE_MRU_FILE2 0xE111 123 | #define ID_FILE_MRU_FILE3 0xE112 124 | #define ID_FILE_MRU_FILE4 0xE113 125 | #define ID_FILE_MRU_FILE5 0xE114 126 | #define ID_FILE_MRU_FILE6 0xE115 127 | #define ID_FILE_MRU_FILE7 0xE116 128 | #define ID_FILE_MRU_FILE8 0xE117 129 | #define ID_FILE_MRU_FILE9 0xE118 130 | #define ID_FILE_MRU_FILE10 0xE119 131 | #define ID_FILE_MRU_FILE11 0xE11A 132 | #define ID_FILE_MRU_FILE12 0xE11B 133 | #define ID_FILE_MRU_FILE13 0xE11C 134 | #define ID_FILE_MRU_FILE14 0xE11D 135 | #define ID_FILE_MRU_FILE15 0xE11E 136 | #define ID_FILE_MRU_FILE16 0xE11F 137 | #define ID_FILE_MRU_LAST 0xE11F 138 | 139 | // Edit commands 140 | #define ID_EDIT_CLEAR 0xE120 141 | #define ID_EDIT_CLEAR_ALL 0xE121 142 | #define ID_EDIT_COPY 0xE122 143 | #define ID_EDIT_CUT 0xE123 144 | #define ID_EDIT_FIND 0xE124 145 | #define ID_EDIT_PASTE 0xE125 146 | #define ID_EDIT_PASTE_LINK 0xE126 147 | #define ID_EDIT_PASTE_SPECIAL 0xE127 148 | #define ID_EDIT_REPEAT 0xE128 149 | #define ID_EDIT_REPLACE 0xE129 150 | #define ID_EDIT_SELECT_ALL 0xE12A 151 | #define ID_EDIT_UNDO 0xE12B 152 | #define ID_EDIT_REDO 0xE12C 153 | 154 | // Window commands 155 | #define ID_WINDOW_NEW 0xE130 156 | #define ID_WINDOW_ARRANGE 0xE131 157 | #define ID_WINDOW_CASCADE 0xE132 158 | #define ID_WINDOW_TILE_HORZ 0xE133 159 | #define ID_WINDOW_TILE_VERT 0xE134 160 | #define ID_WINDOW_SPLIT 0xE135 161 | #ifndef RC_INVOKED // code only 162 | #define ATL_IDM_WINDOW_FIRST 0xE130 163 | #define ATL_IDM_WINDOW_LAST 0xE13F 164 | #define ATL_IDM_FIRST_MDICHILD 0xFF00 // window list starts here 165 | #define ATL_IDM_LAST_MDICHILD 0xFFFD 166 | #endif // !RC_INVOKED 167 | // TabView 168 | #define ID_WINDOW_TABFIRST 0xFF00 // = ATL_IDM_FIRST_MDICHILD 169 | #define ID_WINDOW_TABLAST 0xFFFD 170 | #define ID_WINDOW_SHOWTABLIST 0xFFFE 171 | 172 | // Help and App commands 173 | #define ID_APP_ABOUT 0xE140 174 | #define ID_APP_EXIT 0xE141 175 | #define ID_HELP_INDEX 0xE142 176 | #define ID_HELP_FINDER 0xE143 177 | #define ID_HELP_USING 0xE144 178 | #define ID_CONTEXT_HELP 0xE145 // shift-F1 179 | // special commands for processing help 180 | #define ID_HELP 0xE146 // first attempt for F1 181 | #define ID_DEFAULT_HELP 0xE147 // last attempt 182 | 183 | // Misc 184 | #define ID_NEXT_PANE 0xE150 185 | #define ID_PREV_PANE 0xE151 186 | #define ID_PANE_CLOSE 0xE152 187 | 188 | // Format 189 | #define ID_FORMAT_FONT 0xE160 190 | 191 | // Scroll 192 | #define ID_SCROLL_UP 0xE170 193 | #define ID_SCROLL_DOWN 0xE171 194 | #define ID_SCROLL_PAGE_UP 0xE172 195 | #define ID_SCROLL_PAGE_DOWN 0xE173 196 | #define ID_SCROLL_TOP 0xE174 197 | #define ID_SCROLL_BOTTOM 0xE175 198 | #define ID_SCROLL_LEFT 0xE176 199 | #define ID_SCROLL_RIGHT 0xE177 200 | #define ID_SCROLL_PAGE_LEFT 0xE178 201 | #define ID_SCROLL_PAGE_RIGHT 0xE179 202 | #define ID_SCROLL_ALL_LEFT 0xE17A 203 | #define ID_SCROLL_ALL_RIGHT 0xE17B 204 | 205 | // OLE commands 206 | #define ID_OLE_INSERT_NEW 0xE200 207 | #define ID_OLE_EDIT_LINKS 0xE201 208 | #define ID_OLE_EDIT_CONVERT 0xE202 209 | #define ID_OLE_EDIT_CHANGE_ICON 0xE203 210 | #define ID_OLE_EDIT_PROPERTIES 0xE204 211 | #define ID_OLE_VERB_FIRST 0xE210 // range - 16 max 212 | #ifndef RC_INVOKED // code only 213 | #define ID_OLE_VERB_LAST 0xE21F 214 | #endif // !RC_INVOKED 215 | 216 | // View commands (same number used as IDW used for toolbar and status bar) 217 | #define ID_VIEW_TOOLBAR 0xE800 218 | #define ID_VIEW_STATUS_BAR 0xE801 219 | #define ID_VIEW_REFRESH 0xE803 220 | #define ID_VIEW_RIBBON 0xE804 // Ribbon 221 | 222 | /////////////////////////////////////////////////////////////////////////////// 223 | // Standard control IDs 224 | 225 | #ifdef IDC_STATIC 226 | #undef IDC_STATIC 227 | #endif // IDC_STATIC 228 | #define IDC_STATIC (-1) // all static controls 229 | 230 | /////////////////////////////////////////////////////////////////////////////// 231 | // Standard string error/warnings 232 | 233 | // idle status bar message 234 | #define ATL_IDS_IDLEMESSAGE 0xE001 235 | 236 | #ifndef RC_INVOKED // code only 237 | #define ATL_IDS_SCFIRST 0xEF00 238 | #endif // !RC_INVOKED 239 | 240 | #define ATL_IDS_SCSIZE 0xEF00 241 | #define ATL_IDS_SCMOVE 0xEF01 242 | #define ATL_IDS_SCMINIMIZE 0xEF02 243 | #define ATL_IDS_SCMAXIMIZE 0xEF03 244 | #define ATL_IDS_SCNEXTWINDOW 0xEF04 245 | #define ATL_IDS_SCPREVWINDOW 0xEF05 246 | #define ATL_IDS_SCCLOSE 0xEF06 247 | #define ATL_IDS_SCRESTORE 0xEF12 248 | #define ATL_IDS_SCTASKLIST 0xEF13 249 | 250 | #define ATL_IDS_MDICHILD 0xEF1F 251 | #define ATL_IDS_MRU_FILE 0xEFDA 252 | 253 | /////////////////////////////////////////////////////////////////////////////// 254 | // Misc. control IDs 255 | 256 | // Property Sheet control id's (determined with Spy++) 257 | #define ID_APPLY_NOW 0x3021 258 | #define ID_WIZBACK 0x3023 259 | #define ID_WIZNEXT 0x3024 260 | #define ID_WIZFINISH 0x3025 261 | #define ATL_IDC_TAB_CONTROL 0x3020 262 | 263 | #endif // __ATLRES_H__ 264 | -------------------------------------------------------------------------------- /TXDViewer2/atlwfile.h: -------------------------------------------------------------------------------- 1 | #ifndef __ATLWFILE_H__ 2 | #define __ATLWFILE_H__ 3 | 4 | #pragma once 5 | 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // Windows File API wrappers 8 | // 9 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 10 | // Copyright (c) 2001-2010 Bjarke Viksoe. 11 | // 12 | // This code may be used in compiled form in any way you desire. This 13 | // source file may be redistributed by any means PROVIDING it is 14 | // not sold for profit without the authors written consent, and 15 | // providing that this notice and the authors name is included. 16 | // 17 | // This file is provided "as is" with no expressed or implied warranty. 18 | // The author accepts no liability if it causes any damage to you or your 19 | // computer whatsoever. It's free, so don't hassle me about it. 20 | // 21 | // Beware of bugs. 22 | // 23 | 24 | 25 | #ifndef __cplusplus 26 | #error ATL requires C++ compilation (use a .cpp suffix) 27 | #endif 28 | 29 | #ifndef INVALID_SET_FILE_POINTER 30 | #define INVALID_SET_FILE_POINTER ((DWORD)-1) 31 | #endif // INVALID_SET_FILE_POINTER 32 | 33 | #ifndef _ASSERTE 34 | #define _ASSERTE(x) 35 | #endif // _ASSERTE 36 | 37 | #ifndef _ATL_DLL_IMPL 38 | namespace ATL 39 | { 40 | #endif // _ATL_DLL_IMPL 41 | 42 | 43 | ///////////////////////////////////////////////////////////////// 44 | // Standard file wrapper 45 | 46 | // Win32 File wrapper class 47 | template< bool t_bManaged > 48 | class CFileT 49 | { 50 | public: 51 | HANDLE m_hFile; 52 | 53 | CFileT(HANDLE hFile = INVALID_HANDLE_VALUE) : m_hFile(hFile) 54 | { 55 | } 56 | 57 | CFileT(const CFileT& file) : m_hFile(INVALID_HANDLE_VALUE) 58 | { 59 | DuplicateHandle(file.m_hFile); 60 | } 61 | 62 | ~CFileT() 63 | { 64 | if( t_bManaged ) Close(); 65 | } 66 | 67 | operator HFILE() const 68 | { 69 | return (HFILE) m_hFile; 70 | } 71 | 72 | operator HANDLE() const 73 | { 74 | return m_hFile; 75 | } 76 | 77 | const CFileT& operator=(const CFileT& file) 78 | { 79 | DuplicateHandle(file.m_hFile); 80 | return *this; 81 | } 82 | 83 | BOOL Open(LPCTSTR pstrFileName, 84 | DWORD dwAccess = GENERIC_READ, 85 | DWORD dwShareMode = FILE_SHARE_READ, 86 | DWORD dwFlags = OPEN_EXISTING, 87 | DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL) 88 | { 89 | _ASSERTE(pstrFileName!=NULL); 90 | Close(); 91 | // Attempt file creation 92 | HANDLE hFile = ::CreateFile(pstrFileName, 93 | dwAccess, 94 | dwShareMode, 95 | NULL, 96 | dwFlags, 97 | dwAttributes, 98 | NULL); 99 | if( hFile == INVALID_HANDLE_VALUE ) return FALSE; 100 | m_hFile = hFile; 101 | return TRUE; 102 | } 103 | 104 | BOOL Create(LPCTSTR pstrFileName, 105 | DWORD dwAccess = GENERIC_WRITE, 106 | DWORD dwShareMode = 0 /*DENY ALL*/, 107 | DWORD dwFlags = CREATE_ALWAYS, 108 | DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL) 109 | { 110 | return Open(pstrFileName, dwAccess, dwShareMode, dwFlags, dwAttributes); 111 | } 112 | 113 | void Close() 114 | { 115 | if( m_hFile == INVALID_HANDLE_VALUE ) return; 116 | ::CloseHandle(m_hFile); 117 | m_hFile = INVALID_HANDLE_VALUE; 118 | } 119 | 120 | BOOL IsOpen() const 121 | { 122 | return m_hFile != INVALID_HANDLE_VALUE; 123 | } 124 | 125 | void Attach(HANDLE hHandle) 126 | { 127 | Close(); 128 | m_hFile = hHandle; 129 | } 130 | 131 | HANDLE Detach() 132 | { 133 | HANDLE h = m_hFile; 134 | m_hFile = INVALID_HANDLE_VALUE; 135 | return h; 136 | } 137 | 138 | BOOL Read(LPVOID lpBuf, DWORD nCount) 139 | { 140 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 141 | _ASSERTE(lpBuf!=NULL); 142 | if( nCount == 0 ) return TRUE; // avoid Win32 "null-read" 143 | DWORD dwBytesRead = 0; 144 | if( !::ReadFile(m_hFile, lpBuf, nCount, &dwBytesRead, NULL) ) return FALSE; 145 | return TRUE; 146 | } 147 | 148 | BOOL Read(LPVOID lpBuf, DWORD nCount, LPDWORD pdwRead) 149 | { 150 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 151 | _ASSERTE(lpBuf!=NULL); 152 | _ASSERTE(pdwRead!=NULL); 153 | *pdwRead = 0; 154 | if( nCount == 0 ) return TRUE; // avoid Win32 "null-read" 155 | if( !::ReadFile(m_hFile, lpBuf, nCount, pdwRead, NULL) ) return FALSE; 156 | return TRUE; 157 | } 158 | 159 | BOOL Write(LPCVOID lpBuf, DWORD nCount) 160 | { 161 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 162 | _ASSERTE(lpBuf!=NULL); 163 | if( nCount == 0 ) return TRUE; // avoid Win32 "null-write" option 164 | DWORD dwBytesWritten = 0; 165 | if( !::WriteFile(m_hFile, lpBuf, nCount, &dwBytesWritten, NULL) ) return FALSE; 166 | return TRUE; 167 | } 168 | 169 | BOOL Write(LPCVOID lpBuf, DWORD nCount, LPDWORD pdwWritten) 170 | { 171 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 172 | _ASSERTE(lpBuf!=NULL); 173 | _ASSERTE(pdwWritten!=NULL); 174 | *pdwWritten = 0; 175 | if( nCount == 0 ) return TRUE; // avoid Win32 "null-write" option 176 | if( !::WriteFile(m_hFile, lpBuf, nCount, pdwWritten, NULL) ) return FALSE; 177 | return TRUE; 178 | } 179 | 180 | DWORD Seek(LONG lOff, UINT nFrom) 181 | { 182 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 183 | return ::SetFilePointer(m_hFile, lOff, NULL, (DWORD) nFrom); 184 | } 185 | 186 | DWORD GetPosition() const 187 | { 188 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 189 | return ::SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT); 190 | } 191 | 192 | BOOL Lock(DWORD dwOffset, DWORD dwSize) 193 | { 194 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 195 | return ::LockFile(m_hFile, dwOffset, 0, dwSize, 0); 196 | } 197 | 198 | BOOL Unlock(DWORD dwOffset, DWORD dwSize) 199 | { 200 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 201 | return ::UnlockFile(m_hFile, dwOffset, 0, dwSize, 0); 202 | } 203 | 204 | BOOL SetEOF() 205 | { 206 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 207 | return ::SetEndOfFile(m_hFile); 208 | } 209 | 210 | BOOL Flush() 211 | { 212 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 213 | return ::FlushFileBuffers(m_hFile); 214 | } 215 | 216 | DWORD GetSize() const 217 | { 218 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 219 | return ::GetFileSize(m_hFile, NULL); 220 | } 221 | 222 | DWORD GetType() const 223 | { 224 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 225 | return ::GetFileType(m_hFile); 226 | } 227 | 228 | BOOL GetFileTime(FILETIME* ftCreate, FILETIME* ftAccess, FILETIME* ftModified) 229 | { 230 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 231 | return ::GetFileTime(m_hFile, ftCreate, ftAccess, ftModified); 232 | } 233 | 234 | BOOL SetFileTime(FILETIME* ftCreate, FILETIME* ftAccess, FILETIME* ftModified) 235 | { 236 | _ASSERTE(m_hFile!=INVALID_HANDLE_VALUE); 237 | return ::SetFileTime(m_hFile, ftCreate, ftAccess, ftModified); 238 | } 239 | 240 | BOOL DuplicateHandle(HANDLE hOther) 241 | { 242 | ATLASSERT(m_hFile==INVALID_HANDLE_VALUE); 243 | ATLASSERT(hOther!=INVALID_HANDLE_VALUE); 244 | HANDLE process = ::GetCurrentProcess(); 245 | return ::DuplicateHandle(process, hOther, process, &m_hFile, NULL, FALSE, DUPLICATE_SAME_ACCESS); 246 | } 247 | 248 | // Static members 249 | 250 | static BOOL FileExists(LPCTSTR pstrFileName) 251 | { 252 | _ASSERTE(pstrFileName!=NULL); 253 | DWORD dwErrMode = ::SetErrorMode(SEM_FAILCRITICALERRORS); 254 | DWORD dwAttribs = ::GetFileAttributes(pstrFileName); 255 | ::SetErrorMode(dwErrMode); 256 | return dwAttribs != INVALID_FILE_ATTRIBUTES && ((dwAttribs & FILE_ATTRIBUTE_DIRECTORY) == 0); 257 | } 258 | 259 | static BOOL Delete(LPCTSTR pstrFileName) 260 | { 261 | _ASSERTE(pstrFileName!=NULL); 262 | return ::DeleteFile(pstrFileName); 263 | } 264 | 265 | static BOOL Rename(LPCTSTR pstrSourceFileName, LPCTSTR pstrTargetFileName) 266 | { 267 | _ASSERTE(pstrSourceFileName!=NULL); 268 | _ASSERTE(pstrTargetFileName!=NULL); 269 | return ::MoveFile(pstrSourceFileName, pstrTargetFileName); 270 | } 271 | }; 272 | 273 | typedef CFileT CFile; 274 | typedef CFileT CFileHandle; 275 | 276 | 277 | ///////////////////////////////////////////////////////////////// 278 | // Temporary file (temp filename and auto delete) 279 | 280 | class CTemporaryFile : public CFileT 281 | { 282 | public: 283 | TCHAR m_szFileName[MAX_PATH]; 284 | 285 | ~CTemporaryFile() 286 | { 287 | Close(); 288 | Delete(m_szFileName); 289 | } 290 | 291 | BOOL Create(LPTSTR pstrFileName, 292 | UINT cchFilenameBuf, 293 | DWORD dwAccess = GENERIC_WRITE, 294 | DWORD dwShareMode = 0 /*DENY ALL*/, 295 | DWORD dwFlags = CREATE_ALWAYS, 296 | DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL) 297 | { 298 | _ASSERTE(pstrFileName!=NULL); 299 | // If a valid filename buffer is supplied we'll create 300 | // and return a new temporary filename, otherwise assume 301 | // that 'pstrFileName' just contains a filename to use. 302 | if( cchFilenameBuf > 0 ) { 303 | _ASSERTE(cchFilenameBuf>=MAX_PATH); 304 | ::GetTempPath(cchFilenameBuf, pstrFileName); 305 | ::GetTempFileName(pstrFileName, _T("BV"), 0, pstrFileName); 306 | } 307 | ::lstrcpyn(m_szFileName, pstrFileName, MAX_PATH); 308 | m_szFileName[MAX_PATH - 1] = '\0'; 309 | return Open(pstrFileName, dwAccess, dwShareMode, dwFlags, dwAttributes); 310 | } 311 | }; 312 | 313 | 314 | #ifndef _ATL_DLL_IMPL 315 | }; //namespace ATL 316 | #endif // _ATL_DLL_IMPL 317 | 318 | 319 | #endif // __ATLWFILE_H___ 320 | -------------------------------------------------------------------------------- /TXDViewer2/dbprops.h: -------------------------------------------------------------------------------- 1 | // props.h : interface for the properties classes 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef __DB_PROPS_H__ 6 | #define __DB_PROPS_H__ 7 | 8 | #if _MSC_VER >= 1000 9 | #pragma once 10 | #endif // _MSC_VER >= 1000 11 | 12 | class CPageOne : public CPropertyPageImpl, public CWinDataExchange 13 | { 14 | public: 15 | enum { IDD = IDD_PROP_PAGE1 }; 16 | CString m_strHost; 17 | CString m_strPort; 18 | CString m_strService; 19 | CString m_strDataBase; 20 | CString m_strSchema; 21 | CString m_strName; 22 | CString m_strUserName; 23 | CString m_strPwd; 24 | CEdit m_hwndNameEdit; 25 | bool m_bEditMode; 26 | 27 | BEGIN_MSG_MAP(CPageOne) 28 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 29 | CHAIN_MSG_MAP(CPropertyPageImpl) 30 | END_MSG_MAP() 31 | 32 | BEGIN_DDX_MAP(CPageOne) 33 | DDX_CONTROL_HANDLE(IDC_EDIT_NAME, m_hwndNameEdit) 34 | DDX_TEXT(IDC_EDIT_HOST, m_strHost) 35 | DDX_TEXT(IDC_EDIT_PORT, m_strPort) 36 | DDX_TEXT(IDC_EDIT_SERVICE, m_strService) 37 | DDX_TEXT(IDC_EDIT_DB, m_strDataBase) 38 | DDX_TEXT(IDC_EDIT_NAME, m_strName) 39 | DDX_TEXT(IDC_EDIT_USERNAME, m_strUserName) 40 | DDX_TEXT(IDC_EDIT_PWD, m_strPwd) 41 | DDX_TEXT(IDC_EDIT_SCHEMA, m_strSchema) 42 | END_DDX_MAP() 43 | 44 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 45 | { 46 | DoDataExchange(false); 47 | if (m_bEditMode) 48 | { 49 | m_hwndNameEdit.EnableWindow(0); 50 | } 51 | return TRUE; 52 | } 53 | 54 | int OnApply() 55 | { 56 | return DoDataExchange(true); 57 | } 58 | }; 59 | 60 | class CPageTwo : public CPropertyPageImpl 61 | { 62 | public: 63 | enum { IDD = IDD_PROP_PAGE2 }; 64 | 65 | BEGIN_MSG_MAP(CPageTwo) 66 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 67 | CHAIN_MSG_MAP(CPropertyPageImpl) 68 | END_MSG_MAP() 69 | 70 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 71 | { 72 | return TRUE; 73 | } 74 | }; 75 | 76 | class CDataBaseProperties : public CPropertySheetImpl 77 | { 78 | public: 79 | CPageOne m_page1; 80 | CPageTwo m_page2; 81 | 82 | CDataBaseProperties() 83 | { 84 | m_psh.dwFlags |= PSH_NOAPPLYNOW; 85 | 86 | m_page1.m_bEditMode = false; 87 | AddPage(m_page1); 88 | AddPage(m_page2); 89 | SetActivePage(0); 90 | SetTitle(_T("New Server Connection")); 91 | } 92 | 93 | BEGIN_MSG_MAP(CDataBaseProperties) 94 | COMMAND_ID_HANDLER(IDOK, OnOK) 95 | CHAIN_MSG_MAP(CPropertySheetImpl) 96 | END_MSG_MAP() 97 | 98 | void SetEditMode() 99 | { 100 | m_page1.m_bEditMode = true; 101 | SetTitle(_T("Edit Server Connection")); 102 | } 103 | 104 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 105 | { 106 | m_page1.Apply(); 107 | if (m_page1.m_strDataBase.IsEmpty()) 108 | { 109 | MessageBox(_T("Must specify a DataBase"), _T("Warning"), MB_OK|MB_ICONWARNING); 110 | return 0; 111 | } 112 | else if (m_page1.m_strSchema.IsEmpty()) 113 | { 114 | MessageBox(_T("Must specify a Schema"), _T("Warning"), MB_OK|MB_ICONWARNING); 115 | return 0; 116 | } 117 | PressButton(PSBTN_OK); 118 | return 0; 119 | } 120 | }; 121 | 122 | #endif // __PROPS_H__ 123 | -------------------------------------------------------------------------------- /TXDViewer2/gdal192/include/cpl_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* We define this here in general so that a VC++ build will publically 3 | declare STDCALL interfaces even if an application is built against it 4 | using MinGW */ 5 | 6 | #ifndef CPL_DISABLE_STDCALL 7 | # define CPL_STDCALL __stdcall 8 | #endif 9 | 10 | /* Define if you don't have vprintf but do have _doprnt. */ 11 | #undef HAVE_DOPRNT 12 | 13 | /* Define if you have the vprintf function. */ 14 | #define HAVE_VPRINTF 1 15 | #define HAVE_VSNPRINTF 1 16 | #define HAVE_SNPRINTF 1 17 | #if defined(_MSC_VER) && (_MSC_VER < 1500) 18 | # define vsnprintf _vsnprintf 19 | #endif 20 | #define snprintf _snprintf 21 | 22 | #define HAVE_GETCWD 1 23 | /* gmt_notunix.h from GMT project also redefines getcwd. See #3138 */ 24 | #ifndef getcwd 25 | #define getcwd _getcwd 26 | #endif 27 | 28 | /* Define if you have the ANSI C header files. */ 29 | #ifndef STDC_HEADERS 30 | # define STDC_HEADERS 1 31 | #endif 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #define HAVE_ASSERT_H 1 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #define HAVE_FCNTL_H 1 38 | 39 | /* Define if you have the header file. */ 40 | #undef HAVE_UNISTD_H 41 | 42 | /* Define if you have the header file. */ 43 | #undef HAVE_STDINT_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #define HAVE_SYS_TYPES_H 1 47 | 48 | #undef HAVE_LIBDL 49 | 50 | /* Define to 1 if you have the header file. */ 51 | #define HAVE_LOCALE_H 1 52 | 53 | #define HAVE_FLOAT_H 1 54 | 55 | #define HAVE_ERRNO_H 1 56 | 57 | #define HAVE_SEARCH_H 1 58 | 59 | /* Define to 1 if you have the header file. */ 60 | #define HAVE_DIRECT_H 61 | 62 | /* Define to 1 if you have the `localtime_r' function. */ 63 | #undef HAVE_LOCALTIME_R 64 | 65 | #undef HAVE_DLFCN_H 66 | #undef HAVE_DBMALLOC_H 67 | #undef HAVE_LIBDBMALLOC 68 | #undef WORDS_BIGENDIAN 69 | 70 | /* The size of a `int', as computed by sizeof. */ 71 | #define SIZEOF_INT 4 72 | 73 | /* The size of a `long', as computed by sizeof. */ 74 | #define SIZEOF_LONG 4 75 | 76 | /* The size of a `unsigned long', as computed by sizeof. */ 77 | #define SIZEOF_UNSIGNED_LONG 4 78 | 79 | /* The size of `void*', as computed by sizeof. */ 80 | #ifdef _WIN64 81 | # define SIZEOF_VOIDP 8 82 | #else 83 | # define SIZEOF_VOIDP 4 84 | #endif 85 | 86 | /* Set the native cpu bit order */ 87 | #define HOST_FILLORDER FILLORDER_LSB2MSB 88 | 89 | /* Define as 0 or 1 according to the floating point format suported by the 90 | machine */ 91 | #define HAVE_IEEEFP 1 92 | 93 | /* Define to `__inline__' or `__inline' if that's what the C compiler 94 | calls it, or to nothing if 'inline' is not supported under any name. */ 95 | #ifndef __cplusplus 96 | # ifndef inline 97 | # define inline __inline 98 | # endif 99 | #endif 100 | 101 | #define lfind _lfind 102 | 103 | #if defined(_MSC_VER) && (_MSC_VER < 1310) 104 | # define VSI_STAT64 _stat 105 | # define VSI_STAT64_T _stat 106 | #else 107 | # define VSI_STAT64 _stat64 108 | # define VSI_STAT64_T __stat64 109 | #endif 110 | 111 | /* VC6 doesn't known intptr_t */ 112 | #if defined(_MSC_VER) && (_MSC_VER <= 1200) 113 | typedef int intptr_t; 114 | #endif 115 | 116 | #pragma warning(disable: 4786) 117 | 118 | /* #define CPL_DISABLE_DLL */ 119 | 120 | -------------------------------------------------------------------------------- /TXDViewer2/gdal192/include/gdal_version.h: -------------------------------------------------------------------------------- 1 | 2 | /* -------------------------------------------------------------------- */ 3 | /* GDAL Version Information. */ 4 | /* -------------------------------------------------------------------- */ 5 | 6 | #ifndef GDAL_VERSION_MAJOR 7 | # define GDAL_VERSION_MAJOR 1 8 | # define GDAL_VERSION_MINOR 9 9 | # define GDAL_VERSION_REV 2 10 | # define GDAL_VERSION_BUILD 0 11 | #endif 12 | 13 | #ifndef GDAL_VERSION_NUM 14 | # define GDAL_VERSION_NUM (GDAL_VERSION_MAJOR*1000+GDAL_VERSION_MINOR*100+GDAL_VERSION_REV*10+GDAL_VERSION_BUILD) 15 | #endif 16 | 17 | #ifndef GDAL_RELEASE_DATE 18 | # define GDAL_RELEASE_DATE 20121008 19 | #endif 20 | #ifndef GDAL_RELEASE_NAME 21 | # define GDAL_RELEASE_NAME "1.9.2" 22 | #endif 23 | -------------------------------------------------------------------------------- /TXDViewer2/gdal192/include/postgres_ext.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | * 3 | * postgres_ext.h 4 | * 5 | * This file contains declarations of things that are visible everywhere 6 | * in PostgreSQL *and* are visible to clients of frontend interface libraries. 7 | * For example, the Oid type is part of the API of libpq and other libraries. 8 | * 9 | * Declarations which are specific to a particular interface should 10 | * go in the header file for that interface (such as libpq-fe.h). This 11 | * file is only for fundamental Postgres declarations. 12 | * 13 | * User-written C functions don't count as "external to Postgres." 14 | * Those function much as local modifications to the backend itself, and 15 | * use header files that are otherwise internal to Postgres to interface 16 | * with the backend. 17 | * 18 | * src/include/postgres_ext.h 19 | * 20 | *------------------------------------------------------------------------- 21 | */ 22 | 23 | #ifndef POSTGRES_EXT_H 24 | #define POSTGRES_EXT_H 25 | 26 | /* 27 | * Object ID is a fundamental type in Postgres. 28 | */ 29 | typedef unsigned int Oid; 30 | 31 | #ifdef __cplusplus 32 | #define InvalidOid (Oid(0)) 33 | #else 34 | #define InvalidOid ((Oid) 0) 35 | #endif 36 | 37 | #define OID_MAX UINT_MAX 38 | /* you will need to include to use the above #define */ 39 | 40 | 41 | /* 42 | * Identifiers of error message fields. Kept here to keep common 43 | * between frontend and backend, and also to export them to libpq 44 | * applications. 45 | */ 46 | #define PG_DIAG_SEVERITY 'S' 47 | #define PG_DIAG_SQLSTATE 'C' 48 | #define PG_DIAG_MESSAGE_PRIMARY 'M' 49 | #define PG_DIAG_MESSAGE_DETAIL 'D' 50 | #define PG_DIAG_MESSAGE_HINT 'H' 51 | #define PG_DIAG_STATEMENT_POSITION 'P' 52 | #define PG_DIAG_INTERNAL_POSITION 'p' 53 | #define PG_DIAG_INTERNAL_QUERY 'q' 54 | #define PG_DIAG_CONTEXT 'W' 55 | #define PG_DIAG_SOURCE_FILE 'F' 56 | #define PG_DIAG_SOURCE_LINE 'L' 57 | #define PG_DIAG_SOURCE_FUNCTION 'R' 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /TXDViewer2/res/Checked.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Checked.ico -------------------------------------------------------------------------------- /TXDViewer2/res/Data_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Data_25.png -------------------------------------------------------------------------------- /TXDViewer2/res/Data_26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Data_26.png -------------------------------------------------------------------------------- /TXDViewer2/res/Data_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Data_6.png -------------------------------------------------------------------------------- /TXDViewer2/res/Data_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Data_7.png -------------------------------------------------------------------------------- /TXDViewer2/res/Find.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Find.ico -------------------------------------------------------------------------------- /TXDViewer2/res/HandClose.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/HandClose.cur -------------------------------------------------------------------------------- /TXDViewer2/res/Identify.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Identify.ico -------------------------------------------------------------------------------- /TXDViewer2/res/Layers.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Layers.ico -------------------------------------------------------------------------------- /TXDViewer2/res/TXDViewer2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/TXDViewer2.ico -------------------------------------------------------------------------------- /TXDViewer2/res/Unchecked.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/Unchecked.ico -------------------------------------------------------------------------------- /TXDViewer2/res/ZoomIn.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ZoomIn.cur -------------------------------------------------------------------------------- /TXDViewer2/res/ZoomInl.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ZoomInl.cur -------------------------------------------------------------------------------- /TXDViewer2/res/ZoomOut.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ZoomOut.cur -------------------------------------------------------------------------------- /TXDViewer2/res/ZoomOutl.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ZoomOutl.cur -------------------------------------------------------------------------------- /TXDViewer2/res/ico3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ico3.ico -------------------------------------------------------------------------------- /TXDViewer2/res/ico4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ico4.ico -------------------------------------------------------------------------------- /TXDViewer2/res/ico5.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/ico5.ico -------------------------------------------------------------------------------- /TXDViewer2/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qtxie/SimpleGISViewer/4d47f2413742e4b7ef49b3d67be9e7857c0bdc64/TXDViewer2/res/toolbar.bmp -------------------------------------------------------------------------------- /TXDViewer2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by TXDViewer2.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDD_PROP_PAGE1 104 7 | #define IDD_PROP_PAGE2 105 8 | #define IDD_DLG_DB 106 9 | #define IDD_DLG_LAYER_INFO 107 10 | #define IDR_MAINFRAME 128 11 | #define IDD_IDENTIFY 129 12 | #define IDD_FIND 130 13 | #define IDD_LOCATE 131 14 | #define IDD_FILE_MANAGER 132 15 | #define IDI_LAYERS 201 16 | #define IDI_UNCHECK 202 17 | #define IDI_CHECK 203 18 | #define IDI_LINE 204 19 | #define IDI_POINT 205 20 | #define IDI_POLYGON 206 21 | #define IDI_FIND 207 22 | #define IDI_IDENTIFY 208 23 | #define IDI_CUR_ZOOM_IN 209 24 | #define IDI_CUR_ZOOM_OUT 300 25 | #define IDR_TREECONTEXTMENU 301 26 | #define IDC_CUR_HAND_CLOSE 302 27 | #define IDR_IDENTIFYCONTEXTMENU 303 28 | #define IDC_EDIT1 1000 29 | #define IDC_COMBO_LOCATE 1001 30 | #define IDC_TREE1 1002 31 | #define IDC_SPLIT 1003 32 | #define ID_SWAP_COORDS 1004 33 | #define IDC_COMBO_IDENTIFY_LAYERS 1005 34 | #define IDC_RADIO_COORDS 1006 35 | #define IDC_RADIO_ID 1007 36 | #define IDC_LIST_FILE 1008 37 | #define IDC_EDIT_PORT 1011 38 | #define IDC_EDIT_SERVICE 1012 39 | #define IDC_EDIT_DB 1013 40 | #define IDC_EDIT_USERNAME 1014 41 | #define IDC_EDIT_PWD 1015 42 | #define IDC_EDIT_HOST 1016 43 | #define IDC_EDIT_NAME 1017 44 | #define IDC_LIST_DB_PARAM 1018 45 | #define IDC_CMB_DB_NAME 1019 46 | #define IDC_EDIT_LAYER_INFO 1020 47 | #define IDC_BTN_EDIT_DB 1021 48 | #define IDC_BTN_DEL_DB 1022 49 | #define IDC_EDIT_SCHEMA 1023 50 | #define IDC_EDIT_ID_COL 1024 51 | #define IDC_CHECK_ID 1025 52 | #define IDC_CHECK_SQL 1026 53 | #define IDC_EDIT_SQL 1027 54 | #define IDC_CHK_COMPLEX_SQL 1028 55 | #define ID_VIEW_TREEPANE 32774 56 | #define ID_FILE_RECENT 32775 57 | #define ID_VIEW_ZOOM_IN 32776 58 | #define ID_VIEW_ZOOM_OUT 32777 59 | #define ID_VIEW_PAN 32778 60 | #define ID_VIEW_FULLEXTENT 32779 61 | #define ID_TOOL_IDENTIFY 32780 62 | #define ID_TOOL_LOCATE 32781 63 | #define ID_EDIT_DELETE 32782 64 | #define ID_VIEW_CHECK_ALL 32783 65 | #define ID_VIEW_UNCHECK_ALL 32784 66 | #define ID_TOOL_FIND 32785 67 | #define ID_IDENTIFY_COPY_SELECT 32786 68 | #define ID_IDENTIFY_COPY_ALL 32787 69 | #define ID_IDENTIFY_EXPORT 32788 70 | #define IDPANE_COORDINATE 40000 71 | #define IDPANE_ALL_RECORD_NUM 40001 72 | #define ID_FILE_RECENTFILES 40001 73 | #define ID__ZOOMTO 40002 74 | #define IDC_DEL_ALL 40003 75 | #define ID_LAYER_MOVE_UP 40004 76 | #define ID_LAYER_MOVE_DOWN 40005 77 | #define ID_TOGGLE_ID 40006 78 | #define ID__LAYERINFO 40007 79 | #define ID_FILE_CONNECTDB 40008 80 | #define IDC_RADIO_ALL_FIELDS 59396 81 | #define IDC_RADIO_IN_FIELDS 59397 82 | #define IDC_COMBO_LAYER 59398 83 | #define IDC_COMBO_FIND 59399 84 | #define IDC_Stop 59404 85 | #define IDC_FIND 59405 86 | #define IDC_RADIO_FEATURES 59406 87 | #define IDC_RADIO_LOCATE 59407 88 | #define IDC_BTN_ADD_DB 59408 89 | #define IDC_COMBO_FIELDS 59409 90 | #define IDC_BTN_LOAD 59410 91 | 92 | // Next default values for new objects 93 | // 94 | #ifdef APSTUDIO_INVOKED 95 | #ifndef APSTUDIO_READONLY_SYMBOLS 96 | #define _APS_NEXT_RESOURCE_VALUE 108 97 | #define _APS_NEXT_COMMAND_VALUE 40009 98 | #define _APS_NEXT_CONTROL_VALUE 1029 99 | #define _APS_NEXT_SYMED_VALUE 101 100 | #endif 101 | #endif 102 | -------------------------------------------------------------------------------- /TXDViewer2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TXDViewer2.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | #if (_ATL_VER < 0x0700) 8 | #include 9 | #endif //(_ATL_VER < 0x0700) 10 | -------------------------------------------------------------------------------- /TXDViewer2/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | // Change these values to use different versions 9 | #define WINVER 0x0501 10 | #define _WIN32_WINNT 0x0501 11 | #define _WIN32_IE 0x0501 12 | #define _RICHEDIT_VER 0x0200 13 | 14 | #define strtk_no_tr1_or_boost 15 | #include "strtk.hpp" 16 | #include "ogr_geometry.h" 17 | #include "libpq-fe.h" 18 | #include 19 | #include 20 | 21 | #define NOMINMAX 22 | using std::min; 23 | using std::max; 24 | 25 | #include 26 | #include 27 | 28 | extern CAppModule _Module; 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include "atlwfile.h" 42 | #include "SplitterBar.h" 43 | #include "MapManager.h" 44 | extern MapManager g_MapManager; 45 | 46 | #if defined _M_IX86 47 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 48 | #elif defined _M_IA64 49 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 50 | #elif defined _M_X64 51 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 52 | #else 53 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 54 | #endif 55 | -------------------------------------------------------------------------------- /TXDViewer2/wtl81_12085/CPL.TXT: -------------------------------------------------------------------------------- 1 | Common Public License Version 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 6 | 1. DEFINITIONS 7 | 8 | "Contribution" means: 9 | 10 | a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. 19 | 20 | "Contributor" means any person or entity that distributes the Program. 21 | 22 | "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. 23 | 24 | "Program" means the Contributions distributed in accordance with this Agreement. 25 | 26 | "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 27 | 28 | 29 | 2. GRANT OF RIGHTS 30 | 31 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. 32 | 33 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. 34 | 35 | c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. 36 | 37 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 38 | 39 | 40 | 3. REQUIREMENTS 41 | 42 | A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: 43 | 44 | a) it complies with the terms and conditions of this Agreement; and 45 | 46 | b) its license agreement: 47 | 48 | i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; 49 | 50 | ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; 51 | 52 | iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and 53 | 54 | iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. 55 | 56 | When the Program is made available in source code form: 57 | 58 | a) it must be made available under this Agreement; and 59 | 60 | b) a copy of this Agreement must be included with each copy of the Program. 61 | 62 | Contributors may not remove or alter any copyright notices contained within the Program. 63 | 64 | Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 65 | 66 | 67 | 4. COMMERCIAL DISTRIBUTION 68 | 69 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. 70 | 71 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 72 | 73 | 74 | 5. NO WARRANTY 75 | 76 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 77 | 78 | 79 | 6. DISCLAIMER OF LIABILITY 80 | 81 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 82 | 83 | 84 | 7. GENERAL 85 | 86 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 87 | 88 | If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. 89 | 90 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. 91 | 92 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. 93 | 94 | This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. 95 | -------------------------------------------------------------------------------- /TXDViewer2/wtl81_12085/Include/atldwm.h: -------------------------------------------------------------------------------- 1 | // Windows Template Library - WTL version 8.1 2 | // Copyright (C) Microsoft Corporation. All rights reserved. 3 | // 4 | // This file is a part of the Windows Template Library. 5 | // The use and distribution terms for this software are covered by the 6 | // Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php) 7 | // which can be found in the file CPL.TXT at the root of this distribution. 8 | // By using this software in any fashion, you are agreeing to be bound by 9 | // the terms of this license. You must not remove this notice, or 10 | // any other, from this software. 11 | 12 | #ifndef __ATLDWM_H__ 13 | #define __ATLDWM_H__ 14 | 15 | #pragma once 16 | 17 | #ifdef _WIN32_WCE 18 | #error atldwm.h is not supported on Windows CE 19 | #endif 20 | 21 | #ifndef __ATLAPP_H__ 22 | #error atldwm.h requires atlapp.h to be included first 23 | #endif 24 | 25 | #ifndef __ATLWIN_H__ 26 | #error atldwm.h requires atlwin.h to be included first 27 | #endif 28 | 29 | #if (_WIN32_WINNT < 0x0600) 30 | #error atldwm.h requires _WIN32_WINNT >= 0x0600 31 | #endif // (_WIN32_WINNT < 0x0600) 32 | 33 | #ifndef _DWMAPI_H_ 34 | #include 35 | #endif // _DWMAPI_H_ 36 | #pragma comment(lib, "dwmapi.lib") 37 | 38 | // Note: To create an application that also runs on older versions of Windows, 39 | // use delay load of dwmapi.dll and ensure that no calls to the DWM API are 40 | // Delay load is NOT AUTOMATIC for VC++ 7, you have to link to delayimp.lib, 41 | // and add dwmapi.dll in the Linker.Input.Delay Loaded DLLs section of the 42 | // project properties. 43 | #if (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) 44 | #pragma comment(lib, "delayimp.lib") 45 | #pragma comment(linker, "/delayload:dwmapi.dll") 46 | #endif // (_MSC_VER < 1300) && !defined(_WTL_NO_DWMAPI_DELAYLOAD) 47 | 48 | /////////////////////////////////////////////////////////////////////////////// 49 | // Classes in this file: 50 | // 51 | // CDwm 52 | // CDwmImpl 53 | // CDwmWindowT - CDwmWindow 54 | // CDwmThumbnailT 55 | // CDwmThumbnail 56 | // CDwmThumbnailHandle 57 | // CAeroControlImpl 58 | 59 | 60 | namespace WTL 61 | { 62 | 63 | /////////////////////////////////////////////////////////////////////////////// 64 | // CDwm - wrapper for DWM handle 65 | 66 | class CDwm 67 | { 68 | public: 69 | // Data members 70 | static int m_nIsDwmSupported; 71 | 72 | // Constructor 73 | CDwm() 74 | { 75 | IsDwmSupported(); 76 | } 77 | 78 | // Dwm support helper 79 | static bool IsDwmSupported() 80 | { 81 | if(m_nIsDwmSupported == -1) 82 | { 83 | CStaticDataInitCriticalSectionLock lock; 84 | if(FAILED(lock.Lock())) 85 | { 86 | ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CDwm::IsDwmSupported.\n")); 87 | ATLASSERT(FALSE); 88 | return false; 89 | } 90 | 91 | if(m_nIsDwmSupported == -1) 92 | { 93 | HMODULE hDwmDLL = ::LoadLibrary(_T("dwmapi.dll")); 94 | m_nIsDwmSupported = (hDwmDLL != NULL) ? 1 : 0; 95 | if(hDwmDLL != NULL) 96 | ::FreeLibrary(hDwmDLL); 97 | } 98 | 99 | lock.Unlock(); 100 | } 101 | 102 | ATLASSERT(m_nIsDwmSupported != -1); 103 | return (m_nIsDwmSupported == 1); 104 | } 105 | 106 | // Operations 107 | BOOL DwmIsCompositionEnabled() const 108 | { 109 | if(!IsDwmSupported()) return FALSE; 110 | BOOL bRes = FALSE; 111 | return SUCCEEDED(::DwmIsCompositionEnabled(&bRes)) && bRes; 112 | } 113 | 114 | BOOL DwmEnableComposition(UINT fEnable) 115 | { 116 | if(!IsDwmSupported()) return FALSE; 117 | return SUCCEEDED(::DwmEnableComposition(fEnable)); 118 | } 119 | 120 | BOOL DwmEnableMMCSS(BOOL fEnableMMCSS) 121 | { 122 | if(!IsDwmSupported()) return FALSE; 123 | return SUCCEEDED(::DwmEnableMMCSS(fEnableMMCSS)); 124 | } 125 | 126 | HRESULT DwmGetColorizationColor(DWORD* pcrColorization, BOOL* pfOpaqueBlend) 127 | { 128 | if(!IsDwmSupported()) return E_NOTIMPL; 129 | return ::DwmGetColorizationColor(pcrColorization, pfOpaqueBlend); 130 | } 131 | 132 | HRESULT DwmFlush() 133 | { 134 | if(!IsDwmSupported()) return E_NOTIMPL; 135 | return ::DwmFlush(); 136 | } 137 | }; 138 | 139 | __declspec(selectany) int CDwm::m_nIsDwmSupported = -1; 140 | 141 | 142 | /////////////////////////////////////////////////////////////////////////////// 143 | // CDwmImpl - DWM window support 144 | 145 | template 146 | class CDwmImpl : public TBase 147 | { 148 | public: 149 | HRESULT DwmEnableBlurBehindWindow(const DWM_BLURBEHIND* pBB) 150 | { 151 | if(!IsDwmSupported()) return E_NOTIMPL; 152 | T* pT = static_cast(this); 153 | ATLASSERT(::IsWindow(pT->m_hWnd)); 154 | return ::DwmEnableBlurBehindWindow(pT->m_hWnd, pBB); 155 | } 156 | 157 | HRESULT DwmExtendFrameIntoClientArea(const MARGINS* pMargins) 158 | { 159 | if(!IsDwmSupported()) return E_NOTIMPL; 160 | T* pT = static_cast(this); 161 | ATLASSERT(::IsWindow(pT->m_hWnd)); 162 | return ::DwmExtendFrameIntoClientArea(pT->m_hWnd, pMargins); 163 | } 164 | 165 | HRESULT DwmExtendFrameIntoEntireClientArea() 166 | { 167 | MARGINS margins = { -1 }; 168 | return DwmExtendFrameIntoClientArea(&margins); 169 | } 170 | 171 | HRESULT DwmGetCompositionTimingInfo(DWM_TIMING_INFO* pTimingInfo) 172 | { 173 | if(!IsDwmSupported()) return E_NOTIMPL; 174 | T* pT = static_cast(this); 175 | ATLASSERT(::IsWindow(pT->m_hWnd)); 176 | return ::DwmGetCompositionTimingInfo(pT->m_hWnd, pTimingInfo); 177 | } 178 | 179 | HRESULT DwmGetWindowAttribute(DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute) 180 | { 181 | if(!IsDwmSupported()) return E_NOTIMPL; 182 | T* pT = static_cast(this); 183 | ATLASSERT(::IsWindow(pT->m_hWnd)); 184 | return ::DwmGetWindowAttribute(pT->m_hWnd, dwAttribute, pvAttribute, cbAttribute); 185 | } 186 | 187 | HRESULT DwmModifyPreviousDxFrameDuration(INT cRefreshes, BOOL fRelative) 188 | { 189 | if(!IsDwmSupported()) return E_NOTIMPL; 190 | T* pT = static_cast(this); 191 | ATLASSERT(::IsWindow(pT->m_hWnd)); 192 | return ::DwmModifyPreviousDxFrameDuration(pT->m_hWnd, cRefreshes, fRelative); 193 | } 194 | 195 | HRESULT DwmSetDxFrameDuration(INT cRefreshes) 196 | { 197 | if(!IsDwmSupported()) return E_NOTIMPL; 198 | T* pT = static_cast(this); 199 | ATLASSERT(::IsWindow(pT->m_hWnd)); 200 | return ::DwmSetDxFrameDuration(pT->m_hWnd, cRefreshes); 201 | } 202 | 203 | HRESULT DwmSetPresentParameters(DWM_PRESENT_PARAMETERS* pPresentParams) 204 | { 205 | if(!IsDwmSupported()) return E_NOTIMPL; 206 | T* pT = static_cast(this); 207 | ATLASSERT(::IsWindow(pT->m_hWnd)); 208 | return ::DwmSetPresentParameters(pT->m_hWnd, pPresentParams); 209 | } 210 | 211 | HRESULT DwmSetWindowAttribute(DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) 212 | { 213 | if(!IsDwmSupported()) return E_NOTIMPL; 214 | T* pT = static_cast(this); 215 | ATLASSERT(::IsWindow(pT->m_hWnd)); 216 | return ::DwmSetWindowAttribute(pT->m_hWnd, dwAttribute, pvAttribute, cbAttribute); 217 | } 218 | 219 | HRESULT DwmAttachMilContent() 220 | { 221 | if(!IsDwmSupported()) return E_NOTIMPL; 222 | T* pT = static_cast(this); 223 | ATLASSERT(::IsWindow(pT->m_hWnd)); 224 | return ::DwmAttachMilContent(pT->m_hWnd); 225 | } 226 | 227 | HRESULT DwmDetachMilContent() 228 | { 229 | if(!IsDwmSupported()) return E_NOTIMPL; 230 | T* pT = static_cast(this); 231 | ATLASSERT(::IsWindow(pT->m_hWnd)); 232 | return ::DwmDetachMilContent(pT->m_hWnd); 233 | } 234 | }; 235 | 236 | template 237 | class CDwmWindowT : public TBase, public CDwmImpl > 238 | { 239 | public: 240 | CDwmWindowT(HWND hWnd = NULL) : TBase(hWnd) 241 | { } 242 | 243 | CDwmWindowT< TBase >& operator =(HWND hWnd) 244 | { 245 | m_hWnd = hWnd; 246 | return *this; 247 | } 248 | }; 249 | 250 | typedef CDwmWindowT CDwmWindow; 251 | 252 | 253 | /////////////////////////////////////////////////////////////////////////////// 254 | // CDwmThumbnail - provides DWM thumbnail support 255 | 256 | template 257 | class CDwmThumbnailT : public TBase 258 | { 259 | public: 260 | // Data members 261 | HTHUMBNAIL m_hThumbnail; 262 | 263 | // Constructor 264 | CDwmThumbnailT(HTHUMBNAIL hThumbnail = NULL) : m_hThumbnail(hThumbnail) 265 | { 266 | } 267 | 268 | ~CDwmThumbnailT() 269 | { 270 | if(t_bManaged && m_hThumbnail != NULL) 271 | Unregister(); 272 | } 273 | 274 | // Operations 275 | CDwmThumbnailT& operator =(HTHUMBNAIL hThumbnail) 276 | { 277 | Attach(hThumbnail); 278 | return *this; 279 | } 280 | 281 | void Attach(HTHUMBNAIL hThumbnailNew) 282 | { 283 | if(t_bManaged && m_hThumbnail != NULL && m_hThumbnail != hThumbnailNew) 284 | Unregister(); 285 | m_hThumbnail = hThumbnailNew; 286 | } 287 | 288 | HTHUMBNAIL Detach() 289 | { 290 | HTHUMBNAIL hThumbnail = m_hThumbnail; 291 | m_hThumbnail = NULL; 292 | return hThumbnail; 293 | } 294 | 295 | HRESULT Register(HWND hwndDestination, HWND hwndSource) 296 | { 297 | ATLASSERT(::IsWindow(hwndDestination)); 298 | ATLASSERT(::IsWindow(hwndSource)); 299 | ATLASSERT(m_hThumbnail==NULL); 300 | if(!IsDwmSupported()) return E_NOTIMPL; 301 | return ::DwmRegisterThumbnail(hwndDestination, hwndSource, &m_hThumbnail); 302 | } 303 | 304 | HRESULT Unregister() 305 | { 306 | if(!IsDwmSupported()) return E_NOTIMPL; 307 | if(m_hThumbnail == NULL) return S_FALSE; 308 | HRESULT Hr = ::DwmUnregisterThumbnail(m_hThumbnail); 309 | if(SUCCEEDED(Hr)) m_hThumbnail = NULL; 310 | return Hr; 311 | } 312 | 313 | operator HTHUMBNAIL() const { return m_hThumbnail; } 314 | 315 | bool IsNull() const { return (m_hThumbnail == NULL); } 316 | 317 | HRESULT UpdateProperties(const DWM_THUMBNAIL_PROPERTIES* ptnProperties) 318 | { 319 | if(!IsDwmSupported()) return E_NOTIMPL; 320 | ATLASSERT(m_hThumbnail != NULL); 321 | return ::DwmUpdateThumbnailProperties(m_hThumbnail, ptnProperties); 322 | } 323 | 324 | // Attributes 325 | HRESULT QuerySourceSize(PSIZE pSize) 326 | { 327 | if(!IsDwmSupported()) return E_NOTIMPL; 328 | ATLASSERT(m_hThumbnail != NULL); 329 | return ::DwmQueryThumbnailSourceSize(m_hThumbnail, pSize); 330 | } 331 | }; 332 | 333 | typedef CDwmThumbnailT CDwmThumbnail; 334 | typedef CDwmThumbnailT CDwmThumbnailHandle; 335 | 336 | 337 | #ifdef __ATLTHEME_H__ 338 | 339 | /////////////////////////////////////////////////////////////////////////////// 340 | // CAeroControlImpl - Base class for controls on Glass 341 | 342 | template 343 | class CAeroControlImpl : 344 | public CThemeImpl, 345 | public CBufferedPaintImpl, 346 | public ATL::CWindowImpl 347 | { 348 | public: 349 | typedef CThemeImpl _themeClass; 350 | typedef CBufferedPaintImpl _baseClass; 351 | typedef ATL::CWindowImpl _windowClass; 352 | 353 | CAeroControlImpl() 354 | { 355 | m_PaintParams.dwFlags = BPPF_ERASE; 356 | } 357 | 358 | static LPCWSTR GetThemeName() 359 | { 360 | #ifdef _UNICODE 361 | return TBase::GetWndClassName(); 362 | #else 363 | ATLASSERT(!_T("Return UNICODE string of window classname / theme class")); 364 | return NULL; 365 | #endif // _UNICODE 366 | } 367 | 368 | // Message map and handlers 369 | BEGIN_MSG_MAP(CAeroControlImpl) 370 | MESSAGE_HANDLER(WM_CREATE, OnCreate) 371 | MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) 372 | CHAIN_MSG_MAP(_themeClass) 373 | CHAIN_MSG_MAP(_baseClass) 374 | END_MSG_MAP() 375 | 376 | LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) 377 | { 378 | T* pT = static_cast(this); 379 | pT->Init(); 380 | bHandled = FALSE; 381 | return 0; 382 | } 383 | 384 | LRESULT OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) 385 | { 386 | if(IsThemingSupported()) Invalidate(FALSE); 387 | bHandled = FALSE; 388 | return 0; 389 | } 390 | 391 | // Operations 392 | BOOL SubclassWindow(HWND hWnd) 393 | { 394 | ATLASSERT(m_hWnd == NULL); 395 | ATLASSERT(::IsWindow(hWnd)); 396 | BOOL bRet = _windowClass::SubclassWindow(hWnd); 397 | if(bRet) { 398 | T* pT = static_cast(this); 399 | pT->Init(); 400 | } 401 | return bRet; 402 | } 403 | 404 | // Implementation 405 | LRESULT DefWindowProc() 406 | { 407 | const _ATL_MSG* pMsg = m_pCurrentMsg; 408 | LRESULT lRes = 0; 409 | if(pMsg != NULL) 410 | lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); 411 | return lRes; 412 | } 413 | 414 | LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) 415 | { 416 | T* pT = static_cast(this); 417 | LRESULT lRes = 0; 418 | if( ::DwmDefWindowProc(pT->m_hWnd, uMsg, wParam, lParam, &lRes) ) return lRes; 419 | return _windowClass::DefWindowProc(uMsg, wParam, lParam); 420 | } 421 | 422 | void DoBufferedPaint(HDC hDC, RECT& rcPaint) 423 | { 424 | T* pT = static_cast(this); 425 | HDC hDCPaint = NULL; 426 | RECT rcClient = { 0 }; 427 | GetClientRect(&rcClient); 428 | m_BufferedPaint.Begin(hDC, &rcClient, m_dwFormat, &m_PaintParams, &hDCPaint); 429 | ATLASSERT(hDCPaint != NULL); 430 | pT->DoAeroPaint(hDCPaint, rcClient, rcPaint); 431 | m_BufferedPaint.End(); 432 | } 433 | 434 | void DoPaint(HDC /*hdc*/, RECT& /*rcClient*/) 435 | { 436 | DefWindowProc(); 437 | } 438 | 439 | // Overridables 440 | void Init() 441 | { 442 | T* pT = static_cast(this); 443 | SetThemeClassList(pT->GetThemeName()); 444 | if(m_lpstrThemeClassList != NULL) 445 | OpenThemeData(); 446 | } 447 | 448 | void DoAeroPaint(HDC hDC, RECT& /*rcClient*/, RECT& rcPaint) 449 | { 450 | DefWindowProc(WM_PAINT, (WPARAM) hDC, 0L); 451 | m_BufferedPaint.MakeOpaque(&rcPaint); 452 | } 453 | }; 454 | 455 | #endif // __ATLTHEME_H__ 456 | 457 | 458 | }; // namespace WTL 459 | 460 | 461 | #endif // __ATLDWM_H__ 462 | -------------------------------------------------------------------------------- /TXDViewer2/wtl81_12085/Include/atlresce.h: -------------------------------------------------------------------------------- 1 | // Windows Template Library - WTL version 8.1 2 | // Copyright (C) Microsoft Corporation. All rights reserved. 3 | // 4 | // This file is a part of the Windows Template Library. 5 | // The use and distribution terms for this software are covered by the 6 | // Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php) 7 | // which can be found in the file CPL.TXT at the root of this distribution. 8 | // By using this software in any fashion, you are agreeing to be bound by 9 | // the terms of this license. You must not remove this notice, or 10 | // any other, from this software. 11 | 12 | #ifndef __ATLRESCE_H__ 13 | #define __ATLRESCE_H__ 14 | 15 | #pragma once 16 | 17 | #ifndef _WIN32_WCE 18 | #error atlresCE.h is only for Windows CE 19 | #endif 20 | 21 | 22 | #ifdef RC_INVOKED 23 | #ifndef _INC_WINDOWS 24 | 25 | #define VS_VERSION_INFO 1 26 | 27 | #ifdef APSTUDIO_INVOKED 28 | #define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols 29 | #endif // APSTUDIO_INVOKED 30 | 31 | #ifndef WINVER 32 | #define WINVER 0x0400 // default to Windows Version 4.0 33 | #endif // !WINVER 34 | 35 | #if !defined(WCEOLE_ENABLE_DIALOGEX) 36 | #define DIALOGEX DIALOG DISCARDABLE 37 | #endif 38 | 39 | #include 40 | #define SHMENUBAR RCDATA 41 | 42 | #if defined(SHELLSDK_MODULES_AYGSHELL) 43 | #include 44 | #else 45 | #define NOMENU 0xFFFF 46 | #define IDS_SHNEW 1 47 | #define IDM_SHAREDNEW 10 48 | #define IDM_SHAREDNEWDEFAULT 11 49 | #endif 50 | #ifndef I_IMAGENONE 51 | #define I_IMAGENONE (-2) 52 | #endif 53 | 54 | #include 55 | 56 | #endif // !_INC_WINDOWS 57 | #endif // RC_INVOKED 58 | 59 | #include "atlres.h" 60 | 61 | #ifdef APSTUDIO_INVOKED 62 | #undef APSTUDIO_HIDDEN_SYMBOLS 63 | #endif // APSTUDIO_INVOKED 64 | 65 | // Visual Studio dialog editor bug fix 66 | #ifndef DS_FIXEDSYS 67 | #define DS_FIXEDSYS 0 68 | #endif 69 | 70 | #define IDC_INFOSTATIC 0xFFFE // == IDC_STATIC -1 71 | 72 | /////////////////////////////////////////////////////////////////////////////// 73 | // Smartphone and PPC 2005 Resource IDs 74 | 75 | // Command and associated string resource IDs 76 | #define ID_MENU_OK 0xE790 77 | #define ID_MENU_CANCEL 0xE791 78 | #define ID_MENU 0xE792 79 | #define ID_ACTION 0xE793 80 | #define ID_VIEW_FULLSCREEN 0xE802 81 | 82 | // MenuBar resource IDs 83 | #define ATL_IDM_MENU_DONE 0xE701 84 | #define ATL_IDM_MENU_CANCEL 0xE702 85 | #define ATL_IDM_MENU_DONECANCEL 0xE703 86 | 87 | // Default device MenuBar control ID and MenuBar resource ID 88 | #define ATL_IDW_MENU_BAR 0xE802 89 | 90 | // SmartPhone spinned controls ID offset for CSpinCtrl 91 | #define ATL_IDW_SPIN_ID 9999 92 | 93 | #endif // __ATLRESCE_H__ 94 | -------------------------------------------------------------------------------- /TXDViewer2_vs2005.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TXDViewer2", "TXDViewer2\TXDViewer2_vs2005.vcproj", "{FEC9D198-9774-4AD2-8160-25726CB63E68}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Debug|Win32.Build.0 = Debug|Win32 16 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Debug|x64.ActiveCfg = Debug|x64 17 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Debug|x64.Build.0 = Debug|x64 18 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Release|Win32.ActiveCfg = Release|Win32 19 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Release|Win32.Build.0 = Release|Win32 20 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Release|x64.ActiveCfg = Release|x64 21 | {FEC9D198-9774-4AD2-8160-25726CB63E68}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /x64/Release_vs2005/txdviewerdbcfg: -------------------------------------------------------------------------------- 1 | DevTest 2 | 172.16.102.142 3 | 5432 4 | dev_test 5 | public 6 | postgres 7 | postgres 8 | 102.146 9 | 172.16.102.146 10 | 5432 11 | NA13M3 12 | usauc1 13 | postgres 14 | 15 | OSM 16 | 10.224.75.96 17 | 5432 18 | OSM_ODBL 19 | %% 20 | postgres 21 | postgres 22 | --------------------------------------------------------------------------------