Search in sources :

Example 16 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class MathModelWindowManager method actionPerformed.

/**
 * Invoked when an action occurs.
 */
public void actionPerformed(java.awt.event.ActionEvent e) {
    String actionCommand = e.getActionCommand();
    final Object source = e.getSource();
    if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_GEOMETRY) || actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY)) {
        AsynchClientTask geomRegionsTask = new AsynchClientTask("Update Geometric regions", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                Geometry newGeom = (Geometry) hashTable.get("doc");
                ClientRequestManager.continueAfterMathModelGeomChangeWarning(MathModelWindowManager.this, newGeom);
                newGeom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
            }
        };
        AsynchClientTask applyGeomTask = new AsynchClientTask("Apply Geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                Geometry newGeom = (Geometry) hashTable.get("doc");
                if (newGeom.getName() == null) {
                    newGeom.setName(getMathModel().getName() + "_" + BeanUtils.generateDateTimeString());
                }
                ((MathModel) getVCDocument()).getMathDescription().setGeometry(newGeom);
            }
        };
        createGeometry(getMathModel().getMathDescription().getGeometry(), new AsynchClientTask[] { /*editSelectTask,*/
        geomRegionsTask, applyGeomTask }, TopLevelWindowManager.DEFAULT_CREATEGEOM_SELECT_DIALOG_TITLE, TopLevelWindowManager.APPLY_GEOMETRY_BUTTON_TEXT, (actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY) ? new DocumentWindowManager.GeometrySelectionInfo() : null));
    }
    if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CHANGE_GEOMETRY)) {
        getRequestManager().changeGeometry(this, null);
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) GeometryViewer(cbit.vcell.geometry.gui.GeometryViewer) Hashtable(java.util.Hashtable)

Example 17 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class SolverTaskDescriptionAdvancedPanel method validateChomboExtentAR.

private void validateChomboExtentAR(SolverDescription solverDescription) throws ChomboInvalidGeometryException {
    if (solverDescription != null && solverDescription.isChomboSolver()) {
        Simulation sim = fieldSolverTaskDescription.getSimulation();
        Geometry geometry = sim.getMathDescription().getGeometry();
        ChomboMeshValidator meshValidator = fieldSolverTaskDescription.getChomboSolverSpec() == null ? new ChomboMeshValidator(geometry.getDimension(), geometry.getExtent(), ChomboSolverSpec.DEFAULT_BLOCK_FACTOR) : new ChomboMeshValidator(geometry, fieldSolverTaskDescription.getChomboSolverSpec());
        ChomboMeshRecommendation chomboMeshRecommendation = meshValidator.computeMeshSpecs();
        if (!chomboMeshRecommendation.validate()) {
            String option = DialogUtils.showWarningDialog(this, "Warning", chomboMeshRecommendation.getErrorMessage(), chomboMeshRecommendation.getDialogOptions(), ChomboMeshRecommendation.optionClose);
            if (ChomboMeshRecommendation.optionSuggestions.equals(option)) {
                DialogUtils.showInfoDialog(this, ChomboMeshRecommendation.optionSuggestions, chomboMeshRecommendation.getMeshSuggestions());
            }
            throw new ChomboInvalidGeometryException(chomboMeshRecommendation);
        }
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) ChomboMeshRecommendation(org.vcell.chombo.ChomboMeshValidator.ChomboMeshRecommendation) ChomboMeshValidator(org.vcell.chombo.ChomboMeshValidator) Simulation(cbit.vcell.solver.Simulation) ChomboInvalidGeometryException(cbit.vcell.geometry.ChomboInvalidGeometryException)

Example 18 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class IssueTableModel method getSourceObjectPathDescription.

private String getSourceObjectPathDescription(VCDocument vcDocument, Issue issue) {
    VCAssert.assertValid(issue);
    Object source = issue.getSource();
    {
        IssueOrigin io = BeanUtils.downcast(IssueOrigin.class, source);
        if (io != null) {
            return io.getDescription();
        }
    }
    if (vcDocument instanceof BioModel) {
        BioModel bioModel = (BioModel) vcDocument;
        String description = "";
        if (source instanceof SymbolTableEntry) {
            if (source instanceof SpeciesContext) {
                description = "Model / Species";
            } else if (source instanceof RbmObservable) {
                description = "Model / Observables";
            } else {
                description = ((SymbolTableEntry) source).getNameScope().getPathDescription();
            }
        } else if (source instanceof MolecularType) {
            description = "Model / Molecules";
        } else if (source instanceof ReactionStep) {
            ReactionStep reactionStep = (ReactionStep) source;
            description = ((ReactionNameScope) reactionStep.getNameScope()).getPathDescription();
        } else if (source instanceof ReactionRule) {
            ReactionRule reactionRule = (ReactionRule) source;
            description = ((ReactionRuleNameScope) reactionRule.getNameScope()).getPathDescription();
        } else if (source instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // description = "Model / Species";
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // description = ((ReactionRuleNameScope)thing.getNameScope()).getPathDescription();
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // description = "Model / Observables";
            // } else {
            System.err.println("Bad issue context for " + ((SpeciesPattern) source).toString());
            description = ((SpeciesPattern) source).toString();
        // }
        } else if (source instanceof Structure) {
            Structure structure = (Structure) source;
            description = "Model / " + structure.getTypeName() + "(" + structure.getName() + ")";
        } else if (source instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) source;
            description = ((StructureMappingNameScope) structureMapping.getNameScope()).getPathDescription();
        } else if (source instanceof OutputFunctionIssueSource) {
            SimulationContext simulationContext = (SimulationContext) ((OutputFunctionIssueSource) source).getOutputFunctionContext().getSimulationOwner();
            description = "App(" + simulationContext.getName() + ") / " + "Simulations" + " / " + "Output Functions";
        } else if (source instanceof Simulation) {
            Simulation simulation = (Simulation) source;
            try {
                SimulationContext simulationContext = bioModel.getSimulationContext(simulation);
                description = "App(" + simulationContext.getName() + ") / Simulations";
            } catch (ObjectNotFoundException e) {
                e.printStackTrace();
                description = "App(" + "unknown" + ") / Simulations";
            }
        } else if (source instanceof UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGC = (UnmappedGeometryClass) source;
            description = "App(" + unmappedGC.getSimulationContext().getName() + ") / Subdomain(" + unmappedGC.getGeometryClass().getName() + ")";
        } else if (source instanceof GeometryContext) {
            description = "App(" + ((GeometryContext) source).getSimulationContext().getName() + ")";
        } else if (source instanceof ModelOptimizationSpec) {
            description = "App(" + ((ModelOptimizationSpec) source).getSimulationContext().getName() + ") / Parameter Estimation";
        } else if (source instanceof MicroscopeMeasurement) {
            description = "App(" + ((MicroscopeMeasurement) source).getSimulationContext().getName() + ") / Microscope Measurements";
        } else if (source instanceof SpatialObject) {
            description = "App(" + ((SpatialObject) source).getSimulationContext().getName() + ") / Spatial Objects";
        } else if (source instanceof SpatialProcess) {
            description = "App(" + ((SpatialProcess) source).getSimulationContext().getName() + ") / Spatial Processes";
        } else if (source instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) source;
            description = "App(" + scs.getSimulationContext().getName() + ") / Specifications / Species";
        } else if (source instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) source;
            description = "App(" + rc.getReactionContext().getSimulationContext().getName() + ") / Specifications / Reactions";
        } else if (source instanceof RbmModelContainer) {
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmMolecularTypesTableBad:
                    description = "Model / " + MolecularType.typeName + "s";
                    break;
                case RbmReactionRulesTableBad:
                    description = "Model / Reactions";
                    break;
                case RbmObservablesTableBad:
                    description = "Model / Observables";
                    break;
                case RbmNetworkConstraintsBad:
                    description = "Network Constrains";
                    break;
                default:
                    description = "Model";
                    break;
            }
        } else if (source instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) source;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    description = "Specifications / Network";
                    break;
                default:
                    description = "Application";
                    break;
            }
        } else if (source instanceof Model) {
            description = "Model";
        } else if (source instanceof BioEvent) {
            return "Protocols / Events";
        } else if (source instanceof MathDescription) {
            return "Math Description";
        } else {
            System.err.println("unknown source type in IssueTableModel.getSourceObjectPathDescription(): " + source.getClass());
        }
        return description;
    } else if (vcDocument instanceof MathModel) {
        if (source instanceof Geometry) {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_GEOMETRY;
        } else if (source instanceof OutputFunctionIssueSource) {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_OUTPUTFUNCTIONS;
        } else if (source instanceof Simulation) {
            return "Simulation(" + ((Simulation) source).getName() + ")";
        } else {
            return GuiConstants.DOCUMENT_EDITOR_FOLDERNAME_MATH_VCML;
        }
    } else {
        System.err.println("unknown document type in IssueTableModel.getSourceObjectPathDescription()");
        return "";
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) IssueOrigin(org.vcell.util.Issue.IssueOrigin) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) ModelOptimizationSpec(cbit.vcell.modelopt.ModelOptimizationSpec) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) ReactionRuleNameScope(cbit.vcell.model.ReactionRule.ReactionRuleNameScope) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ReactionStep(cbit.vcell.model.ReactionStep) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) MathModel(cbit.vcell.mathmodel.MathModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent)

Example 19 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class IssueTableModel method getSourceObjectDescription.

private String getSourceObjectDescription(VCDocument vcDocument, Issue issue) {
    if (vcDocument instanceof BioModel) {
        Object object = issue.getSource();
        {
            DecoratedIssueSource dis = BeanUtils.downcast(DecoratedIssueSource.class, object);
            if (dis != null) {
                return dis.getSourcePath();
            }
        }
        String description = "";
        if (object instanceof SymbolTableEntry) {
            description = ((SymbolTableEntry) object).getName();
        } else if (object instanceof ReactionStep) {
            description = ((ReactionStep) object).getName();
        } else if (object instanceof ReactionRule) {
            description = ((ReactionRule) object).getName();
        } else if (object instanceof SpeciesPattern) {
            // Object parent = issue.getIssueContext().getContextObject();
            // if (parent instanceof SpeciesContext){
            // description = ((SpeciesContext)parent).getName();
            // }
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // description = thing.getName();
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // description = thing.getName();
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // description = thing.getName();
            // } else {
            System.err.println("Bad issue context for " + ((SpeciesPattern) object).toString());
            description = ((SpeciesPattern) object).toString();
        // }
        } else if (object instanceof MolecularType) {
            description = ((MolecularType) object).getName();
        } else if (object instanceof MolecularComponent) {
            description = ((MolecularComponent) object).getName();
        } else if (object instanceof ComponentStateDefinition) {
            description = ((ComponentStateDefinition) object).getName();
        } else if (object instanceof Structure) {
            description = ((Structure) object).getName();
        } else if (object instanceof SubDomain) {
            description = ((SubDomain) object).getName();
        } else if (object instanceof Geometry) {
            description = ((Geometry) object).getName();
        } else if (object instanceof StructureMapping) {
            description = ((StructureMapping) object).getStructure().getName();
        } else if (object instanceof OutputFunctionIssueSource) {
            description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
        } else if (object instanceof UnmappedGeometryClass) {
            description = ((UnmappedGeometryClass) object).getGeometryClass().getName();
        } else if (object instanceof MicroscopeMeasurement) {
            description = ((MicroscopeMeasurement) object).getName();
        } else if (object instanceof SpatialObject) {
            description = ((SpatialObject) object).getName();
        } else if (object instanceof SpatialProcess) {
            description = ((SpatialProcess) object).getName();
        } else if (object instanceof GeometryContext) {
            description = "Geometry";
        } else if (object instanceof ModelOptimizationSpec) {
            description = ((ModelOptimizationSpec) object).getParameterEstimationTask().getName();
        } else if (object instanceof Simulation) {
            description = ((Simulation) object).getName();
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            description = scs.getSpeciesContext().getName();
        } else if (object instanceof ReactionCombo) {
            ReactionSpec rs = ((ReactionCombo) object).getReactionSpec();
            description = rs.getReactionStep().getName();
        } else if (object instanceof RbmModelContainer) {
            // RbmModelContainer mc = (RbmModelContainer)object;
            description = "Rules validator";
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            description = sc.getName();
        } else if (object instanceof Model) {
            Model m = (Model) object;
            description = m.getName();
        } else if (object instanceof BioEvent) {
            return ((BioEvent) object).getName() + "";
        } else if (object instanceof MathDescription) {
            return ((MathDescription) object).getName() + "";
        } else {
            System.err.println("unknown object type in IssueTableModel.getSourceObjectDescription(): " + object.getClass());
        }
        return description;
    } else if (vcDocument instanceof MathModel) {
        Object object = issue.getSource();
        String description = "";
        if (object instanceof Variable) {
            description = ((Variable) object).getName();
        } else if (object instanceof SubDomain) {
            description = ((SubDomain) object).getName();
        } else if (object instanceof Geometry) {
            description = "Geometry";
        } else if (object instanceof OutputFunctionIssueSource) {
            description = ((OutputFunctionIssueSource) object).getAnnotatedFunction().getName();
        } else if (object instanceof MathDescription) {
            return "math";
        } else if (object instanceof Simulation) {
            return "Simulation " + ((Simulation) object).getName() + "";
        }
        return description;
    } else {
        System.err.println("unknown document type in IssueTableModel.getSourceObjectDescription()");
        return "";
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) Variable(cbit.vcell.math.Variable) MathDescription(cbit.vcell.math.MathDescription) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SubDomain(cbit.vcell.math.SubDomain) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) MolecularComponent(org.vcell.model.rbm.MolecularComponent) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) ModelOptimizationSpec(cbit.vcell.modelopt.ModelOptimizationSpec) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) ReactionSpec(cbit.vcell.mapping.ReactionSpec) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ReactionStep(cbit.vcell.model.ReactionStep) MathModel(cbit.vcell.mathmodel.MathModel) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent)

Example 20 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class ClientDocumentManager method getGeometry.

/**
 * Insert the method's description here.
 * Creation date: (11/14/00 4:02:44 PM)
 * @return cbit.vcell.biomodel.BioModel
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
public Geometry getGeometry(KeyValue geometryKey) throws DataAccessException {
    String geometryXML = getGeometryXML(geometryKey);
    Geometry geometry = getGeometryFromDatabaseXML(geometryXML);
    return geometry;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) BigString(org.vcell.util.BigString)

Aggregations

Geometry (cbit.vcell.geometry.Geometry)121 MathDescription (cbit.vcell.math.MathDescription)32 SimulationContext (cbit.vcell.mapping.SimulationContext)31 Simulation (cbit.vcell.solver.Simulation)29 PropertyVetoException (java.beans.PropertyVetoException)24 BioModel (cbit.vcell.biomodel.BioModel)23 DataAccessException (org.vcell.util.DataAccessException)23 VCImage (cbit.image.VCImage)22 SubVolume (cbit.vcell.geometry.SubVolume)21 MathModel (cbit.vcell.mathmodel.MathModel)21 Expression (cbit.vcell.parser.Expression)19 ISize (org.vcell.util.ISize)19 Hashtable (java.util.Hashtable)18 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)17 UserCancelException (org.vcell.util.UserCancelException)17 KeyValue (org.vcell.util.document.KeyValue)17 ImageException (cbit.image.ImageException)16 Extent (org.vcell.util.Extent)16 SurfaceClass (cbit.vcell.geometry.SurfaceClass)15 ExpressionException (cbit.vcell.parser.ExpressionException)15