Changeset 13468
- Timestamp:
- 12/15/15 09:06:49 (9 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan2DView.Designer.cs
r13462 r13468 54 54 | System.Windows.Forms.AnchorStyles.Left) 55 55 | System.Windows.Forms.AnchorStyles.Right))); 56 this.packingPlan2D.Location = new System.Drawing.Point(67, 26);56 this.packingPlan2D.Location = new System.Drawing.Point(67, 3); 57 57 this.packingPlan2D.Name = "packingPlan2D"; 58 this.packingPlan2D.Size = new System.Drawing.Size( 281, 264);58 this.packingPlan2D.Size = new System.Drawing.Size(383, 340); 59 59 this.packingPlan2D.TabIndex = 3; 60 60 // … … 64 64 | System.Windows.Forms.AnchorStyles.Left))); 65 65 this.binSelection.FormattingEnabled = true; 66 this.binSelection.Location = new System.Drawing.Point(6, 26);66 this.binSelection.Location = new System.Drawing.Point(6, 3); 67 67 this.binSelection.Name = "binSelection"; 68 this.binSelection.Size = new System.Drawing.Size(55, 264);68 this.binSelection.Size = new System.Drawing.Size(55, 329); 69 69 this.binSelection.TabIndex = 4; 70 70 this.binSelection.SelectedIndexChanged += new System.EventHandler(this.binSelection_SelectedIndexChanged); … … 77 77 this.Controls.Add(this.packingPlan2D); 78 78 this.Name = "PackingPlan2DView"; 79 this.Size = new System.Drawing.Size(351, 299); 80 this.Controls.SetChildIndex(this.packingPlan2D, 0); 81 this.Controls.SetChildIndex(this.binSelection, 0); 79 this.Size = new System.Drawing.Size(453, 346); 82 80 this.ResumeLayout(false); 83 this.PerformLayout();84 81 85 82 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan3DView.Designer.cs
r13462 r13468 55 55 | System.Windows.Forms.AnchorStyles.Left) 56 56 | System.Windows.Forms.AnchorStyles.Right))); 57 this.packingPlan3D.Location = new System.Drawing.Point(119, 26);57 this.packingPlan3D.Location = new System.Drawing.Point(119, 3); 58 58 this.packingPlan3D.Name = "packingPlan3D"; 59 this.packingPlan3D.Size = new System.Drawing.Size(229, 2 64);59 this.packingPlan3D.Size = new System.Drawing.Size(229, 293); 60 60 this.packingPlan3D.TabIndex = 3; 61 61 // … … 65 65 | System.Windows.Forms.AnchorStyles.Left))); 66 66 this.binSelection.FormattingEnabled = true; 67 this.binSelection.Location = new System.Drawing.Point( 6, 26);67 this.binSelection.Location = new System.Drawing.Point(3, 3); 68 68 this.binSelection.Name = "binSelection"; 69 this.binSelection.Size = new System.Drawing.Size(54, 2 64);69 this.binSelection.Size = new System.Drawing.Size(54, 290); 70 70 this.binSelection.TabIndex = 4; 71 71 this.binSelection.SelectedIndexChanged += new System.EventHandler(this.binSelection_SelectedIndexChanged); … … 76 76 | System.Windows.Forms.AnchorStyles.Left))); 77 77 this.itemSelection.FormattingEnabled = true; 78 this.itemSelection.Location = new System.Drawing.Point(58, 26);78 this.itemSelection.Location = new System.Drawing.Point(58, 3); 79 79 this.itemSelection.Name = "itemSelection"; 80 this.itemSelection.Size = new System.Drawing.Size(55, 2 64);80 this.itemSelection.Size = new System.Drawing.Size(55, 290); 81 81 this.itemSelection.TabIndex = 5; 82 82 this.itemSelection.SelectedIndexChanged += new System.EventHandler(this.itemSelection_SelectedIndexChanged); … … 91 91 this.Name = "PackingPlan3DView"; 92 92 this.Size = new System.Drawing.Size(351, 299); 93 this.Controls.SetChildIndex(this.packingPlan3D, 0);94 this.Controls.SetChildIndex(this.binSelection, 0);95 this.Controls.SetChildIndex(this.itemSelection, 0);96 93 this.ResumeLayout(false); 97 this.PerformLayout();98 94 99 95 } -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/CenteredContainer2D.cs
r13032 r13468 28 28 private Vector2 containerSize; 29 29 private Vector2 controlSize; 30 private float normalizingFactor; 30 private float xScaling; 31 private float yScaling; 32 private readonly List<PackingItem> packingItems = new List<PackingItem>(); 31 33 32 public Vector2 ContainerCenter { 33 get { return new Vector2(controlSize.X / 2, controlSize.Y / 2); } 34 public Vector2 ContainerCenter { 35 get { return new Vector2(controlSize.X / 2, controlSize.Y / 2); } 34 36 } 35 37 … … 37 39 private Vector2 position; 38 40 private Vector2 size; 39 private string label;40 public PackingItem(Vector2 size, Vector2 position, string label , CenteredContainer2D parentContainer) {41 private readonly string label; 42 public PackingItem(Vector2 size, Vector2 position, string label) { 41 43 this.size = size; 42 44 this.position = position; 43 45 this.label = label; 44 46 } 45 public RectangleF GetRectangle(Vector2 topLeft, float normalizingFactor) {47 public RectangleF GetRectangle(Vector2 topLeft, float sx, float sy) { 46 48 return new RectangleF( 47 topLeft.X + position.X * normalizingFactor+ 2,48 topLeft.Y + position.Y * normalizingFactor+ 2,49 topLeft.X + position.X * normalizingFactor + size.X * normalizingFactor- 2,50 topLeft.Y + position.Y * normalizingFactor + size.Y * normalizingFactor- 249 topLeft.X + position.X * sx + 2, 50 topLeft.Y + position.Y * sy + 2, 51 topLeft.X + position.X * sx + size.X * sx - 2, 52 topLeft.Y + position.Y * sy + size.Y * sy - 2 51 53 ); 52 54 } … … 55 57 } 56 58 } 57 private List<PackingItem> packingItems = new List<PackingItem>();58 59 59 //public struct LabelStructure { 60 // private string text; 61 // public string Text { get { return text; } } 62 // private RectangleF layoutRect; 63 // public RectangleF LayoutRectangle { get { return layoutRect; } } 64 // public LabelStructure(string text, RectangleF layout) { 65 // this.text = text; 66 // this.layoutRect = layout; 67 // } 68 //} 69 70 public CenteredContainer2D (Vector2 controlSize, Vector2 containerSize) { 60 public CenteredContainer2D(Vector2 controlSize, Vector2 containerSize) { 71 61 this.containerSize = containerSize; 72 62 UpdateContainer(controlSize); 73 63 } 74 public CenteredContainer2D(float controlWidth, float controlHeight, float containerWidth, float containerHeight) 75 : this(new Vector2 (controlWidth, controlHeight), new Vector2(containerWidth, containerHeight)) {64 public CenteredContainer2D(float controlWidth, float controlHeight, float containerWidth, float containerHeight) 65 : this(new Vector2(controlWidth, controlHeight), new Vector2(containerWidth, containerHeight)) { 76 66 } 77 67 78 68 public void AddItem(Vector2 size, Vector2 position, string label) { 79 packingItems.Add(new PackingItem (size, position, label, this));69 packingItems.Add(new PackingItem(size, position, label)); 80 70 } 81 71 public void AddItem(float width, float height, float x, float y, string label) { 82 AddItem(new Vector2 (width, height), new Vector2(x, y), label);72 AddItem(new Vector2(width, height), new Vector2(x, y), label); 83 73 } 84 74 85 75 public void UpdateContainer(Vector2 controlSize) { 86 76 this.controlSize = controlSize; 87 if (controlSize.X / controlSize.Y > containerSize.X / containerSize.Y) 88 this.normalizingFactor = controlSize.Y / (containerSize.Y + 5); 89 else if (controlSize.X / controlSize.Y <= containerSize.X / containerSize.Y) 90 this.normalizingFactor = controlSize.X / (containerSize.X + 5); 77 xScaling = controlSize.X / (containerSize.X + 5); 78 yScaling = controlSize.Y / (containerSize.Y + 5); 91 79 } 92 80 public void UpdateContainer(float controlWidth, float controlHeight) { 93 UpdateContainer(new Vector2 81 UpdateContainer(new Vector2(controlWidth, controlHeight)); 94 82 } 95 83 … … 98 86 //Compute centered rectangle 99 87 SharpDX.RectangleF result = new SharpDX.RectangleF( 100 ContainerCenter.X - containerSize.X * normalizingFactor/ 2 - 2,101 ContainerCenter.Y - containerSize.Y * normalizingFactor/ 2 - 2,102 ContainerCenter.X + containerSize.X * normalizingFactor/ 2 + 2,103 ContainerCenter.Y + containerSize.Y * normalizingFactor/ 2 + 2);88 ContainerCenter.X - containerSize.X * xScaling / 2 - 2, 89 ContainerCenter.Y - containerSize.Y * yScaling / 2 - 2, 90 ContainerCenter.X + containerSize.X * xScaling / 2 + 2, 91 ContainerCenter.Y + containerSize.Y * yScaling / 2 + 2); 104 92 105 93 return result; … … 115 103 } 116 104 } 105 117 106 public List<LabeledRectangle> GetItemRectangles() { 118 List<LabeledRectangle> result = new List<LabeledRectangle> 107 List<LabeledRectangle> result = new List<LabeledRectangle>(); 119 108 120 109 foreach (PackingItem item in packingItems) { 121 result.Add(new LabeledRectangle(item.GetLabel(), item.GetRectangle(new Vector2(122 ContainerCenter.X - containerSize.X * normalizingFactor/ 2,123 ContainerCenter.Y - containerSize.Y * normalizingFactor / 2), normalizingFactor)));110 result.Add(new LabeledRectangle(item.GetLabel(), 111 item.GetRectangle(new Vector2(ContainerCenter.X - containerSize.X * xScaling / 2, 112 ContainerCenter.Y - containerSize.Y * yScaling / 2), xScaling, yScaling))); 124 113 } 125 114 -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/PackingPlan2D.Designer.cs
r13032 r13468 53 53 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 54 54 this.Name = "PackingPlan2D"; 55 this.Size = new System.Drawing.Size(163, 150); 55 56 this.Load += new System.EventHandler(this.PackingPlan2D_Load); 56 57 this.Paint += new System.Windows.Forms.PaintEventHandler(this.PackingPlan2D_Paint); 57 this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PackingPlan2D_MouseClick);58 58 this.Resize += new System.EventHandler(this.PackingPlan2D_Resize); 59 59 this.ResumeLayout(false); -
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/PackingPlan2D.cs
r13465 r13468 121 121 } 122 122 123 private void PackingPlan2D_MouseClick(object sender, MouseEventArgs e) {124 Console.WriteLine(e.X + " - " + e.Y);125 }126 123 } 127 124 }
Note: See TracChangeset
for help on using the changeset viewer.