/* ============================================================================== This is an automatically generated GUI class created by the Introjucer! Be careful when adding custom code to these files, as only the code within the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded and re-saved. Created with Introjucer version: 3.1.0 ------------------------------------------------------------------------------ The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-13 by Raw Material Software Ltd. ============================================================================== */ //[Headers] You can add your own extra header files here... //[/Headers] #include "MainComponent.h" //[MiscUserDefs] You can add your own user definitions and misc code here... //[/MiscUserDefs] //============================================================================== MainComponent::MainComponent (String const &homeDir, String const &hostIp) { addAndMakeVisible (m_fsuipcStatus = new Label ("FSUIP Status", TRANS("Unknown"))); m_fsuipcStatus->setTooltip (TRANS("FSUIP Status")); m_fsuipcStatus->setFont (Font (15.00f, Font::plain)); 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)); addAndMakeVisible (m_flightStatus = new Label ("Flight Status", TRANS("Unknown"))); m_flightStatus->setTooltip (TRANS("Flight Status")); m_flightStatus->setFont (Font (15.00f, Font::plain)); 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)); addAndMakeVisible (m_cameraAltitude = new Slider ("Camera Altitude")); m_cameraAltitude->setTooltip (TRANS("Camera Altitude")); m_cameraAltitude->setRange (0.1, 7, 0.01); m_cameraAltitude->setSliderStyle (Slider::LinearHorizontal); 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::NoTextBox, false, 80, 20); m_CameraTilt->addListener (this); addAndMakeVisible (m_cameraAutoHeadingEnable = new ToggleButton ("Camera Auto Heading")); m_cameraAutoHeadingEnable->setTooltip (TRANS("Camera Auto Heading")); m_cameraAutoHeadingEnable->addListener (this); addAndMakeVisible (m_cameraAutoRollEnable = new ToggleButton ("Camera Auto Roll")); 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 (300, 300); //[Constructor] You can add your own custom stuff here.. m_toolTip = new TooltipWindow(this); static String workDir(homeDir + String("\\FsTrack")); File file(workDir); file.createDirectory(); m_kml = new Kml(workDir.getCharPointer()); m_fsLink = new FsLink(workDir.getCharPointer()); m_fsLink->addListener(this); m_fsLink->setKml(m_kml); m_httpServer = new HttpServer(5001, workDir.getCharPointer()); m_httpServer->addListener(m_kml); 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] } MainComponent::~MainComponent() { //[Destructor_pre]. You can add your own custom destruction code here.. m_toolTip = nullptr; m_kml = nullptr; m_fsLink = nullptr; m_httpServer = nullptr; //[/Destructor_pre] m_fsuipcStatus = nullptr; m_flightStatus = 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.. //[/Destructor] } //============================================================================== void MainComponent::paint (Graphics& g) { //[UserPrePaint] Add your own custom painting code here.. //[/UserPrePaint] g.fillAll (Colours::white); g.setColour (Colours::black); g.setFont (Font (15.00f, Font::plain)); g.drawText (TRANS("[m]"), 257, 32, 23, 24, Justification::centredLeft, true); g.setColour (Colours::black); g.setFont (Font (15.00f, Font::plain)); g.drawText (CharPointer_UTF8 ("[\xc2\xb0]"), 257, 64, 23, 24, Justification::centredLeft, true); //[UserPaint] Add your own custom painting code here.. //[/UserPaint] } void MainComponent::resized() { 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, 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] } void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved) { //[UsersliderValueChanged_Pre] //[/UsersliderValueChanged_Pre] if (sliderThatWasMoved == m_cameraAltitude) { //[UserSliderCode_m_cameraAltitude] -- add your slider handling code here.. 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)(0.5+sliderThatWasMoved->getValue())); m_labelCameraTilt->setText(s, juce::NotificationType::sendNotification); //[/UserSliderCode_m_CameraTilt] } //[UsersliderValueChanged_Post] //[/UsersliderValueChanged_Post] } void MainComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == m_cameraAutoHeadingEnable) { //[UserButtonCode_m_cameraAutoHeadingEnable] -- add your button handler code here.. m_kml->setCameraAutoHeading(buttonThatWasClicked->getToggleState()); //[/UserButtonCode_m_cameraAutoHeadingEnable] } else if (buttonThatWasClicked == m_cameraAutoRollEnable) { //[UserButtonCode_m_cameraAutoRollEnable] -- add your button handler code here.. 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... 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) { (void)obj; } void MainComponent::changeListenerCallback(juce::ChangeBroadcaster *source) { } //[/MiscUserCode] //============================================================================== #if 0 /* -- Introjucer information section -- This is where the Introjucer stores the metadata that describe this GUI layout, so make changes in here at your peril! BEGIN_JUCER_METADATA END_JUCER_METADATA */ #endif //[EndFile] You can add extra defines here... //[/EndFile]