Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 8962a443 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'group_models' into develop

# Conflicts:
#	VadereSimulator/src/org/vadere/simulator/projects/ScenarioRun.java
parents 9cad2a18 b1c53536
Pipeline #61709 passed with stage
in 51 seconds
......@@ -23,10 +23,12 @@ VadereSimulator/resources/current_commit_hash.txt
#model test output
VadereModelTests/TestOSM/output/*
VadereModelTests/TestOSM_Group/output/*
VadereModelTests/TestSFM/output/*
VadereModelTests/TestGNM/output/*
VadereModelTests/TestOVM/output/*
VadereModelTests/TestOSM/processed output/*
VadereModelTests/TestOSM_Group/processed output/*
VadereModelTests/TestSFM/processed output/*
VadereModelTests/TestGNM/processed output/*
VadereModelTests/TestOVM/processed output/*
......
......@@ -217,6 +217,7 @@ PostVis.chbShowObstacles.text=Show Obstacles
PostVis.chbShowTargets.text=Show Targets
PostVis.chbShowSources.text=Show Sources
PostVis.chbShowStairs.text=Show Stairs
PostVis.btnSnapshot.tooltip=Snapshot
PostVis.btnPNGSnapshot.tooltip=PNG Snapshot
PostVis.btnSVGSnapshot.tooltip=SVG Snapshot
PostVis.btnTikZSnapshot.tooltip=TikZ Snapshot
......@@ -255,6 +256,7 @@ SettingsDialog.menuOpenFloorFieldFile.title=Add Floor Field File...
View.btnDrawVoronoiDiagram.tooltip=Draw and display a Voronoi Diagram
View.chbLogo.text=Show the Vadere logo
View.btnShowWalkingDirection.tooltip=Show the walking direction of all pedestrians
View.btnShowGroupInformation.tooltip=Draw pedestrians within one group with same shape and color
View.btnShowPedestrian.tooltip=Show Pedestrians
View.btnShowPotentialfield.tooltip=Show Potential Field (only possible after adding potential field file)
View.btnShowTrajectories.tooltip=Show Trajectories
......
......@@ -217,9 +217,10 @@ PostVis.chbShowObstacles.text=Hindernisse anzeigen
PostVis.chbShowTargets.text=Ziele anzeigen
PostVis.chbShowSources.text=Quellen anzeigen
PostVis.chbShowStairs.text=Treppen anzeigen
PostVis.btnSnapshot.tooltip=Snapshot
PostVis.btnPNGSnapshot.tooltip=PNG-Snapshot
PostVis.btnSVGSnapshot.tooltip=SVG-Snapshot
PostVis.btnTikZSnapshot.tooltip=TikZ Snapshot
PostVis.btnTikZSnapshot.tooltip=TikZ-Snapshot
PostVis.menuFile.title=Datei
PostVis.menuSettings.title=Einstellungen
PostVis.menuRecentFiles.title=K\u00FCrzlich verwendete Dateien
......@@ -255,6 +256,7 @@ SettingsDialog.menuOpenFloorFieldFile.title=Floor Field-Datei hinzuf\u00fcgen...
View.btnDrawVoronoiDiagram.tooltip=Voronoi-Diagramm zeichnen und anzeigen
View.chbLogo.text=VADERE-Logo anzeigen
View.btnShowWalkingDirection.tooltip=Gehrichtung aller Fu\u00dfg\u00e4nger anzeigen
View.btnShowGroupInformation.tooltip=Zeichne Fu\u00dfg\u00e4nger einer Gruppe mit denn selben Formen und Farben
View.btnShowPedestrian.tooltip=Fu\u00dfg\u00e4nger anzeigen
View.btnShowPotentialfield.tooltip=Potenzialfeld anzeigen (nur m\u00f6glich, nachdem eine Datei f\u00fcr das Potenzialfeld hinzugef\u00fcgt wurde)
View.btnShowTrajectories.tooltip=Trajektorien anzeigen
......
......@@ -22,6 +22,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private boolean showTrajectories = false;
private boolean showGrid = false;
private boolean showDensity = false;
private boolean showGroups = false;
protected final Color pedestrianDefaultColor = Color.BLUE;
public DefaultSimulationConfig() {
......@@ -37,6 +38,15 @@ public class DefaultSimulationConfig extends DefaultConfig {
this.showPedestrians = config.showPedestrians;
this.showLogo = config.showLogo;
this.showStairs = config.showStairs;
this.showGroups = config.showGroups;
}
public boolean isShowGroups() {
return showGroups;
}
public void setShowGroups(boolean showGroups) {
this.showGroups = showGroups;
}
public boolean isShowLogo() {
......
......@@ -106,8 +106,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
}
@Override
public void removeUpdate(DocumentEvent e)
{
public void removeUpdate(DocumentEvent e) {
updateModel();
}
......
......@@ -16,6 +16,7 @@ import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.components.utils.CLGaussianCalculator;
import org.vadere.gui.components.utils.ColorHelper;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.renderer.agent.AgentRender;
import org.vadere.state.scenario.Agent;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VTriangle;
......@@ -35,12 +36,14 @@ public abstract class SimulationRenderer extends DefaultRenderer {
private ColorHelper colorHelper;
private Color lastDensityColor = null;
private int topographyId;
private AgentRender agentRender;
public SimulationRenderer(final SimulationModel model) {
super(model);
this.model = model;
this.topographyId = -1;
this.colorHelper = new ColorHelper(40);
this.agentRender = new AgentRender(model);
}
@Override
......@@ -205,4 +208,12 @@ public abstract class SimulationRenderer extends DefaultRenderer {
private float getGridLineWidth() {
return (float) (0.5 / model.getScaleFactor());
}
public AgentRender getAgentRender() {
return agentRender;
}
public void setAgentRender(AgentRender agentRender) {
this.agentRender = agentRender;
}
}
\ No newline at end of file
......@@ -36,7 +36,8 @@ public class OnlineVisualization implements PassiveCallback {
private OnlineVisualisationWindow onlineVisualisationPanel;
private OnlineVisualizationModel model;
private Topography scenario;
private @Nullable IPotentialFieldTarget potentialFieldTarget;
private @Nullable
IPotentialFieldTarget potentialFieldTarget;
private boolean enableVisualization;
public OnlineVisualization(boolean enableVisualization) {
......
......@@ -12,6 +12,7 @@ import org.vadere.gui.postvisualization.utils.SVGGenerator;
import org.vadere.gui.postvisualization.utils.TikzGenerator;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.SimpleDateFormat;
......@@ -55,5 +56,6 @@ public class ActionGenerateTikz extends AbstractAction implements IRendererChang
}
@Override
public void update(SimulationRenderer renderer) {}
public void update(SimulationRenderer renderer) {
}
}
package org.vadere.gui.onlinevisualization.control;
import org.vadere.gui.postvisualization.control.ActionVisualization;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.List;
import javax.swing.*;
public class ActionOnlineVisMenu extends AbstractAction {
private final List<Action> actions;
private JPopupMenu menu;
private Component parent;
public ActionOnlineVisMenu(final String name, Icon icon, final List<Action> actions) {
super(name, icon);
this.actions = actions;
}
public void setParent(Component parent) {
this.parent = parent;
}
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (menu == null) {
menu = new JPopupMenu();
for (Action action : actions) {
menu.add(action);
}
}
menu.show(parent, 0, parent.getHeight());
}
});
}
}
......@@ -3,8 +3,6 @@ package org.vadere.gui.onlinevisualization.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.*;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
import org.vadere.gui.components.control.PanelResizeListener;
......@@ -18,14 +16,18 @@ import org.vadere.gui.components.view.SimulationInfoPanel;
import org.vadere.gui.onlinevisualization.control.ActionGeneratePNG;
import org.vadere.gui.onlinevisualization.control.ActionGenerateSVG;
import org.vadere.gui.onlinevisualization.control.ActionGenerateTikz;
import org.vadere.gui.onlinevisualization.control.ActionOnlineVisMenu;
import org.vadere.gui.onlinevisualization.control.ActionShowPotentialField;
import org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
import javax.swing.*;
public class OnlineVisualisationWindow extends JPanel implements Observer {
private static final long serialVersionUID = 3522170593760789565L;
......@@ -102,6 +104,15 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
}
};
AbstractAction showGroupInformationAction = new AbstractAction("showGroupInformationAction",
resources.getIcon("group.png", iconWidth, iconHeight)) {
@Override
public void actionPerformed(ActionEvent e) {
model.config.setShowGroups(!model.config.isShowGroups());
model.notifyObservers();
}
};
AbstractAction paintGridAction = new AbstractAction("paintGridAction",
resources.getIcon("grid.png", iconWidth, iconHeight)) {
......@@ -139,20 +150,20 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
};
ActionGeneratePNG generatePNG = new ActionGeneratePNG(
"generatePNG",
Messages.getString("PostVis.btnPNGSnapshot.tooltip"),
resources.getIcon("camera_png.png", iconWidth, iconHeight),
new OnlinevisualizationRenderer(model),
model);
ActionGenerateSVG generateSVG = new ActionGenerateSVG(
"generateSVG",
Messages.getString("PostVis.btnSVGSnapshot.tooltip"),
resources.getIcon("camera_svg.png", iconWidth, iconHeight),
new OnlinevisualizationRenderer(model),
model);
ActionGenerateTikz generateTikz = new ActionGenerateTikz(
"generateTikz",
Messages.getString("PostVis.btnTikZSnapshot.tooltip"),
resources.getIcon("camera_tikz.png", iconWidth, iconHeight),
new OnlinevisualizationRenderer(model),
model);
......@@ -174,6 +185,8 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
Messages.getString("View.btnShowTrajectories.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintArrowAction,
Messages.getString("View.btnShowWalkingDirection.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction,
Messages.getString("View.btnShowGroupInformation.tooltip"));
toolbar.addSeparator();
......@@ -182,9 +195,18 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
toolbar.addSeparator();
SwingUtils.addActionToToolbar(toolbar, generatePNG, Messages.getString("PostVis.btnPNGSnapshot.tooltip"));
SwingUtils.addActionToToolbar(toolbar, generateSVG, Messages.getString("PostVis.btnSVGSnapshot.tooltip"));
SwingUtils.addActionToToolbar(toolbar, generateTikz, Messages.getString("PostVis.btnTikzSnapshot.tooltip"));
ArrayList<Action> imgOptions = new ArrayList<>();
imgOptions.add(generatePNG);
imgOptions.add(generateSVG);
imgOptions.add(generateTikz);
ActionOnlineVisMenu imgDialog = new ActionOnlineVisMenu(
"camera_menu",
resources.getIcon("camera.png", iconWidth, iconHeight), imgOptions);
JButton imgMenuBtn =
SwingUtils.addActionToToolbar(toolbar, imgDialog, "PostVis.btnSnapshot.tooltip");
imgDialog.setParent(imgMenuBtn);
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
add(toolbar, cc.xyw(2, 2, 3));
......@@ -192,6 +214,9 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
scrollPane.setPreferredSize(new Dimension(1, windowHeight));
add(jsonPanel, cc.xy(4, 4));
add(infoPanel, cc.xyw(2, 6, 3));
repaint();
revalidate();
}
@Override
......
......@@ -8,6 +8,7 @@ import java.util.Map;
import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel;
import org.vadere.gui.renderer.agent.AgentRender;
import org.vadere.state.scenario.Agent;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -55,10 +56,11 @@ public class OnlinevisualizationRenderer extends SimulationRenderer {
}
private void renderPedestrians(final Graphics2D g) {
AgentRender agentRender = getAgentRender();
g.setColor(model.config.getPedestrianDefaultColor());
for (Agent ped : model.getAgents()) {
VPoint position = ped.getPosition();
g.fill(ped.getShape());
agentRender.render(ped, g);
if (!pedestrianPositions.containsKey(ped.getId())) {
pedestrianPositions.put(ped.getId(), new LinkedList());
......
......@@ -8,6 +8,7 @@ import org.vadere.gui.postvisualization.utils.TikzGenerator;
import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.SimpleDateFormat;
......
package org.vadere.gui.postvisualization.control;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.List;
import javax.swing.*;
public class ActionVisualizationMenu extends ActionVisualization {
private final List<Action> actions;
private JPopupMenu menu;
private Component parent;
private final ActionVisualization action;
public ActionVisualizationMenu(String name, Icon icon, PostvisualizationModel model,
final ActionVisualization action,
final List<Action> actions) {
super(name, icon, model);
this.action = action;
this.actions = actions;
}
public ActionVisualizationMenu(String name, PostvisualizationModel model,
final ActionVisualization action,
final List<Action> actions) {
super(name, model);
this.action = action;
this.actions = actions;
}
public void setParent(Component parent) {
this.parent = parent;
}
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (menu == null) {
menu = new JPopupMenu();
for (Action action : actions) {
menu.add(action);
}
}
menu.show(parent, 0, parent.getHeight());
}
});
// action.actionPerformed(e);
}
}
......@@ -2,6 +2,7 @@ package org.vadere.gui.postvisualization.utils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.components.view.SimulationRenderer;
......@@ -22,12 +23,10 @@ import static java.awt.geom.PathIterator.*;
* @see PathIterator This PathSeparator must be converted into its TikZ
* representation.
*
* For example, traversing a Java path with PathIterator returns two
* segments:
* For example, traversing a Java path with PathIterator returns two segments:
*
*
* segment type= 0 (SEG_MOVETO) with coords: [1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
* segment type= 3 (SEG_LINETO) with coords: [2.0, 2.0, 0.0, 0.0, 0.0, 0.0]
* segment type = 0 (SEG_MOVETO) with coords: [1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
* segment type = 3 (SEG_LINETO) with coords: [2.0, 2.0, 0.0, 0.0, 0.0, 0.0]
*
* This must be transformed to TikZ:
*
......@@ -75,7 +74,7 @@ public class TikzGenerator {
tikzCode += generateTikzColorDefinitions(model);
tikzCode += convertScenarioElementsToTikz();
String output = (generateCompleteDocument) ? String.format(texTemplate, tikzCode) : tikzCode ;
String output = (generateCompleteDocument) ? String.format(texTemplate, tikzCode) : tikzCode;
// TODO: maybe uses Java's resources notation (in general, writing the file should be done by the caller not here).
try {
......@@ -167,15 +166,44 @@ public class TikzGenerator {
// TODO: maybe, draw also trajectories.
if (config.isShowPedestrians()) {
generatedCode += "% Agents\n";
generatedCode += drawAgents(config);
} else {
generatedCode = "% Agents (not enabled in config)\n";
}
return generatedCode;
}
@NotNull
private String drawAgents(DefaultSimulationConfig config) {
String generatedCode = "";
for (Agent agent : model.getAgents()) {
if (model.getConfig().isShowGroups()) {
try {
Pedestrian pedestrian = (Pedestrian) agent;
Color pedestrianColor = renderer.getAgentRender().getColor(pedestrian);
Shape pedestrianShape = renderer.getAgentRender().getShape(pedestrian);
String colorString = String.format("{rgb,255:red,%d; green,%d; blue,%d}", pedestrianColor.getRed(), pedestrianColor.getGreen(), pedestrianColor.getBlue());
generatedCode += String.format("\\fill[fill=%s] %s\n", colorString, generatePathForShape(pedestrianShape));
} catch (ClassCastException cce) {
logger.error("Error casting to Pedestrian");
cce.printStackTrace();
// TODO: render agent as circle!
}
} else {
String agentTextPattern = "\\fill[AgentColor] (%f,%f) circle [radius=%fcm];\n";
generatedCode += String.format(agentTextPattern, agent.getPosition().x, agent.getPosition().y, agent.getRadius());
}
if (model.isElementSelected() && model.getSelectedElement().equals(agent)) {
String agentTextPattern = "\\draw[magenta] (%f,%f) circle [radius=%fcm];\n";
generatedCode += String.format(agentTextPattern, agent.getPosition().x, agent.getPosition().y, agent.getRadius());
}
// Do not draw agents as path for performance reasons. Usually, agents have a circular shape.
// generatedCode += String.format("\\fill[AgentColor] %s\n", generatePathForScenarioElement(agent));
}
} else {
generatedCode += "% Agents (not enabled in config)\n";
}
return generatedCode;
}
......@@ -197,6 +225,23 @@ public class TikzGenerator {
return generatedPath;
}
private String generatePathForShape(Shape shape) {
String generatedPath = "";
AffineTransform noTransformation = new AffineTransform();
PathIterator pathIterator = shape.getPathIterator(noTransformation);
while (!pathIterator.isDone()) {
float[] coords = new float[6];
int type = pathIterator.currentSegment(coords);
generatedPath += convertJavaToTikzPath(type, coords);
pathIterator.next();
}
return generatedPath;
}
private String convertJavaToTikzPath(int type, float[] coords) {
if (type < SEG_MOVETO || type > SEG_CLOSE) {
throw new IllegalStateException(String.format("Cannot process path segment type: %d (coordinates: %s)", type, Arrays.toString(coords)));
......
......@@ -13,6 +13,7 @@ import org.vadere.gui.components.utils.ColorHelper;
import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.gui.renderer.agent.AgentRender;
import org.vadere.state.scenario.Agent;
import org.vadere.state.simulation.Step;
import org.vadere.state.simulation.Trajectory;
......@@ -70,6 +71,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
private void renderTrajectory(final Graphics2D g, final Color color, final Trajectory trajectory, final Step step) {
Optional<Agent> optionalPedestrian = trajectory.getAgent(step);
AgentRender agentRender = getAgentRender();
if (optionalPedestrian.isPresent()) {
Agent pedestrian = optionalPedestrian.get();
......@@ -88,7 +90,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
// renderImage the pedestrian
if (model.config.isShowPedestrians()) {
if (model.config.isShowFaydedPedestrians() || !trajectory.isPedestrianDisappeared(step)) {
g.fill(pedestrian.getShape());
agentRender.render(pedestrian, g);
if (model.config.isShowPedestrianIds()) {
DefaultRenderer.paintAgentId(g, pedestrian);
}
......
......@@ -26,6 +26,7 @@ import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Observer;
import java.util.prefs.Preferences;
......@@ -190,6 +191,17 @@ public class PostvisualizationWindow extends JPanel implements Observer {
}, "View.btnShowWalkingDirection.tooltip");
addActionToToolbar(toolbar,
new ActionVisualization("show_groups",
resources.getIcon("group.png", iconWidth, iconHeight), model) {
@Override
public void actionPerformed(ActionEvent e) {
model.config.setShowGroups(!model.config.isShowGroups());
model.notifyObservers();
}
}, "View.btnShowGroupInformation.tooltip");
addActionToToolbar(toolbar,
new ActionSwapSelectionMode("draw_voronoi_diagram",
resources.getIcon("voronoi.png", iconWidth, iconHeight), model),
......@@ -236,21 +248,25 @@ public class PostvisualizationWindow extends JPanel implements Observer {
recordAction.setButton(recordButton);
toolbar.addSeparator(new Dimension(5, 50));
addActionToToolbar(
toolbar,
new ActionGeneratePNG("png_snapshot", resources.getIcon("camera_png.png", iconWidth, iconHeight),
renderer),
"PostVis.btnPNGSnapshot.tooltip");
addActionToToolbar(
toolbar,
new ActionGenerateSVG("svg_snapshot", resources.getIcon("camera_svg.png", iconWidth, iconHeight),
renderer),
"PostVis.btnSVGSnapshot.tooltip");
addActionToToolbar(
toolbar,
new ActionGenerateTikz("tikz_snapshot", resources.getIcon("camera_tikz.png", iconWidth, iconHeight),
renderer),
"PostVis.btnTikZSnapshot.tooltip");
ArrayList<Action> imgOptions = new ArrayList<>();
ActionVisualization pngImg = new ActionGeneratePNG(Messages.getString("PostVis.btnPNGSnapshot.tooltip"), resources.getIcon("camera_png.png", iconWidth, iconHeight),
renderer);
ActionVisualization svgImg = new ActionGenerateSVG(Messages.getString("PostVis.btnSVGSnapshot.tooltip"), resources.getIcon("camera_svg.png", iconWidth, iconHeight),
renderer);
ActionVisualization tikzImg = new ActionGenerateTikz(Messages.getString("PostVis.btnTikZSnapshot.tooltip"), resources.getIcon("camera_tikz.png", iconWidth, iconHeight),
renderer);
// add new ImageGenerator Action ...
imgOptions.add(pngImg);
imgOptions.add(svgImg);
imgOptions.add(tikzImg);
// add Action to List ....