Skip to content

Commit

Permalink
Fix bugs in px4 .ulg viewing, and make tooltip avoid the closebox on …
Browse files Browse the repository at this point in the history
…a chart.
  • Loading branch information
lovettchris committed May 10, 2021
1 parent 8d21f60 commit 1efa6c2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
20 changes: 9 additions & 11 deletions LogViewer/LogViewer/Controls/SimpleLineChart.xaml
Expand Up @@ -33,6 +33,14 @@
<Canvas Grid.Row="0" VerticalAlignment="Top">
<Path x:Name="Graph" StrokeThickness="5" VerticalAlignment="Top" SnapsToDevicePixels="True" StrokeLineJoin="Bevel">
</Path>
<Path x:Name="Pointer" Fill="{StaticResource TooltipForeground}" Data="M0,-5 L 5,0 0,5 -5 0z" Visibility="Collapsed"/>
<local:PointerBorder x:Name="PointerBorder" Visibility="Collapsed" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1"
CornerRadius="3" BorderBrush="{StaticResource TooltipForeground}" Background="#80303030">
<TextBlock x:Name="PointerLabel" Foreground="{StaticResource TooltipForeground}"/>
</local:PointerBorder>
<Canvas x:Name="AdornerCanvas">

</Canvas>
</Canvas>

<Grid>
Expand All @@ -45,17 +53,7 @@
<TextBlock x:Name="MinLabel" Grid.Row="2" Margin="4"/>
</Grid>

<local:CloseBox HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5" Click="CloseBoxClick"/>
<local:CloseBox x:Name="CloseBox" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5" Click="CloseBoxClick"/>

<Canvas Grid.Row="0" VerticalAlignment="Top">
<Path x:Name="Pointer" Fill="{StaticResource TooltipForeground}" Data="M0,-5 L 5,0 0,5 -5 0z" Visibility="Collapsed"/>
<local:PointerBorder x:Name="PointerBorder" Visibility="Collapsed" Padding="2" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1"
CornerRadius="3" BorderBrush="{StaticResource TooltipForeground}" Background="#80303030">
<TextBlock x:Name="PointerLabel" Foreground="{StaticResource TooltipForeground}"/>
</local:PointerBorder>
<Canvas x:Name="AdornerCanvas">

</Canvas>
</Canvas>
</Grid>
</UserControl>
7 changes: 7 additions & 0 deletions LogViewer/LogViewer/Controls/SimpleLineChart.xaml.cs
Expand Up @@ -904,6 +904,13 @@ void ShowTip(string label, Point pos, DataValue data = null)
{
tipPositionY = 0;
}

Size closeBoxSize = CloseBox.DesiredSize;
if (tipPositionX == this.ActualWidth - PointerBorder.ActualWidth && tipPositionY < closeBoxSize.Height)
{
tipPositionX -= closeBoxSize.Width;
}

PointerBorder.Margin = new Thickness(tipPositionX, tipPositionY, 0, 0);
PointerBorder.Visibility = System.Windows.Visibility.Visible;
PointerBorder.Data = data;
Expand Down
2 changes: 1 addition & 1 deletion LogViewer/LogViewer/LogViewer.csproj
Expand Up @@ -33,7 +33,7 @@
<SuiteName>PX4 Log Viewer</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>63</ApplicationRevision>
<ApplicationRevision>64</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
9 changes: 8 additions & 1 deletion LogViewer/LogViewer/MainWindow.xaml.cs
Expand Up @@ -962,9 +962,11 @@ private void OnChildListItemSelected(object sender, SelectionChangedEventArgs e)
IEnumerable<DataValue> GetSelectedDataValues(LogItemSchema schema)
{
List<Flight> selected = GetSelectedFlights();
bool everything = false;
if (selected.Count == 0)
{
// show everything.
everything = true;
selected.Add(new Flight() { StartTime = DateTime.MinValue, Duration = TimeSpan.MaxValue });
}

Expand All @@ -982,6 +984,11 @@ IEnumerable<DataValue> GetSelectedDataValues(LogItemSchema schema)
}
}
}
if (everything)
{
// the first Log contains everything, subsequent logs are the separate flights found.
break;
}
}
}
}
Expand Down Expand Up @@ -1094,7 +1101,7 @@ private void GraphItem(LogItemSchema schema)
else
{
var data = GetSelectedDataValues(schema);
if (data.Count() > 0)
if (data.Any())
{
chart = AddChart(schema, data);
}
Expand Down
38 changes: 23 additions & 15 deletions LogViewer/LogViewer/Model/Px4ULog.cs
Expand Up @@ -261,6 +261,11 @@ public MessageData(UInt16 msgId, byte[] value, MessageSubscription s)

public override ulong GetTimestamp()
{
if (values == null)
{
ParseValues();
}

object ts = null;
if (values.TryGetValue("timestamp", out ts))
{
Expand Down Expand Up @@ -747,31 +752,34 @@ public IEnumerable<DataValue> GetDataValues(LogItemSchema schema, DateTime start
if (m is MessageData)
{
MessageData data = (MessageData)m;
if (data.subscription.id == root.Id)
//if (data.subscription.id == root.Id)
{
MessageFormat f = data.format;
// matching root schema, so drill down if necessary.
for (int i = 1, n = path.Count; i < n; i++)
{
bool found = false;
LogItemSchema child = path[i];
foreach (var field in f.fields)
if (path[i].Name == f.name && i + 1 < n)
{
if (field.name == child.Name)
LogItemSchema child = path[i + 1];
foreach (var field in f.fields)
{
found = true;
if (i + 1 < n && child.HasChildren)
{
// still need to drill down, so we need a MessageData and MessageFormat for the child item.
data = data.GetNestedData(field.name);
f = data.format;
}
else
if (field.name == child.Name)
{
yield return data.GetValue(field);
found = false; // done drilling down
found = true;
if (i + 1 < n && child.HasChildren)
{
// still need to drill down, so we need a MessageData and MessageFormat for the child item.
data = data.GetNestedData(field.name);
f = data.format;
}
else
{
yield return data.GetValue(field);
found = false; // done drilling down
}
break;
}
break;
}
}
if (!found)
Expand Down

0 comments on commit 1efa6c2

Please sign in to comment.