From b68e39ab6bc2c528b71c898498453e077cbd5de8 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 8 Mar 2020 17:05:08 -0700 Subject: [PATCH] Progress toward wireframe animations Handle the remaining visualization editor UI controls, except for the "test" button. Save/restore wireframe animations in the project file. Changed the preview from a 1-pixel-wide line drawn by a path half the window size to a 2-pixel-wide line drawn by a path the exact window size. --- SourceGen/ProjectFile.cs | 14 +- .../Visualization/wireframe-test.dis65 | 33 ++++- SourceGen/VisBitmapAnimation.cs | 2 +- SourceGen/VisWireframeAnimation.cs | 17 ++- SourceGen/Visualization.cs | 2 +- SourceGen/WpfGui/EditVisualization.xaml | 44 +++--- SourceGen/WpfGui/EditVisualization.xaml.cs | 136 ++++++++++++++++-- 7 files changed, 207 insertions(+), 41 deletions(-) diff --git a/SourceGen/ProjectFile.cs b/SourceGen/ProjectFile.cs index a969928..a8a2116 100644 --- a/SourceGen/ProjectFile.cs +++ b/SourceGen/ProjectFile.cs @@ -1051,8 +1051,18 @@ namespace SourceGen { vis = null; return false; } - vis = new Visualization(serVis.Tag, serVis.VisGenIdent, - new ReadOnlyDictionary(parms)); + + // We don't store VisWireframeAnimations in a separate area. They're just like + // static Visualizations but with an extra "is animated" parameter set. Check + // for that here and create the correct type. + if (parms.TryGetValue(VisWireframeAnimation.P_IS_ANIMATED, out object objVal) && + objVal is bool && (bool)objVal) { + vis = new VisWireframeAnimation(serVis.Tag, serVis.VisGenIdent, + new ReadOnlyDictionary(parms), null, null); + } else { + vis = new Visualization(serVis.Tag, serVis.VisGenIdent, + new ReadOnlyDictionary(parms)); + } return true; } diff --git a/SourceGen/SGTestData/Visualization/wireframe-test.dis65 b/SourceGen/SGTestData/Visualization/wireframe-test.dis65 index ba7c309..b861f34 100644 --- a/SourceGen/SGTestData/Visualization/wireframe-test.dis65 +++ b/SourceGen/SGTestData/Visualization/wireframe-test.dis65 @@ -42,7 +42,26 @@ }, "UserLabels":{ -}, +"10":{ +"Label":"vertices", +"Value":4106, +"Source":"User", +"Type":"GlobalAddr", +"LabelAnno":"None"}, + +"44":{ +"Label":"edges", +"Value":4140, +"Source":"User", +"Type":"GlobalAddr", +"LabelAnno":"None"}, + +"101":{ +"Label":"faces", +"Value":4197, +"Source":"User", +"Type":"GlobalAddr", +"LabelAnno":"None"}}, "OperandFormats":{ "10":{ @@ -248,8 +267,14 @@ "_isPerspective":true, "_isBfcEnabled":true, "_eulerRotX":0, -"_eulerRotY":34, -"_eulerRotZ":65}}, +"_eulerRotY":21, +"_eulerRotZ":65, +"_isAnimatedWireframe":true, +"_deltaRotX":-6, +"_deltaRotY":30, +"_deltaRotZ":0, +"_frameCount":60, +"_frameDelayMsec":100}}, { "Tag":"bmp_data", @@ -269,7 +294,7 @@ "Tag":"anim00002c", "VisGenIdent":"(animation)", "VisGenParams":{ -"_frame-delay-msec":500}}], +"_frameDelayMsec":100}}], "VisualizationSets":{ "10":{ "Tags":["wf_data", diff --git a/SourceGen/VisBitmapAnimation.cs b/SourceGen/VisBitmapAnimation.cs index 82b0583..7a69bb3 100644 --- a/SourceGen/VisBitmapAnimation.cs +++ b/SourceGen/VisBitmapAnimation.cs @@ -36,7 +36,7 @@ namespace SourceGen { /// /// Frame delay parameter. /// - public const string P_FRAME_DELAY_MSEC_PARAM = "_frame-delay-msec"; + public const string P_FRAME_DELAY_MSEC_PARAM = "_frameDelayMsec"; public const string P_FRAME_DELAY_MSEC_PARAM_OLD = "frame-delay-msec"; /// diff --git a/SourceGen/VisWireframeAnimation.cs b/SourceGen/VisWireframeAnimation.cs index 72ea090..5e6a3ad 100644 --- a/SourceGen/VisWireframeAnimation.cs +++ b/SourceGen/VisWireframeAnimation.cs @@ -32,25 +32,36 @@ namespace SourceGen { /// /// Frame delay parameter. /// - public const string P_FRAME_DELAY_MSEC = "_frame-delay-msec"; + public const string P_FRAME_DELAY_MSEC = "_frameDelayMsec"; /// /// Frame count parameter. /// - public const string P_FRAME_COUNT = "_frame-count"; + public const string P_FRAME_COUNT = "_frameCount"; + + public const string P_IS_ANIMATED = "_isAnimatedWireframe"; public const string P_EULER_ROT_X = "_eulerRotX"; public const string P_EULER_ROT_Y = "_eulerRotY"; public const string P_EULER_ROT_Z = "_eulerRotZ"; + public const string P_DELTA_ROT_X = "_deltaRotX"; + public const string P_DELTA_ROT_Y = "_deltaRotY"; + public const string P_DELTA_ROT_Z = "_deltaRotZ"; + private IVisualizationWireframe mVisWire; public VisWireframeAnimation(string tag, string visGenIdent, ReadOnlyDictionary visGenParams, Visualization oldObj, IVisualizationWireframe visWire) : base(tag, visGenIdent, visGenParams, oldObj) { - Debug.Assert(visWire != null); + // visWire may be null when loading from project file + mVisWire = visWire; + } + public override void SetThumbnail(IVisualizationWireframe visWire, + ReadOnlyDictionary parms) { + base.SetThumbnail(visWire, parms); mVisWire = visWire; } } diff --git a/SourceGen/Visualization.cs b/SourceGen/Visualization.cs index 5231c4a..e58fd7e 100644 --- a/SourceGen/Visualization.cs +++ b/SourceGen/Visualization.cs @@ -192,7 +192,7 @@ namespace SourceGen { /// /// Visualization object. /// Visualization parameters. - public void SetThumbnail(IVisualizationWireframe visWire, + public virtual void SetThumbnail(IVisualizationWireframe visWire, ReadOnlyDictionary parms) { Debug.Assert(visWire != null); Debug.Assert(parms != null); diff --git a/SourceGen/WpfGui/EditVisualization.xaml b/SourceGen/WpfGui/EditVisualization.xaml index 599b9d8..2da6f81 100644 --- a/SourceGen/WpfGui/EditVisualization.xaml +++ b/SourceGen/WpfGui/EditVisualization.xaml @@ -134,17 +134,18 @@ limitations under the License. + Background="{StaticResource CheckerBackground}" + SnapsToDevicePixels="True"> + RenderOptions.BitmapScalingMode="NearestNeighbor"/> - + @@ -192,24 +193,24 @@ limitations under the License. - - + - + - + + Text="Rotation per frame:" + IsEnabled="{Binding ElementName=isAnimated, Path=IsChecked}"/> - + - + - + - - + +