Search in sources :

Example 1 with VolumeDataInfo

use of cbit.vcell.simdata.VolumeDataInfo 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)

Aggregations

CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)1 VolumeDataInfo (cbit.vcell.simdata.VolumeDataInfo)1 StructureMetricsEntry (cbit.vcell.solvers.CartesianMeshChombo.StructureMetricsEntry)1 Dimension (java.awt.Dimension)1 FontMetrics (java.awt.FontMetrics)1 Coordinate (org.vcell.util.Coordinate)1 CoordinateIndex (org.vcell.util.CoordinateIndex)1