Files
2026-04-17 14:55:32 -04:00

7.9 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Model/ChartOptionsModel.cs
2026-04-16T13:57:20.201859+00:00 zai-org/GLM-5-FP8 1 a2e58408ee52b3f9

Documentation: ChartOptionsModel.cs

1. Purpose

ChartOptionsModel is a state management class for chart configuration options within the DTS Viewer application. It serves as the data model backing chart visualization controls, managing unit types (EU, mV, V, PSD, FFT), time units, axis scaling modes, filter selections, cursor behavior, and zoom/pan state. The class implements INotifyPropertyChanged via BasePropertyChanged to support MVVM data binding and coordinates with a parent IChartOptionsViewModel to publish configuration changes.


2. Public Interface

Properties

Property Type Access Description
DisplayingVolts bool get/set Controls whether voltage displays as "V" (true) or "mV" (false). Raises OnPropertyChanged for "MVOrV" and "UnitTypeDescription" when changed.
MVOrV string get Returns "V" if DisplayingVolts is true, otherwise "mV".
IsDigitalChannel bool get/set Indicates whether the current channel is digital.
SupportsADC bool get/set Indicates ADC support for the current context.
SupportsMV bool get/set Indicates mV unit support.
UnitType ChartUnitTypeEnum get/set The current unit type (EU, mV, PSD, FFT, etc.). Changing this sets ReadData = true and auto-adjusts Filter.
UnitTypeDescription string get Returns the display string for UnitType. Returns "V" or "mV" when UnitType == ChartUnitTypeEnum.mV.
TimeUnitType TimeUnitTypeEnum get/set Time axis unit. Defaults to TimeUnitTypeEnum.MS. Changing sets ReadData = true.
TimeUnitTypeDescription string get/set String representation of TimeUnitType.
SelectedFilter IFilterClass get/set Currently selected filter class. Changing sets ReadData = true.
MinFixedY double get/set Minimum Y-axis value for fixed scaling.
MaxFixedY double get/set Maximum Y-axis value for fixed scaling.
MinFixedT double get/set Minimum T (time) axis value for fixed scaling.
MaxFixedT double get/set Maximum T (time) axis value for fixed scaling.
FullScaleValues List<double> get/set Returns _euValues if UnitType is EU or PSD, otherwise _fullScaleValues.
SelectedFullScaleValue double get/set Currently selected full-scale value. Defaults to 100.
LockedT bool get/set Whether the time axis is locked.
LockedY bool get/set Whether the Y-axis is locked.
ShowCursor bool get/set Cursor visibility. Setter calls Parent?.ShowCusor(value).
CurrentCursorValues string get/set Current cursor values display string.
YRange YRangeScaleEnum get/set Y-axis range mode. Setting to Fixed automatically sets LockedY = true.
Filter FilterOptionEnum get/set Filter option enum. Changing sets ReadData = true.
Parent IChartOptionsViewModel get/set Parent view model reference.
CanPublishChanges bool get/set Controls whether property changes trigger Parent.PublishChanges(). Defaults to true.
IsCursorsAvailable bool get/set Whether cursors are available for the current context.
T0Cursor bool get/set T0 cursor flag.
MinMaxCursors bool get/set Min/Max cursors flag.
ReadData bool get/set Flag indicating data should be re-read.
IsSaved bool get Saved status (setter not visible in source).
DecimateData bool get/set Getter returns false if UnitType is PSD or FFT, otherwise returns backing field value.
WidthPoints long get/set Width points for decimation.

Commands

Command Type Description
ResetZoomCommand DelegateCommand Executes ResetZoomMethod(), which delegates to Parent.ResetZoomMethod().
ResetTCommand DelegateCommand Executes ResetTMethod(), which delegates to Parent.ResetTMethod().
SaveToPDFCommand DelegateCommand Executes SaveToPDFMethod(), which delegates to Parent.SaveToPDFMethod().

Methods

Method Signature Description
ChartOptionsModel public ChartOptionsModel() Empty constructor.
SetSelectedFilterToUnfilteredNoRead public void SetSelectedFilterToUnfilteredNoRead() Sets SelectedFilter to unfiltered without setting ReadData = true.
OnPropertyChanged public void OnPropertyChanged(string propertyName) Raises PropertyChanged event and conditionally calls Parent?.PublishChanges().

Events

Event Type Description
PropertyChanged PropertyChangedEventHandler Standard INotifyPropertyChanged event.

3. Invariants

  1. UnitType → Filter coupling: When UnitType is set to anything other than EU or PSD, Filter is automatically set to FilterOptionEnum.Unfiltered. When set to EU or PSD, Filter is set to FilterOptionEnum.TestSetupDefault.

  2. YRange → LockedY coupling: Setting YRange to YRangeScaleEnum.Fixed automatically sets LockedY = true.

  3. DecimateData PSD/FFT exclusion: DecimateData getter always returns false when UnitType is ChartUnitTypeEnum.PSD or ChartUnitTypeEnum.FFT, regardless of the backing field value.

  4. FullScaleValues selection: The property returns _euValues (5000, 2500, 1000, 500, 100, 50, 10, 5) for EU or PSD unit types, and _fullScaleValues (200, 100, 50, 20, 10, 5, 1, 0.1) otherwise.

  5. ReadData side effects: Setting UnitType, TimeUnitType, SelectedFilter, or Filter automatically sets ReadData = true.


4. Dependencies

This module depends on:

  • DTS.Common — Common utilities
  • DTS.Common.Classes.SensorsFilterClass implementation
  • DTS.Common.Enums.ViewerChartUnitTypeEnum, TimeUnitTypeEnum, FilterOptionEnum, YRangeScaleEnum
  • DTS.Common.InterfaceIChartOptionsModel interface
  • DTS.Common.Interface.Sensors.SoftwareFiltersIFilterClass interface
  • Prism.CommandsDelegateCommand for MVVM commands
  • Common.Base.BasePropertyChanged — Base class providing SetProperty method for INotifyPropertyChanged implementation

What depends on this module:

  • IChartOptionsViewModel implementations (referenced as Parent property)

5. Gotchas

  1. Typo in method call: In ShowCursor setter, the code calls Parent?.ShowCusor(_showCursor) — note the misspelling "Cusor" instead of "Cursor". This may cause confusion when searching for the method definition.

  2. Conditional PublishChanges suppression: The OnPropertyChanged method explicitly skips calling Parent?.PublishChanges() for specific property names: "CanPublishChanges", "Parent", "ReadData", "UnitTypeDescription", "ShowCursor", "LockedT", "LockedY", "MVOrV", "DisplayingVolts", "DecimateData", "WidthPoints". This is not documented elsewhere and could lead to unexpected behavior.

  3. IsSaved property has no visible implementation: The property has only a getter with no backing field or setter visible in the source. Its behavior is unclear from this file alone.

  4. SetSelectedFilterToUnfilteredNoRead bypasses normal flow: This method directly sets the backing field _selectedFilter and sets ReadData = false, bypassing the normal property setter which would set ReadData = true.

  5. Inconsistent property change patterns: Some properties use SetProperty(ref _field, value, "PropertyName") while others manually check equality and call OnPropertyChanged. This inconsistency may indicate incremental development over time.