Skip to content

Commit b08253b

Browse files
first version of working cross sections
1 parent d172ffe commit b08253b

8 files changed

Lines changed: 85 additions & 34 deletions

File tree

profileDrawing/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ python draw_profile.py --profile testProfile.csv --curtain-height 30 --min-altit
3434
| `--y-interval` | Optional. Major tick/label interval for y-axis in meters |
3535
| `--x-grid` | Optional. Minor grid line interval for x-axis in meters |
3636
| `--y-grid` | Optional. Minor grid line interval for y-axis in meters |
37+
| `--hide-zero` | Optional. Hide the first x-tick label (0) to avoid clipping at the left edge |
38+
| `--grid-opacity` | Optional. Grid line opacity from 0.0 to 1.0 (default: 0.4, minor grid is 60% of this) |
39+
| `--grid-width` | Optional. Major grid line width in points (default: 1.0, minor grid is half) |
3740

3841
### CSV format
3942

@@ -51,3 +54,8 @@ python test_draw_profile.py
5154
```
5255

5356
This reads `testProfile.csv`, auto-computes sensible bounds with 5 m margin, and writes both `test_profile_normal.svg` (labels outside) and `test_profile_overlay.svg` (labels overlaid).
57+
58+
59+
## Example:
60+
61+
`python draw_profile.py --profile testProfile.csv --curtain-height 100 --min-altitude -2600 --vertical-px 4000 --overlay --x-interval 20 --y-interval 20 --x-grid 25 --y-grid 1 --output profile.png --grid-opacity 1.0 --grid-width 3.0`
-8.78 KB
Binary file not shown.

profileDrawing/draw_profile.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def read_profile(csv_path):
1515
return distances, elevations
1616

1717

18-
def draw_profile(csv_path, curtain_height, min_altitude, vertical_px, output_path="profile_output.svg", overlay=False, x_interval=None, y_interval=None, x_grid=None, y_grid=None, hide_zero=False):
18+
def draw_profile(csv_path, curtain_height, min_altitude, vertical_px, output_path="profile_output.svg", overlay=False, x_interval=None, y_interval=None, x_grid=None, y_grid=None, hide_zero=False, grid_opacity=None, grid_width=None):
1919
distances, elevations = read_profile(csv_path)
2020

2121
max_altitude = min_altitude + curtain_height
@@ -51,8 +51,12 @@ def draw_profile(csv_path, curtain_height, min_altitude, vertical_px, output_pat
5151
ax.xaxis.set_minor_locator(ticker.MultipleLocator(x_grid) if x_grid else ticker.AutoMinorLocator())
5252
ax.yaxis.set_minor_locator(ticker.MultipleLocator(y_grid) if y_grid else ticker.AutoMinorLocator())
5353

54-
ax.grid(True, which="major", linestyle="--", alpha=0.4)
55-
ax.grid(True, which="minor", linestyle=":", linewidth=0.5, alpha=0.25)
54+
major_alpha = grid_opacity if grid_opacity is not None else 0.4
55+
minor_alpha = major_alpha * 0.6
56+
major_lw = grid_width if grid_width is not None else 1.0
57+
minor_lw = major_lw * 0.5
58+
ax.grid(True, which="major", linestyle="--", alpha=major_alpha, linewidth=major_lw)
59+
ax.grid(True, which="minor", linestyle=":", alpha=minor_alpha, linewidth=minor_lw)
5660

5761
if overlay:
5862
# scale font size to be readable relative to the vertical image size
@@ -153,7 +157,9 @@ def draw_profile(csv_path, curtain_height, min_altitude, vertical_px, output_pat
153157
parser.add_argument("--x-grid", type=float, default=None, help="Minor grid line interval for x-axis (meters)")
154158
parser.add_argument("--y-grid", type=float, default=None, help="Minor grid line interval for y-axis (meters)")
155159
parser.add_argument("--hide-zero", action="store_true", help="Hide the first x-tick label (0) to avoid clipping at the left edge")
160+
parser.add_argument("--grid-opacity", type=float, default=None, help="Grid line opacity 0.0–1.0 (default: 0.4, minor grid is 60%% of this)")
161+
parser.add_argument("--grid-width", type=float, default=None, help="Major grid line width in points (default: 1.0, minor is half)")
156162
args = parser.parse_args()
157163

158164
draw_profile(args.profile, args.curtain_height, args.min_altitude, args.vertical_px, args.output, args.overlay,
159-
args.x_interval, args.y_interval, args.x_grid, args.y_grid, args.hide_zero)
165+
args.x_interval, args.y_interval, args.x_grid, args.y_grid, args.hide_zero, args.grid_opacity, args.grid_width)

src/PRo3D.Core/CrossSection-Model.fs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ type CrossSectionModel = {
3333
curtainExtrusionDepth : NumericInput
3434
curtainAbsoluteMode : bool
3535
curtainTargetAltitude : NumericInput
36-
curtainTextureDepth : NumericInput
37-
curtainBaseColor : ColorInput
36+
curtainTextureDepth : NumericInput
37+
curtainTextureStartAltitude : NumericInput
38+
curtainBaseColor : ColorInput
3839
}
3940

4041
module CrossSectionModel =
@@ -56,6 +57,10 @@ module CrossSectionModel =
5657
value = 50.0; min = 1.0; max = 10000.0
5758
step = 10.0; format = "{0:0}"
5859
}
60+
curtainTextureStartAltitude = {
61+
value = 0.0; min = -10000.0; max = 100000.0
62+
step = 10.0; format = "{0:0}"
63+
}
5964
curtainBaseColor = { c = C4b.Gray }
6065
}
6166

@@ -111,6 +116,11 @@ type CrossSectionModel with
111116
match curtainTextureDepthOpt with
112117
| Some (_ : Chiron.Json) -> Json.readWith Ext.fromJson<NumericInput,Ext> "curtainTextureDepth"
113118
| None -> json { return initial.curtainTextureDepth }
119+
let! curtainTextureStartAltOpt = Json.tryRead "curtainTextureStartAltitude"
120+
let! curtainTextureStartAltitude =
121+
match curtainTextureStartAltOpt with
122+
| Some (_ : Chiron.Json) -> Json.readWith Ext.fromJson<NumericInput,Ext> "curtainTextureStartAltitude"
123+
| None -> json { return initial.curtainTextureStartAltitude }
114124
let! curtainBaseColorOpt = Json.tryRead "curtainBaseColor"
115125
let! curtainBaseColor =
116126
match curtainBaseColorOpt with
@@ -125,6 +135,7 @@ type CrossSectionModel with
125135
curtainAbsoluteMode = curtainAbsoluteMode |> Option.defaultValue initial.curtainAbsoluteMode
126136
curtainTargetAltitude = curtainTargetAltitude
127137
curtainTextureDepth = curtainTextureDepth
138+
curtainTextureStartAltitude = curtainTextureStartAltitude
128139
curtainBaseColor = curtainBaseColor
129140
}
130141
}
@@ -137,5 +148,6 @@ type CrossSectionModel with
137148
do! Json.write "curtainAbsoluteMode" x.curtainAbsoluteMode
138149
do! Json.writeWith (Ext.toJson<NumericInput,Ext>) "curtainTargetAltitude" x.curtainTargetAltitude
139150
do! Json.writeWith (Ext.toJson<NumericInput,Ext>) "curtainTextureDepth" x.curtainTextureDepth
151+
do! Json.writeWith (Ext.toJson<NumericInput,Ext>) "curtainTextureStartAltitude" x.curtainTextureStartAltitude
140152
do! Json.writeWith (Ext.toJson<ColorInput,Ext>) "curtainBaseColor" x.curtainBaseColor
141153
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//4d435630-40b4-2568-d813-1635eec11225
2-
//f4885c54-f359-c9e6-e8a7-4377e7f249be
1+
//51a55be8-10c1-3aa7-69b8-c42015a5b17e
2+
//42366d6f-52d2-43a5-d199-5eaa084b5e1a
33
#nowarn "49" // upper case patterns
44
#nowarn "66" // upcast is unncecessary
55
#nowarn "1337" // internal types
@@ -19,6 +19,7 @@ type AdaptiveCrossSectionModel(value : CrossSectionModel) =
1919
let _curtainAbsoluteMode_ = FSharp.Data.Adaptive.cval(value.curtainAbsoluteMode)
2020
let _curtainTargetAltitude_ = Aardvark.UI.Primitives.AdaptiveNumericInput(value.curtainTargetAltitude)
2121
let _curtainTextureDepth_ = Aardvark.UI.Primitives.AdaptiveNumericInput(value.curtainTextureDepth)
22+
let _curtainTextureStartAltitude_ = Aardvark.UI.Primitives.AdaptiveNumericInput(value.curtainTextureStartAltitude)
2223
let _curtainBaseColor_ = Aardvark.UI.AdaptiveColorInput(value.curtainBaseColor)
2324
let mutable __value = value
2425
let __adaptive = FSharp.Data.Adaptive.AVal.custom((fun (token : FSharp.Data.Adaptive.AdaptiveToken) -> __value))
@@ -35,6 +36,7 @@ type AdaptiveCrossSectionModel(value : CrossSectionModel) =
3536
_curtainAbsoluteMode_.Value <- value.curtainAbsoluteMode
3637
_curtainTargetAltitude_.Update(value.curtainTargetAltitude)
3738
_curtainTextureDepth_.Update(value.curtainTextureDepth)
39+
_curtainTextureStartAltitude_.Update(value.curtainTextureStartAltitude)
3840
_curtainBaseColor_.Update(value.curtainBaseColor)
3941
member __.Current = __adaptive
4042
member __.crossSection = _crossSection_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.Option<CrossSection>>
@@ -44,6 +46,7 @@ type AdaptiveCrossSectionModel(value : CrossSectionModel) =
4446
member __.curtainAbsoluteMode = _curtainAbsoluteMode_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.bool>
4547
member __.curtainTargetAltitude = _curtainTargetAltitude_
4648
member __.curtainTextureDepth = _curtainTextureDepth_
49+
member __.curtainTextureStartAltitude = _curtainTextureStartAltitude_
4750
member __.curtainBaseColor = _curtainBaseColor_
4851
[<AutoOpen; System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
4952
module CrossSectionModelLenses =
@@ -55,5 +58,6 @@ module CrossSectionModelLenses =
5558
static member curtainAbsoluteMode_ = ((fun (self : CrossSectionModel) -> self.curtainAbsoluteMode), (fun (value : Microsoft.FSharp.Core.bool) (self : CrossSectionModel) -> { self with curtainAbsoluteMode = value }))
5659
static member curtainTargetAltitude_ = ((fun (self : CrossSectionModel) -> self.curtainTargetAltitude), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : CrossSectionModel) -> { self with curtainTargetAltitude = value }))
5760
static member curtainTextureDepth_ = ((fun (self : CrossSectionModel) -> self.curtainTextureDepth), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : CrossSectionModel) -> { self with curtainTextureDepth = value }))
61+
static member curtainTextureStartAltitude_ = ((fun (self : CrossSectionModel) -> self.curtainTextureStartAltitude), (fun (value : Aardvark.UI.Primitives.NumericInput) (self : CrossSectionModel) -> { self with curtainTextureStartAltitude = value }))
5862
static member curtainBaseColor_ = ((fun (self : CrossSectionModel) -> self.curtainBaseColor), (fun (value : Aardvark.UI.ColorInput) (self : CrossSectionModel) -> { self with curtainBaseColor = value }))
5963

src/PRo3D.Core/CrossSectionApp.fs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ type CrossSectionAction =
1616
| SetCurtainExtrusionDepth of Numeric.Action
1717
| ToggleCurtainAbsoluteMode
1818
| SetCurtainTargetAltitude of Numeric.Action
19-
| SetCurtainTextureDepth of Numeric.Action
20-
| ChangeCurtainBaseColor of ColorPicker.Action
19+
| SetCurtainTextureDepth of Numeric.Action
20+
| SetCurtainTextureStartAltitude of Numeric.Action
21+
| ChangeCurtainBaseColor of ColorPicker.Action
2122

2223
module CrossSectionApp =
2324

@@ -39,6 +40,8 @@ module CrossSectionApp =
3940
{ model with curtainTargetAltitude = Numeric.update model.curtainTargetAltitude a }
4041
| SetCurtainTextureDepth a ->
4142
{ model with curtainTextureDepth = Numeric.update model.curtainTextureDepth a }
43+
| SetCurtainTextureStartAltitude a ->
44+
{ model with curtainTextureStartAltitude = Numeric.update model.curtainTextureStartAltitude a }
4245
| ChangeCurtainBaseColor a ->
4346
{ model with curtainBaseColor = ColorPicker.update model.curtainBaseColor a }
4447

@@ -65,7 +68,8 @@ module CrossSectionApp =
6568
}
6669
)
6770
]
68-
Html.row "Texture Depth (m):" [Numeric.view' [InputBox] model.curtainTextureDepth |> UI.map SetCurtainTextureDepth]
71+
Html.row "Tex Start Alt (m):" [Numeric.view' [InputBox] model.curtainTextureStartAltitude |> UI.map SetCurtainTextureStartAltitude]
72+
Html.row "Tex Depth (m):" [Numeric.view' [InputBox] model.curtainTextureDepth |> UI.map SetCurtainTextureDepth]
6973
Html.row "Base Color:" [ColorPicker.view model.curtainBaseColor |> UI.map ChangeCurtainBaseColor]
7074
]
7175
)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//e4eebad7-e3e9-5330-2090-496649038ecb
2-
//bb4e2d0a-2744-801c-ce26-3edcf884df74
2+
//6b5b11fb-9c2b-6bde-6ca1-76fc5fcc5f1d
33
#nowarn "49" // upper case patterns
44
#nowarn "66" // upcast is unncecessary
55
#nowarn "1337" // internal types
@@ -13,10 +13,10 @@ open PRo3D.Core.SequencedBookmarks
1313
[<System.Diagnostics.CodeAnalysis.SuppressMessage("NameConventions", "*")>]
1414
type AdaptiveSequencedBookmarkModel(value : SequencedBookmarkModel) =
1515
let mutable _key_ = FSharp.Data.Adaptive.cval(value.key)
16-
let mutable _filename_ = FSharp.Data.Adaptive.cval(value.filename)
17-
let mutable _name_ = FSharp.Data.Adaptive.cval(value.name)
1816
let mutable _cameraView_ = FSharp.Data.Adaptive.cval(value.cameraView)
17+
let mutable _name_ = FSharp.Data.Adaptive.cval(value.name)
1918
let mutable _path_ = FSharp.Data.Adaptive.cval(value.path)
19+
let mutable _filename_ = FSharp.Data.Adaptive.cval(value.filename)
2020
let _bookmark_ = PRo3D.Core.AdaptiveBookmark(value.bookmark)
2121
let _metadata_ = FSharp.Data.Adaptive.cval(value.metadata)
2222
let _frustumParameters_ = FSharp.Data.Adaptive.cval(value.frustumParameters)
@@ -42,10 +42,10 @@ type AdaptiveSequencedBookmarkModel(value : SequencedBookmarkModel) =
4242
__value <- value
4343
__adaptive.MarkOutdated()
4444
_key_.Value <- value.key
45-
_filename_.Value <- value.filename
46-
_name_.Value <- value.name
4745
_cameraView_.Value <- value.cameraView
46+
_name_.Value <- value.name
4847
_path_.Value <- value.path
48+
_filename_.Value <- value.filename
4949
_bookmark_.Update(value.bookmark)
5050
_metadata_.Value <- value.metadata
5151
_frustumParameters_.Value <- value.frustumParameters
@@ -57,10 +57,10 @@ type AdaptiveSequencedBookmarkModel(value : SequencedBookmarkModel) =
5757
_observationInfo_.Update(value.observationInfo)
5858
member __.Current = __adaptive
5959
member __.key = _key_ :> FSharp.Data.Adaptive.aval<System.Guid>
60-
member __.filename = _filename_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.string>
61-
member __.name = _name_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.string>
6260
member __.cameraView = _cameraView_ :> FSharp.Data.Adaptive.aval<Aardvark.Rendering.CameraView>
61+
member __.name = _name_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.string>
6362
member __.path = _path_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.string>
63+
member __.filename = _filename_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.string>
6464
member __.version = __value.version
6565
member __.bookmark = _bookmark_
6666
member __.metadata = _metadata_ :> FSharp.Data.Adaptive.aval<Microsoft.FSharp.Core.option<Microsoft.FSharp.Core.string>>

0 commit comments

Comments
 (0)