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 

Embedding DPLOT in a C Win32 GUI Application

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



Joined: 05 Feb 2007
Posts: 4

PostPosted: Mon Feb 05, 2007 9:31 am    Post subject: Embedding DPLOT in a C Win32 GUI Application Reply with quote

Hello,

Disclaimer: I am now familiar with DDE so please assume that I am a newbie.

I am considering integrating DPLOT to our software. Is it possible to add DPLOT as a widget into a windows GUI application (Win32) ? I prefer not to open an additional and separate window but I'd prefer to embed the DPLOT window into my GUI application.

Thanks in advance,

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


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

PostPosted: Mon Feb 05, 2007 9:43 am    Post subject: Reply with quote

Quote:
Is it possible to add DPLOT as a widget into a windows GUI application (Win32) ?


Yes, definitely, and you don't need to know anything about DDE to do what you want. Download the DPlot Jr setup program and take a look at the C demo programs. In particular you'll be interested in CTEST2.EXE, which retrieves a bitmap from DPlot and displays it in a frame within the test application. DPlot/DPlot Jr will not be visible. The demos all use DPLOTLIB.DLL, which interacts with either the full version of DPlot or with DPlot Jr.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mderdem



Joined: 05 Feb 2007
Posts: 4

PostPosted: Mon Feb 05, 2007 9:45 am    Post subject: Reply with quote

Thanks for the quick response. Would it be possible to use zoom and other similar functionality or is it a static bitmap ?

Another question. How does DPLOT do the rendering, is it drawing with DirectX/OpenGL/GDI ?
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


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

PostPosted: Mon Feb 05, 2007 9:54 am    Post subject: Reply with quote

Quote:
Would it be possible to use zoom and other similar functionality or is it a static bitmap ?


It is only a bitmap, and there are no DPLOTLIB functions that act like you're thinking - rendering a graph to a window owned by your application. So the short answer is no. But you can get enough information from DPLOTLIB to do this sort of thing yourself if you're willing to do a little extra work. In the demo already mentioned, a DPLOTLIB call retrieves a bitmap along with scaling information that allows you to translate mouse position to data space. You could use that same information to scale two mouse positions to desired plot extents and redraw the graph with a ManualScale command, then retrieve an updated bitmap.

Quote:
Another question. How does DPLOT do the rendering, is it drawing with DirectX/OpenGL/GDI ?


All standard Windows API calls: LineTo, BitBlt, SetPixel, etc.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mderdem



Joined: 05 Feb 2007
Posts: 4

PostPosted: Mon Feb 05, 2007 9:57 am    Post subject: Reply with quote

Ok, I got it.

Do you think it is realistic to use DPLOT in a GUI app via a bitmap to display realtime data ? I know that this depends on how powerful the hardware is, but I wonder if it would be possible to update the bitmap at 20-30 Hz with data from the simulation.

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


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

PostPosted: Mon Feb 05, 2007 10:37 am    Post subject: Reply with quote

Off the top of my head I'd think 20-30 Hz should be doable, but I've not tried this. I'll try to put a demo together this evening and test this, will let you know when I have something to look at.
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mderdem



Joined: 05 Feb 2007
Posts: 4

PostPosted: Mon Feb 05, 2007 11:22 am    Post subject: Reply with quote

Great. I believe this could also open a new market segment. Realtime data plotting is heavily used in aerospace and simulation.

Another issue. Does DPLOT have any plot editing functionality which allows creation of 2d curves from scratch ?

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


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

PostPosted: Mon Feb 05, 2007 11:36 am    Post subject: Reply with quote

Quote:
Does DPLOT have any plot editing functionality which allows creation of 2d curves from scratch ?


Yes. See the Getting Started section in the Help file, or online see:
http://www.dplot.com/help/index.htm?gettingstartedwithxyplots.htm
_________________
David Hyde
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: 2118
Location: Vicksburg, Mississippi

PostPosted: Mon Feb 05, 2007 8:29 pm    Post subject: Reply with quote

Here's a demo that takes parts of ctest2 (draw a bitmap to the application's window) and ctest3 (real-time simulation): http://www.dplot.com/lib/rtdemo.zip. The zip file includes ctest6.exe and 3 source files. Extract ctest6.exe to the same folder where dplotlib.dll resides; source code can go wherever you want.

As you might expect, results are highly dependent on processor speed. Of the things you have control over, line weight and the size of the bitmap have the biggest effect. Figures below are number of frames dropped in 5 minutes on a 2.4Ghz system.

Update frequency 50 Hz
Line weight 0 (1 pixel): 326/15000 frames dropped
Line weight 0.03": 1725/15000

25 Hz
Line weight 0: 13/7500
Line weight 0.03": 1130/15000

20 Hz
Line weight 0: 0/6000
Line weight 0.03": 9/6000

On an old 300Mhz system running Windows 95... well... it's not so good. At 10Hz it was dropping plenty of frames with wide lines (though the curves still looked smooth).

Curiously I got much better performance on a marginally faster 2.8Ghz system. I didn't do all tests, but with a line weight of 0.03" I did not drop any frames at speeds up to 33Hz.

Another surprise was that changing the plot window width to a shorter time - 15 seconds rather than 60 - had little effect on performance. That says DPlot's line-drawing does OK, and the biggest bottleneck is in producing the bitmap. So you'd think that decreasing the size of the bitmap would make a difference, and it does. The above measurements were on a bitmap 464w x 529h. If I halve both those dimensions then, for example, at 25Hz with 0.03" lines I drop 26 frames in 5 minutes instead of 1130 frames.

If it is critical that you get all your data onto the plot then this obviously isn't the way to go unless you use 1 pixel lines on a fast system. And even then, if this is for a product that you plan to distribute to others, then you should be careful to preserve your data in some other way and not count on DPlot to capture all of it.

Let me know if you have any questions.
_________________
David Hyde
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: 2118
Location: Vicksburg, Mississippi

PostPosted: Mon Feb 05, 2007 11:15 pm    Post subject: Reply with quote

Whoops. Link was bad, but works now.
_________________
David Hyde
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: 2118
Location: Vicksburg, Mississippi

PostPosted: Tue Feb 06, 2007 12:40 am    Post subject: Reply with quote

A couple of notes:

1) It occurred to me that since I had never tried doing a real time problem in this manner (grabbing a bitmap rather than displaying the graph in DPlot) that I was probably doing some things in the code inefficiently, doing some unnecessary calculations for a graph that would never be drawn. And I was. After a few simple changes the slow cases that dropped 1000 or more frames in 5 minutes have been improved by about 1/3. This change will be included in the next release.

2) I'm not sure where I came up with this:

"Another surprise was that changing the plot window width to a shorter time - 15 seconds rather than 60 - had little effect on performance. "

but it's just plain wrong. I must have had my eyes crossed. If you try the demo you'll notice that the number of dropped frames value accelerates with more points on the current window. So it stands to reason that a smaller window will drop fewer frames, and it does. A lot fewer. With a 30 second window and 1-pixel lines I can get 50Hz and only drop 5 or so frames in 5 minutes (compared to 326 frames with a 60 second window). At 25Hz it doesn't miss a frame.
_________________
David Hyde
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: 2118
Location: Vicksburg, Mississippi

PostPosted: Thu Feb 08, 2007 10:39 am    Post subject: Reply with quote

One more:
I'm not sure why this has never occurred to me to try before, but I think the next release will be more to your liking for this sort of thing. I've added a SetOutputWindow command which tells DPlot to direct all graphics to a window you specify rather than its own document window. For real time applications this works much better than the demo mentioned above, mostly because at every time step you'll only be drawing one (or a few) new line segments rather than redrawing the entire plot and producing a bitmap of that plot at every step. In tests I've done I can plot 2 curves at 50Hz (time step=0.02 sec) and not miss a beat.

Currently I have C and VB demos working. I need to complete VB.NET, PowerBasic, and C# demos before turning this loose, most likely late this coming weekend.
_________________
David Hyde
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: 2118
Location: Vicksburg, Mississippi

PostPosted: Mon Feb 12, 2007 9:47 am    Post subject: Reply with quote

A follow-up:

The new DPLOTLIB distribution includes example real-time simulations in C, C#, VB6, and VB.NET in which DPlot/DPlot Jr draws directly to the calling application's window rather than retrieving a bitmap every time step. The performance difference is, as you'd expect, big. With the demos you should be able to plot ~50Hz (0.02 second time step) on a reasonably fast system without missing a frame.

These new features require the latest version (2.1.0.3) of DPlot or DPlot Jr. The demos (and DPLOTLIB.DLL) are included in the DPlot Jr distribution and in the download mentioned above.
_________________
David Hyde
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