Skip to content

Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.

C#
5.5 KB
Raw Blame
<!--
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2026 Alexander Graef <[email protected]>

This file is part of WaveDude Next, a 2D wave simulator.

Based on the work of
  Jeroen Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
    <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
  0x23 (Diffraction Limited), author of WaveSimulator2D
    <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>

WaveDude Next is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<https://www.gnu.org/licenses/>.
-->

<UserControl x:Class="WaveDudeNext.WPF.Views.ShapeMaterialView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:WaveDudeNext.WPF.Controls"
             xmlns:meta="clr-namespace:WaveDudeNext.WPF.Markup"
             xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">

	<UserControl.Resources>
		<!-- a mirror has no index, no coating and no absorption -->
		<Style x:Key="GlassOnly" TargetType="{x:Type controls:NumberBox}" BasedOn="{StaticResource {x:Type controls:NumberBox}}">
			<Style.Triggers>
				<DataTrigger Binding="{Binding Mirror}" Value="True">
					<Setter Property="IsEnabled" Value="False" />
				</DataTrigger>
			</Style.Triggers>
		</Style>
		<Style x:Key="GlassOnlyCombo" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource EnumComboBox}">
			<Style.Triggers>
				<DataTrigger Binding="{Binding Mirror}" Value="True">
					<Setter Property="IsEnabled" Value="False" />
				</DataTrigger>
			</Style.Triggers>
		</Style>
		<Style x:Key="GlassOnlyCheck" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource {x:Type CheckBox}}">
			<Style.Triggers>
				<DataTrigger Binding="{Binding Mirror}" Value="True">
					<Setter Property="IsEnabled" Value="False" />
				</DataTrigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>

	<!-- the material of a shape part (polygon, rectangle, triangle, outline): mirror or glass, the index, the coating, the absorption -->
	<StackPanel>
		<Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionMaterial}" />
		<controls:FormPanel>
			<CheckBox controls:FormPanel.FullWidth="True" Content="{meta:Label model:ShapePart.Mirror}"
			          IsChecked="{Binding Mirror}" ToolTip="{meta:Hint model:ShapePart.Mirror}" AutomationProperties.AutomationId="PartMirror" />

			<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.RefractiveIndex}" />
			<controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding RefractiveIndex}" Minimum="1" Maximum="2.55" Increment="0.01"
			                    ToolTip="{meta:Hint model:ShapePart.RefractiveIndex}" AutomationProperties.AutomationId="PartIndex" />

			<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.Coating}" />
			<controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding Coating}" Minimum="0" Maximum="50"
			                    ToolTip="{meta:Hint model:ShapePart.Coating}" AutomationProperties.AutomationId="PartCoating" />

			<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:CoatedPart.CoatingProfile}" />
			<ComboBox Style="{StaticResource GlassOnlyCombo}" ItemsSource="{meta:EnumValues model:CoatingProfile}" SelectedItem="{Binding CoatingProfile}"
			          ToolTip="{meta:Hint model:CoatedPart.CoatingProfile}" AutomationProperties.AutomationId="PartCoatingProfile" />

			<!-- the faces by their outward normal: front toward a source on the left, back away from it, the rest sides (2026-10-29) -->
			<CheckBox controls:FormPanel.FullWidth="True" Style="{StaticResource GlassOnlyCheck}" Content="{meta:Label model:CoatedPart.FrontCoated}"
			          IsChecked="{Binding FrontCoated}" ToolTip="{meta:Hint model:CoatedPart.FrontCoated}" AutomationProperties.AutomationId="PartFrontCoated" />
			<CheckBox controls:FormPanel.FullWidth="True" Style="{StaticResource GlassOnlyCheck}" Content="{meta:Label model:CoatedPart.BackCoated}"
			          IsChecked="{Binding BackCoated}" ToolTip="{meta:Hint model:CoatedPart.BackCoated}" AutomationProperties.AutomationId="PartBackCoated" />
			<CheckBox controls:FormPanel.FullWidth="True" Style="{StaticResource GlassOnlyCheck}" Content="{meta:Label model:CoatedPart.SidesCoated}"
			          IsChecked="{Binding SidesCoated}" ToolTip="{meta:Hint model:CoatedPart.SidesCoated}" AutomationProperties.AutomationId="PartSidesCoated" />

			<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.Absorption}" />
			<controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding Absorption}" Minimum="0" Maximum="255" Increment="5"
			                    ToolTip="{meta:Hint model:ShapePart.Absorption}" AutomationProperties.AutomationId="PartAbsorption" />

			<TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.AbsorptionRamp}" />
			<controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding AbsorptionRamp}" Minimum="1" Maximum="400" Increment="5"
			                    ToolTip="{meta:Hint model:ShapePart.AbsorptionRamp}" AutomationProperties.AutomationId="PartAbsorptionRamp" />
		</controls:FormPanel>
	</StackPanel>
</UserControl>