private void btnApplyToAll_Click(object sender, EventArgs e)
        {
            if (this._supportCone != null)
            {
                var selectedModel = this._supportCone.Model;

                if (selectedModel != null)
                {
                    var supportUpdateArgs = new Core.Events.SupportEventArgs();
                    supportUpdateArgs.TopRadius    = this._supportCone.TopRadius;
                    supportUpdateArgs.TopHeight    = this._supportCone.TopHeight;
                    supportUpdateArgs.MiddleRadius = this._supportCone.MiddleRadius;
                    supportUpdateArgs.BottomHeight = this._supportCone.BottomHeight;
                    supportUpdateArgs.BottomRadius = this._supportCone.BottomRadius;

                    foreach (var supportCone in selectedModel.TotalObjectSupportCones)
                    {
                        if (supportCone != null)
                        {
                            supportCone.Update(supportUpdateArgs, selectedModel);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnSupportApplyToAll_Click(object sender, EventArgs e)
        {
            if (this._datasource != null)
            {
                STLModel3D model = null;
                if (ObjectView.SelectedModel is SupportCone)
                {
                    model = (ObjectView.SelectedModel as SupportCone).Model;
                }
                else if (ObjectView.SelectedModel is STLModel3D)
                {
                    model = ObjectView.SelectedModel as STLModel3D;
                }
                else if (this._datasource is SupportCone)
                {
                    model = (this._datasource as SupportCone).Model;
                }

                if (model != null)
                {
                    var supportUpdateArgs = new Core.Events.SupportEventArgs();
                    var selectedPGLabel   = this.pgSupport.SelectedGridItem.Label;
                    if (selectedPGLabel != null)
                    {
                        if (selectedPGLabel == "Top Radius")
                        {
                            supportUpdateArgs.TopRadius = this._datasource.TopRadius;
                        }
                        else if (selectedPGLabel == "Top Height")
                        {
                            supportUpdateArgs.TopHeight = this._datasource.TopHeight;
                        }
                        else if (selectedPGLabel == "Middle Radius")
                        {
                            supportUpdateArgs.MiddleRadius = this._datasource.MiddleRadius;
                        }
                        else if (selectedPGLabel == "Bottom Height")
                        {
                            supportUpdateArgs.BottomHeight = this._datasource.BottomHeight;
                        }
                        else if (selectedPGLabel == "Bottom Radius")
                        {
                            supportUpdateArgs.BottomRadius = this._datasource.BottomRadius;
                        }
                        SupportEngine.UpdateModelSingleSupportCones(supportUpdateArgs, model);
                    }


                    //surface support
                    foreach (var supportCone in model.Triangles.HorizontalSurfaces.SupportStructure)
                    {
                        supportCone.Update(supportUpdateArgs, model);
                    }

                    //flat support
                    foreach (var supportCone in model.Triangles.FlatSurfaces.SupportStructure)
                    {
                        supportCone.Update(supportUpdateArgs, model);
                    }
                }

                //update main scene
                this.ValueChanged?.Invoke(this);
            }
        }
Esempio n. 3
0
        private void pgSupport_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            //UNDO
            var selectedModel = this._datasource.Model;

            if (this.DataSource is SupportConeV2)
            {
                var supportConeV2 = this.DataSource as SupportConeV2;
                supportConeV2.Update();

                var manualSupportCone  = this._datasource;
                var manualSupportEvent = new ManualSupportConePropertyChange();
                manualSupportEvent.PropertyName     = e.ChangedItem.Label;
                manualSupportEvent.PropertyValueNew = (float)e.ChangedItem.Value;
                manualSupportEvent.PropertyValueOld = (float)e.OldValue;
                manualSupportEvent.SupportCone      = this._datasource;
                manualSupportEvent.ModelIndex       = selectedModel.Index;

                UndoRedoManager.GetInstance.PushReverseAction(x => SupportEngine.UndoManualSupportConeProperty(x), manualSupportEvent);

                this.ValueChanged?.Invoke(this);
            }
            else
            {
                if (!this._datasource.IsSurfaceSupport)
                {
                    //manual
                    if (e.OldValue != e.ChangedItem.Value)
                    {
                        var manualSupportCone  = this._datasource;
                        var manualSupportEvent = new ManualSupportConePropertyChange();
                        manualSupportEvent.PropertyName     = e.ChangedItem.Label;
                        manualSupportEvent.PropertyValueNew = (float)e.ChangedItem.Value;
                        manualSupportEvent.PropertyValueOld = (float)e.OldValue;
                        manualSupportEvent.SupportCone      = this._datasource;
                        manualSupportEvent.ModelIndex       = selectedModel.Index;

                        UndoRedoManager.GetInstance.PushReverseAction(x => Core.Engines.SupportEngine.UndoManualSupportConeProperty(x), manualSupportEvent);
                    }
                }
                else
                {
                    //grid support
                    var gridSupportCone  = this._datasource;
                    var gridSupportEvent = new GridSupportConePropertyChange();
                    gridSupportEvent.PropertyName = e.ChangedItem.Label;

                    if (gridSupportEvent.PropertyName == "Cross Support")
                    {
                        gridSupportEvent.PropertyValueNew = ((bool)e.ChangedItem.Value) == true ? 1f : 0f;
                        gridSupportEvent.PropertyValueOld = ((bool)e.OldValue) == true ? 1f : 0f;
                    }
                    else
                    {
                        gridSupportEvent.PropertyValueNew = (float)e.ChangedItem.Value;
                        gridSupportEvent.PropertyValueOld = (float)e.OldValue;
                    }
                    gridSupportEvent.ModelIndex = selectedModel.Index;

                    var selectedSurface = this._datasource.SupportSurface;
                    if (selectedModel != null)
                    {
                        var surfaceIndex = 0;
                        foreach (var flatSurface in selectedModel.Triangles.FlatSurfaces)
                        {
                            if (flatSurface == selectedSurface)
                            {
                                gridSupportEvent.IsFlatSurface        = true;
                                gridSupportEvent.SelectedSurfaceIndex = surfaceIndex;
                                break;
                            }

                            surfaceIndex++;
                        }

                        surfaceIndex = 0;
                        foreach (var horizontalSurface in selectedModel.Triangles.HorizontalSurfaces)
                        {
                            if (horizontalSurface == selectedSurface)
                            {
                                gridSupportEvent.IsHorizontalSurface  = true;
                                gridSupportEvent.SelectedSurfaceIndex = surfaceIndex;
                                break;
                            }

                            surfaceIndex++;
                        }
                    }

                    UndoRedoManager.GetInstance.PushReverseAction(x => Core.Engines.SupportEngine.UndoGridSupportConeProperty(x), gridSupportEvent);
                }

                if (e.ChangedItem.Label == "Translation-X")
                {
                    if (this._datasource.IsSurfaceSupport)
                    {
                        foreach (var supportCone in this._datasource.SupportSurface.SupportStructure)
                        {
                            supportCone.MoveTranslation = new Vector3((float)e.ChangedItem.Value, supportCone.MoveTranslationY, supportCone.MoveTranslationZ);
                        }

                        this._datasource.SupportSurface.UpdateBoundries(this._datasource.Model.Triangles);
                    }
                }
                else if (e.ChangedItem.Label == "Translation-Y")
                {
                    if (this._datasource.IsSurfaceSupport)
                    {
                        foreach (var supportCone in this._datasource.SupportSurface.SupportStructure)
                        {
                            supportCone.MoveTranslation = new Vector3(supportCone.MoveTranslationX, (float)e.ChangedItem.Value, supportCone.MoveTranslationZ);
                        }
                        this._datasource.SupportSurface.UpdateBoundries(this._datasource.Model.Triangles);
                    }
                    else
                    {
                        this._datasource.MoveTranslation = new Vector3(this._datasource.MoveTranslationX, (float)e.ChangedItem.Value, this._datasource.MoveTranslationZ);
                    }
                }
                else if (e.ChangedItem.Label == "Bottom Radius" && this._datasource.IsSurfaceSupport)
                {
                    var changingEvents = new Atum.Studio.Core.Events.SupportEventArgs();
                    changingEvents.BottomHeight = this._datasource.BottomHeight;
                    changingEvents.BottomRadius = (float)e.ChangedItem.Value;
                    changingEvents.MiddleRadius = this._datasource.MiddleRadius;
                    changingEvents.TopHeight    = this._datasource.TopHeight;
                    changingEvents.TopRadius    = this._datasource.TopRadius;

                    this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                    //this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                }
                else if (e.ChangedItem.Label == "Bottom Height" && this._datasource.IsSurfaceSupport)
                {
                    var changingEvents = new Atum.Studio.Core.Events.SupportEventArgs();
                    changingEvents.BottomRadius = this._datasource.BottomRadius;
                    changingEvents.BottomHeight = (float)e.ChangedItem.Value;
                    changingEvents.MiddleRadius = this._datasource.MiddleRadius;
                    changingEvents.TopHeight    = this._datasource.TopHeight;
                    changingEvents.TopRadius    = this._datasource.TopRadius;

                    this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                }
                else if (e.ChangedItem.Label == "Middle Radius" && this._datasource.IsSurfaceSupport)
                {
                    var changingEvents = new Core.Events.SupportEventArgs();
                    changingEvents.BottomRadius = this._datasource.BottomRadius;
                    changingEvents.BottomHeight = this._datasource.BottomHeight;
                    changingEvents.MiddleRadius = (float)e.ChangedItem.Value;
                    changingEvents.TopHeight    = this._datasource.TopHeight;
                    changingEvents.TopRadius    = this._datasource.TopRadius;

                    this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                }
                else if (e.ChangedItem.Label == "Top Radius" && this._datasource.IsSurfaceSupport)
                {
                    var changingEvents = new Core.Events.SupportEventArgs();
                    changingEvents.BottomRadius = this._datasource.BottomRadius;
                    changingEvents.BottomHeight = this._datasource.BottomHeight;
                    changingEvents.MiddleRadius = this._datasource.MiddleRadius;
                    changingEvents.TopHeight    = this._datasource.TopHeight;
                    changingEvents.TopRadius    = (float)e.ChangedItem.Value;

                    this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                }
                else if (e.ChangedItem.Label == "Top Height" && this._datasource.IsSurfaceSupport)
                {
                    var changingEvents = new Core.Events.SupportEventArgs();
                    changingEvents.BottomRadius = this._datasource.BottomRadius;
                    changingEvents.BottomHeight = this._datasource.BottomHeight;
                    changingEvents.MiddleRadius = this._datasource.MiddleRadius;
                    changingEvents.TopHeight    = (float)e.ChangedItem.Value;
                    changingEvents.TopRadius    = this._datasource.TopRadius;

                    this._datasource.SupportSurface.UpdateGridSupport(changingEvents);
                }
                else if (e.ChangedItem.Label == "Translation-Z")
                {
                }
                else if (e.ChangedItem.Label == "Cross Support")
                {
                    //change support cones in selected horizontal surface
                    foreach (var surface in this._datasource.Model.Triangles.HorizontalSurfaces)
                    {
                        if (surface.Selected)
                        {
                            surface.SupportStructure.Clear();
                            if (selectedModel is STLModel3D)
                            {
                                var stlModel = selectedModel as STLModel3D;
                                stlModel.UpdateSurfaceSupportASync(surface);
                            }

                            break;
                        }
                    }

                    //change support cones in selected horizontal surface
                    foreach (var surface in this._datasource.Model.Triangles.FlatSurfaces)
                    {
                        if (surface.Selected)
                        {
                            surface.SupportStructure.Clear();
                            if (selectedModel is STLModel3D)
                            {
                                var stlModel = selectedModel as STLModel3D;
                                stlModel.UpdateSurfaceSupportASync(surface);
                            }

                            break;
                        }
                    }
                }
                else if (e.ChangedItem.Label == "Cone Distance")
                {
                    //change support cones in selected horizontal surface
                    foreach (var surface in this._datasource.Model.Triangles.HorizontalSurfaces)
                    {
                        if (surface.Selected)
                        {
                            surface.SupportStructure.Clear();
                            if (selectedModel is STLModel3D)
                            {
                                var stlModel = selectedModel as STLModel3D;
                                stlModel.UpdateSurfaceSupportASync(surface);
                            }

                            break;
                        }
                    }

                    //change support cones in selected flat surface
                    foreach (var surface in this._datasource.Model.Triangles.FlatSurfaces)
                    {
                        if (surface.Selected)
                        {
                            surface.SupportStructure.Clear();
                            if (selectedModel is STLModel3D)
                            {
                                var stlModel = selectedModel as STLModel3D;
                                stlModel.UpdateSurfaceSupportASync(surface);
                            }

                            break;
                        }
                    }
                }

                this.ValueChanged?.Invoke(this);
            }
        }