X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FGUIWire.java;h=5a0579c3b0a728e0f8911271d60b616a89cc30d1;hb=a4d1573c2f2cf8236bcb56dc70bc8b8c60b6c225;hp=e92044444891da1aecbe1081c31b31ce30cef6e4;hpb=b37ba7609a925cc945bbac0f6ead619d07912238;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java index e9204444..5a0579c3 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java @@ -10,19 +10,19 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; +import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.core.types.BitVectorFormatter; +import net.mograsim.logic.core.wires.Wire; import net.mograsim.logic.core.wires.Wire.ReadEnd; import net.mograsim.logic.ui.ColorHelper; -import net.mograsim.logic.ui.model.ModelVisitor; import net.mograsim.logic.ui.model.ViewModelModifiable; -import net.mograsim.logic.ui.model.Visitable; /** * A wire connecting exactly two {@link Pin}s. * * @author Daniel Kirschten */ -public class GUIWire implements Visitable +public class GUIWire { /** * The model this wire is a part of. @@ -73,37 +73,7 @@ public class GUIWire implements Visitable * * @author Daniel Kirschten */ - public GUIWire(ViewModelModifiable model, WireCrossPoint pin1, WireCrossPoint pin2) - { - this(model, pin1, pin2, (Point[]) null); - } - - /** - * Creates a new {@link GUIWire} with automatic interpolation. - * - * @author Daniel Kirschten - */ - public GUIWire(ViewModelModifiable model, WireCrossPoint pin1, Pin pin2) - { - this(model, pin1, pin2, (Point[]) null); - } - - /** - * Creates a new {@link GUIWire} with automatic interpolation. - * - * @author Daniel Kirschten - */ - public GUIWire(ViewModelModifiable model, Pin pin1, WireCrossPoint pin2) - { - this(model, pin1, pin2, (Point[]) null); - } - - /** - * Creates a new {@link GUIWire} with automatic interpolation. - * - * @author Daniel Kirschten - */ - public GUIWire(ViewModelModifiable model, Pin pin1, Pin pin2) + public GUIWire(ViewModelModifiable model, ConnectionPoint pin1, ConnectionPoint pin2) { this(model, pin1, pin2, (Point[]) null); } @@ -113,7 +83,7 @@ public class GUIWire implements Visitable * * @author Daniel Kirschten */ - public GUIWire(ViewModelModifiable model, WireCrossPoint pin1, WireCrossPoint pin2, Point... path) + public GUIWire(ViewModelModifiable model, ConnectionPoint pin1, ConnectionPoint pin2, Point... path) { this(model, pin1.getPin(), pin2.getPin(), path); } @@ -123,27 +93,7 @@ public class GUIWire implements Visitable * * @author Daniel Kirschten */ - public GUIWire(ViewModelModifiable model, WireCrossPoint pin1, Pin pin2, Point... path) - { - this(model, pin1.getPin(), pin2, path); - } - - /** - * Creates a new {@link GUIWire} without automatic interpolation. - * - * @author Daniel Kirschten - */ - public GUIWire(ViewModelModifiable model, Pin pin1, WireCrossPoint pin2, Point... path) - { - this(model, pin1, pin2.getPin(), path); - } - - /** - * Creates a new {@link GUIWire} without automatic interpolation. - * - * @author Daniel Kirschten - */ - public GUIWire(ViewModelModifiable model, Pin pin1, Pin pin2, Point... path) + GUIWire(ViewModelModifiable model, Pin pin1, Pin pin2, Point... path) { logicObs = (i) -> callRedrawListeners(); this.model = model; @@ -310,6 +260,38 @@ public class GUIWire implements Visitable end.registerObserver(logicObs); } + /** + * Returns whether this {@link GUIWire} has a logic model binding or not. + * + * @author Daniel Kirschten + */ + public boolean hasLogicModelBinding() + { + return end != null; + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link Wire#forceValues(BitVector)} for the {@link Wire} + * corresponding to this {@link GUIWire}. + * + * @author Daniel Kirschten + */ + public void forceWireValues(BitVector values) + { + end.getWire().forceValues(values); + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link ReadEnd#getValues()} for the {@link ReadEnd} corresponding to + * this {@link GUIWire}. + * + * @author Daniel Kirschten + */ + public BitVector getWireValues() + { + return end.getValues(); + } + // listeners // @formatter:off @@ -325,10 +307,4 @@ public class GUIWire implements Visitable { return "GUIWire [" + pin1 + "---" + pin2 + ", value=" + (end == null ? "null" : end.getValues()) + "]"; } - - @Override - public void accept(ModelVisitor mv) - { - mv.visit(this); - } } \ No newline at end of file