Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
ChingYen  
#1 Posted : Wednesday, May 18, 2011 6:00:59 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Hi,

We need to draw an VObjectPath with "Transparent hole" at the middle with a given PointF[].

The simple idea will be something like XOR of 2 VObjectPath. Wondering how can we do XOR on VObject ? Or if create own Custom VObjectPath is needed, please advise us on how..

Thanks..
Alex Kon  
#2 Posted : Friday, May 20, 2011 3:32:38 AM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello ChingYen,

You can do this by modifying existing PathVObject or creating new one - it depends on what you want to get.

If you need to "make a hole" in RectangleVObject - you can inherit it and add new circular shape to it's path. By default paths are filled with FillMode.Alternate, so this will result in a "hole effect".

If you need to "make a hole" in an Image - you can just create ImageVObject based on image with transparent area inside. Or make this area with Graphics Mill methods.

Best regards,
Alex Kon
ChingYen  
#3 Posted : Saturday, May 21, 2011 5:40:16 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Alex Kon wrote:
Hello ChingYen,

If you need to "make a hole" in RectangleVObject - you can inherit it and add new circular shape to it's path. By default paths are filled with FillMode.Alternate, so this will result in a "hole effect".

Best regards,
Alex Kon


Do you mind to give us an example on this? Thanks.
ChingYen  
#4 Posted : Tuesday, May 24, 2011 1:07:06 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
ChingYen wrote:
Alex Kon wrote:
Hello ChingYen,

If you need to "make a hole" in RectangleVObject - you can inherit it and add new circular shape to it's path. By default paths are filled with FillMode.Alternate, so this will result in a "hole effect".

Best regards,
Alex Kon


Do you mind to give us an example on this? Thanks.


What we really need is a RectangleVObject with a Transparent Polygon inside. Big Thanks...
Alex Kon  
#5 Posted : Tuesday, May 24, 2011 2:37:28 AM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello Ching-Yen,

Here is simple snippet (no coords checks, be careful :)) for rectangle object with hole:

Code:
class HoledRectVObject: RectangleVObject
{
	public HoledRectVObject(float x, 
							float y, 
							float w, 
							float h, 
							float holeX, 
							float holeY, 
							float holeRadius, 
							bool makeRoundHole)
		: base(x, y, w, h)

	{
		if (makeRoundHole)
		{
			base.Path.AddEllipse(
							x + holeX - holeRadius, 
							y + holeY - holeRadius, 2 * holeRadius, 2 * holeRadius);
		}
		else
		{
			System.Drawing.PointF[] vertexes = new System.Drawing.PointF[7];

			Random rnd = new Random();
			double angle = Math.PI * rnd.NextDouble();
			double angleStep = 2 * Math.PI / vertexes.Length;
			for (int i = 0; i < vertexes.Length; i++)
			{
				float r = holeRadius + rnd.Next((int)w / 10);
				vertexes[i].X = (float)(x + holeX + Math.Cos(angle) * r);
				vertexes[i].Y = (float)(y + holeY + Math.Sin(angle) * r);

				angle += angleStep;
			}

			base.Path.AddPolygon(vertexes);
		}
	}
}

Usage almost the same as with RectangleVObject:

Code:
_mlv.CurrentLayer.VObjects.Add(
	new HoledRectVObject(50, 300, 200, 200, 100, 100, 80, true));
_mlv.CurrentLayer.VObjects.Add(
	new HoledRectVObject(200, 100, 200, 200, 100, 100, 80, false));


Best regards,
Alex Kon
thanks 1 user thanked Alex Kon for this useful post.
ChingYen on 5/28/2011(UTC)
dotnet67  
#6 Posted : Sunday, October 30, 2011 1:26:42 AM(UTC)
dotnet67

Rank: Newbie

Groups: Member
Joined: 10/25/2011(UTC)
Posts: 5

Hi,

I'm found this article, but how to implement this function to two polyline objects ?

For example I'm create fist big polyline.
I'm create second polyline into first polyline.
After button click I need create hole into first big polyline.

If exist way, please write me short example.

Thank you,

Roman
Dmitry.Obukhov  
#7 Posted : Monday, October 31, 2011 12:10:04 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hi Roman,

Unfortunately, we do not have code snippets illustrating this. You can implement it like in the code for rectangle listed above, i.e. inherit your class from PolylineVObject, and implement a new method which will allow to make a hole in the first rectangle. In your case, first large polyline will be objects instead of rectangle, and second polilyne - instead of circle.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
dotnet67  
#8 Posted : Monday, October 31, 2011 10:49:15 AM(UTC)
dotnet67

Rank: Newbie

Groups: Member
Joined: 10/25/2011(UTC)
Posts: 5

Hi Dmitry,

for example i'm create simple custom polyline class:

Public Class CustomPolylineObject
Inherits Aurigma.GraphicsMill.WinControls.PolylineVObject
Public Sub New(ByVal p() As PointF)
MyBase.New(p, True, Drawing2D.FillMode.Alternate)
MyBase.Path.AddRectangle(New RectangleF(30, 30, 100, 100))
End Sub
End Class

And call in form:

Dim pf As PointF() = {New System.Drawing.PointF(20.0F, 20.0F), _
New System.Drawing.PointF(20.0F, 220), _
New System.Drawing.PointF(220, 220), _
New System.Drawing.PointF(220, 20.0F)}
Dim o As New CustomPolylineObject(pf)
MultiLayerViewer1.CurrentLayer.VObjects.Add(o)

Create polyline with hole (This OK), but after drag to new position hole in polyline is filled with polyline background.(missing)
If create custom rectangleVobject (see above) its all OK.
Thank you,

Roman
Dmitry.Obukhov  
#9 Posted : Monday, October 31, 2011 11:57:10 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hi Roman,

This behavior occurs because polyline is one-dimensional object. The area inside of polyline, filled by a color, is conditional. The polygon created with polyline object does not have an exact square bounded by borders. In other words, it is not possible to create a one-dimensional object with placing a two-dimensional one on it. You can create a rectangle hole on rectangle (or ellipse) objects only, it is working okay.

Edited by user Tuesday, November 1, 2011 12:00:23 AM(UTC)  | Reason: Not specified

Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
dotnet67  
#10 Posted : Tuesday, November 1, 2011 2:31:57 AM(UTC)
dotnet67

Rank: Newbie

Groups: Member
Joined: 10/25/2011(UTC)
Posts: 5

Hi Dmitry,

Thank you for information.

Roman
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.