Curved Crosshair problem - urgent help
Hi All;
As you see attached picture, i have a boring case drawing crosshair on a globe, i am drawing crosshair with DrawMode=10 (Nor Xor Pen) therefore yor have draw line two times one for disappering one for redrawing you know. Hence when there is an another line under crosshair this time drawn line is boring little. Also i want crosshair to draw in solid color not chance with underlying color.
Is there an another drawing crosshair technique?
Re: Curved Crosshair problem - urgent help
Re: Curved Crosshair problem - urgent help
A couple of ideas I have.
1. create a memory DC for a rectangle the height and width of your crosshairs.
before drawing the crosshairs draw to the memory DC what is on the map in the region of the crosshairs.
draw the crosshairs
to remove crosshairs, bitblt the memory DC back to the map
2. create a sprite using a usercontrol with a transparent background.
move the sprite on top of the map whereever the crosshairs are supposed to be
without seeing the rest od your code I cannot be more specific.
Re: Curved Crosshair problem - urgent help
Dear moeur;
thanks for your valuable attention
i wish i could sent whole code, but it is very complex and not writting in English
therefore i can show you a small part, code below is the calculation of corsshair points and drawing on screen, PicHolder is picturebox that grid is drawn on it
I hope you can understand the drawing idea of crosshair. Crosshair points are the longitude and latitude points of the globe.
Quote:
is there sample that you stated?
VB Code:
'assignment
Private Type fCoord
X As Integer
Y As Integer
End Type
Private CrosshairScreen(0 To 1, 0 To 90) As fCoord
Private oldCrosshair(0 To 1, 0 To 90) As fCoord
'LatitudeX and LongitudeX are coordinates of mouse pointer on globe as longitude and latitude
'Covert3D is a function that convert globe coordinate Lat/Long to plane (or screen)
'Calculate Crosshair Latitude points
Longitude = -90
For k = 0 To 90
CrosshairScreen(0, k) = Convert3D(LatitudeX, Longitude )
Longitude = Longitude + 2
Next k
'and now Longitude points
Latitude = 90
For k = 0 To 90
CrosshairScreen(1, k) = Convert3D(Latitude, LongitudeX)
Latitude = Latitude - 2
Next k
'Draw Crosshair point on to globe
PicHolder.ForeColor = vbRed
For k = 0 To 1
MoveToEx PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y, vbNullString
For p = 1 To 90
LineTo PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y
Next p
Next k
'erase old crosshair and assign new as old
For k = 0 To 1
PicHolder.PSet (oldCrosshair(k, 0).X, oldCrosshair(k, 0).Y), vbRed
oldCrosshair(k, 0) = CrosshairScreen(k, 0)
For p = 1 To 90
PicHolder.Line -(oldCrosshair(k, 0).X, oldCrosshair(k, 0).Y), vbRed
oldCrosshair(k, p) = CrosshairScreen(k, p)
Next p
Next k
Re: Curved Crosshair problem - urgent help
In a perfect world your method would work, however the points you calculate for the crosshairs don't all line-up with the lines on the graph. So you get the funny looking line.
Can you do this:
create a second hidden picturebox that holds the map picture without any crosshairs
To erase the old line simply Call Picture1.PaintPicture(picHidden.Picture, 0, 0)
Draw the new line using DrawMode vbCopyPen - 13.
If your picture is very big this probably will create some flicker.
Try this first, if it does not work then we can move to more complicated methods.
Re: Curved Crosshair problem - urgent help
you are right moeur, with hidden picture crosshair is working as i want
but it is very very slowly working, good side it is not flicker.
VB Code:
'Calculate Crosshair Latitude points
Longitude = -90
For k = 0 To 90
CrosshairScreen(0, k) = Convert3D(LatitudeX, Longitude )
Longitude = Longitude + 2
Next k
'and now Longitude points
Latitude = 90
For k = 0 To 90
CrosshairScreen(1, k) = Convert3D(Latitude, LongitudeX)
Latitude = Latitude - 2
Next k
'before redrawing crosshair it is updated to original picture
[COLOR=Red]PicHolder.PaintPicture hiddenimage.Picture, 0, 0[/COLOR]
'Draw Crosshair point on to globe
PicHolder.ForeColor = vbRed
For k = 0 To 1
MoveToEx PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y, vbNullString
For p = 1 To 90
LineTo PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y
Next p
Next k
what is it your complicated method.
1 Attachment(s)
Re: Curved Crosshair problem - urgent help
OK, try this.
I've created a usercontrol that I place on top of the map.
The usercontrol is trasparent except where the crosshairs are drawn.
Try out the attached project, then you'll have to adapt it to your curved situation since I don't have your 3d function.
If the speed is OK but it flickers too much we can make some more improvements using a memory device context.
Re: Curved Crosshair problem - urgent help
Derar moeur;
I've done your Crosshairs to work, but i could not find it satisfactory, project that i rearranged is attached look and test it youself, is it good enough or not? :rolleyes:
I think the difficulty of this is to make crosshair visible everytime while the mouse is moving, therefore because the crosshair is slightly more big, time to rearrange and show the crosshair is getting much more long, but i think it must be a way to solve this.
What do you think about that?
1 Attachment(s)
Re: Curved Crosshair problem - urgent help
Here is an improvement.
Since picHolder is larger than Picture1 you want to make the control the size of Picture1.
You'll have to add some code to translate the scaling between picholder and picture 1 but that shouldn't be too hard.
I also fixed a problem with the right button dragging of picholder.
Re: Curved Crosshair problem - urgent help
thanks moeur
crosshair is slightly working good but there is still some flickering
and also when we move picture with RMB crosshair isn't updated and moving with picture and centered on picture1
is it some thing missing?
1 Attachment(s)
Re: Curved Crosshair problem - urgent help
OK,
I've made more improvements. This is the best we can do I think. I use two usercontrols to double buffer the drawing. Also I needed to put the cursor redraw in both crosshais and picture mouse move events.
Re: Curved Crosshair problem - urgent help
OK,
very very good, although there is small flickering, it is slightly satisfactory and acceptable.
I will adapt this to curved crosshair and will see result.
but for the present i can say "resolved"
thanks for your valuable support.