From: miettinen Date: Wed, 20 Nov 2013 13:24:11 +0000 (+0000) Subject: Added loop to Sysdyn comment symbols. Loop has properties of direction of rotation... X-Git-Tag: 1.8.1~189 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=36c3a5bd6b10154ccfd7dd8d5b04a309190fe438;p=simantics%2Fsysdyn.git Added loop to Sysdyn comment symbols. Loop has properties of direction of rotation and comment, of which both can be modified, but are not yet shown on diagram. (refs #3012) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28345 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ontology/graph.tg b/org.simantics.sysdyn.ontology/graph.tg index d606923c..848075d6 100644 Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ diff --git a/org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph b/org.simantics.sysdyn.ontology/graph/CommentSymbols.pgraph similarity index 68% rename from org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph rename to org.simantics.sysdyn.ontology/graph/CommentSymbols.pgraph index 0f6a24a3..22f149e7 100644 --- a/org.simantics.sysdyn.ontology/graph/GeneralSymbols.pgraph +++ b/org.simantics.sysdyn.ontology/graph/CommentSymbols.pgraph @@ -2,8 +2,10 @@ L0 = G2D = DIA = SYSDYN = +IMAGE = +MOD = -GENERAL = SYSDYN.SymbolReferences.GeneralSymbols : DIA.SymbolReferenceLibrary +GENERAL = SYSDYN.SymbolReferences.CommentSymbols : DIA.SymbolReferenceLibrary L0.HasDescription "General graphical components" SYSDYN.AdditionalSymbols : L0.Library @@ -12,3 +14,21 @@ SYSDYN.AdditionalSymbols.MultilineText """ : L0.String + +SYSDYN.Loop -- SYSDYN.Loop.Clockwise --> L0.Boolean -- SYSDYN.Loop.Comment --> L0.String -- SYSDYN.Loop.Items --> L0.List -- SYSDYN.ConfigurationDiagram.selection --> DIA.Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java index f0b55a2f..b51c3e17 100644 --- a/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java @@ -457,6 +457,14 @@ public class SysdynResource { public final Resource LookupExpression; public final Resource LookupExpression_lookup; public final Resource LookupExpression_lookup_Inverse; + public final Resource Loop; + public final Resource LoopSymbol; + public final Resource Loop_Clockwise; + public final Resource Loop_Clockwise_Inverse; + public final Resource Loop_Comment; + public final Resource Loop_Comment_Inverse; + public final Resource Loop_Items; + public final Resource Loop_Items_Inverse; public final Resource Migration; public final Resource Migration_from1$6to1$7; public final Resource Migration_from1$6to1$7_Ontologies; @@ -598,7 +606,7 @@ public class SysdynResource { public final Resource StockSymbol; public final Resource SymbolReferences; public final Resource SymbolReferences_BasicSymbols; - public final Resource SymbolReferences_GeneralSymbols; + public final Resource SymbolReferences_CommentSymbols; public final Resource Symbols; public final Resource SysdynConnectionType; public final Resource SysdynDiagramModelingRules; @@ -1203,6 +1211,14 @@ public class SysdynResource { public static final String LookupExpression = "http://www.simantics.org/Sysdyn-1.1/LookupExpression"; public static final String LookupExpression_lookup = "http://www.simantics.org/Sysdyn-1.1/LookupExpression/lookup"; public static final String LookupExpression_lookup_Inverse = "http://www.simantics.org/Sysdyn-1.1/LookupExpression/lookup/Inverse"; + public static final String Loop = "http://www.simantics.org/Sysdyn-1.1/Loop"; + public static final String LoopSymbol = "http://www.simantics.org/Sysdyn-1.1/LoopSymbol"; + public static final String Loop_Clockwise = "http://www.simantics.org/Sysdyn-1.1/Loop/Clockwise"; + public static final String Loop_Clockwise_Inverse = "http://www.simantics.org/Sysdyn-1.1/Loop/Clockwise/Inverse"; + public static final String Loop_Comment = "http://www.simantics.org/Sysdyn-1.1/Loop/Comment"; + public static final String Loop_Comment_Inverse = "http://www.simantics.org/Sysdyn-1.1/Loop/Comment/Inverse"; + public static final String Loop_Items = "http://www.simantics.org/Sysdyn-1.1/Loop/Items"; + public static final String Loop_Items_Inverse = "http://www.simantics.org/Sysdyn-1.1/Loop/Items/Inverse"; public static final String Migration = "http://www.simantics.org/Sysdyn-1.1/Migration"; public static final String Migration_from1$6to1$7 = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7"; public static final String Migration_from1$6to1$7_Ontologies = "http://www.simantics.org/Sysdyn-1.1/Migration/from1.6to1.7/Ontologies"; @@ -1344,7 +1360,7 @@ public class SysdynResource { public static final String StockSymbol = "http://www.simantics.org/Sysdyn-1.1/StockSymbol"; public static final String SymbolReferences = "http://www.simantics.org/Sysdyn-1.1/SymbolReferences"; public static final String SymbolReferences_BasicSymbols = "http://www.simantics.org/Sysdyn-1.1/SymbolReferences/BasicSymbols"; - public static final String SymbolReferences_GeneralSymbols = "http://www.simantics.org/Sysdyn-1.1/SymbolReferences/GeneralSymbols"; + public static final String SymbolReferences_CommentSymbols = "http://www.simantics.org/Sysdyn-1.1/SymbolReferences/CommentSymbols"; public static final String Symbols = "http://www.simantics.org/Sysdyn-1.1/Symbols"; public static final String SysdynConnectionType = "http://www.simantics.org/Sysdyn-1.1/SysdynConnectionType"; public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.1/SysdynDiagramModelingRules"; @@ -1959,6 +1975,14 @@ public class SysdynResource { LookupExpression = getResourceOrNull(graph, URIs.LookupExpression); LookupExpression_lookup = getResourceOrNull(graph, URIs.LookupExpression_lookup); LookupExpression_lookup_Inverse = getResourceOrNull(graph, URIs.LookupExpression_lookup_Inverse); + Loop = getResourceOrNull(graph, URIs.Loop); + LoopSymbol = getResourceOrNull(graph, URIs.LoopSymbol); + Loop_Clockwise = getResourceOrNull(graph, URIs.Loop_Clockwise); + Loop_Clockwise_Inverse = getResourceOrNull(graph, URIs.Loop_Clockwise_Inverse); + Loop_Comment = getResourceOrNull(graph, URIs.Loop_Comment); + Loop_Comment_Inverse = getResourceOrNull(graph, URIs.Loop_Comment_Inverse); + Loop_Items = getResourceOrNull(graph, URIs.Loop_Items); + Loop_Items_Inverse = getResourceOrNull(graph, URIs.Loop_Items_Inverse); Migration = getResourceOrNull(graph, URIs.Migration); Migration_from1$6to1$7 = getResourceOrNull(graph, URIs.Migration_from1$6to1$7); Migration_from1$6to1$7_Ontologies = getResourceOrNull(graph, URIs.Migration_from1$6to1$7_Ontologies); @@ -2100,7 +2124,7 @@ public class SysdynResource { StockSymbol = getResourceOrNull(graph, URIs.StockSymbol); SymbolReferences = getResourceOrNull(graph, URIs.SymbolReferences); SymbolReferences_BasicSymbols = getResourceOrNull(graph, URIs.SymbolReferences_BasicSymbols); - SymbolReferences_GeneralSymbols = getResourceOrNull(graph, URIs.SymbolReferences_GeneralSymbols); + SymbolReferences_CommentSymbols = getResourceOrNull(graph, URIs.SymbolReferences_CommentSymbols); Symbols = getResourceOrNull(graph, URIs.Symbols); SysdynConnectionType = getResourceOrNull(graph, URIs.SysdynConnectionType); SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules); diff --git a/org.simantics.sysdyn.ui/adapters.xml b/org.simantics.sysdyn.ui/adapters.xml index f89f2e41..517bc7e2 100644 --- a/org.simantics.sysdyn.ui/adapters.xml +++ b/org.simantics.sysdyn.ui/adapters.xml @@ -10,5 +10,5 @@ VTT Technical Research Centre of Finland - initial API and implementation --> - none 0 fill 1 + none 0 fill 1 \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/CreateVariablesShortcutParticipant.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/CreateVariablesShortcutParticipant.java index a5a2e5a3..4919ec2b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/CreateVariablesShortcutParticipant.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/CreateVariablesShortcutParticipant.java @@ -163,6 +163,12 @@ public class CreateVariablesShortcutParticipant extends AbstractDiagramParticipa SysdynResource.URIs.ShadowSymbol, (ShapeNode)ShadowFactory.GHOST_IMAGE.init(parent) ); + /*} else if (kpe.keyCode == java.awt.event.KeyEvent.VK_L) { + variableInformation = new VariableInformation( + java.awt.event.KeyEvent.VK_L, + SysdynResource.URIs.LoopSymbol, + (ShapeNode)LoopFactory.LOOP_STATIC_IMAGE.init(parent) + );*/ } if (variableInformation != null) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopFactory.java new file mode 100644 index 00000000..f606fc72 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopFactory.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2010 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.sysdyn.ui.elements; + +import java.awt.BasicStroke; +import java.awt.Shape; +import java.awt.geom.Arc2D; +import java.awt.geom.Path2D; +import java.util.Collection; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.stubs.G2DResource; +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.handler.impl.BoundsOutline; +import org.simantics.g2d.element.handler.impl.DefaultTransform; +import org.simantics.g2d.element.handler.impl.ObjectTerminal; +import org.simantics.g2d.element.handler.impl.OutlinePick; +import org.simantics.g2d.element.handler.impl.SimpleElementLayers; +import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; +import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer; +import org.simantics.g2d.element.handler.impl.StaticSymbolImpl; +import org.simantics.g2d.element.handler.impl.TextColorImpl; +import org.simantics.g2d.element.handler.impl.TextFontImpl; +import org.simantics.g2d.element.handler.impl.TextImpl; +import org.simantics.g2d.elementclass.ImageClass.StaticImageElementHandler; +import org.simantics.g2d.image.DefaultImages; +import org.simantics.g2d.image.Image; +import org.simantics.g2d.image.impl.ShapeImage; +import org.simantics.g2d.svg.SVGImage; + +/** + * @author Tuomas Miettinen + */ +public class LoopFactory extends SysdynElementFactory { + + public static final Image LOOP_STATIC_IMAGE = new ShapeImage(getLoopShape(), null, new BasicStroke(1), true); + + @Override + public ElementClass create(ReadGraph graph, ICanvasContext canvas, + IDiagram diagram, Resource elementType) throws DatabaseException { + + G2DResource g2d = G2DResource.getInstance(graph); + String svgDoc = graph.getPossibleRelatedValue(elementType, g2d.HasSVGDocument); + Image image = null; + String id = "TextElement: " + NameUtils.getSafeName(graph, elementType); + if (svgDoc != null) + image = new SVGImage(id+".svg", svgDoc); + else + image = DefaultImages.ERROR_DECORATOR.get(); + + return ElementClass.compile( + SimpleElementLayers.INSTANCE, + OutlinePick.INSTANCE, + TextImpl.INSTANCE, + TextColorImpl.BLACK, + TextFontImpl.DEFAULT, + DefaultTransform.INSTANCE, + new StaticSymbolImpl(image), + new StaticImageElementHandler(image), + new StaticObjectAdapter(elementType), + StaticSymbolImageInitializer.INSTANCE, + //new HoverTextElementHandler(0, 0, Alignment.LEADING, 0, 1.5, 1.5, true), + BoundsOutline.INSTANCE + ).setId(LoopFactory.class.getSimpleName()); + } + + static Shape getLoopShape() { + Path2D loop = new Path2D.Double(); + loop.moveTo(1, 2); + loop.lineTo(0, 0); + loop.lineTo(-1, 2); + loop.closePath(); + + loop.append(new Arc2D.Double(-10, -3, 10, 10, 0, -270, Arc2D.OPEN), false); + return loop; + } + + @Override + protected ElementClass compileElementClass(Resource elementType, + Collection terminals) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java new file mode 100644 index 00000000..272e98d0 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java @@ -0,0 +1,220 @@ +/******************************************************************************* + * Copyright (c) 2010, 2012 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.sysdyn.ui.properties; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.swt.widgets.Button; +import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier; +import org.simantics.browsing.ui.swt.widgets.TrackedText; +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; +import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl; +import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.util.ObjectUtils; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.management.ISessionContext; +import org.simantics.sysdyn.SysdynResource; +import org.simantics.utils.datastructures.Pair; +import org.simantics.utils.datastructures.Triple; + +/** + * Tab for displaying information of a loop + * @author Tuomas Miettinen + * + */ +public class LoopTab extends LabelPropertyTabContributor { + + Button auto, balancing, reinforcing, other, inside, outside; + TrackedText loopComment, polarityLocationText; + public static final String AUTO = "$$AUTO$$"; + + @Override + public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { + Composite composite = new Composite(body, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite); + + Group commentGroup = new Group(composite, SWT.NONE); + commentGroup.setText("Comment"); + GridDataFactory.fillDefaults().grab(true, false).applyTo(commentGroup); + GridLayoutFactory.fillDefaults().numColumns(5).applyTo(commentGroup); + + auto = new Button(commentGroup, support, SWT.RADIO); + auto.setText("Auto"); + auto.setSelectionFactory(new CommentRadioSelectionFactory("$$AUTO$$")); + auto.addSelectionListener(new CommentSelectionListener(context, "$$AUTO$$")); + + balancing = new Button(commentGroup, support, SWT.RADIO); + balancing.setText("B"); + balancing.setSelectionFactory(new CommentRadioSelectionFactory("B")); + balancing.addSelectionListener(new CommentSelectionListener(context, "B")); + + reinforcing = new Button(commentGroup, support, SWT.RADIO); + reinforcing.setText("R"); + reinforcing.setSelectionFactory(new CommentRadioSelectionFactory("R")); + reinforcing.addSelectionListener(new CommentSelectionListener(context, "R")); + + other = new Button(commentGroup, support, SWT.RADIO); + other.setText("other"); + other.setSelectionFactory(new OtherCommentSelectionFactory(new String[] {null, "B", "R", AUTO})); + + loopComment = new TrackedText(commentGroup, support, SWT.BORDER); + loopComment.setTextFactory(new OtherCommentStringPropertyFactory()); + loopComment.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.Loop_Comment)); + GridDataFactory.fillDefaults().grab(true, false).applyTo(loopComment.getWidget()); + + Group rotationGroup = new Group(composite, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(rotationGroup); + GridLayoutFactory.fillDefaults().applyTo(rotationGroup); + rotationGroup.setText("Direction of Rotation"); + + inside = new Button(rotationGroup, support, SWT.RADIO); + inside.setText("Clockwise"); + inside.setSelectionFactory(new ClockwiseRotationRadioSelectionFactory(true)); + inside.addSelectionListener(new ClockwiseRotationSelectionListener(context, true)); + + outside = new Button(rotationGroup, support, SWT.RADIO); + outside.setText("Counterclockwise"); + outside.setSelectionFactory(new ClockwiseRotationRadioSelectionFactory(false)); + outside.addSelectionListener(new ClockwiseRotationSelectionListener(context, false)); + } + + class OtherCommentStringPropertyFactory extends ReadFactoryImpl { + + private final String propertyURI; + + public OtherCommentStringPropertyFactory() { + this.propertyURI = SysdynResource.URIs.Loop_Comment; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Triple((Resource)inputContents, propertyURI, getClass()); + } + + @Override + public String perform(ReadGraph graph, Resource resource) throws DatabaseException { + String value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI));; + if (value == null || AUTO.equals(value)) + return ""; + return value; + } + } + + class ClockwiseRotationSelectionListener extends SelectionListenerImpl { + private boolean clockwise; + + public ClockwiseRotationSelectionListener(ISessionContext context, boolean clockwise) { + super(context); + this.clockwise = clockwise; + } + + @Override + public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + graph.claimLiteral(connectionElement, sr.Loop_Clockwise, clockwise); + } + + } + + class ClockwiseRotationRadioSelectionFactory extends ReadFactoryImpl { + private boolean clockwise; + + public ClockwiseRotationRadioSelectionFactory(boolean clockwise) { + this.clockwise = clockwise; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Triple>(inputContents, clockwise, getClass()); + } + + @Override + public Boolean perform(ReadGraph graph, Resource dependencyConnection) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Boolean clockwise = graph.getPossibleRelatedValue(dependencyConnection, sr.Loop_Clockwise, Bindings.BOOLEAN); + return ObjectUtils.objectEquals(this.clockwise, clockwise); + } + } + + class CommentSelectionListener extends SelectionListenerImpl { + private String comment; + + public CommentSelectionListener(ISessionContext context, String comment) { + super(context); + this.comment = comment; + } + + @Override + public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + graph.claimLiteral(connectionElement, sr.Loop_Comment, comment.trim()); + } + + } + + class CommentRadioSelectionFactory extends ReadFactoryImpl { + private String comment; + + public CommentRadioSelectionFactory(String comment) { + this.comment = comment; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Triple>(inputContents, comment, getClass()); + } + + @Override + public Boolean perform(ReadGraph graph, Resource dependencyConnection) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + String comment = graph.getPossibleRelatedValue(dependencyConnection, sr.Loop_Comment, Bindings.STRING); + if(comment == null && this.comment.equals("")) + return true; + return ObjectUtils.objectEquals(comment, this.comment); + } + } + + class OtherCommentSelectionFactory extends ReadFactoryImpl { + + String[] limits; + + public OtherCommentSelectionFactory(String[] limits) { + this.limits = limits; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Pair>(inputContents, getClass()); + } + + @Override + public Boolean perform(ReadGraph graph, Resource dependencyConnection) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + String comment = graph.getPossibleRelatedValue(dependencyConnection, sr.Loop_Comment, Bindings.STRING); + for(String s : limits) { + if(ObjectUtils.objectEquals(comment, s)) + return false; + } + return true; + } + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index 20adbc43..168fdf9b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -208,6 +208,16 @@ public class ResourceSelectionProcessor implements SelectionProcessor items = new ArrayList(); + + @Override + public void accept(IElementVisitorVoid v) { + v.visit(this); + } + + /** + * + * @return The name of this loop + */ + public String getName() { + return this.name; + } + + /** + * + * @return The comment of this loop + */ + public String getComment() { + return this.comment; + } + + /** + * + * @return The variables and dependencies of this loop + */ + public ArrayList getItems() { + return this.items; + } + + /** + * + * @return true iff loop rotates clockwise. + */ + public boolean isClockwise() { + return this.clockwise; + } + + /** + * + * @return Parent configuration of this loop (or null if something is wrong) + */ + public Configuration getParentConfiguration() { + if(parent instanceof Configuration) { + return (Configuration)parent; + } else { + return null; + } + } + +} diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java index 4d47a8c5..1cd9a727 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java @@ -58,6 +58,7 @@ public class SysdynSchema extends SimpleSchema { addLinkType(MappingSchemas.fromAnnotations(g, Entity.class)); addLinkType(MappingSchemas.fromAnnotations(g, ParameterOverride.class)); addLinkType(MappingSchemas.fromAnnotations(g, Shadow.class)); + addLinkType(MappingSchemas.fromAnnotations(g, Loop.class)); } catch (DatabaseException e) { e.printStackTrace(); } catch (InstantiationException e) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java index b48955c4..6b5465a9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java @@ -21,6 +21,7 @@ import org.simantics.sysdyn.representation.Enumeration; import org.simantics.sysdyn.representation.Flow; import org.simantics.sysdyn.representation.Input; import org.simantics.sysdyn.representation.LibraryDummy; +import org.simantics.sysdyn.representation.Loop; import org.simantics.sysdyn.representation.Module; import org.simantics.sysdyn.representation.Stock; import org.simantics.sysdyn.representation.Valve; @@ -83,4 +84,8 @@ public class ElementVisitorVoidAdapter implements IElementVisitorVoid { @Override public void visit(Variable variable) { } + + @Override + public void visit(Loop loop) { + } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java index a15028dc..3b282583 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java @@ -21,6 +21,7 @@ import org.simantics.sysdyn.representation.Enumeration; import org.simantics.sysdyn.representation.Flow; import org.simantics.sysdyn.representation.Input; import org.simantics.sysdyn.representation.LibraryDummy; +import org.simantics.sysdyn.representation.Loop; import org.simantics.sysdyn.representation.Module; import org.simantics.sysdyn.representation.Stock; import org.simantics.sysdyn.representation.Valve; @@ -42,4 +43,6 @@ public interface IElementVisitorVoid { void visit(Book sheet); void visit(DiagramContainerDummy container); void visit(Variable variable); + void visit(Loop loop); + }