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
294bec0b
Commit
294bec0b
authored
Aug 10, 2018
by
Benedikt Zoennchen
Browse files
it is now possible to visualize the overall potential field of an individual pedestrian.
parent
e8af1b77
Pipeline
#65254
failed with stages
in 46 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereGui/resources/messages.properties
View file @
294bec0b
...
...
@@ -227,7 +227,12 @@ PostVis.menuRecentFiles.title=Recent Files
PostVis.menuOpenFile.title
=
Open File...
PostVis.menuCloseFloorFieldFile.title
=
Remove Floor Field File
OnlineVis.btnShowPotentialfield.tooltip
=
Show the Target Potential Field for the selected Agent
OnlineVis.btnShowPotentialfield.tooltip
=
Show the different Potential Fields for the selected Agent
OnlineVis.msgDialogShowPotentialfield.title
=
Potentialfield visualization
OnlineVis.msgDialogShowPotentialfield.text
=
Choose the Potential Field to be displayed.
OnlineVis.msgDialogShowPotentialfield.target
=
Target Potential Field
OnlineVis.msgDialogShowPotentialfield.overall
=
Potential Field (OSM only)
OnlineVis.msgDialogShowPotentialfield.none
=
None
TopographyBoundDialog.title
=
Set Topography Bounds
...
...
VadereGui/resources/messages_de_DE.properties
View file @
294bec0b
...
...
@@ -227,7 +227,12 @@ PostVis.menuRecentFiles.title=K\u00FCrzlich verwendete Dateien
PostVis.menuOpenFile.title
=
Datei
\u
00F6ffnen...
PostVis.menuCloseFloorFieldFile.title
=
Floor Field-Datei l
\u
00F6schen
OnlineVis.btnShowPotentialfield.tooltip
=
Zeigt das Zielpotenzialfeld des ausgew
\u
00E4hlten Agenten
OnlineVis.btnShowPotentialfield.tooltip
=
Zeige Potentialfeld des ausgew
\u
00E4hlten Agenten
OnlineVis.msgDialogShowPotentialfield.title
=
Potentialfeld visualisieren
OnlineVis.msgDialogShowPotentialfield.text
=
W
\u
00E4hle Potentialfeld
OnlineVis.msgDialogShowPotentialfield.target
=
Zielpotential
OnlineVis.msgDialogShowPotentialfield.overall
=
Potential (OSM only)
OnlineVis.msgDialogShowPotentialfield.none
=
Keines
TopographyBoundDialog.title
=
Setze Topographie Grenzen
...
...
VadereGui/src/org/vadere/gui/components/model/DefaultSimulationConfig.java
View file @
294bec0b
...
...
@@ -18,6 +18,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private
boolean
showStairs
=
true
;
private
boolean
showPedestrians
=
true
;
private
boolean
showWalkdirection
=
false
;
private
boolean
showTargetPotentialField
=
false
;
private
boolean
showPotentialField
=
false
;
private
boolean
showTrajectories
=
false
;
private
boolean
showGrid
=
false
;
...
...
@@ -32,13 +33,14 @@ public class DefaultSimulationConfig extends DefaultConfig {
public
DefaultSimulationConfig
(
final
DefaultSimulationConfig
config
)
{
super
(
config
);
this
.
showDensity
=
config
.
showDensity
;
this
.
showPotentialField
=
config
.
showPotentialField
;
this
.
show
Target
PotentialField
=
config
.
show
Target
PotentialField
;
this
.
showWalkdirection
=
config
.
showWalkdirection
;
this
.
showGrid
=
config
.
showGrid
;
this
.
showPedestrians
=
config
.
showPedestrians
;
this
.
showLogo
=
config
.
showLogo
;
this
.
showStairs
=
config
.
showStairs
;
this
.
showGroups
=
config
.
showGroups
;
this
.
showPotentialField
=
config
.
showPotentialField
;
}
public
boolean
isShowGroups
()
{
...
...
@@ -143,6 +145,11 @@ public class DefaultSimulationConfig extends DefaultConfig {
setChanged
();
}
public
void
setShowTargetPotentialField
(
final
boolean
showTargetPotentialField
)
{
this
.
showTargetPotentialField
=
showTargetPotentialField
;
setChanged
();
}
public
void
setShowPotentialField
(
final
boolean
showPotentialField
)
{
this
.
showPotentialField
=
showPotentialField
;
setChanged
();
...
...
@@ -164,6 +171,10 @@ public class DefaultSimulationConfig extends DefaultConfig {
return
pedestrianTorso
;
}
public
boolean
isShowTargetPotentialField
()
{
return
showTargetPotentialField
;
}
public
boolean
isShowPotentialField
()
{
return
showPotentialField
;
}
...
...
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
View file @
294bec0b
...
...
@@ -48,7 +48,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
@Override
protected
void
renderPreTransformation
(
Graphics2D
graphics2D
,
int
width
,
int
height
)
{
if
(
model
.
isFloorFieldAvailable
()
&&
model
.
config
.
isShowPotentialField
())
{
if
(
model
.
isFloorFieldAvailable
()
&&
(
model
.
config
.
isShowTargetPotentialField
()
||
model
.
config
.
isShowPotentialField
())
)
{
synchronized
(
model
)
{
renderPotentialField
(
graphics2D
,
(
int
)(
Math
.
min
(
model
.
getTopographyBound
().
width
,
model
.
getViewportBound
().
width
)
*
model
.
getScaleFactor
()),
...
...
@@ -64,7 +64,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
// if there is no potential field than draw the default background (white)
// otherwise do not overdraw the potential field!!!
if
(!
model
.
isFloorFieldAvailable
()
||
!
model
.
config
.
isShowPotentialField
())
{
if
(!
model
.
isFloorFieldAvailable
()
||
!
(
model
.
config
.
isShowTargetPotentialField
()
||
model
.
config
.
isShowPotentialField
())
)
{
super
.
renderPostTransformation
(
graphics
,
width
,
height
);
}
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/OnlineVisualization.java
View file @
294bec0b
...
...
@@ -10,7 +10,9 @@ import org.vadere.gui.onlinevisualization.view.OnlineVisualisationWindow;
import
org.vadere.simulator.control.PassiveCallback
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.IPotentialFieldTarget
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.util.geometry.shapes.VRectangle
;
public
class
OnlineVisualization
implements
PassiveCallback
{
...
...
@@ -24,11 +26,20 @@ public class OnlineVisualization implements PassiveCallback {
public
final
double
simTimeInSec
;
public
final
Topography
scenario
;
public
final
IPotentialField
potentialFieldTarget
;
public
ObservationAreaSnapshotData
(
double
simTimeInSec
,
@NotNull
Topography
scenario
,
@Nullable
IPotentialField
potentialFieldTarget
)
{
public
final
Agent
selectedAgent
;
public
final
IPotentialField
potentialField
;
public
ObservationAreaSnapshotData
(
final
double
simTimeInSec
,
@NotNull
final
Topography
scenario
,
@Nullable
final
IPotentialField
potentialFieldTarget
,
@Nullable
final
IPotentialField
potentialField
,
@Nullable
final
Agent
selectedAgent
)
{
this
.
simTimeInSec
=
simTimeInSec
;
this
.
scenario
=
scenario
;
this
.
potentialFieldTarget
=
potentialFieldTarget
;
this
.
potentialField
=
potentialField
;
this
.
selectedAgent
=
selectedAgent
;
}
}
...
...
@@ -36,8 +47,17 @@ public class OnlineVisualization implements PassiveCallback {
private
OnlineVisualisationWindow
onlineVisualisationPanel
;
private
OnlineVisualizationModel
model
;
private
Topography
scenario
;
private
@Nullable
IPotentialFieldTarget
potentialFieldTarget
;
/**
* Target potential.
*/
private
@Nullable
IPotentialFieldTarget
potentialFieldTarget
;
/**
* The overall potential.
*/
private
@Nullable
IPotentialField
potentialField
;
private
boolean
enableVisualization
;
public
OnlineVisualization
(
boolean
enableVisualization
)
{
...
...
@@ -60,6 +80,11 @@ public class OnlineVisualization implements PassiveCallback {
this
.
potentialFieldTarget
=
potentialFieldTarget
;
}
@Override
public
void
setPotentialField
(
final
IPotentialField
potentialField
)
{
this
.
potentialField
=
potentialField
;
}
@Override
public
void
preLoop
(
double
simTimeInSec
)
{
onlineVisualisationPanel
.
setVisible
(
this
.
enableVisualization
);
...
...
@@ -91,11 +116,17 @@ public class OnlineVisualization implements PassiveCallback {
synchronized
(
model
.
getDataSynchronizer
())
{
/* Push new snapshot of the observation area to the draw thread. */
model
.
pushObersavtionAreaSnapshot
(
new
ObservationAreaSnapshotData
(
simTimeInSec
,
scenario
.
clone
(),
(
model
.
config
.
isShowPotentialField
()
&&
potentialFieldTarget
!=
null
)
?
potentialFieldTarget
.
copyFields
()
:
null
));
IPotentialField
pft
=
(
model
.
config
.
isShowTargetPotentialField
()
&&
potentialFieldTarget
!=
null
)
?
potentialFieldTarget
.
copyFields
()
:
null
;
IPotentialField
pedPotentialField
=
null
;
Agent
selectedAgent
=
null
;
if
(
model
.
config
.
isShowPotentialField
()
&&
model
.
getSelectedElement
()
instanceof
Agent
&&
potentialField
!=
null
)
{
selectedAgent
=
(
Agent
)
model
.
getSelectedElement
();
pedPotentialField
=
IPotentialField
.
copyAgentField
(
potentialField
,
selectedAgent
,
new
VRectangle
(
model
.
getTopographyBound
()),
0.1
);
}
ObservationAreaSnapshotData
data
=
new
ObservationAreaSnapshotData
(
simTimeInSec
,
scenario
.
clone
(),
pft
,
pedPotentialField
,
selectedAgent
);
model
.
pushObersavtionAreaSnapshot
(
data
);
}
}
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/control/ActionShowPotentialField.java
View file @
294bec0b
...
...
@@ -4,6 +4,7 @@ import org.apache.log4j.LogManager;
import
org.apache.log4j.Logger
;
import
org.vadere.gui.components.model.DefaultSimulationConfig
;
import
org.vadere.gui.components.model.SimulationModel
;
import
org.vadere.gui.components.utils.Messages
;
import
org.vadere.gui.components.view.SimulationRenderer
;
import
org.vadere.gui.onlinevisualization.view.IRendererChangeListener
;
...
...
@@ -24,8 +25,37 @@ public class ActionShowPotentialField extends AbstractAction implements IRendere
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
model
.
config
.
setShowPotentialField
(!
model
.
config
.
isShowPotentialField
());
model
.
notifyObservers
();
String
[]
possibilities
=
{
Messages
.
getString
(
"OnlineVis.msgDialogShowPotentialfield.target"
),
Messages
.
getString
(
"OnlineVis.msgDialogShowPotentialfield.overall"
),
Messages
.
getString
(
"OnlineVis.msgDialogShowPotentialfield.none"
)};
String
s
=
(
String
)
JOptionPane
.
showInputDialog
(
null
,
Messages
.
getString
(
"OnlineVis.msgDialogShowPotentialfield.text"
),
Messages
.
getString
(
"OnlineVis.msgDialogShowPotentialfield.title"
),
JOptionPane
.
PLAIN_MESSAGE
,
null
,
possibilities
,
possibilities
[
0
]);
//If a string was returned, say so.
if
(
possibilities
[
0
].
equals
(
s
))
{
model
.
config
.
setShowTargetPotentialField
(
true
);
model
.
config
.
setShowPotentialField
(
false
);
model
.
notifyObservers
();
}
else
if
(
possibilities
[
1
].
equals
(
s
))
{
model
.
config
.
setShowTargetPotentialField
(
false
);
model
.
config
.
setShowPotentialField
(
true
);
model
.
notifyObservers
();
}
else
{
model
.
config
.
setShowTargetPotentialField
(
false
);
model
.
config
.
setShowPotentialField
(
false
);
}
}
@Override
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/model/OnlineVisualizationModel.java
View file @
294bec0b
...
...
@@ -11,7 +11,6 @@ import org.vadere.gui.components.model.DefaultSimulationConfig;
import
org.vadere.gui.components.model.SimulationModel
;
import
org.vadere.gui.onlinevisualization.OnlineVisualization
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.IPotentialFieldTarget
;
import
org.vadere.state.scenario.*
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.voronoi.VoronoiDiagram
;
...
...
@@ -29,8 +28,12 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* pontetial field of a certain pedestrian. See 'Simulation' for more
* information. For debug purposes. Updated by popDrawData().
*/
private
IPotentialField
potentialFieldTarget
=
null
;
private
IPotentialField
potentialField
=
null
;
private
Agent
agent
=
null
;
/**
* Latest snapshot of the jts diagram to be displayed. Updated by
* popDrawData().
...
...
@@ -104,8 +107,10 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
observationAreaSnapshots
.
getFirst
();
simTimeInSec
=
observationAreaSnapshot
.
simTimeInSec
;
// potentialField might be null!
potentialField
=
observationAreaSnapshot
.
potentialFieldTarget
;
// potentialFieldTarget might be null!
potentialFieldTarget
=
observationAreaSnapshot
.
potentialFieldTarget
;
potentialField
=
observationAreaSnapshot
.
potentialField
;
agent
=
observationAreaSnapshot
.
selectedAgent
;
/*
* if(topography == null ||
...
...
@@ -179,10 +184,13 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
public
Function
<
VPoint
,
Double
>
getPotentialField
()
{
Function
<
VPoint
,
Double
>
f
=
pos
->
0.0
;
if
(
potentialField
!=
null
)
{
if
(
potentialField
!=
null
&&
config
.
isShowPotentialField
()
&&
agent
.
equals
(
getSelectedElement
()))
{
f
=
pos
->
potentialField
.
getPotential
(
pos
,
agent
);
}
else
if
(
potentialFieldTarget
!=
null
&&
config
.
isShowTargetPotentialField
())
{
if
(
getSelectedElement
()
instanceof
Agent
)
{
Agent
selectedAgent
=
(
Agent
)
getSelectedElement
();
f
=
pos
->
potentialField
.
getPotential
(
pos
,
selectedAgent
);
f
=
pos
->
potentialField
Target
.
getPotential
(
pos
,
selectedAgent
);
}
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/control/ActionShowPotentialField.java
View file @
294bec0b
...
...
@@ -24,7 +24,7 @@ public class ActionShowPotentialField extends ActionVisualization {
@Override
public
void
actionPerformed
(
final
ActionEvent
event
)
{
if
(!
model
.
config
.
isShowPotentialField
())
{
if
(!
model
.
config
.
isShow
Target
PotentialField
())
{
//final JFileChooser fc = new JFileChooser(resources.getProperty("View.outputDirectory.path"));
final
JFileChooser
fc
=
new
JFileChooser
(
model
.
getOutputPath
());
int
returnVal
=
fc
.
showOpenDialog
(
null
);
...
...
@@ -44,7 +44,7 @@ public class ActionShowPotentialField extends ActionVisualization {
PotentialFieldContainer
container
=
new
PotentialFieldContainer
(
file
,
topography
.
getBounds
().
getWidth
(),
topography
.
getBounds
().
getHeight
(),
false
);
model
.
setPotentialFieldContainer
(
container
);
model
.
config
.
setShowPotentialField
(
true
);
model
.
config
.
setShow
Target
PotentialField
(
true
);
model
.
notifyObservers
();
// logger.info("read: \n" + data);
}
catch
(
Exception
e
)
{
...
...
@@ -65,7 +65,7 @@ public class ActionShowPotentialField extends ActionVisualization {
new
Thread
(
runnable
).
start
();
}
}
else
{
model
.
config
.
setShowPotentialField
(
false
);
model
.
config
.
setShow
Target
PotentialField
(
false
);
model
.
notifyObservers
();
}
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
View file @
294bec0b
...
...
@@ -362,7 +362,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
e
.
printStackTrace
();
}
}
config
.
setShowPotentialField
(
false
);
config
.
setShow
Target
PotentialField
(
false
);
potentialContainer
=
null
;
}
}
VadereSimulator/src/org/vadere/simulator/control/PassiveCallback.java
View file @
294bec0b
package
org.vadere.simulator.control
;
import
org.jetbrains.annotations.Nullable
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.IPotentialFieldTarget
;
import
org.vadere.state.scenario.Topography
;
...
...
@@ -20,5 +22,7 @@ public interface PassiveCallback {
void
setTopography
(
Topography
scenario
);
default
void
setPotentialFieldTarget
(
IPotentialFieldTarget
potentialFieldTarget
){}
default
void
setPotentialFieldTarget
(
@Nullable
IPotentialFieldTarget
potentialFieldTarget
){}
default
void
setPotentialField
(
@Nullable
IPotentialField
potentialField
)
{}
}
VadereSimulator/src/org/vadere/simulator/control/Simulation.java
View file @
294bec0b
...
...
@@ -6,7 +6,9 @@ import org.vadere.simulator.control.factory.SourceControllerFactory;
import
org.vadere.simulator.models.DynamicElementFactory
;
import
org.vadere.simulator.models.MainModel
;
import
org.vadere.simulator.models.Model
;
import
org.vadere.simulator.models.osm.PedestrianOSM
;
import
org.vadere.simulator.models.potential.PotentialFieldModel
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.IPotentialFieldTarget
;
import
org.vadere.simulator.projects.ScenarioStore
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
...
...
@@ -88,17 +90,27 @@ public class Simulation {
this
.
passiveCallbacks
=
passiveCallbacks
;
this
.
topographyController
=
new
TopographyController
(
topography
,
dynamicElementFactory
);
IPotentialFieldTarget
pft
=
null
;
if
(
mainModel
instanceof
PotentialFieldModel
)
{
pft
=
((
PotentialFieldModel
)
mainModel
).
getPotentialFieldTarget
();
}
// ::start:: this code is to visualize the potential fields. It may be refactored later.
IPotentialFieldTarget
pft
=
null
;
IPotentialField
pt
=
null
;
if
(
mainModel
instanceof
PotentialFieldModel
)
{
pft
=
((
PotentialFieldModel
)
mainModel
).
getPotentialFieldTarget
();
pt
=
(
pos
,
agent
)
->
{
if
(
agent
instanceof
PedestrianOSM
)
{
return
((
PedestrianOSM
)
agent
).
getPotential
(
pos
);
}
else
{
return
0.0
;
}
};
}
for
(
PassiveCallback
pc
:
this
.
passiveCallbacks
)
{
pc
.
setTopography
(
topography
);
if
(
pft
!=
null
)
{
pc
.
setPotentialFieldTarget
(
pft
);
}
pc
.
setPotentialFieldTarget
(
pft
);
pc
.
setPotentialField
(
pt
);
}
// ::end::
// create source and target controllers
for
(
Source
source
:
topography
.
getSources
())
{
...
...
VadereSimulator/src/org/vadere/simulator/models/potential/fields/IPotentialField.java
View file @
294bec0b
package
org.vadere.simulator.models.potential.fields
;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.math.InterpolationUtil
;
/**
* @author Benedikt Zoennchen
...
...
@@ -17,4 +20,51 @@ public interface IPotentialField {
* @return a potential at pos for the agent
*/
double
getPotential
(
final
VPoint
pos
,
final
Agent
agent
);
static
IPotentialField
copyAgentField
(
final
@NotNull
IPotentialField
potentialField
,
final
@NotNull
Agent
agent
,
final
@NotNull
VRectangle
bound
,
final
double
steps
)
{
final
int
gridWidth
=
(
int
)
Math
.
ceil
(
bound
.
getWidth
()
/
steps
)+
1
;
final
int
gridHeight
=
(
int
)
Math
.
ceil
(
bound
.
getHeight
()
/
steps
)+
1
;
final
double
[][]
potentialFieldApproximation
=
new
double
[
gridHeight
][
gridWidth
];
for
(
int
row
=
0
;
row
<
gridHeight
;
row
++)
{
for
(
int
col
=
0
;
col
<
gridWidth
;
col
++)
{
double
x
=
col
*
steps
;
double
y
=
row
*
steps
;
potentialFieldApproximation
[
row
][
col
]
=
potentialField
.
getPotential
(
new
VPoint
(
x
,
y
),
agent
);
}
}
return
(
pos
,
ped
)
->
{
if
(
ped
.
equals
(
agent
))
{
int
incX
=
1
;
int
incY
=
1
;
int
col
=
(
int
)(
pos
.
getX
()
/
steps
);
int
row
=
(
int
)(
pos
.
getY
()
/
steps
);
if
(
col
+
1
>=
gridWidth
)
{
incX
=
0
;
}
if
(
row
+
1
>=
gridHeight
)
{
incY
=
0
;
}
VPoint
gridPointCoord
=
new
VPoint
(
col
*
steps
,
row
*
steps
);
double
z1
=
potentialFieldApproximation
[
row
][
col
];
double
z2
=
potentialFieldApproximation
[
row
][
col
+
incX
];
double
z3
=
potentialFieldApproximation
[
row
+
incY
][
col
+
incX
];
double
z4
=
potentialFieldApproximation
[
row
+
incY
][
col
];
double
t
=
(
pos
.
x
-
gridPointCoord
.
x
)
/
steps
;
double
u
=
(
pos
.
y
-
gridPointCoord
.
y
)
/
steps
;
return
InterpolationUtil
.
bilinearInterpolation
(
z1
,
z2
,
z3
,
z4
,
t
,
u
);
}
else
{
return
0.0
;
}
};
}
}
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