Example #1
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
            {
                var aabb = ItemToScale.GetAxisAlignedBoundingBox();

                if (FitType == FitType.Box)
                {
                    var center      = aabb.Center;
                    var worldMatrix = this.WorldMatrix();

                    var minXyz = center - new Vector3(Width / 2, Depth / 2, Height / 2);
                    var maxXyz = center + new Vector3(Width / 2, Depth / 2, Height / 2);
                    var bounds = new AxisAlignedBoundingBox(minXyz, maxXyz);
                    //var leftW = Vector3Ex.Transform(, worldMatrix);
                    var right = Vector3Ex.Transform(center + new Vector3(Width / 2, 0, 0), worldMatrix);
                    // layer.World.Render3DLine(left, right, Agg.Color.Red);
                    layer.World.RenderAabb(bounds, worldMatrix, Agg.Color.Red, 1, 1);
                }
                else
                {
                    layer.World.RenderCylinderOutline(this.WorldMatrix(), aabb.Center, Diameter, Height, 30, Color.Red, 1, 1);
                }
                // turn the lighting back on
                GL.Enable(EnableCap.Lighting);
            }
        }
Example #2
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            var aabb = this.GetAxisAlignedBoundingBox();

            layer.World.RenderCylinderOutline(this.WorldMatrix(), aabb.Center, Diameter, aabb.ZSize, 30, Color.Red, 1, 1);
            layer.World.RenderCylinderOutline(this.WorldMatrix(), Vector3.Zero, Diameter, aabb.ZSize, 30, Color.Green, 1, 1);
        }
Example #3
0
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     if (layer.Scene.SelectedItem != null &&
         layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
     {
         layer.World.RenderDirectionAxis(RotateAbout, this.WorldMatrix(), 30);
     }
 }
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     if (layer.Scene.SelectedItem != null &&
         layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
     {
         var aabb = UntransformedChildren.GetAxisAlignedBoundingBox();
         layer.World.RenderCylinderOutline(this.WorldMatrix(), aabb.Center, Diameter, aabb.ZSize, 30, Color.Red, 1, 1);
     }
 }
Example #5
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
            var center     = sourceAabb.Center + new Vector3(RotationOffset);

            // render the top and bottom rings
            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, 1, sourceAabb.ZSize, 15, Color.Red, Color.Red, 5);

            // turn the lighting back on
            GL.Enable(EnableCap.Lighting);
        }
Example #6
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem == this)
            {
                suppressNormalDraw = true;

                var parentOfPaintTargets = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();

                var paintObjects = parentOfPaintTargets.Children
                                   .Where((i) => SelectedChildren
                                          .Contains(i.Name))
                                   .SelectMany(c => c.VisibleMeshes())
                                   .ToList();

                foreach (var item in paintObjects)
                {
                    transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 128)));
                }

                var keepObjects = parentOfPaintTargets.Children
                                  .Where((i) => !SelectedChildren
                                         .Contains(i.Name))
                                  .ToList();

                foreach (var keepItem in keepObjects)
                {
                    var isPaintChild = this.Children.Where(i => i.Name == keepItem.Name).FirstOrDefault() != null;
                    foreach (var item in keepItem.VisibleMeshes())
                    {
                        if (isPaintChild)
                        {
                            GLHelper.Render(item.Mesh,
                                            item.WorldColor(),
                                            item.WorldMatrix(),
                                            RenderTypes.Outlines,
                                            item.WorldMatrix() * layer.World.ModelviewMatrix);

                            //suppressNormalDraw = false;
                        }
                        else
                        {
                            GLHelper.Render(item.Mesh,
                                            item.WorldColor(this.SourceContainer),
                                            item.WorldMatrix(),
                                            RenderTypes.Outlines,
                                            item.WorldMatrix() * layer.World.ModelviewMatrix);
                        }
                    }
                }
            }
        }
Example #7
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
            {
                // we want to measure the
                var currentMatrixInv = Matrix.Inverted;
                var aabb             = this.GetAxisAlignedBoundingBox(currentMatrixInv);

                layer.World.RenderCylinderOutline(this.WorldMatrix(), new Vector3(rotationCenter, aabb.Center.Z), Diameter, aabb.ZSize, 30, Color.Red);
            }

            // turn the lighting back on
            GL.Enable(EnableCap.Lighting);
        }
        public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, string startingTextMessage = "", EditorType editorType = EditorType.Part)
        {
            this.EditorMode       = editorType;
            this.scene            = sceneContext.Scene;
            this.sceneContext     = sceneContext;
            this.interactionLayer = interactionLayer;
            this.World            = interactionLayer.World;

            var theme = ApplicationController.Instance.Theme;

            gridColors = new GridColors()
            {
                Gray  = theme.ResolveColor(theme.ActiveTabColor, theme.GetBorderColor((theme.Colors.IsDarkTheme ? 35 : 55))),
                Red   = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Red, (theme.Colors.IsDarkTheme ? 105 : 170))),
                Green = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Green, (theme.Colors.IsDarkTheme ? 105 : 170))),
                Blue  = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Blue, 195))
            };

            gCodeMeshColor = new Color(theme.Colors.PrimaryAccentColor, 35);

            scene.SelectionChanged += (sender, e) =>
            {
                Invalidate();
                lastSelectionChangedMs = UiThread.CurrentTimerMs;
            };

            BedColor         = new ColorF(.8, .8, .8, .7).ToColor();
            BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor();

            this.interactionLayer.DrawGlTransparentContent += Draw_GlTransparentContent;

            if (ViewOnlyTexture == null)
            {
                UiThread.RunOnIdle(() =>
                {
                    ViewOnlyTexture = new ImageBuffer(32, 32, 32);
                    var graphics2D  = ViewOnlyTexture.NewGraphics2D();
                    graphics2D.Clear(Color.White);
                    graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray);
                    // request the texture so we can set it to repeat
                    var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false);
                });
            }
        }
Example #9
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem == this)
            {
                suppressNormalDraw = true;

                var parentOfSubtractTargets = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();

                var removeObjects = parentOfSubtractTargets.Children
                                    .Where(i => SelectedChildren.Contains(i.ID))
                                    .SelectMany(c => c.VisibleMeshes())
                                    .ToList();

                foreach (var item in removeObjects)
                {
                    transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80)));
                }

                var keepItems = parentOfSubtractTargets.Children
                                .Where(i => !SelectedChildren.Contains(i.ID))
                                .ToList();

                foreach (var keepItem in keepItems)
                {
                    var drawItem = keepItem;

                    var keepItemResult = this.Children.Where(i => i.OwnerID == keepItem.ID).FirstOrDefault();
                    drawItem = keepItemResult != null ? keepItemResult : drawItem;

                    foreach (var item in drawItem.VisibleMeshes())
                    {
                        GLHelper.Render(item.Mesh,
                                        item.WorldColor(),
                                        item.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        item.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                }
            }
        }
Example #10
0
        public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, ThemeConfig theme, EditorType editorType = EditorType.Part)
        {
            this.EditorMode       = editorType;
            this.scene            = sceneContext.Scene;
            this.sceneContext     = sceneContext;
            this.interactionLayer = interactionLayer;
            this.World            = interactionLayer.World;
            this.theme            = theme;

            gridColors = new GridColors()
            {
                Gray  = theme.ResolveColor(theme.BackgroundColor, theme.GetBorderColor((theme.IsDarkTheme ? 35 : 55))),
                Red   = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Red, (theme.IsDarkTheme ? 105 : 170))),
                Green = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Green, (theme.IsDarkTheme ? 105 : 170))),
                Blue  = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Blue, 195))
            };

            gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35);

            // Register listeners
            scene.SelectionChanged += selection_Changed;

            BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor();

            this.interactionLayer.DrawGlTransparentContent += Draw_GlTransparentContent;

            if (ViewOnlyTexture == null)
            {
                // TODO: What is the ViewOnlyTexture???
                UiThread.RunOnIdle(() =>
                {
                    ViewOnlyTexture = new ImageBuffer(32, 32, 32);
                    var graphics2D  = ViewOnlyTexture.NewGraphics2D();
                    graphics2D.Clear(Color.White);
                    graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray);
                    // request the texture so we can set it to repeat
                    var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false);
                });
            }
        }
Example #11
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
            var distance   = Diameter / 2 + sourceAabb.YSize / 2;
            var center     = sourceAabb.Center + new Vector3(0, BendCcw ? distance : -distance, 0);

            center.X -= sourceAabb.XSize / 2 - (StartPercent / 100.0) * sourceAabb.XSize;

            // render the top and bottom rings
            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, Diameter, sourceAabb.ZSize, 100, Color.Red, Color.Transparent);

            // render the split lines
            var radius        = Diameter / 2;
            var circumference = MathHelper.Tau * radius;
            var xxx           = sourceAabb.XSize * (StartPercent / 100.0);
            var startAngle    = MathHelper.Tau * 3 / 4 - xxx / circumference * MathHelper.Tau;

            layer.World.RenderCylinderOutline(this.WorldMatrix(), center, Diameter, sourceAabb.ZSize, (int)Math.Max(0, Math.Min(100, this.MinSidesPerRotation)), Color.Transparent, Color.Red, phase: startAngle);

            // turn the lighting back on
            GL.Enable(EnableCap.Lighting);
        }
Example #12
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            if (layer.Scene.SelectedItem != null &&
                layer.Scene.SelectedItem == this)
            {
                suppressNormalDraw = true;

                var removeObjects = this.SourceContainer.VisibleMeshes()
                                    .Where((i) => SelectedChildren.Contains(i.Name)).ToList();
                var keepObjects = this.SourceContainer.VisibleMeshes()
                                  .Where((i) => !SelectedChildren.Contains(i.Name)).ToList();

                foreach (var item in removeObjects)
                {
                    transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(SourceContainer), 128)));
                }

                foreach (var item in keepObjects)
                {
                    var subtractChild = this.Children.Where(i => i.Name == item.Name).FirstOrDefault();
                    if (subtractChild != null)
                    {
                        GLHelper.Render(subtractChild.Mesh,
                                        subtractChild.Color,
                                        subtractChild.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        subtractChild.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                    else
                    {
                        GLHelper.Render(item.Mesh,
                                        item.WorldColor(SourceContainer),
                                        item.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        item.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                }
            }
        }
Example #13
0
        public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
        {
            suppressNormalDraw = true;

            var parentOfSourceItems = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();

            var sourceItems = parentOfSourceItems.Children.ToList();

            foreach (var paintItem in sourceItems)
            {
                var paintItemResults  = this.Children.Where(i => i.OwnerID == paintItem.ID);
                var wasSelected       = ComputedChildren.Contains(paintItem.ID);
                var currentlySelected = SelectedChildren.Contains(paintItem.ID);

                if (currentlySelected)
                {
                    // if this is selected always paint a transparent source
                    foreach (var item in paintItem.VisibleMeshes())
                    {
                        transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80)));
                    }

                    // if it was also selected in before (the results are right)
                    if (wasSelected)
                    {
                        // paint solid results
                        if (paintItemResults != null)
                        {
                            foreach (var paintItemResult in paintItemResults)
                            {
                                foreach (var item in paintItemResult.VisibleMeshes())
                                {
                                    GLHelper.Render(item.Mesh,
                                                    item.WorldColor(),
                                                    item.WorldMatrix(),
                                                    RenderTypes.Outlines,
                                                    item.WorldMatrix() * layer.World.ModelviewMatrix);
                                }
                            }
                        }
                    }
                }
                else if (wasSelected)
                {
                    // it is not selected now but was selected before (changed state)
                    // pant the solid source
                    foreach (var item in paintItem.VisibleMeshes())
                    {
                        GLHelper.Render(item.Mesh,
                                        item.WorldColor(),
                                        item.WorldMatrix(),
                                        RenderTypes.Outlines,
                                        item.WorldMatrix() * layer.World.ModelviewMatrix);
                    }
                }
                else                 // it is not selected now and was not before (same state)
                {
                    // paint the results
                    if (paintItemResults != null && paintItemResults.Count() > 0)
                    {
                        foreach (var paintItemResult in paintItemResults)
                        {
                            foreach (var item in paintItemResult.VisibleMeshes())
                            {
                                GLHelper.Render(item.Mesh,
                                                item.WorldColor(),
                                                item.WorldMatrix(),
                                                RenderTypes.Outlines,
                                                item.WorldMatrix() * layer.World.ModelviewMatrix);
                            }
                        }
                    }
                    else                     // we don't have any results yet
                    {
                        foreach (var item in paintItem.VisibleMeshes())
                        {
                            GLHelper.Render(item.Mesh,
                                            item.WorldColor(),
                                            item.WorldMatrix(),
                                            RenderTypes.Outlines,
                                            item.WorldMatrix() * layer.World.ModelviewMatrix);
                        }
                    }
                }
            }
        }
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     ImageToPathObject3D.DrawPath(this);
 }
Example #15
0
 public void DrawEditor(InteractionLayer layer, List <Object3DView> transparentMeshes, DrawEventArgs e, ref bool suppressNormalDraw)
 {
     layer.World.RenderDirectionAxis(Axis, this.WorldMatrix(), 30);
 }
        public CustomComponent()
            : base()
        {
            layers = new List<Layer>();

            //InteractionLayer interaction1 = new InteractionLayer();
            //interaction1.Control.SetOuterMargins(20, GavControl.DistanceType.Absolute);
            //_sampleLayers.Add(interaction1);

            //InteractionLayer interaction2 = new InteractionLayer();
            //interaction2.Control.SetOuterMargins(30, GavControl.DistanceType.Absolute);
            //_sampleLayers.Add(interaction2);
            /*
            GlyphLayer glyphLayer = new GlyphLayer();
            glyphLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute);
            layers.Add(glyphLayer);*/

            this.lineLayer = new LineLayer();
            this.lineLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute);
            this.lineLayer.XAxisSpacing = 30;
            this.lineLayer.YAxisSpacing = 30;
            layers.Add(this.lineLayer);

            this.axisLayer = new AxisLayer();
            this.axisLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute);
            this.axisLayer.XAxisSpacing = 30.0f;
            this.axisLayer.YAxisSpacing = 30.0f;
            layers.Add(this.axisLayer);

            this.interactionLayer = new InteractionLayer(this.lineLayer,this);
            this.interactionLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute);
            this.interactionLayer.SelectionChanged += new SelectionUpdatedEventHandler(InternalSelectionUpdatedEvent);
            layers.Add(this.interactionLayer);
            /*
            TextLayer textLayer = new TextLayer();
            textLayer.Control.SetOuterMargins(10, GavControl.DistanceType.Absolute);
            layers.Add(textLayer);
            */

            List<int> selected = new List<int>();
            selected.Add(201);
            selected.Add(202);
            selected.Add(203);

            // default settings
            this.TimeSourceAxis = Axis.Z;
            this.LineSourceAxis = Axis.Y;
            this.DataSourceAxis = Axis.X;
            this.DataLineXIndex = 0;
            this.DataLineYIndex = 1;
            this.DataLineThicknessIndex = -1;
            this.DataLineThicknessScale = 1.5f;
            this.ColorMap = null;
            this.SelectedIndexColor = Color.Red;
            this.AllowCustomizeXAxis = true;
            this.AllowCustomizeYAxis = true;
            this.AllowCustomizeThickness = true;

            this.SetSelectedIndexes(selected);

            foreach (Layer layer in layers)
            {
                AddLayer(layer);
            }
        }