Skip to content

Commit b2ed071

Browse files
authored
Merge branch 'develop' into compathelper/new_version/2025-02-06-01-02-16-409-00441822848
2 parents 5575080 + b5593f2 commit b2ed071

13 files changed

+90
-50
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
22

3+
# v0.26
4+
- Graph structure plotting now uses GraphMakie.jl instead of GraphPlot.jl. Update by replacing `using GraphPlot` with `using GraphMakie`.
5+
36
# v0.25
47
- Deprecated nouns:
58
SessionBlobEntry -> GraphBlobEntry

Project.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.25.4"
3+
version = "0.26.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -33,11 +33,11 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
3333

3434
[weakdeps]
3535
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
36-
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
36+
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
3737

3838
[extensions]
3939
BlobArrow = "Arrow"
40-
DFGPlots = "GraphPlot"
40+
DFGPlots = "GraphMakie"
4141

4242
[compat]
4343
Aqua = "0.8"
@@ -51,7 +51,7 @@ Dates = "1.10"
5151
Distributions = "0.23, 0.24, 0.25"
5252
DocStringExtensions = "0.8, 0.9"
5353
FileIO = "1"
54-
GraphPlot = "0.5.0, 0.6"
54+
GraphMakie = "0.5.14"
5555
Graphs = "1.4"
5656
InteractiveUtils = "1.10"
5757
JSON3 = "1"
@@ -79,12 +79,12 @@ julia = "1.10"
7979
[extras]
8080
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
8181
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
82-
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
82+
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
8383
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8484
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
8585
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
8686
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
8787
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8888

8989
[targets]
90-
test = ["Aqua", "Test", "DataStructures", "GraphPlot", "LinearAlgebra", "Manifolds", "Pkg", "Statistics"]
90+
test = ["Aqua", "Test", "DataStructures", "GraphMakie", "LinearAlgebra", "Manifolds", "Pkg", "Statistics"]

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
33
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
44
DistributedFactorGraphs = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
55
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
6-
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
6+
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
77

88
[compat]
99
Documenter = "1"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Documenter
2-
using GraphPlot
2+
using GraphMakie
33
using DistributedFactorGraphs
44

55
makedocs(;

docs/src/DrawingGraphs.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Drawing Graphs
22

3-
Graphs can be visualized by using either `GraphPlot` or rendering to .dot files (which can be viewed using xdot).
3+
Graphs can be visualized by using either `GraphMakie` or rendering to .dot files (which can be viewed using xdot).
44

5-
## GraphPlot
5+
## GraphMakie
66

7-
`GraphPlot` plotting is available if `GraphPlot` is imported before DFG is imported. Install `GraphPlot` using the following command:
7+
`GraphMakie` plotting is available if `GraphMakie` is imported before DFG is imported. Install `GraphMakie` using the following command:
88

99
```julia
1010
using Pkg
11-
Pkg.add("GraphPlot")
11+
Pkg.add("GraphMakie")
1212
```
1313

14-
Then bring `GraphPlot` in before DFG:
14+
Then bring `GraphMakie` in before DFG:
1515

1616
```julia
17-
using GraphPlot
17+
using GraphMakie
1818
using DistributedFactorGraphs
1919
```
2020

@@ -38,7 +38,7 @@ f1 = addFactor!(dfg, [:l0; :x1], LinearRelative(Normal(-10.0,5.0)), solvable=1)
3838
plotDFG(dfg)
3939
```
4040

41-
### Rendering GraphPlot to PDF
41+
### Rendering GraphMakie to PDF
4242

4343
The graph can be rendered to PDF, SVG or JPG in the following way by including compose:
4444

@@ -57,12 +57,12 @@ FIXME show graph.svg
5757

5858
### More Information
5959

60-
More information at [GraphPlot.jl](https://github.com/JuliaGraphs/GraphPlot.jl)
60+
More information at [GraphMakie.jl](https://github.com/MakieOrg/GraphMakie.jl)
6161

6262
## Dot Files
6363

6464
Dot files are a standard format for visualizing graphs and applications such as
65-
xdot are available to view the files. Dot plotting does not require `GraphPlot`
65+
xdot are available to view the files. Dot plotting does not require `GraphMakie`
6666
and can be drawn by either:
6767
- Calling [`toDot`](@ref) on any graph to produce a string of the graph
6868
- Calling [`toDotFile`](@ref) on any graph to save it directly to a dotfile

docs/src/func_ref.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Modules = [DistributedFactorGraphs]
4444
Pages = ["entities/DFGFactor.jl"]
4545
```
4646

47-
## DFG Plots [GraphPlot.jl]
47+
## DFG Plots [GraphMakie.jl]
4848

4949
```@autodocs
5050
Modules = [DistributedFactorGraphs]

ext/DFGPlots.jl

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module DFGPlots
22

33
using Colors
44
using Graphs
5-
using GraphPlot
65
using DocStringExtensions
7-
import GraphPlot: gplot
6+
using GraphMakie
87

98
using DistributedFactorGraphs
109

11-
import DistributedFactorGraphs.plotDFG
10+
import DistributedFactorGraphs: plotDFG
11+
import GraphMakie: graphplot
1212

1313
export plotDFG, DFGPlotProps
1414

@@ -17,40 +17,77 @@ struct DFGPlotProps
1717
nodesize::NamedTuple{(:var, :fac), Tuple{Float64, Float64}}
1818
shape::NamedTuple{(:var, :fac), Tuple{Symbol, Symbol}} #not upported yet
1919

20-
layout::Function #spring_layout, spectral_layout
20+
layout::Any #FIXME add layout type
2121
drawlabels::Bool
2222
end
2323

2424
function DFGPlotProps()
2525
return DFGPlotProps(
26-
(var = colorant"seagreen", fac = colorant"cyan3"),
27-
(var = 1.0, fac = 0.3),
28-
(var = :box, fac = :elipse),
29-
spring_layout,
26+
(var = colorant"lightgreen", fac = colorant"cyan3"),
27+
(var = 40.0, fac = 20.0),
28+
(var = :circle, fac = :rect),
29+
GraphMakie.Stress(),
3030
true,
3131
)
3232
end
3333

34-
function plotDFG(dfg::GraphsDFG, p::DFGPlotProps = DFGPlotProps())
34+
function plotDFG(dfg::GraphsDFG; p::DFGPlotProps = DFGPlotProps(), interactive::Bool = true)
3535
nodetypes = [haskey(dfg.g.variables, s) for s in dfg.g.labels]
3636

3737
nodesize = [isVar ? p.nodesize.var : p.nodesize.fac for isVar in nodetypes]
3838
# nodelabel = [isVar ? string(get_prop(dfg.g,i,:label)) : "" for (i,isVar) in enumerate(nodetypes)]
3939
if p.drawlabels
40-
nodelabel = [nodetypes[i] ? string(s) : "" for (i, s) in enumerate(dfg.g.labels)]
40+
ilabels = [nodetypes[i] ? string(s) : "" for (i, s) in enumerate(dfg.g.labels)]
4141
else
42-
nodelabel = nothing
42+
ilabels = nothing
4343
end
4444

45-
nodefillc = [isVar ? p.nodefillc.var : p.nodefillc.fac for isVar in nodetypes]
45+
node_color = [isVar ? p.nodefillc.var : p.nodefillc.fac for isVar in nodetypes]
46+
marker = [isVar ? p.shape.var : p.shape.fac for isVar in nodetypes]
4647

47-
return gplot(
48+
figaxpl = graphplot(
4849
dfg.g;
49-
nodelabel = nodelabel,
50-
nodesize = nodesize,
51-
nodefillc = nodefillc,
50+
ilabels,
5251
layout = p.layout,
52+
node_size = nodesize,
53+
node_color,
54+
node_attr = (marker = marker,),
5355
)
56+
57+
(f, ax, p) = figaxpl
58+
59+
label_text = GraphMakie.text!(
60+
ax,
61+
0,
62+
0;
63+
text = "",
64+
font = :bold,
65+
fontsize = 30,
66+
glowcolor = (:white, 1),
67+
glowwidth = 3,
68+
)
69+
70+
ax.aspect = GraphMakie.DataAspect()
71+
if interactive
72+
function node_drag_action(state, idx, event, axis)
73+
p[:node_pos][][idx] = event.data
74+
return p[:node_pos][] = p[:node_pos][]
75+
end
76+
GraphMakie.hidedecorations!(ax)
77+
GraphMakie.hidespines!(ax)
78+
ndrag = NodeDragHandler(node_drag_action)
79+
GraphMakie.deregister_interaction!(ax, :rectanglezoom)
80+
GraphMakie.register_interaction!(ax, :ndrag, ndrag)
81+
82+
function node_hover_action(state, idx, event, axis)
83+
label = dfg.g.labels[idx]
84+
label_text.text[] = state ? string(label) : ""
85+
return label_text.transformation.translation[] = (event.data..., 0)
86+
end
87+
nhover = NodeHoverHandler(node_hover_action)
88+
GraphMakie.register_interaction!(ax, :nhover, nhover)
89+
end
90+
return figaxpl
5491
end
5592

5693
function plotDFG(dfg::AbstractDFG, p::DFGPlotProps = DFGPlotProps())
@@ -60,8 +97,8 @@ function plotDFG(dfg::AbstractDFG, p::DFGPlotProps = DFGPlotProps())
6097
return plotDFG(ldfg, p)
6198
end
6299

63-
function gplot(dfg::GraphsDFG; keyargs...)
64-
return gplot(dfg.g; keyargs...)
100+
function graphplot(dfg::GraphsDFG; keyargs...)
101+
return graphplot(dfg.g; keyargs...)
65102
end
66103

67104
end

src/entities/DFGVariable.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ getEstimateFields(::MeanMaxPPE) = [:suggested, :max, :mean]
210210
$(TYPEDEF)
211211
212212
The Variable information packed in a way that accomdates multi-lang using json.
213+
214+
Notes:
215+
- timestamp is a `ZonedDateTime` in UTC.
216+
- nstime can be used as mission time, with the convention that the timestamp millis coincide with the mission start nstime
217+
- e.g. timestamp is `2020-01-01 06:30:01.250 UTC` and first nstime is `250_000_000`.
213218
"""
214219
Base.@kwdef struct VariableDFG <: AbstractDFGVariable
215220
id::Union{UUID, Nothing} = nothing

src/weakdeps_prototypes.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
"""
22
$(SIGNATURES)
3-
Plots the structure of the factor graph. GraphPlot must be imported before DistributedFactorGraphs for these functions to be available.
3+
Plots the structure of the factor graph. GraphMakie must be imported before DistributedFactorGraphs for these functions to be available.
44
Returns the plot context.
55
66
E.g.
77
```
8-
using GraphPlot
9-
using DistributedFactorGraphs, DistributedFactorGraphs.DFGPlots
8+
using GraphMakie
9+
using DistributedFactorGraphs
1010
# ... Make graph...
11-
# Using GraphViz plotting
1211
plotDFG(fg)
13-
# Save to PDF
14-
using Compose
15-
draw(PDF("/tmp/graph.pdf", 16cm, 16cm), plotDFG(fg))
1612
```
17-
18-
More information at [GraphPlot.jl](https://github.com/JuliaGraphs/GraphPlot.jl)
13+
More information at [GraphMakie.jl](https://github.com/MakieOrg/GraphMakie.jl)
1914
"""
2015
function plotDFG end

test/consol_DataEntryBlobTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if false
22
using Test
3-
using GraphPlot
3+
using GraphMakie
44
using DistributedFactorGraphs
55
using Pkg
66
using Dates

test/interfaceTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if false
22
using Test
3-
using GraphPlot
3+
using GraphMakie
44
using DistributedFactorGraphs
55
using Pkg
66
using Dates

test/plottingTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GraphPlot
1+
using GraphMakie
22
using DistributedFactorGraphs
33
# using DistributedFactorGraphs.DFGPlots
44
using Test
@@ -27,7 +27,7 @@ map(
2727

2828
##
2929

30-
# Using GraphPlot plotting
30+
# Using GraphMakie plotting
3131
plot = plotDFG(dfg)
3232
@test plot !== nothing
3333

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Test
2-
using GraphPlot # For plotting tests
2+
using GraphMakie # For plotting tests
33
using DistributedFactorGraphs
44
using Pkg
55
using Dates

0 commit comments

Comments
 (0)