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#
4.2 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.Panes.PropertiesPane"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WaveDudeNext.WPF.Panes"
             xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
             xmlns:converters="clr-namespace:WaveDudeNext.WPF.Converters"
             xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext"
             xmlns:rendering="clr-namespace:WaveDudeNext.Rendering;assembly=WaveDudeNext">

	<!-- one view per model type; the content control picks the template by the selected object's type -->
	<UserControl.Resources>
		<DataTemplate DataType="{x:Type model:Project}">
			<views:ProjectView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:Scene}">
			<views:SceneView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:Simulation}">
			<views:SimulationView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:Display}">
			<views:DisplayView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:Source}">
			<views:SourceView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:LensPart}">
			<views:LensPartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:PolygonPart}">
			<views:PolygonPartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:RectanglePart}">
			<views:RectanglePartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:EllipsePart}">
			<views:EllipsePartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:TrianglePart}">
			<views:TrianglePartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:OutlinePart}">
			<views:OutlinePartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:FiberPart}">
			<views:FiberPartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:BraggReflectorPart}">
			<views:BraggReflectorPartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:GrinLensPart}">
			<views:GrinLensPartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:ZonePlatePart}">
			<views:ZonePlatePartView />
		</DataTemplate>
		<!-- an implicit template is found along the base classes, so the three gate kinds share one -->
		<DataTemplate DataType="{x:Type model:LogicGatePart}">
			<views:LogicGatePartView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type model:Probe}">
			<views:ProbeView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type rendering:ColorScheme}">
			<views:ColorSchemeView />
		</DataTemplate>
		<DataTemplate DataType="{x:Type converters:NamedCollection}">
			<views:CollectionView />
		</DataTemplate>
	</UserControl.Resources>

	<Grid>
		<ContentControl Focusable="False"
		                Content="{Binding SelectedObject, RelativeSource={RelativeSource AncestorType={x:Type local:PropertiesPane}}}" />
		<TextBlock Margin="6" Foreground="{DynamicResource GrayText}" Text="{DynamicResource NoSelection}">
			<TextBlock.Style>
				<Style TargetType="{x:Type TextBlock}">
					<Setter Property="Visibility" Value="Collapsed" />
					<Style.Triggers>
						<DataTrigger Binding="{Binding SelectedObject, RelativeSource={RelativeSource AncestorType={x:Type local:PropertiesPane}}}" Value="{x:Null}">
							<Setter Property="Visibility" Value="Visible" />
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</TextBlock.Style>
		</TextBlock>
	</Grid>
</UserControl>