Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Collections.Generic
Imports BV.Math
Imports BV.Core
Imports BV.TopLevel.Laplace
Imports IMidRange
Imports MidRange
''' <summary>
''' Visor que presnta una porcion del plano complejo y es capaz de mostrar
''' singularidades y lugares de ra�ces en �ste
''' </summary>
''' <remarks></remarks>
Public Class VisorComplexPlain
Inherits VisorXYAdvanced
Implements IVisorDataRanges
Protected Shadows intXFrmAxsPrp As FrameAxisCplxProperties
Protected Shadows intYFrmAxsPrp As FrameAxisCplxProperties
#Region "Constructores"
Public Sub New()
MyBase.New()
End Sub
'utilizado cuando se autocontrola!
Public Sub New(ByVal ControlRender As Control)
MyBase.New(ControlRender)
'wasResized = True
'DoResize()
'EngineState = EEngineState.EReady
End Sub
Protected Overrides Sub Initialize()
intResizeManaged = EResizeManaged.Control
MyBase.Initialize()
'intAutoScale = True
wasResized = False
Me.intBriefDesc = "Visor with Complex Capability"
Me.intDescription = "This Visor can show several Graphs with real " & vbCr _
& "value points or complex points"
Me.intName = "Advanced Complex Visor"
intXFrmAxsPrp = New FrameAxisCplxProperties(Me.intFrameCalcX, Me, "Real Axis Properties")
intYFrmAxsPrp = New FrameAxisCplxProperties(Me.intFrameCalcY, Me, "Imaginary Axis Properties")
intZoomPreviousRect = New RectangleF(Me.intFrameCalcX.Min, intFrameCalcY.Min, intFrameCalcX.GetDY, intFrameCalcY.GetDY)
intPanPercentage = 30 '%
End Sub
#End Region
#Region "Properties"
<Browsable(False)> _
Public Shadows ReadOnly Property XAxisProperties() As FrameAxisCplxProperties
Get
Return Me.intXFrmAxsPrp
End Get
End Property
<Browsable(False)> _
Public Shadows ReadOnly Property YAxisProperties() As FrameAxisCplxProperties
Get
Return Me.intYFrmAxsPrp
End Get
End Property
<Browsable(False)> _
Public Shadows Property CurrentGoV() As GraphOfVisorComplexPlain
Get
If Not intCurrentGoV Is Nothing Then
Return intCurrentGoV
Else
Return Nothing
End If
End Get
Set(ByVal Value As GraphOfVisorComplexPlain)
If Not Value Is Nothing Then
intCurrentGoV = Value
End If
End Set
End Property
#End Region
#Region "Create Graphs Methods"
'Public Overloads Sub Add(ByVal Brn As Branch)
' If Not Me.Contains() Then
' CreateGraph()
' Me.intCurrentGoV.Add(RL)
' Me.intCurrentGoV.PointType = GraphicUtilities.ETypeOfPoint.Cross
' Me.intCurrentGoV.LineType = TypeOfVisorLine.OnlyCalculatedPoints
' AddHandler intCurrentGoV.DataChanged, AddressOf OnDataChanged
' Me.Refresh()
' End If
'End Sub
Public Overloads Sub Add(ByVal RL As RootLocusBase)
If Not Me.Contains(RL) Then
CreateGraph()
CType(Me.intCurrentGoV, GraphOfVisorComplexPlain).Add(RL)
Me.intDisableRefresh = True
Add(RL.LaplaceDirectObject)
Add(RL.LaplaceFeedbackObject)
If TypeOf RL.LaplaceGlobalFeedBackedObject Is LaplaceFunction Then
Add(CType(RL.LaplaceGlobalFeedBackedObject, LaplaceFunction))
End If
Me.intDisableRefresh = False
Me.Refresh()
AddHandler intCurrentGoV.DataChanged, AddressOf OnDataChanged
End If
End Sub
Public Overloads Sub Add(ByVal Lap As LaplaceFunction)
If Lap Is Nothing Then
Exit Sub
End If
If Not Me.Contains(Lap) Then
CreateGraph()
'If Me.intCurrentGoV Is Nothing Then
' CreateGraph()
'End If
CType(Me.intCurrentGoV, GraphOfVisorComplexPlain).Add(Lap)
'CType(Me.intCurrentGoV, GraphOfVisorComplexPlain).A(Lap)
AddHandler intCurrentGoV.DataChanged, AddressOf OnDataChanged
Me.Refresh()
End If
End Sub
Public Overloads Function Contains(ByVal RL As RootLocusBase) As Boolean
If RL Is Nothing Then
Return False
End If
For Each Gov As GraphOfVisorComplexPlain In Me.intArrGoV.ToArray
If RL Is Gov.BindedObject Then
Return True
End If
Next
Return False
End Function
Public Overloads Function Contains(ByVal Lap As LaplaceFunction) As Boolean
If Lap Is Nothing Then
Return False
End If
For Each Gov As GraphOfVisorComplexPlain In Me.intArrGoV.ToArray
If Lap Is Gov.BindedObject Then
Return True
End If
Next
Return False
End Function
''' <summary>
''' crea un nuevo grafico. las escalas se crean internamente, por lo
''' tanto monitorizar�, los datos ingresados.
''' devuelve el Id del grafico creado
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Protected Overrides Function CreateGraph() As Integer
Dim p As Pen
p = New Pen(Color.AliceBlue)
intCurrentGoV = New GraphOfVisorComplexPlain(Me, p, SubGraphType.TReal)
p.Color = BVArrayColor.SisColor(BV2DColors.CFunc0 + intArrGoV.Count)
p.Width = 2
intCurrentGoV.LineType = TypeOfVisorLine.SolidWithCalculatedPoints
intCurrentGoV.PointType = GraphicUtilities.ETypeOfPoint.Circle
intArrGoV.Add(intCurrentGoV)
Return intCurrentGoV.Id
End Function
#End Region
#Region "GoV"
'obtiene los rangos de los GoV
'busca los maximos y minimos totales en los GoV, y devuelve los rangos X - Y
'utiliza el formato de Rectangle para devolver los valores
Private Function GetRangesFromGoVs(ByRef Xr As RangeF, ByRef Yr As RangeF) As Boolean
Dim i As Integer
Dim GoV As GraphOfVisorSimple
Dim stateX, stateY As ScaleBasic.LocalEngineState
'verifico que haya al menos un GoV inicializado
For i = 0 To Me.intArrGoV.Count - 1
GoV = Me.intArrGoV(i)
stateY = CType(GoV.ScaleY, ScaleBasic).State
If stateY = ScaleBasic.LocalEngineState.EReady OrElse stateY = ScaleBasic.LocalEngineState.ERangeReady Then
stateY = ScaleBasic.LocalEngineState.EReady
End If
stateX = CType(GoV.ScaleX, ScaleBasic).State
If stateX = ScaleBasic.LocalEngineState.EReady OrElse stateX = ScaleBasic.LocalEngineState.ERangeReady Then
stateX = ScaleBasic.LocalEngineState.EReady
End If
If stateY = ScaleBasic.LocalEngineState.EReady And stateX = ScaleBasic.LocalEngineState.EReady Then
Exit For
End If
Next
If stateY <> ScaleBasic.LocalEngineState.EReady And stateX <> ScaleBasic.LocalEngineState.EReady Then
'si no hay al menos un GoV inicializado me voy
Return False
End If
Dim ScY, ScX, ScYi As BVScale
Dim stateXAll, stateYAll As ScaleBasic.LocalEngineState
ScY = New BVScale
ScYi = New BVScale
ScX = New BVScale
For i = 0 To Me.intArrGoV.Count - 1
GoV = Me.intArrGoV(i)
stateYAll = CType(GoV.ScaleY, ScaleBasic).State
If stateYAll = ScaleBasic.LocalEngineState.EReady OrElse stateYAll = ScaleBasic.LocalEngineState.ERangeReady Then
ScY.StorageMax(GoV.ScaleY.Max)
ScY.StorageMax(GoV.ScaleY.Min)
End If
stateXAll = CType(GoV.ScaleX, ScaleBasic).State
If stateXAll = ScaleBasic.LocalEngineState.EReady OrElse stateXAll = ScaleBasic.LocalEngineState.ERangeReady Then
ScX.StorageMax(GoV.ScaleX.Max)
ScX.StorageMax(GoV.ScaleX.Min)
End If
Next
If stateY = ScaleBasic.LocalEngineState.EReady Then
Yr = ScY.Range
End If
If stateX = ScaleBasic.LocalEngineState.EReady Then
Xr = ScX.Range
End If
Return True
End Function
#End Region
#Region "Events Managed"
Protected Overrides Sub OnDataChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.intAutoRefresh Then
'uso zoomprevios para el caso de que la autoescala este en Off
'If intAutoScale Then
' 'sin x
'Else
' 'Me.Zoom(eex)
'End If
RaiseDataChanged(sender, e)
Me.Refresh()
Else
RaiseDataChanged(sender, e)
End If
End Sub
#End Region
End Class