Skip to content

Commit

Permalink
Add IsTopBottomViewReverseOriented property for Wpf.HelixViewport3D (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MauNguyenVan authored Mar 18, 2024
1 parent 675c903 commit c096f11
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<StackPanel Grid.Column="0">
<WrapPanel >
<CheckBox IsChecked="{Binding ElementName=viewport, Path=IsViewCubeEdgeClicksEnabled}" >Enable Edge click</CheckBox>
<CheckBox IsChecked="{Binding ElementName=viewport, Path=IsTopBottomViewOrientedToFrontBack}" >IsTopBottomViewOrientedToFrontBack</CheckBox>
<CheckBox IsChecked="{Binding ElementName=viewport, Path=IsTopBottomViewReverseOriented}">IsTopBottomViewReverseOriented</CheckBox>
<CheckBox IsChecked="{Binding ElementName=viewport, Path=IsTopBottomViewOrientedToFrontBack}">IsTopBottomViewOrientedToFrontBack</CheckBox>
</WrapPanel>
<WrapPanel >
<TextBlock>ModelUpDirectionX</TextBlock>
Expand Down
22 changes: 22 additions & 0 deletions Source/HelixToolkit.Wpf.Shared/Controls/HelixViewport3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ public class HelixViewport3D : ItemsControl, IHelixViewport3D
public static readonly DependencyProperty IsMoveEnabledProperty = DependencyProperty.Register(
"IsMoveEnabled", typeof(bool), typeof(HelixViewport3D), new UIPropertyMetadata(true));

/// <summary>
/// Identifies the <see cref="IsTopBottomViewReverseOriented"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsTopBottomViewReverseOrientedProperty =
DependencyProperty.Register("IsTopBottomViewReverseOriented", typeof(bool), typeof(HelixViewport3D), new PropertyMetadata(false));

/// <summary>
/// Identifies the <see cref="IsTopBottomViewOrientedToFrontBack"/> dependency property.
/// </summary>
Expand Down Expand Up @@ -1922,6 +1928,22 @@ public bool IsMoveEnabled
}
}

/// <summary>
/// Gets or sets a value indicating whether the top and bottom views reverse oriented.
/// </summary>
public bool IsTopBottomViewReverseOriented
{
get
{
return (bool)GetValue(IsTopBottomViewReverseOrientedProperty);
}

set
{
SetValue(IsTopBottomViewReverseOrientedProperty, value);
}
}

/// <summary>
/// Gets or sets a value indicating whether the top and bottom views are oriented to front and back.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Source/HelixToolkit.Wpf.Shared/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
EnableEdgeClicks="{Binding IsViewCubeEdgeClicksEnabled, RelativeSource={RelativeSource TemplatedParent}}"
FrontText="{Binding ViewCubeFrontText, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding IsRotationEnabled, RelativeSource={RelativeSource TemplatedParent}}"
IsTopBottomViewReverseOriented="{Binding IsTopBottomViewReverseOriented, RelativeSource={RelativeSource TemplatedParent}}"
IsTopBottomViewOrientedToFrontBack="{Binding IsTopBottomViewOrientedToFrontBack, RelativeSource={RelativeSource TemplatedParent}}"
LeftText="{Binding ViewCubeLeftText, RelativeSource={RelativeSource TemplatedParent}}"
ModelUpDirection="{Binding ModelUpDirection, RelativeSource={RelativeSource TemplatedParent}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public class ViewCubeVisual3D : ModelVisual3D
public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register(
"IsEnabled", typeof(bool), typeof(ViewCubeVisual3D), new UIPropertyMetadata(true));

/// <summary>
/// Identifies the <see cref="IsTopBottomViewReverseOriented"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsTopBottomViewReverseOrientedProperty =
DependencyProperty.Register("IsTopBottomViewReverseOriented", typeof(bool), typeof(ViewCubeVisual3D), new PropertyMetadata(false, VisualModelChanged));

/// <summary>
/// Identifies the <see cref="IsTopBottomViewOrientedToFrontBack"/> dependency property.
/// </summary>
Expand Down Expand Up @@ -303,6 +309,22 @@ public bool IsEnabled
}
}

/// <summary>
/// Gets or sets a value indicating whether the top and bottom views reverse oriented.
/// </summary>
public bool IsTopBottomViewReverseOriented
{
get
{
return (bool)GetValue(IsTopBottomViewReverseOrientedProperty);
}

set
{
SetValue(IsTopBottomViewReverseOrientedProperty, value);
}
}

/// <summary>
/// Gets or sets a value indicating whether the top and bottom views are oriented to front and back.
/// </summary>
Expand Down Expand Up @@ -507,15 +529,23 @@ void CreateCubeFaces()
AddCubeFace(cubeFaceModels[CubeFaces.Back], -frontVector, upVector, GetCubeFaceColor(CubeFaces.Back), BackText);
AddCubeFace(cubeFaceModels[CubeFaces.Left], leftVector, upVector, GetCubeFaceColor(CubeFaces.Left), LeftText);
AddCubeFace(cubeFaceModels[CubeFaces.Right], -leftVector, upVector, GetCubeFaceColor(CubeFaces.Right), RightText);

Vector3D tempFrontVector = frontVector;
Vector3D tempLeftVector = leftVector;
if (IsTopBottomViewReverseOriented)
{
tempFrontVector = -frontVector;
tempLeftVector = -leftVector;
}
if (IsTopBottomViewOrientedToFrontBack)
{
AddCubeFace(cubeFaceModels[CubeFaces.Top], upVector, frontVector, GetCubeFaceColor(CubeFaces.Top), TopText);
AddCubeFace(cubeFaceModels[CubeFaces.Bottom], -upVector, -frontVector, GetCubeFaceColor(CubeFaces.Bottom), BottomText);
AddCubeFace(cubeFaceModels[CubeFaces.Top], upVector, tempFrontVector, GetCubeFaceColor(CubeFaces.Top), TopText);
AddCubeFace(cubeFaceModels[CubeFaces.Bottom], -upVector, -tempFrontVector, GetCubeFaceColor(CubeFaces.Bottom), BottomText);
}
else
{
AddCubeFace(cubeFaceModels[CubeFaces.Top], upVector, leftVector, GetCubeFaceColor(CubeFaces.Top), TopText);
AddCubeFace(cubeFaceModels[CubeFaces.Bottom], -upVector, -leftVector, GetCubeFaceColor(CubeFaces.Bottom), BottomText);
AddCubeFace(cubeFaceModels[CubeFaces.Top], upVector, tempLeftVector, GetCubeFaceColor(CubeFaces.Top), TopText);
AddCubeFace(cubeFaceModels[CubeFaces.Bottom], -upVector, -tempLeftVector, GetCubeFaceColor(CubeFaces.Bottom), BottomText);
}
}
private Brush GetCubeFaceColor(CubeFaces cubeFace)
Expand Down

0 comments on commit c096f11

Please sign in to comment.