7.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:18:03.613000+00:00 | zai-org/GLM-5-FP8 | 1 | 7f2f2e90f6f17587 |
Documentation: ChartOptionsViewModel
1. Purpose
ChartOptionsViewModel is a Prism-based view model that manages user-configurable chart display options within the DTS Viewer application. It serves as an intermediary between chart option UI controls and the underlying chart rendering system, handling unit type selection (EU, mV, ADC), axis range configuration, cursor visibility, and PDF export functionality. The module supports multiple parent contexts including IViewerMainViewModel and IPSDReportMainViewModel, with different default configurations based on the parent type.
2. Public Interface
Constructor
public ChartOptionsViewModel(
IChartOptionsView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
Initializes the view model, sets up the view's DataContext, creates interaction requests, and subscribes to ChartAxisChangedEvent.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
Parent |
IBaseViewModel |
get/set | Reference to the parent view model; used for event filtering. |
NotificationRequest |
InteractionRequest<Notification> |
get | Prism interaction request for notifications. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
get | Prism interaction request for confirmations. |
View |
IBaseView |
get/set | The associated view interface. |
Model |
IChartOptionsModel |
get/set | The chart options model; resolves from container on set. Raises OnPropertyChanged("Model"). |
ContextSearchRegion |
object |
get/set | Unused in visible code. |
IsMenuIncluded |
bool |
get/set | Hides base property. |
IsNavigationIncluded |
bool |
get/set | Hides base property. |
IsBusy |
bool |
get/set | Hides base property. |
IsDirty |
bool |
get | Always returns default value; never assigned. |
ChartOptionsVisability |
bool |
get/set | Controls visibility of chart options UI. Raises property changed notification. |
ClearMarkersCommand |
DelegateCommand |
get | Lazy-initialized command that calls ClearMarkersMethod(). |
Methods
public override void Initialize()
Empty override; performs no operations.
public override void Initialize(object parameter)
Initializes the view model with a parent context. Subscribes to events, resolves the model from Unity container, and configures defaults based on parameter type:
- If
parameter is IViewerMainViewModel: SetsModel.DecimateData = true - If
parameter is Tuple<IBaseViewModel, string>whereItem1isIPSDReportMainViewModel: Configures based onchartTypestring ("Graph" vs other)
public void ShowMinMaxCursor(bool value)
Publishes CursorShowMinMaxChangedEvent with the given boolean value.
public void ResetZoomMethod()
Sets Model.YRange to YRangeScaleEnum.AutoRange and publishes ResetZoomChangedEvent with true.
public void ResetTMethod()
Publishes ResetZoomChangedEvent with false.
public void SaveToPDFMethod()
Publishes SaveToPDFRequestedEvent with the stored Directory path.
public void PublishChanges()
Publishes ChartOptionsChangedEvent with a ChartOptionsChangedEventArg containing ParentVM, Model, and ChartType.
public void ShowCusor(bool value)
Publishes CursorShowChangedEvent with the given boolean value.
public new void OnPropertyChanged(string propertyName)
Raises the PropertyChanged event for the specified property name.
Events
public new event PropertyChangedEventHandler PropertyChanged
Hides the base class event; raised by OnPropertyChanged.
3. Invariants
-
Model Resolution:
Modelmust be resolved fromIUnityContainerbefore use; it is not resolved in the constructor but inInitialize(object parameter). -
Event Filtering: All received events are filtered by comparing
args?.ParentVMtoParent. Events from other parent contexts are ignored. -
Publish Guard Pattern: When programmatically modifying
Modelproperties in response to events (e.g., inOnChartAxisChangedEvent),Model.CanPublishChangesmust be set tofalsebefore modifications and restored totrueafterward to prevent recursive event publishing. -
Log Scale Constraint: When
chartType == "Graph",Model.MinFixedYis set to1e-12because log scale cannot handle zero. -
Unit Type Fallback: If channels do not support ADC or mV (determined by
AllChannelsSupportADC/AllChannelsSupportmV), theModel.UnitTypeis automatically reset toChartUnitTypeEnum.EU.
4. Dependencies
This Module Depends On
| Namespace | Types Used |
|---|---|
DTS.Common.Base |
BaseViewModel<T>, IBaseViewModel |
DTS.Common.Enums.Viewer |
ChartUnitTypeEnum, YRangeScaleEnum, FilterOptionEnum |
DTS.Common.Enums.Hardware |
HardwareConstants.IsTSRAIRSerialNumber() |
DTS.Common.Events |
ChartAxisChangedEvent, CursorsAlailableChangedEvent, GraphSelectedChannelsNotification, CursorShowMinMaxChangedEvent, ResetZoomChangedEvent, SaveToPDFRequestedEvent, ChartOptionsChangedEvent, CursorShowChangedEvent, CursorsClearChangedEvent |
DTS.Common.Interface |
IChartOptionsViewModel, IChartOptionsModel, IChartOptionsView, IBaseView, IViewerMainViewModel, IPSDReportMainViewModel, ITestChannel |
DTS.Common.Interactivity |
InteractionRequest<T>, Notification, Confirmation |
Prism.Events |
IEventAggregator |
Prism.Regions |
IRegionManager |
Prism.Commands |
DelegateCommand |
Unity |
IUnityContainer |
Modules That Depend On This Module
Cannot be determined from source alone; would require analysis of consumers of IChartOptionsViewModel.
5. Gotchas
-
Copy-Paste Error in XML Comment: The constructor's XML documentation states "Creates a new instance of the TestSummaryViewModel" — this is incorrect; the class is
ChartOptionsViewModel. -
Typo:
ChartOptionsVisability: Property name should beChartOptionsVisibility. -
Typo:
ShowCusor: Method name should beShowCursor. -
Typo:
OnCursorsAlailableChanged: Event handler and event nameCursorsAlailableChangedEventshould beCursorsAvailableChanged. -
Hidden Base Members: Multiple properties (
IsMenuIncluded,IsNavigationIncluded,IsBusy,IsDirty,ConfirmationRequest,Model,PropertyChanged,OnPropertyChanged) use thenewkeyword to hide base class members. This may cause unexpected behavior when casting to base types. -
Unused
IsDirtyProperty: The property has only a getter and is never assigned a value, making it perpetuallyfalse(default). -
Commented-Out Constructor Code: Lines 55-57 are commented out, suggesting initialization logic was moved to
Initialize(object parameter). -
Hardcoded Magic Strings: Axis comparison uses literal strings
"Y"and"X"inOnChartAxisChangedEvent;chartTypecomparison uses literal"Graph". -
ADC/mV Support Detection: Both
AllChannelsSupportADCandAllChannelsSupportmVuse identical logic (checking for TSR AIR serial numbers). The comment indicates this is a temporary implementation that may need future refinement for calculated channels.