Skip to content

Commit

Permalink
Merge pull request #111 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Merge from MC
  • Loading branch information
lilyclements authored Jan 29, 2017
2 parents 3b2859e + bb20c40 commit 0f65ee3
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 39 deletions.
17 changes: 7 additions & 10 deletions instat/clsRCodeStructure.vb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ Public Class RCodeStructure
clsParam.SetArgument(clsROperatorParameter)
End If
clsParam.bIncludeArgumentName = bIncludeArgumentName
AddParameter(clsParam, iPosition)
clsParam.Position = iPosition
AddParameter(clsParam)
End Sub

'TODO This should be call AddParameter but need to make it unambiguous with above
Expand All @@ -213,20 +214,16 @@ Public Class RCodeStructure
End If
End Sub

Public Overridable Sub AddParameter(clsNewParam As RParameter, Optional iPosition As Integer = -1)
Public Overridable Sub AddParameter(clsNewParam As RParameter)
Dim i As Integer = -1
Dim strTempArgumentName As String = clsNewParam.strArgumentName
clsNewParam.Position = iPosition
If clsNewParam.strArgumentName Is Nothing Then
Dim x = 1
End If
If clsParameters IsNot Nothing Then
If clsNewParam.strArgumentName IsNot Nothing Then
'Dim match As Predicate(Of RParameter) = Function(x) x.strArgumentName.Equals(clsParam.strArgumentName)
i = clsParameters.FindIndex(Function(x) x.strArgumentName.Equals(strTempArgumentName))
End If
If i = -1 Then
ShiftParametersPositions(iPosition) 'Checking if there is room in the parameter's positions to add a parameter with position = iPosition
ShiftParametersPositions(clsNewParam.Position) 'Checking if there is room in the parameter's positions to add a parameter with position = iPosition
clsParameters.Add(clsNewParam)
Else
If clsNewParam.bIsString AndAlso clsNewParam.strArgumentValue IsNot Nothing Then
Expand All @@ -236,12 +233,12 @@ Public Class RCodeStructure
Else
'message
End If
If clsParameters(i).Position <> iPosition Then
If clsParameters(i).Position <> clsNewParam.Position Then
'In case the position needs to be changed, there might exist another parameter with the new position in the list
'The parameter i is then temporarily set to unordered until the Shift in positions has been operated within the clsParameters (if necessary).
clsParameters(i).Position = -1
If iPosition <> -1 Then
ShiftParametersPositions(iPosition)
If clsNewParam.Position <> -1 Then
ShiftParametersPositions(clsNewParam.Position)
clsParameters(i).Position = clsNewParam.Position
End If
End If
Expand Down
5 changes: 3 additions & 2 deletions instat/clsRFunction.vb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Public Class RFunction
Public Overrides Sub AddParameter(Optional strParameterName As String = "", Optional strParameterValue As String = "", Optional clsRFunctionParameter As RFunction = Nothing, Optional clsROperatorParameter As ROperator = Nothing, Optional bIncludeArgumentName As Boolean = True, Optional iPosition As Integer = -1)
MyBase.AddParameter(strParameterName, strParameterValue, clsRFunctionParameter, clsROperatorParameter, bIncludeArgumentName, iPosition)
End Sub
Public Overrides Sub AddParameter(clsParam As RParameter, Optional iPosition As Integer = -1)
MyBase.AddParameter(clsParam, iPosition)

Public Overrides Sub AddParameter(clsParam As RParameter)
MyBase.AddParameter(clsParam)
End Sub

Public Overrides Function GetParameter(strName As String) As RParameter
Expand Down
4 changes: 2 additions & 2 deletions instat/clsROperator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Public Class ROperator
End Function


Public Overrides Sub AddParameter(clsParam As RParameter, Optional iPosition As Integer = -1)
Public Overrides Sub AddParameter(clsParam As RParameter)
clsParam.bIncludeArgumentName = False 'We don't want to allow names in operator parameters...
MyBase.AddParameter(clsParam, iPosition)
MyBase.AddParameter(clsParam)
End Sub

Public Overrides Function GetParameter(strName As String) As RParameter
Expand Down
5 changes: 3 additions & 2 deletions instat/clsRParameter.vb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ Public Class RParameter
Public bIsString As Boolean = False
'iPosition determines the position this parameter should take among other parameters of an Operator or Function. If iPosition is 0, then it is part of the unordered parameters that are added after the ordered ones.
'Note, it is allowed to have gaps in the positions: parameters with positions a 0, b 2, c 5, d 3, e 0 will be sorted as b d c (a e). See CompareParametersPosition in clsRCodeStructure.
Private iPosition As Integer = 0
Private iPosition As Integer = -1
'See strArgumentName
Public bIncludeArgumentName As Boolean = True

Public Sub New()
End Sub

Public Sub New(strParameterName As String)
Public Sub New(strParameterName As String, Optional iNewPosition As Integer = -1)
SetArgumentName(strParameterName)
Position = iNewPosition
End Sub

''Public Event PositionChanged()
Expand Down
36 changes: 18 additions & 18 deletions instat/dlgColourbyProperty.vb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Public Class dlgColourbyProperty
Private Sub SetDefaults()
ucrSelectorColourByMetadata.Reset()
SetOrRemoveColours()
chkRemoveColours.Checked = False
'chkRemoveColours.Checked = False
End Sub

Private Sub TestOKEnabled()
If Not ucrReceiverMetadataProperty.IsEmpty OrElse chkRemoveColours.Checked Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
'If Not ucrReceiverMetadataProperty.IsEmpty OrElse chkRemoveColours.Checked Then
' ucrBase.OKEnabled(True)
'Else
' ucrBase.OKEnabled(False)
'End If
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand All @@ -72,21 +72,21 @@ Public Class dlgColourbyProperty
TestOKEnabled()
End Sub

Private Sub chkRemoveColours_CheckedChanged(sender As Object, e As EventArgs) Handles chkRemoveColours.CheckedChanged
Private Sub chkRemoveColours_CheckedChanged(sender As Object, e As EventArgs) 'Handles chkRemoveColours.CheckedChanged
SetOrRemoveColours()
End Sub

Private Sub SetOrRemoveColours()
If chkRemoveColours.Checked Then
ucrSelectorColourByMetadata.Reset()
ucrSelectorColourByMetadata.SetCurrentReceiver(Nothing)
ucrReceiverMetadataProperty.Enabled = False
ucrBase.clsRsyntax.SetBaseRFunction(clsRemoveColoursFunction)
Else
ucrBase.clsRsyntax.SetBaseRFunction(clsSetColoursFunction)
ucrReceiverMetadataProperty.Enabled = True
ucrReceiverMetadataProperty.SetMeAsReceiver()
End If
TestOKEnabled()
'If chkRemoveColours.Checked Then
' ucrSelectorColourByMetadata.Reset()
' ucrSelectorColourByMetadata.SetCurrentReceiver(Nothing)
' ucrReceiverMetadataProperty.Enabled = False
' ucrBase.clsRsyntax.SetBaseRFunction(clsRemoveColoursFunction)
'Else
' ucrBase.clsRsyntax.SetBaseRFunction(clsSetColoursFunction)
' ucrReceiverMetadataProperty.Enabled = True
' ucrReceiverMetadataProperty.SetMeAsReceiver()
'End If
'TestOKEnabled()
End Sub
End Class
2 changes: 1 addition & 1 deletion instat/dlgInventoryPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Public Class dlgInventoryPlot
ucrBase.clsRsyntax.iCallType = 3

ucrSaveInventoryPlot.SetDataFrameSelector(ucrInventoryPlotSelector.ucrAvailableDataFrames)
clsDefaultRFunction.AddParameter(ucrInventoryPlotSelector.GetParameter(), 0)
clsDefaultRFunction.AddParameter(ucrInventoryPlotSelector.GetParameter())

End Sub

Expand Down
4 changes: 2 additions & 2 deletions instat/dlgOneVariableGraph.vb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Public Class dlgOneVariableGraph

ucrReceiverOneVarGraph.Selector = ucrSelectorOneVarGraph
ucrReceiverOneVarGraph.SetMeAsReceiver()
ucrReceiverOneVarGraph.SetParameter(New RParameter("columns"))
ucrReceiverOneVarGraph.SetParameter(New RParameter("columns", 1))
ucrReceiverOneVarGraph.SetParameterIsString()

ucrSelectorOneVarGraph.SetParameter(New RParameter("data_name"))
ucrSelectorOneVarGraph.SetParameter(New RParameter("data_name", 0))
ucrSelectorOneVarGraph.SetParameterIsString()

ucrChkFlip.SetText("Flip Coordinates")
Expand Down
3 changes: 1 addition & 2 deletions instat/ucrCore.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Public Class ucrCore

'Function or Operator that this control's parameter is added/removed from
Protected clsRCode As New RCodeStructure
Protected iParameterPosition As Integer = -1
'Parameter that this control manages
'Either by editing its value or adding/removing it from an RCodeStructure
Protected clsParameter As RParameter
Expand Down Expand Up @@ -203,7 +202,7 @@ Public Class ucrCore
Public Overridable Sub AddOrRemoveParameter(bAdd As Boolean)
If clsRCode IsNot Nothing AndAlso clsParameter IsNot Nothing Then
If bAdd Then
clsRCode.AddParameter(clsParameter, iParameterPosition)
clsRCode.AddParameter(clsParameter)
Else
clsRCode.RemoveParameter(clsParameter)
End If
Expand Down

0 comments on commit 0f65ee3

Please sign in to comment.