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

Loading GPR files will not unload others, and GPR file panes will be … #114

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.ugcs.gprvisualizer.app.auxcontrol.BaseObject;
import com.ugcs.gprvisualizer.draw.Layer;
import com.ugcs.gprvisualizer.draw.WhatChanged;
import com.ugcs.gprvisualizer.gpr.Model;

import javafx.geometry.Point2D;
Expand Down Expand Up @@ -59,19 +58,13 @@ public void draw(Graphics2D g2, MapField fixedField) {

}

@Override
public void somethingChanged(WhatChanged changed) {

}

@Override
public boolean mousePressed(Point2D point) {
for(BaseObject bo : model.getAuxElements()) {
if(bo.mousePressHandle(point, model.getMapField())) {
return true;
}
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

public class ProfileField extends ScrollableData {

public static final double ZOOM_A = 1.2;
public static final double ASPECT_A = 1.14;

private final Model model;

private int zoom = 1;
private double aspect = -15;

// screen coordinates
Expand All @@ -30,16 +28,18 @@ public class ProfileField extends ScrollableData {
private Rectangle clipInfoRect = new Rectangle();

//
public int visibleStart;
public int visibleFinish;

private double vertScale = 1;
private int visibleStart;
//private int visibleFinish;

public ProfileField(Model model) {
this.model = model;
}

/* public ProfileField(ProfileField copy) {
public int getVisibleStart() {
return visibleStart;
}

/* public ProfileField(ProfileField copy) {

this.model = copy.model;

Expand All @@ -65,9 +65,10 @@ public ProfileField(Model model) {
this.clipInfoRect = copy.clipInfoRect;
}*/

@Override
public void clear() {
zoom = 1;
aspect = -15;
super.clear();
aspect = -15;
startSample = 0;
if (model.isActive() && model.getGprTracesCount() > 0) {
fitFull();
Expand Down Expand Up @@ -172,15 +173,6 @@ public void setAspect(double aspect) {
this.aspect = aspect;
}

public int getZoom() {
return zoom;
}

public void setZoom(int zoom) {
this.zoom = zoom;
vertScale = Math.pow(ZOOM_A, getZoom());
}

public Rectangle getTopRuleRect() {
return topRuleRect;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
package com.github.thecoldwine.sigrun.common.ext;

public class TraceSample {

private int trace;
private int sample;

public TraceSample(int trace, int sample) {

this.setTrace(trace);
this.setSample(sample);

}

public record TraceSample (int trace, int sample) {
public int getTrace() {
return trace;
}

public void setTrace(int trace) {
this.trace = trace;
}

public int getSample() {
return sample;
}

public void setSample(int sample) {
this.sample = sample;
}
}
}
22 changes: 1 addition & 21 deletions src/main/java/com/ugcs/gprvisualizer/app/AppContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.Set;

import com.ugcs.gprvisualizer.app.intf.Status;
import com.ugcs.gprvisualizer.draw.SmthChangeListener;
import com.ugcs.gprvisualizer.draw.WhatChanged;
import com.ugcs.gprvisualizer.gpr.Model;

import javafx.application.Platform;
Expand All @@ -21,22 +19,4 @@ public class AppContext {
public static Model model;
public static Status status;

private static Set<SmthChangeListener> smthListener = new HashSet<>();

public static void setItems(Set<SmthChangeListener> it) {
smthListener = it;
}

public static void notifyAll(WhatChanged changed) {

Platform.runLater(() -> {
for (SmthChangeListener lst : AppContext.smthListener) {
try {
lst.somethingChanged(changed);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
}
68 changes: 36 additions & 32 deletions src/main/java/com/ugcs/gprvisualizer/app/AuxElementEditHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import com.ugcs.gprvisualizer.app.auxcontrol.BaseObjectImpl;
import com.ugcs.gprvisualizer.app.auxcontrol.ClickPlace;
import com.ugcs.gprvisualizer.event.FileOpenedEvent;
import com.ugcs.gprvisualizer.event.WhatChanged;
import javafx.geometry.Point2D;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import com.github.thecoldwine.sigrun.common.ext.CsvFile;
Expand All @@ -17,9 +21,6 @@
import com.github.thecoldwine.sigrun.common.ext.SgyFile;
import com.ugcs.gprvisualizer.app.auxcontrol.BaseObject;
import com.ugcs.gprvisualizer.app.auxcontrol.FoundPlace;
import com.ugcs.gprvisualizer.draw.Change;
import com.ugcs.gprvisualizer.draw.SmthChangeListener;
import com.ugcs.gprvisualizer.draw.WhatChanged;
import com.ugcs.gprvisualizer.gpr.Model;

import javafx.scene.Cursor;
Expand All @@ -32,17 +33,17 @@
import javafx.scene.layout.VBox;

@Component
public class AuxElementEditHandler extends BaseObjectImpl implements SmthChangeListener, InitializingBean {
public class AuxElementEditHandler extends BaseObjectImpl implements InitializingBean {

@Autowired
private ApplicationEventPublisher eventPublisher;

@Autowired
private Model model;

@Autowired
private ProfileView profileView;

@Autowired
private Broadcast broadcast;

private ProfileField field;
private BaseObject selected;
private BaseObject mouseInput;
Expand Down Expand Up @@ -87,7 +88,8 @@
}

if (processed) {
profileView.repaintEvent();
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
//profileView.repaintEvent();
}

return processed;
Expand Down Expand Up @@ -148,8 +150,8 @@
}

model.updateAuxElements();
profileView.repaintEvent();
broadcast.notifyAll(new WhatChanged(Change.justdraw));
//profileView.repaintEvent();
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
});

addFoundBtn.setOnAction(e -> {
Expand Down Expand Up @@ -189,7 +191,7 @@
}

protected void updateViews() {
broadcast.notifyAll(new WhatChanged(Change.justdraw));
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
}

private void clearAuxElements() {
Expand All @@ -211,9 +213,9 @@


model.updateAuxElements();
profileView.repaintEvent();
//profileView.repaintEvent();

broadcast.notifyAll(new WhatChanged(Change.justdraw));
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
}

private boolean processPress(List<BaseObject> controls2,
Expand Down Expand Up @@ -253,29 +255,26 @@
}
}

//@Override
public boolean mouseReleaseHandle(Point2D localPoint, ProfileField profField) {
@Override
public boolean mouseReleaseHandle(Point2D localPoint, ScrollableData profField) {

if (mouseInput != null) {
mouseInput.mouseReleaseHandle(localPoint, profField);
mouseInput = null;

profileView.getImageView().setCursor(Cursor.DEFAULT);

profileView.repaintEvent();
eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
return true;
}
return false;
}

//@Override
public boolean mouseMoveHandle(Point2D localPoint, ProfileField profField) {
@Override
public boolean mouseMoveHandle(Point2D localPoint, ScrollableData profField) {

if (mouseInput != null) {
mouseInput.mouseMoveHandle(localPoint, profField);

profileView.repaintEvent();

eventPublisher.publishEvent(new WhatChanged(this, WhatChanged.Change.justdraw));
return true;
} else {
if (aboveControl(localPoint, profField)) {
Expand All @@ -285,12 +284,11 @@
} else {
profileView.getImageView().setCursor(Cursor.DEFAULT);
}
}

}
return false;
}

private boolean aboveControl(Point2D localPoint, ProfileField profField) {
private boolean aboveControl(Point2D localPoint, ScrollableData profField) {
if (model.getControls() == null) {
return false;
}
Expand All @@ -303,7 +301,7 @@
return false;
}

private boolean aboveElement(Point2D localPoint, ProfileField profField) {
private boolean aboveElement(Point2D localPoint, ScrollableData profField) {
if (model.getAuxElements() == null) {
return false;
}
Expand Down Expand Up @@ -333,13 +331,19 @@
this.selected = selected;
}

@Override
public void somethingChanged(WhatChanged changed) {
if (changed.isFileopened() || changed.isTraceCut()) {

@EventListener
private void somethingChanged(WhatChanged changed) {

Check warning

Code scanning / PMD

Avoid unused private methods such as 'selectFile(FileSelectedEvent)'. Warning

Avoid unused private methods such as 'somethingChanged(WhatChanged)'.
if (changed.isTraceCut()) {
mouseInput = null;
setSelected(null);
model.setControls(null);
}
}
}

@EventListener
private void fileOpened(FileOpenedEvent fileOpenedEvent) {

Check warning

Code scanning / PMD

Avoid unused private methods such as 'selectFile(FileSelectedEvent)'. Warning

Avoid unused private methods such as 'fileOpened(FileOpenedEvent)'.

Check warning

Code scanning / PMD

Avoid unused method parameters such as 'document'. Warning

Avoid unused method parameters such as 'fileOpenedEvent'.
mouseInput = null;
setSelected(null);
model.setControls(null);
}
}
}
58 changes: 0 additions & 58 deletions src/main/java/com/ugcs/gprvisualizer/app/Broadcast.java

This file was deleted.

Loading
Loading