Example #1
0
        private void SetViewMode(PartViewMode viewMode)
        {
            if (gcodePanel == null || gcode2DWidget == null)
            {
                // Wait for controls to initialize
                return;
            }

            switch (viewMode)
            {
            case PartViewMode.Layers2D:
                UserSettings.Instance.set(UserSettingsKey.LayerViewDefault, "2D Layer");
                gcode2DWidget.Visible = true;
                break;

            case PartViewMode.Layers3D:
                UserSettings.Instance.set(UserSettingsKey.LayerViewDefault, "3D Layer");
                break;

            case PartViewMode.Model:
                break;
            }

            gcode2DWidget.Visible = viewMode == PartViewMode.Layers2D;

            view3DWidget.InteractionLayer.DrawOpenGLContent = printer?.ViewState.ViewMode != PartViewMode.Layers2D;

            sceneContext.ViewState.ModelView = viewMode == PartViewMode.Model;

            gcodeContainer.Visible = viewMode != PartViewMode.Model;

            tumbleCubeControl.Visible = !gcode2DWidget.Visible;

            if (viewMode == PartViewMode.Layers3D)
            {
                printer.Bed.Scene.ClearSelection();
            }

            this.SetSliderVisibility();

            view3DWidget.modelViewSidePanel.Visible = printer?.ViewState.ViewMode == PartViewMode.Model;
        }
        public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard)
            : base(calibrationWizard)
        {
            this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize();
            this.HeaderText  = "Calibration Print".Localize();

            preCalibrationPrintViewMode = printer.ViewState.ViewMode;

            contentRow.Padding = theme.DefaultContainerPadding;

            // default to normal offset
            calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0;

            contentRow.AddChild(
                new TextWidget(
                    "This wizard will close to print a calibration part and resume after the print completes.".Localize(),
                    textColor: theme.TextColor,
                    pointSize: theme.DefaultFontSize)
            {
                Margin = new BorderDouble(bottom: theme.DefaultContainerPadding)
            });

            contentRow.AddChild(
                new TextWidget(
                    "Calibration Mode".Localize(),
                    textColor: theme.TextColor,
                    pointSize: theme.DefaultFontSize)
            {
                Margin = new BorderDouble(0, theme.DefaultContainerPadding)
            });


            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                Margin  = new BorderDouble(left: theme.DefaultContainerPadding),
                HAnchor = HAnchor.Stretch,
            };

            contentRow.AddChild(column);

            var coarseText = calibrationWizard.Quality == QualityType.Coarse ? "Initial (Recommended)".Localize() : "Coarse".Localize();

            column.AddChild(coarseCalibration = new RadioButton(coarseText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Coarse
            });
            coarseCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Coarse;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter);
            };

            var normalText = calibrationWizard.Quality == QualityType.Normal ? "Normal (Recommended)".Localize() : "Normal".Localize();

            column.AddChild(normalCalibration = new RadioButton(normalText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Normal
            });
            normalCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Normal;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0;
            };

            column.AddChild(fineCalibration = new RadioButton("Fine".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Fine
            });
            fineCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Fine;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0;
            };

            this.NextButton.Visible = false;

            // add in the option to tell the system the printer is already calibrated
            var alreadyCalibratedButton = theme.CreateDialogButton("Already Calibrated".Localize());

            alreadyCalibratedButton.Name   = "Already Calibrated Button";
            alreadyCalibratedButton.Click += (s, e) =>
            {
                printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1");
                this.FinishWizard();
            };

            this.AddPageAction(alreadyCalibratedButton);

            var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize());

            startCalibrationPrint.Name   = "Start Calibration Print";
            startCalibrationPrint.Click += async(s, e) =>
            {
                await PrintCalibrationPart(calibrationWizard);
            };

            this.AcceptButton = startCalibrationPrint;

            this.AddPageAction(startCalibrationPrint);
        }
        public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard)
            : base(calibrationWizard)
        {
            this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize();
            this.HeaderText  = "Calibration Print".Localize();

            preCalibrationPrintViewMode = printer.ViewState.ViewMode;

            contentRow.Padding = theme.DefaultContainerPadding;

            // default to normal offset
            calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0;

            contentRow.AddChild(
                new TextWidget(
                    "This wizard will close to print a calibration part and resume after the print completes.".Localize(),
                    textColor: theme.TextColor,
                    pointSize: theme.DefaultFontSize)
            {
                Margin = new BorderDouble(bottom: theme.DefaultContainerPadding)
            });

            contentRow.AddChild(
                new TextWidget(
                    "Calibration Mode".Localize(),
                    textColor: theme.TextColor,
                    pointSize: theme.DefaultFontSize)
            {
                Margin = new BorderDouble(0, theme.DefaultContainerPadding)
            });


            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                Margin  = new BorderDouble(left: theme.DefaultContainerPadding),
                HAnchor = HAnchor.Stretch,
            };

            contentRow.AddChild(column);

            var coarseText = calibrationWizard.Quality == QualityType.Coarse ? "Initial (Recommended)".Localize() : "Coarse".Localize();

            column.AddChild(coarseCalibration = new RadioButton(coarseText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Coarse
            });
            coarseCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Coarse;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter);
            };

            var normalText = calibrationWizard.Quality == QualityType.Normal ? "Normal (Recommended)".Localize() : "Normal".Localize();

            column.AddChild(normalCalibration = new RadioButton(normalText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Normal
            });
            normalCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Normal;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0;
            };

            column.AddChild(fineCalibration = new RadioButton("Fine".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)
            {
                Checked = calibrationWizard.Quality == QualityType.Fine
            });
            fineCalibration.CheckedStateChanged += (s, e) =>
            {
                calibrationWizard.Quality = QualityType.Fine;
                calibrationWizard.Offset  = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0;
            };

            var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
            int tabIndex        = 0;
            var allUiFields     = new Dictionary <string, UIField>();
            var settingAdded    = false;

            void AddSettingsRow(string warning, string key)
            {
                if (!settingAdded)
                {
                    contentRow.AddChild(
                        new TextWidget(
                            "Recommended Settings Changes".Localize() + ":",
                            textColor: theme.TextColor,
                            pointSize: theme.DefaultFontSize)
                    {
                        Margin = new BorderDouble(10, 0, 0, 20)
                    });

                    settingAdded = true;
                }

                contentRow.AddChild(
                    new WrappedTextWidget(
                        warning,
                        textColor: theme.TextColor,
                        pointSize: theme.DefaultFontSize)
                {
                    Margin = new BorderDouble(0, 10, 0, 20)
                });

                var settingsData = PrinterSettings.SettingsData[key];
                var row          = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex, allUiFields);

                if (row is SliceSettingsRow settingsRow)
                {
                    settingsRow.ArrowDirection = ArrowDirection.Left;
                }

                contentRow.AddChild(row);
            }

            if (printer.Settings.GetValue <double>(SettingsKey.layer_height) < printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 2)
            {
                // The layer height is very small and it will be hard to see features. Show a warning.
                AddSettingsRow("The calibration object will printer better if the layer hight is set to a larger value. It is recommended that your increase it.".Localize(), SettingsKey.layer_height);
            }

            if (printer.Settings.GetValue <bool>(SettingsKey.create_raft))
            {
                // The layer height is very small and it will be hard to see features. Show a warning.
                AddSettingsRow("A raft is not needed for the calibration object. It is recommended that you turn it off.".Localize(), SettingsKey.create_raft);
            }

            this.NextButton.Visible = false;

            // add in the option to tell the system the printer is already calibrated
            var alreadyCalibratedButton = theme.CreateDialogButton("Already Calibrated".Localize());

            alreadyCalibratedButton.Name   = "Already Calibrated Button";
            alreadyCalibratedButton.Click += (s, e) =>
            {
                printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1");
                this.FinishWizard();
            };

            this.AddPageAction(alreadyCalibratedButton);

            var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize());

            startCalibrationPrint.Name   = "Start Calibration Print";
            startCalibrationPrint.Click += async(s, e) =>
            {
                await PrintCalibrationPart(calibrationWizard);
            };

            this.AcceptButton = startCalibrationPrint;

            this.AddPageAction(startCalibrationPrint);
        }