Layer cannot be drawn completely in VB form
Hi!
I have a trouble in displaying all complete points and text name in a VB form!
I have downloaded the SKD sample. I loaded a file using the C++ version and VB.net version, I found that the layer can be shown completely in C++ version, but not in VB.net version. The top and lowest points can only be shown in half, and the text name cannot be shown in VB form (please refer to my attachment:displayProblem.doc).
How to show a layer in VB form including all complete points and text name?
Thanks!
dilys
I have a trouble in displaying all complete points and text name in a VB form!
I have downloaded the SKD sample. I loaded a file using the C++ version and VB.net version, I found that the layer can be shown completely in C++ version, but not in VB.net version. The top and lowest points can only be shown in half, and the text name cannot be shown in VB form (please refer to my attachment:displayProblem.doc).
How to show a layer in VB form including all complete points and text name?
Thanks!
dilys
Comments
-
dilys,
I'm guessing there are different parameters being passed into the GM_DrawLayerList function when you are calling it from VB vs. when calling it from C++. What are you passing in for the rectangle to draw in VB and what draw flags are you passing into the GM_DrawLayerList function from VB?
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
Hi Mike,
I haven't use the rectangle class before. I am still searching for how to use it in this project. Could you kindly give me any cue?
Anyway, here is the code in the VB vs sample that I am using:
Imports GMDLLTester_VB.GlobalMapperInterface
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub LoadFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadFileButton.Click
'Show the open file dialog
OpenFileDialog1.ShowDialog()
' Load the file
Dim theErr As Int32
Dim theLayerList As IntPtr
Dim theLayerCount As Int32
theLayerList = IntPtr.Zero
theLayerCount = 0
theErr = GM_LoadLayerList(OpenFileDialog1.FileName, theLayerList, theLayerCount, 0)
' Get information about the layers we loaded
If (0 = theErr) Then
Dim i As Int32
For i = 0 To theLayerCount - 1
' Get the layer handle for this layer
Dim theLayerHandle As Int32
theLayerHandle = Marshal.ReadInt32(theLayerList, i * 4)
' Get the pointer to the layer info structure
Dim theLayerInfoPtr As IntPtr
theLayerInfoPtr = GM_GetLayerInfo(theLayerHandle)
' Convert the pointer to our structure
Dim theLayerInfo As GM_LayerInfo_t
theLayerInfo = CType(Marshal.PtrToStructure(theLayerInfoPtr, GetType(GM_LayerInfo_t)), GM_LayerInfo_t)
'Add the layer handle to our handle array. We will have to grow
'it if it is full.
If (sLayerCount = (sLayerHandleList.GetUpperBound(0) + 1)) Then
ReDim Preserve sLayerHandleList(sLayerCount + 1)
End If
sLayerHandleList(sLayerCount) = theLayerHandle
sLayerCount = sLayerCount + 1
Next
'Redraw
MapViewPanel.Invalidate()
End If
End Sub
Private Sub MapViewPanel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MapViewPanel.Paint
'Draw the loaded maps to the given panel
Dim theErr As Int32
Dim theDC As IntPtr
theDC = e.Graphics().GetHdc()
theErr = GlobalMapperInterface.GM_DrawLayerList _
( _
theDC, _
sLayerHandleList(0), _
sLayerCount, _
GM_DrawFlags_t32.GM_DrawFlags_EraseBackground, _
IntPtr.Zero, _
0, _
0, _
MapViewPanel.Width, _
MapViewPanel.Height _
)
e.Graphics().ReleaseHdc(theDC)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize the layer count
sLayerCount = 0
'Set the map panel background color to white
GlobalMapperInterface.GM_SetBackgroundColor(RGB(255, 255, 255))
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
'Close all of the layers that we loaded
Dim i As Int32
For i = 0 To sLayerCount - 1
'Close the layer
GM_CloseLayer(sLayerHandleList(i))
Next
sLayerCount = 0
End Sub
End Class
I have tried to change the value of MapViewPanel.Width and MapViewPanel.Height, but no use!
Thanks for your help!
Dilys -
Dilys,
This seems to work fine in the VB.NET 2003 sample application with no modifications. It looks like you are using something at least slightly different. Are you perhaps painting directly to the dialog instead of on a control on the dialog? If you just run the VB.NET 2003 sample application with no modifications does it work correctly for you then?
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
Mike,
Unfortunately, I do not have VB.Net 2003. I am using VB.Net 2008, and the sample in 2003 version is forced to convert to 2008 version. Can the problem be fixed with the version 2008? Please help me!!:o
Thanks
Dilys -
I would not expect to see different behavior if you convert the sample from VB.Net 2003 to 2008. Are you running the example directly converted to 2008? Can you send me the sample file that you are working with that is displaying oddly?
For working with the GM_Rectangle_t type as discussed before to manually pass the boundaries to draw (you'll need this for zooming and panning anyway), you just need to setup the values in that type to the desired bounds to draw. That type is defined for VB in the GlobalMapperInterface.vb file. Note that the VB sample only has a small collection of the types and functions declared, see the C GlobalMapperInterface.h (and the other .h files) file for a complete list of types and functions. You can always easily create the same declaration in VB if needed.
To work with passing the rectangle to draw as a parameter, change the declaration of the GM_DrawLayerList function to pass a GM_Rectangle_t type ByRef for the aWorldBounds parameter. You can then set up the rectangle to render from the map and pass that in. To initialize it to everything, use the GM_GetLayerInfo function to get the bounds (mGlobalRect) of the loaded layers.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
Mike,
Thanks for your suggestion! I am going to work on it.
Please find my data file: contactTail.txt.
Please let me know the result.
Thanks
Dilys -
global_mapper wrote: »I would not expect to see different behavior if you convert the sample from VB.Net 2003 to 2008. Are you running the example directly converted to 2008? Can you send me the sample file that you are working with that is displaying oddly?
For working with the GM_Rectangle_t type as discussed before to manually pass the boundaries to draw (you'll need this for zooming and panning anyway), you just need to setup the values in that type to the desired bounds to draw. That type is defined for VB in the GlobalMapperInterface.vb file. Note that the VB sample only has a small collection of the types and functions declared, see the C GlobalMapperInterface.h (and the other .h files) file for a complete list of types and functions. You can always easily create the same declaration in VB if needed.
To work with passing the rectangle to draw as a parameter, change the declaration of the GM_DrawLayerList function to pass a GM_Rectangle_t type ByRef for the aWorldBounds parameter. You can then set up the rectangle to render from the map and pass that in. To initialize it to everything, use the GM_GetLayerInfo function to get the bounds (mGlobalRect) of the loaded layers.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com
Mike,
I followed your instruction of using the GM_Rectangle_t and added the code bellow, it works very well!:D
'Expand the view rectangle a bit to get some padding around the data
Dim theWidth As Double
Dim theHeight As Double
theWidth = theRect.mMaxX - theRect.mMinX
theHeight = theRect.mMaxY - theRect.mMaxY
If theWidth = 0.0 Then
theWidth = 1.0
End If
If theHeight = 0.0 Then
theHeight = 1.0
End If
theRect.mMinX = theRect.mMinX - theWidth * 0.7
theRect.mMaxX = theRect.mMaxX + theWidth * 0.7
theRect.mMinY = theRect.mMinY - theHeight * 0.7
theRect.mMaxY = theRect.mMaxY + theHeight * 0.7
Thank you very much!
Dilys
Categories
- 12.8K All Categories
- 5.7K Features Discussion
- 345 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 637 GM Script Language
- 54 User Scripts
- 114 GPS Features
- 417 Projection Questions
- 826 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 178 Announcement and News
- 913 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 569 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 238 How I use Global Mapper
- 107 Global Mapper Forum Website