'Imports ggUtilLib
Imports ggCoreLib
Imports BV.Math
Imports IMidRange
Imports GraphicsObjects
Imports MidRange
Imports BV.Controls
Imports SecundaryForms
Imports GraphicsUtilities
Imports BV.TopLevel
Imports BV.TopLevel.Parsing
Imports BV.TopLevel.Laplace
Imports System.Collections.Generic
Imports Microsoft.Samples.DirectX.UtilityToolkit
Imports System.XML.Serialization
Imports System.IO
Imports System.Xml
Public Class FormBodeViewer
Enum DemoLoaded
Linear
Bode
End Enum
Protected Shared LogUtil As ggUtilLib.LogUtility
Private intDemoLoaded As DemoLoaded = DemoLoaded.Linear
Private disableRootFinding As Boolean = True
Private disableRootLocus As Boolean = True
Private Shared UseDirectX As Boolean = True
Private WithEvents intFormFullScreen As New FrmFullScreen
Private VisorCtlMod1, VisorCtlPH1, VisorCtlMod2, VisorCtlPH2, VisorCtlCP As VisorCtl
Private intD3DManager As ID3DManagable
Friend WithEvents FullD3DControl1 As FullD3DControl2
Private frameWork As Framework
Private WithEvents intVisorM As VisorXYAdvanced
Private WithEvents intVisorP As VisorXYAdvanced
Private WithEvents intVisor2CP As VisorComplexPlain
Private ZoomToolBar As ZoomToolStrip
Private RLToolBar As RLStripToolBar
Private WithEvents ParamToolBar As ParametricsToolStripBar
Private WithEvents CursorToolBar As CursorToolStripBar
Private FRToolBar As FindRootToolStripBar
Private FFTToolBar As FFTToolStripBar
Private MainScanner As AdvancedSingleScanner
Private tnVisors, tnLaplaceFn, tnFunctions, tnCursors, tnScan As TreeNode
Private tnParams, tnParamsControlled, tnFFTObj, tnRecycleBin As TreeNode
Private tnSings, tnRL, tnParseableFn, tn3D, tnRootFinding, tnOthers As TreeNode
Private tnFFTSpectrum As TreeNode
Private htblListItmObj As Dictionary(Of ListViewItem, Object)
Private htblNodeObj As Dictionary(Of TreeNode, Object)
Private htblObjNode As Dictionary(Of Object, TreeNode)
Private htblfnGoV, htblfnGoVP As Dictionary(Of FunctionBase, GraphOfVisorSimple) 'lo uso para guardar el LaplaceSistemCalc, GoV
Private htblfnSysC As Dictionary(Of FunctionBase, BasicSystemCalc)
Dim Selected3Dfn As FunctionBase
Private SelectedSing As Singularity
Private LapFn As LaplaceFunction
Private Fn As FunctionBase
Private Pr As Parameter
Private selectedObj As Object
Private SystemCalc As AutoSystemCalc
Private FnProp As FunctionPropertiesDescriptor
Private ScProp2 As ScannerPropertiesDescriptorBase
Private SCProp As ScannerPropertiesDescriptor
Private dontRun As Boolean
Private PreviousOption As Integer
#Region "Constructor"
Public Sub New()
' Llamada necesaria para el Dise�ador de Windows Forms.
InitializeComponent()
' Agregue cualquier inicializaci�n despu�s de la llamada a InitializeComponent().
If LogUtil Is Nothing Then
LogUtil = New ggUtilLib.LogUtility(System.Windows.Forms.Application.StartupPath & "\BVLog.txt")
End If
#If DEBUG Then
LogUtil.Reset()
#End If
End Sub
Public Sub New(ByVal f As Framework)
' Store framework
frameWork = f
' Llamada necesaria para el Dise�ador de Windows Forms.
InitializeComponent()
' Agregue cualquier inicializaci�n despu�s de la llamada a InitializeComponent().
Me.FullD3DControl1 = New BV.Test.FullD3DControl2
'
'FullD3DControl1
'
Me.FullD3DControl1.BackColor = System.Drawing.Color.Coral
Me.FullD3DControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.FullD3DControl1.frameWork = Nothing
Me.FullD3DControl1.Location = New System.Drawing.Point(3, 3)
Me.FullD3DControl1.MinimumSize = New System.Drawing.Size(200, 200)
Me.FullD3DControl1.Name = "FullD3DControl1"
Me.FullD3DControl1.Size = New System.Drawing.Size(453, 371)
Me.FullD3DControl1.TabIndex = 0
Me.TabPage3DGraph.Controls.Add(Me.FullD3DControl1)
FullD3DControl1.frameWork = frameWork
FullD3DControl1.InitializeApplication()
Me.intD3DManager = Me.FullD3DControl1.d3dObj
End Sub
#End Region
#Region "Load and UnLoad"
Private Sub FormBodeViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Me.TabControlViewer.DoubleBuffered = True
htblNodeObj = New Dictionary(Of TreeNode, Object)
htblListItmObj = New Dictionary(Of ListViewItem, Object)
htblObjNode = New Dictionary(Of Object, TreeNode)
htblfnGoV = New Dictionary(Of FunctionBase, GraphOfVisorSimple)
htblfnGoVP = New Dictionary(Of FunctionBase, GraphOfVisorSimple)
htblfnSysC = New Dictionary(Of FunctionBase, BasicSystemCalc)
MainScanner = New AdvancedSingleScanner
MainScanner.NumberOfPoints = 128
Me.VisorCtlMod1 = New VisorCtl
Me.VisorCtlPH1 = New VisorCtl
Me.VisorCtlMod2 = New VisorCtl
Me.VisorCtlPH2 = New VisorCtl
Me.VisorCtlCP = New VisorCtl
Me.TabPageModule.Controls.Add(Me.VisorCtlMod1)
Me.TabPagePhase.Controls.Add(Me.VisorCtlPH1)
Me.TabPageCP.Controls.Add(Me.VisorCtlCP)
Me.SplitContainerViewerSplit.Panel1.Controls.Add(Me.VisorCtlMod2)
Me.SplitContainerViewerSplit.Panel2.Controls.Add(Me.VisorCtlPH2)
Me.VisorCtlMod1.Dock = DockStyle.Fill
Me.VisorCtlMod2.Dock = DockStyle.Fill
Me.VisorCtlPH1.Dock = DockStyle.Fill
Me.VisorCtlPH2.Dock = DockStyle.Fill
Me.VisorCtlCP.Dock = DockStyle.Fill
intVisorM = New VisorXYAdvanced(Me.VisorCtlMod1) 'TabPageModule)
intVisorP = New VisorXYAdvanced(Me.VisorCtlPH1) 'TabPagePhase)
intVisor2CP = New VisorComplexPlain(Me.VisorCtlCP) 'TabPageCP)
Me.intVisor2CP.RenderControl = Me.VisorCtlCP 'TabPageCP 'Me.VisorCtlCP
SplitGraph()
ToolStripComboBoxMainOptions.Items.Add("Linear Analisys")
ToolStripComboBoxMainOptions.Items.Add("Bode Analisys")
ToolStripButtonShowExpresionEditor.Enabled = False
Me.FillExpresionEditor()
If intDemoLoaded = DemoLoaded.Linear Then
Me.LinearSettings()
ToolStripComboBoxMainOptions.SelectedIndex = 0
Else
Me.BodeSettings()
ToolStripComboBoxMainOptions.SelectedIndex = 1
End If
ComplexPlainSettings()
Me.ZoomToolBar = New ZoomToolStrip(Me.intVisorM, Me.ToolStripContainer1)
Me.ZoomToolBar.Visible = False
Me.ZoomToolBar.Container.Location = New Point(0, 25)
Me.RLToolBar = New RLStripToolBar(Me.intVisor2CP, Me.ToolStripContainer1)
Me.RLToolBar.Container.Location = New Point(0, 25)
Me.RLToolBar.Visible = False
Me.ParamToolBar = New ParametricsToolStripBar(Me.ToolStripContainer1)
Me.ParamToolBar.Location = New Point(0, 25)
Me.ParamToolBar.Visible = False
Me.CursorToolBar = New CursorToolStripBar(Me.intVisorM, Me.ToolStripContainer1)
Me.CursorToolBar.Container.Location = New Point(0, 25)
Me.CursorToolBar.Visible = False
Me.FFTToolBar = New FFTToolStripBar(Me.intVisorP, Me.ToolStripContainer1)
Me.FFTToolBar.Container.Location = New Point(0, 25)
Me.FFTToolBar.Visible = False
Me.FFTToolBar.TimeVisor = Me.intVisorM
If Me.intDemoLoaded = DemoLoaded.Linear OrElse Me.disableRootFinding = False Then
FRToolBar = New FindRootToolStripBar(Me.intVisorM, Me.ToolStripContainer1)
FRToolBar.Container.Location = New Point(0, 25)
End If
InitilalizeTreeView()
DisableRemoveButtons()
InitilizeSubMenus()
Me.FullD3DControl1.BackColor = System.Drawing.Color.FromArgb(45, 50, 170)
AddHandler intVisorM.Selected, AddressOf onSelectItm
AddHandler intVisorP.Selected, AddressOf onSelectItm
AddHandler intVisor2CP.Selected, AddressOf onSelectItm
AddHandler FullD3DControl1.d3dObj.VisorChange, AddressOf On3DVisor_change
AddHandler FullD3DControl1.d3dObj.VisorLimitsChange, AddressOf On3DVisor_change
'AddHandler intVisor2CP.ScaleChange, AddressOf OnPlaneComplexScaleChange
AddHandler MessageManager.SendMessage, AddressOf OnMessageReicived
AddHandler Parser.FunctionsChanged, AddressOf OnParamChanged
AddHandler Parser.ParamsChanged, AddressOf OnParamChanged
If Not frameWork Is Nothing Then
Disable3DLimitChange = True
FullD3DControl1.frameWork = frameWork
FullD3DControl1.InitializeApplication()
Me.ToolStripComboBox3DLimits.Text = Me.intD3DManager.AnalisysArea.XRange.ToString
Disable3DLimitChange = False
End If
End Sub
Dim cbItmFn, cbItmMathFn As WordItemBase
Private Sub FillExpresionEditor()
' FormPropertyEditorUI.Editor.Combo2Title = ""
'agrego los funciones matematicas basicas reconocidas por el Parser
cbItmMathFn = New WordItemBase("Built IN Functions", "Built IN Functions")
cbItmMathFn.Icon = New Icon([GetType], "F.ico")
For Each BUF As BuitlInFunctionContainer In Parser.BuiltInFunctions
If BUF.OperatorType <> BuitlInFunctionContainer.EOperatorType.Binary Then
cbItmMathFn.Add(BUF.FunctionExpresionOperator, BUF)
End If
Next
FormPropertyEditorUI.Editor.AddItem(cbItmMathFn)
'agrego las funciones matematicas agregadas
cbItmMathFn = New WordItemBase("User Functions", "User Functions")
cbItmMathFn.Icon = New Icon([GetType], "fx.ico")
cbItmMathFn.Add(Parser.KnownFuntions)
'For Each Fn As FunctionBase In Parser.KnownFuntions
' cbItmMathFn.Add(Fn.Name, Fn)
'Next
FormPropertyEditorUI.Editor.AddItem(cbItmMathFn)
Dim kys() As Char = New Char() {"+", "/", "-", "*"}
FormPropertyEditorUI.Editor.AddKeys(kys)
End Sub
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'frameWork.CloseWindow()
If frameWork IsNot Nothing Then
frameWork.Dispose()
End If
'Me.FullD3DControl1.Dispose()
End Sub
#End Region
#Region "Some Methods"
Private Sub InitilizeSubMenus()
Me.ToolStripMenuItemRootFinderToolBar.Enabled = Not Me.disableRootFinding
'Me.ToolStripMenuItemRootlBar.Enabled = Not Me.disableRootLocus
End Sub
Sub LinearSettings()
Try
PreviousOption = 0
Me.ToolStripSplitButtonDemos1.Enabled = False
Me.ToolStripSplitButtonDemos3.Enabled = False
Me.ToolStripSplitButtonParametric.Enabled = True
Me.ToolStripDropDownButtonDemos2.Enabled = True
Me.ToolStripMenuItemVariableWidthPulse.Enabled = True
Me.ToolStripMenuItemParabolicFunction.Enabled = True
Me.ToolStripMenuItemRLCResonantCircuit.Enabled = True
Me.ToolStripMenuItemOrder5PolinomicFunction.Enabled = True
MainScanner.TypeOfStep = AdvancedSingleScanner.TypeOfIncrement.Linear
SetXRanges(10, -10)
SetYRanges(12, -12)
'intVisor.SetRanges(-10, 10, -12, 12)
intVisorM.AutoResize = True
intVisorM.AutoScale = AutoScaleCplxTypes.X
intVisorM.Name = "Module Visor"
intVisorM.YAxisProperties.AxisType = EAxisType.Linear
intVisorM.YAxisProperties.AxisLabel = "Y"
intVisorM.YAxisProperties.AxisUnit = "-"
intVisorM.YAxisProperties.UnitIsVisible = False
'intVisorP.SetRanges(0.1, 10000, 0.01, 100)
intVisorP.YAxisProperties.AxisType = EAxisType.Degree
intVisorP.XAxisProperties.AxisType = EAxisType.Logarithmic
intVisorP.XAxisProperties.AxisLabel = "x"
intVisorP.XAxisProperties.AxisUnit = "-"
intVisorP.XAxisProperties.UnitIsVisible = False
'intVisorP.AutoScale = AutoScaleCplxTypes.YImaginary
intVisorP.AutoResize = True
intVisorP.Name = "Phase Visor"
RefreshAll()
Catch ex As Exception
Log(ex.Message)
Stop
End Try
End Sub
Sub BodeSettings()
Try
PreviousOption = 1
Me.ToolStripSplitButtonDemos1.Enabled = True
Me.ToolStripSplitButtonDemos3.Enabled = True
Me.ToolStripSplitButtonParametric.Enabled = True
Me.ToolStripDropDownButtonDemos2.Enabled = False
Me.ToolStripMenuItemVariableWidthPulse.Enabled = False
Me.ToolStripMenuItemParabolicFunction.Enabled = False
Me.ToolStripMenuItemRLCResonantCircuit.Enabled = True
Me.ToolStripMenuItemOrder5PolinomicFunction.Enabled = False
SetXRanges(1000000, 0.1)
MainScanner.TypeOfStep = AdvancedSingleScanner.TypeOfIncrement.Exponential
intVisorM.YRange = New RangeF(0.01, 1000)
'intVisor.SetRanges(0.1, 10000, 0.01, 100)
intVisorM.YAxisProperties.AxisType = EAxisType.Decibell
intVisorM.YAxisProperties.AxisLabel = "T"
intVisorM.YAxisProperties.AxisUnit = "[dB]"
intVisorM.YAxisProperties.UnitIsVisible = True
intVisorM.XAxisProperties.AxisType = EAxisType.Logarithmic
intVisorM.XAxisProperties.AxisLabel = "f"
intVisorM.XAxisProperties.AxisUnit = "[Hz]"
intVisorM.XAxisProperties.UnitIsVisible = True
intVisorM.AutoScale = AutoScaleCplxTypes.YReal
intVisorM.AutoResize = True
'intVisorP.SetRanges(0.1, 10000, 0.01, 100)
intVisorP.YRange = New RangeF(0.01, 100)
intVisorP.YAxisProperties.AxisType = EAxisType.Degree
intVisorP.XAxisProperties.AxisType = EAxisType.Logarithmic
intVisorP.XAxisProperties.AxisLabel = "f"
intVisorP.XAxisProperties.AxisUnit = "[Hz]"
intVisorP.XAxisProperties.UnitIsVisible = True
'objVisor2DP.AutoScale = AutoScaleCplxTypes.YImaginary
intVisorP.AutoResize = True
RefreshAll()
Catch ex As Exception
Log(ex.Message)
Stop
End Try
End Sub
Sub RefreshAll()
If Me.ToolStripButtonAutoRefresh2D.Checked Then
Dim i As Integer
For Each Sys As AutoSystemCalc In Me.htblfnSysC.Values
Sys.UseSharedScanner = True
If i = 0 Then
Sys.Reset()
End If
Sys.Storage()
i += 1
Next
End If
End Sub
Sub ComplexPlainSettings()
'intVisor2CP.SetRanges(-10000, 10000, -10000, 10000)
intVisor2CP.XRange = New RangeF(-10000, 10000)
intVisor2CP.YRange = New RangeF(-10000, 10000)
intVisor2CP.XAxisProperties.AxisLabel = "s"
intVisor2CP.XAxisProperties.AxisUnit = "[Hz]"
intVisor2CP.XAxisProperties.UnitIsVisible = True
intVisor2CP.YAxisProperties.AxisLabel = "f"
intVisor2CP.YAxisProperties.AxisUnit = "[Hz]"
intVisor2CP.YAxisProperties.UnitIsVisible = True
'objVisor2CP.AutoScale = AutoScaleCplxTypes.YReal
intVisor2CP.AutoResize = True
intVisor2CP.IsSimetrical = True
intVisorP.Name = "Complex Plane Visor"
End Sub
Sub SetYRanges(ByVal yMax As Single, ByVal yMin As Single) ', ByVal yMax As Single, ByVal yMin As Single)
Me.intVisorM.YRange = New RangeF(yMin, yMax)
Me.intVisorP.YRange = New RangeF(yMin, yMax)
End Sub
Sub SetXRanges(ByVal xMax As Single, ByVal xMin As Single) ', ByVal yMax As Single, ByVal yMin As Single)
Me.intVisorM.XRange = New RangeF(xMin, xMax)
Me.intVisorP.XRange = New RangeF(xMin, xMax)
MainScanner.FinalValue = xMax
MainScanner.InitialValue = xMin
End Sub
#End Region
#Region "TreeView"
Sub InitilalizeTreeView()
Me.tnFunctions = Me.AddRootNode("Functions", 1)
Me.tnParams = Me.AddRootNode("Parameters", 3)
Me.tnOthers = Me.AddRootNode("Others", 15)
Me.tnVisors = Me.AddSubNode(Me.tnOthers, "Visors", 0)
Me.tnRL = Me.AddSubNode(Me.tnOthers, "Root Locus", 13)
Me.tnScan = Me.AddSubNode(Me.tnOthers, "Scan", 4)
Me.tnCursors = Me.AddSubNode(Me.tnOthers, "Cursors", Me.CursorToolBar, 5)
If Not Me.FRToolBar Is Nothing Then
Me.tnRootFinding = Me.AddSubNode(Me.tnOthers, "Rootfinding", Me.FRToolBar.RootFinderObject, 14)
End If
Me.tnFFTObj = Me.AddSubNode(Me.tnOthers, "FFT", 6)
Me.tn3D = Me.AddSubNode(Me.tnOthers, "3D Graph", Me.FullD3DControl1, 17)
Me.tnRecycleBin = Me.AddSubNode(Me.tnOthers, "Recycle Bin", 7)
Me.tnParseableFn = Me.AddSubNode(Me.tnFunctions, "Parseable Functions", 1)
Me.tnLaplaceFn = Me.AddSubNode(Me.tnFunctions, "Bode Functions", 2)
Me.tnSings = Me.AddSubNode(Me.tnParams, "Singularities", 12)
Me.AddSubNode(tnVisors, Me.intVisorM, Me.intVisorM.Name, 0)
Me.AddSubNode(tnVisors, Me.intVisorP, Me.intVisorP.Name, 0)
Me.AddSubNode(tnVisors, Me.intVisor2CP, Me.intVisor2CP.Name, 0)
Me.AddSubNode(tnScan, Me.ParamToolBar.Scanner, "Parametrics Scanner", 4)
Me.AddSubNode(tnScan, Me.MainScanner, "Main Scanner", 4)
tnFFTSpectrum = Me.AddSubNode(Me.tnFFTObj, Me.FFTToolBar.FFTSpectrum, "FFT Spectrum", 6)
If Not Me.intD3DManager Is Nothing Then
Me.AddSubNode(tn3D, Me.intD3DManager, "3D Enviroment", 4)
End If
Me.tnParamsControlled = Me.AddSubNode(Me.tnParams, "Controlled", 3)
Me.tnFunctions.Expand()
End Sub
Function AddRootNode(ByVal TreeNodeText As String, ByVal ImgIndex As Integer) As TreeNode
Dim Ts As TreeNode
Ts = Me.TreeViewItems.Nodes.Add(TreeNodeText, TreeNodeText, ImgIndex)
Ts.SelectedImageIndex = ImgIndex
Return Ts
End Function
''' <summary>
''' Agrega un nodo raiz al treeview, con el Texto e imagen indicados.
''' Ademas relaciona al nodo con el objeto especificado
''' </summary>
''' <param name="TreeNodeText"></param>
''' <param name="o"></param>
''' <param name="ImgIndex"></param>
''' <returns></returns>
''' <remarks></remarks>
Function AddRootNode(ByVal TreeNodeText As String, ByVal o As Object, ByVal ImgIndex As Integer) As TreeNode
If o Is Nothing Then
Stop
Return Nothing
End If
Dim Ts As TreeNode
Ts = Me.TreeViewItems.Nodes.Add(TreeNodeText, TreeNodeText, ImgIndex)
Ts.SelectedImageIndex = ImgIndex
Me.htblNodeObj.Add(Ts, o)
If Not Me.htblObjNode.ContainsKey(o) Then
Me.htblObjNode.Add(o, Ts)
End If
Return Ts
End Function
Function AddSubNode(ByVal ParentNode As TreeNode, ByVal Text As String, ByVal ImgIndex As Integer) As TreeNode
Dim Ts As TreeNode
Ts = ParentNode.Nodes.Add(Text, Text, ImgIndex)
Ts.SelectedImageIndex = ImgIndex
Return Ts
End Function
Function AddSubNode(ByVal ParentNode As TreeNode, ByVal o As Object, ByVal ObjectName As String, ByVal ImgIndex As Integer) As TreeNode
If o Is Nothing Then
Stop
Return Nothing
End If
Dim Ts As TreeNode
Ts = ParentNode.Nodes.Add(ObjectName, ObjectName, ImgIndex)
Ts.SelectedImageIndex = ImgIndex
Me.htblNodeObj.Add(Ts, o)
If Not Me.htblObjNode.ContainsKey(o) Then
Me.htblObjNode.Add(o, Ts)
End If
Return Ts
End Function
''' <summary>
''' Agrega el subnodo con el texto e imagen especificados al Parentnode indicado,
''' y ademas relaciona al nuevo nodo con el objeto O
''' </summary>
''' <param name="ParentNode"></param>
''' <param name="TreeNodeText"></param>
''' <param name="o"></param>
''' <param name="ImgIndex"></param>
''' <returns></returns>
''' <remarks></remarks>
Function AddSubNode(ByVal ParentNode As TreeNode, ByVal TreeNodeText As String, ByVal o As Object, ByVal ImgIndex As Integer) As TreeNode
If o Is Nothing Then
Stop
Return Nothing
End If
Dim Ts As TreeNode
Ts = ParentNode.Nodes.Add(TreeNodeText, TreeNodeText, ImgIndex)
Ts.SelectedImageIndex = ImgIndex
Me.htblNodeObj.Add(Ts, o)
If Not Me.htblObjNode.ContainsKey(o) Then
Me.htblObjNode.Add(o, Ts)
End If
Return Ts
End Function
Private Sub MoveNode(ByVal NewParentNode As TreeNode, ByVal TN As TreeNode)
TN.Remove()
NewParentNode.Nodes.Add(TN)
End Sub
Private Function RemoveControledNode(ByVal ObjectName As String, ByVal ParentNode As TreeNode) As TreeNode
Dim TN() As TreeNode
TN = Me.TreeViewItems.Nodes.Find(ObjectName, True)
If TN Is Nothing OrElse TN.Length = 0 Then
Return Nothing
End If
For Each node As TreeNode In TN
If node.Parent Is ParentNode Then
RemoveControledNode = node
Me.TreeViewItems.Nodes.Remove(node)
'ParentNode.Nodes.Add(TN(0))
Exit Function
End If
Next
Return Nothing
End Function
#End Region
#Region "ListView"
Function AddListViewItem(ByVal text As String, ByVal o As Object, ByVal ImgIndex As Integer) As ListViewItem
If o Is Nothing Then
Throw New NullReferenceException
End If
AddListViewItem = Me.ListViewSubItems.Items.Add(text, ImgIndex)
Me.htblListItmObj.Add(AddListViewItem, o)
End Function
#End Region
#Region "Message"
Private Sub OnMessageReicived(ByVal sender As Object, ByVal s As MessageEventArgs)
If s.MessageType = MessageEventArgs.EMessageType.Error Then
Me.ToolStripStatusLabel1.ForeColor = Color.White
Me.ToolStripStatusLabel1.BackColor = Color.Brown
ElseIf s.MessageType = MessageEventArgs.EMessageType.Warning Then
Me.ToolStripStatusLabel1.ForeColor = Color.Black
Me.ToolStripStatusLabel1.BackColor = Color.Yellow
Else
Me.ToolStripStatusLabel1.ForeColor = Color.Black
Me.ToolStripStatusLabel1.BackColor = Color.Transparent
End If
Me.ToolStripStatusLabel1.Text = s.Message
Log(s.Message)
End Sub
Sub Log(ByVal Message As String)
Me.TextBoxLog.Text &= ControlChars.NewLine & Message
End Sub
Protected Overridable Sub Log(ByVal Sender As String, ByVal Message As String, ByVal Level As ggUtilLib.LogUtility.PriorityLevel)
Log(Message)
LogUtil.Log(Sender, Message, Level)
'Me.RaiseSendMessage(New MessageEventArgs(Message))
End Sub
Protected Overridable Sub Log(ByVal Message As String, ByVal ex As Exception)
Log(Message)
LogUtil.Log(Me, Message, ex)
'Me.RaiseSendMessage(New MessageEventArgs(Message))
End Sub
Protected Overridable Sub Log(ByVal Messages() As String, ByVal Level As ggUtilLib.LogUtility.PriorityLevel)
Dim txtLog As String = ""
For Each message As String In Messages
txtLog &= message & ControlChars.NewLine
Next
Log(txtLog)
LogUtil.Log(Me, txtLog, Level)
'Me.RaiseSendMessage(New MessageEventArgs(txtLog))
End Sub
Protected Overridable Sub Log(ByVal Message As String, ByVal Level As ggUtilLib.LogUtility.PriorityLevel)
Log(Message)
LogUtil.Log(Me, Message, Level)
'Me.RaiseSendMessage(New MessageEventArgs(Message))
End Sub
#End Region
#Region "Add & Remove Buttons Events"
#Region "Adding Section"
Private Function AddFn2Graph(ByVal fn As FunctionBase) As GraphOfVisorSimple
If Me.htblfnGoV.ContainsKey(fn) Then
Return Me.htblfnGoV.Item(fn)
End If
Me.SystemCalc = New AutoSystemCalc(fn)
If Me.ToolStripComboBoxMainOptions.SelectedIndex = 1 Then
Me.SystemCalc.VariableIsReal = VariableMain.Imaginary
Else
Me.SystemCalc.VariableIsReal = VariableMain.Real
End If
Me.SystemCalc.Scanner = MainScanner
Me.htblfnSysC.Add(fn, Me.SystemCalc)
Dim GoV As GraphOfVisorSimple
Me.intVisorM.Add(Me.SystemCalc)
GoV = Me.intVisorM.CurrentGoV
'GoV.Show = EGraphShowOne.Module
GoV.Name = "Module Graph " & intVisorM.GraphCount
Me.htblfnGoV.Add(fn, GoV)
If Me.dontRun = False Then
SystemCalc.Storage()
End If
Return GoV
End Function
Private Function AddFn2PhaseGraph(ByVal fn As FunctionBase) As GraphOfVisorSimple
If Me.htblfnGoVP.ContainsKey(fn) Then
Return Me.htblfnGoVP.Item(fn)
End If
'If Me.ToolStripComboBoxMainOptions.SelectedIndex = 1 Then
' Me.SystemCalc.VariableIsReal = VariableMain.Imaginary
'Else
' Me.SystemCalc.VariableIsReal = VariableMain.Real
'End If
If Me.htblfnSysC.ContainsKey(fn) Then
Me.SystemCalc = Me.htblfnSysC.Item(fn)
Else
Me.SystemCalc = New AutoSystemCalc(fn)
Me.SystemCalc.Scanner = MainScanner
Me.htblfnSysC.Add(fn, Me.SystemCalc)
End If
Dim GoV As GraphOfVisorComplexS
Me.intVisorP.Add(Me.SystemCalc)
GoV = Me.intVisorP.CurrentGoV
GoV.Show = EGraphShowOne.Angle
GoV.Name = "Phase Graph " & intVisorM.GraphCount
Me.htblfnGoVP.Add(fn, GoV)
SystemCalc.Storage()
Return GoV
End Function
Private Function AddFn2ComplexPlain(ByVal fn As LaplaceFunction) As GraphOfVisorComplexPlain
Me.intVisor2CP.Add(fn)
Return Me.intVisor2CP.CurrentGoV
End Function
Private Function AddFn2AllGraph(ByVal fn As FunctionBase) As GraphOfVisorComplex
Dim GoV As GraphOfVisorComplex
GoV = AddFn2Graph(fn)
Me.intVisorP.Add(Me.SystemCalc)
GoV = Me.intVisorP.CurrentGoV
GoV.Show = EGraphShowOne.Angle
GoV.Name = "Phase Graph " & intVisorP.GraphCount
'Me.intVisor2CP.Add(LapFn)
Return GoV
End Function
Private Function AddParameterForControl(ByVal p As Parameter) As ScanResponseModifier
Return Me.ParamToolBar.Add(p)
End Function
'Private Sub AddLaplaceFunction(ByVal LapFn As LaplaceFunction)
' FunctionManager.Add(LapFn)
' Me.AddSubNode(Me.tnLaplaceFn, LapFn, LapFn.Name, 2)
' Me.TreeViewItems.SelectedNode = Nothing
' Me.ListViewSubItems.SelectedItems.Clear()
' AddHandler LapFn.NameChange, AddressOf OnNameChange
' AddHandler LapFn.DataChange, AddressOf OnFunctionChange
' If Not Me.dontRun Then
' Me.selectedObj = LapFn
' End If
'End Sub
Private Sub AddRootLocus(ByVal RL As RootLocusBase)
Dim TN As TreeNode
TN = Me.AddSubNode(Me.tnRL, RL, RL.Name, 13)
Me.AddSubNode(TN, RL.LaplaceDirectObject, RL.LaplaceDirectObject.Name, 2)
Me.AddSubNode(TN, RL.LaplaceFeedbackObject, RL.LaplaceFeedbackObject.Name, 2)
If Not RL.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddSubNode(TN, RL.LaplaceGlobalFeedBackedObject, RL.LaplaceGlobalFeedBackedObject.Name, 2)
End If
End Sub
Private Sub AddSing(ByVal Sing As Singularity, ByVal LapFn As LaplaceFunction)
If Not Me.htblObjNode.ContainsKey(LapFn) Then
Stop
Exit Sub
End If
Dim TN As TreeNode
TN = Me.htblObjNode.Item(LapFn)
If Sing.SingularitieType = SingType.Zero Then
If Sing.IsConjugated Then
Me.AddSubNode(TN, Sing.Conjugate, Sing.Conjugate.Name, 11)
Me.AddListViewItem(Sing.Name, Sing, 9)
Else
Me.AddSubNode(TN, Sing, Sing.Name, 10)
Me.AddListViewItem(Sing.Name, Sing, 8)
End If
Else
If Sing.IsConjugated Then
Me.AddSubNode(TN, Sing, Sing.Name, 9)
Me.AddListViewItem(Sing.Name, Sing, 7)
Else
Me.AddSubNode(TN, Sing, Sing.Name, 8)
Me.AddListViewItem(Sing.Name, Sing, 6)
End If
End If
selectedObj = Sing
PropertyGrid1.SelectedObject = Sing
End Sub
#End Region
#Region "Creation Section"
''' <summary>
''' Agrega una funcion cualquier al sistema
''' </summary>
''' <param name="Fn"></param>
''' <remarks></remarks>
Private Sub AddFunction(ByVal Fn As FunctionBase)
If FunctionManager.Contains(Fn) Then
If TypeOf Fn Is [Function] AndAlso Me.htblObjNode.ContainsKey(Fn) Then
'siempre contiene a este tipo
Exit Sub
End If
Else
FunctionManager.Add(Fn)
End If
If TypeOf Fn Is LaplaceFunction Then
Me.AddSubNode(Me.tnLaplaceFn, Fn, Fn.Name, 2)
Else
Me.AddSubNode(Me.tnParseableFn, Fn, Fn.Name, 1)
End If
Me.TreeViewItems.SelectedNode = Nothing
Me.ListViewSubItems.SelectedItems.Clear()
AddHandler Fn.NameChange, AddressOf OnNameChange
AddHandler Fn.DataChange, AddressOf OnFunctionChange
If Not Me.dontRun Then
Me.selectedObj = Me.Fn
End If
End Sub
Private Function CreateFunction(ByVal Expresion As String, ByVal Name As String, ByVal Description As String) As [Function]
Fn = FunctionManager.Add(Expresion, Name)
Me.AddFunction(Fn)
Fn.Description = Description
Return Fn
End Function
Private Function CreateFunction(ByVal Expresion As String) As [Function]
Fn = FunctionManager.Add(Expresion)
Me.AddFunction(Fn)
Return Fn
End Function
Private Function CreateFunction() As [Function]
Return Me.CreateFunction("sin(x)")
End Function
Private Function CreateLaplaceFunction(ByVal BaseName As String, ByVal KReal As Single) As FunctionBase
Dim LapFn As LaplaceFunction
If BaseName Is Nothing OrElse BaseName = "" Then
LapFn = New LaplaceFunction
Else
LapFn = New LaplaceFunction(BaseName)
End If
LapFn.Real = KReal
Me.AddFunction(LapFn)
Return LapFn
End Function
Private Function CreateParameter(ByVal Name As String) As Parameter
CreateParameter = New Parameter(Name)
CreateParameter = CreateParameter
FunctionManager.Add(CreateParameter)
Me.AddSubNode(tnParams, CreateParameter, CreateParameter.Name, 4)
AddHandler CreateParameter.NameChange, AddressOf OnNameChange
End Function
''' <summary>
''' Crea un parametro, lo agrega al sistema y devuelve su referencia
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Private Function CreateParameter() As Parameter
CreateParameter = New Parameter
CreateParameter = CreateParameter
FunctionManager.Add(CreateParameter)
Me.AddSubNode(tnParams, CreateParameter, CreateParameter.Name, 4)
AddHandler CreateParameter.NameChange, AddressOf OnNameChange
End Function
Private Function CreateSing(ByVal Real As Single, ByVal Imag As Single, ByVal Cero As Boolean, ByVal LapFn As LaplaceFunction) As Singularity
'CreateSing = Me.CreateSing(Real, Imag, Cero)
If LapFn Is Nothing Then
Stop
Return Nothing
End If
CreateSing = New GraphicsSingularity(Real, Imag)
If Cero Then
CreateSing.SingularitieType = SingType.Zero
Else
CreateSing.SingularitieType = SingType.Polo
End If
LapFn.Add(CreateSing)
AddSing(CreateSing, LapFn)
End Function
'Private Function CreateSing(ByVal Real As Single, ByVal Imag As Single, ByVal Cero As Boolean) As Singularity
' CreateSing = New GraphicsSingularity(Real, Imag)
' If Cero Then
' CreateSing.SingularitieType = SingType.Zero
' Else
' CreateSing.SingularitieType = SingType.Polo
' End If
' LapFn.Add(CreateSing)
' AddSing(CreateSing, LapFn)
'End Function
Private Function CreateConjugatedSings(ByVal Real As Single, ByVal Imag As Single, ByVal Cero As Boolean, ByVal LapFn As LaplaceFunction) As Singularity
'CreateConjugatedSings = CreateConjugatedSings(Real, Imag, Cero)
If LapFn Is Nothing Then
Stop
Return Nothing
End If
CreateConjugatedSings = New GraphicsSingularity(Real, Imag)
If Cero Then
CreateConjugatedSings.SingularitieType = SingType.Zero
Else
CreateConjugatedSings.SingularitieType = SingType.Polo
End If
Dim selectedsing2 As GraphicsSingularity
selectedsing2 = New GraphicsSingularity
selectedsing2.Conjugate = CreateConjugatedSings
LapFn.Add(CreateConjugatedSings)
Me.AddSing(CreateConjugatedSings, LapFn)
End Function
'Private Function CreateConjugatedSings(ByVal Real As Single, ByVal Imag As Single, ByVal Cero As Boolean) As Singularity
' CreateConjugatedSings = New GraphicsSingularity(Real, Imag)
' If Cero Then
' CreateConjugatedSings.SingularitieType = SingType.Zero
' Else
' CreateConjugatedSings.SingularitieType = SingType.Polo
' End If
' Dim SelectedSing2 As GraphicsSingularity
' SelectedSing2 = New GraphicsSingularity
' SelectedSing2.Conjugate = CreateConjugatedSings
' LapFn.Add(CreateConjugatedSings)
' AddSing(CreateConjugatedSings, LapFn)
'End Function
#End Region
#Region "Remove Section"
Private Sub RemoveGraph(ByVal Gov As GraphOfVisorSimple)
If Me.intVisorM.Contains(Gov) Then
Me.intVisorM.Remove(Gov)
End If
If Me.intVisor2CP.Contains(Gov) Then
Me.intVisor2CP.Remove(Gov)
End If
If Me.intVisorP.Contains(Gov) Then
Me.intVisorP.Remove(Gov)
End If
Gov.Dispose()
End Sub
''' <summary>
''' Saca los graficos de la funcion seleccionada y luego envia esta
''' funci�n a la papelera de reciclaje
''' </summary>
''' <remarks></remarks>
Private Sub RemoveFunction()
If Me.Fn Is Nothing Then
Exit Sub
End If
RemoveFunction(Me.Fn)
End Sub
Private Sub RemoveFunction(ByVal Fn As FunctionBase)
Dim gov As GraphOfVisorSimple
If Me.htblfnGoV.ContainsKey(Me.Fn) Then
gov = Me.htblfnGoV.Item(Me.Fn)
Me.htblfnGoV.Remove(Fn)
ElseIf Me.htblfnGoVP.ContainsKey(Me.Fn) Then
gov = Me.htblfnGoVP.Item(Me.Fn)
Me.htblfnGoVP.Remove(Fn)
Else
Stop
Exit Sub
End If
Me.RemoveFunction(Me.Fn, gov)
End Sub
Private Sub RemoveFunction(ByVal Fn As FunctionBase, ByVal Gov As GraphOfVisorSimple)
If MsgBox("Are you sure to remove selected Function :" & Me.Fn.Name, _
MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.No Then
Exit Sub
End If
Me.RemoveGraph(Gov)
If Me.htblfnSysC.ContainsKey(Fn) Then
Me.htblfnSysC.Remove(Fn)
End If
If Not Me.htblObjNode.ContainsKey(Fn) Then
Stop
End If
Dim TN As TreeNode
TN = Me.htblObjNode.Item(Me.Fn)
Me.MoveNode(Me.tnRecycleBin, TN)
End Sub
''' <summary>
''' Saca los graficos de la funcion de Laplace seleccionada y
''' luego envia esta funci�n a la papelera de reciclaje
''' </summary>
''' <remarks></remarks>
Private Sub RemoveLaplaceFunction()
If Me.LapFn Is Nothing Then
Exit Sub
End If
Me.RemoveFunction(Me.LapFn)
'If Me.htblfnGoV.ContainsKey(LapFn) Then
' If MsgBox("Are you sure to remove selected Laplace Function?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.No Then
' Exit Sub
' End If
' Dim gov As GraphOfVisorSimple
' gov = Me.htblfnGoV.Item(LapFn)
' Me.htblfnGoV.Remove(LapFn)
' Me.RemoveGraph(gov)
' If Not Me.htblObjNode.ContainsKey(LapFn) Then
' Stop
' End If
' Dim TN As TreeNode
' TN = Me.htblObjNode.Item(LapFn)
' Me.MoveNode(Me.tnRecycleBin, TN)
'End If
End Sub
''' <summary>
''' Remueve la singularidad seleccionada del sistema de Laplace
''' seleccionado
''' </summary>
''' <remarks></remarks>
Public Sub RemoveSing()
If LapFn Is Nothing Then
Exit Sub
End If
If Me.SelectedSing Is Nothing Then
Exit Sub
End If
If LapFn.Contains(Me.SelectedSing) Then
LapFn.Remove(Me.SelectedSing)
Dim TN As TreeNode
TN = Me.htblObjNode.Item(Me.SelectedSing)
'Me.TreeViewItems.Nodes.Remove(TN)
Me.MoveNode(Me.tnRecycleBin, TN)
End If
End Sub
#End Region
''' <summary>
''' Remueve todas las singularidades del sistema de Laplace Seleccionado
''' </summary>
''' <remarks></remarks>
Public Sub ClearSings()
If LapFn Is Nothing Then
Exit Sub
End If
For Each s As Singularity In LapFn.Singularities
LapFn.Remove(s)
Dim TN As TreeNode
TN = Me.htblObjNode.Item(s)
'Me.TreeViewItems.Nodes.Remove(TN)
Me.MoveNode(Me.tnRecycleBin, TN)
Next
End Sub
#End Region
#Region "TabPage Utilities"
Sub ChangeTabPosition(ByVal OldTabCtrl As TabControl, ByVal NewTabCtrl As TabControl, ByVal TabPg As TabPage)
If OldTabCtrl.TabPages.Contains(TabPg) Then
OldTabCtrl.TabPages.Remove(TabPg)
End If
If Not NewTabCtrl.TabPages.Contains(TabPg) Then
NewTabCtrl.TabPages.Add(TabPg)
End If
End Sub
Sub AddTabPage(ByVal TabCtrl As TabControl, ByVal TabPg As TabPage)
If Not TabCtrl.TabPages.Contains(TabPg) Then
TabCtrl.TabPages.Add(TabPg)
End If
End Sub
Sub RemoveTabPage(ByVal TabCtrl As TabControl, ByVal TabPg As TabPage)
If TabCtrl.TabPages.Contains(TabPg) Then
TabCtrl.TabPages.Remove(TabPg)
End If
End Sub
#End Region
#Region "Add & Remove Button Captur Methods"
Private Sub ToolStripMenuItemAddPole_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddPole.Click
CreateSing(-CInt(Rnd() * 100), 0, False, Me.LapFn)
End Sub
Private Sub AddCeroToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddCeroToolStripMenuItem.Click
CreateSing(-CInt(Rnd() * 100), 0, True, Me.LapFn)
End Sub
Private Sub AddConjugatedPolesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddConjugatedPolesToolStripMenuItem.Click
CreateConjugatedSings(-CInt(Rnd() * 100), CInt(Rnd() * 100), False, Me.LapFn)
End Sub
Private Sub AddConjugatedCerosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddConjugatedCerosToolStripMenuItem.Click
CreateConjugatedSings(-CInt(Rnd() * 100), CInt(Rnd() * 100), True, Me.LapFn)
End Sub
Private Sub AddLaplaceFuncionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddLaplaceFuncion.Click
Me.CreateLaplaceFunction("", 100)
End Sub
Private Sub AddFunctionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddFunction.Click
Me.CreateFunction()
End Sub
Private Sub ToolStripMenuItemRemoveFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemRemoveFunction.Click
Me.RemoveFunction()
End Sub
Private Sub ToolStripMenuItemAddFn2Graph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddFn2Graph.Click
If TypeOf Me.selectedObj Is FunctionBase Then
Me.AddFn2Graph(Me.selectedObj)
End If
End Sub
Private Sub AddFunctionToPhaseGraphToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddFunctionToPhaseGraph.Click
If Not Me.Fn Is Nothing Then
Me.AddFn2PhaseGraph(Me.Fn)
ElseIf Not LapFn Is Nothing Then
Me.AddFn2PhaseGraph(LapFn)
Else
Me.OnMessageReicived(Me, New MessageEventArgs("!Must select first a function!", MessageEventArgs.EMessageType.Info))
End If
End Sub
Private Sub AddLaplaceFunctionToComplexPlainToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddLaplaceFunctionToComplexPlain.Click
If Not LapFn Is Nothing Then
AddFn2ComplexPlain(LapFn)
End If
End Sub
Private Sub AddSelectedSingToFunctionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAddSelectedSingToFunction.Click
If LapFn Is Nothing Then
Exit Sub
End If
If Me.SelectedSing Is Nothing Then
Exit Sub
End If
If Not LapFn.Contains(Me.SelectedSing) Then
LapFn.Add(Me.SelectedSing)
Dim TN, TP As TreeNode
TN = Me.htblObjNode.Item(Me.SelectedSing)
TN.Remove()
TP = Me.htblObjNode.Item(LapFn)
Me.MoveNode(TP, TN)
End If
End Sub
Private Sub ToolStripMenuItemRemoveGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveGraphToolStripMenuItem.Click
If TypeOf Me.selectedObj Is GraphOfVisorSimple Then
If MsgBox("Are you sure to remove selected Graph?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.No Then
Exit Sub
End If
Me.RemoveGraph(Me.selectedObj)
End If
End Sub
Private Sub RemoveLaplaceFunctionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveLaplaceFunctionToolStripMenuItem.Click
Me.RemoveLaplaceFunction()
End Sub
#End Region
#Region "TreeView & ListView Selection"
Private Sub TreeViewItems_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeViewItems.AfterSelect
Me.ListViewSubItems.Clear()
If Not Me.htblNodeObj.ContainsKey(e.Node) Then
PropertyGrid1.SelectedObject = Nothing
If e.Node Is Me.tnParseableFn Then
'Dim tn As TreeNode
Dim LI As ListViewItem
Dim fn As FunctionBase
For Each o As Object In Me.htblObjNode.Keys
If TypeOf o Is FunctionBase Then
If Me.htblObjNode.Item(o).Parent IsNot Me.tnRecycleBin Then
fn = o
If TypeOf o Is [Function] Then
LI = Me.AddListViewItem(fn.Name, fn, 1)
Else
LI = Me.AddListViewItem(fn.Name, fn, 2)
End If
End If
End If
Next
End If
Exit Sub
End If
SelectItm(Me.htblNodeObj.Item(e.Node), Me.TreeViewItems)
End Sub
Private Sub ListViewSubItems_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewSubItems.SelectedIndexChanged
If Me.ListViewSubItems.SelectedItems.Count = 0 Then
Exit Sub
End If
If Not Me.htblListItmObj.ContainsKey(Me.ListViewSubItems.SelectedItems(0)) Then
Stop
Exit Sub
End If
Dim o As Object
o = Me.htblListItmObj.Item(Me.ListViewSubItems.SelectedItems(0))
If TypeOf o Is LaplaceFunction Then
SelectLaplaceFunction(o, False)
Me.TreeViewItems.SelectedNode = Nothing
Exit Sub
End If
Me.TreeViewItems.SelectedNode = Nothing
SelectItm(Me.htblListItmObj.Item(Me.ListViewSubItems.SelectedItems(0)), Me.ListViewSubItems)
End Sub
#End Region
#Region "TollStripButtons Methods Capture"
Private Sub ToolStripButtonRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonRun.Click
Me.RefreshAll()
End Sub
Private Sub ToolStripButtonShowZoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonShowZoom.Click
ZoomToolBar.Visible = Not ZoomToolBar.Visible
End Sub
Private Sub ToolStripMenuItemClearSings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemClearSings.Click
If LapFn Is Nothing Then
Exit Sub
End If
If MsgBox("Are you sure to remove all singularities from the selected Laplace Function?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.ClearSings()
End If
End Sub
Private Sub ToolStripMenuItemRemoveSings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemRemoveSings.Click
If LapFn Is Nothing Then
Exit Sub
End If
If Me.SelectedSing Is Nothing Then
Exit Sub
End If
If MsgBox("Are you sure to remove selected singularity from the selected Laplace Function?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
RemoveSing()
End If
End Sub
Private Sub ToolStripButtonSplitGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonSplitGraph.Click
SplitGraph()
End Sub
Private Sub ToolStripButtonShowCursorToolBar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonShowCursorToolBar.Click
Me.CursorToolBar.Visible = Me.ToolStripButtonShowCursorToolBar.Checked
End Sub
Private Sub CreateParameterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemCreateParameter.Click
Dim Pr As Parameter
Pr = Me.CreateParameter()
Pr.Real = 1
Me.selectedObj = Pr
Me.PropertyGrid1.SelectedObject = Pr
End Sub
Private Sub ToolStripComboBoxMainOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripComboBoxMainOptions.DropDownClosed
If ToolStripComboBoxMainOptions.SelectedIndex = PreviousOption Then
Exit Sub
End If
If ToolStripComboBoxMainOptions.SelectedIndex = 0 Then
If MsgBox("Do you wish to set Linear Scales?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.LinearSettings()
Else
ToolStripComboBoxMainOptions.SelectedIndex = 1
End If
Else
If MsgBox("Do you wish to set Logaritmic Scales for Bode Analisys?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.BodeSettings()
Else
ToolStripComboBoxMainOptions.SelectedIndex = 0
End If
End If
PreviousOption = ToolStripComboBoxMainOptions.SelectedIndex
End Sub
#End Region
#Region "Bode Demos"
Private Sub ToolStripMenuItem_ClickOpenLoopAmplifier(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemOpenLoopAmplifier.Click
Me.SetXRanges(10000000, 1)
Dim fn As [Function]
fn = Me.CreateFunction()
If FunctionManager.Contains("A") Then
fn.Name = "A"
Else
fn.Name = "A" & ParameterBase.Count
End If
fn.Name = "A"
fn.Parts(0).Expresion = "100000/((1+z/1000)*(1+z/100000))"
fn.Description = "Open loop Amplifier transference." & ControlChars.NewLine _
& "In this Demo the amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 1KHz, and Second at 100KHz"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Module
End Sub
Private Sub ToolStripMenuItem_ClickAmplifierWithFeedBack(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAmplifierWithFeedBack.Click
dontRun = True
Dim A, B, D As String
Me.SetXRanges(10000000, 1)
Dim fn As [Function]
fn = Me.CreateFunction()
If FunctionManager.Contains("A") Then
fn.Name = "A"
Else
fn.Name = "A" & ParameterBase.Count
End If
fn.Name = "A"
fn.Parts(0).Expresion = "100000/((1+z/1000)*(1+z/100000))"
fn.Description = "Open loop Amplifier transference." & ControlChars.NewLine _
& "In this Demo the amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 1KHz, and Second at 100KHz"
A = fn.Name
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Module
Dim Pr As Parameter
Pr = Me.CreateParameter()
Pr.Name = "p" & ParameterBase.Count
Pr.Real = 0.1
fn = Me.CreateFunction()
fn.Name = "B"
fn.Parts(0).Expresion = Pr.Name
fn.Description = "Feedback transference"
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Module
B = Me.Fn.Name
fn = Me.CreateFunction()
fn.Name = "D"
fn.Parts(0).Expresion = "1+" & A & "*" & B
fn.Description = "Return Difference"
D = fn.Name
fn = Me.CreateFunction()
fn.Name = "Af"
fn.Parts(0).Expresion = A & "/" & D
fn.Description = "Amplifier with feedback transference"
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Module
Dim SPM As ScanResponseModifier
SPM = Me.AddParameterForControl(Pr)
SPM.Range = New RangeF(0.0001, 1)
SPM.Alinearity = 3
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItem1OpenLoopAmplifier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1OpenLoopAmplifier.Click
dontRun = True
Dim lapFn As LaplaceFunction
lapFn = Me.CreateLaplaceAmplifier(100000, 1000, 100000)
lapFn.Description = "Open loop Amplifier transference." & ControlChars.NewLine _
& "In this Demo the amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 1KHz, and Second at 100KHz"
Me.RefreshAll()
dontRun = False
End Sub
Private Sub ToolStripMenuItemMixedAmplifierWithFeedBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemMixedAmplifierWithFeedBack.Click
dontRun = True
Dim str As String
Dim B, A As LaplaceFunction
Dim Af, D As [Function]
Me.SetXRanges(10000000, 1)
A = Me.CreateLaplaceFunction("A", 100000)
A.Description = "Open loop Amplifier transference." & ControlChars.NewLine _
& "In this Demo the amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 1KHz, and Second at 100KHz"
Me.CreateSing(-1000, 0, False, A)
Me.CreateSing(-100000, 0, False, A)
Me.RLToolBar.LaplaceDirectObject = A
str = "1+" & A.Name & "*"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(A)
GoV.Show = EGraphShowOne.Module
B = Me.CreateLaplaceFunction("B", 0.01)
B.Description = "Feedback transference"
GoV = Me.AddFn2Graph(B)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.LaplaceFeedbackObject = B
'Me.AddFunction(A)
'Me.AddFunction(B)
str &= B.Name
D = Me.CreateFunction()
D.Name = "D"
D.Parts(0).Expresion = str
D.Description = "Return Difference"
Af = Me.CreateFunction()
Af.Name = "Af"
Af.Parts(0).Expresion = A.Name & "/" & D.Name
Af.Description = "Amplifier with feedback transference"
GoV = Me.AddFn2Graph(Af)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItem1LM741_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1LM741.Click
dontRun = True
Dim lapFn As LaplaceFunction
lapFn = Me.CreateLaplaceAmplifier(100000, 10, 5000000)
lapFn.Description = "Open loop LM741 Operational Amplifier transference." & ControlChars.NewLine _
& "This amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 10Hz, and Second at 5MHz" _
& "In this case a Laplace Function was used"
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItemLM741_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemLM741.Click
dontRun = True
Me.SetXRanges(10000000, 1)
Dim fn As [Function]
fn = Me.CreateFunction()
If FunctionManager.Contains("A") Then
fn.Name = "A"
Else
fn.Name = "A" & ParameterBase.Count
End If
fn.Name = "A"
fn.Parts(0).Expresion = "100000/((1+z/10)*(1+z/5000000))"
fn.Description = "Open loop LM741 Operational Amplifier transference." & ControlChars.NewLine _
& "This amplifier have a DC gain of 100.000, and two poles:" & ControlChars.NewLine _
& "First at 10Hz, and Second at 5MHz" & ControlChars.NewLine _
& "In this case a Parseable Expresion - Function was used"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Module
dontRun = False
Me.RefreshAll()
End Sub
Private Function CreateLaplaceAmplifier(ByVal DCGain As Single, ByVal F1 As Single, ByVal f2 As Single) As LaplaceFunction
Me.SetXRanges(10000000, 1)
Me.LapFn = Me.CreateLaplaceFunction("A", DCGain)
CreateLaplaceAmplifier = Me.LapFn
Me.CreateSing(-F1, 0, False, LapFn)
Me.CreateSing(-f2, 0, False, LapFn)
Me.AddFn2Graph(CreateLaplaceAmplifier)
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(CreateLaplaceAmplifier)
GoV.Show = EGraphShowOne.Module
End Function
#End Region
#Region "Root Locus Demos"
Private Sub ToolStripMenuItemAmplifierWith3Poles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAmplifierWith3Poles.Click
Dim GoV As GraphOfVisorComplexS
Dim lapFn As LaplaceFunction
dontRun = True
Me.SetXRanges(10000000, 1)
Me.RLToolBar.CreateNewRootLocus()
'Amplificador
lapFn = Me.CreateLaplaceFunction("A", 100000) 'New LaplaceFunction
Me.CreateSing(-100, 0, False, lapFn)
Me.CreateSing(-1500, 0, False, lapFn)
Me.CreateSing(-4000, 0, False, lapFn)
'Me.CreateSing(-6000, 0, False)
Me.RLToolBar.LaplaceDirectObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
'beta
lapFn = Me.CreateLaplaceFunction("B", 0.01) 'New LaplaceFunction
Me.RLToolBar.LaplaceFeedbackObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
Me.RLToolBar.GetRootLocus()
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddFunction(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV = Me.AddFn2Graph(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV.Show = EGraphShowOne.Module
End If
Me.AddRootLocus(Me.RLToolBar.SelectedRootLocus)
Me.intVisor2CP.Add(Me.RLToolBar.SelectedRootLocus)
Dim srm As ScanResponseModifier
srm = Me.ParamToolBar.Add(lapFn)
srm.Alinearity = 2
srm.Range = New RangeF(0.000001, 1)
srm.Enable = True
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItemUnrealAmplifier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemUnrealAmplifier.Click
Dim GoV As GraphOfVisorComplexS
dontRun = True
Me.SetXRanges(10000000, 1)
Me.RLToolBar.CreateNewRootLocus()
Dim lapFn As LaplaceFunction
'Amplificador
lapFn = Me.CreateLaplaceFunction("A", 100000) 'New LaplaceFunction
Me.CreateSing(-100, 0, False, lapFn)
Me.CreateSing(-1500, 0, False, lapFn)
Me.CreateSing(500, 0, True, lapFn)
Me.CreateSing(-2500, 0, True, lapFn)
'Me.CreateConjugatedSings(40, 2000, True)
Me.RLToolBar.LaplaceDirectObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
'beta
lapFn = Me.CreateLaplaceFunction("B", 0.01) 'New LaplaceFunction
Me.RLToolBar.LaplaceFeedbackObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
Me.RLToolBar.GetRootLocus()
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddFunction(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV = Me.AddFn2Graph(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV.Show = EGraphShowOne.Module
End If
Me.AddRootLocus(Me.RLToolBar.SelectedRootLocus)
Me.intVisor2CP.Add(Me.RLToolBar.SelectedRootLocus)
Dim srm As ScanResponseModifier
srm = Me.ParamToolBar.Add(lapFn)
srm.Alinearity = 2
srm.Range = New RangeF(0.000001, 1)
srm.Enable = True
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItemAmplifierWith2Poles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemAmplifierWith2Poles.Click
Dim GoV As GraphOfVisorComplexS
Dim lapFn As LaplaceFunction
Dim sng As Singularity
dontRun = True
Me.SetXRanges(10000000, 1)
Me.RLToolBar.CreateNewRootLocus()
'Amplificador
lapFn = Me.CreateLaplaceFunction("A", 100000) 'New LaplaceFunction
sng = Me.CreateSing(-100, 0, False, lapFn)
'lapFn.Add(sng)
sng = Me.CreateSing(-4000, 0, False, lapFn)
'lapFn.Add(sng)
Me.RLToolBar.LaplaceDirectObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
'beta
lapFn = Me.CreateLaplaceFunction("B", 0.01) 'New LaplaceFunction
Me.RLToolBar.LaplaceFeedbackObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
Me.RLToolBar.GetRootLocus()
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddFunction(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV = Me.AddFn2Graph(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV.Show = EGraphShowOne.Module
End If
Me.AddRootLocus(Me.RLToolBar.SelectedRootLocus)
Me.intVisor2CP.Add(Me.RLToolBar.SelectedRootLocus)
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItemDerivador_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemDerivador.Click
Dim GoV As GraphOfVisorComplexS
Dim lapFn As LaplaceFunction
Dim sng As Singularity
dontRun = True
Me.SetXRanges(10000000, 1)
Me.RLToolBar.CreateNewRootLocus()
'Amplificador
lapFn = Me.CreateLaplaceFunction("A", 100000) 'New LaplaceFunction
lapFn.BriefDescription = "Direct Amplifier Function"
lapFn.Description = "Direct Amplifier function, Emuling like LM741 Amplifier "
sng = Me.CreateSing(-10, 0, False, lapFn)
Me.RLToolBar.LaplaceDirectObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
'beta
lapFn = Me.CreateLaplaceFunction("B", 0.01) 'New LaplaceFunction
lapFn.BriefDescription = "FeedBack Function"
lapFn.Description = "FeedBack Function for an Derivator Amplifier"
sng = Me.CreateSing(0, 0, False, lapFn)
Me.RLToolBar.LaplaceFeedbackObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
Me.RLToolBar.GetRootLocus()
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddFunction(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV = Me.AddFn2Graph(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV.Show = EGraphShowOne.Module
End If
Me.AddRootLocus(Me.RLToolBar.SelectedRootLocus)
Me.intVisor2CP.Add(Me.RLToolBar.SelectedRootLocus)
dontRun = False
Me.RefreshAll()
End Sub
Private Sub ToolStripMenuItemIntegrador_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemIntegrador.Click
Dim GoV As GraphOfVisorComplexS
Dim lapFn As LaplaceFunction
dontRun = True
Me.SetXRanges(10000000, 1)
Me.RLToolBar.CreateNewRootLocus()
'Amplificador
lapFn = Me.CreateLaplaceFunction("A", 100000) 'New LaplaceFunction
lapFn.BriefDescription = "Direct Amplifier Function"
lapFn.Description = "Direct Amplifier function, Emuling like LM741 Amplifier "
Me.CreateSing(-10, 0, False, lapFn)
Me.CreateSing(-5000000, 0, False, lapFn)
Me.RLToolBar.LaplaceDirectObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
'beta
lapFn = Me.CreateLaplaceFunction("B", 0.01) 'New LaplaceFunction
lapFn.BriefDescription = "FeedBack Function"
lapFn.Description = "FeedBack Function for an Integral Amplifier"
Me.CreateSing(0, 0, True, lapFn)
Me.RLToolBar.LaplaceFeedbackObject = lapFn
GoV = Me.AddFn2Graph(lapFn)
GoV.Show = EGraphShowOne.Module
Me.RLToolBar.SelectedRootLocus.FindingArea = Me.intVisor2CP.VisorArea
Me.RLToolBar.GetRootLocus()
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddFunction(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV = Me.AddFn2Graph(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject)
GoV.Show = EGraphShowOne.Module
End If
Me.AddRootLocus(Me.RLToolBar.SelectedRootLocus)
Me.intVisor2CP.Add(Me.RLToolBar.SelectedRootLocus)
dontRun = False
Me.RefreshAll()
End Sub
#End Region
#Region "Linear Demos"
Private Sub ToolStripMenuItemCosineFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemCosineFunction.Click
'if Me.intVisorM.XRange.Max
Me.SetXRanges(10, -1)
Dim Expresion As String
Dim fn As [Function]
' Expresion = "2E-05*sin(14*0,3141593*z)-6E-05*cos(10*0,3141593*z)"
Expresion = "cos(1,7153*x)"
fn = Me.CreateFunction(Expresion)
fn.Description = "This represent a simple Cosine function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub ToolStripMenuItemExponentialDecrecientFunc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemExponentialDecrecientFunct.Click
Me.SetXRanges(10, -1)
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "10*e^(-0,5*x)*sin(x)"
fn.Description = "This represent a Sine exponencial decrecient function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub ToolStripMenuItemStepFunctionAsX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemStepFunctionAsX2.Click
Me.SetXRanges(10, -1)
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "esc(x-2)"
fn.Description = "This represent a simple step function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub RampFunctionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RampFunctionToolStripMenuItem.Click
Me.SetXRanges(10, -1)
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "ram(x)"
fn.Description = "This represent a ramp function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub ParabolicFunctionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemParabolicFunction2.Click
Me.SetXRanges(10, -10)
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "0.1*z^2+z-10"
fn.Description = "This represent Parabolic function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
#End Region
#Region "Linear Parametric Demos"
Private Sub ToolStripMenuItemParabolicFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemParabolicFunction.Click
Me.SetXRanges(10, -10)
Dim Pr As Parameter
Pr = Me.CreateParameter()
Dim SPM As ScanResponseModifier
SPM = Me.AddParameterForControl(Pr)
SPM.Enable = True
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "0.1*z^2+z+" & Pr.Name & "-10"
fn.Description = "This represent Parabolic function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub ToolStripMenuItemOrder5PolinomicFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemOrder5PolinomicFunction.Click
Me.SetXRanges(10, -10)
Dim Pr As Parameter
Pr = Me.CreateParameter()
Dim SPM As ScanResponseModifier
SPM = Me.AddParameterForControl(Pr)
SPM.Enable = True
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "0.0001*z^5+0.001*z^3+0.1*x^2+" & Pr.Name & "-10"
fn.Description = "This represent Parabolic function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
End Sub
Private Sub ToolStripMenuItemVariableWidthPulse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemVariableWidthPulse.Click
Me.SetXRanges(10, -10)
Dim Pr As Parameter
Dim Fn As [Function]
Pr = Me.CreateParameter()
Pr.Real = 2
Dim SPM As ScanResponseModifier
SPM = Me.AddParameterForControl(Pr)
SPM.Enable = True
Me.ParamToolBar.Scanner.ScannerProperties.Range = New RangeF(0.1, 4)
Me.ParamToolBar.Scanner.ScannerProperties.NumberOfPoints = 20
'SPM.Range = New RangeF(0.1, 4)
Me.SplitGraph(True)
Fn = Me.CreateFunction()
Fn.Parts(0).Expresion = "pul(z/" & Pr.Name & ")"
Fn.Description = "This represent Variable width Pulse function"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(Fn)
GoV.Show = EGraphShowOne.Real
Me.FFTToolBar.Visor = Me.intVisorP
Me.intVisorP.XRange = New RangeF(-1, 64)
Me.FFTToolBar.Add(Me.htblfnSysC.Item(Fn))
End Sub
Private Sub ToolStripMenuItemRLCResonantCircuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemRLCResonantCircuit.Click
'Me.SetXRanges(10000000, 1)
Me.SetXRanges(0.002, 0)
Dim Pr As Parameter
Dim fn, sigma, Wo2, S1, S2, Vt, A, B, D As [Function]
Dim SPM As ScanResponseModifier
Dim desc As String
Pr = Me.CreateParameter("L")
Pr.Real = 0.001
Pr = Me.CreateParameter("C")
Pr.Real = 0.000001
Pr = Me.CreateParameter("R")
Pr.Real = 100
SPM = Me.AddParameterForControl(Pr)
SPM.Enable = True
Me.ParamToolBar.Scanner.ScannerProperties.Range = New RangeF(0.1, 1000)
Me.ParamToolBar.Scanner.ScannerProperties.NumberOfPoints = 40
'SPM.Range = New RangeF(0.1, 4)
'en el plano complejo
desc = "RLC Resonant Circuit." & ControlChars.NewLine _
& "" & ControlChars.NewLine _
& ""
fn = Me.CreateFunction("R/(R*L*C*z^2+L*z+R)", "RLCinPlain", desc)
'fn.Parts(0).Expresion = "(R*L*2*pi*j*x)/(R+2*pi*j*x*L)-1/(2*pi*j*x*C)"
'fn.Parts(0).Expresion = "R/(R*L*C*z^2+L*z+R)"
Me.intD3DManager.BeginUpdate()
' Me.intD3DManager.AnalisysArea = New Areaf(200, -200, 200, -200)
Me.intD3DManager.ComplexValueShowed = ComplexTarget.Real
Me.Show3DSelectedFunction(fn)
Me.intD3DManager.EndUpdate()
'sigma
desc = ""
sigma = Me.CreateFunction("1/(2*R*C)", "sigma", desc)
'Wo^2
Wo2 = Me.CreateFunction("1/(L*C)", "Wo2", "")
'valor del polo
S1 = Me.CreateFunction("-" & sigma.Name & "+sqr(sigma^2-" & Wo2.Name & ")", "S1", "")
S2 = Me.CreateFunction("-" & sigma.Name & "-sqr(sigma^2-" & Wo2.Name & ")", "S2", "")
'cos coeficientes de V(t)
A = Me.CreateFunction("1/(L*C*" & S1.Name & "*" & S2.Name & ")", "A", "")
B = Me.CreateFunction("1/(L*C*" & S1.Name & "*(" & S1.Name & "-" & S2.Name & ")" & ")", "B", "")
D = Me.CreateFunction("1/(L*C*" & S2.Name & "*(" & S2.Name & "-" & S1.Name & ")" & ")", "D", "")
'respuesta temporal
Vt = Me.CreateFunction(A.Name & "+" & _
B.Name & "*e^(-" & S1.Name & "*z)" & "+" & _
D.Name & "*e^(" & S2.Name & "*z)", "Vt", "")
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(Vt)
GoV.Show = EGraphShowOne.Real
End Sub
#End Region
#Region "Linear Parametric 3D Demos"
Private Sub ToolStripMenuItemSincWaves_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSincWaves.Click
Me.SetXRanges(10, -10)
Dim Pr As Parameter
Pr = Me.CreateParameter()
Dim SPM As ScanResponseModifier
SPM = Me.AddParameterForControl(Pr)
SPM.Enable = True
Dim fn As [Function]
fn = Me.CreateFunction()
fn.Parts(0).Expresion = "sinc(mod(z+" & Pr.Name & "))+sinc(mod(z-" & Pr.Name & "+20))"
fn.Description = "This represent two 3D Sinc functions ovelapping it's self"
Dim GoV As GraphOfVisorComplexS
GoV = Me.AddFn2Graph(fn)
GoV.Show = EGraphShowOne.Real
Me.intD3DManager.BeginUpdate()
Me.intD3DManager.ComplexValueShowed = ComplexTarget.Real
Me.Show3DSelectedFunction(fn)
End Sub
#End Region
#Region "Accesory Methods"
Sub DisableRemoveButtons()
Me.ToolStripButtonShowExpresionEditor.Enabled = False
Me.ToolStripMenuItemRemoveFunction.Enabled = False
Me.RemoveLaplaceFunctionToolStripMenuItem.Enabled = False
Me.RemoveParameterToolStripMenuItem.Enabled = False
Me.RemoveGraphToolStripMenuItem.Enabled = False
Me.ToolStripMenuItemRemoveSings.Enabled = False
'Me.ClearFunctionToolStripMenuItem.Enabled = False
'Me.ClearSingsToolStripMenuItem.Enabled = False
Me.ToolStripButtonShow3D.Enabled = False
End Sub
Sub SplitGraph(ByVal Split As Boolean)
Me.ToolStripButtonSplitGraph.Checked = Split
Me.SplitGraph()
End Sub
Sub SplitGraph()
If Not Me.ToolStripButtonSplitGraph.Checked Then
Me.SplitContainerViewerSplit.Hide()
ChangeTabPosition(Me.TabControlMain, Me.TabControlViewer, Me.TabPageCP)
AddTabPage(TabControlViewer, TabPagePhase)
Me.intVisorM.RenderControl = Me.VisorCtlMod1
Me.intVisorP.RenderControl = Me.VisorCtlPH1 'Me.TabPagePhase '
Me.ToolStripButtonSplitGraph.Image = New Bitmap([GetType], "Tabs.bmp")
Me.ToolStripButtonSplitGraph.ToolTipText = "Change to Tab mode - Separated Graphs"
Else
Me.SplitContainerViewerSplit.Show()
ChangeTabPosition(TabControlViewer, Me.TabControlMain, Me.TabPageCP)
RemoveTabPage(TabControlViewer, Me.TabPagePhase)
Me.intVisorM.RenderControl = Me.VisorCtlMod2 'Me.SplitContainerViewerSplit.Panel1
Me.intVisorP.RenderControl = Me.VisorCtlPH2 'Me.SplitContainerViewerSplit.Panel2
Me.ToolStripButtonSplitGraph.Image = New Bitmap([GetType], "Tiled.bmp")
Me.ToolStripButtonSplitGraph.ToolTipText = "Change to Mixed mode - Multi Graphs"
End If
End Sub
#End Region
#Region "Selection Methods"
Sub SelectItm(ByVal sender As Object, ByVal Parent As Object)
DisableRemoveButtons()
'Me.RemoveFunctionToolStripMenuItem.Enabled = False
Try
If TypeOf sender Is Visor2DGoV Then
Me.ListViewSubItems.Clear()
For Each GoV As GraphOfVisorSimple In CType(sender, Visor2DGoV).ArrGraphs
Me.AddListViewItem(GoV.Name, GoV, 0)
Next
Me.selectedObj = sender
If Not sender Is Me.intVisor2CP Then
Me.ZoomToolBar.Visor = sender
Me.CursorToolBar.Visor = sender
End If
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is FrameAxisProperties Then
Me.selectedObj = sender
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is Singularity Then
Me.selectedObj = sender
Me.RLToolBar.SelectedSingularity = sender
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = sender
Me.ToolStripMenuItemRemoveSings.Enabled = True
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is FunctionBase Then
'Para las funciones en general
If TypeOf sender Is LaplaceFunction Then
SelectLaplaceFunction(sender, True)
Me.ToolStripButtonShow3D.Enabled = True
ElseIf TypeOf sender Is [Function] Then
Me.ToolStripButtonShowExpresionEditor.Enabled = True
If FnProp Is Nothing Then
FnProp = New FunctionPropertiesDescriptor(sender)
End If
FnProp.SelectedFunction = sender
If Me.htblfnSysC.ContainsKey(sender) Then
Me.FFTToolBar.SelectedSystem = Me.htblfnSysC.Item(sender)
End If
Me.FFTToolBar.SelectedFunction = sender
If FRToolBar IsNot Nothing Then
Me.FRToolBar.TemporalSelectedCalcObject = sender
End If
Me.ToolStripMenuItemRemoveFunction.Enabled = True
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
Me.PropertyGrid1.SelectedObject = FnProp
End If
If Me.htblfnGoV.ContainsKey(sender) Then
Me.CursorToolBar.SelectedGoV = Me.htblfnGoV.Item(sender)
End If
Me.selectedObj = sender
Me.Fn = sender
'Me.Selected3Dfn = sender
Me.ToolStripButtonShow3D.Enabled = True
ElseIf TypeOf sender Is Parameter Then
Me.selectedObj = sender
Me.Pr = sender
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = sender
ElseIf TypeOf sender Is GraphOfVisorSimple Then
Me.selectedObj = sender
Me.CursorToolBar.SelectedGoV = sender
PropertyGrid1.SelectedObject = sender
Me.RemoveGraphToolStripMenuItem.Enabled = True
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is LinearSingleScanner Then
If SCProp Is Nothing Then
SCProp = New ScannerPropertiesDescriptor(Me.MainScanner)
AddHandler SCProp.Change, AddressOf OnScannerChange
End If
PropertyGrid1.SelectedObject = SCProp
Me.ToolStripMenuItemRemoveSings.Enabled = True
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is ScanResponseModifier Then
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is ComplexMultiScanner Then
If Me.ParamToolBar.Scanner.Count > 0 Then
For Each srm As ScanResponseModifier In Me.ParamToolBar.Scanner.Items
'Me.ListViewSubItems.Items.Add(s.Target.Name & " Controller", 4)
If Me.htblObjNode.ContainsKey(srm.Target) Then
Dim o As TreeNode
o = Me.htblObjNode.Item(srm.Target)
Me.AddListViewItem(srm.Target.Name & " Controller", srm, o.SelectedImageIndex)
Else
Me.AddListViewItem(srm.Target.Name & " Controller", srm, 9)
End If
Next
End If
If ScProp2 Is Nothing Then
ScProp2 = New ScannerPropertiesDescriptorBase(Me.ParamToolBar.Scanner.ScannerProperties)
End If
Me.PropertyGrid1.SelectedObject = ScProp2
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf sender Is Me.CursorToolBar Then
PropertyGrid1.SelectedObject = Me.CursorToolBar.CursorProperties
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is CursorBase Then
PropertyGrid1.SelectedObject = sender
Me.ParamToolBar.SelectedParameter = Nothing
Me.RLToolBar.LaplaceSelectedObject = Nothing
ElseIf TypeOf sender Is RootLocusBase Then
PropertyGrid1.SelectedObject = sender
Me.RLToolBar.SelectedRootLocus = sender
Me.AddListViewItem(Me.RLToolBar.LaplaceDirectObject.Name, Me.RLToolBar.LaplaceDirectObject, 2)
Me.AddListViewItem(Me.RLToolBar.LaplaceFeedbackObject.Name, Me.RLToolBar.LaplaceFeedbackObject, 2)
If Not Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject Is Nothing Then
Me.AddListViewItem(Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject.Name, Me.RLToolBar.SelectedRootLocus.LaplaceGlobalFeedBackedObject, 2)
End If
ElseIf TypeOf sender Is ID3DManagable Then
Me.PropertyGrid1.SelectedObject = sender
ElseIf TypeOf sender Is FullD3DControl2 Then
Me.PropertyGrid1.SelectedObject = sender
ElseIf sender Is Me.FRToolBar.RootFinderObject Then
Me.PropertyGrid1.SelectedObject = Me.FRToolBar.RootFinderObject
ElseIf TypeOf sender Is SpectrumContainer Then
Me.PropertyGrid1.SelectedObject = sender
Else
Stop
Exit Sub
End If
Catch ex As Exception
Stop
End Try
End Sub
Private Sub SelectLaplaceFunction(ByVal LapFn As LaplaceFunction, ByVal ShowSingulaties As Boolean)
If ShowSingulaties Then
If LapFn.SingCount > 0 Then
For Each s As Singularity In LapFn.Singularities
If s.SingularitieType = SingType.Polo Then
If s.IsConjugated Then
Me.AddListViewItem(s.Name, s, 8)
Else
Me.AddListViewItem(s.Name, s, 6)
End If
Else
If s.IsConjugated Then
Me.AddListViewItem(s.Name, s, 9)
Else
Me.AddListViewItem(s.Name, s, 7)
End If
End If
Next
End If
End If
'Me.selectedObj = LapFn
'Me.Selected3Dfn = LapFn
'Me.Fn = LapFn
'If Me.htblfnGoV.ContainsKey(LapFn) Then
' Me.CursorToolBar.SelectedGoV = Me.htblfnGoV.Item(LapFn)
'End If
PropertyGrid1.SelectedObject = LapFn
Me.RLToolBar.LaplaceSelectedObject = LapFn
Me.ToolStripButtonShow3D.Enabled = True
Me.ParamToolBar.SelectedParameter = LapFn
Me.RemoveLaplaceFunctionToolStripMenuItem.Enabled = True
End Sub
Sub onSelectItm(ByVal sender As Object, ByVal e As EventArgs)
Me.TreeViewItems.SelectedNode = Nothing
Me.ListViewSubItems.SelectedItems.Clear()
Me.SelectItm(sender, sender)
End Sub
#End Region
#Region "OnChange Capture Methods"
Private Sub OnFunctionChange(ByVal sender As Object, ByVal e As EventArgs)
If Me.ToolStripButtonAutoRefresh2D.Checked = False Then
Exit Sub
End If
If dontRun Then
Exit Sub
End If
If Not TypeOf sender Is FunctionBase Then
Stop
Exit Sub
End If
If Not Me.htblfnGoV.ContainsKey(sender) Then
Exit Sub
End If
If TypeOf sender Is LaplaceFunction Then
LapFn = sender
ElseIf TypeOf sender Is [Function] Then
Me.Fn = sender
Else
If Not LapFn.Contains(sender) Then
Stop
End If
End If
Dim GoV As GraphOfVisorSimple
GoV = Me.htblfnGoV.Item(sender)
If GoV Is Nothing Then
Stop
MessageManager.Send(Me, New MessageEventArgs("Un error ocurrio al recuperar el GoV", _
MessageEventArgs.EMessageType.[Error]))
Exit Sub
End If
SystemCalc = GoV.BindedObject
Me.SystemCalc.Storage()
If sender Is Me.Selected3Dfn Then
Me.Refresh3DGraph()
End If
End Sub
Private Sub OnNameChange(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim TN As TreeNode
If TypeOf sender Is FunctionBase Then
If TypeOf sender Is LaplaceFunction Then
LapFn = sender
Else
Me.Fn = sender
End If
ElseIf TypeOf sender Is Parameter Then
Pr = sender
Else
Exit Sub
End If
If Not Me.htblObjNode.ContainsKey(sender) Then
Stop
Exit Sub
End If
TN = Me.htblObjNode.Item(sender)
TN.Text = CType(sender, ParameterBase).Name
End Sub
Private Sub OnScannerChange(ByVal sender As Object, ByVal e As EventArgs)
Me.intVisorM.XRange = Me.MainScanner.Range
Me.intVisorP.XRange = Me.MainScanner.Range
Me.RefreshAll()
End Sub
Sub OnParamAdded(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParamToolBar.ParamAdded
If Me.ParamToolBar.SelectedParameter Is Nothing Then
Stop
Exit Sub
End If
Me.AddSubNode(Me.tnParamsControlled, Me.ParamToolBar.SelectedParameter.Name, Me.ParamToolBar.SelectedParameter, 5)
'MoveNode(Me.ParamToolBar.SelectedParameter.Name, Me.tnParamsControlled)
End Sub
Sub OnParamRemoved(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParamToolBar.ParamRemoved
If Me.ParamToolBar.SelectedParameter Is Nothing Then
Stop
Exit Sub
End If
RemoveControledNode(Me.ParamToolBar.SelectedParameter.Name, Me.tnParamsControlled)
'Me.AddSubNode(Me.tParams, Me.ParamToolBar.SelectedParameter, Me.ParamToolBar.SelectedParameter.Name, 5)
End Sub
Sub OnCursorAdded(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CursorToolBar.CursorAdded
For Each cur As Cursor In Me.CursorToolBar.Cursors
If Not Me.htblObjNode.ContainsKey(cur) Then
Me.AddSubNode(Me.tnCursors, cur, cur.Name, 5)
End If
Next
End Sub
'Private Sub OnPlaneComplexScaleChange(ByVal sender As Object, ByVal e As EventArgs)
' For Each RL As RootLocusBase In Me.RLToolBar.RootLocuses
' RL.FindingArea = Me.intVisor2CP.VisorArea
' RL.CalcRootLocus()
' Next
'End Sub
'Private Sub OnCursorRemoved(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CursorToolBar.CursorRemoved
'End Sub
'Private Sub On3DVisor_LimitsChange(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Me.Disable3DLimitChange = True
' Me.ToolStripComboBox3DLimits.Text = Me.intD3DManager.AnalisysArea.ToString
' Refresh3DGraph()
' Me.Disable3DLimitChange = False
'End Sub
Private Sub On3DVisor_change(ByVal sender As System.Object, ByVal e As System.EventArgs)
Refresh3DGraph()
End Sub
#End Region
#Region "3D region"
Private Sub Show3DSelectedFunction(ByVal Selected3Dfn As FunctionBase)
If intD3DManager Is Nothing Then
'intD3DManager = New Form1
OnMessageReicived(Me, New ggCoreLib.MessageEventArgs("El entorno 3D no esta disponible", MessageEventArgs.EMessageType.Error))
Exit Sub
End If
If Me.Selected3Dfn Is Nothing AndAlso Not Selected3Dfn Is Nothing Then
Me.Selected3Dfn = Selected3Dfn
AddHandler Selected3Dfn.DataChange, AddressOf ToolStripButtonShow3D_Click
ElseIf Selected3Dfn Is Me.Selected3Dfn Then
'no hago nada
ElseIf Not Selected3Dfn Is Me.selectedObj Then
RemoveHandler Selected3Dfn.DataChange, AddressOf ToolStripButtonShow3D_Click
Selected3Dfn = Me.selectedObj
AddHandler Selected3Dfn.DataChange, AddressOf ToolStripButtonShow3D_Click
End If
Refresh3DGraph()
End Sub
Private Sub Show3DSelectedFunction()
If Not Selected3Dfn Is Nothing Then
Show3DSelectedFunction(Me.Selected3Dfn)
ElseIf TypeOf Me.selectedObj Is FunctionBase Then
Show3DSelectedFunction(Me.selectedObj)
ElseIf TypeOf Me.Fn Is FunctionBase Then
Show3DSelectedFunction(Me.Fn)
Else
OnMessageReicived(Me, New ggCoreLib.MessageEventArgs("Debe seleccionar antes una funci�n", MessageEventArgs.EMessageType.Error))
End If
End Sub
'Private Sub Refresh3DGraph(ByVal Arr(,) As ComplexUndefinied)
' Dim i, j, M, N As Integer
' M = Arr.GetUpperBound(0)
' N = Arr.GetUpperBound(1)
' Me.FullD3DControl1.d3dObj.NumberOfPoints = M
' Me.intD3DManager.BeginUpdate()
' For i = 0 To M
' For j = 0 To N
' Me.intD3DManager.SetComplexPlainValue(Arr(i, j), i, j)
' Next
' Next
' Me.intD3DManager.EndUpdate()
'End Sub
'Private Sub Refresh3DGraph(ByVal Arr(,) As ComplexPolar)
' Dim i, j, M, N As Integer
' M = Arr.GetUpperBound(0)
' N = Arr.GetUpperBound(1)
' Me.FullD3DControl1.d3dObj.NumberOfPoints = M
' Me.intD3DManager.BeginUpdate()
' For i = 0 To M
' For j = 0 To N
' Me.intD3DManager.SetComplexPlainValue(New ComplexUndefinied(Arr(i, j)), i, j)
' Next
' Next
' Me.intD3DManager.EndUpdate()
'End Sub
Private Sub Refresh3DGraph()
If Me.Selected3Dfn Is Nothing Then
Exit Sub
End If
Dim i, j, M, N As Integer
Dim X, Y As RangeF
Dim pX, pY As Double
X = Me.intD3DManager.AnalisysArea.XRange
Y = Me.intD3DManager.AnalisysArea.YRange
M = Me.intD3DManager.ComplexPlainMatrix.GetUpperBound(0)
N = Me.intD3DManager.ComplexPlainMatrix.GetUpperBound(1)
pX = X.dx / M
pY = Y.dx / N
Me.intD3DManager.BeginUpdate()
For i = 0 To M
For j = 0 To N
Me.intD3DManager.SetComplexPlainValue(Selected3Dfn.Calc(New ComplexUndefinied(i * pX + X.Min, j * pY + Y.Min)), i, j)
Next
Next
Me.intD3DManager.EndUpdate()
End Sub
#End Region
#Region "3D region Capture Buttons Methods"
Private Delegate Sub simpleDelegate()
Dim DelPtr As simpleDelegate
Private Sub ToolStripButtonShow3D_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonShow3D.Click
If Me.Fn Is Nothing Then
Exit Sub
End If
If Me.InvokeRequired Then
DelPtr = New simpleDelegate(AddressOf Show3DSelectedFunction)
Me.BeginInvoke(DelPtr)
Else
Show3DSelectedFunction()
End If
End Sub
Private Sub ToolStripButtonRefreshEnable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonRefreshEnable.Click
If Selected3Dfn Is Nothing Then
Exit Sub
End If
If ToolStripButtonRefreshEnable.Checked Then
AddHandler Selected3Dfn.DataChange, AddressOf ToolStripButtonShow3D_Click
Else
RemoveHandler Selected3Dfn.DataChange, AddressOf ToolStripButtonShow3D_Click
End If
End Sub
Private Sub ToolStripButtonAdjustAnalisys_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonAdjustAnalisys.Click
If Me.intVisorM.GraphCount = 0 Then
Exit Sub
End If
Dim SC As AutoSystemCalc
Dim gov As GraphOfVisorSimple
For Each fn As FunctionBase In Me.htblfnGoV.Keys
gov = Me.htblfnGoV.Item(fn)
If Me.intVisorM.Contains(gov) Then
SC = Me.htblfnSysC.Item(fn)
SC.Scanner.Range = Me.intVisorM.XRange
SC.Storage()
End If
Next
Me.intVisorM.Refresh()
End Sub
Private Sub FullD3DControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FullD3DControl1.Click
If Me.intD3DManager Is Nothing Then
Exit Sub
End If
Me.PropertyGrid1.SelectedObject = Me.intD3DManager
Me.selectedObj = Me.intD3DManager
End Sub
Dim Disable3DLimitChange As Boolean
Private Sub ToolStripComboBox3DLimits_TextChanged(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles ToolStripComboBox3DLimits.KeyDown
If e.KeyCode <> Keys.Enter Then
Exit Sub
End If
If Me.ToolStripComboBox3DLimits.Text = "" OrElse Disable3DLimitChange Then
Exit Sub
End If
Try
Dim d As Double
Dim r As RangeF
d = Math.BVStrMath.DecodeMultiplos(Me.ToolStripComboBox3DLimits.Text)
If Math.BVStrMath.Error = False Then
r = New RangeF(d, -d)
Me.intD3DManager.AnalisysArea = New Areaf(r, r)
Me.ToolStripComboBox3DLimits.Text = r.Max.ToString
Exit Try
End If
If r.Parse(Me.ToolStripComboBox3DLimits.Text) Then
Me.intD3DManager.AnalisysArea = New Areaf(r, r)
Exit Try
End If
Dim a As Areaf
If a.Parse(Me.ToolStripComboBox3DLimits.Text) Then
Me.intD3DManager.AnalisysArea = a
Exit Try
End If
Catch ex As Exception
MessageManager.Send(Me, New MessageEventArgs("Hubo un error al procesar la expresi�n: " & Me.ToolStripComboBox3DLimits.Text))
Me.ToolStripComboBox3DLimits.Text = ""
End Try
End Sub
Private Sub ToolStripButtonLimit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ToolStripButtonLimitDown.Click, _
ToolStripButtonLimitUp.Click
If Me.ToolStripComboBox3DLimits.Text = "" Then
Exit Sub
End If
Dim Increment As Boolean
Increment = (sender Is Me.ToolStripButtonLimitUp)
Try
Dim d As Double
Dim r As RangeF
d = Math.BVStrMath.DecodeMultiplos(Me.ToolStripComboBox3DLimits.Text)
If Math.BVStrMath.Error = False Then
r.Max = Math.BVMathFunctions.ChangeValueLog(d, Increment)
r.Min = Math.BVMathFunctions.ChangeValueLog(-d, Increment)
Me.intD3DManager.AnalisysArea = New Areaf(r, r)
Me.ToolStripComboBox3DLimits.Text = r.Max.ToString
Exit Try
End If
If r.Parse(Me.ToolStripComboBox3DLimits.Text) Then
r.Max = Math.BVMathFunctions.ChangeValueLog(r.Max, Increment)
r.Min = Math.BVMathFunctions.ChangeValueLog(r.Min, Increment)
Me.intD3DManager.AnalisysArea = New Areaf(r, r)
Me.ToolStripComboBox3DLimits.Text = r.ToString
Exit Try
End If
Dim a As Areaf
If a.Parse(Me.ToolStripComboBox3DLimits.Text) Then
a.XMax = Math.BVMathFunctions.ChangeValueLog(a.XMax, Increment)
a.XMin = Math.BVMathFunctions.ChangeValueLog(a.XMin, Increment)
a.YMax = Math.BVMathFunctions.ChangeValueLog(a.YMax, Increment)
a.YMin = Math.BVMathFunctions.ChangeValueLog(a.YMin, Increment)
Me.intD3DManager.AnalisysArea = a
Me.ToolStripComboBox3DLimits.Text = a.ToString
Exit Try
End If
Catch ex As Exception
MessageManager.Send(Me, New MessageEventArgs("Hubo un error al procesar la expresi�n: " & Me.ToolStripComboBox3DLimits.Text))
Me.ToolStripComboBox3DLimits.Text = ""
End Try
End Sub
#End Region
#Region "Main Method"
Public Shared Function Main() As Integer
If UseDirectX Then
'uso DX
System.Windows.Forms.Application.EnableVisualStyles()
#If (Debug) Then
Using frameWork As New Framework()
Dim FrmD3DWindowedInControl As New FormBodeViewer(frameWork)
frameWork.SetCursorSettings(True, True)
' Initialize
' Pass control to the sample framework for handling the message pump and
' dispatching render calls. The sample framework will call your FrameMove
' and FrameRender callback when there is idle time between handling window messages.
FrmD3DWindowedInControl.Show()
frameWork.MainLoop()
' Perform any application-level cleanup here. Direct3D device resources are released within the
' appropriate callback functions and therefore don't require any cleanup code here.
Return frameWork.ExitCode
End Using
#Else
Try
' Show the cursor and clip it when in full screen
frameWork.SetCursorSettings(True, True)
' Initialize
' Pass control to the sample framework for handling the message pump and
' dispatching render calls. The sample framework will call your FrameMove
' and FrameRender callback when there is idle time between handling window messages.
FrmD3DWindowedInControl.Show()
frameWork.MainLoop()
Catch
' In release mode fail silently
' Ignore any exceptions here, they would have been handled by other areas
If frameWork.ExitCode = 0 Then
Return 1
End If
' Return an error code here
Return frameWork.ExitCode
End Try
#End If
Else
Dim FrmD3DWindowedInControl As New FormBodeViewer()
System.Windows.Forms.Application.Run(FrmD3DWindowedInControl)
End If
End Function
' Public Shared Function Main() As Integer
' If UseDirectX Then
' Try
' 'uso DX
' System.Windows.Forms.Application.EnableVisualStyles()
' Using frameWork As New Framework()
' Dim FrmD3DWindowedInControl As New FormBodeViewer(frameWork)
' Try
' ' Show the cursor and clip it when in full screen
' frameWork.SetCursorSettings(True, True)
' ' Initialize
' ' Pass control to the sample framework for handling the message pump and
' ' dispatching render calls. The sample framework will call your FrameMove
' ' and FrameRender callback when there is idle time between handling window messages.
' FrmD3DWindowedInControl.Show()
' frameWork.MainLoop()
' Catch e As Exception
'#If (Debug) Then
' 'In debug mode show this error (maybe - depending on settings)
' frameWork.DisplayErrorMessage(e)
'#Else
' Catch
' ' In release mode fail silently
'#End If
' ' Ignore any exceptions here, they would have been handled by other areas
' If frameWork.ExitCode = 0 Then
' Return 1
' End If
' ' Return an error code here
' Return frameWork.ExitCode
' End Try
' ' Perform any application-level cleanup here. Direct3D device resources are released within the
' ' appropriate callback functions and therefore don't require any cleanup code here.
' Return frameWork.ExitCode
' End Using
' Catch ex As Exception
' Stop
' End Try
' Else
' Dim FrmD3DWindowedInControl As New FormBodeViewer()
' System.Windows.Forms.Application.Run(FrmD3DWindowedInControl)
' End If
' End Function
#End Region
#Region "About"
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Static frmAbout As FrmAbout
If frmAbout Is Nothing Then
frmAbout = New FrmAbout
End If
frmAbout.Show()
End Sub
#End Region
#Region "FullScreen Region"
Sub OnFullScreenClose(ByVal sender As System.Object, ByVal e As FormClosingEventArgs) Handles intFormFullScreen.FormClosing
TabPage3DGraph.Controls.Add(Me.FullD3DControl1)
End Sub
Private Sub ToolStripMenuItemFullScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemX4.Click _
, ToolStripMenuItemX2.Click _
, ToolStripMenuItemX1.Click '_
', ToolStripButtonFullScreen.Click
If sender Is Me.ToolStripMenuItemX1 Then
Me.FullScreen(1)
ElseIf sender Is Me.ToolStripMenuItemX2 Then
Me.FullScreen(2)
ElseIf sender Is Me.ToolStripMenuItemX4 Then
Me.FullScreen(4)
Else
Me.FullScreen()
End If
End Sub
Sub FullScreen()
intFormFullScreen.HideEnable = True
intFormFullScreen.Controls.Add(Me.FullD3DControl1)
intFormFullScreen.ShowFullScreen()
End Sub
Sub FullScreen(ByVal size As Integer)
intFormFullScreen.HideEnable = True
intFormFullScreen.Controls.Add(Me.FullD3DControl1)
intFormFullScreen.ShowFullScreen(New Size(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width * size, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height * size))
End Sub
Sub FullScreen(ByVal size As Size)
intFormFullScreen.HideEnable = True
intFormFullScreen.Controls.Add(Me.FullD3DControl1)
intFormFullScreen.ShowFullScreen(size)
End Sub
#End Region
Private Sub OnParamChanged(ByVal sender As Object, ByVal e As CollectionChangedEventArgs)
If TypeOf e.ObjectChanged Is FunctionBase Then
'funcion
'me.
Else
'parametro
End If
'Dim cbItm As ComboItemBase
'For Each BUF As BuitlInFunctionContainer In Parser.BuiltInFunctions
' cbItm.Add(BUF.Name, BUF)
'Next
'cbItm = FormPropertyEditorUI.Editor.Item("")
'agrego los funciones matematicas agregadas
'cbItm = New ComboItemBase("User Functions")
'For Each Fn As FunctionBase In Parser.KnownFuntions
' cbItm.Add(Fn.Name, Fn)
'Next
If e.Operation = CollectionChangedEventArgs.OperationTypes.Added Then
cbItmMathFn.Add(CType(e.ObjectChanged, INameable)) 'ctype(sender,FunctionBase).
'FormPropertyEditorUI.Editor.AddItem( cbItmMathFn)
ElseIf e.Operation = CollectionChangedEventArgs.OperationTypes.Removed Then
cbItmMathFn.Remove(CType(e.ObjectChanged, INameable).Name) 'ctype(sender,FunctionBase).
End If
End Sub
Private Sub btnClearLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearLog.Click
Me.TextBoxLog.Text = ""
End Sub
Private Sub ToolStripMenuItemListAvailableFunctions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemListAvailableFunctions.Click
For Each fn As BuitlInFunctionContainer In Parser.BuiltInFunctions
Me.Log(fn.FunctionName & " - " & fn.FunctionDescription)
Next
Me.TabPageInfo.Select()
End Sub
Private Sub ToolStripMenuItemSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemSave.Click
' SaveBin()
End Sub
'Dim FileName As String = "D:\test.bvd" 'bode viewer Data
'Private Sub SaveBin()
' Dim Buff() As Byte
' For Each fn As FunctionBase In Me.htblfnGoV.Keys
' Buff = SerializableBlock.Serialize(fn)
' Next
' If Buff Is Nothing OrElse Buff.Length = 0 Then
' Exit Sub
' End If
' My.Computer.FileSystem.WriteAllBytes(FileName, Buff, False)
'End Sub
Private Sub saveXml()
'Dim Ser As New Globe.Xml.Serialization.Serializer
'Ser.Serialize("D:\test.xml", Me.htblfnGoV.Keys)
If File.Exists("D:\test.xml") Then
File.Delete("D:\test.xml")
End If
Dim writer As XmlSerializer
Dim filew As New StreamWriter("D:\test.xml")
'For Each p As ParameterBase In Me.ParamToolBar.pa
' writer = New XmlSerializer(Fn.GetType)
' writer.Serialize(filew, Fn)
'Next
For Each fn As FunctionBase In Me.htblfnGoV.Keys
writer = New XmlSerializer(fn.GetType)
writer.Serialize(filew, fn)
Next
filew.Close()
End Sub
Private Sub ToolStripButtonShowExpresionEditor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonShowExpresionEditor.Click
If Me.FnProp Is Nothing Then
Stop
Exit Sub
End If
FormPropertyEditorUI.Editor.Value = Me.FnProp.Expresion
AddHandler FormPropertyEditorUI.Editor.VisibleChanged, AddressOf OnFormExpresionHide
FormPropertyEditorUI.Editor.ShowDialog()
End Sub
Public Sub OnFormExpresionHide(ByVal sender As Object, ByVal e As EventArgs)
If FormPropertyEditorUI.Editor.Visible Then
Exit Sub
End If
RemoveHandler FormPropertyEditorUI.Editor.VisibleChanged, AddressOf OnFormExpresionHide
If Me.FnProp Is Nothing Then
Stop
Exit Sub
End If
If FormPropertyEditorUI.Editor.IsCanceled = False Then
Me.FnProp.Expresion = FormPropertyEditorUI.Editor.Value
End If
End Sub
Private Sub ToolStripMenuItemOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemOpen.Click
'Dim reader As New XmlSerializer(GetType(FunctionBase))
'Dim file As New StreamReader("D:\test.xml")
'Dim fileData As [Function]
'fileData = CType(reader.Deserialize(file), [Function])
'Dim reader As New XmlTextReader("D:\test.xml")
'Dim contents As String
'contents = reader.ReadInnerXml
End Sub
Private Sub ToolStripButtonAutoRefresh2D_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonAutoRefresh2D.Click
End Sub
Private Sub ShowToolbarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
ToolStripMenuItemCursorToolBar.Click, _
ToolStripMenuItemZoomToolbar.Click, _
ToolStripMenuItemFFTToolBar.Click, _
ParametricToolbarToolStripMenuItem.Click, _
ToolStripMenuItemRootFinderToolBar.Click
Dim toolbar As ToolStripMenuItem
toolbar = sender
If sender Is Me.ToolStripMenuItemCursorToolBar Then
Me.CursorToolBar.Visible = toolbar.Checked
ElseIf sender Is Me.ToolStripMenuItemFFTToolBar Then
Me.FFTToolBar.Visible = toolbar.Checked
ElseIf sender Is Me.ParametricToolbarToolStripMenuItem Then
Me.ParamToolBar.Visible = toolbar.Checked
ElseIf sender Is Me.ToolStripMenuItemZoomToolbar Then
Me.ZoomToolBar.Visible = toolbar.Checked
ElseIf sender Is Me.ToolStripMenuItemRootFinderToolBar Then
Me.FRToolBar.Visible = toolbar.Checked
End If
End Sub
'Private Sub FormBodeViewer_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'End Sub
End Class