public View3DBrailleBuilder(Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape)
        {
            boldTypeFace  = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationMono.svg")));
            brailTypeFace = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "Braille.svg")));

            MeshGroupExtraData = new List <PlatingMeshGroupData>();

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);

            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();

            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape);
                meshViewerWidget.AllowBedRenderingWhenEmpty = true;
                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonBottomPanel.HAnchor         = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding         = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

                processingProgressControl         = new ProgressControl("Finding Parts:".Localize(), ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;

                editPlateButtonsContainer = new FlowLayoutWidget();

                textToAddWidget         = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter Text Here".Localize());
                textToAddWidget.VAnchor = VAnchor.ParentCenter;
                textToAddWidget.Margin  = new BorderDouble(5);
                editPlateButtonsContainer.AddChild(textToAddWidget);
                textToAddWidget.ActualTextEditWidget.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                Button insertTextButton = textImageButtonFactory.Generate("Insert".Localize());
                editPlateButtonsContainer.AddChild(insertTextButton);
                insertTextButton.Click += (sender, e) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                editToolBar.AddChild(editPlateButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);
            }

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);

            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            viewControls3D = new ViewControls3D(meshViewerWidget);

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();

            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

            closeButton = textImageButtonFactory.Generate("Close".Localize());
            buttonBottomPanel.AddChild(closeButton);

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;

            AddChild(viewControls3D);

            // set the view to be a good angle and distance
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Scale = .06;
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(-MathHelper.Tau * .02, 0, 0)));
            meshViewerWidget.TrackballTumbleWidget.TrackBallController.Translate(-new Vector3(bedCenter));

            AddHandlers();
            UnlockEditControls();
            // but make sure we can't use the right panel yet
            buttonRightPanelDisabledCover.Visible = true;

            //meshViewerWidget.RenderType = RenderTypes.Outlines;
            viewControls3D.PartSelectVisible = false;
        }
Exemplo n.º 2
0
        public View3DTextCreator(Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape)
        {
            boldTypeFace = TypeFace.LoadFrom(StaticData.Instance.ReadAllText(Path.Combine("Fonts", "LiberationSans-Bold.svg")));

            MeshGroupExtraData = new List <PlatingMeshGroupData>();

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);

            centerPartPreviewAndControls.AnchorAll();

            GuiWidget viewArea = new GuiWidget();

            viewArea.AnchorAll();
            {
                meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape);
                meshViewerWidget.AllowBedRenderingWhenEmpty = true;
                meshViewerWidget.AnchorAll();
            }
            viewArea.AddChild(meshViewerWidget);

            centerPartPreviewAndControls.AddChild(viewArea);
            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

            FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonBottomPanel.HAnchor         = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding         = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);

            // add in the plater tools
            {
                FlowLayoutWidget editToolBar = new FlowLayoutWidget();

                processingProgressControl         = new ProgressControl("Finding Parts:".Localize(), ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
                processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
                editToolBar.AddChild(processingProgressControl);
                editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;

                editPlateButtonsContainer = new FlowLayoutWidget();

                textToAddWidget         = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter Text Here".Localize());
                textToAddWidget.VAnchor = VAnchor.ParentCenter;
                textToAddWidget.Margin  = new BorderDouble(5);
                editPlateButtonsContainer.AddChild(textToAddWidget);
                textToAddWidget.ActualTextEditWidget.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                Button insertTextButton = textImageButtonFactory.Generate("Insert".Localize());
                editPlateButtonsContainer.AddChild(insertTextButton);
                insertTextButton.Click += (sender, e) =>
                {
                    InsertTextNow(textToAddWidget.Text);
                };

                KeyDown += (sender, e) =>
                {
                    KeyEventArgs keyEvent = e as KeyEventArgs;
                    if (keyEvent != null && !keyEvent.Handled)
                    {
                        if (keyEvent.KeyCode == Keys.Escape)
                        {
                            if (meshSelectInfo.downOnPart)
                            {
                                meshSelectInfo.downOnPart = false;

                                ScaleRotateTranslate translated = SelectedMeshTransform;
                                translated.translation *= transformOnMouseDown;
                                SelectedMeshTransform   = translated;

                                Invalidate();
                            }
                        }
                    }
                };

                editToolBar.AddChild(editPlateButtonsContainer);
                buttonBottomPanel.AddChild(editToolBar);
            }

            GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);

            centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
            buttonRightPanelHolder.AddChild(buttonRightPanel);

            viewControls3D = new ViewControls3D(meshViewerWidget);

            viewControls3D.ResetView += (sender, e) =>
            {
                SetDefaultView();
            };

            buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
            buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
            buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);
            LockEditControls();

            GuiWidget leftRightSpacer = new GuiWidget();

            leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
            buttonBottomPanel.AddChild(leftRightSpacer);

            closeButton = textImageButtonFactory.Generate("Close".Localize());
            buttonBottomPanel.AddChild(closeButton);

            mainContainerTopToBottom.AddChild(buttonBottomPanel);

            this.AddChild(mainContainerTopToBottom);
            this.AnchorAll();

            meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;

            AddChild(viewControls3D);

            SetDefaultView();

            AddHandlers();
            UnlockEditControls();
            // but make sure we can't use the right panel yet
            buttonRightPanelDisabledCover.Visible = true;
        }
Exemplo n.º 3
0
        void CreateAndAddChildren(object state)
        {
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();

            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;

            CloseAndRemoveAllChildren();
            gcodeViewWidget = null;
            gcodeProcessingStateInfoText = null;

            FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

            buttonBottomPanel                 = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonBottomPanel.HAnchor         = HAnchor.ParentLeftRight;
            buttonBottomPanel.Padding         = new BorderDouble(3, 3);
            buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            generateGCodeButton        = textImageButtonFactory.Generate(LocalizedString.Get("Generate"));
            generateGCodeButton.Click += new EventHandler(generateButton_Click);
            buttonBottomPanel.AddChild(generateGCodeButton);

            layerSelectionButtonsPanel         = new FlowLayoutWidget(FlowDirection.RightToLeft);
            layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight;
            layerSelectionButtonsPanel.Padding = new BorderDouble(0);

            GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height);

            layerSelectionButtonsPanel.AddChild(holdPanelOpen);

            if (widgetHasCloseButton)
            {
                Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
                layerSelectionButtonsPanel.AddChild(closeButton);
                closeButton.Click += (sender, e) =>
                {
                    CloseOnIdle();
                };
            }

            FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);

            centerPartPreviewAndControls.AnchorAll();

            gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop);

            SetProcessingMessage("Press 'Add' to select an item.".Localize());
            if (printItem != null)
            {
                SetProcessingMessage(LocalizedString.Get("Loading GCode..."));
                if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
                {
                    gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation));
                }
                else
                {
                    if (File.Exists(printItem.FileLocation))
                    {
                        string gcodePathAndFileName = printItem.GetGCodePathAndFileName();
                        bool   gcodeFileIsComplete  = printItem.IsGCodeFileComplete(gcodePathAndFileName);

                        if (printItem.SlicingHadError)
                        {
                            SetProcessingMessage(slicingErrorMessage);
                        }
                        else
                        {
                            SetProcessingMessage(pressGenerateMessage);
                        }

                        if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
                        {
                            gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
                        }

                        // we only hook these up to make sure we can regenerate the gcode when we want
                        printItem.SlicingOutputMessage.RegisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents);
                        printItem.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
                    }
                    else
                    {
                        SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name));
                    }
                }
            }
            else
            {
                generateGCodeButton.Visible = false;
            }

            centerPartPreviewAndControls.AddChild(gcodeDisplayWidget);

            buttonRightPanel         = CreateRightButtonPanel();
            buttonRightPanel.Visible = false;
            centerPartPreviewAndControls.AddChild(buttonRightPanel);

            // add in a spacer
            layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight));
            buttonBottomPanel.AddChild(layerSelectionButtonsPanel);

            mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);
            mainContainerTopToBottom.AddChild(buttonBottomPanel);
            this.AddChild(mainContainerTopToBottom);

            meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize());
            meshViewerWidget.AnchorAll();
            meshViewerWidget.AllowBedRenderingWhenEmpty = true;
            gcodeDisplayWidget.AddChild(meshViewerWidget);
            meshViewerWidget.Visible = false;
            meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent);

            viewControls2D = new ViewControls2D();
            AddChild(viewControls2D);
            viewControls3D = new ViewControls3D(meshViewerWidget);
            viewControls3D.PartSelectVisible = false;
            AddChild(viewControls3D);
            viewControls3D.rotateButton.ClickButton(null);
            viewControls3D.Visible = false;

            viewControlsToggle         = new ViewControlsToggle();
            viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight;
            AddChild(viewControlsToggle);
            viewControlsToggle.Visible = false;

            //viewControls3D.translateButton.ClickButton(null);

            // move things into the right place and scale
            {
                Vector3 bedCenter3D = new Vector3(bedCenter, 0);
                meshViewerWidget.PrinterBed.Translate(bedCenter3D);
                meshViewerWidget.TrackballTumbleWidget.TrackBallController.Scale = .05;
                meshViewerWidget.TrackballTumbleWidget.TrackBallController.Translate(-bedCenter3D);
            }

            viewControls2D.translateButton.Click += (sender, e) =>
            {
                gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move;
            };
            viewControls2D.scaleButton.Click += (sender, e) =>
            {
                gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale;
            };

            AddHandlers();
        }