Example #1
0
        internal Layer(string name, bool checkName)
            : base(name, DxfObjectCode.Layer, checkName)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException(nameof(name), "The layer name should be at least one character long.");

            this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase);
            this.color = AciColor.Default;
            this.linetype = Linetype.Continuous;
            this.isVisible = true;
            this.plot = true;
            this.lineweight = Lineweight.Default;
            this.transparency = new Transparency(0);
        }
Example #2
0
 protected EntityObject(EntityType type, string dxfCode)
     : base(dxfCode)
 {
     this.type = type;
     this.color = AciColor.ByLayer;
     this.layer = Layer.Default;
     this.lineType = LineType.ByLayer;
     this.lineweight = Lineweight.ByLayer;
     this.transparency = Transparency.ByLayer;
     this.lineTypeScale = 1.0;
     this.isVisible = true;
     this.normal = Vector3.UnitZ;
     this.reactors = new List<DxfObject>();
     this.xData = new XDataDictionary();
     this.xData.AddAppReg += this.XData_AddAppReg;
     this.xData.RemoveAppReg += this.XData_RemoveAppReg;
 }
Example #3
0
 public Pixbuf GetThumbnail(int width, int height, Transparency alpha)
 {
     return new Pixbuf(gimp_image_get_thumbnail(ID, width, height, alpha));
 }
Example #4
0
        public Pixel[,] GetThumbnail(Dimensions dimensions, Transparency alpha)
        {
            IntPtr src = gimp_image_get_thumbnail(ID, dimensions.Width,
                        dimensions.Height, alpha);
              var pixbuf = new Pixbuf(src);

              int bpp = ActiveDrawable.Bpp;
              var thumbnail = Pixel.ConvertToPixelArray(pixbuf.Pixels, dimensions, bpp);
              // Marshaller.Free(src);
              return thumbnail;
        }
Example #5
0
        static extern IntPtr gimp_image_get_thumbnail(Int32 image_ID,
						  int width,
						  int height,
						  Transparency alpha);
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <c>Attribute</c> class.
        /// </summary>
        /// <param name="definition"><see cref="AttributeDefinition">Attribute definition</see>.</param>
        /// <remarks>
        /// Although the attribute entity could override values defined in its definition for simplicity the implementation has restricted this possibility.
        /// </remarks>
        public Attribute(AttributeDefinition definition)
            : base(DxfObjectCode.Attribute)
        {
            if (definition == null)
                throw new ArgumentNullException("definition");

            //EntityObject properties
            this.color = definition.Color;
            this.layer = definition.Layer;
            this.lineType = definition.LineType;
            this.lineweight = definition.Lineweight;
            this.lineTypeScale = definition.LineTypeScale;
            this.transparency = definition.Transparency;
            this.isVisible = definition.IsVisible;
            this.normal = definition.Normal;

            //Attribute definition properties
            this.definition = definition;
            this.tag = definition.Tag;
            this.value = definition.Value;
            this.style = definition.Style;
            this.position = definition.Position;
            this.flags = definition.Flags;
            this.height = definition.Height;
            this.widthFactor = definition.WidthFactor;
            this.obliqueAngle = definition.ObliqueAngle;
            this.rotation = definition.Rotation;
            this.alignment = definition.Alignment;
        }
Example #7
0
        private Layer ReadLayer()
        {
            Debug.Assert(this.chunk.ReadString() == SubclassMarker.Layer);

            string name = null;
            bool isVisible = true;
            bool plot = true;
            AciColor color = AciColor.Default;
            Linetype linetype = Linetype.ByLayer;
            Lineweight lineweight = Lineweight.Default;
            LayerFlags flags = LayerFlags.None;
            Transparency transparency = new Transparency(0);
            XDataDictionary xData = new XDataDictionary();
            this.chunk.Next();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 2:
                        name = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        this.chunk.Next();
                        break;
                    case 70:
                        flags = (LayerFlags) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 62:
                        short index = this.chunk.ReadShort();
                        if (index < 0)
                        {
                            isVisible = false;
                            index = Math.Abs(index);
                        }
                        if (!color.UseTrueColor)
                            color = AciColor.FromCadIndex(index);

                        this.chunk.Next();
                        break;
                    case 420: // the layer uses true color
                        color = AciColor.FromTrueColor(this.chunk.ReadInt());
                        this.chunk.Next();
                        break;
                    case 6:
                        string linetypeName = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        linetype = this.GetLinetype(linetypeName);
                        this.chunk.Next();
                        break;
                    case 290:
                        plot = this.chunk.ReadBool();
                        this.chunk.Next();
                        break;
                    case 370:
                        lineweight = (Lineweight) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 1001:
                        string appId = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        XData data = this.ReadXDataRecord(new ApplicationRegistry(appId));
                        xData.Add(data);
                        break;
                    default:
                        if (this.chunk.Code >= 1000 && this.chunk.Code <= 1071)
                            throw new Exception("The extended data of an entity must start with the application registry code.");
                        this.chunk.Next();
                        break;
                }
            }

            if (string.IsNullOrEmpty(name) || !TableObject.IsValidName(name))
                return null;

            // read the layer transparency from the extended data
            XData xDataTransparency;
            if (xData.TryGetValue("AcCmTransparency", out xDataTransparency))
            {
                // there should be only one entry with the transparency value, the first 1071 code will be used
                foreach (XDataRecord record in xDataTransparency.XDataRecord)
                {
                    if (record.Code == XDataCode.Int32)
                    {
                        transparency = Transparency.FromAlphaValue((int) record.Value);
                        break;
                    }
                }
            }

            return new Layer(name, false)
            {
                Color = color,
                Linetype = linetype,
                IsVisible = isVisible,
                IsFrozen = flags.HasFlag(LayerFlags.Frozen),
                IsLocked = flags.HasFlag(LayerFlags.Locked),
                Plot = plot,
                Lineweight = lineweight,
                Transparency = transparency
            };
        }
Example #8
0
 /// <summary>
 ///  parse method is called from the atom parser to populate an Transparency node
 /// </summary>
 /// <param name="node">the xmlnode to parser</param>
 /// <returns>Transparency object</returns>
 public static Transparency parse(XmlNode node)
 {
     Transparency trans = null;
     if (String.Compare(node.NamespaceURI, BaseNameTable.gNamespace, true) == 0)
     {
         trans = new Transparency();
         if (node.Attributes != null)
         {
             trans.Value = node.Attributes["value"].Value;
         }
     }
     return trans;
 }
Example #9
0
        private Layer ReadLayer()
        {
            Debug.Assert(this.chunk.ReadString() == SubclassMarker.Layer);

            string name = null;
            bool isVisible = true;
            bool plot = true;
            AciColor color = AciColor.Default;
            LineType lineType = LineType.ByLayer;
            Lineweight lineweight = Lineweight.Default;
            LayerFlags flags = LayerFlags.None;
            Transparency transparency = new Transparency(0);

            this.chunk.Next();

            while (this.chunk.Code != 0)
            {
                switch (this.chunk.Code)
                {
                    case 2:
                        name = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        this.chunk.Next();
                        break;
                    case 70:
                        flags = (LayerFlags) this.chunk.ReadShort();
                        this.chunk.Next();
                        break;
                    case 62:
                        short index = this.chunk.ReadShort();
                        if (index < 0)
                        {
                            isVisible = false;
                            index = Math.Abs(index);
                        }
                        if (!color.UseTrueColor)
                            color = AciColor.FromCadIndex(index);

                        this.chunk.Next();
                        break;
                    case 420: // the layer uses true color
                        color = AciColor.FromTrueColor(this.chunk.ReadInt());
                        this.chunk.Next();
                        break;
                    case 6:
                        // the line type names ByLayer or ByBlock are case insensitive
                        string lineTypeName = this.DecodeEncodedNonAsciiCharacters(this.chunk.ReadString());
                        if (string.Compare(lineTypeName, LineType.ByLayerName, StringComparison.OrdinalIgnoreCase) == 0)
                            lineTypeName = LineType.ByLayerName;
                        else if (string.Compare(lineTypeName, LineType.ByBlockName, StringComparison.OrdinalIgnoreCase) == 0)
                            lineTypeName = LineType.ByBlockName;
                        lineType = this.GetLineType(lineTypeName);

                        this.chunk.Next();
                        break;
                    case 290:
                        plot = this.chunk.ReadBool();
                        this.chunk.Next();
                        break;
                    case 370:
                        lineweight = Lineweight.FromCadIndex(this.chunk.ReadShort());
                        this.chunk.Next();
                        break;
                    case 1001:
                        // layer transparency is stored in XData
                        // the ApplicationRegistries might be defined after the objects that requires them,
                        // same old story this time we don't need to store the information in the object XData since it is only supported by entities.
                        if (this.chunk.ReadString() == "AcCmTransparency")
                        {
                            this.chunk.Next();
                            transparency = Transparency.FromAlphaValue(this.chunk.ReadInt());
                        }
                        this.chunk.Next();
                        break;
                    default:
                        this.chunk.Next();
                        break;
                }
            }

            if (string.IsNullOrEmpty(name)) return null;

            return new Layer(name)
            {
                Color = color,
                LineType = lineType,
                IsVisible = isVisible,
                IsFrozen = (flags & LayerFlags.Frozen) == LayerFlags.Frozen,
                IsLocked = (flags & LayerFlags.Locked) == LayerFlags.Locked,
                Plot = plot,
                Lineweight = lineweight,
                Transparency = transparency
            };
        }
        private bool CheckAdjacent( int x, int y, int z, Direction direction, Transparency transparency )
        {
            // returns true if a face should be spawned

            Index index = chunk.GetAdjacentIndex(x,y,z, direction);
            ushort adjacentVoxel = chunk.GetVoxel(index.x, index.y, index.z);

            if (adjacentVoxel == ushort.MaxValue) { // if the neighbor chunk is missing

            if (Engine.ShowBorderFaces || direction == Direction.up) {
                return true;
            }
            else {
                return false;
            }

            }

            Transparency result = Engine.GetVoxelType (adjacentVoxel).VTransparency;	// get the transparency of the adjacent voxel

            // parse the result (taking into account the transparency of the adjacent block as well as the one doing this check)
            if (transparency == Transparency.transparent) {
            if (result == Transparency.transparent)
                return false; // don't draw a transparent block next to another transparent block
            else
                return true; // draw a transparent block next to a solid or semi-transparent
            }
            else {
            if (result == Transparency.solid)
             	return false; // don't draw a solid block or a semi-transparent block next to a solid block
            else
                return true; // draw a solid block or a semi-transparent block next to both transparent and semi-transparent
            }
        }