diff --git a/src/PRo3D.Core/Drawing/Drawing-App.fs b/src/PRo3D.Core/Drawing/Drawing-App.fs index 10cc17b7..90aec724 100644 --- a/src/PRo3D.Core/Drawing/Drawing-App.fs +++ b/src/PRo3D.Core/Drawing/Drawing-App.fs @@ -393,7 +393,8 @@ module DrawingApp = match model.working with | Some w when w.points.Count > 0-> - { model with working = Some { w with points = w.points |> IndexList.removeAt (w.points.Count - 1) }} + { model with working = Some { w with points = w.points |> IndexList.removeAt (w.points.Count - 1); + segments = w.segments |> IndexList.removeAt (w.segments.Count - 1)}} | Some _ -> { model with working = None } | None -> model | SetSegment(segmentIndex,segment), _, _ -> diff --git a/src/PRo3D.Core/GroupsApp.fs b/src/PRo3D.Core/GroupsApp.fs index 8299bac9..6bebac05 100644 --- a/src/PRo3D.Core/GroupsApp.fs +++ b/src/PRo3D.Core/GroupsApp.fs @@ -346,7 +346,7 @@ module GroupsApp = (fun (x:Node) -> { x with subNodes = IndexList.add group x.subNodes }) - { model with rootGroup = updateNodeAt path func model.rootGroup } + { model with rootGroup = updateNodeAt path func model.rootGroup; lastSelectedItem = SelectedItem.Group } let union (left : GroupsModel) (right : GroupsModel) : GroupsModel = if left.rootGroup.key = right.rootGroup.key then diff --git a/src/PRo3D.Core/SceneObjectsApp.fs b/src/PRo3D.Core/SceneObjectsApp.fs index cd4de1bc..8c06a5e6 100644 --- a/src/PRo3D.Core/SceneObjectsApp.fs +++ b/src/PRo3D.Core/SceneObjectsApp.fs @@ -29,6 +29,7 @@ type SceneObjectAction = | PlaceSO of V3d | TranslationMessage of TransformationApp.Action | PlaceSceneObject of V3d + | ChangeSOImportDirectories of list module SceneObjectTransformations = @@ -124,6 +125,12 @@ module SceneObjectsUtils = let sghs = sceneObject |> IndexList.toList + |> List.filter(fun (so : SceneObject) -> + let dirExists = File.Exists so.importPath + if dirExists |> not then + Log.error "[SceneObject.Sg] could not find %s" so.importPath + dirExists + ) |> List.map loadSceneObject let sgSceneObjects = @@ -145,6 +152,26 @@ module SceneObjectsApp = else None + let changeSOImportDirectories (model:SceneObjectsModel) (selectedPaths:list) = + let sceneObjs = + model.sceneObjects + |> HashMap.map(fun id so -> + let newPath = + selectedPaths + |> List.map(fun p -> + let name = p |> IO.Path.GetFileName + match name = so.name with + | true -> Some p + | false -> None + ) + |> List.choose( fun np -> np) + match newPath.IsEmpty with + | true -> so + | false -> { so with importPath = newPath.Head } + ) + + { model with sceneObjects = sceneObjs } + let update (model : SceneObjectsModel) (act : SceneObjectAction) @@ -203,7 +230,14 @@ module SceneObjectsApp = { model with sceneObjects = sceneObjs} | None -> model | None -> model + | ChangeSOImportDirectories sl -> + match sl with + | [] -> model + | paths -> + let selectedPaths = paths |> List.choose( fun p -> if File.Exists p then Some p else None) + changeSOImportDirectories model selectedPaths |_-> model + module UI = diff --git a/src/PRo3D.Core/TransformationApp.fs b/src/PRo3D.Core/TransformationApp.fs index f3a35cce..0afd2915 100644 --- a/src/PRo3D.Core/TransformationApp.fs +++ b/src/PRo3D.Core/TransformationApp.fs @@ -58,27 +58,18 @@ module TransformationApp = //translation along north, east, up let trans = translation |> Trafo3d.Translation + let translationTrafo = refSysRotation.Inverse * trans * refSysRotation let originTrafo = -pivot |> Trafo3d.Translation + let eulerRotation = Trafo3d.RotationEulerInDegrees(roll, pitch, -yaw) let yawRotation = Trafo3d.RotationInDegrees(up, -yaw) let pitchRotation = Trafo3d.RotationInDegrees(east, pitch) let rollRotation = Trafo3d.RotationInDegrees(north,roll) - let oldOriginTrafo = -oldPivot |> Trafo3d.Translation - let rot = yawRotation * pitchRotation * rollRotation - let rotAndScaleTrafo = originTrafo * rot * Trafo3d.Scale(scale) * originTrafo.Inverse - - let newTrafo = refSysRotation.Inverse * trans * refSysRotation * rotAndScaleTrafo //rotAndScaleTrafo * - - - //if pivotChanged then - // let rotAndScaleTrafo = oldOriginTrafo * rot * Trafo3d.Scale(scale) * oldOriginTrafo.Inverse - // let newPivotTrafo = refSysRotation.Inverse * trans * refSysRotation * rotAndScaleTrafo - // newPivotTrafo - //else - // newTrafo + let rotAndScale = originTrafo * refSysRotation.Inverse * eulerRotation * Trafo3d.Scale(scale) * refSysRotation * originTrafo.Inverse + let newTrafo = translationTrafo * rotAndScale newTrafo @@ -99,6 +90,7 @@ module TransformationApp = let noP = Rot3d.Rotation(upP, refsys.noffset.value |> Double.radiansFromDegrees).Transform(northP) noP, upP + let fullTrafo (transform : AdaptiveTransformations) @@ -168,13 +160,6 @@ module TransformationApp = else refSys.northO, refSys.up.value let east = north.Cross(up).Normalized - - let yawRotation = Trafo3d.RotationInDegrees(up, -transform.yaw.value) - let pitchRotation = Trafo3d.RotationInDegrees(east, transform.pitch.value) - let rollRotation = Trafo3d.RotationInDegrees(north,transform.roll.value) - - let rot = yawRotation * pitchRotation * rollRotation - let refSysRotation = Trafo3d.FromOrthoNormalBasis(north, east, up) let trans = translation |> Trafo3d.Translation @@ -277,6 +262,7 @@ module TransformationApp = Html.row "show PivotPoint:" [GuiEx.iconCheckBox model.showPivot TogglePivotVisible ] Html.row "Pivot Point (m):" [viewPivotPointInput model.pivot |> UI.map SetPivotPoint ] Html.row "Pivot Size:" [Numeric.view' [InputBox] model.pivotSize |> UI.map SetPivotSize] + //Html.row "Reset Trafos:" [button [clazz "ui button tiny"; onClick (fun _ -> ResetTrafos )] []] //Html.row "Pivot Point:" [Incremental.text (model.pivot |> AVal.map (fun x -> x.ToString ()))] ] ) diff --git a/src/PRo3D.Viewer/Bookmarks.fs b/src/PRo3D.Viewer/Bookmarks.fs index 181bd8b5..55fe2310 100644 --- a/src/PRo3D.Viewer/Bookmarks.fs +++ b/src/PRo3D.Viewer/Bookmarks.fs @@ -51,7 +51,7 @@ module Bookmarks = let groups = GroupsApp.addLeafToActiveGroup (Leaf.Bookmarks newBm) true bookmarks - outerModel, groups + outerModel, { groups with lastSelectedItem = SelectedItem.Child } | ImportBookmarks pathList -> match pathList with | filepath :: tail -> diff --git a/src/PRo3D.Viewer/Viewer-Model.fs b/src/PRo3D.Viewer/Viewer-Model.fs index 46edcb15..57c26d33 100644 --- a/src/PRo3D.Viewer/Viewer-Model.fs +++ b/src/PRo3D.Viewer/Viewer-Model.fs @@ -157,6 +157,8 @@ type ViewerAction = | StartDragging of V2i * MouseButtons | Dragging of V2i | EndDragging of V2i * MouseButtons +| MouseOut of V2i +| MouseIn of V2i //| CorrelationPanelMessage of CorrelationPanelsMessage | MakeSnapshot of int*int*string | ImportSnapshotData of list diff --git a/src/PRo3D.Viewer/Viewer/Viewer.fs b/src/PRo3D.Viewer/Viewer/Viewer.fs index 970d3249..59124ca4 100644 --- a/src/PRo3D.Viewer/Viewer/Viewer.fs +++ b/src/PRo3D.Viewer/Viewer/Viewer.fs @@ -1340,12 +1340,20 @@ module ViewerApp = // | true -> // Log.line "[Viewer] No shattercone updates found." // m - | StartDragging _,_,_ + | StartDragging _,_,_ | Dragging _,_,_ + //| MouseOut _,_,_ | EndDragging _,_,_ -> - match m.multiSelectBox with - | Some x -> { m with multiSelectBox = None } - | None -> m + let m' = + match m.multiSelectBox with + | Some x -> { m with multiSelectBox = None } + | None -> m + m' //{m' with navigation = {m'.navigation with camera = {m'.navigation.camera with pan = false }}} + | MouseIn _,_,_ -> + {m with navigation = {m.navigation with camera = {m.navigation.camera with pan = true }}} + | MouseOut _,_,_ -> + {m with navigation = {m.navigation with camera = {m.navigation.camera with pan = false }}} + // | CorrelationPanelMessage a,_,_ -> //let blurg = // match a with @@ -1971,7 +1979,9 @@ module ViewerApp = ] let bodyAttributes : list> = - [style "background: #1B1C1E; height:100%; overflow-y:scroll; overflow-x:hidden;" //] //overflow-y : visible + [ + style "background: #1B1C1E; height:100%; overflow-y:scroll; overflow-x:hidden;" //] //overflow-y : visible + onMouseUp (fun button pos -> ViewerAnimationAction.ViewerMessage (EndDragging (pos, button))) ] page ( diff --git a/src/PRo3D.Viewer/Viewer/ViewerGUI.fs b/src/PRo3D.Viewer/Viewer/ViewerGUI.fs index 7ffedc48..6ddf52fa 100644 --- a/src/PRo3D.Viewer/Viewer/ViewerGUI.fs +++ b/src/PRo3D.Viewer/Viewer/ViewerGUI.fs @@ -462,12 +462,30 @@ module Gui = clazz "ui item"; Dialogs.onChooseFiles SurfaceAppAction.ChangeOBJImportDirectories; clientEvent "onclick" jsLocateOBJDialog - ][ + ] [ text "Locate OBJ Surfaces" ] } Incremental.div(AttributeMap.Empty) ui |> UI.map SurfaceActions + + let fixAllBrokenSOPaths = + let jsLocateSODialog = + "top.aardvark.dialog.showOpenDialog({title:'Select directory to locate Scene Objects', filters: [{ name: 'OBJ (*.obj)', extensions: ['obj']}, { name: 'DAE (*.dae)', extensions: ['dae']}], properties: ['openFile', 'multiSelections']}).then(result => {top.aardvark.processEvent('__ID__', 'onchoose', result.filePaths);});" + + let ui = + alist { + yield + div [ + clazz "ui item"; + Dialogs.onChooseFiles SceneObjectAction.ChangeSOImportDirectories; + clientEvent "onclick" jsLocateSODialog + ] [ + text "Locate Scene Objects" + ] + } + + Incremental.div(AttributeMap.Empty) ui |> UI.map SceneObjectsMessage let jsOpenAnnotationFileDialog = "top.aardvark.dialog.showOpenDialog({ title: 'Import Annotations', filters: [{ name: 'Annotations (*.ann)', extensions: ['ann']},], properties: ['openFile']}).then(result => {top.aardvark.processEvent('__ID__', 'onchoose', result.filePaths);});" @@ -613,6 +631,8 @@ module Gui = fixAllBrokenPaths //fixes all broken obj import paths fixAllBrokenOBJPaths + //fixes all broken scene obj paths + fixAllBrokenSOPaths let jsOpenOldAnnotationsFileDialogue = "top.aardvark.dialog.showOpenDialog({title:'Import legacy annotations from PRo3D 1.0' , filters: [{ name: 'Annotations (*.xml)', extensions: ['xml']},], properties: ['openFile']}).then(result => {top.aardvark.processEvent('__ID__', 'onchoose', result.filePaths);});" @@ -1126,6 +1146,8 @@ module Gui = onMouseDown (fun button pos -> StartDragging (pos, button)) // onMouseMove (fun delta -> Dragging delta) onMouseUp (fun button pos -> EndDragging (pos, button)) + //onMouseEnter (fun pos -> (MouseIn pos)) + onMouseOut (fun pos -> (MouseOut pos)) ] |> List.map (ViewerUtils.mapAttribute ViewerMessage) body renderViewAttributes [ //[ style "background: #1B1C1E; height:100%; width:100%"] [