DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to draw and keep circular plot when window is resized

 
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C#
View previous topic :: View next topic  
Author Message
redsun



Joined: 10 Feb 2009
Posts: 5

PostPosted: Wed Apr 29, 2009 11:43 am    Post subject: how to draw and keep circular plot when window is resized Reply with quote

Hi,

would you please help me to solve this problem: when I'm trying to use the dplotlib.dll in C++ to draw a polar plot, I can not control the plot size. i.e. the plot always changes its shape when the window is changed manually ( resize the window). after all, what I need is a circular plot but not an elliptical one!

By the way, I have tried the "[PolarPlotStyle(0x0004)]" to force a circular plot, but it is no use for me.

thanks,

redsun
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Wed Apr 29, 2009 3:14 pm    Post subject: Reply with quote

Quote:
By the way, I have tried the "[PolarPlotStyle(0x0004)]" to force a circular plot, but it is no use for me.


"no use" because it doesn't work? Or no use because for whatever reason you can't call DPlot_Command? I tried it just now to make sure I hadn't botched something up and it worked as expected.

In case you may be one of the unlucky ones to have downloaded a version in which I fouled up interpreting hex numbers, try [PolarPlotStyle(4)].

You can accomplish the (very nearly) same thing with [Size(1,w,h,0)], where w and h should be equal and are the size in inches. The only real difference between using PolarPlotStyle and Size is that the fonts may be sized differently when you size the plot, depending on whether w and h fit within the document window.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
redsun



Joined: 10 Feb 2009
Posts: 5

PostPosted: Thu Apr 30, 2009 11:03 am    Post subject: Reply with quote

Hi, David Hyde,

Thank you for your immediate reply.

I have tried the [PolarPlotStyle(4)] and [Size(1,w,h,0)], but both of them also do not work. I guess that these two macro commands have been properly executed( there is no error information indicated), however, the plot is elliptical and changes its shape with the window resizing.

My program is based on the example program Ctest4.c, which uses DPlot_GetEnhMetaFile and dPlot_Plot functions.

best regards,

redsun
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Thu Apr 30, 2009 12:12 pm    Post subject: Reply with quote

Ah! Now I get it.

I can explain what's going on but I don't have a good answer at the moment. Regardless of what dimensions you specify for the metafile, DPlot changes the dimensions to get rid of extra white space and that definitely isn't what you want in this case. If you request (for example) a metafile that's 7" wide and 3" tall you might get back a metafile that is roughly 3"x3" (in the case of polar plots with PolarPlotStyle[4]). Using the STM_SETIMAGE message to set the picture for the frame ends up stretching the metafile to fill the frame. I tried using styles SS_REALSIZEIMAGE and SS_CENTERIMAGE on that frame, but that had no effect. Those settings apparently only apply to icons.

I'll look into not performing the cropping that DPlot is currently doing when the metafile is requested by another application. I think the best short-term solution will be to change how the frame picture is drawn - instead of using STM_SETIMAGE, handle all of the painting manually. IOW erase the background, get the actual metafile dimensions, and call PlayEnhMetafile to draw it. The only problem I can see with doing this is that it is a one-time deal: if you cover up your app's window and uncover it, the metafile won't be redrawn unless you take steps to handle WM_PAINT messages.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat May 02, 2009 9:07 am    Post subject: Reply with quote

This is fixed in version 2.2.4.7. DPlot will no longer crop metafiles that are requested by another application.

There's another problem (not related to polar plots) with the ctest4 demo you started with, though, and that will require changes at your end. Both programs set the requested picture width to 5" and the height is made proportional. But DPlot forces both dimensions to be at least 3". If the picture frame is more than 5/3 wide as it is tall in ctest4 (which it might be if you resize the window), the requested height will be less than 3". But you'll get back a metafile that is 3" tall. STM_SETIMAGE maps the metafile extents to the extents of the picture frame, so you'll get a picture that is stretched in the horizontal direction (or squashed in the vertical - take your pick). This is especially noticeable with fonts.

The ctest4 and btest4 demo programs distributed with DPlot Jr have been updated to fix this one. The requested size is now the actual physical size of the frame.

Edit: And now that I've written this down, of course, I realize there's one other check that should be made in those demos that I neglected to make. Both dimensions should be at least 3", and if one or the other isn't then it should be set to 3" and the other dimension scaled accordingly.
_________________
Visualize Your Data
support@dplot.com


Last edited by DPlotAdmin on Sat May 02, 2009 5:45 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat May 02, 2009 9:49 am    Post subject: Reply with quote

One thing I neglected to mention which you've probably figured out:

When you resize the ctest4 window the picture frame is resized as well, which causes it to be repainted. But it is repainted with the original metafile, which will result in a distorted picture. Other than fonts being stretched out this isn't a serious problem for most plot types. But for polar plots you'll get an elliptical shape rather than a circle. There are a couple of ways to get around this:

a) When receiving a WM_SIZE message, regenerate the metafile so that the new picture has the correct aspect ratio.

b) Instead of using STM_SETIMAGE (which maps the metafile extents to the frame extents): Fill the picture frame with the background color, then draw the metafile yourself using PlayEnhMetafile, with the target rectangle being some subset of the frame rectangle that is proportional to the metafile dimensions.

I hope all of that is clear - if not let me know.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C# All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group