Changeset 15167


Ignore:
Timestamp:
07/07/17 10:07:32 (2 weeks ago)
Author:
jkarder
Message:

#2739: improved 3d visualization

  • in UpdateVisualization, no materials are available after Clear, therefore TryGetValue is unnecessary
  • removed unnecessary ctrlDown field and OnKeyDown event handler
Location:
trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml

    r14978 r15167  
    3030             MouseWheel="Container3DView_OnMouseWheel"
    3131             MouseEnter="Container3DView_OnMouseEnter"
    32              KeyDown="Container3DView_OnKeyDown"
    3332             Focusable="true"
    3433             >
  • trunk/sources/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs

    r14979 r15167  
    4646      Color.FromRgb(0x63, 0xC2, 0x16),
    4747    };
    48    
     48
    4949    private static readonly Color hiddenColor = Color.FromArgb(0x1A, 0xAA, 0xAA, 0xAA);
    5050    private static readonly Color containerColor = Color.FromArgb(0x7F, 0xAA, 0xAA, 0xAA);
     
    5252    private Point startPos;
    5353    private bool mouseDown = false;
    54     private bool ctrlDown = false;
    5554    private double startAngleX;
    5655    private double startAngleY;
     
    106105        var selectedItem = packing.Items.Single(x => selectedItemKey == x.Key);
    107106        var selectedPos = packing.Positions[selectedItem.Key];
    108         DiffuseMaterial material;
    109         if (!materials.TryGetValue(selectedItem.Value.Material, out material)) {
    110           var colorIdx = selectedItem.Value.Material;
    111           while (colorIdx < 0) colorIdx += colors.Length;
    112           colorIdx = colorIdx % colors.Length;
    113           var color = colors[colorIdx];
    114           material = new DiffuseMaterial { Brush = new SolidColorBrush(color) };
    115           materials[selectedItem.Value.Material] = material;
    116         }
     107
     108        var colorIdx = selectedItem.Value.Material;
     109        while (colorIdx < 0) colorIdx += colors.Length;
     110        colorIdx = colorIdx % colors.Length;
     111        var color = colors[colorIdx];
     112        var material = new DiffuseMaterial { Brush = new SolidColorBrush(color) };
     113        materials[selectedItem.Value.Material] = material;
     114
    117115        var selectedModel = new GeometryModel3D { Geometry = new MeshGeometry3D(), Material = material };
    118116        AddSolidCube((MeshGeometry3D)selectedModel.Geometry, selectedPos.X, selectedPos.Y, selectedPos.Z,
     
    185183      ((Model3DGroup)MyModel.Content).Children.Clear();
    186184      materials.Clear();
    187      
     185
    188186      mouseDown = false;
    189187      startAngleX = 0;
     
    194192      if (!mouseDown) return;
    195193      var pos = e.GetPosition((IInputElement)this);
    196      
     194
    197195      ((AxisAngleRotation3D)rotateX.Rotation).Angle = startAngleX + (pos.X - startPos.X) / 4;
    198196      ((AxisAngleRotation3D)rotateY.Rotation).Angle = startAngleY + (pos.Y - startPos.Y) / 4;
     
    225223      Focus(); // for mouse wheel events
    226224    }
    227 
    228     private void Container3DView_OnKeyDown(object sender, KeyEventArgs e) {
    229       ctrlDown = e.Key.HasFlag(Key.LeftCtrl) || e.Key.HasFlag(Key.RightCtrl);
    230     }
    231 
    232225
    233226    #region helper for cubes
Note: See TracChangeset for help on using the changeset viewer.