temp commit
[SARndbox.git] / DEMTool.h
blob2c9d910ee31ed27cc90452e4e0eeee2ccbf587f1
1 /***********************************************************************
2 DEMTool - Tool class to load a digital elevation model into an augmented
3 reality sandbox to colorize the sand surface based on distance to the
4 DEM.
5 Copyright (c) 2013-2016 Oliver Kreylos
7 This file is part of the Augmented Reality Sandbox (SARndbox).
9 The Augmented Reality Sandbox is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 The Augmented Reality Sandbox is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License along
20 with the Augmented Reality Sandbox; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ***********************************************************************/
24 #ifndef DEMTOOL_INCLUDED
25 #define DEMTOOL_INCLUDED
27 #include <string>
28 #include <GL/gl.h>
29 #include <GL/GLObject.h>
30 #include <GLMotif/FileSelectionHelper.h>
31 #include <Vrui/Tool.h>
32 #include <Vrui/Application.h>
34 #include "Types.h"
35 #include "DEM.h"
37 /* Forward declarations: */
38 class Sandbox;
39 class DEMTool;
41 class DEMToolFactory: public Vrui::ToolFactory {
42 friend class DEMTool;
44 /* Elements: */
45 private:
46 GLMotif::FileSelectionHelper demSelectionHelper; // Helper object to load DEMs from files
48 /* Constructors and destructors: */
49 public:
50 DEMToolFactory(Vrui::ToolManager& toolManager);
51 virtual ~DEMToolFactory(void);
53 /* Methods from Vrui::ToolFactory: */
54 virtual const char* getName(void) const;
55 virtual const char* getButtonFunction(int buttonSlotIndex) const;
56 virtual Vrui::Tool* createTool(const Vrui::ToolInputAssignment& inputAssignment) const;
57 virtual void destroyTool(Vrui::Tool* tool) const;
60 class DEMTool: public DEM, public Vrui::Tool, public Vrui::Application::Tool<Sandbox> {
61 friend class DEMToolFactory;
63 /* Elements: */
64 private:
65 static DEMToolFactory* factory; // Pointer to the factory object for this class
66 std::string demFileName; // Name of DEM file to load
67 bool haveDemTransform; // Flag if the tool's configuration file section specified a DEM transformation
68 OGTransform demTransform; // The transformation to apply to the DEM
69 Scalar demVerticalShift; // Extra vertical shift to apply to DEM in sandbox coordinate units
70 Scalar demVerticalScale; // The vertical exaggeration to apply to the DEM
72 /* Private methods: */
73 void loadDEMFile(const char* demFileName); // Loads a DEM from a file
74 void loadDEMFileCallback(GLMotif::FileSelectionDialog::OKCallbackData*
75 cbData); // Called when the user selects a DEM file to load
77 /* Constructors and destructors: */
78 public:
79 static DEMToolFactory* initClass(Vrui::ToolManager& toolManager);
80 DEMTool(const Vrui::ToolFactory* factory, const Vrui::ToolInputAssignment& inputAssignment);
81 virtual ~DEMTool(void);
83 /* Methods from class Vrui::Tool: */
84 virtual void configure(const Misc::ConfigurationFileSection& configFileSection);
85 virtual void initialize(void);
86 virtual const Vrui::ToolFactory* getFactory(void) const;
87 virtual void buttonCallback(int buttonSlotIndex, Vrui::InputDevice::ButtonCallbackData* cbData);
90 #endif