X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fviews%2FLogicUIPart.java;h=212f777cdd4b30d833e2a64798d4d21f6ae3909e;hb=8bed58cd47f4e53a0a83e066d38864aa6875502f;hp=1ae8066e9d07878223d4d8e33200e3adf145f5c2;hpb=70f60681406dbd8c54d3b6e254a7d1f8bffd268d;p=Mograsim.git diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java index 1ae8066e..212f777c 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java @@ -9,17 +9,10 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; -import net.mograsim.logic.core.timeline.Timeline; -import net.mograsim.logic.ui.LogicExecuter; -import net.mograsim.logic.ui.LogicUICanvas; -import net.mograsim.logic.ui.model.ViewModelModifiable; -import net.mograsim.logic.ui.model.components.GUIBitDisplay; -import net.mograsim.logic.ui.model.components.GUIManualSwitch; -import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; -import net.mograsim.logic.ui.model.components.mi.nandbased.am2901.GUIAm2901; -import net.mograsim.logic.ui.model.wires.GUIWire; -import net.mograsim.logic.ui.modeladapter.LogicModelParameters; -import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter; +import net.mograsim.logic.model.LogicExecuter; +import net.mograsim.logic.model.LogicUICanvas; +import net.mograsim.machine.Machine; +import net.mograsim.plugin.MachineContext; import net.mograsim.plugin.ThemePreferences; import net.mograsim.preferences.Preferences; @@ -44,18 +37,10 @@ public class LogicUIPart extends ViewPart // set preferences Preferences.setPreferences(new ThemePreferences(PlatformUI.getWorkbench().getThemeManager().getCurrentTheme())); - // setup view model - ViewModelModifiable viewModel = new ViewModelModifiable(); - createTestbench(viewModel); - - // convert to logic model - LogicModelParameters params = new LogicModelParameters(); - params.gateProcessTime = 50; - params.wireTravelTime = 10; - Timeline timeline = ViewLogicModelAdapter.convert(viewModel, params); + Machine m = MachineContext.getInstance().getMachine(); // initialize UI - ui = new LogicUICanvas(parent, SWT.NONE, viewModel); + ui = new LogicUICanvas(parent, SWT.NONE, m.getModel()); ui.addTransformListener((x, y, z) -> part.setDirty(z < 1)); ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); userInput.buttonDrag = 3; @@ -63,7 +48,7 @@ public class LogicUIPart extends ViewPart userInput.enableUserInput(); // initialize executer - exec = new LogicExecuter(timeline); + exec = new LogicExecuter(m.getTimeline()); // run it exec.startLiveExecution(); @@ -74,24 +59,4 @@ public class LogicUIPart extends ViewPart { ui.setFocus(); } - - @SuppressWarnings("unused") // for GUIWires being created - public static void createTestbench(ViewModelModifiable model) - { - SimpleRectangularSubmodelComponent comp = new GUIAm2901(model); - - comp.moveTo(100, 0); - for (int i = 0; i < comp.getInputPinNames().size(); i++) - { - GUIManualSwitch sw = new GUIManualSwitch(model); - sw.moveTo(0, 20 * i); - new GUIWire(model, comp.getPin(comp.getInputPinNames().get(i)), sw.getOutputPin()); - } - for (int i = 0; i < comp.getOutputPinNames().size(); i++) - { - GUIBitDisplay bd = new GUIBitDisplay(model); - bd.moveTo(200, 20 * i); - new GUIWire(model, comp.getPin(comp.getOutputPinNames().get(i)), bd.getInputPin()); - } - } } \ No newline at end of file