Skip to content

Commit

Permalink
Fixes #3232 and simplifies some layer operations in OpenGL
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Oct 17, 2021
1 parent 4128c84 commit 6800661
Show file tree
Hide file tree
Showing 19 changed files with 1,164 additions and 350 deletions.
18 changes: 14 additions & 4 deletions msi.gama.core/src/msi/gama/common/interfaces/ILayerManager.java
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* msi.gama.common.interfaces.ILayerManager.java, in plugin msi.gama.core, is part of the source code of the GAMA
* modeling and simulation platform (v. 1.8.1)
* ILayerManager.java, in msi.gama.core, is part of the source code of the
* GAMA modeling and simulation platform (v.1.8.2).
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/SU & Partners
* (c) 2007-2021 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package msi.gama.common.interfaces;

Expand Down Expand Up @@ -78,6 +78,16 @@ public interface ILayerManager extends ItemList<ILayer>, IDisposable {
*/
boolean isProvidingWorldCoordinates();

/**
* Checks for mouse menu event layer.
*
* @return true, if successful
*/
boolean hasMouseMenuEventLayer();

/**
* Force redrawing layers.
*/
void forceRedrawingLayers();

}
39 changes: 21 additions & 18 deletions msi.gama.core/src/msi/gama/outputs/display/LayerManager.java
Expand Up @@ -162,28 +162,26 @@ public void drawLayersOn(final IGraphics g) {
// If the experiment is already closed
if (scope == null || scope.interrupted()) return;
scope.setGraphics(g);
try {
boolean changed = false;
// First we compute all the data and verify if anything is changed
for (final ILayer dis : layers) {
if (scope.interrupted()) return;
changed |= dis.getData().compute(scope, g);
}
if (changed) {
for (final ILayer l : layers) { l.forceRedrawingOnce(); }
surface.layersChanged();
}
if (g.beginDrawingLayers()) {
boolean changed = false;
// First we compute all the data and verify if anything is changed
for (final ILayer dis : layers) {
if (scope.interrupted()) return;
changed |= dis.getData().compute(scope, g);
}
if (changed) { forceRedrawingLayers(); }

if (g.beginDrawingLayers()) {
try {
// We separate in two phases: updating of the data and then drawing
for (final ILayer dis : layers) {
if (scope.interrupted()) return;
dis.draw(scope, g);
}
} catch (final Exception e) {
GAMA.reportAndThrowIfNeeded(scope, GamaRuntimeException.create(e, scope), false);
} finally {
g.endDrawingLayers();
}
} catch (final Exception e) {
GAMA.reportAndThrowIfNeeded(scope, GamaRuntimeException.create(e, scope), false);
} finally {
g.endDrawingLayers();
}
}

Expand Down Expand Up @@ -257,12 +255,17 @@ public void makeItemVisible(final ILayer obj, final boolean b) {
} else {
obj.disableOn(surface);
}
for (final ILayer l : layers) { l.forceRedrawingOnce(); }
surface.layersChanged();
forceRedrawingLayers();
});

}

@Override
public void forceRedrawingLayers() {
for (final ILayer l : layers) { l.forceRedrawingOnce(); }
surface.layersChanged();
}

@Override
public boolean isProvidingCoordinates() {
for (final ILayer i : layers) { if (i.getData().isVisible() && i.isProvidingCoordinates()) return true; }
Expand Down

0 comments on commit 6800661

Please sign in to comment.