/// <summary> /// Sets up all the properties of the aggregate necessary for generation, including /// lattice type, attractor type and the dimensions of the aggregate. /// </summary> private void SetUpAggregateProperties() { // get the selected dimension type ComboBoxItem selected_dimension = (ComboBoxItem)(dimension_ComboBox.SelectedValue); string dimension_str = (string)(selected_dimension.Content); // set corresponding lattice_dimension constant switch (dimension_str) { case "2D": lattice_dimension = LatticeDimension._2D; break; case "3D": lattice_dimension = LatticeDimension._3D; break; } // reset simulation view ResetViewButtonHandler(null, null); // switch on current lattice dimension constant switch (lattice_dimension) { case LatticeDimension._2D: dla_2d.SetCoeffStick(stickiness_slider.Value); // set the lattice type to current selected item // of latticeType_ComboBox ui element ComboBoxItem selected_2DlatticeType = (ComboBoxItem)(latticeType_ComboBox.SelectedValue); string lattice_type2D_str = (string)(selected_2DlatticeType.Content); ManagedLatticeType lattice_type2D = (ManagedLatticeType)Enum.Parse(typeof(ManagedLatticeType), lattice_type2D_str); dla_2d.SetLatticeType(lattice_type2D); // set the attractor type to current selected item // of attractorType_ComboBox ui element ComboBoxItem selected_2DAttractorType = (ComboBoxItem)(attractorType_ComboBox.SelectedValue); string attractor_type2D_str = (string)(selected_2DAttractorType.Content); ManagedAttractorType attractor_type2D = (ManagedAttractorType)Enum.Parse(typeof(ManagedAttractorType), attractor_type2D_str); dla_2d.SetAttractorType(attractor_type2D); break; case LatticeDimension._3D: dla_3d.SetCoeffStick(stickiness_slider.Value); // set the lattice type to current selected item // of latticeType_ComboBox ui element ComboBoxItem selected_3DlatticeType = (ComboBoxItem)(latticeType_ComboBox.SelectedValue); string lattice_type3D_str = (string)(selected_3DlatticeType.Content); ManagedLatticeType lattice_type3D = (ManagedLatticeType)Enum.Parse(typeof(ManagedLatticeType), lattice_type3D_str); dla_3d.SetLatticeType(lattice_type3D); // set the attractor type to current selected item // of attractorType_ComboBox ui element ComboBoxItem selected_3DAttractorType = (ComboBoxItem)(attractorType_ComboBox.SelectedValue); string attractor_type3D_str = (string)(selected_3DAttractorType.Content); ManagedAttractorType attractor_type3D = (ManagedAttractorType)Enum.Parse(typeof(ManagedAttractorType), attractor_type3D_str); dla_3d.SetAttractorType(attractor_type3D); break; } }
public MainWindow() { InitializeComponent(); // initalise aggregate containers dla_2d = new ManagedDLA2DContainer(); dla_3d = new ManagedDLA3DContainer(); aggregate_manager = new AggregateSystemManager(); isPaused = false; hasFinished = true; current_particles = 0; colour_list = new List <Color>(); lattice_dimension = LatticeDimension._2D; WorldModels.Children.Add(aggregate_manager.AggregateSystemModel()); }
/// <summary> /// Sets the value of the lattice_dimension field corresponding to /// selected item in dimension_ComboBox. /// </summary> private void HandleLatticeDimensionComboBox() { // get the selected dimension type ComboBoxItem selected_dimension = (ComboBoxItem)(dimension_ComboBox.SelectedValue); string dimension_str = (string)(selected_dimension.Content); if (dimension_str == null) { lattice_dimension = LatticeDimension._2D; } else { ComboBoxItem planeItem = (ComboBoxItem)attractorType_ComboBox.FindName("PlaneItem"); // set corresponding lattice_dimension switch (dimension_str) { case "2D": lattice_dimension = LatticeDimension._2D; planeItem.IsEnabled = false; // get current selected attractor type ComboBoxItem selected_attractor_type = (ComboBoxItem)(attractorType_ComboBox.SelectedValue); string attractor_type_str = (string)(selected_attractor_type.Content); // if selected attractor is Plane, switch it to Point if (attractor_type_str == "Plane") { attractorType_ComboBox.SelectedValue = attractorType_ComboBox.Items[0]; } if (hasFinished) { orthograghic_camera.Position = new Point3D(0, 0, 32); orthograghic_camera.LookDirection = new Vector3D(0, 0, -32); orthograghic_camera.Width = 256.0; } break; case "3D": lattice_dimension = LatticeDimension._3D; planeItem.IsEnabled = true; if (hasFinished) { orthograghic_camera.Position = new Point3D(16, 16, 16); orthograghic_camera.LookDirection = new Vector3D(-8, -8, -8); orthograghic_camera.Width = 128.0; } break; } } }
/// <summary> /// Handler for generate_button click event. Calls GenerateAggregate() in a separate task factory. /// </summary> /// <param name="sender">Sender identification</param> /// <param name="e">Variable containing state information associated with event</param> private void OnGenerateButtonClicked(object sender, RoutedEventArgs e) { // clear any existing aggregate if (!isCleared) { ClearAggregate(); } current_executing_dimension = lattice_dimension; uint nparticles = (uint)particles_slider.Value; double agg_sticky_coeff = stickiness_slider.Value; // (re)-initialise aggregate properties SetUpAggregateProperties(nparticles, agg_sticky_coeff); //for (int i = 0; i < (int)particles_slider.Value; ++i) { // WorldModels.Children.Add(comp_manager.CreateAggregateComponent(colour_list[i])); //} GenerateAggregate(isContinuous ? 0 : nparticles); }
//private readonly AggregateComponentManager comp_manager; #endregion public MainWindow() { InitializeComponent(); // initalise aggregate containers and related properties dla_2d = new ManagedDLA2DContainer(); dla_3d = new ManagedDLA3DContainer(); current_particles = 0; lattice_dimension = LatticeDimension._2D; current_executing_dimension = lattice_dimension; lattice_type = ManagedLatticeType.Square; attractor_type = ManagedAttractorType.Point; // initialise simulation view properties/handles aggregate_manager = new AggregateSystemManager(); WorldModels.Children.Add(aggregate_manager.AggregateSystemModel()); // add model to view colour_list = new List <Color>(); RenderAttractorGeometry(); // initialise chart related properties/handles nrchart = new NumberRadiusChart(); ratechart = new GenerationRateChart(); chart_type = ChartType.NUMBERRADIUS; Chart.DataContext = nrchart; // default chart data context to Number-Radius chart //comp_manager = new AggregateComponentManager(); }