Commit c89aa3bf authored by langurmonkey's avatar langurmonkey

fix: synchronous catalog loading via script is really synchronous

parent e7db4fe9
Pipeline #60152840 passed with stage
in 4 minutes and 24 seconds
......@@ -2,6 +2,7 @@
# Created by Toni Sagrista
from py4j.java_gateway import JavaGateway, GatewayParameters
from os.path import expanduser
"""
Prints to both gaia sky and python
......@@ -18,19 +19,20 @@ gs.maximizeInterfaceWindow()
name = "hip-script"
# Modify this path to your own file!
gs.loadDataset(name, "/home/tsagrista/git/gaiasky/assets/assets-bak/data/hip.vot")
gs.loadDataset(name, expanduser("~") + "/.local/share/gaiasky/data/catalog/wd/wd_10.vot")
lprint("Dataset ready: %s" % name)
gs.sleep(4)
lprint("Hiding dataset: %s" % name)
gs.hideDataset(name)
gs.sleep(8)
gs.sleep(4)
lprint("Showing dataset: %s" % name)
gs.showDataset(name)
gs.sleep(8)
gs.sleep(4)
lprint("Removing dataset: %s" % name)
gs.removeDataset(name)
......
......@@ -71,6 +71,11 @@ public class FadeNode extends AbstractPositionEntity {
*/
private boolean visible = true;
/**
* Is the node already in the scene graph?
*/
public boolean inSceneGraph = false;
/**
* Time of last visibility change in milliseconds
*/
......@@ -264,4 +269,9 @@ public class FadeNode extends AbstractPositionEntity {
return highlighted;
}
@Override
public void setUp() {
super.setUp();
inSceneGraph = true;
}
}
......@@ -1147,6 +1147,7 @@ public class StarGroup extends ParticleGroup implements ILineRenderable, IStarFo
sg.setLabelposition(new double[] { 0.0, -5.0e7, -4e8 });
sg.setCt("Stars");
sg.setData(data);
sg.setVisible(true);
sg.doneLoading(null);
return sg;
}
......
......@@ -42,6 +42,7 @@ import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
/**
* Implementation of the scripting interface using the event system.
......@@ -2026,19 +2027,21 @@ public class EventScriptingInterface implements IScriptingInterface, IObserver {
// Create star group
if (data != null && data.size > 0 && checkString(dsName, "datasetName")) {
AtomicReference<StarGroup> starGroup = new AtomicReference<>();
Gdx.app.postRunnable(() -> {
StarGroup sg = StarGroup.getDefaultStarGroup(dsName, data);
starGroup.set(StarGroup.getDefaultStarGroup(dsName, data));
// Catalog info
CatalogInfo ci = new CatalogInfo(dsName, absolutePath, null, type, sg);
CatalogInfo ci = new CatalogInfo(dsName, absolutePath, null, type, starGroup.get());
EventManager.instance.post(Events.CATALOG_ADD, ci, true);
logger.info(data.size + " objects loaded");
});
// Sync waiting
while (sync && !CatalogManager.instance().contains(dsName)) {
// Sync waiting until the node is in the scene graph
while (sync && (starGroup.get() == null || !starGroup.get().inSceneGraph)) {
sleepFrames(1);
}
sleepFrames(1);
return true;
} else {
// No data has been loaded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment