Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports BV.Core
Imports BV.Math
Imports MidRange
'Imports BV.Controls
Imports GraphicsObjects
Imports MathUtilities
Imports System.Collections.Generic
''' <summary>
''' ToolBar que contiene cursores para grafica 2D
''' </summary>
''' <remarks></remarks>
Public Class CursorToolStripBar
Inherits ToolStripUtilitiesBase
Protected GMCls As GraphicMathCls
Protected MathDeleg As BVMathDelegate
Protected intCalc As ICalcSC
Protected intPen2 As Pen
Protected hTbl As Dictionary(Of CursorBase, ICalcSC)
Protected CurL, CurR As Cursor
Protected intCursor1Position As PointF
Protected intCursor2Position As PointF
'Protected previousPosition As PointF
Protected intCurProp As CursorsProperties
Protected PreviousMouse1Location, PreviousMouse2Location As Point
Protected intStep As Integer 'paso en pixel de pantalla, de forma de ser identico a pesar de la escala
Private x, y As Single
Private pend As Single
Private PA1, PA2, PA3, PA4, PB1, PB2, PB3, PB4 As PointF
Protected TlBarBtnAddCursors As ToolStripButton
Protected TlBarBtnSmallStep As ToolStripButton
Protected TlBarBtnShowDerivade As ToolStripButton
Protected TlBarBtnEnableCursor As ToolStripButton
'Protected BvTlBarBtnShowDerivade As ToolStripButton
Public Event PropertiesAvailable(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event CursorsChange(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event CursorAdded(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event CursorRemoved(ByVal sender As Object, ByVal e As System.EventArgs)
#Region "Constructor"
Public Sub New(ByVal Visor2D As IVisorBase, ByVal TlBar As ToolStripContainer)
MyBase.New(Visor2D, TlBar)
hTbl = New Dictionary(Of CursorBase, ICalcSC)
ImgLst = New ImageList
ImgLst.ImageSize = New Size(32, 32)
ImgLst.ColorDepth = ColorDepth.Depth16Bit
ImgLst.Images.Add(New Icon([GetType], "Cursors.ico"))
ImgLst.Images.Add(New Icon([GetType], "RectTang.ico"))
ImgLst.Images.Add(New Icon([GetType], "ChangeStep.ico"))
ImgLst.Images.Add(New Icon([GetType], "AddCursor.ico"))
ImgLst.Images.Add(New Icon([GetType], "RemoveCursor.ico"))
GMCls = New GraphicMathCls(Visor2D)
GMCls.Pen.Width = 2
MathDeleg = New BVMathDelegate
InitializeBand()
intPen = New Pen(Color.DarkGreen)
intPen.DashStyle = Drawing2D.DashStyle.Dash
intPen.Width = 2
intPen2 = New Pen(Color.Blue)
intPen2.DashStyle = Drawing2D.DashStyle.Dash
intPen2.Width = 2
'intCurProp=new CursorsProperties(
intStep = 5
AddHandler intRenderCtl.Resize, AddressOf OnRenderControl_Resize
AddHandler intRenderCtl.KeyDown, AddressOf OnRenderControl_KeyDown
'AddHandler intRenderCtl.KeyPress, AddressOf OnRenderControl_KeyPress
End Sub
Private Sub InitializeBand()
Band = New ToolStrip
Band.ImageList = ImgLst
Me.TlBarBtnEnableCursor = Me.Band.Items.Add("", Nothing, New EventHandler(AddressOf BtnChange))
Me.TlBarBtnEnableCursor.ImageIndex = 0
Me.TlBarBtnEnableCursor.CheckOnClick = True
Me.TlBarBtnEnableCursor.Name = "BtnEnableCursors"
Me.TlBarBtnEnableCursor.ToolTipText = "Enable/Disable Cursors"
Me.Band.Items.Add(New ToolStripSeparator)
TlBarBtnAddCursors = Me.Band.Items.Add("", Nothing, New EventHandler(AddressOf BtnChange))
TlBarBtnAddCursors.ImageIndex = 3
TlBarBtnAddCursors.Enabled = False
TlBarBtnAddCursors.Name = "BtnAddCursors"
TlBarBtnAddCursors.ToolTipText = "Add new Cursors"
TlBarBtnShowDerivade = Me.Band.Items.Add("", Nothing, New EventHandler(AddressOf BtnChange))
TlBarBtnShowDerivade.ImageIndex = 1
Me.TlBarBtnShowDerivade.Enabled = False
TlBarBtnShowDerivade.CheckOnClick = True
TlBarBtnShowDerivade.Name = "BtnShowDerivade"
TlBarBtnShowDerivade.ToolTipText = "Show Derivade Cursor"
TlBarBtnSmallStep = Me.Band.Items.Add("", Nothing, New EventHandler(AddressOf BtnChange))
TlBarBtnSmallStep.ImageIndex = 2
TlBarBtnSmallStep.Enabled = True
TlBarBtnSmallStep.CheckOnClick = True
TlBarBtnSmallStep.Name = "BtnSmallStep"
TlBarBtnSmallStep.ToolTipText = "Select Cursor Step"
Me.TlBar.TopToolStripPanel.Controls.Add(Band)
End Sub
#End Region
#Region "Properties"
<Browsable(False)> _
Public Overrides Property Visor() As IVisorBase
Get
Return intVisor2D
End Get
Set(ByVal Value As IVisorBase)
If Value Is intVisor2D Then
Exit Property
End If
If Value Is Nothing Then
Exit Property
End If
If Not intVisor2D Is Nothing Then
RemoveHandler intRenderCtl.MouseDown, AddressOf OnRenderControl_MouseDown
RemoveHandler intRenderCtl.MouseUp, AddressOf OnRenderControl_MouseUp
RemoveHandler intRenderCtl.MouseMove, AddressOf OnRenderControl_MouseMove
RemoveHandler intRenderCtl.Paint, AddressOf Redraw
RemoveHandler intRenderCtl.Resize, AddressOf OnRenderControl_Resize
End If
intVisor2D = Value
intRenderCtl = intVisor2D.RenderControl
GMCls.SelectedObject = intVisor2D
'previousMouseEventArgs = Nothing
AddHandler intRenderCtl.MouseDown, AddressOf OnRenderControl_MouseDown
AddHandler intRenderCtl.MouseUp, AddressOf OnRenderControl_MouseUp
AddHandler intRenderCtl.MouseMove, AddressOf OnRenderControl_MouseMove
AddHandler intRenderCtl.Paint, AddressOf Redraw
AddHandler intRenderCtl.Resize, AddressOf OnRenderControl_Resize
End Set
End Property
''' <summary>
''' Colleccion de Cursores
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property Cursors() As ICollection(Of CursorBase)
Get
Return Me.hTbl.Keys
End Get
End Property
''' <summary>
''' Paso de los cursores en pantalla
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>Debe ser mayor que 0</remarks>
Public Property [Step]() As Integer
Get
Return intStep
End Get
Set(ByVal value As Integer)
If intStep > 0 Then
intStep = value
Else
MessageManager.Send(Me, New MessageEventArgs("Step must be greater than Zero", MessageEventArgs.EMessageType.Warning))
End If
End Set
End Property
''' <summary>
''' Cursor Izquierdo seleccionado
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property SelectedLeftCursor() As CursorBase
Get
Return Me.CurL
End Get
Set(ByVal value As CursorBase)
If Not value Is Nothing Then
Me.CurL = value
End If
End Set
End Property
''' <summary>
''' Cursor derecho seleccionado
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property SelectedRightCursor() As CursorBase
Get
Return Me.CurR
End Get
Set(ByVal value As CursorBase)
If Not value Is Nothing Then
Me.CurR = value
End If
End Set
End Property
''' <summary>
''' Propiedades de los cursores
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property CursorProperties() As CursorsPropertiesBase
Get
If intCurProp Is Nothing Then
If Not Me.CurL Is Nothing AndAlso Not Me.CurR Is Nothing Then
intCurProp = New CursorsProperties(Me.CurL, Me.CurR)
End If
End If
Return intCurProp
End Get
End Property
<Browsable(False)> _
Public Property IsDerivadeCursorVisible() As Boolean
Get
Return TlBarBtnShowDerivade.checked
End Get
Set(ByVal Value As Boolean)
TlBarBtnShowDerivade.checked = Value
If Value Then
RaiseEvent PropertiesAvailable(Me, New EventArgs)
End If
End Set
End Property
<Browsable(False)> _
Public Property CursorsVisibles() As Boolean
Get
Return Me.TlBarBtnEnableCursor.Checked
End Get
Set(ByVal Value As Boolean)
TlBarBtnEnableCursor.Checked = Value
If Value Then
RaiseEvent PropertiesAvailable(Me, New EventArgs)
End If
End Set
End Property
<Browsable(False)> _
Public Property SelectedGoV() As GraphOfVisorSimple
Get
Return Me.intCalc
End Get
Set(ByVal Value As GraphOfVisorSimple)
Me.intCalc = Value
MathDeleg.SelectedObject = intCalc
If Value Is Nothing Then
Me.TlBarBtnEnableCursor.Enabled = False
Me.TlBarBtnEnableCursor.Checked = False
Me.TlBarBtnShowDerivade.Checked = False
Me.TlBarBtnShowDerivade.Enabled = False
Me.TlBarBtnAddCursors.Enabled = False
Else
Me.TlBarBtnAddCursors.Enabled = True
Me.TlBarBtnEnableCursor.Enabled = True
Me.TlBarBtnShowDerivade.Enabled = True
End If
End Set
End Property
#End Region
#Region "Add - Remove Methods"
Public Function Contains(ByVal CalcObj As ICalcSC) As Boolean
Return Me.hTbl.ContainsValue(CalcObj)
End Function
Public Sub Add(ByVal GoV As GraphOfVisorSimple)
If hTbl.ContainsValue(GoV) Then
If MsgBox("selected Graph already have a cursor" & ControlChars.NewLine _
& "Are you sure to add a new cursor for the selected Graph", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.No Then
Exit Sub
End If
End If
If CurL Is Nothing Then
CurL = New Cursor(GoV)
hTbl.Add(CurL, GoV)
CurL.ActionButton = Cursor.EMouseSelectButton.Right
Me.CurL.BackColor = GoV.Color
CurL.Name = "LeftCursor" & Me.hTbl.Count
RaiseEvent CursorAdded(Me, New EventArgs)
End If
If CurR Is Nothing Then
CurR = New Cursor(GoV)
hTbl.Add(CurR, GoV)
CurR.ActionButton = Cursor.EMouseSelectButton.Left
Me.CurR.BackColor = GoV.Color
CurR.Name = "RightCursor" & Me.hTbl.Count
RaiseEvent CursorAdded(Me, New EventArgs)
Else
CurL = New Cursor(GoV)
hTbl.Add(CurL, GoV)
CurL.ActionButton = Cursor.EMouseSelectButton.Left
Me.CurL.BackColor = GoV.Color
CurL.Name = "LeftCursor" & Me.hTbl.Count
RaiseEvent CursorAdded(Me, New EventArgs)
End If
SelectedGoV = GoV
End Sub
Public Sub Remove(ByVal GoV As GraphOfVisorSimple)
For Each c As CursorBase In Me.hTbl.Keys
If TypeOf c Is Cursor Then
If CType(c, Cursor).GraphOfVisor Is GoV Then
Me.hTbl.Remove(c)
End If
Else
'reservado para otro tipo de cursores
Stop
End If
Next
End Sub
#End Region
#Region "Events Managed"
Protected Sub OnRenderControl_Resize(ByVal sender As Object, ByVal e As EventArgs)
'If Not previousMouseEventArgs Is Nothing Then
' OnMouseSome(previousMouseEventArgs)
'End If
y = intVisor2D.YCoordinate(intCursor2Position.Y)
x = Me.intVisor2D.XCoordinate(intCursor2Position.X)
If x > 2 * Me.intRenderCtl.Width OrElse x < -Me.intRenderCtl.Width Then
Exit Sub
End If
If y > 2 * Me.intRenderCtl.Height OrElse x < -Me.intRenderCtl.Height Then
Exit Sub
End If
Me.SetCursor2PointsPosition(x, y, intCursor2Position.X, intCursor2Position.Y)
y = Me.intVisor2D.YCoordinate(intCursor1Position.Y)
x = Me.intVisor2D.XCoordinate(intCursor1Position.X)
If y > 2 * Me.intRenderCtl.Height OrElse x < -Me.intRenderCtl.Height Then
Exit Sub
End If
If x > 2 * Me.intRenderCtl.Width OrElse x < -Me.intRenderCtl.Width Then
Exit Sub
End If
Me.SetCursor1PointsPosition(x, y, intCursor2Position.X, intCursor2Position.Y)
End Sub
Protected Overrides Sub OnRenderControl_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
OnMouseSome(e.Location, e.Button)
End Sub
Protected Overrides Sub OnRenderControl_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles intVisor2D.OnRenderControlMouseUp
OnMouseSome(e.Location, e.Button)
End Sub
Protected Overrides Sub OnRenderControl_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles intVisor2D.OnRenderControlMouseMove
OnMouseSome(e.Location, e.Button)
End Sub
Protected Overridable Sub OnRenderControl_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
Dim p As Point
If e.KeyCode = Keys.Left OrElse e.KeyCode = Keys.A Then
If Not e.Shift Then
p.X = PreviousMouse1Location.X - Me.intStep
p.Y = PreviousMouse1Location.Y
Else
p.X = PreviousMouse2Location.X - Me.intStep
p.Y = PreviousMouse2Location.Y
End If
ElseIf e.KeyCode = Keys.Right OrElse e.KeyCode = Keys.D Then
If Not e.Shift Then
p.X = PreviousMouse1Location.X + Me.intStep
p.Y = PreviousMouse1Location.Y
Else
p.X = PreviousMouse2Location.X + Me.intStep
p.Y = PreviousMouse2Location.Y
End If
Else
Exit Sub
End If
If e.Shift Then
OnMouseSome(p, MouseButtons.Right)
Else
OnMouseSome(p, MouseButtons.Left)
End If
End Sub
#End Region
#Region "Public Methods"
Public Overrides Sub Redraw(ByVal sender As Object, ByVal p As PaintEventArgs)
If Me.TlBarBtnEnableCursor.Checked Then
If TlBarBtnShowDerivade.Checked Then
'If hTbl.Count > 0 Then
' For Each Cur As CursorBase In hTbl.Keys
' Cur.Redraw(Me, p)
' Next
'End If
p.Graphics.DrawLine(Me.intPen, PA1, PA2)
Else
For Each Cur As CursorBase In hTbl.Keys
Cur.Redraw(Me, p)
Next
'If hTbl.Count > 0 Then
'End If
End If
End If
End Sub
#End Region
#Region "private Methods"
Protected Sub BtnChange(ByVal sender As Object, ByVal e As EventArgs)
If intCalc Is Nothing Then
CType(sender, ToolStripButton).Checked = False
Me.OnSendMessage(Me, New MessageEventArgs("You must select some object before show cursors", MessageEventArgs.EMessageType.Info))
Exit Sub
End If
If sender Is TlBarBtnShowDerivade Then
If TlBarBtnShowDerivade.checked Then
'intCurProp = New CursorDerivadeProperties(Me.intCursor1Position, New PointF, Me.pend)
RaiseEvent PropertiesAvailable(Me, New EventArgs)
End If
ElseIf sender Is TlBarBtnAddCursors Then
Me.Add(Me.intCalc)
TlBarBtnEnableCursor.Checked = True
intCurProp = New CursorsProperties(Me.CurL, Me.CurR)
RaiseEvent PropertiesAvailable(Me, New EventArgs)
'If BvTlBarBtnEnableCursor.Checked Then
' 'Me.BvTlBarBtnShowDerivade.Checked = False
'End If
ElseIf sender Is TlBarBtnSmallStep Then
If Me.TlBarBtnSmallStep.Checked Then
Me.intStep = 0.5
Else
Me.intStep = 5
End If
ElseIf sender Is TlBarBtnEnableCursor Then
For Each cur As CursorBase In Me.hTbl.Keys
cur.Visible = Me.TlBarBtnEnableCursor.Checked
Next
If TlBarBtnEnableCursor.Checked Then
RaiseEvent PropertiesAvailable(Me, New EventArgs)
End If
End If
Me.intRenderCtl.Refresh()
End Sub
Protected Sub DoDerivade()
x = intVisor2D.Cursor1Position.X
If intVisor2D.YIsLogaritmic And intVisor2D.XIsLogaritmic Then
'OK
Dim m1, m2, y1, y2, mm As Double
Dim n2, n1, x2, x1, nn As Double
'valor de y calculado de la funcion real
nn = Me.intVisor2D.UCalcXS(x)
y = Calc(x) 'OK
mm = Me.intVisor2D.UCalcYS(y)
n2 = nn * (1 - 0.0001)
n1 = nn * (1 + 0.0001)
x2 = intVisor2D.UInvCalcXS(n2)
x1 = intVisor2D.UInvCalcXS(n1)
y2 = MathDeleg.Calc(x2)
y1 = MathDeleg.Calc(x1)
m1 = Me.intVisor2D.UCalcYS(y1)
m2 = Me.intVisor2D.UCalcYS(y2)
pend = (m1 - m2) / (n1 - n2) 'MathDeleg.DerivadeDelegate(x, 0.0001)
If pend <> 0 Then
PA1 = intVisor2D.Coordinate(x, y)
x2 = intVisor2D.UInvCalcXS(nn - mm / pend) 'intVisor2D.UInvCalcYS
'p2 = objICoord.Coordinate(x2=x1 - y1 / Pend, 0) 'en veces
PA2 = intVisor2D.Coordinate(x2, 1) 'en decibeles
Else
PA1 = intVisor2D.Coordinate(1, y)
PA2 = intVisor2D.Coordinate(x, y)
End If
'CType(intCurProp, CursorDerivadeProperties).Cursor2Position = New PointF(x2, 0)
ElseIf intVisor2D.YIsLogaritmic Then
'OK
Dim m1, m2, y1, y2, mm As Single
Dim x2, x1 As Single
'valor de y calculado de la funcion real
y = Calc(x) 'OK
mm = Me.intVisor2D.UCalcYS(y)
x2 = x * (1 - 0.0001)
x1 = x * (1 + 0.0001)
y2 = MathDeleg.Calc(x2)
y1 = MathDeleg.Calc(x1)
m1 = Me.intVisor2D.UCalcYS(y1)
m2 = Me.intVisor2D.UCalcYS(y2)
pend = (m1 - m2) / (x1 - x2) 'MathDeleg.DerivadeDelegate(x, 0.0001)
If pend <> 0 Then
PA1 = intVisor2D.Coordinate(x, y)
x2 = intVisor2D.UInvCalcXS(x - mm / pend) 'intVisor2D.UInvCalcYS
'p2 = objICoord.Coordinate(x2=x1 - y1 / Pend, 0) 'en veces
PA2 = intVisor2D.Coordinate(x2, 1) 'en decibeles
Else
PA1 = intVisor2D.Coordinate(1, y)
PA2 = intVisor2D.Coordinate(x, y)
End If
'CType(intCurProp, CursorDerivadeProperties).Cursor2Position = New PointF(x2, 0)
ElseIf intVisor2D.XIsLogaritmic Then
'OK
Dim y1, y2, n2, n1, x2, x1, nn As Single
'valor de y calculado de la funcion real
y = MathDeleg.Calc(x)
nn = Me.intVisor2D.UCalcXS(x)
n2 = nn * (1 - 0.0001)
n1 = nn * (1 + 0.0001)
x2 = intVisor2D.UInvCalcXS(n2)
x1 = intVisor2D.UInvCalcXS(n1)
y2 = MathDeleg.Calc(x2)
y1 = MathDeleg.Calc(x1)
pend = (y1 - y2) / (n1 - n2) 'MathDeleg.DerivadeDelegate(x, 0.0001)
If pend <> 0 Then
PA1 = intVisor2D.Coordinate(x, y)
x2 = intVisor2D.UInvCalcXS(nn - y / pend)
'p2 = objICoord.Coordinate(x2=x1 - y1 / Pend, 0) 'en veces
PA2 = intVisor2D.Coordinate(x2, 0) 'en veces
Else
PA1 = intVisor2D.Coordinate(0, y)
PA2 = intVisor2D.Coordinate(x, y)
End If
'CType(intCurProp, CursorDerivadeProperties).Cursor2Position = New PointF(x2, 0)
Else
y = Calc(x)
pend = DerivadeCalc(x, 0.0001)
GMCls.GetTangentCoordinates(x, y, pend, PA1, PA2)
'CType(intCurProp, CursorDerivadeProperties).Cursor2Position = New PointF(x, y)
End If
Check(PA1, PA2)
Check(PA2, PA1)
'CType(intCurProp, CursorDerivadeProperties).Cursor1Position = New PointF(x, y)
'CType(intCurProp, CursorDerivadeProperties).Pendient = pend
Me.intVisor2D.Refresh()
RaiseEvent CursorsChange(Me, New EventArgs)
'GMCls.DrawTangent(
End Sub
Protected Sub OnMouseSome(ByVal Loc As Point, ByVal Button As MouseButtons)
If intCalc Is Nothing Then
Exit Sub
End If
If Not Me.intVisor2D.DataRectangle.Contains(Loc) Then
Exit Sub
End If
If TlBarBtnShowDerivade.Checked Then
If Button = MouseButtons.Left Or Button = MouseButtons.Right Then
Me.DoDerivade()
End If
ElseIf Me.TlBarBtnEnableCursor.Checked Then
If Button = MouseButtons.Left Then
intVisor2D.Cursor1Location = Loc
'calcula el valor de y para el x (valor x del grafico) dado y=F(x)
intCursor1Position.Y = Calc(intVisor2D.Cursor1Position.X)
'calcula Location.Y
y = Me.intVisor2D.YCoordinate(intCursor1Position.Y)
intCursor1Position.X = Me.intVisor2D.Cursor1Position.X
SetCursor1PointsPosition(Loc.X, y, Me.intCursor1Position.X, Me.intCursor1Position.Y)
PreviousMouse1Location = Loc
ElseIf Button = MouseButtons.Right Then
intVisor2D.Cursor2Location = Loc
intCursor2Position.Y = Calc(intVisor2D.Cursor2Position.X)
intCursor2Position.X = Me.intVisor2D.Cursor2Position.X 'intVisor2D.Cursor1Position.X
y = Me.intVisor2D.YCoordinate(intCursor2Position.Y)
SetCursor2PointsPosition(Loc.X, y, Me.intCursor2Position.X, Me.intCursor2Position.Y)
PreviousMouse2Location = Loc
Else
Exit Sub
End If
Me.intVisor2D.Refresh()
RaiseEvent CursorsChange(Me, New EventArgs)
End If
End Sub
Protected Sub SetCursor1PointsPosition(ByVal x As Single, ByVal y As Single, ByVal xValue As Single, ByVal yValue As Single)
If Not Me.CurL Is Nothing Then
Me.CurL.Location = New Point(x, y)
Me.CurL.Position = New PointF(xValue, yValue)
End If
End Sub
Protected Sub SetCursor2PointsPosition(ByVal x As Single, ByVal y As Single, ByVal xValue As Single, ByVal yValue As Single)
If Not Me.CurR Is Nothing Then
Me.CurR.Location = New Point(x, y)
Me.CurR.Position = New PointF(xValue, yValue)
End If
End Sub
Private Function Pendient(ByVal P1 As PointF, ByVal P2 As PointF) As Single
Return (P1.Y - P2.Y) / (P1.X - P2.X)
End Function
Protected Function Check(ByRef P As PointF, ByVal SecondP As PointF) As Boolean
If P.X > 2 * Me.intVisor2D.DataRectangle.Right Then
Dim Ptmp As PointF
Ptmp = P
P.X = Me.intVisor2D.DataRectangle.Right
P.Y = Ptmp.Y - Pendient(Ptmp, SecondP) * (Ptmp.X - P.X)
Return True
End If
If P.X < -Me.intVisor2D.DataRectangle.Right Then
Dim Ptmp As PointF
Ptmp = P
P.X = Me.intVisor2D.DataRectangle.Left
P.Y = Ptmp.Y - Pendient(Ptmp, SecondP) * (Ptmp.X - P.X)
Return True
End If
If P.Y > 2 * Me.intVisor2D.DataRectangle.Bottom Then
Dim Ptmp As PointF
Ptmp = P
P.Y = Me.intVisor2D.DataRectangle.Bottom
If Ptmp.Y - SecondP.Y = 0 Then
P.X = SecondP.X
Else
P.X = Ptmp.X - (Ptmp.Y - P.Y) / Pendient(Ptmp, SecondP)
End If
Return True
End If
If P.Y < -Me.intVisor2D.DataRectangle.Bottom Then
Dim Ptmp As PointF
Ptmp = P
P.Y = Me.intVisor2D.DataRectangle.Top
If Ptmp.Y - SecondP.Y = 0 Then
P.X = SecondP.X
Else
P.X = Ptmp.X - (Ptmp.Y - P.Y) / Pendient(Ptmp, SecondP)
End If
Return True
End If
Return False
End Function
''' <summary>
''' devuelve y=f(x). contempla la posibilidad de que se este mostrando la parte
''' imaginaria en el visor
''' </summary>
''' <param name="x"></param>
''' <returns></returns>
''' <remarks></remarks>
Protected Function Calc(ByVal x As Single) As Single
If TypeOf Me.intCalc Is IComplex Then
Dim h As EGraphShowOne
Dim c As ComplexUndefinied
If TypeOf Me.intCalc Is IVariableIsReal Then
If CType(Me.intCalc, IVariableIsReal).VariableIsReal <> VariableMain.Imaginary Then
c = MathDeleg.Calc(New ComplexUndefinied(x, 0))
Else
c = MathDeleg.Calc(New ComplexUndefinied(0, x))
End If
Else
c = MathDeleg.Calc(New ComplexUndefinied(x, 0))
End If
h = CType(Me.intCalc, IComplex).Show
If h = EGraphShowOne.Real Then
Return c.Real
ElseIf h = EGraphShowOne.Module Then
Return c.Module
ElseIf h = EGraphShowOne.Imaginary Then
Return c.Imaginary
Else
Return c.Angle
End If
End If
End Function
''' <summary>
''' devuelve y=f(x). contempla la posibilidad de que se este mostrando
''' la parte imaginaria en el visor
''' </summary>
''' <param name="x"></param>
''' <param name="dx"></param>
''' <returns></returns>
''' <remarks></remarks>
Protected Function DerivadeCalc(ByVal x As Single, ByVal dx As Single) As Single
Return MathDeleg.DerivadeDelegate(x, dx)
End Function
#End Region
End Class