Search in sources :

Example 6 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class PDEDataContextPanel method updateContours.

/**
 * Insert the method's description here.
 * Creation date: (11/9/2000 4:14:39 PM)
 */
private void updateContours() {
    // 
    if (getPdeDataContext() == null || getPdeDataContext().getDataIdentifier() == null) {
        return;
    }
    // Remove previous curves
    CurveRenderer curveRenderer = getImagePlaneManagerPanel().getCurveRenderer();
    if (contoursAndValues != null) {
        java.util.Enumeration<SampledCurve> keysEnum = contoursAndValues.keys();
        while (keysEnum.hasMoreElements()) {
            Curve curve = keysEnum.nextElement();
            curveRenderer.removeCurve(curve);
        }
    }
    // 
    contoursAndValues = null;
    boolean hasValues = false;
    if (meshDisplayAdapter != null) {
        VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
        if (variableType.equals(VariableType.VOLUME)) {
            // Get curves with no values for overlay on volume Data
            contoursAndValues = meshDisplayAdapter.getCurvesFromContours(null);
        } else if (variableType.equals(VariableType.CONTOUR)) {
            // get curves with values
            contoursAndValues = meshDisplayAdapter.getCurvesFromContours(getPdeDataContext().getDataValues());
            hasValues = true;
        }
    }
    // Add new curves to curveRenderer
    if (contoursAndValues != null) {
        java.util.Enumeration<SampledCurve> keysEnum = contoursAndValues.keys();
        while (keysEnum.hasMoreElements()) {
            Curve curve = (Curve) keysEnum.nextElement();
            // 
            curveRenderer.addCurve(curve);
            // 
            curveRenderer.renderPropertyEditable(curve, false);
            curveRenderer.renderPropertySelectable(curve, hasValues);
            if (hasValues) {
                curveRenderer.renderPropertySubSelectionType(curve, CurveRenderer.SUBSELECTION_SEGMENT);
            } else {
                curveRenderer.renderPropertyLineWidthMultiplier(curve, 3);
            }
        }
    }
}
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)

Example 7 with VariableType

use of cbit.vcell.math.VariableType 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 8 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class PDEDataContextPanel method recodeDataForDomain0.

private void recodeDataForDomain0() {
    Domain varDomain = getPdeDataContext().getDataIdentifier().getDomain();
    double[] tempRecodedData = null;
    Range dataRange = null;
    VariableType vt = getPdeDataContext().getDataIdentifier().getVariableType();
    boolean bRecoding = getDataInfoProvider() != null && varDomain != null;
    Double notInDomainValue = null;
    if (getPdeDataContext().getDataValues() != originalData || recodeDataForDomainInfo == null || ((getDataInfoProvider() == null) != bDataInfoProviderNull) || !Compare.isEqualOrNull(functionStatisticsRange, lastFunctionStatisticsRange)) {
        lastFunctionStatisticsRange = functionStatisticsRange;
        bDataInfoProviderNull = (getDataInfoProvider() == null);
        originalData = getPdeDataContext().getDataValues();
        tempRecodedData = originalData;
        double illegalNumber = Double.POSITIVE_INFINITY;
        if (bRecoding) {
            tempRecodedData = new double[originalData.length];
            System.arraycopy(originalData, 0, tempRecodedData, 0, tempRecodedData.length);
            for (int i = 0; i < originalData.length; i++) {
                if (!Double.isNaN(originalData[i])) {
                    illegalNumber = Math.min(illegalNumber, originalData[i]);
                }
            }
        }
        // 
        illegalNumber -= 1;
        notInDomainValue = new Double(illegalNumber);
        final CartesianMesh cartesianMesh = getPdeDataContext().getCartesianMesh();
        double minCurrTime = Double.POSITIVE_INFINITY;
        double maxCurrTime = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < tempRecodedData.length; i++) {
            if (bRecoding) {
                if (!isInDomain(cartesianMesh, varDomain, dataInfoProvider, i, vt)) {
                    tempRecodedData[i] = illegalNumber;
                }
            }
            if (!Double.isNaN(tempRecodedData[i]) && tempRecodedData[i] != illegalNumber) {
                minCurrTime = Math.min(minCurrTime, tempRecodedData[i]);
                maxCurrTime = Math.max(maxCurrTime, tempRecodedData[i]);
            }
        }
        if (!getdisplayAdapterService1().getAllTimes() || functionStatisticsRange == null) {
            dataRange = new Range(minCurrTime, maxCurrTime);
        } else if (functionStatisticsRange != null) {
            dataRange = functionStatisticsRange;
        } else {
            throw new RuntimeException("Unexpected state for range calculation");
        }
    } else {
        dataRange = recodeDataForDomainInfo.getRecodedDataRange();
        tempRecodedData = recodeDataForDomainInfo.getRecodedDataForDomain();
    }
    if (bRecoding) {
        recodeDataForDomainInfo = new RecodeDataForDomainInfo(true, tempRecodedData, dataRange, notInDomainValue);
    } else {
        recodeDataForDomainInfo = new RecodeDataForDomainInfo(false, tempRecodedData, dataRange, notInDomainValue);
    }
}
Also used : CartesianMesh(cbit.vcell.solvers.CartesianMesh) VariableType(cbit.vcell.math.VariableType) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) Domain(cbit.vcell.math.Variable.Domain) Range(org.vcell.util.Range) SinglePoint(cbit.vcell.geometry.SinglePoint)

Example 9 with VariableType

use of cbit.vcell.math.VariableType in project vcell by virtualcell.

the class PDEDataContextPanel method recodeDataForDomain.

public void recodeDataForDomain() {
    // 
    if (getPdeDataContext() == null) {
        return;
    }
    recodeDataForDomain0();
    VariableType vt = getPdeDataContext().getDataIdentifier().getVariableType();
    // This creates an appropriate volume data data holder for volume data types
    // or creates a dummy background for membrane data types
    SourceDataInfo recodedSourceDataInfo = calculateSourceDataInfo(getPdeDataContext().getCartesianMesh(), recodeDataForDomainInfo.getRecodedDataForDomain(), getPdeDataContext().getDataIdentifier().getVariableType(), recodeDataForDomainInfo.getRecodedDataRange());
    getImagePlaneManagerPanel().setSourceDataInfo(recodedSourceDataInfo);
}
Also used : VariableType(cbit.vcell.math.VariableType) SourceDataInfo(cbit.image.SourceDataInfo)

Example 10 with VariableType

use of cbit.vcell.math.VariableType 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)

Aggregations

VariableType (cbit.vcell.math.VariableType)54 CartesianMesh (cbit.vcell.solvers.CartesianMesh)17 DataAccessException (org.vcell.util.DataAccessException)15 File (java.io.File)13 ISize (org.vcell.util.ISize)12 Expression (cbit.vcell.parser.Expression)11 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)11 SinglePoint (cbit.vcell.geometry.SinglePoint)10 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)10 Domain (cbit.vcell.math.Variable.Domain)9 ExpressionException (cbit.vcell.parser.ExpressionException)9 DataIdentifier (cbit.vcell.simdata.DataIdentifier)9 ArrayList (java.util.ArrayList)9 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 ReservedVariable (cbit.vcell.math.ReservedVariable)8 Variable (cbit.vcell.math.Variable)8 SimDataBlock (cbit.vcell.simdata.SimDataBlock)8 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)8 Hashtable (java.util.Hashtable)8 MathException (cbit.vcell.math.MathException)7