X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fscenegraph%2FG3DNode.java;h=7b890b39b8ae16cdd85ad19f331fffb846b6c46e;hb=9f84331c9967c88e0e5550ce91f2b7e364a5cb6d;hp=714e7a5bc4d2a6fdbf33e4826bab47e7f9fceac5;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git 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 714e7a5b..7b890b39 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/G3DNode.java @@ -1,5 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ package org.simantics.g3d.scenegraph; +import java.util.Objects; + import javax.vecmath.Quat4d; import javax.vecmath.Vector3d; @@ -7,7 +20,6 @@ import org.simantics.g3d.ontology.G3D; import org.simantics.g3d.property.annotations.GetPropertyValue; import org.simantics.g3d.property.annotations.PropertyContributor; import org.simantics.g3d.property.annotations.SetPropertyValue; -import org.simantics.g3d.scenegraph.base.INode; import org.simantics.g3d.scenegraph.base.Node; import org.simantics.g3d.tools.NodeTools; import org.simantics.objmap.graph.annotations.RelatedGetValue; @@ -51,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); } @@ -67,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); @@ -79,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() { @@ -138,11 +161,9 @@ public class G3DNode extends Node implements IG3DNode { } @Override - public Object getAdapter(Class adapter) { - if (INode.class == adapter) - return this; - if (IG3DNode.class == adapter) - return this; + public C getAdapter(Class adapter) { + if (adapter.isInstance(this)) + return adapter.cast(this); return null; }