6.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T13:53:01.641041+00:00 | zai-org/GLM-5-FP8 | 1 | 8c5a8096c69954ca |
Documentation: DTS.Viewer.Graph Views
1. Purpose
This module provides WPF view components for graph visualization within the DTS Viewer application. It contains three XAML code-behind classes—GraphView, TestDataView, and TestDataSeriesView—that implement corresponding interfaces from DTS.Common.Interface. The primary functionality includes rendering charts using ComponentOne WPF Chart controls and exporting test data to PDF and CSV formats with associated metadata (test setup information, gRMS tables, and PSD data).
2. Public Interface
GraphView
Implements: IGraphView
| Member | Signature | Description |
|---|---|---|
| Constructor | public GraphView() |
Initializes the XAML component via InitializeComponent(). |
TestDataView
Implements: ITestDataView
| Member | Signature | Description |
|---|---|---|
| Constructor | public TestDataView() |
Initializes the XAML component via InitializeComponent(). |
Note: Contains extensive commented-out code for mouse-driven zoom functionality (MainChart_MouseLeftButtonDown, MainChart_MouseMove, MainChart_MouseLeftButtonUp, PerformZoom, DrawReversibleRectangle), but none of this is active.
TestDataSeriesView
Implements: ITestDataSeriesView
| Member | Signature | Description |
|---|---|---|
| Constructor | public TestDataSeriesView() |
Initializes the XAML component via InitializeComponent(). |
| SaveReportToPDF | public bool SaveReportToPDF(string directory) |
Generates a PDF containing: test setup info, chart image, and a gRMS table with channel names, sample rates, and gRMS values. Returns true on success, false on failure. |
| SaveReportToCSV | public bool SaveReportToCSV(string directory) |
Exports chart data to CSV format with frequency (Hz) and PSD values (EngineeringUnits²/Hz). Returns true on success, false on failure. |
| obj_DataPointChanged | private void obj_DataPointChanged(object sender, EventArgs e) |
Event handler for data point changes. All logic is commented out. |
| MainChart_OnMouseWheel | private void MainChart_OnMouseWheel(object sender, MouseWheelEventArgs e) |
Mouse wheel event handler. All logic is commented out. |
| MainChart_OnKeyUp | private void MainChart_OnKeyUp(object sender, KeyEventArgs e) |
Key up event handler. Empty implementation. |
AxisExtension (Static Extension Class)
| Member | Signature | Description |
|---|---|---|
| GetDispMin | public static double GetDispMin(this Axis axis) |
Calculates display minimum: axis.ActualMin + axis.Value * (axis.ActualMax - axis.ActualMin) * (1 - axis.Scale) |
| GetDispMax | public static double GetDispMax(this Axis axis) |
Calculates display maximum: axis.ActualMax - (1 - axis.Value) * (axis.ActualMax - axis.ActualMin) * (1 - axis.Scale) |
3. Invariants
- SaveReportToPDF: The
directoryparameter must be non-null and non-whitespace; otherwise, aDirectoryNotFoundExceptionis thrown. - SaveReportToCSV: The method creates the target directory if it does not exist.
- DataContext Requirement: Both
SaveReportToPDFandSaveReportToCSVrequireMainChart.DataContextto be castable toTestDataSeriesViewModelwith a non-nullGraphDataSeriesproperty. - PDF Paper Size: Determined by
System.Globalization.RegionInfo.CurrentRegion.IsMetric— A4 for metric regions, Letter otherwise. - CSV Data Alignment: The CSV export loop assumes all series in
GraphDataSerieshaveXvalueandYvaluearrays of equal or greater length than the iteration index.
4. Dependencies
External Dependencies (Imports)
| Namespace | Purpose |
|---|---|
DTS.Common.Interface |
Provides IGraphView, ITestDataView, ITestDataSeriesView interfaces |
DTS.Common.Utilities.Logging |
Provides APILogger for logging operations |
DTS.Common.Utils |
Provides FileUtils.GetEncoding() for text encoding |
C1.WPF.Chart / C1.WPF.C1Chart / C1.WPF.C1Chart.Extended |
ComponentOne chart controls (C1FlexChart, Axis, ImageFormat) |
C1.WPF.Pdf |
ComponentOne PDF generation (C1PdfDocument, PaperKind, Font, Pen) |
System.Windows |
WPF core types (Point, Rect, Visibility, MessageBox, etc.) |
System.Windows.Input |
Input types (MouseEventArgs, MouseWheelEventArgs, KeyEventArgs, ModifierKeys) |
System.Windows.Media.Imaging |
Bitmap types (BitmapImage, WriteableBitmap) |
Downstream Dependencies
- Unclear from source alone — These are view components; consumers would typically be ViewModels or other presentation-layer components that reference these views, but no direct consumers are visible in the provided source.
5. Gotchas
-
Substantial Commented-Out Code: Both
TestDataViewandTestDataSeriesViewcontain significant commented-out functionality (zoom/pan features, data point tracking). This suggests incomplete features or deprecated functionality that was never removed. -
Direct Concrete Type Cast:
SaveReportToPDFandSaveReportToCSVcastMainChart.DataContextdirectly toTestDataSeriesViewModel(a concrete class) rather than an interface. This tight coupling could cause runtime exceptions if the DataContext type changes. -
Unsafe GraphColor Cast: In
SaveReportToPDF,ds.GraphColoris cast directly toSolidColorBrushwithout null or type checking:pdf.FillRectangle((ds.GraphColor as System.Windows.Media.SolidColorBrush).Color, ...);This will fail silently or throw if
GraphColoris null or a different brush type. -
Empty Event Handlers:
MainChart_OnKeyUpis entirely empty, andobj_DataPointChanged/MainChart_OnMouseWheelhave all logic commented out. These handlers may be wired up in XAML but do nothing. -
CSV Filename Suffix: CSV files are saved with
.PSD.csvextension, indicating Power Spectral Density data, but this is not validated against actual data content. -
Encoding Fallback:
SaveReportToCSVcatches exceptions when getting encoding and falls back toEncoding.Default, which may produce inconsistent file encodings across different systems.