X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.charts%2Fscl%2FSimantics%2FChart.scl;fp=bundles%2Forg.simantics.charts%2Fscl%2FSimantics%2FChart.scl;h=9f1c02c9861ef4c2b4900b89015cd409f359853a;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.charts/scl/Simantics/Chart.scl b/bundles/org.simantics.charts/scl/Simantics/Chart.scl new file mode 100644 index 000000000..9f1c02c98 --- /dev/null +++ b/bundles/org.simantics.charts/scl/Simantics/Chart.scl @@ -0,0 +1,56 @@ +import "Simantics/DB" +import "Simantics/Variables" +import "Simantics/Model" +import "Simantics/Entity" +import "Simantics/Subscription" + +import "http://www.simantics.org/Charts-1.2" as CHART + +type Chart = Resource +type ChartGroup = Resource +type ChartItem = Resource + +importJava "org.simantics.charts.ui.SCLChart" where + @JavaName createNewChart + """ + Creates a new Chart to the default Charts folder under the given Model parameter. Returns the created Chart. + """ + createChart :: Model -> Chart + + @JavaName createNewChart + """ + Creates a new Chart under the given ChartGroup parameter. Returns the created Chart. + """ + createChartInGroup :: ChartGroup -> Chart + + @JavaName createNewChartGroup + """ + Creates a new ChartGroup under the given Model parameter. Returns the created ChartGroup. + """ + createChartGroup :: Model -> ChartGroup + + @JavaName addChartItems + """ + 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. + """ + addChartItems :: Chart -> Variable -> ChartItem + + @JavaName linkSubToChart + """ + Links the given Subscription to the given chart and returns the created ChartItem. + """ + linkSubToChart :: Subscription -> Chart -> ChartItem + +""" +Browses the given Model for its Charts and then returns them in a list. +""" +chartsOf :: Model -> [Chart] +chartsOf model = recurse (toResource model) + where + recurse r = do + cs = resourceChildrenOf r + charts = map fromResource $ filter isChart cs + chartGrp = filter isChartGroup cs + charts + concatMap recurse chartGrp + isChart r = isInstanceOf r CHART.TimeSeriesChart + isChartGroup r = isInstanceOf r CHART.ChartGroup