Skip to content

Comments

Fixes #2767 Make preview option sticky in projects#2768

Merged
rwmcintosh merged 2 commits intodevelopfrom
2767-make-preview-option-sticky-in-projects
Feb 11, 2026
Merged

Fixes #2767 Make preview option sticky in projects#2768
rwmcintosh merged 2 commits intodevelopfrom
2767-make-preview-option-sticky-in-projects

Conversation

@rwmcintosh
Copy link
Member

@rwmcintosh rwmcintosh commented Feb 9, 2026

Fixes #2767 Make preview option sticky in projects

Description

Allows the export preview option to be retained by project save, and also added to templates, and used from templates.

Type of change

Please mark relevant options with an x in the brackets.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires documentation changes (link at least one user or developer documentation issue):
  • Algorithm update - updates algorithm documentation/questions/answers etc.
  • Other (please describe):

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Integration tests
  • Unit tests
  • Manual tests
  • No tests required

Reviewer checklist

Mark everything that needs to be checked before merging the PR.

  • Check if the code is well documented
  • Check if the behavior is what is expected
  • Check if the code is well tested
  • Check if the code is readable and well formatted
  • Additional checks (document below if any)
  • Check if documentation update issue(s) are created if the option This change requires a documentation update above is selected

Screenshots (if appropriate):

Questions (if appropriate):

Summary by CodeRabbit

  • New Features

    • Watermark refresh now updates dynamically when chart size changes and can be triggered externally.
    • Chart preview settings are preserved, serialized, and propagated when creating or applying templates.
  • Tests

    • Added tests to verify preview settings transfer and watermark refresh behavior.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Adds persistence and UI propagation for chart PreviewSettings: mapper copies PreviewSettings to templates, serializers include PreviewSettings in XML, template-to-chart initialization assigns PreviewSettings to charts, and the presenter/view expose/update watermark state accordingly.

Changes

Cohort / File(s) Summary
Chart → Template Mapping
src/OSPSuite.Core/Chart/Mappers/CurveChartToCurveChartTemplateMapper.cs
Mapper now copies PreviewSettings from CurveChart into CurveChartTemplate.
Chart & Template Serialization
src/OSPSuite.Core/Serialization/Chart/CurveChartXmlSerializer.cs, src/OSPSuite.Core/Serialization/Chart/CurveChartTemplateXmlSerializer.cs
Added XML mapping for PreviewSettings to include it during serialize/deserialize.
Template → Chart Initialization
src/OSPSuite.Presentation/Services/ChartFromTemplateService.cs
After curves are added, assigns chart.PreviewSettings = template.PreviewSettings.
Display Presenter & View
src/OSPSuite.Presentation/Presenters/Charts/ChartDisplayPresenter.cs, src/OSPSuite.UI/Views/Charts/ChartDisplayView.cs
Added UpdateWatermark() to presenter; view triggers watermark update on resize; presenter shows watermark when AutoUpdateEnabled.
Tests
tests/OSPSuite.Core.Tests/Mappers/CurveChartToCurveChartTemplateMapperSpecs.cs, tests/OSPSuite.Presentation.Tests/Presentation/ChartFromTemplateServiceSpecs.cs
Tests updated/added to assert PreviewSettings is propagated in mapping and template-to-chart initialization.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Chart
    participant Mapper
    participant Template
    participant Serializer
    participant Storage
    participant Loader
    participant Service
    participant Presenter
    participant View

    User->>Chart: set PreviewSettings
    User->>Storage: save project
    Chart->>Mapper: MapFrom(chart)
    Mapper->>Template: copy PreviewSettings
    Template->>Serializer: Serialize (includes PreviewSettings)
    Serializer->>Storage: write XML

    User->>Storage: load project
    Storage->>Loader: read XML
    Loader->>Template: Deserialize (restores PreviewSettings)
    Template->>Service: InitializeChartFromTemplate
    Service->>Chart: assign PreviewSettings
    Chart->>Presenter: notify
    Presenter->>View: UpdateWatermark()
    View->>User: display watermark state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code to keep settings tight,
Saved them in XML so they stay in sight,
Mapper, service, presenter—linked in a row,
Watermark dances to the preview's glow,
A sticky small change, and the charts say "hooray!" 🎨📈

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: making the preview option persistent across project save/load cycles.
Linked Issues check ✅ Passed The PR implements persistence for the chart preview option across project save/load by adding PreviewSettings to mappers, serializers, and template services, directly addressing issue #2767.
Out of Scope Changes check ✅ Passed All changes are directly related to the preview option persistence feature: mapper updates, XML serialization support, template service integration, watermark UI refresh, and corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2767-make-preview-option-sticky-in-projects

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
tests/OSPSuite.Core.Tests/Mappers/CurveChartToCurveChartTemplateMapperSpecs.cs (1)

88-92: Nit: assertion direction is reversed compared to the rest of the file.

Throughout this test class (e.g., Line 63), the convention is _curveChartTemplate.<prop>.ShouldBeEqualTo(_curveChart.<prop>) — mapped result on the left, source on the right. Line 91 has it flipped. Not a functional issue, but worth aligning for consistency.

Suggested fix
      [Observation]
      public void should_have_the_preview_settings_set()
      {
-         _curveChart.PreviewSettings.ShouldBeEqualTo(_curveChartTemplate.PreviewSettings);
+         _curveChartTemplate.PreviewSettings.ShouldBeEqualTo(_curveChart.PreviewSettings);
      }

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@tests/OSPSuite.Core.Tests/Mappers/CurveChartToCurveChartTemplateMapperSpecs.cs`:
- Around line 88-92: The test should not assert a value against itself; in the
should_have_the_preview_settings_set test replace the self-comparison of
_curveChart.PreviewSettings with a comparison that verifies the mapping
propagated the value to the target, e.g., assert that
_curveChartTemplate.PreviewSettings equals _curveChart.PreviewSettings; update
the assertion in the should_have_the_preview_settings_set method to compare
_curveChartTemplate.PreviewSettings with _curveChart.PreviewSettings.

Comment on lines +194 to +198

/// <summary>
/// Applies the watermark to the chart if the chart is in preview mode and auto update is enabled, otherwise does nothing
/// </summary>
void UpdateWatermark();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but only if the show watermark user option is enabled, correct?

Copy link
Member Author

@rwmcintosh rwmcintosh Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's covered by ApplicationSettings

public string WatermarkTextToUse => UseWatermark.GetValueOrDefault(false) ? WatermarkText : null;

@rwmcintosh rwmcintosh merged commit db6ece2 into develop Feb 11, 2026
6 checks passed
@rwmcintosh rwmcintosh deleted the 2767-make-preview-option-sticky-in-projects branch February 11, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make preview option sticky in projects

2 participants