Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
010d01b0
Commit
010d01b0
authored
Jun 30, 2020
by
Gauthier Quesnel
Browse files
gui: update automatic layout menu item
parent
d152c2bb
Pipeline
#14779
passed with stage
in 1 minute and 54 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
app/gui/node-editor.cpp
View file @
010d01b0
...
...
@@ -321,8 +321,6 @@ editor::group(const ImVector<int>& nodes) noexcept
return
;
}
iteration
=
0
;
/* First, move children models and groups from the current cluster into the
newly allocated cluster. */
...
...
@@ -440,8 +438,6 @@ editor::ungroup(const int node) noexcept
return
;
}
iteration
=
0
;
const
auto
group_id
=
clusters
.
get_id
(
*
group
);
top
.
pop
(
index
);
...
...
@@ -830,7 +826,7 @@ compute_connection_distance(output_port& port, editor& ed, const float k)
}
void
editor
::
reorder
()
noexcept
editor
::
compute_grid_layout
()
noexcept
{
const
auto
size
=
length
(
top
.
children
);
const
auto
tmp
=
std
::
sqrt
(
size
);
...
...
@@ -872,7 +868,7 @@ editor::reorder() noexcept
}
void
editor
::
compute_automatic_layout
_iteration
()
noexcept
editor
::
compute_automatic_layout
()
noexcept
{
/* See. Graph drawing by Forced-directed Placement by Thomas M. J.
Fruchterman and Edward M. Reingold in Software--Pratice and
...
...
@@ -902,6 +898,8 @@ editor::compute_automatic_layout_iteration() noexcept
float
t
=
1.
f
-
1.
f
/
static_cast
<
float
>
(
automatic_layout_iteration_limit
);
for
(
int
iteration
=
0
;
iteration
<
automatic_layout_iteration_limit
;
++
iteration
)
{
for
(
int
i_v
=
0
;
i_v
<
size
;
++
i_v
)
{
const
int
v
=
i_v
;
...
...
@@ -930,14 +928,16 @@ editor::compute_automatic_layout_iteration() noexcept
const
auto
id
=
std
::
get
<
model_id
>
(
top
.
children
[
i
].
first
);
if
(
const
auto
*
mdl
=
sim
.
models
.
try_to_get
(
id
);
mdl
)
{
sim
.
for_all_output_port
(
*
mdl
,
[
this
,
k
](
output_port
&
port
,
output_port_id
/*id*/
)
{
*
mdl
,
[
this
,
k
](
output_port
&
port
,
output_port_id
/*id*/
)
{
compute_connection_distance
(
port
,
*
this
,
k
);
});
}
}
else
{
const
auto
id
=
std
::
get
<
cluster_id
>
(
top
.
children
[
i
].
first
);
if
(
auto
*
gp
=
clusters
.
try_to_get
(
id
);
gp
)
{
for_each
(
sim
.
output_ports
,
for_each
(
sim
.
output_ports
,
gp
->
output_ports
,
[
this
,
k
](
output_port
&
port
,
output_port_id
/*id*/
)
{
compute_connection_distance
(
port
,
*
this
,
k
);
...
...
@@ -968,8 +968,7 @@ editor::compute_automatic_layout_iteration() noexcept
imnodes
::
SetNodeGridSpacePos
(
top
.
children
[
v
].
second
,
positions
[
v
]);
}
++
iteration
;
}
}
status
...
...
@@ -1135,8 +1134,6 @@ editor::add_lotka_volterra() noexcept
parent
(
quantifier_a
.
id
,
undefined
<
cluster_id
>
());
parent
(
quantifier_b
.
id
,
undefined
<
cluster_id
>
());
iteration
=
0
;
return
status
::
success
;
}
...
...
@@ -1301,8 +1298,6 @@ editor::add_izhikevitch() noexcept
parent
(
cross
.
id
,
undefined
<
cluster_id
>
());
parent
(
cross2
.
id
,
undefined
<
cluster_id
>
());
iteration
=
0
;
return
status
::
success
;
}
...
...
@@ -2106,9 +2101,9 @@ editor::show_editor() noexcept
if
(
ImGui
::
MenuItem
(
"Clear"
))
clear
();
if
(
ImGui
::
MenuItem
(
"Grid Reorder"
))
reorder
();
if
(
ImGui
::
MenuItem
(
"Automatic Layout"
,
nullptr
,
&
automatic_layout
))
iteration
=
0
;
compute_grid_layout
();
if
(
ImGui
::
MenuItem
(
"Automatic Layout"
))
compute_automatic_layout
()
;
ImGui
::
EndMenu
();
}
...
...
@@ -2195,12 +2190,6 @@ editor::show_editor() noexcept
ImGui
::
PushStyleVar
(
ImGuiStyleVar_WindowPadding
,
ImVec2
(
8.
f
,
8.
f
));
if
(
imnodes
::
IsAnyAttributeActive
(
nullptr
))
iteration
=
0
;
if
(
automatic_layout
&&
iteration
<
automatic_layout_iteration_limit
)
compute_automatic_layout_iteration
();
if
(
!
ImGui
::
IsAnyItemHovered
()
&&
ImGui
::
IsMouseClicked
(
1
))
ImGui
::
OpenPopup
(
"Context menu"
);
...
...
@@ -2222,7 +2211,6 @@ editor::show_editor() noexcept
parent
(
new_model
,
undefined
<
cluster_id
>
());
imnodes
::
SetNodeScreenSpacePos
(
top
.
emplace_back
(
new_model
),
click_pos
);
iteration
=
0
;
}
}
...
...
app/gui/node-editor.hpp
View file @
010d01b0
...
...
@@ -251,8 +251,6 @@ struct editor
imnodes
::
EditorContext
*
context
=
nullptr
;
bool
initialized
=
false
;
bool
show
=
true
;
bool
automatic_layout
=
false
;
int
iteration
=
0
;
simulation
sim
;
double
simulation_begin
=
0.0
;
...
...
@@ -285,8 +283,8 @@ struct editor
void
free_children
(
const
ImVector
<
int
>&
nodes
)
noexcept
;
status
copy
(
const
ImVector
<
int
>&
nodes
)
noexcept
;
void
reorder
()
noexcept
;
void
compute_automatic_layout
_iteration
()
noexcept
;
void
compute_grid_layout
()
noexcept
;
void
compute_automatic_layout
()
noexcept
;
bool
is_in_hierarchy
(
const
cluster
&
group
,
const
cluster_id
group_to_search
)
const
noexcept
;
...
...
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