Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/16 18:21:19 (8 years ago)
Author:
gkronber
Message:

#1966 work in progress WPF control to visualize packings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan3DView.cs

    r13465 r13532  
    3939
    4040    protected override void DeregisterContentEvents() {
    41       Content.QualityChanged -= new EventHandler(Content_QualityChanged);
    4241      base.DeregisterContentEvents();
    4342    }
    4443    protected override void RegisterContentEvents() {
    4544      base.RegisterContentEvents();
    46       Content.QualityChanged += new EventHandler(Content_QualityChanged);
    4745    }
    4846
     
    5654      base.OnContentChanged();
    5755      binSelection.Items.Clear();
    58       if (Content == null) { 
    59         packingPlan3D.InitializeContainer(0, 0, 0);
     56      if (Content == null) {
     57         packingPlan3D.Clear();
    6058      } else {
    6159        int i = 0;
     
    6563        binSelection.SelectedIndex = 0;
    6664        UpdateModel();
    67         packingPlan3D.StartRendering();
     65        packingPlan3D.Focus(); // for mouse wheel?
     66        // packingPlan3D.StartRendering();
    6867      }
    6968    }
     
    7170    private void UpdateModel() {
    7271      int currentBin = (binSelection != null) ? (int)(binSelection.SelectedIndex) : 0;
    73       var bin = Content.BinPackings[currentBin].BinMeasures;
    74       packingPlan3D.InitializeContainer(bin.Width, bin.Height, bin.Depth);
    75       foreach (var entry in Content.BinPackings[currentBin].ItemMeasures) {
    76         var position = Content.BinPackings[currentBin].ItemPositions[entry.Key];
    77         packingPlan3D.AddItemToContainer(
    78         position.Rotated ? entry.Value.Depth : entry.Value.Width,
    79         entry.Value.Height,
    80         position.Rotated ? entry.Value.Width : entry.Value.Depth,
    81         position.X, position.Y, position.Z, entry.Key, entry.Value.Material);
    82       }
     72      packingPlan3D.ShowContainer(Content.BinPackings[currentBin]);
     73      // var bin = Content.BinPackings[currentBin].BinMeasures;
     74      // // packingPlan3D.InitializeContainer(bin.Width, bin.Height, bin.Depth);
     75      // foreach (var entry in Content.BinPackings[currentBin].ItemMeasures) {
     76      //   var position = Content.BinPackings[currentBin].ItemPositions[entry.Key];
     77      //    packingPlan3D.AddItemToContainer(
     78      //    position.Rotated ? entry.Value.Depth : entry.Value.Width,
     79      //    entry.Value.Height,
     80      //    position.Rotated ? entry.Value.Width : entry.Value.Depth,
     81      //    position.X, position.Y, position.Z, entry.Key, entry.Value.Material);
     82      // }
    8383    }
    8484
     
    8989      itemSelection.Items.Clear();
    9090      int currentBin = (binSelection != null) ? (int)(binSelection.SelectedIndex) : 0;
    91       foreach (var entry in Content.BinPackings[currentBin].ItemMeasures) {
    92         itemSelection.Items.Add(entry.Key);
    93       }
     91      packingPlan3D.ShowContainer(Content.BinPackings[currentBin]);
    9492
    95       packingPlan3D.Invalidate();
    96       packingPlan3D.Update();
    9793    }
    9894
     
    10399      if ((itemSelection != null && itemSelection.SelectedItem != null) && Int32.TryParse(itemSelection.SelectedItem.ToString(), out selectedItem)) {
    104100        packingPlan3D.SelectItem(selectedItem);
    105       } else     
    106         packingPlan3D.UnselectItem();
    107 
    108       packingPlan3D.Invalidate();
    109       packingPlan3D.Update();
     101      } else
     102        packingPlan3D.ClearSelection();
    110103    }
    111104
    112     private void Content_QualityChanged(object sender, EventArgs e) {
    113       if (InvokeRequired)
    114         Invoke(new EventHandler(Content_QualityChanged), sender, e);
    115       else {
    116         binSelection.Items.Clear();
    117         if (Content == null) {
    118           packingPlan3D.InitializeContainer(0, 0, 0);
    119         } else {
    120           int i = 0;
    121           foreach (var bp in Content.BinPackings)
    122             binSelection.Items.Add(i++ + " (" + Math.Round(bp.PackingDensity * 100, 2) + "%)");
    123           binSelection.SelectedIndex = 0;
    124           UpdateModel();
    125           packingPlan3D.StartRendering();
    126         }
    127       }
    128    
     105    // private void Content_QualityChanged(object sender, EventArgs e) {
     106    //   if (InvokeRequired)
     107    //     Invoke(new EventHandler(Content_QualityChanged), sender, e);
     108    //   else {
     109    //     binSelection.Items.Clear();
     110    //     if (Content == null) {
     111    //       packingPlan3D.InitializeContainer(0, 0, 0);
     112    //     } else {
     113    //       int i = 0;
     114    //       foreach (var bp in Content.BinPackings)
     115    //         binSelection.Items.Add(i++ + " (" + Math.Round(bp.PackingDensity * 100, 2) + "%)");
     116    //       binSelection.SelectedIndex = 0;
     117    //       UpdateModel();
     118    //       // packingPlan3D.StartRendering();
     119    //     }
     120    //   }
     121    // }
    129122  }
    130123}
Note: See TracChangeset for help on using the changeset viewer.