From 0602e0f78f22aaf27211ef1de801ddc631e103c0 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 15 Aug 2019 17:01:36 +0300 Subject: [PATCH] SCL bindings to some G3D and Plant3D Java classes gitlab #28 Change-Id: Ide08db8b186645096e50739c6e49d65b2585d627 --- org.simantics.g3d/scl/g3d/math/AxisAngle4d | 20 +++++++ org.simantics.g3d/scl/g3d/math/MathTools.scl | 13 +++++ org.simantics.g3d/scl/g3d/math/Point3d.scl | 14 +++++ org.simantics.g3d/scl/g3d/math/Quat4d.scl | 36 +++++++++++++ org.simantics.g3d/scl/g3d/math/Tuple3d.scl | 25 +++++++++ org.simantics.g3d/scl/g3d/math/Vector3d.scl | 24 +++++++++ .../scl/plant3d/scenegraph/EndComponent.scl | 9 ++++ .../scl/plant3d/scenegraph/Equipment.scl | 12 +++++ .../plant3d/scenegraph/InlineComponent.scl | 17 ++++++ .../scl/plant3d/scenegraph/Nozzle.scl | 14 +++++ .../scl/plant3d/scenegraph/P3DNode.scl | 20 +++++++ .../scl/plant3d/scenegraph/P3DParentNode.scl | 20 +++++++ .../plant3d/scenegraph/PipeControlPoint.scl | 2 + .../scl/plant3d/scenegraph/PipeRun.scl | 4 ++ .../plant3d/scenegraph/PipelineComponent.scl | 54 +++++++++++++++++++ .../scl/plant3d/scenegraph/Root.scl | 0 .../scl/plant3d/scenegraph/TurnComponent.scl | 21 ++++++++ .../scl/plant3d/utils/P3DUtil.scl | 34 ++++++++++++ .../actions/TranslateInlineAction.java | 4 +- .../plant3d/editor/Plant3DEditor.java | 35 +----------- .../plant3d/scenegraph/Equipment.java | 6 ++- .../plant3d/scenegraph/InlineComponent.java | 2 +- .../plant3d/scenegraph/PipelineComponent.java | 16 ++---- .../plant3d/scenegraph/TurnComponent.java | 5 -- .../src/org/simantics/plant3d/utils/Item.java | 2 - .../org/simantics/plant3d/utils/P3DUtil.java | 43 ++++++++++++++- 26 files changed, 396 insertions(+), 56 deletions(-) create mode 100644 org.simantics.g3d/scl/g3d/math/AxisAngle4d create mode 100644 org.simantics.g3d/scl/g3d/math/MathTools.scl create mode 100644 org.simantics.g3d/scl/g3d/math/Point3d.scl create mode 100644 org.simantics.g3d/scl/g3d/math/Quat4d.scl create mode 100644 org.simantics.g3d/scl/g3d/math/Tuple3d.scl create mode 100644 org.simantics.g3d/scl/g3d/math/Vector3d.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/EndComponent.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/Equipment.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/InlineComponent.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/Nozzle.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/P3DNode.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/P3DParentNode.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/PipeControlPoint.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/PipeRun.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/PipelineComponent.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/Root.scl create mode 100644 org.simantics.plant3d/scl/plant3d/scenegraph/TurnComponent.scl create mode 100644 org.simantics.plant3d/scl/plant3d/utils/P3DUtil.scl diff --git a/org.simantics.g3d/scl/g3d/math/AxisAngle4d b/org.simantics.g3d/scl/g3d/math/AxisAngle4d new file mode 100644 index 00000000..ed15467a --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/AxisAngle4d @@ -0,0 +1,20 @@ +import "./Tuple3d" + +importJava "javax.vecmath.AxisAngle4d" where + data AxisAngle4d + + @JavaName "" + createAxisAngle4d -> Double -> Double -> Double -> Double -> AxisAngle4d + @JavaName "" + createAxisAngle4d2 -> Tuple3d -> Double -> AxisAngle4d + @JavaName "" + defaultAxisAngle4d -> AxisAngle4d + + getX :: AxisAngle4d -> Double + getY :: AxisAngle4d -> Double + getZ :: AxisAngle4d -> Double + getAngle :: AxisAngle4d -> Double + setX :: AxisAngle4d -> Double -> () + setY :: AxisAngle4d -> Double -> () + setZ :: AxisAngle4d -> Double -> () + setAngle :: AxisAngle4d -> Double -> () \ No newline at end of file diff --git a/org.simantics.g3d/scl/g3d/math/MathTools.scl b/org.simantics.g3d/scl/g3d/math/MathTools.scl new file mode 100644 index 00000000..9f9d76fd --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/MathTools.scl @@ -0,0 +1,13 @@ +import "./Tuple3d" as T3 + +importJava "org.simantics.g3d.math.MathTools" where + + @JavaName equals + equalsd :: Double -> Double -> Boolean + @JavaName equals + equalst :: T3.Tuple3d -> T3.Tuple3d -> Boolean + + distance :: T3.Tuple3d -> T3.Tuple3d -> Double + distanceSquared :: T3.Tuple3d -> T3.Tuple3d -> Double + + isValid :: T3.Tuple3d -> Boolean \ No newline at end of file diff --git a/org.simantics.g3d/scl/g3d/math/Point3d.scl b/org.simantics.g3d/scl/g3d/math/Point3d.scl new file mode 100644 index 00000000..11012aa4 --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/Point3d.scl @@ -0,0 +1,14 @@ +import "./Tuple3d" + +importJava "javax.vecmath.Point3d" where + data Point3d + + distance :: Point3d -> Point3d -> Double + distanceSquared :: Point3d -> Point3d -> Double + + @JavaName "" + createPoint3d :: Double -> Double -> Double -> Point3d + @JavaName "" + copyPoint3d :: Tuple3d -> Point3d + @JavaName "" + defaultPoint3d :: Point3d \ No newline at end of file diff --git a/org.simantics.g3d/scl/g3d/math/Quat4d.scl b/org.simantics.g3d/scl/g3d/math/Quat4d.scl new file mode 100644 index 00000000..a9910dc6 --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/Quat4d.scl @@ -0,0 +1,36 @@ + +importJava "javax.vecmath.Quat4d" where + data Quat4d + + @JavaName "" + createQuat4d :: Double -> Double -> Double -> Double -> Quat4d + @JavaName "" + copyQuat4d :: Quat4d -> Quat4d + @JavaName "" + defaultQuat4d :: Quat4d + + getX :: Quat4d -> Double + getY :: Quat4d -> Double + getZ :: Quat4d -> Double + getW:: Quat4d -> Double + setX :: Quat4d -> Double -> () + setY :: Quat4d -> Double -> () + setZ :: Quat4d -> Double -> () + setW :: Quat4d -> Double -> () + + mul :: Quat4d -> Quat4d -> () + @JavaName mul + mul2 :: Quat4d -> Quat4d -> Quat4d ->() + + mulInverse :: Quat4d -> Quat4d -> () + @JavaName mulInverse + mulInverse2 :: Quat4d -> Quat4d -> Quat4d ->() + + inverse :: Quat4d -> () + @JavaName inverse + inverse2 :: Quat4d -> Quat4d ->() + + normalize :: Quat4d -> () + @JavaName normalize + normalize2 :: Quat4d -> Quat4d ->() + \ No newline at end of file diff --git a/org.simantics.g3d/scl/g3d/math/Tuple3d.scl b/org.simantics.g3d/scl/g3d/math/Tuple3d.scl new file mode 100644 index 00000000..0126c41b --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/Tuple3d.scl @@ -0,0 +1,25 @@ +importJava "javax.vecmath.Tuple3d" where + data Tuple3d + + getX :: Tuple3d -> Double + getY :: Tuple3d -> Double + getZ :: Tuple3d -> Double + setX :: Tuple3d -> Double -> () + setY :: Tuple3d -> Double -> () + setZ :: Tuple3d -> Double -> () + + add :: Tuple3d -> Tuple3d -> () + @JavaName add + add2 :: Tuple3d -> Tuple3d -> Tuple3d -> () + + sub :: Tuple3d -> Tuple3d -> () + @JavaName sub + sub2 :: Tuple3d -> Tuple3d -> Tuple3d -> () + + negate :: Tuple3d -> () + @JavaName negate + negate2 :: Tuple3d -> Tuple3d -> () + + scale :: Tuple3d -> Double -> () + @JavaName scale + scale2 :: Tuple3d -> Double -> Tuple3d -> () \ No newline at end of file diff --git a/org.simantics.g3d/scl/g3d/math/Vector3d.scl b/org.simantics.g3d/scl/g3d/math/Vector3d.scl new file mode 100644 index 00000000..b2c9243d --- /dev/null +++ b/org.simantics.g3d/scl/g3d/math/Vector3d.scl @@ -0,0 +1,24 @@ +import "./Tuple3d" + +importJava "javax.vecmath.Vector3d" where + data Vector3d + + cross :: Vector3d -> Vector3d -> Vector3d -> () + + normalize :: Vector3d -> () + @JavaName normalize + normalize_2 :: Vector3d -> Vector3d -> () + + dot :: Vector3d -> Vector3d -> Double + + length :: Vector3d -> Double + lengthSquared :: Vector3d -> Double + + angle :: Vector3d -> Vector3d -> Double + + @JavaName "" + createVector3d :: Double -> Double -> Double -> Vector3d + @JavaName "" + copyVector3d :: Tuple3d -> Vector3d + @JavaName "" + defaultVector3d :: Vector3d \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/EndComponent.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/EndComponent.scl new file mode 100644 index 00000000..5a20dcec --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/EndComponent.scl @@ -0,0 +1,9 @@ +import "./PipelineComponent" +import "./PipeRun" + +importJava "org.simantics.plant3d.scenegraph.EndComponent" where + data EndComponent + + getType :: EndComponent -> String + getControlPoint :: EndComponent -> PipeControlPoint + getPipeRun :: EndComponent -> Maybe PipeRun \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/Equipment.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/Equipment.scl new file mode 100644 index 00000000..ce1b3b7a --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/Equipment.scl @@ -0,0 +1,12 @@ +import "./Nozzle" + +importJava "org.simantics.plant3d.scenegraph.Equipment" where + data Equipment + + getType :: Equipment -> String + + addChild :: Equipment -> Nozzle -> () + remChild :: Equipment -> Nozzle -> () + getChild :: Equipment -> [Nozzle] + + numberOfFixedNozzles :: Equipment -> Integer \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/InlineComponent.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/InlineComponent.scl new file mode 100644 index 00000000..1af26ab8 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/InlineComponent.scl @@ -0,0 +1,17 @@ +import "./PipelineComponent" +import "./PipeRun" + +importJava "org.simantics.plant3d.scenegraph.InlineComponent" where + data InlineComponent + + getType :: InlineComponent -> String + getControlPoint :: InlineComponent -> PipeControlPoint + getPipeRun :: InlineComponent -> Maybe PipeRun + + isVariableLength :: InlineComponent -> Boolean + getRotationAngle :: InlineComponent -> Maybe Double + setRotationAngle :: InlineComponent -> Maybe Double -> () + + isReversed :: InlineComponent -> Maybe Boolean + setReversed :: InlineComponent -> Maybe Boolean -> () + \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/Nozzle.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/Nozzle.scl new file mode 100644 index 00000000..702c4b03 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/Nozzle.scl @@ -0,0 +1,14 @@ +import "./PipelineComponent" +import "./PipeRun" + +importJava "org.simantics.plant3d.scenegraph.Nozzle" where + data Nozzle + + getType :: Nozzle -> String + getControlPoint :: Nozzle -> PipeControlPoint + getPipeRun :: Nozzle -> Maybe PipeRun + + getNozzleId :: Nozzle -> Integer + isFixed :: Nozzle -> Boolean + isConnected :: Nozzle -> Boolean + \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/P3DNode.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/P3DNode.scl new file mode 100644 index 00000000..1b30d88c --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/P3DNode.scl @@ -0,0 +1,20 @@ +import "g3d/math/Vector3d" +import "g3d/math/Quat4d" + +importJava "org.simantics.plant3d.scenegraph.P3DNode" where + data P3DNode + + getName :: P3DNode -> Maybe String + setName :: P3DNode -> String -> () + + getOrientation :: P3DNode -> Quat4d + getPosition :: P3DNode -> Vector3d + + setOrientation :: P3DNode -> Quat4d -> () + setPosition :: P3DNode -> Vector3d -> () + + getWorldOrientation :: P3DNode -> Quat4d + getWorldPosition :: P3DNode -> Vector3d + + setWorldOrientation :: P3DNode -> Quat4d -> () + setWorldPosition :: P3DNode -> Vector3d -> () \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/P3DParentNode.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/P3DParentNode.scl new file mode 100644 index 00000000..05e7c1f2 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/P3DParentNode.scl @@ -0,0 +1,20 @@ +import "g3d/math/Vector3d" +import "g3d/math/Quat4d" + +importJava "org.simantics.plant3d.scenegraph.P3DParentNode" where + data P3DParentNode + + getName :: P3DParentNode -> Maybe String + setName :: P3DParentNode -> String -> () + + getOrientation :: P3DParentNode -> Quat4d + getPosition :: P3DParentNode -> Vector3d + + setOrientation :: P3DParentNode -> Quat4d -> () + setPosition :: P3DParentNode -> Vector3d -> () + + getWorldOrientation :: P3DParentNode -> Quat4d + getWorldPosition :: P3DParentNode -> Vector3d + + setWorldOrientation :: P3DParentNode -> Quat4d -> () + setWorldPosition :: P3DParentNode -> Vector3d -> () \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/PipeControlPoint.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/PipeControlPoint.scl new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/PipeControlPoint.scl @@ -0,0 +1,2 @@ + + diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/PipeRun.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/PipeRun.scl new file mode 100644 index 00000000..2e56a0d6 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/PipeRun.scl @@ -0,0 +1,4 @@ +import "g3d/math/Tuple3d" + +importJava "org.simantics.plant3d.scenegraph.PipeRun" where + data PipeRun \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/PipelineComponent.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/PipelineComponent.scl new file mode 100644 index 00000000..94dc9a47 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/PipelineComponent.scl @@ -0,0 +1,54 @@ +import "g3d/math/Tuple3d" + +import "./PipeRun" + +importJava "org.simantics.plant3d.scenegraph.PipelineComponent" where + data PipelineComponent + + getPipeRun :: PipelineComponent -> PipeRun + setPipeRun :: PipelineComponent -> PipeRun -> () + + getAlternativePipeRun :: PipelineComponent -> Maybe PipeRun + setAlternativePipeRun :: PipelineComponent -> PipeRun -> () + + updateParameters :: PipelineComponent -> () + + getNext :: PipelineComponent -> Maybe PipelineComponent + setNext :: PipelineComponent -> Maybe PipelineComponent -> () + + getPrevious :: PipelineComponent -> Maybe PipelineComponent + setPrevious :: PipelineComponent -> Maybe PipelineComponent -> () + + getBranch0 :: PipelineComponent -> Maybe PipelineComponent + setBranch0 :: PipelineComponent -> Maybe PipelineComponent -> () + + getType :: PipelineComponent -> String + + //getControlPoint :: PipelineComponent -> PipeControlPoint + + remove :: PipelineComponent -> () + + getFlowLength :: PipelineComponent -> Maybe Double + getEnds :: PipelineComponent -> Tuple3d -> Tuple3d -> () + +importJava "org.simantics.plant3d.scenegraph.PipeControlPoint$Type" where + data PointType + +importJava "org.simantics.plant3d.scenegraph.PipeControlPoint.Direction" where + data Direction + +importJava "org.simantics.plant3d.scenegraph.PipeControlPoint.PositionType" where + data PositionType + +importJava "org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint" where + data PipeControlPoint + + getPipelineComponent :: PipeControlPoint -> PipelineComponent + + //@JavaName getType + //getPointType :: PipeControlPoint -> PointType + + isFixed :: PipeControlPoint -> Boolean + + getSubPoint :: PipeControlPoint -> [PipeControlPoint] + getParentPoint :: PipeControlPoint -> Maybe PipeControlPoint \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/Root.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/Root.scl new file mode 100644 index 00000000..e69de29b diff --git a/org.simantics.plant3d/scl/plant3d/scenegraph/TurnComponent.scl b/org.simantics.plant3d/scl/plant3d/scenegraph/TurnComponent.scl new file mode 100644 index 00000000..f6ed6cfe --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/scenegraph/TurnComponent.scl @@ -0,0 +1,21 @@ +import "./PipelineComponent" +import "./PipeRun" + +import "g3d/math/Vector3d" + +importJava "org.simantics.plant3d.scenegraph.TurnComponent" where + data TurnComponent + + getType :: TurnComponent -> String + getControlPoint :: TurnComponent -> PipeControlPoint + getPipeRun :: TurnComponent -> Maybe PipeRun + + isVariableAngle :: TurnComponent -> Boolean + getTurnAngle :: TurnComponent -> Maybe Double + setTurnAngle :: TurnComponent -> Maybe Double -> () + + getTurnAxis :: TurnComponent -> Vector3d + + getRotationAngle :: TurnComponent -> Maybe Double + setRotationAngle :: TurnComponent -> Maybe Double -> () + \ No newline at end of file diff --git a/org.simantics.plant3d/scl/plant3d/utils/P3DUtil.scl b/org.simantics.plant3d/scl/plant3d/utils/P3DUtil.scl new file mode 100644 index 00000000..1e73caf4 --- /dev/null +++ b/org.simantics.plant3d/scl/plant3d/utils/P3DUtil.scl @@ -0,0 +1,34 @@ +import "Simantics/DB" + +importJava "org.simantics.plant3d.utils.Item$Type" where + data ItemType + + EQUIPMENT :: ItemType + INLINE :: ItemType + TURN :: ItemType + END :: ItemType + NOZZLE :: ItemType + + +importJava "org.simantics.plant3d.utils.Item" where + data Item + + getUri :: Item -> String + getName :: Item -> String + getType :: Item -> ItemType + + isCode :: Item -> Boolean + isVariable :: Item -> Boolean + isSizeChange :: Item -> Boolean + +importJava "org.simantics.plant3d.utils.P3DUtil" where + + getEquipments :: () -> [Item] + getNozzles :: () -> [Item] + getTurns :: () -> [Item] + getInlines :: () -> [Item] + getEnds :: () -> [Item] + filterUserComponents :: [Item] -> [Item] + + createModel :: String -> Resource + diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java index 7ea42d59..c8c86224 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java @@ -55,8 +55,8 @@ public class TranslateInlineAction extends TranslateAction{ Point3d ne = new Point3d(); Point3d ps = new Point3d(); Point3d pe = new Point3d(); - next.getControlPointEnds(ns, ne); - prev.getControlPointEnds(ps, pe); + next.getEnds(ns, ne); + prev.getEnds(ps, pe); dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT); dir.normalize(); // We may have offsets in the path leg, hence we have to project the coordinates. diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index 159a239d..21b99bfb 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -158,39 +158,8 @@ public class Plant3DEditor extends ResourceEditorPart { // update control points. // TODO : this should be optimized. try { - for (INode node : rootNode.getChild()) { - if (node instanceof PipeRun) { - for (PipelineComponent pc : ((PipeRun) node).getChild()) - pc.sync(); - } else if (node instanceof Equipment) { - for (PipelineComponent pc : ((Equipment) node).getChild()) - pc.sync(); - } - } - - for (INode node : rootNode.getChild()) { - if (node instanceof PipeRun) { - for (PipelineComponent pc : ((PipeRun) node).getChild()) - pc.sync2(); - } else if (node instanceof Equipment) { - for (PipelineComponent pc : ((Equipment) node).getChild()) - pc.sync2(); - } - } - for (INode node : rootNode.getChild()) { - if (node instanceof PipeRun) { - PipingRules.validate((PipeRun)node); - } - } - PipingRules.setEnabled(true); - for (INode node : rootNode.getChild()) { - if (node instanceof PipeRun) { - PipeRun run = (PipeRun)node; - for (PipeControlPoint pcp : run.getControlPoints()) - PipingRules.positionUpdate(pcp); - - } - } + P3DUtil.finalizeDBLoad(rootNode); + } catch (Exception e) { throw new DatabaseException(e); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java index 27a76067..6b17ef86 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Equipment.java @@ -45,8 +45,12 @@ public class Equipment extends P3DParentGeometryNode { @RelatedElementsAdd(Plant3D.URIs.HasNozzle) public void addChild(Nozzle node) { + Collection children = getChild(); + if (numberOfFixedNozzles() > 0 && children.size() >= numberOfFixedNozzles()) + throw new RuntimeException("Equipment has already all fixed nozzles"); + Set ids = new HashSet(); - for (Nozzle n : getChild()) { + for (Nozzle n : children) { ids.add(n.getNozzleId()); } int newId = 0; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java index 6590c73d..61a4bcb2 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -94,7 +94,7 @@ public class InlineComponent extends PipelineComponent { } @RelatedSetValue(Plant3D.URIs.IsReversed) @SetPropertyValue(value=Plant3D.URIs.IsReversed) - public void setReverse(Boolean reverse) { + public void setReversed(Boolean reverse) { if (!controlPoint.isReverse()) return; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index f71dfed4..e200af6b 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -31,6 +31,10 @@ public abstract class PipelineComponent extends GeometryNode { private PipelineComponent next; private PipelineComponent previous; + public PipeRun getPipeRun() { + return pipeRun; + } + /** * Sets the pipe run. * @@ -370,10 +374,6 @@ public abstract class PipelineComponent extends GeometryNode { return Collections.EMPTY_MAP; } - public PipeRun getPipeRun() { - return pipeRun; - } - public abstract String getType(); public abstract PipeControlPoint getControlPoint(); @@ -463,14 +463,8 @@ public abstract class PipelineComponent extends GeometryNode { } } - public void getControlPointEnds(Tuple3d p1, Tuple3d p2) { + public void getEnds(Tuple3d p1, Tuple3d p2) { getControlPoint().getControlPointEnds(p1, p2); } - public Vector3d getNormal() { - Vector3d v = new Vector3d(); - MathTools.rotate(getWorldOrientation(), MathTools.Z_AXIS, v); - return v; - } - } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java index 4f787b8c..e8779985 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java @@ -102,11 +102,6 @@ public class TurnComponent extends PipelineComponent { return getControlPoint().getTurnAxis(); } - @Override - public Vector3d getNormal() { - return getTurnAxis(); - } - @RelatedGetValue(Plant3D.URIs.HasRotationAngle) @GetPropertyValue(name="Rotation Angle", value=Plant3D.URIs.HasRotationAngle, tabId = "Default") public Double getRotationAngle() { 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 61ef6c9a..e1faef34 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/Item.java @@ -40,8 +40,6 @@ public class Item { return code; } - - public void setCode(boolean code) { this.code = code; } 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 e6e3385f..7ba42b8f 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/utils/P3DUtil.java @@ -11,10 +11,16 @@ import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; +import org.simantics.g3d.scenegraph.base.INode; import org.simantics.layer0.Layer0; import org.simantics.plant3d.ontology.Plant3D; +import org.simantics.plant3d.scenegraph.Equipment; +import org.simantics.plant3d.scenegraph.P3DRootNode; +import org.simantics.plant3d.scenegraph.PipeRun; +import org.simantics.plant3d.scenegraph.PipelineComponent; +import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint; +import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; import org.simantics.plant3d.utils.Item.Type; -import org.simantics.ui.SimanticsUI; public class P3DUtil { @@ -175,5 +181,40 @@ public class P3DUtil { return model; } + + public static void finalizeDBLoad(P3DRootNode rootNode) throws Exception{ + for (INode node : rootNode.getChild()) { + if (node instanceof PipeRun) { + for (PipelineComponent pc : ((PipeRun) node).getChild()) + pc.sync(); + } else if (node instanceof Equipment) { + for (PipelineComponent pc : ((Equipment) node).getChild()) + pc.sync(); + } + } + + for (INode node : rootNode.getChild()) { + if (node instanceof PipeRun) { + for (PipelineComponent pc : ((PipeRun) node).getChild()) + pc.sync2(); + } else if (node instanceof Equipment) { + for (PipelineComponent pc : ((Equipment) node).getChild()) + pc.sync2(); + } + } + for (INode node : rootNode.getChild()) { + if (node instanceof PipeRun) { + PipingRules.validate((PipeRun)node); + } + } + PipingRules.setEnabled(true); + for (INode node : rootNode.getChild()) { + if (node instanceof PipeRun) { + PipeRun run = (PipeRun)node; + for (PipeControlPoint pcp : run.getControlPoints()) + PipingRules.positionUpdate(pcp); + } + } + } } -- 2.47.1