Skip to content

Commit

Permalink
[Primitives] Delete obsolete stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jul 18, 2024
1 parent 52f3bd8 commit 4321886
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 242 deletions.
20 changes: 1 addition & 19 deletions src/Aardvark.UI.Primitives/Primitives/UI.Primitives.Models.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,5 @@ type Tree =
module Tree =
let node v p c = Node(v, p, c)


[<ModelType>]
type TreeModel = { data: Tree }

// TODO: Delete
[<ModelType>]
type D3TestInput =
{
t1 : int
t2 : int
}

// TODO: Delete
[<ModelType>]
type D3AxisInput =
{
min : float
max : float
tickCount : float
}
type TreeModel = { data: Tree }
223 changes: 0 additions & 223 deletions src/Aardvark.UI.Primitives/Primitives/UI.Primitives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ module Html =

let horizontal ch = table [clazz "ui table"; style "backgroundColor: transparent"] [ tbody [] [ tr [] ch ] ]

[<Obsolete("Equivalent to 'td [] []'. Why does this exist and why are you using it?")>]
let finish<'msg> = td [] []

type ColorConverter =
static member inline ToHtml(c : C3b) = $"rgb({c.R},{c.G},{c.B})"
static member inline ToHtml(c : C3b, a : float) = if a < 1.0 then $"rgba({c.R},{c.G},{c.B},{string a})" else ColorConverter.ToHtml c
Expand Down Expand Up @@ -70,15 +67,6 @@ module Html =

let row k v = tr [] [ td [clazz "collapsing"] [text k]; td [clazz "right aligned"] v ]

[<Obsolete("Why does this exist and why are you using it?")>]
type A = { a : aval<int> }

[<Obsolete("Why does this exist and why are you using it?")>]
let a = AVal.init { a = AVal.init 10 }

[<Obsolete("Why does this exist and why are you using it?")>]
let test : aval<aval<int>> = AVal.constant (AVal.constant 0)

/// Sets the (top.)document.title property adaptively.
let title (top : bool) (title : aval<string>) (node : DomNode<'msg>) =
let doc = if top then "top.document" else "document";
Expand Down Expand Up @@ -416,217 +404,6 @@ module Numeric =
app () |> App.start


open MBrace.FsPickler.Json

[<Obsolete("Why does this exist and why are you using it?")>]
module D3Test =
type Action =
| SetData of D3TestInput
| IncrementMaxValue
| DecrementMaxValue

let update (model : D3TestInput) (action : Action) =
match action with
| SetData c -> c
| IncrementMaxValue -> { model with t1 = model.t1+10 }
| DecrementMaxValue -> { model with t1 = model.t1-10 }

let init = { t1 = 1; t2 = 50;}

type testData =
{
month : string
apples : int
bananas : int
cherries : int
dates : int
}

let pickler = FsPickler.CreateJsonSerializer(omitHeader = true)

let data loop =
printfn "bla:%d" loop
[|
for a in 1..loop do
yield {month = "Q1-2016"+(string a); apples = 2*a; bananas = a+5; cherries = -2*a; dates = -a}
|] |> pickler.PickleToString
|> (fun s -> printfn "%A" s; s)

let code (min : float) (max : float) =
"""
var svg = d3.select("#ID"),
width = +svg.attr("width"),
height = +svg.attr("height");
var data = [
{month: "Q1-2016", apples: 3840, bananas: 1920, cherries: -1960, dates: -400},
{month: "Q2-2016", apples: 1600, bananas: 1440, cherries: -960, dates: -400},
{month: "Q3-2016", apples: 640, bananas: 960, cherries: -640, dates: -600},
{month: "Q4-2016", apples: 320, bananas: 480, cherries: -640, dates: -400}
];
var series = d3.stack()
.keys(["apples", "bananas", "cherries", "dates"])
.offset(d3.stackOffsetDiverging)
(data);
var svg = d3.select("svg"),
margin = {top: 20, right: 30, bottom: 30, left: 60},
width = +svg.attr("width"),
height = +svg.attr("height");
var x = d3.scaleBand()
.domain(data.map(function(d) { return d.month; }))
.rangeRound([margin.left, width - margin.right])
.padding(0.1);
var y = d3.scaleLinear()
.domain([d3.min(series, stackMin), d3.max(series, stackMax)])
.rangeRound([height - margin.bottom, margin.top]);
var z = d3.scaleOrdinal(d3.schemeCategory10);
svg.append("g")
.selectAll("g")
.data(series)
.enter().append("g")
.attr("fill", function(d) { return z(d.key); })
.selectAll("rect")
.data(function(d) { return d; })
.enter().append("rect")
.attr("width", x.bandwidth)
.attr("x", function(d) { return x(d.data.month); })
.attr("y", function(d) { return y(d[1]); })
.attr("height", function(d) { return y(d[0]) - y(d[1]); })
svg.append("g")
.attr("transform", "translate(0," + y(0) + ")")
.call(d3.axisBottom(x));
svg.append("g")
.attr("transform", "translate(" + margin.left + ",0)")
.call(d3.axisLeft(y));
function stackMin(serie) {
return d3.min(serie, function(d) { return d[0]; });
}
function stackMax(serie) {
return d3.max(serie, function(d) { return d[1]; });
}
"""

let d3Code (model:AdaptiveD3TestInput) =
require [
{ kind = Script; name = "d3"; url = "https://cdnjs.cloudflare.com/ajax/libs/d3/4.11.0/d3.min.js" }
{ kind = Script; name = "d3Test"; url = "d3Test.js" }]
(
Incremental.div AttributeMap.empty (
alist {
let! max = model.t1
let! min = model.t2
yield
//onBoot (code (float min) (float max))(
onBoot (sprintf "D3TestFunktion(%s,%s);" (data max) "'#__ID__'")(
Svg.svg [ attribute "width" "800"; attribute "height" "200"; style "position: absolute; top: 0; left: 0; z-index: 1000;"] []
)
}
)
)

let view (model:AdaptiveD3TestInput) =
require (Html.semui) (
body [clazz "ui"; style "background: #FFFFFF"] [
d3Code model

div [style "width:10%; height: 100%; float:right;"] [
button [clazz "ui icon button"; onMouseClick (fun _ -> IncrementMaxValue)] [ i [clazz "arrow left icon"] [] ]
button [clazz "ui icon button"; onMouseClick (fun _ -> DecrementMaxValue)] [ i [clazz "arrow right icon"] [] ]
]
]
)

let app : App<D3TestInput, AdaptiveD3TestInput, Action> =
{
unpersist = Unpersist.instance
threads = fun _ -> ThreadPool.empty
initial = init
update = update
view = view
}

let start () =
app |> App.start

[<Obsolete("Why does this exist and why are you using it?")>]
module D3Axis =
type Action =
| SetData of D3AxisInput
| IncrementMaxValue
| DecrementMaxValue
| SetMax of float
| SetMin of float
| SetTickCount of float

let update (model : D3AxisInput) (action : Action) =
match action with
| SetData c -> c
| IncrementMaxValue -> { model with max = model.max+100000.0 }
| DecrementMaxValue -> { model with max = model.max-100000.0 }
| SetMax c -> { model with max = c}
| SetMin c -> { model with min = c}
| SetTickCount c -> { model with tickCount = c}

let init = { min = 0.0; max = 100000.0; tickCount = 10.0; }

let pickler = FsPickler.CreateJsonSerializer(omitHeader = true)

let view (model:AdaptiveD3AxisInput) =
require [
{ kind = Script; name = "d3"; url = "https://cdnjs.cloudflare.com/ajax/libs/d3/4.11.0/d3.min.js" }
{ kind = Script; name = "d3Test"; url = "d3Test.js" }]
(
Incremental.div AttributeMap.empty (
alist {
let! max = model.max
let! min = model.min
let! tickCount = model.tickCount
yield
onBoot (sprintf "HiliteAxis(%s,%s,%s,%s);" "'#__ID__'" (string min) (string max) (string tickCount))(
div [style "width:100%; height: 100%;"] [] //display:inline-block; position relative; overflow:hidden;
)
}
)
)

let viewTest (model:AdaptiveD3AxisInput) =
require (Html.semui) (
body [clazz "ui"; style "background: #FFFFFF"] [

div [style "width:90%; height: 10%; float:left"] [
view model
]

div [style "width:10%; height: 100%; float:right;"] [
button [clazz "ui icon button"; onMouseClick (fun _ -> IncrementMaxValue)] [ i [clazz "arrow left icon"] [] ]
button [clazz "ui icon button"; onMouseClick (fun _ -> DecrementMaxValue)] [ i [clazz "arrow right icon"] [] ]
]
]
)

let app : App<D3AxisInput, AdaptiveD3AxisInput, Action> =
{
unpersist = Unpersist.instance
threads = fun _ -> ThreadPool.empty
initial = init
update = update
view = view
}

let start () =
app |> App.start


module Vector3d =

type Action =
Expand Down

0 comments on commit 4321886

Please sign in to comment.