Skip to content

Commit

Permalink
echosounder/sidescan/SidescanPanel: Reverting slider to control sides…
Browse files Browse the repository at this point in the history
…can window (commit 367f047).
  • Loading branch information
paulosousadias committed Feb 2, 2024
1 parent e4ec066 commit 4e7274c
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ void updateImage(long currentTime, long lastUpdateTime) {

sidescanParams.setNormalization(config.normalization);
sidescanParams.setTvgGain(config.tvgGain);
sidescanParams.setMinValue(config.sliceMinValue);
sidescanParams.setWindowValue(config.sliceWindowValue);

boolean autoEGN = toolbar.btnAutoEgn.isSelected();
boolean logarithmicDecompression = toolbar.btnLogarithmicDecompression.isSelected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public class SidescanToolbar extends JToolBar {
final JSpinner spinLogarithmicDecompression = new JSpinner();
private final SpinnerNumberModel modelLogarithmicDecompression = new SpinnerNumberModel(1.7, 0.0, 100.0, 0.1);

RangeSlider windowSlider = new RangeSlider(0, 100);

JButton btnConfig = new JButton(new AbstractAction(I18n.textc("Config", "Configuration")) {
private static final long serialVersionUID = -878895322319699542L;

Expand Down Expand Up @@ -156,9 +154,6 @@ public void stateChanged(ChangeEvent e) {
boolean btnState = !btnAutoEgn.isSelected();
spinNormalization.setEnabled(btnState);
spinTVG.setEnabled(btnState);
windowSlider.setEnabled(btnState);
//btnLogarithmicDecompression.setEnabled(btnState);
//spinLogarithmicDecompression.setEnabled(btnState);
}
};

Expand Down Expand Up @@ -197,71 +192,6 @@ private void buildToolbar() {
btnLogarithmicDecompression.setToolTipText("Logarithmic Decompression");
add(btnLogarithmicDecompression);

windowSlider.setToolTipText(String.format("<html><p>%s</p><p>%s<br/>%s<br/>%s</p>", I18n.text("Window slider"),
I18n.text("Left/right keys for lower value change"),
I18n.text("Shift+left/right keys for upper value change"),
I18n.text("Control+left/right keys for window value change")));
windowSlider.setUpperValue(100);
windowSlider.setValue(0);
windowSlider.setMinorTickSpacing(5);
windowSlider.setMajorTickSpacing(20);
windowSlider.addKeyListener(new KeyAdapter() {
RangeSlider slider = windowSlider;
@Override
public void keyPressed(KeyEvent e) {
slider.setValueIsAdjusting(true);
switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
case KeyEvent.VK_DOWN:
case KeyEvent.VK_KP_DOWN:
if (e.isShiftDown())
slider.setUpperValue(slider.getUpperValue() - slider.getMinorTickSpacing());
else if (e.isControlDown()) {
int delta = slider.getUpperValue() - slider.getValue();
slider.setValue(slider.getValue() - slider.getMinorTickSpacing());
slider.setUpperValue(slider.getValue() + delta);
}
else
slider.setValue(slider.getValue() - slider.getMinorTickSpacing());
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
case KeyEvent.VK_UP:
case KeyEvent.VK_KP_UP:
if (e.isShiftDown())
slider.setUpperValue(slider.getUpperValue() + slider.getMinorTickSpacing());
else if (e.isControlDown()) {
int delta = slider.getUpperValue() - slider.getValue();
slider.setUpperValue(slider.getUpperValue() + slider.getMinorTickSpacing());
slider.setValue(slider.getUpperValue() - delta);
}
else
slider.setValue(slider.getValue() + slider.getMinorTickSpacing());
break;
default:
break;
}
e.consume();
super.keyPressed(e);
}
public void keyReleased(KeyEvent e) {
slider.setValueIsAdjusting(false);
}
});
windowSlider.addChangeListener(e -> {
double selMin = windowSlider.getValue() / 100.0;
double selMax = windowSlider.getUpperValue() / 100.0;
if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
for (SidescanPanel panel : panelList) {
panel.config.sliceMinValue = selMin;
panel.config.sliceWindowValue = selMax - selMin;
panel.config.validateValues();
}
}
});
add(windowSlider);

addSeparator();
add(btnConfig);
add(btnRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ public class SidescanConfig implements PropertiesProvider {
@NeptusProperty (name="Time Variable Gain factor", category="Visualization parameters")
public double tvgGain = 280;

@NeptusProperty (name="Slice Minimum Value", category="Visualization parameters",
description = "Trim values between this minimum and the window. Values in [0.0; 1.0].")
public double sliceMinValue = 0.0;

@NeptusProperty (name="Slice Window Size", category="Visualization parameters",
description = "Trim values between minimum and this window (max = min + window). Values in [0.0; 1.0].")
public double sliceWindowValue = 1.0;

@NeptusProperty (name="Logarithmic Decompression Factor", category = "Visualization parameters")
public double logartihmicDecompression = 1.7;

Expand Down Expand Up @@ -103,8 +95,6 @@ protected void loadProps() {
}

public void validateValues() {
sliceMinValue = Math.min(1, Math.max(0, sliceMinValue));
sliceWindowValue = Math.min(1 - sliceMinValue, Math.max(0, sliceWindowValue));
}

public void saveProps() {
Expand Down
27 changes: 1 addition & 26 deletions src/java/pt/lsts/neptus/mra/api/SidescanParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
public class SidescanParameters {
private double normalization = 0.2;
private double tvgGain = 75;
private double minValue = 0.0;
private double windowValue = 1.0;


/**
* @param normalization
* @param tvgGain
Expand All @@ -52,13 +50,6 @@ public SidescanParameters(double normalization, double tvgGain) {
this.tvgGain = tvgGain;
}

public SidescanParameters(double normalization, double tvgGain, double minValue, double windowValue) {
this.normalization = normalization;
this.tvgGain = tvgGain;
this.minValue = minValue;
this.windowValue = windowValue;
}

/**
* @return the normalization
*/
Expand Down Expand Up @@ -86,20 +77,4 @@ public double getTvgGain() {
public void setTvgGain(double tvgGain) {
this.tvgGain = tvgGain;
}

public double getMinValue() {
return minValue;
}

public void setMinValue(double minValue) {
this.minValue = minValue;
}

public double getWindowValue() {
return windowValue;
}

public void setWindowValue(double windowValue) {
this.windowValue = windowValue;
}
}
11 changes: 1 addition & 10 deletions src/java/pt/lsts/neptus/mra/api/SidescanUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,6 @@ private static double[] applyNormalizationAndTVGMethod1(double[] data, double ra
avgPboard /= (double) middle * sidescanParams.getNormalization();
avgSboard /= (double) middle * sidescanParams.getNormalization();

// applying slide window
double minVal = MathMiscUtils.round(Math.min(1, Math.max(0, sidescanParams.getMinValue())), 2);
double maxVal = MathMiscUtils.round(Math.min(1 - minVal, Math.max(0, minVal + sidescanParams.getWindowValue())), 2);

for (int c = 0; c < data.length; c++) {
double r;
double avg;
Expand All @@ -414,12 +410,7 @@ private static double[] applyNormalizationAndTVGMethod1(double[] data, double ra
}
double gain = Math.abs(30.0 * Math.log(r));
double pb = data[c] * Math.pow(10, gain / sidescanParams.getTvgGain());
double v = pb / avg;

if ((minVal > 0 || maxVal < 1) && !Double.isNaN(v) && Double.isFinite(v)) {
v = (v - minVal) / (maxVal - minVal);
}
outData[c] = v;
outData[c] = pb / avg;
}

return outData;
Expand Down

0 comments on commit 4e7274c

Please sign in to comment.