Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve naming of hasTransferFunction.range property to make its function clear and avoid confusion with minDisplayRange and maxDisplayRange #785

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/graphics/scenery/volumes/BufferedVolume.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class BufferedVolume(val ds: VolumeDataSource.RAISource<*>, options: VolumeViewe
else -> throw java.lang.IllegalStateException("Can't determine density for ${ds.type.javaClass.simpleName} data")
}

val transferRangeMax = range.second
val transferRangeMax = displayRangeLimits.second

val final = transferFunction.evaluate(s / transferRangeMax)
logger.info("Sample at $index is $s, final is $final $transferRangeMax")
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/graphics/scenery/volumes/DisplayRangeEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ class DisplayRangeEditor(private val tfContainer: HasTransferFunction): JPanel()
// Range editor
val initMinValue = max(tfContainer.minDisplayRange.toInt(), 100)
minText = JTextField(initMinValue.toString())
minValueLabel = JLabel(String.format("%.1f", tfContainer.range.first))
minValueLabel = JLabel(String.format("%.1f", tfContainer.displayRangeLimits.first))

val initMaxValue = max(tfContainer.maxDisplayRange.toInt(), 100)
maxText = JTextField(initMaxValue.toString())
maxText.horizontalAlignment = SwingConstants.RIGHT
maxValueLabel = JLabel(String.format("%.1f", tfContainer.range.second))
maxValueLabel = JLabel(String.format("%.1f", tfContainer.displayRangeLimits.second))

rangeSlider = RangeSlider()
rangeSlider.minimum = tfContainer.range.first.roundToInt()
rangeSlider.maximum = tfContainer.range.second.roundToInt()
rangeSlider.minimum = tfContainer.displayRangeLimits.first.roundToInt()
rangeSlider.maximum = tfContainer.displayRangeLimits.second.roundToInt()
rangeSlider.value = tfContainer.minDisplayRange.toInt()
rangeSlider.upperValue = tfContainer.maxDisplayRange.toInt()

Expand Down Expand Up @@ -90,8 +90,8 @@ class DisplayRangeEditor(private val tfContainer: HasTransferFunction): JPanel()
private fun updateConverter() {
minText.text = rangeSlider.value.toString()
maxText.text = rangeSlider.upperValue.toString()
minValueLabel.text = String.format("%.1f", tfContainer.range.first)
maxValueLabel.text = String.format("%.1f", tfContainer.range.second)
minValueLabel.text = String.format("%.1f", tfContainer.displayRangeLimits.first)
maxValueLabel.text = String.format("%.1f", tfContainer.displayRangeLimits.second)

tfContainer.minDisplayRange = rangeSlider.value.toFloat()
tfContainer.maxDisplayRange = rangeSlider.upperValue.toFloat()
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/graphics/scenery/volumes/DummyVolume.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class DummyVolume(val counterStart : Int = 0) : DefaultNode("DummyVolume"), HasT
modifiedAt = System.nanoTime()
}

/** A pair containing the min and max display range. */
override var range: Pair<Float, Float> = Pair<Float, Float>(minDisplayRange,maxDisplayRange)
/** A pair containing the min and max display range limits. */
override var displayRangeLimits: Pair<Float, Float> = Pair<Float, Float>(minDisplayRange,maxDisplayRange)
get() = field
set(m) {
field = m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ interface HasTransferFunction {
var transferFunction : TransferFunction
var minDisplayRange : Float
var maxDisplayRange : Float
var range: Pair<Float, Float>

/**
* The allowed value range for [minDisplayRange] and [maxDisplayRange]. Eg. 0 and Short.MAX_VALUE
*/
var displayRangeLimits: Pair<Float, Float>

/**
* Load transfer function and display range from file that was written by [HasTransferFunction.saveTransferFunctionToFile]
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/graphics/scenery/volumes/Volume.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ open class Volume(
get() = converterSetups.getOrNull(0)?.displayRangeMax?.toFloat() ?: throw IllegalStateException()
set(value) { setTransferFunctionRange(minDisplayRange, value) }

override var range: Pair<Float, Float>
override var displayRangeLimits: Pair<Float, Float>
get() = when(dataSource) {
VolumeDataSource.NullSource -> 0.0f to 0.0f
is VolumeDataSource.RAISource<*> -> dataSource.type.toRange()
Expand Down
Loading