]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/scl/Simantics/Diagram.scl
Added Simantics/Diagram#diagramsUnder to complement diagramsOf
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Diagram.scl
index 6e04a6f6d6f4c6e21cbc9e94d3fae840786838ae..0ee3e9d28ec03afeec9aff59d69097643472df72 100644 (file)
@@ -57,6 +57,17 @@ flipY (Position xx xy yx yy x y) = Position xx (-xy) yx (-yy) x y
 
 positionToDoubleArray (Position a b c d e f) = toDoubleArray [a,b,c,d,e,f]
 
+positionToVector :: Position -> Vector Double
+positionToVector (Position a b c d e f) = runProc
+    (do r = createMVector 6
+        setMVector r 0 a
+        setMVector r 1 b
+        setMVector r 2 c
+        setMVector r 3 d
+        setMVector r 4 e
+        setMVector r 5 f
+        freezeMVector r)
+
 // --- Diagram element data types -----------------------------------
 
 data Property res = Property res Dynamic
@@ -138,9 +149,15 @@ hasRandomIdentifier entity = runProc (claimRelatedValue_ entity L0.identifier GU
 
 """Returns all diagrams of the given model."""
 diagramsOf :: Model -> <ReadGraph> [Diagram]
-diagramsOf model = recurse
-                   DIA.Diagram 
-                   (configurationOf model)
+diagramsOf model = diagramsUnder $ configurationOf model
+
+"""
+Returns all diagrams under the specified diagram folder.
+The parameter can also be the configuration root `configurationOf`
+in which case this function returns the same as `diagramsOf model`.
+"""
+diagramsUnder :: DiagramFolder -> <ReadGraph> [Resource]
+diagramsUnder folder = recurse DIA.Diagram folder 
   where
     recurse t r = do
         cs = children r 
@@ -794,8 +811,10 @@ setTransform element transform = claimRelatedValueWithType element DIA.HasTransf
     
 importJava "org.simantics.modeling.svg.CreateSVGElement" where
     createSVGElement :: Resource -> String -> ByteArray -> Double -> Double -> <WriteGraph> ()
+    createSVGElementR :: Resource -> String -> ByteArray -> Double -> Double -> <WriteGraph> Resource
     
     importSVGElement :: Resource -> File -> Double -> Double -> <WriteGraph> ()
+    importSVGElementR :: Resource -> File -> Double -> Double -> <WriteGraph> Resource
     
 importJava "org.simantics.diagram.synchronization.graph.RemoveElement" where
     removeElement :: Resource -> Resource -> <WriteGraph> ()