Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
3bd216e2
Commit
3bd216e2
authored
Nov 04, 2019
by
Benedikt Zoennchen
Browse files
Visualization: make interpolation configurable.
parent
4d57ac3d
Pipeline
#172965
passed with stages
in 153 minutes and 10 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereGui/resources/messages.properties
View file @
3bd216e2
...
...
@@ -214,6 +214,7 @@ ProjectView.mntmRunOutput.text=Run offline again
ProjectView.OpenInExplorer.text
=
Open in Explorer
ProjectView.mntmCopyOutputDir.text
=
Copy output path to clipboard
SettingsDialog.chbInterpolatePositions.text
=
Interpolate Positions
SettingsDialog.chbShowPedestrianIds.text
=
Show PedestrianIds
PostVis.chShowEvacTimeColor.text
=
Coloring by Evacuation Times
PostVis.chShowCriteriaColor.text
=
Coloring by Predicate
...
...
VadereGui/resources/messages_de_DE.properties
View file @
3bd216e2
...
...
@@ -216,6 +216,7 @@ ProjectView.mntmRunOutput.text=Offline erneut starten
ProjectView.OpenInExplorer.text
=
In Explorer
\u
00F6ffnen
ProjectView.mntmCopyOutputDir.text
=
Kopiere Output Pfad in Zwischenablage
SettingsDialog.chbInterpolatePositions.text
=
Interpoliere Positionen
SettingsDialog.chbShowPedestrianIds.text
=
Fu
\u
00dfg
\u
00E4nger-Ids anzeigen
PostVis.additional.border.text
=
PostVis
PostVis.chShowEvacTimeColor.text
=
F
\u
00e4rbe nach Evakuierungszeit
...
...
VadereGui/src/org/vadere/gui/components/model/DefaultSimulationConfig.java
View file @
3bd216e2
...
...
@@ -20,6 +20,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private
double
densityStandardDerivation
=
CONFIG
.
getDouble
(
"Density.standardDeviation"
);
private
double
pedestrianTorso
=
CONFIG
.
getDouble
(
"Pedestrian.radius"
)
*
2
;
private
boolean
interpolatePositions
=
true
;
private
boolean
showPedestrianIds
=
false
;
private
boolean
showTargets
=
true
;
private
boolean
showTargetChangers
=
true
;
...
...
@@ -293,7 +294,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
return
randomColors
.
get
(
pedId
);
}
public
void
setGridWidth
(
double
gridWidth
)
{
public
void
setGridWidth
(
final
double
gridWidth
)
{
this
.
gridWidth
=
gridWidth
;
}
...
...
@@ -321,4 +322,13 @@ public class DefaultSimulationConfig extends DefaultConfig {
return
false
;
}
public
boolean
isInterpolatePositions
()
{
return
interpolatePositions
;
}
public
void
setInterpolatePositions
(
final
boolean
interpolatePositions
)
{
this
.
interpolatePositions
=
interpolatePositions
;
setChanged
();
}
}
VadereGui/src/org/vadere/gui/components/model/SimulationModel.java
View file @
3bd216e2
...
...
@@ -32,6 +32,8 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends
public
abstract
Collection
<
Agent
>
getAgents
();
public
abstract
Collection
<
Pedestrian
>
getPedestrians
();
public
abstract
int
getTopographyId
();
public
abstract
double
getSimTimeInSec
();
...
...
VadereGui/src/org/vadere/gui/components/view/SettingsDialog.java
View file @
3bd216e2
...
...
@@ -331,10 +331,11 @@ public class SettingsDialog extends JDialog {
BorderFactory
.
createTitledBorder
(
Messages
.
getString
(
"SettingsDialog.additional.border.text"
)));
FormLayout
otherSettingsLayout
=
new
FormLayout
(
createCellsWithSeparators
(
4
),
// col
createCellsWithSeparators
(
1
5
));
// rows
createCellsWithSeparators
(
1
6
));
// rows
otherSettingsPane
.
setLayout
(
otherSettingsLayout
);
// For each scenario element, add a checkbox to toggle its visibility.
JCheckBox
chInterpolatePositions
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbInterpolatePositions.text"
)));
JCheckBox
chShowObstacles
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowObstacles.text"
)));
JCheckBox
chShowTargets
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowTargets.text"
)));
JCheckBox
chShowSources
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowSources.text"
)));
...
...
@@ -343,9 +344,14 @@ public class SettingsDialog extends JDialog {
JCheckBox
chShowStairs
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowStairs.text"
)));
JCheckBox
chShowTargetChangers
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowTargetChangers.text"
)));
JCheckBox
chShowPedIds
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbShowPedestrianIds.text"
)));
JCheckBox
chHideVoronoiDiagram
=
new
JCheckBox
((
Messages
.
getString
(
"SettingsDialog.chbHideVoronoiDiagram.text"
)));
chInterpolatePositions
.
setSelected
(
model
.
config
.
isInterpolatePositions
());
chInterpolatePositions
.
addItemListener
(
e
->
{
model
.
config
.
setInterpolatePositions
(!
model
.
config
.
isInterpolatePositions
());
model
.
notifyObservers
();
});
chHideVoronoiDiagram
.
setSelected
(!
model
.
isVoronoiDiagramVisible
());
chHideVoronoiDiagram
.
addItemListener
(
e
->
{
if
(
model
.
isVoronoiDiagramVisible
())
{
...
...
@@ -410,6 +416,7 @@ public class SettingsDialog extends JDialog {
int
colSpan
=
5
;
CellConstraints
cc
=
new
CellConstraints
();
otherSettingsPane
.
add
(
chInterpolatePositions
,
cc
.
xyw
(
column
,
row
+=
NEXT_CELL
,
colSpan
));
otherSettingsPane
.
add
(
chHideVoronoiDiagram
,
cc
.
xyw
(
column
,
row
+=
NEXT_CELL
,
colSpan
));
otherSettingsPane
.
add
(
chShowObstacles
,
cc
.
xyw
(
column
,
row
+=
NEXT_CELL
,
colSpan
));
otherSettingsPane
.
add
(
chShowTargets
,
cc
.
xyw
(
column
,
row
+=
NEXT_CELL
,
colSpan
));
...
...
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
View file @
3bd216e2
...
...
@@ -128,11 +128,11 @@ public abstract class SimulationRenderer extends DefaultRenderer {
graphics
.
dispose
();
}
protected
void
renderTrajectory
(
final
Graphics2D
g
,
final
java
.
util
.
List
<
VPoint
>
points
,
final
Agent
pedestrain
)
{
protected
void
renderTrajectory
(
final
Graphics2D
g
,
final
java
.
util
.
List
<
VPoint
>
points
,
final
Pedestrian
pedestrain
)
{
renderTrajectory
(
g
,
points
.
stream
(),
pedestrain
);
}
protected
void
renderTrajectory
(
final
Graphics2D
g
,
final
Stream
<
VPoint
>
points
,
final
Agent
pedestrain
)
{
protected
void
renderTrajectory
(
final
Graphics2D
g
,
final
Stream
<
VPoint
>
points
,
final
Pedestrian
pedestrain
)
{
Color
color
=
g
.
getColor
();
Stroke
stroke
=
g
.
getStroke
();
...
...
@@ -143,8 +143,10 @@ public abstract class SimulationRenderer extends DefaultRenderer {
g
.
setStroke
(
new
BasicStroke
(
getLineWidth
()
/
4.0f
));
}
VPoint
endPos
=
model
.
config
.
isInterpolatePositions
()
?
pedestrain
.
getInterpolatedFootStepPosition
(
model
.
getSimTimeInSec
())
:
pedestrain
.
getPosition
();
Path2D
.
Double
path
=
new
Path2D
.
Double
();
path
.
moveTo
(
pedestrain
.
getPosition
().
getX
(),
pedestrain
.
getPosition
().
getY
());
path
.
moveTo
(
endPos
.
getX
(),
endPos
.
getY
());
points
.
forEachOrdered
(
p
->
path
.
lineTo
(
p
.
getX
(),
p
.
getY
()));
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/model/OnlineVisualizationModel.java
View file @
3bd216e2
...
...
@@ -69,6 +69,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
this
.
drawDataSynchronizer
=
new
Object
();
this
.
voronoiSnapshots
=
new
LinkedList
<>();
this
.
observationAreaSnapshots
=
new
LinkedList
<>();
this
.
config
.
setInterpolatePositions
(
false
);
}
@Override
...
...
@@ -81,6 +82,16 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
return
result
;
}
@Override
public
Collection
<
Pedestrian
>
getPedestrians
()
{
if
(
topography
==
null
)
{
return
new
ArrayList
<>();
}
Collection
<
Pedestrian
>
result
=
new
LinkedList
<>();
result
.
addAll
(
topography
.
getElements
(
Pedestrian
.
class
));
return
result
;
}
@Override
public
int
getTopographyId
()
{
return
0
;
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/view/OnlinevisualizationRenderer.java
View file @
3bd216e2
...
...
@@ -60,7 +60,7 @@ public class OnlinevisualizationRenderer extends SimulationRenderer {
private
void
renderPedestrians
(
final
Graphics2D
g
)
{
AgentRender
agentRender
=
getAgentRender
();
for
(
Agent
ped
:
model
.
get
Agent
s
())
{
for
(
Pedestrian
ped
:
model
.
get
Pedestrian
s
())
{
Color
agentColor
=
getPedestrianColor
(
ped
);
g
.
setColor
(
agentColor
);
VPoint
position
=
ped
.
getPosition
();
...
...
@@ -71,7 +71,15 @@ public class OnlinevisualizationRenderer extends SimulationRenderer {
}
// reverse the point order
pedestrianPositions
.
get
(
ped
.
getId
()).
addFirst
(
ped
.
getPosition
());
if
(!
model
.
config
.
isInterpolatePositions
())
{
pedestrianPositions
.
get
(
ped
.
getId
()).
addFirst
(
ped
.
getPosition
());
}
else
{
if
(
ped
.
getFootstepHistory
().
getCapacity
()
>
0
)
{
pedestrianPositions
.
get
(
ped
.
getId
()).
addFirst
(
ped
.
getFootstepHistory
().
getYoungestFootStep
().
getStart
());
}
else
{
pedestrianPositions
.
get
(
ped
.
getId
()).
addFirst
(
ped
.
getPosition
());
}
}
if
(
model
.
config
.
isShowTrajectories
())
{
renderTrajectory
(
g
,
pedestrianPositions
.
get
(
ped
.
getId
()),
ped
);
...
...
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
View file @
3bd216e2
...
...
@@ -177,6 +177,16 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
return
agentList
;
}
@Override
public
Collection
<
Pedestrian
>
getPedestrians
()
{
Table
agents
=
getAgentTable
();
List
<
Pedestrian
>
agentList
=
new
ArrayList
<>(
agents
.
rowCount
());
for
(
Row
agentRow
:
agents
)
{
agentList
.
add
(
toAgent
(
agentRow
));
}
return
agentList
;
}
public
synchronized
TableTrajectoryFootStep
getTrajectories
()
{
return
trajectories
;
}
...
...
@@ -193,7 +203,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
return
trajectories
.
getAgentDataFrame
();
}
private
Agent
toAgent
(
final
Row
row
)
{
private
Pedestrian
toAgent
(
final
Row
row
)
{
int
pedId
=
row
.
getInt
(
trajectories
.
pedIdCol
);
double
startTime
=
row
.
getDouble
(
trajectories
.
startTimeCol
);
double
endTime
=
row
.
getDouble
(
trajectories
.
endTimeCol
);
...
...
@@ -203,7 +213,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
double
endY
=
row
.
getDouble
(
trajectories
.
endYCol
);
VPoint
position
;
if
(
startTime
<=
getSimTimeInSec
()
&&
endTime
>=
getSimTimeInSec
())
{
if
(
config
.
isInterpolatePositions
()
&&
(
startTime
<=
getSimTimeInSec
()
&&
endTime
>=
getSimTimeInSec
())
)
{
position
=
FootStep
.
interpolateFootStep
(
startX
,
startY
,
endX
,
endY
,
startTime
,
endTime
,
getSimTimeInSec
());
}
else
{
position
=
new
VPoint
(
endX
,
endY
);
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/PostVisSettingsDialog.java
deleted
100644 → 0
View file @
4d57ac3d
package
org.vadere.gui.postvisualization.view
;
import
org.vadere.gui.components.view.SettingsDialog
;
import
org.vadere.gui.postvisualization.model.PostvisualizationModel
;
public
class
PostVisSettingsDialog
extends
SettingsDialog
{
public
PostVisSettingsDialog
(
PostvisualizationModel
model
)
{
super
(
null
);
}
}
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationRenderer.java
View file @
3bd216e2
...
...
@@ -6,6 +6,7 @@ import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import
org.vadere.gui.postvisualization.model.TableTrajectoryFootStep
;
import
org.vadere.gui.renderer.agent.AgentRender
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.simulation.FootStep
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.logging.Logger
;
...
...
@@ -70,7 +71,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
slice
=
model
.
getAlivePedestrians
();
}
Collection
<
Agent
>
agents
=
model
.
get
Agent
s
();
Collection
<
Pedestrian
>
agents
=
model
.
get
Pedestrian
s
();
Map
<
Integer
,
Color
>
agentColors
=
new
HashMap
<>();
agents
.
forEach
(
agent
->
agentColors
.
put
(
agent
.
getId
(),
getPedestrianColor
(
agent
)));
...
...
@@ -85,7 +86,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
double
endX
=
row
.
getDouble
(
trajectories
.
endXCol
);
double
endY
=
row
.
getDouble
(
trajectories
.
endYCol
);
if
(
isLastStep
)
{
if
(
isLastStep
&&
model
.
config
.
isInterpolatePositions
()
)
{
VPoint
interpolatedPos
=
FootStep
.
interpolateFootStep
(
startX
,
startY
,
endX
,
endY
,
row
.
getDouble
(
trajectories
.
startTimeCol
),
row
.
getDouble
(
trajectories
.
endTimeCol
),
model
.
getSimTimeInSec
());
endX
=
interpolatedPos
.
getX
();
endY
=
interpolatedPos
.
getY
();
...
...
@@ -117,7 +118,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
// render agents i.e. circles
if
(
model
.
config
.
isShowPedestrians
())
{
for
(
Agent
agent
:
agents
)
{
for
(
Pedestrian
agent
:
agents
)
{
if
(
model
.
config
.
isShowFaydedPedestrians
()
||
model
.
isAlive
(
agent
.
getId
()))
{
agentRender
.
render
(
agent
,
agentColors
.
get
(
agent
.
getId
()),
g
);
if
(
model
.
config
.
isShowPedestrianIds
())
{
...
...
VadereGui/src/org/vadere/gui/renderer/agent/AgentRender.java
View file @
3bd216e2
...
...
@@ -6,6 +6,7 @@ import org.vadere.gui.components.model.SimulationModel;
import
org.vadere.gui.components.view.DefaultRenderer
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.ScenarioElement
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VShape
;
import
org.vadere.util.logging.Logger
;
...
...
@@ -59,12 +60,17 @@ public class AgentRender implements Renderer {
private
void
renderDefault
(
final
ScenarioElement
element
,
Graphics2D
g
,
Color
c
)
{
g
.
setColor
(
c
);
VShape
shape
=
element
.
getShape
();
if
(
model
.
config
.
isInterpolatePositions
())
{
VPoint
pos
=
((
Pedestrian
)
element
).
getInterpolatedFootStepPosition
(
model
.
getSimTimeInSec
());
shape
=
shape
.
translate
(
pos
.
subtract
(((
Pedestrian
)
element
).
getPosition
()));
}
/*VCircle circle = (VCircle) element.getShape();
Pedestrian ped = (Pedestrian) element;
Ellipse2D.Float ellipse = new Ellipse2D.Float((float)ped.getPosition().x, (float)ped.getPosition().y, (float)ped.getRadius() * 2, (float)ped.getRadius() * 2);
Rectangle2D.Double rect = new Rectangle2D.Double(ped.getPosition().x, ped.getPosition().y, ped.getRadius() * 2, ped.getRadius() * 2);*/
//g.fill(new VCircle(ped.getPosition(), ped.getRadius()));
DefaultRenderer
.
fill
(
element
.
getS
hape
()
,
g
);
DefaultRenderer
.
fill
(
s
hape
,
g
);
//g.draw(ellipse);
//DefaultRenderer.fill(ellipse, g);
//g.fill(ellipse);
...
...
@@ -72,12 +78,19 @@ public class AgentRender implements Renderer {
}
public
VShape
getShape
(
Pedestrian
ped
)
{
VShape
shape
=
ped
.
getShape
();
VPoint
pos
=
ped
.
getPosition
();
if
(
model
.
config
.
isInterpolatePositions
())
{
pos
=
ped
.
getInterpolatedFootStepPosition
(
model
.
getSimTimeInSec
());
shape
=
shape
.
translate
(
pos
.
subtract
(
ped
.
getPosition
()));
}
if
(
ped
.
getGroupIds
().
isEmpty
()
||
(!
ped
.
getGroupSizes
().
isEmpty
()
&&
ped
.
getGroupSizes
().
getFirst
()
==
1
))
{
return
ped
.
getS
hape
()
;
return
s
hape
;
}
else
if
(
ped
.
getGroupIds
().
getFirst
()
==
1
)
{
return
ped
.
getS
hape
()
;
return
s
hape
;
}
else
{
return
FormHelper
.
getShape
(
ped
.
getGroupIds
().
getFirst
(),
p
ed
.
getPosition
()
,
ped
.
getRadius
());
return
FormHelper
.
getShape
(
ped
.
getGroupIds
().
getFirst
(),
p
os
,
ped
.
getRadius
());
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment