Skip to content

Commit

Permalink
Merge branch 'View.dialog' of https://github.com/Fidel365/R-Instat in…
Browse files Browse the repository at this point in the history
…to View.dialog
  • Loading branch information
Fidel365 committed Nov 13, 2024
2 parents 0199a50 + 67780a8 commit 7b3d371
Show file tree
Hide file tree
Showing 18 changed files with 998 additions and 1,062 deletions.
12 changes: 4 additions & 8 deletions instat/UserTables/sdgTableOptions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ Public Class sdgTableOptions
End Sub

''' <summary>
''' An R operateor that has a parameter named "gt" set up.
''' The parameter should be an R Function that generates script "gt:gt()" as part of the last script statement.
''' Sets up the sub dialog.
''' Expected to be called before showing the dialog.
''' </summary>
''' <param name="clsNewOperator"></param>
''' <param name="strDataFrameName">Name of the data frame contained in the data book</param>
''' <param name="clsNewOperator">R operator that has a 'gt' parameter that produces a 'gt' object.</param>
Public Sub Setup(strDataFrameName As String, clsNewOperator As ROperator)
If clsTablesUtils.FindRFunctionsParamsWithRCommand({"gt"}, clsNewOperator).Count = 0 Then
MsgBox("Developer Error: Parameter with 'gt' as name MUST be set up before using this subdialog")
Exit Sub
End If

clsOperator = clsNewOperator

ucrHeader.Setup(clsOperator)
Expand Down
14 changes: 7 additions & 7 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ Public Class RLink
Private strRVersionMajorRequired As String = "4"

''' <summary> The R version minor required. </summary>
Private strRVersionMinorRequired As String = "1"
Private strRVersionMinorRequired As String = "4"

''' <summary> The R version required. </summary>
Private strRVersionRequired As String = strRVersionMajorRequired & "." & strRVersionMinorRequired & ".0"
Private strRVersionRequired As String = strRVersionMajorRequired & "." & strRVersionMinorRequired & ".1"

''' <summary> The R bundled version. </summary>
Private strRBundledVersion As String = "4.1.3"
Private strRBundledVersion As String = "4.4.1"

Private clsOutputLogger As clsOutputLogger

Expand Down Expand Up @@ -200,9 +200,9 @@ Public Class RLink
Catch ex As Exception
MsgBox(ex.Message & Environment.NewLine & "Could not establish connection to R." & Environment.NewLine &
"R-Instat requires version " & strRVersionRequired & " of R." & Environment.NewLine &
"Note that R-Instat does not work with R below 3.5.0. We recommend using R " & strRBundledVersion &
". Try reruning the installation to install R " & strRBundledVersion & " or download R " &
strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.",
"Note that R-Instat does not work with R below 4.4.1. We recommend using R " & strRBundledVersion &
". Try rerunning the installation to install R " & strRBundledVersion & " or download R " &
strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.",
MsgBoxStyle.Critical, "Cannot initialise R connection.")
End Try

Expand All @@ -228,7 +228,7 @@ Public Class RLink
MsgBox("Could not determine version of R installed on your machine. R-Instat requires version: " & strRVersionRequired & vbNewLine &
"Try uninstalling any versions of R and rerun the installation to install R " & strRVersionRequired & " or download R " &
strRVersionRequired & "From https://cran.r-project.org/bin/windows/base/old/" & strRVersionRequired &
"And restart R-Instat.",
" and restart R-Instat.",
MsgBoxStyle.Critical, "R Version error.")
ElseIf strMajor <> strRVersionMajorRequired OrElse strMinor.Substring(0, 1) < strRVersionMinorRequired Then
MsgBox("Your current version of R is outdated. You are currently running R version: " & strMajor & "." & strMinor & Environment.NewLine &
Expand Down
46 changes: 31 additions & 15 deletions instat/dlgColumnStats.vb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ Public Class dlgColumnStats
ucrChkOriginalLevel.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkOriginalLevel.SetRDefault("FALSE")

ucrChkPrintOutput.SetParameter(New RParameter("return_output", 4))
ucrChkPrintOutput.SetText("Print Results to Output Window")
ucrChkPrintOutput.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkPrintOutput.SetRDefault("FALSE")

ucrChkDropUnusedLevels.SetParameter(New RParameter("drop", 5))
ucrChkDropUnusedLevels.SetText("Drop Unused Levels")
Expand Down Expand Up @@ -117,6 +114,7 @@ Public Class dlgColumnStats

clsDefaultFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$calculate_summary")
clsDefaultFunction.AddParameter("summaries", clsRFunctionParameter:=clsSummariesList)
clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3)
'Prevents an error if user chooses non count summaries with no columns to summarise
clsDefaultFunction.AddParameter("silent", "TRUE")
ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction)
Expand Down Expand Up @@ -157,11 +155,7 @@ Public Class dlgColumnStats
End Sub

Public Sub TestOKEnabled()
If ((ucrChkStoreResults.Checked OrElse ucrChkPrintOutput.Checked) AndAlso Not clsSummariesList.clsParameters.Count = 0) AndAlso sdgSummaries.bOkEnabled Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
ucrBase.OKEnabled(Not clsSummariesList.clsParameters.Count = 0 AndAlso sdgSummaries.bOkEnabled AndAlso Not ucrReceiverSelectedVariables.IsEmpty)
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand Down Expand Up @@ -226,14 +220,36 @@ Public Class dlgColumnStats
sdgMissingOptions.ShowDialog()
End Sub

'Private Sub ucrReceiverSelectedVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlValueChanged
' Dim bSameType As Boolean = Not ucrReceiverSelectedVariables.IsEmpty _
' AndAlso ucrReceiverSelectedVariables.GetCurrentItemTypes().All(Function(x) x = "factor")
' ucrChkDropUnusedLevels.Enabled = bSameType
' ucrChkDropUnusedLevels.Checked = Not bSameType
'End Sub
Private Sub ucrReceiverByFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverByFactor.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged, ucrReceiverSelectedVariables.ControlValueChanged, ucrChkOriginalLevel.ControlValueChanged
If Not ucrChkOriginalLevel.Checked Then
If ucrReceiverByFactor.IsEmpty AndAlso Not ucrReceiverSelectedVariables.IsEmpty Then
clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3)
clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4)
ucrBase.clsRsyntax.iCallType = 2
Else
clsDefaultFunction.RemoveParameterByName("return_output")
If ucrChkStoreResults.Checked Then
clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3)
Else
clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3)
End If
If ucrChkPrintOutput.Checked Then
clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4)
Else
clsDefaultFunction.AddParameter("return_output", "FALSE", iPosition:=4)
End If
End If
Else
If ucrChkPrintOutput.Checked Then
clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4)
Else
clsDefaultFunction.RemoveParameterByName("return_output")
End If
clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3)
End If
End Sub

Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrChkPrintOutput.ControlContentsChanged, ucrChkStoreResults.ControlContentsChanged
Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlContentsChanged
TestOKEnabled()
End Sub
End Class
1 change: 1 addition & 0 deletions instat/dlgDistances.vb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Public Class dlgDistances
autoTranslate(Me)
End Sub
Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 145

ucrSelectorDistance.SetParameter(New RParameter("df", 0))
ucrSelectorDistance.SetParameterIsrfunction()
Expand Down
2 changes: 1 addition & 1 deletion instat/dlgHeatMapPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Public Class dlgHeatMapPlot
Dim dctLegendPosition As New Dictionary(Of String, String)
Dim dctPalette As New Dictionary(Of String, String)

ucrBase.iHelpTopicID = 476
ucrBase.iHelpTopicID = 437
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False
ucrBase.clsRsyntax.iCallType = 3

Expand Down
12 changes: 0 additions & 12 deletions instat/dlgLinePlot.designer.vb

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

45 changes: 20 additions & 25 deletions instat/dlgLinePlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Public Class dlgLinePlot
Dim dctColourOptions As New Dictionary(Of String, String)
Dim dctSlopeLineColourOptions As New Dictionary(Of String, String)
Dim dctLegendPosition As New Dictionary(Of String, String)
Dim dctSlopePosition As New Dictionary(Of String, String)

ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False
ucrBase.clsRsyntax.iCallType = 3
Expand Down Expand Up @@ -393,10 +394,6 @@ Public Class dlgLinePlot
ucrChkSlopeLineOptions.AddParameterPresentCondition(True, "line_colour")
ucrChkSlopeLineOptions.AddParameterPresentCondition(False, "line_colour", False)

ucrChkSlopeLegend.SetText("Legend")
ucrChkSlopeLegend.AddParameterPresentCondition(True, "slopetheme")
ucrChkSlopeLegend.AddParameterPresentCondition(False, "slopetheme", False)

ucrChkLegend.SetText("Legend:")
ucrChkLegend.AddToLinkedControls({ucrInputLegendPosition}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="None")
ucrInputLegendPosition.SetDropDownStyleAsNonEditable()
Expand Down Expand Up @@ -433,7 +430,7 @@ Public Class dlgLinePlot
ucrPnlOptions.AddToLinkedControls({ucrReceiverSlopeY}, {rdoDumbbell, rdoSlope, rdoLinerange}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverX}, {rdoLine, rdoDumbbell, rdoSmoothing, rdoLinerange}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrVariablesAsFactorForLinePlot}, {rdoLine, rdoSmoothing}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverSlopeX, ucrReceiverSlopeColour, ucrChkSlopeLabelOptions, ucrChkSlopeTextOptions, ucrChkSlopeLineOptions, ucrChkSlopeLegend}, {rdoSlope}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverSlopeX, ucrReceiverSlopeColour, ucrChkSlopeLabelOptions, ucrChkSlopeTextOptions, ucrChkSlopeLineOptions}, {rdoSlope}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverYMax, ucrChkAddLineLineRange, ucrReceiverYMin, ucrChkRibbon}, {rdoLinerange}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrChkDumbbellColour.AddToLinkedControls({ucrInputDumbbellX}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedUpdateFunction:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Orange")
ucrChkDumbbellColour.AddToLinkedControls({ucrInputDumbbellXEnd}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedUpdateFunction:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Blue")
Expand Down Expand Up @@ -667,8 +664,7 @@ Public Class dlgLinePlot
ucrChkSlopeLabelOptions.SetRCode(clsGgSlopeFunction, bReset)
ucrChkSlopeTextOptions.SetRCode(clsGgSlopeFunction, bReset)
ucrChkSlopeLineOptions.SetRCode(clsGgSlopeFunction, bReset)
ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)
ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)

If bReset Then
ucrInputMethod.SetRCode(clsGeomSmoothFunction, bReset)
ucrChkRibbon.SetRCode(clsBaseOperator, bReset)
Expand All @@ -678,6 +674,8 @@ Public Class dlgLinePlot
ucrChkAddLineLineRange.SetRCode(clsBaseOperator, bReset)
ucrChkAddLine.SetRCode(clsBaseOperator, bReset)
ucrChkSpan.SetRCode(clsGeomSmoothFunction, bReset)
ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)
ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)
End If
SetGroupParam()
End Sub
Expand Down Expand Up @@ -801,7 +799,6 @@ Public Class dlgLinePlot
AddRemoveFormula()
AddRemoveGeomLine()
AddRemoveLineRange()
AddRemoveSlopeGraph()
AddRemoveMethodArgs()
AddRemoveLine()
AddRemoveSE()
Expand Down Expand Up @@ -858,9 +855,22 @@ Public Class dlgLinePlot
End Sub

Private Sub ucrChkLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegend.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged
AddRemoveTheme()
If rdoSlope.Checked Then
If ucrChkLegend.Checked Then
clsBaseOperator.AddParameter("theme", clsRFunctionParameter:=clsThemeFunction, iPosition:=-1)
clsThemeFunction.AddParameter("legend.position", Chr(34) & ucrInputLegendPosition.GetValueToSet & Chr(34), iPosition:=1)
clsBaseOperator.RemoveParameterByName("c")
Else
clsBaseOperator.RemoveParameterByName("theme")
clsBaseOperator.RemoveParameterByName("slopetheme")
End If
End If
If rdoLine.Checked OrElse rdoLinerange.Checked OrElse rdoSmoothing.Checked OrElse rdoDumbbell.Checked Then
AddRemoveTheme()
End If
End Sub


Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click, PlotOptionsToolStripMenuItem.Click
sdgPlots.SetRCode(clsNewOperator:=ucrBase.clsRsyntax.clsBaseOperator, clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction,
clsNewXLabsTitleFunction:=clsXlabsFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction,
Expand Down Expand Up @@ -1193,22 +1203,6 @@ Public Class dlgLinePlot
AddRemoveLineRange()
End Sub

Private Sub AddRemoveSlopeGraph()
If rdoSlope.Checked Then
If ucrChkSlopeLegend.Checked Then
clsBaseOperator.RemoveParameterByName("slopetheme")
Else
clsBaseOperator.AddParameter("slopetheme", clsRFunctionParameter:=clsSlopeThemeFunction, iPosition:=-1)
End If
Else
clsBaseOperator.RemoveParameterByName("slopetheme")
End If
End Sub

Private Sub ucrChkSlopeLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkSlopeLegend.ControlValueChanged
AddRemoveSlopeGraph()
End Sub

Private Sub AddRemoveLine()
If rdoSmoothing.Checked Then
If ucrChkAddLine.Checked Then
Expand Down Expand Up @@ -1278,4 +1272,5 @@ Public Class dlgLinePlot
Private Sub ucrChkAddLineLineRange_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkAddLineLineRange.ControlValueChanged
AddRemoveLineOnLineRange()
End Sub

End Class
Loading

0 comments on commit 7b3d371

Please sign in to comment.