]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/SchemaBuilder.java
Perform view direction switching via vtkCameraAndSelectorAction
[simantics/3d.git] / org.simantics.g3d.csg / src / org / simantics / g3d / csg / scenegraph2 / SchemaBuilder.java
1 /*******************************************************************************
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g3d.csg.scenegraph2;
13
14 import org.simantics.Simantics;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.request.Read;
19 import org.simantics.objmap.graph.schema.IMappingSchema;
20 import org.simantics.objmap.graph.schema.MappingSchemas;
21 import org.simantics.objmap.graph.schema.SimpleSchema;
22
23 public class SchemaBuilder {
24         
25         public static IMappingSchema<Resource,Object> getSchema() throws DatabaseException{
26                 return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,Object>>() {
27                         @Override
28                         public IMappingSchema<Resource,Object> perform(ReadGraph g)
29                                         throws DatabaseException {
30                                 return getSchema(g);
31                         }
32                 });
33         }
34         
35         public static IMappingSchema<Resource,Object> getSchema(ReadGraph g) throws DatabaseException{
36                 try {
37                         SimpleSchema schema = new SimpleSchema();
38                         schema.addLinkType(MappingSchemas.fromAnnotations(g, BarrelNode.class));
39                         schema.addLinkType(MappingSchemas.fromAnnotations(g, BoxNode.class));
40                         schema.addLinkType(MappingSchemas.fromAnnotations(g, ConeNode.class));
41                         schema.addLinkType(MappingSchemas.fromAnnotations(g, CylinderNode.class));
42                         schema.addLinkType(MappingSchemas.fromAnnotations(g, DifferenceNode.class));
43                         schema.addLinkType(MappingSchemas.fromAnnotations(g, EllipticCylinderNode.class));
44                         schema.addLinkType(MappingSchemas.fromAnnotations(g, IntersectionNode.class));
45                         schema.addLinkType(MappingSchemas.fromAnnotations(g, RectangularSolidNode.class));
46                         schema.addLinkType(MappingSchemas.fromAnnotations(g, RegularPrismNode.class));
47                         schema.addLinkType(MappingSchemas.fromAnnotations(g, SphereNode.class));
48                         schema.addLinkType(MappingSchemas.fromAnnotations(g, TorusNode.class));
49                         schema.addLinkType(MappingSchemas.fromAnnotations(g, UnionNode.class));
50                         schema.addLinkType(MappingSchemas.fromAnnotations(g, CSGrootNode.class));
51                         return schema;
52                 } catch (IllegalAccessException e) {
53                         throw new DatabaseException(e);
54                 } catch (InstantiationException e) {
55                         throw new DatabaseException(e);
56                 }
57         }
58
59 }