예제 #1
0
        public SceneControlModelMagsAI()
        {
            InitializeComponent();

            this.onClosed += SceneControlModelMagsAI_onClosed;
            this.btnSelectionCircle.BackColor = this.btnSelectionCircle.SelectedBackgroundColor = BrandingManager.Button_HighlightColor;
            this.btnGenerateSupport.BackColor = this.btnModelMarkings.BorderColor = this.btnModelMarkings.ForeColor = BrandingManager.Button_BackgroundColor_Dark;

            this.HeaderText = "MAGS AI";

            if (FontManager.Loaded)
            {
                _fontRegular = FontManager.Montserrat14Regular;
            }
            else
            {
                this._fontRegular = new Font(FontFamily.GenericSerif, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            }

            this.lblInformation.Font     = this._fontRegular;
            this.btnGenerateSupport.Font = this._fontRegular;
            this.lblMoreOptions.Font     = this._fontRegular;
            this.plMoreOptions.Left      = this.lblMoreOptions.Left + this.lblMoreOptions.Width;

            //left icon
            var leftIconGraphicsPath = new GraphicsPath();

            leftIconGraphicsPath.AddEllipse(new RectangleF((this.btnSelectionCircle.Width / 2f) - 6, (btnSelectionCircle.Height / 2f) - 7.5f, 16, 16));
            this.btnSelectionCircle.IconGraphicsPath = leftIconGraphicsPath;
            this.btnSelectionCircle.IsSelected       = true;

            //right icon
            var rightIconGraphicsPath = new GraphicsPath();

            rightIconGraphicsPath.AddRectangle(new RectangleF((this.btnSelectionCircle.Width / 2f) - 8, (btnSelectionCircle.Height / 2f) - 6, 14, 14));
            this.btnSelectionSquare.IconGraphicsPath = rightIconGraphicsPath;
            this.btnSelectionSquare.IsSelected       = false;

            this.magsAISelectionSize.ValueChanged -= magsAISelectionSize_ValueChanged;
            this.magsAISelectionSize.Value         = UserProfileManager.UserProfile.Settings_Studio_SelectionBox_Size;
            this.magsAISelectionSize.ValueChanged += magsAISelectionSize_ValueChanged;

            if (UserProfileManager.UserProfile.Settings_Studio_SelectionBox_Type == Core.Models.MAGSAIMarkSelectionGizmo.TypeOfSelectionBox.Circle)
            {
                this.btnSelectionCircle_Click(null, null);
            }
            else
            {
                this.btnSelectionSquare_Click(null, null);
            }

            this.UpdateMoreOptionsCollapseState(true);
            MAGSAICompleted?.Invoke(null, null);
        }
예제 #2
0
        private void btnGenerateSupport_Click(object sender, EventArgs e)
        {
            this.btnGenerateSupport.Enabled = false;
            var selectedModel = ObjectView.SelectedModel;

            selectedModel.SupportBasement = false;

            //calc new model normal
            var autorotationNormal = selectedModel.Triangles.CalcSelectedOrientationTrianglesNormal();

            float zAngle; float yAngle;

            VectorHelper.CalcRotationAnglesYZFromVector(autorotationNormal, false, out zAngle, out yAngle);

            //rotate model
            if (!float.IsNaN(zAngle) && zAngle != 0)
            {
                selectedModel.Rotate(0, 0, selectedModel.RotationAngleZ - zAngle, RotationEventArgs.TypeAxis.Z);
                selectedModel.UpdateDefaultCenter();
            }

            if (!float.IsNaN(yAngle) && yAngle != 0)
            {
                selectedModel.Rotate(0, selectedModel.RotationAngleY - yAngle, 0, RotationEventArgs.TypeAxis.Y);
                selectedModel.UpdateDefaultCenter();
            }

            selectedModel.UpdateBoundries();
            selectedModel.MoveTranslationZ = 5f;
            selectedModel.LiftModelOnSupport();
            selectedModel.UpdateBinding();
            selectedModel.Triangles.UpdateSelectedOrientationTriangles(selectedModel);

            //   frmStudioMain.SceneControl.Enabled = false;
            Task.Run(() => {
                try { Core.Engines.MagsAI.MagsAIEngine.Calculate(selectedModel, PrintJobManager.CurrentPrintJobSettings.Material, PrintJobManager.SelectedPrinter); }
                catch {
                }
            }).ContinueWith(s =>
            {
                frmStudioMain.SceneControl.EnableRendering();
                if (UserProfileManager.UserProfile.Settings_Use_Support_Basement)
                {
                    selectedModel.SupportBasement = true;
                }

                if (this.btnGenerateSupport.InvokeRequired)
                {
                    this.btnGenerateSupport.Invoke(new MethodInvoker(

                                                       delegate
                    {
                        this.btnGenerateSupport.Enabled = true;
                    }
                                                       ));
                }
                else
                {
                    this.btnGenerateSupport.Enabled = true;
                }
            }).ContinueWith(t => {
                MAGSAICompleted?.Invoke(null, null);
            }, CancellationToken.None, TaskContinuationOptions.None,
                            TaskScheduler.FromCurrentSynchronizationContext());
        }