Community
DWF
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DWFx polyline and ellipse different coords

4 REPLIES 4
Reply
Message 1 of 5
abdul-pablo
600 Views, 4 Replies

DWFx polyline and ellipse different coords

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?

4 REPLIES 4
Message 2 of 5
SilviaCao
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.
Message 3 of 5
abdul-pablo
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

 

Message 4 of 5
abdul-pablo
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?

Message 5 of 5
janderssen
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost

 

”Tips

 

”Services