Skip to content

Commit

Permalink
Merge pull request #222 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Updating Master
  • Loading branch information
Muthenya authored Jan 9, 2019
2 parents 4fd567f + 1ba9fa6 commit deaedef
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 37 deletions.
31 changes: 29 additions & 2 deletions instat/dlgClimaticStationMaps.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 47 additions & 16 deletions instat/dlgClimaticStationMaps.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Imports instat.Translations
Public Class dlgClimaticStationMaps
Private bFirstLoad As Boolean = True
Private bReset As Boolean = True
Private clsGgplotFunction, clsGeomSfFunction, clsGeomPointFunction, clsSfAesFunction, clsGeomPointAesFunction As RFunction
Private clsGGplotOperator As New ROperator
Private clsGgplotFunction, clsGeomSfFunction, clsGeomPointFunction, clsSfAesFunction, clsGeomPointAesFunction, clsFacetFunction, clsScaleShapeFunction As RFunction
Private clsGGplotOperator, clsFacetOp As New ROperator

Private clsLabsFunction As New RFunction
Private clsXlabsFunction As New RFunction
Expand All @@ -34,9 +34,6 @@ Public Class dlgClimaticStationMaps
Private bResetSubdialog As Boolean = True
Private bResetSFLayerSubdialog As Boolean = True




Private Sub dlgClimaticMaps_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If bFirstLoad Then
InitialiseDialog()
Expand Down Expand Up @@ -92,6 +89,11 @@ Public Class dlgClimaticStationMaps
ucrReceiverColor.SetParameterIsString()
ucrReceiverColor.bWithQuotes = False

ucrReceiverFacet.SetParameter(New RParameter("wrap", bNewIncludeArgumentName:=False))
ucrReceiverFacet.Selector = ucrSelectorStation
ucrReceiverFacet.SetParameterIsString()
ucrReceiverFacet.bWithQuotes = False

ucrSaveMap.SetPrefix("Map")
ucrSaveMap.SetSaveTypeAsGraph()
ucrSaveMap.SetIsComboBox()
Expand All @@ -107,15 +109,18 @@ Public Class dlgClimaticStationMaps
clsSfAesFunction = New RFunction
clsGeomPointFunction = New RFunction
clsGeomPointAesFunction = New RFunction
clsFacetFunction = New RFunction
clsScaleShapeFunction = New RFunction

clsGGplotOperator = New ROperator
clsXlimFunction = New RFunction
clsYlimFunction = New RFunction
clsFacetOp = New ROperator

ucrSelectorOutline.Reset()
ucrReceiverFill.SetMeAsReceiver()
ucrSelectorStation.Reset()
ucrReceiverLongitude.SetMeAsReceiver()
ucrReceiverFill.SetMeAsReceiver()
ucrSaveMap.Reset()
bResetSubdialog = True
bResetSFLayerSubdialog = True
Expand All @@ -137,6 +142,18 @@ Public Class dlgClimaticStationMaps
clsGeomPointAesFunction.SetPackageName("ggplot2")
clsGeomPointAesFunction.SetRCommand("aes")

clsScaleShapeFunction.SetPackageName("ggplot2")
clsScaleShapeFunction.SetRCommand("scale_shape_manual")
clsScaleShapeFunction.AddParameter("values", strParameterValue:="c(3,4,7,8,11,13,15,16,17,18,21,22,42)", bIncludeArgumentName:=True, iPosition:=0)

clsFacetOp.SetOperation("~")
clsFacetOp.bForceIncludeOperation = True
clsFacetOp.bBrackets = False

clsFacetFunction.SetPackageName("ggplot2")
clsFacetFunction.SetRCommand("facet_wrap")
clsFacetFunction.AddParameter("facet", clsROperatorParameter:=clsFacetOp, bIncludeArgumentName:=False)

clsGGplotOperator.SetOperation("+")
clsGGplotOperator.AddParameter("ggplot", clsRFunctionParameter:=clsGgplotFunction, bIncludeArgumentName:=False, iPosition:=0)
clsGGplotOperator.AddParameter("geom_sf", clsRFunctionParameter:=clsGeomSfFunction, bIncludeArgumentName:=False, iPosition:=1)
Expand Down Expand Up @@ -174,6 +191,7 @@ Public Class dlgClimaticStationMaps
ucrReceiverLatitude.SetRCode(clsGeomPointAesFunction, bReset)
ucrReceiverShape.SetRCode(clsGeomPointAesFunction, bReset)
ucrReceiverColor.SetRCode(clsGeomPointAesFunction, bReset)
ucrReceiverFacet.SetRCode(clsFacetOp, bReset)
End Sub

Private Sub cmdSFOptions_Click(sender As Object, e As EventArgs) Handles cmdSFOptions.Click
Expand All @@ -195,21 +213,19 @@ Public Class dlgClimaticStationMaps

Private Sub TestOkEnabled()
Dim bOkEnabled As Boolean
If Not ucrReceiverFill.IsEmpty AndAlso ucrSaveMap.IsComplete Then
If ucrSaveMap.IsComplete Then
bOkEnabled = True
If Not ucrReceiverLongitude.IsEmpty AndAlso ucrReceiverLatitude.IsEmpty Then
bOkEnabled = False
ElseIf ucrReceiverLongitude.IsEmpty AndAlso Not ucrReceiverLatitude.IsEmpty Then
bOkEnabled = False
Else
bOkEnabled = True
End If
Else
End If
If Not ucrReceiverLongitude.IsEmpty AndAlso ucrReceiverLatitude.IsEmpty Then
bOkEnabled = False
ElseIf ucrReceiverLongitude.IsEmpty AndAlso Not ucrReceiverLatitude.IsEmpty Then
bOkEnabled = False
Else
bOkEnabled = True
End If

ucrBase.OKEnabled(bOkEnabled)
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
SetRCodeForControls(True)
Expand All @@ -223,8 +239,23 @@ Public Class dlgClimaticStationMaps
clsGGplotOperator.RemoveParameterByName("geom_point")
End If
End Sub
Private Sub ucrReceiverShape_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverShape.ControlValueChanged
If Not ucrReceiverShape.IsEmpty Then
clsGGplotOperator.AddParameter("scale_shape_manual", clsRFunctionParameter:=clsScaleShapeFunction, bIncludeArgumentName:=False, iPosition:=2)
Else
clsGGplotOperator.RemoveParameterByName("scale_shape_manual")
End If
End Sub

Private Sub ucrReceiverFill_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverFill.ControlContentsChanged, ucrReceiverLongitude.ControlContentsChanged, ucrReceiverLatitude.ControlContentsChanged, ucrSaveMap.ControlContentsChanged
TestOkEnabled()
End Sub

Private Sub ucrReceiverFacet_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverFacet.ControlValueChanged
If Not ucrReceiverFacet.IsEmpty Then
clsGGplotOperator.AddParameter("facets", clsRFunctionParameter:=clsFacetFunction, bIncludeArgumentName:=False, iPosition:=2)
Else
clsGGplotOperator.RemoveParameterByName("facets")
End If
End Sub
End Class
24 changes: 5 additions & 19 deletions instat/dlgGeneralForGraphics.vb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Public Class dlgGeneralForGraphics
InitialiseDialog()
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If
autoTranslate(Me)
TestOKEnabled()
Expand All @@ -68,6 +66,7 @@ Public Class dlgGeneralForGraphics
iLayerIndex = 0
lstLayerComplete.Clear()
strGlobalDataFrame = ""
ucrSaveGraph.Reset()
bDataFrameSet = False
bResetOptionsSubdialog = True

Expand All @@ -83,13 +82,9 @@ Public Class dlgGeneralForGraphics
clsGlobalAesFunction.SetRCommand("aes")

clsBaseOperator.AddParameter("ggplot2", clsRFunctionParameter:=clsGgplotFunction, iPosition:=0)
clsBaseOperator.SetAssignTo("last_graph", strTempGraph:="last_graph")
clsBaseOperator.SetAssignTo("last_graph", strTempDataframe:=sdgLayerOptions.ucrGeomWithAes.ucrGeomWithAesSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph")
clsBaseOperator.bExcludeAssignedFunctionOutput = False

ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator)

ucrAdditionalLayers.SetRCodeForControl(clsNewBaseOperator:=clsBaseOperator, clsRNewggplotFunc:=clsGgplotFunction, clsNewAesFunc:=clsGlobalAesFunction, strNewGlobalDataFrame:=strGlobalDataFrame, bReset:=True)

clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone())
clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone()
clsYlabsFunction = GgplotDefaults.clsYlabTitleFunction.Clone()
Expand All @@ -100,6 +95,9 @@ Public Class dlgGeneralForGraphics
dctThemeFunctions = New Dictionary(Of String, RFunction)(GgplotDefaults.dctThemeFunctions)
clsThemeFunction = GgplotDefaults.clsDefaultThemeFunction

ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator)
ucrAdditionalLayers.SetRCodeForControl(clsNewBaseOperator:=clsBaseOperator, clsRNewggplotFunc:=clsGgplotFunction, clsNewAesFunc:=clsGlobalAesFunction, strNewGlobalDataFrame:=strGlobalDataFrame, bReset:=True)

If ucrBase.clsRsyntax.clsBaseOperator IsNot Nothing Then
ucrBase.clsRsyntax.clsBaseOperator.RemoveAllAdditionalParameters()
End If
Expand All @@ -108,9 +106,6 @@ Public Class dlgGeneralForGraphics
TestOKEnabled()
End Sub

Private Sub ReopenDialog()

End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
Expand All @@ -126,15 +121,6 @@ Public Class dlgGeneralForGraphics
ucrBase.OKEnabled(bTemp)
End Sub

Private Sub ucrSaveGraph_GraphNameChanged() Handles ucrSaveGraph.GraphNameChanged, ucrSaveGraph.SaveGraphCheckedChanged
'Warning/Task: this method seems weird to me, why do we get the dataframe from sdgLayerOptions ???!
If ucrSaveGraph.bSaveGraph Then
ucrBase.clsRsyntax.SetAssignTo(ucrSaveGraph.strGraphName, strTempDataframe:=sdgLayerOptions.ucrGeomWithAes.ucrGeomWithAesSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:=ucrSaveGraph.strGraphName)
Else
ucrBase.clsRsyntax.SetAssignTo("last_graph", strTempDataframe:=sdgLayerOptions.ucrGeomWithAes.ucrGeomWithAesSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph")
End If
End Sub

Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.DisableLayersTab()
sdgPlots.SetRCode(clsNewOperator:=ucrBase.clsRsyntax.clsBaseOperator, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewLabsFunction:=clsLabsFunction, clsNewXLabsTitleFunction:=clsXlabsFunction, clsNewYLabTitleFunction:=clsYlabsFunction, clsNewFacetFunction:=clsFacetsFunction, ucrNewBaseSelector:=sdgLayerOptions.ucrGeomWithAes.ucrGeomWithAesSelector, bReset:=bResetSubdialog)
Expand Down

0 comments on commit deaedef

Please sign in to comment.