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

7.5 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/ViewModel/ChartOptionsViewModel.cs
2026-04-16T13:55:59.501828+00:00 zai-org/GLM-5-FP8 1 7f2f2e90f6f17587

Documentation: ChartOptionsViewModel

1. Purpose

ChartOptionsViewModel is a Prism-based ViewModel that manages chart configuration options for the DTS Viewer application. It serves as an intermediary between chart views and the event system, handling axis range settings, unit type selection (EU, mV, ADC), cursor visibility controls, and publishing chart option changes to other application components. The module supports multiple parent contexts including IViewerMainViewModel and IPSDReportMainViewModel, with different initialization behaviors for each.


2. Public Interface

Constructor

public ChartOptionsViewModel(
    IChartOptionsView view, 
    IRegionManager regionManager, 
    IEventAggregator eventAggregator, 
    IUnityContainer unityContainer)

Initializes the ViewModel, sets up interaction requests, and subscribes to ChartAxisChangedEvent.

Properties

Property Type Description
Parent IBaseViewModel Reference to the parent ViewModel.
NotificationRequest InteractionRequest<Notification> Prism interaction request for notifications.
ConfirmationRequest InteractionRequest<Confirmation> Prism interaction request for confirmations.
View IBaseView Associated view instance.
Model IChartOptionsModel The chart options model; setter triggers OnPropertyChanged("Model").
ContextSearchRegion object Region context for search functionality.
IsMenuIncluded bool Hides base member; menu inclusion flag.
IsNavigationIncluded bool Hides base member; navigation inclusion flag.
IsBusy bool Hides base member; busy state indicator.
IsDirty bool Hides base member; dirty state (get-only).
ChartOptionsVisability bool Controls visibility of chart options UI; defaults to false.
ClearMarkersCommand DelegateCommand Command that invokes ClearMarkersMethod().

Methods

Method Signature Description
Initialize override void Initialize() Empty override; no implementation.
Initialize override void Initialize(object parameter) Main initialization accepting IViewerMainViewModel or Tuple<IBaseViewModel, string> containing IPSDReportMainViewModel. Sets up model, subscriptions, and configures based on parameter type.
ShowMinMaxCursor void ShowMinMaxCursor(bool value) Publishes CursorShowMinMaxChangedEvent with the boolean value.
ResetZoomMethod void ResetZoomMethod() Sets Model.YRange to AutoRange and publishes ResetZoomChangedEvent(true).
ResetTMethod void ResetTMethod() Publishes ResetZoomChangedEvent(false).
SaveToPDFMethod void SaveToPDFMethod() Publishes SaveToPDFRequestedEvent with the Directory path.
PublishChanges void PublishChanges() Publishes ChartOptionsChangedEvent with ChartOptionsChangedEventArg containing ParentVM, Model, and ChartType.
ShowCusor void ShowCusor(bool value) Publishes CursorShowChangedEvent with the boolean value.
OnPropertyChanged new void OnPropertyChanged(string propertyName) Raises PropertyChanged event.

3. Invariants

  1. Model Resolution: Model must be resolved via _unityContainer.Resolve<IChartOptionsModel>() before use; it is not resolved in the constructor but in Initialize(object parameter).

  2. Parent Matching for Events: Event handlers (OnChartAxisChangedEvent, OnGraphSelectedChannelsChanged) check args?.ParentVM != Parent and return early if the event is not intended for this instance.

  3. Publish Control: Model.CanPublishChanges must be true for changes to propagate via PublishChanges(). It is set to false during batch configuration updates.

  4. Unit Type Fallback: If channels do not support ADC or mV (determined by AllChannelsSupportADC / AllChannelsSupportmV), the UnitType falls back to ChartUnitTypeEnum.EU.

  5. ADC/mV Support Detection: Both AllChannelsSupportADC and AllChannelsSupportmV return false if any channel's parent module has a TSR AIR serial number (checked via HardwareConstants.IsTSRAIRSerialNumber).

  6. Graph Chart Type Constraints: When chartType == "Graph", the model is configured with:

    • UnitType = ChartUnitTypeEnum.PSD
    • YRange = YRangeScaleEnum.Fixed
    • MaxFixedY = 1
    • MinFixedY = 1e-12 (non-zero for log scale)
    • DecimateData = false

4. Dependencies

This Module Depends On:

  • DTS.Common.Base - BaseViewModel<IChartOptionsViewModel>
  • DTS.Common.Enums.Viewer - ChartUnitTypeEnum, YRangeScaleEnum, FilterOptionEnum
  • DTS.Common.Events - ChartAxisChangedEvent, CursorsAlailableChangedEvent, GraphSelectedChannelsNotification, CursorShowMinMaxChangedEvent, ResetZoomChangedEvent, SaveToPDFRequestedEvent, ChartOptionsChangedEvent, CursorShowChangedEvent, CursorsClearChangedEvent
  • DTS.Common.Interface - IChartOptionsViewModel, IChartOptionsModel, IChartOptionsView, IBaseViewModel, IBaseView, IViewerMainViewModel, IPSDReportMainViewModel, ITestChannel
  • DTS.Common.Interactivity - Interaction requests
  • DTS.Common.Enums.Hardware - HardwareConstants.IsTSRAIRSerialNumber()
  • Prism.Events - IEventAggregator
  • Prism.Regions - IRegionManager
  • Prism.Commands - DelegateCommand
  • Unity - IUnityContainer

What Depends On This Module:

  • Not explicitly shown in source; inferred consumers include:
    • IChartOptionsView implementations
    • IViewerMainViewModel implementations
    • IPSDReportMainViewModel implementations

5. Gotchas

  1. Misleading XML Documentation: The constructor's XML comment references TestSummaryViewModel instead of ChartOptionsViewModel — appears to be copy-paste tech debt.

  2. new Keyword Hiding: Multiple members (IsMenuIncluded, IsNavigationIncluded, IsBusy, IsDirty, ConfirmationRequest, Model, PropertyChanged, OnPropertyChanged) use the new keyword to hide base class members. This can cause unexpected behavior when casting to base types.

  3. Typo in Property Name: ChartOptionsVisability should be ChartOptionsVisibility.

  4. Typo in Method Name: ShowCusor should be ShowCursor.

  5. Typo in Event Handler: OnCursorsAlailableChanged and CursorsAlailableChangedEvent misspell "Available" as "Alailable".

  6. Identical ADC/mV Logic: AllChannelsSupportADC and AllChannelsSupportmV have identical implementations. The comment in AllChannelsSupportADC suggests this may be placeholder logic based on serial numbers, with future sophistication planned.

  7. Unused/Private Fields: Several ReSharper suppressions (UnassignedGetOnlyAutoProperty, NotAccessedField.Local, UnusedAutoPropertyAccessor.Local) suggest dead code or incomplete implementations.

  8. Commented-Out Constructor Code: Lines resolving and assigning Model in the constructor are commented out, suggesting initialization was moved to Initialize(object parameter).

  9. Directory Property Purpose Unclear: The Directory property is set from the first selected channel's BinaryFilePath and used only in SaveToPDFMethod(). The relationship between chart options and this directory is not documented.