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

8.8 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-16T11:19:24.422198+00:00 zai-org/GLM-5-FP8 1 a2e58408ee52b3f9

Documentation: ChartOptionsModel.cs

1. Purpose

ChartOptionsModel is a state-bearing model class that encapsulates all configuration options for chart display within the DTS Viewer application. It manages chart unit types (EU, mV, V, PSD, FFT), time units, Y-axis scaling modes, filter selections, cursor behavior, and axis locking states. The class implements INotifyPropertyChanged (via BasePropertyChanged) to support data binding and coordinates with a parent IChartOptionsViewModel to publish changes and execute commands.


2. Public Interface

Class Signature

public class ChartOptionsModel : Common.Base.BasePropertyChanged, IChartOptionsModel

Properties

Property Type Default Description
DisplayingVolts bool false Toggles between Volts (true) and millivolts (false) display. Raises OnPropertyChanged for "MVOrV" and "UnitTypeDescription" when changed.
MVOrV string Read-only. Returns "V" if DisplayingVolts is true, otherwise "mV".
IsDigitalChannel bool false Indicates whether the channel is digital.
SupportsADC bool true Indicates ADC support.
SupportsMV bool true Indicates millivolt support.
UnitType ChartUnitTypeEnum ChartUnitTypeEnum.EU The unit type for the chart. Changing this sets ReadData = true and auto-adjusts Filter based on unit type.
UnitTypeDescription string Read-only. Returns "V" or "mV" for ChartUnitTypeEnum.mV, otherwise returns UnitType.ToString().
TimeUnitType TimeUnitTypeEnum TimeUnitTypeEnum.MS Time unit for the X-axis. Sets ReadData = true on change.
TimeUnitTypeDescription string "MS" String representation of TimeUnitType.
SelectedFilter IFilterClass FilterClass(Unfiltered) The selected software filter. Sets ReadData = true on change.
MinFixedY double 0.00 Minimum Y-axis value for fixed range.
MaxFixedY double 0.00 Maximum Y-axis value for fixed range.
MinFixedT double 0.00 Minimum X-axis (time) value for fixed range.
MaxFixedT double 0.00 Maximum X-axis (time) value for fixed range.
FullScaleValues List<double> Returns _euValues for EU/PSD unit types, otherwise _fullScaleValues.
SelectedFullScaleValue double 100 Currently selected full-scale value.
LockedT bool false Indicates if the X-axis is locked.
LockedY bool false Indicates if the Y-axis is locked.
ShowCursor bool false Cursor visibility. Calls Parent?.ShowCusor(value) on change.
CurrentCursorValues string "" String representation of current cursor values.
YRange YRangeScaleEnum YRangeScaleEnum.AutoRange Y-axis range mode. Setting to Fixed automatically sets LockedY = true.
Filter FilterOptionEnum FilterOptionEnum.TestSetupDefault Filter option enum. Sets ReadData = true on change.
Parent IChartOptionsViewModel null Reference to parent view model.
CanPublishChanges bool true Controls whether property changes trigger Parent?.PublishChanges().
IsCursorsAvailable bool false Indicates if cursors are available for the current context.
T0Cursor bool false T0 cursor flag.
MinMaxCursors bool false Min/Max cursors flag.
ReadData bool false Flag indicating data should be re-read.
IsSaved bool Read-only auto-property (no setter visible).
DecimateData bool false Getter returns false if UnitType is PSD or FFT, otherwise returns backing field value.
WidthPoints long 0 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 ctor() Empty parameterless constructor.
SetSelectedFilterToUnfilteredNoRead void SetSelectedFilterToUnfilteredNoRead() Sets _selectedFilter to FilterClass(Unfiltered) with ReadData = false. Raises OnPropertyChanged("SelectedFilter").
OnPropertyChanged void OnPropertyChanged(string propertyName) Raises PropertyChanged event. Conditionally calls Parent?.PublishChanges() unless the property is in an exclusion list.

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 UnitType is EU or PSD, Filter is set to FilterOptionEnum.TestSetupDefault.

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

  3. DecimateData conditional return: The DecimateData getter always returns false when UnitType is ChartUnitTypeEnum.PSD or ChartUnitTypeEnum.FFT, regardless of the backing field _decimateData.

  4. FullScaleValues selection: The property returns _euValues list when UnitType is EU or PSD; otherwise returns _fullScaleValues.

  5. Change publishing exclusion: The following properties do not trigger Parent?.PublishChanges() when changed:

    • CanPublishChanges, Parent, ReadData, UnitTypeDescription, ShowCursor, LockedT, LockedY, MVOrV, DisplayingVolts, DecimateData, WidthPoints

4. Dependencies

This Module Depends On

  • System, System.Collections.Generic, System.ComponentModel (BCL)
  • DTS.Common — Base namespace
  • DTS.Common.Base.BasePropertyChanged — Base class providing SetProperty method
  • DTS.Common.Classes.SensorsFilterClass implementation
  • DTS.Common.Enums.ViewerChartUnitTypeEnum, TimeUnitTypeEnum, FilterOptionEnum, YRangeScaleEnum
  • DTS.Common.InterfaceIChartOptionsModel (implied), IChartOptionsViewModel
  • DTS.Common.Interface.Sensors.SoftwareFiltersIFilterClass
  • Prism.CommandsDelegateCommand

What Depends On This Module

  • Unknown from source alone — The IChartOptionsViewModel interface references this model via the Parent property, but concrete consumers are not visible in this file.

5. Gotchas

  1. Typo in method call: In the ShowCursor setter, the code calls Parent?.ShowCusor(_showCursor) — note the spelling "Cusor" instead of "Cursor". This is either a typo in the method name on IChartOptionsViewModel or a historical naming quirk.

  2. SetSelectedFilterToUnfilteredNoRead exists as a workaround: The method SetSelectedFilterToUnfilteredNoRead() specifically bypasses the automatic ReadData = true behavior that occurs when setting SelectedFilter via the property. This suggests the automatic data refresh is sometimes undesirable and requires explicit circumvention.

  3. Inconsistent property setter patterns: Some properties use SetProperty(ref _field, value, "PropertyName") (e.g., IsDigitalChannel, DisplayingVolts), while others manually implement equality checks and OnPropertyChanged calls (e.g., UnitType, MinFixedY). This inconsistency may reflect different authors or refactoring over time.

  4. IsSaved is unassigned: The IsSaved property has no setter and no initialization. The ReSharper annotation // ReSharper disable UnassignedGetOnlyAutoProperty at the top of the file suppresses warnings about this. Accessing this property will return default(bool) (false).

  5. ReadData side effects are implicit: Setting UnitType, TimeUnitType, SelectedFilter, or Filter silently sets ReadData = true. Callers must be aware that these property changes have side effects beyond the property value itself.

  6. Historical comment FB 13120: The comment // FB 13120 does not need to set SelectedFilter any more since it's not using enum and // FB 13120 use filter class instead of cfc filter enum reference a past bug/feature (likely FogBugz case 13120) where filter handling was refactored from an enum to a class-based approach.