Search in sources :

Example 46 with Coordinate

use of org.vcell.util.Coordinate 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)

Example 47 with Coordinate

use of org.vcell.util.Coordinate in project vcell by virtualcell.

the class ImageJHelper method sendMembraneOutline.

private static void sendMembraneOutline(ImageJConnection imageJConnection, Hashtable<SampledCurve, int[]>[] membraneTables) throws Exception {
    if (membraneTables != null) {
        // num slices
        imageJConnection.dos.writeInt(membraneTables.length);
        for (Hashtable<SampledCurve, int[]> membraneTable : membraneTables) {
            // System.out.println();
            if (membraneTable != null) {
                // some slices have no membrane outline
                // num polygons on slice
                imageJConnection.dos.writeInt(membraneTable.size());
                Enumeration<SampledCurve> sliceMembranes = membraneTable.keys();
                while (sliceMembranes.hasMoreElements()) {
                    SampledCurve sampledCurve = sliceMembranes.nextElement();
                    Vector<Coordinate> polygonPoints = sampledCurve.getControlPointsVector();
                    // System.out.println(polygonPoints.size());
                    // num points for polygon
                    imageJConnection.dos.writeInt(polygonPoints.size());
                    // isClosed
                    imageJConnection.dos.writeInt((sampledCurve.isClosed() ? 1 : 0));
                    for (Coordinate coord : polygonPoints) {
                        imageJConnection.dos.writeDouble(coord.getX());
                        imageJConnection.dos.writeDouble(coord.getY());
                        imageJConnection.dos.writeDouble(coord.getZ());
                    }
                }
            } else {
                imageJConnection.dos.writeInt(0);
            }
        }
    } else {
        imageJConnection.dos.writeInt(0);
    }
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate)

Example 48 with Coordinate

use of org.vcell.util.Coordinate in project vcell by virtualcell.

the class ImagePlaneManager method snapWorldCoordinate.

/**
 * Insert the method's description here.
 * Creation date: (7/12/2004 1:52:04 PM)
 */
public org.vcell.util.Coordinate snapWorldCoordinate(org.vcell.util.Coordinate targetC) {
    if (getSourceDataInfo() != null) {
        double distance = 0;
        org.vcell.util.CoordinateIndex centerCI = getSourceDataInfo().getDataIndexFromWorldCoordinate(targetC);
        Coordinate centerCoord = getSourceDataInfo().getWorldCoordinateFromIndex(centerCI);
        return centerCoord;
    }
    return null;
}
Also used : CoordinateIndex(org.vcell.util.CoordinateIndex) Coordinate(org.vcell.util.Coordinate)

Example 49 with Coordinate

use of org.vcell.util.Coordinate in project vcell by virtualcell.

the class PDEOffscreenRenderer method getPixelsRGB.

/**
 * Insert the method's description here.
 * Creation date: (3/1/2001 11:54:44 PM)
 * @return int[]
 */
public int[] getPixelsRGB(int imageScale, int membrScale, int meshMode, int volVarMembrOutlineThickness) {
    if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.VOLUME) || getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING)) {
        CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
        MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
        BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, false);
        // 
        if (!getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.POSTPROCESSING) && volVarMembrOutlineThickness > 0) {
            cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
            curveRenderer.setNormalAxis(getNormalAxis());
            org.vcell.util.Origin origin = mesh.getOrigin();
            org.vcell.util.Extent extent = mesh.getExtent();
            curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
            Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
            curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
            Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
            if (curvesAndMembraneIndexes != null) {
                Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
                for (int i = 0; curves != null && i < curves.length; i++) {
                    curveRenderer.addCurve(curves[i]);
                    curveRenderer.renderPropertySegmentColors(curves[i], null);
                    curveRenderer.renderPropertyLineWidthMultiplier(curves[i], volVarMembrOutlineThickness);
                }
                Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
                // must be false or could get more than 256 colors
                curveRenderer.setAntialias(false);
                curveRenderer.draw(g);
            }
        }
        return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
    } else if (getServerPDEDataContext().getDataIdentifier().getVariableType().equals(VariableType.MEMBRANE)) {
        CartesianMesh mesh = getServerPDEDataContext().getCartesianMesh();
        MeshDisplayAdapter meshDisplayAdapter = new MeshDisplayAdapter(mesh);
        BufferedImage bufferedImage = getScaledRGBVolume(mesh, meshMode, imageScale, true);
        // 
        // apply curve renderer
        // 
        cbit.vcell.geometry.CurveRenderer curveRenderer = new cbit.vcell.geometry.CurveRenderer(getDisplayAdapterService());
        curveRenderer.setNormalAxis(getNormalAxis());
        org.vcell.util.Origin origin = mesh.getOrigin();
        org.vcell.util.Extent extent = mesh.getExtent();
        curveRenderer.setWorldOrigin(new org.vcell.util.Coordinate(origin.getX(), origin.getY(), origin.getZ()));
        Coordinate pixeldelta = getPixelDelta(extent, mesh, meshMode, imageScale);
        curveRenderer.setWorldDelta(new org.vcell.util.Coordinate(pixeldelta.getX(), pixeldelta.getY(), pixeldelta.getZ()));
        Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(getNormalAxis(), getSlice());
        if (curvesAndMembraneIndexes != null) {
            Curve[] curves = (Curve[]) org.vcell.util.BeanUtils.getArray(curvesAndMembraneIndexes.keys(), Curve.class);
            for (int i = 0; curves != null && i < curves.length; i++) {
                curveRenderer.addCurve(curves[i]);
                curveRenderer.renderPropertySegmentColors(curves[i], getCurveColors(curvesAndMembraneIndexes, curves[i], meshDisplayAdapter));
                curveRenderer.renderPropertyLineWidthMultiplier(curves[i], membrScale);
            }
            Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
            curveRenderer.setAntialias(false);
            curveRenderer.draw(g);
        }
        return ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
    } else {
        throw new RuntimeException("unsupported VariableType " + getServerPDEDataContext().getDataIdentifier().getVariableType());
    }
}
Also used : Extent(org.vcell.util.Extent) DataBufferInt(java.awt.image.DataBufferInt) BufferedImage(java.awt.image.BufferedImage) MeshDisplayAdapter(cbit.vcell.solvers.MeshDisplayAdapter) SampledCurve(cbit.vcell.geometry.SampledCurve) Hashtable(java.util.Hashtable) Curve(cbit.vcell.geometry.Curve) SampledCurve(cbit.vcell.geometry.SampledCurve) Extent(org.vcell.util.Extent) Graphics2D(java.awt.Graphics2D) Coordinate(org.vcell.util.Coordinate) CartesianMesh(cbit.vcell.solvers.CartesianMesh) Coordinate(org.vcell.util.Coordinate)

Example 50 with Coordinate

use of org.vcell.util.Coordinate in project vcell by virtualcell.

the class PDEOffscreenRenderer method getPixelDelta.

private Coordinate getPixelDelta(Extent extent, CartesianMesh mesh, int meshMode, int imageScale) {
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    double pixelScaleX = extent.getX() / imagePaneModel.getScaledLength(mesh.getSizeX());
    double pixelScaleY = extent.getY() / imagePaneModel.getScaledLength(mesh.getSizeY());
    double pixelScaleZ = extent.getZ() / imagePaneModel.getScaledLength(mesh.getSizeZ());
    return new Coordinate(pixelScaleX, pixelScaleY, pixelScaleZ);
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Coordinate(org.vcell.util.Coordinate)

Aggregations

Coordinate (org.vcell.util.Coordinate)81 CoordinateIndex (org.vcell.util.CoordinateIndex)16 SampledCurve (cbit.vcell.geometry.SampledCurve)11 SinglePoint (cbit.vcell.geometry.SinglePoint)11 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)10 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)6 Expression (cbit.vcell.parser.Expression)6 CartesianMesh (cbit.vcell.solvers.CartesianMesh)6 Vector (java.util.Vector)6 Extent (org.vcell.util.Extent)6 VariableType (cbit.vcell.math.VariableType)5 ISize (org.vcell.util.ISize)5 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)4 Curve (cbit.vcell.geometry.Curve)4 SubVolume (cbit.vcell.geometry.SubVolume)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Origin (org.vcell.util.Origin)4 VCImageUncompressed (cbit.image.VCImageUncompressed)3 Line (cbit.vcell.geometry.Line)3