From cccc64babdc1d75eea1ea8c3330b7f0ee2039dba Mon Sep 17 00:00:00 2001 From: Stanislav Mishchenko Date: Sat, 4 May 2024 15:16:48 +0300 Subject: [PATCH] codestyle --- .../solve/rendering/canvas/SceneCanvas.kt | 19 ++++++++++--------- .../core/renderers/LandmarkLayerRenderer.kt | 1 - .../renderers/PointAssociationsRenderer.kt | 2 +- src/main/kotlin/solve/scene/view/SceneView.kt | 2 -- .../scene/view/association/AssociationLine.kt | 1 - .../view/association/AssociationManager.kt | 16 +++++++++++----- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt b/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt index 619b5963..be1a3b5b 100644 --- a/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt +++ b/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt @@ -71,7 +71,6 @@ class SceneCanvas : OpenGLCanvas() { private var isFirstAssociatingFrameChosen = false private var associationAdorner: AssociationAdorner? = null - private val contextMenu = buildContextMenu(canvas) init { @@ -99,7 +98,8 @@ class SceneCanvas : OpenGLCanvas() { engineScene?.setFramesSelection(framesSelection) associationManager.setFramesSelection(framesSelection) framesSelectionSize = framesSelection.count() - lastFramesSelection = framesSelection } + lastFramesSelection = framesSelection + } fun setColumnsNumber(columnsNumber: Int) { this.columnsNumber = columnsNumber @@ -334,8 +334,9 @@ class SceneCanvas : OpenGLCanvas() { } private fun onSecondAssociatingFrameChosen(secondFrameIndex: Int) { - if (!isFirstAssociatingFrameChosen) + if (!isFirstAssociatingFrameChosen) { return + } if (firstAssociatingFrameIndex != secondFrameIndex) { associationManager.associate(firstAssociatingFrameIndex, secondFrameIndex) @@ -378,7 +379,8 @@ class SceneCanvas : OpenGLCanvas() { item("Clear associations").action { if (associationManager.associationConnections.any { it.firstFrameIndex == contextMenuInvokeFrameIndex || it.secondFrameIndex == contextMenuInvokeFrameIndex - }) { + } + ) { associationManager.clearAssociation(contextMenuInvokeFrameIndex) } } @@ -434,17 +436,16 @@ class SceneCanvas : OpenGLCanvas() { return shaderVector } - // Returns a frame position in screen coordinates without taking into account the camera position. - fun getGlobalFrameScreenPosition(frameIndexCoordinates: Vector2i, framesSize: Vector2i) : Vector2f { + fun getGlobalFrameScreenPosition(frameIndexCoordinates: Vector2i, framesSize: Vector2i): Vector2f { return Vector2f( - (framesSize.x.toFloat() + Renderer.getSpacingWidth(framesSize)) * frameIndexCoordinates.x , + (framesSize.x.toFloat() + Renderer.getSpacingWidth(framesSize)) * frameIndexCoordinates.x, (framesSize.y.toFloat() * (1f + Renderer.FramesSpacing)) * frameIndexCoordinates.y ) } // Returns a top left corner position in screen coordinates without taking into account the camera position. - fun getGlobalTopLeftCornerScreenPosition(window: Window, framesSize: Vector2i) : Vector2f { + fun getGlobalTopLeftCornerScreenPosition(window: Window, framesSize: Vector2i): Vector2f { val topLeftCornerShaderPosition = window.calculateTopLeftCornerShaderPosition() return shaderToFrameVector(topLeftCornerShaderPosition, framesSize).also { it.x *= framesSize.x @@ -457,7 +458,7 @@ class SceneCanvas : OpenGLCanvas() { frameIndexCoordinates: Vector2i, framesSize: Vector2i, window: Window - ) : Vector2f { + ): Vector2f { val globalFrameScreenPosition = getGlobalFrameScreenPosition(frameIndexCoordinates, framesSize) val globalTopLeftCornerScreenPosition = getGlobalTopLeftCornerScreenPosition(window, framesSize) diff --git a/src/main/kotlin/solve/rendering/engine/core/renderers/LandmarkLayerRenderer.kt b/src/main/kotlin/solve/rendering/engine/core/renderers/LandmarkLayerRenderer.kt index 3e1cc5cf..218f973c 100644 --- a/src/main/kotlin/solve/rendering/engine/core/renderers/LandmarkLayerRenderer.kt +++ b/src/main/kotlin/solve/rendering/engine/core/renderers/LandmarkLayerRenderer.kt @@ -1,6 +1,5 @@ package solve.rendering.engine.core.renderers -import org.joml.Vector2f import solve.rendering.canvas.SceneCanvas import solve.rendering.engine.Window import solve.rendering.engine.utils.plus diff --git a/src/main/kotlin/solve/rendering/engine/core/renderers/PointAssociationsRenderer.kt b/src/main/kotlin/solve/rendering/engine/core/renderers/PointAssociationsRenderer.kt index 0aab9b2e..73a9a285 100644 --- a/src/main/kotlin/solve/rendering/engine/core/renderers/PointAssociationsRenderer.kt +++ b/src/main/kotlin/solve/rendering/engine/core/renderers/PointAssociationsRenderer.kt @@ -88,7 +88,7 @@ class PointAssociationsRenderer( linePoints.forEachIndexed { sideIndex, linePoint -> val pointToVertexVector = Vector2f(normalVector) * AssociationLineWidth / window.camera.zoom / - DefaultLocalVerticesPositionsDivider + DefaultLocalVerticesPositionsDivider val upperVertexPosition = linePoint + pointToVertexVector val bottomVertexPosition = linePoint - pointToVertexVector diff --git a/src/main/kotlin/solve/scene/view/SceneView.kt b/src/main/kotlin/solve/scene/view/SceneView.kt index 387405cf..fdd98aa8 100644 --- a/src/main/kotlin/solve/scene/view/SceneView.kt +++ b/src/main/kotlin/solve/scene/view/SceneView.kt @@ -8,8 +8,6 @@ import solve.rendering.canvas.SceneCanvas import solve.rendering.engine.core.input.MouseButton import solve.scene.SceneFacade import solve.scene.controller.SceneController -import solve.scene.model.Landmark -import solve.scene.model.VisualizationFrame import tornadofx.View import tornadofx.onChange import javafx.scene.input.MouseButton as JavaFXMouseButton diff --git a/src/main/kotlin/solve/scene/view/association/AssociationLine.kt b/src/main/kotlin/solve/scene/view/association/AssociationLine.kt index 56177529..7628f8ef 100644 --- a/src/main/kotlin/solve/scene/view/association/AssociationLine.kt +++ b/src/main/kotlin/solve/scene/view/association/AssociationLine.kt @@ -1,6 +1,5 @@ package solve.scene.view.association -import org.joml.Vector2i import solve.scene.model.Landmark data class AssociationLine( diff --git a/src/main/kotlin/solve/scene/view/association/AssociationManager.kt b/src/main/kotlin/solve/scene/view/association/AssociationManager.kt index 9acfa7a4..4f4f9e1b 100644 --- a/src/main/kotlin/solve/scene/view/association/AssociationManager.kt +++ b/src/main/kotlin/solve/scene/view/association/AssociationManager.kt @@ -26,7 +26,8 @@ class AssociationManager { val secondFramePointLayers = secondFrame.layers.filterIsInstance() if (associatingKeypointLayerIndex !in firstFrameKeypointLayers.indices || - associatingKeypointLayerIndex !in secondFramePointLayers.indices) { + associatingKeypointLayerIndex !in secondFramePointLayers.indices + ) { println("There are no point layer with a given index to associate!") return } @@ -42,7 +43,8 @@ class AssociationManager { val firstKeypoint = firstFrameKeypoints[firstFrameKeypointUID] ?: return@forEach val secondKeypoint = secondFrameKeypoints[firstFrameKeypointUID] ?: return@forEach - associationLines.add(AssociationLine( + associationLines.add( + AssociationLine( firstFrameKeypointUID, firstFrameIndex, secondFrameIndex, @@ -54,14 +56,18 @@ class AssociationManager { } _associationConnections.add( AssociationConnection( - firstFrameIndex, secondFrameIndex, associatingKeypointLayerIndex, associationLines) + firstFrameIndex, + secondFrameIndex, + associatingKeypointLayerIndex, + associationLines + ) ) } fun clearAssociation(frameIndex: Int, associatedKeypointLayerIndex: Int = 0) { _associationConnections.removeAll { it.keypointLayerIndex == associatedKeypointLayerIndex && - (it.firstFrameIndex == frameIndex || it.secondFrameIndex == frameIndex) + (it.firstFrameIndex == frameIndex || it.secondFrameIndex == frameIndex) } } -} \ No newline at end of file +}