Ejemplo n.º 1
0
 public ClippingTypeModel(string name, ClippingType clippingType, string description, string imageUri)
 {
     this.ClippingType = clippingType;
     this.ImageUri     = imageUri;
     this.Description  = description;
     this.Name         = name;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the shapes.
 /// </summary>
 /// <param name="paths">The paths.</param>
 /// <param name="clippingType">The clipping type.</param>
 public void AddPaths(IEnumerable <IPath> paths, ClippingType clippingType)
 {
     Guard.NotNull(paths, nameof(paths));
     foreach (IPath p in paths)
     {
         this.AddPath(p, clippingType);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="clippingType">The clipping type.</param>
 public void AddPath(IPath path, ClippingType clippingType)
 {
     Guard.NotNull(path, nameof(path));
     foreach (ISimplePath p in path.Flatten())
     {
         this.AddPath(p, clippingType);
     }
 }
Ejemplo n.º 4
0
 internal LgrImage(string name, Bitmap bmp, ImageType type, int dist, ClippingType ctype)
 {
     Name         = name;
     Bmp          = bmp;
     Type         = type;
     Distance     = dist;
     ClippingType = ctype;
 }
Ejemplo n.º 5
0
 internal LevelFileTexture(string name, string maskName, Vector position, int distance,
                           ClippingType clipping)
 {
     Name     = name;
     MaskName = maskName;
     Position = position;
     Distance = distance;
     Clipping = clipping;
 }
Ejemplo n.º 6
0
        public void ParseAnnotationInfoShouldCaptureAnnotationMetadata(ClippingType type, string line)
        {
            var clip = this.clipping.ParseAnnotationInfo(line);

            Assert.IsNotNull(clip);
            Assert.AreEqual(type, clip.Type);
            Assert.AreEqual(12, clip.PageNumber);
            Assert.AreEqual(new LineLocation(100, 120), clip.Location);
            Assert.AreEqual(new DateTime(2019, 08, 15, 10, 17, 58), clip.CreationDate);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds the shapes.
        /// </summary>
        /// <param name="paths">The paths.</param>
        /// <param name="clippingType">The clipping type.</param>
        public void AddPaths(IEnumerable <IPath> paths, ClippingType clippingType)
        {
            if (paths is null)
            {
                throw new ArgumentNullException(nameof(paths));
            }

            foreach (IPath p in paths)
            {
                this.AddPath(p, clippingType);
            }
        }
Ejemplo n.º 8
0
 internal DrawableImage(int textureId, double width, double height, ClippingType clipping,
                        int distance,
                        string name, Lgr.ImageType type)
 {
     TextureIdentifier = textureId;
     Width             = width;
     Height            = height;
     DefaultClipping   = clipping;
     DefaultDistance   = distance;
     Name = name;
     Type = type;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds the path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="clippingType">The clipping type.</param>
        public void AddPath(IPath path, ClippingType clippingType)
        {
            if (path is null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            foreach (ISimplePath p in path.Flatten())
            {
                this.AddPath(p, clippingType);
            }
        }
Ejemplo n.º 10
0
 private Picture(Picture T)
 {
     Clipping      = T.Clipping;
     Distance      = T.Distance;
     Height        = T.Height;
     Name          = T.Name;
     Position      = T.Position.Clone();
     Id            = T.Id;
     Width         = T.Width;
     TextureId     = T.TextureId;
     TextureName   = T.TextureName;
     TextureWidth  = T.TextureWidth;
     TextureHeight = T.TextureHeight;
 }
Ejemplo n.º 11
0
 internal void SetPicture(ElmaRenderer.DrawableImage pictureImage, Vector position, int distance,
                          ClippingType clipping)
 {
     Position      = position;
     Id            = pictureImage.TextureIdentifier;
     Width         = pictureImage.Width;
     Height        = pictureImage.Height;
     Clipping      = clipping;
     Distance      = distance;
     Name          = pictureImage.Name;
     TextureId     = 0;
     TextureName   = null;
     TextureWidth  = 0;
     TextureHeight = 0;
 }
Ejemplo n.º 12
0
 internal void SetTexture(ClippingType clipping, int distance, Vector position,
                          ElmaRenderer.DrawableImage texture, ElmaRenderer.DrawableImage mask)
 {
     Clipping      = clipping;
     Distance      = distance;
     Height        = mask.Height;
     Name          = mask.Name;
     Position      = position;
     Id            = mask.TextureIdentifier;
     Width         = mask.Width;
     TextureId     = texture.TextureIdentifier;
     TextureName   = texture.Name;
     TextureWidth  = texture.Width;
     TextureHeight = texture.Height;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes the type of the clipping.
        /// </summary>
        /// <param name="polyType">Type of the poly.</param>
        public void InitClippingType(ClippingType polyType)
        {
            if (this.Current.Y >= this.NextEdge.Current.Y)
            {
                this.Bottom = this.Current;
                this.Top    = this.NextEdge.Current;
            }
            else
            {
                this.Top    = this.Current;
                this.Bottom = this.NextEdge.Current;
            }

            this.PolyType = polyType;

            this.ConfigureDelta();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Adds the path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="clippingType">Type of the poly.</param>
        /// <exception cref="ClipperException">AddPath: Open paths have been disabled.</exception>
        internal void AddPath(ISimplePath path, ClippingType clippingType)
        {
            IReadOnlyList <PointF> vectors = path.Points;

            var points = new List <IntPoint>(vectors.Count);

            for (int i = 0; i < vectors.Count; i++)
            {
                var v = vectors[i];
                points.Add(new IntPoint(v.X * ScalingFactor, v.Y * ScalingFactor));
            }

            var type = clippingType == ClippingType.Clip ? PolyType.ptClip : PolyType.ptSubject;

            lock (this.syncRoot)
                this.innerClipper.AddPath(points, type, path.IsClosed);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Adds the path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="clippingType">Type of the poly.</param>
        /// <exception cref="ClipperException">AddPath: Open paths have been disabled.</exception>
        internal void AddPath(ISimplePath path, ClippingType clippingType)
        {
            var             vectors = path.Points;
            List <IntPoint> points  = new List <ClipperLib.IntPoint>(vectors.Length);

            foreach (var v in vectors)
            {
                points.Add(new IntPoint(v.X * ScalingFactor, v.Y * ScalingFactor));
            }

            PolyType type = clippingType == ClippingType.Clip ? PolyType.ptClip : PolyType.ptSubject;

            lock (this.syncRoot)
            {
                this.innerClipper.AddPath(points, type, path.IsClosed, path);
            }
        }
Ejemplo n.º 16
0
        public void ToAnnotationShouldConvertClippingToAnnotation(ClippingType type, AnnotationType expectedType)
        {
            var clipping = new Clipping
            {
                Author       = "Dummy author",
                Book         = "Dummy book",
                Content      = "Sample highlighted content",
                CreationDate = new DateTime(2019, 08, 15, 10, 48, 48),
                PageNumber   = 90,
                Location     = new LineLocation(10, 12),
                Type         = type
            };

            var annotation = clipping.ToAnnotation();

            Assert.IsNotNull(annotation);
            Assert.AreEqual(clipping.Content, annotation.Content);
            Assert.AreEqual(clipping.CreationDate, annotation.CreatedDate);
            Assert.AreEqual(clipping.PageNumber, annotation.Context.PageNumber);
            Assert.AreEqual("line://10-12", annotation.Context.SerializedLocation);
            Assert.AreEqual(clipping.Book, annotation.Document.Title);
            Assert.AreEqual(clipping.Author, annotation.Document.Author);
            Assert.AreEqual(expectedType, annotation.Type);
        }
Ejemplo n.º 17
0
 public static void SetClippingEnabled(DependencyObject obj, ClippingType value)
 => obj.SetValue(ClippingEnabledProperty, value);
Ejemplo n.º 18
0
 internal Picture(ElmaRenderer.DrawableImage pictureImage, Vector position, int distance,
                  ClippingType clipping)
 {
     SetPicture(pictureImage, position, distance, clipping);
 }
Ejemplo n.º 19
0
 internal Picture(ClippingType clipping, int distance, Vector position, ElmaRenderer.DrawableImage texture,
                  ElmaRenderer.DrawableImage mask)
 {
     SetTexture(clipping, distance, position, texture, mask);
 }
Ejemplo n.º 20
0
        /// <summary>
        ///     Transforms a physical value to the corresponding world value.
        /// </summary>
        /// <param name="physical">
        ///     The physical value to get world value for
        /// </param>
        /// <param name="physicalMin">
        ///     The minimum physical extent of the axis
        /// </param>
        /// <param name="physicalMax">
        ///     The maximum physical extent of the axis
        /// </param>
        /// <param name="clippingType">
        ///     Whether or not to snap to the max / min world value if outside this range
        /// </param>
        /// <returns>
        ///     the world value corresponding to the supplied physical value
        /// </returns>
        public virtual double PhysicalToWorld(double physical, double physicalMin, double physicalMax, ClippingType clippingType)
        {
            double world = ((physical - physicalMin) / (physicalMax - physicalMin)) * WorldRange + WorldMin;

            if (clippingType == ClippingType.Clip)
            {
                if (world > WorldMax)
                {
                    world = WorldMax;
                }
                else if (world < WorldMin)
                {
                    world = WorldMin;
                }
            }
            return(world);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Returns the physical coordinate corresponding to the provided world coordinate.
 /// </summary>
 /// <param name="world">The world value to transform to physical coordinate</param>
 /// <param name="clippingType">Whether or not to clip.</param>
 /// <returns>physical coordinate corresponding to world provided.</returns>
 public abstract double WorldToPhysical(double world, ClippingType clippingType);
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClippablePath" /> struct.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="type">The type.</param>
 public ClippablePath(IPath path, ClippingType type)
 {
     this.Path = path;
     this.Type = type;
 }
Ejemplo n.º 23
0
 private static AnnotationType MapAnnotationType(ClippingType type)
 {
     return(type == ClippingType.Highlight
         ? AnnotationType.Highlight
         : AnnotationType.Note);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClipableShape"/> struct.
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <param name="type">The type.</param>
 public ClipableShape(IShape shape, ClippingType type)
 {
     this.Shape = shape;
     this.Type  = type;
 }
Ejemplo n.º 25
0
        /// <summary>
        ///     Transforms a world to a physical coordinate transform. The default transform is linear,
        ///     subclasses may change this behavior.
        /// </summary>
        /// <param name="clippingType">
        ///     Whether or not to clip the transform to be within the bounds of the physical axis extent
        /// </param>
        /// <param name="world">
        ///     The world coordinate to transform
        /// </param>
        /// <param name="physicalMin">
        ///     The minimum physical coordinate
        /// </param>
        /// <param name="physicalMax">
        ///     The maximum physical coordinate
        /// </param>
        /// <returns>
        ///     The physical coordinate corresponding to the world coordinate.
        /// </returns>
        public virtual double WorldToPhysical(double world, double physicalMin, double physicalMax, ClippingType clippingType)
        {
            double physical = ((world - WorldMin) / WorldRange) * (physicalMax - physicalMin) + physicalMin;

            if (clippingType == ClippingType.NoClip)
            {
                return(physical);
            }
            if (physicalMax > physicalMin)
            {
                if (physical < physicalMin)
                {
                    return(physicalMin);
                }
                if (physical > physicalMax)
                {
                    return(physicalMax);
                }
            }
            else
            {
                if (physical > physicalMin)
                {
                    return(physicalMin);
                }
                if (physical < physicalMax)
                {
                    return(physicalMax);
                }
            }
            return(physical);
        }
Ejemplo n.º 26
0
        internal Lgr(string lgrFile)
        {
            byte[] lgrData = File.ReadAllBytes(lgrFile);
            if (Encoding.ASCII.GetString(lgrData, 0, 5) != "LGR12")
            {
                throw (new Exception("The specified LGR file " + lgrFile + " is not valid!"));
            }
            int numberOfPcXs    = BitConverter.ToInt32(lgrData, 5);
            int numberOfOptPcXs = BitConverter.ToInt32(lgrData, 13);

            for (int i = 0; i < numberOfOptPcXs; i++)
            {
                ListedImages.Add(new ListedImage
                {
                    Name = Utils.ReadNullTerminatedString(lgrData, i * 10 + 17, 10).ToLower(),
                    Type =
                        (ImageType)
                        BitConverter.ToInt32(lgrData, 17 + numberOfOptPcXs * 10 + i * 4),
                    Distance     = BitConverter.ToInt32(lgrData, 17 + numberOfOptPcXs * 14 + i * 4),
                    ClippingType =
                        (ClippingType)
                        BitConverter.ToInt32(lgrData, 17 + numberOfOptPcXs * 18 + i * 4),
                    Transparency =
                        (Transparency)
                        BitConverter.ToInt32(lgrData, 17 + numberOfOptPcXs * 22 + i * 4)
                });
            }

            int sp = 17 + numberOfOptPcXs * 26;

            for (int i = 0; i < numberOfPcXs; i++)
            {
                string lgrImageName =
                    Path.GetFileNameWithoutExtension(Utils.ReadNullTerminatedString(lgrData, sp, 12)).ToLower();
                var          isGrass         = lgrImageName == "qgrass";
                ImageType    imgType         = isGrass ? ImageType.Texture : ImageType.Picture;
                int          imgDistance     = 500;
                ClippingType imgClippingType = isGrass ? ClippingType.Ground : ClippingType.Unclipped;
                var          transparency    = Transparency.TopLeft;
                foreach (ListedImage x in ListedImages)
                {
                    if (x.Name == lgrImageName)
                    {
                        imgType         = x.Type;
                        imgClippingType = x.ClippingType;
                        imgDistance     = x.Distance;
                        if (!TransparencyIgnoreSet.Contains(x.Name))
                        {
                            transparency = x.Transparency;
                        }
                    }
                }

                sp += 24;
                int    sizeOfPcx = BitConverter.ToInt32(lgrData, sp - 4);
                byte[] data      = new byte[sizeOfPcx];
                Array.ConstrainedCopy(lgrData, sp, data, 0, sizeOfPcx);
                MemoryStream memStream = new MemoryStream(data);
                try
                {
                    Bitmap bmp = new Pcx(memStream).ToBitmap();
                    if (imgType != ImageType.Texture)
                    {
                        switch (transparency)
                        {
                        case Transparency.NotTransparent:
                            break;

                        case Transparency.Palette0:
                            bmp.MakeTransparent(Color.Black);     // TODO get from palette index 0
                            break;

                        // If the transparency field value is invalid, we'll assume Transparency.TopLeft as it is the most common case.
                        default:
                            // case Transparency.TopLeft:
                            bmp.MakeTransparent(bmp.GetPixel(0, 0));
                            break;

                        case Transparency.TopRight:
                            bmp.MakeTransparent(bmp.GetPixel(bmp.Width - 1, 0));
                            break;

                        case Transparency.BottomLeft:
                            bmp.MakeTransparent(bmp.GetPixel(0, bmp.Height - 1));
                            break;

                        case Transparency.BottomRight:
                            bmp.MakeTransparent(bmp.GetPixel(bmp.Width - 1, bmp.Height - 1));
                            break;
                        }
                    }

                    LgrImages.Add(new LgrImage(lgrImageName, bmp, imgType, imgDistance, imgClippingType));
                }
                finally
                {
                    memStream.Close();
                }

                sp += sizeOfPcx;
            }
        }
Ejemplo n.º 27
0
        public void ClipByPolygon(Polygon2D polygon, ClippingType type)
        {
            foreach (Edge2D edge in _edges)
            {
                var visibleParts = edge.VisibleParts.ToArray();
                edge.VisibleParts.Clear();

                foreach (var visiblePart in visibleParts)
                {
                    ClippingResult result = ClippingService.ClipLineByPolygon(visiblePart, polygon);

                    if (result.Position == LinePosition.OutsideFully)
                    {
                        if (type == ClippingType.Inside)
                        {
                            edge.NotVisibleParts.Add(visiblePart);
                        }
                        else if (type == ClippingType.External)
                        {
                            edge.VisibleParts.Add(visiblePart);
                        }
                    }
                    else if (result.Position == LinePosition.InsideFully)
                    {
                        if (type == ClippingType.Inside)
                        {
                            edge.VisibleParts.Add(visiblePart);
                        }
                        else if (type == ClippingType.External)
                        {
                            edge.NotVisibleParts.Add(visiblePart);
                        }
                    }
                    else if (result.Position == LinePosition.InsidePartial)
                    {
                        if ((result.t0 == 0) && (result.t1 != 1))
                        {
                            var crossPoint = result.t1.GetLinePoint(visiblePart);

                            if (type == ClippingType.Inside)
                            {
                                edge.VisibleParts.Add((visiblePart.Start, crossPoint));
                                edge.NotVisibleParts.Add((crossPoint, visiblePart.End));
                            }
                            else if (type == ClippingType.External)
                            {
                                edge.NotVisibleParts.Add((visiblePart.Start, crossPoint));
                                edge.VisibleParts.Add((crossPoint, visiblePart.End));
                            }
                        }
                        else if ((result.t0 != 0) && (result.t1 == 1))
                        {
                            var crossPoint = result.t0.GetLinePoint(visiblePart);

                            if (type == ClippingType.Inside)
                            {
                                edge.VisibleParts.Add((crossPoint, visiblePart.End));
                                edge.NotVisibleParts.Add((visiblePart.Start, crossPoint));
                            }
                            else if (type == ClippingType.External)
                            {
                                edge.NotVisibleParts.Add((crossPoint, visiblePart.End));
                                edge.VisibleParts.Add((visiblePart.Start, crossPoint));
                            }
                        }
                        else
                        {
                            var crossPoint1 = result.t0.GetLinePoint(visiblePart);
                            var crossPoint2 = result.t1.GetLinePoint(visiblePart);

                            if (type == ClippingType.Inside)
                            {
                                edge.VisibleParts.Add((crossPoint1, crossPoint2));
                                edge.NotVisibleParts.Add((visiblePart.Start, crossPoint1));
                                edge.NotVisibleParts.Add((crossPoint2, visiblePart.End));
                            }
                            else if (type == ClippingType.External)
                            {
                                edge.NotVisibleParts.Add((crossPoint1, crossPoint2));
                                edge.VisibleParts.Add((visiblePart.Start, crossPoint1));
                                edge.VisibleParts.Add((crossPoint2, visiblePart.End));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 28
0
        internal Lgr(string lgrFile)
        {
            using (var stream = File.OpenRead(lgrFile))
            {
                Path = lgrFile;
                var lgr = new BinaryReader(stream, Encoding.ASCII);
                if (lgr.ReadString(5) != "LGR12")
                {
                    throw new Exception($"The LGR file {lgrFile} is not valid (magic start string not found)");
                }
                int numberOfPcXs       = lgr.ReadInt32();
                int picturesLstVersion = lgr.ReadInt32(); // unused
                int numberOfOptPcXs    = lgr.ReadInt32();
                var pcxNames           = new List <string>();
                var pcxTypes           = new List <ImageType>();
                var distances          = new List <int>();
                var clippingTypes      = new List <ClippingType>();
                var transparencies     = new List <Transparency>();
                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    pcxNames.Add(lgr.ReadNullTerminatedString(10));
                }

                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    pcxTypes.Add((ImageType)lgr.ReadInt32());
                }

                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    distances.Add(lgr.ReadInt32());
                }

                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    clippingTypes.Add((ClippingType)lgr.ReadInt32());
                }

                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    transparencies.Add((Transparency)lgr.ReadInt32());
                }

                for (int i = 0; i < numberOfOptPcXs; i++)
                {
                    ListedImages.Add(new ListedImage
                    {
                        Name         = pcxNames[i].ToLower(),
                        Type         = pcxTypes[i],
                        Distance     = distances[i],
                        ClippingType = clippingTypes[i],
                        Transparency = transparencies[i]
                    });
                }

                for (int i = 0; i < numberOfPcXs; i++)
                {
                    string       lgrImageName    = System.IO.Path.GetFileNameWithoutExtension(lgr.ReadNullTerminatedString(12)).ToLower();
                    var          isGrass         = lgrImageName == "qgrass";
                    ImageType    imgType         = isGrass ? ImageType.Texture : ImageType.Picture;
                    int          imgDistance     = 500;
                    ClippingType imgClippingType = isGrass ? ClippingType.Ground : ClippingType.Unclipped;
                    var          transparency    = Transparency.TopLeft;
                    foreach (ListedImage x in ListedImages)
                    {
                        if (x.Name == lgrImageName)
                        {
                            imgType         = x.Type;
                            imgClippingType = x.ClippingType;
                            imgDistance     = x.Distance;
                            if (!TransparencyIgnoreSet.Contains(x.Name))
                            {
                                transparency = x.Transparency;
                            }
                        }
                    }

                    lgr.ReadInt32(); // unknown, not used
                    lgr.ReadInt32(); // unknown, not used
                    int    sizeOfPcx = lgr.ReadInt32();
                    Bitmap bmp       = new Pcx(stream).ToBitmap();
                    if (imgType != ImageType.Texture)
                    {
                        switch (transparency)
                        {
                        case Transparency.NotTransparent:
                            break;

                        case Transparency.Palette0:
                            bmp.MakeTransparent(Color.Black);     // TODO get from palette index 0
                            break;

                        // If the transparency field value is invalid, we'll assume Transparency.TopLeft as it is the most common case.
                        default:
                            // case Transparency.TopLeft:
                            bmp.MakeTransparent(bmp.GetPixel(0, 0));
                            break;

                        case Transparency.TopRight:
                            bmp.MakeTransparent(bmp.GetPixel(bmp.Width - 1, 0));
                            break;

                        case Transparency.BottomLeft:
                            bmp.MakeTransparent(bmp.GetPixel(0, bmp.Height - 1));
                            break;

                        case Transparency.BottomRight:
                            bmp.MakeTransparent(bmp.GetPixel(bmp.Width - 1, bmp.Height - 1));
                            break;
                        }
                    }

                    LgrImages.Add(new LgrImage(lgrImageName, bmp, imgType, imgDistance, imgClippingType));
                }
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Returns the world coordinate corresponding to the provided physical coordinate.
 /// </summary>
 /// <param name="physical">the physical coordinate to get world value for</param>
 /// <param name="clippingType">whether or not to clip.</param>
 /// <returns>world coordinate corresponding to physical provided</returns>
 public abstract double PhysicalToWorld(double physical, ClippingType clippingType);
Ejemplo n.º 30
0
        public Collection <Feature> Clip(FeatureLayer featureSource, IEnumerable <Feature> areaBaseShape, ClippingType clipMode)
        {
            Collection <Feature> clipedFeatures = new Collection <Feature>();

            switch (clipMode)
            {
            case ClippingType.Inverse:
                foreach (var feature in InverseClip(featureSource, areaBaseShape))
                {
                    clipedFeatures.Add(feature);
                }
                break;

            case ClippingType.Standard:
            default:
                foreach (var feature in StandardClip(featureSource, areaBaseShape))
                {
                    clipedFeatures.Add(feature);
                }
                break;
            }

            return(clipedFeatures);
        }