-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #636 from uni-bremen-agst/563-incremental-layout
563 incremental layout
- Loading branch information
Showing
42 changed files
with
2,390 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using SEE.Utils; | ||
using Sirenix.OdinInspector; | ||
using UnityEngine; | ||
|
||
namespace SEE.Game.City | ||
{ | ||
/// <summary> | ||
/// The settings for <see cref="Layout.NodeLayouts.IncrementalTreeMapLayout"/>. | ||
/// </summary> | ||
[Serializable] | ||
public class IncrementalTreeMapSetting : ConfigIO.PersistentConfigItem | ||
{ | ||
/// <summary> | ||
/// The depth of the local moves search. | ||
/// </summary> | ||
[SerializeField] | ||
[Range(0, 5)] | ||
[Tooltip("The maximal depth for local moves algorithm. Increase for higher visual quality, " + | ||
"decrease for higher stability and to save runtime")] | ||
public int LocalMovesDepth = 3; | ||
|
||
/// <summary> | ||
/// The maximal branching factor of the local moves search. | ||
/// </summary> | ||
[SerializeField] | ||
[Range(1, 10)] | ||
[Tooltip("The maximal branching factor for local moves algorithm. Increase for higher visual quality, " + | ||
"decrease for higher stability and to save runtime")] | ||
public int LocalMovesBranchingLimit = 4; | ||
|
||
/// <summary> | ||
/// Defines the specific p norm used in the local moves algorithm. See here: | ||
/// <see cref="Layout.NodeLayouts.IncrementalTreeMap.LocalMoves.AspectRatiosPNorm"/>. | ||
/// | ||
/// Notice: | ||
/// The kind of p norm changes which layout is considered to have the greatest visual quality. | ||
/// For example with p=1 (Manhattan Norm) the algorithm would | ||
/// minimize the sum of aspect ratios, while with p=infinity (Chebyshev Norm) | ||
/// the algorithm would minimize the maximal aspect ratio over the layout nodes. | ||
/// The other p norms range between these extremes. | ||
/// | ||
/// Needs therefor a mapping from <see cref="PNormRange"/> to a double value p, which is realized with the | ||
/// property <see cref="PNorm"/>. | ||
/// </summary> | ||
[SerializeField] | ||
[Tooltip("Norm for the visual quality of a set of nodes, " + | ||
"larger p values lead to stronger penalties for larger deviations in aspect ratio of single nodes.")] | ||
private PNormRange pNorm = PNormRange.P2Euclidean; | ||
|
||
/// <summary> | ||
/// The absolute padding between neighboring nodes so that they can be distinguished (in millimeters). | ||
/// </summary> | ||
[SerializeField] | ||
[Range(0.1f, 100f)] | ||
[LabelText("Padding (mm)")] | ||
[Tooltip("The distance between two neighbour nodes in mm")] | ||
public float PaddingMm = 5f; | ||
|
||
/// <summary> | ||
/// The maximal error for the method | ||
/// <see cref="Layout.NodeLayouts.IncrementalTreeMap.CorrectAreas.GradientDecent"/> as power of 10. | ||
/// </summary> | ||
[SerializeField] | ||
[Range(-7, -2)] | ||
[LabelText("Gradient Descent Precision (10^n)")] | ||
[Tooltip("The maximal error for the gradient descent method as power of 10")] | ||
public int GradientDescentPrecisionExponent = -4; | ||
|
||
/// <summary> | ||
/// Maps <see cref="pNorm"/> to a double. | ||
/// </summary> | ||
public double PNorm => pNorm switch | ||
{ | ||
(PNormRange.P1Manhattan) => 1d, | ||
(PNormRange.P2Euclidean) => 2d, | ||
(PNormRange.P3) => 3d, | ||
(PNormRange.P4) => 4d, | ||
(PNormRange.PInfinityChebyshev) => double.PositiveInfinity, | ||
_ => throw new InvalidEnumArgumentException("Unrecognized PNormRange value.") | ||
}; | ||
|
||
public void Save(ConfigWriter writer, string label) | ||
{ | ||
writer.BeginGroup(label); | ||
writer.Save(LocalMovesDepth, LocalMovesDepthLabel); | ||
writer.Save(LocalMovesBranchingLimit, LocalMovesBranchingLimitLabel); | ||
writer.Save(pNorm.ToString(), PNormLabel); | ||
writer.Save(GradientDescentPrecisionExponent, GradientDescentPrecisionLabel); | ||
writer.Save(PaddingMm, PaddingLabel); | ||
writer.EndGroup(); | ||
} | ||
|
||
public bool Restore(Dictionary<string, object> attributes, string label) | ||
{ | ||
if (!attributes.TryGetValue(label, out object dictionary)) | ||
{ | ||
return false; | ||
} | ||
Dictionary<string, object> values = dictionary as Dictionary<string, object>; | ||
bool result = ConfigIO.Restore(values, LocalMovesDepthLabel, ref LocalMovesDepth); | ||
result |= ConfigIO.Restore(values, LocalMovesBranchingLimitLabel, ref LocalMovesBranchingLimit); | ||
result |= ConfigIO.RestoreEnum(values, PNormLabel, ref pNorm); | ||
result |= ConfigIO.Restore(values, GradientDescentPrecisionLabel, ref GradientDescentPrecisionExponent); | ||
result |= ConfigIO.Restore(values, PaddingLabel, ref PaddingMm); | ||
return result; | ||
} | ||
|
||
/// <summary> | ||
/// Configuration label for <see cref="LocalMovesDepth"/>. | ||
/// </summary> | ||
private const string LocalMovesDepthLabel = "LocalMovesDepth"; | ||
/// <summary> | ||
/// Configuration label for <see cref="LocalMovesBranchingLimit"/>. | ||
/// </summary> | ||
private const string LocalMovesBranchingLimitLabel = "LocalMovesBranchingLimit"; | ||
/// <summary> | ||
/// Configuration label for <see cref="PNorm"/>. | ||
/// </summary> | ||
private const string PNormLabel = "PNorm"; | ||
/// <summary> | ||
/// Configuration label for <see cref="GradientDescentPrecisionExponent"/>. | ||
/// </summary> | ||
private const string GradientDescentPrecisionLabel = "GradientDescentPrecision"; | ||
/// <summary> | ||
/// Configuration label for <see cref="PaddingMm"/>. | ||
/// </summary> | ||
private const string PaddingLabel = "Padding"; | ||
} | ||
|
||
/// <summary> | ||
/// Selection of possible PNorms. Used for better access in Unity Editor for the field | ||
/// <see cref="IncrementalTreeMapSetting.pNorm"/>. | ||
/// </summary> | ||
public enum PNormRange | ||
{ | ||
P1Manhattan, | ||
P2Euclidean, | ||
P3, | ||
P4, | ||
PInfinityChebyshev, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fileFormatVersion: 2 | ||
guid: 32bc90aa558d49f5b773a0e799a1bdbe | ||
timeCreated: 1691856370 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace SEE.Layout.NodeLayouts | ||
{ | ||
/// <summary> | ||
/// Defines the interface for incremental node layouts. | ||
/// | ||
/// Incremental node layouts are designed for the animation of evolution | ||
/// and each layout depends on the layout of the last revision. | ||
/// | ||
/// This interface extends a layout by <see cref="OldLayout"/> | ||
/// to hand over the layout of the last revision. | ||
/// </summary> | ||
public interface IIncrementalNodeLayout | ||
{ | ||
/// <summary> | ||
/// Setter for the layout of the last revision. | ||
/// </summary> | ||
IIncrementalNodeLayout OldLayout { set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/SEE/Layout/NodeLayouts/IIncrementalNodeLayout.cs.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fileFormatVersion: 2 | ||
guid: c08a007a03783def3883f51a6fecb1b5 | ||
MonoImporter: | ||
externalObjects: {} | ||
serializedVersion: 2 | ||
defaultReferences: [] | ||
executionOrder: 0 | ||
icon: {instanceID: 0} | ||
userData: | ||
assetBundleName: | ||
assetBundleVariant: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fileFormatVersion: 2 | ||
guid: 3d3e0b38dff2821d59a3dde1e44d24c9 | ||
folderAsset: yes | ||
DefaultImporter: | ||
externalObjects: {} | ||
userData: | ||
assetBundleName: | ||
assetBundleVariant: |
Oops, something went wrong.