DWF

DWF

Reply
Member
abdul-pablo
Posts: 3
Registered: ‎04-26-2011
Message 1 of 5 (334 Views)

DWFx polyline and ellipse different coords

334 Views, 4 Replies
04-26-2011 06:27 AM

I've drawn in Autocad a rectangle (0,0,100,100). Then I added two circles (outline ellipses in terms of DWFx), both with center in (50,50). Radius of the first one = 25, radius of the second one = 50. Then I exported the drawing to dwfx with view set to rectangle (-50,-50, 150, 150). It looks ok in Design Review. However I've got problems when loading the drawing with dwf toolkit. Namely, coordinates of ellpises are 100% corrected and after applying appropriate transformation (scale and offset from transformation matrix) I receive back point (50,50) and corresponding radius. But the coordinates of polyline (corresponding to the rectangle) are a bit wierd (y is negative) and afer the same transformation I receive different points than in original drawing. I checked the distanes and they are ok -> the scale factor is ok but there is something wrong with offset. Thus, the rectnagle is placed in wrong location and its enter doesn't coincide with the ellpises' centers any more. I attach the dwfx file. Where should I look for some informationn about that offset?

Employee
SilviaCao
Posts: 136
Registered: ‎06-07-2009
Message 2 of 5 (320 Views)

Re: DWFx polyline and ellipse different coords

04-29-2011 01:03 AM in reply to: abdul-pablo

Thank you for your question.

 

Please send us a snapshot of you source code to research; I haven’t found any special transform setting of the rectangle.



Silvia Cao
SW Engineer
PSEB-GE- ACRD PSEB
Autodesk, Inc.
Member
abdul-pablo
Posts: 3
Registered: ‎04-26-2011
Message 3 of 5 (306 Views)

Re: DWFx polyline and ellipse different coords

05-04-2011 01:15 AM in reply to: abdul-pablo

 

WT_Matrix Vm = vp.viewport_units().application_to_dwf_transform();
 WT_Matrix Vm_inv = dwfImp::inverseTransformationMatrix(Vm);

 

 

then I store Vm_inv and calculate coordinates of the points (with respect to viewports origin) by

 

Vm_inv.transform(p_from_dwfx, p_real);

 

assuming that origin of the viewport in real world coordinates can be calculated as follows:

 

box = const_cast<WT_Contour_Set&>(*viewport.contour()).bounds();

 

_offsetInfo._x = box.minpt().m_x;

_offsetInfo._y = box.minpt().m_y;

 

tmp_origin(Vm_inv(3,0), Vm_inv(3,1), 0 );

 

tmp_origin.x = (-tmp_origin.x) - (Vm_inv(0,0) * _offsetInfo._x);

tmp_origin.y = (-tmp_origin.y) - (Vm_inv(1,1) * _offsetInfo._y);

The code works for many dwf files. Now I try to add dwfx support and I encounter those problems

 

Member
abdul-pablo
Posts: 3
Registered: ‎04-26-2011
Message 4 of 5 (303 Views)

Re: DWFx polyline and ellipse different coords

05-04-2011 07:49 AM in reply to: abdul-pablo

I investigated the dwfx file manually, after changing it into zip archive and I found that outline_ellipse is saved as an entry in a xml file while square (polyline) is saved in FixedPage.fpage file. I suppose it could mean that there are two different transforms to be applied (one for coordinates of ellipse and the other for polyline). Am I right?

Contributor
janderssen
Posts: 20
Registered: ‎11-25-2008
Message 5 of 5 (299 Views)

Re: DWFx polyline and ellipse different coords

05-04-2011 05:56 PM in reply to: abdul-pablo

Hello abdul-pablo,

 

I had exactly the same issues, and after researching it and looking at the example files, you basically goto ensure that the pahelayout defiination is correct, to help this is the code I use, and fixes it nicely :-)

 

// first get our graphics resource.

DWFGraphicResource *pGraphicResource = dynamic_cast< DWFGraphicResource *>(m_piXamlStrmRes->get());

 

// now we can get our transformation, as follows for the definePageLayout.

 

WT_Matrix2D oTransform;
 oTransform(0,0) = pGraphicResource->transform()[0];
 oTransform(1,1) = pGraphicResource->transform()[5];
 oTransform(2,0) = pGraphicResource->transform()[12];
 oTransform(2,1) = pGraphicResource->transform()[13];

 

 

// next get our plot section

DWFEPlotSection *pPlotSection = dynamic_cast<DWFEPlotSection*>( m_pSection );

 

// and finally setup the Page Layout.

pxFile->definePageLayout( oTransform, pPlotSection->paper()->width(), pPlotSection->paper()->height(), 1);

 

I hope this helps, if you look at the xaml example in the dwf toolkit, the above code should make sense.

 

Cheers

Jason

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.