Exemplo n.º 1
0
        /// <summary>
        /// Overriden. Creates a simple shape, depending on the <see cref="Shape"/> value
        /// set in the accompanying <see cref="ControlDescription"/> object.
        /// </summary>
        /// <seealso cref="BaseControl.CreateShape"/>
        public override void CreateShape()
        {
            if (!Description.HasShape) return;

            ShapeDescription = ShapeCreator.ComputeData(this);
            Shapes[0] = ShapeDescription;
        }
Exemplo n.º 2
0
 public PhysxPhysicObject(ShapeDescription ShapeDescription, Matrix worldTransformation, Vector3 scale, String name = null)
 {
     Scale     = scale;
     ActorDesc = new ActorDescription()
     {
         Name       = name,
         GlobalPose = worldTransformation.AsPhysX(),
         Shapes     = { ShapeDescription },
     };
 }
 public PhysxPhysicObject(ShapeDescription ShapeDescription, Matrix worldTransformation, Vector3 scale, String name = null)
 {
     Scale = scale;
     ActorDesc = new ActorDescription()
     {                
         Name = name,                
         GlobalPose = worldTransformation.AsPhysX(),
         Shapes = { ShapeDescription },
     };
 }
 public PhysxTrigger(ShapeDescription ShapeDescription, Matrix worldTransformation, TriggerEvent evt,
                     String Name = null, bool FireOnBeginsTouching = false, bool FireOnEndsTouching = false, bool FireOnContaining = false)
 {
     this.Name = Name;
     this.FireOnBeginsTouching = FireOnBeginsTouching;
     this.FireOnEndsTouching   = FireOnEndsTouching;
     this.FireOnContaining     = FireOnContaining;
     ShapeDescription.Flags   |= ShapeFlag.TriggerEnable | ShapeFlag.TriggerOnEnter | ShapeFlag.TriggerOnLeave | ShapeFlag.TriggerOnStay;
     ShapeDescription.UserData = this;
     Physics.PhysxPhysicObject obj = new Physics.PhysxPhysicObject(ShapeDescription, worldTransformation, Vector3.One);
     obj.BeTrigger();
     GhostObject = obj;
     this.Event  = evt;
 }
Exemplo n.º 5
0
        public void DrawClosedPath()
        {
            CheckParameters(Options.Shader);

            Color4[] colors = Shader.Method(Shader, Points.Length, Shape.Rectangle);
            ushort[] indices;
            ColoredVertex[] vertices = PolyMesh.DrawPolyLine((int)Width, colors, true, Points, out indices);

            ShapeDescription pathShape = new ShapeDescription
            {
                Vertices = vertices,
                Indices = indices,
                Primitives = indices.Length / 3,
                Shape = Shape.RectangleMesh
            };

            shapes.Add(pathShape);
        }
Exemplo n.º 6
0
        public void DrawPolygon(ushort[] indices)
        {
            Color4[] colors = Shader.Method(Shader, Points.Length, Shape.Rectangle);
            ColoredVertex[] vertices = new ColoredVertex[Points.Length];

            //colors[colors.Length - 1] = new Color4(0, 1, 0);

            for (int i = 0; i < Points.Length; i++)
            {
                Vector4 vertex = Points[i];
                vertices[i] = new ColoredVertex(vertex, colors[i]);
            }

            ShapeDescription polygonShape = new ShapeDescription
            {
                Vertices = vertices,
                Indices = indices,
                Primitives = indices.Length / 3,
                Shape = Shape.RectangleMesh
            };

            shapes.Add(polygonShape);
        }
Exemplo n.º 7
0
 public void Insert(int index, ShapeDescription val)
 {
     _set.Insert(index, val);
 }
        protected override async void OnClick()
        {
            var selectedLayer = MapView.Active.GetSelectedLayers().FirstOrDefault();

            if (selectedLayer == null || !(selectedLayer is FeatureLayer))
            {
                MessageBox.Show("You have to select a feature layer.  The selected layer's database connection is then used to create the new FeatureClass.");
                return;
            }
            var selectedFeatureLayer = selectedLayer as FeatureLayer;

            await QueuedTask.Run(() =>
            {
                var selectedLayerTable = selectedFeatureLayer.GetTable();

                var testName = $@"Point{DateTime.Now:HHmmss}";
                var hasZ     = false;
                var hasM     = false;
                // Create a ShapeDescription object
                var shapeDescription = new ShapeDescription(GeometryType.Point, SpatialReferences.WebMercator)
                {
                    HasM = hasM,
                    HasZ = hasZ
                };
                var objectIDFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("ObjectID", FieldType.OID);
                var stringFieldDescription   = new ArcGIS.Core.Data.DDL.FieldDescription("TheString", FieldType.String);
                var intFieldDescription      = new ArcGIS.Core.Data.DDL.FieldDescription("TheInteger", FieldType.Integer);
                var dblFieldDescription      = new ArcGIS.Core.Data.DDL.FieldDescription("TheDouble", FieldType.Double)
                {
                    Precision = 9,
                    Scale     = 5
                };
                var dateFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDate", FieldType.Date);

                using (var geoDb = selectedLayerTable.GetDatastore() as Geodatabase)
                {
                    var fcName = $@"{testName}";
                    try
                    {
                        // Assemble a list of all of our field descriptions
                        var fieldDescriptions = new List <ArcGIS.Core.Data.DDL.FieldDescription>()
                        {
                            objectIDFieldDescription,
                            stringFieldDescription,
                            intFieldDescription,
                            dblFieldDescription,
                            dateFieldDescription
                        };
                        // Create a FeatureClassDescription object to describe the feature class
                        // that we want to create
                        var fcDescription =
                            new FeatureClassDescription(fcName, fieldDescriptions, shapeDescription);

                        // Create a SchemaBuilder object
                        SchemaBuilder schemaBuilder = new SchemaBuilder(geoDb);

                        // Add the creation of the new feature class to our list of DDL tasks
                        schemaBuilder.Create(fcDescription);

                        // Execute the DDL
                        bool success = schemaBuilder.Build();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($@"Exception: {ex}");
                    }
                }
            });
        }
Exemplo n.º 9
0
 public DiagramShapeEx(ShapeDescription shape, int x, int y, int width, int height) : base(shape, x, y, width, height)
 {
 }
Exemplo n.º 10
0
        public void FillRectangle()
        {
            CheckParameters(Options.Size | Options.Shader);
            int widthSegments;
            int heightSegments;
            float[] offsets = Shader.GradientType != GradientType.Uniform
                                      ? Shader.Gradient.Select(g => g.Offset).ToArray()
                                      : null;
            float[] widthOffsets = null;
            float[] heightOffsets = null;

            switch (Shader.GradientType)
            {
                case GradientType.Uniform:
                    widthSegments = heightSegments = 1;
                    break;
                case GradientType.LinearVerticalGradient:
                    widthSegments = 1;
                    heightSegments = offsets.Length - 1;
                    heightOffsets = offsets;
                    break;
                case GradientType.LinearHorizontalGradient:
                    widthSegments = offsets.Length - 1;
                    heightSegments = 1;
                    widthOffsets = offsets;
                    break;
                case GradientType.Radial:
                    widthSegments = offsets.Length;
                    heightSegments = widthSegments;
                    break;

                default:
                    throw Error.WrongCase("colorshader.GradientType", "DrawSubdividedRectangleWithOutline",
                        Shader.GradientType);
            }
            Color4[] colors = Shader.Method(Shader, (1 + widthSegments) * (1 + heightSegments), Shape.Rectangle);

            ushort[] indices;
            ColoredVertex[] vertices;

            if (widthSegments == 1 && heightSegments == 1)
                vertices = PolyMesh.CreateQuad(Position.ToVector4(),
                Width,
                Height,
                colors, out indices);
            else
                vertices = PolyMesh.CreateRectangleMesh
                    (Position.ToVector4(),
                     Width,
                     Height,
                     widthSegments,
                     heightSegments,
                     colors,
                     out indices,
                     widthOffsets,
                     heightOffsets);

            ShapeDescription rectangleShape = new ShapeDescription
            {
                Vertices = vertices,
                Indices = indices,
                Primitives = indices.Length/3,
                Shape = Shape.RectangleMesh
            };

            shapes.Add(rectangleShape);
        }
Exemplo n.º 11
0
 public DiagramShapeEx(ShapeDescription shape, int x, int y, int width, int height)
     : base(shape, x, y, width, height)
 {
 }
Exemplo n.º 12
0
        public void DrawClippedEllipse()
        {
            CheckParameters(Options.Size | Options.Shader);
            RadialShader rs = (RadialShader) Shader;
            // Create a polygon for the control bounds
            OrthoRectangle rectangle = new OrthoRectangle(Position.X, Position.Y, Width, Height);
            // Create the ellipse representing the radial effect

            Ellipse ellipse = rs.CreateEllipse(rectangle);

            // Create the ellipse polygon for the radial gradient
            PolyEllipse ellipsePolygon = PolyEllipse.CreateEllipse(ellipse, EllipseSegments);
            Polygon rectanglePolygon = (Polygon) rectangle;
            //rectanglePolygon.Detail(16);

            float[] offsets = Shader.Gradient.Skip(1).Select(g => g.Offset).ToArray();

            // Determine if we need to clip the inner ellipses
            int innerSegments = DetermineEllipsesToClip(ellipse, rectangle, offsets);

            Ellipse[] ellipses = (from f in offsets
                                  select new Ellipse(ellipse.Center, f*ellipse.RadiusX, f*ellipse.RadiusY)).ToArray();

            GradientStop[] gradient = rs.Gradient;

            List<Vector2D> points = new List<Vector2D>();
            //List<Polygon> clipResult = new List<Polygon>();
            PolyClipError polyClipError;

            //if (innerSegments < ellipses.Length)
            //{
            PolyEllipse outerEllipse = PolyEllipse.CreateEllipse(ellipse, rs.Slices, offsets);
            //EllipseClipper.ClipAgainstPolygon(outerEllipse, rectanglePolygon);

            for (int i = 0; i < outerEllipse.Slices; i++)
            {

                Polygon ringSlice = outerEllipse.GetRingSlice(i, 0, 3);
                Polygon clipResult = YuPengClipper.Intersect(ringSlice, rectanglePolygon, out polyClipError)[0];
                points.AddRange(clipResult.Vertices);
            }
            //}

            //if (innerSegments < ellipses.Length)
            //{
            //    for (int i = innerSegments; i < ellipses.Length; i++)
            //    {

            //        PolyEllipse firstClippedEllipse = PolyEllipse.CreateEllipse(ellipses[i], rs.Slices);

            //        Polygon clippedAgainstRectangle =
            //            YuPengClipper.Intersect(firstClippedEllipse, rectanglePolygon, out polyClipError)[0];
            //        points.AddRange(clippedAgainstRectangle.Vertices);
            //    }

            //    for (int i = 0; i < innerSegments; i++)
            //    {
            //        PolyEllipse innerEllipse = PolyEllipse.CreateEllipse(ellipses[i], rs.Slices);
            //        points.AddRange(innerEllipse.Vertices);
            //    }

                //points.Insert(0, ellipse.Center);
                ushort[] indices = Delauney.Triangulate(points);

                Color4[] colors = RadialShader.RadialManual2(gradient, points.Count, points, ellipse);
                ShapeDescription ellipseShape = new ShapeDescription
                                                {
                                                    Vertices = points.Select(
                                                        (v, index) =>
                                                        new ColoredVertex(new Vector4(v, Position.Z, 1.0f),
                                                                          colors[index])).ToArray(),
                                                    Indices = indices,
                                                    Primitives = indices.Length / 3,
                                                    Shape = Shape.RectangleMesh
                                                };

                shapes.Add(ellipseShape);
            //}

            //if (innerSegments != 0)
            //{

            //    rs.Gradient = SplitGradient(gradient, 0, innerSegments);
            //    DrawEllipse(ellipses[innerSegments - 1]);
            //    rs.Gradient = gradient;
            //}
        }
Exemplo n.º 13
0
        public void DrawEllipse()
        {
            CheckParameters(Options.Size | Options.Shader);
            RadialShader rs = (RadialShader) Shader;

            float[] offsets = Shader.Gradient.Select(g => g.Offset).ToArray();
            int segments = offsets.Length;
            Color4[] colors = Shader.Method(Shader, (segments - 1)*(rs.Slices) + 1,
                                            Shape.Rectangle);
            ushort[] indices;
            ColoredVertex[] vertices = PolyMesh.CreateEllipseMesh
                (Position.ToVector4(),
                 Width/2,
                 Height/2,
                 rs.Slices,
                 segments,
                 colors,
                 out indices,
                 offsets);

            ShapeDescription ellipseShape = new ShapeDescription
                                            {
                                                Vertices = vertices,
                                                Indices = indices,
                                                Primitives = indices.Length/3,
                                                Shape = Shape.RectangleMesh
                                            };

            shapes.Add(ellipseShape);
        }
Exemplo n.º 14
0
 internal void AssembleInterface()
 {
     hudShapes.Sort();
     hudInterface = ShapeDescription.Join(hudShapes.ToArray());
     GenerateRenderSteps(hudShapes);
 }
Exemplo n.º 15
0
        public override void CreateShape()
        {
            boxDescriptor = ShapeCreator.DrawFullRectangle(AbsoluteOrthoPosition, Size,
                Description.Enabled[0],InnerAreaColor,Description.BorderSize, Description.BorderStyle, BorderColor);
            boxDescriptor.Depth = Depth;
            boxDescriptor.Tag = Id;
            Shapes[0] = boxDescriptor;

            listPanel.Depth = new Depth
            {
                WindowLayer = Depth.WindowLayer,
                ComponentLayer = Depth.ComponentLayer - 1,
                ZOrder = Depth.ZOrder
            };

            foreach (BaseControl control in listPanel.Controls)
            {
                control.Depth = Depth.AsChildOf(listPanel.Depth);
            }
            AddItems(Items);
        }