Skip to content

Commit

Permalink
The visual representation of the GPR pane made more consistent with t…
Browse files Browse the repository at this point in the history
…hat of the CSV pane.
  • Loading branch information
a-kogun committed Dec 22, 2024
1 parent 1702070 commit e9a0ecb
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 1,228 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
</build>

<dependencies>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>org.jfree.fxgraphics2d</artifactId>
<version>2.1.4</version>
</dependency>
<!-- Core JavaFX modules -->
<dependency>
<groupId>org.openjfx</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.List;

import com.ugcs.gprvisualizer.app.ScrollableData;
import com.ugcs.gprvisualizer.gpr.Model;
import com.ugcs.gprvisualizer.gpr.Settings;
import javafx.geometry.Point2D;

public class ProfileField extends ScrollableData {
Expand All @@ -31,6 +33,46 @@ public class ProfileField extends ScrollableData {
private int visibleStart;
//private int visibleFinish;

private int maxHeightInSamples = 0;
private Settings profileSettings = new Settings();


public int getMaxHeightInSamples() {
return maxHeightInSamples;
}

public void updateMaxHeightInSamples() {

//set index of traces
int maxHeight = 0;
for (int i = 0; i < getGprTracesCount(); i++) {
Trace tr = getGprTraces().get(i);
maxHeight = Math.max(maxHeight, tr.getNormValues().length);
}

this.maxHeightInSamples = maxHeight;
getProfileSettings().maxsamples = maxHeightInSamples;


if (getProfileSettings().getLayer() + getProfileSettings().hpage > maxHeightInSamples) {
getProfileSettings().setLayer(maxHeightInSamples / 4);
getProfileSettings().hpage = maxHeightInSamples / 4;
}

}

public Settings getProfileSettings() {
return profileSettings;
}

public List<Trace> getGprTraces() {
return model.getFileManager().getGprTraces();
}

public int getGprTracesCount() {
return getGprTraces().size();
}

public ProfileField(Model model) {
this.model = model;
}
Expand Down Expand Up @@ -76,9 +118,8 @@ public void clear() {
}

private void fitFull() {
setMiddleTrace(model.getGprTracesCount() / 2);
int maxSamples = model.getMaxHeightInSamples();
fit(maxSamples * 2, model.getGprTracesCount());
setMiddleTrace(getGprTracesCount() / 2);
fit(maxHeightInSamples * 2, getGprTracesCount());
}

public void fit(int maxSamples, int tracesCount) {
Expand Down Expand Up @@ -144,8 +185,8 @@ public void setStartSample(int startSample) {

public Dimension getScreenImageSize() {
return new Dimension(
(int) (model.getGprTracesCount() * getHScale()),
(int) (model.getMaxHeightInSamples() * getVScale()));
(int) (getGprTracesCount() * getHScale()),
(int) (getMaxHeightInSamples() * getVScale()));
}

public Dimension getViewDimension() {
Expand All @@ -154,16 +195,19 @@ public Dimension getViewDimension() {

public void setViewDimension(Dimension viewDimension) {
this.viewDimension = viewDimension;

int leftMargin = 30;
int ruleWidth = 90;

infoRect = new Rectangle(0, 0, Model.TOP_MARGIN - 1, Model.TOP_MARGIN - 1);
topRuleRect = new Rectangle(Model.TOP_MARGIN, 0, viewDimension.width - Model.TOP_MARGIN, Model.TOP_MARGIN - 1);
leftRuleRect = new Rectangle(0, Model.TOP_MARGIN - 1, Model.TOP_MARGIN-1, viewDimension.height - Model.TOP_MARGIN);
mainRectRect = new Rectangle(Model.TOP_MARGIN, Model.TOP_MARGIN, viewDimension.width - Model.TOP_MARGIN, viewDimension.height - Model.TOP_MARGIN);
topRuleRect = new Rectangle(leftMargin, 0, viewDimension.width - leftMargin - ruleWidth, Model.TOP_MARGIN - 1);
infoRect = new Rectangle(leftMargin + topRuleRect.width, 0, Model.TOP_MARGIN - 1, Model.TOP_MARGIN - 1);
leftRuleRect = new Rectangle(leftMargin + topRuleRect.width, Model.TOP_MARGIN, ruleWidth, viewDimension.height - leftMargin);
mainRectRect = new Rectangle(leftMargin, Model.TOP_MARGIN, viewDimension.width - leftMargin - ruleWidth, viewDimension.height - leftMargin);

visibleStart = -mainRectRect.x -mainRectRect.width / 2;

initClipRects();
}
}

public double getAspect() {
return aspect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public boolean mouseReleaseHandle(Point2D localPoint, ScrollableData profField)
mouseInput.mouseReleaseHandle(localPoint, profField);
mouseInput = null;

profileView.getImageView().setCursor(Cursor.DEFAULT);
profileView.setCursor(Cursor.DEFAULT);
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
return true;
}
Expand All @@ -278,11 +278,11 @@ public boolean mouseMoveHandle(Point2D localPoint, ScrollableData profField) {
return true;
} else {
if (aboveControl(localPoint, profField)) {
profileView.getImageView().setCursor(Cursor.MOVE);
profileView.setCursor(Cursor.MOVE);
} else if (aboveElement(localPoint, profField)) {
profileView.getImageView().setCursor(Cursor.HAND);
profileView.setCursor(Cursor.HAND);
} else {
profileView.getImageView().setCursor(Cursor.DEFAULT);
profileView.setCursor(Cursor.DEFAULT);
}
}
return false;
Expand Down
95 changes: 1 addition & 94 deletions src/main/java/com/ugcs/gprvisualizer/app/OptionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ private List<Node> getPositionCsvButtons(PositionFile positionFile) {

vBox.setStyle(BORDER_STYLING);

vBox.getChildren().addAll(
List.of(new Label("Elevation source: " + getSourceName(positionFile))));
vBox.getChildren().add(new Label("Elevation source: " + getSourceName(positionFile)));

vBox.getChildren().addAll(levelFilter.getToolNodes2());

Expand Down Expand Up @@ -573,98 +572,6 @@ public void handle(ActionEvent event) {

return btn;
}

private void prepareTab2(Tab tab2) {

showGreenLineBtn.setTooltip(new Tooltip("Show/hide anomaly probability chart"));
showGreenLineBtn.setSelected(model.getSettings().showGreenLine);
showGreenLineBtn.setOnAction(e -> {
model.getSettings().showGreenLine = showGreenLineBtn.isSelected();
//eventPublisher.publishEvent(new WhatChanged(Change.justdraw));
});


VBox t2 = new VBox(10);
t2.getChildren().addAll(profileView.getRightSearch());

ToggleButton shEdge;
t2.getChildren().addAll(
//new HBox(

// commandRegistry.createAsinqTaskButton(
// expHoughScan,
// e -> radarMap.selectAlgMode()
// )

// ,
// commandRegistry.createAsinqTaskButton(
// houghScan,
// e -> radarMap.selectAlgMode()
// )
//),

//new HBox(
// commandRegistry.createAsinqTaskButton(
// new AlgorithmicScanFull(),
// e -> radarMap.selectAlgMode()
// ),
// commandRegistry.createAsinqTaskButton(
// new PluginRunner(model),
// e -> {}
// )
//),

//commandRegistry.createAsinqTaskButton(
// new AlgorithmicScan()),

new HBox(
prepareToggleButton("Hyperbola detection mode",
"hypLive.png",
model.getSettings().getHyperliveview(),
e -> {
//eventPublisher.publishEvent(new WhatChanged(Change.justdraw));

profileView.getPrintHoughSlider().requestFocus();
}),
showGreenLineBtn),



//new HBox(
// commandRegistry.createButton(
// new EdgeFinder()),
// commandRegistry.createButton(
// new EdgeSubtractGround())
// ),
new HBox(
shEdge =
uiUtils.prepareToggleButton("show edge", null,
model.getSettings().showEdge,
WhatChanged.Change.justdraw),

uiUtils.prepareToggleButton("show good", null,
model.getSettings().showGood,
WhatChanged.Change.justdraw)
),
commandRegistry.createButton(new TraceStacking()),
commandRegistry.createButton(new LevelScanHP(),
e -> {
//eventPublisher.publishEvent(new WhatChanged(Change.justdraw));
//levelCalculated = true;
//updateButtons();
})


);



// KeyCombination kc = new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN);
// Mnemonic mn = new Mnemonic(shEdge, kc); // you can also use kp
// AppContext.scene.addMnemonic(mn);

tab2.setContent(t2);
}

@EventListener
private void handleFileSelectedEvent(FileSelectedEvent event) {
Expand Down
Loading

0 comments on commit e9a0ecb

Please sign in to comment.