Skip to content

Commit

Permalink
updated edge animations feature to be more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
itsMando committed Dec 12, 2024
1 parent 9fc0301 commit c9860df
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 159 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![NSD_2294_BRAND_HAGEN-GLIMPSE_final_color](https://github.com/user-attachments/assets/182d1235-eb30-4467-b880-aec3000e786f)

# v0.4.1
# v0.4.2

GLIMPSE is a graph-based desktop application to visualize and update GridLAB-D power grid models. The tool can be used to search and highlight power grid model objects. Additionally, it also update the model attributes and export the modified model future simulations. The application is developed using React.js, Electron.js, Node.js, and Python.

Expand Down
8 changes: 8 additions & 0 deletions glimpse/config/appConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"showButton": false
},
"edges": {
"scaling": {
"min": 5,
"max": 20
},
"font": {
"multi": true,
"align": "horizontal"
Expand All @@ -45,6 +49,10 @@
"color": "#000",
"multi": true,
"bold": "20px arial black"
},
"scaling": {
"min": 5,
"max": 75
}
},
"interaction": {
Expand Down
8 changes: 4 additions & 4 deletions glimpse/data/demo_examples/socialExample.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"objects":[
"objects": [
{
"objectType": "person",
"elementType": "node",
Expand Down Expand Up @@ -58,7 +58,7 @@
{
"objectType": "location",
"elementType": "node",
"attributes":{
"attributes": {
"id": "LVIII",
"event": "Super Bowl",
"location": "Las Vegas"
Expand All @@ -67,7 +67,7 @@
{
"objectType": "location",
"elementType": "node",
"attributes":{
"attributes": {
"id": "PNNL1965",
"location": "Richland WA",
"locationName": "Pacific Northwest National Laboratory",
Expand Down Expand Up @@ -145,4 +145,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion glimpse/local-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_graph(data: dict, set_communities: bool=False) -> dict:
GRAPH.add_edge(obj["attributes"]["from"], obj["attributes"]["to"], obj["attributes"]["id"])

if set_communities :
partition = nx.algorithms.community.louvain_communities(G=GRAPH, max_level=5)
partition = nx.algorithms.community.louvain_communities(G=GRAPH, resolution=1, max_level=5)

community_ids = {node: community_id for community_id, community in enumerate(partition) for node in community}

Expand Down
2 changes: 2 additions & 0 deletions glimpse/local-server/server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ a = Analysis(
noarchive=False,
optimize=0,
)

pyz = PYZ(a.pure)

exe = EXE(
Expand All @@ -39,6 +40,7 @@ exe = EXE(
codesign_identity=None,
entitlements_file=None,
)

coll = COLLECT(
exe,
a.binaries,
Expand Down
16 changes: 14 additions & 2 deletions glimpse/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if (!app.isPackaged) {
const jsonUploadSchema = require("./schemas/json_upload.schema.json");
const themeUploadSchema = require("./schemas/theme_upload.schema.json");
const socket = io("http://127.0.0.1:5051");
// const socket2 = io("http://127.0.0.1:5051");
const isMac = process.platform === "darwin";
let mainWindow = null;
let splashWindow = null;
Expand Down Expand Up @@ -133,6 +134,7 @@ const validateJson = (filePaths) => {
const data = {};
const nodeLinkDataKeys = ["directed", "multigraph", "graph", "nodes", "edges"];
let valid = true;
// let edgesKeyName = null;

for (const filePath of filePaths) {
const fileData = JSON.parse(fs.readFileSync(filePath, { encoding: "utf-8" }));
Expand All @@ -143,8 +145,18 @@ const validateJson = (filePaths) => {
};

for (const node of fileData.nodes) {
let objectType = null;

if ("type" in node && typeof node.type === "object") {
objectType = node.type.join("-");
} else if ("type" in node) {
objectType = node.type;
} else {
objectType = "node";
}

data[path.basename(filePath)].objects.push({
objectType: "type" in node ? node.type : "node",
objectType: objectType,
elementType: "node",
attributes: node,
});
Expand Down Expand Up @@ -390,7 +402,7 @@ const initiateServer = () => {

if (fs.existsSync(serverExecutablePath)) {
try {
execFile(serverPath, (error, stdout, stderr) => {
execFile(serverExecutablePath, (error, stdout, stderr) => {
if (error) throw error;
if (stderr) throw stderr;
console.log(stdout);
Expand Down
2 changes: 1 addition & 1 deletion glimpse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"productName": "GLIMPSE",
"version": "0.4.1",
"version": "0.4.2",
"main": "main.js",
"description": "A lightweight graph-based power grid model visualization tool",
"author": "Armando Mendoza Sanchez",
Expand Down
2 changes: 1 addition & 1 deletion glimpse/renderer/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<body>
<div id="root"></div>
<div id="portal"></div>
<script src="../build/renderer.js"></script>
<script defer="defer" src="../build/renderer.js"></script>
</body>
</html>
13 changes: 7 additions & 6 deletions glimpse/renderer/src/components/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const About = ({ show, close }) => {
</div>
<DialogContent sx={{ maxWidth: "72rem", padding: "0 2rem" }}>
<div className="about-title">
<h1>GLIMPSE v0.4.1</h1>
<h1>GLIMPSE v0.4.2</h1>
<h3>(Grid Layout Interface for Model Preview and System Exploration)</h3>
</div>
<div className="description">
Expand Down Expand Up @@ -95,10 +95,10 @@ const About = ({ show, close }) => {
</li>
<li>
Uploading larger models and larger networks will be clustered in to
communities allowing for smoother visualization experience. Clicking on
these clustered nodes will release all nodes in that cluster for further
examination utilizing the tools highlighting, exploration, and modification
features.
communities allowing for smoother visualization experience. Right-clicking
on these clustered nodes will give you the option to open the cluster. This
will release all nodes in that cluster for further examination utilizing the
tools highlighting, exploration, and modification features.
</li>
<li>
To upload multiple models or related files simply use the overlay upload
Expand All @@ -117,7 +117,8 @@ const About = ({ show, close }) => {
animate edge context menu item will remove the animation.
</li>
<li>
{`Using GLIMPSE's local WebSocket API a key value pair such as {animation: true} can be supplied to an existing edge to show an animation of a small red circle following the edge's path.`}
{`Using GLIMPSE's local WebSocket API a key value pair such as {animation: true}
can be supplied to an existing edge to show an animation of a small red circle following the edge's path.`}
</li>
</ul>
</div>
Expand Down
13 changes: 12 additions & 1 deletion glimpse/renderer/src/components/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const ContextMenu = ({
openNewEdgeForm,
deleteNode,
createCluster,
openCluster,
animateEdge,
deleteEdge,
}) => {
Expand Down Expand Up @@ -83,6 +84,11 @@ const ContextMenu = ({
setContextMenu(null);
};

const handleOpenCluster = () => {
openCluster(contextMenu.clusterNodeID);
setContextMenu(null);
};

const EdgeMenuItems = () => {
return (
<>
Expand Down Expand Up @@ -115,6 +121,11 @@ const ContextMenu = ({
Cluster
</MenuItem>
)}
{"clusterNodeID" in contextMenu && (
<MenuItem key={"open-cluster"} onClick={handleOpenCluster}>
Open Cluster
</MenuItem>
)}
</>
);
};
Expand All @@ -131,7 +142,7 @@ const ContextMenu = ({
: { top: 0, left: 0 }
}
>
{"nodeID" in contextMenu ? (
{"nodeID" in contextMenu || "clusterNodeID" in contextMenu ? (
<NodeMenuItems />
) : "edgeID" in contextMenu ? (
<EdgeMenuItems />
Expand Down
Loading

0 comments on commit c9860df

Please sign in to comment.