1 | using System.Collections.Generic;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Drawing.Drawing2D;
|
---|
4 | using System.Linq;
|
---|
5 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
|
---|
6 | using HeuristicLab.Visualization;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
9 | public partial class SymbolicExpressionChartControl : ChartControl {
|
---|
10 | public SymbolicExpressionChartControl() {
|
---|
11 | InitializeComponent();
|
---|
12 | if (Chart == null) { Chart = new Chart(0, 0, PreferredSize.Width, PreferredSize.Height); }
|
---|
13 | }
|
---|
14 |
|
---|
15 | public void Clear() {
|
---|
16 | Chart.Group.Clear();
|
---|
17 | }
|
---|
18 |
|
---|
19 | public void Add(IPrimitive primitive) {
|
---|
20 | Chart.Group.Add(primitive);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public void AddRange(IEnumerable<IPrimitive> primitives) {
|
---|
24 | Chart.Group.AddRange(primitives);
|
---|
25 | }
|
---|
26 |
|
---|
27 | public void Draw(Graphics graphics) {
|
---|
28 | graphics.SmoothingMode = SmoothingMode.HighQuality;
|
---|
29 | Chart.Group.Draw(graphics);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public bool UpdateEnabled {
|
---|
33 | get { return Chart.UpdateEnabled; }
|
---|
34 | set { Chart.UpdateEnabled = value; }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void EnforceUpdate() {
|
---|
38 | Chart.EnforceUpdate();
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void FlipVertical() {
|
---|
42 | foreach (var p in Chart.Group.Primitives.OfType<SymbolicExpressionTreeTile>().SelectMany(x => x.Primitives)) {
|
---|
43 | FlipPrimitive(p);
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public void FlipPrimitive(IPrimitive primitive) {
|
---|
48 | var height = pictureBox.Height;
|
---|
49 | var rect = primitive as RectangularPrimitiveBase;
|
---|
50 | var line = primitive as LinearPrimitiveBase;
|
---|
51 | if (rect != null) {
|
---|
52 | rect.SetPosition(rect.LowerLeft.X, height - rect.UpperRight.Y, rect.UpperRight.X, height - rect.LowerLeft.Y);
|
---|
53 | } else if (line != null) {
|
---|
54 | line.SetPosition(line.Start.X, height - line.Start.Y, line.End.X, height - line.End.Y);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|