├── .gitignore ├── .gitmodules ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── configure.in ├── doc ├── class_diagram.dia └── class_diagram.png ├── icons ├── lagicon.png └── lagicon_small.png ├── lag.ui ├── lagfonts ├── DejaVuSansMono.ttf ├── FreeMono.ttf └── README.txt ├── lidarquadtree ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── configure.in ├── doxygen_settings ├── lidarquadtree.pc.in └── src │ ├── Boundary.h │ ├── CacheMinder.cpp │ ├── CacheMinder.h │ ├── CollisionDetection.cpp │ ├── CollisionDetection.h │ ├── LidarPoint.cpp │ ├── LidarPoint.h │ ├── Point.cpp │ ├── Point.h │ ├── PointBucket.cpp │ ├── PointBucket.h │ ├── PointData.h │ ├── Quadtree.cpp │ ├── Quadtree.h │ ├── QuadtreeExceptions.h │ ├── QuadtreeNode.cpp │ └── QuadtreeNode.h ├── src ├── BoxOverlay.cpp ├── BoxOverlay.h ├── ClassifyWorker.cpp ├── ClassifyWorker.h ├── Colour.cpp ├── Colour.h ├── DrawWorker.cpp ├── DrawWorker.h ├── FileUtils.cpp ├── FileUtils.h ├── LagDisplay.cpp ├── LagDisplay.h ├── LoadWorker.cpp ├── LoadWorker.h ├── MathFuncs.cpp ├── MathFuncs.h ├── PointFilter.h ├── Profile.cpp ├── Profile.h ├── ProfileTypes.h ├── ProfileWorker.cpp ├── ProfileWorker.h ├── SaveWorker.cpp ├── SaveWorker.h ├── SelectionBox.cpp ├── SelectionBox.h ├── TwoDeeOverview.cpp ├── TwoDeeOverview.h ├── Worker.h ├── config.h ├── geoprojectionconverter.cpp ├── geoprojectionconverter.hpp ├── lag.cpp └── ui │ ├── AdvancedLoadDialog.cpp │ ├── AdvancedLoadDialog.h │ ├── AdvancedOptionsWindow.cpp │ ├── AdvancedOptionsWindow.h │ ├── FileOpener.cpp │ ├── FileOpener.h │ ├── FileSaver.cpp │ ├── FileSaver.h │ ├── ProfileWindow.cpp │ ├── ProfileWindow.h │ ├── README │ ├── TwoDeeOverviewWindow.cpp │ └── TwoDeeOverviewWindow.h └── ubuntu-Makefile.patch /.gitignore: -------------------------------------------------------------------------------- 1 | # Automake junk 2 | *.deps/ 3 | *Makefile 4 | *Makefile.in 5 | config.* 6 | configure 7 | *.m4 8 | *autom4te.cache/ 9 | depcomp 10 | *install-sh 11 | *ltmain.sh 12 | 13 | # Compiled executable 14 | lag 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lastools"] 2 | path = lastools 3 | url = https://github.com/arsf/LAStools.git 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Andrew Chambers 2 | Haraldur Tristan Gunnarsson 3 | Jan Holownia 4 | Berin Smaldon 5 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2012-02-08 Jan Holownia 2 | * general: Moved LAG to use laslib library instead of liblas, added support for las 1.3 with modified quadtree. 3 | 4 | 2012-02-17 Jan Holownia 5 | * general: Fixed ascii support, can now load and save ascii files correctly. Removed AsciiLoader from the 6 | quadtree and replaced it with overloaded load methods. 7 | * FileSaver.cpp: Added option to specify scale factors for ascii files, fixed segfault occuring sometimes 8 | when saving multiple files. 9 | * FileOpener.cpp: Added option to specify scale factors for ascii files. 10 | * lag.ui: Added controls to specify scale factors or use default laslib values (0.01). 11 | 12 | 2012-03-08 Jan Holownia 13 | * general: Added some exception handling, possible minor performance improvements 14 | * all UI classes: Partialy rewritten most of the classes to improve maintainability, improved interface, 15 | refactored code, added some missing delete statements, comments etc. 16 | * Colour.cpp: Added comparison operators (==, !=) to simplify class interface. 17 | 18 | 2012-03-09 Jan Holownia 19 | * general/quadtree: Fixed a bug which would cause some incorrect points to load when using the fence. 20 | 21 | 2012-03-15 Jan Holownia 22 | * general: Cleaned up unused code, refactored and optimised some parts. 23 | 24 | 2012-03-27 Jan Holownia 25 | * FileOpener.cpp: Added the code to clean up after quadtree. It has to be here because this class creates 26 | the lidardata quadtree. It should be reorganised though, especially the null pointers 27 | passed from main(). 28 | 29 | 2012-03-28 Jan Holownia 30 | * Profile.cpp: Fixed a memory leak in Profile::classify(). 31 | 32 | 2012-04-02 Jan Holownia 33 | * general: Improved responsiveness by tuning some of the rendering parameters. Added an option to 34 | turn on/off full refresh while panning. Added an option to change background colour. 35 | * lag.cpp: Removed the misleading null pointers passed around for no reason and altered constructors 36 | of most classes to reflect this change. 37 | 38 | 2012-04-12 Jan Holownia 39 | * general: Removed loading errors files. Added vertical slicing (only use data in given z range). 40 | Added 'Super zoom' option which zooms in to points very closely. Added Heights dialog 41 | to profile window which shows average heights and elevation differences for selected data. 42 | * lag.ui: Modified toolbars to look more consistent and added controls for new functionality. 43 | * MathFuncs.cpp: Modified vetpoints() method to exclude points outside given z values range. 44 | 45 | 2012-04-20 Jan Holownia 46 | * general: Added options to handle latlong files and ability to convert between latlong and UTM. 47 | Added quandtree information dialog. Removed unused menu options. 48 | * TwoDeeOverview: Added option to display data as UTM or latlong. 49 | 50 | 2012-05-10 Jan Holownia 51 | * general: Improved superzoom. Added an option to excude noise points when calculating average heights 52 | in the profile. All long-running tasks are now in separate threads so the GUI doesn't lock. 53 | * Worker.h: Added as a base class for long-running tasks. Also added the following classes which inherit 54 | from it: LoadWorker, SaveWorker, ProfileWorker, ClassifyWorker. The last two use existing 55 | Profile class methods and can be improved by moving the logic into the worker calsses. Thread 56 | safety needs to be improved (mutexes in get/set methods of variables accessed from multiple 57 | threads). 58 | 59 | 2012-05-23 Jan Holownia 60 | * general: Improved thread safety - no more random segfaults. Keys 1-7 can now be used in profile window 61 | to quickly change classification. 62 | * LoadWorker.cpp: Fixed a bug where Adding files to an existing quadtree would sometimes not work correctly. 63 | Improved handling of incorrect files and exceptions during loading. 64 | * ProfileWindow: Added Glib::Mutex as a member to protect critical sections (drawProfile()). This could be 65 | as there is still some GUI locking. Some of the code from loadProfile() could probably be moved 66 | to ProfileWorker class. The drawing methods are a mess and need to be fixed at some point. 67 | 68 | 2012-06-28 Jan Holownia 69 | * general: Moved loading and saving of points to LAG from the quadtree. Added progress dialogs for loading 70 | and saving. Improved the layout of Load and Save dialogs. Added Advanced Load Dialog. Fixed some 71 | more memory leaks (Profile::load_profile). 72 | * FileOpener.cpp: An AdvanceLoadDialog can now be opened which holds options for quadtree creation and allows to 73 | chose filters to be used when loading files. LASreadOpener.parse() function is used to create 74 | the filter and the arguments are held in new PointFilter object, a member of AdvancedLoadDialog 75 | which is then passed to LoadWorker and converted to char* [] argv for the parse() function. 76 | * LoadWorker.cpp: All loading functionality has now been moved here so the points are loaded using LASreader and 77 | then inserted directly into the quadtree. Projection conversion has also been implemented here. 78 | Similar changes have been made to SaveWorker. 79 | * FileUtils.cpp: Added to hold various generic functions used by both LoadWorker and SaveWorker. 80 | 81 | 2012-06-29 Jan Holownia 82 | * Profile.cpp: Fixed a problem with Z scale height labels not being displayed in the Profile window. 83 | * LoadWorker.cpp: Changed tmpnam() to mksptemp() for creation of temporary files, to get rid of the 84 | compiler warning about tmpname() being unsafe. 85 | 86 | 2012-07-10 Jan Holownia 87 | * geoprojectionconverter: Added for projection conversions. Also there is a modified code at line 4665 88 | which redirects stderrr to /dev/null to suppress warning messages so if you 89 | want to get some spam on the screen, remove this line. 90 | 91 | 2012-07-12 Jan Holownia 92 | * general: Replaced standard malloc with jemalloc for improved memory consumption. Fixed memory 93 | fragmentation. 94 | * FileOpener.cpp: Added an option to AdvancedLoad dialog to allow setting location where quadtree cache 95 | files will be stored. The default location is now set to "tmp" but this should be changed 96 | to boost::temp_folder_name() which comes with boost::filesystem 1.46. 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile.am for LiDAR Analysis GUI 2 | 3 | AUTOMAKE_OPTIONS = subdir-objects 4 | bin_PROGRAMS = lag 5 | AM_CXXFLAGS=-Wall -Wextra -DLINUX 6 | # allow automake to find any required extra m4 macros 7 | ACLOCAL_AMFLAGS = -I m4 8 | 9 | lag_SOURCES = src/lag.cpp src/ui/AdvancedOptionsWindow.cpp \ 10 | src/ui/FileOpener.cpp src/MathFuncs.cpp src/TwoDeeOverview.cpp \ 11 | src/BoxOverlay.cpp src/ui/FileSaver.cpp src/Profile.cpp \ 12 | src/ui/TwoDeeOverviewWindow.cpp src/LagDisplay.cpp src/ui/ProfileWindow.cpp \ 13 | src/Colour.cpp src/SelectionBox.cpp src/LoadWorker.cpp src/SaveWorker.cpp \ 14 | src/ProfileWorker.cpp src/ClassifyWorker.cpp src/Worker.h src/FileUtils.cpp \ 15 | src/ui/AdvancedLoadDialog.cpp src/geoprojectionconverter.cpp \ 16 | src/DrawWorker.cpp 17 | 18 | lag_CPPFLAGS = @GTKmm_CFLAGS@ @GTKGLextmm_CFLAGS@ @GThread_CFLAGS@ @lidarquadtree_CFLAGS@ 19 | lag_LDFLAGS = @GTKmm_LIBS@ @GTKGLextmm_LIBS@ @GThread_LIBS@ @lidarquadtree_LIBS@ -ljemalloc -lboost_system 20 | lagdir = $(prefix)/share/lag 21 | lag_DATA = lag.ui 22 | lagiconsdir = $(prefix)/share/lag/icons 23 | lagicons_DATA = icons/* 24 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | LAG 1.2.1 (2012-07-12) 2 | 3 | * Improved memory consumption 4 | * Possible performance improvements 5 | 6 | LAG 1.2.0 (2012-07-10) 7 | 8 | * Major GUI improvements (new layout, threads, progress bars) 9 | * Several new tools (vertical slicing, superzoom, average heights) 10 | * Loading filters 11 | * Support for latlong projection 12 | * Improved error handling 13 | * Performance optimisations 14 | * bugfixes 15 | 16 | 17 | LAG 1.1.0 (2012-02-04) 18 | 19 | * Moved to use Laslib in place of Liblas 20 | * Support for LAS 1.3 format 21 | * Full support for ASCII files 22 | * Faster rendering 23 | * bugfixes 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | LAG - LiDAR Analysis GUI 2 | ======================== 3 | 4 | This file contains the following sections: 5 | 6 | GENERAL NOTES 7 | INSTALLATION 8 | LICENSE 9 | 10 | GENERAL NOTES 11 | ============= 12 | LAG is a software for visualisation, analysis and processing of LiDAR data. It has 13 | been initially created at Airborne Reasearch and Survey faciliy in Plymouth Marine 14 | Laboratory to help with data processing. 15 | 16 | For more information see: [website?] 17 | For user's guide see: http://arsf-dan.nerc.ac.uk/trac/wiki/Processing/laguserguide 18 | If you are a developer see: http://arsf-dan.nerc.ac.uk/trac/wiki/Processing/lagdevelopersfaq 19 | 20 | INSTALLATION 21 | ============ 22 | 23 | Required Dependencies 24 | --------------------- 25 | 26 | To be able to build LAG you will need a compiled version of lidarquadtree and 27 | you may need to modify Makefile.am to point to its location. 28 | 29 | The following libraries are required to make LAG compile. 30 | * boost 31 | * GTKmm 32 | * GTKGLextmm 33 | * GThread 34 | * libgeotiff 35 | 36 | * laslib 37 | * lidarquadtree 38 | 39 | laslib 40 | ------ 41 | 42 | LASlib, courtesy of Martin Isenburg, is a component of LAStools used in LAG for 43 | handling LAS reading and writing. However, the version provided on the LAStools 44 | website (http://www.cs.unc.edu/~isenburg/lastools/) is not made or intended for 45 | use as a standard linux library. This means that every program intending to use 46 | it must bundle the entire library with every distribution. 47 | 48 | In keeping with a more standard linux/gnu build+release process, a patched 49 | version of LAStools has been bundled with LAG. This patch changes only the 50 | Makefiles used to build LASlib, to support both static and dynamic linking, and 51 | an installation procedure which allows other programs to utilise laslib as 52 | though it were a standard linux library. 53 | 54 | This also renames "liblas" to "liblaslib" to be more distinct from the 55 | (unsupported) libLAS library. This should make it possible to use libLAS and 56 | laslib alongside each other on the same system, but as a side effect, also 57 | breaks backwards compatibility with any existing laslib programs. 58 | 59 | lidarquadtree 60 | ------------- 61 | 62 | Lidarquadtree is a library originally built and used for LAG. It features disk 63 | caching of points to allow it to load potentially very huge datasets and still 64 | support spatial indexing, meaning it can be using for LAS processing. 65 | 66 | It will need to be built and installed before LAG can be compiled. 67 | 68 | Ubuntu Linux Users 69 | ------------------ 70 | 71 | Ubuntu linux users will find, and other linux users dependent on distribution, 72 | may find that ubuntu fails to compile towards the end of the process, with a 73 | lot of messages including "undefined reference to" about halfway through. 74 | 75 | This has been seen in Ubuntu 11.10 and 12.04. 76 | 77 | If this happens, you have two options: 78 | 1) Install the binutils-gold package before compiling 79 | 2) After ./configure and before running make, apply the provided patch: 80 | patch Makefile < ubuntu-Makefile.patch 81 | 82 | Compiling on GNU/Linux x86 83 | -------------------------- 84 | 85 | This codebase uses the GNU packaging tools. To get things to a sane state 86 | after checkout, do: 87 | 88 | libtoolize && autoheader && aclocal && automake --add-missing && autoconf 89 | 90 | Depending on where you've installed laslib, you may need to do the following 91 | to allow configure to find it: 92 | 93 | export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/ 94 | 95 | Then you can do the normal: 96 | 97 | ./configure 98 | make 99 | make install 100 | 101 | Compiling on win32 102 | ------------------ 103 | 104 | Hopefully in the future. :-) 105 | 106 | LICENSE 107 | ======= 108 | 109 | LAG is licensed under the GNU General Public License, version 2. 110 | Read the file COPYING in the source distribution for details. 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LAG - LiDAR Analysis GUI 2 | ======================== 3 | 4 | This file contains the following sections: 5 | 6 | GENERAL NOTES 7 | INSTALLATION 8 | LICENSE 9 | 10 | GENERAL NOTES 11 | ============= 12 | LAG is a software for visualisation, analysis and processing of LiDAR data. It has 13 | been initially created at NERC Airborne Reasearch Faciliy Data Analysis Node (NERC-ARF-DAN) in Plymouth Marine 14 | Laboratory to help with data processing. 15 | 16 | For user's guide see: https://nerc-arf-dan.pml.ac.uk/trac/wiki/Processing/laguserguide 17 | 18 | If you are a developer see: https://nerc-arf-dan.pml.ac.uk/trac/wiki/Processing/lagdevelopersfaq 19 | 20 | INSTALLATION 21 | ============ 22 | 23 | Required Dependencies 24 | --------------------- 25 | 26 | To be able to build LAG you will need a compiled version of lidarquadtree and 27 | you may need to modify Makefile.am to point to its location. 28 | 29 | The following libraries are required to make LAG compile. 30 | * boost 31 | * GTKmm 32 | * GTKGLextmm 33 | * GThread 34 | * libgeotiff 35 | 36 | * laslib 37 | * lidarquadtree 38 | 39 | laslib 40 | ------ 41 | 42 | LASlib, courtesy of Martin Isenburg, is a component of LAStools used in LAG for 43 | handling LAS reading and writing. However, the version provided on the LAStools 44 | website (http://www.cs.unc.edu/~isenburg/lastools/) is not made or intended for 45 | use as a standard linux library. This means that every program intending to use 46 | it must bundle the entire library with every distribution. 47 | 48 | In keeping with a more standard linux/gnu build+release process, a patched 49 | version of LAStools, forked from the main version, is available from: 50 | 51 | https://github.com/arsf/LAStools 52 | 53 | This patch changes only the Makefiles used to build LASlib, to support both 54 | static and dynamic linking, and an installation procedure which allows other 55 | programs to utilise laslib as though it were a standard linux library. 56 | 57 | This also renames "liblas" to "liblaslib" to be more distinct from the 58 | (unsupported) libLAS library. This should make it possible to use libLAS and 59 | laslib alongside each other on the same system, but as a side effect, also 60 | breaks backwards compatibility with any existing laslib programs. 61 | 62 | lidarquadtree 63 | ------------- 64 | 65 | Lidarquadtree is a library originally built and used for LAG. It features disk 66 | caching of points to allow it to load potentially very huge datasets and still 67 | support spatial indexing, meaning it can be using for LAS processing. 68 | 69 | It will need to be built and installed before LAG can be compiled. 70 | 71 | Ubuntu Linux Users 72 | ------------------ 73 | 74 | Ubuntu linux users will find, and other linux users dependent on distribution, 75 | may find that ubuntu fails to compile towards the end of the process, with a 76 | lot of messages including "undefined reference to" about halfway through. 77 | 78 | This has been seen in Ubuntu 11.10 and 12.04. 79 | 80 | If this happens, you have two options: 81 | 1) Install the binutils-gold package before compiling 82 | 2) After ./configure and before running make, apply the provided patch: 83 | patch Makefile < ubuntu-Makefile.patch 84 | 85 | Compiling on GNU/Linux x86 86 | -------------------------- 87 | 88 | This codebase uses the GNU packaging tools. To get things to a sane state 89 | after checkout, do: 90 | 91 | libtoolize && autoheader && aclocal && automake --add-missing && autoconf 92 | 93 | Depending on where you've installed laslib, you may need to do the following 94 | to allow configure to find it: 95 | 96 | export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/ 97 | 98 | Then you can do the normal: 99 | 100 | ./configure 101 | make 102 | make install 103 | 104 | Compiling on win32 105 | ------------------ 106 | 107 | Hopefully in the future. :-) 108 | 109 | LICENSE 110 | ======= 111 | 112 | LAG is licensed under the GNU General Public License, version 2. 113 | Read the file COPYING in the source distribution for details. 114 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ(2.59) 5 | AC_INIT([LiDAR Analysis GUI], [1.1.1] , [arsf-processing@pml.ac.uk]) 6 | AC_CONFIG_SRCDIR([src]) 7 | AM_INIT_AUTOMAKE([1.10 -Wall no-define]) 8 | AC_CONFIG_HEADERS([config.h]) 9 | # use some not always publicly available autoconf magic 10 | AC_CONFIG_MACRO_DIR([m4]) 11 | 12 | # we want things to break quickly 13 | : ${CXXFLAGS="-O2"} 14 | 15 | # Debugging purposes 16 | #: ${CXXFLAGS="-g"} 17 | 18 | # Checks for programs. 19 | AC_PROG_CXX 20 | #AC_PROG_INSTALL 21 | 22 | # Checks for libraries using pkg-config 23 | #PKG_CHECK_MODULES([DEPS], [gtkmm-2.4 gtkglextmm-1.2 gthread-2.0 libgeotiff lidarquadtree] ) 24 | PKG_CHECK_MODULES([GTKmm], [gtkmm-2.4]) 25 | #PKG_CHECK_MODULES([GTKmm], [gtkmm-3.0]) 26 | PKG_CHECK_MODULES([GTKGLextmm], [gtkglextmm-1.2]) 27 | PKG_CHECK_MODULES([GThread], [gthread-2.0]) 28 | # strictly speaking, this is a sub-dependency of lidarquadtree, but automake doesn't check it 29 | # and fails silently in the makefile. This makes it explicit 30 | PKG_CHECK_MODULES([laslib], [laslib]) 31 | PKG_CHECK_MODULES([lidarquadtree], [lidarquadtree >= 1.3]) 32 | 33 | # Checks for header files. 34 | AC_HEADER_STDC 35 | AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) 36 | 37 | # Checks for typedefs, structures, and compiler characteristics. 38 | 39 | # Checks for library functions. 40 | 41 | AC_CONFIG_FILES([Makefile]) 42 | AC_OUTPUT 43 | -------------------------------------------------------------------------------- /doc/class_diagram.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/doc/class_diagram.dia -------------------------------------------------------------------------------- /doc/class_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/doc/class_diagram.png -------------------------------------------------------------------------------- /icons/lagicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/icons/lagicon.png -------------------------------------------------------------------------------- /icons/lagicon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/icons/lagicon_small.png -------------------------------------------------------------------------------- /lagfonts/DejaVuSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/lagfonts/DejaVuSansMono.ttf -------------------------------------------------------------------------------- /lagfonts/FreeMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arsf/lag/e9780b62cca12e8e0acd2412d5625b10ac6a30d2/lagfonts/FreeMono.ttf -------------------------------------------------------------------------------- /lagfonts/README.txt: -------------------------------------------------------------------------------- 1 | these fonts are assumed to be present on the system and this directory is only here for "backup" 2 | -------------------------------------------------------------------------------- /lidarquadtree/AUTHORS: -------------------------------------------------------------------------------- 1 | Andrew Chambers 2 | Christopher Finerty 3 | Jan Holownia 4 | Berin Smaldon 5 | -------------------------------------------------------------------------------- /lidarquadtree/ChangeLog: -------------------------------------------------------------------------------- 1 | 2012-03-15 Jan Holownia 2 | * general: Cleaned up unused code, refactored some parts for better maintainability. 3 | * general: Removed unnecessary threading. 4 | * AsciiLoader.cpp: Removed. LasLoader now deals with ascii files. 5 | * Point.cpp: Rewritten for slightly better performance. 6 | * LidarPoint.cpp: Modified to hold las 1.3 data. (It's now too big and affects performance!) 7 | * LasLoader.cpp: Rewritten to use laslib library. Added methods to read ascii data with or 8 | without specifying scale factors. 9 | * LasSaver.cpp: Rewritten to use laslib library. Added methods to save waveform data. 10 | * Quadtree.cpp: Fixed a bug where using a fence would include some incorrect points. 11 | 12 | 2012-03-20 Jan Holownia 13 | * Quadtree.cpp: Fixed possible memory leak when loading using a fence and when saving files. 14 | 15 | 2012-03-26 Jan Holownia 16 | * PointData.h: Added. A struct to hold LAS 1.3 waveform attributes. 17 | * LidarPoint.cpp: Reduced size to improve overall performance. Removed waveform related attributes 18 | and moved the to PointData. Added dataindex which holds an index to PointData 19 | object in a file. 20 | * LasLoader.cpp: Now creates temporary files which hold PointData objects. Added static members to 21 | keep track of loaded points and indexing of temporary files. A separate file is 22 | created for each flightline. 23 | * LasSaver.cpp: Modified to read PointData objects from temporary files when saving. 24 | 25 | 2012-03-27 Jan Holownia 26 | * Quadtree.cpp: Added code which properly cleans up temporary files left by the quadtree. 27 | * PointBucket.cpp: Modified setPoint() method to used precomputed values for inserting into subbuckets. 28 | They are stored in int* pointInterval and calculated in constructor. Big performance 29 | improvement (~50%). 30 | 31 | 2012-04-04 Jan Holownia 32 | * Quadtree.cpp: Fixed a huge memory usage caused by using potentially unlimited size array in load method. 33 | * LasLoader.cpp: Modified so it now reads data in chunks. 34 | 35 | 2012-04-12 Jan Holownia 36 | * Quadtree.cpp: Fixed a bug where point skipping would not work corectly. 37 | * LasSaver.cpp: Fixed a bug when saving a LAS file to ascii would set time to 0. 38 | 39 | 2012-04-20 Jan Holownia 40 | * general: Added support for latlong projection. 41 | * LasLoader.cpp: Added conversion method to automatically convert latlong points to UTM when loading. 42 | * LasSaver.cpp: Added conversion methods which allow specifying projection of the output file between 43 | latlong and UTM. UTM to latlong conversion not fully working. 44 | 45 | 2012-05-10 Jan Holownia 46 | * general: Projection conversion now fixed except UTM to latlong. There is a problem with determining 47 | correct UTM zone, because alspp puts projection information under wrong geokeys in VLRs. 48 | UTM files outputted by lag work fine. 49 | 50 | 2012-05-23 Jan Holownia 51 | * QuadtreeNode.cpp: Fixed splitNode() bug which wouldn't allow to add new points to the quadtree after filling a 52 | bucket, when using Add to load files in LAG to load files. 53 | 54 | 2012-06-28 Jan Holownia 55 | * General: Started Removing LasLoader and LasReader. They are still included, however the should be 56 | deleted eventually and are no longer maintained. The loading and saving of points is now 57 | handles outside of the quadtree. This make the maintenance easier and and lowers memory 58 | consumption as no additional buffer is required. 59 | * Quadtree.cpp: Added adjustBoundary method, which has to be used when loading points from multiple files. 60 | 61 | 2012-07-09 Jan Holownia 62 | * General: Removed LasLoader, LasSaver and geoprojection converter as loading/saving is no longer done 63 | through the quadtree. 64 | * Quadtree.cpp: Removed constructors based on LasLoader, load() method and save_points() method. Cleaned up 65 | the interface. 66 | * Quadtree.cpp: Added function getAllBuckets() which returns all buckets from the quadtree. 67 | 68 | 2012-07-11 Jan Holownia 69 | * LidarPoint.cpp: Added an assignment operator which assignes values to the point provided a LASpoint object 70 | which makes it easier to use (eg. LidarPoint point = reader->point; intead of LidarPoint 71 | point = LidarPoint(reader->point.get_x(), reader->point.get_y() ...). 72 | * PointData.cpp: Added an assignment operator similarly to the LidarPoint, but it takes LASpoint.wavepacket 73 | object. 74 | 75 | 2012-07-12 Jan Holownia 76 | * general: Replaced standard malloc with jemalloc to solve memory fragmentation issue. The memory usage 77 | dropped down by around 60% and to desired level. Finally. 78 | * Quadtree.cpp: Added cacheFolder as an argument to the constructor which specifies the location of quadtree 79 | cache. 80 | 81 | -------------------------------------------------------------------------------- /lidarquadtree/Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile.am for LiDAR QuadTree 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | AUTOMAKE_OPTIONS = subdir-objects 6 | lib_LTLIBRARIES = liblidarquadtree.la 7 | AM_CXXFLAGS=-Wall -Wextra -DLINUX 8 | liblidarquadtree_la_SOURCES = src/CollisionDetection.cpp src/LidarPoint.cpp src/Point.cpp src/PointBucket.cpp src/QuadtreeNode.cpp src/CacheMinder.cpp src/Quadtree.cpp src/PointData.h 9 | liblidarquadtree_ladir= $(includedir)/lidar/quadtree 10 | liblidarquadtree_la_HEADERS = src/Boundary.h \ 11 | src/CacheMinder.h src/CollisionDetection.h \ 12 | src/LidarPoint.h \ 13 | src/PointBucket.h src/Point.h src/QuadtreeExceptions.h src/Quadtree.h \ 14 | src/QuadtreeNode.h src/PointData.h 15 | liblidarquadtree_la_CPPFLAGS = $(laslib_CFLAGS) 16 | liblidarquadtree_la_LIBADD = $(laslib_LIBS) 17 | # pkgconfig creation and installation 18 | # see http://www.eyrie.org/~eagle/notes/style/build.html 19 | pkgconfigdir = $(libdir)/pkgconfig 20 | nodist_pkgconfig_DATA = lidarquadtree.pc 21 | lidarquadtree.pc: $(srcdir)/lidarquadtree.pc.in 22 | sed -e 's![@]prefix[@]!$(prefix)!g' \ 23 | -e 's![@]exec_prefix[@]!$(exec_prefix)!g' \ 24 | -e 's![@]includedir[@]!$(includedir)!g' \ 25 | -e 's![@]libdir[@]!$(libdir)!g' \ 26 | -e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \ 27 | $(srcdir)/lidarquadtree.pc.in > $@ 28 | AM_LDFLAGS = -version-info 0:1:0 -llzo2 -llaslib -ljemalloc 29 | -------------------------------------------------------------------------------- /lidarquadtree/NEWS: -------------------------------------------------------------------------------- 1 | lidarquadtree 1.1 (2012-07-12) 2 | 3 | * fixed memory fragmentation problem 4 | * much lower memory consumption 5 | * improved performance 6 | 7 | 8 | lidarquadtree 1.0 (2012-07-09) 9 | 10 | * uses Laslib library in place of Liblas 11 | * support for LAS 1.3 point format 12 | * removed a lot of unnecessary code 13 | * performance optimisations 14 | * bugfixes 15 | -------------------------------------------------------------------------------- /lidarquadtree/README: -------------------------------------------------------------------------------- 1 | lidarquadtree library 2 | ===================== 3 | 4 | This file contains the following sections: 5 | 6 | GENERAL NOTES 7 | INSTALLATION 8 | LICENSE 9 | 10 | GENERAL NOTES 11 | ============= 12 | 13 | Lidarquadtree is a library initially created for LiDAR Analysis GUI (LAG). 14 | It provides an efficient data structure for storing and indexing points. 15 | For more information see: [website?] 16 | 17 | INSTALLATION 18 | ============ 19 | 20 | Dependencies 21 | ------------ 22 | 23 | A few libraries are required to make this library compile. 24 | * liblzo2 25 | * laslib 26 | 27 | Compiling on GNU/Linux x86 28 | -------------------------- 29 | 30 | This codebase uses the GNU packaging tools. To get things to a sane state 31 | after checkout, do: 32 | 33 | libtoolize && autoheader && aclocal && automake --add-missing && autoconf 34 | 35 | Then you can do the normal: 36 | 37 | ./configure 38 | make 39 | make install 40 | 41 | Use make clean if you want a fresh rebuild. The resulting .so library will be put in .libs 42 | and installed in (prefix)/lib/lidar/quadtree. 43 | 44 | Compiling on win32 45 | ------------------ 46 | 47 | Hopefully in the future. :-) 48 | 49 | Documentation 50 | ------------- 51 | 52 | To make the docs, type: 53 | 54 | doxygen doxygen_settings 55 | 56 | Which will create html documentation in doc/html. 57 | 58 | LICENSE 59 | ======= 60 | 61 | See COPYING for the GNU GENERAL PUBLIC LICENSE. 62 | -------------------------------------------------------------------------------- /lidarquadtree/README.md: -------------------------------------------------------------------------------- 1 | lidarquadtree library 2 | ===================== 3 | 4 | This file contains the following sections: 5 | 6 | GENERAL NOTES 7 | INSTALLATION 8 | LICENSE 9 | 10 | GENERAL NOTES 11 | ============= 12 | 13 | Lidarquadtree is a library initially created for LiDAR Analysis GUI (LAG). 14 | It provides an efficient data structure for storing and indexing points. 15 | 16 | INSTALLATION 17 | ============ 18 | 19 | Dependencies 20 | ------------ 21 | 22 | A few libraries are required to make this library compile. 23 | * liblzo2 24 | * laslib 25 | 26 | Compiling on GNU/Linux x86 27 | -------------------------- 28 | 29 | This codebase uses the GNU packaging tools. To get things to a sane state 30 | after checkout, do: 31 | 32 | libtoolize && autoheader && aclocal && automake --add-missing && autoconf 33 | 34 | Then you can do the normal: 35 | 36 | ./configure 37 | make 38 | make install 39 | 40 | Use make clean if you want a fresh rebuild. The resulting .so library will be put in .libs 41 | and installed in (prefix)/lib/lidar/quadtree. 42 | 43 | Compiling on win32 44 | ------------------ 45 | 46 | Hopefully in the future. :-) 47 | 48 | Documentation 49 | ------------- 50 | 51 | To make the docs, type: 52 | 53 | doxygen doxygen_settings 54 | 55 | Which will create html documentation in doc/html. 56 | 57 | LICENSE 58 | ======= 59 | 60 | See COPYING for the GNU GENERAL PUBLIC LICENSE. 61 | -------------------------------------------------------------------------------- /lidarquadtree/configure.in: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ(2.59) 5 | AC_INIT([LiDAR QuadTree Library], [1.3] , [arsf-processing@pml.ac.uk]) 6 | AC_CONFIG_SRCDIR([src]) 7 | AM_INIT_AUTOMAKE([liblidarquadtree], [1.11]) 8 | AC_CONFIG_HEADERS([config.h]) 9 | 10 | # we want things to break quickly 11 | : ${CXXFLAGS="-O3"} 12 | 13 | # Checks for programs. 14 | AC_PROG_CXX 15 | AC_PROG_LIBTOOL 16 | # set the language to c++ 17 | AC_LANG(C++) 18 | # keep the correct libtool macros in-tree (libtoolize recommendation) 19 | AC_CONFIG_MACRO_DIR([m4]) 20 | 21 | # Checks for libraries. 22 | 23 | # Checks for header files. 24 | AC_HEADER_STDC 25 | AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) 26 | 27 | 28 | 29 | # Checks for libraries using pkg-config. 30 | PKG_CHECK_MODULES([laslib], [laslib]) 31 | 32 | AC_CONFIG_FILES([Makefile]) 33 | AC_OUTPUT 34 | -------------------------------------------------------------------------------- /lidarquadtree/lidarquadtree.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/lidar/quadtree 5 | 6 | Name: lidarquadtree 7 | Description: Library to handle LIDAR data using a quad tree structure with paging to disk 8 | URL: http://rsg.pml.ac.uk/ 9 | Version: @PACKAGE_VERSION@ 10 | Requires: laslib 11 | Libs: -L${libdir} -llidarquadtree 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /lidarquadtree/src/Boundary.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Christopher Stanley Finerty 3 | * @version 2.0 4 | * 5 | * A data container class storing a boundary (min and max XY values) 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. 31 | */ 32 | 33 | #ifndef _BOUNDARY_H_ 34 | #define _BOUNDARY_H_ 35 | 36 | class Boundary 37 | { 38 | public: 39 | double minX; 40 | double minY; 41 | double maxX; 42 | double maxY; 43 | }; 44 | 45 | #endif /* _BOUNDARY_H */ 46 | 47 | -------------------------------------------------------------------------------- /lidarquadtree/src/CacheMinder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: CacheMinder.cpp 3 | * Author: chrfi, jaho 4 | * 5 | * Created on January 26, 2010, 3:57 PM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #include "CacheMinder.h" 34 | #include "QuadtreeExceptions.h" 35 | 36 | #include 37 | 38 | 39 | CacheMinder::CacheMinder(int cacheSize) 40 | : 41 | cacheUsed_ (0), 42 | totalCache_ (cacheSize), 43 | cacheing_ (false) 44 | { 45 | } 46 | 47 | void CacheMinder::clearCache() 48 | { 49 | while (!bucketsInCache_.empty()) 50 | { 51 | bucketsInCache_.front()->uncache(); 52 | } 53 | } 54 | 55 | bool CacheMinder::updateCache(int requestSize, PointBucket *pointBucket, bool force) 56 | { 57 | 58 | if (requestSize > totalCache_) 59 | { 60 | throw RamAllocationException("request has been made to cache minder asking \ 61 | for more ram in a single block than available \ 62 | in total"); 63 | } 64 | 65 | // if we are reducing the cache a bucket is using we don't want to change its 66 | // position in the que 67 | if(requestSize >= 0) 68 | { 69 | //remove the pointbucket from the cache que if it is present 70 | deque::iterator ity; 71 | for (ity = bucketsInCache_.begin(); ity < bucketsInCache_.end(); ++ity) 72 | { 73 | if (*ity == pointBucket) 74 | { 75 | bucketsInCache_.erase(ity); 76 | break; 77 | } 78 | } 79 | } 80 | 81 | if (force) 82 | { 83 | // if not enough free cache remove buckets from cache in queue order till there 84 | // is space 85 | while (cacheUsed_ + requestSize > totalCache_) 86 | { 87 | // if we are reducing the cache a bucket is using we don't want to change 88 | // its position in the que 89 | bucketsInCache_.front()->uncache(); 90 | cacheing_ = true; 91 | } 92 | } 93 | else if ((cacheUsed_ + requestSize > totalCache_)) 94 | { 95 | return false; 96 | } 97 | 98 | // add the pointbucket back into the cache que but at the back (this means 99 | // that it will be the last to uncache now) 100 | // if we are reducing the cache a bucket is using we don't want to change 101 | // its position in the que 102 | if (requestSize >= 0) 103 | { 104 | bucketsInCache_.push_back(pointBucket); 105 | } 106 | cacheUsed_ = cacheUsed_ + requestSize; 107 | return true; 108 | } 109 | 110 | void CacheMinder::releaseCache(int releaseSize, PointBucket *bucketToRemove) 111 | { 112 | // remove the pointbucket from the cache que and update available cache 113 | deque::iterator ity; 114 | for (ity = bucketsInCache_.begin(); ity <= bucketsInCache_.end(); ++ity) 115 | { 116 | if (*ity == bucketToRemove) 117 | { 118 | bucketsInCache_.erase(ity); 119 | cacheUsed_ = cacheUsed_ - releaseSize; 120 | return; 121 | } 122 | } 123 | throw RamAllocationException("cache minder asked to release cache that is \ 124 | not being used"); 125 | } 126 | 127 | CacheMinder::~CacheMinder() 128 | { 129 | } 130 | -------------------------------------------------------------------------------- /lidarquadtree/src/CacheMinder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: cacheminder.h 3 | * Authors: chrfi, jaho 4 | * 5 | * Created on January 26, 2010, 3:57 PM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _CACHEMINDER_H 34 | #define _CACHEMINDER_H 35 | 36 | #include "PointBucket.h" 37 | #include 38 | 39 | using namespace std; 40 | 41 | 42 | /** 43 | * @author Christopher Stanley Finerty 44 | * @version 2.0 45 | * 46 | * this class keeps track of the number of points that are currently in main 47 | * memory (cached). 48 | * it dosen't track specific memory locations just the overal memory usage. 49 | * 50 | * a normal quadtree will normally have a single cacheminder that tracks the 51 | * memory usage for all the buckets within the quadtree. 52 | * 53 | * @warning The CacheMinder makes no attempt to keep track of the cache used by 54 | * individual pointbuckets, therefore the pointbuckets must ensure that they 55 | * request and free the same amount otherwise things go badly fast (equivalent 56 | * of a memory leak) 57 | */ 58 | class CacheMinder 59 | { 60 | public: 61 | /** 62 | * a constructor 63 | * 64 | * @param cacheSize the number of points that can be cache at any one time 65 | */ 66 | CacheMinder(int cacheSize); 67 | 68 | /** 69 | * a destructor 70 | */ 71 | ~CacheMinder(); 72 | 73 | /** 74 | * a method to update the amount of cache being used by a bucket. if the 75 | * amount of 76 | * free cache is insufficient buckets will be uncached until enough space 77 | * is free. 78 | * 79 | * @note updating the cache used by a bucket to zero does not remove it 80 | * from the cache list 81 | * to remove a bucket from cache completely call release cache. 82 | * @param requestSize the number of points to increase (or if negative 83 | * decrease) the number of cache points by 84 | * @param pointBucket a pointer to the bucket asking for the cache (used for 85 | * uncache calls) 86 | * @param force true=remove other buckets from cache to make room. 87 | * 88 | * @return true=space found and allocated. only possible to return false if 89 | * force=false 90 | */ 91 | bool updateCache(int requestSize, PointBucket *pointBucket, bool force); 92 | 93 | /** 94 | * A method to release the cache being used by a bucket and remove the 95 | * bucket from the cached list. 96 | * this should only be called if your really really sure that you have 97 | * already freed the ram 98 | * 99 | * @warning as this is dealing with keeping a count of ram it is 100 | * imperitive that 101 | * any object calling releasecache gets its sums right, if your cumulative 102 | * cacheUpdates and releases don't 103 | * match up all hell will break loose. 104 | * 105 | * @note this can only be called on a bucket that has been cached. 106 | * Additionally 107 | * this method must be called to completely remove a bucket from cache, 108 | * even if 109 | * updatecache has been used to reduce the bucket's cache usage to zero 110 | * 111 | * @param releaseSize the amount of cache to be realse (MUST match the 112 | * amount used by the bucket) 113 | * @param pointBucket the bucket whose cache is to be freed 114 | */ 115 | void releaseCache(int releaseSize, PointBucket *pointBucket); 116 | 117 | /** 118 | * a method that removes all buckets from cache 119 | */ 120 | void clearCache(); 121 | 122 | int get_cacheused() 123 | { 124 | return this->cacheUsed_; 125 | } 126 | 127 | protected: 128 | deque bucketsInCache_; 129 | int cacheUsed_; 130 | int totalCache_; 131 | bool cacheing_; 132 | }; 133 | 134 | #endif /* _CACHEMINDER_H */ 135 | 136 | -------------------------------------------------------------------------------- /lidarquadtree/src/CollisionDetection.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: collisiondetection.cpp 3 | * Author: chrfi 4 | * 5 | * Created on March 23, 2010, 10:38 AM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #include "CollisionDetection.h" 34 | #include 35 | #include 36 | 37 | 38 | using namespace std; 39 | 40 | // this method takes the forumula for 4 lines and checks if the x and y 41 | // arguments are within them 42 | bool kobbPoint(double m1, double c1, double m2, double c2, double m3, 43 | double c3, double m4, double c4, double x, double y) 44 | { 45 | // find the point where an imaginary vertical line through the x value 46 | // intersects with each line 47 | double intersec1 = m1 * x + c1; 48 | double intersec2 = m2 * x + c2; 49 | double intersec3 = m3 * x + c3; 50 | double intersec4 = m4 * x + c4; 51 | 52 | // if the xy point is between the intersections with the oposite sides of the 53 | // rectangle the 54 | // point is within the rectangle (think about it, it works) 55 | double err = 0.000001; 56 | if (((intersec1 - y + err) > 0 && (intersec3 - y - err) < 0) || 57 | ((intersec1 - y - err) < 0 && (intersec3 - y + err) > 0)) 58 | { 59 | if (((intersec2 - y + err) > 0 && (intersec4 - y - err) < 0) || 60 | ((intersec2 - y - err) < 0 && (intersec4 - y + err) > 0)) 61 | { 62 | return true; 63 | } 64 | } 65 | return false; 66 | } 67 | 68 | // function to test if a point lies within a polygon using the fact that 69 | // if it does the area of the triangles formed by 2 points from the polgon 70 | // and the test point will all have the same sign 71 | // check wikipedia for more infor :P 72 | bool triangleTest(double *Xs, double *Ys, int size, double px, double py) 73 | { 74 | double sign = 0.5 * (Xs[0] * py - Ys[0] * px - Xs[size - 1] * py + 75 | Ys[size - 1] * px + Xs[size - 1] * Ys[0] + 76 | Ys[size - 1] * Xs[0]); 77 | for (int k = 0; k < size; k++) 78 | { 79 | double test = 0.5 * (Xs[k + 1] * py - Ys[k + 1] * px - Xs[k] * py + 80 | Ys[k] * px + Xs[k] * Ys[k + 1] + Ys[k] * Xs[k + 1]); 81 | 82 | if (test * sign < 0) 83 | { 84 | return false; 85 | } 86 | 87 | } 88 | return true; 89 | } 90 | 91 | 92 | // function to test if a point lies within a polygon using the fact 93 | // that if it does a vector drawn outwards from that point will intersect 94 | // with the polygon an odd number of times 95 | // check wikipedia for more infor :P 96 | bool vectorTest(vector Xs, vector Ys, int size, double px, double py) 97 | { 98 | bool in = false; 99 | int j = size - 1; 100 | for (int k = 0; k < size; k++) 101 | { 102 | if ((Ys[k] < py && Ys[j] >= py) || (Ys[j] < py && Ys[k] >= py)) 103 | { 104 | if (Xs[k]+((py - Ys[k]) / (Ys[j] - Ys[k])) * (Xs[j] - Xs[k]) < px) 105 | { 106 | in = !in; 107 | } 108 | } 109 | j=k; 110 | } 111 | return in; 112 | } 113 | 114 | // function to detect collision between an axis orientated rectangle and 115 | // a rotated rectangle 116 | bool aoRectangleNaoRectangle(double minX, double minY, double maxX, 117 | double maxY, vector Xs, vector Ys, int size) 118 | { 119 | 120 | // find a simple bounding box for the non axis orientated area, 121 | double largestX = Xs[0]; 122 | double largestY = Ys[0]; 123 | double smallestX = Xs[0]; 124 | double smallestY = Ys[0]; 125 | 126 | for (int k = 1; k < size; ++k) 127 | { 128 | if (Xs[k] > largestX) 129 | { 130 | largestX = Xs[k]; 131 | } 132 | if (Xs[k] < smallestX) 133 | { 134 | smallestX = Xs[k]; 135 | } 136 | if (Ys[k] > largestY) 137 | { 138 | largestY = Ys[k]; 139 | } 140 | if (Ys[k] < smallestY) 141 | { 142 | smallestY = Ys[k]; 143 | } 144 | } 145 | 146 | // check simple bounding box against axis oriented box 147 | if (largestX < minX || smallestX > maxX || largestY < minY || 148 | smallestY > maxY) 149 | { 150 | return false; 151 | } 152 | 153 | // convert AOrec to arrays of points 154 | vector bXs(4); 155 | vector bYs(4); 156 | bXs[0] = minX; 157 | bXs[1] = minX; 158 | bXs[2] = maxX; 159 | bXs[3] = maxX; 160 | bYs[0] = minY; 161 | bYs[1] = maxY; 162 | bYs[2] = maxY; 163 | bYs[3] = minY; 164 | 165 | // compare the boxes as polygons using axis seperation theory 166 | return (axisSeperationTest(Xs, Ys, 4, bXs, bYs, 4)); 167 | } 168 | 169 | // this method uses the axis seperation test to determine if two convex 170 | // polygons collide the two pairs of arrays it takes as argurments represent 171 | // the polgons and the points within them must be sequential (so that drawing 172 | // a line from 1 to 2 to 3 to 1 forms a polygon 173 | bool axisSeperationTest(vector poly1Xs, vector poly1Ys, int poly1size, 174 | vector poly2Xs, vector poly2Ys, int poly2size) 175 | { 176 | // these vectors keep track of the perpendicular vectors already checked 177 | vector previousX = vector(); 178 | vector previousY = vector(); 179 | 180 | // for each edge in polygon 1 181 | int j = poly1size - 1; 182 | for (int k = 0; k < poly1size; k++) 183 | { 184 | double vecx, vecy; 185 | double abx, aby; 186 | 187 | vecx = poly1Xs[j] - poly1Xs[k]; 188 | vecy = poly1Ys[j] - poly1Ys[k]; 189 | 190 | // find the perpendicular vector 191 | abx = vecy; 192 | aby = -vecx; 193 | 194 | // check that a parallel vector has not already been checked 195 | for (unsigned int i = 0; i < previousX.size(); i++) 196 | { 197 | if ((previousX[i] * vecy)-(vecx * previousY[i]) == 0) 198 | { 199 | continue; 200 | } 201 | } 202 | 203 | previousX.push_back(vecx); 204 | previousY.push_back(vecy); 205 | 206 | // find magnitude of ab 207 | double abmag = sqrt(abx * abx + aby * aby); 208 | 209 | double min1, max1, min2, max2; 210 | 211 | //for each point in poly1 212 | min1 = max1 = poly1Xs[0] * abx + poly1Ys[0] * aby / abmag; 213 | for (int points1 = 1; points1 < poly1size; points1++) 214 | { 215 | // project the points onto the perpendicular vector and record the min 216 | // and max positions 217 | double temp = poly1Xs[points1] * abx + poly1Ys[points1] * aby / abmag; 218 | 219 | if (temp < min1) 220 | { 221 | min1 = temp; 222 | } 223 | if (temp > max1) 224 | { 225 | max1 = temp; 226 | } 227 | } 228 | 229 | //for each point in poly2 230 | min2 = max2 = poly2Xs[0] * abx + poly2Ys[0] * aby / abmag; 231 | for (int points2 = 1; points2 < poly2size; points2++) 232 | { 233 | // project the points onto the perpendicular vector and record the min 234 | // and max positions 235 | double temp = poly2Xs[points2] * abx + poly2Ys[points2] * aby / abmag; 236 | 237 | if (temp < min2) 238 | { 239 | min2 = temp; 240 | } 241 | if (temp > max2) 242 | { 243 | max2 = temp; 244 | } 245 | } 246 | 247 | // if the min max don't overlap when projected on this plane the objects 248 | // don't collide 249 | if (min1 > max2 || max1 < min2) 250 | { 251 | return false; 252 | } 253 | j = k; 254 | } 255 | 256 | // for each edge in polygon 2 257 | j = poly2size - 1; 258 | for (int k = 0; k < poly2size; k++) 259 | { 260 | 261 | double vecx, vecy; 262 | double abx, aby; 263 | 264 | 265 | vecx = poly2Xs[j] - poly2Xs[k]; 266 | vecy = poly2Ys[j] - poly2Ys[k]; 267 | 268 | // find the perpendicular vector 269 | abx = vecy; 270 | aby = -vecx; 271 | 272 | // check that a parallel vector has not already been checked 273 | for (unsigned int i = 0; i < previousX.size(); i++) 274 | { 275 | if ((previousX[i] * vecy)-(vecx * previousY[i]) == 0) 276 | { 277 | continue; 278 | } 279 | } 280 | 281 | // find magnitude of ab 282 | double abmag = sqrt((abx * abx) + (aby * aby)); 283 | 284 | double min1, max1, min2, max2; 285 | 286 | //for each point in poly1 287 | min1 = max1 = poly1Xs[0] * abx + poly1Ys[0] * aby / abmag; 288 | for (int points1 = 1; points1 < poly1size; points1++) 289 | { 290 | // project the points onto the perpendicular vector and record the min 291 | // and max positions 292 | double temp = poly1Xs[points1] * abx + poly1Ys[points1] * aby / abmag; 293 | 294 | if (temp < min1) 295 | { 296 | min1 = temp; 297 | } 298 | if (temp > max1) 299 | { 300 | max1 = temp; 301 | } 302 | } 303 | 304 | //for each point in poly2 305 | min2 = max2 = poly2Xs[0] * abx + poly2Ys[0] * aby / abmag; 306 | for (int points2 = 1; points2 < poly2size; points2++) 307 | { 308 | // project the points onto the perpendicular vector and record the min 309 | // and max positions 310 | double temp = poly2Xs[points2] * abx + poly2Ys[points2] * aby / abmag; 311 | 312 | if (temp < min2) 313 | { 314 | min2 = temp; 315 | } 316 | if (temp > max2) 317 | { 318 | max2 = temp; 319 | } 320 | } 321 | 322 | // if the min max don't overlap when projected on this vector so the objects 323 | // don't collide 324 | if (min1 > max2 || max1 < min2) 325 | { 326 | return false; 327 | } 328 | j = k; 329 | } 330 | 331 | return true; 332 | } 333 | -------------------------------------------------------------------------------- /lidarquadtree/src/CollisionDetection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: collisiondetection.h 3 | * Author: chrfi 4 | * 5 | * Created on March 23, 2010, 10:38 AM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _COLLISIONDETECTION_H 34 | #define _COLLISIONDETECTION_H 35 | 36 | #include 37 | 38 | 39 | /** 40 | * a function that checks for collision between an axis orientated 41 | * rectangle(ao) and a none axis orientated(nao) rectangle 42 | * 43 | * @note the x and y values for the corners of a polygon must be in 44 | * sequential order 45 | * (so that drawing a line from 1 to 2 to 3 to 1 forms a polygon) 46 | * @param minX the minimum x value of the AOrec 47 | * @param minY the maximum y value of the AOrec 48 | * @param maxX the minimum x value of the AOrec 49 | * @param maxY the maximum y value of the AOrec 50 | * @param Xs an array of doubles each of which is the x componant of a 51 | * point of the polygon (in sequence) 52 | * @param Ys an array of doubles each of which is the y componant of a 53 | * point of the polygon (in sequence) 54 | * @param size the number of corners that make up the polygon (the length 55 | * of the Xs and Ys arrays) 56 | * 57 | * @return true indicates a collision 58 | */ 59 | bool aoRectangleNaoRectangle(double minX, double minY, double maxX, 60 | double maxY, std::vector Xs, std::vector Ys, 61 | int size); 62 | 63 | /** 64 | * a function to test if a point falls within a convex polygon 65 | * 66 | * @note the x and y values for the corners of a polygon must be in 67 | * sequential order 68 | * (so that drawing a line from 1 to 2 to 3 to 1 forms a polygon) 69 | * @param Xs an array of doubles each of which is the x componant 70 | * of a point of the polygon (in sequence) 71 | * @param Ys an array of doubles each of which is the y componant 72 | * of a point of the polygon (in sequence) 73 | * @param size the number of corners that make up the polygon (the 74 | * length of the Xs and Ys arrays) 75 | * @param px x value of the point 76 | * @param py y value of the point 77 | * 78 | * @return true indicates that the point falls inside the polygon 79 | */ 80 | bool vectorTest(std::vector Xs, std::vector Ys, int size, double px, double py); 81 | 82 | /** 83 | * a function that checks for collision between two convex polgons 84 | * 85 | * @note the x and y values for the corners of a polygon must be in 86 | * sequential order 87 | * (so that drawing a line from 1 to 2 to 3 to 1 forms a polygon) 88 | * @param Xs1 an array of doubles each of which is the x componant of a 89 | * point of the polygon (in sequence) 90 | * @param Ys1 an array of doubles each of which is the y componant of a 91 | * point of the polygon (in sequence) 92 | * @param size1 the number of corners that make up the polygon (the 93 | * length of the Xs and Ys arrays) 94 | * @param Xs2 an array of doubles each of which is the x componant of a 95 | * point of the polygon (in sequence) 96 | * @param Ys2 an array of doubles each of which is the y componant of a 97 | * point of the polygon (in sequence) 98 | * @param size2 the number of corners that make up the polygon (the length 99 | * of the Xs and Ys arrays) 100 | */ 101 | bool axisSeperationTest(std::vector Xs1, std::vector Ys1, int size1, 102 | std::vector Xs2, std::vector Ys2, int size2); 103 | 104 | #endif /* _COLLISIONDETECTION_H */ 105 | 106 | -------------------------------------------------------------------------------- /lidarquadtree/src/LidarPoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: LidarPoint.cpp 3 | * Author: jaho 4 | * 5 | * Created on 10 March 2012 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | 34 | #include "LidarPoint.h" 35 | #include 36 | 37 | LidarPoint::LidarPoint(double x, double y, double z, double time, uint16_t intensity, uint8_t classification, uint8_t flightline, 38 | uint8_t returnNumber, uint8_t noOfReturns, uint8_t scanDirection, uint8_t scanEdge, uint8_t scanAngle, 39 | uint16_t pointSourceId, int dataindex) : Point(x, y, z), 40 | time (time), 41 | intensity (intensity), 42 | classification (classification), 43 | flightline (flightline), 44 | packedByte (returnNumber), 45 | scanAngle (scanAngle), 46 | pointSourceId (pointSourceId), 47 | dataindex (dataindex) 48 | { 49 | packedByte = packedByte | noOfReturns << 3; 50 | packedByte = packedByte | scanDirection << 6; 51 | packedByte = packedByte | scanEdge << 7; 52 | } 53 | 54 | LidarPoint::LidarPoint() : Point() 55 | {} 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /lidarquadtree/src/LidarPoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: LidarPoint.h 3 | * Author: jaho 4 | * 5 | * Created on 10 March 2012 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _LIDAR_POINT_H_ 34 | #define _LIDAR_POINT_H_ 35 | 36 | #include "Point.h" 37 | #include 38 | #include 39 | #include "PointData.h" 40 | 41 | class LidarPoint: public Point 42 | { 43 | 44 | public: 45 | // Constructors 46 | LidarPoint(); 47 | LidarPoint(double,double,double,double,uint16_t,uint8_t,uint8_t,uint8_t,uint8_t, uint8_t, uint8_t, uint8_t, uint16_t, int); 48 | 49 | // Getter methods 50 | double getTime(); 51 | uint16_t getIntensity(); 52 | uint8_t getClassification(); 53 | uint8_t getFlightline(); 54 | uint8_t getReturn(); 55 | uint8_t getNumberOfReturns(); 56 | uint8_t getScanDirection(); 57 | uint8_t getScanEdge(); 58 | uint8_t getScanAngle(); 59 | uint16_t getPointSourceId(); 60 | int getDataindex(); 61 | 62 | // Assignment operator that gets values from a laslib::LASpoint 63 | LidarPoint& operator=(LASpoint const& laspoint); 64 | 65 | void setClassification(int); 66 | void setDataindex(int); 67 | void setFlightlineNumber(int); 68 | 69 | private: 70 | double time; 71 | uint16_t intensity; 72 | uint8_t classification; 73 | uint8_t flightline; 74 | uint8_t packedByte; 75 | uint8_t scanAngle; 76 | uint16_t pointSourceId; 77 | int dataindex; 78 | }; 79 | 80 | // Set classification 81 | inline void LidarPoint::setClassification(int classification) 82 | { 83 | this->classification = classification; 84 | } 85 | 86 | inline void LidarPoint::setDataindex(int dataindex) 87 | { 88 | this->dataindex = dataindex; 89 | } 90 | 91 | inline void LidarPoint::setFlightlineNumber(int number) 92 | { 93 | this->flightline = number; 94 | } 95 | 96 | // Getter methods 97 | inline double LidarPoint::getTime() { return time; } 98 | inline uint16_t LidarPoint::getIntensity() { return intensity; } 99 | inline uint8_t LidarPoint::getClassification() { return classification; } 100 | inline uint8_t LidarPoint::getFlightline() { return flightline; } 101 | inline uint8_t LidarPoint::getReturn() { return packedByte & 7; } 102 | inline uint8_t LidarPoint::getNumberOfReturns() { return (packedByte & 56) >> 3; } 103 | inline uint8_t LidarPoint::getScanDirection() { return (packedByte & 64) >> 6; } 104 | inline uint8_t LidarPoint::getScanEdge() { return (packedByte & 128) >> 7; } 105 | inline uint8_t LidarPoint::getScanAngle() { return scanAngle; } 106 | inline uint16_t LidarPoint::getPointSourceId() { return pointSourceId; } 107 | inline int LidarPoint::getDataindex() { return dataindex; } 108 | 109 | inline LidarPoint& LidarPoint::operator=(LASpoint const& laspoint) 110 | { 111 | x_ = laspoint.get_x(); 112 | y_ = laspoint.get_y(); 113 | z_ = laspoint.get_z(); 114 | time = laspoint.gps_time; 115 | intensity = laspoint.intensity; 116 | classification = laspoint.classification; 117 | packedByte = laspoint.return_number; 118 | scanAngle = laspoint.scan_angle_rank; 119 | pointSourceId = laspoint.point_source_ID; 120 | 121 | packedByte = packedByte | laspoint.number_of_returns << 3; 122 | packedByte = packedByte | laspoint.scan_direction_flag << 6; 123 | packedByte = packedByte | laspoint.edge_of_flight_line << 7; 124 | 125 | flightline = 0; 126 | 127 | return *this; 128 | } 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /lidarquadtree/src/Point.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Point.cpp 3 | * Author: jaho 4 | * 5 | * Created on 10 March 2012 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #include "Point.h" 34 | #include 35 | 36 | //Default 37 | Point::Point() 38 | { 39 | } 40 | 41 | // 1D Point 42 | Point::Point(double x) 43 | : 44 | x_ (x), 45 | y_ (0), 46 | z_ (0) 47 | { 48 | } 49 | 50 | // 2D Point 51 | Point::Point(double x, double y) 52 | : 53 | x_ (x), 54 | y_ (y), 55 | z_ (0) 56 | { 57 | } 58 | 59 | // 3D Point 60 | Point::Point(double x, double y, double z) 61 | : 62 | x_ (x), 63 | y_ (y), 64 | z_ (z) 65 | { 66 | } 67 | 68 | // Euclidian distance 69 | double Point::distanceTo(const Point& other) 70 | { 71 | return sqrt((x_-other.x_)*(x_-other.x_) + 72 | (y_-other.y_)*(y_-other.y_) + 73 | (z_-other.z_)*(z_-other.z_)); 74 | } 75 | 76 | bool operator==(Point& lhs, Point& rhs) 77 | { 78 | return lhs.x_ == rhs.x_ && lhs.y_ == rhs.y_ && lhs.z_ == rhs.z_; 79 | } 80 | 81 | bool operator!=(Point& lhs, Point& rhs) 82 | { 83 | if (lhs == rhs) 84 | return false; 85 | else 86 | return true; 87 | } 88 | 89 | // Mutator methods for the Point 90 | void Point::translate(double x, double y , double z) 91 | { 92 | x_ += x; 93 | y_ += y; 94 | z_ += z; 95 | } 96 | 97 | void Point::move(double x, double y, double z) 98 | { 99 | x_ = x; 100 | y_ = y; 101 | z_ = z; 102 | } 103 | 104 | const Point Point::operator+(Point& other) const 105 | { 106 | return Point( 107 | x_ + other.getX(), 108 | y_ + other.getY(), 109 | z_ + other.getZ() ); 110 | } 111 | 112 | const Point Point::operator-(Point& other) const 113 | { 114 | return Point( 115 | x_ - other.getX(), 116 | y_ - other.getY(), 117 | z_ - other.getZ() ); 118 | } 119 | -------------------------------------------------------------------------------- /lidarquadtree/src/Point.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Point.h 3 | * Author: jaho 4 | * 5 | * Created on 10 March 2012 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _POINT_H_ 34 | #define _POINT_H_ 35 | 36 | 37 | class Point { 38 | 39 | public: 40 | Point(); 41 | // 1D Point 42 | Point(double); 43 | // 2D Point 44 | Point(double, double); 45 | // 3D Point 46 | Point(double, double, double); 47 | 48 | // Distance to another Point 49 | double distanceTo(const Point&); 50 | 51 | // Comparison operators 52 | friend bool operator== (Point& lhs, Point& rhs); 53 | friend bool operator!= (Point& lhs, Point& rhs); 54 | 55 | // Methods to move the Point 56 | void translate(double, double, double); 57 | void move(double, double, double); 58 | 59 | // Arithmetic operators 60 | const Point operator+ (Point& other) const; 61 | const Point operator- (Point& other) const; 62 | 63 | // Getter methods 64 | double getX(); 65 | double getY(); 66 | double getZ(); 67 | 68 | protected: 69 | double x_; 70 | double y_; 71 | double z_; 72 | }; 73 | 74 | // Getters for coordinates 75 | inline double Point::getX() { return x_; } 76 | inline double Point::getY() { return y_; } 77 | inline double Point::getZ() { return z_; } 78 | 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /lidarquadtree/src/PointBucket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: PointBucket.h 3 | * Authors: chrfi, jaho, Berin Smaldon 4 | * 5 | * Created on February 11, 2010, 12:08 PM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _POINTBUCKET_H 34 | #define _POINTBUCKET_H 35 | 36 | #include "LidarPoint.h" 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include "lzo/lzo1b.h" 42 | #include "QuadtreeExceptions.h" 43 | 44 | using namespace std; 45 | 46 | class CacheMinder; 47 | 48 | 49 | /** 50 | * @author Christopher Stanley Finerty 51 | * @version 2.0 52 | * 53 | * This class represents a bucket which holds a colletion of points. 54 | * It stores 55 | * metadata about the points it holds and manages the caching and 56 | * uncaching of the points. 57 | *
58 | * The pointbucket class can hold several subsets of the points that 59 | * fall within it 60 | * depending on the arguements when it is constructed. The pointbucket 61 | * always stores a full list of points but also possibly several 62 | * progressivly smaller subsets. These are defined by a base number and a 63 | * number of levels, so that base 10 levels 4 results in 4 subsets 64 | * 10^0:every point, the second 10^1:every 10th point, 10^2:every 100th 65 | * point, 10^3: every 1000th point. 66 | * Points that fall into multiple subsets will be present in all those 67 | * subsets so the first point always falls into every subset.
68 | *
69 | * This is mostly hidden from other classes 70 | * except when getting a point or the number of points both of which 71 | * depend on the resolution desired. 72 | * 73 | * @note because the pointbucket holds several sets of data of the same 74 | * type many of its attributes are stored in arrays with each index 75 | * holding the value that relates to a different subset. 76 | */ 77 | class PointBucket 78 | { 79 | public: 80 | /** 81 | * constructer which initilizes the capacity of the bucket along 82 | * with the boundary from 83 | * parameters and the other varibles to defaults. 84 | * 85 | * 86 | * @param capacity the number of points the bucket can hold 87 | * @param minX X value of the lower left corner of the boundary 88 | * @param minY Y value of the lower left corner of the boundary 89 | * @param maxX X value of the upper right corner of the boundary 90 | * @param maxY Y value of the upper right corner of the boundary 91 | * @param MCP the cacheminder for this quadtree instance 92 | * @param instanceDirectory string containing a path to a directory 93 | * where temporary files will be saved 94 | * @param resolutionBase the base number for subset calculation 95 | * (see class description for more detail) 96 | * @param numberOfResolutionLevels the number of resolution levels 97 | * (see class description for more detail) 98 | */ 99 | PointBucket(int capacity, double minX, double minY, 100 | double maxX, double maxY, CacheMinder *MCP, 101 | string instanceDirectory, 102 | int resolutionBase, 103 | int numberOfResolutionLevels); 104 | 105 | /** 106 | * deconstructor 107 | */ 108 | ~PointBucket(); 109 | 110 | /** 111 | * a method that adds a layer between outside classes and the 112 | * SerializableInnerBucket. this prevents outside classes from 113 | * accessing the subset array without the pointbuckets knowledge. This 114 | * is important as the subset may not be cached. by providing this 115 | * method all access to the subset array prompts the pointbucket to 116 | * check if its cached and cache if neccessary. 117 | * 118 | * @param i the index of the point to get 119 | * @param resolution index of resolution level to get the point 120 | * from (0 to (the number of levels-1)) 121 | * 122 | * @return a reference to the desired point 123 | */ 124 | LidarPoint& getPoint(int i, int resolution); 125 | 126 | /** 127 | * a method to allow the classification of a point in this bucket to be 128 | * set to a desired value, 129 | * this method provides an interface between users and the points which 130 | * insures the points are cached 131 | * before they are manipulated 132 | * 133 | * @param i the index of the point to set 134 | * @param classification the new classification value of the point 135 | */ 136 | void setClassification(int i, uint8_t classification); 137 | 138 | 139 | 140 | // getters 141 | 142 | /** 143 | * returns the number of points in the specified resolution bucket 144 | * 145 | * @param resolution the index of the resolution level 146 | */ 147 | 148 | 149 | int getNumberOfPoints(int resolution) 150 | { 151 | if (resolution > numberOfResolutionLevels_) 152 | { 153 | throw "resolution index out of bounds"; 154 | } 155 | return numberOfPoints_[resolution]; 156 | } 157 | 158 | double getmaxX() const 159 | { 160 | return maxX_; 161 | } 162 | 163 | double getmaxY() const 164 | { 165 | return maxY_; 166 | } 167 | 168 | double getmaxZ() const 169 | { 170 | return maxZ_; 171 | } 172 | 173 | double getminX() const 174 | { 175 | return minX_; 176 | } 177 | 178 | double getminY() const 179 | { 180 | return minY_; 181 | } 182 | 183 | double getminZ() const 184 | { 185 | return minZ_; 186 | } 187 | 188 | const bool *getIncacheList() const 189 | { 190 | return incache_; 191 | } 192 | 193 | unsigned short int getmaxintensity() const 194 | { 195 | return maxIntensity_; 196 | } 197 | 198 | unsigned short int getminintensity() const 199 | { 200 | return minIntensity_; 201 | } 202 | 203 | static void clean_up() 204 | { 205 | if (workingMemory != NULL) 206 | { 207 | free(workingMemory); 208 | workingMemory = NULL; 209 | } 210 | if (compressedData != NULL) 211 | { 212 | free(compressedData); 213 | compressedData = NULL; 214 | } 215 | } 216 | 217 | int get_cache_used(); 218 | 219 | protected: 220 | 221 | unsigned short int minIntensity_, maxIntensity_; 222 | double minZ_, maxZ_; 223 | double minX_, maxX_; 224 | double minY_, maxY_; 225 | CacheMinder *MCP_; 226 | int resolutionBase_; 227 | int numberOfResolutionLevels_; 228 | int capacity_; 229 | string instanceDirectory_; 230 | static unsigned char *workingMemory; 231 | static unsigned char *compressedData; 232 | 233 | // arrays containing different values for these attributes for each subset 234 | // of points 235 | int *numberOfPoints_; 236 | string *filePath_; 237 | bool *updated_; 238 | int *numberOfSerializedPoints_; 239 | bool *serialized_; 240 | bool *incache_; 241 | int *pointArraySize_; 242 | int *pointInterval_; 243 | LidarPoint **points_; 244 | // static shared working memory 245 | // these are reused alot as each use writes over the previous values 246 | //unsigned char *workingMemory; 247 | //unsigned char *compressedData; 248 | 249 | lzo_uint *compressedDataSize_; 250 | 251 | friend class CacheMinder; 252 | /** 253 | * a method which removes the smallest cached subset and writes 254 | * it to secondary memory if neccessary, it then informs the cacheminder 255 | * that the memory has been freed 256 | */ 257 | void uncache(); 258 | 259 | /** 260 | * a method that requests some space in main memory and then loads the 261 | * point data from secondary memory to main memory into it. 262 | * this is only done if the pointdata is not already in cache. 263 | * 264 | * @note this requests cache space equal to the number of points in the 265 | * resolution 266 | * 267 | * @param force this boolean indicates wether other buckets should be 268 | * forced out of main memory to make space 269 | * @param resolution indicates which subset to cache 270 | * 271 | * @return true=memory assigned use it 272 | */ 273 | bool cache(bool force, int resolution); 274 | 275 | friend class QuadtreeNode; 276 | /** 277 | * a method to add a new point to the serializableinnerbucket. 278 | * it also checks the new point and updates the min and max values 279 | * accordingly 280 | * 281 | * @param newP the new point to be added 282 | */ 283 | void setPoint(LidarPoint& newP); 284 | 285 | 286 | 287 | 288 | }; 289 | 290 | 291 | #endif /* _POINTBUCKET_H */ 292 | 293 | -------------------------------------------------------------------------------- /lidarquadtree/src/PointData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: PointData.h 3 | * Author: jaho 4 | * 5 | * Created on 15 March 2012 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef POINTDATA_H_ 34 | #define POINTDATA_H_ 35 | 36 | 37 | class PointData 38 | { 39 | public: 40 | uint8_t wfDescriptorIndex; 41 | U64 wfOffset; 42 | uint32_t wfPacketSize; 43 | float wfPointLocation; 44 | float xt; 45 | float yt; 46 | float zt; 47 | 48 | // Assignment operator that gets values from a laslib::LASwavepacket 49 | PointData& operator=(LASwavepacket const& wavepacket); 50 | }; 51 | 52 | inline PointData& PointData::operator=(LASwavepacket const& wp) 53 | { 54 | wfDescriptorIndex = wp.getIndex(); 55 | wfOffset = wp.getOffset(); 56 | wfPacketSize = wp.getSize(); 57 | wfPointLocation = wp.getLocation(); 58 | xt = wp.getXt(); 59 | yt = wp.getYt(); 60 | zt = wp.getZt(); 61 | 62 | return *this; 63 | } 64 | 65 | #endif /* POINTDATA_H_ */ 66 | -------------------------------------------------------------------------------- /lidarquadtree/src/QuadtreeExceptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: QuadtreeExceptions.h 3 | * Author: chrfi, Berin Smaldon 4 | * 5 | * Created on February 10, 2010, 4:10 PM 6 | * 7 | * ---------------------------------------------------------------- 8 | * 9 | * This file is part of lidarquadtree, a library providing a data 10 | * structure for storing and indexing LiDAR points. 11 | * 12 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 13 | * arsfinternal@pml.ac.uk 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License as 17 | * published by the Free Software Foundation; either version 2 of the 18 | * License, or (at your option) any later version. 19 | * 20 | * This program is distributed in the hope that it will be useful, but 21 | * WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with this program; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 28 | * 02111-1307, USA. 29 | * 30 | * The GNU General Public License is contained in the file COPYING. * 31 | */ 32 | 33 | #ifndef _QUADTREEEXCEPTIONS_H 34 | #define _QUADTREEEXCEPTIONS_H 35 | 36 | #include 37 | 38 | using namespace std; 39 | 40 | /** 41 | * @author Berin Smaldon 42 | * @version 1.0 43 | * 44 | * a pretty vanilla exception to indicate some regular I/O error 45 | */ 46 | class QuadtreeIOException : public exception 47 | { 48 | public: 49 | virtual const char* what() const throw () 50 | { 51 | return "Quadtree I/O failed critically"; 52 | } 53 | }; 54 | 55 | /** 56 | * @author Christopher Stanley Finerty 57 | * @version 2.0 58 | * 59 | * an extension of the standard c++ exception class which adds 60 | * a why() method so that additional information can be passed. 61 | * the idea is that the existing what() method tells you the type 62 | * of exception and the details attribute (which is returned by the why() 63 | * method) can be set when the exception is thrown and should explain 64 | * why it was thrown. 65 | */ 66 | class DescriptiveException : public exception 67 | { 68 | private: 69 | 70 | public: 71 | const char *details; 72 | 73 | DescriptiveException(const char *details) 74 | { 75 | this->details = details; 76 | } 77 | 78 | const char* why() 79 | { 80 | return details; 81 | } 82 | }; 83 | 84 | 85 | /** 86 | * @author Christopher Stanley Finerty 87 | * @version 2.0 88 | * 89 | * new exception extended from DescriptiveException 90 | */ 91 | class RamAllocationException : public DescriptiveException 92 | { 93 | public: 94 | 95 | virtual const char* what() const throw () 96 | { 97 | return "an exception has occoured during ram allocation"; 98 | } 99 | 100 | RamAllocationException(const char *details) 101 | : DescriptiveException(details) { } 102 | }; 103 | 104 | 105 | /** 106 | * @author Christopher Stanley Finerty 107 | * @version 2.0 108 | * 109 | * new exception extended from DescriptiveException 110 | */ 111 | class FileException : public DescriptiveException 112 | { 113 | public: 114 | 115 | virtual const char* what() const throw () 116 | { 117 | return "file io exception"; 118 | } 119 | 120 | FileException(const char *details) 121 | : DescriptiveException(details) { } 122 | }; 123 | 124 | 125 | /** 126 | * @author Christopher Stanley Finerty 127 | * @version 2.0 128 | * 129 | * new exception extended from DescriptiveException 130 | */ 131 | class OutOfBoundsException : public DescriptiveException 132 | { 133 | public: 134 | 135 | virtual const char* what() const throw () 136 | { 137 | 138 | return details; //"a variable has fallen outside all possible boundaries or values"; 139 | } 140 | 141 | OutOfBoundsException(const char *details) 142 | : DescriptiveException(details) { } 143 | }; 144 | 145 | 146 | /** 147 | * @author Christopher Stanley Finerty 148 | * @version 2.0 149 | * 150 | * new exception extended from DescriptiveException 151 | */ 152 | class NullPointerException : public DescriptiveException 153 | { 154 | public: 155 | 156 | virtual const char* what() const throw () 157 | { 158 | return "a method or attribute of a pointer which is \ 159 | null has been requested"; 160 | } 161 | 162 | NullPointerException(const char *details) 163 | : DescriptiveException(details) { } 164 | }; 165 | 166 | 167 | #endif /* _QUADTREEEXCEPTIONS_H */ 168 | 169 | -------------------------------------------------------------------------------- /lidarquadtree/src/QuadtreeNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: QuadtreeNode.h 3 | * Authors: Christopher Stanley Finerty (chrfi) 4 | * 5 | * ---------------------------------------------------------------- 6 | * 7 | * This file is part of lidarquadtree, a library providing a data 8 | * structure for storing and indexing LiDAR points. 9 | * 10 | * Copyright (C) 2008-2012 Plymouth Marin Laboratory 11 | * arsfinternal@pml.ac.uk 12 | * 13 | * This program is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU General Public License as 15 | * published by the Free Software Foundation; either version 2 of the 16 | * License, or (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but 19 | * WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program; if not, write to the Free Software 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26 | * 02111-1307, USA. 27 | * 28 | * The GNU General Public License is contained in the file COPYING. * 29 | */ 30 | 31 | #ifndef _QUADTREENODE_H 32 | #define _QUADTREENODE_H 33 | 34 | #include "LidarPoint.h" 35 | #include "Boundary.h" 36 | #include "PointBucket.h" 37 | #include 38 | #include 39 | 40 | using namespace std; 41 | 42 | /** 43 | * @author Christopher Stanley Finerty 44 | * @version 2.0 45 | * 46 | * this class represents a single node (leaf or nonleaf) within a quadtree. 47 | * 48 | * each node is defined by its boundary which places it within the quadtree 49 | * and indicates which points fall within it. 50 | * When a node exceeds its capacity it creates four new child nodes each 51 | * a quarter the size which are leaves. 52 | * in this way the number of nodes expands until all the being inserted 53 | * are held in non overflowing nodes. 54 | */ 55 | class QuadtreeNode 56 | { 57 | 58 | public: 59 | 60 | protected: 61 | friend class Quadtree; 62 | 63 | QuadtreeNode *a_, *b_, *c_, *d_; 64 | double minX_, minY_, maxX_, maxY_; 65 | int capacity_; 66 | int numberOfPoints_; 67 | PointBucket *bucket_; 68 | bool leaf_; 69 | CacheMinder *MCP_; 70 | string instanceDirectory_; 71 | int resolutionBase_; 72 | int numberOfResolutionLevels_; 73 | 74 | 75 | /** 76 | * constructor allowing the boundary of the new node to be defined and 77 | * sets other attributes to default values 78 | * 79 | * @note this constructor should be used with extreme caution. creation 80 | * of nodes is normally handled by the quadtree 81 | * and any difference in the way the boundarys are calculated could lead 82 | * to points falling between gaps or nodes overlaping. 83 | * 84 | * @param minX X value of the lower left corner of the boundary 85 | * @param minY Y value of the lower left corner of the boundary 86 | * @param maxX X value of the upper right corner of the boundary 87 | * @param maxY Y value of the upper right corner of the boundary 88 | * @param capacity the capacity of the node before it overflows and splits 89 | * @param MCD the cacheminder for this quadtree instance 90 | * @param instanceDirectory string containing a path to a directory where 91 | * temporary files will be saved 92 | * @param resolutionBase is passed on to pointbuckets, see \link 93 | * PointBucket \endlink detailed description for explanation 94 | * @param numberOfResolutionLevels is passed on to pointbuckets, see 95 | * \link PointBucket \endlink detailed description for explanation 96 | */ 97 | QuadtreeNode(double minX, double minY, double maxX, double maxY, 98 | int capacity, CacheMinder *MCD, string instanceDirectory, 99 | int resolutionBase, int numberOfResolutionLevels); 100 | 101 | 102 | /** 103 | * constructor allowing the boundary of the new node to be defined 104 | * and its children specified 105 | * 106 | * @note this constructor should be used with extreme caution. creation of 107 | * nodes is normally handled by the quadtree 108 | * and any difference in the way the boundarys are calculated could 109 | * lead to points falling between gaps or nodes overlaping. 110 | * 111 | * @param minX X value of the lower left corner of the boundary 112 | * @param minY Y value of the lower left corner of the boundary 113 | * @param maxX X value of the upper right corner of the boundary 114 | * @param maxY Y value of the upper right corner of the boundary 115 | * @param capacity the capacity of the node before it overflows and splits 116 | * @param a child node (by convention top left) 117 | * @param b child node (by convention top right) 118 | * @param d child node (by convention bottom left) 119 | * @param c child node (by convention bottom right) 120 | * @param MCD the cacheminder for this quadtree instance 121 | * @param instanceDirectory string containing a path to a directory where 122 | * temporary files will be saved 123 | * @param resolutionBase is passed on to pointbuckets, see \link 124 | * PointBucket \endlink detailed description for explanation 125 | * @param numberOfResolutionLevels is passed on to pointbuckets, see 126 | * \link PointBucket \endlink detailed description for explanation 127 | */ 128 | QuadtreeNode(double minX, double minY, double maxX, double maxY, 129 | int capacity, QuadtreeNode* a, QuadtreeNode* b, 130 | QuadtreeNode* c, QuadtreeNode* d, CacheMinder *MCD, 131 | string instanceDirectory, int resolutionBase, 132 | int numberOfResolutionLevels); 133 | ~QuadtreeNode(); 134 | 135 | 136 | /** 137 | * a method to insert a new point into the node 138 | * 139 | * @note if the insertion of the point causes the node to overflow 140 | * then it creates 141 | * four child nodes and inserts the point into one of thease (along 142 | * with copying 143 | * all the points it already contains into the corrisponding children) 144 | * 145 | * @param newPoint the point to be inserted 146 | * 147 | * @return false=the point falls within this nodes boundary but the node 148 | * is not a leaf, true=sucssesfull insertion 149 | */ 150 | bool insert(LidarPoint newPoint); 151 | 152 | /** 153 | * a method to print a debug view of the node to cout 154 | */ 155 | void print(); 156 | 157 | /** 158 | * a method to check if the node is a leaf 159 | * 160 | * @return true=leaf 161 | */ 162 | bool isLeaf(); 163 | 164 | 165 | /** 166 | * this method checks if a given point is within the boundary of the node 167 | * 168 | * @param newPoint the point to check 169 | * 170 | * @return true=within boundary 171 | */ 172 | bool checkBoundary(LidarPoint newPoint); 173 | 174 | /** 175 | * a method to get the boundary of the node in a boundary struct 176 | * 177 | * @return the boundary of the node 178 | */ 179 | Boundary* getBoundary(); 180 | 181 | /** 182 | * this method returns the child into which the point passed fits 183 | * 184 | * @param newPoint the point to check against 185 | * 186 | * @return a pointer to the child of this node that the point falls within, 187 | * if this node is a leaf then NULL is returned 188 | */ 189 | QuadtreeNode* pickChild(LidarPoint newPoint); 190 | 191 | 192 | 193 | /** 194 | * a method that sorts the bucket in the node and recurivly in all 195 | * child nodes using the point comparison function passed 196 | * 197 | * @param comparator a comparison function for two points that returns an 198 | * int 199 | */ 200 | void sort(int ( * comparator) (const void *, const void *)); 201 | 202 | /** 203 | * checks if the node is empty 204 | * 205 | * @return true=empty 206 | */ 207 | bool isEmpty(); 208 | 209 | /** 210 | * a method to add pointbuckets from nodes that fall within a given 211 | * boundary to a vector. this method is recursive so if the node is 212 | * not a leaf it simply calls this method in its child nodes 213 | * this means that every node below the node you first call it on is 214 | * checked. 215 | * 216 | * @note this method creates the search area by drawing a line from point 217 | * 1 to 2 to 3 to 4. and searches the area within these lines these lines 218 | * MUST describe a convex polygon 219 | * 220 | * @param horizontalCornerValues an array of doubles each of which is the 221 | * x componant of a point of the polygon (in sequence) 222 | * @param verticalCornerValues an array of doubles each of which is the 223 | * y componant of a point of the polygon (in sequence) 224 | * @param size the number of corners that make up the polygon (the length 225 | * of the HorizontalCornerValues and VerticalCornerValues arrays) 226 | * @param buckets the pointer to a vector to which any correct nodes are 227 | * added 228 | */ 229 | void advSubset(vector horizontalCornerValues, vector verticalCornerValues, 230 | int size, vector *buckets); 231 | 232 | /** 233 | * a method that creates 4 child nodes each a quater of the size of this 234 | * node and copies the points into the child node they fall within 235 | */ 236 | void splitNode(); 237 | 238 | /** 239 | * a method which increases the depth of all leaf nodes below it by i 240 | * (splits them then checks) 241 | */ 242 | void increaseDepth(int i); 243 | 244 | /** 245 | * a method which increases the depth of all leaf nodes below it to a 246 | * minimum of i 247 | */ 248 | void increaseToMinimumDepth(int i); 249 | }; 250 | 251 | inline bool QuadtreeNode::isLeaf() 252 | { 253 | return leaf_; 254 | } 255 | 256 | 257 | #endif /* _QUADTREENODE_H */ 258 | 259 | -------------------------------------------------------------------------------- /src/BoxOverlay.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | BoxOverlay.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef BOXOVERLAY_H 29 | #define BOXOVERLAY_H 30 | #include 31 | 32 | #include 33 | #include 34 | #include "Colour.h" 35 | #include "Point.h" 36 | #include "SelectionBox.h" 37 | 38 | /* 39 | =============================================================================== 40 | 41 | BoxOverlay - represents a rectangle on the screen. 42 | 43 | =============================================================================== 44 | */ 45 | class BoxOverlay 46 | { 47 | public: 48 | BoxOverlay(Gtk::Label *label, Colour majorcolour, Colour minorcolour); 49 | 50 | ~BoxOverlay(); 51 | 52 | // Determine the boundaries from the start and end points of the user's 53 | // clicks and drags and whether to be orthogonal or slanted. 54 | void makeboundaries(); 55 | 56 | //Make the box with one line possibly in a different colour.. 57 | void makebox(double rmaxz); 58 | 59 | //Defines the start point and, initially, the end point. 60 | void on_start(Point, double areawidth, double areaheight); 61 | 62 | //Defines the end point. 63 | void on_(Point, double areawidth, double areaheight); 64 | 65 | // Moves the box using keyboard input, with different methods depending 66 | // on slantedness and directionality. 67 | bool on_key(GdkEventKey* event, double scrollspeed, bool fractionalshift); 68 | 69 | // Directly defines both start and end 70 | void directly_place(Point, Point, double areawidth, double areaheight); 71 | 72 | //Outputs coordinate information to the label. 73 | void drawinfo(); 74 | 75 | //Getters: 76 | 77 | inline SelectionBox getSelectionBox() 78 | { 79 | return theBox; 80 | } 81 | 82 | //Setters: 83 | 84 | //Set width of the slanted box. 85 | inline void setslantwidth(double slantwidth) 86 | { 87 | this->slantwidth = slantwidth; 88 | } 89 | 90 | inline void setorthogonalshape(bool orthogonalshape) 91 | { 92 | this->orthogonalshape = orthogonalshape; 93 | } 94 | 95 | inline void setslantedshape(bool slantedshape) 96 | { 97 | this->slantedshape = slantedshape; 98 | } 99 | 100 | inline void setratio(double ratio) 101 | { 102 | this->ratio = ratio; 103 | } 104 | 105 | inline void setzoomlevel(double zoomlevel) 106 | { 107 | this->zoomlevel = zoomlevel; 108 | } 109 | 110 | inline void setcentre(Point c) 111 | { 112 | centre = c; 113 | } 114 | 115 | private: 116 | // This is true if there is a minor colour and means that keyboard movement 117 | // will be forward and backwards and so on respective to looking into the 118 | // box from the line in the minor colour. 119 | bool directional; 120 | 121 | //Determines whether or not to draw an orthogonal box. 122 | bool orthogonalshape; 123 | 124 | //Determines whether or not to draw a slanted box. 125 | bool slantedshape; 126 | 127 | //Label showing the distance, in various dimensions, covered by 128 | //the ruler. 129 | Gtk::Label *label; 130 | 131 | //This is the colour of three of the four lines that make up the box. 132 | Colour majorcolour; 133 | 134 | // This is the colour of the line that, for a profile, represents the 135 | // near clipping plane and indicates where the profile is used from. 136 | Colour minorcolour; 137 | 138 | //These are returned to other objects to define the box. 139 | //Store the boundaries of the profile: 140 | SelectionBox theBox; 141 | 142 | // Stores the number of corners for the profile. 143 | // Position variables: 144 | // These give the centre of the viewport in image terms, rather than 145 | // screen terms. 146 | Point centre; 147 | 148 | //The width of the slanted box in world units. 149 | double slantwidth; 150 | 151 | //The start coordinates in world units. 152 | Point start; 153 | 154 | //The end coordinates in world units. 155 | Point end; 156 | 157 | // This stores the ratio for translating to and from screen scale and 158 | // world scale. It should be set to be the same as in the parent Display 159 | // area. 160 | double ratio; 161 | 162 | // Like the ratio, it should be the same as in the parent Display area. 163 | // It modifies the ratio. 164 | double zoomlevel; 165 | }; 166 | #endif 167 | -------------------------------------------------------------------------------- /src/ClassifyWorker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | ClassifyWorker.cpp 5 | 6 | Created on: 11 May 2012 7 | Authors: jaho, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include "ClassifyWorker.h" 29 | #include "Profile.h" 30 | #include "ProfileTypes.h" 31 | 32 | /* 33 | ================================== 34 | ClassifyWorker::ClassifyWorker 35 | ================================== 36 | */ 37 | ClassifyWorker::ClassifyWorker(Profile* prof) : 38 | Worker(), profile(prof), stopFlag(false) 39 | { 40 | // dummy point 41 | currentjob = make_pair(make_pair(Point(0), Point(0)), 255); 42 | } 43 | 44 | /* 45 | ================================================================================ 46 | ClassifyWorker::~ClassifyWorker 47 | ================================================================================ 48 | */ 49 | ClassifyWorker::~ClassifyWorker() 50 | { 51 | stop(); 52 | } 53 | 54 | /* 55 | ================================================================================ 56 | ClassifyWorker::stop 57 | ================================================================================ 58 | */ 59 | void ClassifyWorker::stop() 60 | { 61 | Glib::Mutex::Lock internal_lock(internal_mutex); 62 | 63 | stopFlag = true; 64 | classify_condition.signal(); 65 | } 66 | 67 | /* 68 | ================================================================================ 69 | ClassifyWorker::nudge 70 | 71 | Indicates to this thread that jobs are/could be available 72 | ================================================================================ 73 | */ 74 | void ClassifyWorker::nudge() 75 | { 76 | classify_condition.signal(); 77 | } 78 | 79 | /* 80 | ================================================================================ 81 | ClassifyWorker::getCurrentJob 82 | 83 | Retrieve current job from this thread 84 | ================================================================================ 85 | */ 86 | ClassificationJob ClassifyWorker::getCurrentJob() 87 | { 88 | Glib::Mutex::Lock internal_lock(internal_mutex); 89 | 90 | return currentjob; 91 | } 92 | 93 | /* 94 | ================================================================================ 95 | ClassifyWorker::run 96 | ================================================================================ 97 | */ 98 | void ClassifyWorker::run() 99 | { 100 | Glib::Mutex::Lock internal_lock(internal_mutex); 101 | 102 | // internal copies 103 | FenceType thisfence; 104 | 105 | while(!stopFlag) 106 | { 107 | for(currentjob = profile->popNextClassify(); currentjob.second == 255 && !stopFlag; currentjob = profile->popNextClassify()) 108 | classify_condition.wait(internal_mutex); 109 | 110 | if(!stopFlag) 111 | { 112 | thisfence = currentjob.first; 113 | 114 | internal_lock.release(); 115 | profile->classify(thisfence.first, thisfence.second, currentjob.second); 116 | internal_lock.acquire(); 117 | 118 | currentjob.second = 255; 119 | profile->clearProcessingFence(); 120 | sig_done(); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/ClassifyWorker.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | ClassifyWorker.h 5 | 6 | Created on: 11 May 2012 7 | Authors: jaho, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef CLASSIFYWORKER_H_ 29 | #define CLASSIFYWORKER_H_ 30 | 31 | #include 32 | #include "Worker.h" 33 | #include "ProfileTypes.h" 34 | 35 | class Profile; 36 | 37 | /* 38 | =============================================================================== 39 | 40 | ClassifyWorker - a worker class for points classification. 41 | 42 | =============================================================================== 43 | */ 44 | class ClassifyWorker: public Worker 45 | { 46 | public: 47 | ClassifyWorker(Profile* prof); 48 | ~ClassifyWorker(); 49 | void nudge(); 50 | void stop(); 51 | 52 | ClassificationJob getCurrentJob(); 53 | 54 | protected: 55 | void run(); 56 | 57 | private: 58 | Profile* profile; 59 | ClassificationJob currentjob; 60 | bool stopFlag; 61 | 62 | // Threading control 63 | Glib::Cond classify_condition; 64 | Glib::Mutex internal_mutex; 65 | }; 66 | 67 | #endif /* CLASSIFYWORKER_H_ */ 68 | -------------------------------------------------------------------------------- /src/Colour.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | Colour.cpp 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include "Colour.h" 29 | 30 | /* 31 | ================================== 32 | Colour::Colour 33 | ================================== 34 | */ 35 | Colour::Colour() 36 | { 37 | colourValues[0] = 0.0; 38 | colourValues[1] = 0.0; 39 | colourValues[2] = 0.0; 40 | } 41 | 42 | /* 43 | ================================== 44 | Colour::Colour 45 | ================================== 46 | */ 47 | Colour::Colour(float r, float g, float b) 48 | { 49 | colourValues[0] = r; 50 | colourValues[1] = g; 51 | colourValues[2] = b; 52 | } 53 | 54 | /* 55 | ================================== 56 | Colour::Colour 57 | ================================== 58 | */ 59 | Colour::Colour(const std::string& colourName) 60 | { 61 | if(colourName == "red") 62 | { 63 | colourValues[0] = 1.0f; 64 | colourValues[1] = 0.0f; 65 | colourValues[2] = 0.0f; 66 | } else if(colourName == "white") 67 | { 68 | colourValues[0] = 1.0f; 69 | colourValues[1] = 1.0f; 70 | colourValues[2] = 1.0f; 71 | } else if(colourName == "green") 72 | { 73 | colourValues[0] = 0.0f; 74 | colourValues[1] = 1.0f; 75 | colourValues[2] = 0.0f; 76 | } else if(colourName == "blue") 77 | { 78 | colourValues[0] = 0.0f; 79 | colourValues[1] = 0.0f; 80 | colourValues[2] = 1.0f; 81 | } 82 | } 83 | 84 | /* 85 | ================================== 86 | operator== 87 | ================================== 88 | */ 89 | bool operator==(Colour& lhs, Colour& rhs) 90 | { 91 | for(int i = 0; i < 3; ++i) 92 | { 93 | if(lhs.getRGB()[i] != rhs.getRGB()[i]) 94 | return false; 95 | } 96 | return true; 97 | } 98 | 99 | /* 100 | ================================== 101 | operator!= 102 | ================================== 103 | */ 104 | bool operator!=(Colour& lhs, Colour& rhs) 105 | { 106 | if(lhs == rhs) 107 | return false; 108 | else 109 | return true; 110 | } 111 | 112 | /* 113 | ================================== 114 | Colour::multiply 115 | ================================== 116 | */ 117 | void Colour::multiply(Colour other) 118 | { 119 | colourValues[0] *= other.getR(); 120 | if(colourValues[0] > 1.0) 121 | colourValues[0] = 1.0; 122 | 123 | colourValues[1] *= other.getG(); 124 | if(colourValues[1] > 1.0) 125 | colourValues[1] = 1.0; 126 | 127 | colourValues[2] *= other.getB(); 128 | if(colourValues[2] > 1.0) 129 | colourValues[2] = 1.0; 130 | } 131 | 132 | /* 133 | ================================== 134 | Colour::multiply 135 | ================================== 136 | */ 137 | void Colour::multiply(float multiplicant) 138 | { 139 | colourValues[0] *= multiplicant; 140 | if(colourValues[0] > 1.0) 141 | colourValues[0] = 1.0; 142 | 143 | colourValues[1] *= multiplicant; 144 | if(colourValues[1] > 1.0) 145 | colourValues[1] = 1.0; 146 | 147 | colourValues[2] *= multiplicant; 148 | if(colourValues[2] > 1.0) 149 | colourValues[2] = 1.0; 150 | } 151 | 152 | /* 153 | ================================== 154 | Colour::multiply 155 | ================================== 156 | */ 157 | void Colour::multiply(float r, float g, float b) 158 | { 159 | colourValues[0] *= r; 160 | if(colourValues[0] > 1.0) 161 | colourValues[0] = 1.0; 162 | 163 | colourValues[1] *= g; 164 | if(colourValues[1] > 1.0) 165 | colourValues[1] = 1.0; 166 | 167 | colourValues[2] *= b; 168 | if(colourValues[2] > 1.0) 169 | colourValues[2] = 1.0; 170 | } 171 | 172 | /* 173 | ================================== 174 | Colour::add 175 | ================================== 176 | */ 177 | void Colour::add(Colour other) 178 | { 179 | colourValues[0] += other.getR(); 180 | if(colourValues[0] > 1.0) 181 | colourValues[0] = 1.0; 182 | 183 | colourValues[1] += other.getG(); 184 | if(colourValues[1] > 1.0) 185 | colourValues[1] = 1.0; 186 | 187 | colourValues[2] += other.getB(); 188 | if(colourValues[2] > 1.0) 189 | colourValues[2] = 1.0; 190 | } 191 | 192 | /* 193 | ================================== 194 | Colour::add 195 | ================================== 196 | */ 197 | void Colour::add(float numberToAdd) 198 | { 199 | colourValues[0] += numberToAdd; 200 | if(colourValues[0] > 1.0) 201 | colourValues[0] = 1.0; 202 | 203 | colourValues[1] += numberToAdd; 204 | if(colourValues[1] > 1.0) 205 | colourValues[1] = 1.0; 206 | 207 | colourValues[2] += numberToAdd; 208 | if(colourValues[2] > 1.0) 209 | colourValues[2] = 1.0; 210 | } 211 | 212 | /* 213 | ================================== 214 | Colour::add 215 | ================================== 216 | */ 217 | void Colour::add(float r, float g, float b) 218 | { 219 | colourValues[0] += r; 220 | if(colourValues[0] > 1.0) 221 | colourValues[0] = 1.0; 222 | 223 | colourValues[1] += g; 224 | if(colourValues[1] > 1.0) 225 | colourValues[1] = 1.0; 226 | 227 | colourValues[2] += b; 228 | if(colourValues[2] > 1.0) 229 | colourValues[2] = 1.0; 230 | } 231 | 232 | /* 233 | ================================== 234 | Colour::subtract 235 | ================================== 236 | */ 237 | void Colour::subtract(Colour other) 238 | { 239 | colourValues[0] -= other.getR(); 240 | if(colourValues[0] < 0.0) 241 | colourValues[0] = 0.0; 242 | 243 | colourValues[1] -= other.getG(); 244 | if(colourValues[1] < 0.0) 245 | colourValues[1] = 0.0; 246 | 247 | colourValues[2] -= other.getB(); 248 | if(colourValues[2] < 0.0) 249 | colourValues[2] = 0.0; 250 | } 251 | 252 | /* 253 | ================================== 254 | Colour::subtract 255 | ================================== 256 | */ 257 | void Colour::subtract(float numberToSubtract) 258 | { 259 | colourValues[0] -= numberToSubtract; 260 | if(colourValues[0] < 0.0) 261 | colourValues[0] = 0.0; 262 | 263 | colourValues[1] -= numberToSubtract; 264 | if(colourValues[1] < 0.0) 265 | colourValues[1] = 0.0; 266 | 267 | colourValues[2] -= numberToSubtract; 268 | if(colourValues[2] < 0.0) 269 | colourValues[2] = 0.0; 270 | } 271 | 272 | /* 273 | ================================== 274 | Colour::subtract 275 | ================================== 276 | */ 277 | void Colour::subtract(float r, float g, float b) 278 | { 279 | colourValues[0] -= r; 280 | if(colourValues[0] < 0.0) 281 | colourValues[0] = 0.0; 282 | 283 | colourValues[1] -= g; 284 | if(colourValues[1] < 0.0) 285 | colourValues[1] = 0.0; 286 | 287 | colourValues[2] -= b; 288 | if(colourValues[2] < 0.0) 289 | colourValues[2] = 0.0; 290 | } 291 | 292 | /* 293 | ================================== 294 | Colour::~Colour 295 | ================================== 296 | */ 297 | Colour::~Colour() 298 | { 299 | } 300 | 301 | // Getters 302 | float Colour::getR() 303 | { 304 | return colourValues[0]; 305 | } 306 | float Colour::getG() 307 | { 308 | return colourValues[1]; 309 | } 310 | float Colour::getB() 311 | { 312 | return colourValues[2]; 313 | } 314 | float* Colour::getRGB() 315 | { 316 | return colourValues; 317 | } 318 | 319 | // Setters 320 | void Colour::setR(float r) 321 | { 322 | colourValues[0] = r; 323 | } 324 | void Colour::setG(float g) 325 | { 326 | colourValues[1] = g; 327 | } 328 | void Colour::setB(float b) 329 | { 330 | colourValues[2] = b; 331 | } 332 | void Colour::setRGB(float r, float g, float b) 333 | { 334 | colourValues[0] = r; 335 | colourValues[1] = g; 336 | colourValues[2] = b; 337 | } 338 | -------------------------------------------------------------------------------- /src/Colour.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | Colour.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef _COLOUR_H_ 29 | #define _COLOUR_H_ 30 | 31 | #include 32 | 33 | /* 34 | =============================================================================== 35 | 36 | Colour - class to hold information about a colour. This will hold a red, green, 37 | and blue value. 38 | 39 | =============================================================================== 40 | */ 41 | class Colour 42 | { 43 | 44 | public: 45 | Colour(); 46 | Colour(float, float, float); 47 | Colour(const std::string&); 48 | ~Colour(); 49 | 50 | // Comparison operators 51 | friend bool operator==(Colour& lhs, Colour& rhs); 52 | friend bool operator!=(Colour& lhs, Colour& rhs); 53 | 54 | // Multiply 55 | void multiply(Colour); 56 | void multiply(float); 57 | void multiply(float, float, float); 58 | 59 | // Add 60 | void add(Colour); 61 | void add(float); 62 | void add(float, float, float); 63 | 64 | // Subtract 65 | void subtract(Colour); 66 | void subtract(float); 67 | void subtract(float, float, float); 68 | 69 | // Getters 70 | float getR(); 71 | float getG(); 72 | float getB(); 73 | float* getRGB(); 74 | 75 | // Setters 76 | void setR(float); 77 | void setG(float); 78 | void setB(float); 79 | void setRGB(float, float, float); 80 | 81 | private: 82 | float colourValues[3]; 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/DrawWorker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ================================================================================ 3 | 4 | DrawWorker.cpp 5 | 6 | Created on: 1 August 2012 7 | Authors: Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | ================================================================================ 26 | */ 27 | 28 | #include "DrawWorker.h" 29 | #include "Profile.h" 30 | 31 | /* 32 | ================================================================================ 33 | DrawWorker::DrawWorker 34 | 35 | Parameters: 36 | disp - The LagDisplay object that this thread is to be associated with 37 | ================================================================================ 38 | */ 39 | DrawWorker::DrawWorker(LagDisplay* disp) : 40 | Worker(), display(disp), goFlag(false), stopFlag(false), drawing(false) 41 | { 42 | } 43 | 44 | /* 45 | ================================================================================ 46 | DrawWorker::~DrawWorker 47 | ================================================================================ 48 | */ 49 | DrawWorker::~DrawWorker() 50 | { 51 | if(thread) 52 | { 53 | stop(); 54 | this->~Worker(); 55 | } 56 | } 57 | 58 | /* 59 | ================================================================================ 60 | DrawWorker::stop 61 | 62 | Stops this drawing thread from executing as soon as possible, and may wake 63 | it up to do so. 64 | ================================================================================ 65 | */ 66 | void DrawWorker::stop() 67 | { 68 | Glib::Mutex::Lock internal_lock(internal_mutex); 69 | 70 | stopFlag = true; 71 | 72 | // unlock GL to make sure the thread is able to proceed without deadlock 73 | display->abortFrame(true); 74 | 75 | goFlag = true; 76 | draw_frame.signal(); 77 | } 78 | 79 | /* 80 | ================================================================================ 81 | DrawWorker::run 82 | 83 | Used internally by all Worker objects, main function of execution, thread 84 | terminates on completion. 85 | ================================================================================ 86 | */ 87 | void DrawWorker::run() 88 | { 89 | // Initialisation now that Glib is set up 90 | PointBucket** copyof_buckets; 91 | int copyof_numbuckets; 92 | 93 | Glib::Mutex::Lock internal_lock(internal_mutex); 94 | 95 | stopFlag = false; 96 | drawing = false; 97 | 98 | while(!stopFlag) 99 | { 100 | // awaits another process to give the signal to proceed 101 | while(!goFlag) 102 | draw_frame.wait(internal_mutex); 103 | goFlag = false; 104 | drawing = true; 105 | 106 | // per-thread copies, safe to call display->mainimage with without the 107 | // internal mutex being locked 108 | copyof_buckets = internal_buckets; 109 | copyof_numbuckets = internal_numbuckets; 110 | 111 | // aborting is now futile, since buckets and numbuckets are as up-to-date 112 | // as they can be 113 | display->clear_abortFrame(); 114 | 115 | if(!stopFlag) 116 | { 117 | internal_lock.release(); 118 | display->mainimage(copyof_buckets, copyof_numbuckets); 119 | internal_lock.acquire(); 120 | 121 | drawing = goFlag; 122 | } 123 | 124 | sig_done(); 125 | } 126 | } 127 | 128 | /* 129 | ================================================================================ 130 | DrawWorker::draw 131 | 132 | Notes down what values to draw when the next frame happens (which can be any 133 | time in the future), and may trigger the next frame, but not necessarily 134 | 135 | Parameters: 136 | buckets - Buckets to draw the main image with 137 | numbuckets - Count of buckets in given array 138 | ================================================================================ 139 | */ 140 | void DrawWorker::draw(PointBucket** buckets, int numbuckets) 141 | { 142 | // attain exclusive rights to internal_buckets and internal_numbuckets 143 | Glib::Mutex::Lock lock(internal_mutex); 144 | 145 | internal_buckets = buckets; 146 | internal_numbuckets = numbuckets; 147 | 148 | goFlag = true; 149 | draw_frame.signal(); 150 | } 151 | 152 | /* 153 | ================================================================================ 154 | DrawWorker::isDrawing 155 | 156 | Returns whether or not the thread is presently drawing. Accurate at exactly 157 | the moment of use, but only for an undefined period of time (due to threading 158 | policies in the kernel) - use sparingly if at all. 159 | ================================================================================ 160 | */ 161 | bool DrawWorker::isDrawing() 162 | { 163 | Glib::Mutex::Lock lock(internal_mutex); 164 | 165 | return drawing; 166 | } 167 | -------------------------------------------------------------------------------- /src/DrawWorker.h: -------------------------------------------------------------------------------- 1 | /* 2 | ================================================================================ 3 | 4 | DrawWorker.h 5 | 6 | Created on: 1 August 2012 7 | Author: Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | ================================================================================ 26 | */ 27 | 28 | #ifndef DRAWWORKER_H_ 29 | #define DRAWWORKER_H_ 30 | 31 | #include 32 | #include "Worker.h" 33 | 34 | class LagDisplay; 35 | 36 | /* 37 | ================================================================================ 38 | 39 | DrawWorker - a worker class for drawing lag information in gtkglextmm viewports 40 | 41 | ================================================================================ 42 | */ 43 | class DrawWorker: public Worker 44 | { 45 | public: 46 | DrawWorker(LagDisplay* disp); 47 | 48 | ~DrawWorker(); 49 | 50 | void stop(); 51 | void run(); 52 | 53 | void draw(PointBucket** buckets, int numbuckets); 54 | 55 | bool isDrawing(); 56 | 57 | private: 58 | bool goFlag; 59 | bool stopFlag; 60 | bool drawing; 61 | 62 | LagDisplay* display; 63 | 64 | // arguments for draw 65 | PointBucket** internal_buckets; 66 | int internal_numbuckets; 67 | 68 | // Signal to indicate to the drawing thread to wake up and check the goFlag 69 | // to proceed to draw a frame 70 | Glib::Cond draw_frame; 71 | 72 | // Exclusive access to internal values 73 | Glib::Mutex internal_mutex; 74 | }; 75 | 76 | #endif /* DRAWWORKER_H_ */ 77 | -------------------------------------------------------------------------------- /src/FileUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FileUtils.cpp 5 | 6 | Created on: 19 Jun 2012 7 | Authors: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include 29 | #include 30 | #include "FileUtils.h" 31 | #include "laslib/lasreader.hpp" 32 | 33 | /* 34 | ================================== 35 | test_filename 36 | 37 | Determines type of the file based on its extension. 38 | Returns type of the file: LAS_FILE, ASCII_FILE or UNKNOWN_FILE. 39 | ================================== 40 | */ 41 | filetype_t test_filename(std::string const& filename) 42 | { 43 | if(filename.find(".las", filename.length() - 4) != std::string::npos || filename.find(".LAS", filename.length() - 4) != std::string::npos 44 | || filename.find(".laz", filename.length() - 4) != std::string::npos || filename.find(".LAZ", filename.length() - 4) != std::string::npos) 45 | { 46 | return LAS_FILE; 47 | } else if(filename.find(".txt", filename.length() - 4) != std::string::npos || filename.find(".TXT", filename.length() - 4) != std::string::npos 48 | || filename.find(".csv", filename.length() - 4) != std::string::npos || filename.find(".CSV", filename.length() - 4) != std::string::npos) 49 | { 50 | return ASCII_FILE; 51 | } 52 | 53 | return UNKNOWN_FILE; 54 | } 55 | 56 | /* 57 | ================================== 58 | has_waveform 59 | 60 | Given a LASreader object checks if the associated file contains waveform information. 61 | Note it only checks point version and doesn't actually search for waveform data. 62 | ================================== 63 | */ 64 | bool has_waveform(LASreader const* reader) 65 | { 66 | return (reader->header.version_minor >= 3); 67 | } 68 | 69 | /* 70 | ================================== 71 | is_latlong 72 | 73 | Given a LASreader object checks if the associated file 74 | is in latlong projection. Returns true/false. 75 | ================================== 76 | */ 77 | bool is_latlong(LASreader const* reader) 78 | { 79 | return (-360 < reader->header.min_x && -360 < reader->header.min_y && reader->header.max_x < 360 && reader->header.max_y < 360); 80 | } 81 | 82 | /* 83 | ================================== 84 | convert_string 85 | 86 | Converts a std::string to char*. Returns a copy of the string. 87 | The object has to be deleted by the caller. 88 | ================================== 89 | */ 90 | char* convert_string(std::string const& str) 91 | { 92 | char* c = new char[str.size() + 1]; 93 | strcpy(c, str.c_str()); 94 | return c; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /src/FileUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FileUtils.h 5 | 6 | This file contains various definitions and 7 | methods used by LoadWorker and SaveWorker. 8 | 9 | Created on: 19 Jun 2012 10 | Authors: Jan Holownia 11 | 12 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 13 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 14 | 15 | This program is free software: you can redistribute it and/or modify 16 | it under the terms of the GNU General Public License as published by 17 | the Free Software Foundation, either version 3 of the License, or 18 | (at your option) any later version. 19 | 20 | This program is distributed in the hope that it will be useful, 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | GNU General Public License for more details. 24 | 25 | You should have received a copy of the GNU General Public License 26 | along with this program. If not, see . 27 | 28 | =============================================================================== 29 | */ 30 | 31 | #ifndef FILEUTILS_H_ 32 | #define FILEUTILS_H_ 33 | 34 | #include 35 | #include "laslib/lasdefinitions.hpp" 36 | #include "geoprojectionconverter.hpp" 37 | 38 | class LASreader; 39 | 40 | // Supported file types 41 | typedef enum 42 | { 43 | LAS_FILE, ASCII_FILE, UNKNOWN_FILE 44 | } filetype_t; 45 | 46 | filetype_t test_filename(std::string const& filename); 47 | bool has_waveform(LASreader const* reader); 48 | bool is_latlong(LASreader const* reader); 49 | char* convert_string(std::string const& str); 50 | 51 | #endif /* FILEUTILS_H_ */ 52 | -------------------------------------------------------------------------------- /src/LoadWorker.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | LoadWorker.h 5 | 6 | Created on: 24 Apr 2012 7 | Author: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef LOADWORKER_H_ 29 | #define LOADWORKER_H_ 30 | 31 | #include "Worker.h" 32 | #include "SelectionBox.h" 33 | #include 34 | #include 35 | #include "geoprojectionconverter.hpp" 36 | #include "laslib/lasdefinitions.hpp" 37 | #include "PointFilter.h" 38 | 39 | class FileOpener; 40 | class Boundary; 41 | class Quadtree; 42 | class LASreader; 43 | 44 | /* 45 | =============================================================================== 46 | 47 | LoadWorker - a worker class for loading files. Also creates and populates the 48 | Quadtree. 49 | 50 | =============================================================================== 51 | */ 52 | class LoadWorker: public Worker 53 | { 54 | public: 55 | LoadWorker(FileOpener* fo, int point_offset, std::vector filenames, bool s, bool usearea, int resolutiondepth, int resolutionbase, 56 | int bucketlevels, int bucketlimit, int cachelimit, bool default_scale_factors, double scale_factor[3], std::string ascii_code, 57 | SelectionBox fence, PointFilter pf, std::string cache_path); 58 | 59 | void stop(); 60 | 61 | Glib::Dispatcher sig_message; // Signals the GUI to display a message 62 | Glib::Dispatcher sig_file_loaded; // Signals that a file has been loaded 63 | Glib::Dispatcher sig_fail; // Signals failure 64 | Glib::Dispatcher sig_progress; // Signals when loading (1%, typically) 65 | Glib::Dispatcher sig_ascii; // Signals when not possible to estimate sig_progress 66 | 67 | // This stores location of PointData files with 1.3 point attributes 68 | static std::tr1::unordered_map point_data_paths; 69 | static std::vector point_number; 70 | 71 | protected: 72 | void run(); 73 | void send_message(std::string message); 74 | Boundary get_boundary(); 75 | int load_points(Quadtree* qt); 76 | int load_points_wf(Quadtree* qt); 77 | 78 | void convert_projection(); 79 | std::string get_utm_zone(); 80 | 81 | FileOpener* fileopener; 82 | int point_offset; 83 | std::vector filenames; 84 | bool create_new_quadtree; 85 | bool usearea; 86 | int resolutiondepth; 87 | int resolutionbase; 88 | int bucketLevels; 89 | int bucketlimit; 90 | int cachelimit; 91 | bool use_default_scale_factors; 92 | double scale_factor[3]; 93 | std::string ascii_code; 94 | SelectionBox fence; 95 | PointFilter point_filter; 96 | std::string cache_path; 97 | 98 | bool latlong; 99 | GeoProjectionConverter gpc; 100 | LASquantizer* reproject_quantizer; 101 | LASquantizer* saved_quantizer; 102 | LASreader* reader; 103 | }; 104 | 105 | #endif /* LOADWORKER_H_ */ 106 | -------------------------------------------------------------------------------- /src/MathFuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | MathFuncs.h 5 | 6 | Created on: December 2009 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef MATHFUNCS_H 29 | #define MATHFUNCS_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "PointBucket.h" 36 | 37 | using namespace std; 38 | 39 | double percentilevalue(double* data, int datasize, double percentile, double minval, double maxval); 40 | 41 | bool* vetpoints(PointBucket* points, std::vector xs, std::vector ys, int numberofcorners, bool profileNoisePoints); 42 | 43 | bool* vetpoints_slice(PointBucket* points, std::vector xs, std::vector ys, int numberofcorners, bool profileNoisePoints, double minz, 44 | double maxz); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/PointFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PointFilter.h 5 | 6 | Created on: 27 Jun 2012 7 | Authors: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef POINTFILTER_H_ 29 | #define POINTFILTER_H_ 30 | 31 | /* 32 | =============================================================================== 33 | 34 | PointFilter - a structure to hold filter arguments in a commandline-like string. 35 | If argc = 0 the filter is inactive. 36 | 37 | =============================================================================== 38 | */ 39 | struct PointFilter 40 | { 41 | PointFilter() : 42 | argc(0) 43 | { 44 | } 45 | ; 46 | ~PointFilter() 47 | { 48 | } 49 | ; 50 | int argc; 51 | std::vector args; 52 | }; 53 | 54 | #endif /* POINTFILTER_H_ */ 55 | -------------------------------------------------------------------------------- /src/ProfileTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | ProfileTypes.h 5 | 6 | Created on: 31 August 2012 7 | Authors: Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef PROFILETYPES_H_ 29 | #define PROFILETYPES_H_ 30 | #include 31 | #include "Point.h" 32 | 33 | /* 34 | * Mostly just a quick convenience & clarity header, shared between Profile and 35 | * any of the Profile's Worker classes that need it 36 | * 37 | */ 38 | 39 | /* 40 | ================================================================================ 41 | FenceType 42 | 43 | Defines a box (or fence) from two points 44 | ================================================================================ 45 | */ 46 | typedef std::pair FenceType; 47 | 48 | /* 49 | ================================================================================ 50 | ClassificationJob 51 | 52 | ClassifyWorker(s) takes jobs from a respective Profile as and when ready. 53 | ClassificationJob is a type which bundles all the necessary data to specify a 54 | job into one object, handy for things like forming lists 55 | ================================================================================ 56 | */ 57 | typedef std::pair ClassificationJob; 58 | 59 | #endif /* #ifdef PROFILETYPES_H_ */ 60 | -------------------------------------------------------------------------------- /src/ProfileWorker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PriofileWorker.cpp 5 | 6 | Created on: 10 May 2012 7 | Author: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include "ProfileWorker.h" 29 | #include "Profile.h" 30 | 31 | /* 32 | ================================== 33 | ProfileWorker::ProfileWorker 34 | ================================== 35 | */ 36 | ProfileWorker::ProfileWorker(Profile* prof, vector xs, vector ys, int ps) : 37 | Worker(), profile(prof), profxs(xs), profys(ys), profps(ps) 38 | { 39 | } 40 | 41 | /* 42 | ================================== 43 | ProfileWorker::run 44 | ================================== 45 | */ 46 | void ProfileWorker::run() 47 | { 48 | // Improve this 49 | profile->loadprofile(profxs, profys, profps); 50 | sig_done(); 51 | } 52 | -------------------------------------------------------------------------------- /src/ProfileWorker.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PriofileWorker.h 5 | 6 | Created on: 10 May 2012 7 | Author: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef PROFILEWORKER_H_ 29 | #define PROFILEWORKER_H_ 30 | 31 | #include "Worker.h" 32 | 33 | class Profile; 34 | 35 | /* 36 | =============================================================================== 37 | 38 | ProfileWorker - a worker class for loading points into the profile. 39 | 40 | =============================================================================== 41 | */ 42 | class ProfileWorker: public Worker 43 | { 44 | public: 45 | ProfileWorker(Profile* prof, std::vector xs, std::vector ys, int ps); 46 | 47 | protected: 48 | void run(); 49 | 50 | Profile* profile; 51 | std::vector profxs; 52 | std::vector profys; 53 | int profps; 54 | }; 55 | 56 | #endif /* PROFILEWORKER_H_ */ 57 | -------------------------------------------------------------------------------- /src/SaveWorker.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | SaveWorker.h 5 | 6 | Created on: 10 May 2012 7 | Authors: Jan Holownia, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef SAVEWORKER_H_ 29 | #define SAVEWORKER_H_ 30 | 31 | #include "Worker.h" 32 | #include "geoprojectionconverter.hpp" 33 | #include "laslib/lasdefinitions.hpp" 34 | 35 | #define SAVEWORKER_CACHE_POINTS 1048576 36 | 37 | class FileSaver; 38 | class LASreader; 39 | class LASwriter; 40 | class LidarPoint; 41 | 42 | /* 43 | =============================================================================== 44 | 45 | SaveWorker - a worker class for saving files. 46 | 47 | =============================================================================== 48 | */ 49 | class SaveWorker: public Worker 50 | { 51 | public: 52 | SaveWorker(FileSaver* fs, std::string filename, std::string filein, int flightline, std::string parse_string, bool use_latlong, 53 | bool use_default_scalefactor, double scale_factor[3], Glib::Mutex* pointbucket_mutex); 54 | void stop(); 55 | 56 | Glib::Dispatcher sig_progress; // Signals that 1% of saving has completed 57 | Glib::Dispatcher sig_waveform; // Signals that there is full waveform 58 | Glib::Dispatcher sig_waveform_progress; // Signals 1% of waveform data copied 59 | 60 | protected: 61 | void run(); 62 | void save_points(int n, LidarPoint* points); 63 | void save_points_wf(int n, LidarPoint* points); 64 | void close(); 65 | void convert_projection(); 66 | 67 | Glib::Mutex* pointbucket_mutex; 68 | 69 | FileSaver* filesaver; 70 | std::string filename; 71 | std::string source_filename; 72 | int flightline_number; 73 | std::string parse_string; 74 | bool latlong_output; 75 | bool latlong_input; 76 | bool use_default_scalefactor; 77 | double scale_factor[3]; 78 | int number_of_points; 79 | 80 | LASreader* reader; 81 | LASwriter* writer; 82 | 83 | GeoProjectionConverter gpc; 84 | GeoProjectionConverter gpc_ll; 85 | LASquantizer* reproject_quantizer; 86 | LASquantizer* saved_quantizer; 87 | }; 88 | 89 | #endif /* SAVEWORKER_H_ */ 90 | -------------------------------------------------------------------------------- /src/SelectionBox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | SelectionBox.cpp 5 | 6 | Created on: December 2010 7 | Author: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include "SelectionBox.h" 29 | #include 30 | 31 | /* 32 | ================================== 33 | SelectionBox::SelectionBox 34 | ================================== 35 | */ 36 | SelectionBox::SelectionBox(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double thirdX, double thirdY, 37 | double thirdZ, double fourthX, double fourthY, double fourthZ) 38 | { 39 | points[0].move(firstX, firstY, firstZ); 40 | points[1].move(secondX, secondY, secondZ); 41 | points[2].move(thirdX, thirdY, thirdZ); 42 | points[3].move(fourthX, fourthY, fourthZ); 43 | } 44 | 45 | /* 46 | ================================== 47 | SelectionBox::SelectionBox 48 | ================================== 49 | */ 50 | SelectionBox::SelectionBox(Point first, Point second, Point third, Point fourth) 51 | { 52 | points[0] = first; 53 | points[1] = second; 54 | points[2] = third; 55 | points[3] = fourth; 56 | } 57 | 58 | /* 59 | ================================== 60 | SelectionBox::~SelectionBox 61 | ================================== 62 | */ 63 | SelectionBox::~SelectionBox() 64 | { 65 | } 66 | 67 | /* 68 | ================================== 69 | SelectionBox::move 70 | ================================== 71 | */ 72 | void SelectionBox::move(double moveX, double moveY, double moveZ) 73 | { 74 | for(int i = 0; i < NUMBER_OF_POINTS; i++) 75 | points[i].move(moveX, moveY, moveZ); 76 | } 77 | 78 | /* 79 | ================================== 80 | SelectionBox::translate 81 | ================================== 82 | */ 83 | void SelectionBox::translate(double transX, double transY, double transZ) 84 | { 85 | for(int i = 0; i < NUMBER_OF_POINTS; i++) 86 | points[i].translate(transX, transY, transZ); 87 | } 88 | 89 | /* 90 | ================================== 91 | SelectionBox::movePoint 92 | ================================== 93 | */ 94 | void SelectionBox::movePoint(int pointNumber, double moveX, double moveY, double moveZ) 95 | { 96 | points[pointNumber].move(moveX, moveY, moveZ); 97 | } 98 | 99 | /* 100 | ================================== 101 | SelectionBox::translatePoint 102 | ================================== 103 | */ 104 | void SelectionBox::translatePoint(int pointNumber, double transX, double transY, double transZ) 105 | { 106 | points[pointNumber].translate(transX, transY, transZ); 107 | } 108 | 109 | /* 110 | ================================== 111 | SelectionBox::getCorner 112 | ================================== 113 | */ 114 | Point SelectionBox::getCorner(int cornerNumber) 115 | { 116 | return points[cornerNumber]; 117 | } 118 | 119 | /* 120 | ================================== 121 | SelectionBox::getCorners 122 | ================================== 123 | */ 124 | Point* SelectionBox::getCorners() 125 | { 126 | return points; 127 | } 128 | 129 | /* 130 | ================================== 131 | SelectionBox::getXs 132 | ================================== 133 | */ 134 | std::vector SelectionBox::getXs() 135 | { 136 | std::vector returner(4); 137 | for(int i = 0; i < 4; i++) 138 | returner[i] = points[i].getX(); 139 | return returner; 140 | } 141 | 142 | /* 143 | ================================== 144 | SelectionBox::getYs 145 | ================================== 146 | */ 147 | std::vector SelectionBox::getYs() 148 | { 149 | std::vector returner(4); 150 | for(int i = 0; i < 4; i++) 151 | { 152 | returner[i] = points[i].getY(); 153 | } 154 | return returner; 155 | } 156 | 157 | /* 158 | ================================== 159 | SelectionBox::get_min_x 160 | ================================== 161 | */ 162 | double SelectionBox::get_min_x() 163 | { 164 | double x = points[0].getX(); 165 | for(int i = 1; i < 4; ++i) 166 | { 167 | if(points[i].getX() < x) 168 | x = points[i].getX(); 169 | } 170 | return x; 171 | } 172 | 173 | /* 174 | ================================== 175 | SelectionBox::get_max_x 176 | ================================== 177 | */ 178 | double SelectionBox::get_max_x() 179 | { 180 | double x = points[0].getX(); 181 | for(int i = 1; i < 4; ++i) 182 | { 183 | if(points[i].getX() > x) 184 | x = points[i].getX(); 185 | } 186 | return x; 187 | } 188 | 189 | /* 190 | ================================== 191 | SelectionBox::get_min_y 192 | ================================== 193 | */ 194 | double SelectionBox::get_min_y() 195 | { 196 | double y = points[0].getY(); 197 | for(int i = 1; i < 4; ++i) 198 | { 199 | if(points[i].getY() < y) 200 | y = points[i].getY(); 201 | } 202 | return y; 203 | } 204 | 205 | /* 206 | ================================== 207 | SelectionBox::get_max_y 208 | ================================== 209 | */ 210 | double SelectionBox::get_max_y() 211 | { 212 | double y = points[0].getY(); 213 | for(int i = 1; i < 4; ++i) 214 | { 215 | if(points[i].getY() > y) 216 | y = points[i].getY(); 217 | } 218 | return y; 219 | } 220 | -------------------------------------------------------------------------------- /src/SelectionBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | SelectionBox.h 5 | 6 | Created on: December 2010 7 | Author: Haraldur Tristan Gunnarsson 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef _SELECTIONBOX_H_ 29 | #define _SELECTIONBOX_H_ 30 | 31 | #include "Point.h" 32 | #include 33 | 34 | /* 35 | =============================================================================== 36 | 37 | SelectionBox - Class to hold info about a selection box. This will be a rectangle 38 | holding four Points - one for each corner. 39 | 40 | =============================================================================== 41 | */ 42 | class SelectionBox 43 | { 44 | 45 | public: 46 | SelectionBox() 47 | { 48 | } 49 | 50 | SelectionBox(double, double, double, double, double, double, double, double, double, double, double, double); 51 | 52 | SelectionBox(Point, Point, Point, Point); 53 | 54 | ~SelectionBox(); 55 | 56 | Point getCorner(int); 57 | Point* getCorners(); 58 | 59 | std::vector getXs(); 60 | std::vector getYs(); 61 | 62 | double get_min_x(); 63 | double get_max_x(); 64 | double get_min_y(); 65 | double get_max_y(); 66 | 67 | // Mutators for the whole SelectionBox 68 | void move(double, double, double); 69 | void translate(double, double, double); 70 | 71 | // Mutators for the individual Points. 72 | void movePoint(int, double, double, double); 73 | void translatePoint(int, double, double, double); 74 | 75 | // Rotate one day? 76 | 77 | private: 78 | static const int NUMBER_OF_POINTS = 4; 79 | Point points[4]; 80 | }; 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/Worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | Worker.h 5 | 6 | Created on: 24 Apr 2012 7 | Authors: Jan Holownia, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef WORKER_H_ 29 | #define WORKER_H_ 30 | 31 | #include 32 | 33 | /* 34 | =============================================================================== 35 | 36 | Worker - a generic worker class. 37 | 38 | =============================================================================== 39 | */ 40 | class Worker 41 | { 42 | public: 43 | Worker() : 44 | thread(0), stopped(false) 45 | { 46 | } 47 | 48 | virtual ~Worker() 49 | { 50 | { 51 | Glib::Mutex::Lock lock(mutex); 52 | stopped = true; 53 | } 54 | this->join(); 55 | } 56 | 57 | void start() 58 | { 59 | thread = Glib::Thread::create(sigc::mem_fun(*this, &Worker::run), true); 60 | } 61 | 62 | void join() 63 | { 64 | if(thread) 65 | thread->join(); 66 | thread = 0; 67 | } 68 | 69 | Glib::Dispatcher sig_done; 70 | 71 | protected: 72 | virtual void run() = 0; 73 | 74 | Glib::Thread* thread; 75 | Glib::Mutex mutex; 76 | bool stopped; 77 | }; 78 | 79 | #endif /* WORKER_H_ */ 80 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.in by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_INTTYPES_H 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_MEMORY_H 1 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_STDINT_H 1 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #define HAVE_STDLIB_H 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_STRINGS_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_STRING_H 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_SYS_STAT_H 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_SYS_TYPES_H 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_UNISTD_H 1 30 | 31 | /* Name of package */ 32 | /* #undef PACKAGE */ 33 | 34 | /* Define to the address where bug reports for this package should be sent. */ 35 | #define PACKAGE_BUGREPORT "anch@pml.ac.uk" 36 | 37 | /* Define to the full name of this package. */ 38 | #define PACKAGE_NAME "LiDAR Analysis GUI" 39 | 40 | /* Define to the full name and version of this package. */ 41 | #define PACKAGE_STRING "LiDAR Analysis GUI 1.0 " 42 | 43 | /* Define to the one symbol short name of this package. */ 44 | #define PACKAGE_TARNAME "lidar-analysis-gui" 45 | 46 | /* Define to the home page for this package. */ 47 | #define PACKAGE_URL "" 48 | 49 | /* Define to the version of this package. */ 50 | #define PACKAGE_VERSION "1.0 " 51 | 52 | /* Define to 1 if you have the ANSI C header files. */ 53 | #define STDC_HEADERS 1 54 | 55 | /* Version number of package */ 56 | /* #undef VERSION */ 57 | -------------------------------------------------------------------------------- /src/lag.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ================================== 3 | 4 | lag.cpp 5 | 6 | Written: November 2009 - July 2012 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2010 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | ================================== 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "Quadtree.h" 34 | #include "TwoDeeOverview.h" 35 | #include "Profile.h" 36 | #include "ui/TwoDeeOverviewWindow.h" 37 | #include "ui/ProfileWindow.h" 38 | #include "ui/FileOpener.h" 39 | #include "ui/AdvancedLoadDialog.h" 40 | 41 | #ifdef __WIN32 42 | #include 43 | #endif 44 | 45 | using namespace std; 46 | 47 | /* 48 | ================================== 49 | glade_exists 50 | 51 | Returns true if a file exists. 52 | ================================== 53 | */ 54 | bool glade_exists(string const& filename) 55 | { 56 | #ifndef __WIN32 57 | struct stat sb; 58 | 59 | if(stat(filename.c_str(), &sb) == 0) 60 | return true; 61 | else 62 | return false; 63 | #else 64 | return false; // fix me 65 | #endif 66 | } 67 | 68 | /* 69 | ================================== 70 | findgladepath 71 | 72 | Takes the path the executable was called with and uses it to find the 73 | .glade file needed to make the GUI. 74 | ================================== 75 | */ 76 | string findgladepath(char* programpath) 77 | { 78 | // For lag installed in /usr/local/bin, /usr/local/share/lag 79 | // EDIT: Now supporting similar windows layouts 80 | // i.e., C:\Program Files\PML\Lag\bin, now produces something 81 | // like C:\Program Files\PML\Lag\share\lag\lag.ui 82 | 83 | // Find the path of the executable 84 | char buff[1024]; 85 | ssize_t len; 86 | #ifdef __WIN32 87 | // windows only 88 | len = GetModuleFileName(NULL, buff, sizeof(buff)-1); 89 | #else 90 | // linux only 91 | len = readlink("/proc/self/exe", buff, sizeof(buff) - 1); 92 | #endif 93 | if(len > 0) // len = -1 for linux failure, 0 for windows failure 94 | { 95 | buff[len] = '\0'; 96 | } 97 | 98 | string gladepath(buff); 99 | #ifndef __WIN32 100 | gladepath.erase(gladepath.rfind("/") + 1, gladepath.size()); 101 | gladepath += "../share/lag/lag.ui"; 102 | #else 103 | gladepath.erase(gladepath.rfind("\\")+1, gladepath.size()); 104 | gladepath += "lag.ui"; 105 | #endif 106 | 107 | if(glade_exists(gladepath)) 108 | { 109 | return gladepath; 110 | } 111 | 112 | // For lag not installed: 113 | 114 | //The path of the executable. 115 | string mypath(programpath); 116 | 117 | #ifndef __WIN32 118 | mypath.erase(mypath.rfind("/") + 1, mypath.size()); 119 | #else 120 | mypath.erase(mypath.rfind("\\")+1, mypath.size()); 121 | #endif 122 | 123 | string gladename1(mypath); 124 | string gladename2(mypath); 125 | 126 | gladename1 += "../lag.ui"; 127 | gladename2 += "lag.ui"; 128 | 129 | if(glade_exists(gladename1)) 130 | { 131 | return gladename1; 132 | } else if(glade_exists(gladename2)) 133 | { 134 | return gladename2; 135 | } else 136 | { 137 | std::cerr << "No lag.ui glade file found" << std::endl << "Tried: " << std::endl << gladename1 << std::endl << gladename2; 138 | exit(1); 139 | } 140 | } 141 | 142 | /* 143 | ================================== 144 | 145 | main 146 | 147 | ================================== 148 | */ 149 | int main(int argc, char** argv) 150 | { 151 | //This allows the creation and running of threads. 152 | Glib::thread_init(); 153 | 154 | // This is required for GTK to work. It must be the first GTK object 155 | // created and may not be global. 156 | Gtk::Main gtkmain(argc, argv); 157 | 158 | //This will extract widgets from the glade file when directed. 159 | const Glib::RefPtr builder = Gtk::Builder::create(); 160 | 161 | try 162 | { 163 | builder->add_from_file(findgladepath(argv[0])); 164 | } catch(const Glib::FileError& ex) 165 | { 166 | std::cerr << "FileError: " << ex.what() << std::endl; 167 | return 1; 168 | } catch(const Glib::MarkupError& ex) 169 | { 170 | std::cerr << "MarkupError: " << ex.what() << std::endl; 171 | return 1; 172 | } catch(const Gtk::BuilderError& ex) 173 | { 174 | std::cerr << "BuilderError: " << ex.what() << std::endl; 175 | return 1; 176 | } 177 | 178 | Gtk::GL::init(argc, argv); 179 | Glib::RefPtr < Gdk::GL::Config > glconfig; 180 | 181 | glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH | Gdk::GL::MODE_DOUBLE); 182 | if(glconfig == 0) 183 | { 184 | glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH); 185 | if(glconfig == 0) 186 | { 187 | cout << "Cannot intialise OpenGL. Exiting." << endl; 188 | std::exit(1); 189 | } 190 | } 191 | 192 | //How many points in each bucket, maximum. 193 | int bucketlimit = 65536; 194 | 195 | // Label displaying the distance along the ruler, in all dimensions etc. 196 | // for the overview. Also other text output about the data and fences, 197 | // profiles etc. is put here. 198 | Gtk::Label *rulerlabelover = NULL; 199 | builder->get_widget("rulerlabelover", rulerlabelover); 200 | 201 | //The 2d overview. 202 | TwoDeeOverview *tdo = new TwoDeeOverview(glconfig, bucketlimit, rulerlabelover); 203 | 204 | // Label displaying the distance along the ruler, in all dimensions 205 | // etc. for the profile. 206 | Gtk::Label *rulerlabel = NULL; 207 | builder->get_widget("rulerlabel", rulerlabel); 208 | 209 | //The profile. 210 | Profile *prof = new Profile(glconfig, bucketlimit, rulerlabel); 211 | 212 | //This contains the widgets of the advanced options window. 213 | AdvancedOptionsWindow *aow = new AdvancedOptionsWindow(tdo, prof, builder); 214 | 215 | //This contains the widgets of the file saver window. 216 | FileSaver *fs = new FileSaver(tdo, prof, builder); 217 | 218 | // Contains the overview. It is used to simulate the 2d overview getting 219 | // focus without causing it to be redrawn every time. 220 | Gtk::EventBox *eventboxtdo = NULL; 221 | builder->get_widget("eventboxtdo", eventboxtdo); 222 | 223 | // Contains the profile. It is used to simulate the profile getting focus 224 | // without causing it to be redrawn every time. 225 | Gtk::EventBox *eventboxprof = NULL; 226 | builder->get_widget("eventboxprof", eventboxprof); 227 | Gtk::Window *overviewwindow = NULL; 228 | builder->get_widget("overviewwindow", overviewwindow); 229 | Gtk::Window *profilewindow = NULL; 230 | builder->get_widget("profilewindow", profilewindow); 231 | 232 | //This contains the widgets of the profile window. 233 | ProfileWindow *profwin = new ProfileWindow(prof, tdo, profilewindow, overviewwindow, eventboxprof, builder, aow); 234 | 235 | //This contains the widgets of the 2D overview window. 236 | TwoDeeOverviewWindow *tdow = new TwoDeeOverviewWindow(tdo, aow, fs, overviewwindow, profilewindow, builder, eventboxtdo, profwin); 237 | 238 | //This contains the widgets of advanced loading options window 239 | AdvancedLoadDialog* ald = new AdvancedLoadDialog(builder); 240 | 241 | //This contains the widgets of the file opener window. 242 | FileOpener *fo = new FileOpener(tdo, prof, builder, aow, fs, bucketlimit, eventboxtdo, eventboxprof, tdow, ald); 243 | 244 | gdk_threads_enter(); 245 | 246 | gtkmain.run(*overviewwindow); 247 | 248 | gdk_threads_leave(); 249 | 250 | tdo->stopDrawingThread(); 251 | prof->stopDrawingThread(); 252 | 253 | delete tdow; 254 | delete profwin; 255 | delete fo; 256 | delete fs; 257 | delete aow; 258 | delete eventboxtdo; 259 | delete eventboxprof; 260 | delete rulerlabelover; 261 | delete overviewwindow; 262 | delete profilewindow; 263 | delete ald; 264 | if(tdo != NULL) 265 | delete tdo; 266 | if(prof != NULL) 267 | delete prof; 268 | 269 | return 0; 270 | } 271 | -------------------------------------------------------------------------------- /src/ui/AdvancedLoadDialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | AdvancedLoadDialog.h 5 | 6 | Created on: 25 Jun 2012 7 | Author: Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef ADVANCEDLOADDIALOG_H_ 29 | #define ADVANCEDLOADDIALOG_H_ 30 | 31 | #include 32 | #include 33 | #include "../PointFilter.h" 34 | 35 | /* 36 | =============================================================================== 37 | 38 | AdvancedLoadDialog - represents a dialog with advanced load options (filters 39 | and quadtree options). 40 | 41 | =============================================================================== 42 | */ 43 | class AdvancedLoadDialog 44 | { 45 | public: 46 | AdvancedLoadDialog(const Glib::RefPtr&); 47 | ~AdvancedLoadDialog(); 48 | 49 | PointFilter get_point_filter() 50 | { 51 | return this->point_filter; 52 | } 53 | 54 | private: 55 | PointFilter point_filter; 56 | std::string arg; 57 | 58 | Gtk::Dialog* advanced_load_dialog; 59 | 60 | Gtk::CheckButton* inside_rectangle_cb; 61 | Gtk::Entry* inside_rectangle_min_x; 62 | Gtk::Entry* inside_rectangle_min_y; 63 | Gtk::Entry* inside_rectangle_max_x; 64 | Gtk::Entry* inside_rectangle_max_y; 65 | 66 | Gtk::CheckButton* inside_box_cb; 67 | Gtk::Entry* inside_box_min_x; 68 | Gtk::Entry* inside_box_min_y; 69 | Gtk::Entry* inside_box_min_z; 70 | Gtk::Entry* inside_box_max_x; 71 | Gtk::Entry* inside_box_max_y; 72 | Gtk::Entry* inside_box_max_z; 73 | 74 | Gtk::CheckButton* inside_circle_cb; 75 | Gtk::Entry* inside_circle_x; 76 | Gtk::Entry* inside_circle_y; 77 | Gtk::Entry* inside_circle_radius; 78 | 79 | Gtk::CheckButton* clip_x_cb; 80 | Gtk::Entry* clip_x_above; 81 | Gtk::Entry* clip_x_below; 82 | 83 | Gtk::CheckButton* clip_y_cb; 84 | Gtk::Entry* clip_y_above; 85 | Gtk::Entry* clip_y_below; 86 | 87 | Gtk::CheckButton* clip_z_cb; 88 | Gtk::Entry* clip_z_above; 89 | Gtk::Entry* clip_z_below; 90 | 91 | Gtk::CheckButton* return_cb; 92 | Gtk::Entry* return_entry; 93 | Gtk::ToggleButton* return_drop_btn; 94 | 95 | Gtk::CheckButton* intensity_cb; 96 | Gtk::Entry* intensity_from; 97 | Gtk::Entry* intensity_to; 98 | Gtk::ToggleButton* intensity_drop_btn; 99 | 100 | Gtk::CheckButton* classification_cb; 101 | Gtk::Entry* classification_entry; 102 | Gtk::ToggleButton* classification_drop_btn; 103 | 104 | Gtk::CheckButton* gps_time_cb; 105 | Gtk::Entry* gps_time_from; 106 | Gtk::Entry* gps_time_to; 107 | Gtk::ToggleButton* gps_time_drop_btn; 108 | 109 | Gtk::Button* ok_btn; 110 | 111 | void load_xml(const Glib::RefPtr&); 112 | void connect_signals(); 113 | void on_inside_rectangle_cb_toggled(); 114 | void on_inside_box_cb_toggled(); 115 | void on_inside_circle_cb_toggled(); 116 | void on_clip_x_cb_toggled(); 117 | void on_clip_y_cb_toggled(); 118 | void on_clip_z_cb_toggled(); 119 | void on_return_cb_toggled(); 120 | void on_intensity_cb_toggled(); 121 | void on_classification_cb_toggled(); 122 | void on_gps_time_cb_toggled(); 123 | void on_return_drop_btn_toggled(); 124 | void on_intensity_drop_btn_toggled(); 125 | void on_classification_drop_btn_toggled(); 126 | void on_gps_time_drop_btn_toggled(); 127 | void on_ok_btn_clicked(); 128 | }; 129 | #endif /* ADVANCEDLOADDIALOG_H_ */ 130 | 131 | -------------------------------------------------------------------------------- /src/ui/AdvancedOptionsWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | AdvancedOptionsWindow.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef ADVANCEDOPTIONSWINDOW_H 29 | #define ADVANCEDOPTIONSWINDOW_H 30 | 31 | #include 32 | #include 33 | #include "../TwoDeeOverview.h" 34 | #include "../Profile.h" 35 | 36 | /* 37 | =============================================================================== 38 | 39 | AdvancedOptionsWindow - represents a dialog with advanced options. 40 | 41 | =============================================================================== 42 | */ 43 | class AdvancedOptionsWindow 44 | { 45 | public: 46 | AdvancedOptionsWindow(TwoDeeOverview*, Profile*, const Glib::RefPtr&); 47 | 48 | ~AdvancedOptionsWindow(); 49 | 50 | void show() 51 | { 52 | advancedoptionsdialog->present(); 53 | } 54 | 55 | void resetcolouringandshading() 56 | { 57 | on_drawingresetbutton_clicked(); 58 | } 59 | 60 | bool getfractionalshift() 61 | { 62 | return fractionalshiftcheck->get_active(); 63 | } 64 | 65 | double getmovespeed() 66 | { 67 | return movespeedselect->get_value(); 68 | } 69 | 70 | void setmaindetailrange(double min, double max) 71 | { 72 | maindetailselect->set_range(min, max); 73 | } 74 | 75 | private: 76 | TwoDeeOverview *tdo; 77 | Profile *prof; 78 | 79 | //Advanced viewing options: 80 | 81 | //Dialog window for advanced options. 82 | Gtk::Dialog *advancedoptionsdialog; 83 | Gtk::SpinButton *movespeedselect; 84 | Gtk::CheckButton *fractionalshiftcheck; 85 | 86 | //False elevation: 87 | 88 | //Elevate classifications with the respective codes: 89 | Gtk::CheckButton *classcheckbutton0; 90 | Gtk::CheckButton *classcheckbutton2; 91 | Gtk::CheckButton *classcheckbutton3; 92 | Gtk::CheckButton *classcheckbutton4; 93 | Gtk::CheckButton *classcheckbutton5; 94 | Gtk::CheckButton *classcheckbutton6; 95 | Gtk::CheckButton *classcheckbutton7; 96 | Gtk::CheckButton *classcheckbutton8; 97 | Gtk::CheckButton *classcheckbutton9; 98 | Gtk::CheckButton *classcheckbutton12; 99 | 100 | //"Anything else" classification elevator. 101 | Gtk::CheckButton *classcheckbuttonA; 102 | Gtk::CheckButton *profdisplaynoise; 103 | Gtk::CheckButton *tdodisplaynoise; 104 | 105 | //Colouring and shading: 106 | 107 | //Determines the maximum height for colouring and shading. 108 | Gtk::SpinButton *heightmaxselect; 109 | 110 | //Determines the minimum height for colouring and shading. 111 | Gtk::SpinButton *heightminselect; 112 | 113 | // Used for "stepping through" the height range (absolute minimum to 114 | // absolute maximum) with a page size defined by the difference between 115 | // heightmaxselect and heightminselect. 116 | Gtk::HScrollbar *heightscrollbar; 117 | 118 | // This increases all brightness levels by a fixed amount, if based on 119 | // height. In analogy to heightfloorselect, this raises both the floor 120 | // and the ceiling. 121 | Gtk::SpinButton *heightoffsetselect; 122 | 123 | // This increases brightness levels by a varying amount such that the 124 | // lowest level will be increased by the value and higher levels by by 125 | // a declining value until the level of 1.0, which will not increase at 126 | // all. In the analogy, the floor is raised but not the ceiling, and 127 | // the "space" between them is "squashed". 128 | Gtk::SpinButton *heightfloorselect; 129 | 130 | //Equivalent as for height: 131 | Gtk::SpinButton *intensitymaxselect; 132 | Gtk::SpinButton *intensityminselect; 133 | Gtk::HScrollbar *intensityscrollbar; 134 | Gtk::SpinButton *intensityoffsetselect; 135 | Gtk::SpinButton *intensityfloorselect; 136 | 137 | //Resets all other colouring and shading widgets to initial values. 138 | Gtk::Button *drawingresetbutton; 139 | 140 | // Detail level (i.e. how many points to skip for each point shown, worked 141 | // out INDIRECTLY; see the profile and overview classes for details): 142 | //Determines how many points are skipped displaying the main overview image. 143 | Gtk::SpinButton *maindetailselect; 144 | 145 | //Determines how many points are skipped displaying the main profile image. 146 | Gtk::SpinButton *maindetailselectprof; 147 | 148 | //Determines how many points are skipped displaying the profile preview. 149 | Gtk::SpinButton *previewdetailselectprof; 150 | 151 | Gtk::CheckButton *fullrefreshonpanning; 152 | Gtk::ColorButton *backgroundcolorbutton; 153 | 154 | //Signals: 155 | 156 | // These connections are for controlling the interaction of the height and 157 | // intensity colouring and shading scrollbars and spinbuttons, particularly 158 | // so that they do not interfere with each other at the wrong moment. 159 | sigc::connection heightminconn; 160 | sigc::connection heightmaxconn; 161 | sigc::connection intensityminconn; 162 | sigc::connection intensitymaxconn; 163 | 164 | void load_xml(const Glib::RefPtr&); 165 | void connect_signals(); 166 | 167 | void on_fullrefresh_toggled(); 168 | void on_backgroundcolor_changed(); 169 | void on_advancedoptionsdialog_response(int response_id); 170 | 171 | void on_classcheckbutton0_toggled(); 172 | void on_classcheckbutton2_toggled(); 173 | void on_classcheckbutton3_toggled(); 174 | void on_classcheckbutton4_toggled(); 175 | void on_classcheckbutton5_toggled(); 176 | void on_classcheckbutton6_toggled(); 177 | void on_classcheckbutton7_toggled(); 178 | void on_classcheckbutton8_toggled(); 179 | void on_classcheckbutton9_toggled(); 180 | void on_classcheckbutton12_toggled(); 181 | void on_classcheckbuttonA_toggled(); 182 | 183 | void on_profile_noise_toggle(); 184 | void on_tdo_noise_toggle(); 185 | void changecoloursandshades(); 186 | 187 | void on_heightmaxselect_changed(); 188 | void on_heightminselect_changed(); 189 | bool on_heightscrollbar_scrolled(Gtk::ScrollType scroll, double new_value); 190 | void on_heightoffsetselect_changed(); 191 | void on_heightfloorselect_changed(); 192 | void on_intensitymaxselect_changed(); 193 | void on_intensityminselect_changed(); 194 | bool on_intensityscrollbar_scrolled(Gtk::ScrollType scroll, double new_value); 195 | void on_intensityoffsetselect_changed(); 196 | void on_intensityfloorselect_changed(); 197 | 198 | // This resets the advanced colouring and shading options to the values 199 | // indicated by the drawing objects. 200 | void on_drawingresetbutton_clicked(); 201 | 202 | // This indirectly determines how many points are skipped when viewing the 203 | // main overview image. I.e. this affects it as well as the number of 204 | // visible buckets. 205 | void on_maindetailselected(); 206 | 207 | // Does the same as on_maindetailselected, except for the profile. 208 | void on_maindetailselectedprof(); 209 | 210 | // Does the same as on_maindetailselectedprof, except for the preview of 211 | // the profile. 212 | void on_previewdetailselectedprof(); 213 | 214 | // When toggled, the profile box is shown on the 2d overview regardless of 215 | // whether profiling mode is active. 216 | void on_raiselinecheck(); 217 | }; 218 | 219 | #endif 220 | -------------------------------------------------------------------------------- /src/ui/FileOpener.h: -------------------------------------------------------------------------------- 1 | /* 2 | ================================== 3 | 4 | FileOpener.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | ================================== 26 | */ 27 | 28 | #ifndef _FILEOPENER_H_ 29 | #define _FILEOPENER_H_ 30 | 31 | #include 32 | #include 33 | //#include "FileSaver.h" 34 | #include "AdvancedOptionsWindow.h" 35 | #include "TwoDeeOverviewWindow.h" 36 | #include "AdvancedLoadDialog.h" 37 | #include "../TwoDeeOverview.h" 38 | #include "../Profile.h" 39 | #include "../LoadWorker.h" 40 | 41 | /* 42 | =============================================================================== 43 | 44 | FileOpener - a file chooser dialog for loading files. 45 | 46 | =============================================================================== 47 | */ 48 | class FileOpener 49 | { 50 | public: 51 | FileOpener(TwoDeeOverview*, Profile*, const Glib::RefPtr&, AdvancedOptionsWindow*, FileSaver*, int, Gtk::EventBox*, Gtk::EventBox*, 52 | TwoDeeOverviewWindow*, AdvancedLoadDialog*); 53 | 54 | ~FileOpener(); 55 | 56 | void show() 57 | { 58 | filechooserdialog->present(); 59 | } 60 | 61 | void set_lidardata(Quadtree* lidardata) 62 | { 63 | Glib::Mutex::Lock lock(mutex); 64 | this->lidardata = lidardata; 65 | } 66 | 67 | Quadtree* get_lidardata() 68 | { 69 | Glib::Mutex::Lock lock(mutex); 70 | return this->lidardata; 71 | } 72 | 73 | void delete_lidardata() 74 | { 75 | Glib::Mutex::Lock lock(mutex); 76 | if(lidardata != NULL) 77 | delete lidardata; 78 | lidardata = NULL; 79 | } 80 | 81 | void set_newQuadtree(bool newqt) 82 | { 83 | Glib::Mutex::Lock lock(mutex); 84 | this->newQuadtree = newqt; 85 | } 86 | 87 | void set_loadedanyfiles(bool loaded) 88 | { 89 | Glib::Mutex::Lock lock(mutex); 90 | this->loadedanyfiles = loaded; 91 | } 92 | 93 | bool get_loadedanyfiles() 94 | { 95 | Glib::Mutex::Lock lock(mutex); 96 | return this->loadedanyfiles; 97 | } 98 | 99 | void set_thread_message(std::string message) 100 | { 101 | // Glib::Mutex::Lock lock (mutex); 102 | this->thread_message = message; 103 | } 104 | 105 | void set_minZ(double z) 106 | { 107 | Glib::Mutex::Lock lock(mutex); 108 | this->minZ = z; 109 | } 110 | 111 | double get_minZ() 112 | { 113 | Glib::Mutex::Lock lock(mutex); 114 | return this->minZ; 115 | } 116 | 117 | void set_maxZ(double z) 118 | { 119 | Glib::Mutex::Lock lock(mutex); 120 | this->maxZ = z; 121 | } 122 | 123 | double get_maxZ() 124 | { 125 | Glib::Mutex::Lock lock(mutex); 126 | return this->maxZ; 127 | } 128 | 129 | void set_utm_zone(std::string zone) 130 | { 131 | Glib::Mutex::Lock lock(mutex); 132 | this->utm_zone = zone; 133 | } 134 | 135 | double minZ, maxZ; 136 | std::string utm_zone; 137 | 138 | private: 139 | Quadtree *lidardata; 140 | int numlines; 141 | TwoDeeOverview *tdo; 142 | Profile* prof; 143 | TwoDeeOverviewWindow *tdow; 144 | AdvancedOptionsWindow *aow; 145 | FileSaver *fs; 146 | AdvancedLoadDialog* ald; 147 | 148 | //For opening files. 149 | Gtk::FileChooserDialog *filechooserdialog; 150 | 151 | //How many points to skip while loading one. 152 | Gtk::SpinButton *pointskipselect; 153 | 154 | // Check button determining whether the (overview) fence is used for 155 | // loading flightlines. 156 | Gtk::CheckButton *fenceusecheck; 157 | 158 | //The type code for opening ASCII files. 159 | Gtk::Entry *asciicodeentry; 160 | 161 | // Scale factor entries and check box 162 | Gtk::Entry* scaleFactorEntryX; 163 | Gtk::Entry* scaleFactorEntryY; 164 | Gtk::Entry* scaleFactorEntryZ; 165 | Gtk::CheckButton* btnUseDefault; 166 | 167 | //The maximumum number of points to hold in cache. 168 | Gtk::SpinButton *cachesizeselect; 169 | 170 | //This displays the cache size in terms of gigabytes, approximately. 171 | Gtk::Label *cachesizeGBlabel; 172 | 173 | //This displays the errors and so on that occur in loading. 174 | Gtk::Label *loadoutputlabel; 175 | 176 | //Contains the overview. 177 | Gtk::EventBox *eventboxtdo; 178 | 179 | //Contains the profile. 180 | Gtk::EventBox *eventboxprof; 181 | Gtk::SpinButton *resbaseselect; 182 | Gtk::SpinButton *resdepthselect; 183 | 184 | Gtk::MenuItem* openfilemenuitem; 185 | Gtk::ToolButton* openbutton; 186 | 187 | //Stringstream getting error messages from the quadtree. 188 | ostringstream *loaderrorstream; 189 | 190 | Gtk::FileChooserButton* cache_folder_select; 191 | 192 | //How many points to hold in cache. 1 GB ~= 25000000 points. 193 | int cachelimit; 194 | 195 | //How many points in each bucket, maximum. 196 | int bucketlimit; 197 | 198 | // Advanced loading options 199 | Gtk::Dialog* loadadvanceddialog; 200 | Gtk::Button* loadadvancedbutton; 201 | Gtk::Button* loadadvancedcancel; 202 | 203 | // Threading 204 | LoadWorker* loadworker; 205 | Glib::Mutex mutex; 206 | 207 | // Loading dialog 208 | Gtk::Dialog* loaddialog; 209 | Gtk::Label* filelabel; 210 | Gtk::ProgressBar* fileprogressbar; 211 | Gtk::Label* totallabel; 212 | Gtk::ProgressBar* totalprogressbar; 213 | Gtk::Button* loadcancelbutton; 214 | int num_files_loading; 215 | 216 | // Members accessed from other thread (need thread-safe get/set methods) 217 | bool newQuadtree; 218 | std::string thread_message; 219 | 220 | //Whether or not any files have already been loaded in this session. 221 | bool loadedanyfiles; 222 | 223 | // Whether to treat the current file in LoadWorker as a headerless (ascii) 224 | // file, or to take on_progress as an indication of 1% of progress 225 | bool ascii_progress; 226 | 227 | void load_xml(const Glib::RefPtr&); 228 | void connect_signals(); 229 | void on_usedefault_changed(); 230 | void on_filechooserdialogresponse(int response_id); 231 | void on_cachesize_changed(); 232 | void on_resolutionbase_changed(); 233 | 234 | //When selected from the menu, the file chooser opens. 235 | void on_openfilemenuactivated(); 236 | 237 | //Clean up on quit. 238 | int on_quit(); 239 | 240 | // Methods used called by another thread, through signals 241 | void show_thread_message(); 242 | void add_line(); 243 | void files_loaded(); 244 | void load_failed(); 245 | void on_progress(); 246 | void on_ascii(); 247 | void on_loadcancelbutton_clicked(); 248 | 249 | // Advanced dialog 250 | void on_loadadvancedbutton_clicked(); 251 | void on_loadadvancedcancel_clicked(); 252 | }; 253 | 254 | #endif 255 | -------------------------------------------------------------------------------- /src/ui/FileSaver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FileSaver.cpp 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia, Berin Smaldon 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2010 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #include "FileSaver.h" 29 | 30 | /* 31 | ================================== 32 | FileSaver::FileSaver 33 | ================================== 34 | */ 35 | FileSaver::FileSaver(TwoDeeOverview *tdo, Profile *prof, const Glib::RefPtr& builder) : 36 | lidardata(NULL), tdo(tdo), prof(prof), saveworker(NULL) 37 | 38 | { 39 | load_xml(builder); 40 | connect_signals(); 41 | utmselect->set_active(true); 42 | } 43 | 44 | /* 45 | ================================== 46 | FileSaver::~FileSaver 47 | ================================== 48 | */ 49 | FileSaver::~FileSaver() 50 | { 51 | delete flightlinelistlabel; 52 | delete flightlinesaveselect; 53 | delete parsestringentry; 54 | delete utmselect; 55 | delete latlongselect; 56 | delete scaleFactorEntryX; 57 | delete scaleFactorEntryY; 58 | delete scaleFactorEntryZ; 59 | delete btnUseDefault; 60 | delete savedialog; 61 | delete saveprogressbar; 62 | delete savecancelbutton; 63 | delete waveformdialog; 64 | delete waveformprogressbar; 65 | delete waveformcancelbutton; 66 | delete filesaverdialog; 67 | } 68 | 69 | /* 70 | ================================== 71 | FileSaver::load_xml 72 | ================================== 73 | */ 74 | void FileSaver::load_xml(const Glib::RefPtr& builder) 75 | { 76 | builder->get_widget("filesaverdialog", filesaverdialog); 77 | builder->get_widget("flightlinelistlabel", flightlinelistlabel); 78 | builder->get_widget("flightlinesaveselect", flightlinesaveselect); 79 | builder->get_widget("parsestringentry", parsestringentry); 80 | builder->get_widget("scaleFactorEntryX1", scaleFactorEntryX); 81 | builder->get_widget("scaleFactorEntryY1", scaleFactorEntryY); 82 | builder->get_widget("scaleFactorEntryZ1", scaleFactorEntryZ); 83 | builder->get_widget("btnUseDefault1", btnUseDefault); 84 | builder->get_widget("utmselect", utmselect); 85 | builder->get_widget("latlongselect", latlongselect); 86 | builder->get_widget("savedialog", savedialog); 87 | builder->get_widget("saveprogressbar", saveprogressbar); 88 | builder->get_widget("savecancelbutton", savecancelbutton); 89 | builder->get_widget("waveformdialog", waveformdialog); 90 | builder->get_widget("waveformprogressbar", waveformprogressbar); 91 | builder->get_widget("waveformcancelbutton", waveformcancelbutton); 92 | } 93 | 94 | /* 95 | ================================== 96 | FileSaver::connect_signals 97 | ================================== 98 | */ 99 | void FileSaver::connect_signals() 100 | { 101 | filesaverdialog->signal_response().connect(sigc::mem_fun(*this, &FileSaver::on_filesaverdialogresponse)); 102 | btnUseDefault->signal_toggled().connect(sigc::mem_fun(*this, &FileSaver::on_usedefault_changed)); 103 | //flightlinesaveselect->signal_value_changed().connect(sigc::mem_fun(*this,&FileSaver::on_flightlinesaveselected)); 104 | savecancelbutton->signal_clicked().connect(sigc::mem_fun(*this, &FileSaver::on_savecancelbutton_clicked)); 105 | waveformcancelbutton->signal_clicked().connect(sigc::mem_fun(*this, &FileSaver::on_savecancelbutton_clicked)); 106 | } 107 | 108 | /* 109 | ================================== 110 | FileSaver::on_usedefault_changed 111 | 112 | Whether library deafult scale factor values should be used. 113 | ================================== 114 | */ 115 | void FileSaver::on_usedefault_changed() 116 | { 117 | bool temp = !(btnUseDefault->get_active()); 118 | 119 | scaleFactorEntryX->set_sensitive(temp); 120 | scaleFactorEntryY->set_sensitive(temp); 121 | scaleFactorEntryZ->set_sensitive(temp); 122 | } 123 | 124 | /* 125 | ================================== 126 | FileSaver::on_filesaverdialogresponse 127 | 128 | If Save button has been pressed creates a SaveWorker which 129 | saves selected flightline. 130 | ================================== 131 | */ 132 | void FileSaver::on_filesaverdialogresponse(int response_id) 133 | { 134 | if(response_id == Gtk::RESPONSE_CLOSE) 135 | { 136 | //filesaverdialog->set_filename(""); 137 | filesaverdialog->hide_all(); 138 | } else if(response_id == 1) 139 | { 140 | if(lidardata == NULL) 141 | return; 142 | 143 | if(saveworker != NULL) 144 | return; 145 | 146 | double scale_factor[3]; 147 | if(!btnUseDefault->get_active()) 148 | { 149 | const char* temp; 150 | temp = scaleFactorEntryX->get_text().c_str(); 151 | scale_factor[0] = atof(temp); 152 | temp = scaleFactorEntryY->get_text().c_str(); 153 | scale_factor[1] = atof(temp); 154 | temp = scaleFactorEntryZ->get_text().c_str(); 155 | scale_factor[2] = atof(temp); 156 | } else 157 | { 158 | scale_factor[0] = scale_factor[1] = scale_factor[2] = 0; 159 | } 160 | 161 | // tdo and prof should have the same pointbucket mutex 162 | Glib::Mutex* pbkt_mutex = tdo->getPointBucketMutex(); 163 | 164 | saveworker = new SaveWorker(this, filesaverdialog->get_filename(), lidardata->getFileName(flightlinesaveselect->get_value_as_int()), 165 | flightlinesaveselect->get_value_as_int(), parsestringentry->get_text(), latlongselect->get_active(), 166 | btnUseDefault->get_active(), scale_factor, pbkt_mutex); 167 | saveworker->start(); 168 | saveworker->sig_done.connect(sigc::mem_fun(*this, &FileSaver::files_saved)); 169 | saveworker->sig_progress.connect(sigc::mem_fun(*this, &FileSaver::on_progress)); 170 | saveworker->sig_waveform.connect(sigc::mem_fun(*this, &FileSaver::waveform_started)); 171 | saveworker->sig_waveform_progress.connect(sigc::mem_fun(*this, &FileSaver::on_waveform_progress)); 172 | 173 | // Show saving dialog 174 | savedialog->show_all(); 175 | saveprogressbar->set_fraction(0); 176 | 177 | // Change cursor to busy 178 | GdkDisplay* display; 179 | GdkCursor* cursor; 180 | GdkWindow* window; 181 | 182 | cursor = gdk_cursor_new(GDK_WATCH); 183 | display = gdk_display_get_default(); 184 | window = (GdkWindow*) filesaverdialog->get_window()->gobj(); 185 | 186 | gdk_window_set_cursor(window, cursor); 187 | gdk_display_sync(display); 188 | gdk_cursor_unref(cursor); 189 | } 190 | } 191 | 192 | /* 193 | ================================== 194 | FileSaver::on_progress 195 | 196 | Moves saving progress bar by 1%. 197 | ================================== 198 | */ 199 | void FileSaver::on_progress() 200 | { 201 | saveprogressbar->set_fraction((saveprogressbar->get_fraction() + 0.01) > 1 ? 1 : (saveprogressbar->get_fraction() + 0.01)); 202 | } 203 | 204 | /* 205 | ================================== 206 | FileSaver::waveform_started 207 | 208 | Displays a dialog showing progress for copying 209 | full waveform data. 210 | ================================== 211 | */ 212 | void FileSaver::waveform_started() 213 | { 214 | waveformdialog->show_all(); 215 | waveformprogressbar->set_fraction(0); 216 | } 217 | 218 | /* 219 | ================================== 220 | FileSaver::on_waveform_progress 221 | 222 | Moves waveform progress bar by 1%. 223 | ================================== 224 | */ 225 | void FileSaver::on_waveform_progress() 226 | { 227 | waveformprogressbar->set_fraction((waveformprogressbar->get_fraction() + 0.01) > 1 ? 1 : (waveformprogressbar->get_fraction() + 0.01)); 228 | } 229 | 230 | /* 231 | ================================== 232 | FileSaver::files_saved 233 | 234 | Called once the files has been saved. 235 | ================================== 236 | */ 237 | void FileSaver::files_saved() 238 | { 239 | delete saveworker; 240 | saveworker = NULL; 241 | 242 | savedialog->hide_all(); 243 | 244 | if(waveformdialog->get_realized()) 245 | waveformdialog->hide_all(); 246 | 247 | // Set cursor back to normal 248 | GdkDisplay* display; 249 | GdkCursor* cursor; 250 | GdkWindow* window; 251 | 252 | cursor = gdk_cursor_new(GDK_LEFT_PTR); 253 | display = gdk_display_get_default(); 254 | window = (GdkWindow*) filesaverdialog->get_window()->gobj(); 255 | 256 | gdk_window_set_cursor(window, cursor); 257 | gdk_display_sync(display); 258 | gdk_cursor_unref(cursor); 259 | } 260 | 261 | /* 262 | ================================== 263 | FileSaver::on_savecancelbutton_clicked 264 | 265 | Stops saving. 266 | ================================== 267 | */ 268 | void FileSaver::on_savecancelbutton_clicked() 269 | { 270 | if(saveworker != NULL) 271 | saveworker->stop(); 272 | } 273 | 274 | /* 275 | ================================== 276 | FileSaver::on_flightlinesaveselected 277 | 278 | Not used? 279 | ================================== 280 | */ 281 | void FileSaver::on_flightlinesaveselected() 282 | { 283 | if(lidardata != NULL) 284 | filesaverdialog->set_filename(lidardata->getFileName(flightlinesaveselect->get_value_as_int())); 285 | } 286 | 287 | -------------------------------------------------------------------------------- /src/ui/FileSaver.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FileSaver.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef FILESAVER_H 29 | #define FILESAVER_H 30 | 31 | #include 32 | #include 33 | #include "../TwoDeeOverview.h" 34 | #include "../Profile.h" 35 | #include "../SaveWorker.h" 36 | 37 | /* 38 | =============================================================================== 39 | 40 | FileSaver - a file chooser dialog for saving files. 41 | 42 | =============================================================================== 43 | */ 44 | class FileSaver 45 | { 46 | public: 47 | FileSaver(TwoDeeOverview*, Profile*, const Glib::RefPtr&); 48 | 49 | ~FileSaver(); 50 | 51 | void show() 52 | { 53 | filesaverdialog->present(); 54 | } 55 | 56 | void setlinerange(int first, int second) 57 | { 58 | flightlinesaveselect->set_range(first, second); 59 | } 60 | 61 | void setlabeltext(string text) 62 | { 63 | flightlinelistlabel->set_text(text); 64 | } 65 | 66 | void on_flightlinesaveselected(); 67 | 68 | void setlidardata(Quadtree *lidardata) 69 | { 70 | this->lidardata = lidardata; 71 | } 72 | 73 | // FIXME (make private and add thread safe get/set methods) 74 | Quadtree *lidardata; 75 | 76 | private: 77 | 78 | TwoDeeOverview *tdo; 79 | Profile *prof; 80 | 81 | //For opening files. 82 | Gtk::FileChooserDialog *filesaverdialog; 83 | 84 | Gtk::Label *flightlinelistlabel; 85 | Gtk::SpinButton *flightlinesaveselect; 86 | 87 | Gtk::RadioButton* utmselect; 88 | Gtk::RadioButton* latlongselect; 89 | 90 | Gtk::Entry* parsestringentry; 91 | Gtk::Entry* scaleFactorEntryX; 92 | Gtk::Entry* scaleFactorEntryY; 93 | Gtk::Entry* scaleFactorEntryZ; 94 | Gtk::CheckButton* btnUseDefault; 95 | 96 | // Threading 97 | SaveWorker* saveworker; 98 | 99 | // Saving dialog 100 | Gtk::Dialog* savedialog; 101 | Gtk::ProgressBar* saveprogressbar; 102 | Gtk::Button* savecancelbutton; 103 | 104 | // Waveform 105 | Gtk::Dialog* waveformdialog; 106 | Gtk::ProgressBar* waveformprogressbar; 107 | Gtk::Button* waveformcancelbutton; 108 | 109 | void load_xml(const Glib::RefPtr&); 110 | void connect_signals(); 111 | void on_filesaverdialogresponse(int response_id); 112 | void on_usedefault_changed(); 113 | void on_progress(); 114 | void files_saved(); 115 | void on_savecancelbutton_clicked(); 116 | void waveform_started(); 117 | void on_waveform_progress(); 118 | }; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/ui/ProfileWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | ProfileWindow.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef PROFILEWINDOW_H 29 | #define PROFILEWINDOW_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include "AdvancedOptionsWindow.h" 35 | #include "../Profile.h" 36 | #include "../TwoDeeOverview.h" 37 | #include "../ProfileWorker.h" 38 | #include "../ClassifyWorker.h" 39 | 40 | /* 41 | =============================================================================== 42 | 43 | ProfileWindow 44 | 45 | =============================================================================== 46 | */ 47 | class ProfileWindow 48 | { 49 | public: 50 | ProfileWindow(Profile*, TwoDeeOverview*, Gtk::Window*, Gtk::Window*, Gtk::EventBox*, const Glib::RefPtr&, AdvancedOptionsWindow*); 51 | ~ProfileWindow(); 52 | 53 | //This grabs the profile from the overview. 54 | void on_showprofilebutton_clicked(); 55 | 56 | ProfileWorker* profileworker; 57 | void profile_loaded(); 58 | 59 | void points_classified(); 60 | 61 | private: 62 | Profile *prof; 63 | TwoDeeOverview *tdo; 64 | AdvancedOptionsWindow *aow; 65 | 66 | ClassifyWorker* classifyworker; 67 | 68 | // This contains the profile area and takes keyboard input for it. 69 | Gtk::EventBox *eventboxprof; 70 | Gtk::Window *profilewindow; 71 | Gtk::Window *overviewwindow; 72 | 73 | // Check button determining whether the height scale is viewable on 74 | // the profile. 75 | Gtk::CheckMenuItem *showheightscalecheck; 76 | 77 | // Status bar label 78 | Gtk::Label* profstatuslabel; 79 | 80 | Gtk::RadioMenuItem* colourbynonemenuprof; 81 | Gtk::RadioMenuItem* brightnessbynonemenuprof; 82 | //Determines whether the profile is coloured by intensity. 83 | Gtk::RadioMenuItem *colourbyintensitymenuprof; 84 | //Determines whether the profile is coloured by height. 85 | Gtk::RadioMenuItem *colourbyheightmenuprof; 86 | //Determines whether the profile is coloured by flightline. 87 | Gtk::RadioMenuItem *colourbyflightlinemenuprof; 88 | //Determines whether the profile is coloured by classification. 89 | Gtk::RadioMenuItem *colourbyclassificationmenuprof; 90 | //Determines whether the profile is coloured by return. 91 | Gtk::RadioMenuItem *colourbyreturnmenuprof; 92 | //Determines whether the profile is shaded by intensity. 93 | Gtk::RadioMenuItem *brightnessbyintensitymenuprof; 94 | //Determines whether the profile is shaded by height. 95 | Gtk::RadioMenuItem *brightnessbyheightmenuprof; 96 | //Determines the width of the points in the profile in pixels. 97 | Gtk::SpinButton *pointwidthselectprof; 98 | 99 | //Whether to show the points on the profile. 100 | Gtk::ToggleToolButton *pointshowtoggle; 101 | //Whether to show the lines on the profile. 102 | Gtk::ToggleToolButton *lineshowtoggle; 103 | 104 | Gtk::ToolButton *returnbuttonprof; 105 | Gtk::ToolButton *showprofilebutton; 106 | Gtk::ToolButton *classbutton; 107 | 108 | Gtk::ToolButton *refreshbuttonprof; 109 | Gtk::ToolButton *heightsbuttonprof; 110 | 111 | //The range of the moving average for the lines on the profile. 112 | Gtk::SpinButton *movingaveragerangeselect; 113 | 114 | //Toggle button determining whether mouse dragging selects the fence. 115 | Gtk::ToggleToolButton *fencetoggleprof; 116 | 117 | //Toggle button determining whether the ruler is viewable on the profile. 118 | Gtk::ToggleToolButton *rulertoggle; 119 | 120 | //Determines the width of the fence in metres when slanted. 121 | Gtk::SpinButton *slantwidthselectprof; 122 | 123 | //Determine whether the profile fence is orthogonal or slanted. 124 | Gtk::ToggleToolButton *slantedprof; 125 | 126 | // This determines what to classify points as when selected through the 127 | // profile. 128 | Gtk::SpinButton *classificationselect; 129 | 130 | Gtk::CheckButton* heightsexcludenoise; 131 | 132 | Glib::Mutex mutex; 133 | 134 | // Initialisation 135 | void load_xml(const Glib::RefPtr&); 136 | void connect_signals(); 137 | 138 | void on_refreshbutton_clicked(); 139 | void on_heightsbuttonprof_clicked(); 140 | 141 | //When toggled, the height scale is shown on the profile. 142 | void on_showheightscalecheck(); 143 | 144 | //Does the same as on_colouractivated, except for the profile. 145 | void on_colouractivatedprof(); 146 | 147 | //Does the same as on_brightnessactivated, except for the profile. 148 | void on_brightnessactivatedprof(); 149 | 150 | //This returns the profile to its original position. 151 | void on_returnbuttonprof_clicked(); 152 | 153 | //Does the same as on_pointwidthselected, except for the profile. 154 | void on_pointwidthselectedprof(); 155 | 156 | //Determines whether to display the points on the profile. 157 | void on_pointshowtoggle(); 158 | 159 | //Determines whether to display the (best fit) lines on the profile. 160 | void on_lineshowtoggle(); 161 | 162 | // The best fit is a moving average, and this changes the range, and 163 | // therefore the shape of the line. 164 | void on_movingaveragerangeselect(); 165 | 166 | //This classifies the points surrounded by the fence. 167 | void on_classbutton_clicked(); 168 | 169 | //Toggles whether clicking and dragging will select the fence in the profile. 170 | void on_fencetoggleprof(); 171 | 172 | //Updates the slant width and redraws the fence when the spinbutton has its 173 | //value changed. 174 | void on_slantwidthselectedprof(); 175 | 176 | //These update the fence when the shape to draw it is changed. 177 | void on_orthogonalprof(); 178 | //... 179 | void on_slantedprof(); 180 | 181 | // When toggled, the profile view goes into rulering mode. When untoggled, 182 | // rulering mode ends. 183 | void on_rulertoggle(); 184 | 185 | //Interpret keybaord signals from the EventBox. 186 | bool on_prof_key_press(GdkEventKey* event); 187 | 188 | //Manage scrolling of the profile with automatic redraw. 189 | bool on_profile_shift(GdkEventKey* event); 190 | 191 | // Set cursor to busy/not busy 192 | void make_busy_cursor(bool); 193 | 194 | // Set status bar label 195 | void set_statusbar_label(std::string); 196 | 197 | // Set classification 198 | void set_classification(double); 199 | }; 200 | 201 | #endif 202 | -------------------------------------------------------------------------------- /src/ui/README: -------------------------------------------------------------------------------- 1 | ############# 2 | #### Regarding the UI for lag. 3 | ############ 4 | 5 | The UI for lag is produced in Glade and can be edited by using "Glade Interface Designer". 6 | 7 | I have converted the UI from libglade to GTKBuilder which means the XML file 8 | can be parsed without the need for seperate libraries. 9 | 10 | Note that because LAG is written in C++, the function connect_all_signals() (Or 11 | something that resembles that name) is not available - which is a shame, and means 12 | that these .cpp files have had to be created to connect the UI to signal handlers, 13 | rather than this being all handled by the XML. 14 | 15 | This is probably subject to change and should be monitored by whoever is maintaining LAG. 16 | 17 | The addition of this functionality would probably mean that the UI could be completely 18 | handled by an XML file - which consequently would mean that changes to the UI would not 19 | require recompilation (except perhaps adding handlers in callbacks.cpp). 20 | 21 | *** 22 | Due to a current bug in Glade, spin buttons cannot have their default value set in Glade, 23 | because when saving the XML it puts the "value" and "upper" tags in the wrong order. 24 | 25 | To counteract this, there are button->set_value() calls in various places in the UI code. 26 | An update to Glade should fix this in the near future. 27 | -------------------------------------------------------------------------------- /src/ui/TwoDeeOverviewWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | TwoDeeOverviewWindow.h 5 | 6 | Created on: June-July 2010 7 | Authors: Haraldur Tristan Gunnarsson, Jan Holownia 8 | 9 | LIDAR Analysis GUI (LAG), viewer for LIDAR files in .LAS or ASCII format 10 | Copyright (C) 2009-2012 Plymouth Marine Laboratory (PML) 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | =============================================================================== 26 | */ 27 | 28 | #ifndef TWODEEOVERVIEWWINDOW_H 29 | #define TWODEEOVERVIEWWINDOW_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include "../TwoDeeOverview.h" 35 | #include "AdvancedOptionsWindow.h" 36 | #include "FileSaver.h" 37 | #include "ProfileWindow.h" 38 | 39 | /* 40 | =============================================================================== 41 | 42 | TwoDeeOverviewWindow 43 | 44 | =============================================================================== 45 | */ 46 | class TwoDeeOverviewWindow 47 | { 48 | public: 49 | TwoDeeOverviewWindow(TwoDeeOverview*, AdvancedOptionsWindow*, FileSaver*, Gtk::Window*, Gtk::Window*, const Glib::RefPtr&, Gtk::EventBox*, 50 | ProfileWindow*); 51 | 52 | ~TwoDeeOverviewWindow(); 53 | 54 | // Update so that all loaded flightlines can be raised without leaving 55 | // a lot of useless options. 56 | void setraiselinerange(int first, int second) 57 | { 58 | raiselineselect->set_range(first, second); 59 | } 60 | 61 | void set_slice_range(double min, double max); 62 | void set_utm_zone(std::string zone); 63 | 64 | Gtk::Window* get_profilewindow(); 65 | 66 | private: 67 | TwoDeeOverview *tdo; 68 | ProfileWindow *profwin; 69 | 70 | //Contains the overview. 71 | Gtk::EventBox *eventboxtdo; 72 | 73 | Gtk::Window *tdowin; 74 | Gtk::Window *profilewindow; 75 | AdvancedOptionsWindow *aow; 76 | FileSaver *fs; 77 | 78 | // This variable prevents the image(s) from being drawn twice as a result 79 | // of toggling a radio button (or similar), which deactivates (and therefore 80 | // toggles again) another one in the same group. This variable must start 81 | // as true, as the methods make it opposite before using it, so that things 82 | // will de drawn after the second "toggling". 83 | bool drawwhentoggled; 84 | 85 | //Help for LAG. 86 | Gtk::Dialog *help; 87 | 88 | //Information about LAG. 89 | Gtk::AboutDialog *about; 90 | 91 | // Menu items 92 | Gtk::MenuItem* openfilemenuitem; 93 | Gtk::MenuItem* saveasfilemenuitem; 94 | Gtk::MenuItem* quitfilemenuitem; 95 | Gtk::MenuItem* helpmenu; 96 | Gtk::MenuItem* aboutmenu; 97 | Gtk::MenuItem* quadtreemenu; 98 | 99 | Gtk::CheckMenuItem* uselatlongcheck; 100 | 101 | //Check button determining whether the distance scale is viewable 102 | //on the 2d overview. 103 | Gtk::CheckMenuItem *showdistancescalecheck; 104 | 105 | //Check button determining whether the distance scale is viewable 106 | //on the 2d overview. 107 | Gtk::CheckMenuItem *showlegendcheck; 108 | 109 | //Check button determining whether the distance scale is viewable on 110 | //the 2d overview. 111 | Gtk::CheckMenuItem *reverseheightcheck; 112 | 113 | //Determines which flightline is to be raised above the others. 114 | Gtk::SpinButton *raiselineselect; 115 | 116 | //Determines whether any flightline at all is to be raised. 117 | Gtk::CheckMenuItem *raiselinecheckmenu; 118 | 119 | // Detemines whether the image is coloured. 120 | Gtk::RadioMenuItem* colourbynonemenu; 121 | Gtk::RadioMenuItem* brightnessbynonemenu; 122 | 123 | //Determines whether the image is coloured by intensity. 124 | Gtk::RadioMenuItem *colourbyintensitymenu; 125 | 126 | //Determines whether the image is coloured by height. 127 | Gtk::RadioMenuItem *colourbyheightmenu; 128 | 129 | //Determines whether the image is coloured by flightline. 130 | Gtk::RadioMenuItem *colourbyflightlinemenu; 131 | 132 | //Determines whether the image is coloured by classification. 133 | Gtk::RadioMenuItem *colourbyclassificationmenu; 134 | 135 | //Determines whether the image is coloured by return. 136 | Gtk::RadioMenuItem *colourbyreturnmenu; 137 | 138 | //Determines whether the image is shaded by intensity. 139 | Gtk::RadioMenuItem *brightnessbyintensitymenu; 140 | 141 | //Determines whether the image is shaded by height. 142 | Gtk::RadioMenuItem *brightnessbyheightmenu; 143 | 144 | //Toggle button determining whether mouse dragging selects the fence. 145 | Gtk::ToggleToolButton *fencetoggle; 146 | 147 | //Toggle button determining whether mouse dragging selects the profile. 148 | Gtk::ToggleToolButton *profiletoggle; 149 | 150 | //Toggle button determining whether or not to use a slanted selection. 151 | Gtk::ToggleToolButton *slantedrectshapetoggle; 152 | 153 | //Determines the width of the profile in metres. 154 | Gtk::SpinButton *slantwidthselect; 155 | 156 | //Determines the width of the points in the overview in pixels. 157 | Gtk::SpinButton *pointwidthselect; 158 | 159 | //Toggle button determining whether the ruler is viewable on the overview. 160 | Gtk::ToggleToolButton *rulertoggleover; 161 | 162 | Gtk::ToolButton* returnbutton; 163 | Gtk::ToolButton* advancedbutton; 164 | 165 | Gtk::ToolButton* refreshbutton; 166 | void on_refreshbuttonclicked(); 167 | 168 | Gtk::ToolButton* saveasbutton; 169 | 170 | // Vertical slices 171 | Gtk::ToggleToolButton* slicebutton; 172 | Gtk::SpinButton* zminselect; 173 | Gtk::SpinButton* zmaxselect; 174 | 175 | Gtk::ToggleToolButton* superzoombutton; 176 | void on_superzoomclicked(); 177 | 178 | // Loads widgets from xml file 179 | void load_xml(const Glib::RefPtr&); 180 | 181 | // Connects signals 182 | void connect_signals(); 183 | 184 | //When toggled, the distance scale is shown on the 2d overview. 185 | void on_showdistancescalecheck(); 186 | 187 | //When toggled, the legend is shown on the 2d overview. 188 | void on_showlegendcheck(); 189 | 190 | //When toggled, the heights are reversed on the 2d overview. 191 | void on_reverseheightcheck(); 192 | 193 | //If one of the colour radio menu items is selected (and, therefore, 194 | //the others deselected) then set the values of the colour control 195 | //variables in the overview to the values of the corresponding radio 196 | //menu items. 197 | void on_colouractivated(); 198 | 199 | //If one of the brightness radio menu items is selected (and, therefore, 200 | //the others deselected) then set the values of the brightness control 201 | //variables in the overview to the values of the corresponding radio 202 | //menu items. 203 | void on_brightnessactivated(); 204 | 205 | //This returns the overview to its original position. 206 | void on_returnbutton_clicked(); 207 | 208 | //This changes the width of the points in pixels. 209 | void on_pointwidthselected(); 210 | 211 | //When toggled, the profile view goes into rulering mode. When 212 | //untoggled, rulering mode ends. 213 | void on_rulertoggleover(); 214 | 215 | //Toggles whether clicking and dragging will select the fence in the 216 | //overview. 217 | void on_fencetoggle(); 218 | 219 | //When toggled, the 2d overview goes into profile selection mode. When 220 | //untoggled, 2d overview goes out of profile selection mode and the profile 221 | //parameters are sent to the profile area. 222 | void on_profiletoggle(); 223 | 224 | //When toggled, this makes sure that the orthogonal toggle is in the 225 | //opposite state and then sets the slanted shape on the overview and makes 226 | //new profile and fence boundaries before redrawing the overview, possibly 227 | //with the new boundaries for profile and/or fence displayed. 228 | void on_slantedrectshapetoggle(); 229 | 230 | //When the value in the spinbutton for slanted shape width is changed, 231 | //tell the 2d overview, then make the new slanted box and then draw it. 232 | //This does NOT update the profile itself (or, at least, not yet) if the 233 | //slanted box is for a profile. To update the profile after the width has 234 | //been satisfactorily adjusted, the profiletoggle must be toggled and then 235 | //untoggled. 236 | void on_slantwidthselected(); 237 | 238 | //Opens the advanced options dialog. 239 | void on_advancedbutton_clicked(); 240 | 241 | //Show the help dialog when respective menu item activated. 242 | void on_helpmenuactivated(); 243 | 244 | //Hide the help dialog when close button activated. 245 | void on_helpresponse(int response_id); 246 | 247 | //Show the about dialog when respective menu item activated. 248 | void on_aboutmenuactivated(); 249 | 250 | //Hide the about dialog when close button activated. 251 | void on_aboutresponse(int response_id); 252 | 253 | //When selected from the menu, the file chooser opens. 254 | void on_openfilemenuactivated(); 255 | 256 | //When selected from the menu, the file saver opens. 257 | void on_savefilemenuactivated(); 258 | 259 | //Intreprets keybaord signals from the EventBox. 260 | bool on_tdo_key_press(GdkEventKey* event); 261 | 262 | //Updates the line to be raised and redraws. 263 | void on_raiselineselected(); 264 | 265 | //Updates whether any line is to be raised and redraws. 266 | void on_raiselinecheckmenu(); 267 | 268 | //Slicing 269 | void on_slicebuttontoggled(); 270 | void on_zminvaluechanged(); 271 | void on_zmaxvaluechanged(); 272 | 273 | //Shows quadtree information 274 | void on_quadtreemenu_activated(); 275 | 276 | //Displays coordinates in latlong/UTM 277 | void on_uselatlongcheck(); 278 | }; 279 | #endif 280 | -------------------------------------------------------------------------------- /ubuntu-Makefile.patch: -------------------------------------------------------------------------------- 1 | 405c405,407 2 | < $(lag_LINK) $(lag_OBJECTS) $(lag_LDADD) $(LIBS) 3 | --- 4 | > $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(lag_LDFLAGS) \ 5 | > $(LDFLAGS) -o $@ $(lag_OBJECTS) $(lag_LDADD) $(LIBS) \ 6 | > $(lag_LDADD) $(lag_LDFLAGS) 7 | --------------------------------------------------------------------------------