+ Added VertexShape.Ellipse math shape

This commit is contained in:
panthernet 2015-08-27 12:23:34 +03:00
Родитель 4768e85539
Коммит c478aa5146
5 изменённых файлов: 43 добавлений и 41 удалений

Просмотреть файл

@ -4,6 +4,7 @@ DETAILED CHANGELOG:
+ Added GroupId property to IGraphXVertex interface
+ Added parameters class RandomLayoutAlgorithmParams for corresponding algorithm. It contains Bounds property which can restrict vertex coordinates to respect provided bounds.
+ Added two methods to EdgeControl: GetEdgePointerForSource() and GetEdgePointerForTarget() which allows to get to edge pointer objects manualy
+ Added VertexShape.Ellipse math shape
+ Fixed bindings to DefaultEdgePointer::Visibility property
+ Implemented edge cut logic for EdgePointer placed at edge 'source' to gain better visual quality like its 'target' counterpart
+ Implemented many changed in algorithm base classes, mainly in AlgorithmLayoutBase: made VisitedGraph and VertexPositions props assignable externally

Просмотреть файл

@ -181,13 +181,17 @@ namespace ShowcaseApp.WPF.Pages
void butGeneral_Click(object sender, RoutedEventArgs e)
{
CreateNewArea();
dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(2, false);
dg_Area.LogicCore.Graph = ShowcaseHelper.GenerateDataGraph(5, false);
var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();
dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[1]) { ArrowTarget = true});
// dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[1], vlist[2]) { ArrowTarget = false});
dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[2]) { ArrowTarget = true });
dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[3]) { ArrowTarget = true });
dg_Area.LogicCore.Graph.AddEdge(new DataEdge(vlist[0], vlist[4]) { ArrowTarget = true });
dg_Area.LogicCore.EdgeCurvingEnabled = true;
//dg_Area.PreloadGraph(new Dictionary<DataVertex, Point>() { {vlist[0], new Point()} });
dg_Area.LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;
dg_Area.LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog;
dg_Area.SetVerticesMathShape(VertexShape.Ellipse);
dg_Area.GenerateGraph(true);
dg_Area.VertexList.Values.ToList().ForEach(a => a.SetConnectionPointsVisibility(false));

Просмотреть файл

@ -23,30 +23,9 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:VertexControl}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding Vertex}" Grid.Column="1"/>
<StackPanel Orientation="Vertical" Grid.Column="0">
<Border Padding="0" Margin="2,2,0,2">
<controls:StaticVertexConnectionPoint Id="1" />
</Border>
<Border Padding="0" Margin="2,2,0,2">
<controls:StaticVertexConnectionPoint Id="2" />
</Border>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2">
<Border Padding="0" Margin="0,2,2,2">
<controls:StaticVertexConnectionPoint Id="3" />
</Border>
<Border Padding="0" Margin="0,2,2,2">
<controls:StaticVertexConnectionPoint Id="4" />
</Border>
</StackPanel>
</Grid>
<Ellipse Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}" Width="150" Height="80">
</Ellipse>
</ControlTemplate>
</Setter.Value>
</Setter>

Просмотреть файл

@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Windows.Data;
using GraphX.PCL.Common.Enums;
#if WPF
using System.Windows;
@ -62,7 +63,7 @@ namespace GraphX.Controls
/// <param name="tension"></param>
/// <param name="tolerance"></param>
/// <returns></returns>
public static PolyLineSegment GetCurveThroughPoints(Point[] points, Double tension, Double tolerance)
public static PolyLineSegment GetCurveThroughPoints(Point[] points, double tension, double tolerance)
{
Debug.Assert(points != null);
Debug.Assert(points.Length >= 2);
@ -106,12 +107,12 @@ namespace GraphX.Controls
return oPolyLineSegment;
}
private static void AddPointsToPolyLineSegment(PolyLineSegment oPolyLineSegment, Point oPoint0, Point oPoint1, Point oPoint2, Point oPoint3, Double dTension, Double dTolerance)
private static void AddPointsToPolyLineSegment(PolyLineSegment oPolyLineSegment, Point oPoint0, Point oPoint1, Point oPoint2, Point oPoint3, double dTension, double dTolerance)
{
Debug.Assert(oPolyLineSegment != null);
Debug.Assert(dTolerance > 0);
var iPoints = (Int32)((Math.Abs(oPoint1.X - oPoint2.X) +
var iPoints = (int)((Math.Abs(oPoint1.X - oPoint2.X) +
Math.Abs(oPoint1.Y - oPoint2.Y)) / dTolerance);
var oPolyLineSegmentPoints = oPolyLineSegment.Points;
@ -141,7 +142,7 @@ namespace GraphX.Controls
for (var i = 1; i < iPoints; i++)
{
var t = (Double)i / (iPoints - 1);
var t = (double)i / (iPoints - 1);
var oPoint = new Point(
dAx * t * t * t + dBx * t * t + dCx * t + dDx,
@ -154,7 +155,7 @@ namespace GraphX.Controls
}
}
public static PathFigure GetPathFigureFromPathSegments(Point oStartPoint, Boolean bPathFigureIsFilled, bool freezeAll, params PathSegment[] aoPathSegments)
public static PathFigure GetPathFigureFromPathSegments(Point oStartPoint, bool bPathFigureIsFilled, bool freezeAll, params PathSegment[] aoPathSegments)
{
Debug.Assert(aoPathSegments != null);
@ -174,7 +175,7 @@ namespace GraphX.Controls
return oPathFigure;
}
public static PathGeometry GetPathGeometryFromPathSegments(Point oStartPoint, Boolean bPathFigureIsFilled, params PathSegment[] aoPathSegments)
public static PathGeometry GetPathGeometryFromPathSegments(Point oStartPoint, bool bPathFigureIsFilled, params PathSegment[] aoPathSegments)
{
Debug.Assert(aoPathSegments != null);
@ -203,7 +204,7 @@ namespace GraphX.Controls
/// </summary>
/// <param name="freezable">Freezable object</param>
/// <returns></returns>
public static Boolean TryFreeze(Freezable freezable)
public static bool TryFreeze(Freezable freezable)
{
Debug.Assert(freezable != null);
@ -221,6 +222,8 @@ namespace GraphX.Controls
{
case VertexShape.Circle:
return GetEdgeEndpointOnCircle(source, Math.Max(sourceSize.Height, sourceSize.Width) * .5, target);
case VertexShape.Ellipse:
return GetEdgeEndpointOnEllipse(source, sourceSize.Width*.5, sourceSize.Height*.5, target);
case VertexShape.Diamond:
return GetEdgeEndpointOnDiamond(source, sourceSize.Width * .5, target);
case VertexShape.Triangle:
@ -230,7 +233,7 @@ namespace GraphX.Controls
}
}
public static Point GetEdgeEndpointOnCircle(Point oVertexALocation, Double dVertexARadius, Point oVertexBLocation)
public static Point GetEdgeEndpointOnCircle(Point oVertexALocation, double dVertexARadius, Point oVertexBLocation)
{
Debug.Assert(dVertexARadius >= 0);
@ -242,7 +245,21 @@ namespace GraphX.Controls
);
}
public static Point GetEdgeEndpointOnTriangle(Point oVertexLocation, Double mDHalfWidth, Point otherEndpoint)
public static Point GetEdgeEndpointOnEllipse(Point oVertexALocation, double dVertexARadiusWidth, double dVertexARadiusHeight, Point oVertexBLocation)
{
Debug.Assert(dVertexARadiusWidth >= 0);
Debug.Assert(dVertexARadiusHeight >= 0);
var dEdgeAngle = MathHelper.GetAngleBetweenPointsRadians(oVertexALocation, oVertexBLocation);
return new Point(
oVertexALocation.X + (dVertexARadiusWidth * Math.Cos(dEdgeAngle)),
oVertexALocation.Y - (dVertexARadiusHeight * Math.Sin(dEdgeAngle))
);
}
public static Point GetEdgeEndpointOnTriangle(Point oVertexLocation, double mDHalfWidth, Point otherEndpoint)
{
// Instead of doing geometry calculations similar to what is done in
// VertexDrawingHistory.GetEdgePointOnRectangle(), make use of that
@ -256,7 +273,7 @@ namespace GraphX.Controls
var dEdgeAngleDegrees = MathHelper.RadiansToDegrees(dEdgeAngle);
Double dAngleToRotateDegrees;
double dAngleToRotateDegrees;
if (dEdgeAngleDegrees >= -30.0 && dEdgeAngleDegrees < 90.0)
{
@ -302,7 +319,7 @@ namespace GraphX.Controls
return oMatrix.Transform(oRotatedEdgeEndpoint);
}
public static Point GetEdgeEndpointOnDiamond(Point oVertexLocation, Double mDHalfWidth, Point otherEndpoint)
public static Point GetEdgeEndpointOnDiamond(Point oVertexLocation, double mDHalfWidth, Point otherEndpoint)
{
// A diamond is just a rotated square, so the
// GetEdgePointOnRectangle() can be used if the
@ -495,7 +512,7 @@ namespace GraphX.Controls
return GetPathFigureFromPoints(aoPoints[0], aoPoints[1], aoPoints[2]);
}
public static Matrix GetRotatedMatrix(Point centerOfRotation, Double angleToRotateDegrees)
public static Matrix GetRotatedMatrix(Point centerOfRotation, double angleToRotateDegrees)
{
var oMatrix = Matrix.Identity;

Просмотреть файл

@ -6,6 +6,7 @@
Diamond,
Triangle,
Circle,
None
None,
Ellipse
}
}