From daa07327bd3222487742965d433ea2f041e5ae73 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 15 Nov 2019 13:49:33 +0200 Subject: [PATCH] Tag user modifiable length With modifiable tag, we can ask for length parameter when we insert new components gitlab #26 Change-Id: Ic98a1b491bb8223d28bdca570af5fc792df3fe6c --- org.simantics.plant3d.ontology/graph/plant3d.pgraph | 7 +++---- .../plant3d/dialog/ComponentSelectionDialog.java | 4 ++-- .../simantics/plant3d/scenegraph/InlineComponent.java | 4 ++++ .../plant3d/scenegraph/PipelineComponent.java | 6 ++++++ .../scenegraph/controlpoint/ControlPointFactory.java | 11 +++++++++++ .../scenegraph/controlpoint/PipeControlPoint.java | 10 ++++++++++ .../org/simantics/plant3d/utils/ComponentUtils.java | 8 +++++--- .../src/org/simantics/plant3d/utils/Item.java | 9 +++++++++ .../src/org/simantics/plant3d/utils/P3DUtil.java | 2 ++ 9 files changed, 52 insertions(+), 9 deletions(-) diff --git a/org.simantics.plant3d.ontology/graph/plant3d.pgraph b/org.simantics.plant3d.ontology/graph/plant3d.pgraph index 5621443e..d6029cc6 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d.pgraph @@ -56,15 +56,14 @@ P3D.TurnComponent parameters = new HashMap<>(getParameterMap()); + parameters.put(name, value); + setParameterMap(parameters); + } public abstract void setType(String typeURI) throws Exception; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java index 6b92e447..ff49b93a 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java @@ -45,6 +45,7 @@ public class ControlPointFactory { PipeControlPoint pcp = new PipeControlPoint(component); pcp.setType(inst.type); pcp.setFixed(inst.fixed); + pcp.setMod(inst.mod); pcp.setRotate(inst.isRotate); pcp.setReverse(inst.isReverse); switch(inst.type) { @@ -58,6 +59,7 @@ public class ControlPointFactory { sub.parent = pcp; sub.setType(inst.type); sub.setFixed(inst.fixed); + sub.setMod(inst.mod); sub.setSub(true); sub.setDeletable(false); if (inst.isOffset) @@ -78,6 +80,7 @@ public class ControlPointFactory { private static class Instruction { PointType type; boolean fixed; + boolean mod; boolean isOffset; boolean isSizeChange; boolean isRotate; @@ -98,6 +101,7 @@ public class ControlPointFactory { i.isRotate = false; i.isReverse = false; i.type = PointType.INLINE; + i.mod = false; if (graph.isInheritedFrom(res, p3d.Nozzle)) { i.fixed = true; i.isOffset = false; @@ -110,6 +114,11 @@ public class ControlPointFactory { i.fixed = false; } else if (graph.hasStatement(res,p3d.FixedLengthInlineComponent)) { i.fixed = true; + } else if (graph.hasStatement(res,p3d.AdjustableLengthInlineComponent)) { + i.fixed = true; + i.mod = true; + } else { + throw new DatabaseException("Inline component type " + res + " does not have length configuration."); } if (graph.hasStatement(res,p3d.SizeChangeComponent)) { @@ -133,6 +142,8 @@ public class ControlPointFactory { i.fixed = false; } else if (graph.hasStatement(res,p3d.FixedAngleTurnComponent)) { i.fixed = true; + } else { + throw new DatabaseException("Turn component type " + res + " does not have angle configuration."); } } else if (graph.isInheritedFrom(res, p3d.EndComponent)) { i.fixed = false; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index 20386b54..232b8ab4 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -36,6 +36,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private PointType type; private boolean isFixed = true; // In-line: fixed-length Turn: fixed-angle + private boolean isMod = false; // Can user modify fixed value manually private boolean isRotate = false; // rotates around path leg axis. private boolean isReverse = false; // definition direction can be swapped private boolean isDeletable = true; // can be removed by rules @@ -88,6 +89,15 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public void setFixed(boolean fixed) { this.isFixed = fixed; } + + @GetPropertyValue(name="Mod",tabId="Debug",value="mod") + public boolean isMod() { + return isMod; + } + + public void setMod(boolean isMod) { + this.isMod = isMod; + } @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate") public boolean isRotate() { diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java index 14dce68d..50ede807 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java @@ -329,7 +329,7 @@ public class ComponentUtils { PositionType insertPosition = inst.insertPosition; boolean lengthAdjustable = false; if (newComponent instanceof InlineComponent) { - lengthAdjustable = ((InlineComponent)newComponent).isVariableLength(); + lengthAdjustable = ((InlineComponent)newComponent).isVariableLength() || ((InlineComponent)newComponent).isModifialble(); } boolean insertAdjustable = false; if (component instanceof InlineComponent) { @@ -407,11 +407,13 @@ public class ComponentUtils { newComponent.setName(name); pipeRun.addChild(newComponent); - // TODO: these options are not stored into DB. Should they?! - if (newComponent instanceof InlineComponent && ((InlineComponent)newComponent).isVariableLength()) { + + if (newComponent instanceof InlineComponent && ((InlineComponent)newComponent).isVariableLength() ||((InlineComponent)newComponent).isModifialble()) { newPcp.setLength(inst.length); + newComponent.setParameter("length", inst.length); } else if (newComponent instanceof TurnComponent && ((TurnComponent)newComponent).isVariableAngle()) { newPcp.setTurnAngle(inst.angle); + newComponent.setParameter("turnAngle", inst.angle); } newComponent.updateParameters(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java index e1faef34..799d0727 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java @@ -10,6 +10,7 @@ public class Item { private Type type; private boolean code = false; private boolean variable = false; + private boolean modifiable = false; private boolean sizeChange = false; @@ -52,6 +53,14 @@ public class Item { this.variable = variable; } + public boolean isModifiable() { + return modifiable; + } + + public void setModifiable(boolean modifiable) { + this.modifiable = modifiable; + } + public boolean isSizeChange() { return sizeChange; } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java b/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java index cb46546e..55cfead4 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java @@ -207,6 +207,8 @@ public class P3DUtil { if (graph.hasStatement(r, p3d.VariableAngleTurnComponent) || graph.hasStatement(r, p3d.VariableLengthInlineComponent)) item.setVariable(true); + if (graph.hasStatement(r, p3d.AdjustableLengthInlineComponent)) + item.setModifiable(true); if (graph.hasStatement(r, p3d.SizeChangeComponent)) item.setSizeChange(true); return item; -- 2.47.1