Page 1 of 2

How to transform Polyline and Ellipse?

Posted: 08 Jun 2010, 16:38
by jasonz_2003
Hi,

I am writing codes for moving a SPline, Polyline and Ellipse.

I have successful with Spline by recalculate the Fits anf Controls with Matrix. But Do not know what points should be calculated with the other two. I have tried the following code on both PolyPoints and the DottedPoints,
for(int i=Ent->PolyPoints->Count-1; i>=0; i--)
{
vPt = (TFPoint *)(Ent->PolyPoints->Items);
*vPt = ::PtXMat(*vPt, FCADParams.Matrix);
}
I can see that the value of the points changed but the graph is not moved. Please advise. Also what points should I use for Ellipse?

Re: How to transform Polyline and Ellipse?

Posted: 10 Jun 2010, 16:05
by support
Hello.
You're correct, the Fit points and Control points must be recalculated to move a TsgDXFSpline object. For moving a TsgDXFPolyline object please recalculate its Vertexes (TsgDXFVertex objects, placed in child entities collection of TsgDXFPolyline object). To move TsgDXFEllipse object just change its Point property.

Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 10 Jun 2010, 18:48
by jasonz_2003
HI Alexander,

Thanks for the tips. I have done the Ellipse transform. But for the LwPolyline or Polyline, I donot know how to get the vertecis as you mentioned. I noticed in CADImage.pas, the code for drawing polyline first check the child entities for type Line and Arc and draw respectively,
for I := 0 to APolyLine.PolyLineEntities.Count - 1 do
begin
vEnt := TsgDXFEntity(APolyLine.PolyLineEntities);
if vEnt is TsgDXFArc then
DrawArc(TsgDXFArc(APolyLine.PolyLineEntities))
else
if vEnt is TsgDXFLine then
DrawLine(TsgDXFLine(APolyLine.PolyLineEntities));
end;
I wonder if I should do the same in transformation? Also, I want to mark the selected entity on screen with the 8 dots on the Box. What is the best way. I am using the TsgDXFText with charactor "." and put all the TExt entities in a TsgDXFInsert. Now when doing transform, how can I point to thess Text entities in the Insert? Or, Can you guide me a better way. The problem of using The TsgDXFText is that the dots zoom when the graph is zoomed. I wish the dots donot change size no matter how big or small the enclosed graph changes. Thanks!

Jason

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 01:25
by jasonz_2003
Hi Alexander,

When using TsgDXFPolyline, I tried to use PolyFaceVertexIndexes to access the CHild Entities but always get a "Access Violation" error. The definition of PolyFaceVertexIndexes in DXFConv.hpp is,

Code: Select all

__property Classes::TList* PolyLineEntities = {read=FPolyLineEntities}
So I tried both,

Code: Select all

for( int i=Ent->TsgDXFPolyline::PolyFaceVertexIndexes->Count-1; i>=0; i--)
and

Code: Select all

for( int i=Ent->PolyFaceVertexIndexes->Count-1; i>=0; i--)
Both get the "Access Violation" error.

Please advise why?

Jason

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 09:13
by jasonz_2003
Hi, Alexander,

I tried to change the Point property to move a TsgDXFInsert on the screen. I found the Point property can not be changed. By checking DXFConv.hpp I found the Point is defined in TsgDXFCustomVertex public section as follows,

Code: Select all

__property Sgconsts::TFPoint Point = {read=GetPoint, write=SetPoint};


Donot know why I could not write.

After change the line to:

Code: Select all

__property Sgconsts::TFPoint Point = {read=FPoint, write=FPoint}; 
the problem is solved. I can move a TsgDXFInsert around by changing the Point property. I donot know if this change will cause other functions of the package, or it is really a BUg?

Please advise.

Jason

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 11:41
by support
Hello Jason.
Child entities of an entity accessible via TsgDXFEntity.Entities, where i - number of entity in the list. TsgDXFPolyline.Entities will return vertex with i number.
I want to mark the selected entity on screen with the 8 dots on the Box. I am using the TsgDXFText with charactor "." and put all the TExt entities in a TsgDXFInsert. Now when doing transform, how can I point to thess Text entities in the Insert?
Insert is the reference to the block that contains entities. Text entities accessible within the insert in the similar way: TsgDXFInsert.Block.Entities.
Or, Can you guide me a better way. The problem of using The TsgDXFText is that the dots zoom when the graph is zoomed. I wish the dots donot change size no matter how big or small the enclosed graph changes.
You can use TsgDXFPoint objects instead the "." texts. TsgDXFPoint doesn't zoomed.

Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 12:49
by support
The modification to access TFPoint field directly is incorrect. Please use the MakeFPoint method from sgConsts unit:

Code: Select all

var
     ins: TsgDXFInsert;
begin
     ...
     ins.Point := MakeFPoint(x, y, z);
Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 13:01
by jasonz_2003
Hi Alexander,

TsgDXFPolyline.Entities does not work in C++. The following code does not pass the compiler,

Code: Select all

for( int i=Ent->Entities->Count-1; i>=0; i--)
I have checked the DXFConv.hpp. In the definition of TsgDXFPolyline, Entities is not defined anywhere. There is only this line:

Code: Select all

protected:
.
.
	__property Classes::TList* List = {read=FEntities};
Please advise hw I should refer to the List? There is also this line under Public:

Code: Select all

	__property Classes::TList* PolyLineEntities = {read=FPolyLineEntities};
Can I use this PolyLineEntities? If so, how should I refer to it, ::PolyLineEntities good?

thanks.

Jason

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 13:07
by jasonz_2003
The modification to access TFPoint field directly is incorrect. Please use the MakeFPoint method from sgConsts unit:

Code: Select all
var
ins: TsgDXFInsert;
begin
...
ins.Point := MakeFPoint(x, y, z);
THis probblly does not solve my problem. My code is as follows,

Code: Select all

	vPt = (TFPoint *)(&(Ent->Point));
	*vPt = ::PtXMat(*vPt, FCADParams.Matrix);
Ent is TsgDXFInsert. Before modify the Point, *vPt changed but Ent->Point remain unchanged. After the modification both changed. Please advises a better way.

Jason

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 15:10
by support
Hello Jason.
TsgDXFPolyline->Entities doesn't gives access to entities list, but single TsgDXFEntity object from list.

Code: Select all

for (int i = 0; i < Ent->Count; i++)
{     
     Ent->Entities[i]->Visible = true;
}
Please see help system if any similar questions, it contains description of entities structure.

Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 15:37
by support
Please try the following code:

Code: Select all

     PFPoint vpt;
     *vpt = ::PtXMat(*vPt, FCADParams.Matrix);
     Ent->Point = *vpt;
Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 15:46
by support
Also TsfDXFPolyline.PolyLineEntities property contain TsgDXFArc, TsgDXFLine objects that form polyline if TsgDXFConverter.AllArcsAsCurves = false.

Alexander.

Re: How to transform Polyline and Ellipse?

Posted: 11 Jun 2010, 18:25
by jasonz_2003
Hi Alexander,
You can use TsgDXFPoint objects instead the "." texts. TsgDXFPoint doesn't zoomed.
I have taken your advice and changed to use TsgDXFPoint to draw the 8 points on the selected entity box. The problem is no mater what value I set for PointDisplayMode and PointDisplaySize, it always only show a one pixel dot. Just want to ask if PointDisplayMode and PointDisplaySize are actually supported in CADImport? My code is as follows,

Code: Select all

FImg->Converter->HeadVarStruct.PointDisplayMode = 64;
FImg->Converter->HeadVarStruct.PointDisplaySize = -15;
.
.
void TForm1::AddBoxDotToConv(TsgCADImage *Im, TFPoint vPoint)
{
	TsgDXFPoint *pText;
	pText = new TsgDXFPoint;
	pText->Point = vPoint;
	pText->Color = clRed;
	Im->Converter->Sections[csEntities]->AddEntity(pText);
	if (Im->Converter->OnCreate != NULL)
		Im->Converter->OnCreate(pText);
	Im->Converter->Loads(pText);

}
Jason

Re: How to transform Polyline and Ellipse?

Posted: 15 Jun 2010, 17:35
by Evgeny Chuzhakin
Hi Jason,

PointDisplayMode and PointDisplaySize should be used as properties of TsgDXFConverter:
FImg->Converter->PointDisplayMode
FImg->Converter->PointDisplayMode

without "->HeadVarStruct."

and please call
Im->GetExtents
after adding or changing the point.

Thanks.
Evgeny

Re: How to transform Polyline and Ellipse?

Posted: 16 Jun 2010, 13:23
by jasonz_2003
PointDisplayMode and PointDisplaySize should be used as properties of TsgDXFConverter:
FImg->Converter->PointDisplayMode
FImg->Converter->PointDisplayMode

without "->HeadVarStruct."

and please call
Im->GetExtents
after adding or changing the point.
Still not working. the line FImg->Converter->PointDisplaySize does not pass compile with message "PointDisplaySize is not a member of Convertor". Tried

Code: Select all

		FImg->Converter->PointDisplayMode = 64;
		FImg->Converter->HeadVarStruct.PointDisplaySize = -5;
and add Im->GetExtents(); after adding the dots. Still only show a Dot. Please advise.

Jason