Files

101 lines
8.1 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common/Interface/DTS.Viewer/ChartOptions/IChartOptionsView.cs
- Common/DTS.Common/Interface/DTS.Viewer/ChartOptions/IChartOptionsViewModel.cs
- Common/DTS.Common/Interface/DTS.Viewer/ChartOptions/IChartOptionsModel.cs
generated_at: "2026-04-16T03:09:08.434841+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "9646cefae729c3f3"
---
# ChartOptions
## Documentation Page: Chart Options Module
### 1. Purpose
This module defines the core interfaces for the *Chart Options* view layer in the DTS Viewer subsystem. It establishes the contract between the UI (`IChartOptionsView`), its data-binding context (`IChartOptionsViewModel`), and the underlying state and business logic (`IChartOptionsModel`). The module enables user interaction with chart configuration options—such as scaling, units, timebase, filtering, cursor visibility, and export functionality—while enforcing separation of concerns via the MVVM pattern. It exists to decouple chart presentation logic from data acquisition and rendering, allowing flexible configuration of chart behavior without tight coupling to specific chart implementations.
### 2. Public Interface
#### `IChartOptionsView`
- **Inherits**: `IBaseView`
- **Description**: Marker interface for the view (e.g., XAML UserControl) responsible for rendering the chart options UI. No additional members beyond base view contract.
#### `IChartOptionsViewModel`
- **Inherits**: `IBaseViewModel`
- **Properties**:
- `IBaseView View { get; set; }` Binds to the associated view instance.
- `IBaseViewModel Parent { get; set; }` Reference to the parent view model (e.g., main chart view model).
- `IChartOptionsModel Model { get; set; }` Reference to the model containing chart configuration state.
- `object ContextSearchRegion { get; set; }` Holds context for a search region (type not specified; likely used for region selection or filtering).
- **Methods**:
- `void PublishChanges()` Commits pending configuration changes (e.g., to chart rendering or data processing).
- `void ResetZoomMethod()` Resets Y-axis zoom to default (likely auto-scale).
- `void ResetTMethod()` Resets T-axis (timebase) zoom to default.
- `void SaveToPDFMethod()` Triggers export of the current chart view to PDF.
- `void ShowCusor(bool value)` Controls visibility of the primary cursor (note: typo in method name—`Cusor` vs. `Cursor`).
- `void ShowMinMaxCursor(bool value)` Controls visibility of min/max cursor indicators.
#### `IChartOptionsModel`
- **Inherits**: `IBaseModel`
- **Properties**:
- `bool SupportsADC { get; set; }` True if *all* channels support analog-to-digital conversion.
- `bool SupportsMV { get; set; }` True if *all* channels support millivolt measurement.
- `bool DisplayingVolts { get; set; }` True if units are displayed in Volts; false implies millivolts.
- `string MVOrV { get; }` Returns `"mV"` or `"V"` based on `DisplayingVolts`.
- `List<double> FullScaleValues { get; set; }` List of available full-scale range values (e.g., [1.0, 2.0, 5.0]).
- `double SelectedFullScaleValue { get; set; }` Currently selected full-scale value.
- `double MinFixedY { get; set; }` / `MaxFixedY { get; set; }` Fixed Y-axis range limits (used when `YRange` is `Fixed`).
- `double MinFixedT { get; set; }` / `MaxFixedT { get; set; }` Fixed T-axis (time) range limits.
- `bool LockedT { get; set; }` True if T-axis range is locked (prevents auto-adjustment).
- `bool LockedY { get; set; }` True if Y-axis range is locked.
- `bool ShowCursor { get; set; }` Controls primary cursor visibility.
- `string CurrentCursorValues { get; set; }` String representation of cursor positions (e.g., `"t=1.23s, y=45.6mV"`).
- `YRangeScaleEnum YRange { get; set; }` Scaling mode for Y-axis (e.g., Auto, Fixed, FullScale).
- `ChartUnitTypeEnum UnitType { get; set; }` Unit type for Y-axis (e.g., Voltage, Pressure).
- `TimeUnitTypeEnum TimeUnitType { get; set; }` Unit type for T-axis (e.g., Seconds, Minutes).
- `string UnitTypeDescription { get; }` Human-readable description of `UnitType` (e.g., `"Voltage (mV)"`).
- `FilterOptionEnum Filter { get; set; }` Selected filter type (e.g., None, LowPass, HighPass).
- `IFilterClass SelectedFilter { get; set; }` Instance of the selected filter implementation (e.g., `ButterworthFilter`).
- `bool IsCursorsAvailable { get; set; }` True if cursor functionality is enabled for the current chart.
- `bool CanPublishChanges { get; set; }` Indicates whether `PublishChanges()` should be allowed (e.g., after validation).
- `bool ReadData { get; set; }` Controls whether new data should be read/refreshed after changes.
- `bool IsDigitalChannel { get; set; }` True if the chart is displaying digital (logic) channel data.
- `bool DecimateData { get; set; }` True if data decimation is applied for performance.
- `long WidthPoints { get; set; }` Number of data points horizontally displayed (e.g., 1000 points).
- **Commands**:
- `DelegateCommand ResetZoomCommand { get; }` Binds to `ResetZoomMethod()`.
- `DelegateCommand ResetTCommand { get; }` Binds to `ResetTMethod()`.
- `DelegateCommand SaveToPDFCommand { get; }` Binds to `SaveToPDFMethod()`.
- **Methods**:
- `void SetSelectedFilterToUnfilteredNoRead()` Resets the filter to "unfiltered" state *without* triggering data reload.
### 3. Invariants
- `IChartOptionsModel.Model` must be non-null and assigned before `IChartOptionsViewModel` operations (e.g., `PublishChanges()`) are invoked.
- `DisplayingVolts` and `MVOrV` must be consistent: `MVOrV` returns `"V"` iff `DisplayingVolts` is `true`.
- `YRange`, `MinFixedY`, `MaxFixedY`, `MinFixedT`, `MaxFixedT`, and `LockedT`/`LockedY` must be coherently interpreted by consumers (e.g., if `LockedY` is `true`, `MinFixedY`/`MaxFixedY` are fixed and unchanging).
- `IsCursorsAvailable` must be `true` for cursor-related methods (`ShowCusor`, `ShowMinMaxCursor`) to have effect.
- `SelectedFilter` must be a valid `IFilterClass` instance when `Filter` is not `FilterOptionEnum.None`.
- `CanPublishChanges` must be `true` before calling `PublishChanges()` to avoid invalid state transitions.
### 4. Dependencies
- **Depends on**:
- `DTS.Common.Base` (for `IBaseView`, `IBaseViewModel`, `IBaseModel`).
- `DTS.Common.Enums.Viewer` (for `YRangeScaleEnum`, `ChartUnitTypeEnum`, `TimeUnitTypeEnum`).
- `DTS.Common.Interface.Sensors.SoftwareFilters` (for `IFilterClass`).
- `Prism.Commands` (for `DelegateCommand`).
- **Used by**:
- Likely consumed by chart rendering/view components (e.g., `IChartView`/`IChartViewModel`) to configure display parameters.
- View models for chart pages or dialogs that expose chart options.
- **Implied consumers**: Any class implementing `IChartOptionsView` (e.g., WPF `UserControl`) and `IChartOptionsViewModel` (e.g., `ChartOptionsViewModel`).
### 5. Gotchas
- **Typo in method name**: `ShowCusor(bool value)` uses `Cusor` instead of `Cursor`. This may cause confusion or mismatches in binding if not consistently handled.
- **Ambiguous `ContextSearchRegion`**: Type is `object` with no documentation on expected structure or usage. Its purpose (e.g., region coordinates, search term) is unclear from this interface alone.
- **`SetSelectedFilterToUnfilteredNoRead()` semantics**: The `NoRead` suffix implies it avoids reloading data, but no documentation clarifies whether this affects `ReadData` or other state.
- **`SupportsADC`/`SupportsMV` are "all channels" checks**: These are *global* flags (not per-channel), meaning partial channel support may not be reflected.
- **`MVOrV` is read-only**: Its value is derived from `DisplayingVolts`; direct mutation is impossible, so consumers must update `DisplayingVolts` instead.
- **No validation rules exposed**: While `CanPublishChanges` exists, there is no documented criteria for when it becomes `true` (e.g., required fields, range checks).
None identified beyond the above.