diff --git a/instat/dlgDescribeTwoVarGraph.Designer.vb b/instat/dlgDescribeTwoVarGraph.Designer.vb index cac687f3ed6..f8bd1fbf831 100644 --- a/instat/dlgDescribeTwoVarGraph.Designer.vb +++ b/instat/dlgDescribeTwoVarGraph.Designer.vb @@ -103,6 +103,7 @@ Partial Class dlgDescribeTwoVarGraph Me.ucrChkAddLabelsText = New instat.ucrCheck() Me.lblLabelPosition = New System.Windows.Forms.Label() Me.ucrInputLabelColour = New instat.ucrInputComboBox() + Me.cmdPairOptions = New System.Windows.Forms.Button() Me.grpSummaries.SuspendLayout() Me.grpOptions.SuspendLayout() Me.grpTypeOfDispaly.SuspendLayout() @@ -747,7 +748,7 @@ Partial Class dlgDescribeTwoVarGraph Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrBase.Location = New System.Drawing.Point(10, 460) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 8 ' 'ucrReceiverFirstVars @@ -835,12 +836,24 @@ Partial Class dlgDescribeTwoVarGraph Me.ucrInputLabelColour.Size = New System.Drawing.Size(57, 21) Me.ucrInputLabelColour.TabIndex = 63 ' + 'cmdPairOptions + ' + Me.cmdPairOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.cmdPairOptions.Location = New System.Drawing.Point(11, 226) + Me.cmdPairOptions.Name = "cmdPairOptions" + Me.cmdPairOptions.Size = New System.Drawing.Size(119, 23) + Me.cmdPairOptions.TabIndex = 66 + Me.cmdPairOptions.Tag = "Options..." + Me.cmdPairOptions.Text = "Pair Plot Options" + Me.cmdPairOptions.UseVisualStyleBackColor = True + ' 'dlgDescribeTwoVarGraph ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.ClientSize = New System.Drawing.Size(438, 516) + Me.Controls.Add(Me.cmdPairOptions) Me.Controls.Add(Me.ucrInputLabelSize) Me.Controls.Add(Me.lblLabelColour) Me.Controls.Add(Me.lblLabelSize) @@ -946,4 +959,5 @@ Partial Class dlgDescribeTwoVarGraph Friend WithEvents ucrChkAddLabelsText As ucrCheck Friend WithEvents lblLabelPosition As Label Friend WithEvents ucrInputLabelColour As ucrInputComboBox + Friend WithEvents cmdPairOptions As Button End Class \ No newline at end of file diff --git a/instat/dlgDescribeTwoVarGraph.vb b/instat/dlgDescribeTwoVarGraph.vb index 10b5185322d..4b7340e7178 100644 --- a/instat/dlgDescribeTwoVarGraph.vb +++ b/instat/dlgDescribeTwoVarGraph.vb @@ -17,12 +17,12 @@ Imports instat.Translations Public Class dlgDescribeTwoVarGraph - Private clsBaseOperator, clsCoordPolarStartOperator As New ROperator + Private clsBaseOperator, clsPairOperator, clsCoordPolarStartOperator As New ROperator Private clsRGGplotFunction, clsMosaicGgplotFunction, clsRFacet, clsThemeFunction, clsGlobalAes, clsLabsFunction, clsXlabsFunction, clsYlabFunction, clsXScaleContinuousFunction, clsYScaleContinuousFunction, clsCoordPolarFunction, clsXScaleDateFunction, clsYScaleDateFunction, clsScaleFillViridisFunction, - clsScaleColourViridisFunction As New RFunction + clsScaleColourViridisFunction, clsPairThemesFunction As New RFunction 'Geoms Private clsGeomJitter, clsGeomViolin, clsGeomBar, clsGeomMosaic, clsGeomBoxplot, clsGeomPoint, clsGeomLine, clsStatSummaryHline, clsStatSummaryCrossbar, @@ -52,6 +52,7 @@ Public Class dlgDescribeTwoVarGraph Private strGeomParameterNames() As String = {"geom_jitter", "geom_violin", "geom_bar", "geom_mosaic", "geom_boxplot", "geom_point", "geom_line", "stat_summary_hline", "stat_summary_crossline", "geom_freqpoly", "geom_histogram", "geom_density"} Private strFirstVariablesType, strSecondVariableType As String + Private dctThemeFunctions As Dictionary(Of String, RFunction) Private bFirstLoad As Boolean = True Private bReset As Boolean = True @@ -274,8 +275,10 @@ Public Class dlgDescribeTwoVarGraph Private Sub SetDefaults() clsGGpairsFunction = New RFunction clsRGGplotFunction = New RFunction + clsPairThemesFunction = New RFunction clsMosaicGgplotFunction = New RFunction clsDummyFunction = New RFunction + clsPairOperator = New ROperator clsRFacet = New RFunction clsThemeFunction = GgplotDefaults.clsDefaultThemeFunction.Clone() dctThemeFunctions = New Dictionary(Of String, RFunction)(GgplotDefaults.dctThemeFunctions) @@ -329,7 +332,6 @@ Public Class dlgDescribeTwoVarGraph ucrSaveGraph.Reset() ucrSelectorTwoVarGraph.Reset() - cmdOptions.Enabled = False ucrReceiverFirstVars.SetMeAsReceiver() clsDummyFunction.AddParameter("checked", "pair", iPosition:=0) @@ -369,6 +371,13 @@ Public Class dlgDescribeTwoVarGraph clsGGpairsFunction.SetPackageName("GGally") clsGGpairsFunction.SetRCommand("ggpairs") + clsPairThemesFunction.SetPackageName("ggplot2") + clsPairThemesFunction.SetRCommand("theme") + clsPairThemesFunction.AddParameter("legend.position", Chr(34) & "none" & Chr(34), iPosition:=0) + + clsPairOperator.SetOperation("+") + clsPairOperator.AddParameter("left", clsRFunctionParameter:=clsGGpairsFunction, iPosition:=0) + clsBaseOperator.SetOperation("+") clsRGGplotFunction.SetPackageName("ggplot2") @@ -482,9 +491,11 @@ Public Class dlgDescribeTwoVarGraph clsBaseOperator.AddParameter("ggplot", clsRFunctionParameter:=clsRGGplotFunction, iPosition:=0) clsBaseOperator.SetAssignTo("last_graph", strTempDataframe:=ucrSelectorTwoVarGraph.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph") - ucrBase.clsRsyntax.SetBaseRFunction(clsGGpairsFunction) + clsPairOperator.SetAssignTo("last_graph", strTempDataframe:=ucrSelectorTwoVarGraph.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph") + + ucrBase.clsRsyntax.SetBaseROperator(clsPairOperator) + AddDataFrame() - ' bResetSubdialog = True End Sub Private Sub SetRCodeForControls(bReset As Boolean) @@ -495,7 +506,7 @@ Public Class dlgDescribeTwoVarGraph ucrReceiverSecondVar.AddAdditionalCodeParameterPair(clsAesCategoricalByNumericXNumeric, New RParameter("x", 0), iAdditionalPairNo:=4) ucrReceiverSecondVar.AddAdditionalCodeParameterPair(clsAesNumericByNumeric, New RParameter("x", 0), iAdditionalPairNo:=5) ucrReceiverSecondVar.AddAdditionalCodeParameterPair(clsAesStatSummaryHlineCategoricalByNumeric, New RParameter("y", 1), iAdditionalPairNo:=6) - ucrSaveGraph.AddAdditionalRCode(clsGGpairsFunction, bReset) + ucrSaveGraph.AddAdditionalRCode(clsPairOperator, bReset) ucrSelectorTwoVarGraph.SetRCode(clsRGGplotFunction, bReset) ucrReceiverSecondVar.SetRCode(clsAesCategoricalByCategoricalBarChart, bReset) @@ -532,12 +543,10 @@ Public Class dlgDescribeTwoVarGraph End Sub Private Sub TestOkEnabled() - If rdoBy.Checked AndAlso Not ucrReceiverFirstVars.IsEmpty AndAlso Not ucrReceiverSecondVar.IsEmpty AndAlso ucrSaveGraph.IsComplete Then - ucrBase.OKEnabled(True) - ElseIf rdoPairs.Checked AndAlso Not ucrReceiverFirstVars.IsEmpty Then - ucrBase.OKEnabled(True) + If rdoBy.Checked Then + ucrBase.OKEnabled(Not ucrReceiverFirstVars.IsEmpty AndAlso Not ucrReceiverSecondVar.IsEmpty AndAlso ucrSaveGraph.IsComplete) Else - ucrBase.OKEnabled(False) + ucrBase.OKEnabled(Not ucrReceiverFirstVars.IsEmpty) End If End Sub @@ -810,7 +819,9 @@ Public Class dlgDescribeTwoVarGraph ChangeGeomToMosaicAndFacet() End Sub - Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSecondVar.ControlContentsChanged, ucrReceiverFirstVars.ControlContentsChanged, ucrSaveGraph.ControlContentsChanged, ucrPnlByPairs.ControlContentsChanged + Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSecondVar.ControlContentsChanged, + ucrReceiverFirstVars.ControlContentsChanged, ucrSaveGraph.ControlContentsChanged, + ucrPnlByPairs.ControlContentsChanged, ucrReceiverColour.ControlContentsChanged TestOkEnabled() End Sub @@ -844,11 +855,17 @@ Public Class dlgDescribeTwoVarGraph sdgPlots.tbpFacet.Enabled = False sdgPlots.ShowDialog() sdgPlots.tbpFacet.Enabled = True - ' Readd as may get removed by subdialog clsRFacet.AddParameter("facets", "~variable", iPosition:=0) bResetSubdialog = False End Sub + Private Sub cmdPairOptions_Click(sender As Object, e As EventArgs) Handles cmdPairOptions.Click + sdgPairPlotOptions.SetRCode(clsNewPairOperator:=clsPairOperator, clsNewPairThemesFunction:=clsPairThemesFunction, clsNewGGpairAesFunction:=clsGGpairsFunction, bReset:=bResetSubdialog) + + sdgPairPlotOptions.ShowDialog() + bResetSubdialog = False + End Sub + Private Sub SetFreeYAxis() Dim clsScaleParam As RParameter Dim strXName As String @@ -898,7 +915,6 @@ Public Class dlgDescribeTwoVarGraph strXName = "x" strYName = "y" End If - If bAdd Then If clsRFacet.ContainsParameter("scales") Then clsScaleParam = clsRFacet.GetParameter("scales") @@ -952,10 +968,8 @@ Public Class dlgDescribeTwoVarGraph ucrReceiverFirstVars.ucrMultipleVariables.Clear() ucrReceiverFirstVars.SetMeAsReceiver() If rdoBy.Checked Then - cmdOptions.Enabled = True ucrReceiverFirstVars.ucrMultipleVariables.SetSingleTypeStatus(True, bIsCategoricalNumeric:=True) Else - cmdOptions.Enabled = False ucrReceiverFirstVars.ucrMultipleVariables.SetSingleTypeStatus(False) End If If bRCodeSet Then @@ -963,13 +977,14 @@ Public Class dlgDescribeTwoVarGraph ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator) clsDummyFunction.AddParameter("checked", "by", iPosition:=0) Else - ucrBase.clsRsyntax.SetBaseRFunction(clsGGpairsFunction) + ucrBase.clsRsyntax.SetBaseROperator(clsPairOperator) clsDummyFunction.AddParameter("checked", "pair", iPosition:=0) End If End If EnableVisibleLabelControls() AddRemoveColourParameter() ChangeGeomToMosaicAndFacet() + HideShowOptions() End Sub Private Sub ucrSelectorTwoVarGraph_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorTwoVarGraph.ControlValueChanged @@ -985,6 +1000,13 @@ Public Class dlgDescribeTwoVarGraph Private Sub ucrReceiverColour_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverColour.ControlValueChanged AddRemoveColourParameter() + HideShowOptions() + End Sub + + Private Sub HideShowOptions() + cmdOptions.Visible = Not rdoPairs.Checked + cmdPairOptions.Visible = rdoPairs.Checked + cmdPairOptions.Enabled = cmdPairOptions.Visible AndAlso Not ucrReceiverColour.IsEmpty End Sub Private Sub AddRemoveColourParameter() diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 14261159918..bbd8bccd841 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -239,6 +239,12 @@ + + sdgPairPlotOptions.vb + + + Form + sdgSummaryThemes.vb @@ -3087,6 +3093,9 @@ dlgThreeVariablePivotTable.vb + + sdgPairPlotOptions.vb + sdgSummaryThemes.vb diff --git a/instat/sdgPairPlotOptions.Designer.vb b/instat/sdgPairPlotOptions.Designer.vb new file mode 100644 index 00000000000..859df509766 --- /dev/null +++ b/instat/sdgPairPlotOptions.Designer.vb @@ -0,0 +1,108 @@ + _ +Partial Class sdgPairPlotOptions + Inherits System.Windows.Forms.Form + + 'Form remplace la méthode Dispose pour nettoyer la liste des composants. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Requise par le Concepteur Windows Form + Private components As System.ComponentModel.IContainer + + 'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form + 'Elle peut être modifiée à l'aide du Concepteur Windows Form. + 'Ne la modifiez pas à l'aide de l'éditeur de code. + _ + Private Sub InitializeComponent() + Me.tpLegend = New System.Windows.Forms.TabPage() + Me.ucrInputLegendPosition = New instat.ucrInputComboBox() + Me.ucrChkLegendPosition = New instat.ucrCheck() + Me.tbInventory = New System.Windows.Forms.TabControl() + Me.ucrButtonsInventoryplot = New instat.ucrButtonsSubdialogue() + Me.tpLegend.SuspendLayout() + Me.tbInventory.SuspendLayout() + Me.SuspendLayout() + ' + 'tpLegend + ' + Me.tpLegend.Controls.Add(Me.ucrInputLegendPosition) + Me.tpLegend.Controls.Add(Me.ucrChkLegendPosition) + Me.tpLegend.Location = New System.Drawing.Point(4, 22) + Me.tpLegend.Name = "tpLegend" + Me.tpLegend.Padding = New System.Windows.Forms.Padding(3) + Me.tpLegend.Size = New System.Drawing.Size(291, 36) + Me.tpLegend.TabIndex = 3 + Me.tpLegend.Text = "Legend" + Me.tpLegend.UseVisualStyleBackColor = True + ' + 'ucrInputLegendPosition + ' + Me.ucrInputLegendPosition.AddQuotesIfUnrecognised = True + Me.ucrInputLegendPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputLegendPosition.GetSetSelectedIndex = -1 + Me.ucrInputLegendPosition.IsReadOnly = False + Me.ucrInputLegendPosition.Location = New System.Drawing.Point(154, 3) + Me.ucrInputLegendPosition.Name = "ucrInputLegendPosition" + Me.ucrInputLegendPosition.Size = New System.Drawing.Size(134, 25) + Me.ucrInputLegendPosition.TabIndex = 1 + ' + 'ucrChkLegendPosition + ' + Me.ucrChkLegendPosition.AutoSize = True + Me.ucrChkLegendPosition.Checked = False + Me.ucrChkLegendPosition.Location = New System.Drawing.Point(7, 5) + Me.ucrChkLegendPosition.Name = "ucrChkLegendPosition" + Me.ucrChkLegendPosition.Size = New System.Drawing.Size(204, 23) + Me.ucrChkLegendPosition.TabIndex = 0 + ' + 'tbInventory + ' + Me.tbInventory.Controls.Add(Me.tpLegend) + Me.tbInventory.Location = New System.Drawing.Point(3, 0) + Me.tbInventory.Name = "tbInventory" + Me.tbInventory.SelectedIndex = 0 + Me.tbInventory.Size = New System.Drawing.Size(299, 62) + Me.tbInventory.TabIndex = 2 + ' + 'ucrButtonsInventoryplot + ' + Me.ucrButtonsInventoryplot.AutoSize = True + Me.ucrButtonsInventoryplot.Location = New System.Drawing.Point(46, 64) + Me.ucrButtonsInventoryplot.Name = "ucrButtonsInventoryplot" + Me.ucrButtonsInventoryplot.Size = New System.Drawing.Size(224, 30) + Me.ucrButtonsInventoryplot.TabIndex = 4 + ' + 'sdgPairPlotOptions + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(311, 98) + Me.Controls.Add(Me.ucrButtonsInventoryplot) + Me.Controls.Add(Me.tbInventory) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "sdgPairPlotOptions" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Pair Plot Options" + Me.tpLegend.ResumeLayout(False) + Me.tpLegend.PerformLayout() + Me.tbInventory.ResumeLayout(False) + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents tpLegend As TabPage + Friend WithEvents ucrInputLegendPosition As ucrInputComboBox + Friend WithEvents ucrChkLegendPosition As ucrCheck + Friend WithEvents tbInventory As TabControl + Friend WithEvents ucrButtonsInventoryplot As ucrButtonsSubdialogue +End Class diff --git a/instat/sdgPairPlotOptions.resx b/instat/sdgPairPlotOptions.resx new file mode 100644 index 00000000000..1af7de150c9 --- /dev/null +++ b/instat/sdgPairPlotOptions.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/sdgPairPlotOptions.vb b/instat/sdgPairPlotOptions.vb new file mode 100644 index 00000000000..2d2de9bb207 --- /dev/null +++ b/instat/sdgPairPlotOptions.vb @@ -0,0 +1,73 @@ +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . + +Imports instat +Imports instat.Translations +Public Class sdgPairPlotOptions + Public clsPairOperator As New ROperator + Public clsPairThemesFunction, clsGGpairsFunction As New RFunction + Private bControlsInitialised As Boolean = False + + Private Sub sdgPairPlotOptions_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub + + Public Sub InitialiseControls() + Dim dctLegendPosition As New Dictionary(Of String, String) + + ucrChkLegendPosition.SetText("Legend Position") + ucrChkLegendPosition.AddToLinkedControls(ucrInputLegendPosition, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="None") + ucrInputLegendPosition.SetDropDownStyleAsNonEditable() + ucrInputLegendPosition.SetParameter(New RParameter("legend.position")) + dctLegendPosition.Add("None", Chr(34) & "none" & Chr(34)) + dctLegendPosition.Add("Left", Chr(34) & "left" & Chr(34)) + dctLegendPosition.Add("Right", Chr(34) & "right" & Chr(34)) + dctLegendPosition.Add("Top", Chr(34) & "top" & Chr(34)) + dctLegendPosition.Add("Bottom", Chr(34) & "bottom" & Chr(34)) + ucrInputLegendPosition.SetItems(dctLegendPosition) + ucrChkLegendPosition.AddParameterPresentCondition(True, "legend_position") + ucrChkLegendPosition.AddParameterPresentCondition(False, "legend_position", False) + + bControlsInitialised = True + End Sub + + Public Sub SetRCode(clsNewPairOperator As ROperator, clsNewPairThemesFunction As RFunction, clsNewGGpairAesFunction As RFunction, Optional bReset As Boolean = False) + clsPairOperator = clsNewPairOperator + clsPairThemesFunction = clsNewPairThemesFunction + clsGGpairsFunction = clsNewGGpairAesFunction + + If Not bControlsInitialised Then + InitialiseControls() + End If + If bReset Then + ucrChkLegendPosition.SetRCode(clsPairThemesFunction, bReset, bCloneIfNeeded:=True) + ucrInputLegendPosition.SetRCode(clsPairThemesFunction, bReset, bCloneIfNeeded:=True) + End If + End Sub + + Private Sub ucrChkLegendPosition_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegendPosition.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged + If ucrChkLegendPosition.Checked Then + clsPairOperator.AddParameter("right", clsRFunctionParameter:=clsPairThemesFunction, iPosition:=1) + If ucrInputLegendPosition.GetText = "None" Then + clsGGpairsFunction.RemoveParameterByName("legend") + Else + clsGGpairsFunction.AddParameter("legend", 1, iPosition:=2) + End If + Else + clsPairOperator.RemoveParameterByName("right") + End If + End Sub +End Class \ No newline at end of file