Class Hatch
- Namespace
- CADability.GeoObject
- Assembly
- CADability.dll
A GeoObject that represents a flat (2d) shape filled by a HatchStyle. It also acts as a Block presenting e.g. the hatch lines as its containing child objects. To fully define a Hatch object you have to set these three properties: Plane, CompoundShape and HatchStyle. If you omit one of these properties you wont see the Hatch object as it is not fully defined. No defaults are assumed.
public class Hatch : Block, IGeoObject, ILayer, IStyle, IOctTreeInsertable, IComparable, IFeedBack, ICloneable, IColorDef, IGeoObjectOwner, IDeserializationCallback, IExportStep, IJsonSerializeDone, ISerializable, IHatchStyle, IJsonSerialize
- Inheritance
-
Hatch
- Implements
- Inherited Members
Constructors
Hatch()
Empty constructor, must be called when a derived object is constructed.
protected Hatch()
Hatch(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected Hatch(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
Fields
Constructor
Factory mechanism for constructing Hatch objects If you have a class derivec from this class (Hatch) and everytime CADability creates a hatch object your object should be created, you have to register your static construct method here.
public static Hatch.ConstructionDelegate Constructor
Field Value
OnPaintTo3D
Hook to replace the painting of hatches: when set, PaintTo3D(IPaintTo3D) calls this delegate and does nothing more if it returns true. It is not consulted for a solid hatch on a paint interface that can fill paths, which is painted as a filled path directly. Hides OnPaintTo3D, which is not used for hatches. Null by default.
public static Hatch.PaintTo3DDelegate OnPaintTo3D
Field Value
OnRecalc
Hook to replace the generation of the hatch contents: when set, Recalc() calls this delegate and uses the returned objects as the contents of the hatch instead of what GenerateContent(CompoundShape, Plane) produces. Returning null falls back to the hatch style. Applies to all hatches. Null by default.
public static Hatch.RecalcDelegate OnRecalc
Field Value
Properties
ColorDef
The color of the block. Contained objects whose color is "from parent" (fromParent) are displayed in this color and follow it when it changes; objects with a color of their own are not affected. May be null, the objects "from parent" are then displayed in the default color. Setting it raises the change events and is undoable.
public override ColorDef ColorDef { get; set; }
Property Value
CompoundShape
The 2d shape (outline and holes, in the coordinate system of Plane) that is filled by this hatch. Setting it marks the hatch lines for recalculation.
public CompoundShape CompoundShape { get; set; }
Property Value
- CompoundShape
The shape (CompoundShape, bounding curves and holes) which is handled by this object
HatchStyle
The HatchStyle that defines the interior of this object
public HatchStyle HatchStyle { get; set; }
Property Value
Layer
Fully implements Layer. Stores the layer in a private member. Setting raises the WillChangeEvent and DidChangeEvent.
public override Layer Layer { get; set; }
Property Value
OwnedItems
Returns an array of objects owned by this object. E.g. a face is owned by a shell.
public override IGeoObject[] OwnedItems { get; }
Property Value
Plane
The Plane which defines the 3d position of the CompoundShape.
public Plane Plane { get; set; }
Property Value
PreferredStyle
Returns the preferred style for this objects, see Style.EDefaultFor.
public override Style.EDefaultFor PreferredStyle { get; }
Property Value
Style
Fully implements Style. Stores the style in a private member. Setting raises the WillChangeEvent and DidChangeEvent.
public override Style Style { get; set; }
Property Value
Methods
Clone()
public override IGeoObject Clone()
Returns
- IGeoObject
see Clone()
Construct()
The only way to construct a hatch object. If a Constructor is registered, this constructor will be used, if not a Hatch object is created.
public static Hatch Construct()
Returns
CopyGeometry(IGeoObject)
Overrides IGeoObjectImpl.CopyGeometry(IGeoObject) and implements IGeoObject.CopyGeometry(IGeoObject).
public override void CopyGeometry(IGeoObject ToCopyFrom)
Parameters
ToCopyFromIGeoObject
Decompose()
Decomposes the object into simpler objects, see Decompose(). The default implementation returns null: the object cannot be decomposed.
public override GeoObjectList Decompose()
Returns
- GeoObjectList
the parts, or null
GetAttributeProperties(IFrame)
Overrides IGeoObjectImpl.GetAttributeProperties(IFrame) and implements IGeoObject.GetAttributeProperties(IFrame).
public override IPropertyEntry[] GetAttributeProperties(IFrame Frame)
Parameters
FrameIFrame
Returns
GetBoundingCube()
Returns a bounding cube of the object. The object must fir into this cube. There may be a smaller cube that contains the object if it is to expensive to calculate the exact cube.
public override BoundingCube GetBoundingCube()
Returns
- BoundingCube
the bounding cube
GetExtent(Projection, ExtentPrecision)
Returns the 2d extent of the object as it appears in the given projection, in the coordinates of the projection's plane (not in pixels).
public override BoundingRect GetExtent(Projection projection, ExtentPrecision extentPrecision)
Parameters
projectionProjectionthe projection
extentPrecisionExtentPrecisionExact for the exact extent, Raw for a quick estimate that may be larger
Returns
- BoundingRect
the extent in the projection's 2d coordinates
GetExtent(double)
Gets the 3-dimensional extent of an object
public override BoundingCube GetExtent(double precision)
Parameters
precisiondoublePrecision of the test
Returns
- BoundingCube
The minmax cube
GetObjectData(IJsonWriteData)
Implements GetObjectData(IJsonWriteData): writes the data of the block (GetObjectData(IJsonWriteData)) followed by the shape, the hatch style and the plane of the hatch. The contents are brought up to date first. Hides the base method so that the interface is bound to this one.
public void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDatareceives the data
GetObjectData(SerializationInfo, StreamingContext)
Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.
public override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
GetQuadTreeItem(Projection, ExtentPrecision)
Returns an item for a 2d quad tree of the projected objects, used for hit tests in a projection: it knows the 2d extent of the object, whether a 2d rectangle hits it, and the depth (z position) of the object at a 2d point. Composite objects (blocks, solids, paths) return a collection of the items of their parts.
public override IQuadTreeInsertableZ GetQuadTreeItem(Projection projection, ExtentPrecision extentPrecision)
Parameters
projectionProjectionthe projection
extentPrecisionExtentPrecisionprecision of the extent, see GetExtent(Projection, ExtentPrecision)
Returns
- IQuadTreeInsertableZ
the item for the quad tree
GetShowProperties(IFrame)
Overrides IGeoObjectImpl.GetShowProperties(IFrame) and implements IGeoObject.GetShowProperties(IFrame).
public override IPropertyEntry GetShowProperties(IFrame Frame)
Parameters
FrameIFrame
Returns
HitTest(ref BoundingCube, double)
Tests whether an object is touched by the provided cube
public override bool HitTest(ref BoundingCube cube, double precision)
Parameters
cubeBoundingCubeTo test with
precisiondoubleRequired precision
Returns
- bool
true if the object strikes the cube
HitTest(Projection, BoundingRect, bool)
Tests whether an object is inside or touched by the rectangle when projected with the provided projection
public override bool HitTest(Projection projection, BoundingRect rect, bool onlyInside)
Parameters
projectionProjectionThe projection for the test
rectBoundingRectThe rectangle to test the position
onlyInsidebooltrue: the object must be totaly inside the rectangle, false: the object must be totaly or partially inside the rectangle
Returns
- bool
true when the test succeedes, false otherwise
IsAttributeUsed(object)
Overrides IGeoObjectImpl.IsAttributeUsed(object) and implements IGeoObject.IsAttributeUsed(object).
public override bool IsAttributeUsed(object Attribute)
Parameters
Attributeobject
Returns
Modify(ModOp)
Overrides IGeoObjectImpl.Modify(ModOp) and implements IGeoObject.Modify(ModOp).
public override void Modify(ModOp m)
Parameters
mModOpsee Modify(ModOp)
PaintTo3D(IPaintTo3D)
Paints the object with the methods of paintTo3D: lines, triangles, text... The views implement
IPaintTo3D (with OpenGL or GDI) and collect what the object paints in a display list, so this is
called rarely, after PrepareDisplayList(double) has done the expensive work (triangulation, approximation).
public override void PaintTo3D(IPaintTo3D paintTo3D)
Parameters
paintTo3DIPaintTo3Dwhere to paint
PaintTo3DList(IPaintTo3D, ICategorizedDislayLists)
Adds this object as a whole to the display lists, in the category of its layer. Suitable for simple objects like curves and text; composite objects (solids, shells, blocks) override it and add their parts by category.
public override void PaintTo3DList(IPaintTo3D paintTo3D, ICategorizedDislayLists lists)
Parameters
paintTo3DIPaintTo3Dthe paint interface of the view
listsICategorizedDislayListsthe display lists to add to
Position(GeoPoint, GeoVector, double)
Returns the smallest parameter value (l) where the provided line hits the object so that the point
fromHere + l * direction is on or close to the object. The result may be negative.
Return double.MaxValue if there is no such point.
public override double Position(GeoPoint fromHere, GeoVector direction, double precision)
Parameters
fromHereGeoPointStartpoint of the line
directionGeoVectorDirection of the line
precisiondoublePrecision for the test
Returns
- double
Position on the line
Recalc()
After the HatchStyle, the CompoundShape or the HatchStyle has been modified this method must be called to calculate the new contents.
public void Recalc()
SetObjectData(IJsonReadData)
Implements SetObjectData(IJsonReadData): reads the data of the block (SetObjectData(IJsonReadData)) followed by the shape, the hatch style and the plane of the hatch. Hides the base method so that the interface is bound to this one.
public void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDataprovides the data
Events
Constructed
Raised from the constructor whenever a hatch is created, by Construct() as well as when a hatch is read from a file. The handler gets the new hatch; when it was created by Construct(), its Plane, CompoundShape and HatchStyle are not set yet. Lets an application attach to every hatch without deriving from the class.
public static event Hatch.ConstructedDelegate Constructed