From 765c7240fe08652f6e1ba204f44a79f173c958a0 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Tue, 11 Jun 2024 15:33:04 +0200 Subject: [PATCH] Fix selection rendering --- .../viz/engine/status/GraphSelection.java | 3 ++ .../viz/engine/status/GraphSelectionImpl.java | 5 ++ .../pipeline/arrays/ArrayDrawEdgeData.java | 13 +++-- .../pipeline/common/AbstractEdgeData.java | 52 +++++++++---------- .../pipeline/common/AbstractNodeData.java | 4 +- .../pipeline/instanced/InstancedEdgeData.java | 9 ++-- .../pipeline/arrays/ArrayDrawEdgeData.java | 13 +++-- .../pipeline/common/AbstractEdgeData.java | 52 +++++++++---------- .../pipeline/common/AbstractNodeData.java | 4 +- .../pipeline/instanced/InstancedEdgeData.java | 13 ++--- 10 files changed, 84 insertions(+), 84 deletions(-) diff --git a/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelection.java b/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelection.java index d2e0726..e9a9c44 100644 --- a/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelection.java +++ b/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelection.java @@ -16,6 +16,9 @@ enum GraphSelectionMode { SIMPLE_MOUSE_SELECTION, RECTANGLE_SELECTION } + + boolean someNodesOrEdgesSelection(); + boolean isNodeSelected(Node node); int getSelectedNodesCount(); diff --git a/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelectionImpl.java b/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelectionImpl.java index 6af0baf..0fd2972 100644 --- a/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelectionImpl.java +++ b/modules/engine-core/src/main/java/org/gephi/viz/engine/status/GraphSelectionImpl.java @@ -20,6 +20,11 @@ public GraphSelectionImpl() { this.selectionMode = GraphSelectionMode.SIMPLE_MOUSE_SELECTION; } + @Override + public boolean someNodesOrEdgesSelection() { + return !nodes.isEmpty() || !edges.isEmpty(); + } + @Override public boolean isNodeSelected(Node node) { return nodes.contains(node); diff --git a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/arrays/ArrayDrawEdgeData.java b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/arrays/ArrayDrawEdgeData.java index 2b92706..61530fb 100644 --- a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/arrays/ArrayDrawEdgeData.java +++ b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/arrays/ArrayDrawEdgeData.java @@ -221,10 +221,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt graphIndex.indexEdges(); //Selection: - final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0; - final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0; + final boolean someSelection = graphSelection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); - final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); + final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor(); final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB()); final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB()); @@ -246,13 +245,13 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt int attribsIndex = 0; attribsIndex = updateUndirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, - graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, + graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, attribsIndex ); updateDirectedData( - graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, - graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, + graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, attribsIndex ); } diff --git a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractEdgeData.java b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractEdgeData.java index b22cca6..168727d 100644 --- a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractEdgeData.java +++ b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractEdgeData.java @@ -85,7 +85,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final GL2ES2 gl, final RenderingLayer layer, final VizEngine engine, final float[] mvpFloats) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedEdges = layer.isBack(); if (!someSelection && renderingUnselectedEdges) { return 0; @@ -133,7 +133,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final GL2ES2 gl, ); if (someSelection) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { lineModelUndirected.useProgram( gl, mvpFloats, @@ -175,7 +175,7 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl, final RenderingLayer layer, final VizEngine engine, final float[] mvpFloats) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedEdges = layer.isBack(); if (!someSelection && renderingUnselectedEdges) { return 0; @@ -222,7 +222,7 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl, ); if (someSelection) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { lineModelDirected.useProgram( gl, mvpFloats, @@ -262,15 +262,15 @@ protected int setupShaderProgramForRenderingLayerDirected(final GL2ES2 gl, protected int updateDirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index ) { - return updateDirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); + return updateDirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); } protected int updateDirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index, final FloatBuffer directBuffer ) { checkBufferIndexing(directBuffer, attribs, index); @@ -281,11 +281,11 @@ protected int updateDirectedData( return index; } - saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); + saveSelectionState(this.someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); int newEdgesCountUnselected = 0; int newEdgesCountSelected = 0; - if (someEdgesSelection) { + if (someSelection) { if (hideNonSelected) { for (int j = 0; j < visibleEdgesCount; j++) { final Edge edge = visibleEdgesArray[j]; @@ -387,15 +387,15 @@ protected int updateDirectedData( protected int updateUndirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index ) { - return updateUndirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); + return updateUndirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); } protected int updateUndirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index, final FloatBuffer directBuffer ) { checkBufferIndexing(directBuffer, attribs, index); @@ -406,12 +406,12 @@ protected int updateUndirectedData( return index; } - saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); + saveSelectionState(someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); int newEdgesCountUnselected = 0; int newEdgesCountSelected = 0; //Undirected edges: - if (someEdgesSelection) { + if (someSelection) { if (hideNonSelected) { for (int j = 0; j < visibleEdgesCount; j++) { final Edge edge = visibleEdgesArray[j]; @@ -522,20 +522,20 @@ private void checkBufferIndexing(final FloatBuffer directBuffer, final float[] a } } - private boolean someNodesSelection; + private boolean someSelection; private boolean edgeSelectionColor; private GraphSelection graphSelection; private float edgeBothSelectionColor; private float edgeOutSelectionColor; private float edgeInSelectionColor; - private void saveSelectionState(final boolean someNodesSelection1, final boolean edgeSelectionColor1, final GraphSelection graphSelection1, final float edgeBothSelectionColor1, final float edgeOutSelectionColor1, final float edgeInSelectionColor1) { - this.someNodesSelection = someNodesSelection1; - this.edgeSelectionColor = edgeSelectionColor1; - this.graphSelection = graphSelection1; - this.edgeBothSelectionColor = edgeBothSelectionColor1; - this.edgeOutSelectionColor = edgeOutSelectionColor1; - this.edgeInSelectionColor = edgeInSelectionColor1; + private void saveSelectionState(final boolean someSelection, final boolean edgeSelectionColor, final GraphSelection graphSelection, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor) { + this.someSelection = someSelection; + this.edgeSelectionColor = edgeSelectionColor; + this.graphSelection = graphSelection; + this.edgeBothSelectionColor = edgeBothSelectionColor; + this.edgeOutSelectionColor = edgeOutSelectionColor; + this.edgeInSelectionColor = edgeInSelectionColor; } protected void fillUndirectedEdgeAttributesDataBase(final float[] buffer, final Edge edge, final int index) { @@ -579,7 +579,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe //Color: if (selected) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { boolean sourceSelected = graphSelection.isNodeSelected(source); boolean targetSelected = graphSelection.isNodeSelected(target); @@ -593,7 +593,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe buffer[index + 7] = Float.intBitsToFloat(edge.getRGBA());//Color } } else { - if (someNodesSelection && edge.alpha() <= 0) { + if (someSelection && edge.alpha() <= 0) { if (graphSelection.isNodeSelected(source)) { buffer[index + 7] = Float.intBitsToFloat(target.getRGBA());//Color } else { @@ -650,7 +650,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer, //Color: if (selected) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { boolean sourceSelected = graphSelection.isNodeSelected(source); boolean targetSelected = graphSelection.isNodeSelected(target); @@ -664,7 +664,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer, buffer[index + 6] = Float.intBitsToFloat(edge.getRGBA());//Color } } else { - if (someNodesSelection && edge.alpha() <= 0) { + if (someSelection && edge.alpha() <= 0) { if (graphSelection.isNodeSelected(source)) { buffer[index + 6] = Float.intBitsToFloat(target.getRGBA());//Color } else { diff --git a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractNodeData.java b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractNodeData.java index 9f8c82e..538f1d0 100644 --- a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractNodeData.java +++ b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/common/AbstractNodeData.java @@ -161,7 +161,7 @@ protected int setupShaderProgramForRenderingLayer(final GL2ES2 gl, final VizEngine engine, final float[] mvpFloats, final boolean isRenderingOutsideCircle) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedNodesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedNodes = layer.isBack(); if (!someSelection && renderingUnselectedNodes) { return 0; @@ -222,7 +222,7 @@ protected void updateData(final float zoom, spatialIndex.indexNodes(); //Selection: - final boolean someSelection = selection.getSelectedNodesCount() > 0; + final boolean someSelection = selection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); diff --git a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/instanced/InstancedEdgeData.java b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/instanced/InstancedEdgeData.java index 1b59718..d8838a9 100644 --- a/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/instanced/InstancedEdgeData.java +++ b/modules/opengl-jogl/src/main/java/org/gephi/viz/engine/jogl/pipeline/instanced/InstancedEdgeData.java @@ -160,10 +160,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt graphIndex.indexEdges(); //Selection: - final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0; - final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0; + final boolean someSelection = graphSelection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); - final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); + final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor(); final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB()); final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB()); @@ -184,12 +183,12 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt updateUndirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attributesBufferBatch, 0, attribsDirectBuffer ); updateDirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attributesBufferBatch, 0, attribsDirectBuffer ); } diff --git a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/arrays/ArrayDrawEdgeData.java b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/arrays/ArrayDrawEdgeData.java index d5e8126..c0f5cf7 100644 --- a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/arrays/ArrayDrawEdgeData.java +++ b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/arrays/ArrayDrawEdgeData.java @@ -222,10 +222,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt graphIndex.indexEdges(); //Selection: - final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0; - final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0; + final boolean someSelection = graphSelection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); - final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); + final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor(); final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB()); final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB()); @@ -247,13 +246,13 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt int attribsIndex = 0; attribsIndex = updateUndirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, - graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, + graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, attribsIndex ); updateDirectedData( - graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, - graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, + graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, attribsIndex ); } diff --git a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractEdgeData.java b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractEdgeData.java index dd63e33..bede1b8 100644 --- a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractEdgeData.java +++ b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractEdgeData.java @@ -87,7 +87,7 @@ protected void initBuffers() { protected int setupShaderProgramForRenderingLayerUndirected(final RenderingLayer layer, final VizEngine engine, final float[] mvpFloats) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedEdges = layer.isBack(); if (!someSelection && renderingUnselectedEdges) { return 0; @@ -133,7 +133,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final RenderingLayer ); if (someSelection) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { lineModelUndirected.useProgram( mvpFloats, edgeScale, @@ -171,7 +171,7 @@ protected int setupShaderProgramForRenderingLayerUndirected(final RenderingLayer protected int setupShaderProgramForRenderingLayerDirected(final RenderingLayer layer, final VizEngine engine, final float[] mvpFloats) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedEdgesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedEdges = layer.isBack(); if (!someSelection && renderingUnselectedEdges) { return 0; @@ -216,7 +216,7 @@ protected int setupShaderProgramForRenderingLayerDirected(final RenderingLayer l ); if (someSelection) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { lineModelDirected.useProgram( mvpFloats, edgeScale, @@ -253,15 +253,15 @@ protected int setupShaderProgramForRenderingLayerDirected(final RenderingLayer l protected int updateDirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index ) { - return updateDirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); + return updateDirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); } protected int updateDirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index, final FloatBuffer directBuffer ) { checkBufferIndexing(directBuffer, attribs, index); @@ -272,11 +272,11 @@ protected int updateDirectedData( return index; } - saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); + saveSelectionState(someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); int newEdgesCountUnselected = 0; int newEdgesCountSelected = 0; - if (someEdgesSelection) { + if (someSelection) { if (hideNonSelected) { for (int j = 0; j < visibleEdgesCount; j++) { final Edge edge = visibleEdgesArray[j]; @@ -378,15 +378,15 @@ protected int updateDirectedData( protected int updateUndirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index ) { - return updateUndirectedData(graph, someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); + return updateUndirectedData(graph, someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attribs, index, null); } protected int updateUndirectedData( final Graph graph, - final boolean someEdgesSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean someNodesSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, + final boolean someSelection, final boolean hideNonSelected, final int visibleEdgesCount, final Edge[] visibleEdgesArray, final GraphSelection graphSelection, final boolean edgeSelectionColor, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor, final float[] attribs, int index, final FloatBuffer directBuffer ) { checkBufferIndexing(directBuffer, attribs, index); @@ -397,12 +397,12 @@ protected int updateUndirectedData( return index; } - saveSelectionState(someNodesSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); + saveSelectionState(someSelection, edgeSelectionColor, graphSelection, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor); int newEdgesCountUnselected = 0; int newEdgesCountSelected = 0; //Undirected edges: - if (someEdgesSelection) { + if (someSelection) { if (hideNonSelected) { for (int j = 0; j < visibleEdgesCount; j++) { final Edge edge = visibleEdgesArray[j]; @@ -513,20 +513,20 @@ private void checkBufferIndexing(final FloatBuffer directBuffer, final float[] a } } - private boolean someNodesSelection; + private boolean someSelection; private boolean edgeSelectionColor; private GraphSelection graphSelection; private float edgeBothSelectionColor; private float edgeOutSelectionColor; private float edgeInSelectionColor; - private void saveSelectionState(final boolean someNodesSelection1, final boolean edgeSelectionColor1, final GraphSelection graphSelection1, final float edgeBothSelectionColor1, final float edgeOutSelectionColor1, final float edgeInSelectionColor1) { - this.someNodesSelection = someNodesSelection1; - this.edgeSelectionColor = edgeSelectionColor1; - this.graphSelection = graphSelection1; - this.edgeBothSelectionColor = edgeBothSelectionColor1; - this.edgeOutSelectionColor = edgeOutSelectionColor1; - this.edgeInSelectionColor = edgeInSelectionColor1; + private void saveSelectionState(final boolean someSelection, final boolean edgeSelectionColor, final GraphSelection graphSelection, final float edgeBothSelectionColor, final float edgeOutSelectionColor, final float edgeInSelectionColor) { + this.someSelection = someSelection; + this.edgeSelectionColor = edgeSelectionColor; + this.graphSelection = graphSelection; + this.edgeBothSelectionColor = edgeBothSelectionColor; + this.edgeOutSelectionColor = edgeOutSelectionColor; + this.edgeInSelectionColor = edgeInSelectionColor; } protected void fillUndirectedEdgeAttributesDataBase(final float[] buffer, final Edge edge, final int index) { @@ -570,7 +570,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe //Color: if (selected) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { boolean sourceSelected = graphSelection.isNodeSelected(source); boolean targetSelected = graphSelection.isNodeSelected(target); @@ -584,7 +584,7 @@ protected void fillUndirectedEdgeAttributesDataWithSelection(final float[] buffe buffer[index + 7] = Float.intBitsToFloat(edge.getRGBA());//Color } } else { - if (someNodesSelection && edge.alpha() <= 0) { + if (someSelection && edge.alpha() <= 0) { if (graphSelection.isNodeSelected(source)) { buffer[index + 7] = Float.intBitsToFloat(target.getRGBA());//Color } else { @@ -641,7 +641,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer, //Color: if (selected) { - if (someNodesSelection && edgeSelectionColor) { + if (someSelection && edgeSelectionColor) { boolean sourceSelected = graphSelection.isNodeSelected(source); boolean targetSelected = graphSelection.isNodeSelected(target); @@ -655,7 +655,7 @@ protected void fillDirectedEdgeAttributesDataWithSelection(final float[] buffer, buffer[index + 6] = Float.intBitsToFloat(edge.getRGBA());//Color } } else { - if (someNodesSelection && edge.alpha() <= 0) { + if (someSelection && edge.alpha() <= 0) { if (graphSelection.isNodeSelected(source)) { buffer[index + 6] = Float.intBitsToFloat(target.getRGBA());//Color } else { diff --git a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractNodeData.java b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractNodeData.java index 7ae8582..7466d6e 100644 --- a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractNodeData.java +++ b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/common/AbstractNodeData.java @@ -152,7 +152,7 @@ protected int setupShaderProgramForRenderingLayer(final RenderingLayer layer, final VizEngine engine, final float[] mvpFloats, final boolean isRenderingOutsideCircle) { - final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).getSelectedNodesCount() > 0; + final boolean someSelection = engine.getLookup().lookup(GraphSelection.class).someNodesOrEdgesSelection(); final boolean renderingUnselectedNodes = layer.isBack(); if (!someSelection && renderingUnselectedNodes) { return 0; @@ -211,7 +211,7 @@ protected void updateData(final float zoom, spatialIndex.indexNodes(); //Selection: - final boolean someSelection = selection.getSelectedNodesCount() > 0; + final boolean someSelection = selection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); diff --git a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/instanced/InstancedEdgeData.java b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/instanced/InstancedEdgeData.java index 259b47d..4bf2be2 100644 --- a/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/instanced/InstancedEdgeData.java +++ b/modules/opengl-lwjgl/src/main/java/org/gephi/viz/engine/lwjgl/pipeline/instanced/InstancedEdgeData.java @@ -7,18 +7,14 @@ import org.gephi.viz.engine.lwjgl.models.EdgeLineModelUndirected; import org.gephi.viz.engine.lwjgl.pipeline.common.AbstractEdgeData; import org.gephi.viz.engine.lwjgl.util.gl.GLBufferMutable; -import org.gephi.viz.engine.lwjgl.util.gl.ManagedDirectBuffer; import org.gephi.viz.engine.pipeline.RenderingLayer; import org.gephi.viz.engine.status.GraphRenderingOptions; import org.gephi.viz.engine.status.GraphSelection; -import org.gephi.viz.engine.structure.GraphIndex; import org.gephi.viz.engine.structure.GraphIndexImpl; import org.lwjgl.system.MemoryStack; import java.nio.FloatBuffer; -import static org.gephi.viz.engine.pipeline.RenderingLayer.BACK1; -import static org.lwjgl.opengl.GL11.GL_FLOAT; import static org.lwjgl.opengl.GL15.glGenBuffers; /** @@ -159,10 +155,9 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt graphIndex.indexEdges(); //Selection: - final boolean someEdgesSelection = graphSelection.getSelectedEdgesCount() > 0; - final boolean someNodesSelection = graphSelection.getSelectedNodesCount() > 0; + final boolean someSelection = graphSelection.someNodesOrEdgesSelection(); final float lightenNonSelectedFactor = renderingOptions.getLightenNonSelectedFactor(); - final boolean hideNonSelected = someEdgesSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); + final boolean hideNonSelected = someSelection && (renderingOptions.isHideNonSelected() || lightenNonSelectedFactor >= 1); final boolean edgeSelectionColor = renderingOptions.isEdgeSelectionColor(); final float edgeBothSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeBothSelectionColor().getRGB()); final float edgeInSelectionColor = Float.intBitsToFloat(renderingOptions.getEdgeInSelectionColor().getRGB()); @@ -183,12 +178,12 @@ private void updateData(final GraphIndexImpl graphIndex, final GraphRenderingOpt updateUndirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attributesBufferBatch, 0, attribsDirectBuffer ); updateDirectedData( graph, - someEdgesSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, someNodesSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, + someSelection, hideNonSelected, visibleEdgesCount, visibleEdgesArray, graphSelection, edgeSelectionColor, edgeBothSelectionColor, edgeOutSelectionColor, edgeInSelectionColor, attributesBufferBatch, 0, attribsDirectBuffer ); }