Maria globe client/Advanced map settings: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
()
()
 
(13 intermediate revisions by the same user not shown)
Line 38: Line 38:
public ICommand RotateRightCmnd { get { return new DelegateCommand(OnRotateRight); } }
public ICommand RotateRightCmnd { get { return new DelegateCommand(OnRotateRight); } }


private void OnRotateLeft(object obj)
private void OnRotateLeft(object obj) { Rotation += 1;}
{
private void OnRotateRight(object obj) { Rotation -= 1;}
    Rotation += 1;
}
 
private void OnRotateRight(object obj)
{
    Rotation -= 1;
}


public int Rotation
public int Rotation
Line 59: Line 52:
. . .
. . .
</source>
</source>


=== Running with map rotation ===
=== Running with map rotation ===
Line 109: Line 101:
=== Additional components and code ===
=== Additional components and code ===


To visualise the 3D settings, add display, with ability for modification, for:
To visualise the 3D settings, add display, with ability of modification, for:
;Camera  
;Camera  
:* Yaw
:* Yaw
Line 116: Line 108:
;Target
;Target
:* Follow ground
:* Follow ground
:* Distance
:* Altitude
:* Altitude
::Changes are not applicable while:
::Changes are not applicable while:
Line 124: Line 115:
::Changes are not applicable while:
::Changes are not applicable while:
::* auto follow is active, as the target position is defined by the item followed.
::* auto follow is active, as the target position is defined by the item followed.
:* Distance


Example of necessary components, properties and command handlers are described [[3D_map_settings_components_and_code_sample|''are described separately'' here]].
{{Note|Example of necessary components, properties and command handlers [[Maria globe client/Advanced map settings/3D_settings_code_sample|''are described separately'' '''''here''''']].}}
 
=== Synchronise with map actions ===
 
We need to synchronise the 3D map settings when 3D mode is entered, and also whenever altered by mouse actions in the map area.
 
To do that, subscribe to events from:
 
:;GlobeMapViewModel
:* Entered2DMode
:* Entered3DMode
:;GlobeMapViewModel.Globe3DViewModel.CameraControl
:* AfterPan
:* TargetDistanceChanged
:* TargetPosChanged
:* OrientationChanged
 
In '''''MapViewModel''''':
 
<source lang="C#">
. . .
public void SetGlobeMapViewModel(IGlobeMapViewModel globeMapViewModel)
{
    _globeMapViewModel = globeMapViewModel;         
 
    _globeMapViewModel.Globe3DViewModel.CameraControl.AfterPan += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.TargetDistanceChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.TargetPosChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.OrientationChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Entered2DMode += OnModeOrSettingsChanged;
    _globeMapViewModel.Entered3DMode += OnModeOrSettingsChanged;
}
private void OnModeOrSettingsChanged(object sender, EventArgs args)
{
    RefreshTargetAndCameraValues();
}
. . .
</source>


=== Running with display of 3D settings ===
=== Running with displayed 3D settings ===


Running the '''''Globe client''''' in 3D mode, altering the 3D parameters will give results like this:
Running the '''''Globe client''''' in 3D mode, altering the 3D parameters will give results like this:
Line 149: Line 178:
|
|
[[File:3D_Set_P15_Y120_af_close.png|450px|Auto follow - closer ]] <br>
[[File:3D_Set_P15_Y120_af_close.png|450px|Auto follow - closer ]] <br>
Auto follow - closer
With auto follow, modified target distance (camera closer)
|
|
[[File:3D_Set_P15_Y120_R30_af.png|450px| Modified ''roll'' ]]<br>
[[File:3D_Set_P15_Y120_R30_af.png|450px| Modified ''roll'' ]]<br>

Latest revision as of 11:46, 7 October 2019

Map rotation

As default, 2D maps are displayed with north up, but you may rotate the map by modifying the map layer rotation parameter - GeoContext.RotateValue.

Additional components and code

Add the following components:

  • Text box to display the current rotation value
  • Two buttons, for right (clockwise) add left (counter clockwise).

Add the following to your Main Window XAML:

. . .
<Label Grid.Row="4" Grid.Column="0"
       Content="Rotation" FontWeight="DemiBold"/>

<TextBox Grid.Row="4" Grid.Column="1" Margin="3"
         Text="{Binding MapViewModel.Rotation}" TextAlignment="Right" />

<StackPanel  Grid.Row="5" Grid.Column="1" Orientation="Horizontal" 
             VerticalAlignment="Center" HorizontalAlignment="Center">
    <RepeatButton Margin="3" Width="50" 
                  Content="Left" 
                  Command="{Binding MapViewModel.RotateLeftCmnd}"/>
    <RepeatButton Margin="3" Width="50" 
                  Content="Right" 
                  Command="{Binding MapViewModel.RotateRightCmnd}"/>
</StackPanel>
. . .

And implement corresponding properties and command handlers in MapViewModel:

. . .
public ICommand RotateLeftCmnd { get { return new DelegateCommand(OnRotateLeft); } }
public ICommand RotateRightCmnd { get { return new DelegateCommand(OnRotateRight); } }

private void OnRotateLeft(object obj) { Rotation += 1;}
private void OnRotateRight(object obj) { Rotation -= 1;}

public int Rotation
{
    get { return _mapLayer.GeoContext != null ? (int)_mapLayer.GeoContext.RotateValue : 0; }
    set
    {                
        _mapLayer.GeoContext.RotateValue = value;
        NotifyPropertyChanged(() => Rotation);
    }
}
. . .

Running with map rotation

Pressing the rotation buttons, the map is rotated, and the rotation display is updated accordingly.

Map rotation.


3D map settings

The Globe Client 3D view is the view from a camera towards a target, specified by the following parameters:

Description
Camera yaw Horizontal rotation, degrees - counterclockwise. Roll, pitch and yaw
Camera pitch Front/back rotation, degrees - counterclockwise
Camera roll Left/right rotation, degrees - counterclockwise.
Follow ground

Lock the target altitude is to the elevation of the target position.

Target altitude

Height above sea level (0-elevation) at target position.

Target position

Latitude and longitude.

Target distance Distance from camera to target.


Note
  • 3D rotations are not commutative.
Performing the same rotations in different order will give different results.

Additional components and code

To visualise the 3D settings, add display, with ability of modification, for:

Camera
  • Yaw
  • Pitch
  • Roll
Target
  • Follow ground
  • Altitude
Changes are not applicable while:
  • auto follow is active, as the target elevation is defined by the item followed.
  • follow ground is active.
  • Position
Changes are not applicable while:
  • auto follow is active, as the target position is defined by the item followed.
  • Distance
Example of necessary components, properties and command handlers are described separately here.

Synchronise with map actions

We need to synchronise the 3D map settings when 3D mode is entered, and also whenever altered by mouse actions in the map area.

To do that, subscribe to events from:

GlobeMapViewModel
  • Entered2DMode
  • Entered3DMode
GlobeMapViewModel.Globe3DViewModel.CameraControl
  • AfterPan
  • TargetDistanceChanged
  • TargetPosChanged
  • OrientationChanged

In MapViewModel:

. . .
public void SetGlobeMapViewModel(IGlobeMapViewModel globeMapViewModel)
{
    _globeMapViewModel = globeMapViewModel;           

    _globeMapViewModel.Globe3DViewModel.CameraControl.AfterPan += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.TargetDistanceChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.TargetPosChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Globe3DViewModel.CameraControl.OrientationChanged += OnModeOrSettingsChanged;
    _globeMapViewModel.Entered2DMode += OnModeOrSettingsChanged;
    _globeMapViewModel.Entered3DMode += OnModeOrSettingsChanged;
} 
private void OnModeOrSettingsChanged(object sender, EventArgs args)
{
    RefreshTargetAndCameraValues();
}
. . .

Running with displayed 3D settings

Running the Globe client in 3D mode, altering the 3D parameters will give results like this:

Default 3D setting
Default 3D setting

Modified pitch
Modified pitch

Modified yaw
Modified yaw

With auto follow, track as target
With auto follow, track as target

Auto follow - closer
With auto follow, modified target distance (camera closer)

Modified roll
Modified roll