Files
FsTrack/Source/MainComponent.cpp
T
jens 176b4224e3 - reorganized Kml generation
- Kml generation on demand
- cleaned up GUI
  - removed color selector
  - remove track rate slider
  - adjusted altitude slider


git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@175 b431acfa-c32f-4a4a-93f1-934dc6c82436
2015-01-30 19:18:10 +00:00

359 lines
16 KiB
C++

/*
==============================================================================
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::centredLeft);
m_fsuipcStatus->setEditable (false, false, false);
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::centredLeft);
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]"),
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, 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]
}
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)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());
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);
}
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
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
parentClasses="public Component, public IFsLinkListener, public ChangeListener"
constructorParams="String const &amp;homeDir, String const &amp;hostIp"
variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
overlayOpacity="0.330" fixedSize="1" initialWidth="300" initialHeight="300">
<BACKGROUND backgroundColour="ffffffff">
<TEXT pos="265 32 23 24" fill="solid: ff000000" hasStroke="0" text="[m]"
fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/>
<TEXT pos="265 64 23 24" fill="solid: ff000000" hasStroke="0" text="[&#176;]"
fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/>
</BACKGROUND>
<LABEL name="FSUIP Status" id="a891503ff0f699d7" memberName="m_fsuipcStatus"
virtualName="" explicitFocusOrder="0" pos="16 256 120 24" tooltip="FSUIP Status"
edTextCol="ff000000" edBkgCol="0" labelText="Unknown" editableSingleClick="0"
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="33"/>
<LABEL name="Flight Status" id="2a046c84c0638c1f" memberName="m_flightStatus"
virtualName="" explicitFocusOrder="0" pos="160 256 120 24" tooltip="Flight Status"
edTextCol="ff000000" edBkgCol="0" labelText="Unknown" editableSingleClick="0"
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="33"/>
<SLIDER name="Camera Altitude" id="3352cbc6aebbcc9e" memberName="m_cameraAltitude"
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"/>
<SLIDER name="Camera Tilt" id="4993af2027f11be1" memberName="m_CameraTilt"
virtualName="" explicitFocusOrder="0" pos="24 64 144 24" tooltip="Camera Tilt"
min="0" max="90" int="5" style="LinearHorizontal" textBoxPos="NoTextBox"
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
<TOGGLEBUTTON name="Camera Auto Heading" id="97a6fc7c399da63d" memberName="m_cameraAutoHeadingEnable"
virtualName="" explicitFocusOrder="0" pos="24 104 176 24" tooltip="Camera Auto Heading"
buttonText="Camera Auto Heading" connectedEdges="0" needsCallback="1"
radioGroupId="0" state="0"/>
<TOGGLEBUTTON name="Camera Auto Roll" id="cc847f94257e9212" memberName="m_cameraAutoRollEnable"
virtualName="" explicitFocusOrder="0" pos="24 136 176 24" tooltip="Camera Auto Roll"
buttonText="Camera Auto Roll" connectedEdges="0" needsCallback="1"
radioGroupId="0" state="0"/>
<TOGGLEBUTTON name="Camera Auto FlyToView" id="7c8f89a74ece3ccb" memberName="m_cameraAutoFlyToView"
virtualName="" explicitFocusOrder="0" pos="24 168 176 24" tooltip="Camera Auto FlyToView"
buttonText="Camera Auto FlyToView" connectedEdges="0" needsCallback="1"
radioGroupId="0" state="0"/>
<LABEL name="Camera Altitude" id="22b0982961c62c7f" memberName="m_labelCameraAltitude"
virtualName="" explicitFocusOrder="0" pos="176 32 88 24" tooltip="Camera Altitude in meter"
edTextCol="ff000000" edBkgCol="0" labelText="0" editableSingleClick="1"
editableDoubleClick="1" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="34"/>
<LABEL name="Camera Tilt" id="a2fedc79e61668d0" memberName="m_labelCameraTilt"
virtualName="" explicitFocusOrder="0" pos="176 64 88 24" tooltip="Camera Tilt in degrees"
edTextCol="ff000000" edBkgCol="0" labelText="0" editableSingleClick="1"
editableDoubleClick="1" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="34"/>
</JUCER_COMPONENT>
END_JUCER_METADATA
*/
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]