Skip to content

Commit

Permalink
Merge branch 'epicsa2' of https://github.com/Vitalis95/R-Instat
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmusyoka committed Jun 24, 2024
2 parents 45e83c1 + eda90e1 commit d8fb82d
Show file tree
Hide file tree
Showing 54 changed files with 4,939 additions and 4,164 deletions.
2 changes: 2 additions & 0 deletions instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ Public Class clsDataFramePage
columnHeader.strTypeShortCode = "(CX)"
ElseIf strHeaderType.Contains("sfc_MULTIPOLYGON") OrElse strHeaderType.Contains("sfc") Then
columnHeader.strTypeShortCode = "(G)"
ElseIf strHeaderType.Contains("Timeseries") OrElse strHeaderType.Contains("ts") Then
columnHeader.strTypeShortCode = "(TS)"
' Types of data for specific Application areas e.g. survival are coded with "(A)"
' No examples implemented yet.
'ElseIf strType.Contains() Then
Expand Down
2 changes: 2 additions & 0 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,8 @@ Public Class RLink
clsGetItems.SetRCommand(strInstatDataObject & "$get_link_names")
Case "key"
clsGetItems.SetRCommand(strInstatDataObject & "$get_key_names")
Case "scalar"
clsGetItems.SetRCommand(strInstatDataObject & "$get_scalar_names")
Case "database_variables"
clsGetItems.SetRCommand(strInstatDataObject & "$get_database_variable_names")
clsGetItems.AddParameter("query", Chr(34) & strDatabaseQuery & Chr(34))
Expand Down
4 changes: 2 additions & 2 deletions instat/clsRSyntax.vb
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ Public Class RSyntax
'Sometimes the output of the R-command we deal with should not be part of the script...
'That's only the case when this output has already been assigned.
If (bUseBaseFunction AndAlso clsBaseFunction.IsAssigned()) OrElse
(bUseBaseOperator AndAlso clsBaseFunction.IsAssigned()) OrElse
(bUseCommandString AndAlso clsBaseFunction.IsAssigned()) Then
(bUseBaseOperator AndAlso clsBaseOperator.IsAssigned()) OrElse
(bUseCommandString AndAlso clsBaseCommandString.IsAssigned()) Then
Return strScript
End If
End If
Expand Down
2 changes: 1 addition & 1 deletion instat/dlgBoxPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Public Class dlgBoxplot

ucrSaveBoxplot.SetPrefix("box_plot")
ucrSaveBoxplot.SetIsComboBox()
ucrSaveBoxplot.SetCheckBoxText("Save Graph")
ucrSaveBoxplot.SetCheckBoxText("Store Graph")
ucrSaveBoxplot.SetSaveTypeAsGraph()
ucrSaveBoxplot.SetDataFrameSelector(ucrSelectorBoxPlot.ucrAvailableDataFrames)
ucrSaveBoxplot.SetAssignToIfUncheckedValue("last_graph")
Expand Down
137 changes: 122 additions & 15 deletions instat/dlgCalculator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Public Class dlgCalculator
Private clsAttachFunction As New RFunction
Private clsDetachFunction As New RFunction
Private clsRemoveLabelsFunction As New RFunction
Private clsScalarsDataFuntion, clsAddScalarFunction As New RFunction
Private clsAttachScalarsFunction, clsDetachScalarsFunction As New RFunction
Public bFirstLoad As Boolean = True
Public iHelpCalcID As Integer
'holds the original width of the form
Expand All @@ -35,15 +37,15 @@ Public Class dlgCalculator
iBasicWidth = Me.Width
SetDefaults()
bFirstLoad = False
Else
ReopenDialog()
End If

ReopenDialog()
TestOKEnabled()
autoTranslate(Me)
End Sub

Private Sub TestOKEnabled()
ucrBase.OKEnabled(Not ucrCalc.ucrReceiverForCalculation.IsEmpty AndAlso ucrCalc.ucrSaveResultInto.IsComplete)
ucrBase.OKEnabled(Not ucrCalc.ucrReceiverForCalculation.IsEmpty)
End Sub

Private Sub SetDefaults()
Expand All @@ -54,6 +56,8 @@ Public Class dlgCalculator
ucrCalc.ucrSaveResultInto.Reset()
ucrCalc.ucrSaveResultInto.ucrChkSave.Checked = True
ucrCalc.chkShowParameters.Checked = False
ucrCalc.ucrChkStoreScalar.Checked = False
ucrCalc.ucrSelectorForCalculations.ResetCheckBoxScalar()
ucrCalc.ucrSaveResultInto.SetRCode(ucrBase.clsRsyntax.clsBaseCommandString)
SaveResults()
ucrCalc.ucrSelectorForCalculations.bUseCurrentFilter = False
Expand All @@ -69,6 +73,8 @@ Public Class dlgCalculator

Private Sub ReopenDialog()
SaveResults()
ucrCalc.ucrSelectorForCalculations.ShowCheckBoxScalar(True)
ucrCalc.ucrChkStoreScalar.Checked = False
End Sub

Private Sub InitialiseDialog()
Expand All @@ -77,28 +83,64 @@ Public Class dlgCalculator
ucrCalc.ucrTryCalculator.SetIsCommand()
ucrCalc.ucrTryCalculator.SetReceiver(ucrCalc.ucrReceiverForCalculation)

ucrCalc.ucrSelectorForCalculations.SetItemType("column")
ucrCalc.ucrReceiverForCalculation.strSelectorHeading = "Variables"

clsAddScalarFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_scalar")

clsScalarsDataFuntion.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_scalars")
clsScalarsDataFuntion.SetAssignTo("scalars")

clsRemoveLabelsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_variables_metadata")
clsRemoveLabelsFunction.AddParameter("property", Chr(34) & "labels" & Chr(34), iPosition:=2)
clsRemoveLabelsFunction.AddParameter("new_val", Chr(34) & Chr(34), iPosition:=3)

clsAttachFunction.SetRCommand("attach")
clsDetachFunction.SetRCommand("detach")
clsAttachFunction.AddParameter("what", clsRFunctionParameter:=ucrCalc.ucrSelectorForCalculations.ucrAvailableDataFrames.clsCurrDataFrame)
clsDetachFunction.AddParameter("name", clsRFunctionParameter:=ucrCalc.ucrSelectorForCalculations.ucrAvailableDataFrames.clsCurrDataFrame)
clsDetachFunction.AddParameter("unload", "TRUE")

clsAttachScalarsFunction.SetRCommand("attach")
clsDetachScalarsFunction.SetRCommand("detach")
clsAttachScalarsFunction.AddParameter("what", clsRFunctionParameter:=clsScalarsDataFuntion)
clsDetachScalarsFunction.AddParameter("name", "scalars")
clsDetachScalarsFunction.AddParameter("unload", "TRUE")

ucrBase.clsRsyntax.AddToBeforeCodes(clsAttachFunction, 0)
ucrBase.clsRsyntax.AddToAfterCodes(clsDetachFunction, 0)
ucrBase.clsRsyntax.AddToBeforeCodes(clsAttachScalarsFunction, 1)

ucrBase.clsRsyntax.AddToAfterCodes(clsDetachFunction, 1)
ucrBase.clsRsyntax.AddToAfterCodes(clsDetachScalarsFunction, 2)

ucrBase.clsRsyntax.SetCommandString("")

ucrCalc.ucrSaveResultInto.SetPrefix("calc")
ucrCalc.ucrSaveResultInto.SetSaveTypeAsColumn()
ucrCalc.ucrSaveResultInto.SetIsComboBox()
ucrCalc.ucrSaveResultInto.SetCheckBoxText("Save Result")
ucrCalc.ucrSaveResultInto.SetCheckBoxText("Store Result")
ucrCalc.ucrSaveResultInto.SetAssignToIfUncheckedValue("last_calc")

ucrCalc.ucrSaveResultInto.SetDataFrameSelector(ucrCalc.ucrSelectorForCalculations.ucrAvailableDataFrames)
ucrCalc.ucrTryCalculator.StrvecOutputRequired()

AddHandler ucrCalc.ucrSelectorForCalculations.checkBoxScalar.CheckedChanged, AddressOf checkBoxScalar_CheckedChanged

End Sub

Private Sub checkBoxScalar_CheckedChanged()
SetItemType()
End Sub

Private Sub SetItemType()
If Not String.IsNullOrEmpty(ucrCalc.ucrSelectorForCalculations.strCurrentDataFrame) Then
If ucrCalc.ucrSelectorForCalculations.checkBoxScalar.Checked Then
ucrCalc.ucrReceiverForCalculation.strSelectorHeading = "Scalars"
ucrCalc.ucrSelectorForCalculations.SetItemType("scalar")
Else
ucrCalc.ucrReceiverForCalculation.strSelectorHeading = "Variables"
ucrCalc.ucrSelectorForCalculations.SetItemType("column")
End If
End If
End Sub

Public Sub SetDefaultKeyboard(strNewDefaultKeyboard As String)
Expand All @@ -112,7 +154,6 @@ Public Class dlgCalculator

Private Sub ucrCalc_SaveNameChanged() Handles ucrCalc.SaveNameChanged
SaveResults()
TestOKEnabled()
End Sub

Private Sub ucrCalc_ControlValueChanged() Handles ucrCalc.ControlValueChanged
Expand All @@ -125,7 +166,7 @@ Public Class dlgCalculator
Private Sub SaveResults()
If ucrCalc.ucrSaveResultInto.ucrChkSave.Checked AndAlso ucrCalc.ucrSaveResultInto.IsComplete Then
clsRemoveLabelsFunction.AddParameter("col_names", Chr(34) & ucrCalc.ucrSaveResultInto.GetText() & Chr(34), iPosition:=1)
ucrBase.clsRsyntax.AddToAfterCodes(clsRemoveLabelsFunction, 1)
ucrBase.clsRsyntax.AddToAfterCodes(clsRemoveLabelsFunction, 3)
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = True
ucrBase.clsRsyntax.iCallType = 0
Else
Expand All @@ -134,6 +175,43 @@ Public Class dlgCalculator
ucrBase.clsRsyntax.iCallType = 5
ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False
End If
ManageScalarStorage()
End Sub

Private Sub ManageScalarStorage()

Dim dataFrameName As String = ucrCalc.ucrSelectorForCalculations.strCurrentDataFrame

' Check if scalar should be stored
If ucrCalc.ucrChkStoreScalar.Checked AndAlso Not ucrCalc.ucrReceiverForCalculation.IsEmpty _
AndAlso ucrCalc.ucrSaveResultInto.GetText <> "" _
AndAlso Not String.IsNullOrEmpty(dataFrameName) Then
Dim strResut As String = ucrCalc.ucrSaveResultInto.GetText
clsAddScalarFunction.AddParameter("scalar_name", Chr(34) & strResut & Chr(34), iPosition:=1)
clsAddScalarFunction.AddParameter("scalar_value", strResut, iPosition:=2)
ucrBase.clsRsyntax.AddToAfterCodes(clsAddScalarFunction, 0)
ucrBase.clsRsyntax.SetAssignTo(strResut)
ucrCalc.ucrSaveResultInto.btnColumnPosition.Enabled = False
ucrCalc.ucrSaveResultInto.btnColumnPosition.Visible = True
ucrCalc.ucrSaveResultInto.ucrChkSave.Checked = False
ucrCalc.ucrSaveResultInto.ucrChkSave.Enabled = False
ucrCalc.ucrSaveResultInto.ucrInputComboSave.Visible = True
ucrCalc.ucrSaveResultInto.ucrInputComboSave.Enabled = True
Else
ucrBase.clsRsyntax.RemoveFromAfterCodes(clsAddScalarFunction)
ucrCalc.ucrSaveResultInto.btnColumnPosition.Enabled = True
ucrCalc.ucrSaveResultInto.btnColumnPosition.Visible = True
ucrCalc.ucrSaveResultInto.ucrChkSave.Enabled = True
ucrCalc.ucrSaveResultInto.ucrInputComboSave.Visible = True
ucrCalc.ucrSaveResultInto.ucrInputComboSave.Enabled = True

End If

' Update command string and clear input try message name
ucrBase.clsRsyntax.SetCommandString(ucrCalc.ucrReceiverForCalculation.GetVariableNames(False))

' Test if OK button can be enabled
TestOKEnabled()

End Sub

Expand All @@ -142,13 +220,46 @@ Public Class dlgCalculator
End Sub

Private Sub ucrCalc_SelectionChanged() Handles ucrCalc.SelectionChanged
ucrBase.clsRsyntax.SetCommandString(ucrCalc.ucrReceiverForCalculation.GetVariableNames(False))
ucrCalc.ucrTryCalculator.ucrInputTryMessage.SetName("")
ucrCalc.ucrChkStoreScalar.Checked = False
ManageScalarStorage()
SaveResults()
TestOKEnabled()
End Sub

Private Sub ucrSelectorForCalculation_DataframeChanged() Handles ucrCalc.DataFrameChanged
clsRemoveLabelsFunction.AddParameter("data_name", Chr(34) & ucrCalc.ucrSelectorForCalculations.strCurrentDataFrame & Chr(34), iPosition:=0)
If Not String.IsNullOrEmpty(ucrCalc.ucrSelectorForCalculations.strCurrentDataFrame) Then
Dim strDataFrame As String = ucrCalc.ucrSelectorForCalculations.strCurrentDataFrame
ucrCalc.ucrTryCalculator.ucrInputTryMessage.SetName("")
clsScalarsDataFuntion.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34))
clsDetachFunction.AddParameter("name", strDataFrame)
clsAddScalarFunction.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34), iPosition:=0)
clsRemoveLabelsFunction.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34), iPosition:=0)
SaveResults()
ucrBase.clsRsyntax.AddToBeforeCodes(clsAttachFunction, 0)
ucrBase.clsRsyntax.AddToBeforeCodes(clsAttachScalarsFunction, 1)

ucrBase.clsRsyntax.AddToAfterCodes(clsDetachFunction, 1)
ucrBase.clsRsyntax.AddToAfterCodes(clsDetachScalarsFunction, 2)
ucrCalc.ucrSaveResultInto.Enabled = True
ucrCalc.ucrChkStoreScalar.Visible = True
Else
ucrBase.clsRsyntax.RemoveFromBeforeCodes(clsAttachFunction)
ucrBase.clsRsyntax.RemoveFromBeforeCodes(clsAttachScalarsFunction)
ucrBase.clsRsyntax.RemoveFromAfterCodes(clsDetachFunction)
ucrBase.clsRsyntax.RemoveFromAfterCodes(clsDetachScalarsFunction)
ucrCalc.ucrSelectorForCalculations.ResetCheckBoxScalar()
ucrCalc.ucrSaveResultInto.Enabled = False
ucrCalc.ucrChkStoreScalar.Visible = False
ucrCalc.ucrChkStoreScalar.Checked = False
End If
End Sub

Private Sub ucrCalc_Click() Handles ucrCalc.CheckBoxClick
ManageScalarStorage()
End Sub

Private Sub ucrCalc_ClearClick() Handles ucrCalc.ClearClick
ucrCalc.ucrChkStoreScalar.Checked = False
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand Down Expand Up @@ -212,10 +323,6 @@ Public Class dlgCalculator
End Select
End Sub

Private Sub ucrSelectorForCalculations_DataframeChanged() Handles ucrCalc.DataFrameChanged
ucrCalc.ucrTryCalculator.ucrInputTryMessage.SetName("")
SaveResults()
End Sub
End Class


2 changes: 1 addition & 1 deletion instat/dlgCluster.vb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Public Class dlgCluster

ucrSaveDistance.SetSaveTypeAsDataFrame()
ucrSaveDistance.SetDataFrameSelector(ucrSelectorPrepareData.ucrAvailableDataFrames)
ucrSaveDistance.SetCheckBoxText("Save Result:")
ucrSaveDistance.SetCheckBoxText("Store Result:")
ucrSaveDistance.SetPrefix("distance")
ucrSaveDistance.SetIsComboBox()
ucrSaveDistance.SetAssignToIfUncheckedValue("last_distance")
Expand Down
2 changes: 1 addition & 1 deletion instat/dlgCompareColumns.vb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Public Class dlgCompareColumns

ucrSaveLogical.SetLabelText("New Column Name:")

ucrSaveLogical.SetLabelText("Save result for second column:")
ucrSaveLogical.SetLabelText("Store result for second column:")
ucrSaveLogical.setLinkedReceiver(ucrReceiverSecond)

ucrBase.clsRsyntax.iCallType = 2
Expand Down
4 changes: 1 addition & 3 deletions instat/dlgDeleteObjects.vb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ Public Class dlgDeleteObjects
dctTypes.Add("Filters", Chr(34) & "filter" & Chr(34))
dctTypes.Add("Column selections", Chr(34) & "column_selection" & Chr(34))
dctTypes.Add("Calculations", Chr(34) & "calculation" & Chr(34))
dctTypes.Add("Scalars", Chr(34) & "scalar" & Chr(34))
ucrInputComboType.SetItems(dctTypes)
ucrInputComboType.SetDropDownStyleAsNonEditable()

ucrReceiverObjectsToDelete.SetParameter(New RParameter("object_names", 1))
ucrReceiverObjectsToDelete.SetParameterIsString()
ucrReceiverObjectsToDelete.Selector = ucrSelectorDeleteObject
ucrReceiverObjectsToDelete.SetMeAsReceiver()



End Sub

Private Sub SetDefaults()
Expand Down
13 changes: 13 additions & 0 deletions instat/dlgDuplicateColumns.Designer.vb

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

14 changes: 14 additions & 0 deletions instat/dlgDuplicateColumns.vb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Public Class dlgDuplicateColumns
ucrChkConvertKeepAttributes.SetText("Keep Attributes")
ucrChkConvertKeepAttributes.SetRDefault("TRUE")

ucrPnlConvertTo.AddToLinkedControls(ucrChkIgnoreLabels, {rdoConvertToNumeric}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrChkIgnoreLabels.SetParameter(New RParameter("ignore_labels", 7))
ucrChkIgnoreLabels.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkIgnoreLabels.SetRDefault("FALSE")
ucrChkIgnoreLabels.SetText("Ignore Labels")

ucrPnlConvertTo.AddToLinkedControls(ucrChkConvertCreateLabels, {rdoConvertToNumeric}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrChkConvertCreateLabels.SetParameter(New RParameter("keep.labels", 7))
ucrChkConvertCreateLabels.SetText("Create Labels")
Expand Down Expand Up @@ -218,4 +224,12 @@ Public Class dlgDuplicateColumns
Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverDuplicateColumns.ControlContentsChanged, ucrPnlConvertTo.ControlContentsChanged, ucrNudConvertDisplayDecimals.ControlContentsChanged, ucrChkConvertSpecifyDecimalsToDisplay.ControlContentsChanged, ucrChkChangeType.ControlContentsChanged
TestOKEnabled()
End Sub

Private Sub ucrChkIgnoreLabels_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkIgnoreLabels.ControlValueChanged
If ucrChkIgnoreLabels.Checked Then
clsConvertFunction.AddParameter("ignore_labels", "TRUE")
Else
clsConvertFunction.RemoveParameterByName("ignore_labels")
End If
End Sub
End Class
Loading

0 comments on commit d8fb82d

Please sign in to comment.