use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class SpatialSelectionVolume method offsetCoordinate.
/**
* Insert the method's description here.
* Creation date: (10/9/2004 12:20:17 PM)
* @return cbit.vcell.geometry.Coordinate
* @param from cbit.vcell.geometry.Coordinate
* @param to cbit.vcell.geometry.Coordinate
*/
private Coordinate offsetCoordinate(Coordinate start, Coordinate towards) {
// Offset 1/10 the smallest mesh cell dimension length
cbit.vcell.render.Vect3d offsetV = new cbit.vcell.render.Vect3d((towards.getX() - start.getX()), (towards.getY() - start.getY()), (towards.getZ() - start.getZ()));
double length = offsetV.length();
double scale = (getSmallestMeshCellDimensionLength() / 10.0) / length;
offsetV.scale(scale);
Coordinate offsetCoord = new Coordinate(start.getX() + offsetV.getX(), start.getY() + offsetV.getY(), start.getZ() + offsetV.getZ());
return offsetCoord;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class SpatialSelectionVolume method getMeshIndexFromU.
private int getMeshIndexFromU(double u) {
Coordinate wc = getSamplingWorldCoordinate(u);
CoordinateIndex ci = getCoordinateIndexFromWC(wc);
return getMesh().getVolumeIndex(ci);
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CurveEditorTool method move.
/**
* Insert the method's description here.
* Creation date: (7/17/2003 5:59:43 PM)
* @param dx double
* @param dy double
*/
private boolean move(double xDelta, double yDelta, CurveSelectionInfo csi, int normalAxis, boolean bAdjustToSlice) {
//
double maxDistance = 0;
ControlPointCurve cpc = (ControlPointCurve) csi.getCurve();
Coordinate[] newCPArr = new Coordinate[cpc.getControlPointCount()];
Coordinate[] oldCPArr = new Coordinate[cpc.getControlPointCount()];
//
for (int i = 0; i < cpc.getControlPointCount(); i += 1) {
//
double xCoord = Coordinate.convertAxisFromStandardXYZToNormal(cpc.getControlPoint(i), Coordinate.X_AXIS, normalAxis);
double yCoord = Coordinate.convertAxisFromStandardXYZToNormal(cpc.getControlPoint(i), Coordinate.Y_AXIS, normalAxis);
double zCoord;
if (bAdjustToSlice) {
zCoord = Coordinate.convertAxisFromStandardXYZToNormal(getWorldCoordinateCalculator().getWorldCoordinateFromUnitized2D(0, 0), Coordinate.Z_AXIS, normalAxis);
} else {
zCoord = Coordinate.convertAxisFromStandardXYZToNormal(cpc.getControlPoint(i), Coordinate.Z_AXIS, normalAxis);
}
//
Coordinate oldCoord = Coordinate.convertCoordinateFromNormalToStandardXYZ(xCoord, yCoord, zCoord, normalAxis);
Coordinate newCoord = Coordinate.convertCoordinateFromNormalToStandardXYZ(xCoord + xDelta, yCoord + yDelta, zCoord, normalAxis);
//
Coordinate snapOldCoord = getWorldCoordinateCalculator().snapWorldCoordinate(oldCoord);
Coordinate snapNewCoord = getWorldCoordinateCalculator().snapWorldCoordinate(newCoord);
double nextDistance = Math.abs(snapOldCoord.distanceTo(snapNewCoord));
if (nextDistance > maxDistance) {
maxDistance = nextDistance;
}
oldCPArr[i] = snapOldCoord;
newCPArr[i] = snapNewCoord;
}
//
// Check if all controlpoints moved the same (some may be at edge)
//
boolean bAllSame = true;
for (int i = 0; i < newCPArr.length; i += 1) {
double nextDistance = Math.abs(oldCPArr[i].distanceTo(newCPArr[i]));
double dDelta = (maxDistance - nextDistance) / maxDistance;
if (dDelta > 1e-8) {
bAllSame = false;
break;
}
}
if (!bAllSame && (csi.getType() == CurveSelectionInfo.TYPE_CURVE)) {
return false;
}
//
for (int i = 0; i < cpc.getControlPointCount(); i += 1) {
if (csi.getType() == CurveSelectionInfo.TYPE_CONTROL_POINT) {
if (csi.getControlPoint() == i) {
cpc.setControlPoint(i, newCPArr[i]);
}
} else if (csi.getType() == CurveSelectionInfo.TYPE_CURVE) {
cpc.setControlPoint(i, newCPArr[i]);
}
}
return true;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CurveEditorTool method getWorldCoordinateValue.
/**
* Insert the method's description here.
* Creation date: (10/15/00 1:56:24 PM)
* @param mousePoint java.awt.Point
*/
private Coordinate getWorldCoordinateValue(java.awt.Point mousePoint) {
java.awt.geom.Point2D.Double c2dUnitized = getVcellDrawable().getImagePointUnitized(mousePoint);
Coordinate worldCoordinate = getWorldCoordinateCalculator().getWorldCoordinateFromUnitized2D(c2dUnitized.getX(), c2dUnitized.getY());
return worldCoordinate;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CurveEditorTool method mouseDragged.
/**
* This method was created in VisualAge.
* @param event java.awt.event.MouseEvent
*/
public void mouseDragged(MouseEvent event) {
if (!getProperlyConfigured() || !getCurveRenderer().getSelectionValid()) {
return;
}
if (getTool() != TOOL_SELECT) {
// Prevents spurious coordinate changes with other tools
return;
}
CurveSelectionInfo csi = getCurveRenderer().getSelection();
if (csi != null) {
if (csi.getType() == CurveSelectionInfo.TYPE_SEGMENT || csi.getType() == CurveSelectionInfo.TYPE_U) {
// extend the selection
CurveSelectionInfo csiExtended = getCurveRenderer().extend(getWorldCoordinateValue(event.getPoint()));
if (csiExtended != null) {
getCurveRenderer().setSelection(csiExtended);
}
} else {
// move the selection
if (lastSnappedWorldCoord != null) {
// getCurveRenderer().move(event.getPoint().x - lastPoint.x, event.getPoint().y - lastPoint.y);
if (csi.getCurve() instanceof ControlPointCurve && getCurveRenderer().getRenderPropertyEditable(csi.getCurve())) {
Coordinate currentSnappedWorldCoord = getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint()));
if (!lastSnappedWorldCoord.compareEqual(currentSnappedWorldCoord)) {
double xDelta = Coordinate.convertAxisFromStandardXYZToNormal(currentSnappedWorldCoord, Coordinate.X_AXIS, getCurveRenderer().getNormalAxis()) - Coordinate.convertAxisFromStandardXYZToNormal(lastSnappedWorldCoord, Coordinate.X_AXIS, getCurveRenderer().getNormalAxis());
double yDelta = Coordinate.convertAxisFromStandardXYZToNormal(currentSnappedWorldCoord, Coordinate.Y_AXIS, getCurveRenderer().getNormalAxis()) - Coordinate.convertAxisFromStandardXYZToNormal(lastSnappedWorldCoord, Coordinate.Y_AXIS, getCurveRenderer().getNormalAxis());
if (move(xDelta, yDelta, csi, getCurveRenderer().getNormalAxis(), event.isControlDown())) {
lastSnappedWorldCoord = currentSnappedWorldCoord;
}
}
} else {
lastSnappedWorldCoord = getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint()));
}
}
}
getVcellDrawable().repaint();
}
}
Aggregations