]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/scl/Simantics/District.scl
First prototype of HSV color space based dynamic DN element coloring
[simantics/district.git] / org.simantics.district.network / scl / Simantics / District.scl
index 6318d7550b5a7bfcf7a15c0a245bdce85c83aef9..b99442e6b0177c9e5e3c032c0ff42eadb029a1cf 100644 (file)
@@ -1,5 +1,7 @@
 import "Simantics/DB"
 import "Simantics/Ontologies"
+import "Simantics/Variables"
+import "http://www.simantics.org/DistrictNetwork-1.0" as DN
 
 import "Map" as Map
 import "MSet" as MSet
@@ -83,3 +85,36 @@ importJava "org.simantics.district.network.DistrictNetworkUtil" where
     createVertex :: Resource -> Vector Double -> Resource -> <WriteGraph, Proc> Resource
     createEdge :: Resource -> Resource -> <WriteGraph, Proc> Resource
 
+"""
+Tries to look for the Variable representing the configuration component
+mapped to the specified district network diagram element.
+
+The variable returned is by default the active experiment context variable
+but if that is not available then a configuration context variable is returned.
+"""
+possibleMappedComponentVariable :: Resource -> <ReadGraph> Maybe Variable
+possibleMappedComponentVariable r = match possibleObject r DN.MappedComponent with
+    Nothing -> Nothing
+    Just me -> match possibleObject me MOD.ElementToComponent with
+        Nothing -> Nothing
+        Just mc -> do
+            mcv = resourceVariable mc
+            match possibleActiveVariable mcv with
+                Nothing -> Just mcv
+                a       -> a
+
+"""
+"""
+possibleMappedComponentPropertyValue :: String -> Resource -> <ReadGraph> Maybe Double
+possibleMappedComponentPropertyValue propName r = match possibleMappedComponentVariable r with
+    Nothing -> Nothing
+    Just mv -> possiblePropertyValue mv propName
+
+"""
+"""
+mappedComponentPropertyValue :: Double -> String -> Resource -> <ReadGraph> Double
+mappedComponentPropertyValue def propName r = match possibleMappedComponentVariable r with
+    Nothing -> def
+    Just mv -> match possiblePropertyValue mv propName with
+        Nothing -> def
+        Just v  -> v