From a3b6137601545ac6e3484995d0ec6d39224bbf3f Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 6 Sep 2018 00:24:28 +0300 Subject: [PATCH] Added Edge.ThicknessProperty for generic edge-thickness styling gitlab #2 Change-Id: I9ce4bb9274a184d3e4ae83669c2079e3720dd412 --- .../graph/DistrictNetwork.pgraph | 332 +++++------------- .../DistrictNetworkDiagramSettings.pgraph | 63 ++++ .../graph/DistrictNetworkProfiles.pgraph | 35 ++ .../graph/DistrictNetworkViewpoint.pgraph | 47 +++ .../ontology/DistrictNetworkResource.java | 99 ++++-- .../network/ui/function/Functions.java | 13 + .../ui/nodes/DistrictNetworkEdgeNode.java | 3 +- org.simantics.district.network/adapters.xml | 13 +- .../network/profile/DiagramSettings.java | 59 ++++ .../profile/DiagramSettingsRequest.java | 54 +++ .../network/profile/EdgeNodeGroup.java | 41 --- .../district/network/profile/EdgeStyle.java | 59 ++++ .../{EdgeNodeStyle.java => VertexStyle.java} | 27 +- 13 files changed, 507 insertions(+), 338 deletions(-) create mode 100644 org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph create mode 100644 org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph create mode 100644 org.simantics.district.network.ontology/graph/DistrictNetworkViewpoint.pgraph create mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java create mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeGroup.java create mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java rename org.simantics.district.network/src/org/simantics/district/network/profile/{EdgeNodeStyle.java => VertexStyle.java} (52%) diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index 435bd55d..657ffc69 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -13,16 +13,94 @@ DN = : L0.Ontology L0.Ontology.global true L0.HasResourceClass "org.simantics.district.network.ontology.DistrictNetworkResource" -DN.Layer -- DN.Vertex.HasElevation + @defProperty "Elevation" L0.Double + >-- DN.Vertex.HasAddress + @defProperty "Address" L0.String + >-- DN.Vertex.HasSupplyTemperature + @defProperty "Supply Temperature" L0.Double + >-- DN.Vertex.HasReturnTemperature + @defProperty "Return Temperature" L0.Double + >-- DN.Vertex.HasSupplyPressure + @defProperty "Supply Pressure" L0.Double + >-- DN.Vertex.HasReturnPressure + @defProperty "Return Pressure" L0.Double + >-- DN.Vertex.HasDeltaPressure + @defProperty "Delta pressure" L0.Double + >-- DN.Vertex.HasDeltaTemperature + @defProperty "Delta temperature" L0.Double + >-- DN.Vertex.HasHeatPower + @defProperty "Heat Power" L0.Double + >-- DN.Vertex.HasNominalHeadM + @defProperty "NominalHeadM" L0.Double + >-- DN.Vertex.HasNominalHeadB + @defProperty "NominalHeadB" L0.Double + >-- DN.Vertex.HasNominalFlow + @defProperty "Nominal Flow" L0.Double + >-- DN.Vertex.HasMaximumHeadM + @defProperty "Maximum head M" L0.Double + >-- DN.Vertex.HasHeatLoadDs + @defProperty "Heat Load ds" L0.Double + >-- DN.Vertex.HasMassFlow + @defProperty "Mass Flow" L0.Double + >-- DN.Vertex.HasVolFlow + @defProperty "Vol Flow" L0.Double + >-- DN.Vertex.HasVelocity + @defProperty "Velocity" L0.Double + >-- DN.Vertex.HasFlowArea + @defProperty "Flow Area" L0.Double + >-- DN.Vertex.HasValvePosition + @defProperty "Valve position" L0.Double + >-- DN.Vertex.HasNominalPressureLoss + @defProperty "Nominal Pressure Loss" L0.Double + @L0.assert DN.Vertex.HasElevation 0.0 + DN.Edge -- DN.Edge.HasLength + @defProperty "Length" L0.Double + L0.readOnly true + >-- DN.Edge.HasDiameter + @defProperty "Diameter" L0.Double + >-- DN.Edge.HasOuterDiameter + @defProperty "Outer Diameter" L0.Double + >-- DN.Edge.HasNominalMassFlow + @defProperty "Nominal Mass Flow" L0.Double + >-- DN.Edge.HasFlowArea + @defProperty "Flow Area" L0.Double + >-- DN.Edge.HasKReturn + @defProperty "K Return" L0.Double + >-- DN.Edge.HasKSupply + @defProperty "K Supply" L0.Double + >-- DN.Edge.HasTGround + @defProperty "T Ground" L0.Double @L0.assert DN.Edge.HasDiameter 0.1 @L0.assert DN.Edge.HasOuterDiameter 0.11 -DN.Vertex L0.String -- DN.Mapping.EdgeMapping.KSupplyAttribute --> L0.String -- DN.Mapping.EdgeMapping.TGroundAttribute --> L0.String -- DN.Mapping.Terminals - -DN.SCLMain : L0.SCLModule - L0.SCLModule.definition - """ - include "Simantics/District/SCLMain" - """ - -DN.DistrictProfile : DIA.Profile - L0.HasLabel "District Network Profile" - DIA.Profile.priority 0.0 - DIA.HasEntries - _ : DIA.Profile - @L0.list - DN.DistrictProfile.entry - L0.HasLabel "Component names" - @DIA.groupStyleProfileEntry DN.ComponentNameStyle DN.Groups.ElementGroup - DN.DistrictProfile.entry1 - L0.HasLabel "Id" - @DIA.groupStyleProfileEntry DN.ComponentIdStyle DN.Groups.ElementGroup - DN.DistrictProfile.entry2 - L0.HasLabel "Edge Node Styling" - @DIA.groupStyleProfileEntry DN.EdgeNodeStyle DN.Groups.ElementGroup - -DN.Groups : L0.Library - -DN.Groups.ElementGroup : DIA.TypeGroup - DIA.TypeGroup.HasType DN.Element - -DN.ComponentNameStyle : DIA.ResourceSCLTextGridStyle - @MOD.scl DIA.ResourceSCLTextGridStyle.texts - """ - districtNetworkProfileStyle "http://www.simantics.org/Layer0-1.1/HasName" - """ - "String -> Variable -> (String, String, String)" - @G2D.fontProperty DIA.TextElement.font "Arial" 30 G2D.FontStyle.normal_font_style - -DN.ComponentIdStyle : DIA.ResourceSCLTextGridStyle - @MOD.scl DIA.ResourceSCLTextGridStyle.texts - """ - districtNetworkProfileStyle "http://www.simantics.org/Layer0-1.1/HasName" - """ - "String -> Variable -> (String, String, String)" - @G2D.fontProperty DIA.TextElement.font "Arial" 30 G2D.FontStyle.normal_font_style - -//DN.EdgeNodeGroup : DIA.Group - -//DN.Profiles : L0.Library - -DN.EdgeNodeStyle : DIA.Style - -// Templates - -//groupStyleEntry : L0.Template -// @template %subject %style %group -// %subject : DIA.GroupStyleProfileEntry -// DIA.ProfileEntry.HasStyle %style -// DIA.ProfileEntry.HasGroup %group - - -//DN.Profiles.EdgeNodeStyle -// L0.HasLabel "Edge Node Style" -// @groupStyleEntry DN.EdgeNodeStyle DN.EdgeNodeGroup diff --git a/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph new file mode 100644 index 00000000..686fb391 --- /dev/null +++ b/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph @@ -0,0 +1,63 @@ +L0 = +DIA = +STR = +MOD = +VP = +IMAGE = +SEL = +SEL_UI = +G2D = +DN = + +// ---------------------------------------------------------------------------- + +DN.EdgeThicknessPropertyParameterType -- DN.Vertex.ScaleProperty.value --> L0.Relation -- DN.Vertex.ScaleProperty.scale ==> "Double" -- DN.Edge.ThicknessProperty.scale --> L0.Double -- DN.Edge.ThicknessProperty.value --> L0.Relation -- DN.Diagram.nodeScale ==> "Double" -- DN.Diagram.nodeScalingProperty --> DN.Vertex.ScaleProperty -- DN.Diagram.edgeThicknessScale ==> "Double" -- DN.Diagram.edgeThicknessProperty --> DN.Edge.ThicknessProperty +DIA = +STR = +MOD = +VP = +IMAGE = +SEL = +SEL_UI = +G2D = +DN = + +/* +DN.DistrictProfile : DIA.Profile + L0.HasLabel "District Network Profile" + DIA.Profile.priority 0.0 + DIA.HasEntries + _ : DIA.Profile + @L0.list + DN.DistrictProfile.entry1 + L0.HasLabel "Node Coloring" + @DIA.groupStyleProfileEntry DN.VertexStyle DN.Groups.VertexGroup + DN.DistrictProfile.entry2 + L0.HasLabel "Edge Styling" + @DIA.groupStyleProfileEntry DN.EdgeStyle DN.Groups.EdgeGroup +*/ + +DN.Groups : L0.Library + +DN.Groups.VertexGroup : DIA.TypeGroup + DIA.TypeGroup.HasType DN.Vertex +DN.Groups.EdgeGroup : DIA.TypeGroup + DIA.TypeGroup.HasType DN.Edge + +DN.VertexStyle : DIA.Style +DN.EdgeStyle : DIA.Style diff --git a/org.simantics.district.network.ontology/graph/DistrictNetworkViewpoint.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetworkViewpoint.pgraph new file mode 100644 index 00000000..8fa53c93 --- /dev/null +++ b/org.simantics.district.network.ontology/graph/DistrictNetworkViewpoint.pgraph @@ -0,0 +1,47 @@ +L0 = +DIA = +STR = +MOD = +VP = +IMAGE = +SEL = +SEL_UI = +G2D = +DN = + +// ---------------------------------------------------------------------------- + +MBC = MOD.ModelingBrowseContext + +DNAC.newDiagramContribution : L0.Template + @template %actionContext %label %image %action + %actionContext + VP.BrowseContext.HasActionContribution _ : VP.ActionContribution + L0.HasLabel %label + VP.ActionContribution.HasImage %image + VP.ActionContribution.HasCategory VP.NewActionCategory + VP.ActionContribution.HasNodeType MBC.Configuration + VP.ActionContribution.HasAction %action + +DNAC = DN.ActionContext : VP.BrowseContext + VP.BrowseContext.IsIncludedIn MOD.ModelingActionContext + @DNAC.newDiagramContribution "Network Diagram" IMAGES.MapImage ACTIONS.NewDNDiagram + +DNBC = DN.BrowseContext : VP.BrowseContext + VP.BrowseContext.IsIncludedIn MOD.ModelingBrowseContext + VP.BrowseContext.Includes SEL_UI.StandardPropertiesBase.BrowseContext + + @VP.customModifierRule DN.Edge VP.ResourceLabelModifierRule + @VP.constantImageRule DN.Composite IMAGES.MapImage + + +ACTIONS = DN.Actions : L0.Library + +ACTIONS.NewDNDiagram : MOD.NewComposite + MOD.NewComposite.HasCompositeType DN.Composite + MOD.NewComposite.HasDefaultName "NewNetworkDiagram" + +IMAGES = DN.Images : L0.Library + +IMAGES.MapImage : IMAGE.PngImage + @L0.loadBytes "images/map.png" diff --git a/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java b/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java index 159af7ba..e7e7bf6f 100644 --- a/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java +++ b/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java @@ -16,23 +16,22 @@ public class DistrictNetworkResource { public final Resource Actions_NewDNDiagram; public final Resource AddLayerToDNDiagramTemplate; public final Resource BrowseContext; - public final Resource ComponentIdStyle; - public final Resource ComponentNameStyle; public final Resource Composite; public final Resource Connection; public final Resource Diagram; public final Resource Diagram_MappedDiagram; public final Resource Diagram_MappedFromDiagram; - public final Resource DistrictProfile; - public final Resource DistrictProfile_entry; - public final Resource DistrictProfile_entry1; - public final Resource DistrictProfile_entry2; + public final Resource Diagram_edgeThicknessProperty; + public final Resource Diagram_edgeThicknessProperty_Inverse; + public final Resource Diagram_edgeThicknessScale; + public final Resource Diagram_edgeThicknessScale_Inverse; public final Resource EPSG_4326; public final Resource Edge; public final Resource EdgeDefaultMapping; public final Resource EdgeDefaultMapping_Inverse; public final Resource EdgeMappingParameterType; - public final Resource EdgeNodeStyle; + public final Resource EdgeStyle; + public final Resource EdgeThicknessPropertyParameterType; public final Resource Edge_HasDiameter; public final Resource Edge_HasDiameter_Inverse; public final Resource Edge_HasFlowArea; @@ -49,16 +48,26 @@ public class DistrictNetworkResource { public final Resource Edge_HasOuterDiameter_Inverse; public final Resource Edge_HasTGround; public final Resource Edge_HasTGround_Inverse; + public final Resource Edge_ThicknessProperty; + public final Resource Edge_ThicknessProperty_Diameter; + public final Resource Edge_ThicknessProperty_NominalMassFlow; + public final Resource Edge_ThicknessProperty_scale; + public final Resource Edge_ThicknessProperty_scale_Inverse; + public final Resource Edge_ThicknessProperty_value; + public final Resource Edge_ThicknessProperty_value_Inverse; public final Resource Element; public final Resource Functions; public final Resource Functions_compositeInstantiator; public final Resource Functions_convertToValue; public final Resource Functions_defaultEdgeMappingModifier; public final Resource Functions_defaultVertexMappingModifier; + public final Resource Functions_edgeThicknessPropertyEnumerationValues; + public final Resource Functions_edgeThicknessPropertyModifier; public final Resource Functions_enumerationValues; public final Resource Functions_mappingModifier; public final Resource Groups; - public final Resource Groups_ElementGroup; + public final Resource Groups_EdgeGroup; + public final Resource Groups_VertexGroup; public final Resource HasEndVertex; public final Resource HasEndVertex_Inverse; public final Resource HasId; @@ -166,6 +175,8 @@ public class DistrictNetworkResource { public final Resource VertexDefaultMapping; public final Resource VertexDefaultMapping_Inverse; public final Resource VertexMappingParameterType; + public final Resource VertexStyle; + public final Resource Vertex_ColorProperty; public final Resource Vertex_HasAddress; public final Resource Vertex_HasAddress_Inverse; public final Resource Vertex_HasDeltaPressure; @@ -206,6 +217,12 @@ public class DistrictNetworkResource { public final Resource Vertex_HasVelocity_Inverse; public final Resource Vertex_HasVolFlow; public final Resource Vertex_HasVolFlow_Inverse; + public final Resource Vertex_ScaleProperty; + public final Resource Vertex_ScaleProperty_SupplyPressure; + public final Resource Vertex_ScaleProperty_scale; + public final Resource Vertex_ScaleProperty_scale_Inverse; + public final Resource Vertex_ScaleProperty_value; + public final Resource Vertex_ScaleProperty_value_Inverse; public static class URIs { public static final String ActionContext = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext"; @@ -214,23 +231,22 @@ public class DistrictNetworkResource { public static final String Actions_NewDNDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Actions/NewDNDiagram"; public static final String AddLayerToDNDiagramTemplate = "http://www.simantics.org/DistrictNetwork-1.0/AddLayerToDNDiagramTemplate"; public static final String BrowseContext = "http://www.simantics.org/DistrictNetwork-1.0/BrowseContext"; - public static final String ComponentIdStyle = "http://www.simantics.org/DistrictNetwork-1.0/ComponentIdStyle"; - public static final String ComponentNameStyle = "http://www.simantics.org/DistrictNetwork-1.0/ComponentNameStyle"; public static final String Composite = "http://www.simantics.org/DistrictNetwork-1.0/Composite"; public static final String Connection = "http://www.simantics.org/DistrictNetwork-1.0/Connection"; public static final String Diagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram"; public static final String Diagram_MappedDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/MappedDiagram"; public static final String Diagram_MappedFromDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/MappedFromDiagram"; - public static final String DistrictProfile = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile"; - public static final String DistrictProfile_entry = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry"; - public static final String DistrictProfile_entry1 = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry1"; - public static final String DistrictProfile_entry2 = "http://www.simantics.org/DistrictNetwork-1.0/DistrictProfile/entry2"; + public static final String Diagram_edgeThicknessProperty = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessProperty"; + public static final String Diagram_edgeThicknessProperty_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessProperty/Inverse"; + public static final String Diagram_edgeThicknessScale = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessScale"; + public static final String Diagram_edgeThicknessScale_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessScale/Inverse"; public static final String EPSG_4326 = "http://www.simantics.org/DistrictNetwork-1.0/EPSG_4326"; public static final String Edge = "http://www.simantics.org/DistrictNetwork-1.0/Edge"; public static final String EdgeDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping"; public static final String EdgeDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping/Inverse"; public static final String EdgeMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeMappingParameterType"; - public static final String EdgeNodeStyle = "http://www.simantics.org/DistrictNetwork-1.0/EdgeNodeStyle"; + public static final String EdgeStyle = "http://www.simantics.org/DistrictNetwork-1.0/EdgeStyle"; + public static final String EdgeThicknessPropertyParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeThicknessPropertyParameterType"; public static final String Edge_HasDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter"; public static final String Edge_HasDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter/Inverse"; public static final String Edge_HasFlowArea = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasFlowArea"; @@ -247,16 +263,26 @@ public class DistrictNetworkResource { public static final String Edge_HasOuterDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter/Inverse"; public static final String Edge_HasTGround = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasTGround"; public static final String Edge_HasTGround_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasTGround/Inverse"; + public static final String Edge_ThicknessProperty = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty"; + public static final String Edge_ThicknessProperty_Diameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/Diameter"; + public static final String Edge_ThicknessProperty_NominalMassFlow = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/NominalMassFlow"; + public static final String Edge_ThicknessProperty_scale = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/scale"; + public static final String Edge_ThicknessProperty_scale_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/scale/Inverse"; + public static final String Edge_ThicknessProperty_value = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/value"; + public static final String Edge_ThicknessProperty_value_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/value/Inverse"; public static final String Element = "http://www.simantics.org/DistrictNetwork-1.0/Element"; public static final String Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions"; public static final String Functions_compositeInstantiator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/compositeInstantiator"; public static final String Functions_convertToValue = "http://www.simantics.org/DistrictNetwork-1.0/Functions/convertToValue"; public static final String Functions_defaultEdgeMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultEdgeMappingModifier"; public static final String Functions_defaultVertexMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultVertexMappingModifier"; + public static final String Functions_edgeThicknessPropertyEnumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/edgeThicknessPropertyEnumerationValues"; + public static final String Functions_edgeThicknessPropertyModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/edgeThicknessPropertyModifier"; public static final String Functions_enumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/enumerationValues"; public static final String Functions_mappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/mappingModifier"; public static final String Groups = "http://www.simantics.org/DistrictNetwork-1.0/Groups"; - public static final String Groups_ElementGroup = "http://www.simantics.org/DistrictNetwork-1.0/Groups/ElementGroup"; + public static final String Groups_EdgeGroup = "http://www.simantics.org/DistrictNetwork-1.0/Groups/EdgeGroup"; + public static final String Groups_VertexGroup = "http://www.simantics.org/DistrictNetwork-1.0/Groups/VertexGroup"; public static final String HasEndVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex"; public static final String HasEndVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex_Inverse"; public static final String HasId = "http://www.simantics.org/DistrictNetwork-1.0/HasId"; @@ -364,6 +390,8 @@ public class DistrictNetworkResource { public static final String VertexDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping"; public static final String VertexDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping/Inverse"; public static final String VertexMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexMappingParameterType"; + public static final String VertexStyle = "http://www.simantics.org/DistrictNetwork-1.0/VertexStyle"; + public static final String Vertex_ColorProperty = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ColorProperty"; public static final String Vertex_HasAddress = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress"; public static final String Vertex_HasAddress_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress/Inverse"; public static final String Vertex_HasDeltaPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaPressure"; @@ -404,6 +432,12 @@ public class DistrictNetworkResource { public static final String Vertex_HasVelocity_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVelocity/Inverse"; public static final String Vertex_HasVolFlow = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVolFlow"; public static final String Vertex_HasVolFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVolFlow/Inverse"; + public static final String Vertex_ScaleProperty = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty"; + public static final String Vertex_ScaleProperty_SupplyPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/SupplyPressure"; + public static final String Vertex_ScaleProperty_scale = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/scale"; + public static final String Vertex_ScaleProperty_scale_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/scale/Inverse"; + public static final String Vertex_ScaleProperty_value = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/value"; + public static final String Vertex_ScaleProperty_value_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/value/Inverse"; } public static Resource getResourceOrNull(ReadGraph graph, String uri) { @@ -422,23 +456,22 @@ public class DistrictNetworkResource { Actions_NewDNDiagram = getResourceOrNull(graph, URIs.Actions_NewDNDiagram); AddLayerToDNDiagramTemplate = getResourceOrNull(graph, URIs.AddLayerToDNDiagramTemplate); BrowseContext = getResourceOrNull(graph, URIs.BrowseContext); - ComponentIdStyle = getResourceOrNull(graph, URIs.ComponentIdStyle); - ComponentNameStyle = getResourceOrNull(graph, URIs.ComponentNameStyle); Composite = getResourceOrNull(graph, URIs.Composite); Connection = getResourceOrNull(graph, URIs.Connection); Diagram = getResourceOrNull(graph, URIs.Diagram); Diagram_MappedDiagram = getResourceOrNull(graph, URIs.Diagram_MappedDiagram); Diagram_MappedFromDiagram = getResourceOrNull(graph, URIs.Diagram_MappedFromDiagram); - DistrictProfile = getResourceOrNull(graph, URIs.DistrictProfile); - DistrictProfile_entry = getResourceOrNull(graph, URIs.DistrictProfile_entry); - DistrictProfile_entry1 = getResourceOrNull(graph, URIs.DistrictProfile_entry1); - DistrictProfile_entry2 = getResourceOrNull(graph, URIs.DistrictProfile_entry2); + Diagram_edgeThicknessProperty = getResourceOrNull(graph, URIs.Diagram_edgeThicknessProperty); + Diagram_edgeThicknessProperty_Inverse = getResourceOrNull(graph, URIs.Diagram_edgeThicknessProperty_Inverse); + Diagram_edgeThicknessScale = getResourceOrNull(graph, URIs.Diagram_edgeThicknessScale); + Diagram_edgeThicknessScale_Inverse = getResourceOrNull(graph, URIs.Diagram_edgeThicknessScale_Inverse); EPSG_4326 = getResourceOrNull(graph, URIs.EPSG_4326); Edge = getResourceOrNull(graph, URIs.Edge); EdgeDefaultMapping = getResourceOrNull(graph, URIs.EdgeDefaultMapping); EdgeDefaultMapping_Inverse = getResourceOrNull(graph, URIs.EdgeDefaultMapping_Inverse); EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType); - EdgeNodeStyle = getResourceOrNull(graph, URIs.EdgeNodeStyle); + EdgeStyle = getResourceOrNull(graph, URIs.EdgeStyle); + EdgeThicknessPropertyParameterType = getResourceOrNull(graph, URIs.EdgeThicknessPropertyParameterType); Edge_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter); Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse); Edge_HasFlowArea = getResourceOrNull(graph, URIs.Edge_HasFlowArea); @@ -455,16 +488,26 @@ public class DistrictNetworkResource { Edge_HasOuterDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter_Inverse); Edge_HasTGround = getResourceOrNull(graph, URIs.Edge_HasTGround); Edge_HasTGround_Inverse = getResourceOrNull(graph, URIs.Edge_HasTGround_Inverse); + Edge_ThicknessProperty = getResourceOrNull(graph, URIs.Edge_ThicknessProperty); + Edge_ThicknessProperty_Diameter = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_Diameter); + Edge_ThicknessProperty_NominalMassFlow = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_NominalMassFlow); + Edge_ThicknessProperty_scale = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_scale); + Edge_ThicknessProperty_scale_Inverse = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_scale_Inverse); + Edge_ThicknessProperty_value = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_value); + Edge_ThicknessProperty_value_Inverse = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_value_Inverse); Element = getResourceOrNull(graph, URIs.Element); Functions = getResourceOrNull(graph, URIs.Functions); Functions_compositeInstantiator = getResourceOrNull(graph, URIs.Functions_compositeInstantiator); Functions_convertToValue = getResourceOrNull(graph, URIs.Functions_convertToValue); Functions_defaultEdgeMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultEdgeMappingModifier); Functions_defaultVertexMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultVertexMappingModifier); + Functions_edgeThicknessPropertyEnumerationValues = getResourceOrNull(graph, URIs.Functions_edgeThicknessPropertyEnumerationValues); + Functions_edgeThicknessPropertyModifier = getResourceOrNull(graph, URIs.Functions_edgeThicknessPropertyModifier); Functions_enumerationValues = getResourceOrNull(graph, URIs.Functions_enumerationValues); Functions_mappingModifier = getResourceOrNull(graph, URIs.Functions_mappingModifier); Groups = getResourceOrNull(graph, URIs.Groups); - Groups_ElementGroup = getResourceOrNull(graph, URIs.Groups_ElementGroup); + Groups_EdgeGroup = getResourceOrNull(graph, URIs.Groups_EdgeGroup); + Groups_VertexGroup = getResourceOrNull(graph, URIs.Groups_VertexGroup); HasEndVertex = getResourceOrNull(graph, URIs.HasEndVertex); HasEndVertex_Inverse = getResourceOrNull(graph, URIs.HasEndVertex_Inverse); HasId = getResourceOrNull(graph, URIs.HasId); @@ -572,6 +615,8 @@ public class DistrictNetworkResource { VertexDefaultMapping = getResourceOrNull(graph, URIs.VertexDefaultMapping); VertexDefaultMapping_Inverse = getResourceOrNull(graph, URIs.VertexDefaultMapping_Inverse); VertexMappingParameterType = getResourceOrNull(graph, URIs.VertexMappingParameterType); + VertexStyle = getResourceOrNull(graph, URIs.VertexStyle); + Vertex_ColorProperty = getResourceOrNull(graph, URIs.Vertex_ColorProperty); Vertex_HasAddress = getResourceOrNull(graph, URIs.Vertex_HasAddress); Vertex_HasAddress_Inverse = getResourceOrNull(graph, URIs.Vertex_HasAddress_Inverse); Vertex_HasDeltaPressure = getResourceOrNull(graph, URIs.Vertex_HasDeltaPressure); @@ -612,6 +657,12 @@ public class DistrictNetworkResource { Vertex_HasVelocity_Inverse = getResourceOrNull(graph, URIs.Vertex_HasVelocity_Inverse); Vertex_HasVolFlow = getResourceOrNull(graph, URIs.Vertex_HasVolFlow); Vertex_HasVolFlow_Inverse = getResourceOrNull(graph, URIs.Vertex_HasVolFlow_Inverse); + Vertex_ScaleProperty = getResourceOrNull(graph, URIs.Vertex_ScaleProperty); + Vertex_ScaleProperty_SupplyPressure = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_SupplyPressure); + Vertex_ScaleProperty_scale = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_scale); + Vertex_ScaleProperty_scale_Inverse = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_scale_Inverse); + Vertex_ScaleProperty_value = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_value); + Vertex_ScaleProperty_value_Inverse = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_value_Inverse); } public static DistrictNetworkResource getInstance(ReadGraph graph) { diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java index d80082ec..9748f87c 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java @@ -467,4 +467,17 @@ public class Functions { } return results; } + + @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") + public static Object edgeThicknessPropertyEnumerationValues(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { + return Collections.emptyList(); + } + + @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") + public static Object edgeThicknessPropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { + Resource diagram = resolveElement(graph, context); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + return baseMappingModifier(graph, diagram, DN.Diagram_edgeThicknessProperty, DN.Edge_ThicknessProperty, context); + } + } diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java index a088ca90..92299324 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java @@ -7,7 +7,6 @@ import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Path2D; -import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import org.simantics.district.network.ModelledCRS; @@ -135,7 +134,7 @@ public class DistrictNetworkEdgeNode extends G2DNode { @PropertySetter(value = "stroke") public void setStroke(Double stroke) { - this.stroke = stroke / 100; + this.stroke = stroke; } } diff --git a/org.simantics.district.network/adapters.xml b/org.simantics.district.network/adapters.xml index 03953cf7..a6463cd7 100644 --- a/org.simantics.district.network/adapters.xml +++ b/org.simantics.district.network/adapters.xml @@ -8,15 +8,12 @@ - - + + + \ No newline at end of file diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java new file mode 100644 index 00000000..8136b19c --- /dev/null +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java @@ -0,0 +1,59 @@ +package org.simantics.district.network.profile; + +import java.util.Optional; + +import org.simantics.db.Resource; + +/** + * @author Tuukka Lehtonen + */ +public class DiagramSettings { + + public final Optional vertexScalingProperty; + public final double vertexScalingScale; + public final Optional edgeThicknessProperty; + public final double edgeThicknessScale; + + public DiagramSettings(Resource vertexScalingProperty, double vertexScalingScale, Resource edgeThicknessProperty, double edgeThicknessScale) { + this.vertexScalingProperty = Optional.ofNullable(vertexScalingProperty); + this.vertexScalingScale = vertexScalingScale; + this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty); + this.edgeThicknessScale = edgeThicknessScale; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + edgeThicknessProperty.hashCode(); + long temp; + temp = Double.doubleToLongBits(edgeThicknessScale); + result = prime * result + (int) (temp ^ (temp >>> 32)); +// result = prime * result + vertexScalingProperty.hashCode(); + temp = Double.doubleToLongBits(vertexScalingScale); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DiagramSettings other = (DiagramSettings) obj; + if (!edgeThicknessProperty.equals(other.edgeThicknessProperty)) + return false; + if (Double.doubleToLongBits(edgeThicknessScale) != Double.doubleToLongBits(other.edgeThicknessScale)) + return false; + if (!vertexScalingProperty.equals(other.vertexScalingProperty)) + return false; + if (Double.doubleToLongBits(vertexScalingScale) != Double.doubleToLongBits(other.vertexScalingScale)) + return false; + return true; + } + + +} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java new file mode 100644 index 00000000..726005ee --- /dev/null +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java @@ -0,0 +1,54 @@ +package org.simantics.district.network.profile; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.district.network.ontology.DistrictNetworkResource; + +/** + * @author Tuukka Lehtonen + */ +public class DiagramSettingsRequest extends ResourceRead { + + protected DiagramSettingsRequest(Resource runtimeDiagram) { + super(runtimeDiagram); + } + + @Override + public DiagramSettings perform(ReadGraph graph) throws DatabaseException { + DiagramResource DIA = DiagramResource.getInstance(graph); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + + Resource edgeThicknessProperty = null; + Resource nodeScalingProperty = null; + double edgeThicknessScale = 1; + double nodeScalingScale = 1; + + Resource diagram = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasConfiguration); + if (diagram != null) { + Resource etp = graph.getPossibleObject(diagram, DN.Diagram_edgeThicknessProperty); + edgeThicknessProperty = graph.getPossibleObject(etp, DN.Edge_ThicknessProperty_value); +// Resource nsp = graph.getPossibleObject(diagram, DN.Diagram_nodeScalingProperty); +// nodeScalingProperty = graph.getPossibleObject(nsp, DN.Vertex_ScaleProperty_value); + + edgeThicknessScale = + safeDoubleProperty(graph, etp, DN.Edge_ThicknessProperty_scale, 1) + * safeDoubleProperty(graph, diagram, DN.Diagram_edgeThicknessScale, 1); + +// nodeScalingScale = +// safeDoubleProperty(graph, nsp, DN.Vertex_ScaleProperty_scale, 1) +// * safeDoubleProperty(graph, diagram, DN.Diagram_nodeScale, 1); + } + + return new DiagramSettings(nodeScalingProperty, nodeScalingScale, edgeThicknessProperty, edgeThicknessScale); + } + + private static double safeDoubleProperty(ReadGraph graph, Resource r, Resource property, double defaultValue) throws DatabaseException { + Double d = graph.getPossibleRelatedValue(r, property, Bindings.DOUBLE); + return d != null ? d : defaultValue; + } + +} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeGroup.java b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeGroup.java deleted file mode 100644 index c66fc973..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeGroup.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.district.network.profile; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.profile.DiagramElementGroup; -import org.simantics.district.network.ontology.DistrictNetworkResource; - -public class EdgeNodeGroup extends DiagramElementGroup { - - public EdgeNodeGroup(ReadGraph graph) { - super(graph); - System.out.println("EdgeNodeGroup init"); - } - - @Override - protected boolean test(ReadGraph graph, Resource element) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - if (graph.isInstanceOf(element, DN.Edge)) { - return true; - } - return false; - } - - @Override - public String toString() { - return "Edge Nodes"; - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java new file mode 100644 index 00000000..4ee26ad4 --- /dev/null +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java @@ -0,0 +1,59 @@ +package org.simantics.district.network.profile; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.profile.StyleBase; +import org.simantics.scenegraph.INode; +import org.simantics.scenegraph.g2d.G2DSceneGraph; +import org.simantics.scenegraph.g2d.nodes.ConnectionNode; +import org.simantics.scenegraph.profile.EvaluationContext; +import org.simantics.scenegraph.profile.common.ProfileVariables; + +public class EdgeStyle extends StyleBase { + + private static final Double PENDING = Double.NaN; + private static final Double ONE = 1.0; + + @Override + public Double calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { + DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); + Double thickness = ONE; + if (ds.edgeThicknessProperty.isPresent()) { + thickness = graph.getPossibleRelatedValue2(groupItem, ds.edgeThicknessProperty.get(), Bindings.DOUBLE); + //System.out.println("read thickness: " + thickness + " : " + ds.edgeThicknessProperty); + if (thickness == null) { + thickness = ONE; + } else { + thickness = thickness * ds.edgeThicknessScale; + } + } + return thickness; + } + + @Override + public void applyStyleForNode(EvaluationContext observer, INode node, Double value) { + //System.out.println("apply: " + node + " : " + value); + ConnectionNode n = (ConnectionNode) node; + if (value == PENDING) { + ((G2DSceneGraph)node.getRootNode()).setPending(node); + } else { + ((G2DSceneGraph)node.getRootNode()).clearPending(node); + } + if (value == null) + value = ONE; + for (INode nn : n.getNodes()) + ProfileVariables.claimNodeProperty(nn, "stroke", value, observer); + } + + @Override + protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) { + ((G2DSceneGraph)node.getRootNode()).clearPending(node); + ConnectionNode n = (ConnectionNode) node; + for (INode nn : n.getNodes()) + ProfileVariables.claimNodeProperty(nn, "stroke", ONE, evaluationContext); + } + +} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/VertexStyle.java similarity index 52% rename from org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeStyle.java rename to org.simantics.district.network/src/org/simantics/district/network/profile/VertexStyle.java index 9d96f48c..6fc5dfcc 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeNodeStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/VertexStyle.java @@ -10,30 +10,21 @@ import org.simantics.scenegraph.g2d.nodes.ConnectionNode; import org.simantics.scenegraph.profile.EvaluationContext; import org.simantics.scenegraph.profile.common.ProfileVariables; -public class EdgeNodeStyle extends StyleBase { +public class VertexStyle extends StyleBase { - public EdgeNodeStyle() { - System.out.println("EdgeNodeStyle init"); - } - @Override public Double calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Double diameter = graph.getPossibleRelatedValue(groupItem, DN.Edge_HasDiameter); - if (diameter != null) { - return diameter; - } - return super.calculateStyle(graph, runtimeDiagram, entry, groupItem); + return 1.0; } - + @Override public void applyStyleForNode(EvaluationContext observer, INode node, Double result) { - if (result != null) { - ConnectionNode n = (ConnectionNode) node; - for (INode nn : n.getNodes()) { - ProfileVariables.claimNodeProperty(nn, "stroke", result, observer); - } - } +// if (result != null) { +// ConnectionNode n = (ConnectionNode) node; +// for (INode nn : n.getNodes()) { +// ProfileVariables.claimNodeProperty(nn, "stroke", result, observer); +// } +// } } } -- 2.45.1