Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13468


Ignore:
Timestamp:
12/15/15 09:06:49 (9 years ago)
Author:
gkronber
Message:

#1966: worked on visualization of packing plans

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  
    5454            | System.Windows.Forms.AnchorStyles.Left)
    5555            | 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);
    5757      this.packingPlan2D.Name = "packingPlan2D";
    58       this.packingPlan2D.Size = new System.Drawing.Size(281, 264);
     58      this.packingPlan2D.Size = new System.Drawing.Size(383, 340);
    5959      this.packingPlan2D.TabIndex = 3;
    6060      //
     
    6464            | System.Windows.Forms.AnchorStyles.Left)));
    6565      this.binSelection.FormattingEnabled = true;
    66       this.binSelection.Location = new System.Drawing.Point(6, 26);
     66      this.binSelection.Location = new System.Drawing.Point(6, 3);
    6767      this.binSelection.Name = "binSelection";
    68       this.binSelection.Size = new System.Drawing.Size(55, 264);
     68      this.binSelection.Size = new System.Drawing.Size(55, 329);
    6969      this.binSelection.TabIndex = 4;
    7070      this.binSelection.SelectedIndexChanged += new System.EventHandler(this.binSelection_SelectedIndexChanged);
     
    7777      this.Controls.Add(this.packingPlan2D);
    7878      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);
    8280      this.ResumeLayout(false);
    83       this.PerformLayout();
    8481
    8582    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan3DView.Designer.cs

    r13462 r13468  
    5555            | System.Windows.Forms.AnchorStyles.Left)
    5656            | 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);
    5858      this.packingPlan3D.Name = "packingPlan3D";
    59       this.packingPlan3D.Size = new System.Drawing.Size(229, 264);
     59      this.packingPlan3D.Size = new System.Drawing.Size(229, 293);
    6060      this.packingPlan3D.TabIndex = 3;
    6161      //
     
    6565            | System.Windows.Forms.AnchorStyles.Left)));
    6666      this.binSelection.FormattingEnabled = true;
    67       this.binSelection.Location = new System.Drawing.Point(6, 26);
     67      this.binSelection.Location = new System.Drawing.Point(3, 3);
    6868      this.binSelection.Name = "binSelection";
    69       this.binSelection.Size = new System.Drawing.Size(54, 264);
     69      this.binSelection.Size = new System.Drawing.Size(54, 290);
    7070      this.binSelection.TabIndex = 4;
    7171      this.binSelection.SelectedIndexChanged += new System.EventHandler(this.binSelection_SelectedIndexChanged);
     
    7676            | System.Windows.Forms.AnchorStyles.Left)));
    7777      this.itemSelection.FormattingEnabled = true;
    78       this.itemSelection.Location = new System.Drawing.Point(58, 26);
     78      this.itemSelection.Location = new System.Drawing.Point(58, 3);
    7979      this.itemSelection.Name = "itemSelection";
    80       this.itemSelection.Size = new System.Drawing.Size(55, 264);
     80      this.itemSelection.Size = new System.Drawing.Size(55, 290);
    8181      this.itemSelection.TabIndex = 5;
    8282      this.itemSelection.SelectedIndexChanged += new System.EventHandler(this.itemSelection_SelectedIndexChanged);
     
    9191      this.Name = "PackingPlan3DView";
    9292      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);
    9693      this.ResumeLayout(false);
    97       this.PerformLayout();
    9894
    9995    }
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/CenteredContainer2D.cs

    r13032 r13468  
    2828    private Vector2 containerSize;
    2929    private Vector2 controlSize;
    30     private float normalizingFactor;
     30    private float xScaling;
     31    private float yScaling;
     32    private readonly List<PackingItem> packingItems = new List<PackingItem>();
    3133
    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); }
    3436    }
    3537
     
    3739      private Vector2 position;
    3840      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) {
    4143        this.size = size;
    4244        this.position = position;
    4345        this.label = label;
    4446      }
    45       public RectangleF GetRectangle(Vector2 topLeft, float normalizingFactor) {
     47      public RectangleF GetRectangle(Vector2 topLeft, float sx, float sy) {
    4648        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 - 2
     49          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
    5153        );
    5254      }
     
    5557      }
    5658    }
    57     private List<PackingItem> packingItems = new List<PackingItem>();
    5859
    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) {
    7161      this.containerSize = containerSize;
    7262      UpdateContainer(controlSize);
    7363    }
    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)) {
    7666    }
    7767
    7868    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));
    8070    }
    8171    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);
    8373    }
    84      
     74
    8575    public void UpdateContainer(Vector2 controlSize) {
    8676      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);
    9179    }
    9280    public void UpdateContainer(float controlWidth, float controlHeight) {
    93       UpdateContainer(new Vector2 (controlWidth, controlHeight));
     81      UpdateContainer(new Vector2(controlWidth, controlHeight));
    9482    }
    9583
     
    9886      //Compute centered rectangle
    9987      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);
    10492
    10593      return result;
     
    115103      }
    116104    }
     105
    117106    public List<LabeledRectangle> GetItemRectangles() {
    118       List<LabeledRectangle> result = new List<LabeledRectangle> ();
     107      List<LabeledRectangle> result = new List<LabeledRectangle>();
    119108
    120109      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)));
    124113      }
    125114
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/PackingPlan2D.Designer.cs

    r13032 r13468  
    5353      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    5454      this.Name = "PackingPlan2D";
     55      this.Size = new System.Drawing.Size(163, 150);
    5556      this.Load += new System.EventHandler(this.PackingPlan2D_Load);
    5657      this.Paint += new System.Windows.Forms.PaintEventHandler(this.PackingPlan2D_Paint);
    57       this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PackingPlan2D_MouseClick);
    5858      this.Resize += new System.EventHandler(this.PackingPlan2D_Resize);
    5959      this.ResumeLayout(false);
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/2D/PackingPlan2D.cs

    r13465 r13468  
    121121    }
    122122
    123     private void PackingPlan2D_MouseClick(object sender, MouseEventArgs e) {
    124       Console.WriteLine(e.X + " - " + e.Y);
    125     }
    126123  }
    127124}
Note: See TracChangeset for help on using the changeset viewer.