Search in sources :

Example 1 with SolverTaskDescriptionAdvancedPanel

use of cbit.vcell.solver.ode.gui.SolverTaskDescriptionAdvancedPanel in project vcell by virtualcell.

the class SimulationEditor method prepareToEdit.

/**
 * Comment
 * @param simulation not null
 * @param parent
 * @throws ChomboInvalidGeometryException
 * @throws NullPointerException
 */
public void prepareToEdit(Simulation simulation, Component parent) throws ChomboInvalidGeometryException {
    Objects.requireNonNull(simulation);
    try {
        Simulation clonedSimulation = (Simulation) BeanUtils.cloneSerializable(simulation);
        clonedSimulation.refreshDependencies();
        getMathOverridesPanel1().setMathOverrides(clonedSimulation == null ? null : clonedSimulation.getMathOverrides());
        getMeshTabPanel().setSimulation(parent, clonedSimulation);
        SolverTaskDescriptionAdvancedPanel stdap = getSolverTaskDescriptionAdvancedPanel1();
        {
            SimulationOwner so = simulation.getSimulationOwner();
            UnitInfo unitInfo = so.getUnitInfo();
            stdap.setUnitInfo(unitInfo);
        }
        stdap.setSolverTaskDescription(clonedSimulation == null ? null : clonedSimulation.getSolverTaskDescription());
        boolean shouldMeshBeEnabled = false;
        MeshSpecification meshSpec = clonedSimulation.getMeshSpecification();
        if (meshSpec != null && meshSpec.getGeometry() != null && meshSpec.getGeometry().getDimension() > 0) {
            shouldMeshBeEnabled = true;
        }
        if (!shouldMeshBeEnabled) {
            getJTabbedPane1().remove(getMeshTabPanel());
        }
        setClonedSimulation(clonedSimulation);
    } catch (ChomboInvalidGeometryException exc) {
        // if this happens, sim is not allowed to edit
        exc.printStackTrace(System.out);
        throw exc;
    } catch (Throwable exc) {
        exc.printStackTrace(System.out);
        JOptionPane.showMessageDialog(this, "Could not initialize simulation editor\n" + exc.getMessage(), "Error:", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : SimulationOwner(cbit.vcell.solver.SimulationOwner) UnitInfo(cbit.vcell.solver.SimulationOwner.UnitInfo) Simulation(cbit.vcell.solver.Simulation) SolverTaskDescriptionAdvancedPanel(cbit.vcell.solver.ode.gui.SolverTaskDescriptionAdvancedPanel) ChomboInvalidGeometryException(cbit.vcell.geometry.ChomboInvalidGeometryException) MeshSpecification(cbit.vcell.solver.MeshSpecification)

Aggregations

ChomboInvalidGeometryException (cbit.vcell.geometry.ChomboInvalidGeometryException)1 MeshSpecification (cbit.vcell.solver.MeshSpecification)1 Simulation (cbit.vcell.solver.Simulation)1 SimulationOwner (cbit.vcell.solver.SimulationOwner)1 UnitInfo (cbit.vcell.solver.SimulationOwner.UnitInfo)1 SolverTaskDescriptionAdvancedPanel (cbit.vcell.solver.ode.gui.SolverTaskDescriptionAdvancedPanel)1