Results 1 to 6 of 6

Thread: Arrows pointing to all the wrong places & Unloading Line control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Unhappy Arrows pointing to all the wrong places & Unloading Line control

    The purpose of this program is to display a graphic tech tree.

    The problem is that I can’t seem to get the arrows to point to the right spot.
    Would someone Please take a look to see what I'm doing wrong?

    PS: the 2 required bmp zips total about 4.9 MB and can be downloaded at: www.geocities.com/tontow_merlin/


    Everything having to do with loading and placing controls is in drawingclass.bas . If you hit run program and then go under options and check "Add Name To ToolTips" and "Add Name To Labels" it will provide some addition information for debugging.


    Public Sub LoadData(Index As Integer) - Loads and places all the picture boxes.

    Public Sub DrawArrows() - determines where to draw the lines and arrows
    -- Public Function GetReq(ByVal ObjID As String) As String() - returns an array containing the Picturebox index of all the required objects that must be researched in order to enable the current object. (I know that this function is working correctly because of the Debug output shown in labels and tool tips providing the options mentioned above are enabled)



    Also I get an error on the following code (line controls):
    VB Code:
    1. For I = Form1.Lin1().UBound To 1 Step -1
    2.     Unload Form1.Lin1(Index)
    3.     Unload Form1.Lin1a(Index)
    4.     Unload Form1.Lin1b(Index)
    5. Next I
    Last edited by Tontow; Dec 25th, 2006 at 12:54 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: Arrows pointing to all the wrong places & Unloading Line control

    Anyone? I don't know how to fix this; I'm at my wits end.

    ScaleMode is set to 3-Pixle.

    I pass the .left as x and .top as y. Yet .top and .left seem to be giveing the wrong value.

    VB Code:
    1. Public Sub DrawArrows()
    2. 'Start drawing arrows
    3. Dim ArrowXY() As String
    4. For I = LBound(DisplayTree()) To UBound(DisplayTree())
    5.     If DisplayTree(I).Pre <> "" Then
    6.         ReDim ArrowXY(UBound(GetReq(I))) As String
    7.         ArrowXY() = GetReq(I)
    8.         For II = LBound(ArrowXY()) To UBound(ArrowXY())
    9.             If ArrowXY(II) <> "" Then
    10.                 Debug.Print "Element: " & DisplayTree(I).nName & " " & I & " To Element: " & DisplayTree(ArrowXY(II)).nName & " ; " & Form1.Img1(I).Left & "," & Form1.Img1(I).Height & " :: " & Form1.Img1(ArrowXY(II)).Left & "," & Form1.Img1(ArrowXY(II)).Top
    11.                 Debug.Print Join(ArrowXY(), " :; ")
    12.                 'MsgBox ("asdf")
    13.                 Call ArrowTip(Form1.Img1(I).Left, Form1.Img1(I).Height, Form1.Img1(ArrowXY(II)).Left, Form1.Img1(ArrowXY(II)).Top, Form1.Lin1().UBound)
    14.             End If
    15.         Next II
    16.     End If
    17. Next I
    18. End Sub



    VB Code:
    1. Public Sub ArrowTip(x1, y1, x2, y2, Index)
    2. If (x1 <> x2) Or (y1 <> y2) Then 'cleared for 0 lenth string
    3.  
    4.         Load Form1.Lin1(Index + 1)
    5.         Form1.Lin1(Index + 1).Visible = True
    6.         Load Form1.Lin1a(Index + 1)
    7.         Form1.Lin1a(Index + 1).Visible = True
    8.         Load Form1.Lin1b(Index + 1)
    9.         Form1.Lin1b(Index + 1).Visible = True
    10.    
    11.     Debug.Print "ArrowTip: " & x1 & "," & y1 & " :: " & x2 & "," & y2 & " index " & Index
    12.    
    13.     p1 = 0: q2 = 1: p2 = Form1.Width: q1 = Form1.Height
    14.     arrow_length = 10   '0.01 * 1 * Form1.Width
    15.     beta = 30 * PI / 180
    16.    
    17.     Form1.Lin1(Index).x1 = x1
    18.     Form1.Lin1(Index).y1 = y1
    19.     Form1.Lin1(Index).x2 = x2
    20.     Form1.Lin1(Index).y2 = y2
    21.     Dim salfa As Single, calfa As Single, vector As Single
    22.     Dim cth1 As Single, sth1 As Single
    23.     Dim cth2 As Single, sth2 As Single
    24.     Dim v1 As Single, w1 As Single, v2 As Single, w2 As Single
    25.     Dim xab1 As Single, yab1 As Single, xab2 As Single, yab2 As Single
    26.     Dim vab1 As Single, wab1 As Single, vab2 As Single, wab2 As Single
    27.     'Arrow's main line in "absolute" coordinates
    28.     xab1 = Form1.Width * (x1 - p1) / (p2 - p1)
    29.     yab1 = Form1.Height * (y1 - q1) / (q2 - q1)
    30.     xab2 = Form1.Width * (x2 - p1) / (p2 - p1)
    31.     yab2 = Form1.Height * (y2 - q1) / (q2 - q1)
    32.     'Length of the arrow's main body
    33.     vector = Sqr((xab2 - xab1) * (xab2 - xab1) + (yab2 - yab1) * (yab2 - yab1))
    34.     'Cos(alpha) and Sin(alpha):
    35.     calfa = (xab2 - xab1) / vector
    36.     salfa = (yab2 - yab1) / vector
    37.     'Sin & Cos of the angles between the 2 arrow tips and the x axis
    38.     'th1 = alpha - beta
    39.     'th2 = alpha + beta
    40.     cth1 = calfa * Cos(beta) + salfa * Sin(beta)
    41.     sth1 = salfa * Cos(beta) - calfa * Sin(beta)
    42.     cth2 = calfa * Cos(beta) - salfa * Sin(beta)
    43.     sth2 = salfa * Cos(beta) + calfa * Sin(beta)
    44.     'Arrow tips positions in "absolute" coordinates
    45.     vab1 = xab2 - arrow_length * cth1
    46.     wab1 = yab2 - arrow_length * sth1
    47.     vab2 = xab2 - arrow_length * cth2
    48.     wab2 = yab2 - arrow_length * sth2
    49.     'Back to user coordinates
    50.     v1 = p1 + vab1 * (p2 - p1) / Form1.Width
    51.     w1 = q1 + wab1 * (q2 - q1) / Form1.Height
    52.     v2 = p1 + vab2 * (p2 - p1) / Form1.Width
    53.     w2 = q1 + wab2 * (q2 - q1) / Form1.Height
    54.     Form1.Lin1a(Index).x1 = x2
    55.     Form1.Lin1a(Index).y1 = y2
    56.     Form1.Lin1a(Index).x2 = v1
    57.     Form1.Lin1a(Index).y2 = w1
    58.    
    59.     Form1.Lin1b(Index).x1 = x2
    60.     Form1.Lin1b(Index).y1 = y2
    61.     Form1.Lin1b(Index).x2 = v2
    62.     Form1.Lin1b(Index).y2 = w2
    63. End If
    64. End Sub

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Arrows pointing to all the wrong places & Unloading Line control

    If you hit run program
    What program? The zip files you posted only contain bitmaps.

    Also I get an error on the following code (line controls):
    A runtime error or compile error. The For Loop uses a variable named I but the array elements are referenced using a variable named Index, probably should be I.

    Anyone? I don't know how to fix this; I'm at my wits end.
    Without posting a working sample program, I doubt if anyone would be able to help.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: Arrows pointing to all the wrong places & Unloading Line control

    ?? I thought I uploaded it. Anyway, here it is, thanks.
    Attached Files Attached Files

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: Arrows pointing to all the wrong places & Unloading Line control

    BTW, If anyone decides to get the bmp zips thay go in a folder call "bmps".
    Also, here is the program with the unload problem fixed.
    Attached Files Attached Files

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    172

    Re: Arrows pointing to all the wrong places & Unloading Line control

    Dose anyone have any ideas on how to fix it? if you put a break in the module drawingclass - Public Sub DrawArrows() and open the immediate window (ctrl-g),


    VB Code:
    1. Public Sub DrawArrows()
    2. 'Start drawing arrows
    3. Dim ArrowXY() As String
    4. For I = LBound(DisplayTree()) To UBound(DisplayTree())
    5.     If DisplayTree(I).Pre <> "" Then
    6.         ReDim ArrowXY(UBound(GetReq(I))) As String
    7.         ArrowXY() = GetReq(I)
    8.         For II = LBound(ArrowXY()) To UBound(ArrowXY())
    9.             If ArrowXY(II) <> "" Then
    10.                 Debug.Print "Element: " & DisplayTree(I).nName & " " & I & " To Element: " & DisplayTree(ArrowXY(II)).nName & " ; " & Form1.Img1(I).Left & "," & Form1.Img1(I).Height & " :: " & Form1.Img1(ArrowXY(II)).Left & "," & Form1.Img1(ArrowXY(II)).Top
    11.                 Debug.Print Join(ArrowXY(), " :; ")
    12.                 'MsgBox ("asdf")
    13.                 Call ArrowTip(Form1.Img1(I).Left, Form1.Img1(I).Height, Form1.Img1(ArrowXY(II)).Left, Form1.Img1(ArrowXY(II)).Top, Form1.Lin1().UBound)
    14.             End If
    15.         Next II [B]'Put debugging break here[/B]
    16.     End If
    17. Next I [B]'Put debugging break here[/B]
    18. End Sub


    run the program,
    and then go under options and check "Add Name To ToolTips" and "Add Name To Labels" it will provide some addition information for debugging in the picturebox tooltips and labels
    then click anything under the menu "Load Faction Base_tech".

    You will notice that .top and .left properties are not reporting the correct coronets of the pictureboxes if you compare the debug output of the immediate window. - This is the problem that I am having.

    As far as I can tell, it should work correctly, but its not ......

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