Free cookie consent management tool by TermsFeed Policy Generator

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

#1966 work in progress WPF control to visualize packings

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3
Files:
4 added
8 edited

Legend:

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

    r13466 r13532  
    140140      <Private>False</Private>
    141141    </Reference>
     142    <Reference Include="PresentationCore" />
     143    <Reference Include="PresentationFramework" />
    142144    <Reference Include="System" />
    143145    <Reference Include="System.Core" />
    144146    <Reference Include="System.Drawing" />
    145147    <Reference Include="System.Windows.Forms" />
    146   </ItemGroup>
    147   <ItemGroup>
    148     <Compile Include="PackingPlans\PackingPlan2DView.cs">
    149       <SubType>UserControl</SubType>
    150     </Compile>
    151     <Compile Include="PackingPlans\PackingPlan2DView.Designer.cs">
    152       <DependentUpon>PackingPlan2DView.cs</DependentUpon>
    153     </Compile>
     148    <Reference Include="System.Xaml" />
     149    <Reference Include="UIAutomationProvider" />
     150    <Reference Include="WindowsBase" />
     151    <Reference Include="WindowsFormsIntegration" />
     152  </ItemGroup>
     153  <ItemGroup>
    154154    <Compile Include="PackingPlans\PackingPlan3DView.cs">
    155155      <SubType>UserControl</SubType>
     
    158158      <DependentUpon>PackingPlan3DView.cs</DependentUpon>
    159159    </Compile>
     160    <Compile Include="Shapes\Container3DView.xaml.cs">
     161      <DependentUpon>Container3DView.xaml</DependentUpon>
     162    </Compile>
    160163    <Compile Include="Shapes\CuboidPackingItemView.cs">
    161164      <SubType>UserControl</SubType>
     
    169172    <Compile Include="Shapes\CuboidPackingShapeView.Designer.cs">
    170173      <DependentUpon>CuboidPackingShapeView.cs</DependentUpon>
    171     </Compile>
    172     <Compile Include="Shapes\RectangularPackingItemView.cs">
    173       <SubType>UserControl</SubType>
    174     </Compile>
    175     <Compile Include="Shapes\RectangularPackingItemView.Designer.cs">
    176       <DependentUpon>RectangularPackingItemView.cs</DependentUpon>
    177     </Compile>
    178     <Compile Include="Shapes\RectangularPackingShapeView.cs">
    179       <SubType>UserControl</SubType>
    180     </Compile>
    181     <Compile Include="Shapes\RectangularPackingShapeView.Designer.cs">
    182       <DependentUpon>RectangularPackingShapeView.cs</DependentUpon>
    183174    </Compile>
    184175    <None Include="HeuristicLab.snk" />
     
    194185      <Private>False</Private>
    195186    </ProjectReference>
    196     <ProjectReference Include="..\..\PackingPlanVisualizations\PackingPlanVisualizations.csproj">
    197       <Project>{0fd5ea67-a284-4166-9f45-9c6bc07d5b83}</Project>
    198       <Name>PackingPlanVisualizations</Name>
    199     </ProjectReference>
     187  </ItemGroup>
     188  <ItemGroup>
     189    <EmbeddedResource Include="PackingPlans\PackingPlan3DView.resx">
     190      <DependentUpon>PackingPlan3DView.cs</DependentUpon>
     191    </EmbeddedResource>
     192  </ItemGroup>
     193  <ItemGroup>
     194    <Page Include="Shapes\Container3DView.xaml">
     195      <SubType>Designer</SubType>
     196      <Generator>MSBuild:Compile</Generator>
     197    </Page>
    200198  </ItemGroup>
    201199  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan3DView.Designer.cs

    r13468 r13532  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.packingPlan3D = new PackingPlanVisualizations.PackingPlan3D();
    4847      this.binSelection = new System.Windows.Forms.ListBox();
    4948      this.itemSelection = new System.Windows.Forms.ListBox();
     49      this.elementHost = new System.Windows.Forms.Integration.ElementHost();
     50      this.packingPlan3D = new HeuristicLab.Problems.BinPacking.Views.Shapes.Container3DView();
    5051      this.SuspendLayout();
    51       //
    52       // packingPlan3D
    53       //
    54       this.packingPlan3D.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    55             | System.Windows.Forms.AnchorStyles.Left)
    56             | System.Windows.Forms.AnchorStyles.Right)));
    57       this.packingPlan3D.Location = new System.Drawing.Point(119, 3);
    58       this.packingPlan3D.Name = "packingPlan3D";
    59       this.packingPlan3D.Size = new System.Drawing.Size(229, 293);
    60       this.packingPlan3D.TabIndex = 3;
    6152      //
    6253      // binSelection
     
    8273      this.itemSelection.SelectedIndexChanged += new System.EventHandler(this.itemSelection_SelectedIndexChanged);
    8374      //
     75      // elementHost
     76      //
     77      this.elementHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     78            | System.Windows.Forms.AnchorStyles.Left)
     79            | System.Windows.Forms.AnchorStyles.Right)));
     80      this.elementHost.Location = new System.Drawing.Point(119, 3);
     81      this.elementHost.Name = "elementHost";
     82      this.elementHost.Size = new System.Drawing.Size(229, 290);
     83      this.elementHost.TabIndex = 6;
     84      this.elementHost.Text = "elementHost1";
     85      this.elementHost.Child = this.packingPlan3D;
     86      //
    8487      // PackingPlan3DView
    8588      //
    8689      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    8790      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     91      this.Controls.Add(this.elementHost);
    8892      this.Controls.Add(this.itemSelection);
    8993      this.Controls.Add(this.binSelection);
    90       this.Controls.Add(this.packingPlan3D);
    9194      this.Name = "PackingPlan3DView";
    9295      this.Size = new System.Drawing.Size(351, 299);
     
    97100    #endregion
    98101
    99     private PackingPlanVisualizations.PackingPlan3D packingPlan3D;
    100102    private System.Windows.Forms.ListBox binSelection;
    101103    private System.Windows.Forms.ListBox itemSelection;
     104    private System.Windows.Forms.Integration.ElementHost elementHost;
     105    private Shapes.Container3DView packingPlan3D;
    102106  }
    103107}
  • 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}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs.frame

    r13461 r13532  
    2828  [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)]
    30   [PluginFile("PackingPlanVisualizations.dll", PluginFileType.Assembly)]
    3130  [PluginDependency("HeuristicLab.Core", "3.3")]
    3231  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/CuboidPackingItemView.Designer.cs

    r13466 r13532  
    4848    /// </summary>
    4949    private void InitializeComponent() {
    50       this.packingPlan3D = new PackingPlanVisualizations.PackingPlan3D();
    5150      this.SuspendLayout();
    52       //
    53       // packingPlan3D
    54       //
    55       this.packingPlan3D.Dock = System.Windows.Forms.DockStyle.Fill;
    56       this.packingPlan3D.Location = new System.Drawing.Point(0, 0);
    57       this.packingPlan3D.Name = "packingPlan3D";
    58       this.packingPlan3D.Size = new System.Drawing.Size(351, 299);
    59       this.packingPlan3D.TabIndex = 3;
    6051      //
    6152      // CuboidPackingItemView
    6253      //
    6354      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    64       this.Controls.Add(this.packingPlan3D);
    6555      this.Name = "CuboidPackingItemView";
    6656      this.Size = new System.Drawing.Size(351, 299);
     
    7161    #endregion
    7262
    73     private PackingPlanVisualizations.PackingPlan3D packingPlan3D;
    74 
    7563  }
    7664}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/CuboidPackingItemView.cs

    r13466 r13532  
    4343      } else {
    4444        Redraw(Content);
    45         packingPlan3D.StartRendering();
    4645      }
    4746    }
    4847
    4948    private void Redraw() {
    50       packingPlan3D.InitializeContainer(0, 0, 0);
     49      // packingPlan3D.InitializeContainer(0, 0, 0);
    5150    }
    5251
    5352    private void Redraw(CuboidPackingItem item) {
    54       packingPlan3D.InitializeContainer(item.TargetBin.Width, item.TargetBin.Height, item.TargetBin.Depth);
    55       packingPlan3D.AddItemToContainer(item.Width, item.Height, item.Depth, 0, 0, 0, 0);
     53      // packingPlan3D.InitializeContainer(item.TargetBin.Width, item.TargetBin.Height, item.TargetBin.Depth);
     54      // packingPlan3D.AddItemToContainer(item.Width, item.Height, item.Depth, 0, 0, 0, 0);
    5655    }
    5756  }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/CuboidPackingShapeView.Designer.cs

    r13466 r13532  
    4848    /// </summary>
    4949    private void InitializeComponent() {
    50       this.packingPlan3D = new PackingPlanVisualizations.PackingPlan3D();
    5150      this.SuspendLayout();
    52       //
    53       // packingPlan3D
    54       //
    55       this.packingPlan3D.Dock = System.Windows.Forms.DockStyle.Fill;
    56       this.packingPlan3D.Location = new System.Drawing.Point(0, 0);
    57       this.packingPlan3D.Name = "packingPlan3D";
    58       this.packingPlan3D.Size = new System.Drawing.Size(351, 299);
    59       this.packingPlan3D.TabIndex = 3;
    6051      //
    6152      // CuboidPackingShapeView
    6253      //
    6354      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    64       this.Controls.Add(this.packingPlan3D);
    6555      this.Name = "CuboidPackingShapeView";
    6656      this.Size = new System.Drawing.Size(351, 299);
     
    7161    #endregion
    7262
    73     private PackingPlanVisualizations.PackingPlan3D packingPlan3D;
    74 
    7563  }
    7664}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Shapes/CuboidPackingShapeView.cs

    r13466 r13532  
    4343      } else {
    4444        Redraw(Content);
    45         packingPlan3D.StartRendering();
    4645      }
    4746    }
    4847
    4948    private void Redraw() {
    50       packingPlan3D.InitializeContainer(0, 0, 0);
     49      // packingPlan3D.InitializeContainer(0, 0, 0);
    5150    }
    5251
    5352    private void Redraw(CuboidPackingShape shape) {
    54       packingPlan3D.InitializeContainer(shape.Width, shape.Height, shape.Depth);
     53      // packingPlan3D.InitializeContainer(shape.Width, shape.Height, shape.Depth);
    5554    }
    5655  }
Note: See TracChangeset for help on using the changeset viewer.