Results 1 to 12 of 12

Thread: Curved Crosshair problem - urgent help

  1. #1

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    Resolved 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?
    Last edited by BlueRose; Mar 5th, 2006 at 04:54 AM.
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  2. #2

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    Re: Curved Crosshair problem - urgent help

    No idea from anybody
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  4. #4

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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.


    is there sample that you stated?

    VB Code:
    1. 'assignment
    2.  
    3. Private Type fCoord
    4.     X As Integer
    5.     Y As Integer
    6. End Type
    7.  
    8. Private CrosshairScreen(0 To 1, 0 To 90) As fCoord
    9. Private oldCrosshair(0 To 1, 0 To 90) As fCoord
    10.  
    11.  
    12. 'LatitudeX and LongitudeX are coordinates of mouse pointer on globe as longitude and latitude
    13. 'Covert3D is a function that convert globe coordinate Lat/Long to plane (or screen)
    14.  
    15. 'Calculate Crosshair Latitude points
    16.     Longitude = -90
    17.     For k = 0 To 90
    18.         CrosshairScreen(0, k) = Convert3D(LatitudeX, Longitude )
    19.         Longitude = Longitude + 2
    20.     Next k
    21.  
    22. 'and now Longitude points
    23.     Latitude = 90
    24.     For k = 0 To 90
    25.         CrosshairScreen(1, k) = Convert3D(Latitude, LongitudeX)
    26.         Latitude = Latitude - 2
    27.     Next k
    28.  
    29. 'Draw Crosshair point on to globe
    30.      PicHolder.ForeColor = vbRed
    31.      For k = 0 To 1
    32.         MoveToEx PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y, vbNullString
    33.         For p = 1 To 90
    34.             LineTo PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y
    35.         Next p
    36.     Next k
    37.    
    38. 'erase old crosshair and assign new as old
    39.         For k = 0 To 1
    40.             PicHolder.PSet (oldCrosshair(k, 0).X, oldCrosshair(k, 0).Y), vbRed
    41.             oldCrosshair(k, 0) = CrosshairScreen(k, 0)
    42.             For p = 1 To 90
    43.                 PicHolder.Line -(oldCrosshair(k, 0).X, oldCrosshair(k, 0).Y), vbRed
    44.                 oldCrosshair(k, p) = CrosshairScreen(k, p)
    45.             Next p
    46.         Next k
    Last edited by BlueRose; Feb 27th, 2006 at 03:39 PM.
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  6. #6

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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:
    1. 'Calculate Crosshair Latitude points
    2.     Longitude = -90
    3.     For k = 0 To 90
    4.         CrosshairScreen(0, k) = Convert3D(LatitudeX, Longitude )
    5.         Longitude = Longitude + 2
    6.     Next k
    7.  
    8. 'and now Longitude points
    9.     Latitude = 90
    10.     For k = 0 To 90
    11.         CrosshairScreen(1, k) = Convert3D(Latitude, LongitudeX)
    12.         Latitude = Latitude - 2
    13.     Next k
    14.  
    15. 'before redrawing crosshair it is updated to original picture
    16.  
    17.    [COLOR=Red]PicHolder.PaintPicture hiddenimage.Picture, 0, 0[/COLOR]
    18.    
    19. 'Draw Crosshair point on to globe
    20.      PicHolder.ForeColor = vbRed
    21.      For k = 0 To 1
    22.         MoveToEx PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y, vbNullString
    23.         For p = 1 To 90
    24.             LineTo PicHolder.hdc, CrosshairScreen(k, 0).X, CrosshairScreen(k, 0).Y
    25.         Next p
    26.     Next k

    what is it your complicated method.
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.
    Attached Files Attached Files

  8. #8

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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?

    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?
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  9. #9
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.
    Attached Files Attached Files

  10. #10

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    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?
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

  11. #11
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.
    Attached Files Attached Files

  12. #12

    Thread Starter
    Addicted Member BlueRose's Avatar
    Join Date
    Jan 2002
    Location
    ISTANBUL
    Posts
    245

    Resolved 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.
    You can do while you think that you can do

    If you think my answer solve your question, please rate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width