The name of the initial branch for new projects is now "main" instead of "master". Existing projects remain unchanged. More information: https://doku.lrz.de/display/PUBLIC/GitLab

Commit 560f50e1 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

Merge branch 'develop' into 'processor_test'

# Conflicts:
#   .gitignore
parents ab0e0d72 deec92bf
......@@ -30,6 +30,7 @@ VadereModelTests/TestOSM/processed output/*
VadereModelTests/TestSFM/processed output/*
VadereModelTests/TestGNM/processed output/*
VadereModelTests/TestOVM/processed output/*
VadereUtils/output/*
#deprecated: can potentially be removed
bin/
......@@ -38,6 +39,5 @@ VadereGui/output/
#mac osx files
.DS_Store
#kde dolphin file explorere dot files
**/*.directory
#linux deskopt dotfiles
**/.directory
......@@ -6,5 +6,6 @@ unit_tests_with_coverage:
# Here you can execute arbitrate terminal commands.
# If any of the commands returns a non zero exit code the job fails.
script:
- mvn clean
- mvn test
\ No newline at end of file
......@@ -73,6 +73,25 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-vadere-console</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>org.vadere.simulator.entrypoints.VadereConsole</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>vadere-console</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
<execution>
<id>build-vadere</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
......
......@@ -207,6 +207,8 @@ PostVis.menuCloseFloorFieldFile.title=Remove Floor Field File
OnlineVis.btnShowPotentialfield.tooltip=Show the Target Potential Field for the selected Agent
TopographyBoundDialog.title = Set Topography Bounds
InformationDialogError.title=Internal Error
InformationDialogFileError=Could not load file!
LoadingDialog.title=Loading...
......@@ -252,6 +254,7 @@ TopographyCreator.btnUndo.tooltip=Undo
TopographyCreator.btnRedo.tooltip=Redo
TopographyCreator.btnCutTopography.tooltip=Cut Scenario
TopographyCreator.btnInsertPedestrian.tooltip=Pedestrian
TopographyCreator.btnTopographyBound.tooltip=Topography Bound
TopographyCreator.btnInsertObstacle.tooltip=Obstacle
TopographyCreator.btnInsertTarget.tooltip=Target
TopographyCreator.btnInsertSource.tooltip=Source
......
......@@ -206,6 +206,8 @@ PostVis.menuCloseFloorFieldFile.title=Floor Field-Datei l\u00F6schen
OnlineVis.btnShowPotentialfield.tooltip=Zeigt das Zielpotenzialfeld des ausgew\u00E4hlten Agenten
TopographyBoundDialog.title = Setze Topographie Grenzen
InformationDialogError.title=Interner Fehelr
InformationDialogFileError=Datei konnte nicht geladen werden!
LoadingDialog.title=Lade...
......@@ -253,6 +255,7 @@ TopographyCreator.btnCutTopography.tooltip=Szenario ausschneiden
TopographyCreator.btnInsertPedestrian.tooltip=Fu\u00dfg\u00e4nger
TopographyCreator.btnInsertObstacle.tooltip=Hindernis
TopographyCreator.btnInsertTarget.tooltip=Ziel
TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze
TopographyCreator.btnInsertSource.tooltip=Quelle
TopographyCreator.btnInsertStairs.tooltip=Treppen
TopographyCreator.btnErase.tooltip=Radierer
......
......@@ -73,9 +73,13 @@ public interface IDefaultModel<T extends DefaultConfig> extends Iterable<Scenari
*/
void setViewportBound(final Rectangle2D.Double viewportBound);
/**
* resets the scenarioSize to the original scenario size.
*/
void resetTopographySize();
/**
*
* @param viewportBound
*/
void fireChangeViewportEvent(final Rectangle2D.Double viewportBound);
......@@ -89,8 +93,7 @@ public interface IDefaultModel<T extends DefaultConfig> extends Iterable<Scenari
/**
* Sets the window bound.
*
* @param windowBound
*
*/
void setWindowBound(final Rectangle2D.Double windowBound);
......@@ -103,8 +106,7 @@ public interface IDefaultModel<T extends DefaultConfig> extends Iterable<Scenari
/**
* Tells the model that a element has been changed.
*
* @param element
*
*/
void setElementHasChanged(final ScenarioElement element);
......
......@@ -6,11 +6,13 @@ import java.util.function.Function;
import org.vadere.state.scenario.Agent;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
public abstract class SimulationModel<T extends DefaultSimulationConfig> extends DefaultModel {
public final T config;
@SuppressWarnings("unchecked")
public SimulationModel(final T config) {
super(config);
this.config = config;
......@@ -26,6 +28,11 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends
public abstract boolean isFloorFieldAvailable();
@Override
public void resetTopographySize() {
fireChangeViewportEvent(new VRectangle(getTopographyBound()));
}
public T getConfig() {
return config;
}
......
......@@ -7,6 +7,7 @@ import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
import org.vadere.gui.components.control.PanelResizeListener;
import org.vadere.gui.components.control.ViewportChangeListener;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.components.utils.SwingUtils;
......@@ -29,6 +30,7 @@ import org.vadere.gui.projectview.control.ActionDeselect;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.io.HashGenerator;
import org.vadere.simulator.projects.io.IOOutput;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.io.IOUtils;
import java.awt.*;
......@@ -63,7 +65,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
this(false, projectPath);
}
public PostvisualizationWindow(final boolean loadTopographyInformationsOnly, final String projectPath) {
private PostvisualizationWindow(final boolean loadTopographyInformationsOnly, final String projectPath) {
// 1. get data from the user screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
......@@ -137,16 +139,13 @@ public class PostvisualizationWindow extends JPanel implements Observer {
final String test = java.text.MessageFormat.format(Messages.getString("PostVis.about.text"), "0.1");
JButton infoButton = new JButton(new ImageIcon(Resources.class.getResource("/icons/info_icon.png")));
infoButton.setBorderPainted(false);
infoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String text = "<html><font size =\"5\"><b>"+Messages.getString("PostVis.title") + "</font></b><br>" +
"<font size =\"3\"><em>" + MessageFormat.format(Messages.getString("PostVis.version"), HashGenerator.releaseNumber()) + "</em></font><br>" +
"<font size =\"3\">" + MessageFormat.format(Messages.getString("PostVis.license.text"), "<a href=\"https://www.gnu.org/licenses/lgpl-3.0.txt\">LGPL</a>")+".</font></html>";
JOptionPane.showMessageDialog(null, text,
Messages.getString("PostVis.about.title"),
JOptionPane.INFORMATION_MESSAGE);
}
infoButton.addActionListener(e -> {
String text = "<html><font size =\"5\"><b>"+Messages.getString("PostVis.title") + "</font></b><br>" +
"<font size =\"3\"><em>" + MessageFormat.format(Messages.getString("PostVis.version"), HashGenerator.releaseNumber()) + "</em></font><br>" +
"<font size =\"3\">" + MessageFormat.format(Messages.getString("PostVis.license.text"), "<a href=\"https://www.gnu.org/licenses/lgpl-3.0.txt\">LGPL</a>")+".</font></html>";
JOptionPane.showMessageDialog(null, text,
Messages.getString("PostVis.about.title"),
JOptionPane.INFORMATION_MESSAGE);
});
/*
......@@ -178,7 +177,6 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
;
}, "View.btnShowPedestrian.tooltip");
addActionToToolbar(toolbar,
......@@ -190,7 +188,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
;
}, "View.btnShowTrajectories.tooltip");
addActionToToolbar(toolbar,
......@@ -202,7 +200,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
;
}, "View.btnShowWalkingDirection.tooltip");
addActionToToolbar(toolbar,
......@@ -226,7 +224,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
;
}, "View.btnShowGrid.tooltip");
addActionToToolbar(
......@@ -239,7 +237,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
;
}, "View.btnShowDensity.tooltip");
......@@ -312,12 +310,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
}
miGlobalSettings.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DialogFactory.createSettingsDialog(model).setVisible(true);
}
});
miGlobalSettings.addActionListener(e -> DialogFactory.createSettingsDialog(model).setVisible(true));
mFile.add(miLoadFile);
// mFile.add(miLoadFloorFile);
......@@ -333,7 +326,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
getActionMap().put("deselect", new ActionDeselect(model, this, null));
}
public JMenuBar getMenu() {
private JMenuBar getMenu() {
return menuBar;
}
......@@ -343,7 +336,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
model.notifyObservers();
}
public void loadOutputFile(final Scenario scenario) throws IOException {
public void loadOutputFile(final Scenario scenario) {
Player.getInstance(model).stop();
model.init(scenario, model.getOutputPath());
model.notifyObservers();
......@@ -354,6 +347,10 @@ public class PostvisualizationWindow extends JPanel implements Observer {
return SwingUtils.addActionToToolbar(toolbar, action, Messages.getString(toolTipProperty));
}
public IDefaultModel getDefaultModel(){
return this.model;
}
@Override
public void update(java.util.Observable o, Object arg) {
......
......@@ -21,6 +21,7 @@ import org.vadere.state.attributes.models.AttributesGNM;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.attributes.models.AttributesOVM;
import org.vadere.state.attributes.models.AttributesPotentialCompact;
import org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell;
import org.vadere.state.attributes.models.AttributesPotentialGNM;
import org.vadere.state.attributes.models.AttributesPotentialSFM;
import org.vadere.state.attributes.models.AttributesReynolds;
......@@ -48,7 +49,7 @@ public class ModelPresets {
// Optimal Steps Model
list.clear();
list.add(AttributesOSM.class);
list.add(AttributesPotentialCompact.class);
list.add(AttributesPotentialCompactSoftshell.class);
list.add(AttributesFloorField.class);
registerModelPreset(OptimalStepsModel.class, list);
......
......@@ -16,7 +16,6 @@ import org.vadere.state.scenario.Topography;
import org.vadere.state.util.StateJsonConverter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.beans.IntrospectionException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
......@@ -224,7 +223,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
if (isEditable) {
menusInTabs.forEach(menu -> menu.setEnabled(true));
try {
int index = tabbedPane.getSelectedIndex();
if (topographyCreatorView != null && tabbedPane.indexOfComponent(topographyCreatorView) >= 0) {
tabbedPane.removeTabAt(tabbedPane.indexOfComponent(topographyCreatorView));
......@@ -232,13 +231,11 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
topographyCreatorView = new TopographyWindow(scenario);
tabbedPane.addTab(Messages.getString("Tab.TopographyCreator.title"), topographyCreatorView);
setTopography(scenario.getTopography());
tabbedPane.validate();
tabbedPane.repaint();
tabbedPane.setSelectedIndex(index);
setTopography(scenario.getTopography());
} catch (IOException | IntrospectionException e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
}
} else {
menusInTabs.forEach(menu -> menu.setEnabled(false));
boolean topoWasSelected = false;
......@@ -252,7 +249,11 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
tabbedPane.setSelectedComponent(postVisualizationView);
}
}
tabbedPane.validate();
tabbedPane.repaint();
postVisualizationView.revalidate();
postVisualizationView.repaint(); // force a repaint, otherwise it sometimes only repaints when the mouse moves from the output table to the postvis-view
postVisualizationView.getDefaultModel().resetTopographySize();
}
this.attributesModelView.setVadereScenario(scenario);
......
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionResizeTopographyBound extends TopographyAction {
private TopographyAction action;
public ActionResizeTopographyBound(String name, ImageIcon icon, IDrawPanelModel<?> panelModel,
TopographyAction action) {
super(name, icon, panelModel);
this.action = action;
}
public ActionResizeTopographyBound(final String name, final IDrawPanelModel<?> panelModel,
TopographyAction action) {
super(name, panelModel);
this.action = action;
}
@Override
public void actionPerformed(ActionEvent e) {
//set to Selection to to be sure no accidental changes are introduced
action.actionPerformed(e);
TopographyCreatorModel model = (TopographyCreatorModel) getScenarioPanelModel();
ActionResizeTopographyBoundDialog dialog = new ActionResizeTopographyBoundDialog(
model.getTopography().getBounds().width,
model.getTopography().getBounds().height
);
if (dialog.getValue()){
model.setTopographyBound(dialog.getBound());
}
getScenarioPanelModel().notifyObservers();
}
}
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class ActionResizeTopographyBoundDialog {
JTextField textField;
VRectangle bound;
VRectangle boundOld;
boolean valid;
public ActionResizeTopographyBoundDialog(double width, double height){
textField = new JTextField();
textField.setText(String.format("%.3f x %.3f", width, height));
textField.getDocument().addDocumentListener(new DialogListener());
bound = new VRectangle(0.0,0.0, width, height);
boundOld = new VRectangle(0.0,0.0, width, height);
valid = false;
}
public VRectangle getBound() {
return valid ? bound : boundOld;
}
public boolean getValue(){
return JOptionPane.showConfirmDialog(
ProjectView.getMainWindow(),
textField,
"width x heigt",
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION;
}
private class DialogListener implements DocumentListener{
JTextField textField;
String text;
DialogListener(){
textField = ActionResizeTopographyBoundDialog.this.textField;
}
@Override
public void insertUpdate(DocumentEvent e) {
handle(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
handle(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
handle(e);
}
private void handle(DocumentEvent e){
text = textField.getText().replace(" ", "");
String[] tmp = text.split("x");
double width;
double height;
try {
width = Double.valueOf(tmp[0]);
height = Double.valueOf(tmp[1]);
ActionResizeTopographyBoundDialog.this.bound =
new VRectangle(0.0,0.0, width, height);
ActionResizeTopographyBoundDialog.this.valid = true;
textField.setForeground(Color.BLACK);
}catch (Exception ex){
ActionResizeTopographyBoundDialog.this.valid = false;
textField.setForeground(Color.RED);
}
}
}
}
......@@ -34,7 +34,7 @@ public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<
/**
* Part of the observer-pattern. Adds an observer that will be notified about the changes of
* this panelModel.
*
*
* @param observer the observer that will be notified about the change of this panelModel.
*/
void addObserver(Observer observer);
......@@ -83,10 +83,6 @@ public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<
@Override
void hideSelection();
/**
* resets the scenarioSize to the original scenario size.
*/
void resetTopographySize();
/**
* cleans the whole topography, after this call there is no topography element in the topography
......
......@@ -17,14 +17,15 @@
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesPotentialCompact" : {
"pedPotentialWidth" : 0.5,
"pedPotentialHeight" : 12.6,
"obstPotentialWidth" : 0.25,
"obstPotentialHeight" : 20.1,
"useHardBodyShell" : false,
"obstDistanceDeviation" : 0.0,
"visionFieldRadius" : 5.0
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
......@@ -41,8 +42,8 @@
"seeSmallWalls" : false,
"minimumStepLength" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompact",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompact",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ ]
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
......@@ -113,6 +114,222 @@
"type" : "RECTANGLE"
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : -1.0E-4,
"y" : -1.0E-4
}, {
"x" : 35.0001,
"y" : -1.0E-4
}, {
"x" : 35.0001,
"y" : 0.5001
}, {
"x" : -1.0E-4,
"y" : 0.5001
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 35.0001,
"y" : -1.0E-4
}, {
"x" : 35.0001,
"y" : 60.0001
}, {
"x" : 34.4999,
"y" : 60.0001
}, {
"x" : 34.4999,
"y" : -1.0E-4
} ]
},
"id" : -1