1 /***********************************************************************
2 BathymetrySaverTool - Tool to save the current bathymetry grid of an
3 augmented reality sandbox to a file or network socket.
4 Copyright (c) 2016 Oliver Kreylos
6 This file is part of the Augmented Reality Sandbox (SARndbox).
8 The Augmented Reality Sandbox is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 The Augmented Reality Sandbox is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with the Augmented Reality Sandbox; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ***********************************************************************/
23 #ifndef BATHYMETRYSAVERTOOL_INCLUDED
24 #define BATHYMETRYSAVERTOOL_INCLUDED
28 #include <Vrui/Tool.h>
29 #include <Vrui/Application.h>
33 /* Forward declarations: */
36 class BathymetrySaverTool
;
38 class BathymetrySaverToolFactory
: public Vrui::ToolFactory
{
39 friend class BathymetrySaverTool
;
41 /* Embedded classes: */
43 struct Configuration
{ // Structure containing tool settings
46 std::string saveFileName
; // Name of file to which to save the bathymetry grid
47 bool postUpdate
; // Flag whether to post an update message to a web server after saving the bathymetry grid
48 std::string postUpdateHostName
; // Name of web server to which to send update messages
49 int postUpdatePort
; // TCP port number of web server to which to send update messages
50 std::string postUpdatePage
; // Name of page on web server to which update messages are posted
51 std::string postUpdateMessage
; // The message to send to the web server
52 double gridScale
; // Overall scale factor to applied to grids on export
54 /* Constructors and destructors: */
55 Configuration(void); // Creates default configuration
58 void read(const Misc::ConfigurationFileSection
&
59 cfs
); // Overrides configuration from configuration file section
60 void write(Misc::ConfigurationFileSection
& cfs
)
61 const; // Writes configuration to configuration file section
66 Configuration configuration
; // Default configuration for all tools
67 WaterTable2
* waterTable
; // Pointer to water table object from which to request bathymetry grids
68 GLsizei gridSize
[2]; // Width and height of the water table's bathymetry grid
69 GLfloat cellSize
[2]; // Width and height of each water table cell
71 /* Constructors and destructors: */
73 BathymetrySaverToolFactory(WaterTable2
* sWaterTable
, Vrui::ToolManager
& toolManager
);
74 virtual ~BathymetrySaverToolFactory(void);
76 /* Methods from Vrui::ToolFactory: */
77 virtual const char* getName(void) const;
78 virtual const char* getButtonFunction(int buttonSlotIndex
) const;
79 virtual Vrui::Tool
* createTool(const Vrui::ToolInputAssignment
& inputAssignment
) const;
80 virtual void destroyTool(Vrui::Tool
* tool
) const;
83 class BathymetrySaverTool
: public Vrui::Tool
, public Vrui::Application::Tool
<Sandbox
> {
84 friend class BathymetrySaverToolFactory
;
88 static BathymetrySaverToolFactory
* factory
; // Pointer to the factory object for this class
89 BathymetrySaverToolFactory::Configuration configuration
; // Configuration of this tool
90 GLfloat
* bathymetryBuffer
; // Bathymetry grid buffer
91 bool requestPending
; // Flag if this tool has a pending request to retrieve a bathymetry grid
93 /* Private methods: */
94 void writeDEMFile(void) const; // Writes the bathymetry grid to a file in USGS DEM format
95 void postUpdate(void) const; // Sends an update message to a web server
97 /* Constructors and destructors: */
99 static BathymetrySaverToolFactory
* initClass(WaterTable2
* sWaterTable
,
100 Vrui::ToolManager
& toolManager
);
101 BathymetrySaverTool(const Vrui::ToolFactory
* factory
,
102 const Vrui::ToolInputAssignment
& inputAssignment
);
103 virtual ~BathymetrySaverTool(void);
105 /* Methods from class Vrui::Tool: */
106 virtual void configure(const Misc::ConfigurationFileSection
& configFileSection
);
107 virtual void storeState(Misc::ConfigurationFileSection
& configFileSection
) const;
108 virtual const Vrui::ToolFactory
* getFactory(void) const;
109 virtual void buttonCallback(int buttonSlotIndex
, Vrui::InputDevice::ButtonCallbackData
* cbData
);
110 virtual void frame(void);