Skip to content

Commit

Permalink
Make newest sciview compatible with local scenery (stupid jackson)
Browse files Browse the repository at this point in the history
  • Loading branch information
smlpt committed Aug 26, 2024
1 parent 6d94bbd commit 8c6c93a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
88 changes: 45 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,29 @@ dependencies {
val isRelease: Boolean
get() = System.getProperty("release") == "true"

kotlin {
jvmToolchain(21)
// compilerOptions {
// jvmTarget = JvmTarget.JVM_21
// freeCompilerArgs = listOf("-Xinline-classes", "-opt-in=kotlin.RequiresOptIn")
// }
}

java {
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
}
//kotlin {
// jvmToolchain(21)
//// compilerOptions {
//// jvmTarget = JvmTarget.JVM_21
//// freeCompilerArgs = listOf("-Xinline-classes", "-opt-in=kotlin.RequiresOptIn")
//// }
//}
//
//java {
// targetCompatibility = JavaVersion.VERSION_21
// sourceCompatibility = JavaVersion.VERSION_21
//}

tasks {
// withType<KotlinCompile>().all {
// val version = System.getProperty("java.version").substringBefore('.').toInt()
// val default = if (version == 1) "21" else "$version"
// kotlinOptions {
// jvmTarget = project.properties["jvmTarget"]?.toString() ?: default
// freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn")
// }
//// sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default
// }
withType<KotlinCompile>().all {
val version = System.getProperty("java.version").substringBefore('.').toInt()
val default = if (version == 1) "21" else "$version"
kotlinOptions {
jvmTarget = project.properties["jvmTarget"]?.toString() ?: default
freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn")
}
// sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default
}
test {
finalizedBy(jacocoTestReport) // report is always generated after tests run
}
Expand Down Expand Up @@ -428,30 +428,32 @@ tasks {

register<JavaExec>(name = "run") {
classpath = sourceSets.main.get().runtimeClasspath
if (project.hasProperty("target")) {
project.property("target")?.let { target ->
classpath = sourceSets.test.get().runtimeClasspath

println("Target is $target")
// if(target.endsWith(".kt")) {
// main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt")
// } else {
// main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java")
// }

mainClass.set("$target")
val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") }

val additionalArgs = System.getenv("SCENERY_JVM_ARGS")
allJvmArgs = if (additionalArgs != null) {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs
} else {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") }
}
var target: Any? = null
if (project.hasProperty("target"))
target = project.property("target")
target = "StartEyeTrackingDirectlyKt"
if (target != null) {
classpath = sourceSets.test.get().runtimeClasspath

println("Target is $target")
// if(target.endsWith(".kt")) {
// main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt")
// } else {
// main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java")
// }

mainClass.set("$target")
val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") }

println("Will run target $target with classpath $classpath, main=${mainClass.get()}")
println("JVM arguments passed to target: $allJvmArgs")
val additionalArgs = System.getenv("SCENERY_JVM_ARGS")
allJvmArgs = if (additionalArgs != null) {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs
} else {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") }
}

println("Will run target $target with classpath $classpath, main=${mainClass.get()}")
println("JVM arguments passed to target: $allJvmArgs")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-XX:MaxMetaspaceSize=2g
org.gradle.caching=true
jvmTarget=21
#useLocalScenery=true
useLocalScenery=true
kotlinVersion=1.9.23
dokkaVersion=1.9.10
scijavaParentPOMVersion=37.0.0
Expand Down
51 changes: 25 additions & 26 deletions src/test/kotlin/sc/iview/StartEyeTrackingDirectly.kt
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
package sc.iview

import graphics.scenery.utils.lazyLogger
import graphics.scenery.volumes.RAIVolume
import graphics.scenery.volumes.TransferFunction
import org.scijava.command.CommandService
import org.scijava.ui.UIService
import sc.iview.SciView
import sc.iview.commands.demo.advanced.EyeTrackingDemo

object StartEyeTrackingDirectly {
//object StartEye {

val logger by lazyLogger()
// val logger by lazyLogger()

@JvmStatic
fun main(args: Array<String>) {
val sv = SciView.create()
val context = sv.scijavaContext
val uiService = context?.service(UIService::class.java)
uiService?.showUI()
// @JvmStatic
fun main() {
val sv = SciView.create()
val context = sv.scijavaContext
val uiService = context?.service(UIService::class.java)
uiService?.showUI()

sv.open("C:/Software/datasets/MastodonTutorialDataset1/datasethdf5.xml")
val volumes = sv.findNodes { it.javaClass == RAIVolume::class.java }
volumes.first().let {
it as RAIVolume
it.minDisplayRange = 400f
it.maxDisplayRange = 1500f
val tf = TransferFunction()
tf.addControlPoint(0f, 0f)
tf.addControlPoint(1f, 1f)
it.transferFunction = tf
}
sv.open("C:/Software/datasets/MastodonTutorialDataset1/datasethdf5.xml")
val volumes = sv.findNodes { it.javaClass == RAIVolume::class.java }
volumes.first().let {
it as RAIVolume
it.minDisplayRange = 400f
it.maxDisplayRange = 1500f
val tf = TransferFunction()
tf.addControlPoint(0f, 0f)
tf.addControlPoint(1f, 1f)
it.transferFunction = tf
}

val command = sv.scijavaContext!!.getService(CommandService::class.java)
val argmap = HashMap<String, Any>()
command.run(EyeTrackingDemo::class.java, true, argmap)
val command = sv.scijavaContext!!.getService(CommandService::class.java)
val argmap = HashMap<String, Any>()
command.run(EyeTrackingDemo::class.java, true, argmap)

}
}
}
//}

0 comments on commit 8c6c93a

Please sign in to comment.