Page 1 of 1
move tool available outside of TeeCommander1
Posted: Mon Apr 07, 2008 8:59 pm
by 6928489
Hi:
I'm successfully using the rotate and magnifying tools. Now I want to a "move" tool, similar to what the TeeCommander does, but don't want to use the commander per se.
Can I use this tool outside of the commander? Or is this function only available in the commander?
Thanks,
Matt
Posted: Tue Apr 08, 2008 8:34 am
by yeray
Hi Matt,
I'm afraid there's no tool to move the chart. Otherwise, you always can emulate this TeeCommander function by doing something similar than following:
Code: Select all
Dim MoveChart As Boolean
Dim StartX, StartY As Double
Private Sub Form_Load()
TChart1.AddSeries scPoint
TChart1.Series(0).FillSampleValues 25
MoveChart = False
TChart1.Zoom.Enable = False
End Sub
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If Button = mbLeft Then
StartX = X
StartY = Y
MoveChart = True
End If
End Sub
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If MoveChart = True Then
With TChart1
.Aspect.HorizOffset = X - StartX
.Aspect.VertOffset = Y - StartY
End With
End If
End Sub
Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If Button = mbLeft Then
With TChart1
.Aspect.HorizOffset = X - StartX
.Aspect.VertOffset = Y - StartY
End With
MoveChart = False
End If
End Sub
Posted: Tue Apr 08, 2008 10:47 am
by 6928489
Hi:
That's fine, as long as it works. Thanks!
What about the 3d depth tool? Do use the same event structure and follow a "mode" selector to change the 3d-ness? If so, just let me know what the correct method is.
Thanks again,
Matt
Posted: Tue Apr 08, 2008 11:37 am
by yeray
Hi Matt,
Here you have an example of how you could achieve similar results as teecommander, using simple buttons:
Code: Select all
Dim RotateChart, MoveChart, ZoomChart, DChart, Go As Boolean
Dim StartX, StartY As Double
Dim StartZoom As Integer
Private Sub Rotate_Click()
RotateChart = True
MoveChart = False
ZoomChart = False
DChart = False
End Sub
Private Sub Reset_Click()
With TChart1
.Aspect.Orthogonal = True
.Aspect.HorizOffset = 0
.Aspect.VertOffset = 0
.Aspect.Zoom = 100
.Aspect.Chart3DPercent = 15
End With
MoveChart = False
RotateChart = False
ZoomChart = False
DChart = False
Go = False
End Sub
Private Sub Move_Click()
MoveChart = True
RotateChart = False
ZoomChart = False
DChart = False
End Sub
Private Sub Zoom_Click()
ZoomChart = True
MoveChart = False
Rotate = False
DChart = False
End Sub
Private Sub ThreeDPercent_Click()
DChart = True
ZoomChart = False
MoveChart = False
Rotate = False
End Sub
Private Sub Editor_Click()
TChart1.ShowEditor
End Sub
Private Sub Form_Load()
With TChart1
.AddSeries scLine
.Series(0).FillSampleValues 20
.Zoom.Enable = False
.Scroll.Enable = pmNone
End With
End Sub
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If RotateChart = True Then
Go = True
StartX = X
StartY = Y
End If
If MoveChart = True Then
Go = True
StartX = X
StartY = Y
End If
If ZoomChart = True Then
Go = True
StartZoom = TChart1.Aspect.Zoom
StartY = Y
End If
If DChart = True Then
Go = True
StartX = X
StartY = Y
End If
End Sub
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If RotateChart = True And Go = True Then
With TChart1
.Aspect.Orthogonal = False
.Aspect.Elevation = X - StartX
.Aspect.Rotation = Y - StartY
End With
End If
If MoveChart = True And Go = True Then
With TChart1
.Aspect.HorizOffset = X - StartX
.Aspect.VertOffset = Y - StartY
End With
End If
If ZoomChart = True And Go = True Then
With TChart1
.Aspect.Zoom = StartZoom + StartY - Y
End With
End If
If DChart = True And Go = True Then
With TChart1
If (X - StartX) < 101 And (X - StartX) > 0 Then
.Aspect.Chart3DPercent = X - StartX
Else
If (X - StartX) > 101 Then
.Aspect.Chart3DPercent = 100
Else
.Aspect.Chart3DPercent = 1
End If
End If
End With
End If
End Sub
Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If RotateChart = True Then
With TChart1
.Aspect.Orthogonal = False
.Aspect.Elevation = X - StartX
.Aspect.Rotation = Y - StartY
End With
Go = False
End If
If MoveChart = True Then
With TChart1
.Aspect.HorizOffset = X - StartX
.Aspect.VertOffset = Y - StartY
End With
Go = False
End If
If ZoomChart = True Then
With TChart1
.Aspect.Zoom = StartZoom + StartY - Y
End With
Go = False
End If
If DChart = True Then
With TChart1
If (X - StartX) < 101 And (X - StartX) > 0 Then
.Aspect.Chart3DPercent = X - StartX
Else
If (X - StartX) > 101 Then
.Aspect.Chart3DPercent = 100
Else
.Aspect.Chart3DPercent = 1
End If
End If
End With
Go = False
End If
End Sub
Posted: Tue Apr 08, 2008 1:56 pm
by 6928489
Hi:
This code is working fairly nicely (with a few minor mods). Thanks again.
I need to turn off the default left-click mouse behavior that drags and grid around independently of the plotting data, since in some cases, it interferes with the functions in the code you provided. How is that done?
Thanks,
Matt
Posted: Tue Apr 08, 2008 2:58 pm
by narcis
Hi Matt,
You can use this:
Posted: Tue Apr 08, 2008 5:07 pm
by 6928489
Thanks!
Posted: Tue Apr 08, 2008 5:59 pm
by 6928489
Hi:
Your suggestion doesn't appear to work. Maybe I didn't explain what has happening. This issue occurs when I lasso a box somewhere in the graph. When I let the right button up, the chart appears to zoom in on a particular section. It is this behavior I want to suppress.
Thanks,
Matt
Posted: Wed Apr 09, 2008 9:18 am
by narcis
Hi Matt,
Sorry for the confusion. In that case you can try using this:
Posted: Wed Apr 09, 2008 11:13 am
by 6928489
Thanks! That did the trick.
-- Matt