From 9f84331c9967c88e0e5550ce91f2b7e364a5cb6d Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 24 Feb 2020 20:40:36 +0200 Subject: [PATCH] Remove listener calls when property values not updated. gitlab #90 Change-Id: Ic3e4097cc19fb9ebd295052f9a5f0c57ad39328a --- org.simantics.g3d.csg/.classpath | 2 +- org.simantics.g3d.csg/META-INF/MANIFEST.MF | 3 ++- .../g3d/csg/scenegraph2/BarrelNode.java | 6 ++++++ .../simantics/g3d/csg/scenegraph2/BoxNode.java | 6 ++++++ .../simantics/g3d/csg/scenegraph2/CSGnode.java | 2 +- .../g3d/csg/scenegraph2/CSGparentNode.java | 9 ++++++++- .../simantics/g3d/csg/scenegraph2/ConeNode.java | 4 ++++ .../g3d/csg/scenegraph2/CylinderNode.java | 6 ++++++ .../csg/scenegraph2/EllipticCylinderNode.java | 6 ++++++ .../csg/scenegraph2/RectangularSolidNode.java | 10 ++++++++++ .../g3d/csg/scenegraph2/RegularPrismNode.java | 6 ++++++ .../g3d/csg/scenegraph2/SphereNode.java | 2 ++ .../simantics/g3d/csg/scenegraph2/TorusNode.java | 4 ++++ .../org/simantics/g3d/scenegraph/G3DNode.java | 15 ++++++++++++++- .../g3d/scenegraph/structural/ComponentNode.java | 7 ++++--- .../scenegraph/structural/G3DComponentNode.java | 6 +++--- .../structural/G3DStructuralParentNode.java | 7 +++++++ .../structural/StructuralParentNode.java | 6 +++--- org.simantics.plant3d/META-INF/MANIFEST.MF | 4 ++-- .../plant3d/scenegraph/GeometryComponent.java | 3 ++- .../org/simantics/plant3d/scenegraph/Nozzle.java | 3 +++ .../simantics/plant3d/scenegraph/P3DNode.java | 6 +++++- .../plant3d/scenegraph/P3DParentNode.java | 9 ++++++++- .../simantics/plant3d/scenegraph/PipeRun.java | 11 +++++++++-- .../plant3d/scenegraph/PipelineComponent.java | 8 +++----- .../controlpoint/PipeControlPoint.java | 16 +++++++++++++--- .../scenegraph/controlpoint/PipingRules.java | 4 ++-- 27 files changed, 140 insertions(+), 31 deletions(-) diff --git a/org.simantics.g3d.csg/.classpath b/org.simantics.g3d.csg/.classpath index b862a296..5e4f6d9c 100644 --- a/org.simantics.g3d.csg/.classpath +++ b/org.simantics.g3d.csg/.classpath @@ -1,7 +1,7 @@ - + diff --git a/org.simantics.g3d.csg/META-INF/MANIFEST.MF b/org.simantics.g3d.csg/META-INF/MANIFEST.MF index 1680ff0f..46700b06 100644 --- a/org.simantics.g3d.csg/META-INF/MANIFEST.MF +++ b/org.simantics.g3d.csg/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.core.runtime, org.simantics.g3d.vtk;bundle-version="1.0.0", org.simantics.browsing.ui.common;bundle-version="1.1.0", org.simantics.objmap2;bundle-version="1.0.0", - org.simantics.opencascade.vtk;bundle-version="1.0.0" + org.simantics.opencascade.vtk;bundle-version="1.0.0", + org.slf4j.api Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.simantics.g3d.csg.handler, diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BarrelNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BarrelNode.java index 0a417f3b..5e0d5c0b 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BarrelNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BarrelNode.java @@ -40,6 +40,8 @@ public class BarrelNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMinorRadius) @SetPropertyValue(CSG.URIs.HasMinorRadius) public void setR1(double r1) { + if (this.r1 == r1) + return; this.r1 = r1; firePropertyChanged(CSG.URIs.HasMinorRadius); } @@ -47,6 +49,8 @@ public class BarrelNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMajorRadius) @SetPropertyValue(CSG.URIs.HasMajorRadius) public void setR2(double r2) { + if (this.r2 == r2) + return; this.r2 = r2; firePropertyChanged(CSG.URIs.HasMajorRadius); } @@ -54,6 +58,8 @@ public class BarrelNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasHeight) @SetPropertyValue(CSG.URIs.HasHeight) public void setH(double h) { + if (this.h == h) + return; this.h = h; firePropertyChanged(CSG.URIs.HasHeight); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java index a2e0145f..ea950eeb 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/BoxNode.java @@ -34,6 +34,8 @@ public class BoxNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasXAxisSize) @SetPropertyValue(CSG.URIs.HasXAxisSize) public void setSX(double d) { + if (this.sx == d) + return; this.sx = d; firePropertyChanged(CSG.URIs.HasXAxisSize); } @@ -41,6 +43,8 @@ public class BoxNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasYAxisSize) @SetPropertyValue(CSG.URIs.HasYAxisSize) public void setSY(double d) { + if (this.sy == d) + return; this.sy = d; firePropertyChanged(CSG.URIs.HasYAxisSize); } @@ -48,6 +52,8 @@ public class BoxNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasZAxisSize) @SetPropertyValue(CSG.URIs.HasZAxisSize) public void setSZ(double d) { + if (this.sz == d) + return; this.sz = d; firePropertyChanged(CSG.URIs.HasZAxisSize); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGnode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGnode.java index 68c1c015..a30bb540 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGnode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGnode.java @@ -48,7 +48,7 @@ public abstract class CSGnode extends G3DNode implements ICSGnode { @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || name.equals(this.name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGparentNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGparentNode.java index 087ec522..46610414 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGparentNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGparentNode.java @@ -13,6 +13,7 @@ package org.simantics.g3d.csg.scenegraph2; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import javax.vecmath.AxisAngle4d; import javax.vecmath.Quat4d; @@ -56,7 +57,7 @@ public abstract class CSGparentNode extends ParentNode implements ICSG @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || name.equals(this.name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); @@ -181,6 +182,9 @@ public abstract class CSGparentNode extends ParentNode implements ICSG @SetPropertyValue(G3D.URIs.hasOrientation) public void setOrientation(Quat4d orientation) { assert(orientation != null); + if (Objects.equals(this.orientation, orientation)) + return; + this.orientation = orientation; firePropertyChanged(G3D.URIs.hasOrientation); @@ -190,6 +194,9 @@ public abstract class CSGparentNode extends ParentNode implements ICSG @SetPropertyValue(G3D.URIs.hasPosition) public void setPosition(Vector3d position) { assert(position != null); + if (Objects.equals(this.position, position)) + return; + this.position = position; firePropertyChanged(G3D.URIs.hasPosition); diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java index 6c8c218a..1b14a405 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/ConeNode.java @@ -31,6 +31,8 @@ public class ConeNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasBottomRadius) @SetPropertyValue(CSG.URIs.HasBottomRadius) public void setR1(double r1) { + if (this.r1 == r1) + return; this.r1 = r1; firePropertyChanged(CSG.URIs.HasBottomRadius); } @@ -38,6 +40,8 @@ public class ConeNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasTopRadius) @SetPropertyValue(CSG.URIs.HasTopRadius) public void setR2(double r2) { + if (this.r2 == r2) + return; this.r2 = r2; firePropertyChanged(CSG.URIs.HasTopRadius); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java index a715eb4c..cf2e0183 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CylinderNode.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.simantics.g3d.csg.scenegraph2; +import java.util.Objects; + import org.jcae.opencascade.jni.TopoDS_Shape; import org.simantics.g3d.csg.ontology.CSG; import org.simantics.g3d.property.annotations.GetPropertyValue; @@ -29,6 +31,8 @@ public class CylinderNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasRadius) @SetPropertyValue(CSG.URIs.HasRadius) public void setR(double r) { + if (this.r == r) + return; this.r = r; firePropertyChanged(CSG.URIs.HasRadius); } @@ -36,6 +40,8 @@ public class CylinderNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasHeight) @SetPropertyValue(CSG.URIs.HasHeight) public void setH(double h) { + if (this.h == h) + return; this.h = h; firePropertyChanged(CSG.URIs.HasHeight); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/EllipticCylinderNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/EllipticCylinderNode.java index 8c99638d..e4030728 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/EllipticCylinderNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/EllipticCylinderNode.java @@ -30,6 +30,8 @@ public class EllipticCylinderNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMinorRadius) @SetPropertyValue(CSG.URIs.HasMinorRadius) public void setR1(double r1) { + if (this.r1 == r1) + return; this.r1 = r1; firePropertyChanged(CSG.URIs.HasMinorRadius); } @@ -37,6 +39,8 @@ public class EllipticCylinderNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMajorRadius) @SetPropertyValue(CSG.URIs.HasMajorRadius) public void setR2(double r2) { + if (this.r2 == r2) + return; this.r2 = r2; firePropertyChanged(CSG.URIs.HasMajorRadius); } @@ -44,6 +48,8 @@ public class EllipticCylinderNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasHeight) @SetPropertyValue(CSG.URIs.HasHeight) public void setH(double h) { + if (this.h == h) + return; this.h = h; firePropertyChanged(CSG.URIs.HasHeight); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RectangularSolidNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RectangularSolidNode.java index 562b810f..01aaf2cd 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RectangularSolidNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RectangularSolidNode.java @@ -38,6 +38,8 @@ public class RectangularSolidNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasXAxisMinimumSize) @SetPropertyValue(CSG.URIs.HasXAxisMinimumSize) public void setX1(double d) { + if (this.x1 == d) + return; this.x1 = d; firePropertyChanged(CSG.URIs.HasXAxisMinimumSize); } @@ -45,6 +47,8 @@ public class RectangularSolidNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasXAxisMaximumSize) @SetPropertyValue(CSG.URIs.HasXAxisMaximumSize) public void setX2(double d) { + if (this.x2 == d) + return; this.x2 = d; firePropertyChanged(CSG.URIs.HasXAxisMaximumSize); } @@ -52,6 +56,8 @@ public class RectangularSolidNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasYAxisSize) @SetPropertyValue(CSG.URIs.HasYAxisSize) public void setSY(double d) { + if (this.y == d) + return; this.y = d; firePropertyChanged(CSG.URIs.HasYAxisSize); } @@ -59,6 +65,8 @@ public class RectangularSolidNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasZAxisMinimumSize) @SetPropertyValue(CSG.URIs.HasZAxisMinimumSize) public void setZ1(double d) { + if (this.z1 == d) + return; this.z1 = d; firePropertyChanged(CSG.URIs.HasZAxisMinimumSize); } @@ -66,6 +74,8 @@ public class RectangularSolidNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasZAxisMaximumSize) @SetPropertyValue(CSG.URIs.HasZAxisMaximumSize) public void setZ2(double d) { + if (this.z2 == d) + return; this.z2 = d; firePropertyChanged(CSG.URIs.HasZAxisMaximumSize); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java index 6f959d31..3d52b602 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/RegularPrismNode.java @@ -30,6 +30,8 @@ public class RegularPrismNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasRadius) @SetPropertyValue(CSG.URIs.HasRadius) public void setR(double r) { + if (this.r == r) + return; this.r = r; firePropertyChanged(CSG.URIs.HasRadius); } @@ -38,6 +40,8 @@ public class RegularPrismNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasHeight) @SetPropertyValue(CSG.URIs.HasHeight) public void setH(double h) { + if (this.h == h) + return; this.h = h; firePropertyChanged(CSG.URIs.HasHeight); } @@ -47,6 +51,8 @@ public class RegularPrismNode extends CSGnode { public void setN(int n) { if (n < 3) n = 3; + if (this.n == n) + return; this.n = n; firePropertyChanged(CSG.URIs.HasCorners); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java index 03a9a248..e71632da 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SphereNode.java @@ -28,6 +28,8 @@ public class SphereNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasRadius) @SetPropertyValue(CSG.URIs.HasRadius) public void setR(double r) { + if (this.r == r) + return; this.r = r; firePropertyChanged(CSG.URIs.HasRadius); } diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java index e7794e86..9b92854e 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/TorusNode.java @@ -30,6 +30,8 @@ public class TorusNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMinorRadius) @SetPropertyValue(CSG.URIs.HasMinorRadius) public void setR1(double r1) { + if (this.r1 == r1) + return; this.r1 = r1; firePropertyChanged(CSG.URIs.HasMinorRadius); } @@ -37,6 +39,8 @@ public class TorusNode extends CSGnode { @RelatedSetValue(CSG.URIs.HasMajorRadius) @SetPropertyValue(CSG.URIs.HasMajorRadius) public void setR2(double r2) { + if (this.r2 == r2) + return; this.r2 = r2; firePropertyChanged(CSG.URIs.HasMajorRadius); } diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java index c955dc6a..7b890b39 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.simantics.g3d.scenegraph; +import java.util.Objects; + import javax.vecmath.Quat4d; import javax.vecmath.Vector3d; @@ -61,8 +63,11 @@ public class G3DNode extends Node implements IG3DNode { @SetPropertyValue(G3D.URIs.hasOrientation) public void setOrientation(Quat4d orientation) { assert(orientation != null); + if (Objects.equals(this.orientation, orientation)) + return; + this.orientation = orientation; - + firePropertyChanged(G3D.URIs.hasOrientation); } @@ -77,6 +82,9 @@ public class G3DNode extends Node implements IG3DNode { @SetPropertyValue(G3D.URIs.hasPosition) public void setPosition(Vector3d position) { assert(position != null); + if (Objects.equals(this.position, position)) + return; + this.position = position; firePropertyChanged(G3D.URIs.hasPosition); @@ -89,6 +97,11 @@ public class G3DNode extends Node implements IG3DNode { setPosition(new Vector3d(arr)); } + public void _setPosition(Vector3d position) { + assert(position != null); + this.position = position; + } + @Override @GetPropertyValue(value = G3D.URIs.hasWorldPosition, tabId = "Transform", name = "World Position") public Vector3d getWorldPosition() { diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/ComponentNode.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/ComponentNode.java index 13ac2f52..332d3cdf 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/ComponentNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/ComponentNode.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.simantics.g3d.ontology.G3D; import org.simantics.g3d.property.annotations.GetPropertyValue; @@ -41,7 +42,7 @@ public abstract class ComponentNode, T2 extends IComp @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || Objects.equals(this.name, name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); @@ -96,8 +97,8 @@ public abstract class ComponentNode, T2 extends IComp @Override public void addPublishedBy(IStructuralNode node) { - publisher.add(node); - firePropertyChanged(G3D.URIs.publishes); + if (publisher.add(node)) + firePropertyChanged(G3D.URIs.publishes); } @Override diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DComponentNode.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DComponentNode.java index 69291365..9ebd8c88 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DComponentNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DComponentNode.java @@ -41,7 +41,7 @@ public abstract class G3DComponentNode, T2 extends IC @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || name.equals(this.name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); @@ -96,8 +96,8 @@ public abstract class G3DComponentNode, T2 extends IC @Override public void addPublishedBy(IStructuralNode node) { - publisher.add(node); - firePropertyChanged(G3D.URIs.publishes); + if (publisher.add(node)) + firePropertyChanged(G3D.URIs.publishes); } @Override diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DStructuralParentNode.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DStructuralParentNode.java index 073ef79d..569f0211 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DStructuralParentNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/G3DStructuralParentNode.java @@ -12,6 +12,7 @@ package org.simantics.g3d.scenegraph.structural; import java.util.Collection; +import java.util.Objects; import javax.vecmath.Quat4d; import javax.vecmath.Vector3d; @@ -95,6 +96,9 @@ public abstract class G3DStructuralParentNode extends @Override @SetPropertyValue(G3D.URIs.hasPosition) public void setPosition(Vector3d position) { + if (Objects.equals(this.position, position)) + return; + this.position = position; firePropertyChanged(G3D.URIs.hasPosition); } @@ -102,6 +106,9 @@ public abstract class G3DStructuralParentNode extends @Override @SetPropertyValue(G3D.URIs.hasOrientation) public void setOrientation(Quat4d orientation) { + if (Objects.equals(this.orientation, orientation)) + return; + this.orientation = orientation; firePropertyChanged(G3D.URIs.hasOrientation); } diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/StructuralParentNode.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/StructuralParentNode.java index 1ae00096..032ba981 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/StructuralParentNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/structural/StructuralParentNode.java @@ -38,7 +38,7 @@ public abstract class StructuralParentNode extends Pa @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || name.equals(this.name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); @@ -84,8 +84,8 @@ public abstract class StructuralParentNode extends Pa @Override public void addPublishedBy(IStructuralNode node) { - publisher.add(node); - firePropertyChanged(G3D.URIs.publishes); + if (publisher.add(node)) + firePropertyChanged(G3D.URIs.publishes); } @Override diff --git a/org.simantics.plant3d/META-INF/MANIFEST.MF b/org.simantics.plant3d/META-INF/MANIFEST.MF index aa6bfd98..4d63758e 100644 --- a/org.simantics.plant3d/META-INF/MANIFEST.MF +++ b/org.simantics.plant3d/META-INF/MANIFEST.MF @@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.core.runtime, org.simantics.browsing.ui.platform;bundle-version="1.1.0", org.simantics.structural.ui;bundle-version="1.1.1", org.simantics.g3d.csg;bundle-version="1.0.0", - org.simantics.utils.thread.swt;bundle-version="1.1.0" + org.simantics.utils.thread.swt;bundle-version="1.1.0", + org.slf4j.api Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.simantics.plant3d.actions, @@ -50,4 +51,3 @@ Export-Package: org.simantics.plant3d.actions, org.simantics.plant3d.scl, org.simantics.plant3d.utils Automatic-Module-Name: org.simantics.plant3d -Import-Package: org.slf4j diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java index 6c6c1b66..c784b411 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/GeometryComponent.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.jcae.opencascade.jni.TopoDS_Shape; @@ -133,7 +134,7 @@ public class GeometryComponent { for (String id : parameters.keySet()) { Object currentValue = currentParameters.get(id); Object newValue = parameters.get(id); - if (currentValue == newValue) + if (Objects.equals(currentValue, newValue)) continue; if (newValue == null) { continue; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java index cbdecc1c..61ac722c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java @@ -83,6 +83,9 @@ public class Nozzle extends PipelineComponent { @RelatedSetObj(Plant3D.URIs.HasPipeRun) @Override public void setPipeRun(PipeRun pipeRun) { + if (this.getPipeRun() == pipeRun) + return; + super.setPipeRun(pipeRun); try { _createCP(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DNode.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DNode.java index 84e1535e..14ffcf53 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DNode.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DNode.java @@ -1,5 +1,7 @@ package org.simantics.plant3d.scenegraph; +import java.util.Objects; + import org.simantics.g3d.property.annotations.GetPropertyValue; import org.simantics.g3d.property.annotations.SetPropertyValue; import org.simantics.g3d.scenegraph.G3DNode; @@ -20,9 +22,11 @@ public abstract class P3DNode extends G3DNode implements IP3DVisualNode { @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || Objects.equals(this.name, name)) return; + this.name = name; + firePropertyChanged(Layer0.URIs.HasName); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DParentNode.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DParentNode.java index 2be49183..d7f6749e 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DParentNode.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DParentNode.java @@ -1,6 +1,7 @@ package org.simantics.plant3d.scenegraph; import java.util.HashSet; +import java.util.Objects; import java.util.Set; import javax.vecmath.Quat4d; @@ -35,7 +36,7 @@ public abstract class P3DParentNode extends ParentNode im @RelatedSetValue(Layer0.URIs.HasName) @SetPropertyValue(Layer0.URIs.HasName) public void setName(String name) { - if (name == null) + if (name == null || name.equals(this.name)) return; this.name = name; firePropertyChanged(Layer0.URIs.HasName); @@ -80,6 +81,9 @@ public abstract class P3DParentNode extends ParentNode im @SetPropertyValue(G3D.URIs.hasOrientation) public void setOrientation(Quat4d orientation) { assert(orientation != null); + if (Objects.equals(this.orientation, orientation)) + return; + this.orientation = orientation; firePropertyChanged(G3D.URIs.hasOrientation); @@ -89,6 +93,9 @@ public abstract class P3DParentNode extends ParentNode im @SetPropertyValue(G3D.URIs.hasPosition) public void setPosition(Vector3d position) { assert(position != null); + if (Objects.equals(this.position, position)) + return; + this.position = position; firePropertyChanged(G3D.URIs.hasPosition); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java index 1d199f53..86f649aa 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java @@ -1,12 +1,14 @@ package org.simantics.plant3d.scenegraph; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.simantics.g3d.math.MathTools; import org.simantics.g3d.property.annotations.GetPropertyValue; @@ -64,6 +66,8 @@ public class PipeRun extends P3DParentNode { @RelatedSetValue(Plant3D.URIs.HasTurnRadius) @SetPropertyValue(Plant3D.URIs.HasTurnRadius) public void setTurnRadius(double turnRadius) { + if (this.turnRadius[0] == turnRadius) + return; this.turnRadius[0] = turnRadius; firePropertyChanged(Plant3D.URIs.HasTurnRadius); firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray); @@ -78,7 +82,7 @@ public class PipeRun extends P3DParentNode { @RelatedSetValue(Plant3D.URIs.HasTurnRadiusArray) @SetPropertyValue(Plant3D.URIs.HasTurnRadiusArray) public void setTurnRadiusArray(double[] turnRadiusArray) { - if (turnRadiusArray == null || turnRadiusArray.length == 0) + if (turnRadiusArray == null || turnRadiusArray.length == 0 || Arrays.equals(this.turnRadius, turnRadiusArray)) return; this.turnRadius = turnRadiusArray; firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray); @@ -93,7 +97,10 @@ public class PipeRun extends P3DParentNode { @RelatedSetValue(Plant3D.URIs.HasPipeDiameter) @SetPropertyValue(Plant3D.URIs.HasPipeDiameter) public void setPipeDiameter(double pipeDiameter) { - this.pipeDiameter = pipeDiameter; + if (Objects.equals(this.pipeDiameter, pipeDiameter)) + return; + + this.pipeDiameter = pipeDiameter; firePropertyChanged(Plant3D.URIs.HasPipeDiameter); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index d3ded1ef..f0621fdd 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import javax.vecmath.Quat4d; import javax.vecmath.Tuple3d; @@ -728,12 +729,9 @@ public abstract class PipelineComponent extends GeometryNode { * @param error */ public void setError(String error) { - if (this.error == null) { - if (error == null) - return; - } else if (this.error.equals(error)) + if (Objects.equals(this.error, error)) return; - this.error = error; + this.error = error; firePropertyChanged("error"); } } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index 9e9beb9c..8f1b9a88 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Objects; import javax.vecmath.AxisAngle4d; import javax.vecmath.Matrix3d; @@ -379,9 +380,10 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public void setLength(double l) { - if (Double.isInfinite(l) || Double.isNaN(l)) { + if (this.length == l) + return; + if (Double.isInfinite(l) || Double.isNaN(l)) return; - } if (Math.abs(this.length-l) < MathTools.NEAR_ZERO) return; this.length = l; @@ -429,6 +431,8 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } if (this.turnAngle != null && Math.abs(this.turnAngle-turnAngle) < MathTools.NEAR_ZERO) return; + if (Objects.equals(this.turnAngle, turnAngle)) + return; this.turnAngle = turnAngle; firePropertyChanged("turnAngle"); } @@ -446,6 +450,8 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } if (this.offset != null && Math.abs(this.offset-offset) < MathTools.NEAR_ZERO) return; + if (Objects.equals(this.offset, offset)) + return; this.offset = offset; firePropertyChanged("offset"); } @@ -456,11 +462,15 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } if (this.rotationAngle != null && Math.abs(this.rotationAngle-rotationAngle) < MathTools.NEAR_ZERO) return; + if (Objects.equals(rotationAngle, rotationAngle)) + return; this.rotationAngle = rotationAngle; firePropertyChanged("rotationAngle"); } public void setReversed(Boolean reversed) { + if (this.reversed == reversed) + return; this.reversed = reversed; firePropertyChanged("reversed"); } @@ -1603,7 +1613,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { component._setWorldPosition(getWorldPosition()); updateSubPoint(); } - + private void updateSubPoint() { if (isOffset()) { if (next == null && previous == null) { diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index 2c77c2bf..e8729872 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -1370,7 +1370,7 @@ public class PipingRules { while (iter > 0) { Vector3d tp = new Vector3d(dir); tp.scaleAdd(curr, dp); - tcp.setPosition(tp); + tcp._setPosition(tp); // no firing of listeners here if (other == ne) { dir2 = pathLegDirection(tcp); } else { @@ -1390,7 +1390,7 @@ public class PipingRules { } } finally { - tcp.setPosition(tp0); + tcp._setPosition(tp0); // return the original value } return curr; } -- 2.47.0