]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Include CSG modelling with Plant3D 65/3065/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 6 Aug 2019 09:46:44 +0000 (12:46 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 6 Aug 2019 09:46:44 +0000 (12:46 +0300)
gitlab #20

Change-Id: I2e2da1579d4982abfe08c9548f9f335ba3353110

org.simantics.g3d.csg/META-INF/MANIFEST.MF
org.simantics.g3d.csg/src/org/simantics/g3d/csg/handler/NewCSGModelHandler.java [new file with mode: 0644]
org.simantics.g3d.csg/src/org/simantics/g3d/csg/model/ModelUtil.java [new file with mode: 0644]
org.simantics.plant3d.modeling.feature/feature.xml
org.simantics.plant3d.ontology/graph/plant3d_viewpoint.pgraph
org.simantics.plant3d/META-INF/MANIFEST.MF
org.simantics.plant3d/plugin.xml

index a0a1c81b675798cb32644b686830f1ae7927c3a2..c2c209c92ee6a55bb5c3e13f29310f6478fd6a26 100644 (file)
@@ -24,3 +24,5 @@ Require-Bundle: org.eclipse.core.runtime,
  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
diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/handler/NewCSGModelHandler.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/handler/NewCSGModelHandler.java
new file mode 100644 (file)
index 0000000..668f7bf
--- /dev/null
@@ -0,0 +1,40 @@
+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
diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/model/ModelUtil.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/model/ModelUtil.java
new file mode 100644 (file)
index 0000000..743ca8e
--- /dev/null
@@ -0,0 +1,19 @@
+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;
+       }
+}
index e307342bad5bcf2788aaf40a6d4614814110a0a6..96f2034f115aaaf885fcc094a71968d3af0f91f5 100644 (file)
          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>
index c2d02ada614bfcbcf3d6ca33eb6fda516e88f632..bb06785b1fe4ff4751966b6d19f390e3da1340a2 100644 (file)
@@ -20,6 +20,7 @@ PBC = P3D.P3DBrowseContext : VP.BrowseContext
     @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
 
index 6f2e691d46972e0f35f768d2cddf3c43c79cd1e9..2b216e01d690417c259e95bd43bac3efa1221380 100644 (file)
@@ -31,7 +31,8 @@ Require-Bundle: org.eclipse.core.runtime,
  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,
index e256683aa30ceb134c09d297c483ab54a1ef52b9..29f03e32f7d392644b72b7378416454831c33e71 100644 (file)
                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">