diff --git a/FsTrack.jucer b/FsTrack.jucer
index 9172452..e020d8b 100644
--- a/FsTrack.jucer
+++ b/FsTrack.jucer
@@ -33,36 +33,22 @@
isDebug="0" optimisation="2" targetName="FsTrack" headerPath="../../../../../extLib/FSUIPC"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Makefile b/Makefile
index e69de29..05de621 100644
--- a/Makefile
+++ b/Makefile
@@ -0,0 +1,128 @@
+#
+# There exist several targets which are by default empty and which can be
+# used for execution of your targets. These targets are usually executed
+# before and after some main targets. They are:
+#
+# .build-pre: called before 'build' target
+# .build-post: called after 'build' target
+# .clean-pre: called before 'clean' target
+# .clean-post: called after 'clean' target
+# .clobber-pre: called before 'clobber' target
+# .clobber-post: called after 'clobber' target
+# .all-pre: called before 'all' target
+# .all-post: called after 'all' target
+# .help-pre: called before 'help' target
+# .help-post: called after 'help' target
+#
+# Targets beginning with '.' are not intended to be called on their own.
+#
+# Main targets can be executed directly, and they are:
+#
+# build build a specific configuration
+# clean remove built files from a configuration
+# clobber remove all built files
+# all build all configurations
+# help print help mesage
+#
+# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
+# .help-impl are implemented in nbproject/makefile-impl.mk.
+#
+# Available make variables:
+#
+# CND_BASEDIR base directory for relative paths
+# CND_DISTDIR default top distribution directory (build artifacts)
+# CND_BUILDDIR default top build directory (object files, ...)
+# CONF name of current configuration
+# CND_PLATFORM_${CONF} platform name (current configuration)
+# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
+# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
+# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
+# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
+# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
+# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
+#
+# NOCDDL
+
+
+# Environment
+MKDIR=mkdir
+CP=cp
+CCADMIN=CCadmin
+
+
+# build
+build: .build-post
+
+.build-pre:
+# Add your pre 'build' code here...
+
+.build-post: .build-impl
+# Add your post 'build' code here...
+
+
+# clean
+clean: .clean-post
+
+.clean-pre:
+# Add your pre 'clean' code here...
+
+.clean-post: .clean-impl
+# Add your post 'clean' code here...
+
+
+# clobber
+clobber: .clobber-post
+
+.clobber-pre:
+# Add your pre 'clobber' code here...
+
+.clobber-post: .clobber-impl
+# Add your post 'clobber' code here...
+
+
+# all
+all: .all-post
+
+.all-pre:
+# Add your pre 'all' code here...
+
+.all-post: .all-impl
+# Add your post 'all' code here...
+
+
+# build tests
+build-tests: .build-tests-post
+
+.build-tests-pre:
+# Add your pre 'build-tests' code here...
+
+.build-tests-post: .build-tests-impl
+# Add your post 'build-tests' code here...
+
+
+# run tests
+test: .test-post
+
+.test-pre: build-tests
+# Add your pre 'test' code here...
+
+.test-post: .test-impl
+# Add your post 'test' code here...
+
+
+# help
+help: .help-post
+
+.help-pre:
+# Add your pre 'help' code here...
+
+.help-post: .help-impl
+# Add your post 'help' code here...
+
+
+
+# include project implementation makefile
+include nbproject/Makefile-impl.mk
+
+# include project make variables
+include nbproject/Makefile-variables.mk
diff --git a/Source/FsLink.cpp b/Source/FsLink.cpp
index 73c5fdc..7648ad4 100644
--- a/Source/FsLink.cpp
+++ b/Source/FsLink.cpp
@@ -207,6 +207,7 @@ void FsLink::timerCallback()
case ls_connected:
if (!m_flightData.isFsDialog && m_flightData.isFsReady)
{
+ m_pKml->updateFlightData(m_flightData);
if (m_pKml)
{
m_pKml->create();
@@ -309,14 +310,15 @@ void FsLink::timerCallback()
{
m_listeners.call(&IFsLinkListener::onDataChanged, *this);
- m_pKml->updatePlane(m_flightData);
+ m_pKml->updateFlightData(m_flightData);
+// m_pKml->updatePlane(m_flightData);
if (m_kmlUpdateCount > 0)
{
m_kmlUpdateCount--;
}
else
{
- m_pKml->updatePath(m_flightData);
+ m_pKml->updateTrack();
m_pKml->exportKml(m_pKml->getPath());
m_kmlUpdateCount = m_kmlUpdateInterval;
}
diff --git a/Source/IFsLink.hpp b/Source/IFsLink.hpp
index 59bae21..ce8bdea 100644
--- a/Source/IFsLink.hpp
+++ b/Source/IFsLink.hpp
@@ -10,6 +10,8 @@
struct FlightData
{
+ FlightData() {}
+ ~FlightData() {}
bool isFsReady, isFsDialog, isPaused, isParked, isOnGround, isReplay;
unsigned long timeZulu;
double lat, lon, alt_meter, alt_feet, gl_meter, bank_deg, pitch_deg, hdgTrue_deg, hdgMag_deg, gs_meterPerSec, gs_knots, tas_knots, ias_knots, bpa_knots, vs_feetPerMin, magVar_deg;
@@ -23,6 +25,43 @@ struct FlightData
char atcAirlineStr[24];
char atcAircraftTypeStr[24];
+ const FlightData& operator=(const FlightData &rhs)
+ {
+ isFsReady = rhs.isFsReady;
+ isFsDialog = rhs.isFsDialog;
+ isPaused = rhs.isPaused;
+ isParked = rhs.isParked;
+ isOnGround = rhs.isOnGround;
+ isReplay = rhs.isReplay;
+ lat = rhs.lat;
+ lon = rhs.lon;
+ alt_meter = rhs.alt_meter;
+ alt_feet = rhs.alt_feet;
+ gl_meter = rhs.gl_meter;
+ bank_deg = rhs.bank_deg;
+ pitch_deg = rhs.pitch_deg;
+ hdgTrue_deg = rhs.hdgTrue_deg;
+ hdgMag_deg = rhs.hdgMag_deg;
+ gs_meterPerSec = rhs.gs_meterPerSec;
+ gs_knots = rhs.gs_knots;
+ tas_knots = rhs.tas_knots;
+ ias_knots = rhs.ias_knots;
+ bpa_knots = rhs.bpa_knots;
+ vs_feetPerMin = rhs.vs_feetPerMin;
+ magVar_deg = rhs.magVar_deg;
+ framerate = rhs.framerate;
+
+ memcpy(aircraftTitle, rhs.aircraftTitle, sizeof(aircraftTitle));
+ memcpy(tcasStr, rhs.tcasStr, sizeof(tcasStr));
+ memcpy(tcasStr2, rhs.tcasStr2, sizeof(tcasStr2));
+ memcpy(flightname, rhs.flightname, sizeof(flightname));
+ memcpy(atcFlightNumStr, rhs.atcFlightNumStr, sizeof(atcFlightNumStr));
+ memcpy(atcFlightIDStr, rhs.atcFlightIDStr, sizeof(atcFlightIDStr));
+ memcpy(atcAirlineStr, rhs.atcAirlineStr, sizeof(atcAirlineStr));
+ memcpy(atcAircraftTypeStr, rhs.atcAircraftTypeStr, sizeof(atcAircraftTypeStr));
+
+ return *this;
+ }
};
struct IFsLink
diff --git a/Source/IKml.hpp b/Source/IKml.hpp
index ab6226e..d79c008 100644
--- a/Source/IKml.hpp
+++ b/Source/IKml.hpp
@@ -18,9 +18,9 @@ struct IKml
virtual void create() = 0;
virtual void destroy() = 0;
virtual const char* getPath() = 0;
-
- virtual void updatePlane(FlightData const &flightData) = 0;
- virtual void updatePath(FlightData const &flightData) = 0;
+
+ virtual void updateFlightData(FlightData const &flightData) = 0;
+ virtual void updateTrack() = 0;
virtual void exportKml(const char *pPath) = 0;
virtual void exportKmz(const char *pPath) = 0;
};
diff --git a/Source/Kml.cpp b/Source/Kml.cpp
index 93c9526..f3bf16d 100644
--- a/Source/Kml.cpp
+++ b/Source/Kml.cpp
@@ -7,9 +7,9 @@
//#define WITH_FANCY_CAMERA
Kml::Kml(const char *pDocRoot)
-: kml(nullptr)
+: m_pKml(nullptr)
, m_pPlanePlaceMark(nullptr)
-, m_pPathPlaceMark(nullptr)
+, m_pTrackPlaceMark(nullptr)
, m_pCameraPlaceMark(nullptr)
, m_docRoot(pDocRoot)
, m_altitudeModeString("absolute")
@@ -18,6 +18,7 @@ Kml::Kml(const char *pDocRoot)
, m_cameraTilt(0)
, m_cameraAutoHeading(false)
, m_cameraAutoRoll(false)
+, m_cameraFlyToView(false)
{
memset(m_path, 0, sizeof(m_path));
}
@@ -25,7 +26,55 @@ Kml::Kml(const char *pDocRoot)
Kml::~Kml(void)
{
- kml = nullptr;
+ m_pKml = nullptr;
+}
+
+void Kml::updateFlightData(FlightData const &flightData)
+{
+ const ScopedLock sl (m_lock);
+ m_flightData = flightData;
+}
+
+void Kml::createNetworkLinkFile(String const &path, String const &hostIp)
+{
+ File file(path);
+
+ if (file.exists())
+ {
+ return;
+ }
+
+ ScopedPointer pKml = new XmlElement("kml");
+ pKml->setAttribute("xmlns", "http://www.opengis.net/kml/2.2");
+
+ XmlElement *pDoc = pKml->createNewChildElement("Document");
+ pDoc->createNewChildElement("visibility")->addTextElement("1");
+
+ XmlElement *pNetworkLink = pDoc->createNewChildElement("NetworkLink");
+ pNetworkLink->setAttribute("id", "NetworkLink_0");
+ pNetworkLink->createNewChildElement("name")->addTextElement("Link");
+
+
+ XmlElement *pFlyToView = pNetworkLink->createNewChildElement("flyToView");
+ if (m_cameraFlyToView)
+ {
+ pFlyToView->addTextElement("1");
+ }
+ else
+ {
+ pFlyToView->addTextElement("0");
+ }
+
+ XmlElement *pLink = pNetworkLink->createNewChildElement("Link");
+ pLink->createNewChildElement("href")->addTextElement(String("http://") + hostIp + String(":5001/flight.kml"));
+ pLink->createNewChildElement("refreshMode")->addTextElement("onInterval");
+ pLink->createNewChildElement("refreshInterval")->addTextElement("1");
+ pLink->createNewChildElement("viewRefreshMode")->addTextElement("onStop");
+ pLink->createNewChildElement("viewRefreshInterval")->addTextElement("0");
+ pLink->createNewChildElement("viewFormat")->addTextElement("BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth];CAMERA=[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading];VIEW=[horizFov],[vertFov],[horizPixels],[vertPixels],[terrainEnabled]");
+
+ pKml->writeToFile(file, StringRef(""));
+
}
const char* Kml::getPath()
@@ -38,114 +87,37 @@ void Kml::create()
time_t time_departure;
struct tm *time_now;
- if (kml)
+ if (m_pKml)
destroy();
- kml = new XmlElement("kml");
- XmlElement *pNetworkLinkControl = kml->createNewChildElement("NetworkLinkControl");
- pNetworkLinkControl->createNewChildElement("LinkName")->addTextElement("FsTrack");
- XmlElement *pDoc = kml->createNewChildElement("Document");
- XmlElement *pFile = kml->getChildByName("Document")->createNewChildElement("filename");
- XmlElement *pSnippet = kml->getChildByName("Document")->createNewChildElement("Snippet");
+ m_pKml = new XmlElement("kml");
+ XmlElement *pDoc = m_pKml->createNewChildElement("Document");
time(&time_departure);
time_now = localtime(&time_departure);
char time_str[256];
// Create an outer XML element..
- kml->setAttribute("xmlns", "http://www.opengis.net/kml/2.2");
- kml->setAttribute("xmlns:gx", "http://www.google.com/kml/ext/2.2");
+ m_pKml->setAttribute("xmlns", "http://www.opengis.net/kml/2.2");
+ m_pKml->setAttribute("xmlns:gx", "http://www.google.com/kml/ext/2.2");
sprintf(m_path, "%s\\flight_%4.4d%2.2d%2.2d_%2.2d%2.2d%2.2d.kml", m_docRoot, 1900+time_now->tm_year, time_now->tm_mon+1, time_now->tm_mday, time_now->tm_hour, time_now->tm_min, time_now->tm_sec);
- pFile->addTextElement(m_path);
- pSnippet->setAttribute("maxLines", "2");
-
+ pDoc->createNewChildElement("filename")->addTextElement(m_path);
+
sprintf(time_str, "Created on %4.4d-%2.2d-%2.2d at %2.2d:%2.2d:%2.2d", 1900+time_now->tm_year, time_now->tm_mon+1, time_now->tm_mday, time_now->tm_hour, time_now->tm_min, time_now->tm_sec);
+ XmlElement *pSnippet = pDoc->createNewChildElement("Snippet");
+ pSnippet->setAttribute("maxLines", "2");
pSnippet->addTextElement(time_str);
-
- // Camera
- XmlElement *pCamera = pNetworkLinkControl->createNewChildElement("Camera");
- pCamera->createNewChildElement("longitude")->addTextElement("0");
- pCamera->createNewChildElement("latitude")->addTextElement("0");
- pCamera->createNewChildElement("altitude")->addTextElement("0");
- pCamera->createNewChildElement("heading")->addTextElement("0");
- pCamera->createNewChildElement("tilt")->addTextElement("0");
- pCamera->createNewChildElement("roll")->addTextElement("0");
- pCamera->createNewChildElement("altitudeMode")->addTextElement(m_altitudeModeString);
-
+
+ m_pTrackPlaceMark = createTrack();
+
}
-void Kml::destroy()
-{
- kml = nullptr;
- m_pPlanePlaceMark = nullptr;
- m_pPathPlaceMark = nullptr;
- m_pCameraPlaceMark = nullptr;
-}
-
-void Kml::setAltitudeMode(String const &modeString)
-{
- m_altitudeModeString = modeString;
-
- if (m_pPlanePlaceMark)
- {
- m_pPlanePlaceMark->getChildByName("Point")->getChildByName("altitudeMode")->getFirstChildElement()->setText(modeString);
- }
-
- if (m_pPathPlaceMark)
- {
- m_pPathPlaceMark->getChildByName("LineString")->getChildByName("altitudeMode")->getFirstChildElement()->setText(modeString);
- }
-
-}
-
-void Kml::setPathColor(String const &colorString)
+XmlElement* Kml::createPlane()
{
const ScopedLock sl (m_lock);
-
- m_pathColorString = colorString;
-
- if (m_pPathPlaceMark)
- {
- m_pPathPlaceMark->getChildByName("Style")->getChildByName("LineStyle")->getChildByName("color")->getFirstChildElement()->setText(colorString);
- }
-
-}
-
-void Kml::setCameraAltitude(float alt_meters)
-{
- m_cameraAlt = alt_meters;
-}
-
-void Kml::setCameraTilt(float tilt_deg)
-{
- m_cameraTilt = tilt_deg;
-}
-
-void Kml::update(FlightData const &flightData)
-{
- updatePlane(flightData);
- updatePath(flightData);
-}
-
-void Kml::setCameraAutoHeading(bool enable)
-{
- m_cameraAutoHeading = enable;
-}
-
-void Kml::setCameraAutoRoll(bool enable)
-{
- m_cameraAutoRoll = enable;
-}
-
-void Kml::updatePlane(FlightData const &flightData)
-{
- const ScopedLock sl (m_lock);
-
char temp_str[1024];
- XmlElement *pDoc = kml->getChildByName("Document");
-
- XmlElement *pPlacemark = m_pPlanePlaceMark;
+ XmlElement *pPlacemark;
XmlElement *pName;
XmlElement *pStyle;
XmlElement *pIconStyle;
@@ -161,192 +133,181 @@ void Kml::updatePlane(FlightData const &flightData)
XmlElement *pAltitudeMode;
XmlElement *pCoords;
- XmlElement *pCamera;
+ // Placemark
+ pPlacemark = new XmlElement("Placemark");
+ pPlacemark->setAttribute("id", "Plane_0");
- if(pPlacemark == nullptr)
+ // Name
+ sprintf(temp_str, "Unknown flight");
+ if (strlen(m_flightData.atcFlightIDStr))
{
- // Placemark
- pPlacemark = pDoc->createNewChildElement("Placemark");
-
- // Name
- sprintf(temp_str, "Unknown flight");
- if (strlen(flightData.atcFlightIDStr))
+ if (strlen(m_flightData.atcFlightNumStr) == 0)
{
- if (strlen(flightData.atcFlightNumStr) == 0)
- {
- sprintf(temp_str, "%s", flightData.atcFlightIDStr);
- }
- else
- {
- sprintf(temp_str, "%s/%s", flightData.atcFlightIDStr, flightData.atcFlightNumStr);
- }
+ sprintf(temp_str, "%s", m_flightData.atcFlightIDStr);
}
- pName = pPlacemark->createNewChildElement("name");
- pName->addTextElement(temp_str);
- printf("%s\n", temp_str);
-
- // Description
- pDescr = pPlacemark->createNewChildElement("description");
- sprintf(temp_str, "%s\nAltitude: %d ft, Speed: %d kts", flightData.atcFlightIDStr, (int)(flightData.alt_feet+0.5), (int)(flightData.gs_knots+0.5));
- pDescr->addTextElement(temp_str);
-
- // Style
- pStyle = pPlacemark->createNewChildElement("Style");
-
- // IconStyle
- pIconStyle = pStyle->createNewChildElement("IconStyle");
- pHeading = pIconStyle->createNewChildElement("heading");
- pHeading->addTextElement(String(flightData.hdgTrue_deg));
-
- // Icon
- pIcon = pIconStyle->createNewChildElement("Icon");
- pHref = pIcon->createNewChildElement("href");
- pHref->addTextElement("root://icons/palette-2.png");
- pY = pIcon->createNewChildElement("y");
- pY->addTextElement("0");
- pW = pIcon->createNewChildElement("w");
- pW->addTextElement("32");
- pH = pIcon->createNewChildElement("h");
- pH->addTextElement("32");
-
- // Point
- pPoint = pPlacemark->createNewChildElement("Point");
- pPoint->setAttribute("id", "Pointy");
- pExtrude = pPoint->createNewChildElement("extrude");
- pExtrude->addTextElement("1");
- pTesselate = pPoint->createNewChildElement("tesselate");
- pTesselate->addTextElement("1");
- pAltitudeMode = pPoint->createNewChildElement("altitudeMode");
- pAltitudeMode->addTextElement(m_altitudeModeString);
- pCoords = pPoint->createNewChildElement("coordinates");
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f", flightData.lon, flightData.lat, flightData.alt_meter);
- pCoords->addTextElement(temp_str);
-
- m_pPlanePlaceMark = pPlacemark;
- }
- else
- {
- // Description
- sprintf(temp_str, "%s\nAltitude: %d ft, Speed: %d kts", flightData.atcFlightIDStr, (int)(flightData.alt_feet+0.5), (int)(flightData.gs_knots+0.5));
- pDescr = pPlacemark->getChildByName("description");
- pDescr->getFirstChildElement()->setText(temp_str);
-
- // Heading
- pHeading = pPlacemark->getChildByName("Style")->getChildByName("IconStyle")->getChildByName("heading");
- pHeading->getFirstChildElement()->setText(String(flightData.hdgTrue_deg));
-
- // Coordinates
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f", flightData.lon, flightData.lat, flightData.alt_meter);
- pCoords = pPlacemark->getChildByName("Point")->getChildByName("coordinates");
- pCoords->getFirstChildElement()->setText(temp_str);
-
- pCamera = kml->getChildByName("NetworkLinkControl")->getChildByName("Camera");
-
- pCamera->getChildByName("longitude")->getFirstChildElement()->setText(String(flightData.lon));
- pCamera->getChildByName("latitude")->getFirstChildElement()->setText(String(flightData.lat));
- pCamera->getChildByName("altitude")->getFirstChildElement()->setText(String(flightData.alt_meter+m_cameraAlt));
-
- if (m_cameraAutoHeading)
- pCamera->getChildByName("heading")->getFirstChildElement()->setText(String(flightData.hdgTrue_deg));
else
- pCamera->getChildByName("heading")->getFirstChildElement()->setText("0");
-
- pCamera->getChildByName("tilt")->getFirstChildElement()->setText(String(m_cameraTilt));
-
- if (m_cameraAutoRoll)
- pCamera->getChildByName("roll")->getFirstChildElement()->setText(String(flightData.bank_deg));
- else
- pCamera->getChildByName("roll")->getFirstChildElement()->setText("0");
-
- pCamera->getChildByName("altitudeMode")->getFirstChildElement()->setText(m_altitudeModeString);
-
- }
-
-#ifdef WITH_FANCY_CAMERA
- if (m_pCameraPlaceMark == nullptr)
- {
-
- // Placemark
- m_pCameraPlaceMark = pDoc->createNewChildElement("Placemark");
- m_pCameraPlaceMark->setAttribute("id", "Cam");
- m_pCameraPlaceMark->createNewChildElement("name")->addTextElement("Camera");
- pPoint = m_pCameraPlaceMark->createNewChildElement("Point");
- pPoint->setAttribute("id", "CamPoint");
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f", flightData.lon, flightData.lat, flightData.alt_meter);
- pPoint->createNewChildElement("coordinates")->addTextElement(temp_str);
- pPoint->createNewChildElement("altitudeMode")->addTextElement(m_altitudeModeString);
-
- // Name
- pName = m_pCameraPlaceMark->createNewChildElement("name");
- pName->addTextElement("Loxo");
-
- // Style
- pStyle = m_pCameraPlaceMark->createNewChildElement("Style");
-
- // LineStyle
- XmlElement *pLineStyle = pStyle->createNewChildElement("LineStyle");
- XmlElement *pLineColor = pLineStyle->createNewChildElement("color");
- pLineColor->addTextElement("0xff0000ff");
-
- XmlElement *pLineWidth = pLineStyle->createNewChildElement("width");
- pLineWidth->addTextElement("1");
-
- // LineString
- XmlElement *pLineString = m_pCameraPlaceMark->createNewChildElement("LineString");
- pExtrude = pLineString->createNewChildElement("extrude");
- pExtrude->addTextElement("1");
- pTesselate = pLineString->createNewChildElement("tesselate");
- pTesselate->addTextElement("1");
- pAltitudeMode = pLineString->createNewChildElement("altitudeMode");
- pAltitudeMode->addTextElement("clampToGround");
- pCoords = pLineString->createNewChildElement("coordinates");
- }
- else
- {
- const double pi = 3.14159265359;
- double r = flightData.alt_meter;
- double theta = flightData.lat/180*pi; // 0 = Equator
- double phi = flightData.lon/180*pi; // 0 = Greenwich
- double hdg = flightData.hdgTrue_deg/180*pi;
-
-
-
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f", phi/pi*180, theta/pi*180, r);
- pCoords = m_pCameraPlaceMark->getChildByName("Point")->getChildByName("coordinates");
- pCoords->deleteAllTextElements();
- pCoords->addTextElement(temp_str);
- m_pCameraPlaceMark->getChildByName("Point")->getChildByName("altitudeMode")->getFirstChildElement()->setText("clampToGround");
-
- // Coordinates
- pCoords = m_pCameraPlaceMark->getChildByName("LineString")->getChildByName("coordinates");
- if (!pCoords)
{
- pCoords = m_pCameraPlaceMark->getChildByName("LineString")->createNewChildElement("coordinates");
- }
- pCoords->deleteAllTextElements();
-
- double k = 1.0/tan(hdg);
- for (int i=0; i < 100; i++)
- {
-
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f\n", phi/pi*180, theta/pi*180, r);
- pCoords->addTextElement(temp_str);
- theta = asin(tanh(k*phi)) + flightData.lat/180*pi;
- phi += pi/10000;
+ sprintf(temp_str, "%s/%s", m_flightData.atcFlightIDStr, m_flightData.atcFlightNumStr);
}
}
-#endif
+ pName = pPlacemark->createNewChildElement("name");
+ pName->addTextElement(temp_str);
+ printf("%s\n", temp_str);
+
+ // Description
+ pDescr = pPlacemark->createNewChildElement("description");
+ sprintf(temp_str, "%s\nAltitude: %d ft, Speed: %d kts", m_flightData.atcFlightIDStr, (int)(m_flightData.alt_feet+0.5), (int)(m_flightData.gs_knots+0.5));
+ pDescr->addTextElement(temp_str);
+
+ // Style
+ pStyle = pPlacemark->createNewChildElement("Style");
+
+ // IconStyle
+ pIconStyle = pStyle->createNewChildElement("IconStyle");
+ pHeading = pIconStyle->createNewChildElement("heading");
+ pHeading->addTextElement(String(m_flightData.hdgTrue_deg));
+
+ // Icon
+ pIcon = pIconStyle->createNewChildElement("Icon");
+ pHref = pIcon->createNewChildElement("href");
+ pHref->addTextElement("root://icons/palette-2.png");
+ pY = pIcon->createNewChildElement("y");
+ pY->addTextElement("0");
+ pW = pIcon->createNewChildElement("w");
+ pW->addTextElement("32");
+ pH = pIcon->createNewChildElement("h");
+ pH->addTextElement("32");
+
+ // Point
+ pPoint = pPlacemark->createNewChildElement("Point");
+ pPoint->setAttribute("id", "Pointy");
+ pExtrude = pPoint->createNewChildElement("extrude");
+ pExtrude->addTextElement("1");
+ pTesselate = pPoint->createNewChildElement("tesselate");
+ pTesselate->addTextElement("1");
+ pAltitudeMode = pPoint->createNewChildElement("altitudeMode");
+ pAltitudeMode->addTextElement(m_altitudeModeString);
+ pCoords = pPoint->createNewChildElement("coordinates");
+ sprintf(temp_str, "%9.6f,%9.6f,%9.6f", m_flightData.lon, m_flightData.lat, m_flightData.alt_meter);
+ pCoords->addTextElement(temp_str);
+
+ return pPlacemark;
}
-void Kml::updatePath(FlightData const &flightData)
+XmlElement* Kml::createNetworkLinkControl()
+{
+ XmlElement *pNetworkLinkControl = new XmlElement("NetworkLinkControl");
+ pNetworkLinkControl->createNewChildElement("LinkName")->addTextElement("Link");
+
+ XmlElement *pCamera = pNetworkLinkControl->createNewChildElement("Camera");
+
+ pCamera->createNewChildElement("longitude")->addTextElement(String(m_flightData.lon));
+ pCamera->createNewChildElement("latitude")->addTextElement(String(m_flightData.lat));
+ pCamera->createNewChildElement("altitude")->addTextElement(String(m_flightData.alt_meter+m_cameraAlt));
+
+ if (m_cameraAutoHeading)
+ pCamera->createNewChildElement("heading")->addTextElement(String(m_flightData.hdgTrue_deg));
+ else
+ pCamera->createNewChildElement("heading")->addTextElement("0");
+
+ pCamera->createNewChildElement("tilt")->addTextElement(String(m_cameraTilt));
+
+ if (m_cameraAutoRoll)
+ pCamera->createNewChildElement("roll")->addTextElement(String(m_flightData.bank_deg));
+ else
+ pCamera->createNewChildElement("roll")->addTextElement("0");
+
+ pCamera->createNewChildElement("altitudeMode")->addTextElement(m_altitudeModeString);
+
+#if 0
+ XmlElement *pUpdate = pNetworkLinkControl->createNewChildElement("Update");
+ pUpdate->createNewChildElement("targetHref")->addTextElement("FsTrack.kml");
+ XmlElement *pChange = pUpdate->createNewChildElement("Change");
+ XmlElement *pNetworkLink = pChange->createNewChildElement("NetworkLink");
+ pNetworkLink->setAttribute("targetId", "NetworkLink_0");
+ XmlElement *pFlyToView = pNetworkLink->createNewChildElement("flyToView");
+
+ if (m_cameraFlyToView)
+ {
+ pFlyToView->addTextElement("0");
+ }
+ else
+ {
+ pFlyToView->addTextElement("1");
+ }
+#endif
+ return pNetworkLinkControl;
+}
+
+void Kml::destroy()
+{
+ m_pKml = nullptr;
+ m_pPlanePlaceMark = nullptr;
+ m_pTrackPlaceMark = nullptr;
+ m_pCameraPlaceMark = nullptr;
+}
+
+void Kml::setAltitudeMode(String const &modeString)
+{
+ m_altitudeModeString = modeString;
+
+ if (m_pPlanePlaceMark)
+ {
+ m_pPlanePlaceMark->getChildByName("Point")->getChildByName("altitudeMode")->getFirstChildElement()->setText(modeString);
+ }
+
+ if (m_pTrackPlaceMark)
+ {
+ m_pTrackPlaceMark->getChildByName("LineString")->getChildByName("altitudeMode")->getFirstChildElement()->setText(modeString);
+ }
+
+}
+
+void Kml::setPathColor(String const &colorString)
+{
+ const ScopedLock sl (m_lock);
+
+ m_pathColorString = colorString;
+
+ if (m_pTrackPlaceMark)
+ {
+ m_pTrackPlaceMark->getChildByName("Style")->getChildByName("LineStyle")->getChildByName("color")->getFirstChildElement()->setText(colorString);
+ }
+
+}
+
+void Kml::setCameraAltitude(float alt_meters)
+{
+ m_cameraAlt = alt_meters;
+}
+
+void Kml::setCameraTilt(float tilt_deg)
+{
+ m_cameraTilt = tilt_deg;
+}
+
+void Kml::setCameraFlyToView(bool enable)
+{
+ m_cameraFlyToView = enable;
+}
+
+void Kml::setCameraAutoHeading(bool enable)
+{
+ m_cameraAutoHeading = enable;
+}
+
+void Kml::setCameraAutoRoll(bool enable)
+{
+ m_cameraAutoRoll = enable;
+}
+
+XmlElement* Kml::createTrack()
{
const ScopedLock sl (m_lock);
char temp_str[1024];
- XmlElement *pDoc = kml->getChildByName("Document");
-
- XmlElement *pPlacemark = m_pPathPlaceMark;
+ XmlElement *pPlacemark;
XmlElement *pName;
XmlElement *pStyle;
XmlElement *pLineStyle;
@@ -361,63 +322,79 @@ void Kml::updatePath(FlightData const &flightData)
XmlElement *pAltitudeMode;
XmlElement *pCoords;
- if(pPlacemark == NULL)
+ // Placemark
+ pPlacemark = new XmlElement("Placemark");
+ pPlacemark->setAttribute("id", "Track_0");
+
+ // Name
+ pName = pPlacemark->createNewChildElement("name");
+ pName->addTextElement("Track");
+
+ // Style
+ pStyle = pPlacemark->createNewChildElement("Style");
+
+ // LineStyle
+ pLineStyle = pStyle->createNewChildElement("LineStyle");
+ pLineColor = pLineStyle->createNewChildElement("color");
+ pLineColor->addTextElement(m_pathColorString);
+
+ pLineWidth = pLineStyle->createNewChildElement("width");
+ pLineWidth->addTextElement("4");
+
+ // PolyStyle
+ pPolyStyle = pStyle->createNewChildElement("PolyStyle");
+ pPolyColor = pPolyStyle->createNewChildElement("color");
+ sprintf(temp_str, "%4.4X", 0x7f00ff00);
+ pPolyColor->addTextElement(temp_str);
+
+ // LineString
+ pLineString = pPlacemark->createNewChildElement("LineString");
+ pExtrude = pLineString->createNewChildElement("extrude");
+ pExtrude->addTextElement("1");
+ pTesselate = pLineString->createNewChildElement("tesselate");
+ pTesselate->addTextElement("1");
+ pAltitudeMode = pLineString->createNewChildElement("altitudeMode");
+ pAltitudeMode->addTextElement(m_altitudeModeString);
+
+ sprintf(temp_str, "\n%9.6f,%9.6f,%9.6f", m_flightData.lon, m_flightData.lat, m_flightData.alt_meter);
+ pCoords = pLineString->createNewChildElement("coordinates");
+ pCoords = pPlacemark->getChildByName("LineString")->getChildByName("coordinates");
+ pCoords->addTextElement(temp_str);
+
+ return pPlacemark;
+}
+
+void Kml::updateTrack()
+{
+ const ScopedLock sl (m_lock);
+ char temp_str[1024];
+
+ if (!m_pTrackPlaceMark)
{
- // Placemark
- pPlacemark = pDoc->createNewChildElement("Placemark");
-
- // Name
- pName = pPlacemark->createNewChildElement("name");
- pName->addTextElement("Track");
-
- // Style
- pStyle = pPlacemark->createNewChildElement("Style");
-
- // LineStyle
- pLineStyle = pStyle->createNewChildElement("LineStyle");
- pLineColor = pLineStyle->createNewChildElement("color");
- pLineColor->addTextElement(m_pathColorString);
-
- pLineWidth = pLineStyle->createNewChildElement("width");
- pLineWidth->addTextElement("4");
-
- // PolyStyle
- pPolyStyle = pStyle->createNewChildElement("PolyStyle");
- pPolyColor = pPolyStyle->createNewChildElement("color");
- sprintf(temp_str, "%4.4X", 0x7f00ff00);
- pPolyColor->addTextElement(temp_str);
-
- // LineString
- pLineString = pPlacemark->createNewChildElement("LineString");
- pExtrude = pLineString->createNewChildElement("extrude");
- pExtrude->addTextElement("1");
- pTesselate = pLineString->createNewChildElement("tesselate");
- pTesselate->addTextElement("1");
- pAltitudeMode = pLineString->createNewChildElement("altitudeMode");
- pAltitudeMode->addTextElement(m_altitudeModeString);
- pCoords = pLineString->createNewChildElement("coordinates");
- sprintf(temp_str, "%9.6f,%9.6f,%9.6f", flightData.lon, flightData.lat, flightData.alt_meter);
- pCoords->addTextElement(temp_str);
-
- m_pPathPlaceMark = pPlacemark;
- }
- else
- {
- // Coordinates
- sprintf(temp_str, "\n%9.6f,%9.6f,%9.6f", flightData.lon, flightData.lat, flightData.alt_meter);
- pCoords = pPlacemark->getChildByName("LineString")->getChildByName("coordinates");
- pCoords->addTextElement(temp_str);
+ return;
}
+ // Coordinates
+ sprintf(temp_str, "\n%9.6f,%9.6f,%9.6f", m_flightData.lon, m_flightData.lat, m_flightData.alt_meter);
+ XmlElement *pCoords = m_pTrackPlaceMark->getChildByName("LineString")->getChildByName("coordinates");
+ pCoords->addTextElement(temp_str);
}
void Kml::exportKml(const char *pPath)
{
const ScopedLock sl (m_lock);
- if (pPath && kml)
+ if (pPath && m_pKml)
{
File file(pPath);
- kml->writeToFile(file, StringRef(""));
+ ScopedPointer pPlane = createPlane();
+ ScopedPointer pNetworkLinkcontrol = createNetworkLinkControl();
+ m_pKml->addChildElement(pNetworkLinkcontrol);
+ m_pKml->getChildByName("Document")->addChildElement(pPlane);
+ m_pKml->getChildByName("Document")->addChildElement(m_pTrackPlaceMark);
+ m_pKml->writeToFile(file, StringRef(""));
+ m_pKml->removeChildElement(pNetworkLinkcontrol, false);
+ m_pKml->getChildByName("Document")->removeChildElement(pPlane, false);
+ m_pKml->getChildByName("Document")->removeChildElement(m_pTrackPlaceMark, false);
}
}
@@ -426,27 +403,27 @@ void Kml::exportKmz(const char *pPath)
// ToDo: add Compression if available in Juce
const ScopedLock sl (m_lock);
- if (pPath && kml)
+ if (pPath && m_pKml)
{
File file(pPath);
file.deleteFile();
ScopedPointer pStream = file.createOutputStream();
- kml->writeToStream(*pStream, StringRef(""));
+ m_pKml->writeToStream(*pStream, StringRef(""));
pStream = nullptr;
}
}
void Kml::onUpdate(const char *pPath, ViewFormat const &viewFormat)
{
- if (kml == nullptr)
+ if (m_pKml == nullptr)
return;
// LookAt
- XmlElement *pCamera;
+// XmlElement *pCamera;
- pCamera = kml->getChildByName("NetworkLinkControl")->getChildByName("Camera");
+// pCamera = m_pKml->getChildByName("NetworkLinkControl")->getChildByName("Camera");
if (viewFormat.has_camera)
{
@@ -462,6 +439,6 @@ void Kml::onUpdate(const char *pPath, ViewFormat const &viewFormat)
// pCamera->getChildByName("altitudeMode")->getFirstChildElement()->setText(m_altitudeModeString);
}
- exportKmz(pPath);
+ exportKml(pPath);
}
diff --git a/Source/Kml.hpp b/Source/Kml.hpp
index 634e921..7621cf8 100644
--- a/Source/Kml.hpp
+++ b/Source/Kml.hpp
@@ -11,18 +11,20 @@ public:
Kml(const char *pDocRoot);
~Kml(void);
+ void createNetworkLinkFile(String const &filename, String const &hostIp);
void setAltitudeMode(String const &modeString);
void setPathColor(String const &colorString);
void setCameraAltitude(float alt_meters);
void setCameraTilt(float tilt_deg);
void setCameraAutoHeading(bool enable);
void setCameraAutoRoll(bool enable);
-
+ void setCameraFlyToView(bool enable);
+
private:
CriticalSection m_lock;
- ScopedPointer kml;
+ ScopedPointer m_pKml;
XmlElement *m_pPlanePlaceMark;
- XmlElement *m_pPathPlaceMark;
+ XmlElement *m_pTrackPlaceMark;
XmlElement *m_pCameraPlaceMark;
char m_path[1024];
const char *m_docRoot;
@@ -32,15 +34,22 @@ private:
float m_cameraTilt;
bool m_cameraAutoHeading;
bool m_cameraAutoRoll;
+ bool m_cameraFlyToView;
+ FlightData m_flightData;
void create();
void destroy();
const char* getPath();
+ void updateFlightData(FlightData const &flightData);
void update(FlightData const &flightData);
void exportKml(const char *pPath);
void exportKmz(const char *pPath);
- void updatePlane(FlightData const &flightData);
- void updatePath(FlightData const &flightData);
+ void updatePlane();
+ void updateTrack();
void onUpdate(const char *pPath, ViewFormat const &viewFormat);
+
+ XmlElement* createNetworkLinkControl();
+ XmlElement* createPlane();
+ XmlElement* createTrack();
};
#endif // !KML_HPP
diff --git a/Source/Main.cpp b/Source/Main.cpp
index b344b8e..07a2ee6 100644
--- a/Source/Main.cpp
+++ b/Source/Main.cpp
@@ -23,8 +23,9 @@ public:
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
- static void getNetworkAdapters()
+ static String getNetworkAdapters()
{
+ String hostIp("0.0.0.0");
PIP_ADAPTER_INFO pAdapterInfo;
pAdapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof(IP_ADAPTER_INFO));
ULONG buflen = sizeof(IP_ADAPTER_INFO);
@@ -51,6 +52,7 @@ public:
printf("\tDHCP Enabled: Yes\n");
printf("\t\tDHCP Server: \t%s\n", pAdapter->DhcpServer.IpAddress.String);
printf("\tLease Obtained: %ld\n", pAdapter->LeaseObtained);
+ hostIp = String(pAdapter->IpAddressList.IpAddress.String);
} else {
printf("\tDHCP Enabled: No\n");
}
@@ -69,6 +71,7 @@ public:
{
printf("Call to GetAdaptersInfo failed.\n");
}
+ return hostIp;
}
//==============================================================================
void initialise (const String& commandLine) override
@@ -114,7 +117,7 @@ public:
Colours::lightgrey,
DocumentWindow::allButtons)
{
- FsTrackApplication::getNetworkAdapters();
+ String hostIp = FsTrackApplication::getNetworkAdapters();
char path[1024];
if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_DESKTOP, nullptr, 0, path)))
@@ -122,7 +125,7 @@ public:
return;
}
static String pathStr(path);
- setContentOwned (new MainComponent(pathStr), true);
+ setContentOwned (new MainComponent(pathStr, hostIp), true);
centreWithSize (getWidth(), getHeight());
setVisible (true);
diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp
index 725beaa..cfc961f 100644
--- a/Source/MainComponent.cpp
+++ b/Source/MainComponent.cpp
@@ -27,7 +27,7 @@
//[/MiscUserDefs]
//==============================================================================
-MainComponent::MainComponent (String const &homeDir)
+MainComponent::MainComponent (String const &homeDir, String const &hostIp)
{
addAndMakeVisible (m_fsuipcStatus = new Label ("FSUIP Status",
TRANS("Unknown")));
@@ -47,40 +47,18 @@ MainComponent::MainComponent (String const &homeDir)
m_flightStatus->setColour (TextEditor::textColourId, Colours::black);
m_flightStatus->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
- addAndMakeVisible (m_kmlUpdInterval_s = new Slider ("KML Update Interval"));
- m_kmlUpdInterval_s->setTooltip (TRANS("KML Update Interval"));
- m_kmlUpdInterval_s->setRange (0.1, 10, 0.1);
- m_kmlUpdInterval_s->setSliderStyle (Slider::LinearHorizontal);
- m_kmlUpdInterval_s->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
- m_kmlUpdInterval_s->addListener (this);
-
- addAndMakeVisible (m_colorSelector = new ColourSelector());
- m_colorSelector->setName ("Color Selector");
-
- addAndMakeVisible (m_altitudeMode = new ComboBox ("Altitude Mode"));
- m_altitudeMode->setTooltip (TRANS("Altitude Mode"));
- m_altitudeMode->setEditableText (false);
- m_altitudeMode->setJustificationType (Justification::centredLeft);
- m_altitudeMode->setTextWhenNothingSelected (String::empty);
- m_altitudeMode->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
- m_altitudeMode->addItem (TRANS("absolute"), 1);
- m_altitudeMode->addItem (TRANS("relativeToGround"), 2);
- m_altitudeMode->addItem (TRANS("clampToGround"), 3);
- m_altitudeMode->addSeparator();
- m_altitudeMode->addListener (this);
-
addAndMakeVisible (m_cameraAltitude = new Slider ("Camera Altitude"));
m_cameraAltitude->setTooltip (TRANS("Camera Altitude"));
- m_cameraAltitude->setRange (0, 1e+007, 100);
+ m_cameraAltitude->setRange (0.1, 7, 0.01);
m_cameraAltitude->setSliderStyle (Slider::LinearHorizontal);
- m_cameraAltitude->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
+ m_cameraAltitude->setTextBoxStyle (Slider::NoTextBox, false, 80, 20);
m_cameraAltitude->addListener (this);
addAndMakeVisible (m_CameraTilt = new Slider ("Camera Tilt"));
m_CameraTilt->setTooltip (TRANS("Camera Tilt"));
m_CameraTilt->setRange (0, 90, 5);
m_CameraTilt->setSliderStyle (Slider::LinearHorizontal);
- m_CameraTilt->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
+ m_CameraTilt->setTextBoxStyle (Slider::NoTextBox, false, 80, 20);
m_CameraTilt->addListener (this);
addAndMakeVisible (m_cameraAutoHeadingEnable = new ToggleButton ("Camera Auto Heading"));
@@ -91,11 +69,35 @@ MainComponent::MainComponent (String const &homeDir)
m_cameraAutoRollEnable->setTooltip (TRANS("Camera Auto Roll"));
m_cameraAutoRollEnable->addListener (this);
+ addAndMakeVisible (m_cameraAutoFlyToView = new ToggleButton ("Camera Auto FlyToView"));
+ m_cameraAutoFlyToView->setTooltip (TRANS("Camera Auto FlyToView"));
+ m_cameraAutoFlyToView->addListener (this);
+
+ addAndMakeVisible (m_labelCameraAltitude = new Label ("Camera Altitude",
+ TRANS("0")));
+ m_labelCameraAltitude->setTooltip (TRANS("Camera Altitude in meter"));
+ m_labelCameraAltitude->setFont (Font (15.00f, Font::plain));
+ m_labelCameraAltitude->setJustificationType (Justification::centredRight);
+ m_labelCameraAltitude->setEditable (true, true, false);
+ m_labelCameraAltitude->setColour (TextEditor::textColourId, Colours::black);
+ m_labelCameraAltitude->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
+ m_labelCameraAltitude->addListener (this);
+
+ addAndMakeVisible (m_labelCameraTilt = new Label ("Camera Tilt",
+ TRANS("0")));
+ m_labelCameraTilt->setTooltip (TRANS("Camera Tilt in degrees"));
+ m_labelCameraTilt->setFont (Font (15.00f, Font::plain));
+ m_labelCameraTilt->setJustificationType (Justification::centredRight);
+ m_labelCameraTilt->setEditable (true, true, false);
+ m_labelCameraTilt->setColour (TextEditor::textColourId, Colours::black);
+ m_labelCameraTilt->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
+ m_labelCameraTilt->addListener (this);
+
//[UserPreSize]
//[/UserPreSize]
- setSize (400, 300);
+ setSize (300, 300);
//[Constructor] You can add your own custom stuff here..
@@ -115,14 +117,12 @@ MainComponent::MainComponent (String const &homeDir)
m_httpServer = new HttpServer(5001, workDir.getCharPointer());
m_httpServer->addListener(m_kml);
- m_kmlUpdInterval_s->setValue(1.0, juce::NotificationType::sendNotification);
-
- m_colorSelector->addChangeListener(this);
- m_colorSelector->setCurrentColour(juce::Colours::yellow);
-
- m_altitudeMode->setSelectedId(1, juce::NotificationType::sendNotification);
m_cameraAltitude->setValue(10000, juce::NotificationType::sendNotification);
m_CameraTilt->setValue(0, juce::NotificationType::sendNotification);
+ m_cameraAutoFlyToView->setToggleState(true, juce::NotificationType::sendNotification);
+ m_labelCameraAltitude->setText("1000", juce::NotificationType::sendNotification);
+ m_kml->createNetworkLinkFile(workDir + String("\\FsTrack.kml"), hostIp);
+ m_fsLink->setUpdateInterval(1.0);
//[/Constructor]
}
@@ -137,13 +137,13 @@ MainComponent::~MainComponent()
m_fsuipcStatus = nullptr;
m_flightStatus = nullptr;
- m_kmlUpdInterval_s = nullptr;
- m_colorSelector = nullptr;
- m_altitudeMode = nullptr;
m_cameraAltitude = nullptr;
m_CameraTilt = nullptr;
m_cameraAutoHeadingEnable = nullptr;
m_cameraAutoRollEnable = nullptr;
+ m_cameraAutoFlyToView = nullptr;
+ m_labelCameraAltitude = nullptr;
+ m_labelCameraTilt = nullptr;
//[Destructor]. You can add your own custom destruction code here..
@@ -158,21 +158,33 @@ void MainComponent::paint (Graphics& g)
g.fillAll (Colours::white);
+ g.setColour (Colours::black);
+ g.setFont (Font (15.00f, Font::plain));
+ g.drawText (TRANS("[m]"),
+ 265, 32, 23, 24,
+ Justification::centredLeft, true);
+
+ g.setColour (Colours::black);
+ g.setFont (Font (15.00f, Font::plain));
+ g.drawText (CharPointer_UTF8 ("[\xc2\xb0]"),
+ 265, 64, 23, 24,
+ Justification::centredLeft, true);
+
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
void MainComponent::resized()
{
- m_fsuipcStatus->setBounds (16, 264, 150, 24);
- m_flightStatus->setBounds (216, 264, 150, 24);
- m_kmlUpdInterval_s->setBounds (24, 232, 160, 24);
- m_colorSelector->setBounds (24, 24, 168, 192);
- m_altitudeMode->setBounds (216, 32, 160, 24);
- m_cameraAltitude->setBounds (216, 80, 160, 24);
- m_CameraTilt->setBounds (216, 120, 160, 24);
- m_cameraAutoHeadingEnable->setBounds (216, 160, 150, 24);
- m_cameraAutoRollEnable->setBounds (216, 192, 150, 24);
+ m_fsuipcStatus->setBounds (16, 256, 120, 24);
+ m_flightStatus->setBounds (160, 256, 120, 24);
+ m_cameraAltitude->setBounds (24, 32, 144, 24);
+ m_CameraTilt->setBounds (24, 64, 144, 24);
+ m_cameraAutoHeadingEnable->setBounds (24, 104, 176, 24);
+ m_cameraAutoRollEnable->setBounds (24, 136, 176, 24);
+ m_cameraAutoFlyToView->setBounds (24, 168, 176, 24);
+ m_labelCameraAltitude->setBounds (176, 32, 88, 24);
+ m_labelCameraTilt->setBounds (176, 64, 88, 24);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
@@ -182,22 +194,18 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
//[UsersliderValueChanged_Pre]
//[/UsersliderValueChanged_Pre]
- if (sliderThatWasMoved == m_kmlUpdInterval_s)
- {
- //[UserSliderCode_m_kmlUpdInterval_s] -- add your slider handling code here..
- m_fsLink->setUpdateInterval(sliderThatWasMoved->getValue());
- //[/UserSliderCode_m_kmlUpdInterval_s]
- }
- else if (sliderThatWasMoved == m_cameraAltitude)
+ if (sliderThatWasMoved == m_cameraAltitude)
{
//[UserSliderCode_m_cameraAltitude] -- add your slider handling code here..
- m_kml->setCameraAltitude(sliderThatWasMoved->getValue());
+ String s = String((int)std::pow(10.0, sliderThatWasMoved->getValue()));
+ m_labelCameraAltitude->setText(s, juce::NotificationType::sendNotification);
//[/UserSliderCode_m_cameraAltitude]
}
else if (sliderThatWasMoved == m_CameraTilt)
{
//[UserSliderCode_m_CameraTilt] -- add your slider handling code here..
- m_kml->setCameraTilt(sliderThatWasMoved->getValue());
+ String s = String((int)sliderThatWasMoved->getValue());
+ m_labelCameraTilt->setText(s, juce::NotificationType::sendNotification);
//[/UserSliderCode_m_CameraTilt]
}
@@ -205,22 +213,6 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
//[/UsersliderValueChanged_Post]
}
-void MainComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
-{
- //[UsercomboBoxChanged_Pre]
- //[/UsercomboBoxChanged_Pre]
-
- if (comboBoxThatHasChanged == m_altitudeMode)
- {
- //[UserComboBoxCode_m_altitudeMode] -- add your combo box handling code here..
- m_kml->setAltitudeMode(comboBoxThatHasChanged->getItemText(comboBoxThatHasChanged->getSelectedItemIndex()));
- //[/UserComboBoxCode_m_altitudeMode]
- }
-
- //[UsercomboBoxChanged_Post]
- //[/UsercomboBoxChanged_Post]
-}
-
void MainComponent::buttonClicked (Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
@@ -238,11 +230,41 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
m_kml->setCameraAutoRoll(buttonThatWasClicked->getToggleState());
//[/UserButtonCode_m_cameraAutoRollEnable]
}
+ else if (buttonThatWasClicked == m_cameraAutoFlyToView)
+ {
+ //[UserButtonCode_m_cameraAutoFlyToView] -- add your button handler code here..
+ m_kml->setCameraFlyToView(buttonThatWasClicked->getToggleState());
+ //[/UserButtonCode_m_cameraAutoFlyToView]
+ }
//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
}
+void MainComponent::labelTextChanged (Label* labelThatHasChanged)
+{
+ //[UserlabelTextChanged_Pre]
+ //[/UserlabelTextChanged_Pre]
+
+ if (labelThatHasChanged == m_labelCameraAltitude)
+ {
+ //[UserLabelCode_m_labelCameraAltitude] -- add your label text handling code here..
+ m_kml->setCameraAltitude(labelThatHasChanged->getText().getFloatValue());
+ m_cameraAltitude->setValue(std::log10(1+labelThatHasChanged->getText().getFloatValue()));
+ //[/UserLabelCode_m_labelCameraAltitude]
+ }
+ else if (labelThatHasChanged == m_labelCameraTilt)
+ {
+ //[UserLabelCode_m_labelCameraTilt] -- add your label text handling code here..
+ m_kml->setCameraTilt(labelThatHasChanged->getText().getFloatValue());
+ m_CameraTilt->setValue(labelThatHasChanged->getText().getFloatValue());
+ //[/UserLabelCode_m_labelCameraTilt]
+ }
+
+ //[UserlabelTextChanged_Post]
+ //[/UserlabelTextChanged_Post]
+}
+
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
@@ -259,11 +281,6 @@ void MainComponent::onDataChanged(IFsLink &obj)
void MainComponent::changeListenerCallback(juce::ChangeBroadcaster *source)
{
- if (m_colorSelector == source)
- {
- ColourSelector &obj = (ColourSelector&)*source;
- m_kml->setPathColor(String(obj.getCurrentColour().fromRGBA(obj.getCurrentColour().getBlue(), obj.getCurrentColour().getGreen(), obj.getCurrentColour().getRed(), obj.getCurrentColour().getAlpha()).toString()));
- }
}
//[/MiscUserCode]
@@ -280,48 +297,56 @@ BEGIN_JUCER_METADATA
-
+ constructorParams="String const &homeDir, String const &hostIp"
+ variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
+ overlayOpacity="0.330" fixedSize="1" initialWidth="300" initialHeight="300">
+
+
+
+
-
-
-
+ virtualName="" explicitFocusOrder="0" pos="24 32 144 24" tooltip="Camera Altitude"
+ min="0.10000000000000001" max="7" int="0.01" style="LinearHorizontal"
+ textBoxPos="NoTextBox" textBoxEditable="1" textBoxWidth="80"
+ textBoxHeight="20" skewFactor="1"/>
+
+
+
END_JUCER_METADATA
diff --git a/Source/MainComponent.h b/Source/MainComponent.h
index eec778c..d72b868 100644
--- a/Source/MainComponent.h
+++ b/Source/MainComponent.h
@@ -41,12 +41,12 @@ class MainComponent : public Component,
public IFsLinkListener,
public ChangeListener,
public SliderListener,
- public ComboBoxListener,
- public ButtonListener
+ public ButtonListener,
+ public LabelListener
{
public:
//==============================================================================
- MainComponent (String const &homeDir);
+ MainComponent (String const &homeDir, String const &hostIp);
~MainComponent();
//==============================================================================
@@ -56,8 +56,8 @@ public:
void paint (Graphics& g);
void resized();
void sliderValueChanged (Slider* sliderThatWasMoved);
- void comboBoxChanged (ComboBox* comboBoxThatHasChanged);
void buttonClicked (Button* buttonThatWasClicked);
+ void labelTextChanged (Label* labelThatHasChanged);
@@ -76,13 +76,13 @@ private:
//==============================================================================
ScopedPointer