NDEVR
API Documentation
GoogleEarthApplicationManager.h
1#pragma once
2#include "NDEVR/Headers/QTModelManager.h"
3#include "NDEVR/Headers/ProjectFileManager.h"
4#include "Widgets/Headers/Button.h"
5#include "Widgets/Headers/QTErrorDialog.h"
6#include "Widgets/Headers/ApplicationLauncherButton.h"
7#include "KMLInterface/Headers/KMLFactory.h"
8#include "Base/Headers/ApplicationResource.h"
9#include "Base/Headers/Exception.hpp"
10#include "Base/Headers/Translator.h"
11#include "Base/Headers/FileResource.h"
12namespace NDEVR
13{
19 {
20 public:
25 , m_dxf_folder(FileResource::ProgramTempPath())
26 , m_manager(manager)
27 {
28
29 }
30
32 void setCADLauncher(const File& f)
33 {
35 }
36
39 {
40 if (!m_cad_launcher.exists())
43 m_google_earth_button_manager->setAppFinishedCallback([this]
44 {
45 if (m_active_kml.exists())
46 {
47#if NDEVR_SUPPORTS_THREADING
48 BasicThread* read_dxf = new BasicThread("Google Earth KML", false, [this]
49 {
50#endif
51 Buffer<FileFormat> formats;
52 m_factory.getSupportedFormats(formats, false);
53 if (formats.size() > 0)
54 {
55 FactoryParameters parms(m_active_kml, formats.last());
56 parms.lookup = m_manager;
57 parms.options = m_factory.defaultReadOptions(parms);
58 parms.options.ignore_invisible = true;
59 parms.setInfoPipe(m_manager->logManager()->defaultLog());
60 try
61 {
62 m_factory.readFile(parms);
63 }
64 catch (const Exception& e)
65 {
67 }
68 }
69 m_active_kml.clear();
70#if NDEVR_SUPPORTS_THREADING
71 });
72 read_dxf->start();
73#endif
74 }
75 //m_collect_data_completed = true;
76 //m_manager->convertGPSFiles();
77 });
78 m_google_earth_button_manager->setAppLaunchCallback([this]
79 {
81 });
83 }
84
87 {
88 if (m_google_earth_button_manager == nullptr)
90 Button* button = m_google_earth_button_manager->createButton();
91 button->setTitle(_t("G-Earth"));
92 return button;
93 }
94
97 {
98 if (!m_cad_launcher.exists())
99 return FindGoogleEarthApp().exists();
100 return true;
101 }
102
104 {
106 m_active_kml.appendPath(m_manager->projectFileManager()->projectFile().getPath(File::e_file_name) + ".kml");
107
108 Buffer<FileFormat> formats;
109 m_factory.getSupportedFormats(formats, false);
110 if (formats.size() > 0)
111 {
112 FactoryParameters parms(m_active_kml, formats[0]);
113 parms.lookup = m_manager;
114 parms.options = m_factory.defaultWriteOptions(parms);
115 parms.options.ignore_invisible = true;
116 parms.cameras = m_manager->cameraManager()->userCameraIDs();
117 parms.models = m_manager->getRootObjectIDs();
118 try
119 {
120 m_factory.writeFile(parms);
121 }
122 catch (Exception& e)
123 {
125 }
126 }
127 if (!m_active_kml.exists())
128 {
129 QTErrorDialog::CreateErrorDialog(Exception(_t("Could not create KML"), _td("could_not_create", "Could not create: [file]").replace("[file]", m_active_kml)));
130 }
131 m_google_earth_button_manager->setArgs("\""+ m_active_kml +"\"");
132
133 }
134
138 {
139 //return File("C:\\Program Files\\Autodesk\\AutoCAD 2020\\acad.exe");
140 return File("C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe");
141 //return File("C:\\ProgramData\\Carlson Software\\CSI2019\\scjstart.exe");
142 //return File("C:\\Program Files\\Autodesk\\AutoCAD 2018\\acad.exe");
143 //return File(String(GetAutoCADInstallPath()));
144 }
151 };
152}
Creates a button for launching a 3rd party application.
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
void setTitle(const TranslatedString &title)
Sets the display title of the button.
Provides consistent interface to handle errors through the throw expression.
Definition Exception.hpp:47
bool ignore_invisible
Whether to skip invisible objects during import/export.
Contains methods for getting information about particular OS directories or static program file direc...
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
@ e_file_name
The file name without extension.
Definition File.h:77
bool exists() const
Checks whether this file or directory exists on disk.
QTModelManager * m_manager
The application model manager.
File m_cad_launcher
Path to the Google Earth executable.
ApplicationLauncherButtonManager * createAppLauncher()
Creates the application launcher manager with callbacks for KML export and import.
bool hasActiveInstallation() const
Checks whether Google Earth Pro is installed on this system.
Button * createLauncherButton()
Creates a UI button that launches Google Earth Pro.
KMLFactory m_factory
KML read/write factory instance.
ApplicationLauncherButtonManager * m_google_earth_button_manager
The button manager for launching Google Earth.
File m_dxf_folder
Temporary folder for exported files.
GoogleEarthApplicationManager(QTModelManager *manager)
Constructs a GoogleEarthApplicationManager.
File m_active_kml
Path to the active KML file being shared.
void setupForCAD()
Exports the current project data as KML and configures the launcher arguments.
static File FindGoogleEarthApp()
Locates the Google Earth Pro executable on the system.
void setCADLauncher(const File &f)
Sets the path to the Google Earth executable.
Reads and writes KML/KMZ geographic markup files using the IOFactory interface.
Definition KMLFactory.h:50
static void CreateErrorDialog(Exception exception, LogPtr log=LogPtr())
Creates and shows an error dialog for the given exception.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
void start()
Starts the thread execution.
The primary namespace for the NDEVR SDK.
A container of input information that is to be filled with output information by an IOFactory.
Definition IOFactory.h:105
FactoryOptions options
All read/write options including special parameters.
Definition IOFactory.h:185
void setInfoPipe(InfoPipe *pipe)
Sets the info pipe for streaming log messages or cancelling the operation.
Buffer< UUID > cameras
UUIDs of cameras created or targeted by the operation.
Definition IOFactory.h:189
Buffer< UUID > models
UUIDs of models created or targeted by the operation.
Definition IOFactory.h:188
DesignObjectLookup * lookup
The design object lookup used to resolve models and objects.
Definition IOFactory.h:190