From c53f945a47c4cbe2d48e0f198eaf34e1f05de985 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 30 Jan 2015 20:30:40 +0000 Subject: [PATCH] - fixed flightstate in disconnected mode - added heading to description git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@176 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/FsLink.cpp | 4 +- Source/Kml.cpp | 2 +- Source/MainComponent.cpp | 88 ++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/Source/FsLink.cpp b/Source/FsLink.cpp index 7648ad4..d3a6d09 100644 --- a/Source/FsLink.cpp +++ b/Source/FsLink.cpp @@ -252,6 +252,9 @@ void FsLink::timerCallback() switch(m_flightState) { case fs_suspend: + if (m_linkState == ls_disconnected) + break; + if (!m_flightData.isFsDialog && !m_flightData.isReplay) { m_flightStateNext = fs_ground; @@ -311,7 +314,6 @@ void FsLink::timerCallback() m_listeners.call(&IFsLinkListener::onDataChanged, *this); m_pKml->updateFlightData(m_flightData); -// m_pKml->updatePlane(m_flightData); if (m_kmlUpdateCount > 0) { m_kmlUpdateCount--; diff --git a/Source/Kml.cpp b/Source/Kml.cpp index f3bf16d..559a714 100644 --- a/Source/Kml.cpp +++ b/Source/Kml.cpp @@ -156,7 +156,7 @@ XmlElement* Kml::createPlane() // 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)); + sprintf(temp_str, "Altitude: %d ft
Ground speed: %d kts
Heading: %d degrees", (int)(m_flightData.alt_feet+0.5), (int)(m_flightData.gs_knots+0.5), (int)(m_flightData.hdgTrue_deg+0.5)); pDescr->addTextElement(temp_str); // Style diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index cfc961f..5d57c2d 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -33,8 +33,9 @@ MainComponent::MainComponent (String const &homeDir, String const &hostIp) TRANS("Unknown"))); m_fsuipcStatus->setTooltip (TRANS("FSUIP Status")); m_fsuipcStatus->setFont (Font (15.00f, Font::plain)); - m_fsuipcStatus->setJustificationType (Justification::centredLeft); + m_fsuipcStatus->setJustificationType (Justification::centred); m_fsuipcStatus->setEditable (false, false, false); + m_fsuipcStatus->setColour (Label::backgroundColourId, Colour (0x00000000)); m_fsuipcStatus->setColour (TextEditor::textColourId, Colours::black); m_fsuipcStatus->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); @@ -42,7 +43,7 @@ MainComponent::MainComponent (String const &homeDir, String const &hostIp) TRANS("Unknown"))); m_flightStatus->setTooltip (TRANS("Flight Status")); m_flightStatus->setFont (Font (15.00f, Font::plain)); - m_flightStatus->setJustificationType (Justification::centredLeft); + m_flightStatus->setJustificationType (Justification::centred); m_flightStatus->setEditable (false, false, false); m_flightStatus->setColour (TextEditor::textColourId, Colours::black); m_flightStatus->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); @@ -161,13 +162,13 @@ void MainComponent::paint (Graphics& g) g.setColour (Colours::black); g.setFont (Font (15.00f, Font::plain)); g.drawText (TRANS("[m]"), - 265, 32, 23, 24, + 257, 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, + 257, 64, 23, 24, Justification::centredLeft, true); //[UserPaint] Add your own custom painting code here.. @@ -176,15 +177,15 @@ void MainComponent::paint (Graphics& g) void MainComponent::resized() { - m_fsuipcStatus->setBounds (16, 256, 120, 24); - m_flightStatus->setBounds (160, 256, 120, 24); + m_fsuipcStatus->setBounds (24, 232, 104, 40); + m_flightStatus->setBounds (168, 232, 104, 40); 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); + m_cameraAutoHeadingEnable->setBounds (24, 112, 176, 24); + m_cameraAutoRollEnable->setBounds (24, 144, 176, 24); + m_cameraAutoFlyToView->setBounds (24, 176, 176, 24); + m_labelCameraAltitude->setBounds (168, 32, 88, 24); + m_labelCameraTilt->setBounds (168, 64, 88, 24); //[UserResized] Add your own custom resize handling here.. //[/UserResized] } @@ -197,14 +198,14 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved) if (sliderThatWasMoved == m_cameraAltitude) { //[UserSliderCode_m_cameraAltitude] -- add your slider handling code here.. - String s = String((int)std::pow(10.0, sliderThatWasMoved->getValue())); + String s = String((int)(0.5+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.. - String s = String((int)sliderThatWasMoved->getValue()); + String s = String((int)(0.5+sliderThatWasMoved->getValue())); m_labelCameraTilt->setText(s, juce::NotificationType::sendNotification); //[/UserSliderCode_m_CameraTilt] } @@ -272,6 +273,41 @@ void MainComponent::onStateChanged(IFsLink &obj) { m_fsuipcStatus->setText(obj.getLinkState(), juce::sendNotification); m_flightStatus->setText(obj.getFlightState(), juce::sendNotification); + + Colour c = juce::Colours::red; + float alpha = 0.5f; + if (String(obj.getLinkState()) == String("Connected")) + { + c = juce::Colours::blue; + } + else if (String(obj.getLinkState()) == String("Paused")) + { + c = juce::Colours::orange; + } + else if (String(obj.getLinkState()) == String("Recording")) + { + c = juce::Colours::limegreen; + } + m_fsuipcStatus->setColour (Label::backgroundColourId, c.withAlpha(alpha)); + + c = juce::Colours::red; + if (String(obj.getFlightState()) == String("Ground")) + { + c = juce::Colours::brown; + } + else if (String(obj.getFlightState()) == String("Touch down")) + { + c = juce::Colours::brown; + } + else if (String(obj.getFlightState()) == String("Take off")) + { + c = juce::Colours::skyblue; + } + else if (String(obj.getFlightState()) == String("Enroute")) + { + c = juce::Colours::skyblue; + } + m_flightStatus->setColour (Label::backgroundColourId, c.withAlpha(alpha)); } void MainComponent::onDataChanged(IFsLink &obj) @@ -301,21 +337,21 @@ BEGIN_JUCER_METADATA variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1" initialWidth="300" initialHeight="300"> - -