VB.NET and DPLOTLIB

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot

Moderator: DPlotAdmin

Post Reply
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

VB.NET and DPLOTLIB

Post by DPlotAdmin »

VB.NET demos using DPLOTLIB.DLL to create plots with DPlot or DPlot Jr are now available here: :!: (Edit: Removed. These demo programs are now included with the DPLOTLIB and DPlot Jr distributions.)

These demos require an updated DPLOTLIB.DLL, which is included in the .zip file.

I had fits trying to make DPlot_Plot work with VB.NET - the DPLOT structure passed to that function was gibberish. This may eventually be worked out, but for now I've punted: VB.NET programs should call the new function DPlot_PlotNET rather than DPlot_Plot. DPlot_PlotNET, like DPlot_Plot8, takes arrays of Double rather than Single; if this is an unworkable limitation for any VB.NET users please let me know.

This is all very preliminary; you may find that some features which work in VB demos don't work in your VB.NET programs... if so just let me know.

There's at least one curiosity in the .NET demos that has nothing at all to do with DPLOTLIB, but I'd like to figure it out just the same if any .NET gurus have an idea: the Project2 and Project4 demos paint to a picturebox control, and that picturebox is not updated if it is covered/uncovered. I've no idea why as I'm a 2-day VB.NET veteran - any suggestions would be appreciated.

Documentation for new functions is nonexistant other than comments in the source. Docs will be updated in the next full release.

Comments, suggestions, and criticisms are of course welcome.
Last edited by DPlotAdmin on Thu Nov 17, 2005 10:19 am, edited 8 times in total.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Perhaps my wife is right... I do need Ritalin :shock:

I've stumbled into the correct, or at least functional, way of making the original DPLOTLIB functions work with VB.NET. The solution involves a bit of convoluted .NET statements in the DPLOT structure, which you don't need to be concerned about unless you want to go insane along with me. See global.vb in each of the project folders if you are crazy (or want to be).

The updated distribution is in the same location: :!: (Edit: Removed. These demo programs are now included with the DPLOTLIB and DPlot Jr distributions.)

I still have no idea why the picture control isn't updated properly, though. If any VB.NET gurus can figure this out I'll buy the beer.
[Edit]Figured this one out finally, and it is incorporated in the new DPLOTLIB and DPlot Jr 1.967 distributions.[/Edit]
Last edited by DPlotAdmin on Thu Nov 17, 2005 10:20 am, edited 3 times in total.
Visualize Your Data
support@dplot.com
JetDeveloper
Posts: 2
Joined: Wed Feb 16, 2005 1:49 pm

Post by JetDeveloper »

About the picture box update, I downloaded the latest version yesterday and the demos still don't work with redrawing after cover up.

However, I did make some changes to the code.

First of all, I use a .NET Bitmap object (System.Drawing.Bitmap)
Dim myBmp as Bitmap

Then instead of


If (hBitmap <> 0) Then
ret = DeleteObject(hBitmap)
hBitmap = 0
End If


I use


If (Not (myBmp Is Nothing)) Then
myBmp.Dispose()
myBmp = Nothing
End If


Then I changed the
hBitmap type from Integer to IntPtr
I also changed the return type of
DPlot_GetBitmapEx() from Integer to IntPtr

Finally, to draw the plot in the picture box, I use
Bitmap.FromHBitmap(hBitmap) and Picture1.Image=myBmp
This avoids a whole mess of WinAPI GDI calls.

It seems to redraw fine after I cover it up.

Code: Select all

DocNum = DPlot_Plot8(d, x(0), y(0), cmds)
        If (DocNum > 0) Then
            DPM.size = Len(DPM)
            hBitmap2 = DPlot_GetBitmapEx(DocNum, rect.Right - rect.Left, rect.Bottom - rect.Top, DPM)
            myBmp = Bitmap.FromHbitmap(hBitmap2)
            HasMetrics = 1
            Picture1.Image = myBmp
            ' Be sure to do a FileClose after DPlot_GetBitmapEx (if you're done with the document)
            ret = DPlot_Command(DocNum, "[FileClose()]")
        End If
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Outstanding, thanks for your input. I've plugged this in and it seems to work perfectly.

If your e-mail address on record here is correct you should have an e-mail soon. If not then please reply privately with your correct address.
Visualize Your Data
support@dplot.com
DPlot_User
Posts: 5
Joined: Tue May 17, 2005 1:01 pm

Post by DPlot_User »

I'm having a problem with the order of the data for a 3DS plot. Here's how I'm generating the data.


For intIndex = 0 To Points.GetUpperBound(0)
adblNodes(0, intIndex) = intIndex
adblNodes(1, intIndex) = 100 + intIndex
adblNodes(2, intIndex) = 200 + intIndex
Next

This should generate a series of X's starting at 0, Y's starting at 100, and Z's starting at 200, all incrementing by 1.

Instead the data is coming into DPlotJr as follows (Using Edit>Copy>DataValues)

000 001 002
003 004 005
006 007 008
009 100 101
102 103 104
105 106 107
108 109 200
201 202 203
204 205 206
207 208 209


Using the same method of data generation in VB6 produces this data order.

000 100 200
001 101 201
002 102 202
003 103 203
004 104 204
005 105 205
006 106 206
007 107 207
008 108 208
009 109 209

I can change my routines to order the values to work in this manner but I thought you might like to know since I don't think it's supposed to be doing this. Please correct me if I'm wrong.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

That's a difference between VB and VB.NET. VB.NET treats array dimensions the same way all C's do: last dimension varies the fastest. If you change your code to

Code: Select all

For intIndex = 0 To Points.GetUpperBound(0) 
adblNodes(intIndex,0) = intIndex 
adblNodes(intIndex,1) = 100 + intIndex 
adblNodes(intIndex,2) = 200 + intIndex 
Next 
it will work as expected (though not, of course, in VB6).
Visualize Your Data
support@dplot.com
DPlot_User
Posts: 5
Joined: Tue May 17, 2005 1:01 pm

Post by DPlot_User »

OK.

Thanks for the quick response and thanks again for developing and supporting such a great product.
Post Reply