Skip to content

Commit

Permalink
Merge pull request #41 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
FrancoisJRenaud authored Nov 29, 2016
2 parents 20eaa82 + 43fc353 commit d0ae38b
Show file tree
Hide file tree
Showing 12 changed files with 448 additions and 22 deletions.
24 changes: 24 additions & 0 deletions instat/instat.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,24 @@
<Compile Include="ucrAdditionalLayers.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrCheck.Designer.vb">
<DependentUpon>ucrCheck.vb</DependentUpon>
</Compile>
<Compile Include="ucrCheck.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrColors.Designer.vb">
<DependentUpon>ucrColors.vb</DependentUpon>
</Compile>
<Compile Include="ucrColors.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrCore.Designer.vb">
<DependentUpon>ucrCore.vb</DependentUpon>
</Compile>
<Compile Include="ucrCore.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrDialogDisabled.Designer.vb">
<DependentUpon>ucrDialogDisabled.vb</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1828,6 +1840,12 @@
<Compile Include="ucrNewColumnName.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrRadio.Designer.vb">
<DependentUpon>ucrRadio.vb</DependentUpon>
</Compile>
<Compile Include="ucrRadio.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ucrReceiver.Designer.vb">
<DependentUpon>ucrReceiver.vb</DependentUpon>
</Compile>
Expand Down Expand Up @@ -4063,6 +4081,9 @@
<EmbeddedResource Include="ucrButtonsSubdialogue.sw-KE.resx">
<DependentUpon>ucrButtonsSubdialogue.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ucrCheck.resx">
<DependentUpon>ucrCheck.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ucrColors.fr-FR.resx">
<DependentUpon>ucrColors.vb</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -4234,6 +4255,9 @@
<EmbeddedResource Include="ucrNewColumnName.sw-KE.resx">
<DependentUpon>ucrNewColumnName.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ucrRadio.resx">
<DependentUpon>ucrRadio.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ucrReceiverExpression.fr-FR.resx">
<DependentUpon>ucrReceiverExpression.vb</DependentUpon>
</EmbeddedResource>
Expand Down
63 changes: 43 additions & 20 deletions instat/sdgLayerOptions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,34 @@ Public Class sdgLayerOptions
clsGgplotFunction = clsTempGgPlot
ucrGeomWithAes.Setup(clsTempGgPlot, clsTempGeomFunc, clsTempAesFunc, bFixAes, bFixGeom, strDataframe, bApplyAesGlobally, bIgnoreGlobalAes, iNumVariablesForGeoms, clsTempLocalAes)
ucrLayerParameter.Setup(clsTempGgPlot, clsTempGeomFunc, clsTempAesFunc, bFixAes, bFixGeom, strDataframe, bApplyAesGlobally, bIgnoreGlobalAes, iNumVariablesForGeoms, clsTempLocalAes) 'Don't really need to give all parameters through as this function just calls the mother Setup from ucrGeom who doesn't use some of them which are optional, such as clsTempLocalAes...
'Warning: when coming back to a layer where the geom was not fixed, the geom is now fixed...
'Task: should be written as an issue
End Sub

Public Function TestForOKEnabled() As Boolean
Return ucrGeomWithAes.TestForOkEnabled()
End Function

Private Sub PartiallyMandatoryAesFillingMethod(clsRelevantAesFunction As RFunction)
'This sub is called to add "" mapping for axis x or y when no variables are mapped to them (only relavant for a few geoms). The mapping is added in the global or local aes depending on whether apply on all layers is checked or not (choice of clsRelevantAesFunction).
Dim bTempIgnoreGlobalAes As Boolean
bTempIgnoreGlobalAes = ((clsGeomFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "inherit.aes") <> -1) AndAlso (clsGeomFunction.GetParameter("inherit.aes").strArgumentValue = "FALSE"))
If clsGeomFunction.strRCommand = "geom_boxplot" OrElse clsGeomFunction.strRCommand = "geom_dotplot" Then
If (clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 OrElse bTempIgnoreGlobalAes) AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 Then
clsRelevantAesFunction.AddParameter("x", Chr(34) & Chr(34))
End If
ElseIf clsGeomFunction.strRCommand = "geom_point" OrElse clsGeomFunction.strRCommand = "geom_line" Then
If (clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 OrElse bTempIgnoreGlobalAes) AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 Then
clsRelevantAesFunction.AddParameter("x", Chr(34) & Chr(34))
End If
If (clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") = -1 OrElse bTempIgnoreGlobalAes) AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") = -1 Then
clsRelevantAesFunction.AddParameter("y", Chr(34) & Chr(34))
End If
End If
End Sub

Private Sub ucrSdgLayerBase_ClickReturn(sender As Object, e As EventArgs) Handles ucrSdgLayerBase.ClickReturn
Dim clsRelevantAesFunction As New RFunction 'Will be used in the partially mandatory aes filling method below.

'Two situations: apply on all layers checked or not. Would edit the global or local aes accordingly.
If ucrGeomWithAes.chkApplyOnAllLayers.Checked Then
'First, in case the chkApplyOnAllLayers is checked, what is by default understood as local mapping (clsGeomAesFunction) needs to become global mapping: the Aes parameters in clsGeomAesFunction are sent through to clsAesFunction.
For Each clsParam In ucrGeomWithAes.clsGeomAesFunction.clsParameters
Expand All @@ -93,7 +112,7 @@ Public Class sdgLayerOptions
'Question: why do we even do this ? Should it not have been done earlier ? What's the point of changing parameters on sdgLayerOptions right before closing it ?
strGlobalDataFrame = ucrGeomWithAes.ucrGeomWithAesSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text
ucrGeomWithAes.strGlobalDataFrame = strGlobalDataFrame
Else 'Warning: in case the dggLayerOptions has been called by specific dlg, need to refill the aes on that dlg. Imagine the ApplyOnAllLayers has been unticked ? Problem... Also in order to solve this, would need to know on the specific dialog if it has been unticked or not in order to know how to fill in the aes receivers ! The linking will be restudied anyway. There are many ways to go, see discussion on github.
Else 'Warning: in case the sdgLayerOptions has been called by specific dlg, need to refill the aes on that dlg. Imagine the ApplyOnAllLayers has been unticked ? Problem... Also in order to solve this, would need to know on the specific dialog if it has been unticked or not in order to know how to fill in the aes receivers ! The linking will be restudied anyway. There are many ways to go, see discussion on github.
If ucrGeomWithAes.clsGeomAesFunction.iParameterCount > 0 Then
clsGeomFunction.AddParameter("mapping", clsRFunctionParameter:=ucrGeomWithAes.clsGeomAesFunction.Clone())
Else
Expand All @@ -105,28 +124,32 @@ Public Class sdgLayerOptions
clsGeomFunction.RemoveParameterByName("data")
End If
End If

'Partially mandatory aes filling method
If ucrGeomWithAes.chkApplyOnAllLayers.Checked Then
PartiallyMandatoryAesFillingMethod(clsAesFunction)

'Warning: in some cases, this is sources of errors in R: is a continuous variable is mapped to y (for instance plot1 <- ggplot(diamonds,aes(y=price,x="") + geom_boxplot()), and in some layer where global aes are ignored, "" is mapped to y (e.g. plot1 + geom_point(inherit.aes = FALSE, mapping = aes(x="",y="")) ), then an error occurs as a discrete vriable cannot be mapped to a continuous scale.
'Warning: again coming from specific plots, If ApplyOnAllLayers is unticked, the linking will make this mehtod fail.
ElseIf clsGeomFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "mapping") <> -1 Then
PartiallyMandatoryAesFillingMethod(clsGeomFunction.clsParameters.Find(Function(x) x.strArgumentName = "mapping").clsArgumentFunction)
Else
clsRelevantAesFunction.SetRCommand("aes")
PartiallyMandatoryAesFillingMethod(clsRelevantAesFunction)
If clsRelevantAesFunction.iParameterCount > 0 Then
clsGeomFunction.AddParameter("mapping", clsRFunctionParameter:=clsRelevantAesFunction.Clone())
End If
End If

'Adding stat = identity method
If clsGeomFunction.strRCommand = "geom_bar" OrElse clsGeomFunction.strRCommand = "geom_density" OrElse clsGeomFunction.strRCommand = "geom_freqpoly" Then
'If there is a y in the global aes, and the global aes are not ignored or if there is a y in the local aes then in case stat has not been set manually, stat is set to identity.
If (((clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") <> -1) AndAlso ((clsGeomFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "inherit.aes") = -1) OrElse (clsGeomFunction.GetParameter("inherit.aes").strArgumentValue = "TRUE"))) OrElse (ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") <> -1)) AndAlso (clsGeomFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "stat") = -1) Then
clsGeomFunction.AddParameter("stat", Chr(34) & "identity" & Chr(34))
End If
If clsGeomFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "stat") <> -1 Then
If ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") Then
ucrGeomWithAes.clsGeomAesFunction.RemoveParameterByName("stat")
ElseIf clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") = -1 Then
clsAesFunction.RemoveParameterByName("stat")
End If
End If
ElseIf clsGeomFunction.strRCommand = "geom_boxplot" OrElse clsGeomFunction.strRCommand = "geom_dotplot" Then
If clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 Then
clsAesFunction.AddParameter("x", Chr(34) & Chr(34))
End If
ElseIf clsGeomFunction.strRCommand = "geom_point" OrElse clsGeomFunction.strRCommand = "geom_line" Then
If clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "x") = -1 Then
clsAesFunction.AddParameter("x", Chr(34) & Chr(34))
ElseIf clsAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") = -1 AndAlso ucrGeomWithAes.clsGeomAesFunction.clsParameters.FindIndex(Function(x) x.strArgumentName = "y") = -1 Then
clsAesFunction.AddParameter("y", Chr(34) & Chr(34))
'Task: send a message to the user saying that stat = identity has been added as a parameter in order to avoid error. Can be modified on the LayerParameter tab.
'In case the "y" mapping has been removed after editing the layer, the added "stat" parameter should probably be removed so it is important for the user to know it has been added in automatically, in case he wants to go to the layer parameters tab and remove it.
End If
End If

End Sub
End Class
50 changes: 50 additions & 0 deletions instat/ucrCheck.Designer.vb

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

120 changes: 120 additions & 0 deletions instat/ucrCheck.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
3 changes: 3 additions & 0 deletions instat/ucrCheck.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Public Class ucrCheck

End Class
Loading

0 comments on commit d0ae38b

Please sign in to comment.