Skip to content

Commit

Permalink
#186 obj import with large coordinates compensation, #156 view planne…
Browse files Browse the repository at this point in the history
…r serialization, changed selection type for selected vp (fixed some bugs), load scene with wrong obj path and reload obj per gui, bug fixes: selection problems for multiple platforms, pan and tilt axes don't move in 3d view
  • Loading branch information
LauraFritz14 committed Jun 9, 2022
1 parent 35bacf4 commit dce1f02
Show file tree
Hide file tree
Showing 9 changed files with 692 additions and 168 deletions.
84 changes: 64 additions & 20 deletions src/PRo3D.Core/Surface/SurfaceApp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ open Adaptify.FSharp.Core
open Aardvark.Base.Coder

type SurfaceAppAction =
| SurfacePropertiesMessage of SurfaceProperties.Action
| FlyToSurface of Guid
| MakeRelative of Guid
| RemoveSurface of Guid*list<Index>
| PickSurface of SceneHit*string
| OpenFolder of Guid
| RebuildKdTrees of Guid
| ToggleActiveFlag of Guid
| ChangeImportDirectory of Guid*string
| ChangeImportDirectories of list<string>
| GroupsMessage of GroupsAppAction
//| PickObject of V3d
| PlaceSurface of V3d
| ScalarsColorLegendMessage of FalseColorLegendApp.Action
| ColorCorrectionMessage of ColorCorrectionProperties.Action
| SetHomePosition
| TranslationMessage of TranslationApp.Action
| SetPreTrafo of string
| SurfacePropertiesMessage of SurfaceProperties.Action
| FlyToSurface of Guid
| MakeRelative of Guid
| RemoveSurface of Guid*list<Index>
| PickSurface of SceneHit*string
| OpenFolder of Guid
| RebuildKdTrees of Guid
| ToggleActiveFlag of Guid
| ChangeImportDirectory of Guid*string
| ChangeImportDirectories of list<string>
| ChangeOBJImportDirectories of list<string>
| GroupsMessage of GroupsAppAction
//| PickObject of V3d
| PlaceSurface of V3d
| ScalarsColorLegendMessage of FalseColorLegendApp.Action
| ColorCorrectionMessage of ColorCorrectionProperties.Action
| SetHomePosition
| TranslationMessage of TranslationApp.Action
| SetPreTrafo of string

module SurfaceUtils =

Expand Down Expand Up @@ -187,6 +188,12 @@ module SurfaceUtils =
let sghs =
surfaces
|> IndexList.toList
|> List.filter(fun s ->
let dirExists = File.Exists s.importPath
if dirExists |> not then
Log.error "[Surface.Sg] could not find %s" s.importPath
dirExists
)
|> List.map loadObject

let sgObjects =
Expand Down Expand Up @@ -306,6 +313,38 @@ module SurfaceApp =

{ model with surfaces = { model.surfaces with flat = flat' } }

let changeOBJImportDirectories (model:SurfaceModel) (selectedPaths:list<string>) =

let surfaces =
model.surfaces.flat
|> HashMap.toList
|> List.map(fun (_,v) ->
let s = (v |> Leaf.toSurface)
let newPath =
selectedPaths
|> List.map(fun p ->
let name = p |> IO.Path.GetFileName
match name = s.name with
| true -> Some p
| false -> None
)
|> List.choose( fun np -> np)
match newPath.IsEmpty with
| true -> s
| false -> { s with importPath = newPath.Head }
)

let flat' =
surfaces
|> List.choose(fun x ->
let f = (fun _ -> x |> Leaf.Surfaces)
Groups.updateLeaf' x.guid f model.surfaces
|> HashMap.tryFind x.guid
|> Option.map(fun leaf -> (x.guid,leaf) |> hmapsingle))
|> List.fold HashMap.union HashMap.empty

{ model with surfaces = { model.surfaces with flat = flat' } }



let update
Expand Down Expand Up @@ -394,7 +433,12 @@ module SurfaceApp =
| paths ->
let selectedPaths = paths |> List.choose Files.tryDirectoryExists
changeImportDirectories model selectedPaths

| ChangeOBJImportDirectories sl ->
match sl with
| [] -> model
| paths ->
let selectedPaths = paths |> List.choose( fun p -> if File.Exists p then Some p else None)
changeOBJImportDirectories model selectedPaths
| GroupsMessage msg ->
let groups = GroupsApp.update model.surfaces msg

Expand Down Expand Up @@ -720,7 +764,7 @@ module SurfaceApp =
let isobj = Path.GetExtension path = ".obj"
//
// yield i
if ((Directory.Exists path) |> not || (path |> Files.isSurfaceFolder |> not)) && (isobj |> not) then
if (((Directory.Exists path) |> not || (path |> Files.isSurfaceFolder |> not)) && (isobj |> not)) || ( isobj && (File.Exists path) |> not ) then
yield i [
clazz "exclamation red icon"
//Dialogs.onChooseDirectory key ChangeImportDirectory;
Expand Down
Loading

0 comments on commit dce1f02

Please sign in to comment.