AVAX-software.com Forums: Moving Circle - AVAX-software.com Forums

Jump to content

Page 1 of 1

Moving Circle

#1 User is offline   Rplp4 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 21-May 08

Posted 22 May 2008 - 07:31 PM

I am tring to get a circle to move by seleting it the entering in new values. The object properties change but the drawing is not refeshed. The circle does not visualy move.

Below is the code:

Private Sub ChangeCircle()
Dim XCenter, Ycenter, Xrad, Yrad As Single

Dim LineHandle As Long
Dim dx As Single
Dim dy As Single
Dim h() As Long, iType() As AvaxItemType
Dim sLayerNames() As String, iLayerStatus() As Integer, sLineStyleNames() As String
Dim vProp() As Variant, vData() As Variant
Dim xyz() As Single
ReDim h(1) As Long
   Dim sKey As String
   
    Call frmMain.cAvax1.GetLayers(sLayerNames(), iLayerStatus())
    Call frmMain.cAvax1.GetLineStyleNames(sLineStyleNames())
    ReDim h(1)
    h(1) = txtHandle.Text 'LastSelectedHandle
    If frmMain.cAvax1.GetProperties(h(), iType(), vProp(), vData()) = True Then
        sKey = frmMain.cAvax1.GetHandleKey(h(1))
        If iType(1) = Ellipse_i Then
            XCenter = txtCircle(0).Text
            Ycenter = txtCircle(1).Text
            Xrad = txtCircle(2).Text
            xyz() = vData(1)
            xyz(1) = XCenter - Xrad 'x1
            xyz(2) = Ycenter - Xrad 'y1
            xyz(4) = Val(XCenter) + Val(Xrad) 'x2
            xyz(5) = Val(Ycenter) + Val(Xrad) 'y2
            arrPanes(1).txtHandle = ""
            vData(1) = xyz()
            Call frmMain.cAvax1.SetProperties(h(), iType(), vProp(), vData())
        End If
    End If
    
End Sub


#2 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 333
  • Joined: 21-March 05
  • Gender:Male

Posted 23 May 2008 - 10:00 AM

VB6 example on how to move a circle:
Dim hCircle As Long

Private Sub Command1_Click()
    Call MoveTheCircle
End Sub

Private Sub MoveTheCircle()
    Dim XCenter As Single, Ycenter As Single
    Dim Xrad As Single, Yrad As Single
    Dim LineHandle As Long
    Dim dx As Single, dy As Single
    Dim h() As Long, iType() As AvaxItemType
    Dim sLayerNames() As String, iLayerStatus() As Integer
    Dim sLineStyleNames() As String
    Dim vProp() As Variant, vData() As Variant
    Dim xyz() As Single
    ReDim h(1) As Long
    Dim sKey As String
    ReDim h(1) As Long
    h(1) = hCircle
    If cAvax1.GetProperties(h(), iType(), vProp(), vData()) = True Then
        sKey = cAvax1.GetHandleKey(h(1))
        If iType(1) = Ellipse_i Then
            xyz() = vData(1)
            XCenter = xyz(7) + 1
            Ycenter = xyz(8) + 1
            Xrad = xyz(10)
            Yrad = xyz(11)
            '---
            xyz(1) = XCenter - Xrad
            xyz(2) = Ycenter - Yrad
            xyz(4) = XCenter + Xrad
            xyz(5) = Ycenter + Yrad
            xyz(7) = XCenter
            xyz(8) = Ycenter
            xyz(10) = Xrad
            xyz(11) = Yrad
            xyz(13) = XCenter - Xrad
            xyz(14) = Ycenter - Yrad
            xyz(16) = XCenter + Xrad
            xyz(17) = Ycenter + Yrad
            '---
            vData(1) = xyz()
            Call cAvax1.SetProperties(h(), iType(), vProp(), vData())
            hCircle = cAvax1.LastHandle
            Call cAvax1.SetHandleKey(hCircle, sKey)
        End If
    End If
End Sub

Private Sub Form_Load()
    Command1.Caption = "Move the circle"
    Call cAvax1.StartAvax
    hCircle = cAvax1.Add_Circle(1, 1, 0, 5)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call cAvax1.EndAvax
End Sub

Athanasios Gardos
Avax-Software.com

#3 User is offline   Rplp4 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 21-May 08

Posted 23 May 2008 - 01:48 PM

Thank You,
This is a great control once I learn all the functions it will be even better.

How about an example of moving a group of objects.

#4 User is offline   Rplp4 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 21-May 08

Posted 23 May 2008 - 06:17 PM

The above example works until I move the circle with the mouse. I select the circle with the mouse the click the move circle button the circle will move. If I select the circle and drag it with the mouse the button will not move the circle. What am I missing?

Option Explicit
Dim hCircle As Long
Dim ObjHandle As Long
Private Sub cAvax1_SelectChange(LastSelectedHandle As Long)
    ObjHandle = LastSelectedHandle
End Sub

Private Sub Command1_Click()
Call MoveTheCircle(ObjHandle)
End Sub
Private Sub MoveTheCircle(LastSelectedHandle)
Dim XCenter As Single, Ycenter As Single
Dim Xrad As Single, Yrad As Single
Dim LineHandle As Long
Dim dx As Single, dy As Single
Dim h() As Long, iType() As AvaxItemType
Dim sLayerNames() As String, iLayerStatus() As Integer
Dim sLineStyleNames() As String
Dim vProp() As Variant, vData() As Variant
Dim xyz() As Single
ReDim h(1) As Long
Dim sKey As String
ReDim h(1) As Long
h(1) = ObjHandle
If cAvax1.GetProperties(h(), iType(), vProp(), vData()) = True Then
    sKey = cAvax1.GetHandleKey(h(1))
    If iType(1) = Ellipse_i Then
        xyz() = vData(1)
        XCenter = xyz(7) + 1
        Ycenter = xyz(8) + 1
        Xrad = xyz(10)
        Yrad = xyz(11)
        '---
        xyz(1) = XCenter - Xrad
        xyz(2) = Ycenter - Yrad
        xyz(4) = XCenter + Xrad
        xyz(5) = Ycenter + Yrad
        xyz(7) = XCenter
        xyz(8) = Ycenter
        xyz(10) = Xrad
        xyz(11) = Yrad
        xyz(13) = XCenter - Xrad
        xyz(14) = Ycenter - Yrad
        xyz(16) = XCenter + Xrad
        xyz(17) = Ycenter + Yrad
        '---
        vData(1) = xyz()
        Call cAvax1.SetProperties(h(), iType(), vProp(), vData())
        hCircle = ObjHandle 'cAvax1.LastHandle
        Call cAvax1.SetHandleKey(hCircle, sKey)
    End If
End If

End Sub
Private Sub Form_Load()

    Command1.Caption = "Move the circle"
    Call cAvax1.StartAvax
    hCircle = cAvax1.Add_Circle(1, 1, 0, 5)
    hCircle = cAvax1.Add_Circle(2, 2, 0, 5)
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Call cAvax1.EndAvax
End Sub


#5 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 333
  • Joined: 21-March 05
  • Gender:Male

Posted 26 May 2008 - 11:57 AM

You can use another method:
Option Explicit

Dim ObjHandle As Long

Private Sub cAvax1_SelectChange(LastSelectedHandle As Long)
    ObjHandle = LastSelectedHandle
End Sub

Private Sub Command1_Click()
    Call MoveTheCircle(ObjHandle)
End Sub

Private Sub MoveTheCircle(hCircle As Long)
    Dim XCenter As Single, Ycenter As Single
    Dim Xrad As Single, Yrad As Single
    Dim LineHandle As Long
    Dim dx As Single, dy As Single
    Dim h() As Long, iType() As AvaxItemType
    Dim sLayerNames() As String, iLayerStatus() As Integer
    Dim sLineStyleNames() As String
    Dim vProp() As Variant, vData() As Variant
    Dim xyz() As Single
    ReDim h(1) As Long
    Dim sKey As String
    Dim cx As Single, cy As Single
    Dim aR As Single, bR As Single, dAngle As Single
    ReDim h(1) As Long
    h(1) = hCircle
    If cAvax1.GetProperties(h(), iType(), vProp(), vData()) = True Then
        sKey = cAvax1.GetHandleKey(h(1))
        If iType(1) = Ellipse_i Then
           If cAvax1.GetEllipseGeometry(h(1), cx, cy, aR, bR, dAngle) = True Then
              cx = cx + 1
              cy = cy + 1
              Call cAvax1.DeleteItems(h())
              hCircle = cAvax1.Add_Ellipse(cx, cy, 0, aR, bR)
              Call cAvax1.SetHandleKey(hCircle, sKey)
              h(1) = hCircle
              Call cAvax1.SelectItems(h())
           End If
        End If
    End If
End Sub

Private Sub Form_Load()
    Command1.Caption = "Move the circle"
    Call cAvax1.StartAvax
    Call cAvax1.Add_Circle(1, 1, 0, 5)
    Call cAvax1.Add_Circle(2, 2, 0, 5)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call cAvax1.EndAvax
End Sub

Athanasios Gardos
Avax-Software.com

#6 User is offline   Rplp4 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 21-May 08

Posted 26 May 2008 - 04:17 PM

Thank you

Page 1 of 1


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users