├── media
└── readme_example_pic.png
├── .editorconfig
├── HelixTraceDemoApp
├── App.config
├── packages.config
├── App.xaml.cs
├── App.xaml
├── MainWindow.xaml
├── Properties
│ └── AssemblyInfo.cs
├── HelixTraceDemoApp.csproj
├── MainWindow.xaml.cs
└── HelixPlot.cs
├── LICENSE
├── HelixTraceApp.sln
├── readme.md
├── .gitattributes
└── .gitignore
/media/readme_example_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZhukovWang/HelixTraceApp/HEAD/media/readme_example_pic.png
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.cs]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = crlf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HelixTraceDemoApp
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 ZhukovWang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/HelixTraceApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29911.84
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelixTraceDemoApp", "HelixTraceDemoApp\HelixTraceDemoApp.csproj", "{0D1358B1-F552-46EF-868A-AD444C2ACF64}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0D1358B1-F552-46EF-868A-AD444C2ACF64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {0D1358B1-F552-46EF-868A-AD444C2ACF64}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {0D1358B1-F552-46EF-868A-AD444C2ACF64}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {0D1358B1-F552-46EF-868A-AD444C2ACF64}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {AABC87EE-917D-449F-B6CE-4461D30C3E2C}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # HelixTraceApp
2 |
3 | HelixTraceApp是一个用于绘制轨迹动画的软件。使用`C#`和`Helix-Toolkit`。
4 |
5 | HelixTraceApp is a software that can be used to pltting data trajectory. Use `C#` and `Helix-Toolkit`.
6 |
7 | 参考了[此处Demo](https://www.codeproject.com/Articles/1246255/Plotting-a-Real-time-D-Toolpath-with-Helix-Toolkit),并进行了一定的改造。
8 |
9 | Refering to [this Demo](https://www.codeproject.com/Articles/1246255/Plotting-a-Real-time-D-Toolpath-with-Helix-Toolkit), and change some code.
10 |
11 | 
12 |
13 | ## 背景 Background
14 |
15 | 在Windows上处理一些大量轨迹数据的时候,需要绘图进行分析,过去使用的`gnuplot`显得有些力不从心,无论是使用`wxt`还是`qt`反应速度都无法让人满意。究其原因,似乎二者都不是使用GPU进行绘图,而是使用CPU进行绘图,在进行图形绘制时,计算量过大。
16 |
17 | 另外一点是,`gnuplot`无法进行点位动画的展示,尝试使用`r`的`plotly`包生成`HTML`网页进行动画展示,同样的问题出现了,在数据量过大的情况下,生成网页数据很慢,打开很慢,效果很差。
18 |
19 | 在网上查询后,发现了相关绘图库,并发现了一位前辈写的简单Demo,经过一定改写后,加入了文件读取功能,改进了一部分代码,提高了绘图速度。
20 |
21 | ## 编译 Build
22 |
23 | 使用Visual Studio打开工程后,编译即可。
24 |
25 | Use Visual Studio open the solution file, and build.
26 |
27 | 测试VS2019编译成功。注意.Net版本。
28 |
29 | VS2019 can build successfully. Please check the `.Net` version correctly.
30 |
31 | ## 使用
32 |
33 | ### 准备数据文件
34 |
35 | 本软件是读取数据文件后,再做动画绘图的过程,所以需要预先准备好数据文件。
36 |
37 | This software read the data file, then plot and display animation. So need to prepare the data file before.
38 |
39 | 数据文件格式为:每行写一个点的数据,数值用空格分开。可以两个数据,也可以三个数据。
40 |
41 | The data file format is: each line has one point data, the data value split by spaces. The point data can have two or three value.
42 |
43 | 举例如下:
44 |
45 | For example:
46 |
47 | ```text
48 | 0 0 0
49 | 10 10 10
50 | 15 10 10
51 | ```
52 |
53 | ### 执行程序 Execute
54 |
55 | 运行编译后程序,会弹出文件选择框,选择数据文件,即可开始绘图。
56 |
57 | Build and exeucte, then choose the data file, and plotting.
58 |
59 | ## To-Do
60 |
61 | 1. 修复巨量数据绘图刷新率低的问题
62 | 1. 使得网格框可以跟随图像大小自动变化
63 | 1. 可以使网格框显示消失的按钮
64 | 1. 图像可以进行移动
65 | 1. 加入绘图速度条件滑动条
66 | 1. 加入立即绘图按钮
67 |
68 | ## License
69 |
70 | MIT
--------------------------------------------------------------------------------
/HelixTraceDemoApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("HelixTraceDemoApp")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("HelixTraceDemoApp")]
15 | [assembly: AssemblyCopyright("Copyright © 2018")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/HelixTraceDemoApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {0D1358B1-F552-46EF-868A-AD444C2ACF64}
8 | WinExe
9 | HelixTraceDemoApp
10 | HelixTraceDemoApp
11 | v4.6.1
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | false
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\HelixToolkit.2.11.0\lib\netstandard1.1\HelixToolkit.dll
40 |
41 |
42 | ..\packages\HelixToolkit.Wpf.2.11.0\lib\net45\HelixToolkit.Wpf.dll
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | 4.0
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | MSBuild:Compile
64 | Designer
65 |
66 |
67 | App.xaml
68 | Code
69 |
70 |
71 |
72 | MainWindow.xaml
73 | Code
74 |
75 |
76 |
77 |
78 | Code
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/HelixTraceDemoApp/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | //Copyright (c) 2018 Bruce Greene
2 |
3 | //Permission is hereby granted, free of charge, to any person obtaining a copy
4 | //of this software and associated documentation files (the "Software"), to deal
5 | //in the Software without restriction, including without limitation the rights to
6 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | //of the Software, and to permit persons to whom the Software is furnished to do
8 | //so, subject to the following conditions:
9 |
10 | //The above copyright notice and this permission notice shall be included in all
11 | //copies or substantial portions of the Software.
12 |
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 | //WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
20 | using System;
21 | using System.Collections.Concurrent;
22 | using System.Collections.Generic;
23 | using System.ComponentModel;
24 | using System.Diagnostics;
25 | using System.IO;
26 | using System.Text;
27 | using System.Threading;
28 | using System.Windows;
29 | using System.Windows.Media;
30 | using System.Windows.Media.Media3D;
31 | using System.Windows.Threading;
32 |
33 | namespace HelixTraceDemoApp
34 | {
35 | public partial class MainWindow : Window
36 | {
37 | private struct Point3DPlus
38 | {
39 | public Point3DPlus(Point3D point, Color color, double thickness)
40 | {
41 | this.point = point;
42 | this.color = color;
43 | this.thickness = thickness;
44 | }
45 |
46 | public Point3D point;
47 | public Color color;
48 | public double thickness;
49 | }
50 |
51 | private Stopwatch stopwatch = Stopwatch.StartNew();
52 |
53 | private string filePath;
54 |
55 | private ConcurrentQueue> pointsList = new ConcurrentQueue>();
56 |
57 | public MainWindow()
58 | {
59 | InitializeComponent();
60 |
61 | OpenFile();
62 |
63 | var bw = new BackgroundWorker();
64 | bw.DoWork += GatherData;
65 | bw.RunWorkerAsync();
66 | }
67 |
68 | private void OpenFile()
69 | {
70 | var openDialog = new System.Windows.Forms.OpenFileDialog();
71 | openDialog.Multiselect = false;
72 | openDialog.CheckPathExists = true;
73 |
74 | if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
75 | {
76 | filePath = openDialog.FileName;
77 |
78 | if (!File.Exists(filePath))
79 | {
80 | System.Windows.MessageBox.Show("File is NOT exists!", "Error", MessageBoxButton.OK,
81 | MessageBoxImage.Error);
82 | }
83 | }
84 | else
85 | {
86 | Environment.Exit(-1);
87 | }
88 | }
89 |
90 | private void GatherData(object sender, DoWorkEventArgs e)
91 | {
92 | var readDataStream = new System.IO.StreamReader(filePath, Encoding.UTF8);
93 |
94 | while (true)
95 | {
96 | Thread.Sleep(100); // can use to change the poltting rate
97 |
98 | //Generate a test trace: an upward spiral with square corners
99 |
100 | #region old test code
101 |
102 | //double t = stopwatch.Elapsed.TotalSeconds * 0.25;
103 | //double sint = Math.Sin(t);
104 | //double cost = Math.Cos(t);
105 | //double x, y, z = t * 0.5;
106 | //Color color;
107 |
108 | //if (sint > 0.0 && cost > 0.0)
109 | //{
110 | // if (sint > cost)
111 | // {
112 | // x = 100.0;
113 | // y = 70.71 * cost + 50.0;
114 | // }
115 | // else
116 | // {
117 | // x = 70.71 * sint + 50.0;
118 | // y = 100.0;
119 | // }
120 | // color = Colors.Red;
121 | //}
122 | //else if (sint < 0.0 && cost < 0.0)
123 | //{
124 | // if (sint < cost)
125 | // {
126 | // x = 0.0;
127 | // y = 70.71 * cost + 50.0;
128 | // }
129 | // else
130 | // {
131 | // x = 70.71 * sint + 50.0;
132 | // y = 0.0;
133 | // }
134 | // color = Colors.Red;
135 | //}
136 | //else
137 | //{
138 | // x = 50.0 * sint + 50.0;
139 | // y = 50.0 * cost + 50.0;
140 | // color = Colors.Blue;
141 | //}
142 |
143 | #endregion old test code
144 |
145 | List points = new List();
146 |
147 | Color color = Colors.Black;
148 | double x = 0, y = 0, z = 0;
149 |
150 | const int addPointSum = 50; //can use to change the poltting rate
151 |
152 | for (int i = 0; i < addPointSum; i++)
153 | {
154 | if (readDataStream.EndOfStream)
155 | {
156 | break;
157 | }
158 |
159 | var readDataLine = readDataStream.ReadLine();
160 |
161 | var readDataNumbers = readDataLine.Split(' ');
162 |
163 | try
164 | {
165 | x = Convert.ToDouble(readDataNumbers[0]);
166 | y = Convert.ToDouble(readDataNumbers[1]);
167 |
168 | if (readDataNumbers.Length >= 3)
169 | {
170 | z = Convert.ToDouble(readDataNumbers[2]);
171 | }
172 | else
173 | {
174 | z = 0;
175 | }
176 | }
177 | catch
178 | {
179 | System.Windows.MessageBox.Show("Data format is error. The format is 'x y z'.", "Error", MessageBoxButton.OK,
180 | MessageBoxImage.Error);
181 | Environment.Exit(-1);
182 | }
183 |
184 | var point = new Point3DPlus(new Point3D(x, y, z), color, 1.5);
185 |
186 | points.Add(point);
187 | }
188 |
189 | bool invoke = false;
190 | if (points.Count > 0)
191 | {
192 | pointsList.Enqueue(points);
193 | invoke = true;
194 | }
195 |
196 | if (invoke)
197 | {
198 | Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)PlotData);
199 | }
200 | }
201 | }
202 |
203 | private void PlotData()
204 | {
205 | if (pointsList.Count > 0)
206 | {
207 | bool resultPop = pointsList.TryDequeue(out var points);
208 | if (resultPop)
209 | {
210 | var pointsArray = points.ToArray();
211 |
212 | foreach (Point3DPlus point in pointsArray)
213 | plot.AddPoint(point.point, point.color, point.thickness);
214 | }
215 | }
216 | }
217 |
218 | private void btnZoom_Click(object sender, RoutedEventArgs e)
219 | {
220 | plot.ZoomExtents(500); // zoom to extents
221 | //plot.ResetCamera(); // orient and zoom
222 | }
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/HelixTraceDemoApp/HelixPlot.cs:
--------------------------------------------------------------------------------
1 | //Copyright (c) 2018 Bruce Greene
2 |
3 | //Permission is hereby granted, free of charge, to any person obtaining a copy
4 | //of this software and associated documentation files (the "Software"), to deal
5 | //in the Software without restriction, including without limitation the rights to
6 | //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | //of the Software, and to permit persons to whom the Software is furnished to do
8 | //so, subject to the following conditions:
9 |
10 | //The above copyright notice and this permission notice shall be included in all
11 | //copies or substantial portions of the Software.
12 |
13 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 | //WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
20 | using HelixToolkit.Wpf;
21 | using System;
22 | using System.Collections.Generic;
23 | using System.Windows;
24 | using System.Windows.Media;
25 | using System.Windows.Media.Media3D;
26 |
27 | namespace HelixTraceDemoApp
28 | {
29 | ///
30 | /// Plot a trace in 3D space with marker, axes and bounding box.
31 | ///
32 | ///
33 | /// This class utilizes the Helix Toolkit which is licensed under the MIT License.
34 | ///
35 | /// The MIT License (MIT)
36 | /// Copyright(c) 2018 Helix Toolkit contributors
37 | ///
38 | /// Permission is hereby granted, free of charge, to any person obtaining a
39 | /// copy of this software and associated documentation files (the
40 | /// "Software"), to deal in the Software without restriction, including
41 | /// without limitation the rights to use, copy, modify, merge, publish,
42 | /// distribute, sublicense, and/or sell copies of the Software, and to
43 | /// permit persons to whom the Software is furnished to do so, subject to
44 | /// the following conditions:
45 | ///
46 | /// The above copyright notice and this permission notice shall be included
47 | /// in all copies or substantial portions of the Software.
48 | ///
49 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
50 | /// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51 | /// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52 | /// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53 | /// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54 | /// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55 | /// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56 | ///
57 | public class HelixPlot : HelixViewport3D
58 | {
59 | private TruncatedConeVisual3D marker;
60 | private BillboardTextVisual3D coords;
61 | private double labelOffset, minDistanceSquared;
62 | private string coordinateFormat;
63 | private List trace;
64 | private LinesVisual3D path;
65 | private Point3D point0; // last point
66 | private Vector3D delta0; // (dx,dy,dz)
67 |
68 | /// Initializes a new instance of the class.
69 | public HelixPlot()
70 | : base()
71 | {
72 | ZoomExtentsWhenLoaded = true;
73 | ShowCoordinateSystem = false;
74 | ShowViewCube = false;
75 | ShowFrameRate = true; // very useful diagnostic info
76 | ShowTriangleCountInfo = true; // very useful diagnostic info
77 |
78 | // Default configuration:
79 | AxisLabels = "X,Y,Z";
80 | BoundingBox = new Rect3D(-50, -50, -25, 100, 100, 50); // the original place
81 | TickSize = 10;
82 | MinDistance = 0.01;
83 | DecimalPlaces = 1;
84 | Background = Brushes.White;
85 | AxisBrush = Brushes.Gray;
86 | MarkerBrush = Brushes.Red;
87 | Elements = EElements.All;
88 | CreateElements();
89 | }
90 |
91 | /// Axis labels separated by commas ("X,Y,Z" default).
92 | public string AxisLabels { get; set; }
93 |
94 | /// XYZ bounding box for the 3D plot.
95 | public Rect3D BoundingBox { get; set; }
96 |
97 | /// Distance between ticks on the XY grid.
98 | public double TickSize { get; set; }
99 |
100 | /// A point closer than this distance from the previous point will not be plotted.
101 | public double MinDistance { get; set; }
102 |
103 | /// Number of decimal places for the marker coordinates.
104 | public int DecimalPlaces { get; set; }
105 |
106 | /// Brush used for the axes, grid and bounding box.
107 | public SolidColorBrush AxisBrush { get; set; }
108 |
109 | /// Brush used for the marker cone and coordinates.
110 | public SolidColorBrush MarkerBrush { get; set; }
111 |
112 | /// Determines which plot elements are included.
113 | ///
114 | [Flags]
115 | public enum EElements
116 | {
117 | /// Traces only.
118 | None = 0x00,
119 |
120 | /// XYZ axes.
121 | Axes = 0x01,
122 |
123 | /// XY grid.
124 | Grid = 0x02,
125 |
126 | /// XYZ bounding box.
127 | BoundingBox = 0x04,
128 |
129 | /// Marker cone and coordinates.
130 | Marker = 0x08,
131 |
132 | /// Axes, grid, bounding box and marker.
133 | All = 0x0F
134 | };
135 |
136 | /// Determines which plot elements are included.
137 | public EElements Elements { get; set; }
138 |
139 | /// Gets the current trace color.
140 | public Color TraceColor { get { return (path != null) ? path.Color : Colors.Black; } }
141 |
142 | /// Gets the current trace thickness.
143 | public double TraceThickness { get { return (path != null) ? path.Thickness : 1; } }
144 |
145 | /// Creates the plot elements.
146 | /// Changes to the bounding box and other parameters will not take effect until this method is called.
147 | public void CreateElements()
148 | {
149 | Children.Clear();
150 | Children.Add(new DefaultLights());
151 |
152 | string[] labels = AxisLabels.Split(',');
153 | if (labels.Length < 3)
154 | labels = new string[] { "X", "Y", "Z" };
155 |
156 | double bbSize = Math.Max(Math.Max(BoundingBox.SizeX, BoundingBox.SizeY), BoundingBox.SizeZ);
157 | double lineThickness = bbSize / 1000;
158 | double arrowOffset = lineThickness * 30;
159 | labelOffset = lineThickness * 50;
160 | minDistanceSquared = MinDistance * MinDistance;
161 |
162 | if (Elements.HasFlag(EElements.Grid))
163 | {
164 | var grid = new GridLinesVisual3D();
165 | grid.Center = new Point3D(BoundingBox.X + 0.5 * BoundingBox.SizeX, BoundingBox.Y + 0.5 * BoundingBox.SizeY, BoundingBox.Z);
166 | grid.Length = BoundingBox.SizeX;
167 | grid.Width = BoundingBox.SizeY;
168 | grid.MinorDistance = TickSize;
169 | grid.MajorDistance = bbSize;
170 | grid.Thickness = lineThickness;
171 | grid.Fill = AxisBrush;
172 | Children.Add(grid);
173 | }
174 |
175 | if (Elements.HasFlag(EElements.Axes))
176 | {
177 | var arrow = new ArrowVisual3D();
178 | arrow.Point2 = new Point3D((BoundingBox.X + BoundingBox.SizeX) + arrowOffset, 0.0, 0.0);
179 | arrow.Diameter = lineThickness * 5;
180 | arrow.Fill = AxisBrush;
181 | Children.Add(arrow);
182 |
183 | var label = new BillboardTextVisual3D();
184 | label.Text = labels[0];
185 | label.FontWeight = FontWeights.Bold;
186 | label.Foreground = AxisBrush;
187 | label.Position = new Point3D((BoundingBox.X + BoundingBox.SizeX) + labelOffset, 0.0, 0.0);
188 | Children.Add(label);
189 |
190 | arrow = new ArrowVisual3D();
191 | arrow.Point2 = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + arrowOffset, 0.0);
192 | arrow.Diameter = lineThickness * 5;
193 | arrow.Fill = AxisBrush;
194 | Children.Add(arrow);
195 |
196 | label = new BillboardTextVisual3D();
197 | label.Text = labels[1];
198 | label.FontWeight = FontWeights.Bold;
199 | label.Foreground = AxisBrush;
200 | label.Position = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + labelOffset, 0.0);
201 | Children.Add(label);
202 |
203 | if (BoundingBox.SizeZ > 0)
204 | {
205 | arrow = new ArrowVisual3D();
206 | arrow.Point2 = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + arrowOffset);
207 | arrow.Diameter = lineThickness * 5;
208 | arrow.Fill = AxisBrush;
209 | Children.Add(arrow);
210 |
211 | label = new BillboardTextVisual3D();
212 | label.Text = labels[2];
213 | label.FontWeight = FontWeights.Bold;
214 | label.Foreground = AxisBrush;
215 | label.Position = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + labelOffset);
216 | Children.Add(label);
217 | }
218 | }
219 |
220 | if (Elements.HasFlag(EElements.BoundingBox) && BoundingBox.SizeZ > 0)
221 | {
222 | var box = new BoundingBoxWireFrameVisual3D();
223 | box.BoundingBox = BoundingBox;
224 | box.Thickness = 1;
225 | box.Color = AxisBrush.Color;
226 | Children.Add(box);
227 | }
228 |
229 | if (Elements.HasFlag(EElements.Marker))
230 | {
231 | marker = new TruncatedConeVisual3D();
232 | marker.Height = labelOffset;
233 | marker.BaseRadius = 0.0;
234 | marker.TopRadius = labelOffset / 5;
235 | marker.TopCap = true;
236 | marker.Origin = new Point3D(0.0, 0.0, 0.0);
237 | marker.Normal = new Vector3D(-1.0, -1.0, 1.0);
238 | marker.Fill = MarkerBrush;
239 | Children.Add(marker);
240 |
241 | coords = new BillboardTextVisual3D();
242 | coordinateFormat = string.Format("{{0:F6}}, {{1:F6}}, {{2:F6}}", DecimalPlaces, DecimalPlaces, DecimalPlaces); // "{0:F2}, {1:F2}, {2:F2}"
243 | coords.Text = string.Format(coordinateFormat, 0.0, 0.0, 0.0);
244 | coords.Foreground = MarkerBrush;
245 | coords.Position = new Point3D(-labelOffset, -labelOffset, labelOffset);
246 | Children.Add(coords);
247 | }
248 | else
249 | {
250 | marker = null;
251 | coords = null;
252 | }
253 |
254 | if (trace != null)
255 | {
256 | foreach (LinesVisual3D p in trace)
257 | Children.Add(p);
258 | path = trace[trace.Count - 1];
259 | }
260 | }
261 |
262 | /// Clears all traces.
263 | public void Clear()
264 | {
265 | trace = null;
266 | path = null;
267 | CreateElements();
268 | }
269 |
270 | ///
271 | /// Creates a new trace.
272 | ///
273 | /// Existing traces will remain in the plot until or is called.
274 | /// The (X,Y,Z) location.
275 | /// The initial color.
276 | /// The initial line thickness.
277 | /// The trace count.
278 | ///
279 | public void NewTrace(Point3D point, Color color, double thickness = 1)
280 | {
281 | path = new LinesVisual3D();
282 | path.Color = color;
283 | path.Thickness = thickness;
284 | trace = new List();
285 | trace.Add(path);
286 | Children.Add(path);
287 | point0 = point;
288 | delta0 = new Vector3D();
289 |
290 | if (marker != null)
291 | {
292 | marker.Origin = point;
293 | coords.Position = new Point3D(point.X - labelOffset, point.Y - labelOffset, point.Z + labelOffset);
294 | coords.Text = string.Format(coordinateFormat, point.X, point.Y, point.Z);
295 | }
296 | }
297 |
298 | ///
299 | /// Creates a new trace.
300 | ///
301 | /// Existing traces will remain in the plot until or is called.
302 | /// The initial X location.
303 | /// The initial Y location.
304 | /// The initial Z location.
305 | /// The initial color.
306 | /// The initial line thickness.
307 | /// The trace count.
308 | ///
309 | public void NewTrace(double x, double y, double z, Color color, double thickness = 1)
310 | {
311 | NewTrace(new Point3D(x, y, z), color, thickness);
312 | }
313 |
314 | ///
315 | /// Adds a point to the current trace with a specified color.
316 | ///
317 | /// The (X,Y,Z) location.
318 | /// The color.
319 | /// The line thickness (optional).
320 | ///
321 | public void AddPoint(Point3D point, Color color, double thickness = -1)
322 | {
323 | if (trace == null)
324 | {
325 | NewTrace(point, color, (thickness > 0) ? thickness : 1);
326 | return;
327 | }
328 |
329 | if ((point - point0).LengthSquared < minDistanceSquared) return; // less than min distance from last point
330 |
331 | if (path.Color != color || (thickness > 0 && path.Thickness != thickness))
332 | {
333 | if (thickness <= 0)
334 | thickness = path.Thickness;
335 |
336 | path = new LinesVisual3D();
337 | path.Color = color;
338 | path.Thickness = thickness;
339 | trace.Add(path);
340 | Children.Add(path);
341 | }
342 |
343 | // If line segments AB and BC have the same direction (small cross product) then remove point B.
344 | bool sameDir = false;
345 | var delta = new Vector3D(point.X - point0.X, point.Y - point0.Y, point.Z - point0.Z);
346 | delta.Normalize(); // use unit vectors (magnitude 1) for the cross product calculations
347 | if (path.Points.Count > 0)
348 | {
349 | double xp2 = Vector3D.CrossProduct(delta, delta0).LengthSquared;
350 | sameDir = (xp2 < 0.0005); // approx 0.001 seems to be a reasonable threshold from logging xp2 values
351 | //if (!sameDir) Title = string.Format("xp2={0:F6}", xp2);
352 | }
353 |
354 | if (sameDir) // extend the current line segment
355 | {
356 | path.Points[path.Points.Count - 1] = point;
357 | point0 = point;
358 | delta0 += delta;
359 | }
360 | else // add a new line segment
361 | {
362 | path.Points.Add(point0);
363 | path.Points.Add(point);
364 | point0 = point;
365 | delta0 = delta;
366 | }
367 |
368 | if (marker != null)
369 | {
370 | marker.Origin = point;
371 | coords.Position = new Point3D(point.X - labelOffset, point.Y - labelOffset, point.Z + labelOffset);
372 | coords.Text = string.Format(coordinateFormat, point.X, point.Y, point.Z);
373 | }
374 | }
375 |
376 | ///
377 | /// Adds a point to the current trace.
378 | ///
379 | /// The (X,Y,Z) location.
380 | ///
381 | public void AddPoint(Point3D point)
382 | {
383 | if (path == null)
384 | {
385 | NewTrace(point, Colors.Black, 1);
386 | return;
387 | }
388 |
389 | AddPoint(point, path.Color, path.Thickness);
390 | }
391 |
392 | ///
393 | /// Adds a point to the current trace with a specified color.
394 | ///
395 | /// The X location.
396 | /// The Y location.
397 | /// The Z location.
398 | /// The color.
399 | /// The line thickness (optional).
400 | ///
401 | public void AddPoint(double x, double y, double z, Color color, double thickness = -1)
402 | {
403 | AddPoint(new Point3D(x, y, z), color, thickness);
404 | }
405 |
406 | ///
407 | /// Adds a point to the current trace.
408 | ///
409 | /// The X location.
410 | /// The Y location.
411 | /// The Z location.
412 | ///
413 | public void AddPoint(double x, double y, double z)
414 | {
415 | if (path == null) return;
416 |
417 | AddPoint(new Point3D(x, y, z), path.Color, path.Thickness);
418 | }
419 | }
420 | }
421 |
--------------------------------------------------------------------------------