Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingPlan3D.cs @ 13365

Last change on this file since 13365 was 13032, checked in by gkronber, 9 years ago

#1966:

  • removed unused using
  • added/updated license headers
File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Joseph Helm and Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Windows.Forms;
24using System.Threading;
25
26
27namespace PackingPlanVisualizations {
28  public partial class PackingPlan3D : UserControl {
29    private PackingGame game;
30    private Thread gameLoopThread;
31
32    public PackingPlan3D() {
33      InitializeComponent();
34      if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) {
35        game = new PackingGame(this);
36      }
37    }
38
39
40    public void StartRendering() {
41      if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) {
42        if (!game.IsRunning)
43          StartGameLoop();
44      }
45    }
46
47    private void StartGameLoop() {
48      if (game == null || game.IsRunning)
49        return;
50      gameLoopThread =
51        new Thread(
52            () => {
53              //this.BeginInvoke(game.Run, this);
54              this.Invoke(
55                new MethodInvoker(
56                  () => {
57                    game.Run(this);
58                  }
59                )
60              );
61            }
62        );
63
64      gameLoopThread.Start();
65      //this.BeginInvoke(new MethodInvoker( () => {  game.Run(this);  }));
66    }
67
68
69
70    #region Archive ..
71    //private BasicCuboidShape containerShape;
72    //private List<BasicCuboidShape> itemShapes;
73    //private void RunGame() {
74    //  if (containerShape == null)
75    //    return;
76    //  game = new PackingGame(this);
77    //  game.InitializeContainer(containerShape);
78    //  foreach (BasicCuboidShape shape in itemShapes)
79    //    game.AddItemToContainer(shape);
80    //  game.Run(this);
81    //}
82    #endregion
83
84
85
86    public void InitializeContainer(float width, float height, float depth) {
87      //if (game != null) {
88      //  game.Exit();
89      //  game.Dispose();
90      //}
91      //game = new PackingGame(this);
92      game.InitializeContainer(width, height, depth);
93      //containerShape = new BasicCuboidShape(new Vector3 (width, height, depth));
94    }
95
96    public void AddItemToContainer(float width, float height, float depth, float x, float y, float z, int itemNr) {
97      AddItemToContainer(width, height, depth, x,y,z, itemNr, 0);
98    }
99    public void AddItemToContainer(float width, float height, float depth, float x, float y, float z, int itemNr, int material) {
100      game.AddItemToContainer(width, height, depth, x, y, z, itemNr, material);
101      //itemShapes.Add(new BasicCuboidShape (new Vector3 (width, height, depth), new Vector3 (x, y, z)));
102    }
103
104    public void SelectItem(int itemIndex) {
105      game.SelectItem(itemIndex);
106    }
107    public void UnselectItem() {
108      game.UnselectItem();
109    }
110
111
112    private void PackingPlan3D_Resize(object sender, EventArgs e) {
113      //this.Refresh();                                         
114      if (!(System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")) {
115        game.SetSize(this.Width, this.Height);
116      }
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.