Skip to content

Commit 3451df5

Browse files
Clean up custom inspector panels
1 parent 3db4344 commit 3451df5

File tree

6 files changed

+28
-47
lines changed

6 files changed

+28
-47
lines changed

src/main/kotlin/sc/iview/commands/edit/BasicProperties.kt

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@ package sc.iview.commands.edit
3030

3131
import graphics.scenery.*
3232
import graphics.scenery.attribute.material.HasMaterial
33-
import net.imagej.lut.LUTService
3433
import okio.withLock
3534
import org.joml.Quaternionf
3635
import org.joml.Vector3f
3736
import org.scijava.command.Command
3837
import org.scijava.plugin.Parameter
3938
import org.scijava.plugin.Plugin
40-
import org.scijava.ui.UIService
4139
import org.scijava.util.ColorRGB
4240
import org.scijava.widget.ChoiceWidget
4341
import org.scijava.widget.NumberWidget
4442
import sc.iview.event.NodeChangedEvent
4543
import java.util.*
4644

45+
const val GROUP_NAME_BASIC = "group:Basic Properties"
46+
const val GROUP_NAME_ROTATION = "group:Rotation & Scaling"
47+
4748
/**
4849
* A command for interactively editing a node's properties.
4950
*
@@ -54,52 +55,45 @@ import java.util.*
5455
*/
5556
@Plugin(type = Command::class, initializer = "updateCommandFields", visible = false)
5657
class BasicProperties : InspectorInteractiveCommand() {
57-
@Parameter
58-
private lateinit var uiSrv: UIService
59-
60-
@Parameter
61-
private lateinit var lutService: LUTService
62-
6358
/* Basic properties */
6459

6560
@Parameter(required = false, style = ChoiceWidget.LIST_BOX_STYLE, callback = "refreshSceneNodeInDialog")
6661
private val sceneNode: String? = null
6762

68-
@Parameter(label = "Visible", callback = "updateNodeProperties", style = "group:Basic")
63+
@Parameter(label = "Visible", callback = "updateNodeProperties", style = GROUP_NAME_BASIC)
6964
private var visible = false
7065

71-
@Parameter(label = "Color", required = false, callback = "updateNodeProperties", style = "group:Basic")
72-
private var colour: ColorRGB? = null
66+
@Parameter(label = "Color", required = false, callback = "updateNodeProperties", style = GROUP_NAME_BASIC)
67+
private var color: ColorRGB? = null
7368

74-
@Parameter(label = "Name", callback = "updateNodeProperties", style = "group:Basic")
69+
@Parameter(label = "Name", callback = "updateNodeProperties", style = GROUP_NAME_BASIC)
7570
private var name: String = ""
7671

77-
@Parameter(label = "Position X", style = NumberWidget.SPINNER_STYLE+ ",group:Basic" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
72+
@Parameter(label = "Position X", style = NumberWidget.SPINNER_STYLE + "," + GROUP_NAME_BASIC + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
7873
private var positionX = 0f
7974

80-
@Parameter(label = "Position Y", style = NumberWidget.SPINNER_STYLE+ ",group:Basic" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
75+
@Parameter(label = "Position Y", style = NumberWidget.SPINNER_STYLE + "," + GROUP_NAME_BASIC + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
8176
private var positionY = 0f
8277

83-
@Parameter(label = "Position Z", style = NumberWidget.SPINNER_STYLE+ ",group:Basic" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
78+
@Parameter(label = "Position Z", style = NumberWidget.SPINNER_STYLE + "," + GROUP_NAME_BASIC + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
8479
private var positionZ = 0f
8580

86-
87-
@Parameter(label = "[Rotation & Scaling]Scale X", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
81+
@Parameter(label = "Scale X", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
8882
private var scaleX = 1f
8983

90-
@Parameter(label = "[Rotation & Scaling]Scale Y", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
84+
@Parameter(label = "Scale Y", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
9185
private var scaleY = 1f
9286

93-
@Parameter(label = "[Rotation & Scaling]Scale Z", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
87+
@Parameter(label = "Scale Z", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", stepSize = "0.1", callback = "updateNodeProperties")
9488
private var scaleZ = 1f
9589

96-
@Parameter(label = "[Rotation & Scaling]Rotation Phi", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
90+
@Parameter(label = "Rotation Phi", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
9791
private var rotationPhi = 0f
9892

99-
@Parameter(label = "[Rotation & Scaling]Rotation Theta", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
93+
@Parameter(label = "Rotation Theta", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
10094
private var rotationTheta = 0f
10195

102-
@Parameter(label = "[Rotation & Scaling]Rotation Psi", style = NumberWidget.SPINNER_STYLE+"group:Rotation & Scaling" + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
96+
@Parameter(label = "Rotation Psi", style = NumberWidget.SPINNER_STYLE + GROUP_NAME_ROTATION + ",format:0.000", min = PI_NEG, max = PI_POS, stepSize = "0.01", callback = "updateNodeProperties")
10397
private var rotationPsi = 0f
10498

10599

@@ -168,7 +162,7 @@ class BasicProperties : InspectorInteractiveCommand() {
168162
else -> Vector3f(0.5f)
169163
}
170164

171-
colour = ColorRGB(
165+
color = ColorRGB(
172166
(colourVector[0] * 255).toInt(), //
173167
(colourVector[1] * 255).toInt(), //
174168
(colourVector[2] * 255).toInt()
@@ -209,9 +203,9 @@ class BasicProperties : InspectorInteractiveCommand() {
209203

210204
// update colour
211205
val cVector = Vector3f(
212-
colour!!.red / 255f,
213-
colour!!.green / 255f,
214-
colour!!.blue / 255f
206+
color!!.red / 255f,
207+
color!!.green / 255f,
208+
color!!.blue / 255f
215209
)
216210
if(node is PointLight) {
217211
node.emissionColor = cVector

src/main/kotlin/sc/iview/commands/edit/InspectorInteractiveCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class InspectorInteractiveCommand : InteractiveCommand() {
5959
val item = info.getMutableInput(name, type) ?: return
6060
info.removeInput(item)
6161
} catch (npe: NullPointerException) {
62-
log.info("Input field $name of type ${type.simpleName} not found, therefore it can't be removed.")
62+
log.debug("Input field $name of type ${type.simpleName} not found, therefore it can't be removed. This is normal if the panel is collapsed.")
6363
return
6464
}
6565
}

src/main/kotlin/sc/iview/commands/edit/ResetScene.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ import sc.iview.commands.MenuWeights.EDIT_RESET_SCENE
4444
*/
4545
@Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "Edit", weight = EDIT), Menu(label = "Reset Scene", weight = EDIT_RESET_SCENE)])
4646
class ResetScene : Command {
47-
@Parameter
48-
private lateinit var logService: LogService
49-
5047
@Parameter
5148
private lateinit var sciView: SciView
5249

src/main/kotlin/sc/iview/commands/edit/SlicingPlaneProperties.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ import org.scijava.ui.UIService
1414
*/
1515
@Plugin(type = Command::class, initializer = "updateCommandFields", visible = false)
1616
class SlicingPlaneProperties : InspectorInteractiveCommand() {
17-
@Parameter
18-
private lateinit var uiSrv: UIService
19-
20-
@Parameter
21-
private lateinit var lutService: LUTService
22-
2317
/* Targets properties */
2418
@Parameter(label = "Sliced volumes", callback = "updateNodeProperties", style = "group:Targets")
2519
private var slicedVolumes: VolumeSelectorWidget.VolumeSelection = VolumeSelectorWidget.VolumeSelection()

src/main/kotlin/sc/iview/commands/edit/TextBoardProperties.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class TextBoardProperties : InspectorInteractiveCommand() {
4343
node.backgroundColor.z().toInt() * 255
4444
)
4545
transparentBackground = node.transparent > 0
46+
47+
maybeRemoveInput("color", ColorRGB::class.java)
4648
}
4749
}
4850

src/main/kotlin/sc/iview/commands/edit/VolumeProperties.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
package sc.iview.commands.edit
22

33
import graphics.scenery.volumes.Volume
4-
import net.imagej.lut.LUTService
54
import okio.withLock
65
import org.scijava.ItemVisibility
76
import org.scijava.command.Command
87
import org.scijava.plugin.Parameter
98
import org.scijava.plugin.Plugin
10-
import org.scijava.ui.UIService
119
import org.scijava.widget.Button
1210
import org.scijava.widget.ChoiceWidget
1311
import org.scijava.widget.NumberWidget
1412

13+
const val PLAY_PAUSE_BUTTON_NAME = "playPauseButton"
1514
/**
1615
* Inspector panel for [Volume] nodes.
1716
*/
1817
@Plugin(type = Command::class, initializer = "updateCommandFields", visible = false)
1918
class VolumeProperties : InspectorInteractiveCommand() {
20-
@Parameter
21-
private lateinit var uiSrv: UIService
22-
23-
@Parameter
24-
private lateinit var lutService: LUTService
25-
2619
/* Basic properties */
2720

2821
@Parameter(required = false, style = ChoiceWidget.LIST_BOX_STYLE, callback = "refreshSceneNodeInDialog")
@@ -62,6 +55,7 @@ class VolumeProperties : InspectorInteractiveCommand() {
6255
}
6356

6457
/** Plays a volume time series, if the volume has more than one timepoint. */
58+
@Suppress("unused")
6559
fun playTimeSeries() {
6660
if (currentSceneNode !is Volume) {
6761
return
@@ -85,7 +79,7 @@ class VolumeProperties : InspectorInteractiveCommand() {
8579
}
8680
}
8781
}
88-
info.getMutableInput("playPauseButton", Button::class.java).label = "Pause"
82+
info.getMutableInput(PLAY_PAUSE_BUTTON_NAME, Button::class.java).label = "Pause"
8983
timeSeriesPlayer!!.start()
9084
} else {
9185
try {
@@ -94,7 +88,7 @@ class VolumeProperties : InspectorInteractiveCommand() {
9488
e.printStackTrace()
9589
}
9690
timeSeriesPlayer = null
97-
info.getMutableInput("playPauseButton", Button::class.java).setLabel("Play")
91+
info.getMutableInput(PLAY_PAUSE_BUTTON_NAME, Button::class.java).setLabel("Play")
9892
}
9993
}
10094

@@ -126,7 +120,7 @@ class VolumeProperties : InspectorInteractiveCommand() {
126120
// reverts to the Kotlin types and you'll end up with interesting error messages
127121
// like "float does not match type float" ;-)
128122
maybeRemoveInput("timepoint", java.lang.Integer::class.java)
129-
maybeRemoveInput("playPauseButton", Button::class.java)
123+
maybeRemoveInput(PLAY_PAUSE_BUTTON_NAME, Button::class.java)
130124
maybeRemoveInput("playSpeed", java.lang.Integer::class.java)
131125
}
132126
}

0 commit comments

Comments
 (0)