]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java
Overriding selection and hover highlights
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / common / VTKSelectionItem.java
index d998801b50faed05e3debfc8d96e384d5037d0e7..222da8b92012de4a404d0d3f862b84ed926768e3 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g3d.vtk.common;\r
-\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.simantics.db.Resource;\r
-import org.simantics.g3d.scenegraph.IG3DNode;\r
-import org.simantics.g3d.scenegraph.base.INode;\r
-import org.simantics.objmap.structural.StructuralResource;\r
-\r
-import vtk.vtkProp;\r
-\r
-public class VTKSelectionItem<DBObject> implements IAdaptable{\r
-\r
-       private vtkProp prop;\r
-       private IG3DNode node;\r
-       private DBObject resource;\r
-\r
-       //private VTKpropSet actors;\r
-       \r
-       \r
-       public VTKSelectionItem(vtkProp prop, IG3DNode node, DBObject res) {\r
-               this.prop = prop;\r
-               this.node = node;\r
-               this.resource = res;\r
-       }\r
-       \r
-//     public VTKSelectionItem(Resource res, Collection<vtkProp> actors) {\r
-//             this.resource = res;\r
-//             this.actors = new VTKpropSet();\r
-//             this.actors.addAll(actors);\r
-//     }\r
-//     \r
-//     public VTKSelectionItem(Resource res, vtkProp... actors) {\r
-//             this.resource = res;\r
-//             this.actors = new VTKpropSet();\r
-//             for (vtkProp a : actors)\r
-//                     this.actors.add(a);\r
-//     }\r
-\r
-       @SuppressWarnings("rawtypes")\r
-       @Override\r
-       public Object getAdapter(Class adapter) {\r
-               if (adapter == Resource.class)\r
-                       if (resource instanceof Resource)\r
-                               return resource;\r
-                       else\r
-                               return null;\r
-               if (adapter == StructuralResource.class)\r
-                       if (resource instanceof StructuralResource)\r
-                               return resource;\r
-                       else\r
-                               return null;\r
-               if (adapter == vtkProp.class)\r
-                       return prop;\r
-               if (adapter == IG3DNode.class)\r
-                       return node;\r
-               if (adapter == INode.class)\r
-                       return node;\r
-               return null;\r
-       }\r
-       \r
-//     @SuppressWarnings("rawtypes")\r
-//     @Override\r
-//     public Object getAdapter(Class adapter) {\r
-//             if (adapter == Resource.class)\r
-//                     return resource;\r
-//             if (adapter == VTKpropSet.class)\r
-//                     return actors;\r
-//             return null;\r
-//     }\r
-       \r
-//     public Resource getResource() {\r
-//             return resource;\r
-//     }\r
-//     \r
-//     public VTKpropSet getActors() {\r
-//             return actors;\r
-//     }\r
-       \r
-       @SuppressWarnings("rawtypes")\r
-       @Override\r
-       public boolean equals(Object obj) {\r
-               if (obj == null)\r
-                       return false;\r
-               if (obj.getClass() != this.getClass())\r
-                       return false;\r
-               VTKSelectionItem other = (VTKSelectionItem)obj;\r
-               if (prop != null)\r
-                       return prop.equals(other.prop);\r
-               if (node != null)\r
-                       return node.equals(other.node);\r
-               return resource.equals(other.resource);\r
-               //return resource.equals(other.resource);\r
-                       \r
-       }\r
-}\r
+/*******************************************************************************
+ * 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<DBObject> 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;
+                       
+       }
+}