AVAX-software.com Forums: Adding spline or point by mouse move? - AVAX-software.com Forums

Jump to content

Page 1 of 1

Adding spline or point by mouse move?

#1 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 28 March 2012 - 11:48 AM

Hello,
I'm new, so I have idea to make little application.
I need to draw point or better spline automatically by mouse move on screen.
After that the last point will be in the center of drawing.
On that way I can draw example shape 5mx6m without breaking and moving drawing.
Is that possible?
Thanks

Here is my sample:

Private Sub cAvax1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

Dim x1 As Single
Dim y1 As Single
Dim z1 As Single
Dim vItemProperties As Variant
Dim iClr As Integer
Dim iWidth As Integer
Dim iPointStyle As Integer
Dim iLayer As Integer
Dim AvaxHandle As Long
z1 = 0
AvaxHandle = cAvax1.Add_Point(x, y, 0)

End Sub

#2 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 29 March 2012 - 07:11 AM

Also, coordinates given by events MOUSE MOVE and add_point are not in same directions.
How to programatically simulate PAN option? Not resize, just moving drawing.
Thanks

#3 User is offline   elias Icon

  • Newbie
  • Icon
  • Group: Support
  • Posts: 51
  • Joined: 24-October 08
  • Gender:Male

Posted 30 March 2012 - 11:10 AM

Hi,

You can also try
cAvax1.Command = FreehandPolyLine_c
. For Add_Point to behave correctly replace it with
Dim x1 As Single, y1 As Single
Call cAvax1.LongToSingle(CLng(X), CLng(Y), x1, y1)
AvaxHandle = cAvax1.Add_Point(x1, y1, 0)

For pan add
cAvax1.Command = Zoom_Pan_c

What do you mean by "draw example shape 5mx6m"?

#4 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 31 March 2012 - 08:07 AM

My idea is to use mouse as "scanner".


The original irregular shape in real dimension is about 5x6 m.
PC screen has limitations defined by resolution.
My idea is after drawing every point center of screen will be on that point.
I'm trying to move PC mouse around the shape and that drawing should be on CAD software in
real dimension so I can use that drawing for cutting on CNC machine.
Is it possible?
Thanks

#5 User is offline   Athanasios Gardos Icon

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

Posted 04 April 2012 - 10:09 AM

Try the following code:

Option Explicit

Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT_TYPE) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type RECT_TYPE
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Sub MouseGet(X As Long, Y As Long)

    Dim pt As POINTAPI
    Dim typ_RECT As RECT_TYPE
    GetWindowRect cAvax1.hwnd, typ_RECT
    GetCursorPos pt
    X = pt.X - typ_RECT.Left
    Y = pt.Y - typ_RECT.Top
    
End Sub

Private Sub MousePut(X As Long, Y As Long)

    Dim typ_RECT As RECT_TYPE
    GetWindowRect cAvax1.hwnd, typ_RECT
    SetCursorPos typ_RECT.Left + X, typ_RECT.Top + Y
    
End Sub

Private Sub cAvax1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim x1 As Single
    Dim y1 As Single
    Dim z1 As Single
    Dim x2 As Single
    Dim y2 As Single
    Dim avaxdx As Single, avaxdy As Single
    Dim zxMin As Single, zyMin As Single
    Dim zxMax As Single, zyMax As Single
    Dim xMin As Single, yMin As Single, zMin As Single
    Dim xMax As Single, yMax As Single, zMax As Single
    Dim AvaxHandle As Long
    Dim dxMove As Long, dyMove As Long
    Static fIn As Boolean
    
    If Button = MouseButtonConstants.vbRightButton Then Unload Me: Exit Sub
    
    If fIn = True Then Exit Sub
    fIn = True
    avaxdx = CLng(cAvax1.Width / Screen.TwipsPerPixelX)
    avaxdy = CLng(cAvax1.Height / Screen.TwipsPerPixelY)
    dxMove = avaxdx / 10
    dyMove = avaxdy / 10
    Call cAvax1.LongToSingle(CLng(X), CLng(Y), x1, y1)
    cAvax1.AutoRedraw = False
    AvaxHandle = cAvax1.Add_Point(x1, y1, z1)
    If X > avaxdx - dxMove Then
       Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call cAvax1.LongToSingle(CLng(X) - dxMove, CLng(Y), x2, y2)
       zxMin = zxMin + (x1 - x2)
       zxMax = zxMax + (x1 - x2)
       If zxMin < xMin Then xMin = zxMin
       If zxMax > xMax Then xMax = zxMax
       If zyMin < yMin Then yMin = zyMin
       If zyMax > yMax Then yMax = zyMax
       Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call MousePut(CLng(X) - dxMove, CLng(Y))
    ElseIf X < dxMove Then
       Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call cAvax1.LongToSingle(CLng(X) + dxMove, CLng(Y), x2, y2)
       zxMin = zxMin - (x2 - x1)
       zxMax = zxMax - (x2 - x1)
       If zxMin < xMin Then xMin = zxMin
       If zxMax > xMax Then xMax = zxMax
       If zyMin < yMin Then yMin = zyMin
       If zyMax > yMax Then yMax = zyMax
       Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call MousePut(CLng(X) + dxMove, CLng(Y))
    End If
    If Y > avaxdy - dyMove Then
       Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call cAvax1.LongToSingle(CLng(X), CLng(Y) - dyMove, x2, y2)
       zyMin = zyMin + (y1 - y2)
       zyMax = zyMax + (y1 - y2)
       If zxMin < xMin Then xMin = zxMin
       If zxMax > xMax Then xMax = zxMax
       If zyMin < yMin Then yMin = zyMin
       If zyMax > yMax Then yMax = zyMax
       Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call MousePut(CLng(X), CLng(Y) - dyMove)
    ElseIf Y < dyMove Then
       Call cAvax1.GetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.GetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call cAvax1.LongToSingle(CLng(X), CLng(Y) + dyMove, x2, y2)
       zyMin = zyMin - (y2 - y1)
       zyMax = zyMax - (y2 - y1)
       If zxMin < xMin Then xMin = zxMin
       If zxMax > xMax Then xMax = zxMax
       If zyMin < yMin Then yMin = zyMin
       If zyMax > yMax Then yMax = zyMax
       Call cAvax1.SetBoundsAvax(xMin, yMin, zMin, xMax, yMax, zMax)
       Call cAvax1.SetBoundsZoom(zxMin, zyMin, zxMax, zyMax)
       Call MousePut(CLng(X), CLng(Y) + dyMove)
    End If
    cAvax1.AutoRedraw = True
    fIn = False
End Sub

Private Sub Form_Load()
    Dim avaxdx As Single, avaxdy As Single
    Call cAvax1.SetAvaxProperty(BackBitmapDrawingOn_p, False)
    Call cAvax1.StartAvax
    avaxdx = CLng(cAvax1.Width / Screen.TwipsPerPixelX)
    avaxdy = CLng(cAvax1.Height / Screen.TwipsPerPixelY)
    Call MousePut(avaxdx / 2, avaxdy / 2)
End Sub

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

Athanasios Gardos
Avax-Software.com

#6 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 07 April 2012 - 10:42 AM

I got error: User type not defined (typ_RECT as RECT_TYPE)...
Where do you put code MousePut and MouseGet?
Do you have sample project in VB6 that woks?
Thanks

#7 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 07 April 2012 - 11:26 AM

I solve it. It' works.
Nice job.. :)
Need more improvement but it is ok.
Thanks

#8 User is offline   Fikri Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 28-March 12

Posted 08 April 2012 - 11:44 AM

I must integrate exporting to dxf instead default format, and make scale for real dimension from shape to PC.
Is it possible to automatically draw spline by given points at the end?

#9 User is offline   elias Icon

  • Newbie
  • Icon
  • Group: Support
  • Posts: 51
  • Joined: 24-October 08
  • Gender:Male

Posted 20 April 2012 - 11:08 AM

Check out this example

This post has been edited by elias: 20 April 2012 - 11:09 AM


Page 1 of 1


Fast Reply

  

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