Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Enhanced Ground Software
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Skyward Enhanced Ground Software
Commits
c8ba50d4
Commit
c8ba50d4
authored
5 months ago
by
Alberto Nidasio
Committed by
Federico Lolli
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
PID editor can now be locked to disable editing
parent
dbd24c54
No related branches found
No related tags found
1 merge request
!15
Integrated P&ID Editor and Configurable Pane
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ui/panes/pid_drawing_tool.rs
+60
-35
60 additions, 35 deletions
src/ui/panes/pid_drawing_tool.rs
with
60 additions
and
35 deletions
src/ui/panes/pid_drawing_tool.rs
+
60
−
35
View file @
c8ba50d4
...
@@ -39,6 +39,9 @@ pub struct PidPane {
...
@@ -39,6 +39,9 @@ pub struct PidPane {
#[serde(skip)]
#[serde(skip)]
action
:
Option
<
Action
>
,
action
:
Option
<
Action
>
,
#[serde(skip)]
editable
:
bool
,
}
}
impl
Default
for
PidPane
{
impl
Default
for
PidPane
{
...
@@ -47,8 +50,8 @@ impl Default for PidPane {
...
@@ -47,8 +50,8 @@ impl Default for PidPane {
elements
:
Vec
::
default
(),
elements
:
Vec
::
default
(),
connections
:
Vec
::
default
(),
connections
:
Vec
::
default
(),
grid
:
GridInfo
{
size
:
10.0
},
grid
:
GridInfo
{
size
:
10.0
},
action
:
None
,
action
:
None
,
editable
:
false
,
}
}
}
}
}
}
...
@@ -56,8 +59,12 @@ impl Default for PidPane {
...
@@ -56,8 +59,12 @@ impl Default for PidPane {
impl
PaneBehavior
for
PidPane
{
impl
PaneBehavior
for
PidPane
{
fn
ui
(
&
mut
self
,
ui
:
&
mut
egui
::
Ui
)
->
PaneResponse
{
fn
ui
(
&
mut
self
,
ui
:
&
mut
egui
::
Ui
)
->
PaneResponse
{
let
theme
=
PidPane
::
find_theme
(
ui
.ctx
());
let
theme
=
PidPane
::
find_theme
(
ui
.ctx
());
if
self
.editable
{
self
.draw_grid
(
theme
,
ui
);
self
.draw_grid
(
theme
,
ui
);
self
.draw_connections
(
theme
,
ui
);
}
self
.draw_connections
(
theme
,
self
.editable
,
ui
);
self
.draw_elements
(
theme
,
ui
);
self
.draw_elements
(
theme
,
ui
);
// Allocate the space to sense inputs
// Allocate the space to sense inputs
...
@@ -66,8 +73,9 @@ impl PaneBehavior for PidPane {
...
@@ -66,8 +73,9 @@ impl PaneBehavior for PidPane {
// Set grab icon when hovering an element
// Set grab icon when hovering an element
if
let
Some
(
pointer_pos
)
=
&
pointer_pos
{
if
let
Some
(
pointer_pos
)
=
&
pointer_pos
{
if
self
.is_hovering_element
(
pointer_pos
)
if
self
.editable
||
self
.is_hovering_connection_point
(
pointer_pos
)
&&
(
self
.is_hovering_element
(
pointer_pos
)
||
self
.is_hovering_connection_point
(
pointer_pos
))
{
{
ui
.ctx
()
ui
.ctx
()
.output_mut
(|
output
|
output
.cursor_icon
=
CursorIcon
::
Grab
);
.output_mut
(|
output
|
output
.cursor_icon
=
CursorIcon
::
Grab
);
...
@@ -79,7 +87,8 @@ impl PaneBehavior for PidPane {
...
@@ -79,7 +87,8 @@ impl PaneBehavior for PidPane {
if
response
.clicked_by
(
PointerButton
::
Secondary
)
{
if
response
.clicked_by
(
PointerButton
::
Secondary
)
{
println!
(
"Context menu opened"
);
println!
(
"Context menu opened"
);
self
.action
=
Some
(
Action
::
ContextMenu
(
pointer_pos
.clone
()));
self
.action
=
Some
(
Action
::
ContextMenu
(
pointer_pos
.clone
()));
}
else
if
response
.drag_started
()
{
}
else
if
self
.editable
{
if
response
.drag_started
()
{
println!
(
"Checking drag start at {:?}"
,
pointer_pos
);
println!
(
"Checking drag start at {:?}"
,
pointer_pos
);
if
let
Some
(
drag_connection_point
)
=
self
if
let
Some
(
drag_connection_point
)
=
self
.find_hovered_connection_point
(
pointer_pos
)
.find_hovered_connection_point
(
pointer_pos
)
...
@@ -100,6 +109,7 @@ impl PaneBehavior for PidPane {
...
@@ -100,6 +109,7 @@ impl PaneBehavior for PidPane {
println!
(
"Drag stopped"
);
println!
(
"Drag stopped"
);
}
}
}
}
}
// Context menu
// Context menu
if
let
Some
(
Action
::
ContextMenu
(
pointer_pos
))
=
self
.action
.clone
()
{
if
let
Some
(
Action
::
ContextMenu
(
pointer_pos
))
=
self
.action
.clone
()
{
...
@@ -236,7 +246,7 @@ impl PidPane {
...
@@ -236,7 +246,7 @@ impl PidPane {
}
}
}
}
fn
draw_connections
(
&
self
,
theme
:
Theme
,
ui
:
&
Ui
)
{
fn
draw_connections
(
&
self
,
theme
:
Theme
,
draw_handles
:
bool
,
ui
:
&
Ui
)
{
let
painter
=
ui
.painter
();
let
painter
=
ui
.painter
();
for
connection
in
&
self
.connections
{
for
connection
in
&
self
.connections
{
...
@@ -270,7 +280,8 @@ impl PidPane {
...
@@ -270,7 +280,8 @@ impl PidPane {
painter
.line_segment
([
a
,
b
],
PathStroke
::
new
(
2.0
,
line_color
));
painter
.line_segment
([
a
,
b
],
PathStroke
::
new
(
2.0
,
line_color
));
}
}
// Draw dragging boxes
// Draw handles (dragging boxes)
if
draw_handles
{
for
middle_point
in
&
connection
.middle_points
{
for
middle_point
in
&
connection
.middle_points
{
painter
.rect
(
painter
.rect
(
egui
::
Rect
::
from_center_size
(
egui
::
Rect
::
from_center_size
(
...
@@ -284,6 +295,7 @@ impl PidPane {
...
@@ -284,6 +295,7 @@ impl PidPane {
}
}
}
}
}
}
}
fn
draw_elements
(
&
self
,
theme
:
Theme
,
ui
:
&
Ui
)
{
fn
draw_elements
(
&
self
,
theme
:
Theme
,
ui
:
&
Ui
)
{
for
element
in
&
self
.elements
{
for
element
in
&
self
.elements
{
...
@@ -307,6 +319,14 @@ impl PidPane {
...
@@ -307,6 +319,14 @@ impl PidPane {
fn
draw_context_menu
(
&
mut
self
,
pointer_pos
:
&
Pos2
,
ui
:
&
mut
Ui
)
{
fn
draw_context_menu
(
&
mut
self
,
pointer_pos
:
&
Pos2
,
ui
:
&
mut
Ui
)
{
ui
.set_max_width
(
120.0
);
// To make sure we wrap long text
ui
.set_max_width
(
120.0
);
// To make sure we wrap long text
if
!
self
.editable
{
if
ui
.button
(
"Enable editing"
)
.clicked
()
{
self
.editable
=
true
;
ui
.close_menu
();
}
return
;
}
if
self
.is_hovering_element
(
&
pointer_pos
)
{
if
self
.is_hovering_element
(
&
pointer_pos
)
{
let
hovered_element
=
self
.find_hovered_element_idx
(
&
pointer_pos
);
let
hovered_element
=
self
.find_hovered_element_idx
(
&
pointer_pos
);
if
ui
.button
(
"Connect"
)
.clicked
()
{
if
ui
.button
(
"Connect"
)
.clicked
()
{
...
@@ -373,6 +393,11 @@ impl PidPane {
...
@@ -373,6 +393,11 @@ impl PidPane {
}
}
});
});
}
}
if
ui
.button
(
"Disable editing"
)
.clicked
()
{
self
.editable
=
false
;
ui
.close_menu
();
}
}
}
fn
delete_element
(
&
mut
self
,
idx
:
usize
)
{
fn
delete_element
(
&
mut
self
,
idx
:
usize
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment