]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKSelectionItem.java
d998801b50faed05e3debfc8d96e384d5037d0e7
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / common / VTKSelectionItem.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g3d.vtk.common;\r
13 \r
14 import org.eclipse.core.runtime.IAdaptable;\r
15 import org.simantics.db.Resource;\r
16 import org.simantics.g3d.scenegraph.IG3DNode;\r
17 import org.simantics.g3d.scenegraph.base.INode;\r
18 import org.simantics.objmap.structural.StructuralResource;\r
19 \r
20 import vtk.vtkProp;\r
21 \r
22 public class VTKSelectionItem<DBObject> implements IAdaptable{\r
23 \r
24         private vtkProp prop;\r
25         private IG3DNode node;\r
26         private DBObject resource;\r
27 \r
28         //private VTKpropSet actors;\r
29         \r
30         \r
31         public VTKSelectionItem(vtkProp prop, IG3DNode node, DBObject res) {\r
32                 this.prop = prop;\r
33                 this.node = node;\r
34                 this.resource = res;\r
35         }\r
36         \r
37 //      public VTKSelectionItem(Resource res, Collection<vtkProp> actors) {\r
38 //              this.resource = res;\r
39 //              this.actors = new VTKpropSet();\r
40 //              this.actors.addAll(actors);\r
41 //      }\r
42 //      \r
43 //      public VTKSelectionItem(Resource res, vtkProp... actors) {\r
44 //              this.resource = res;\r
45 //              this.actors = new VTKpropSet();\r
46 //              for (vtkProp a : actors)\r
47 //                      this.actors.add(a);\r
48 //      }\r
49 \r
50         @SuppressWarnings("rawtypes")\r
51         @Override\r
52         public Object getAdapter(Class adapter) {\r
53                 if (adapter == Resource.class)\r
54                         if (resource instanceof Resource)\r
55                                 return resource;\r
56                         else\r
57                                 return null;\r
58                 if (adapter == StructuralResource.class)\r
59                         if (resource instanceof StructuralResource)\r
60                                 return resource;\r
61                         else\r
62                                 return null;\r
63                 if (adapter == vtkProp.class)\r
64                         return prop;\r
65                 if (adapter == IG3DNode.class)\r
66                         return node;\r
67                 if (adapter == INode.class)\r
68                         return node;\r
69                 return null;\r
70         }\r
71         \r
72 //      @SuppressWarnings("rawtypes")\r
73 //      @Override\r
74 //      public Object getAdapter(Class adapter) {\r
75 //              if (adapter == Resource.class)\r
76 //                      return resource;\r
77 //              if (adapter == VTKpropSet.class)\r
78 //                      return actors;\r
79 //              return null;\r
80 //      }\r
81         \r
82 //      public Resource getResource() {\r
83 //              return resource;\r
84 //      }\r
85 //      \r
86 //      public VTKpropSet getActors() {\r
87 //              return actors;\r
88 //      }\r
89         \r
90         @SuppressWarnings("rawtypes")\r
91         @Override\r
92         public boolean equals(Object obj) {\r
93                 if (obj == null)\r
94                         return false;\r
95                 if (obj.getClass() != this.getClass())\r
96                         return false;\r
97                 VTKSelectionItem other = (VTKSelectionItem)obj;\r
98                 if (prop != null)\r
99                         return prop.equals(other.prop);\r
100                 if (node != null)\r
101                         return node.equals(other.node);\r
102                 return resource.equals(other.resource);\r
103                 //return resource.equals(other.resource);\r
104                         \r
105         }\r
106 }\r