- color and altitude mode can be changed from GUI
git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@126 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+35
-5
@@ -10,6 +10,8 @@ Kml::Kml(const char *pDocRoot)
|
||||
, m_pPlanePlaceMark(nullptr)
|
||||
, m_pPathPlaceMark(nullptr)
|
||||
, m_docRoot(pDocRoot)
|
||||
, m_altitudeModeString("absolute")
|
||||
, m_pathColorString("0xff00ffff")
|
||||
{
|
||||
memset(m_path, 0, sizeof(m_path));
|
||||
}
|
||||
@@ -60,6 +62,35 @@ void Kml::destroy()
|
||||
m_pPathPlaceMark = 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)
|
||||
{
|
||||
const ScopedLock sl (m_lock);
|
||||
|
||||
m_pathColorString = colorString;
|
||||
|
||||
if (m_pPathPlaceMark)
|
||||
{
|
||||
m_pPathPlaceMark->getChildByName("Style")->getChildByName("LineStyle")->getChildByName("color")->getFirstChildElement()->setText(colorString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Kml::update(FlightData const &flightData)
|
||||
{
|
||||
const ScopedLock sl (m_lock);
|
||||
@@ -143,7 +174,7 @@ void Kml::updatePlane(FlightData const &flightData)
|
||||
pTesselate = pPoint->createNewChildElement("tesselate");
|
||||
pTesselate->addTextElement("1");
|
||||
pAltitudeMode = pPoint->createNewChildElement("altitudeMode");
|
||||
pAltitudeMode->addTextElement("absolute");
|
||||
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);
|
||||
@@ -206,8 +237,7 @@ void Kml::updatePath(FlightData const &flightData)
|
||||
// LineStyle
|
||||
pLineStyle = pStyle->createNewChildElement("LineStyle");
|
||||
pLineColor = pLineStyle->createNewChildElement("color");
|
||||
sprintf(temp_str, "%4.4X\n", 0xff00ffff);
|
||||
pLineColor->addTextElement(temp_str);
|
||||
pLineColor->addTextElement(m_pathColorString);
|
||||
|
||||
pLineWidth = pLineStyle->createNewChildElement("width");
|
||||
pLineWidth->addTextElement("4");
|
||||
@@ -215,7 +245,7 @@ void Kml::updatePath(FlightData const &flightData)
|
||||
// PolyStyle
|
||||
pPolyStyle = pStyle->createNewChildElement("PolyStyle");
|
||||
pPolyColor = pPolyStyle->createNewChildElement("color");
|
||||
sprintf(temp_str, "%4.4X\n", 0x7f00ff00);
|
||||
sprintf(temp_str, "%4.4X", 0x7f00ff00);
|
||||
pPolyColor->addTextElement(temp_str);
|
||||
|
||||
// LineString
|
||||
@@ -225,7 +255,7 @@ void Kml::updatePath(FlightData const &flightData)
|
||||
pTesselate = pLineString->createNewChildElement("tesselate");
|
||||
pTesselate->addTextElement("1");
|
||||
pAltitudeMode = pLineString->createNewChildElement("altitudeMode");
|
||||
pAltitudeMode->addTextElement("absolute");
|
||||
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);
|
||||
|
||||
@@ -11,6 +11,9 @@ public:
|
||||
Kml(const char *pDocRoot);
|
||||
~Kml(void);
|
||||
|
||||
void setAltitudeMode(String const &modeString);
|
||||
void setPathColor(String const &colorString);
|
||||
|
||||
private:
|
||||
CriticalSection m_lock;
|
||||
ScopedPointer<XmlElement> kml;
|
||||
@@ -18,6 +21,8 @@ private:
|
||||
XmlElement *m_pPathPlaceMark;
|
||||
char m_path[1024];
|
||||
const char *m_docRoot;
|
||||
String m_altitudeModeString;
|
||||
String m_pathColorString;
|
||||
|
||||
void create();
|
||||
void destroy();
|
||||
|
||||
+82
-19
@@ -31,6 +31,7 @@ MainComponent::MainComponent (String const &homeDir)
|
||||
{
|
||||
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);
|
||||
@@ -39,6 +40,7 @@ MainComponent::MainComponent (String const &homeDir)
|
||||
|
||||
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);
|
||||
@@ -46,11 +48,27 @@ MainComponent::MainComponent (String const &homeDir)
|
||||
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);
|
||||
|
||||
|
||||
//[UserPreSize]
|
||||
//[/UserPreSize]
|
||||
@@ -59,6 +77,8 @@ MainComponent::MainComponent (String const &homeDir)
|
||||
|
||||
|
||||
//[Constructor] You can add your own custom stuff here..
|
||||
m_toolTip = new TooltipWindow(this);
|
||||
|
||||
static String workDir(homeDir + String("\\FsTrack"));
|
||||
|
||||
File file(workDir);
|
||||
@@ -74,17 +94,28 @@ MainComponent::MainComponent (String const &homeDir)
|
||||
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);
|
||||
//[/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_kmlUpdInterval_s = nullptr;
|
||||
m_colorSelector = nullptr;
|
||||
m_altitudeMode = nullptr;
|
||||
|
||||
|
||||
//[Destructor]. You can add your own custom destruction code here..
|
||||
@@ -100,11 +131,6 @@ void MainComponent::paint (Graphics& g)
|
||||
g.fillAll (Colours::white);
|
||||
|
||||
//[UserPaint] Add your own custom painting code here..
|
||||
g.fillAll (Colour (0xffeeddff));
|
||||
|
||||
g.setFont (Font (16.0f));
|
||||
g.setColour (Colours::black);
|
||||
g.drawText ("Hello World!", getLocalBounds(), Justification::centred, true);
|
||||
//[/UserPaint]
|
||||
}
|
||||
|
||||
@@ -113,6 +139,8 @@ void MainComponent::resized()
|
||||
m_fsuipcStatus->setBounds (16, 256, 150, 24);
|
||||
m_flightStatus->setBounds (216, 256, 150, 24);
|
||||
m_kmlUpdInterval_s->setBounds (16, 216, 184, 24);
|
||||
m_colorSelector->setBounds (24, 32, 168, 152);
|
||||
m_altitudeMode->setBounds (216, 40, 160, 24);
|
||||
//[UserResized] Add your own custom resize handling here..
|
||||
//[/UserResized]
|
||||
}
|
||||
@@ -133,6 +161,22 @@ 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]
|
||||
}
|
||||
|
||||
|
||||
|
||||
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
|
||||
@@ -146,6 +190,16 @@ void MainComponent::onDataChanged(IFsLink &obj)
|
||||
{
|
||||
(void)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]
|
||||
|
||||
|
||||
@@ -159,24 +213,33 @@ void MainComponent::onDataChanged(IFsLink &obj)
|
||||
BEGIN_JUCER_METADATA
|
||||
|
||||
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
||||
parentClasses="public Component, public IFsLinkListener" constructorParams="String const &homeDir"
|
||||
variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
|
||||
overlayOpacity="0.330" fixedSize="1" initialWidth="400" initialHeight="300">
|
||||
parentClasses="public Component, public IFsLinkListener, public ChangeListener"
|
||||
constructorParams="String const &homeDir" variableInitialisers=""
|
||||
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
|
||||
fixedSize="1" initialWidth="400" initialHeight="300">
|
||||
<BACKGROUND backgroundColour="ffffffff"/>
|
||||
<LABEL name="FSUIP Status" id="a891503ff0f699d7" memberName="m_fsuipcStatus"
|
||||
virtualName="" explicitFocusOrder="0" pos="16 256 150 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="Unknown" editableSingleClick="0" editableDoubleClick="0"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="33"/>
|
||||
virtualName="" explicitFocusOrder="0" pos="16 256 150 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="216 256 150 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="Unknown" editableSingleClick="0" editableDoubleClick="0"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="33"/>
|
||||
virtualName="" explicitFocusOrder="0" pos="216 256 150 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="KML Update Interval" id="c4434642fabdd31c" memberName="m_kmlUpdInterval_s"
|
||||
virtualName="" explicitFocusOrder="0" pos="16 216 184 24" min="0.10000000000000001"
|
||||
max="10" int="0.10000000000000001" style="LinearHorizontal" textBoxPos="TextBoxLeft"
|
||||
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||
virtualName="" explicitFocusOrder="0" pos="16 216 184 24" tooltip="KML Update Interval"
|
||||
min="0.10000000000000001" max="10" int="0.10000000000000001"
|
||||
style="LinearHorizontal" textBoxPos="TextBoxLeft" textBoxEditable="1"
|
||||
textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||
<GENERICCOMPONENT name="Color Selector" id="bccc8a8094997edb" memberName="m_colorSelector"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 32 168 152" class="ColourSelector"
|
||||
params=""/>
|
||||
<COMBOBOX name="Altitude Mode" id="93006349fcf3e57a" memberName="m_altitudeMode"
|
||||
virtualName="" explicitFocusOrder="0" pos="216 40 160 24" tooltip="Altitude Mode"
|
||||
editable="0" layout="33" items="absolute relativeToGround clampToGround "
|
||||
textWhenNonSelected="" textWhenNoItems="(no choices)"/>
|
||||
</JUCER_COMPONENT>
|
||||
|
||||
END_JUCER_METADATA
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
*/
|
||||
class MainComponent : public Component,
|
||||
public IFsLinkListener,
|
||||
public SliderListener
|
||||
public ChangeListener,
|
||||
public SliderListener,
|
||||
public ComboBoxListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -53,24 +55,28 @@ public:
|
||||
void paint (Graphics& g);
|
||||
void resized();
|
||||
void sliderValueChanged (Slider* sliderThatWasMoved);
|
||||
void comboBoxChanged (ComboBox* comboBoxThatHasChanged);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
ScopedPointer<TooltipWindow> m_toolTip;
|
||||
ScopedPointer<FsLink> m_fsLink;
|
||||
ScopedPointer<Kml> m_kml;
|
||||
ScopedPointer<HttpServer> m_httpServer;
|
||||
|
||||
void onStateChanged(IFsLink &obj);
|
||||
void onDataChanged(IFsLink &obj);
|
||||
|
||||
void changeListenerCallback(juce::ChangeBroadcaster *source);
|
||||
//[/UserVariables]
|
||||
|
||||
//==============================================================================
|
||||
ScopedPointer<Label> m_fsuipcStatus;
|
||||
ScopedPointer<Label> m_flightStatus;
|
||||
ScopedPointer<Slider> m_kmlUpdInterval_s;
|
||||
ScopedPointer<ColourSelector> m_colorSelector;
|
||||
ScopedPointer<ComboBox> m_altitudeMode;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user