Skip to content

Commit ea520fd

Browse files
author
Tore Niermann
committed
Initial commit to github (Version 1.0.0)
0 parents  commit ea520fd

38 files changed

+6226
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/3rdparty/utfcpp*
2+
/3rdparty/zlib*
3+
/3rdparty/hdf5*
4+
/3rdparty/szip*

3rdparty/README.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See INSTALL.txt for required contents of this directory

INSTALL.txt

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
1. Introduction
2+
======================================================================
3+
4+
Their are two versions of the plugin.
5+
6+
* the GMS-2.X version, which is build using Visual Studio 2008
7+
and obviously requires the DMSDK for GMS 2.X
8+
9+
* the GMS-1.X version, which is build using Visual Studio 2003
10+
and obviously requires the DMSDK for GMS 1.X (aka DMSDK382)
11+
12+
For the DMSDKs contact Gatan or look on their website www.gatan.com.
13+
14+
2. Prerequisites
15+
======================================================================
16+
17+
The DMSDK must running work (examples will compile), so any prerequisites
18+
for the DMSDK (e.g. boost) must be properly installed.
19+
20+
The plugin depends on some 3rdparty libraries (for example the HDF5 library...).
21+
These must be separately downloaded and unpacked or linked to the directory
22+
names mentioned below
23+
24+
Required libraries:
25+
utfcpp
26+
* see http://utfcpp.sourceforge.net
27+
* version 2.3.1A was used for building the plugin
28+
* unpack to 3rdparty/utfcpp
29+
30+
zlib
31+
* see http://zlib.org
32+
* version 1.2.8 was used for building the plugin
33+
* unpack to 3rdparty/zlib
34+
35+
szip
36+
* see http://www.hdfgroup.org/HDF5
37+
* version version 2.1 was used for building the plugin
38+
* unpack to 3rdparty/szip
39+
* As there are special licensing issues with this library, the
40+
compression is disabled by the build instructions below. The
41+
decompression has no licensing problems.
42+
43+
hdf5
44+
* see http//www.hdfgroup.org/HDF5
45+
* Version 1.8.8 was used for the GMS-2.X plugin
46+
* Version 1.8.3 was used for the GMS-1.X plugin, due to the needed
47+
VS2003 support)
48+
* unpack to 3rdparty/hdf5
49+
50+
3. Building
51+
======================================================================
52+
53+
3.1 Build zlib
54+
--------------------------------------------------------------
55+
56+
This can be done from the Visual Studio command prompt. Go to the
57+
3rdparty/zlib directory and execute either
58+
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="inffas32.obj match686.obj"
59+
or
60+
nmake -f win32/Makefile.msc
61+
62+
3.2 Build szip
63+
--------------------------------------------------------------
64+
65+
For GMS-1.X:
66+
* Copy the vc2003/szip_static_vs2003.vcproj file to 3rdparty/szip/window/static
67+
* Open the 3rdparty/szip/windows/static/szip_static_vs2003.vcproj in Visual Studio 2003.
68+
69+
For GMS-2.X:
70+
* Open the 3rdparty/szip/windows/static/szip_static.vcproj in Visual Studio 2008.
71+
72+
The following steps are for both versions:
73+
* Remove line "#define HAVE_ENCODING" in SZconfig.h
74+
* Build the Release build
75+
76+
3.3 Build hdf5
77+
--------------------------------------------------------------
78+
79+
* Set up environment variables
80+
HDF5_EXT_ZLIB=YOURDIR\3rdparty\zlib\zlib.lib
81+
HDF5_EXT_SZIB=YOURDIR\3rdparty\szib\windows\static\lib\Win32\Release\libszip.lib
82+
* Call windows\copy_hdf.bat
83+
* For GMS-1.X: Open windows_vnet\proj\all\all.sln with Visual Studio 2003
84+
For GMS-2.X: Open windows\proj\all\all.sln with Visual Studio 2008
85+
* In Visual Studio add to the include directories (in Tools/Options/Projects and Solutions/VC++ Directories)
86+
3rdparty\zlib
87+
3rdparty\szib\src
88+
* IMPORTANT: In the "Release" configuration of the projects hdf5 set the Runtime Library (under
89+
C/C++/Code Generation) to Multi-threaded DLL (/MD).
90+
* Build the hdf5 project (Release build).
91+
92+
3.4 Build the plugin
93+
--------------------------------------------------------------
94+
95+
GMS-2.X:
96+
* Open vc2008/hdf5_plugin.vcproj with Visual Studio 2008
97+
* Add your DMSDK include and library directories to the VC++ Directories
98+
in Visual Studio (in Tools/Options/Projects and Solutions/VC++ Directories). The
99+
DMSDK is usally installed to C:\ProgramData\Gatan\DMSDK
100+
* Build the Release build
101+
* You should find your plugin as vc2008/Release/hdf5_plugin.dll
102+
103+
GMS-1.X:
104+
* Open vc2003/hdf5_plugin.vcproj with Visual Studio 2003
105+
* Add your DMSDK include and library directories to the VC++ Directories
106+
in Visual Studio (in Tools/Options/Projects/VC++ Directories).
107+
* Build the Release build
108+
* You should find your plugin as vc2003/Release/hdf5_GMS1X_x86.dll
109+
110+
3.5 Building the documentation
111+
--------------------------------------------------------------
112+
113+
The documentation requires the Sphinx Python tool (www.sphinx-doc.org).
114+
With Sphinx/Python properly installed, simply change into the doc
115+
directory and execute
116+
make WHATEVER
117+
to produce the documentation in the desired format. Call make
118+
without an argument to see a list of possible formats.
119+
120+
Tested with Sphinx version 1.3
121+
122+
4. Testing
123+
======================================================================
124+
125+
To run the tests, the unittest.s (in tests/unittest) script must be installed in DigitalMicrograph.
126+
Follow the instruction accompanied with the script for installation.
127+
128+
The tests access some test data files, which are also in the tests directory. In order to
129+
know that directory under DigitalMicrograph the tests must be immediately run after loading
130+
them into DigitalMicrograph. Otherwise the directory may not be discoverable anymore.
131+
132+
The tests are designed to succeed under GMS-2.X. Under GMS-1.X some magic numbers and functionality
133+
is different. To run change the arguments of the following calls
134+
135+
# Current directory
136+
GMS-2.X: GetApplicationDirectory(0, 0)
137+
GMS-1.X: GetApplicationDirectory(2, 0)
138+
139+
# Temporary directory
140+
GMS-2.X: GetApplicationDirectory(6, 0)
141+
GMS-1.X: GetApplicationDirectory(3, 0)
142+
143+
A known issue is that the handling of packed complex data is different and currently only works under GMS 2.X.
144+
145+
5. Install
146+
======================================================================
147+
148+
The Visual Studio project files are designed to produce different outputs, depending on the
149+
combination of target GMS version and platform. The plugins produced are:
150+
151+
GMS-1.X (32 bit): vc2008\Release\hdf5_GMS1X_x86.dll
152+
GMS-2.X (32 bit): vc2008\Release\hdf5_GMS2X_x86.dll
153+
GMS-2.X (64 bit): vc2008\x64\Release\hdf5_GMS2X_amd64.dll
154+
155+
For installation simply copy the correct DLL file into the plugin directory of your Digital
156+
Micrograph installation. By default these are:
157+
158+
GMS-2.X: c:\ProgramData\Gatan\Plugins
159+
GMS-1.X: c:\Program Files\Gatan\DigitalMicrograph\Plugins

README.txt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
HDF5 Plugin for DigitalMicrograph
2+
=================================
3+
4+
This is a plugin allowing to read and write HDF5 files under
5+
DigitalMicrograph by Gatan Inc.
6+
7+
Tested on
8+
DigitalMicrograph Version 1.8.X (32 Bit)
9+
DigitalMicrograph Version 2.3.X (32 Bit)
10+
11+
Usage
12+
=====
13+
14+
The plugin provides functions to be called from the DigitalMicrograph
15+
scripting language. An example script which can be installed into the
16+
menu for importing HDF5 files is provided under
17+
tests/CMD_import_hdf5.s
18+
19+
For details of the functions the plugin provides,
20+
see documentation in the doc/ directory.
21+
22+
Building and Installation
23+
=========================
24+
25+
For building instruction see INSTALL.txt file.
26+
27+
Copyright
28+
=========
29+
30+
The plugin itself is licensed under GPL v3+ (see below). Other parts of
31+
this software have different licenses. See the license information
32+
in the documentation for details.
33+
34+
HDF5 Plugin for DigitalMicrograph
35+
Copyright (C) 2012-2016 Tore Niermann
36+
37+
This program is free software: you can redistribute it and/or modify
38+
it under the terms of the GNU General Public License as published by
39+
the Free Software Foundation, either version 3 of the License, or
40+
(at your option) any later version.
41+
42+
This program is distributed in the hope that it will be useful,
43+
but WITHOUT ANY WARRANTY; without even the implied warranty of
44+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+
GNU General Public License for more details.
46+
47+
You should have received a copy of the GNU General Public License
48+
along with this program. If not, see <http://www.gnu.org/licenses/>.
49+
50+
* For copyright / license information see doc/license.rst file.
51+
52+
Disclaimer
53+
==========
54+
55+
All product and company names are trademarks or registered trademarks of
56+
their respective holders. Use of them does not imply any affiliation
57+
with or endorsement by them.
58+
59+
Author & Contact
60+
================
61+
62+
The plugin was written by Tore Niermann.
63+
Email: niermann at physik.tu-berlin.de

autohandle.h

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#ifndef HDF5_AUTOHANDLE_INC
2+
#define HDF5_AUTOHANDLE_INC
3+
4+
#include <hdf5.h>
5+
#include <algorithm>
6+
7+
// Forwards
8+
void debug(const char* fmt, ...);
9+
10+
typedef herr_t (*auto_handle_closer_t)(hid_t);
11+
12+
/**
13+
* A wrapper class for HDF5 handles (hid_t), that provides RAII semantics.
14+
* The class interface is designed like auto_ptr.
15+
* No method throws an exception.
16+
*/
17+
template <auto_handle_closer_t closer> class auto_handle
18+
{
19+
private:
20+
hid_t hid;
21+
22+
public:
23+
/** Default CTOR: Creates invalid handle. */
24+
auto_handle() throw (): hid(-1) {}
25+
26+
/** Copy CTOR: Transfers handle ownership to the newly created handle. */
27+
auto_handle(auto_handle<closer>& h) throw () : hid(h.hid) { h.hid = -1; }
28+
29+
/** Create handle from hid_t. */
30+
explicit auto_handle(hid_t id) throw () : hid(id)
31+
{
32+
// if (valid())
33+
// debug("CREATE %s hid=%x\n", typeid(*this).name(), hid);
34+
}
35+
36+
// DTOR
37+
~auto_handle() throw ()
38+
{
39+
if (valid()) {
40+
// debug("DESTROY %s hid=%x\n", typeid(*this).name(), hid);
41+
closer(hid);
42+
}
43+
}
44+
45+
/** Assign handle. Ownership is transferred to this class. */
46+
auto_handle& operator=(auto_handle<closer>& h) throw ()
47+
{
48+
reset(h.release());
49+
return *this;
50+
}
51+
52+
/** Returns true, if this is a valid handle */
53+
bool valid() const throw () { return hid >= 0; }
54+
55+
/** Swaps to handles. */
56+
void swap(auto_handle<closer>& h) throw () { std::swap(hid, h.hid); }
57+
58+
/** Resets this handle to a new value. */
59+
void reset(hid_t id = -1) throw ()
60+
{
61+
auto_handle<closer> tmp(id);
62+
swap(tmp);
63+
}
64+
65+
/** Returns handle id */
66+
hid_t get() const throw () { return hid; }
67+
68+
/** Releases handle id. This is an invalid handle afterwards. */
69+
hid_t release() throw ()
70+
{
71+
hid_t id = hid;
72+
hid = -1;
73+
return id;
74+
}
75+
};
76+
77+
template <auto_handle_closer_t closer>
78+
inline void swap(auto_handle<closer>& h1, auto_handle<closer>&h2)
79+
{
80+
h1.swap(h2);
81+
}
82+
83+
typedef auto_handle<H5Oclose> object_handle_t;
84+
typedef auto_handle<H5Tclose> type_handle_t;
85+
typedef auto_handle<H5Sclose> space_handle_t;
86+
typedef auto_handle<H5Aclose> attr_handle_t;
87+
typedef auto_handle<H5Fclose> file_handle_t;
88+
typedef auto_handle<H5Dclose> dataset_handle_t;
89+
typedef auto_handle<H5Pclose> plist_handle_t;
90+
typedef auto_handle<H5Gclose> group_handle_t;
91+
92+
#endif // HDF5_AUTOHANDLE_INC

0 commit comments

Comments
 (0)