Skip to content

Commit

Permalink
Merge pull request #1211 from virtualsatellite/hotfix/task_1209-Visua…
Browse files Browse the repository at this point in the history
…lization_crashe

Release 4.17.1- HotFixes
  • Loading branch information
PhilMFischer authored Oct 10, 2024
2 parents aaa5063 + 57722b2 commit 84eef1f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
# --------------------------------------------
- name: Build and Test - Upload SWTBot Screenshots on Failure
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.3.4
with:
name: SWTBot Screenshots
path:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.osgi.framework.BundleContext;

import de.dlr.sc.virsat.model.extension.visualisation.treemanager.StartManagers;
import de.dlr.sc.virsat.model.extension.visualisation.ui.vtkClient.VtkClientVisUpdateHandler;
import de.dlr.sc.virsat.project.editingDomain.VirSatTransactionalEditingDomain;

/**
Expand Down Expand Up @@ -68,6 +69,8 @@ public void start(BundleContext context) throws Exception {
pluginId = getDefault().getBundle().getSymbolicName();
// initialize the communication servers
try {

StartManagers.getTreeManager().setVisUpdateHandler(VtkClientVisUpdateHandler.getInstance());

resourceReloadListener = new ResourceReloadListener();
VirSatTransactionalEditingDomain.addResourceEventListener(resourceReloadListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
Expand All @@ -26,8 +27,8 @@
import de.dlr.sc.virsat.model.extension.visualisation.Activator;
import de.dlr.sc.virsat.model.extension.visualisation.treemanager.IVisUpdateHandler;
import de.dlr.sc.virsat.uiengine.ui.editor.GenericEditor;
import de.dlr.sc.visproto.VisProto.SceneGraph;
import de.dlr.sc.visproto.VisProto.SceneGraphNode;
import de.dlr.sc.visproto.VisProto.VisualisationMessage;
import vtk.vtkProp;

/**
Expand All @@ -52,12 +53,12 @@ private VtkClientVisUpdateHandler() {
*
* @param visualisationMessage
*/
public synchronized void updateVisualisationData(VisualisationMessage visualisationMessage) {
public synchronized void updateVisualisationData(SceneGraph sceneGraph) {
EventQueue.invokeLater(new Runnable() {

@Override
public void run() {
mNode = visualisationMessage.getSceneGraph().getNode();
mNode = sceneGraph.getNode();
VtkTreeManager visMan = VtkTreeManager.getInstance();
visMan.clearInvalidActors();
visMan.forceSceneryUpdate(mNode);
Expand Down Expand Up @@ -93,8 +94,10 @@ public static synchronized VtkClientVisUpdateHandler getInstance() {
if (instance == null) {
instance = new VtkClientVisUpdateHandler();
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchwindow = workbench.getActiveWorkbenchWindow();
workbenchwindow.getPartService().addPartListener(instance);
Display.getDefault().syncExec(() -> {
IWorkbenchWindow workbenchwindow = workbench.getActiveWorkbenchWindow();
workbenchwindow.getPartService().addPartListener(instance);
});
}
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private void updateHighlightedObjectIfSelected(SceneGraphNode node, ActorVtk par
ActorVtk actor = actorMap.get(node.getID());

if (selectedActor != null) {
if (selectedActor.getId().equals(actor.getId())) {
if (selectedActor.getId().equals(actor.getId()) && selectedActor.GetMapper() != null) {
highlightSource.SetBounds(selectedActor.GetMapper().GetBounds());
localAxes.SetUserTransform(parent.GetUserTransform());
highlightActor.SetUserTransform(actor.GetUserTransform());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected void setShapeParent(String parentShapeId, String shapeId) {
public void traverseTreeAndCreateShapes(StructuralElementInstance rootSei) {
super.traverseTreeAndCreateShapes(rootSei);

pauseVisTreeManagerUpdateSending();
for (GhostShapeDelta ghostShapeDelta : ghostShapeDeltas) {
Shape ghostShape = ghostShapeDelta.shape;
ghostShape.id += GHOST_SHAPE_SUFFIX;
Expand All @@ -106,6 +105,5 @@ public void traverseTreeAndCreateShapes(StructuralElementInstance rootSei) {
visualisationTreeManager.setParent(ghostShapeId, ghostShapeParentId);
}
}
resumeVisTreeManagerUpdateSending();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import de.dlr.sc.virsat.model.dvlm.structural.StructuralElementInstance;
import de.dlr.sc.virsat.model.extension.visualisation.IVisualisationTreeManager;
import de.dlr.sc.virsat.model.extension.visualisation.model.Visualisation;
import de.dlr.sc.virsat.model.extension.visualisation.treemanager.IPausableSender;

/**
* A class for extracting of shape data from a StructuralElementInstance,
Expand Down Expand Up @@ -48,11 +47,9 @@ public ShapeHelper(IVisualisationTreeManager visualisationTreeManager, ShapeEdit
* @param sei The SEI for which to create a shape.
*/
public void traverseTreeAndCreateShapes(StructuralElementInstance sei) {
pauseVisTreeManagerUpdateSending();
StructuralElementInstance visParent = getVisualisationParent(sei);
String visParentId = visParent != null ? visParent.getUuid().toString() : null;
traverseTreeAndCreateShapes(sei, visParentId);
resumeVisTreeManagerUpdateSending();
}

/**
Expand Down Expand Up @@ -258,24 +255,7 @@ protected Shape createShapeFromVisualisationBean(Visualisation visBean, String s
return createShapeFromBean(visBean, shapeId);
}

/**
* tries to pause update sending until all the scenegraph is created
*/
protected void pauseVisTreeManagerUpdateSending() {
if (visualisationTreeManager instanceof IPausableSender) {
((IPausableSender) visualisationTreeManager).pauseSending();
}
}

/**
* tries to resume update sending
*/
protected void resumeVisTreeManagerUpdateSending() {
if (visualisationTreeManager instanceof IPausableSender) {
((IPausableSender) visualisationTreeManager).resumeSending();
}
}

/**
* Creates Shape from Vis Bean
* @param visBean The bean from which to use the values
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*******************************************************************************/
package de.dlr.sc.virsat.model.extension.visualisation.treemanager;

import de.dlr.sc.visproto.VisProto.VisualisationMessage;
import de.dlr.sc.visproto.VisProto.SceneGraph;

/**
* Calling VisualisationManager to refresh
Expand All @@ -22,7 +22,7 @@ public interface IVisUpdateHandler {
/**
* Updates corresponding TreeManagern and Visualisation.
*
* @param visualisationMessage contains the SceneGraph message with the updated SceneGraph
* @param sceneGraph contains the SceneGraph message with the updated SceneGraph
*/
void updateVisualisationData(VisualisationMessage visualisationMessage);
void updateVisualisationData(SceneGraph sceneGraph);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* This class is responsible for the management of the ProtoBuf-SceneGraph
*/
public class TreeManager implements IVisualisationTreeManager, IPausableSender {
public class TreeManager implements IVisualisationTreeManager {

//global root node created on initialisation which always exists
public static final String VISUALISATION_GLOBAL_ROOT_ID = "0";
Expand All @@ -53,6 +53,7 @@ public class TreeManager implements IVisualisationTreeManager, IPausableSender {
private Map<String, Integer> hashNodeMap = new HashMap<String, Integer>();
private IShapeEditObserver observer;


/**
* Log root node
*/
Expand Down Expand Up @@ -131,6 +132,8 @@ public void editShape(Shape shape) {
if (!protoNodeMap.get(shape.id).hasGeometry() && protoGeometryFileMap.containsKey(shape.id)) {
protoGeometryFileMap.remove(shape.id);
}

sendSceneGraph(mSceneGraph.build());
}

/**
Expand Down Expand Up @@ -317,6 +320,8 @@ public void createShape(Shape shape) {
shape.rotationX, shape.rotationY, shape.rotationZ,
shape.color, shape.transparency);
addChildNode(VISUALISATION_GLOBAL_ROOT_ID, shape.id);

sendSceneGraph(mSceneGraph.build());
} else {
activator.getLog().log(new Status(Status.ERROR, Activator.getPluginId(), "ID already exists", null));
throw new RuntimeException("Error at creating new shape. ID already exist");
Expand Down Expand Up @@ -470,6 +475,7 @@ private void refreshMapFrom(Builder nodeBuilder) {
public void setParent(String idChild, String idParent) {
removeFromCurrentParent(idChild);
addChildNode(idParent, idChild);
sendSceneGraph(mSceneGraph.build());
}

/**
Expand Down Expand Up @@ -516,6 +522,7 @@ public void removeShape(String id) {
addChildNode(mSceneGraph.getNodeBuilder(), child);
}

sendSceneGraph(mSceneGraph.build());
}

/**
Expand All @@ -538,6 +545,7 @@ private Builder removeNodeFromMaps(String id) {
public void removeShapeWithSubtree(String id) {
removeFromCurrentParent(id);
removeNodeRecursively(id);
sendSceneGraph(mSceneGraph.build());
}

/**
Expand All @@ -551,7 +559,6 @@ private void removeNodeRecursively(String id) {
}
}


/**
* Checks if there is a registered node with the ide
* @param id Id of the node
Expand Down Expand Up @@ -607,6 +614,7 @@ public void update(VisualisationMessage visualisationMessage) {
}
protoNodeMap.clear();
this.refreshMapFrom(mSceneGraph.getNodeBuilder());
sendSceneGraph(mSceneGraph.build());
} else {
activator.getLog().log(new Status(Status.WARNING, Activator.getPluginId(), "Received SceneGraph is equal to the current one", null));
}
Expand Down Expand Up @@ -683,16 +691,21 @@ private Shape convertProtobufNodeToShape(SceneGraphNodeOrBuilder node) {
return shape;
}

@Override
public void pauseSending() {
}

@Override
public void resumeSending() {
}

@Override
public void reloadGeometryFile(String shapeId) {
createGeometryFileBuilder(shapeId);
}

private IVisUpdateHandler visUpdateHandler;

public void setVisUpdateHandler(IVisUpdateHandler visUpdateHandler) {
this.visUpdateHandler = visUpdateHandler;
}

public void sendSceneGraph(SceneGraph sceneGraph) {
if (visUpdateHandler != null) {
visUpdateHandler.updateVisualisationData(sceneGraph);
}
}

}

0 comments on commit 84eef1f

Please sign in to comment.