Changeset 13578


Ignore:
Timestamp:
01/28/16 19:35:42 (4 years ago)
Author:
gkronber
Message:

#1966: implemented visualization for 2d packings

Location:
branches/HeuristicLab.BinPacking
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/HeuristicLab.Problems.BinPacking.Views-3.3.csproj

    r13576 r13578  
    155155      <DependentUpon>Container3DView.xaml</DependentUpon>
    156156    </Compile>
     157    <Compile Include="Container2DView.xaml.cs">
     158      <DependentUpon>Container2DView.xaml</DependentUpon>
     159    </Compile>
     160    <Compile Include="PackingPlan2DView.cs">
     161      <SubType>UserControl</SubType>
     162    </Compile>
     163    <Compile Include="PackingPlan2DView.Designer.cs">
     164      <DependentUpon>PackingPlan2DView.cs</DependentUpon>
     165    </Compile>
    157166    <Compile Include="PackingPlan3DView.cs">
    158167      <SubType>UserControl</SubType>
     
    175184  </ItemGroup>
    176185  <ItemGroup>
     186    <EmbeddedResource Include="PackingPlan2DView.resx">
     187      <DependentUpon>PackingPlan2DView.cs</DependentUpon>
     188    </EmbeddedResource>
    177189    <EmbeddedResource Include="PackingPlan3DView.resx">
    178190      <DependentUpon>PackingPlan3DView.cs</DependentUpon>
     
    181193  <ItemGroup>
    182194    <Page Include="Container3DView.xaml">
     195      <Generator>MSBuild:Compile</Generator>
     196      <SubType>Designer</SubType>
     197    </Page>
     198    <Page Include="Container2DView.xaml">
    183199      <Generator>MSBuild:Compile</Generator>
    184200      <SubType>Designer</SubType>
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan2DView.Designer.cs

    r13576 r13578  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.packingPlan2D = new PackingPlanVisualizations.PackingPlan2D();
    4847      this.binSelection = new System.Windows.Forms.ListBox();
     48      this.elementHost = new System.Windows.Forms.Integration.ElementHost();
     49      this.container2DView = new HeuristicLab.Problems.BinPacking.Views.Container2DView();
    4950      this.SuspendLayout();
    50       //
    51       // packingPlan2D
    52       //
    53       this.packingPlan2D.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    54             | System.Windows.Forms.AnchorStyles.Left)
    55             | System.Windows.Forms.AnchorStyles.Right)));
    56       this.packingPlan2D.Location = new System.Drawing.Point(67, 3);
    57       this.packingPlan2D.Name = "packingPlan2D";
    58       this.packingPlan2D.Size = new System.Drawing.Size(383, 340);
    59       this.packingPlan2D.TabIndex = 3;
    6051      //
    6152      // binSelection
     
    7061      this.binSelection.SelectedIndexChanged += new System.EventHandler(this.binSelection_SelectedIndexChanged);
    7162      //
     63      // elementHost
     64      //
     65      this.elementHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     66            | System.Windows.Forms.AnchorStyles.Left)
     67            | System.Windows.Forms.AnchorStyles.Right)));
     68      this.elementHost.Location = new System.Drawing.Point(67, 3);
     69      this.elementHost.Name = "elementHost";
     70      this.elementHost.Size = new System.Drawing.Size(383, 329);
     71      this.elementHost.TabIndex = 5;
     72      this.elementHost.Text = "elementHost";
     73      this.elementHost.Child = this.container2DView;
     74      //
    7275      // PackingPlan2DView
    7376      //
    7477      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7578      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     79      this.Controls.Add(this.elementHost);
    7680      this.Controls.Add(this.binSelection);
    77       this.Controls.Add(this.packingPlan2D);
    7881      this.Name = "PackingPlan2DView";
    7982      this.Size = new System.Drawing.Size(453, 346);
     
    8386
    8487    #endregion
    85 
    86     private PackingPlanVisualizations.PackingPlan2D packingPlan2D;
     88   
    8789    private System.Windows.Forms.ListBox binSelection;
     90    private System.Windows.Forms.Integration.ElementHost elementHost;
     91    private Container2DView container2DView;
    8892  }
    8993}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan2DView.cs

    r13576 r13578  
    3737    }
    3838
    39     protected override void DeregisterContentEvents() {
    40       Content.QualityChanged -= new EventHandler(Content_QualityChanged);
    41       base.DeregisterContentEvents();
    42     }
    43     protected override void RegisterContentEvents() {
    44       base.RegisterContentEvents();
    45       Content.QualityChanged += new EventHandler(Content_QualityChanged);
    46     }
    47 
    48 
    4939    public new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Content {
    5040      get { return (PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>)base.Content; }
    5141      set { base.Content = value; }
    5242    }
    53 
    5443
    5544    protected override void OnContentChanged() {
     
    6554    }
    6655
    67 
    6856    private void ClearState() {
    69       packingPlan2D.InitializeContainer(0, 0);
     57      container2DView.Packing = null;
    7058    }
    7159
    72     private void UpdateState(PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> plan) {     
     60    private void UpdateState(PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> plan) {
    7361      int currentBin = (binSelection != null && binSelection.SelectedItem != null) ? (int)(binSelection.SelectedItem) : 0;
    74       var bin = plan.BinPackings[currentBin].BinMeasures;
    75       packingPlan2D.InitializeContainer(bin.Width, bin.Height);
    76       foreach (var entry in plan.BinPackings[currentBin].ItemMeasures) {
    77         var position = plan.BinPackings[currentBin].ItemPositions[entry.Key];
    78           packingPlan2D.AddItemToContainer(
    79             position.Rotated ? entry.Value.Height : entry.Value.Width,
    80             position.Rotated ? entry.Value.Width : entry.Value.Height,
    81             position.X, position.Y, entry.Key.ToString());
    82       }
     62      container2DView.Packing = plan.BinPackings[currentBin];
    8363    }
    8464
    8565    private void binSelection_SelectedIndexChanged(object sender, EventArgs e) {
    8666      UpdateState(Content);
    87       packingPlan2D.Refresh();
    8867    }
    89 
    90 
    91 
    92     private void Content_QualityChanged(object sender, EventArgs e) {
    93       if (InvokeRequired)
    94         Invoke(new EventHandler(Content_QualityChanged), sender, e);
    95       else {
    96         binSelection.Items.Clear();
    97         if (Content == null) {
    98           ClearState();
    99         } else {
    100           for (int i = 0; i < Content.NrOfBins; i++)
    101             binSelection.Items.Add(i);
    102           UpdateState(Content);
    103         }
    104         packingPlan2D.Refresh();
    105       }
    106     } 
    10768  }
    10869}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs

    r13032 r13578  
    4141
    4242    [Storable]
    43     public ObservableDictionary<int, I> ItemMeasures { get; private set; }
     43    public ObservableDictionary<int, I> ItemMeasures { get; private set; } // TODO: renamed to item
    4444
    4545    [Storable]
     
    4747
    4848    [Storable]
    49     //public HashSet<D> ExtremePoints { get; protected set; }
    5049    public SortedSet<D> ExtremePoints { get; protected set; }
    5150
     
    5554    #endregion Properties
    5655
    57     public BinPacking(B binMeasures) : base() {   
     56    protected BinPacking(B binMeasures) : base() {   
    5857      ItemPositions = new ObservableDictionary<int, D>();
    5958      ItemMeasures = new ObservableDictionary<int, I>();
    6059      BinMeasures = (B)binMeasures.Clone();
    6160      OccupationLayers = new Dictionary<int, List<int>>();
    62       InitializeOccupationLayers();
     61      InitializeOccupationLayers(); // TODO
    6362    }
    6463
Note: See TracChangeset for help on using the changeset viewer.