X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FDiagram.scl;fp=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FDiagram.scl;h=8276962eac7d4aefab138355327ee3d364cd3ffe;hp=0ee3e9d28ec03afeec9aff59d69097643472df72;hb=2318f67fbf458ee97fd438678be1bc5a636c9fa7;hpb=bb8e054f744ea6a627ac9f2e3cc49c08719bed90 diff --git a/bundles/org.simantics.modeling/scl/Simantics/Diagram.scl b/bundles/org.simantics.modeling/scl/Simantics/Diagram.scl index 0ee3e9d28..8276962ea 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/Diagram.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/Diagram.scl @@ -188,8 +188,6 @@ pathNameOf diagram = do diagramResourceOf :: Diagram -> Resource diagramResourceOf d = singleObject d MOD.CompositeToDiagram -import "Extras/HashMap" as Map - """Constructs a transformation for a diagram element.""" mapDiagramElement :: (a -> b) -> (a -> b) -> (a -> Maybe b) -> (a -> b) -> DiagramElement a -> DiagramElement b mapDiagramElement mapComponentType mapTerminal mapAttribute mapFlagType diagramElement = @@ -234,9 +232,9 @@ createDiagramR (ExistingDiagram diagram') joinMap elementSpecs = runProc do configuration = diagram' diagram = compositeToDiagram' configuration hasName = L0.HasName - componentMap = Map.fromList [ (c `relatedValue` hasName :: String, c) - | c <- children configuration - ] + componentMap = MMap.fromEntryList [ (c `relatedValue` hasName :: String, c) + | c <- children configuration + ] denyByPredicate diagram L0.ConsistsOf elements = setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpecs claimRelatedValue diagram DIA.HasModCount @@ -246,7 +244,7 @@ createDiagramR (ExistingDiagram diagram') joinMap elementSpecs = runProc do createDiagramR (NewDiagram model path folderType compositeType) joinMap elementSpecs = (runProc do configuration = createConfiguration () diagram = compositeToDiagram' configuration - elements = setElements (DiagramInfo diagram configuration (Map.create ())) joinMap elementSpecs + elements = setElements (DiagramInfo diagram configuration (MMap.create ())) joinMap elementSpecs claimRelatedValue diagram DIA.HasModCount (fromInteger (length elements) :: Long) (configuration, elements) @@ -304,19 +302,19 @@ importJava "org.simantics.modeling.utils.JoinMap" where /* createJoin :: (Dynamic -> Resource) -> Dynamic -> Resource -createJoin joinMap key = if Map.contains joinMap key - then Map.unsafeGet joinMap key +createJoin joinMap key = if MMap.containsKey joinMap key + then MMap.unsafeGet joinMap key else do j = newEntity [ hasType STR.ConnectionJoin ] - Map.put joinMap key j + MMap.put joinMap key j j */ data DiagramInfo = DiagramInfo Resource // diagram Resource // configuration - (Map.T String Resource) // existing components + (MMap.T String Resource) // existing components """ Sets the elements of the diagram. Diagram is assumed to be empty, @@ -336,7 +334,7 @@ setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpec for (zip elementSpecs elements) setConnectionName elements ) where - elementMap = Map.create () + elementMap = MMap.create () idRef = ref (0 :: Integer) isConnectionResource r = isInstanceOf r DIA.Connection @@ -349,8 +347,8 @@ setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpec idRef := id + 1 show id createElement (Component componentType name position properties) = do - component = if Map.contains componentMap name - then Map.unsafeGet componentMap name + component = if MMap.containsKey componentMap name + then MMap.unsafeGet componentMap name else newEntity [ hasName name, hasParent configuration, @@ -371,13 +369,13 @@ setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpec MOD.ElementToComponent component ] - Map.put elementMap name element + MMap.put elementMap name element Just element newOrMappedElement eName = do - element = match Map.get elementMap eName with + element = match MMap.get elementMap eName with Just element -> element Nothing -> newEntity [] - Map.put elementMap eName element + MMap.put elementMap eName element element createElement (SimpleConnection aName ar bName br _) = do connection = newEntity [ @@ -421,7 +419,7 @@ setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpec then do claim flag DIA.ExternalFlag flag else () - Map.put elementMap name flag + MMap.put elementMap name flag Just flag createElement (Connection nodeSpecs edges _) = do connection = newEntity [ @@ -505,7 +503,7 @@ setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpec hasFont font ] createElement (Monitor label (Just (MonitorReference componentName suffix)) (MonitorVisuals font strokeWidth hAlign vAlign) position) = do - match (Map.get elementMap componentName) with + match (MMap.get elementMap componentName) with Nothing -> Nothing // Monitored component is not on the same diagram as the monitor. Not supported by this routine. Just element -> do component = singleObject element MOD.ElementToComponent @@ -705,11 +703,11 @@ elementsOfR diagram = filterJust $ map readElement' nodeResources = connectors + routeLines nodeResourceWithIds = zip nodeResources [0..length nodeResources-1] edges = runProc do - rMap = Map.fromList nodeResourceWithIds + rMap = MMap.fromEntryList nodeResourceWithIds edgesOf (node,i) = [ Edge i j | r <- node # DIA.AreConnected - , j = Map.unsafeGet rMap r + , j = MMap.unsafeGet rMap r , j > i ] concatMap edgesOf nodeResourceWithIds