Search in sources :

Example 1 with StructureMetricsEntry

use of cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry in project vcell by virtualcell.

the class ImagePlaneManagerPanel method updateInfo.

private void updateInfo(MouseEvent mouseEvent) {
    if (mouseEvent == null) {
        return;
    }
    String infoS = null;
    // }else
    if (mouseEvent.getID() != java.awt.event.MouseEvent.MOUSE_EXITED) {
        Coordinate wc = null;
        boolean bNeedsMembraneCursor = false;
        if (getCurveEditorTool().getTool() == CurveEditorTool.TOOL_ZOOM || getCurveEditorTool().getTool() == CurveEditorTool.TOOL_PAN) {
            infoS = getCurveEditorTool().getToolDescription(getCurveEditorTool().getTool());
            setToolCursor();
        } else if (mouseEvent.getID() != java.awt.event.MouseEvent.MOUSE_ENTERED) {
            lastValidMouseEvent = mouseEvent;
            if (getimagePaneView1().isPointOnImage(mouseEvent.getPoint())) {
                java.awt.geom.Point2D unitP = getimagePaneView1().getImagePointUnitized(mouseEvent.getPoint());
                wc = getImagePlaneManager().getWorldCoordinateFromUnitized2D(unitP.getX(), unitP.getY());
                if (wc != null) {
                    if (getCurveValueProvider() != null) {
                        if (getSourceDataInfo() != null && getSourceDataInfo().isChombo()) {
                            // for chombo, can't use closest curve method, one irregular point has one curve, it can be very far
                            CoordinateIndex ci = getImagePlaneManager().getDataIndexFromUnitized2D(unitP.getX(), unitP.getY());
                            CurveSelectionInfo csiSegment = getCurveValueProvider().findChomboCurveSelectionInfoForPoint(ci);
                            if (csiSegment != null) {
                                String infoTemp = getCurveValueProvider().getCurveValue(csiSegment);
                                if (infoTemp != null) {
                                    infoS = infoTemp;
                                    bNeedsMembraneCursor = true;
                                }
                            }
                        } else {
                            CurveSelectionInfo[] curveCSIArr = getCurveRenderer().getCloseCurveSelectionInfos(wc);
                            if (curveCSIArr != null) {
                                for (int i = 0; i < curveCSIArr.length; i += 1) {
                                    CurveSelectionInfo csiSegment = getCurveRenderer().getClosestSegmentSelectionInfo(wc, curveCSIArr[i].getCurve());
                                    if (csiSegment != null) {
                                        String infoTemp = getCurveValueProvider().getCurveValue(csiSegment);
                                        if (infoTemp != null) {
                                            infoS = infoTemp;
                                            bNeedsMembraneCursor = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (infoS == null && getSourceDataInfo() != null) {
                        CoordinateIndex ci = getImagePlaneManager().getDataIndexFromUnitized2D(unitP.getX(), unitP.getY());
                        int volumeIndex = getSourceDataInfo().calculateWorldIndex(ci);
                        Coordinate quantizedWC = getSourceDataInfo().getWorldCoordinateFromIndex(ci);
                        boolean bUndefined = getSourceDataInfo().isDataNull() || (getDataInfoProvider() != null && !getDataInfoProvider().isDefined(volumeIndex));
                        String xCoordString = NumberUtils.formatNumber(quantizedWC.getX());
                        String yCoordString = NumberUtils.formatNumber(quantizedWC.getY());
                        String zCoordString = NumberUtils.formatNumber(quantizedWC.getZ());
                        infoS = "(" + xCoordString + (getSourceDataInfo().getYSize() > 1 ? "," + yCoordString : "") + (getSourceDataInfo().getZSize() > 1 ? "," + zCoordString : "") + ") " + "[" + volumeIndex + "]" + " [" + ci.x + (getSourceDataInfo().getYSize() > 1 ? "," + ci.y : "") + (getSourceDataInfo().getZSize() > 1 ? "," + ci.z : "") + "] " + (bUndefined ? "Undefined" : getSourceDataInfo().getDataValueAsString(ci.x, ci.y, ci.z));
                        if (getDataInfoProvider() != null) {
                            if (getDataInfoProvider().getPDEDataContext().getCartesianMesh().isChomboMesh()) {
                                if (!bUndefined) {
                                    StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
                                    if (structure != null) {
                                        infoS += " || " + structure.getDisplayLabel();
                                    }
                                }
                            } else if (getDataInfoProvider() != null) {
                                infoS += "          ";
                                try {
                                    VolumeDataInfo volumeDataInfo = getDataInfoProvider().getVolumeDataInfo(volumeIndex);
                                    if (volumeDataInfo.subvolumeID0 != null) {
                                        infoS += " \"" + volumeDataInfo.volumeNamePhysiology + "\"" + " (\"" + volumeDataInfo.volumeNameGeometry + "\")";
                                        infoS += " svID=" + volumeDataInfo.subvolumeID0;
                                        infoS += " vrID=" + volumeDataInfo.volumeRegionID;
                                    }
                                } catch (Exception e) {
                                    // This can happen with FieldData viewer
                                    e.printStackTrace();
                                }
                            }
                        }
                        String curveDescr = CurveRenderer.getROIDescriptions(wc, getCurveRenderer());
                        if (curveDescr != null) {
                            infoS += "     " + curveDescr;
                        }
                    }
                    if (infoS == null) {
                        infoS = "Unknown";
                    }
                }
            }
            if (bNeedsMembraneCursor) {
                getimagePaneView1().setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
            } else {
                getimagePaneView1().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                setToolCursor();
            }
        } else {
            lastValidMouseEvent = null;
        }
    } else {
        lastValidMouseEvent = null;
    }
    // if(mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_DRAGGED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_PRESSED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_EXITED ||
    // mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_ENTERED){
    // getInfoJlabel().setText((infoS == null?defaultInfoString:infoS));
    // }
    getimagePaneView1().setToolTipText(infoS == null ? defaultInfoString : infoS);
    // make sure the vertical space for the infoText is sufficient to avoid resizing
    FontMetrics fontMetrics = getInfoJlabel().getGraphics().getFontMetrics();
    getInfoJlabel().setMinimumSize(new Dimension(50, (fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent() + 1)));
    getInfoJlabel().setText((infoS == null ? defaultInfoString : infoS));
}
Also used : VolumeDataInfo(cbit.vcell.simdata.VolumeDataInfo) Coordinate(org.vcell.util.Coordinate) FontMetrics(java.awt.FontMetrics) StructureMetricsEntry(cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry) Dimension(java.awt.Dimension) CoordinateIndex(org.vcell.util.CoordinateIndex) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo)

Example 2 with StructureMetricsEntry

use of cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry in project vcell by virtualcell.

the class PDEDataContextPanel method getCurveValue.

/**
 * Insert the method's description here.
 * Creation date: (3/13/2001 12:53:10 PM)
 * @return java.lang.String
 * @param csi cbit.vcell.geometry.CurveSelectionInfo
 */
public String getCurveValue(CurveSelectionInfo csi) {
    String infoS = null;
    if (csi.getType() == CurveSelectionInfo.TYPE_SEGMENT) {
        if (membranesAndIndexes != null) {
            java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
            while (keysEnum.hasMoreElements()) {
                Curve curve = (Curve) keysEnum.nextElement();
                if (csi.getCurve() == curve) {
                    int[] membraneIndexes = (int[]) membranesAndIndexes.get(curve);
                    if (meshDisplayAdapter != null) {
                        double[] membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, getPdeDataContext().getDataValues(), getPdeDataContext().getDataIdentifier().getVariableType());
                        if (membraneValues != null) {
                            Coordinate segmentWC = getPdeDataContext().getCartesianMesh().getCoordinateFromMembraneIndex(membraneIndexes[csi.getSegment()]);
                            String xCoordString = NumberUtils.formatNumber(segmentWC.getX());
                            String yCoordString = NumberUtils.formatNumber(segmentWC.getY());
                            String zCoordString = NumberUtils.formatNumber(segmentWC.getZ());
                            boolean bDefined = getDataInfoProvider() == null || getDataInfoProvider().isDefined(membraneIndexes[csi.getSegment()]);
                            infoS = "(" + xCoordString + "," + yCoordString + "," + zCoordString + ")  [" + membraneIndexes[csi.getSegment()] + "]  Value = " + (bDefined ? membraneValues[csi.getSegment()] : "Undefined");
                            if (getPdeDataContext().getCartesianMesh() != null && getPdeDataContext().getCartesianMesh().isChomboMesh()) {
                                if (bDefined && getDataInfoProvider() != null) {
                                    StructureMetricsEntry structure = ((CartesianMeshChombo) getDataInfoProvider().getPDEDataContext().getCartesianMesh()).getStructureInfo(getDataInfoProvider().getPDEDataContext().getDataIdentifier());
                                    if (structure != null) {
                                        infoS += " || " + structure.getDisplayLabel();
                                    }
                                }
                            } else {
                                if (getDataInfoProvider() != null) {
                                    MembraneDataInfo membraneDataInfo = getDataInfoProvider().getMembraneDataInfo(membraneIndexes[csi.getSegment()]);
                                    infoS += "          ";
                                    infoS += " \"" + membraneDataInfo.membraneName + "\"";
                                    infoS += " mrID=" + membraneDataInfo.membraneRegionID;
                                }
                                String curveDescr = CurveRenderer.getROIDescriptions(segmentWC, getImagePlaneManagerPanel().getCurveRenderer());
                                if (curveDescr != null) {
                                    infoS += "     " + curveDescr;
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    return infoS;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve) Curve(cbit.vcell.geometry.Curve) SampledCurve(cbit.vcell.geometry.SampledCurve) CurveSelectionCurve(cbit.vcell.geometry.CurveSelectionCurve) StructureMetricsEntry(cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry) MembraneDataInfo(cbit.vcell.simdata.MembraneDataInfo) CartesianMeshChombo(cbit.vcell.solvers.CartesianMeshChombo)

Aggregations

StructureMetricsEntry (cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry)2 Coordinate (org.vcell.util.Coordinate)2 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)1 Curve (cbit.vcell.geometry.Curve)1 CurveSelectionCurve (cbit.vcell.geometry.CurveSelectionCurve)1 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)1 SampledCurve (cbit.vcell.geometry.SampledCurve)1 MembraneDataInfo (cbit.vcell.simdata.MembraneDataInfo)1 VolumeDataInfo (cbit.vcell.simdata.VolumeDataInfo)1 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)1 Dimension (java.awt.Dimension)1 FontMetrics (java.awt.FontMetrics)1 CoordinateIndex (org.vcell.util.CoordinateIndex)1