Skip to content

Commit

Permalink
Merge pull request #2270 from FrancoisJRenaud/dlgGeneralForGraphics
Browse files Browse the repository at this point in the history
dlgGeneralForGraphics, ucrAdditionalLayers, sdgPlots #1947
  • Loading branch information
dannyparsons authored Nov 17, 2016
2 parents 7b2b405 + faec7d7 commit 36b6c35
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
13 changes: 13 additions & 0 deletions instat/dlgGeneralForGraphics.Designer.vb

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

20 changes: 19 additions & 1 deletion instat/dlgGeneralForGraphics.vb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Public Class dlgGeneralForGraphics
clsRggplotFunction.SetRCommand("ggplot")
clsGgplotAesFunction.SetRCommand("aes")
ucrBase.clsRsyntax.SetOperatorParameter(True, clsRFunc:=clsRggplotFunction)
'True for "we are setting the first parameter, on the left of +.
'True for "we are setting the first parameter, on the left of +".
ucrBase.iHelpTopicID = 356

ucrSaveGraph.SetDataFrameSelector(sdgLayerOptions.ucrGeomWithAes.UcrSelector.ucrAvailableDataFrames)
Expand All @@ -70,6 +70,8 @@ Public Class dlgGeneralForGraphics
If ucrBase.clsRsyntax.clsBaseOperator IsNot Nothing Then
ucrBase.clsRsyntax.clsBaseOperator.RemoveAllAdditionalParameters()
End If
sdgPlots.Reset()
'Warning/to be discussed: sdgPlots doesn't work like sdgLayerOptions. Information actually stays on the dialogue, as it cannot be editted on the general for graphics (yet) I think that sdgPlots should work like LayerOptions and be filled in at load, thanks to a setup function and setsettings sub.
TestOKEnabled()
End Sub

Expand Down Expand Up @@ -168,4 +170,20 @@ Public Class dlgGeneralForGraphics
ucrBase.clsRsyntax.SetAssignTo("last_graph", strTempDataframe:=sdgLayerOptions.ucrGeomWithAes.UcrSelector.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempGraph:="last_graph")
End If
End Sub

Private Sub SetupPlotOptions() 'Warning to be discussed: I m hoping to have a Setup function in sdgPlots itself... ?
sdgPlots.SetRSyntax(ucrBase.clsRsyntax)
sdgPlots.SetGgplotFunction(clsRggplotFunction)
End Sub
Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click
sdgPlots.DisableLayersTab()
SetupPlotOptions()
sdgPlots.ShowDialog()
sdgPlots.EnableLayersTab()
End Sub

Private Sub ucrAdditionalLayers_NumberOfLayersChanged() Handles ucrAdditionalLayers.NumberOfLayersChanged
'When the number of Layers in the lstLayers on ucrAdditionalLayers need to check if OK is enabled on dlgGeneralForGraphics.
TestOKEnabled()
End Sub
End Class
21 changes: 18 additions & 3 deletions instat/sdgPlots.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Public Class sdgPlots
Public clsRsyntax As New RSyntax
'This clsRSyntax is linked with the ucrBase.clsRSyntax from the dlg calling sdgPLotOptions...
Public clsRggplotFunction As New RFunction
Public clsAesFunction As New RFunction
Public clsAesFunction As New RFunction 'Warning: I m not sure this field is useful... Will all be revised when changing links though...
Public clsRFacetFunction As New RFunction
Public clsXLabFunction As New RFunction
Public clsYLabFunction As New RFunction
Expand All @@ -46,6 +46,13 @@ Public Class sdgPlots
autoTranslate(Me)
End Sub

Public Sub DisableLayersTab()
tabLayers.Enabled = False
End Sub

Public Sub EnableLayersTab()
tabLayers.Enabled = True
End Sub
Public Sub SetDefaults()
TitleDefaults()

Expand Down Expand Up @@ -80,10 +87,12 @@ Public Class sdgPlots
InitialiseTabs()
CreateThemes()
FacetsReceiversSetup()
'The following three setup the ucrAdditionalLayers on the sdgPlots. Shares the global ggplot function and aesthetics, as well as the whole PLots RSyntax.
ucrPlotsAdditionalLayers.SetGGplotFunction(clsRggplotFunction)
'The following sets up the clsGgplotAesFunction in ucrAdditionalLayers. Not sure this should happen in the initialise dialog... Not sure of the objective either... It is never linked to the main dlg anyway...
ucrPlotsAdditionalLayers.SetAesFunction(clsAesFunction)
'The following two setup the ucrAdditionalLayers on the sdgPlots. Shares the global ggplot function, as well as the whole PLots RSyntax.
ucrPlotsAdditionalLayers.SetGGplotFunction(clsRggplotFunction)
ucrPlotsAdditionalLayers.SetRSyntax(clsRsyntax)

'Set's the X Axis tab to X mode and the YAxis tab to Y mode (each tab contains a generic ucrAxis with internal X or Y boolean setting).
'Also carry the RSyntax through to these ucr's .
ucrXAxis.SetXorY(True)
Expand Down Expand Up @@ -346,7 +355,9 @@ Public Class sdgPlots

'Question to be discussed/Task: This is the kind of subs that could go into a SetupPlotOptions procedure... also only called in two specific plots and not in the others ... Why ? (to be explored)
Public Sub SetGgplotFunction(clsGgplotFunc As RFunction)
'When the link for clsRggplotFunction has been changed, the ucrAdditionalLayers GgplotFunction needs to be updated.
clsRggplotFunction = clsGgplotFunc
ucrPlotsAdditionalLayers.SetGGplotFunction(clsRggplotFunction)
End Sub

Public Sub SetDataFrame(strNewDataFrame As String)
Expand All @@ -355,7 +366,9 @@ Public Class sdgPlots
End Sub

Public Sub SetRSyntax(clsRSyntaxIn As RSyntax)
'When the link for RSyntax has been changed, the ucrAdditionalLayers RSyntax needs to be updated.
clsRsyntax = clsRSyntaxIn
ucrPlotsAdditionalLayers.SetRSyntax(clsRsyntax)
End Sub


Expand Down Expand Up @@ -422,4 +435,6 @@ Public Class sdgPlots
End Sub


'Warning/Task to be discussed: need to disable ok on dlg's when layers are not complete on subdialogues + warning message...
'Warning: actually this will be very hard to implement until the global aes, set from the main layer are properly communicated to plots. Global aes might fill in missing mandatory aes...
End Class
23 changes: 15 additions & 8 deletions instat/ucrAdditionalLayers.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Public Class ucrAdditionalLayers
Public bSetGlobalIsDefault As Boolean
'Deciding if the first layer needs to be used for global aesthetics.
'Question to be discussed: What is this variable about again ? it is linked with sdgPlots.bAdditionalLayersSetGlobal in sdgPLots.bLayersDefaultIsGolobal.

Public Event NumberOfLayersChanged() 'This event is raised when the number of Layers in the lstLayers on ucrAdditionalLayers has been changed, then handled by testOkEnabled On GeneralForGraphics.
Public Sub New()

' This call is required by the designer.
Expand Down Expand Up @@ -114,15 +114,20 @@ Public Class ucrAdditionalLayers
End If

clsRSyntax.SetOperatorParameter(False, strParameterName:=strLayerName, clsRFunc:=sdgLayerOptions.clsGeomFunction.Clone())
'Note: as the GeomFunction on sdgLayerOptions will be edited for different layers, it cannot be linked like clsGgplotFunction would, it needs to be cloned.

dlgGeneralForGraphics.TestOKEnabled()
'When the number of Layers in the lstLayers on ucrAdditionalLayers need to check if OK is enabled on dlgGeneralForGraphics.
RaiseEvent NumberOfLayersChanged()
End Sub

Private Sub cmdDelete_Click(sender As Object, e As EventArgs) Handles cmdDelete.Click
If lstLayers.SelectedItems.Count = 1 Then
clsRSyntax.RemoveOperatorParameter(lstLayers.SelectedItems(0).Text)
lstLayerComplete.RemoveAt(lstLayers.SelectedIndices(0))
lstLayers.Items.Remove(lstLayers.SelectedItems(0))

'When the number of Layers in the lstLayers on ucrAdditionalLayers need to check if OK is enabled on dlgGeneralForGraphics.
RaiseEvent NumberOfLayersChanged()
End If
End Sub

Expand All @@ -131,7 +136,7 @@ Public Class ucrAdditionalLayers
Dim clsLocalAes As RFunction
Dim bIgnoreGlobalAes As Boolean
'bIgnoreGlobalAes is used in Setup(Layer) to determine whether the chkIgnoreGlobalAes should be ticked in the sdgLayerOptions. It's value is determined below. The following RParameter will be used in this procedure.
Dim clsTempRParameter As RParameter

'The selected geom is found as the RFunction of the appropriate RParameter of RSyntax. The name of that Parameter is the name of the selected item in the lstLayers. That one is fetched using .SelectedItems(0) as there can only be one selected item at a time when the edit button is clicked.
clsSelectedGeom = clsRSyntax.GetParameter(lstLayers.SelectedItems(0).Text).clsArgumentFunction
If clsSelectedGeom.GetParameter("mapping") IsNot Nothing Then
Expand All @@ -141,14 +146,16 @@ Public Class ucrAdditionalLayers
End If

'Before we set-up the Layer in sdgLayerOptions, we determine the value of bIgnoreGlobalAes. We can detect if chkIgnoreGlobalAes was ticked last time the Layer was editted by looking at the "inherit.aes" parameter of the layer parameters.
clsTempRParameter = clsSelectedGeom.GetParameter("inherit.aes")
If (clsTempRParameter IsNot Nothing) AndAlso (clsTempRParameter.strArgumentValue = "False") Then
If (clsSelectedGeom.GetParameter("inherit.aes") IsNot Nothing) AndAlso (clsSelectedGeom.GetParameter("inherit.aes").strArgumentValue = "FALSE") Then
bIgnoreGlobalAes = True
Else bIgnoreGlobalAes = False
Else
bIgnoreGlobalAes = False
End If

sdgLayerOptions.SetupLayer(clsTempGgPlot:=dlgGeneralForGraphics.clsRggplotFunction, clsTempGeomFunc:=clsSelectedGeom, clsTempAesFunc:=dlgGeneralForGraphics.clsGgplotAesFunction, bFixAes:=False, bFixGeom:=True, strDataframe:=strGlobalDataFrame, bApplyAesGlobally:=False, bIgnoreGlobalAes:=bIgnoreGlobalAes, clsTempLocalAes:=clsLocalAes)
'It has been chosen to fix the value of bApplyAesGlobally to False as when a Layer is editted, the choice to apply the Aes globally should be reconsidered no matter what it has been during last edit.
'Warning: sdgLayerOptions should not be setup using dlgGeneralForGraphics' fields !! These fields should be given through to the ucrAdditionalLayers (which should have all these)
sdgLayerOptions.SetupLayer(clsTempGgPlot:=clsRggplotFunction, clsTempGeomFunc:=clsSelectedGeom, clsTempAesFunc:=clsGgplotAesFunction, bFixAes:=False, bFixGeom:=True, strDataframe:=strGlobalDataFrame, bApplyAesGlobally:=False, bIgnoreGlobalAes:=bIgnoreGlobalAes, clsTempLocalAes:=clsLocalAes)
'It has been chosen to fix the value of bApplyAesGlobally to False as when a Layer is editted, the choice to apply the Aes globally should be reconsidered no matter what it has been during last edit.
ParentForm.SendToBack() 'Otherwise sdgLayerOptions appears behind sdgPLotOptions
sdgLayerOptions.ShowDialog()
AddLayers(lstLayers.SelectedItems(0))
End Sub
Expand Down

0 comments on commit 36b6c35

Please sign in to comment.