Skip to content

Commit

Permalink
Merge branch 'restart_R' of https://github.com/N-thony/R-Instat into …
Browse files Browse the repository at this point in the history
…restart_R
  • Loading branch information
N-thony committed Feb 5, 2025
2 parents 595d012 + f7e8c39 commit a0338d0
Show file tree
Hide file tree
Showing 61 changed files with 3,041 additions and 1,209 deletions.
4 changes: 2 additions & 2 deletions inno_install_script_64bit.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppVersion= {#GetStringFileInfo("instat\bin\x64\Release\instat.exe", "FileVersion")}
AppId={{5455FC1A-85BE-4679-B600-8A1A4FC3CDD9-{#SetupSetting("AppVersion")}}
AppName=R-Instat
AppVerName ={code:GetShortAppVersion|{#SetupSetting("AppVersion")}}
AppName=R-Instat {#SetupSetting("AppVersion")}
AppVerName =R-Instat {#SetupSetting("AppVersion")}

AppPublisher=African Maths Initiative
AppPublisherURL=http://r-instat.org/
Expand Down
1 change: 1 addition & 0 deletions instat/Model/DataFrame/clsDataFrame.vb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Public Class clsDataFrame
Else
bRefreshed = False
End If
_clsVisibleDataFramePage.HasDataChangedForAutoSave = True
End If
_clsColumnMetaData.RefreshData()
Return bRefreshed
Expand Down
17 changes: 16 additions & 1 deletion instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Public Class clsDataFramePage
Private _lstColumns As List(Of clsColumnHeaderDisplay)
Private _hasChanged As Boolean
Private _useColumnSelectionInDataView As Boolean
Private _HasDataChangedForAutoSave As Boolean

Private ReadOnly Property iColumnIncrements As Integer
Get
Expand Down Expand Up @@ -140,6 +141,19 @@ Public Class clsDataFramePage
End Set
End Property

''' <summary>
''' holds whether the dataframe is different from visual grid component and trigger auto save
''' </summary>
''' <returns></returns>
Public Property HasDataChangedForAutoSave() As Boolean
Get
Return _HasDataChangedForAutoSave
End Get
Set(ByVal value As Boolean)
_HasDataChangedForAutoSave = value
End Set
End Property

''' <summary>
''' Create a new instance of a dataframe page
''' </summary>
Expand All @@ -152,6 +166,7 @@ Public Class clsDataFramePage
_iColumnStart = 1
_iRowStart = 1
_hasChanged = True
_HasDataChangedForAutoSave = True
_useColumnSelectionInDataView = True
End Sub

Expand Down Expand Up @@ -236,7 +251,7 @@ Public Class clsDataFramePage

Dim strDisable As String = If(bDisable, "TRUE", "FALSE")
clsEnableDisableUndoRFunction.AddParameter("disable_undo", strDisable)
_clsRLink.RunScript(clsEnableDisableUndoRFunction.ToScript)
_clsRLink.RunScript(clsEnableDisableUndoRFunction.ToScript, bSkipScriptAndOutput:=True)

End Sub

Expand Down
2 changes: 1 addition & 1 deletion instat/Model/RCommand/clsPrepareFunctionsForGrids.vb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Public Class clsPrepareFunctionsForGrids
clsViewDataFrame.AddParameter("x", clsRFunctionParameter:=clsGetDataFrame)
clsGetDataFrame.SetAssignTo(_strDataFrame)
strTemp = clsViewDataFrame.ToScript(strScript)
_RLink.RunScript(strScript & strTemp, strComment:="Right click menu: View R Data Frame", bSeparateThread:=False)
_RLink.RunScript(strScript & strTemp, strComment:="Toolbar Option: View R Data Frame", bSeparateThread:=False)
End Sub
''' <summary>
''' insert new rows
Expand Down
5 changes: 2 additions & 3 deletions instat/UserControl/ucrOutputPage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Public Class ucrOutputPage
End If

'if no contents added just exit sub
If richTextBox.TextLength = 0 Then
If String.IsNullOrWhiteSpace(richTextBox.Text) Then
Exit Sub
End If

Expand All @@ -211,11 +211,10 @@ Public Class ucrOutputPage
If frmMain.clsInstatOptions.bIncludeCommentDefault Then
'show comments only
For Each line As clsRScriptElement In formattedRScript
If line.Type = RToken.TokenTypes.RComment Then
If line.Type = RToken.TokenTypes.RComment OrElse line.Type = RToken.TokenTypes.RNewLine Then
AddFormatedTextToRichTextBox(richTextBox, line.Text, OutputFont.GetFontForScriptType(line.Type), OutputFont.GetColourForScriptType(line.Type))
End If
Next

ElseIf frmMain.clsInstatOptions.bCommandsinOutput Then
'show command lines that are not comments
For Each line As clsRScriptElement In formattedRScript
Expand Down
2 changes: 1 addition & 1 deletion instat/clsGgplotDefaults.vb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Public Class GgplotDefaults
Get
Dim strTemp As String()
'TODO need to make proper functions and set package names
strTemp = {"theme_bw", "theme_linedraw", "theme_light", "theme_minimal", "theme_classic", "theme_dark", "theme_void", "theme_base", "theme_calc", "theme_economist", "theme_few", "theme_fivethirtyeight", "theme_foundation", "theme_grey", "theme_gdocs", "theme_igray", "theme_map", "theme_par", "theme_solarized", "theme_hc", "theme_pander", "theme_solid", "theme_stata", "theme_tufte", "theme_wsj"}
strTemp = {"theme_bw", "theme_linedraw", "theme_light", "theme_minimal", "theme_classic", "theme_dark", "theme_void", "theme_base", "theme_calc", "theme_economist", "theme_few", "theme_fivethirtyeight", "theme_foundation", "theme_grey", "theme_gdocs", "theme_igray", "theme_map", "theme_par", "theme_solarized", "theme_hc", "theme_pander", "theme_solid", "theme_stata", "theme_tufte", "theme_wsj", "theme_excel", "theme_excel_new", "theme_economist_white", "theme_solarized_2", "reset_theme_settings"}
System.Array.Sort(Of String)(strTemp)
Return strTemp
End Get
Expand Down
9 changes: 6 additions & 3 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ Public Class RLink
Optional bSeparateThread As Boolean = True,
Optional bShowWaitDialogOverride As Nullable(Of Boolean) = Nothing,
Optional bUpdateGrids As Boolean = True,
Optional bSilent As Boolean = False)
Optional bSilent As Boolean = False,
Optional bSkipScriptAndOutput As Boolean = False)

'if there is no script to run then just ignore and exit sub
If String.IsNullOrWhiteSpace(strScript) Then
Expand Down Expand Up @@ -1043,8 +1044,10 @@ Public Class RLink
End If
End If

' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output
clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer)
If Not bSkipScriptAndOutput Then
' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output
clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer)
End If


Catch e As Exception
Expand Down
28 changes: 28 additions & 0 deletions instat/dlgBarAndPieChart.Designer.vb

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

80 changes: 69 additions & 11 deletions instat/dlgBarAndPieChart.vb
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ Public Class dlgBarAndPieChart
ucrPnlOptions.AddFunctionNamesCondition(rdoTreeMap, {"geom_treemap", "geom_treemap_text"})
ucrPnlOptions.AddFunctionNamesCondition(rdoWordCloud, {"geom_text_wordcloud", "scale_size_area"})

ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates, ucrChkPolarCoordinates, ucrReceiverByFactor, ucrInputBarChartPositions, ucrChkAddLabelsText, ucrVariablesAsFactorForBarChart, ucrChkBacktoback}, {rdoFrequency, rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrChkFlipCoordinates, ucrChkPolarCoordinates, ucrReceiverByFactor, ucrInputBarChartPositions, ucrChkAddLabelsText, ucrVariablesAsFactorForBarChart, ucrChkBacktoback}, {rdoFrequency, rdoValue}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverX, ucrChkReorderValue, ucrInputAddReorder, ucrChkLollipop}, {rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrChkReorderFrequency, ucrInputAddReorder}, {rdoFrequency}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrChkReorderFrequency, ucrChkBinWidth, ucrInputAddReorder}, {rdoFrequency}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverArea, ucrReceiverFill, ucrChkLayout, ucrChkStart, ucrChkAddLabelsTreemap}, {rdoTreeMap}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlOptions.AddToLinkedControls({ucrReceiverWordcloudAngle, ucrReceiverWordcloudColor, ucrReceiverWordcloudLabel, ucrReceiverWordcloudSize, ucrChkIncreaseSize}, {rdoWordCloud}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrReceiverByFactor.SetLinkedDisplayControl(lblByFactor)
Expand Down Expand Up @@ -301,6 +301,12 @@ Public Class dlgBarAndPieChart
ucrNudLollipopSize.Minimum = 1
ucrNudLollipopSize.Maximum = 15

ucrChkBinWidth.SetText("Binwidth")
ucrChkBinWidth.AddToLinkedControls({ucrInputWidth}, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:=1.5)

ucrInputWidth.SetParameter(New RParameter("binwidth", 3))
ucrInputWidth.SetValidationTypeAsNumeric()

ucrChkLollipop.SetText("Lollipop")
ucrChkLollipop.AddParameterPresentCondition(True, "geom_lollipop")
ucrChkLollipop.AddParameterPresentCondition(False, "geom_lollipop", False)
Expand Down Expand Up @@ -481,7 +487,6 @@ Public Class dlgBarAndPieChart
clsRgeomBarFunction.SetPackageName("ggplot2")
clsRgeomBarFunction.SetRCommand("geom_bar")
clsRgeomBarFunction.AddParameter("position", Chr(34) & "stack" & Chr(34), iPosition:=0)
clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1)

clsRggplotFunction.SetPackageName("ggplot2")
clsRggplotFunction.SetRCommand("ggplot")
Expand Down Expand Up @@ -641,6 +646,8 @@ Public Class dlgBarAndPieChart

clsBaseOperator.SetAssignTo("last_graph", strTempDataframe:=ucrBarChartSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph")
ucrBase.clsRsyntax.SetBaseROperator(clsBaseOperator)
HideShowWidth()
EnableDisablesOptions()
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
Expand Down Expand Up @@ -679,12 +686,15 @@ Public Class dlgBarAndPieChart
ucrChkReorderFrequency.SetRCode(clsDummyFunction, bReset)
ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)
ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True)
ucrInputWidth.SetRCode(clsRgeomBarFunction, bReset)

If bReset Then
ucrChkStart.SetRCode(clsGeomTreemapFunction, bReset)
ucrChkLayout.SetRCode(clsGeomTreemapFunction, bReset)
ucrChkIncreaseSize.SetRCode(clsScaleSizeAreaFunction, bReset)
ucrChkBinWidth.SetRCode(clsRgeomBarFunction, bReset)
End If
HideShowWidth()
End Sub

Private Sub TestOkEnabled()
Expand Down Expand Up @@ -816,6 +826,15 @@ Public Class dlgBarAndPieChart
openSdgLayerOptions(clsGeomTextFunction, clsTextAesFunction)
End Sub

Private Sub EnableDisablesOptions()
toolStripMenuItemBarchartOptions.Enabled = rdoFrequency.Checked OrElse rdoValue.Checked
toolStripMenuItemTextOptions.Enabled = ucrChkAddLabelsText.Checked AndAlso (rdoValue.Checked OrElse rdoFrequency.Checked)
toolStripMenuItemTreemapTextOptionsOptions.Enabled = ucrChkAddLabelsTreemap.Checked AndAlso rdoTreeMap.Checked
toolStripMenuItemWordcloudOptions.Enabled = rdoWordCloud.Checked AndAlso rdoWordCloud.Checked
toolStripMenuItemTreemapOptions.Enabled = rdoTreeMap.Checked
toolStripMenuItemLollipopOptions.Enabled = ucrChkLollipop.Checked AndAlso rdoValue.Checked
End Sub

Private Sub SetDialogOptions()
If rdoValue.Checked Or rdoFrequency.Checked Then
clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1)
Expand Down Expand Up @@ -1264,7 +1283,11 @@ Public Class dlgBarAndPieChart
ucrInputAddReorder.ControlValueChanged, ucrInputReorderValue.ControlValueChanged, ucrNudMaxSize.ControlValueChanged,
ucrChkIncreaseSize.ControlValueChanged, ucrChkLollipop.ControlValueChanged
SetDialogOptions()
EnableDisablesOptions()
ChangeParameterName()
AddStatsParm()
HideShowWidth()

If rdoTreeMap.Checked Then
ucrReceiverArea.SetMeAsReceiver()
ElseIf rdoWordCloud.Checked Then
Expand All @@ -1284,18 +1307,18 @@ Public Class dlgBarAndPieChart

Private Sub ucrChkBacktoback_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkBacktoback.ControlValueChanged,
ucrVariablesAsFactorForBarChart.ControlValueChanged, ucrReceiverX.ControlValueChanged, ucrPnlOptions.ControlValueChanged
clsBaseOperator.RemoveParameterByName("geom_bar1")
clsBaseOperator.RemoveParameterByName("geom_bar2")
clsBaseOperator.RemoveParameterByName("scale_y_symmetric")
clsAesFunction1.RemoveParameterByName("y")
clsAesFunction2.RemoveParameterByName("y")
clsRgeomBarFunction2.RemoveParameterByName("aes")
clsRgeomBarFunction1.RemoveParameterByName("aes")
clsRggplotFunction.RemoveParameterByName("aes")
If rdoFrequency.Checked OrElse rdoValue.Checked Then
clsBaseOperator.RemoveParameterByName("geom_bar1")
clsBaseOperator.RemoveParameterByName("geom_bar2")
clsBaseOperator.RemoveParameterByName("scale_y_symmetric")
clsAesFunction1.RemoveParameterByName("y")
clsAesFunction2.RemoveParameterByName("y")
clsRgeomBarFunction2.RemoveParameterByName("aes")
clsRgeomBarFunction1.RemoveParameterByName("aes")
ucrChkPolarCoordinates.Enabled = True
clsBaseOperator.AddParameter("geom_bar", clsRFunctionParameter:=clsRgeomBarFunction, iPosition:=2)
clsRggplotFunction.AddParameter("mapping", clsRFunctionParameter:=clsBarAesFunction, iPosition:=1)
clsRggplotFunction.RemoveParameterByName("aes")
If ucrChkBacktoback.Checked Then
ucrChkPolarCoordinates.Enabled = False
ucrChkPolarCoordinates.Checked = Not ucrChkBacktoback.Checked
Expand All @@ -1317,9 +1340,14 @@ Public Class dlgBarAndPieChart
clsRgeomBarFunction1.AddParameter("aes", clsRFunctionParameter:=clsAesFunction1, iPosition:=1, bIncludeArgumentName:=False)
End If
End If
Else
clsBaseOperator.RemoveParameterByName("geom_bar")
clsRggplotFunction.RemoveParameterByName("mapping")
End If
ChangeParameterName()
SetGeomTextOptions()
HideShowWidth()
AddStatsParm()
End Sub

Private Sub ucrChkPolarCoordinates_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkPolarCoordinates.ControlValueChanged, ucrPnlPolar.ControlValueChanged,
Expand Down Expand Up @@ -1390,10 +1418,40 @@ Public Class dlgBarAndPieChart
End Sub

Private Sub ucrChkAddLabelsTreemap_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkAddLabelsTreemap.ControlValueChanged
EnableDisablesOptions()
If ucrChkAddLabelsTreemap.Checked Then
clsBaseOperator.AddParameter("geom_treemap_text", clsRFunctionParameter:=clsGeomTreemapTextFunction, iPosition:=3)
Else
clsBaseOperator.RemoveParameterByName("geom_treemap_text")
End If
End Sub

Private Sub ucrChkBinWidth_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkBinWidth.ControlValueChanged, ucrInputWidth.ControlValueChanged, ucrVariablesAsFactorForBarChart.ControlValueChanged
If ucrChkBinWidth.Checked AndAlso ucrVariablesAsFactorForBarChart.ucrSingleVariable.strCurrDataType = "numeric" Then
clsRgeomBarFunction.AddParameter("binwidth", ucrInputWidth.GetText, iPosition:=4)
Else
clsRgeomBarFunction.RemoveParameterByName("binwidth")
End If
AddStatsParm()
HideShowWidth()
End Sub

Private Sub HideShowWidth()
If rdoFrequency.Checked AndAlso (Not ucrVariablesAsFactorForBarChart.IsEmpty AndAlso ucrVariablesAsFactorForBarChart.ucrSingleVariable.strCurrDataType = "numeric") Then
ucrChkBinWidth.Visible = True
ucrInputWidth.Visible = ucrChkBinWidth.Checked
Else
ucrChkBinWidth.Visible = False
ucrInputWidth.Visible = False
End If
End Sub

Private Sub AddStatsParm()
If rdoFrequency.Checked AndAlso ucrChkBinWidth.Checked AndAlso ucrVariablesAsFactorForBarChart.ucrSingleVariable.strCurrDataType = "numeric" Then
clsRgeomBarFunction.AddParameter("stat", Chr(34) & "bin" & Chr(34), iPosition:=1)
Else
clsRgeomBarFunction.AddParameter("stat", Chr(34) & "count" & Chr(34), iPosition:=1)
End If
End Sub

End Class
Loading

0 comments on commit a0338d0

Please sign in to comment.