org.simantics.opencascade.vtk;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.g3d.csg.handler,
+ org.simantics.g3d.csg.model
--- /dev/null
+package org.simantics.g3d.csg.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.g3d.csg.model.ModelUtil;
+import org.simantics.layer0.Layer0;
+
+public class NewCSGModelHandler extends AbstractHandler {
+
+ private final String defaultName = "CSG Model";
+
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final Resource library = Simantics.getProject().get();
+
+ Simantics.getSession().asyncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ Layer0 l0 = Layer0.getInstance(graph);
+
+ String name = NameUtils.findFreshName(graph, defaultName, library, l0.ConsistsOf, "%s%d");
+
+ Resource model = ModelUtil.createCSGModel(graph, name);
+ graph.claim(library, l0.ConsistsOf, model);
+
+ }
+ });
+ return null;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.simantics.g3d.csg.model;
+
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.g3d.csg.ontology.CSG;
+import org.simantics.layer0.Layer0;
+
+public class ModelUtil {
+
+ public static Resource createCSGModel(WriteGraph graph, String name) throws DatabaseException{
+ Layer0 l0 = Layer0.getInstance(graph);
+ CSG csg = CSG.getInstance(graph);
+ Resource model = graph.newResource();
+ graph.claim(model, l0.InstanceOf, csg.Model);
+ graph.claimLiteral(model, l0.HasName, name);
+ return model;
+ }
+}
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.simantics.g3d.csg"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.simantics.g3d.csg.ontology"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
@VP.constantImageRule P3D.EndComponent IMAGES.Component
@VP.constantImageRule P3D.PipeRun IMAGES.Straight
@VP.relationChildRule PROJ.Project L0.ConsistsOf P3D.Plant
+ @VP.relationChildRule PROJ.Project L0.ConsistsOf CSG.Model
@VP.relationChildRule P3D.Node P3D.childen P3D.Node
@VP.relationChildRule P3D.Node P3D.HasNozzle P3D.Node
org.simantics.ui;bundle-version="1.0.0",
org.simantics.opencascade.vtk;bundle-version="1.0.0",
org.simantics.browsing.ui.platform;bundle-version="1.1.0",
- org.simantics.structural.ui;bundle-version="1.1.1"
+ org.simantics.structural.ui;bundle-version="1.1.1",
+ org.simantics.g3d.csg;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.plant3d.editor,
label="New Plant"
style="push">
</command>
+ <command
+ commandId="org.simantics.plant3d.newCSGModel"
+ label="New CSG Model"
+ style="push">
+ </command>
</menuContribution>
<menuContribution
allPopups="false"
name="Plant3D commands">
</category>
<command
- category="org.simantics.plant3d.category"
+ categoryId="org.simantics.plant3d.category"
id="org.simantics.plant3d.newPlant"
name="New Plant">
</command>
+ <command
+ categoryId="org.simantics.plant3d.category"
+ id="org.simantics.plant3d.newCSGModel"
+ name="New CSG Model">
+ </command>
</extension>
<extension
point="org.eclipse.ui.handlers">
</with>
</activeWhen>
</handler>
+ <handler
+ class="org.simantics.g3d.csg.handler.NewCSGModelHandler"
+ commandId="org.simantics.plant3d.newCSGModel">
+ </handler>
</extension>
<extension
point="org.simantics.project.feature">