]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/scl/Simantics/Chart.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.charts / scl / Simantics / Chart.scl
1 import "Simantics/DB"\r
2 import "Simantics/Variables"\r
3 import "Simantics/Model"\r
4 import "Simantics/Entity"\r
5 import "Simantics/Subscription"\r
6 \r
7 import "http://www.simantics.org/Charts-1.2" as CHART\r
8 \r
9 type Chart = Resource\r
10 type ChartGroup = Resource\r
11 type ChartItem = Resource\r
12 \r
13 importJava "org.simantics.charts.ui.SCLChart" where\r
14     @JavaName createNewChart\r
15     """\r
16     Creates a new Chart to the default Charts folder under the given Model parameter. Returns the created Chart.\r
17     """\r
18     createChart :: Model -> <Proc> Chart\r
19 \r
20     @JavaName createNewChart\r
21     """\r
22     Creates a new Chart under the given ChartGroup parameter. Returns the created Chart.\r
23     """\r
24     createChartInGroup :: ChartGroup -> <Proc> Chart\r
25 \r
26     @JavaName createNewChartGroup\r
27     """\r
28     Creates a new ChartGroup under the given Model parameter. Returns the created ChartGroup.\r
29     """\r
30     createChartGroup :: Model -> <Proc> ChartGroup\r
31 \r
32     @JavaName addChartItems\r
33     """\r
34     Creates new chartItem with the given Variable to the given Chart and returns the created ChartItem. New Subscription item is created at the same time.\r
35     """\r
36     addChartItems :: Chart -> Variable -> <WriteGraph> ChartItem \r
37 \r
38     @JavaName linkSubToChart\r
39     """\r
40     Links the given Subscription to the given chart and returns the created ChartItem.\r
41     """\r
42     linkSubToChart :: Subscription -> Chart -> <WriteGraph> ChartItem\r
43 \r
44 """\r
45 Browses the given Model for its Charts and then returns them in a list.\r
46 """\r
47 chartsOf :: Model -> <ReadGraph> [Chart]\r
48 chartsOf model = recurse (toResource model)\r
49   where\r
50     recurse r = do\r
51         cs = resourceChildrenOf r \r
52         charts = map fromResource $ filter isChart cs\r
53         chartGrp = filter isChartGroup cs\r
54         charts + concatMap recurse chartGrp\r
55     isChart r = isInstanceOf r CHART.TimeSeriesChart\r
56     isChartGroup r = isInstanceOf r CHART.ChartGroup\r