Search in sources :

Example 6 with SampledCurve

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

the class PDEDataContextPanel method updateMembraneCurves.

/**
 * Insert the method's description here.
 * Creation date: (10/22/00 3:15:49 PM)
 */
private void updateMembraneCurves() {
    // 
    if (getPdeDataContext() == null || getPdeDataContext().getDataIdentifier() == null) {
        return;
    }
    int normalAxis = getImagePlaneManagerPanel().getImagePlaneManager().getNormalAxis();
    int slice = getImagePlaneManagerPanel().getImagePlaneManager().getSlice();
    // Remove previous curves
    CurveRenderer curveRenderer = getImagePlaneManagerPanel().getCurveRenderer();
    if (membranesAndIndexes != null) {
        java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
        while (keysEnum.hasMoreElements()) {
            Curve curve = keysEnum.nextElement();
            curveRenderer.removeCurve(curve);
        }
    }
    // 
    membranesAndIndexes = null;
    boolean hasValues = false;
    if (meshDisplayAdapter != null) {
        // Get new curves for slice and normalAxis
        VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
        if (variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
            // Turn off showing Membrane values over mouse
            // getImagePlaneManagerPanel().setCurveValueProvider(null);
            // 
            // GET CURVES WITH NO VALUES FOR OVERLAY ON VOLUME DATA
            membranesAndIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(normalAxis, slice);
        } else if (variableType.equals(VariableType.MEMBRANE)) {
            // Turn on showing Membrane values over mouse
            // getImagePlaneManagerPanel().setCurveValueProvider(this);
            // 
            // GET CURVES WITH VALUES
            membranesAndIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(normalAxis, slice);
            hasValues = true;
        } else if (variableType.equals(VariableType.MEMBRANE_REGION)) {
            // Turn on showing Membrane values over mouse
            // getImagePlaneManagerPanel().setCurveValueProvider(this);
            // 
            // GET CURVES WITH REGIONIDS
            membranesAndIndexes = meshDisplayAdapter.getCurvesAndMembraneIndexes(normalAxis, slice);
            /*
			//RegionID values
			double[] regionValues = getPdeDataContext().getDataValues();
			java.util.Iterator regionIDCurveValues = membranesAndValues.values().iterator();
			//convert RegionID to value
			while(regionIDCurveValues.hasNext()){
				java.util.Vector regionIDValues = (java.util.Vector)regionIDCurveValues.next();
				for(int i = 0;i < regionIDValues.size();i+= 1){
					int regionID = (int)(((Double)(regionIDValues.elementAt(i))).doubleValue());
					Double decodedRegionValue = new Double(regionValues[regionID]);
					regionIDValues.setElementAt(decodedRegionValue,i);
				}
			}
			*/
            hasValues = true;
        }
    }
    // Add new curves to curveRenderer
    if (membranesAndIndexes != null) {
        java.util.Enumeration<SampledCurve> keysEnum = membranesAndIndexes.keys();
        while (keysEnum.hasMoreElements()) {
            Curve curve = keysEnum.nextElement();
            // 
            curveRenderer.addCurve(curve);
            // 
            curveRenderer.renderPropertyEditable(curve, false);
            curveRenderer.renderPropertySelectable(curve, false);
            if (!hasValues) {
                curveRenderer.renderPropertyLineWidthMultiplier(curve, 3);
            }
        // getImagePlaneManagerPanel().getCurveRenderer().renderPropertySelectable(curve, hasValues);
        // if (hasValues) {
        // getImagePlaneManagerPanel().getCurveRenderer().renderPropertySubSelectionType(curve, cbit.vcell.geometry.gui.CurveRenderer.SUBSELECTION_SEGMENT);
        // }else{
        // getImagePlaneManagerPanel().getCurveRenderer().renderPropertyLineWidthMultiplier(curve,3);
        // }
        }
    }
    // 
    refreshColorCurves();
    // 
    // Set visibility of curve samplers
    Curve[] curves = curveRenderer.getAllCurves();
    if (curves != null && curves.length > 0) {
        for (int i = 0; i < curves.length; i += 1) {
            if (membranesAndIndexes == null || !membranesAndIndexes.containsKey(curves[i])) {
                boolean isCurveValidDataSampler = isValidDataSampler(curves[i]);
                curveRenderer.renderPropertyVisible(curves[i], isCurveValidDataSampler);
                curveRenderer.renderPropertyEditable(curves[i], (membraneSamplerCurves != null && membraneSamplerCurves.contains(curves[i]) ? false : true));
            }
        }
    }
    // See if we should keep selection
    if (curveRenderer.getSelection() != null) {
        CurveSelectionInfo csi = curveRenderer.getSelection();
        curveRenderer.selectNothing();
        if (isValidDataSampler(csi.getCurve())) {
            curveRenderer.setSelection(csi);
        }
    }
    // 
    // 
    fireDataSamplers();
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) VariableType(cbit.vcell.math.VariableType) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve) Curve(cbit.vcell.geometry.Curve) SampledCurve(cbit.vcell.geometry.SampledCurve) CurveSelectionCurve(cbit.vcell.geometry.CurveSelectionCurve) CurveRenderer(cbit.vcell.geometry.CurveRenderer) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 7 with SampledCurve

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

the class PDEDataContextPanel method projectCurveOntoSlice.

/**
 * Insert the method's description here.
 * Creation date: (7/16/2003 1:05:56 PM)
 * @return cbit.vcell.geometry.ControlPointCurve
 * @param curve cbit.vcell.geometry.ControlPointCurve
 */
private ControlPointCurve projectCurveOntoSlice(ControlPointCurve curve) {
    // for SinglePoint(timepoint) and PolyLine(spatial) samplers(always stored in world coordinates),
    // convert the curve coordinates into view coordinates from the sliceviewer
    ControlPointCurve cpCurve = null;
    java.util.Vector<Coordinate> cpV = new java.util.Vector<Coordinate>();
    int normalAxis = getimagePlaneManager1().getNormalAxis();
    for (int i = 0; i < curve.getControlPointCount(); i += 1) {
        // convert curves that are always stored in world coordinates into coordinates that
        // represent how user sees them in the slice viewer
        double xCoord = Coordinate.convertAxisFromStandardXYZToNormal(curve.getControlPoint(i), Coordinate.X_AXIS, normalAxis);
        double yCoord = Coordinate.convertAxisFromStandardXYZToNormal(curve.getControlPoint(i), Coordinate.Y_AXIS, normalAxis);
        // Get z from slice
        double zCoord = Coordinate.convertAxisFromStandardXYZToNormal(getimagePlaneManager1().getWorldCoordinateFromUnitized2D(0, 0), Coordinate.Z_AXIS, normalAxis);
        // These are now the real coordinates as they are viewed in the slice viewer
        // Coordinate newCoord = new Coordinate(xCoord,yCoord,zCoord);
        Coordinate newCoord = Coordinate.convertCoordinateFromNormalToStandardXYZ(xCoord, yCoord, zCoord, normalAxis);
        cpV.add(newCoord);
    }
    if (cpV.size() > 0) {
        Coordinate[] cpArr = new Coordinate[cpV.size()];
        cpV.copyInto(cpArr);
        // Determine if curve has been projected down to a single point
        boolean bSinglePoint = true;
        for (int i = 0; i < cpArr.length; i += 1) {
            if (i > 0 && !cpArr[i].equals(cpArr[i - 1])) {
                bSinglePoint = false;
                break;
            }
        }
        // if(curve instanceof SinglePoint){
        if (bSinglePoint) {
            cpCurve = new SinglePoint(cpArr[0]);
        } else if (curve instanceof SampledCurve) {
            cpCurve = new PolyLine(cpArr);
        }
    }
    return cpCurve;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) PolyLine(cbit.vcell.geometry.PolyLine) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve) SinglePoint(cbit.vcell.geometry.SinglePoint) SinglePoint(cbit.vcell.geometry.SinglePoint) Coordinate(org.vcell.util.Coordinate) Vector(java.util.Vector)

Example 8 with SampledCurve

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

the class PDEDataContextPanel method getInitalCurveSelection.

/**
 * Insert the method's description here.
 * Creation date: (7/4/2003 6:10:48 PM)
 */
public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
    // 
    CurveSelectionInfo newCurveSelection = null;
    VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
    if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
        if (getPdeDataContext().getCartesianMesh().isChomboMesh() && tool == CurveEditorTool.TOOL_POINT) {
            newCurveSelection = findChomboSinglePointSelectionInfoForPoint(wc);
        } else {
            CurveSelectionInfo[] closeCSI = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(wc);
            if (closeCSI != null) {
                for (int i = 0; i < closeCSI.length; i += 1) {
                    if (membranesAndIndexes != null && membranesAndIndexes.containsKey(closeCSI[i].getCurve())) {
                        if (tool == CurveEditorTool.TOOL_LINE) {
                            newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
                        } else if (tool == CurveEditorTool.TOOL_POINT) {
                            newCurveSelection = new CurveSelectionInfo(new CurveSelectionCurve((SampledCurve) (closeCSI[i].getCurve())));
                            double dist = closeCSI[i].getCurve().getDistanceTo(wc);
                            int segmentIndex = closeCSI[i].getCurve().pickSegment(wc, dist * 1.1);
                            Coordinate[] coordArr = closeCSI[i].getCurve().getSampledCurve().getControlPointsForSegment(segmentIndex);
                            Coordinate middleCoord = new Coordinate((coordArr[0].getX() + coordArr[1].getX()) / 2, (coordArr[0].getY() + coordArr[1].getY()) / 2, (coordArr[0].getZ() + coordArr[1].getZ()) / 2);
                            newCurveSelection = new CurveSelectionInfo(new SinglePoint(middleCoord));
                        }
                        break;
                    }
                }
            }
        }
    }
    if (newCurveSelection != null) {
        if (membraneSamplerCurves == null) {
            membraneSamplerCurves = new java.util.Vector<Curve>();
        }
        membraneSamplerCurves.add(newCurveSelection.getCurve());
    }
    return newCurveSelection;
}
Also used : CurveSelectionCurve(cbit.vcell.geometry.CurveSelectionCurve) SampledCurve(cbit.vcell.geometry.SampledCurve) SinglePoint(cbit.vcell.geometry.SinglePoint) VariableType(cbit.vcell.math.VariableType) 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) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 9 with SampledCurve

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

the class PDEDataContextPanel method colorMembraneCurvesPrivate.

/**
 * Insert the method's description here.
 * Creation date: (10/26/00 4:49:39 PM)
 */
private void colorMembraneCurvesPrivate(java.util.Hashtable<SampledCurve, int[]> curvesAndMembraneIndexes, MeshDisplayAdapter meshDisplayAdapter) {
    DisplayAdapterService das = getdisplayAdapterService1();
    if (curvesAndMembraneIndexes != null) {
        java.util.Enumeration<SampledCurve> keysEnum = curvesAndMembraneIndexes.keys();
        while (keysEnum.hasMoreElements()) {
            SampledCurve curve = keysEnum.nextElement();
            int[] membraneIndexes = curvesAndMembraneIndexes.get(curve);
            double[] membraneValues = null;
            if (membraneIndexes != null && getPdeDataContext().getDataValues() != null && getPdeDataContext().getDataIdentifier() != null) {
                membraneValues = meshDisplayAdapter.getDataValuesForMembraneIndexes(membraneIndexes, (recodeDataForDomainInfo.isRecoded ? recodeDataForDomainInfo.getRecodedDataForDomain() : getPdeDataContext().getDataValues()), getPdeDataContext().getDataIdentifier().getVariableType());
            }
            if (membraneValues != null) {
                int[] valueColors = new int[membraneValues.length];
                for (int i = 0; i < membraneValues.length; i += 1) {
                    valueColors[i] = das.getColorFromValue(membraneValues[i]);
                }
                getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentColors(curve, valueColors);
                getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentIndexes(curve, membraneIndexes);
            } else {
                getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentColors(curve, null);
                getImagePlaneManagerPanel().getCurveRenderer().renderPropertySegmentIndexes(curve, null);
            }
        }
    }
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) SampledCurve(cbit.vcell.geometry.SampledCurve) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 10 with SampledCurve

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

the class MeshDisplayAdapter method constructChomboCurves.

private Hashtable<SampledCurve, int[]> constructChomboCurves(int normalAxis, int slice) {
    Hashtable<SampledCurve, int[]> curvesAndValues = null;
    if (mesh.isChomboMesh() && mesh.getMembraneElements() != null) {
        CartesianMeshChombo chomboMesh = (CartesianMeshChombo) mesh;
        curvesAndValues = new Hashtable<SampledCurve, int[]>();
        if (chomboMesh.getDimension() == 2) {
            MembraneElement[] membraneElements = mesh.getMembraneElements();
            List<MembraneElement> melist = new ArrayList<MembraneElement>();
            Segment2D[] segments = chomboMesh.get2DSegments();
            List<MembraneElement> openCurveStartingPointList = new ArrayList<MembraneElement>();
            for (MembraneElement me : membraneElements) {
                melist.add(me);
                Segment2D segment = segments[me.getMembraneIndex()];
                if (segment.prevNeigbhor < 0) {
                    openCurveStartingPointList.add(me);
                }
            }
            MembraneElement me = null;
            Coordinate[] vertices = chomboMesh.getVertices();
            SampledCurve curve = null;
            List<Integer> indexList = new ArrayList<Integer>();
            int startingIndex = -1;
            boolean bOpen = false;
            while (melist.size() > 0) {
                if (me == null) {
                    if (openCurveStartingPointList.size() > 0) {
                        me = openCurveStartingPointList.remove(0);
                        bOpen = true;
                    } else {
                        me = melist.get(0);
                        bOpen = false;
                    }
                    startingIndex = me.getMembraneIndex();
                    curve = new SampledCurve();
                    indexList.clear();
                }
                melist.remove(me);
                Segment2D segment = segments[me.getMembraneIndex()];
                indexList.add(me.getMembraneIndex());
                int pcnt = curve.getControlPointCount();
                if (pcnt == 0 && segment.prevVertex >= 0) {
                    Coordinate p1 = vertices[segment.prevVertex];
                    curve.appendControlPoint(p1);
                }
                if (segment.nextVertex >= 0 && segment.nextNeigbhor != startingIndex) {
                    Coordinate p2 = vertices[segment.nextVertex];
                    curve.appendControlPoint(p2);
                }
                int nextIndex = segment.nextNeigbhor;
                if (nextIndex == startingIndex || nextIndex < 0) {
                    // curve complete
                    int[] rmi = new int[indexList.size()];
                    for (int i = 0; i < indexList.size(); ++i) {
                        rmi[i] = indexList.get(i);
                    }
                    curve.setClosed(!bOpen);
                    curvesAndValues.put(curve, rmi);
                    // start a new curve
                    me = null;
                } else {
                    me = membraneElements[nextIndex];
                }
            }
        } else {
        // 3D
        }
    }
    return curvesAndValues;
}
Also used : SampledCurve(cbit.vcell.geometry.SampledCurve) ArrayList(java.util.ArrayList) Segment2D(cbit.vcell.solvers.CartesianMeshChombo.Segment2D) Coordinate(org.vcell.util.Coordinate)

Aggregations

SampledCurve (cbit.vcell.geometry.SampledCurve)18 Coordinate (org.vcell.util.Coordinate)11 SinglePoint (cbit.vcell.geometry.SinglePoint)8 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)6 Curve (cbit.vcell.geometry.Curve)6 VariableType (cbit.vcell.math.VariableType)5 Vector (java.util.Vector)5 CurveSelectionCurve (cbit.vcell.geometry.CurveSelectionCurve)4 CurveSelectionInfo (cbit.vcell.geometry.CurveSelectionInfo)3 Hashtable (java.util.Hashtable)3 CurveRenderer (cbit.vcell.geometry.CurveRenderer)2 Line (cbit.vcell.geometry.Line)2 Spline (cbit.vcell.geometry.Spline)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)2 SpatialSelectionMembrane (cbit.vcell.simdata.SpatialSelectionMembrane)2 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)2 Element (org.jdom.Element)2