Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Reza Cheraghi
swarm-sim
Commits
03a6f9f4
Commit
03a6f9f4
authored
Dec 16, 2019
by
Karol Actun
Browse files
marker renamed to location, grid's locations renamed to coordinates
parent
c3a91e1f
Changes
32
Expand all
Show whitespace changes
Inline
Side-by-side
config.ini
View file @
03a6f9f4
...
...
@@ -29,7 +29,7 @@ gui = default_gui
;# .obj (Wavefront) filenames in lib/visualization/models
;particle_model_file = 2d_particle.obj
;tile_model_file = 2d_quad_tile.obj
;
marker
_model_file = 2d_
marker
.obj
;
location
_model_file = 2d_
location
.obj
;grid_size = 1000
; end of Quadratic grid configs
...
...
@@ -39,7 +39,7 @@ gui = default_gui
;# .obj (Wavefront) filenames in lib/visualization/models
;particle_model_file = 2d_particle.obj
;tile_model_file = 2d_hex_tile.obj
;
marker
_model_file = 2d_
marker
.obj
;
location
_model_file = 2d_
location
.obj
;grid_size = 100
; end of Triangular grid configs
...
...
@@ -48,7 +48,7 @@ gui = default_gui
;grid_class = CubicGrid
;particle_model_file = 3d_particle_low_poly.obj
;tile_model_file = 3d_cube_tile.obj
;
marker
_model_file = 3d_
marker
.obj
;
location
_model_file = 3d_
location
.obj
;grid_size = 10
; end of cubic grid configs
...
...
@@ -57,14 +57,14 @@ gui = default_gui
grid_class
=
CCPGrid
particle_model_file
=
3d_particle.obj
tile_model_file
=
3d_ccp_tile.obj
marker
_model_file
=
3d_
marker
.obj
location
_model_file
=
3d_
location
.obj
grid_size
=
10
# end of ccp grid configs
# matter default colors (rgba)
particle_color
=
(0.8, 0.3, 0.3, 1.0)
tile_color
=
(0.3, 0.3, 0.8, 1.0)
marker
_color
=
(0.3, 0.8, 0.3, 1.0)
location
_color
=
(0.3, 0.8, 0.3, 1.0)
grid_color
=
(0.0, 0.0, 0.0, 1.0)
cursor_color
=
(0.5, 0.5, 0.5, 0.5)
center_color
=
(1.0, 0.0, 0.0, 0.5)
...
...
@@ -77,12 +77,12 @@ line_color = (0.0, 0.0, 0.0, 1.0)
line_scaling
=
(1.0, 1.0, 1.0)
# flag for showing the lines
show_lines
=
True
# color of grid
location
s (rgba)
location
_color
=
(0.0, 0.0, 0.0, 1.0)
# size/scaling of the
location
model. wouldn't make it bigger than 0.2, 0.2, 0.2
location
_scaling
=
(0.05, 0.05, 0.05)
# flag for showing the
location
models
show_
location
s
=
True
# color of grid
coordinate
s (rgba)
coordinates
_color
=
(0.0, 0.0, 0.0, 1.0)
# size/scaling of the
coordinate
model. wouldn't make it bigger than 0.2, 0.2, 0.2
coordinates
_scaling
=
(0.05, 0.05, 0.05)
# flag for showing the
coordinate
models
show_
coordinate
s
=
True
# flag for showing the center of the grid
show_center
=
True
# camera focus color
...
...
@@ -119,11 +119,11 @@ memory_limitation = False
## mm size in quantity
## Works only with memory_limitation flag set on 1
marker
_mm_size
=
2
location
_mm_size
=
2
particle_mm_size
=
2
tile_mm_size
=
2
[File]
scenario
=
rings_of _matter
scenario
=
lonely_particle
solution
=
random_walk_with_take_and_drop
grids/CCPGrid.py
View file @
03a6f9f4
...
...
@@ -32,15 +32,15 @@ class CCPGrid(Grid):
for
x
in
range
(
-
int
(
width
/
2
),
int
(
width
/
2
)):
for
y
in
range
(
-
int
(
width
/
2
),
int
(
width
/
2
)):
for
z
in
range
(
-
int
(
width
/
2
),
int
(
width
/
2
)):
if
self
.
is
_valid_
location
((
x
,
y
,
z
)):
if
self
.
are
_valid_
coordinates
((
x
,
y
,
z
)):
locations
.
append
((
x
,
y
,
z
))
return
locations
def
is
_valid_
location
(
self
,
location
):
x
=
location
[
0
]
y
=
location
[
1
]
z
=
location
[
2
]
def
are
_valid_
coordinates
(
self
,
coordinates
):
x
=
coordinates
[
0
]
y
=
coordinates
[
1
]
z
=
coordinates
[
2
]
if
y
%
2.0
==
0
:
if
x
%
2.0
==
z
%
2.0
==
0
or
x
%
2.0
==
z
%
2.0
==
1
:
return
True
...
...
@@ -49,7 +49,7 @@ class CCPGrid(Grid):
return
True
return
False
def
get_nearest_
location
(
self
,
coordinates
):
def
get_nearest_
valid_coordinates
(
self
,
coordinates
):
x
=
round
(
coordinates
[
0
])
y
=
round
(
coordinates
[
1
])
z
=
round
(
coordinates
[
2
])
...
...
grids/CubicGrid.py
View file @
03a6f9f4
...
...
@@ -28,13 +28,13 @@ class CubicGrid(Grid):
locations
.
append
((
x
,
y
,
z
))
return
locations
def
is
_valid_
location
(
self
,
location
):
if
location
[
0
]
%
1
==
0
and
location
[
1
]
%
1
==
0
and
location
[
2
]
%
1
==
0
:
def
are
_valid_
coordinates
(
self
,
coordinates
):
if
coordinates
[
0
]
%
1
==
0
and
coordinates
[
1
]
%
1
==
0
and
coordinates
[
2
]
%
1
==
0
:
return
True
else
:
return
False
def
get_nearest_
location
(
self
,
coordinates
):
def
get_nearest_
valid_coordinates
(
self
,
coordinates
):
return
(
round
(
coordinates
[
0
]),
round
(
coordinates
[
1
]),
round
(
coordinates
[
2
]))
...
...
grids/Grid.py
View file @
03a6f9f4
...
...
@@ -14,20 +14,20 @@ class Grid(ABC):
pass
@
abstractmethod
def
is
_valid_
location
(
self
,
location
):
def
are
_valid_
coordinates
(
self
,
coordinates
):
"""
checks if given
location i
s a valid
location for matter in
this grid
:param
location
: (float, float, float)
:return: true =
location is
valid, false =
location
invalid
checks if given
coordinate
s a
re
valid
for
this grid
:param
coordinates
: (float, float, float)
:return: true =
coordinates are
valid, false =
coordinates
invalid
"""
pass
@
abstractmethod
def
get_nearest_
location
(
self
,
coordinates
):
def
get_nearest_
valid_coordinates
(
self
,
coordinates
):
"""
calculates the nearest
location
to given coordinates
calculates the nearest
valid coordinates
to given coordinates
:param coordinates: (float, float, float)
:return: valid
location
:return: valid
coordinates
"""
pass
...
...
@@ -71,7 +71,7 @@ class Grid(ABC):
@
abstractmethod
def
get_box
(
self
,
width
):
"""
calculates
location
s in a box
calculates
all valid coordinate
s in a box
:return: list of 3d coordinates: [(x_start_l0, y_start_l0), (x_end_l0, y_end_l0), (x_start_l1, y_start_l1), ...)
"""
pass
...
...
@@ -88,19 +88,19 @@ class Grid(ABC):
def
get_distance
(
self
,
start
,
end
):
"""
the metric or distance function for this grid
:param start:
location
, (float, float, float) tuple, start of path
:param end:
location
, (float, float, float) tuple, end of path
:param start:
coordinates
, (float, float, float) tuple, start of path
:param end:
coordinates
, (float, float, float) tuple, end of path
:return: integer, minimal amount of steps between start and end
"""
pass
@
staticmethod
def
get_
location
_in_direction
(
position
,
direction
):
def
get_
coordinates
_in_direction
(
position
,
direction
):
"""
calculates a new position from current position and direction
:param position:
location
, (float, float, float) tuple, current position
:param direction:
location
, (float, float, float) tuple, direction
:return:
location
, (float, float, float) tuple, new position
:param position:
coordinates
, (float, float, float) tuple, current position
:param direction:
coordinates
, (float, float, float) tuple, direction
:return:
coordinates
, (float, float, float) tuple, new position
"""
new_pos
=
[]
for
i
in
range
(
len
(
position
)):
...
...
@@ -110,7 +110,7 @@ class Grid(ABC):
def
get_center
(
self
):
"""
returns the center of the grid. usually (0,0,0)
:return:
location
, (float, float, float) tuple
:return:
coordinates
, (float, float, float) tuple
"""
return
0.0
,
0.0
,
0.0
...
...
@@ -121,75 +121,75 @@ class Grid(ABC):
"""
return
1.0
,
1.0
,
1.0
def
get_adjacent_
locations
(
self
,
location
):
def
get_adjacent_
coordinates
(
self
,
coordinates
):
"""
calculates a set of adjacent
location
s of the given
location
:param
location: the location
of which the neighboring
location
s should be calculated
:return: a set of
location
s
calculates a set of adjacent
coordinate
s of the given
coordinates
:param
coordinates: the coordinates
of which the neighboring
coordinate
s should be calculated
:return: a set of
coordinate
s
"""
n
=
set
()
for
d
in
self
.
get_directions_list
():
n
.
add
(
self
.
get_
location
_in_direction
(
location
,
d
))
n
.
add
(
self
.
get_
coordinates
_in_direction
(
coordinates
,
d
))
return
n
def
_get_adjacent_
location
s_not_in_set
(
self
,
location
,
not_in_set
):
def
_get_adjacent_
coordinate
s_not_in_set
(
self
,
coordinates
,
not_in_set
):
"""
the same as 'get_neighboring_
location
s', but doesn't return
location
s which are in the given 'not_in_set'.
:param
location: the location
of which the neighboring
location
s should be calculated
:param not_in_set: set of
location
s, which should not be included in the result
:return: a set of
location
s
the same as 'get_neighboring_
coordinate
s', but doesn't return
coordinate
s which are in the given 'not_in_set'.
:param
coordinates: the coordinates
of which the neighboring
coordinate
s should be calculated
:param not_in_set: set of
coordinate
s, which should not be included in the result
:return: a set of
coordinate
s
"""
result
=
set
()
for
d
in
self
.
get_directions_list
():
n
=
self
.
get_
location
_in_direction
(
location
,
d
)
n
=
self
.
get_
coordinates
_in_direction
(
coordinates
,
d
)
if
n
not
in
not_in_set
:
result
.
add
(
n
)
return
result
def
get_n_sphere
(
self
,
location
,
radius
):
def
get_n_sphere
(
self
,
coordinates
,
radius
):
"""
calculates the n-sphere of this grid
:param
location
: center of the circle/sphere
:param
coordinates
: center of the circle/sphere
:param radius: radius of the circle/sphere
:return: set of
location
s
:return: set of
coordinate
s
"""
result
=
set
()
ns
=
self
.
get_adjacent_
locations
(
location
)
ns
=
self
.
get_adjacent_
coordinates
(
coordinates
)
current_ns
=
ns
result
.
update
(
ns
)
for
i
in
range
(
radius
):
tmp
=
set
()
for
n
in
current_ns
:
ns
=
self
.
_get_adjacent_
location
s_not_in_set
(
n
,
result
)
ns
=
self
.
_get_adjacent_
coordinate
s_not_in_set
(
n
,
result
)
tmp
.
update
(
ns
)
result
.
update
(
ns
)
current_ns
=
tmp
return
result
def
get_n_sphere_border
(
self
,
location
,
radius
):
def
get_n_sphere_border
(
self
,
coordinates
,
radius
):
"""
calculates the border of an n-sphere around the center with the given radius
:param
location
: center of the ring
:param
coordinates
: center of the ring
:param radius: radius of the ring
:return: set of
location
s
:return: set of
coordinate
s
"""
if
radius
==
0
:
r
=
set
()
r
.
add
(
location
)
r
.
add
(
coordinates
)
return
r
seen
=
set
()
ns
=
self
.
get_adjacent_
locations
(
location
)
ns
=
self
.
get_adjacent_
coordinates
(
coordinates
)
current_ns
=
ns
seen
.
update
(
ns
)
seen
.
add
(
location
)
seen
.
add
(
coordinates
)
for
i
in
range
(
radius
-
1
):
tmp
=
set
()
for
n
in
current_ns
:
ns
=
self
.
_get_adjacent_
location
s_not_in_set
(
n
,
seen
)
ns
=
self
.
_get_adjacent_
coordinate
s_not_in_set
(
n
,
seen
)
seen
.
update
(
ns
)
tmp
.
update
(
ns
)
current_ns
=
tmp
...
...
grids/QuadraticGrid.py
View file @
03a6f9f4
...
...
@@ -25,13 +25,13 @@ class QuadraticGrid(Grid):
locations
.
append
((
x
,
y
,
0.0
))
return
locations
def
is
_valid_
location
(
self
,
location
):
if
location
[
0
]
%
1
==
0
and
location
[
1
]
%
1
==
0
:
def
are
_valid_
coordinates
(
self
,
coordinates
):
if
coordinates
[
0
]
%
1
==
0
and
coordinates
[
1
]
%
1
==
0
:
return
True
else
:
return
False
def
get_nearest_
location
(
self
,
coordinates
):
def
get_nearest_
valid_coordinates
(
self
,
coordinates
):
return
(
round
(
coordinates
[
0
]),
round
(
coordinates
[
1
]),
0.0
)
...
...
grids/TriangularGrid.py
View file @
03a6f9f4
...
...
@@ -33,18 +33,18 @@ class TriangularGrid(Grid):
return
locs
def
is
_valid_
location
(
self
,
location
):
if
not
location
[
2
]
==
0.0
:
def
are
_valid_
coordinates
(
self
,
coordinates
):
if
not
coordinates
[
2
]
==
0.0
:
return
False
if
location
[
1
]
%
2.0
==
0.0
:
if
location
[
0
]
%
1.0
==
0.0
:
if
coordinates
[
1
]
%
2.0
==
0.0
:
if
coordinates
[
0
]
%
1.0
==
0.0
:
return
True
else
:
if
location
[
0
]
%
1.0
==
0.5
:
if
coordinates
[
0
]
%
1.0
==
0.5
:
return
True
return
False
def
get_nearest_
location
(
self
,
coordinates
):
def
get_nearest_
valid_coordinates
(
self
,
coordinates
):
nearest_y
=
round
(
coordinates
[
1
])
if
nearest_y
%
2
==
0
:
nearest_x
=
round
(
coordinates
[
0
])
...
...
gui/default_gui.py
View file @
03a6f9f4
from
PyQt5.QtGui
import
QColor
,
QIntValidator
from
PyQt5.QtGui
import
QColor
,
QIntValidator
,
QFont
from
PyQt5.QtWidgets
import
(
QVBoxLayout
,
QPushButton
,
QColorDialog
,
QRadioButton
,
QLabel
,
QTabWidget
,
QSlider
,
QHBoxLayout
,
QCheckBox
,
QTabBar
,
QTextEdit
,
QLineEdit
,
Q
Style
)
QSlider
,
QHBoxLayout
,
QCheckBox
,
QTabBar
,
QLineEdit
,
Q
ComboBox
)
from
PyQt5.QtCore
import
Qt
from
OpenGL.GL
import
glGetFloatv
,
GL_LINE_WIDTH_RANGE
from
lib.vis3d
import
Visualization
from
lib.visualization.utils
import
eprint
def
create_slider
(
tick_interval
:
int
,
tick_position
:
int
,
max_position
:
int
,
min_position
:
int
,
slider_position
:
int
,
callback
,
orientation
=
Qt
.
Horizontal
):
"""
helper function for creating a slider
"""
slider
=
QSlider
(
orientation
)
slider
.
setTickInterval
(
tick_interval
)
slider
.
setTickPosition
(
tick_position
)
slider
.
setMaximum
(
max_position
)
slider
.
setMinimum
(
min_position
)
slider
.
setSliderPosition
(
slider_position
)
slider
.
valueChanged
.
connect
(
callback
)
return
slider
from
lib.swarm_sim_header
import
eprint
from
lib.vis3d
import
Visualization
def
create_gui
(
world
,
vis
:
Visualization
):
...
...
@@ -30,6 +16,7 @@ def create_gui(world, vis: Visualization):
tabbar
.
addTab
(
vis_tab
(
vis
),
"Visualization"
)
tabbar
.
addTab
(
grid_tab
(
vis
),
"Grid"
)
tabbar
.
addTab
(
matter_tab
(
vis
),
"Matter"
)
tabbar
.
addTab
(
help_tab
(),
"Help"
)
return
tabbar
...
...
@@ -39,6 +26,51 @@ def key_handler(key, world, vis):
vis
.
start_stop
()
def
help_tab
():
vcontrols
=
QLabel
(
"view controls:"
)
lmd
=
QLabel
(
"
\t
mouse dragging with left mouse button:
\n\t\t
rotation (only in 3D)"
)
rmd
=
QLabel
(
"
\t
mouse dragging with right mouse button:
\n\t\t
dragging the view"
)
mw
=
QLabel
(
"
\t
scrolling:
\n\t\t
zooming"
)
ccontrols
=
QLabel
(
"
\n
cursor controls:"
)
sc
=
QLabel
(
"
\t
holding 'CTRL':
\n\t\t
show cursor"
)
mcc
=
QLabel
(
"
\t
left mouse button click while holding 'CTRL':
\n\t\t
adding/removing matter at cursors position"
)
mwc
=
QLabel
(
"
\t
scrolling while holding 'CTRL':
\n\t\t
moving the cursor in the relative z-direction"
)
scontrols
=
QLabel
(
"
\n
simulation controls:"
)
sss
=
QLabel
(
"
\t
spacebar:
\n\t\t
start / stop the simulation"
)
vbox
=
QVBoxLayout
()
vbox
.
addWidget
(
vcontrols
)
vbox
.
addWidget
(
lmd
)
vbox
.
addWidget
(
rmd
)
vbox
.
addWidget
(
mw
)
vbox
.
addWidget
(
ccontrols
)
vbox
.
addWidget
(
sc
)
vbox
.
addWidget
(
mcc
)
vbox
.
addWidget
(
mwc
)
vbox
.
addWidget
(
scontrols
)
vbox
.
addWidget
(
sss
)
vbox
.
addStretch
(
0
)
tabbar
=
QTabBar
()
tabbar
.
setLayout
(
vbox
)
return
tabbar
def
create_slider
(
tick_interval
:
int
,
tick_position
:
int
,
max_position
:
int
,
min_position
:
int
,
slider_position
:
int
,
callback
,
orientation
=
Qt
.
Horizontal
):
"""
helper function for creating a slider
"""
slider
=
QSlider
(
orientation
)
slider
.
setTickInterval
(
tick_interval
)
slider
.
setTickPosition
(
tick_position
)
slider
.
setMaximum
(
max_position
)
slider
.
setMinimum
(
min_position
)
slider
.
setSliderPosition
(
slider_position
)
slider
.
valueChanged
.
connect
(
callback
)
return
slider
def
sim_tab
(
vis
,
world
):
tab
=
QTabBar
()
layout
=
QVBoxLayout
()
...
...
@@ -109,7 +141,7 @@ def grid_tab(vis: Visualization):
layout
=
QVBoxLayout
()
layout
.
addLayout
(
get_grid_width_slider
(
vis
))
layout
.
addLayout
(
get_grid_lines_scale_slider
(
vis
))
layout
.
addLayout
(
get_grid_
location
s_scale_slider
(
vis
))
layout
.
addLayout
(
get_grid_
coordinate
s_scale_slider
(
vis
))
layout
.
addLayout
(
get_show_checkboxes
(
vis
))
layout
.
addLayout
(
recalculate_grid
(
vis
))
layout
.
addLayout
(
get_color_picker
(
vis
))
...
...
@@ -121,14 +153,34 @@ def grid_tab(vis: Visualization):
def
matter_tab
(
vis
):
tab
=
QTabBar
()
layout
=
QVBoxLayout
()
layout
.
addLayout
(
get_matter_combo
(
vis
))
layout
.
addStretch
(
1
)
layout
.
addLayout
(
get_particle_scaler
(
vis
))
layout
.
addLayout
(
get_marker_scaler
(
vis
))
layout
.
addStretch
(
1
)
layout
.
addLayout
(
get_location_scaler
(
vis
))
layout
.
addStretch
(
1
)
layout
.
addLayout
(
get_tile_scaler
(
vis
))
layout
.
addStretch
(
0
)
layout
.
addStretch
(
1
)
tab
.
setLayout
(
layout
)
return
tab
def
get_matter_combo
(
vis
):
combo
=
QComboBox
()
combo
.
addItems
([
"particle"
,
"tile"
,
"location"
])
combo
.
setCurrentIndex
(
1
)
def
on_change
(
value
):
print
(
value
)
combo
.
currentTextChanged
.
connect
(
on_change
)
desc
=
QLabel
(
"matter to create on cursor click:"
)
vbox
=
QVBoxLayout
()
vbox
.
addWidget
(
desc
,
alignment
=
Qt
.
AlignBaseline
)
vbox
.
addWidget
(
combo
,
alignment
=
Qt
.
AlignBaseline
)
return
vbox
def
get_particle_scaler
(
vis
):
def
x_scaler_change
(
value
):
current_scaling
=
vis
.
get_particle_scaling
()
...
...
@@ -221,23 +273,23 @@ def get_tile_scaler(vis):
return
vbox
def
get_
marker
_scaler
(
vis
):
def
get_
location
_scaler
(
vis
):
def
x_scaler_change
(
value
):
current_scaling
=
vis
.
get_
marker
_scaling
()
current_scaling
=
vis
.
get_
location
_scaling
()
print
(
current_scaling
)
new_scaling
=
(
value
/
10.0
,
current_scaling
[
1
],
current_scaling
[
2
])
print
(
new_scaling
)
vis
.
set_
marker
_scaling
(
new_scaling
)
vis
.
set_
location
_scaling
(
new_scaling
)
def
y_scaler_change
(
value
):
current_scaling
=
vis
.
get_
marker
_scaling
()
current_scaling
=
vis
.
get_
location
_scaling
()
new_scaling
=
(
current_scaling
[
0
],
value
/
10.0
,
current_scaling
[
2
])
vis
.
set_
marker
_scaling
(
new_scaling
)
vis
.
set_
location
_scaling
(
new_scaling
)
def
z_scaler_change
(
value
):
current_scaling
=
vis
.
get_
marker
_scaling
()
current_scaling
=
vis
.
get_
location
_scaling
()
new_scaling
=
(
current_scaling
[
0
],
current_scaling
[
1
],
value
/
10.0
)
vis
.
set_
marker
_scaling
(
new_scaling
)
vis
.
set_
location
_scaling
(
new_scaling
)
x_desc
=
QLabel
(
"x scale:"
)
y_desc
=
QLabel
(
"y scale:"
)
...
...
@@ -259,7 +311,7 @@ def get_marker_scaler(vis):
hbox3
.
addWidget
(
z_scaler
,
alignment
=
Qt
.
AlignBaseline
)
vbox
=
QVBoxLayout
()
vbox
.
addWidget
(
QLabel
(
"
marker
scaling:"
),
alignment
=
Qt
.
AlignBaseline
)
vbox
.
addWidget
(
QLabel
(
"
location
scaling:"
),
alignment
=
Qt
.
AlignBaseline
)
vbox
.
addLayout
(
hbox1
)
vbox
.
addLayout
(
hbox2
)
vbox
.
addLayout
(
hbox3
)
...
...
@@ -372,15 +424,15 @@ def get_color_picker(vis):
lines_button
.
clicked
.
connect
(
lines
)
locs_button
=
QPushButton
(
"grid
location
s"
)
locs_button
=
QPushButton
(
"grid
coordinate
s"
)
def
locs
():
qcd
=
QColorDialog
()
qcd
.
setOption
(
QColorDialog
.
ShowAlphaChannel
)
qcd
.
setCurrentColor
(
QColor
.
fromRgbF
(
*
vis
.
get_grid_
location
_color
()))
qcd
.
setCurrentColor
(
QColor
.
fromRgbF
(
*
vis
.
get_grid_
coordinates
_color
()))
qcd
.
exec
()
if
qcd
.
result
()
==
1
:
vis
.
set_grid_
location
_color
((
qcd
.
selectedColor
().
getRgbF
()))
vis
.
set_grid_
coordinates
_color
((
qcd
.
selectedColor
().
getRgbF
()))
locs_button
.
clicked
.
connect
(
locs
)
...
...
@@ -432,14 +484,14 @@ def get_show_checkboxes(vis):
vis
.
set_show_lines
(
lines_cb
.
isChecked
())
lines_cb
.
clicked
.
connect
(
lines_clicked
)
loc
s_cb
=
QCheckBox
()
loc
s_cb
.
setText
(
"show
location
s"
)
loc
s_cb
.
setChecked
(
vis
.
get_show_
location
s
())
coord
s_cb
=
QCheckBox
()
coord
s_cb
.
setText
(
"show
coordinate
s"
)
coord
s_cb
.
setChecked
(
vis
.
get_show_
coordinate
s
())
def
loc
s_clicked
():
vis
.
set_show_
locations
(
loc
s_cb
.
isChecked
())
def
coord
s_clicked
():
vis
.
set_show_
coordinates
(
coord
s_cb
.
isChecked
())
loc
s_cb
.
clicked
.
connect
(
loc
s_clicked
)
coord
s_cb
.
clicked
.
connect
(
coord
s_clicked
)
center_cb
=
QCheckBox
()
center_cb
.
setText
(
"show center"
)
...
...
@@ -470,7 +522,7 @@ def get_show_checkboxes(vis):
hbox1
=
QHBoxLayout
()
hbox1
.
addWidget
(
lines_cb
)
hbox1
.
addWidget
(
loc
s_cb
)
hbox1
.
addWidget
(
coord
s_cb
)
hbox2
=
QHBoxLayout
()
hbox2
.
addWidget
(
center_cb
)
hbox2
.
addWidget
(
focus_cb
)
...
...
@@ -498,16 +550,16 @@ def get_grid_lines_scale_slider(vis):
return
vbox
def
get_grid_
location
s_scale_slider
(
vis
):
def
get_grid_
coordinate
s_scale_slider
(
vis
):
vbox
=
QVBoxLayout
()
desc
=
QLabel
(
"grid
location
s model scale (%d%%):"
%
int
(
vis
.
get_grid_
location
_scaling
()[
0
]
*
500
))
desc
=
QLabel
(
"grid
coordinate
s model scale (%d%%):"
%
int
(
vis
.
get_grid_
coordinates
_scaling
()[
0
]
*
500
))
vbox
.
addWidget
(
desc
,
alignment
=
Qt
.
AlignBaseline
)
def
set_scale
(
value
):
vis
.
set_grid_
location
_scaling
([
value
/
1000.0
,
value
/
1000.0
,
value
/
1000.0
])
desc
.
setText
(
"grid
location
s model scale (%d%%):"
%
(
int
(
value
/
2.0
)))
vis
.
set_grid_
coordinates
_scaling
([
value
/
1000.0
,
value
/
1000.0
,
value
/
1000.0
])
desc
.
setText
(
"grid
coordinate
s model scale (%d%%):"
%
(
int
(
value
/
2.0
)))
vbox
.
addWidget
(
create_slider
(
10
,
2
,
200
,
10
,
int
(
vis
.
get_grid_
location
_scaling
()[
0
]
*
1000.0
),
set_scale
),
vbox
.
addWidget
(
create_slider
(
10
,
2
,
200
,
10
,
int
(
vis
.
get_grid_
coordinates
_scaling
()[
0
]
*
1000.0
),
set_scale
),
alignment
=
Qt
.
AlignBaseline
)
return
vbox
...
...
gui/empty_gui.py
View file @
03a6f9f4
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtWidgets
import
QVBoxLayout
,
QLabel
,
QSlider
from
lib.vis3d
import
Visualization
from
lib.world
import
World
...
...
lib/config.py
View file @
03a6f9f4
...
...
@@ -37,11 +37,11 @@ class ConfigData:
self
.
particle_model_file
=
config
.
get
(
"Visualization"
,
"particle_model_file"
)
self
.
tile_model_file
=
config
.
get
(
"Visualization"
,
"tile_model_file"
)
self
.
marker
_model_file
=
config
.
get
(
"Visualization"
,
"
marker
_model_file"
)
self
.
location
_model_file
=
config
.
get
(
"Visualization"
,
"
location
_model_file"
)
self
.
particle_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"particle_color"
))
self
.
tile_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"tile_color"
))
self
.
marker
_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
marker
_color"
))
self
.
location
_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
location
_color"
))
self
.
grid_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"grid_color"
))
self
.
cursor_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"cursor_color"
))
self
.
background_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"background_color"
))
...
...
@@ -49,9 +49,9 @@ class ConfigData:
self
.
line_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"line_color"
))
self
.
line_scaling
=
make_tuple
(
config
.
get
(
"Visualization"
,
"line_scaling"
))
self
.
show_lines
=
config
.
getboolean
(
"Visualization"
,
"show_lines"
)
self
.
location
_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
location
_color"
))
self
.
location
_scaling
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
location
_scaling"
))
self
.
show_
location
s
=
config
.
getboolean
(
"Visualization"
,
"show_
location
s"
)
self
.
coordinates
_color
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
coordinates
_color"
))
self
.
coordinates
_scaling
=
make_tuple
(
config
.
get
(
"Visualization"
,
"
coordinates
_scaling"
))
self
.
show_
coordinate
s
=
config
.
getboolean
(
"Visualization"
,
"show_
coordinate
s"
)
self
.
show_center
=
config
.
getboolean
(
"Visualization"
,
"show_center"
)