diff --git a/instat/UcrGeomListWithAes.vb b/instat/UcrGeomListWithAes.vb index 4892c4f8d30..b8b23ff90b5 100644 --- a/instat/UcrGeomListWithAes.vb +++ b/instat/UcrGeomListWithAes.vb @@ -94,8 +94,8 @@ Public Class UcrGeomListWithParameters chkApplyOnAllLayers.Checked = bApplyAesGlobally chkIgnoreGlobalAes.Checked = bIgnoreGlobalAes 'Task: check if this launches checkchanged and accordingly delete SetAes below. + bCurrentFixAes = bFixAes 'Warning/Question/Task: this is not flexible enough. Some of the aesthetics are set in the options. They cannot be editted on the main, however when coming back to options these are fixed and so cannot be editted anywhere anymore. Would need to be able to choose which aesthetics among a Layer should be fixed maybe. 'SetAes needs to be called after the IgnoreGlobalAes has been setup as it determines whether the global aes are written in the rceivers or not. - bCurrentFixAes = bFixAes SetAes(bCurrentFixAes) 'Warning: SetAes is called three times when a layer is created... one in the load, one in the setup ... (and one in the ignoreGAes check changed ?) End Sub @@ -115,10 +115,10 @@ Public Class UcrGeomListWithParameters If Not chkIgnoreGlobalAes.Checked Then For Each clsParam In clsGgplotAesFunction.clsParameters If clsParam.strArgumentName = lstCurrArguments(i) Then - 'For some geoms like BoxPlot, when the x aes is not filled, ggplot R syntax requires to set x="". This x="" might be copied into the global aes if the ApplyOnAllLayers is set to true for a BoxPlot Layer. This might be copied from the GgplotAesFunction parameters into the aes receivers by error in subsequent layers. - If Not (clsParam.strArgumentName = "x" AndAlso clsParam.strArgumentValue = Chr(34) & Chr(34)) Then + 'For some geoms like LinePlot, when the x or y aes is not filled, ggplot R syntax requires to set x="". This x="" might be copied into the global aes if the ApplyOnAllLayers is set to true for a BoxPlot Layer. This might be copied from the GgplotAesFunction parameters into the aes receivers by error in subsequent layers. + If Not ((clsParam.strArgumentName = "x" OrElse clsParam.strArgumentName = "y") AndAlso clsParam.strArgumentValue = Chr(34) & Chr(34)) Then lstAesParameterUcr(i).Add(clsParam.strArgumentValue) - lstAesParameterUcr(i).Enabled = Not bFixAes + lstAesParameterUcr(i).Enabled = Not bFixAes 'Warning/Question/Task: this is not flexible enough. Some of the aesthetics are set in the options. They cannot be editted on the main, however when coming back to options these are fixed and so cannot be editted anywhere anymore. Would need to be able to choose which aesthetics among a Layer should be fixed maybe. Exit For End If End If @@ -126,7 +126,7 @@ Public Class UcrGeomListWithParameters End If For Each clsParam In clsGeomAesFunction.clsParameters If clsParam.strArgumentName = lstCurrArguments(i) Then - If Not (clsParam.strArgumentName = "x" AndAlso clsParam.strArgumentValue = Chr(34) & Chr(34)) Then 'As before, check that x is not mapped to "" before putting in receivers. + If Not ((clsParam.strArgumentName = "x" OrElse clsParam.strArgumentName = "y") AndAlso clsParam.strArgumentValue = Chr(34) & Chr(34)) Then 'As before, check that x is not mapped to "" before putting in receivers. lstAesParameterUcr(i).Add(clsParam.strArgumentValue) lstAesParameterUcr(i).Enabled = True Exit For diff --git a/instat/dlgBarAndPieChart.vb b/instat/dlgBarAndPieChart.vb index 7cae3a40148..d07cda7f162 100644 --- a/instat/dlgBarAndPieChart.vb +++ b/instat/dlgBarAndPieChart.vb @@ -179,7 +179,7 @@ Public Class dlgBarAndPieChart sdgLayerOptions.ShowDialog() For Each clsParam In clsRaesFunction.clsParameters If clsParam.strArgumentName = "x" Then - If clsParam.strArgumentValue = "" Then + If clsParam.strArgumentValue = Chr(34) & Chr(34) Then ucrFactorReceiver.Clear() Else ucrFactorReceiver.Add(clsParam.strArgumentValue) diff --git a/instat/dlgCompareModels.vb b/instat/dlgCompareModels.vb index c74bd7cdf67..383c258c819 100644 --- a/instat/dlgCompareModels.vb +++ b/instat/dlgCompareModels.vb @@ -14,7 +14,10 @@ ' You should have received a copy of the GNU General Public License k ' along with this program. If not, see . Imports instat.Translations +Imports RDotNet Public Class dlgCompareModels + Public strOutput As String + Public clsPlotDist As New RFunction Public bFirstLoad As Boolean = True Private Sub dlgCompareModels_Load(sender As Object, e As EventArgs) Handles MyBase.Load autoTranslate(Me) @@ -28,15 +31,25 @@ Public Class dlgCompareModels TestOKEnabled() End Sub Private Sub InitialiseDialog() - + clsPlotDist.SetRCommand("plotDist") + ucrBase.clsRsyntax.SetFunction("grid.arrange") End Sub Private Sub TestOKEnabled() + If nudXlimMax.Value > nudXlimMin.Value AndAlso nudYlimMax.Value > nudYlimMin.Value Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If End Sub Private Sub SetDefaults() - + rdoSingle.Checked = True + rdoDensity.Checked = True + nudNumberofColumns.Enabled = False + lblNumberofColumns.Enabled = False + rdoCombine.Enabled = False End Sub Private Sub ReopenDialog() @@ -47,4 +60,82 @@ Public Class dlgCompareModels SetDefaults() TestOKEnabled() End Sub + + Private Sub ucrDistributionForCompareModels_ParameterChanged() Handles ucrDistributionForCompareModels.ParameterChanged + distParameters() + End Sub + + Private Sub distParameters() + clsPlotDist.ClearParameters() + clsPlotDist.AddParameter("dist", Chr(34) & ucrDistributionForCompareModels.clsCurrDistribution.strRName & Chr(34)) + For Each clstempparam In ucrDistributionForCompareModels.clsCurrRFunction.clsParameters + clsPlotDist.AddParameter(clstempparam.Clone()) + Next + End Sub + + Private Sub cmdAddNewDistributions_Click(sender As Object, e As EventArgs) Handles cmdAddNewDistributions.Click + sdgAddNewDistribution.ShowDialog() + End Sub + + Private Sub nudXlimMin_ValueChanged(sender As Object, e As EventArgs) Handles nudXlimMin.ValueChanged, nudYlimMin.ValueChanged, nudNumberofColumns.ValueChanged, nudXlimMax.ValueChanged, nudYlimMax.ValueChanged + XLimits() + Ylimits() + TestOKEnabled() + End Sub + + Private Sub grpPlotOptions_CheckedChanged(sender As Object, e As EventArgs) Handles rdoCDF.CheckedChanged, rdoDensity.CheckedChanged, rdoHistogram.CheckedChanged, rdoqq.CheckedChanged + kindParameters() + End Sub + + Private Sub Ylimits() + If nudYlimMax.Value > nudYlimMin.Value Then + If nudYlimMax.Text <> "" AndAlso nudYlimMin.Text <> "" Then + clsPlotDist.AddParameter("ylim", "c(" & nudYlimMin.Text & "," & nudYlimMax.Text & ")") + Else + clsPlotDist.RemoveParameterByName("ylim") + End If + clsPlotDist.RemoveParameterByName("ylim") + End If + End Sub + Private Sub XLimits() + If nudXlimMax.Value > nudXlimMin.Value Then + If nudXlimMax.Text <> "" AndAlso nudXlimMin.Text <> "" Then + clsPlotDist.AddParameter("xlim", "c(" & nudXlimMin.Text & "," & nudXlimMax.Text & ")") + + Else + clsPlotDist.RemoveParameterByName("xlim") + End If + Else + clsPlotDist.RemoveParameterByName("xlim") + End If + + End Sub + + Private Sub kindParameters() + If rdoqq.Checked Then + clsPlotDist.AddParameter("kind", Chr(34) & "qq" & Chr(34)) + ElseIf rdoHistogram.Checked Then + clsPlotDist.AddParameter("kind", Chr(34) & "histogram" & Chr(34)) + ElseIf rdoCDF.Checked Then + clsPlotDist.AddParameter("kind", Chr(34) & "cdf" & Chr(34)) + Else + clsPlotDist.AddParameter("kind", Chr(34) & "density" & Chr(34)) + End If + + End Sub + + Private Sub plotgraphspar() + If rdoSingle.Checked Then + cmdAddNewDistributions.Enabled = False + ucrBase.clsRsyntax.AddParameter("x", clsPlotDist.ToScript) + ucrBase.clsRsyntax.AddParameter("ncol", 1) + ElseIf rdoCombine.Checked Then + cmdAddNewDistributions.Enabled = True + nudNumberofColumns.Enabled = True + lblNumberofColumns.Enabled = True + End If + End Sub + Private Sub grpPlotGraphs_CheckedChanged(sender As Object, e As EventArgs) Handles rdoCombine.CheckedChanged, rdoSingle.CheckedChanged + plotgraphspar() + End Sub End Class \ No newline at end of file diff --git a/instat/dlgPlot.vb b/instat/dlgPlot.vb index a24dc515ad6..eeddda98d35 100644 --- a/instat/dlgPlot.vb +++ b/instat/dlgPlot.vb @@ -36,21 +36,6 @@ Public Class dlgPlot TestOkEnabled() End Sub - Private Sub SetDefaults() - clsRaesFunction.ClearParameters() - clsRgeom_lineplotFunction.ClearParameters() - chkPoints.Checked = False - ' ucrLinePlotSelector.Focus() - ucrSaveLinePlot.strPrefix = "Line" - ucrVariablesAsFactorForLinePlot.SetMeAsReceiver() - ucrLinePlotSelector.Reset() - ucrVariablesAsFactorForLinePlot.ResetControl() - ucrSaveLinePlot.Reset() - sdgPlots.Reset() - TempOptionsDisabledInMultipleVariablesCase() - TestOkEnabled() - End Sub - Private Sub InitialiseDialog() ucrBase.clsRsyntax.SetOperation("+") clsRggplotFunction.SetRCommand("ggplot") @@ -82,10 +67,44 @@ Public Class dlgPlot End Sub + Private Sub SetDefaults() + clsRaesFunction.ClearParameters() + clsRgeom_lineplotFunction.ClearParameters() + chkPoints.Checked = False + ' ucrLinePlotSelector.Focus() + ucrSaveLinePlot.strPrefix = "Line" + ucrVariablesAsFactorForLinePlot.SetMeAsReceiver() + ucrLinePlotSelector.Reset() + ucrVariablesAsFactorForLinePlot.ResetControl() + ucrSaveLinePlot.Reset() + sdgPlots.Reset() + SetXParameter() + SetYParameter() + TempOptionsDisabledInMultipleVariablesCase() + TestOkEnabled() + End Sub + + + + Private Sub SetXParameter() + If Not ucrReceiverX.IsEmpty Then + clsRaesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False)) + ucrFactorOptionalReceiver.SetMeAsReceiver() + Else + clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) + End If + End Sub + Private Sub SetYParameter() + If Not ucrVariablesAsFactorForLinePlot.IsEmpty Then + clsRaesFunction.AddParameter("y", ucrVariablesAsFactorForLinePlot.GetVariableNames(False)) + Else + clsRaesFunction.AddParameter("y", Chr(34) & Chr(34)) + End If + End Sub Private Sub TestOkEnabled() 'Both x and y aesthetics are mandatory for geom_line. However, when not filled they will be automatically populated by "". - If (ucrReceiverX.IsEmpty() OrElse ucrVariablesAsFactorForLinePlot.IsEmpty()) OrElse (ucrSaveLinePlot.chkSaveGraph.Checked AndAlso ucrSaveLinePlot.ucrInputGraphName.IsEmpty) Then + If (ucrSaveLinePlot.chkSaveGraph.Checked AndAlso ucrSaveLinePlot.ucrInputGraphName.IsEmpty) Then ucrBase.OKEnabled(False) Else ucrBase.OKEnabled(True) @@ -97,13 +116,7 @@ Public Class dlgPlot End Sub Private Sub ucrReceiverX_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverX.SelectionChanged - - If ucrReceiverX.IsEmpty() = False Then - clsRaesFunction.AddParameter("x", ucrReceiverX.GetVariableNames(False)) - ucrFactorOptionalReceiver.SetMeAsReceiver() - Else - clsRaesFunction.RemoveParameterByName("x") - End If + SetXParameter() TestOkEnabled() End Sub @@ -134,11 +147,7 @@ Public Class dlgPlot End Sub Private Sub UcrVariablesAsFactor_SelectionChanged() Handles ucrVariablesAsFactorForLinePlot.SelectionChanged - If Not ucrVariablesAsFactorForLinePlot.IsEmpty() Then - clsRaesFunction.AddParameter("y", ucrVariablesAsFactorForLinePlot.GetVariableNames(False)) - Else - clsRaesFunction.RemoveParameterByName("y") - End If + SetYParameter() TempOptionsDisabledInMultipleVariablesCase() TestOkEnabled() End Sub @@ -164,12 +173,24 @@ Public Class dlgPlot Private Sub cmdLineOptions_Click(sender As Object, e As EventArgs) Handles cmdLineOptions.Click sdgLayerOptions.SetupLayer(clsTempGgPlot:=clsRggplotFunction, clsTempGeomFunc:=clsRgeom_lineplotFunction, clsTempAesFunc:=clsRaesFunction, bFixAes:=True, bFixGeom:=True, strDataframe:=ucrLinePlotSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, bApplyAesGlobally:=True, bIgnoreGlobalAes:=False) sdgLayerOptions.ShowDialog() + 'Coming from the sdgLayerOptions, clsRaesFunction and others has been modified. One then needs to display these modifications on the dlgScatteredPlot. + 'The aesthetics parameters on the main dialog are repopulated as required. For Each clsParam In clsRaesFunction.clsParameters - If clsParam.strArgumentName = "y" AndAlso (clsParam.strArgumentValue <> "value" OrElse ucrVariablesAsFactorForLinePlot.bSingleVariable) Then - ucrVariablesAsFactorForLinePlot.Add(clsParam.strArgumentValue) - ElseIf clsParam.strArgumentName = "x" Then - ucrReceiverX.Add(clsParam.strArgumentValue) + If clsParam.strArgumentName = "x" Then + If clsParam.strArgumentValue = Chr(34) & Chr(34) Then + ucrReceiverX.Clear() + Else + ucrReceiverX.Add(clsParam.strArgumentValue) + End If + 'In the y case, the vlue stored in the clsReasFunction in the multiplevariables case is "value", however that one shouldn't be written in the multiple variables receiver (otherwise it would stack all variables and the stack ("value") itself!). + 'Warning: what if someone used the name value for one of it's variables independently from the multiple variables method ? Here if the receiver is actually in single mode, the variable "value" will still be given back, which throws the problem back to the creation of "value" in the multiple receiver case. + ElseIf clsParam.strArgumentName = "y" AndAlso (clsParam.strArgumentValue <> "value" OrElse ucrVariablesAsFactorForLinePlot.bSingleVariable) Then + 'Still might be in the case of bSingleVariable with mapping y="". + If clsParam.strArgumentValue = (Chr(34) & Chr(34)) Then + ucrVariablesAsFactorForLinePlot.Clear() + Else ucrVariablesAsFactorForLinePlot.Add(clsParam.strArgumentValue) + End If ElseIf clsParam.strArgumentName = "colour" Then ucrFactorOptionalReceiver.Add(clsParam.strArgumentValue) End If diff --git a/instat/dlgScatterPlot.vb b/instat/dlgScatterPlot.vb index 25b6bc19f23..20bb7337c4c 100644 --- a/instat/dlgScatterPlot.vb +++ b/instat/dlgScatterPlot.vb @@ -147,7 +147,7 @@ Public Class dlgScatterPlot 'Warning: what if someone used the name value for one of it's variables independently from the multiple variables method ? Here if the receiver is actually in single mode, the variable "value" will still be given back, which throws the problem back to the creation of "value" in the multiple receiver case. ElseIf clsParam.strArgumentName = "y" AndAlso (clsParam.strArgumentValue <> "value" OrElse ucrVariablesAsFactorForScatter.bSingleVariable) Then 'Still might be in the case of bSingleVariable with mapping y="". - If clsParam.strArgumentValue <> (Chr(34) & Chr(34)) Then + If clsParam.strArgumentValue = (Chr(34) & Chr(34)) Then ucrVariablesAsFactorForScatter.Clear() Else ucrVariablesAsFactorForScatter.Add(clsParam.strArgumentValue) End If diff --git a/instat/sdgAddNewDistribution.vb b/instat/sdgAddNewDistribution.vb index caa5eb21263..053a7771dec 100644 --- a/instat/sdgAddNewDistribution.vb +++ b/instat/sdgAddNewDistribution.vb @@ -16,6 +16,7 @@ Imports instat.Translations Public Class sdgAddNewDistribution Public bFirstLoad As Boolean = True + Public clsCompareDist As New RFunction Private Sub sdgAddNewDistribution_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then InitialiseDialog() @@ -33,4 +34,16 @@ Public Class sdgAddNewDistribution End Sub + Private Sub ucrNewDistributions_ParameterChanged() Handles ucrNewDistributions.ParameterChanged + newDist() + End Sub + + Private Sub newDist() + clsCompareDist.ClearParameters() + clsCompareDist.AddParameter("dist", Chr(34) & ucrNewDistributions.clsCurrDistribution.strRName & Chr(34)) + + For Each clstempparam In ucrNewDistributions.clsCurrRFunction.clsParameters + clsCompareDist.AddParameter(clstempparam.Clone()) + Next + End Sub End Class \ No newline at end of file diff --git a/instat/sdgLayerOptions.vb b/instat/sdgLayerOptions.vb index 03e30f36128..0ac98f56c96 100644 --- a/instat/sdgLayerOptions.vb +++ b/instat/sdgLayerOptions.vb @@ -105,6 +105,7 @@ Public Class sdgLayerOptions End If End If If clsGeomFunction.strRCommand = "geom_bar" OrElse clsGeomFunction.strRCommand = "geom_density" OrElse clsGeomFunction.strRCommand = "geom_freqpoly" Then + 'Warning: this is not working quite ok yet. Got some bad behaviour when "" comes from global aes, but is overwritten I think. Will tidy this up when introducing partially mandatory aesthetics method. 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 @@ -119,7 +120,7 @@ Public Class sdgLayerOptions 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" Then + 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 diff --git a/instat/ucrGeom.vb b/instat/ucrGeom.vb index 5907d296f70..b25b84778bc 100644 --- a/instat/ucrGeom.vb +++ b/instat/ucrGeom.vb @@ -579,8 +579,9 @@ Public Class ucrGeom clsgeom_line.strGeomName = "geom_line" 'mandatory - clsgeom_line.AddAesParameter("x", strIncludedDataTypes:={"factor", "numeric"}, bIsMandatory:=True) - clsgeom_line.AddAesParameter("y", strIncludedDataTypes:={"factor", "numeric"}, bIsMandatory:=True) + 'x and y are mandatory, but these are autofilled by "" when no variable is mapped. "Partially mandatory" + clsgeom_line.AddAesParameter("x", strIncludedDataTypes:={"factor", "numeric"}) + clsgeom_line.AddAesParameter("y", strIncludedDataTypes:={"factor", "numeric"}) 'optional clsgeom_line.AddAesParameter("alpha", strIncludedDataTypes:={"numeric", "factor"}) clsgeom_line.AddAesParameter("colour", strIncludedDataTypes:={"numeric", "factor"})