Search in sources :

Example 16 with Project

use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.

the class Startup method doPrintFile.

private void doPrintFile(File file) {
    if (initialized) {
        Project toPrint = ProjectActions.doOpen(null, null, file);
        Print.doPrint(toPrint);
        toPrint.getFrame().dispose();
    } else {
        filesToPrint.add(file);
    }
}
Also used : Project(com.cburch.logisim.proj.Project)

Example 17 with Project

use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.

the class TtyInterface method run.

public static void run(Startup args) {
    File fileToOpen = args.getFilesToOpen().get(0);
    Loader loader = new Loader(null);
    LogisimFile file;
    try {
        file = loader.openLogisimFile(fileToOpen, args.getSubstitutions());
    } catch (LoadFailedException e) {
        logger.error("{}", Strings.get("ttyLoadError", fileToOpen.getName()));
        System.exit(-1);
        return;
    }
    int format = args.getTtyFormat();
    if ((format & FORMAT_STATISTICS) != 0) {
        format &= ~FORMAT_STATISTICS;
        displayStatistics(file);
    }
    if (format == 0) {
        // no simulation remaining to perform, so just exit
        System.exit(0);
    }
    Project proj = new Project(file);
    Circuit circuit = file.getMainCircuit();
    Map<Instance, String> pinNames = Analyze.getPinLabels(circuit);
    ArrayList<Instance> outputPins = new ArrayList<Instance>();
    Instance haltPin = null;
    for (Map.Entry<Instance, String> entry : pinNames.entrySet()) {
        Instance pin = entry.getKey();
        String pinName = entry.getValue();
        if (!Pin.FACTORY.isInputPin(pin)) {
            outputPins.add(pin);
            if (pinName.equals("halt")) {
                haltPin = pin;
            }
        }
    }
    CircuitState circState = new CircuitState(proj, circuit);
    // we have to do our initial propagation before the simulation starts -
    // it's necessary to populate the circuit with substates.
    circState.getPropagator().propagate();
    if (args.getLoadFile() != null) {
        try {
            boolean loaded = loadRam(circState, args.getLoadFile());
            if (!loaded) {
                logger.error("{}", Strings.get("loadNoRamError"));
                System.exit(-1);
            }
        } catch (IOException e) {
            logger.error("{}: {}", Strings.get("loadIoError"), e.toString());
            System.exit(-1);
        }
    }
    int ttyFormat = args.getTtyFormat();
    int simCode = runSimulation(circState, outputPins, haltPin, ttyFormat);
    System.exit(simCode);
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) Instance(com.cburch.logisim.instance.Instance) ArrayList(java.util.ArrayList) Loader(com.cburch.logisim.file.Loader) Circuit(com.cburch.logisim.circuit.Circuit) IOException(java.io.IOException) Project(com.cburch.logisim.proj.Project) LogisimFile(com.cburch.logisim.file.LogisimFile) LogisimFile(com.cburch.logisim.file.LogisimFile) File(java.io.File) Map(java.util.Map) LoadFailedException(com.cburch.logisim.file.LoadFailedException)

Example 18 with Project

use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.

the class WindowManagers method computeListeners.

private static void computeListeners() {
    List<Project> nowOpen = Projects.getOpenProjects();
    HashSet<Project> closed = new HashSet<Project>(projectMap.keySet());
    closed.removeAll(nowOpen);
    for (Project proj : closed) {
        ProjectManager manager = projectMap.get(proj);
        manager.frameClosed(manager.getJFrame(false));
        projectMap.remove(proj);
    }
    HashSet<Project> opened = new LinkedHashSet<Project>(nowOpen);
    opened.removeAll(projectMap.keySet());
    for (Project proj : opened) {
        ProjectManager manager = new ProjectManager(proj);
        projectMap.put(proj, manager);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Project(com.cburch.logisim.proj.Project) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 19 with Project

use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.

the class LoadedLibrary method replaceAll.

private static void replaceAll(Map<ComponentFactory, ComponentFactory> compMap, Map<Tool, Tool> toolMap) {
    for (Project proj : Projects.getOpenProjects()) {
        Tool oldTool = proj.getTool();
        Circuit oldCircuit = proj.getCurrentCircuit();
        if (toolMap.containsKey(oldTool)) {
            proj.setTool(toolMap.get(oldTool));
        }
        SubcircuitFactory oldFactory = oldCircuit.getSubcircuitFactory();
        if (compMap.containsKey(oldFactory)) {
            SubcircuitFactory newFactory;
            newFactory = (SubcircuitFactory) compMap.get(oldFactory);
            proj.setCurrentCircuit(newFactory.getSubcircuit());
        }
        replaceAll(proj.getLogisimFile(), compMap, toolMap);
    }
    for (LogisimFile file : LibraryManager.instance.getLogisimLibraries()) {
        replaceAll(file, compMap, toolMap);
    }
}
Also used : Project(com.cburch.logisim.proj.Project) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 20 with Project

use of com.cburch.logisim.proj.Project in project logisim-evolution by reds-heig.

the class LayoutEditHandler method computeEnabled.

@Override
public void computeEnabled() {
    Project proj = frame.getProject();
    Selection sel = proj == null ? null : proj.getSelection();
    boolean selEmpty = (sel == null ? true : sel.isEmpty());
    boolean canChange = proj != null && proj.getLogisimFile().contains(proj.getCurrentCircuit());
    boolean selectAvailable = false;
    for (Library lib : proj.getLogisimFile().getLibraries()) {
        if (lib instanceof Base)
            selectAvailable = true;
    }
    setEnabled(LogisimMenuBar.CUT, !selEmpty && selectAvailable && canChange);
    setEnabled(LogisimMenuBar.COPY, !selEmpty && selectAvailable);
    setEnabled(LogisimMenuBar.PASTE, selectAvailable && canChange && !Clipboard.isEmpty());
    setEnabled(LogisimMenuBar.DELETE, !selEmpty && selectAvailable && canChange);
    setEnabled(LogisimMenuBar.DUPLICATE, !selEmpty && selectAvailable && canChange);
    setEnabled(LogisimMenuBar.SELECT_ALL, selectAvailable);
    setEnabled(LogisimMenuBar.RAISE, false);
    setEnabled(LogisimMenuBar.LOWER, false);
    setEnabled(LogisimMenuBar.RAISE_TOP, false);
    setEnabled(LogisimMenuBar.LOWER_BOTTOM, false);
    setEnabled(LogisimMenuBar.ADD_CONTROL, false);
    setEnabled(LogisimMenuBar.REMOVE_CONTROL, false);
}
Also used : Project(com.cburch.logisim.proj.Project) Library(com.cburch.logisim.tools.Library) Base(com.cburch.logisim.std.base.Base)

Aggregations

Project (com.cburch.logisim.proj.Project)26 Circuit (com.cburch.logisim.circuit.Circuit)11 Component (com.cburch.logisim.comp.Component)7 Location (com.cburch.logisim.data.Location)5 Action (com.cburch.logisim.proj.Action)5 AttributeSet (com.cburch.logisim.data.AttributeSet)3 Bounds (com.cburch.logisim.data.Bounds)3 Selection (com.cburch.logisim.gui.main.Selection)3 Wire (com.cburch.logisim.circuit.Wire)2 ComponentUserEvent (com.cburch.logisim.comp.ComponentUserEvent)2 LoadFailedException (com.cburch.logisim.file.LoadFailedException)2 Loader (com.cburch.logisim.file.Loader)2 ToolAttributeAction (com.cburch.logisim.gui.main.ToolAttributeAction)2 MoveGesture (com.cburch.logisim.tools.move.MoveGesture)2 MoveResult (com.cburch.logisim.tools.move.MoveResult)2 File (java.io.File)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Selection (com.cburch.draw.canvas.Selection)1 CanvasObject (com.cburch.draw.model.CanvasObject)1