diff --git a/instat/dlgCumulativeDistribution.Designer.vb b/instat/dlgCumulativeDistribution.Designer.vb index 07d77df1015..45a346662f0 100644 --- a/instat/dlgCumulativeDistribution.Designer.vb +++ b/instat/dlgCumulativeDistribution.Designer.vb @@ -54,6 +54,11 @@ Partial Class dlgCumulativeDistribution Me.ucrFactorReceiver = New instat.ucrReceiverSingle() Me.ucrCumDistSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() + Me.ucrInputStation = New instat.ucrInputComboBox() + Me.ucr1stFactorReceiver = New instat.ucrReceiverSingle() + Me.lblFacetBy = New System.Windows.Forms.Label() + Me.ucrInputLegendPosition = New instat.ucrInputComboBox() + Me.ucrChkLegend = New instat.ucrCheck() Me.SuspendLayout() ' 'lblFactors @@ -162,7 +167,7 @@ Partial Class dlgCumulativeDistribution ' Me.ucrPnlOption.Anchor = System.Windows.Forms.AnchorStyles.None Me.ucrPnlOption.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlOption.Location = New System.Drawing.Point(101, 9) + Me.ucrPnlOption.Location = New System.Drawing.Point(101, 7) Me.ucrPnlOption.Name = "ucrPnlOption" Me.ucrPnlOption.Size = New System.Drawing.Size(211, 38) Me.ucrPnlOption.TabIndex = 0 @@ -188,7 +193,7 @@ Partial Class dlgCumulativeDistribution 'ucrSaveCumDist ' Me.ucrSaveCumDist.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveCumDist.Location = New System.Drawing.Point(10, 327) + Me.ucrSaveCumDist.Location = New System.Drawing.Point(10, 373) Me.ucrSaveCumDist.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrSaveCumDist.Name = "ucrSaveCumDist" Me.ucrSaveCumDist.Size = New System.Drawing.Size(320, 24) @@ -236,17 +241,77 @@ Partial Class dlgCumulativeDistribution ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(10, 354) + Me.ucrBase.Location = New System.Drawing.Point(10, 402) 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 = 15 ' + 'ucrInputStation + ' + Me.ucrInputStation.AddQuotesIfUnrecognised = True + Me.ucrInputStation.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputStation.GetSetSelectedIndex = -1 + Me.ucrInputStation.IsReadOnly = False + Me.ucrInputStation.Location = New System.Drawing.Point(313, 336) + Me.ucrInputStation.Name = "ucrInputStation" + Me.ucrInputStation.Size = New System.Drawing.Size(101, 21) + Me.ucrInputStation.TabIndex = 101 + ' + 'ucr1stFactorReceiver + ' + Me.ucr1stFactorReceiver.AutoSize = True + Me.ucr1stFactorReceiver.frmParent = Me + Me.ucr1stFactorReceiver.Location = New System.Drawing.Point(202, 337) + Me.ucr1stFactorReceiver.Margin = New System.Windows.Forms.Padding(0) + Me.ucr1stFactorReceiver.Name = "ucr1stFactorReceiver" + Me.ucr1stFactorReceiver.Selector = Nothing + Me.ucr1stFactorReceiver.Size = New System.Drawing.Size(110, 26) + Me.ucr1stFactorReceiver.strNcFilePath = "" + Me.ucr1stFactorReceiver.TabIndex = 100 + Me.ucr1stFactorReceiver.ucrSelector = Nothing + ' + 'lblFacetBy + ' + Me.lblFacetBy.AutoSize = True + Me.lblFacetBy.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblFacetBy.Location = New System.Drawing.Point(204, 322) + Me.lblFacetBy.Name = "lblFacetBy" + Me.lblFacetBy.Size = New System.Drawing.Size(52, 13) + Me.lblFacetBy.TabIndex = 99 + Me.lblFacetBy.Tag = "" + Me.lblFacetBy.Text = "Facet By:" + ' + '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(88, 336) + Me.ucrInputLegendPosition.Name = "ucrInputLegendPosition" + Me.ucrInputLegendPosition.Size = New System.Drawing.Size(112, 21) + Me.ucrInputLegendPosition.TabIndex = 103 + ' + 'ucrChkLegend + ' + Me.ucrChkLegend.AutoSize = True + Me.ucrChkLegend.Checked = False + Me.ucrChkLegend.Location = New System.Drawing.Point(9, 337) + Me.ucrChkLegend.Name = "ucrChkLegend" + Me.ucrChkLegend.Size = New System.Drawing.Size(98, 24) + Me.ucrChkLegend.TabIndex = 102 + ' 'dlgCumulativeDistribution ' 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(415, 410) + Me.ClientSize = New System.Drawing.Size(415, 458) + Me.Controls.Add(Me.ucrInputStation) + Me.Controls.Add(Me.ucr1stFactorReceiver) + Me.Controls.Add(Me.lblFacetBy) + Me.Controls.Add(Me.ucrInputLegendPosition) + Me.Controls.Add(Me.ucrChkLegend) Me.Controls.Add(Me.rdoExceedance) Me.Controls.Add(Me.rdoCumulative) Me.Controls.Add(Me.ucrNudBy) @@ -291,4 +356,9 @@ Partial Class dlgCumulativeDistribution Friend WithEvents lblNudby As Label Friend WithEvents rdoExceedance As RadioButton Friend WithEvents rdoCumulative As RadioButton + Friend WithEvents ucrInputStation As ucrInputComboBox + Friend WithEvents ucr1stFactorReceiver As ucrReceiverSingle + Friend WithEvents lblFacetBy As Label + Friend WithEvents ucrInputLegendPosition As ucrInputComboBox + Friend WithEvents ucrChkLegend As ucrCheck End Class diff --git a/instat/dlgCumulativeDistribution.vb b/instat/dlgCumulativeDistribution.vb index dbf8902b5ae..cd123316452 100644 --- a/instat/dlgCumulativeDistribution.vb +++ b/instat/dlgCumulativeDistribution.vb @@ -41,6 +41,21 @@ Public Class dlgCumulativeDistribution Private clsSequence As New RFunction Private bReset As Boolean = True + Private clsFacetFunction As New RFunction + Private clsFacetVariablesOperator As New ROperator + Private clsFacetRowOp As New ROperator + Private clsFacetColOp As New ROperator + Private clsPipeOperator As New ROperator + Private clsGroupByFunction As New RFunction + + Private ReadOnly strNone As String = "None" + Private ReadOnly strFacetWrap As String = "Facet Wrap" + Private ReadOnly strFacetRow As String = "Facet Row" + Private ReadOnly strFacetCol As String = "Facet Column" + + Private bUpdateComboOptions As Boolean = True + Private bUpdatingParameters As Boolean = False + Private strFirstParameterName As String = "stat_ecdf" Private strFirstPointParameterName As String = "stat_ecdf2" Private strYScleParameterName As String = "YscaleContinous" @@ -65,6 +80,7 @@ Public Class dlgCumulativeDistribution Private Sub InitaliseDialog() Dim dctScalesPairs As New Dictionary(Of String, String) + Dim dctLegendPosition As New Dictionary(Of String, String) ucrChkCountsOnYAxis.Enabled = False ' temporary What should this do? @@ -120,6 +136,32 @@ Public Class dlgCumulativeDistribution 'ucrInputComboPad.SetDropDownStyleAsNonEditable() 'ucrInputComboPad.SetRDefault("TRUE") + ucrChkLegend.SetText("Legend:") + ucrChkLegend.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) + ucrChkLegend.AddParameterPresentCondition(True, "legend.position") + ucrChkLegend.AddParameterPresentCondition(False, "legend.position", False) + + ucr1stFactorReceiver.SetParameter(New RParameter("var1")) + ucr1stFactorReceiver.Selector = ucrCumDistSelector + ucr1stFactorReceiver.SetIncludedDataTypes({"factor"}) + ucr1stFactorReceiver.strSelectorHeading = "Factors" + ucr1stFactorReceiver.bWithQuotes = False + ucr1stFactorReceiver.SetParameterIsString() + ucr1stFactorReceiver.SetValuesToIgnore({"."}) + ucr1stFactorReceiver.SetParameterPosition(1) + ucr1stFactorReceiver.SetLinkedDisplayControl(lblFacetBy) + + ucrInputStation.SetItems({strFacetWrap, strFacetRow, strFacetCol, strNone}) + ucrInputStation.SetDropDownStyleAsNonEditable() + ucrSaveCumDist.SetSaveTypeAsGraph() ucrSaveCumDist.SetDataFrameSelector(ucrCumDistSelector.ucrAvailableDataFrames) ucrSaveCumDist.SetCheckBoxText("Save Graph") @@ -136,6 +178,16 @@ Public Class dlgCumulativeDistribution clsRggplotFunction = New RFunction clsStatECDFAesFunction = New RFunction clsStatECDFPointAesFunction = New RFunction + clsFacetFunction = New RFunction + clsFacetVariablesOperator = New ROperator + clsFacetRowOp = New ROperator + clsFacetColOp = New ROperator + clsPipeOperator = New ROperator + clsGroupByFunction = New RFunction + + ucrInputStation.SetName(strFacetWrap) + ucrInputStation.bUpdateRCodeFromControl = True + clsSequence = New RFunction clsSequence.SetRCommand("seq") @@ -185,6 +237,22 @@ Public Class dlgCumulativeDistribution clsLabsFunction.SetRCommand("labs") clsLabsFunction.AddParameter("y", "NULL") + clsFacetFunction.SetPackageName("ggplot2") + clsFacetRowOp.SetOperation("+") + clsFacetRowOp.bBrackets = False + clsFacetColOp.SetOperation("+") + clsFacetColOp.bBrackets = False + clsFacetVariablesOperator.SetOperation("~") + clsFacetVariablesOperator.bForceIncludeOperation = True + clsFacetVariablesOperator.bBrackets = False + clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetVariablesOperator, iPosition:=0) + + clsPipeOperator.SetOperation("%>%") + SetPipeAssignTo() + + clsGroupByFunction.SetPackageName("dplyr") + clsGroupByFunction.SetRCommand("group_by") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() @@ -224,6 +292,9 @@ Public Class dlgCumulativeDistribution ucrChkIncludePoints.SetRCode(clsStatECDFPointFunction, bReset) + ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + ucrNudBy.SetRCode(clsSequence, bReset) End Sub @@ -246,7 +317,7 @@ Public Class dlgCumulativeDistribution sdgPlots.SetRCode(clsBaseOperator, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, clsNewGlobalAesFunction:=clsRaesFunction, clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewXLabsTitleFunction:=clsXlabsFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, - clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, ucrNewBaseSelector:=ucrCumDistSelector, clsNewCoordPolarFunction:=clsCoordPolarFunction, + clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, ucrNewBaseSelector:=ucrCumDistSelector, clsNewCoordPolarFunction:=clsCoordPolarFunction, clsNewFacetVariablesOperator:=clsFacetVariablesOperator, clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, clsNewAnnotateFunction:=clsAnnotateFunction, strMainDialogGeomParameterNames:=strGeomParameterNames, bReset:=bResetSubdialog) sdgPlots.ShowDialog() @@ -275,4 +346,173 @@ Public Class dlgCumulativeDistribution clsBaseOperator.RemoveParameterByName(strFirstPointParameterName) End If End Sub + + Private Sub AddRemoveTheme() + If clsThemeFunction.iParameterCount > 0 Then + clsBaseOperator.AddParameter("theme", clsRFunctionParameter:=clsThemeFunction, iPosition:=15) + Else + clsBaseOperator.RemoveParameterByName("theme") + End If + End Sub + + Private Sub ucrChkLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegend.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged + AddRemoveTheme() + End Sub + + Private Sub AutoFacetStation() + Dim currentReceiver As ucrReceiver = ucrCumDistSelector.CurrentReceiver + + If currentReceiver IsNot Nothing Then + ucr1stFactorReceiver.AddItemsWithMetadataProperty(ucrCumDistSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Climatic_Type", {"station_label"}) + currentReceiver.SetMeAsReceiver() + AddRemoveGroupBy() + End If + End Sub + Private Sub ucrInput_ControlValueChanged(ucrChangedControl As ucrInputComboBox) Handles ucrInputStation.ControlValueChanged + If Not bUpdateComboOptions Then + Exit Sub + End If + Dim strChangedText As String = ucrChangedControl.GetText() + If strChangedText <> strNone Then + If Not strChangedText = strFacetCol AndAlso Not strChangedText = strFacetRow AndAlso + Not ucrInputStation.Equals(ucrChangedControl) AndAlso ucrInputStation.GetText() = strChangedText Then + bUpdateComboOptions = False + ucrInputStation.SetName(strNone) + bUpdateComboOptions = True + End If + If (strChangedText = strFacetWrap AndAlso ucrInputStation.GetText = strFacetRow) OrElse (strChangedText = strFacetRow AndAlso + ucrInputStation.GetText = strFacetWrap) OrElse (strChangedText = strFacetWrap AndAlso + ucrInputStation.GetText = strFacetCol) OrElse (strChangedText = strFacetCol AndAlso ucrInputStation.GetText = strFacetWrap) Then + ucrInputStation.SetName(strNone) + End If + End If + UpdateParameters() + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub UpdateParameters() + clsFacetVariablesOperator.RemoveParameterByName("var1") + clsFacetColOp.RemoveParameterByName("col" & ucrInputStation.Name) + clsFacetRowOp.RemoveParameterByName("row" & ucrInputStation.Name) + + clsBaseOperator.RemoveParameterByName("facets") + bUpdatingParameters = True + ucr1stFactorReceiver.SetRCode(Nothing) + Select Case ucrInputStation.GetText() + Case strFacetWrap + ucr1stFactorReceiver.ChangeParameterName("var1") + ucr1stFactorReceiver.SetRCode(clsFacetVariablesOperator) + Case strFacetCol + ucr1stFactorReceiver.ChangeParameterName("col" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetColOp) + Case strFacetRow + ucr1stFactorReceiver.ChangeParameterName("row" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetRowOp) + End Select + If Not clsRaesFunction.ContainsParameter("x") Then + clsRaesFunction.AddParameter("x", Chr(34) & Chr(34)) + End If + bUpdatingParameters = False + End Sub + + Private Sub AddRemoveFacets() + Dim bWrap As Boolean = False + Dim bCol As Boolean = False + Dim bRow As Boolean = False + + If bUpdatingParameters Then + Exit Sub + End If + + clsBaseOperator.RemoveParameterByName("facets") + If Not ucr1stFactorReceiver.IsEmpty Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + bWrap = True + Case strFacetCol + bCol = True + Case strFacetRow + bRow = True + End Select + End If + + If bWrap OrElse bRow OrElse bCol Then + clsBaseOperator.AddParameter("facets", clsRFunctionParameter:=clsFacetFunction) + End If + If bWrap Then + clsFacetFunction.SetRCommand("facet_wrap") + End If + If bRow OrElse bCol Then + clsFacetFunction.SetRCommand("facet_grid") + End If + If bRow Then + clsFacetVariablesOperator.AddParameter("left", clsROperatorParameter:=clsFacetRowOp, iPosition:=0) + ElseIf bCol AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("left", ".", iPosition:=0) + Else + clsFacetVariablesOperator.RemoveParameterByName("left") + End If + If bCol Then + clsFacetVariablesOperator.AddParameter("right", clsROperatorParameter:=clsFacetColOp, iPosition:=1) + ElseIf bRow AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("right", ".", iPosition:=1) + Else + clsFacetVariablesOperator.RemoveParameterByName("right") + End If + End Sub + + Private Sub ucr1stFactorReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucr1stFactorReceiver.ControlValueChanged, ucrVariablesAsFactorforCumDist.ControlValueChanged + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub GetParameterValue(clsOperator As ROperator) + Dim i As Integer = 0 + For Each clsTempParam As RParameter In clsOperator.clsParameters + If clsTempParam.strArgumentValue <> "" AndAlso clsTempParam.strArgumentValue <> "." Then + clsGroupByFunction.AddParameter(i, clsTempParam.strArgumentValue, bIncludeArgumentName:=False, iPosition:=i) + i = i + 1 + End If + Next + End Sub + + Private Sub AddRemoveGroupBy() + If clsPipeOperator.ContainsParameter("mutate") Then + clsGroupByFunction.ClearParameters() + If clsBaseOperator.ContainsParameter("facets") Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + GetParameterValue(clsFacetVariablesOperator) + Case strFacetCol + GetParameterValue(clsFacetColOp) + Case strFacetRow + GetParameterValue(clsFacetRowOp) + End Select + End If + + If clsGroupByFunction.iParameterCount > 0 Then + clsPipeOperator.AddParameter("group_by", clsRFunctionParameter:=clsGroupByFunction, iPosition:=1) + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + + SetPipeAssignTo() + End Sub + + Private Sub SetPipeAssignTo() + If ucrCumDistSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" AndAlso clsPipeOperator.clsParameters.Count > 1 Then + clsPipeOperator.SetAssignTo(ucrCumDistSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text) + Else + clsPipeOperator.RemoveAssignTo() + End If + End Sub + + Private Sub ucrCumDistSelector_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrCumDistSelector.ControlValueChanged + AutoFacetStation() + SetPipeAssignTo() + End Sub End Class \ No newline at end of file diff --git a/instat/dlgHeatMapPlot.Designer.vb b/instat/dlgHeatMapPlot.Designer.vb index dd78aa726a6..9ff7ff37d50 100644 --- a/instat/dlgHeatMapPlot.Designer.vb +++ b/instat/dlgHeatMapPlot.Designer.vb @@ -54,6 +54,18 @@ Partial Class dlgHeatMapPlot Me.lblLongitude = New System.Windows.Forms.Label() Me.lblLatitude = New System.Windows.Forms.Label() Me.lblFillChoropleth = New System.Windows.Forms.Label() + Me.lblGroup = New System.Windows.Forms.Label() + Me.contextMenuStripOptions = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.toolStripMenuItemPlotOptions = New System.Windows.Forms.ToolStripMenuItem() + Me.toolStripMenuItemTileOptions = New System.Windows.Forms.ToolStripMenuItem() + Me.toolStripMenuItemPolygonOptions = New System.Windows.Forms.ToolStripMenuItem() + Me.lblFacetBy = New System.Windows.Forms.Label() + Me.ucrInputStation = New instat.ucrInputComboBox() + Me.ucr1stFactorReceiver = New instat.ucrReceiverSingle() + Me.ucrInputLegendPosition = New instat.ucrInputComboBox() + Me.ucrChkLegend = New instat.ucrCheck() + Me.cmdOptions = New instat.ucrSplitButton() + Me.ucrChkPoints = New instat.ucrCheck() Me.ucrChkFlipCoordinates = New instat.ucrCheck() Me.ucrReceiverPointsHeatMap = New instat.ucrReceiverSingle() Me.ucrNudShapeHeatMap = New instat.ucrNud() @@ -71,18 +83,11 @@ Partial Class dlgHeatMapPlot Me.ucrVariableAsFactorForHeatMap = New instat.ucrVariablesAsFactor() Me.ucrInputReorderVariableX = New instat.ucrInputComboBox() Me.ucrInputSize = New instat.ucrInputComboBox() - Me.ucrChkAddLabels = New instat.ucrCheck() Me.ucrInputPosition = New instat.ucrInputComboBox() Me.ucrInputColour = New instat.ucrInputComboBox() Me.ucrReceiverX = New instat.ucrReceiverSingle() Me.ucrReceiverGroup = New instat.ucrReceiverSingle() - Me.lblGroup = New System.Windows.Forms.Label() - Me.ucrChkPoints = New instat.ucrCheck() - Me.contextMenuStripOptions = New System.Windows.Forms.ContextMenuStrip(Me.components) - Me.toolStripMenuItemPlotOptions = New System.Windows.Forms.ToolStripMenuItem() - Me.toolStripMenuItemTileOptions = New System.Windows.Forms.ToolStripMenuItem() - Me.toolStripMenuItemPolygonOptions = New System.Windows.Forms.ToolStripMenuItem() - Me.cmdOptions = New instat.ucrSplitButton() + Me.ucrChkAddLabels = New instat.ucrCheck() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -174,6 +179,84 @@ Partial Class dlgHeatMapPlot Me.lblFillChoropleth.Name = "lblFillChoropleth" Me.lblFillChoropleth.Tag = "fill" ' + 'lblGroup + ' + resources.ApplyResources(Me.lblGroup, "lblGroup") + Me.lblGroup.Name = "lblGroup" + ' + 'contextMenuStripOptions + ' + Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemTileOptions, Me.toolStripMenuItemPolygonOptions}) + Me.contextMenuStripOptions.Name = "contextMenuStripOk" + resources.ApplyResources(Me.contextMenuStripOptions, "contextMenuStripOptions") + ' + 'toolStripMenuItemPlotOptions + ' + Me.toolStripMenuItemPlotOptions.Name = "toolStripMenuItemPlotOptions" + resources.ApplyResources(Me.toolStripMenuItemPlotOptions, "toolStripMenuItemPlotOptions") + ' + 'toolStripMenuItemTileOptions + ' + Me.toolStripMenuItemTileOptions.Name = "toolStripMenuItemTileOptions" + resources.ApplyResources(Me.toolStripMenuItemTileOptions, "toolStripMenuItemTileOptions") + ' + 'toolStripMenuItemPolygonOptions + ' + Me.toolStripMenuItemPolygonOptions.Name = "toolStripMenuItemPolygonOptions" + resources.ApplyResources(Me.toolStripMenuItemPolygonOptions, "toolStripMenuItemPolygonOptions") + ' + 'lblFacetBy + ' + resources.ApplyResources(Me.lblFacetBy, "lblFacetBy") + Me.lblFacetBy.Name = "lblFacetBy" + Me.lblFacetBy.Tag = "" + ' + 'ucrInputStation + ' + Me.ucrInputStation.AddQuotesIfUnrecognised = True + resources.ApplyResources(Me.ucrInputStation, "ucrInputStation") + Me.ucrInputStation.GetSetSelectedIndex = -1 + Me.ucrInputStation.IsReadOnly = False + Me.ucrInputStation.Name = "ucrInputStation" + ' + 'ucr1stFactorReceiver + ' + resources.ApplyResources(Me.ucr1stFactorReceiver, "ucr1stFactorReceiver") + Me.ucr1stFactorReceiver.frmParent = Me + Me.ucr1stFactorReceiver.Name = "ucr1stFactorReceiver" + Me.ucr1stFactorReceiver.Selector = Nothing + Me.ucr1stFactorReceiver.strNcFilePath = "" + Me.ucr1stFactorReceiver.ucrSelector = Nothing + ' + 'ucrInputLegendPosition + ' + Me.ucrInputLegendPosition.AddQuotesIfUnrecognised = True + resources.ApplyResources(Me.ucrInputLegendPosition, "ucrInputLegendPosition") + Me.ucrInputLegendPosition.GetSetSelectedIndex = -1 + Me.ucrInputLegendPosition.IsReadOnly = False + Me.ucrInputLegendPosition.Name = "ucrInputLegendPosition" + ' + 'ucrChkLegend + ' + resources.ApplyResources(Me.ucrChkLegend, "ucrChkLegend") + Me.ucrChkLegend.Checked = False + Me.ucrChkLegend.Name = "ucrChkLegend" + ' + 'cmdOptions + ' + resources.ApplyResources(Me.cmdOptions, "cmdOptions") + Me.cmdOptions.ContextMenuStrip = Me.contextMenuStripOptions + Me.cmdOptions.Name = "cmdOptions" + Me.cmdOptions.SplitMenuStrip = Me.contextMenuStripOptions + Me.cmdOptions.Tag = "Plot Options" + Me.cmdOptions.UseVisualStyleBackColor = True + ' + 'ucrChkPoints + ' + resources.ApplyResources(Me.ucrChkPoints, "ucrChkPoints") + Me.ucrChkPoints.Checked = False + Me.ucrChkPoints.Name = "ucrChkPoints" + ' 'ucrChkFlipCoordinates ' resources.ApplyResources(Me.ucrChkFlipCoordinates, "ucrChkFlipCoordinates") @@ -306,12 +389,6 @@ Partial Class dlgHeatMapPlot Me.ucrInputSize.IsReadOnly = False Me.ucrInputSize.Name = "ucrInputSize" ' - 'ucrChkAddLabels - ' - resources.ApplyResources(Me.ucrChkAddLabels, "ucrChkAddLabels") - Me.ucrChkAddLabels.Checked = False - Me.ucrChkAddLabels.Name = "ucrChkAddLabels" - ' 'ucrInputPosition ' Me.ucrInputPosition.AddQuotesIfUnrecognised = True @@ -346,56 +423,24 @@ Partial Class dlgHeatMapPlot Me.ucrReceiverGroup.strNcFilePath = "" Me.ucrReceiverGroup.ucrSelector = Nothing ' - 'lblGroup - ' - resources.ApplyResources(Me.lblGroup, "lblGroup") - Me.lblGroup.Name = "lblGroup" - ' - 'ucrChkPoints - ' - resources.ApplyResources(Me.ucrChkPoints, "ucrChkPoints") - Me.ucrChkPoints.Checked = False - Me.ucrChkPoints.Name = "ucrChkPoints" - ' - 'contextMenuStripOptions - ' - Me.contextMenuStripOptions.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripMenuItemPlotOptions, Me.toolStripMenuItemTileOptions, Me.toolStripMenuItemPolygonOptions}) - Me.contextMenuStripOptions.Name = "contextMenuStripOk" - resources.ApplyResources(Me.contextMenuStripOptions, "contextMenuStripOptions") - ' - 'toolStripMenuItemPlotOptions - ' - Me.toolStripMenuItemPlotOptions.Name = "toolStripMenuItemPlotOptions" - resources.ApplyResources(Me.toolStripMenuItemPlotOptions, "toolStripMenuItemPlotOptions") - ' - 'toolStripMenuItemTileOptions - ' - Me.toolStripMenuItemTileOptions.Name = "toolStripMenuItemTileOptions" - resources.ApplyResources(Me.toolStripMenuItemTileOptions, "toolStripMenuItemTileOptions") - ' - 'toolStripMenuItemPolygonOptions - ' - Me.toolStripMenuItemPolygonOptions.Name = "toolStripMenuItemPolygonOptions" - resources.ApplyResources(Me.toolStripMenuItemPolygonOptions, "toolStripMenuItemPolygonOptions") - ' - 'cmdOptions + 'ucrChkAddLabels ' - resources.ApplyResources(Me.cmdOptions, "cmdOptions") - Me.cmdOptions.ContextMenuStrip = Me.contextMenuStripOptions - Me.cmdOptions.Name = "cmdOptions" - Me.cmdOptions.SplitMenuStrip = Me.contextMenuStripOptions - Me.cmdOptions.Tag = "Plot Options" - Me.cmdOptions.UseVisualStyleBackColor = True + resources.ApplyResources(Me.ucrChkAddLabels, "ucrChkAddLabels") + Me.ucrChkAddLabels.Checked = False + Me.ucrChkAddLabels.Name = "ucrChkAddLabels" ' 'dlgHeatMapPlot ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.ucrInputStation) + Me.Controls.Add(Me.ucr1stFactorReceiver) + Me.Controls.Add(Me.lblFacetBy) + Me.Controls.Add(Me.ucrInputLegendPosition) + Me.Controls.Add(Me.ucrChkLegend) Me.Controls.Add(Me.cmdOptions) - Me.Controls.Add(Me.ucrChkPoints) Me.Controls.Add(Me.lblGroup) Me.Controls.Add(Me.lblFillChoropleth) - Me.Controls.Add(Me.ucrChkFlipCoordinates) Me.Controls.Add(Me.rdoChoroplethMap) Me.Controls.Add(Me.rdoHeatMap) Me.Controls.Add(Me.lblPointsOptional) @@ -430,6 +475,8 @@ Partial Class dlgHeatMapPlot Me.Controls.Add(Me.lblReorderVariableX) Me.Controls.Add(Me.ucrReceiverGroup) Me.Controls.Add(Me.ucrChkAddLabels) + Me.Controls.Add(Me.ucrChkPoints) + Me.Controls.Add(Me.ucrChkFlipCoordinates) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False @@ -482,4 +529,9 @@ Partial Class dlgHeatMapPlot Friend WithEvents toolStripMenuItemPlotOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemTileOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemPolygonOptions As ToolStripMenuItem + Friend WithEvents ucrInputStation As ucrInputComboBox + Friend WithEvents ucr1stFactorReceiver As ucrReceiverSingle + Friend WithEvents lblFacetBy As Label + Friend WithEvents ucrInputLegendPosition As ucrInputComboBox + Friend WithEvents ucrChkLegend As ucrCheck End Class \ No newline at end of file diff --git a/instat/dlgHeatMapPlot.resx b/instat/dlgHeatMapPlot.resx index 0aac402b5a0..3835b0a3259 100644 --- a/instat/dlgHeatMapPlot.resx +++ b/instat/dlgHeatMapPlot.resx @@ -148,7 +148,7 @@ $this - 23 + 26 True @@ -178,7 +178,7 @@ $this - 14 + 17 True @@ -187,7 +187,7 @@ NoControl - 126, 413 + 126, 391 47, 13 @@ -208,7 +208,7 @@ $this - 31 + 34 True @@ -217,7 +217,7 @@ NoControl - 229, 413 + 229, 391 40, 13 @@ -238,7 +238,7 @@ $this - 33 + 36 True @@ -247,7 +247,7 @@ NoControl - 322, 413 + 322, 391 30, 13 @@ -268,7 +268,7 @@ $this - 35 + 38 True @@ -298,7 +298,7 @@ $this - 8 + 11 True @@ -328,7 +328,7 @@ $this - 9 + 12 True @@ -358,7 +358,7 @@ $this - 37 + 40 True @@ -388,7 +388,7 @@ $this - 26 + 29 Button @@ -424,7 +424,7 @@ $this - 6 + 9 Button @@ -460,7 +460,7 @@ $this - 7 + 10 True @@ -490,7 +490,7 @@ $this - 21 + 24 True @@ -520,7 +520,7 @@ $this - 25 + 28 True @@ -550,33 +550,123 @@ $this - 4 + 8 - + True - - 10, 379 + + NoControl - - 166, 23 + + 273, 197 - - 27 + + 55, 13 - - ucrChkFlipCoordinates + + 16 - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + Group/ID: - + + lblGroup + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - 5 + + 7 - + + 17, 17 + + + 164, 70 + + + contextMenuStripOptions + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 163, 22 + + + Plot Options + + + 163, 22 + + + Tile Options + + + 163, 22 + + + Polygon Options + + + True + + + NoControl + + + 207, 411 + + + 52, 13 + + + 89 + + + Facet By: + + + lblFacetBy + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + GrowAndShrink + + + 316, 425 + + + 101, 21 + + + 91 + + + ucrInputStation + + + instat.ucrInputComboBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 1 + + True @@ -586,22 +676,61 @@ 6, 13 - 420, 562 + 420, 538 - + + GrowAndShrink + + + 86, 425 + + + 112, 21 + + + 93 + + + ucrInputLegendPosition + + + instat.ucrInputComboBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + + True - - 17, 17 - - - 164, 70 + + 8, 426 - - contextMenuStripOptions + + 98, 24 - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 92 + + + ucrChkLegend + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 5 + + + True + + + NoControl 8, 247 @@ -625,58 +754,34 @@ $this - 1 - - - True - - - 10, 379 - - - 166, 23 - - - 39 - - - ucrChkPoints - - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 2 + 6 - + True - - 273, 197 + + 273, 343 - - 55, 13 + + 0, 0, 0, 0 - - 16 + + 125, 20 - - Group/ID: + + 24 - - lblGroup + + ucrReceiverPointsHeatMap - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - - 3 + + 13 True @@ -700,13 +805,13 @@ $this - 11 + 14 True - 10, 439 + 8, 346 128, 23 @@ -724,13 +829,13 @@ $this - 12 + 15 GrowAndShrink - 141, 439 + 142, 346 63, 21 @@ -748,7 +853,7 @@ $this - 13 + 16 True @@ -775,13 +880,13 @@ $this - 15 + 18 GrowAndShrink - 10, 470 + 8, 453 4, 5, 4, 5 @@ -802,13 +907,13 @@ $this - 16 + 19 GrowAndShrink - 8, 510 + 8, 487 410, 58 @@ -826,7 +931,7 @@ $this - 17 + 20 GrowAndShrink @@ -850,7 +955,7 @@ $this - 18 + 21 GrowAndShrink @@ -874,7 +979,7 @@ $this - 19 + 22 True @@ -901,7 +1006,7 @@ $this - 20 + 23 True @@ -928,7 +1033,7 @@ $this - 22 + 25 True @@ -955,7 +1060,7 @@ $this - 24 + 27 True @@ -982,7 +1087,7 @@ $this - 27 + 30 True @@ -1006,7 +1111,7 @@ $this - 28 + 31 GrowAndShrink @@ -1030,13 +1135,13 @@ $this - 29 + 32 GrowAndShrink - 349, 409 + 349, 387 59, 23 @@ -1054,13 +1159,13 @@ $this - 30 + 33 GrowAndShrink - 173, 409 + 173, 387 52, 23 @@ -1078,13 +1183,13 @@ $this - 32 + 35 GrowAndShrink - 269, 409 + 269, 387 50, 23 @@ -1102,7 +1207,7 @@ $this - 34 + 37 True @@ -1129,7 +1234,7 @@ $this - 36 + 39 True @@ -1156,13 +1261,13 @@ $this - 38 + 41 True - 10, 409 + 8, 387 128, 23 @@ -1180,8 +1285,59 @@ $this + 42 + + + True + + + 8, 314 + + + 166, 23 + + 39 + + ucrChkPoints + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 43 + + + True + + + 8, 315 + + + 166, 23 + + + 27 + + + ucrChkFlipCoordinates + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 44 + + + NoControl + CenterScreen @@ -1212,46 +1368,28 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 273, 343 + + 204, 426 - + 0, 0, 0, 0 - - 125, 20 + + 110, 26 - - 24 + + 90 - - ucrReceiverPointsHeatMap + + ucr1stFactorReceiver - + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - - 10 - - - 163, 22 - - - Plot Options - - - 163, 22 - - - Tile Options - - - 163, 22 - - - Polygon Options + + 2 \ No newline at end of file diff --git a/instat/dlgHeatMapPlot.vb b/instat/dlgHeatMapPlot.vb index 7ebeb13f287..e27f4c5f5d8 100644 --- a/instat/dlgHeatMapPlot.vb +++ b/instat/dlgHeatMapPlot.vb @@ -30,6 +30,18 @@ Public Class dlgHeatMapPlot Private ReadOnly strReverse As String = "Reverse" Private ReadOnly strNone As String = "None" + Private clsFacetFunction As New RFunction + Private clsFacetVariablesOperator As New ROperator + Private clsFacetRowOp As New ROperator + Private clsFacetColOp As New ROperator + + Private ReadOnly strFacetWrap As String = "Facet Wrap" + Private ReadOnly strFacetRow As String = "Facet Row" + Private ReadOnly strFacetCol As String = "Facet Column" + + Private bUpdateComboOptions As Boolean = True + Private bUpdatingParameters As Boolean = False + Private clsCoordPolarStartOperator, clsBaseOperator, clsPipeOperator As New ROperator Private clsCoordPolarFunction, clsAnnotateFunction, clsLocalRaesFunction, clsXScaleDateFunction, clsYScaleDateFunction, @@ -65,6 +77,7 @@ Public Class dlgHeatMapPlot Dim dctLabelPositions As New Dictionary(Of String, String) Dim dctLabelSizes As New Dictionary(Of String, String) Dim dctColourPallette As New Dictionary(Of String, String) + Dim dctLegendPosition As New Dictionary(Of String, String) ucrBase.iHelpTopicID = 476 ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False @@ -202,6 +215,32 @@ Public Class dlgHeatMapPlot ucrInputReorderVariableX.SetDropDownStyleAsNonEditable() ucrInputReorderVariableX.SetLinkedDisplayControl(lblReorderVariableX) + ucrChkLegend.SetText("Legend:") + ucrChkLegend.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) + ucrChkLegend.AddParameterPresentCondition(True, "legend.position") + ucrChkLegend.AddParameterPresentCondition(False, "legend.position", False) + + ucr1stFactorReceiver.SetParameter(New RParameter("var1")) + ucr1stFactorReceiver.Selector = ucrHeatMapSelector + ucr1stFactorReceiver.SetIncludedDataTypes({"factor"}) + ucr1stFactorReceiver.strSelectorHeading = "Factors" + ucr1stFactorReceiver.bWithQuotes = False + ucr1stFactorReceiver.SetParameterIsString() + ucr1stFactorReceiver.SetValuesToIgnore({"."}) + ucr1stFactorReceiver.SetParameterPosition(1) + ucr1stFactorReceiver.SetLinkedDisplayControl(lblFacetBy) + + ucrInputStation.SetItems({strFacetWrap, strFacetRow, strFacetCol, strNone}) + ucrInputStation.SetDropDownStyleAsNonEditable() + clsCoordFlipFunction.SetPackageName("ggplot2") clsCoordFlipFunction.SetRCommand("coord_flip") clsCoordFlipParam.SetArgumentName("coord_flip") @@ -240,6 +279,13 @@ Public Class dlgHeatMapPlot clsGroupByFunction = New RFunction clsSummariseFunction = New RFunction clsDummyFunction = New RFunction + clsFacetFunction = New RFunction + clsFacetVariablesOperator = New ROperator + clsFacetRowOp = New ROperator + clsFacetColOp = New ROperator + + ucrInputStation.SetName(strFacetWrap) + ucrInputStation.bUpdateRCodeFromControl = True ucrSaveGraph.Reset() ucrVariableAsFactorForHeatMap.SetMeAsReceiver() @@ -362,6 +408,22 @@ Public Class dlgHeatMapPlot clsSizeChoroplethAesFunction.AddParameter("x", "x", iPosition:=0) clsSizeChoroplethAesFunction.AddParameter("y", "y", iPosition:=1) + clsFacetFunction.SetPackageName("ggplot2") + clsFacetRowOp.SetOperation("+") + clsFacetRowOp.bBrackets = False + clsFacetColOp.SetOperation("+") + clsFacetColOp.bBrackets = False + clsFacetVariablesOperator.SetOperation("~") + clsFacetVariablesOperator.bForceIncludeOperation = True + clsFacetVariablesOperator.bBrackets = False + clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetVariablesOperator, iPosition:=0) + + ' clsPipeOperator.SetOperation("%>%") + SetPipeAssignTo() + + 'clsGroupByFunction.SetPackageName("dplyr") + 'clsGroupByFunction.SetRCommand("group_by") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() @@ -425,6 +487,8 @@ Public Class dlgHeatMapPlot ucrReceiverPointsHeatMap.SetRCode(clsSizeHeatMapAesFunction, bReset) ucrNudShapeHeatMap.SetRCode(clsGeomPointShapeHeatMapFunction, bReset) ucrChkFlipCoordinates.SetRCode(clsBaseOperator, bReset) + ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) bRCodeSet = True UnstackColumns() @@ -454,6 +518,18 @@ Public Class dlgHeatMapPlot TestOkEnabled() End Sub + Private Sub AddRemoveTheme() + If clsThemeFunction.iParameterCount > 0 Then + clsBaseOperator.AddParameter("theme", clsRFunctionParameter:=clsThemeFunction, iPosition:=15) + Else + clsBaseOperator.RemoveParameterByName("theme") + End If + End Sub + + Private Sub ucrChkLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegend.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged + AddRemoveTheme() + End Sub + Private Sub ucrChkAddLabels_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkAddLabels.ControlValueChanged If ucrChkAddLabels.Checked Then clsBaseOperator.AddParameter("geom_text", clsRFunctionParameter:=clsGeomTextFunction, iPosition:=5) @@ -476,7 +552,7 @@ Public Class dlgHeatMapPlot sdgPlots.SetRCode(clsBaseOperator, clsNewYScalecontinuousFunction:=clsYScalecontinuousFunction, clsNewXScalecontinuousFunction:=clsXScalecontinuousFunction, clsNewGlobalAesFunction:=If(rdoHeatMap.Checked, clsHeatmapAesFunction, clsChoroplethAesFunction), clsNewXLabsTitleFunction:=clsXlabsFunction, clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, - clsNewFacetFunction:=clsRFacetFunction, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, ucrNewBaseSelector:=ucrHeatMapSelector, + clsNewFacetFunction:=clsRFacetFunction, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, ucrNewBaseSelector:=ucrHeatMapSelector, clsNewFacetVariablesOperator:=clsFacetVariablesOperator, strMainDialogGeomParameterNames:=strGeomParameterNames, clsNewCoordPolarFunction:=clsCoordPolarFunction, clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewAnnotateFunction:=clsAnnotateFunction, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, bReset:=bResetSubdialog) sdgPlots.ShowDialog() @@ -655,8 +731,163 @@ Public Class dlgHeatMapPlot End If End Sub + Private Sub AutoFacetStation() + Dim currentReceiver As ucrReceiver = ucrHeatMapSelector.CurrentReceiver + + If currentReceiver IsNot Nothing Then + ucr1stFactorReceiver.AddItemsWithMetadataProperty(ucrHeatMapSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Climatic_Type", {"station_label"}) + currentReceiver.SetMeAsReceiver() + AddRemoveGroupBy() + End If + End Sub + + Private Sub ucrInput_ControlValueChanged(ucrChangedControl As ucrInputComboBox) Handles ucrInputStation.ControlValueChanged + If Not bUpdateComboOptions Then + Exit Sub + End If + Dim strChangedText As String = ucrChangedControl.GetText() + If strChangedText <> strNone Then + If Not strChangedText = strFacetCol AndAlso Not strChangedText = strFacetRow AndAlso + Not ucrInputStation.Equals(ucrChangedControl) AndAlso ucrInputStation.GetText() = strChangedText Then + bUpdateComboOptions = False + ucrInputStation.SetName(strNone) + bUpdateComboOptions = True + End If + If (strChangedText = strFacetWrap AndAlso ucrInputStation.GetText = strFacetRow) OrElse (strChangedText = strFacetRow AndAlso + ucrInputStation.GetText = strFacetWrap) OrElse (strChangedText = strFacetWrap AndAlso + ucrInputStation.GetText = strFacetCol) OrElse (strChangedText = strFacetCol AndAlso ucrInputStation.GetText = strFacetWrap) Then + ucrInputStation.SetName(strNone) + End If + End If + UpdateParameters() + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub UpdateParameters() + clsFacetVariablesOperator.RemoveParameterByName("var1") + clsFacetColOp.RemoveParameterByName("col" & ucrInputStation.Name) + clsFacetRowOp.RemoveParameterByName("row" & ucrInputStation.Name) + + clsBaseOperator.RemoveParameterByName("facets") + bUpdatingParameters = True + ucr1stFactorReceiver.SetRCode(Nothing) + Select Case ucrInputStation.GetText() + Case strFacetWrap + ucr1stFactorReceiver.ChangeParameterName("var1") + ucr1stFactorReceiver.SetRCode(clsFacetVariablesOperator) + Case strFacetCol + ucr1stFactorReceiver.ChangeParameterName("col" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetColOp) + Case strFacetRow + ucr1stFactorReceiver.ChangeParameterName("row" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetRowOp) + End Select + If Not clsHeatmapAesFunction.ContainsParameter("x") Then + clsHeatmapAesFunction.AddParameter("x", Chr(34) & Chr(34)) + End If + bUpdatingParameters = False + End Sub + + Private Sub AddRemoveFacets() + Dim bWrap As Boolean = False + Dim bCol As Boolean = False + Dim bRow As Boolean = False + + If bUpdatingParameters Then + Exit Sub + End If + + clsBaseOperator.RemoveParameterByName("facets") + If Not ucr1stFactorReceiver.IsEmpty Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + bWrap = True + Case strFacetCol + bCol = True + Case strFacetRow + bRow = True + End Select + End If + + If bWrap OrElse bRow OrElse bCol Then + clsBaseOperator.AddParameter("facets", clsRFunctionParameter:=clsFacetFunction) + End If + If bWrap Then + clsFacetFunction.SetRCommand("facet_wrap") + End If + If bRow OrElse bCol Then + clsFacetFunction.SetRCommand("facet_grid") + End If + If bRow Then + clsFacetVariablesOperator.AddParameter("left", clsROperatorParameter:=clsFacetRowOp, iPosition:=0) + ElseIf bCol AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("left", ".", iPosition:=0) + Else + clsFacetVariablesOperator.RemoveParameterByName("left") + End If + If bCol Then + clsFacetVariablesOperator.AddParameter("right", clsROperatorParameter:=clsFacetColOp, iPosition:=1) + ElseIf bRow AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("right", ".", iPosition:=1) + Else + clsFacetVariablesOperator.RemoveParameterByName("right") + End If + End Sub + + Private Sub ucr1stFactorReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucr1stFactorReceiver.ControlValueChanged, ucrReceiverX.ControlValueChanged + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub GetParameterValue(clsOperator As ROperator) + Dim i As Integer = 0 + For Each clsTempParam As RParameter In clsOperator.clsParameters + If clsTempParam.strArgumentValue <> "" AndAlso clsTempParam.strArgumentValue <> "." Then + clsGroupByFunction.AddParameter(i, clsTempParam.strArgumentValue, bIncludeArgumentName:=False, iPosition:=i) + i = i + 1 + End If + Next + End Sub + + Private Sub AddRemoveGroupBy() + If clsPipeOperator.ContainsParameter("mutate") Then + clsGroupByFunction.ClearParameters() + If clsBaseOperator.ContainsParameter("facets") Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + GetParameterValue(clsFacetVariablesOperator) + Case strFacetCol + GetParameterValue(clsFacetColOp) + Case strFacetRow + GetParameterValue(clsFacetRowOp) + End Select + End If + + If clsGroupByFunction.iParameterCount > 0 Then + clsPipeOperator.AddParameter("group_by", clsRFunctionParameter:=clsGroupByFunction, iPosition:=1) + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + + SetPipeAssignTo() + End Sub + + Private Sub SetPipeAssignTo() + If ucrHeatMapSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" AndAlso clsPipeOperator.clsParameters.Count > 1 Then + clsPipeOperator.SetAssignTo(ucrHeatMapSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text) + Else + clsPipeOperator.RemoveAssignTo() + End If + End Sub + Private Sub ucrHeatMapSelector_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrHeatMapSelector.ControlValueChanged clsPipeOperator.AddParameter("data", ucrHeatMapSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, iPosition:=0) + AutoFacetStation() + SetPipeAssignTo() End Sub Private Sub AddRemoveGeomParameter() diff --git a/instat/dlgMosaicPlot.Designer.vb b/instat/dlgMosaicPlot.Designer.vb index 17023502c43..dfe34001258 100644 --- a/instat/dlgMosaicPlot.Designer.vb +++ b/instat/dlgMosaicPlot.Designer.vb @@ -43,6 +43,11 @@ Partial Class dlgMosaicPlot Me.toolStripMenuItemPlotOptions = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItemMosaicOptions = New System.Windows.Forms.ToolStripMenuItem() Me.cmdOptions = New instat.ucrSplitButton() + Me.ucrInputStation = New instat.ucrInputComboBox() + Me.ucr1stFactorReceiver = New instat.ucrReceiverSingle() + Me.lblFacetBy = New System.Windows.Forms.Label() + Me.ucrInputLegendPosition = New instat.ucrInputComboBox() + Me.ucrChkLegend = New instat.ucrCheck() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -101,7 +106,7 @@ Partial Class dlgMosaicPlot Me.ucrNudXAxisLabelsAngle.AutoSize = True Me.ucrNudXAxisLabelsAngle.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) Me.ucrNudXAxisLabelsAngle.Increment = New Decimal(New Integer() {1, 0, 0, 0}) - Me.ucrNudXAxisLabelsAngle.Location = New System.Drawing.Point(183, 301) + Me.ucrNudXAxisLabelsAngle.Location = New System.Drawing.Point(183, 326) Me.ucrNudXAxisLabelsAngle.Maximum = New Decimal(New Integer() {100, 0, 0, 0}) Me.ucrNudXAxisLabelsAngle.Minimum = New Decimal(New Integer() {0, 0, 0, 0}) Me.ucrNudXAxisLabelsAngle.Name = "ucrNudXAxisLabelsAngle" @@ -124,7 +129,7 @@ Partial Class dlgMosaicPlot ' Me.ucrChkOmitMissing.AutoSize = True Me.ucrChkOmitMissing.Checked = False - Me.ucrChkOmitMissing.Location = New System.Drawing.Point(9, 269) + Me.ucrChkOmitMissing.Location = New System.Drawing.Point(9, 278) Me.ucrChkOmitMissing.Name = "ucrChkOmitMissing" Me.ucrChkOmitMissing.Size = New System.Drawing.Size(224, 23) Me.ucrChkOmitMissing.TabIndex = 13 @@ -184,7 +189,7 @@ Partial Class dlgMosaicPlot 'ucrSaveMosaicPlot ' Me.ucrSaveMosaicPlot.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveMosaicPlot.Location = New System.Drawing.Point(9, 385) + Me.ucrSaveMosaicPlot.Location = New System.Drawing.Point(9, 422) Me.ucrSaveMosaicPlot.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrSaveMosaicPlot.Name = "ucrSaveMosaicPlot" Me.ucrSaveMosaicPlot.Size = New System.Drawing.Size(317, 24) @@ -194,7 +199,7 @@ Partial Class dlgMosaicPlot ' Me.ucrChkXAxisLabelAngle.AutoSize = True Me.ucrChkXAxisLabelAngle.Checked = False - Me.ucrChkXAxisLabelAngle.Location = New System.Drawing.Point(9, 301) + Me.ucrChkXAxisLabelAngle.Location = New System.Drawing.Point(9, 326) Me.ucrChkXAxisLabelAngle.Name = "ucrChkXAxisLabelAngle" Me.ucrChkXAxisLabelAngle.Size = New System.Drawing.Size(168, 23) Me.ucrChkXAxisLabelAngle.TabIndex = 14 @@ -215,7 +220,7 @@ Partial Class dlgMosaicPlot ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(12, 418) + Me.ucrBase.Location = New System.Drawing.Point(12, 455) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 17 @@ -252,12 +257,72 @@ Partial Class dlgMosaicPlot Me.cmdOptions.Text = "Plot Options" Me.cmdOptions.UseVisualStyleBackColor = True ' + 'ucrInputStation + ' + Me.ucrInputStation.AddQuotesIfUnrecognised = True + Me.ucrInputStation.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputStation.GetSetSelectedIndex = -1 + Me.ucrInputStation.IsReadOnly = False + Me.ucrInputStation.Location = New System.Drawing.Point(321, 381) + Me.ucrInputStation.Name = "ucrInputStation" + Me.ucrInputStation.Size = New System.Drawing.Size(101, 21) + Me.ucrInputStation.TabIndex = 96 + ' + 'ucr1stFactorReceiver + ' + Me.ucr1stFactorReceiver.AutoSize = True + Me.ucr1stFactorReceiver.frmParent = Me + Me.ucr1stFactorReceiver.Location = New System.Drawing.Point(209, 382) + Me.ucr1stFactorReceiver.Margin = New System.Windows.Forms.Padding(0) + Me.ucr1stFactorReceiver.Name = "ucr1stFactorReceiver" + Me.ucr1stFactorReceiver.Selector = Nothing + Me.ucr1stFactorReceiver.Size = New System.Drawing.Size(110, 26) + Me.ucr1stFactorReceiver.strNcFilePath = "" + Me.ucr1stFactorReceiver.TabIndex = 95 + Me.ucr1stFactorReceiver.ucrSelector = Nothing + ' + 'lblFacetBy + ' + Me.lblFacetBy.AutoSize = True + Me.lblFacetBy.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblFacetBy.Location = New System.Drawing.Point(212, 367) + Me.lblFacetBy.Name = "lblFacetBy" + Me.lblFacetBy.Size = New System.Drawing.Size(52, 13) + Me.lblFacetBy.TabIndex = 94 + Me.lblFacetBy.Tag = "" + Me.lblFacetBy.Text = "Facet By:" + ' + '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(91, 381) + Me.ucrInputLegendPosition.Name = "ucrInputLegendPosition" + Me.ucrInputLegendPosition.Size = New System.Drawing.Size(112, 21) + Me.ucrInputLegendPosition.TabIndex = 98 + ' + 'ucrChkLegend + ' + Me.ucrChkLegend.AutoSize = True + Me.ucrChkLegend.Checked = False + Me.ucrChkLegend.Location = New System.Drawing.Point(9, 382) + Me.ucrChkLegend.Name = "ucrChkLegend" + Me.ucrChkLegend.Size = New System.Drawing.Size(98, 24) + Me.ucrChkLegend.TabIndex = 97 + ' 'dlgMosaicPlot ' 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(441, 475) + Me.ClientSize = New System.Drawing.Size(441, 510) + Me.Controls.Add(Me.ucrInputStation) + Me.Controls.Add(Me.ucr1stFactorReceiver) + Me.Controls.Add(Me.lblFacetBy) + Me.Controls.Add(Me.ucrInputLegendPosition) + Me.Controls.Add(Me.ucrChkLegend) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.ucrNudXAxisLabelsAngle) Me.Controls.Add(Me.ucrInputPartitioning) @@ -308,4 +373,9 @@ Partial Class dlgMosaicPlot Friend WithEvents contextMenuStripOptions As ContextMenuStrip Friend WithEvents toolStripMenuItemPlotOptions As ToolStripMenuItem Friend WithEvents toolStripMenuItemMosaicOptions As ToolStripMenuItem + Friend WithEvents ucrInputStation As ucrInputComboBox + Friend WithEvents ucr1stFactorReceiver As ucrReceiverSingle + Friend WithEvents lblFacetBy As Label + Friend WithEvents ucrInputLegendPosition As ucrInputComboBox + Friend WithEvents ucrChkLegend As ucrCheck End Class diff --git a/instat/dlgMosaicPlot.vb b/instat/dlgMosaicPlot.vb index 8ee21119606..f4f6c2cf6f0 100644 --- a/instat/dlgMosaicPlot.vb +++ b/instat/dlgMosaicPlot.vb @@ -42,6 +42,22 @@ Public Class dlgMosaicPlot Private clsYScaleDateFunction As New RFunction Private clsScaleFillViridisFunction As New RFunction Private clsScaleColourViridisFunction As New RFunction + + Private clsFacetFunction As New RFunction + Private clsFacetVariablesOperator As New ROperator + Private clsFacetRowOp As New ROperator + Private clsFacetColOp As New ROperator + Private clsPipeOperator As New ROperator + Private clsGroupByFunction As New RFunction + + Private ReadOnly strNone As String = "None" + Private ReadOnly strFacetWrap As String = "Facet Wrap" + Private ReadOnly strFacetRow As String = "Facet Row" + Private ReadOnly strFacetCol As String = "Facet Column" + + Private bUpdateComboOptions As Boolean = True + Private bUpdatingParameters As Boolean = False + Private bFirstLoad As Boolean = True Private bReset As Boolean = True Private bRCodeSet As Boolean = True @@ -65,6 +81,7 @@ Public Class dlgMosaicPlot Private Sub InitialiseDialog() Dim dctPartitionOptions As New Dictionary(Of String, String) + Dim dctLegendPosition As New Dictionary(Of String, String) ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False ucrBase.iHelpTopicID = 594 @@ -129,6 +146,32 @@ Public Class dlgMosaicPlot ucrNudXAxisLabelsAngle.SetParameter(New RParameter("angle")) ucrNudXAxisLabelsAngle.SetMinMax(0, 360) + ucrChkLegend.SetText("Legend:") + ucrChkLegend.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) + ucrChkLegend.AddParameterPresentCondition(True, "legend.position") + ucrChkLegend.AddParameterPresentCondition(False, "legend.position", False) + + ucr1stFactorReceiver.SetParameter(New RParameter("var1")) + ucr1stFactorReceiver.Selector = ucrSelectorMosaicPlot + ucr1stFactorReceiver.SetIncludedDataTypes({"factor"}) + ucr1stFactorReceiver.strSelectorHeading = "Factors" + ucr1stFactorReceiver.bWithQuotes = False + ucr1stFactorReceiver.SetParameterIsString() + ucr1stFactorReceiver.SetValuesToIgnore({"."}) + ucr1stFactorReceiver.SetParameterPosition(1) + ucr1stFactorReceiver.SetLinkedDisplayControl(lblFacetBy) + + ucrInputStation.SetItems({strFacetWrap, strFacetRow, strFacetCol, strNone}) + ucrInputStation.SetDropDownStyleAsNonEditable() + ucrSaveMosaicPlot.SetPrefix("mosaic") ucrSaveMosaicPlot.SetIsComboBox() ucrSaveMosaicPlot.SetCheckBoxText("Save Graph") @@ -146,6 +189,17 @@ Public Class dlgMosaicPlot clsXElementLabels = New RFunction + clsFacetFunction = New RFunction + clsFacetVariablesOperator = New ROperator + clsFacetRowOp = New ROperator + clsFacetColOp = New ROperator + clsPipeOperator = New ROperator + clsGroupByFunction = New RFunction + + ucrInputStation.SetName(strFacetWrap) + ucrInputStation.bUpdateRCodeFromControl = True + + ucrSelectorMosaicPlot.Reset() ucrSelectorMosaicPlot.SetGgplotFunction(clsBaseOperator) @@ -172,6 +226,22 @@ Public Class dlgMosaicPlot clsAesFunction.SetPackageName("ggplot2") clsAesFunction.SetRCommand("aes") + clsFacetFunction.SetPackageName("ggplot2") + clsFacetRowOp.SetOperation("+") + clsFacetRowOp.bBrackets = False + clsFacetColOp.SetOperation("+") + clsFacetColOp.bBrackets = False + clsFacetVariablesOperator.SetOperation("~") + clsFacetVariablesOperator.bForceIncludeOperation = True + clsFacetVariablesOperator.bBrackets = False + clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetVariablesOperator, iPosition:=0) + + clsPipeOperator.SetOperation("%>%") + SetPipeAssignTo() + + clsGroupByFunction.SetPackageName("dplyr") + clsGroupByFunction.SetRCommand("group_by") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXlabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() @@ -215,6 +285,9 @@ Public Class dlgMosaicPlot ucrSaveMosaicPlot.SetRCode(clsBaseOperator, bReset) + ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + AddRemoveXAxisTextParameters() bRCodeSet = True End Sub @@ -237,6 +310,163 @@ Public Class dlgMosaicPlot TestOkEnabled() End Sub + Private Sub AutoFacetStation() + Dim currentReceiver As ucrReceiver = ucrSelectorMosaicPlot.CurrentReceiver + + If currentReceiver IsNot Nothing Then + ucr1stFactorReceiver.AddItemsWithMetadataProperty(ucrSelectorMosaicPlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Climatic_Type", {"station_label"}) + currentReceiver.SetMeAsReceiver() + AddRemoveGroupBy() + End If + End Sub + + Private Sub ucrInput_ControlValueChanged(ucrChangedControl As ucrInputComboBox) Handles ucrInputStation.ControlValueChanged + If Not bUpdateComboOptions Then + Exit Sub + End If + Dim strChangedText As String = ucrChangedControl.GetText() + If strChangedText <> strNone Then + If Not strChangedText = strFacetCol AndAlso Not strChangedText = strFacetRow AndAlso + Not ucrInputStation.Equals(ucrChangedControl) AndAlso ucrInputStation.GetText() = strChangedText Then + bUpdateComboOptions = False + ucrInputStation.SetName(strNone) + bUpdateComboOptions = True + End If + If (strChangedText = strFacetWrap AndAlso ucrInputStation.GetText = strFacetRow) OrElse (strChangedText = strFacetRow AndAlso + ucrInputStation.GetText = strFacetWrap) OrElse (strChangedText = strFacetWrap AndAlso + ucrInputStation.GetText = strFacetCol) OrElse (strChangedText = strFacetCol AndAlso ucrInputStation.GetText = strFacetWrap) Then + ucrInputStation.SetName(strNone) + End If + End If + UpdateParameters() + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub UpdateParameters() + clsFacetVariablesOperator.RemoveParameterByName("var1") + clsFacetColOp.RemoveParameterByName("col" & ucrInputStation.Name) + clsFacetRowOp.RemoveParameterByName("row" & ucrInputStation.Name) + + clsBaseOperator.RemoveParameterByName("facets") + bUpdatingParameters = True + ucr1stFactorReceiver.SetRCode(Nothing) + Select Case ucrInputStation.GetText() + Case strFacetWrap + ucr1stFactorReceiver.ChangeParameterName("var1") + ucr1stFactorReceiver.SetRCode(clsFacetVariablesOperator) + Case strFacetCol + ucr1stFactorReceiver.ChangeParameterName("col" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetColOp) + Case strFacetRow + ucr1stFactorReceiver.ChangeParameterName("row" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetRowOp) + End Select + If Not clsAesFunction.ContainsParameter("x") Then + clsAesFunction.AddParameter("x", Chr(34) & Chr(34)) + End If + bUpdatingParameters = False + End Sub + + Private Sub AddRemoveFacets() + Dim bWrap As Boolean = False + Dim bCol As Boolean = False + Dim bRow As Boolean = False + + If bUpdatingParameters Then + Exit Sub + End If + + If Not ucr1stFactorReceiver.IsEmpty Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + bWrap = True + Case strFacetCol + bCol = True + Case strFacetRow + bRow = True + End Select + End If + + If bWrap OrElse bRow OrElse bCol Then + clsBaseOperator.AddParameter("facets", clsRFunctionParameter:=clsFacetFunction) + End If + If bWrap Then + clsFacetFunction.SetRCommand("facet_wrap") + End If + If bRow OrElse bCol Then + clsFacetFunction.SetRCommand("facet_grid") + End If + If bRow Then + clsFacetVariablesOperator.AddParameter("left", clsROperatorParameter:=clsFacetRowOp, iPosition:=0) + ElseIf bCol AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("left", ".", iPosition:=0) + Else + clsFacetVariablesOperator.RemoveParameterByName("left") + End If + If bCol Then + clsFacetVariablesOperator.AddParameter("right", clsROperatorParameter:=clsFacetColOp, iPosition:=1) + ElseIf bRow AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("right", ".", iPosition:=1) + Else + clsFacetVariablesOperator.RemoveParameterByName("right") + End If + End Sub + + Private Sub ucr1stFactorReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucr1stFactorReceiver.ControlValueChanged, ucrReceiverX.ControlValueChanged + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub GetParameterValue(clsOperator As ROperator) + Dim i As Integer = 0 + For Each clsTempParam As RParameter In clsOperator.clsParameters + If clsTempParam.strArgumentValue <> "" AndAlso clsTempParam.strArgumentValue <> "." Then + clsGroupByFunction.AddParameter(i, clsTempParam.strArgumentValue, bIncludeArgumentName:=False, iPosition:=i) + i = i + 1 + End If + Next + End Sub + + Private Sub AddRemoveGroupBy() + If clsPipeOperator.ContainsParameter("mutate") Then + clsGroupByFunction.ClearParameters() + If clsBaseOperator.ContainsParameter("facets") Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + GetParameterValue(clsFacetVariablesOperator) + Case strFacetCol + GetParameterValue(clsFacetColOp) + Case strFacetRow + GetParameterValue(clsFacetRowOp) + End Select + End If + + If clsGroupByFunction.iParameterCount > 0 Then + clsPipeOperator.AddParameter("group_by", clsRFunctionParameter:=clsGroupByFunction, iPosition:=1) + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + + SetPipeAssignTo() + End Sub + + Private Sub SetPipeAssignTo() + If ucrSelectorMosaicPlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" AndAlso clsPipeOperator.clsParameters.Count > 1 Then + clsPipeOperator.SetAssignTo(ucrSelectorMosaicPlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text) + Else + clsPipeOperator.RemoveAssignTo() + End If + End Sub + + Private Sub ucrSelectorMosaicPlot_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorMosaicPlot.ControlValueChanged + AutoFacetStation() + SetPipeAssignTo() + End Sub + Private Sub ucrReceiverX_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverX.ControlValueChanged Dim iXVarCount As Integer @@ -285,6 +515,10 @@ Public Class dlgMosaicPlot End If End Sub + Private Sub ucrChkLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegend.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged + AddRemoveTheme() + End Sub + Private Sub XAxisLabelAngleControls_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkXAxisLabelAngle.ControlValueChanged, ucrNudXAxisLabelsAngle.ControlValueChanged AddRemoveXAxisTextParameters() End Sub @@ -300,7 +534,7 @@ Public Class dlgMosaicPlot clsNewXScalecontinuousFunction:=clsXScaleContinuousFunction, clsNewYScalecontinuousFunction:=clsYScaleContinuousFunction, clsNewXLabsTitleFunction:=clsXlabsFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, ucrNewBaseSelector:=ucrSelectorMosaicPlot, clsNewCoordPolarFunction:=clsCoordPolarFunction, - clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewXScaleDateFunction:=clsXScaleDateFunction, + clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewFacetVariablesOperator:=clsFacetVariablesOperator, clsNewAnnotateFunction:=clsAnnotateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, bNewEnableColour:=False, bNewEnableDiscrete:=False, bReset:=bResetSubdialog) sdgPlots.ShowDialog() bResetSubdialog = False diff --git a/instat/dlgParallelCoordinatePlot.Designer.vb b/instat/dlgParallelCoordinatePlot.Designer.vb index 709f74443cc..eadafee6fe7 100644 --- a/instat/dlgParallelCoordinatePlot.Designer.vb +++ b/instat/dlgParallelCoordinatePlot.Designer.vb @@ -40,6 +40,11 @@ Partial Class dlgParallelCoordinatePlot Me.toolStripMenuItemParcoordOptions = New System.Windows.Forms.ToolStripMenuItem() Me.ucrChkBoxplots = New instat.ucrCheck() Me.ucrChkPoints = New instat.ucrCheck() + Me.ucrInputStation = New instat.ucrInputComboBox() + Me.ucr1stFactorReceiver = New instat.ucrReceiverSingle() + Me.lblFacetBy = New System.Windows.Forms.Label() + Me.ucrInputLegendPosition = New instat.ucrInputComboBox() + Me.ucrChkLegend = New instat.ucrCheck() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' @@ -86,7 +91,7 @@ Partial Class dlgParallelCoordinatePlot 'ucrSaveGraph ' Me.ucrSaveGraph.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveGraph.Location = New System.Drawing.Point(11, 313) + Me.ucrSaveGraph.Location = New System.Drawing.Point(11, 351) Me.ucrSaveGraph.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrSaveGraph.Name = "ucrSaveGraph" Me.ucrSaveGraph.Size = New System.Drawing.Size(324, 24) @@ -120,7 +125,7 @@ Partial Class dlgParallelCoordinatePlot ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(9, 342) + Me.ucrBase.Location = New System.Drawing.Point(9, 380) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 13 @@ -212,12 +217,72 @@ Partial Class dlgParallelCoordinatePlot Me.ucrChkPoints.Size = New System.Drawing.Size(100, 23) Me.ucrChkPoints.TabIndex = 11 ' + 'ucrInputStation + ' + Me.ucrInputStation.AddQuotesIfUnrecognised = True + Me.ucrInputStation.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputStation.GetSetSelectedIndex = -1 + Me.ucrInputStation.IsReadOnly = False + Me.ucrInputStation.Location = New System.Drawing.Point(315, 315) + Me.ucrInputStation.Name = "ucrInputStation" + Me.ucrInputStation.Size = New System.Drawing.Size(101, 21) + Me.ucrInputStation.TabIndex = 106 + ' + 'ucr1stFactorReceiver + ' + Me.ucr1stFactorReceiver.AutoSize = True + Me.ucr1stFactorReceiver.frmParent = Me + Me.ucr1stFactorReceiver.Location = New System.Drawing.Point(204, 316) + Me.ucr1stFactorReceiver.Margin = New System.Windows.Forms.Padding(0) + Me.ucr1stFactorReceiver.Name = "ucr1stFactorReceiver" + Me.ucr1stFactorReceiver.Selector = Nothing + Me.ucr1stFactorReceiver.Size = New System.Drawing.Size(110, 26) + Me.ucr1stFactorReceiver.strNcFilePath = "" + Me.ucr1stFactorReceiver.TabIndex = 105 + Me.ucr1stFactorReceiver.ucrSelector = Nothing + ' + 'lblFacetBy + ' + Me.lblFacetBy.AutoSize = True + Me.lblFacetBy.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblFacetBy.Location = New System.Drawing.Point(206, 301) + Me.lblFacetBy.Name = "lblFacetBy" + Me.lblFacetBy.Size = New System.Drawing.Size(52, 13) + Me.lblFacetBy.TabIndex = 104 + Me.lblFacetBy.Tag = "" + Me.lblFacetBy.Text = "Facet By:" + ' + '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(90, 315) + Me.ucrInputLegendPosition.Name = "ucrInputLegendPosition" + Me.ucrInputLegendPosition.Size = New System.Drawing.Size(112, 21) + Me.ucrInputLegendPosition.TabIndex = 108 + ' + 'ucrChkLegend + ' + Me.ucrChkLegend.AutoSize = True + Me.ucrChkLegend.Checked = False + Me.ucrChkLegend.Location = New System.Drawing.Point(11, 316) + Me.ucrChkLegend.Name = "ucrChkLegend" + Me.ucrChkLegend.Size = New System.Drawing.Size(98, 24) + Me.ucrChkLegend.TabIndex = 107 + ' 'dlgParallelCoordinatePlot ' 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(417, 399) + Me.ClientSize = New System.Drawing.Size(417, 436) + Me.Controls.Add(Me.ucrInputStation) + Me.Controls.Add(Me.ucr1stFactorReceiver) + Me.Controls.Add(Me.lblFacetBy) + Me.Controls.Add(Me.ucrInputLegendPosition) + Me.Controls.Add(Me.ucrChkLegend) Me.Controls.Add(Me.ucrChkPoints) Me.Controls.Add(Me.ucrChkBoxplots) Me.Controls.Add(Me.cmdOptions) @@ -261,4 +326,9 @@ Partial Class dlgParallelCoordinatePlot Friend WithEvents toolStripMenuItemParcoordOptions As ToolStripMenuItem Friend WithEvents ucrChkPoints As ucrCheck Friend WithEvents ucrChkBoxplots As ucrCheck + Friend WithEvents ucrInputStation As ucrInputComboBox + Friend WithEvents ucr1stFactorReceiver As ucrReceiverSingle + Friend WithEvents lblFacetBy As Label + Friend WithEvents ucrInputLegendPosition As ucrInputComboBox + Friend WithEvents ucrChkLegend As ucrCheck End Class diff --git a/instat/dlgParallelCoordinatePlot.vb b/instat/dlgParallelCoordinatePlot.vb index 693bef45b0b..54210b80f68 100644 --- a/instat/dlgParallelCoordinatePlot.vb +++ b/instat/dlgParallelCoordinatePlot.vb @@ -37,6 +37,21 @@ Public Class dlgParallelCoordinatePlot Private clsScaleColourViridisFunction As New RFunction Private clsAnnotateFunction As New RFunction + Private clsFacetFunction As New RFunction + Private clsFacetVariablesOperator As New ROperator + Private clsFacetRowOp As New ROperator + Private clsFacetColOp As New ROperator + Private clsPipeOperator As New ROperator + Private clsGroupByFunction As New RFunction + + Private ReadOnly strNone As String = "None" + Private ReadOnly strFacetWrap As String = "Facet Wrap" + Private ReadOnly strFacetRow As String = "Facet Row" + Private ReadOnly strFacetCol As String = "Facet Column" + + Private bUpdateComboOptions As Boolean = True + Private bUpdatingParameters As Boolean = False + Private Sub dlgParallelCoordinatePlot_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstload Then InitialiseDialog() @@ -53,6 +68,7 @@ Public Class dlgParallelCoordinatePlot Private Sub InitialiseDialog() Dim dctScale As New Dictionary(Of String, String) + Dim dctLegendPosition As New Dictionary(Of String, String) ucrBase.clsRsyntax.bExcludeAssignedFunctionOutput = False ucrBase.iHelpTopicID = 593 ucrBase.clsRsyntax.iCallType = 3 @@ -100,6 +116,32 @@ Public Class dlgParallelCoordinatePlot ucrInputScale.SetRDefault("std") ucrInputScale.SetDropDownStyleAsNonEditable() + ucrChkLegend.SetText("Legend:") + ucrChkLegend.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) + ucrChkLegend.AddParameterPresentCondition(True, "legend.position") + ucrChkLegend.AddParameterPresentCondition(False, "legend.position", False) + + ucr1stFactorReceiver.SetParameter(New RParameter("var1")) + ucr1stFactorReceiver.Selector = ucrSelectorParallelCoordinatePlot + ucr1stFactorReceiver.SetIncludedDataTypes({"factor"}) + ucr1stFactorReceiver.strSelectorHeading = "Factors" + ucr1stFactorReceiver.bWithQuotes = False + ucr1stFactorReceiver.SetParameterIsString() + ucr1stFactorReceiver.SetValuesToIgnore({"."}) + ucr1stFactorReceiver.SetParameterPosition(1) + ucr1stFactorReceiver.SetLinkedDisplayControl(lblFacetBy) + + ucrInputStation.SetItems({strFacetWrap, strFacetRow, strFacetCol, strNone}) + ucrInputStation.SetDropDownStyleAsNonEditable() + ucrSaveGraph.SetPrefix("par_coord_plot") ucrSaveGraph.SetSaveTypeAsGraph() ucrSaveGraph.SetDataFrameSelector(ucrSelectorParallelCoordinatePlot.ucrAvailableDataFrames) @@ -111,6 +153,15 @@ Public Class dlgParallelCoordinatePlot Private Sub SetDefaults() clsBaseOperator = New ROperator clsGGParCoordFunc = New RFunction + clsFacetFunction = New RFunction + clsFacetVariablesOperator = New ROperator + clsFacetRowOp = New ROperator + clsFacetColOp = New ROperator + clsPipeOperator = New ROperator + clsGroupByFunction = New RFunction + + ucrInputStation.SetName(strFacetWrap) + ucrInputStation.bUpdateRCodeFromControl = True ucrReceiverXVariables.SetMeAsReceiver() ucrSelectorParallelCoordinatePlot.Reset() @@ -127,6 +178,22 @@ Public Class dlgParallelCoordinatePlot clsBaseOperator.SetOperation("+") clsBaseOperator.AddParameter("ggparcord", clsRFunctionParameter:=clsGGParCoordFunc, iPosition:=0) + clsFacetFunction.SetPackageName("ggplot2") + clsFacetRowOp.SetOperation("+") + clsFacetRowOp.bBrackets = False + clsFacetColOp.SetOperation("+") + clsFacetColOp.bBrackets = False + clsFacetVariablesOperator.SetOperation("~") + clsFacetVariablesOperator.bForceIncludeOperation = True + clsFacetVariablesOperator.bBrackets = False + clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetVariablesOperator, iPosition:=0) + + clsPipeOperator.SetOperation("%>%") + SetPipeAssignTo() + + clsGroupByFunction.SetPackageName("dplyr") + clsGroupByFunction.SetRCommand("group_by") + clsBaseOperator.AddParameter(GgplotDefaults.clsDefaultThemeParameter.Clone()) clsXLabsFunction = GgplotDefaults.clsXlabTitleFunction.Clone() clsLabsFunction = GgplotDefaults.clsDefaultLabs.Clone() @@ -151,13 +218,17 @@ Public Class dlgParallelCoordinatePlot Private Sub SetRCodeForControls(bReset As Boolean) ucrSelectorParallelCoordinatePlot.SetRCode(clsGGParCoordFunc, bReset) - ucrReceiverXVariables.SetRCode(clsGGParCoordFunc, bReset) ucrReceiverFactor.SetRCode(clsGGParCoordFunc, bReset) ucrChkBoxplots.SetRCode(clsGGParCoordFunc, bReset) ucrChkPoints.SetRCode(clsGGParCoordFunc, bReset) ucrNudTransparency.SetRCode(clsGGParCoordFunc, bReset) ucrInputScale.SetRCode(clsGGParCoordFunc, bReset) + ucrChkLegend.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) + ucrInputLegendPosition.SetRCode(clsThemeFunction, bReset, bCloneIfNeeded:=True) ucrSaveGraph.SetRCode(clsBaseOperator, bReset) + If bReset Then + ucrReceiverXVariables.SetRCode(clsGGParCoordFunc, bReset) + End If End Sub Private Sub TestOkEnabled() @@ -182,13 +253,180 @@ Public Class dlgParallelCoordinatePlot Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click, toolStripMenuItemPlotOptions.Click sdgPlots.SetRCode(clsBaseOperator, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, clsNewXScalecontinuousFunction:=clsXScaleContinuousFunction, clsNewYScalecontinuousFunction:=clsYScaleContinuousFunction, - clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, clsNewXLabsTitleFunction:=clsXLabsFunction, clsNewYLabTitleFunction:=clsYLabsFunction, + clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, clsNewXLabsTitleFunction:=clsXLabsFunction, clsNewYLabTitleFunction:=clsYLabsFunction, clsNewFacetVariablesOperator:=clsFacetVariablesOperator, clsNewLabsFunction:=clsLabsFunction, clsNewFacetFunction:=clsRFacetFunction, ucrNewBaseSelector:=ucrSelectorParallelCoordinatePlot, clsNewCoordPolarFunction:=clsCoordPolarFunction, clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, clsNewAnnotateFunction:=clsAnnotateFunction, bReset:=bResetSubdialog) sdgPlots.ShowDialog() bResetSubdialog = False End Sub + Private Sub AddRemoveTheme() + If clsThemeFunction.iParameterCount > 0 Then + clsBaseOperator.AddParameter("theme", clsRFunctionParameter:=clsThemeFunction, iPosition:=15) + Else + clsBaseOperator.RemoveParameterByName("theme") + End If + End Sub + + Private Sub ucrChkLegend_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkLegend.ControlValueChanged, ucrInputLegendPosition.ControlValueChanged + AddRemoveTheme() + End Sub + + Private Sub AutoFacetStation() + Dim currentReceiver As ucrReceiver = ucrSelectorParallelCoordinatePlot.CurrentReceiver + + If currentReceiver IsNot Nothing Then + ucr1stFactorReceiver.AddItemsWithMetadataProperty(ucrSelectorParallelCoordinatePlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text, "Climatic_Type", {"station_label"}) + currentReceiver.SetMeAsReceiver() + AddRemoveGroupBy() + End If + End Sub + + Private Sub ucrInput_ControlValueChanged(ucrChangedControl As ucrInputComboBox) Handles ucrInputStation.ControlValueChanged + If Not bUpdateComboOptions Then + Exit Sub + End If + Dim strChangedText As String = ucrChangedControl.GetText() + If strChangedText <> strNone Then + If Not strChangedText = strFacetCol AndAlso Not strChangedText = strFacetRow AndAlso + Not ucrInputStation.Equals(ucrChangedControl) AndAlso ucrInputStation.GetText() = strChangedText Then + bUpdateComboOptions = False + ucrInputStation.SetName(strNone) + bUpdateComboOptions = True + End If + If (strChangedText = strFacetWrap AndAlso ucrInputStation.GetText = strFacetRow) OrElse (strChangedText = strFacetRow AndAlso + ucrInputStation.GetText = strFacetWrap) OrElse (strChangedText = strFacetWrap AndAlso + ucrInputStation.GetText = strFacetCol) OrElse (strChangedText = strFacetCol AndAlso ucrInputStation.GetText = strFacetWrap) Then + ucrInputStation.SetName(strNone) + End If + End If + UpdateParameters() + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub UpdateParameters() + clsFacetVariablesOperator.RemoveParameterByName("var1") + clsFacetColOp.RemoveParameterByName("col" & ucrInputStation.Name) + clsFacetRowOp.RemoveParameterByName("row" & ucrInputStation.Name) + + clsBaseOperator.RemoveParameterByName("facets") + bUpdatingParameters = True + ucr1stFactorReceiver.SetRCode(Nothing) + Select Case ucrInputStation.GetText() + Case strFacetWrap + ucr1stFactorReceiver.ChangeParameterName("var1") + ucr1stFactorReceiver.SetRCode(clsFacetVariablesOperator) + Case strFacetCol + ucr1stFactorReceiver.ChangeParameterName("col" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetColOp) + Case strFacetRow + ucr1stFactorReceiver.ChangeParameterName("row" & ucrInputStation.Name) + ucr1stFactorReceiver.SetRCode(clsFacetRowOp) + End Select + bUpdatingParameters = False + End Sub + + Private Sub AddRemoveFacets() + Dim bWrap As Boolean = False + Dim bCol As Boolean = False + Dim bRow As Boolean = False + + If bUpdatingParameters Then + Exit Sub + End If + + clsBaseOperator.RemoveParameterByName("facets") + If Not ucr1stFactorReceiver.IsEmpty Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + bWrap = True + Case strFacetCol + bCol = True + Case strFacetRow + bRow = True + End Select + End If + + If bWrap OrElse bRow OrElse bCol Then + clsBaseOperator.AddParameter("facets", clsRFunctionParameter:=clsFacetFunction) + End If + If bWrap Then + clsFacetFunction.SetRCommand("facet_wrap") + End If + If bRow OrElse bCol Then + clsFacetFunction.SetRCommand("facet_grid") + End If + If bRow Then + clsFacetVariablesOperator.AddParameter("left", clsROperatorParameter:=clsFacetRowOp, iPosition:=0) + ElseIf bCol AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("left", ".", iPosition:=0) + Else + clsFacetVariablesOperator.RemoveParameterByName("left") + End If + If bCol Then + clsFacetVariablesOperator.AddParameter("right", clsROperatorParameter:=clsFacetColOp, iPosition:=1) + ElseIf bRow AndAlso bWrap = False Then + clsFacetVariablesOperator.AddParameter("right", ".", iPosition:=1) + Else + clsFacetVariablesOperator.RemoveParameterByName("right") + End If + End Sub + + Private Sub ucr1stFactorReceiver_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucr1stFactorReceiver.ControlValueChanged + AddRemoveFacets() + AddRemoveGroupBy() + End Sub + + Private Sub GetParameterValue(clsOperator As ROperator) + Dim i As Integer = 0 + For Each clsTempParam As RParameter In clsOperator.clsParameters + If clsTempParam.strArgumentValue <> "" AndAlso clsTempParam.strArgumentValue <> "." Then + clsGroupByFunction.AddParameter(i, clsTempParam.strArgumentValue, bIncludeArgumentName:=False, iPosition:=i) + i = i + 1 + End If + Next + End Sub + + Private Sub AddRemoveGroupBy() + If clsPipeOperator.ContainsParameter("mutate") Then + clsGroupByFunction.ClearParameters() + If clsBaseOperator.ContainsParameter("facets") Then + Select Case ucrInputStation.GetText() + Case strFacetWrap + GetParameterValue(clsFacetVariablesOperator) + Case strFacetCol + GetParameterValue(clsFacetColOp) + Case strFacetRow + GetParameterValue(clsFacetRowOp) + End Select + End If + + If clsGroupByFunction.iParameterCount > 0 Then + clsPipeOperator.AddParameter("group_by", clsRFunctionParameter:=clsGroupByFunction, iPosition:=1) + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + Else + clsPipeOperator.RemoveParameterByName("group_by") + End If + + SetPipeAssignTo() + End Sub + + Private Sub SetPipeAssignTo() + If ucrSelectorParallelCoordinatePlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" AndAlso clsPipeOperator.clsParameters.Count > 1 Then + clsPipeOperator.SetAssignTo(ucrSelectorParallelCoordinatePlot.ucrAvailableDataFrames.cboAvailableDataFrames.Text) + Else + clsPipeOperator.RemoveAssignTo() + End If + End Sub + + Private Sub ucrSelectorParallelCoordinatePlot_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorParallelCoordinatePlot.ControlValueChanged + AutoFacetStation() + SetPipeAssignTo() + End Sub + Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverXVariables.ControlContentsChanged, ucrSaveGraph.ControlContentsChanged, ucrNudTransparency.ControlContentsChanged TestOkEnabled() End Sub diff --git a/instat/dlgScript.Designer.vb b/instat/dlgScript.Designer.vb index 87f9545cc1c..f210262196f 100644 --- a/instat/dlgScript.Designer.vb +++ b/instat/dlgScript.Designer.vb @@ -24,49 +24,50 @@ Partial Class dlgScript Private Sub InitializeComponent() Me.tbFeatures = New System.Windows.Forms.TabControl() Me.tbPageSaveData = New System.Windows.Forms.TabPage() - Me.ucrChkSaveDataFrameSingle = New instat.ucrCheck() Me.lblSaveDataFrame = New System.Windows.Forms.Label() - Me.ucrInputSaveDataFrame = New instat.ucrInputTextBox() Me.lblSaveObjectFormat = New System.Windows.Forms.Label() - Me.ucrCboSaveOutputObjectFormat = New instat.ucrInputComboBox() Me.lblSaveObjectType = New System.Windows.Forms.Label() - Me.ucrCboSaveOutputObjectType = New instat.ucrInputComboBox() Me.rdoSaveOutputObject = New System.Windows.Forms.RadioButton() Me.rdoSaveDataFrame = New System.Windows.Forms.RadioButton() Me.rdoSaveColumn = New System.Windows.Forms.RadioButton() - Me.ucrSaveObject = New instat.ucrSave() - Me.ucrDataFrameSaveOutputSelect = New instat.ucrDataFrame() - Me.ucrPnlSaveData = New instat.UcrPanel() Me.tbPageGetData = New System.Windows.Forms.TabPage() - Me.ucrReceiverGetOutputObject = New instat.ucrReceiverSingle() - Me.ucrReceiverGetColumns = New instat.ucrReceiverMultiple() Me.lblGetColumn = New System.Windows.Forms.Label() Me.lblGetObjectType = New System.Windows.Forms.Label() Me.rdoGetOutputObject = New System.Windows.Forms.RadioButton() Me.lblGetOutputObject = New System.Windows.Forms.Label() Me.rdoGetDataFrame = New System.Windows.Forms.RadioButton() Me.rdoGetColumn = New System.Windows.Forms.RadioButton() - Me.ucrDataFrameGetDF = New instat.ucrDataFrame() - Me.ucrCboGetOutputObjectType = New instat.ucrInputComboBox() - Me.ucrPnlGetData = New instat.UcrPanel() - Me.ucrSelectorGetObject = New instat.ucrSelectorByDataFrameAddRemove() Me.tbPageCommand = New System.Windows.Forms.TabPage() - Me.ucrInputRemoveObjects = New instat.ucrInputTextBox() Me.rdoCommandPackage = New System.Windows.Forms.RadioButton() Me.rdoCommandObject = New System.Windows.Forms.RadioButton() - Me.ucrCboCommandPackage = New instat.ucrInputComboBox() - Me.ucrPnlCommands = New instat.UcrPanel() Me.tbPageExamples = New System.Windows.Forms.TabPage() Me.rdoExampleData = New System.Windows.Forms.RadioButton() Me.rdoExampleFunction = New System.Windows.Forms.RadioButton() - Me.ucrPnlExample = New instat.UcrPanel() Me.lstExampleCollection = New System.Windows.Forms.ListView() Me.clmDatasets = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.clmDesc = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Label3 = New System.Windows.Forms.Label() - Me.ucrCboExamplePackages = New instat.ucrInputComboBox() Me.lblPreview = New System.Windows.Forms.Label() Me.txtScript = New System.Windows.Forms.TextBox() + Me.ucrChkDisplayGraph = New instat.ucrCheck() + Me.ucrChkSaveDataFrameSingle = New instat.ucrCheck() + Me.ucrInputSaveDataFrame = New instat.ucrInputTextBox() + Me.ucrCboSaveOutputObjectFormat = New instat.ucrInputComboBox() + Me.ucrCboSaveOutputObjectType = New instat.ucrInputComboBox() + Me.ucrSaveObject = New instat.ucrSave() + Me.ucrDataFrameSaveOutputSelect = New instat.ucrDataFrame() + Me.ucrPnlSaveData = New instat.UcrPanel() + Me.ucrReceiverGetOutputObject = New instat.ucrReceiverSingle() + Me.ucrReceiverGetColumns = New instat.ucrReceiverMultiple() + Me.ucrDataFrameGetDF = New instat.ucrDataFrame() + Me.ucrCboGetOutputObjectType = New instat.ucrInputComboBox() + Me.ucrPnlGetData = New instat.UcrPanel() + Me.ucrSelectorGetObject = New instat.ucrSelectorByDataFrameAddRemove() + Me.ucrInputRemoveObjects = New instat.ucrInputTextBox() + Me.ucrCboCommandPackage = New instat.ucrInputComboBox() + Me.ucrPnlCommands = New instat.UcrPanel() + Me.ucrPnlExample = New instat.UcrPanel() + Me.ucrCboExamplePackages = New instat.ucrInputComboBox() Me.ucrBase = New instat.ucrButtons() Me.tbFeatures.SuspendLayout() Me.tbPageSaveData.SuspendLayout() @@ -89,6 +90,7 @@ Partial Class dlgScript ' 'tbPageSaveData ' + Me.tbPageSaveData.Controls.Add(Me.ucrChkDisplayGraph) Me.tbPageSaveData.Controls.Add(Me.ucrChkSaveDataFrameSingle) Me.tbPageSaveData.Controls.Add(Me.lblSaveDataFrame) Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveDataFrame) @@ -109,15 +111,6 @@ Partial Class dlgScript Me.tbPageSaveData.Text = "Save Data" Me.tbPageSaveData.UseVisualStyleBackColor = True ' - 'ucrChkSaveDataFrameSingle - ' - Me.ucrChkSaveDataFrameSingle.AutoSize = True - Me.ucrChkSaveDataFrameSingle.Checked = False - Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(91, 101) - Me.ucrChkSaveDataFrameSingle.Name = "ucrChkSaveDataFrameSingle" - Me.ucrChkSaveDataFrameSingle.Size = New System.Drawing.Size(146, 23) - Me.ucrChkSaveDataFrameSingle.TabIndex = 59 - ' 'lblSaveDataFrame ' Me.lblSaveDataFrame.AutoSize = True @@ -127,18 +120,6 @@ Partial Class dlgScript Me.lblSaveDataFrame.TabIndex = 58 Me.lblSaveDataFrame.Text = "Data Frame:" ' - 'ucrInputSaveDataFrame - ' - Me.ucrInputSaveDataFrame.AddQuotesIfUnrecognised = True - Me.ucrInputSaveDataFrame.AutoSize = True - Me.ucrInputSaveDataFrame.IsMultiline = False - Me.ucrInputSaveDataFrame.IsReadOnly = False - Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(92, 70) - Me.ucrInputSaveDataFrame.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputSaveDataFrame.Name = "ucrInputSaveDataFrame" - Me.ucrInputSaveDataFrame.Size = New System.Drawing.Size(145, 21) - Me.ucrInputSaveDataFrame.TabIndex = 57 - ' 'lblSaveObjectFormat ' Me.lblSaveObjectFormat.AutoSize = True @@ -148,18 +129,6 @@ Partial Class dlgScript Me.lblSaveObjectFormat.TabIndex = 56 Me.lblSaveObjectFormat.Text = "Format:" ' - 'ucrCboSaveOutputObjectFormat - ' - Me.ucrCboSaveOutputObjectFormat.AddQuotesIfUnrecognised = True - Me.ucrCboSaveOutputObjectFormat.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboSaveOutputObjectFormat.GetSetSelectedIndex = -1 - Me.ucrCboSaveOutputObjectFormat.IsReadOnly = False - Me.ucrCboSaveOutputObjectFormat.Location = New System.Drawing.Point(88, 160) - Me.ucrCboSaveOutputObjectFormat.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboSaveOutputObjectFormat.Name = "ucrCboSaveOutputObjectFormat" - Me.ucrCboSaveOutputObjectFormat.Size = New System.Drawing.Size(141, 21) - Me.ucrCboSaveOutputObjectFormat.TabIndex = 55 - ' 'lblSaveObjectType ' Me.lblSaveObjectType.AutoSize = True @@ -169,18 +138,6 @@ Partial Class dlgScript Me.lblSaveObjectType.TabIndex = 54 Me.lblSaveObjectType.Text = "Type:" ' - 'ucrCboSaveOutputObjectType - ' - Me.ucrCboSaveOutputObjectType.AddQuotesIfUnrecognised = True - Me.ucrCboSaveOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboSaveOutputObjectType.GetSetSelectedIndex = -1 - Me.ucrCboSaveOutputObjectType.IsReadOnly = False - Me.ucrCboSaveOutputObjectType.Location = New System.Drawing.Point(87, 116) - Me.ucrCboSaveOutputObjectType.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboSaveOutputObjectType.Name = "ucrCboSaveOutputObjectType" - Me.ucrCboSaveOutputObjectType.Size = New System.Drawing.Size(144, 21) - Me.ucrCboSaveOutputObjectType.TabIndex = 53 - ' 'rdoSaveOutputObject ' Me.rdoSaveOutputObject.Appearance = System.Windows.Forms.Appearance.Button @@ -232,35 +189,6 @@ Partial Class dlgScript Me.rdoSaveColumn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoSaveColumn.UseVisualStyleBackColor = True ' - 'ucrSaveObject - ' - Me.ucrSaveObject.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveObject.Location = New System.Drawing.Point(88, 193) - Me.ucrSaveObject.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.ucrSaveObject.Name = "ucrSaveObject" - Me.ucrSaveObject.Size = New System.Drawing.Size(258, 22) - Me.ucrSaveObject.TabIndex = 35 - ' - 'ucrDataFrameSaveOutputSelect - ' - Me.ucrDataFrameSaveOutputSelect.AutoSize = True - Me.ucrDataFrameSaveOutputSelect.bDropUnusedFilterLevels = False - Me.ucrDataFrameSaveOutputSelect.bUseCurrentFilter = True - Me.ucrDataFrameSaveOutputSelect.Location = New System.Drawing.Point(86, 54) - Me.ucrDataFrameSaveOutputSelect.Margin = New System.Windows.Forms.Padding(0) - Me.ucrDataFrameSaveOutputSelect.Name = "ucrDataFrameSaveOutputSelect" - Me.ucrDataFrameSaveOutputSelect.Size = New System.Drawing.Size(224, 59) - Me.ucrDataFrameSaveOutputSelect.TabIndex = 29 - ' - 'ucrPnlSaveData - ' - Me.ucrPnlSaveData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlSaveData.Location = New System.Drawing.Point(13, 12) - Me.ucrPnlSaveData.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlSaveData.Name = "ucrPnlSaveData" - Me.ucrPnlSaveData.Size = New System.Drawing.Size(402, 36) - Me.ucrPnlSaveData.TabIndex = 47 - ' 'tbPageGetData ' Me.tbPageGetData.Controls.Add(Me.ucrReceiverGetOutputObject) @@ -283,32 +211,6 @@ Partial Class dlgScript Me.tbPageGetData.Text = "Get Data" Me.tbPageGetData.UseVisualStyleBackColor = True ' - 'ucrReceiverGetOutputObject - ' - Me.ucrReceiverGetOutputObject.AutoSize = True - Me.ucrReceiverGetOutputObject.frmParent = Nothing - Me.ucrReceiverGetOutputObject.Location = New System.Drawing.Point(240, 117) - Me.ucrReceiverGetOutputObject.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverGetOutputObject.Name = "ucrReceiverGetOutputObject" - Me.ucrReceiverGetOutputObject.Selector = Nothing - Me.ucrReceiverGetOutputObject.Size = New System.Drawing.Size(138, 20) - Me.ucrReceiverGetOutputObject.strNcFilePath = "" - Me.ucrReceiverGetOutputObject.TabIndex = 27 - Me.ucrReceiverGetOutputObject.ucrSelector = Nothing - ' - 'ucrReceiverGetColumns - ' - Me.ucrReceiverGetColumns.AutoSize = True - Me.ucrReceiverGetColumns.frmParent = Nothing - Me.ucrReceiverGetColumns.Location = New System.Drawing.Point(243, 104) - Me.ucrReceiverGetColumns.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverGetColumns.Name = "ucrReceiverGetColumns" - Me.ucrReceiverGetColumns.Selector = Nothing - Me.ucrReceiverGetColumns.Size = New System.Drawing.Size(137, 105) - Me.ucrReceiverGetColumns.strNcFilePath = "" - Me.ucrReceiverGetColumns.TabIndex = 49 - Me.ucrReceiverGetColumns.ucrSelector = Nothing - ' 'lblGetColumn ' Me.lblGetColumn.AutoSize = True @@ -389,50 +291,6 @@ Partial Class dlgScript Me.rdoGetColumn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoGetColumn.UseVisualStyleBackColor = True ' - 'ucrDataFrameGetDF - ' - Me.ucrDataFrameGetDF.AutoSize = True - Me.ucrDataFrameGetDF.bDropUnusedFilterLevels = False - Me.ucrDataFrameGetDF.bUseCurrentFilter = True - Me.ucrDataFrameGetDF.Location = New System.Drawing.Point(81, 55) - Me.ucrDataFrameGetDF.Margin = New System.Windows.Forms.Padding(0) - Me.ucrDataFrameGetDF.Name = "ucrDataFrameGetDF" - Me.ucrDataFrameGetDF.Size = New System.Drawing.Size(224, 59) - Me.ucrDataFrameGetDF.TabIndex = 31 - ' - 'ucrCboGetOutputObjectType - ' - Me.ucrCboGetOutputObjectType.AddQuotesIfUnrecognised = True - Me.ucrCboGetOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboGetOutputObjectType.GetSetSelectedIndex = -1 - Me.ucrCboGetOutputObjectType.IsReadOnly = False - Me.ucrCboGetOutputObjectType.Location = New System.Drawing.Point(241, 72) - Me.ucrCboGetOutputObjectType.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboGetOutputObjectType.Name = "ucrCboGetOutputObjectType" - Me.ucrCboGetOutputObjectType.Size = New System.Drawing.Size(137, 21) - Me.ucrCboGetOutputObjectType.TabIndex = 47 - ' - 'ucrPnlGetData - ' - Me.ucrPnlGetData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlGetData.Location = New System.Drawing.Point(5, 10) - Me.ucrPnlGetData.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlGetData.Name = "ucrPnlGetData" - Me.ucrPnlGetData.Size = New System.Drawing.Size(402, 36) - Me.ucrPnlGetData.TabIndex = 42 - ' - 'ucrSelectorGetObject - ' - Me.ucrSelectorGetObject.AutoSize = True - Me.ucrSelectorGetObject.bDropUnusedFilterLevels = False - Me.ucrSelectorGetObject.bShowHiddenColumns = False - Me.ucrSelectorGetObject.bUseCurrentFilter = True - Me.ucrSelectorGetObject.Location = New System.Drawing.Point(9, 52) - Me.ucrSelectorGetObject.Margin = New System.Windows.Forms.Padding(0) - Me.ucrSelectorGetObject.Name = "ucrSelectorGetObject" - Me.ucrSelectorGetObject.Size = New System.Drawing.Size(320, 274) - Me.ucrSelectorGetObject.TabIndex = 34 - ' 'tbPageCommand ' Me.tbPageCommand.Controls.Add(Me.ucrInputRemoveObjects) @@ -447,18 +305,6 @@ Partial Class dlgScript Me.tbPageCommand.Text = "Commands" Me.tbPageCommand.UseVisualStyleBackColor = True ' - 'ucrInputRemoveObjects - ' - Me.ucrInputRemoveObjects.AddQuotesIfUnrecognised = True - Me.ucrInputRemoveObjects.AutoSize = True - Me.ucrInputRemoveObjects.IsMultiline = False - Me.ucrInputRemoveObjects.IsReadOnly = False - Me.ucrInputRemoveObjects.Location = New System.Drawing.Point(156, 56) - Me.ucrInputRemoveObjects.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputRemoveObjects.Name = "ucrInputRemoveObjects" - Me.ucrInputRemoveObjects.Size = New System.Drawing.Size(145, 21) - Me.ucrInputRemoveObjects.TabIndex = 2 - ' 'rdoCommandPackage ' Me.rdoCommandPackage.AutoSize = True @@ -483,27 +329,6 @@ Partial Class dlgScript Me.rdoCommandObject.Text = "Remove Object(s):" Me.rdoCommandObject.UseVisualStyleBackColor = True ' - 'ucrCboCommandPackage - ' - Me.ucrCboCommandPackage.AddQuotesIfUnrecognised = True - Me.ucrCboCommandPackage.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboCommandPackage.GetSetSelectedIndex = -1 - Me.ucrCboCommandPackage.IsReadOnly = False - Me.ucrCboCommandPackage.Location = New System.Drawing.Point(156, 19) - Me.ucrCboCommandPackage.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboCommandPackage.Name = "ucrCboCommandPackage" - Me.ucrCboCommandPackage.Size = New System.Drawing.Size(137, 21) - Me.ucrCboCommandPackage.TabIndex = 44 - ' - 'ucrPnlCommands - ' - Me.ucrPnlCommands.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlCommands.Location = New System.Drawing.Point(9, 8) - Me.ucrPnlCommands.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlCommands.Name = "ucrPnlCommands" - Me.ucrPnlCommands.Size = New System.Drawing.Size(333, 143) - Me.ucrPnlCommands.TabIndex = 47 - ' 'tbPageExamples ' Me.tbPageExamples.Controls.Add(Me.rdoExampleData) @@ -553,15 +378,6 @@ Partial Class dlgScript Me.rdoExampleFunction.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoExampleFunction.UseVisualStyleBackColor = True ' - 'ucrPnlExample - ' - Me.ucrPnlExample.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlExample.Location = New System.Drawing.Point(7, 51) - Me.ucrPnlExample.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlExample.Name = "ucrPnlExample" - Me.ucrPnlExample.Size = New System.Drawing.Size(402, 34) - Me.ucrPnlExample.TabIndex = 56 - ' 'lstExampleCollection ' Me.lstExampleCollection.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.clmDatasets, Me.clmDesc}) @@ -598,18 +414,6 @@ Partial Class dlgScript Me.Label3.TabIndex = 52 Me.Label3.Text = "Package" ' - 'ucrCboExamplePackages - ' - Me.ucrCboExamplePackages.AddQuotesIfUnrecognised = True - Me.ucrCboExamplePackages.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboExamplePackages.GetSetSelectedIndex = -1 - Me.ucrCboExamplePackages.IsReadOnly = False - Me.ucrCboExamplePackages.Location = New System.Drawing.Point(14, 22) - Me.ucrCboExamplePackages.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboExamplePackages.Name = "ucrCboExamplePackages" - Me.ucrCboExamplePackages.Size = New System.Drawing.Size(137, 21) - Me.ucrCboExamplePackages.TabIndex = 51 - ' 'lblPreview ' Me.lblPreview.AutoSize = True @@ -629,6 +433,213 @@ Partial Class dlgScript Me.txtScript.Size = New System.Drawing.Size(445, 96) Me.txtScript.TabIndex = 32 ' + 'ucrChkDisplayGraph + ' + Me.ucrChkDisplayGraph.AutoSize = True + Me.ucrChkDisplayGraph.Checked = False + Me.ucrChkDisplayGraph.Location = New System.Drawing.Point(88, 217) + Me.ucrChkDisplayGraph.Name = "ucrChkDisplayGraph" + Me.ucrChkDisplayGraph.Size = New System.Drawing.Size(113, 23) + Me.ucrChkDisplayGraph.TabIndex = 60 + ' + 'ucrChkSaveDataFrameSingle + ' + Me.ucrChkSaveDataFrameSingle.AutoSize = True + Me.ucrChkSaveDataFrameSingle.Checked = False + Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(91, 101) + Me.ucrChkSaveDataFrameSingle.Name = "ucrChkSaveDataFrameSingle" + Me.ucrChkSaveDataFrameSingle.Size = New System.Drawing.Size(146, 23) + Me.ucrChkSaveDataFrameSingle.TabIndex = 59 + ' + 'ucrInputSaveDataFrame + ' + Me.ucrInputSaveDataFrame.AddQuotesIfUnrecognised = True + Me.ucrInputSaveDataFrame.AutoSize = True + Me.ucrInputSaveDataFrame.IsMultiline = False + Me.ucrInputSaveDataFrame.IsReadOnly = False + Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(92, 70) + Me.ucrInputSaveDataFrame.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputSaveDataFrame.Name = "ucrInputSaveDataFrame" + Me.ucrInputSaveDataFrame.Size = New System.Drawing.Size(145, 21) + Me.ucrInputSaveDataFrame.TabIndex = 57 + ' + 'ucrCboSaveOutputObjectFormat + ' + Me.ucrCboSaveOutputObjectFormat.AddQuotesIfUnrecognised = True + Me.ucrCboSaveOutputObjectFormat.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboSaveOutputObjectFormat.GetSetSelectedIndex = -1 + Me.ucrCboSaveOutputObjectFormat.IsReadOnly = False + Me.ucrCboSaveOutputObjectFormat.Location = New System.Drawing.Point(88, 160) + Me.ucrCboSaveOutputObjectFormat.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboSaveOutputObjectFormat.Name = "ucrCboSaveOutputObjectFormat" + Me.ucrCboSaveOutputObjectFormat.Size = New System.Drawing.Size(141, 21) + Me.ucrCboSaveOutputObjectFormat.TabIndex = 55 + ' + 'ucrCboSaveOutputObjectType + ' + Me.ucrCboSaveOutputObjectType.AddQuotesIfUnrecognised = True + Me.ucrCboSaveOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboSaveOutputObjectType.GetSetSelectedIndex = -1 + Me.ucrCboSaveOutputObjectType.IsReadOnly = False + Me.ucrCboSaveOutputObjectType.Location = New System.Drawing.Point(87, 116) + Me.ucrCboSaveOutputObjectType.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboSaveOutputObjectType.Name = "ucrCboSaveOutputObjectType" + Me.ucrCboSaveOutputObjectType.Size = New System.Drawing.Size(144, 21) + Me.ucrCboSaveOutputObjectType.TabIndex = 53 + ' + 'ucrSaveObject + ' + Me.ucrSaveObject.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrSaveObject.Location = New System.Drawing.Point(88, 193) + Me.ucrSaveObject.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.ucrSaveObject.Name = "ucrSaveObject" + Me.ucrSaveObject.Size = New System.Drawing.Size(258, 22) + Me.ucrSaveObject.TabIndex = 35 + ' + 'ucrDataFrameSaveOutputSelect + ' + Me.ucrDataFrameSaveOutputSelect.AutoSize = True + Me.ucrDataFrameSaveOutputSelect.bDropUnusedFilterLevels = False + Me.ucrDataFrameSaveOutputSelect.bUseCurrentFilter = True + Me.ucrDataFrameSaveOutputSelect.Location = New System.Drawing.Point(86, 54) + Me.ucrDataFrameSaveOutputSelect.Margin = New System.Windows.Forms.Padding(0) + Me.ucrDataFrameSaveOutputSelect.Name = "ucrDataFrameSaveOutputSelect" + Me.ucrDataFrameSaveOutputSelect.Size = New System.Drawing.Size(224, 59) + Me.ucrDataFrameSaveOutputSelect.TabIndex = 29 + ' + 'ucrPnlSaveData + ' + Me.ucrPnlSaveData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlSaveData.Location = New System.Drawing.Point(13, 12) + Me.ucrPnlSaveData.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlSaveData.Name = "ucrPnlSaveData" + Me.ucrPnlSaveData.Size = New System.Drawing.Size(402, 36) + Me.ucrPnlSaveData.TabIndex = 47 + ' + 'ucrReceiverGetOutputObject + ' + Me.ucrReceiverGetOutputObject.AutoSize = True + Me.ucrReceiverGetOutputObject.frmParent = Me + Me.ucrReceiverGetOutputObject.Location = New System.Drawing.Point(240, 117) + Me.ucrReceiverGetOutputObject.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverGetOutputObject.Name = "ucrReceiverGetOutputObject" + Me.ucrReceiverGetOutputObject.Selector = Nothing + Me.ucrReceiverGetOutputObject.Size = New System.Drawing.Size(138, 20) + Me.ucrReceiverGetOutputObject.strNcFilePath = "" + Me.ucrReceiverGetOutputObject.TabIndex = 27 + Me.ucrReceiverGetOutputObject.ucrSelector = Nothing + ' + 'ucrReceiverGetColumns + ' + Me.ucrReceiverGetColumns.AutoSize = True + Me.ucrReceiverGetColumns.frmParent = Me + Me.ucrReceiverGetColumns.Location = New System.Drawing.Point(243, 104) + Me.ucrReceiverGetColumns.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverGetColumns.Name = "ucrReceiverGetColumns" + Me.ucrReceiverGetColumns.Selector = Nothing + Me.ucrReceiverGetColumns.Size = New System.Drawing.Size(137, 105) + Me.ucrReceiverGetColumns.strNcFilePath = "" + Me.ucrReceiverGetColumns.TabIndex = 49 + Me.ucrReceiverGetColumns.ucrSelector = Nothing + ' + 'ucrDataFrameGetDF + ' + Me.ucrDataFrameGetDF.AutoSize = True + Me.ucrDataFrameGetDF.bDropUnusedFilterLevels = False + Me.ucrDataFrameGetDF.bUseCurrentFilter = True + Me.ucrDataFrameGetDF.Location = New System.Drawing.Point(81, 55) + Me.ucrDataFrameGetDF.Margin = New System.Windows.Forms.Padding(0) + Me.ucrDataFrameGetDF.Name = "ucrDataFrameGetDF" + Me.ucrDataFrameGetDF.Size = New System.Drawing.Size(224, 59) + Me.ucrDataFrameGetDF.TabIndex = 31 + ' + 'ucrCboGetOutputObjectType + ' + Me.ucrCboGetOutputObjectType.AddQuotesIfUnrecognised = True + Me.ucrCboGetOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboGetOutputObjectType.GetSetSelectedIndex = -1 + Me.ucrCboGetOutputObjectType.IsReadOnly = False + Me.ucrCboGetOutputObjectType.Location = New System.Drawing.Point(241, 72) + Me.ucrCboGetOutputObjectType.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboGetOutputObjectType.Name = "ucrCboGetOutputObjectType" + Me.ucrCboGetOutputObjectType.Size = New System.Drawing.Size(137, 21) + Me.ucrCboGetOutputObjectType.TabIndex = 47 + ' + 'ucrPnlGetData + ' + Me.ucrPnlGetData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlGetData.Location = New System.Drawing.Point(5, 10) + Me.ucrPnlGetData.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlGetData.Name = "ucrPnlGetData" + Me.ucrPnlGetData.Size = New System.Drawing.Size(402, 36) + Me.ucrPnlGetData.TabIndex = 42 + ' + 'ucrSelectorGetObject + ' + Me.ucrSelectorGetObject.AutoSize = True + Me.ucrSelectorGetObject.bDropUnusedFilterLevels = False + Me.ucrSelectorGetObject.bShowHiddenColumns = False + Me.ucrSelectorGetObject.bUseCurrentFilter = True + Me.ucrSelectorGetObject.Location = New System.Drawing.Point(9, 52) + Me.ucrSelectorGetObject.Margin = New System.Windows.Forms.Padding(0) + Me.ucrSelectorGetObject.Name = "ucrSelectorGetObject" + Me.ucrSelectorGetObject.Size = New System.Drawing.Size(320, 274) + Me.ucrSelectorGetObject.TabIndex = 34 + ' + 'ucrInputRemoveObjects + ' + Me.ucrInputRemoveObjects.AddQuotesIfUnrecognised = True + Me.ucrInputRemoveObjects.AutoSize = True + Me.ucrInputRemoveObjects.IsMultiline = False + Me.ucrInputRemoveObjects.IsReadOnly = False + Me.ucrInputRemoveObjects.Location = New System.Drawing.Point(156, 56) + Me.ucrInputRemoveObjects.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputRemoveObjects.Name = "ucrInputRemoveObjects" + Me.ucrInputRemoveObjects.Size = New System.Drawing.Size(145, 21) + Me.ucrInputRemoveObjects.TabIndex = 2 + ' + 'ucrCboCommandPackage + ' + Me.ucrCboCommandPackage.AddQuotesIfUnrecognised = True + Me.ucrCboCommandPackage.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboCommandPackage.GetSetSelectedIndex = -1 + Me.ucrCboCommandPackage.IsReadOnly = False + Me.ucrCboCommandPackage.Location = New System.Drawing.Point(156, 19) + Me.ucrCboCommandPackage.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboCommandPackage.Name = "ucrCboCommandPackage" + Me.ucrCboCommandPackage.Size = New System.Drawing.Size(137, 21) + Me.ucrCboCommandPackage.TabIndex = 44 + ' + 'ucrPnlCommands + ' + Me.ucrPnlCommands.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlCommands.Location = New System.Drawing.Point(9, 8) + Me.ucrPnlCommands.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlCommands.Name = "ucrPnlCommands" + Me.ucrPnlCommands.Size = New System.Drawing.Size(333, 143) + Me.ucrPnlCommands.TabIndex = 47 + ' + 'ucrPnlExample + ' + Me.ucrPnlExample.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlExample.Location = New System.Drawing.Point(7, 51) + Me.ucrPnlExample.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlExample.Name = "ucrPnlExample" + Me.ucrPnlExample.Size = New System.Drawing.Size(402, 34) + Me.ucrPnlExample.TabIndex = 56 + ' + 'ucrCboExamplePackages + ' + Me.ucrCboExamplePackages.AddQuotesIfUnrecognised = True + Me.ucrCboExamplePackages.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboExamplePackages.GetSetSelectedIndex = -1 + Me.ucrCboExamplePackages.IsReadOnly = False + Me.ucrCboExamplePackages.Location = New System.Drawing.Point(14, 22) + Me.ucrCboExamplePackages.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboExamplePackages.Name = "ucrCboExamplePackages" + Me.ucrCboExamplePackages.Size = New System.Drawing.Size(137, 21) + Me.ucrCboExamplePackages.TabIndex = 51 + ' 'ucrBase ' Me.ucrBase.AutoSize = True @@ -715,4 +726,5 @@ Partial Class dlgScript Friend WithEvents lblSaveDataFrame As Label Friend WithEvents ucrInputSaveDataFrame As ucrInputTextBox Friend WithEvents ucrChkSaveDataFrameSingle As ucrCheck + Friend WithEvents ucrChkDisplayGraph As ucrCheck End Class diff --git a/instat/dlgScript.vb b/instat/dlgScript.vb index 17b3d481199..84c0f6491dc 100644 --- a/instat/dlgScript.vb +++ b/instat/dlgScript.vb @@ -20,6 +20,7 @@ Public Class dlgScript Private strComment As String = "Code generated by the dialog, Script" Private bFirstload As Boolean = True Private clsSaveDataFunction As New RFunction + Private clsGetRObjectFunction As New RFunction Private dctOutputObjectTypes As New Dictionary(Of String, String) Private dctOutputObjectFormats As New Dictionary(Of String, String) @@ -68,6 +69,8 @@ Public Class dlgScript ucrInputSaveDataFrame.SetLinkedDisplayControl(lblSaveDataFrame) ucrChkSaveDataFrameSingle.SetText("Single") + ucrChkDisplayGraph.SetText("Display Output") + '-------------------------------- 'Get data controls @@ -136,7 +139,7 @@ Public Class dlgScript End Function Private Sub SetDefaults() - + clsGetRObjectFunction = New RFunction ' Examples controls rdoExampleData.Checked = True @@ -150,6 +153,7 @@ Public Class dlgScript ucrSaveObject.Reset() rdoSaveDataFrame.Checked = True ucrChkSaveDataFrameSingle.Checked = True + ucrChkDisplayGraph.Checked = True ucrDataFrameSaveOutputSelect.Reset() ' Get controls reset @@ -171,20 +175,24 @@ Public Class dlgScript ucrCboSaveOutputObjectFormat.SetVisible(False) ucrSaveObject.SetVisible(False) ucrInputSaveDataFrame.SetVisible(False) + ucrChkDisplayGraph.Visible = False ucrChkSaveDataFrameSingle.SetVisible(False) If rdoSaveDataFrame.Checked Then ucrInputSaveDataFrame.SetVisible(True) ucrChkSaveDataFrameSingle.SetVisible(True) + ucrChkDisplayGraph.Visible = False ucrInputSaveDataFrame.SetName("") ElseIf rdoSaveColumn.Checked Then ucrSaveObject.Location = New Point(ucrSaveObject.Location.X, ucrCboSaveOutputObjectType.Location.Y) ucrSaveObject.SetVisible(True) ucrDataFrameSaveOutputSelect.SetVisible(True) + ucrChkDisplayGraph.Visible = False SetupSaveDataControl("Column", RObjectTypeLabel.Column, "") ElseIf rdoSaveOutputObject.Checked Then ucrSaveObject.Location = New Point(ucrSaveObject.Location.X, ucrCboSaveOutputObjectFormat.Location.Y + 33) ucrSaveObject.SetVisible(True) ucrDataFrameSaveOutputSelect.SetVisible(True) + ucrChkDisplayGraph.Visible = True ucrCboSaveOutputObjectType.SetVisible(True) ucrCboSaveOutputObjectFormat.SetVisible(True) SetupSaveDataControl(ucrCboSaveOutputObjectType.GetText(), dctOutputObjectTypes.Item(ucrCboSaveOutputObjectType.GetText()), dctOutputObjectFormats.Item(ucrCboSaveOutputObjectFormat.GetText())) @@ -229,8 +237,9 @@ Public Class dlgScript PreviewScript(strScript) End Sub - Private Sub ucrSaveData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSaveObject.ControlContentsChanged + Private Sub ucrSaveData_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSaveObject.ControlContentsChanged, ucrChkDisplayGraph.ControlValueChanged Dim strScript As String = "" + Dim strGetScript As String = "" If ucrSaveObject.IsComplete Then ' R code is not automatiucally updated by save control when control contents changed event is raised by the control @@ -250,9 +259,18 @@ Public Class dlgScript strTemp = arrtemp(1) strScript = "# Save " & strDataType & " """ & ucrSaveObject.GetText() & """" & Environment.NewLine & strTemp End If - End If - PreviewScript(strScript) + If ucrChkDisplayGraph.Checked Then + ucrChkDisplayGraph.UpdateRCode() + clsGetRObjectFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_object_data") + clsGetRObjectFunction.AddParameter("data_name", Chr(34) & ucrDataFrameSaveOutputSelect.strCurrDataFrame & Chr(34), iPosition:=0) + clsGetRObjectFunction.AddParameter("as_file", "TRUE", iPosition:=2) + clsGetRObjectFunction.AddParameter("object_name", Chr(34) & ucrSaveObject.GetText & Chr(34), iPosition:=1) + strGetScript = "" & Environment.NewLine & clsGetRObjectFunction.ToScript() + End If + End If + Dim combinedScript As String = strScript & Environment.NewLine & strGetScript + PreviewScript(combinedScript) End Sub Private Sub ucrPnlGetData_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlGetData.ControlValueChanged @@ -497,6 +515,4 @@ Public Class dlgScript txtScript.ScrollToCaret() txtScript.Refresh() End Sub - - End Class \ No newline at end of file