Skip to content

Commit 716f36b

Browse files
added ScaleRepresentation to ScaleBars which allows to render coordaniate frames instead of classic scalbars (renamed ScaleBar to ScaleVisualization to reflect his additional visualization behavior), Outline rendering: optional parameter for thickness
1 parent feaed0c commit 716f36b

File tree

5 files changed

+156
-53
lines changed

5 files changed

+156
-53
lines changed

src/PRo3D.Base/OutlineEffect.fs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module OutlineEffect =
5454
}
5555

5656
// NOTE: sg MUST only hold pure Sg without any modes or shaders!
57-
let createForSg (outlineGroup: int) (pass: RenderPass) (color: C4f) sg =
57+
let createForSg' (lineWidth : aval<float>) (outlineGroup: int) (pass: RenderPass) (color: C4f) (sg : ISg<_>) =
5858
let sg = sg |> Sg.uniform "Color" (AVal.constant color)
5959

6060
let mask =
@@ -79,7 +79,7 @@ module OutlineEffect =
7979
|> Sg.blendMode (AVal.init BlendMode.Blend)
8080
|> Sg.fillMode (AVal.init FillMode.Fill)
8181
|> Sg.pass pass
82-
|> Sg.uniform "LineWidth" (AVal.constant 5.0)
82+
|> Sg.uniform "LineWidth" lineWidth
8383
|> Sg.shader {
8484
do! DefaultSurfaces.stableTrafo
8585
do! Shader.lines
@@ -89,6 +89,10 @@ module OutlineEffect =
8989
}
9090

9191
[ mask; outline ] |> Sg.ofList
92+
93+
// NOTE: sg MUST only hold pure Sg without any modes or shaders!
94+
let createForSg (outlineGroup: int) (pass: RenderPass) (color: C4f) (sg : ISg<_>) =
95+
createForSg' (AVal.constant 5.0) outlineGroup pass color sg
9296

9397
let createForLine
9498
(points: aval<V3d[]>)

src/PRo3D.Core/ScaleBars-Model.fs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@ type scSegment with
9696
do! Json.write "color" (x.color.ToString())
9797
}
9898

99+
type ScaleRepresentation =
100+
| ScaleBar = 0
101+
| CoordinateFrame = 1
102+
99103
[<ModelType>]
100-
type ScaleBar = {
104+
type ScaleVisualization = {
101105
version : int
102106
guid : System.Guid
103107
name : string
@@ -120,6 +124,8 @@ type ScaleBar = {
120124
transformation : Transformations
121125
preTransform : Trafo3d
122126
//direction : V3d
127+
128+
representation : ScaleRepresentation
123129
}
124130

125131
[<ModelType>]
@@ -175,6 +181,10 @@ module ScaleBar =
175181

176182
let orientation = orientation |> enum<Orientation>
177183

184+
let! representation =
185+
Json.tryRead "representation"
186+
187+
178188
//let! direction = Json.tryRead "direction"
179189

180190
return
@@ -200,14 +210,12 @@ module ScaleBar =
200210
view = view
201211
transformation = transformation
202212
preTransform = preTransform |> Trafo3d.Parse
203-
//direction = match direction with
204-
// | Some d -> d |> V3d.Parse
205-
// | None -> getDirectionVec orientation view
213+
representation = representation |> Option.map enum<ScaleRepresentation> |> Option.defaultValue ScaleRepresentation.ScaleBar
206214
}
207215
}
208216

209-
type ScaleBar with
210-
static member FromJson(_ : ScaleBar) =
217+
type ScaleVisualization with
218+
static member FromJson(_ : ScaleVisualization) =
211219
json {
212220
let! v = Json.read "version"
213221
match v with
@@ -217,7 +225,7 @@ type ScaleBar with
217225
|> sprintf "don't know version %A of ScaleBar"
218226
|> Json.error
219227
}
220-
static member ToJson(x : ScaleBar) =
228+
static member ToJson(x : ScaleVisualization) =
221229
json {
222230
do! Json.write "version" x.version
223231
do! Json.write "guid" x.guid
@@ -242,14 +250,15 @@ type ScaleBar with
242250
do! Json.write "view" camView
243251
do! Json.write "transformation" x.transformation
244252
do! Json.write "preTransform" (x.preTransform.ToString())
253+
do! Json.write "representation" (int x.representation)
245254
//do! Json.write "direction" (x.direction.ToString())
246255
}
247256

248257

249258
[<ModelType>]
250259
type ScaleBarsModel = {
251260
version : int
252-
scaleBars : HashMap<Guid,ScaleBar>
261+
scaleBars : HashMap<Guid,ScaleVisualization>
253262
selectedScaleBar : Option<Guid>
254263
}
255264

@@ -259,7 +268,7 @@ module ScaleBarsModel =
259268
let read0 =
260269
json {
261270
let! scaleBars = Json.read "scaleBars"
262-
let scaleBars = scaleBars |> List.map(fun (a : ScaleBar) -> (a.guid, a)) |> HashMap.ofList
271+
let scaleBars = scaleBars |> List.map(fun (a : ScaleVisualization) -> (a.guid, a)) |> HashMap.ofList
263272

264273
let! selected = Json.read "selectedScaleBar"
265274
return

src/PRo3D.Core/ScaleBars-Model.g.fs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//27ac5532-ddb7-01d9-9019-b717235c0777
2-
//652ff85a-951e-e7c3-8a3d-31cd4ac20715
1+
//55ffe839-1706-fe94-127c-a66d739541fc
2+
//6e02a380-6769-a0ff-1f49-6d0a6d57d862
33
#nowarn "49" // upper case patterns
44
#nowarn "66" // upcast is unncecessary
55
#nowarn "1337" // internal types
@@ -37,7 +37,7 @@ module scSegmentLenses =
3737
static member endPoint_ = ((fun (self : scSegment) -> self.endPoint), (fun (value : Aardvark.Base.V3d) (self : scSegment) -> { self with endPoint = value }))
3838
static member color_ = ((fun (self : scSegment) -> self.color), (fun (value : Aardvark.Base.C4b) (self : scSegment) -> { self with color = value }))
3939
[<System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
40-
type AdaptiveScaleBar(value : ScaleBar) =
40+
type AdaptiveScaleVisualization(value : ScaleVisualization) =
4141
let _version_ = FSharp.Data.Adaptive.cval(value.version)
4242
let _guid_ = FSharp.Data.Adaptive.cval(value.guid)
4343
let _name_ = FSharp.Data.Adaptive.cval(value.name)
@@ -60,12 +60,13 @@ type AdaptiveScaleBar(value : ScaleBar) =
6060
let _view_ = FSharp.Data.Adaptive.cval(value.view)
6161
let _transformation_ = PRo3D.Core.Surface.AdaptiveTransformations(value.transformation)
6262
let _preTransform_ = FSharp.Data.Adaptive.cval(value.preTransform)
63+
let _representation_ = FSharp.Data.Adaptive.cval(value.representation)
6364
let mutable __value = value
6465
let __adaptive = FSharp.Data.Adaptive.AVal.custom((fun (token : FSharp.Data.Adaptive.AdaptiveToken) -> __value))
65-
static member Create(value : ScaleBar) = AdaptiveScaleBar(value)
66-
static member Unpersist = Adaptify.Unpersist.create (fun (value : ScaleBar) -> AdaptiveScaleBar(value)) (fun (adaptive : AdaptiveScaleBar) (value : ScaleBar) -> adaptive.Update(value))
67-
member __.Update(value : ScaleBar) =
68-
if Microsoft.FSharp.Core.Operators.not((FSharp.Data.Adaptive.ShallowEqualityComparer<ScaleBar>.ShallowEquals(value, __value))) then
66+
static member Create(value : ScaleVisualization) = AdaptiveScaleVisualization(value)
67+
static member Unpersist = Adaptify.Unpersist.create (fun (value : ScaleVisualization) -> AdaptiveScaleVisualization(value)) (fun (adaptive : AdaptiveScaleVisualization) (value : ScaleVisualization) -> adaptive.Update(value))
68+
member __.Update(value : ScaleVisualization) =
69+
if Microsoft.FSharp.Core.Operators.not((FSharp.Data.Adaptive.ShallowEqualityComparer<ScaleVisualization>.ShallowEquals(value, __value))) then
6970
__value <- value
7071
__adaptive.MarkOutdated()
7172
_version_.Value <- value.version
@@ -86,6 +87,7 @@ type AdaptiveScaleBar(value : ScaleBar) =
8687
_view_.Value <- value.view
8788
_transformation_.Update(value.transformation)
8889
_preTransform_.Value <- value.preTransform
90+
_representation_.Value <- value.representation
8991
member __.Current = __adaptive
9092
member __.version = _version_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.int>
9193
member __.guid = _guid_ :> FSharp.Data.Adaptive.aval<System.Guid>
@@ -105,27 +107,29 @@ type AdaptiveScaleBar(value : ScaleBar) =
105107
member __.view = _view_ :> FSharp.Data.Adaptive.aval<Aardvark.Rendering.CameraView>
106108
member __.transformation = _transformation_
107109
member __.preTransform = _preTransform_ :> FSharp.Data.Adaptive.aval<Aardvark.Base.Trafo3d>
110+
member __.representation = _representation_ :> FSharp.Data.Adaptive.aval<ScaleRepresentation>
108111
[<AutoOpen; System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
109-
module ScaleBarLenses =
110-
type ScaleBar with
111-
static member version_ = ((fun (self : ScaleBar) -> self.version), (fun (value : Microsoft.FSharp.Core.int) (self : ScaleBar) -> { self with version = value }))
112-
static member guid_ = ((fun (self : ScaleBar) -> self.guid), (fun (value : System.Guid) (self : ScaleBar) -> { self with guid = value }))
113-
static member name_ = ((fun (self : ScaleBar) -> self.name), (fun (value : Microsoft.FSharp.Core.string) (self : ScaleBar) -> { self with name = value }))
114-
static member text_ = ((fun (self : ScaleBar) -> self.text), (fun (value : Microsoft.FSharp.Core.string) (self : ScaleBar) -> { self with text = value }))
115-
static member textsize_ = ((fun (self : ScaleBar) -> self.textsize), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleBar) -> { self with textsize = value }))
116-
static member textVisible_ = ((fun (self : ScaleBar) -> self.textVisible), (fun (value : Microsoft.FSharp.Core.bool) (self : ScaleBar) -> { self with textVisible = value }))
117-
static member isVisible_ = ((fun (self : ScaleBar) -> self.isVisible), (fun (value : Microsoft.FSharp.Core.bool) (self : ScaleBar) -> { self with isVisible = value }))
118-
static member position_ = ((fun (self : ScaleBar) -> self.position), (fun (value : Aardvark.Base.V3d) (self : ScaleBar) -> { self with position = value }))
119-
static member scSegments_ = ((fun (self : ScaleBar) -> self.scSegments), (fun (value : FSharp.Data.Adaptive.IndexList<scSegment>) (self : ScaleBar) -> { self with scSegments = value }))
120-
static member orientation_ = ((fun (self : ScaleBar) -> self.orientation), (fun (value : Orientation) (self : ScaleBar) -> { self with orientation = value }))
121-
static member alignment_ = ((fun (self : ScaleBar) -> self.alignment), (fun (value : Pivot) (self : ScaleBar) -> { self with alignment = value }))
122-
static member thickness_ = ((fun (self : ScaleBar) -> self.thickness), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleBar) -> { self with thickness = value }))
123-
static member length_ = ((fun (self : ScaleBar) -> self.length), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleBar) -> { self with length = value }))
124-
static member unit_ = ((fun (self : ScaleBar) -> self.unit), (fun (value : Unit) (self : ScaleBar) -> { self with unit = value }))
125-
static member subdivisions_ = ((fun (self : ScaleBar) -> self.subdivisions), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleBar) -> { self with subdivisions = value }))
126-
static member view_ = ((fun (self : ScaleBar) -> self.view), (fun (value : Aardvark.Rendering.CameraView) (self : ScaleBar) -> { self with view = value }))
127-
static member transformation_ = ((fun (self : ScaleBar) -> self.transformation), (fun (value : PRo3D.Core.Surface.Transformations) (self : ScaleBar) -> { self with transformation = value }))
128-
static member preTransform_ = ((fun (self : ScaleBar) -> self.preTransform), (fun (value : Aardvark.Base.Trafo3d) (self : ScaleBar) -> { self with preTransform = value }))
112+
module ScaleVisualizationLenses =
113+
type ScaleVisualization with
114+
static member version_ = ((fun (self : ScaleVisualization) -> self.version), (fun (value : Microsoft.FSharp.Core.int) (self : ScaleVisualization) -> { self with version = value }))
115+
static member guid_ = ((fun (self : ScaleVisualization) -> self.guid), (fun (value : System.Guid) (self : ScaleVisualization) -> { self with guid = value }))
116+
static member name_ = ((fun (self : ScaleVisualization) -> self.name), (fun (value : Microsoft.FSharp.Core.string) (self : ScaleVisualization) -> { self with name = value }))
117+
static member text_ = ((fun (self : ScaleVisualization) -> self.text), (fun (value : Microsoft.FSharp.Core.string) (self : ScaleVisualization) -> { self with text = value }))
118+
static member textsize_ = ((fun (self : ScaleVisualization) -> self.textsize), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleVisualization) -> { self with textsize = value }))
119+
static member textVisible_ = ((fun (self : ScaleVisualization) -> self.textVisible), (fun (value : Microsoft.FSharp.Core.bool) (self : ScaleVisualization) -> { self with textVisible = value }))
120+
static member isVisible_ = ((fun (self : ScaleVisualization) -> self.isVisible), (fun (value : Microsoft.FSharp.Core.bool) (self : ScaleVisualization) -> { self with isVisible = value }))
121+
static member position_ = ((fun (self : ScaleVisualization) -> self.position), (fun (value : Aardvark.Base.V3d) (self : ScaleVisualization) -> { self with position = value }))
122+
static member scSegments_ = ((fun (self : ScaleVisualization) -> self.scSegments), (fun (value : FSharp.Data.Adaptive.IndexList<scSegment>) (self : ScaleVisualization) -> { self with scSegments = value }))
123+
static member orientation_ = ((fun (self : ScaleVisualization) -> self.orientation), (fun (value : Orientation) (self : ScaleVisualization) -> { self with orientation = value }))
124+
static member alignment_ = ((fun (self : ScaleVisualization) -> self.alignment), (fun (value : Pivot) (self : ScaleVisualization) -> { self with alignment = value }))
125+
static member thickness_ = ((fun (self : ScaleVisualization) -> self.thickness), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleVisualization) -> { self with thickness = value }))
126+
static member length_ = ((fun (self : ScaleVisualization) -> self.length), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleVisualization) -> { self with length = value }))
127+
static member unit_ = ((fun (self : ScaleVisualization) -> self.unit), (fun (value : Unit) (self : ScaleVisualization) -> { self with unit = value }))
128+
static member subdivisions_ = ((fun (self : ScaleVisualization) -> self.subdivisions), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : ScaleVisualization) -> { self with subdivisions = value }))
129+
static member view_ = ((fun (self : ScaleVisualization) -> self.view), (fun (value : Aardvark.Rendering.CameraView) (self : ScaleVisualization) -> { self with view = value }))
130+
static member transformation_ = ((fun (self : ScaleVisualization) -> self.transformation), (fun (value : PRo3D.Core.Surface.Transformations) (self : ScaleVisualization) -> { self with transformation = value }))
131+
static member preTransform_ = ((fun (self : ScaleVisualization) -> self.preTransform), (fun (value : Aardvark.Base.Trafo3d) (self : ScaleVisualization) -> { self with preTransform = value }))
132+
static member representation_ = ((fun (self : ScaleVisualization) -> self.representation), (fun (value : ScaleRepresentation) (self : ScaleVisualization) -> { self with representation = value }))
129133
[<System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
130134
type AdaptiveScaleBarDrawing(value : ScaleBarDrawing) =
131135
let _orientation_ = FSharp.Data.Adaptive.cval(value.orientation)
@@ -164,10 +168,10 @@ module ScaleBarDrawingLenses =
164168
type AdaptiveScaleBarsModel(value : ScaleBarsModel) =
165169
let _version_ = FSharp.Data.Adaptive.cval(value.version)
166170
let _scaleBars_ =
167-
let inline __arg2 (m : AdaptiveScaleBar) (v : ScaleBar) =
171+
let inline __arg2 (m : AdaptiveScaleVisualization) (v : ScaleVisualization) =
168172
m.Update(v)
169173
m
170-
FSharp.Data.Traceable.ChangeableModelMap(value.scaleBars, (fun (v : ScaleBar) -> AdaptiveScaleBar(v)), __arg2, (fun (m : AdaptiveScaleBar) -> m))
174+
FSharp.Data.Traceable.ChangeableModelMap(value.scaleBars, (fun (v : ScaleVisualization) -> AdaptiveScaleVisualization(v)), __arg2, (fun (m : AdaptiveScaleVisualization) -> m))
171175
let _selectedScaleBar_ = FSharp.Data.Adaptive.cval(value.selectedScaleBar)
172176
let mutable __value = value
173177
let __adaptive = FSharp.Data.Adaptive.AVal.custom((fun (token : FSharp.Data.Adaptive.AdaptiveToken) -> __value))
@@ -182,12 +186,12 @@ type AdaptiveScaleBarsModel(value : ScaleBarsModel) =
182186
_selectedScaleBar_.Value <- value.selectedScaleBar
183187
member __.Current = __adaptive
184188
member __.version = _version_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.int>
185-
member __.scaleBars = _scaleBars_ :> FSharp.Data.Adaptive.amap<System.Guid, AdaptiveScaleBar>
189+
member __.scaleBars = _scaleBars_ :> FSharp.Data.Adaptive.amap<System.Guid, AdaptiveScaleVisualization>
186190
member __.selectedScaleBar = _selectedScaleBar_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.Option<System.Guid>>
187191
[<AutoOpen; System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
188192
module ScaleBarsModelLenses =
189193
type ScaleBarsModel with
190194
static member version_ = ((fun (self : ScaleBarsModel) -> self.version), (fun (value : Microsoft.FSharp.Core.int) (self : ScaleBarsModel) -> { self with version = value }))
191-
static member scaleBars_ = ((fun (self : ScaleBarsModel) -> self.scaleBars), (fun (value : FSharp.Data.Adaptive.HashMap<System.Guid, ScaleBar>) (self : ScaleBarsModel) -> { self with scaleBars = value }))
195+
static member scaleBars_ = ((fun (self : ScaleBarsModel) -> self.scaleBars), (fun (value : FSharp.Data.Adaptive.HashMap<System.Guid, ScaleVisualization>) (self : ScaleBarsModel) -> { self with scaleBars = value }))
192196
static member selectedScaleBar_ = ((fun (self : ScaleBarsModel) -> self.selectedScaleBar), (fun (value : Microsoft.FSharp.Core.Option<System.Guid>) (self : ScaleBarsModel) -> { self with selectedScaleBar = value }))
193197

0 commit comments

Comments
 (0)