X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fcommon%2FVTKSelectionItem.java;h=222da8b92012de4a404d0d3f862b84ed926768e3;hb=9070983be64f9f107e0a6388549aad475fcd9d76;hp=5bbbebc10faaf38cf4a3a016a23b07f5efd05655;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java index 5bbbebc1..222da8b9 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java @@ -1,95 +1,75 @@ -package org.simantics.g3d.vtk.common; - -import org.eclipse.core.runtime.IAdaptable; -import org.simantics.db.Resource; -import org.simantics.g3d.scenegraph.IG3DNode; -import org.simantics.g3d.scenegraph.base.INode; -import org.simantics.objmap.structural.StructuralResource; - -import vtk.vtkProp; - -public class VTKSelectionItem implements IAdaptable{ - - private vtkProp prop; - private IG3DNode node; - private DBObject resource; - - //private VTKpropSet actors; - - - public VTKSelectionItem(vtkProp prop, IG3DNode node, DBObject res) { - this.prop = prop; - this.node = node; - this.resource = res; - } - -// public VTKSelectionItem(Resource res, Collection actors) { -// this.resource = res; -// this.actors = new VTKpropSet(); -// this.actors.addAll(actors); -// } -// -// public VTKSelectionItem(Resource res, vtkProp... actors) { -// this.resource = res; -// this.actors = new VTKpropSet(); -// for (vtkProp a : actors) -// this.actors.add(a); -// } - - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class adapter) { - if (adapter == Resource.class) - if (resource instanceof Resource) - return resource; - else - return null; - if (adapter == StructuralResource.class) - if (resource instanceof StructuralResource) - return resource; - else - return null; - if (adapter == vtkProp.class) - return prop; - if (adapter == IG3DNode.class) - return node; - if (adapter == INode.class) - return node; - return null; - } - -// @SuppressWarnings("rawtypes") -// @Override -// public Object getAdapter(Class adapter) { -// if (adapter == Resource.class) -// return resource; -// if (adapter == VTKpropSet.class) -// return actors; -// return null; -// } - -// public Resource getResource() { -// return resource; -// } -// -// public VTKpropSet getActors() { -// return actors; -// } - - @SuppressWarnings("rawtypes") - @Override - public boolean equals(Object obj) { - if (obj == null) - return false; - if (obj.getClass() != this.getClass()) - return false; - VTKSelectionItem other = (VTKSelectionItem)obj; - if (prop != null) - return prop.equals(other.prop); - if (node != null) - return node.equals(other.node); - return resource.equals(other.resource); - //return resource.equals(other.resource); - - } -} +/******************************************************************************* + * 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.vtk.common; + +import org.eclipse.core.runtime.IAdaptable; +import org.simantics.db.Resource; +import org.simantics.g3d.scenegraph.IG3DNode; +import org.simantics.g3d.scenegraph.base.INode; +import org.simantics.objmap.structural.StructuralResource; + +import vtk.vtkProp; + +public class VTKSelectionItem implements IAdaptable{ + + private vtkProp prop; + private IG3DNode node; + private DBObject resource; + + public VTKSelectionItem(vtkProp prop, IG3DNode node, DBObject res) { + this.prop = prop; + this.node = node; + this.resource = res; + } + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) { + if (adapter == Resource.class) + if (resource instanceof Resource) + return resource; + else + return null; + if (adapter == StructuralResource.class) + if (resource instanceof StructuralResource) + return resource; + else + return null; + if (adapter == vtkProp.class) + return prop; + if (adapter == IG3DNode.class) + return node; + if (adapter == INode.class) + return node; + return null; + } + + @SuppressWarnings("rawtypes") + @Override + public boolean equals(Object obj) { + if (obj == null) + return false; + if (obj.getClass() != this.getClass()) + return false; + VTKSelectionItem other = (VTKSelectionItem)obj; + if (prop != null) + if (!prop.equals(other.prop)) + return false; + if (node != null) + if (!node.equals(other.node)) + return false; + if (resource != null) + return resource.equals(other.resource); + return true; + + } +}