use of cbit.vcell.geometry.CurveSelectionInfo 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));
}
use of cbit.vcell.geometry.CurveSelectionInfo in project vcell by virtualcell.
the class PDEDataContextPanel method findChomboSinglePointSelectionInfoForPoint.
public CurveSelectionInfo findChomboSinglePointSelectionInfoForPoint(Coordinate wc) {
if (getPdeDataContext().getCartesianMesh().isChomboMesh()) {
CartesianMeshChombo chomboMesh = (CartesianMeshChombo) getPdeDataContext().getCartesianMesh();
int memIndex = chomboMesh.findMembraneIndexFromVolumeCoordinate(wc);
if (memIndex >= 0) {
Coordinate coord = chomboMesh.getMembraneElements()[memIndex].getCentroid();
return new CurveSelectionInfo(new SinglePoint(coord));
}
}
return null;
}
use of cbit.vcell.geometry.CurveSelectionInfo 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();
}
use of cbit.vcell.geometry.CurveSelectionInfo in project vcell by virtualcell.
the class PDEDataContextPanel method fetchSpatialSelections0.
/**
* Insert the method's description here.
* Creation date: (6/28/2003 4:57:18 PM)
* @return cbit.vcell.simdata.gui.SpatialSelection[]
*/
private SpatialSelection[] fetchSpatialSelections0(Curve curveOfInterest, boolean bFetchOnlyVisible, VariableType vt) {
//
java.util.Vector<SpatialSelection> spatialSelection = new java.util.Vector<SpatialSelection>();
//
if (getPdeDataContext() != null && getPdeDataContext().getCartesianMesh() != null && getImagePlaneManagerPanel() != null && getImagePlaneManagerPanel().getCurveRenderer() != null) {
//
CartesianMesh cm = getPdeDataContext().getCartesianMesh();
Curve[] curves = getImagePlaneManagerPanel().getCurveRenderer().getAllCurves();
//
if (curves != null && curves.length > 0) {
for (int i = 0; i < curves.length; i += 1) {
boolean bIsVisible = getImagePlaneManagerPanel().getCurveRenderer().getRenderPropertyVisible(curves[i]);
if ((bFetchOnlyVisible && !bIsVisible) || (curveOfInterest != null && curves[i] != curveOfInterest)) {
continue;
}
//
if ((vt.equals(VariableType.POSTPROCESSING) || vt.equals(VariableType.VOLUME) || vt.equals(VariableType.VOLUME_REGION)) && curves[i] instanceof ControlPointCurve && !(curves[i] instanceof CurveSelectionCurve) && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_VOLUME)) && (membranesAndIndexes == null || !membranesAndIndexes.containsKey(curves[i]))) {
// Volume
//
Curve samplerCurve = null;
// if(isSpatial2D){
samplerCurve = projectCurveOntoSlice(curves[i].getSampledCurve());
// }
if (samplerCurve != null) {
samplerCurve.setDescription(curves[i].getDescription());
spatialSelection.add(new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), vt, cm));
}
} else if ((vt.equals(VariableType.MEMBRANE) || vt.equals(VariableType.MEMBRANE_REGION)) && membranesAndIndexes != null) {
//
if (curves[i] instanceof CurveSelectionCurve) {
CurveSelectionCurve csCurve = (CurveSelectionCurve) curves[i];
if (csCurve.getSourceCurveSelectionInfo().getCurve() instanceof ControlPointCurve) {
int[] csisegsel = csCurve.getSourceCurveSelectionInfo().getSegmentsInSelectionOrder();
if (csisegsel != null) {
ControlPointCurve cscpcCurve = (ControlPointCurve) (csCurve.getSourceCurveSelectionInfo().getCurve());
Curve[] membraneCurves = (Curve[]) (membranesAndIndexes.keySet().toArray(new Curve[membranesAndIndexes.size()]));
// See if CurveSelectionCurve matches controlpoints in space of a membrane we have
for (int j = 0; j < membraneCurves.length; j += 1) {
if (membraneCurves[j] instanceof ControlPointCurve) {
// They should all be
ControlPointCurve cpc = (ControlPointCurve) membraneCurves[j];
boolean bSame = true;
for (int k = 0; k < csisegsel.length; k += 1) {
if (csisegsel[k] >= cpc.getControlPointCount() || csisegsel[k] >= cscpcCurve.getControlPointCount() || !Coordinate.get2DProjection(cpc.getControlPoint(csisegsel[k]), getNormalAxis()).equals(Coordinate.get2DProjection(cscpcCurve.getControlPoint(csisegsel[k]), getNormalAxis()))) {
//
bSame = false;
break;
}
}
if (bSame) {
int[] mi = (int[]) membranesAndIndexes.get(membraneCurves[j]);
spatialSelection.add(new SpatialSelectionMembrane(new CurveSelectionInfo(membraneCurves[j], csisegsel[0], csisegsel[csisegsel.length - 1], csCurve.getSourceCurveSelectionInfo().getDirectionNegative()), vt, cm, mi, csCurve));
}
}
}
}
}
} else if (curves[i] instanceof SinglePoint && (curves[i].getDescription() == null || curves[i].getDescription().startsWith(CurveValueProvider.DESCRIPTION_MEMBRANE))) {
CurveSelectionInfo[] csiArr = getImagePlaneManagerPanel().getCurveRenderer().getCloseCurveSelectionInfos(curves[i].getBeginningCoordinate());
if (csiArr != null && csiArr.length > 0) {
for (int j = 0; j < csiArr.length; j += 1) {
if (membranesAndIndexes.containsKey(csiArr[j].getCurve())) {
CurveSelectionInfo closestCSI = getImagePlaneManagerPanel().getCurveRenderer().getClosestSegmentSelectionInfo(curves[i].getBeginningCoordinate(), csiArr[j].getCurve());
int[] mi = (int[]) membranesAndIndexes.get(csiArr[j].getCurve());
spatialSelection.add(new SpatialSelectionMembrane(closestCSI, vt, cm, mi, (SinglePoint) curves[i]));
break;
}
}
}
}
}
}
}
}
//
if (spatialSelection.size() > 0) {
SpatialSelection[] ss = new SpatialSelection[spatialSelection.size()];
spatialSelection.copyInto(ss);
return ss;
}
return null;
}
use of cbit.vcell.geometry.CurveSelectionInfo 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;
}
Aggregations