use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataViewer method showTimePlot.
// private static final String PROPERTY_PDEDC = "pdedc";
/**
* Comment
*/
private void showTimePlot() {
VariableType varType = getPdeDataContext().getDataIdentifier().getVariableType();
// Collect all sample curves created by user
SpatialSelection[] spatialSelectionArr = getPDEDataContextPanel1().fetchSpatialSelections(true, true);
SpatialSelection[] spatialSelectionArr2 = null;
if (varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME) || varType.getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_POSTPROCESSING)) {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType, true, true);
} else {
spatialSelectionArr2 = getPDEDataContextPanel1().fetchSpatialSelections(varType.equals(VariableType.MEMBRANE) ? VariableType.MEMBRANE_REGION : VariableType.MEMBRANE, true, true);
}
final Vector<SpatialSelection> singlePointSSOnly = new Vector<SpatialSelection>();
final Vector<SpatialSelection> singlePointSSOnly2 = new Vector<SpatialSelection>();
if (spatialSelectionArr != null && spatialSelectionArr.length > 0) {
for (int i = 0; i < spatialSelectionArr.length; i++) {
if (spatialSelectionArr[i].isPoint() || (spatialSelectionArr[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly.add(spatialSelectionArr[i]);
}
if (spatialSelectionArr2[i].isPoint() || (spatialSelectionArr2[i] instanceof SpatialSelectionMembrane && ((SpatialSelectionMembrane) spatialSelectionArr2[i]).getSelectionSource() instanceof SinglePoint)) {
singlePointSSOnly2.add(spatialSelectionArr2[i]);
}
}
}
final String varName = getPdeDataContext().getVariableName();
if (singlePointSSOnly.size() == 0) {
PopupGenerator.showErrorDialog(this, "No Time sampling points match DataType=" + varType);
return;
}
try {
int[] indices = null;
//
indices = new int[singlePointSSOnly.size()];
for (int i = 0; i < singlePointSSOnly.size(); i++) {
if (varType.equals(VariableType.VOLUME) || varType.equals(VariableType.VOLUME_REGION) || varType.equals(VariableType.POSTPROCESSING)) {
SpatialSelectionVolume ssv = (SpatialSelectionVolume) singlePointSSOnly.get(i);
indices[i] = ssv.getIndex(0);
} else if (varType.equals(VariableType.MEMBRANE) || varType.equals(VariableType.MEMBRANE_REGION)) {
SpatialSelectionMembrane ssm = (SpatialSelectionMembrane) singlePointSSOnly.get(i);
indices[i] = ssm.getIndex(0);
}
}
double[] timePoints = getPdeDataContext().getTimePoints();
final TimeSeriesJobSpec tsjs = new TimeSeriesJobSpec(new String[] { varName }, new int[][] { indices }, null, timePoints[0], 1, timePoints[timePoints.length - 1], VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
if (!tsjs.getVcDataJobID().isBackgroundTask()) {
throw new RuntimeException("Use getTimeSeries(...) if not a background job");
}
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(StringKey_timeSeriesJobSpec, tsjs);
AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving Data for '" + varName + "'...", PDEDataViewer.this, getPdeDataContext());
AsynchClientTask multiTimePlotHelperTask = new AsynchClientTask("", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = createMultiTimePlotHelper((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext(), PDEDataViewer.this.getDataViewerManager().getUser(), getSimulationModelInfo().getDataSymbolMetadataResolver());
hashTable.put(MULTITPHELPER_TASK_KEY, multiTimePlotHelper);
}
};
AsynchClientTask task2 = new AsynchClientTask("showing time plot for '" + varName + "'", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Exception timeSeriesJobFailed = (Exception) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobException);
if (timeSeriesJobFailed != null) {
throw timeSeriesJobFailed;
}
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
// Make independent Plotviewer that is unaffected by changes (time,var,paramscan) in 'this' PDEDataviewer except to pass-thru OutputContext changes
PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelper = (PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper) hashTable.get(MULTITPHELPER_TASK_KEY);
try {
PdeTimePlotMultipleVariablesPanel pdeTimePlotPanel = new PdeTimePlotMultipleVariablesPanel(multiTimePlotHelper, singlePointSSOnly, singlePointSSOnly2, tsJobResultsNoStats);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
String prefix = "Time Plot (" + getPDEPlotControlPanel1().getPlotVariableJList().getSelectedValue().getVariableType().getTypeName() + ") ";
ChildWindow childWindow = childWindowManager.addChildWindow(pdeTimePlotPanel, pdeTimePlotPanel, createContextTitle(PDEDataViewer.this.isPostProcess(), prefix, getPdeDataContext(), getSimulationModelInfo(), getSimulation()));
childWindow.getParent().addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
@Override
public void windowClosed(WindowEvent e) {
super.windowClosed(e);
multiTimePlotHelper.removeallPropertyChangeListeners();
}
});
// childWindow.addChildWindowListener(new ChildWindowListener() {
// @Override
// public void closing(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// @Override
// public void closed(ChildWindow childWindow) {
// multiTimePlotHelper.removeallPropertyChangeListeners();
// }
// });
childWindow.setSize(900, 550);
childWindow.setIsCenteredOnParent();
childWindow.show();
} catch (Exception e) {
e.printStackTrace();
multiTimePlotHelper.removeallPropertyChangeListeners();
}
}
};
// ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1,multiTimePlotHelperTask, task2 }, true, true, null);
ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, multiTimePlotHelperTask, task2 }, null, false, false, true, null, false);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method fireDataSamplers.
/**
* Insert the method's description here.
* Creation date: (7/6/2003 7:42:59 PM)
* @param curve cbit.vcell.geometry.Curve
*/
private void fireDataSamplers() {
// fire "dataSamplers" if there are any
boolean bTimeDataSamplerVisible = false;
boolean bSpatialDataSamplerVisible = false;
CurveRenderer cr = getImagePlaneManagerPanel().getCurveRenderer();
if (cr != null) {
Curve[] curves = getImagePlaneManagerPanel().getCurveRenderer().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]);
bTimeDataSamplerVisible = bTimeDataSamplerVisible || (isCurveValidDataSampler && curves[i] instanceof SinglePoint);
bSpatialDataSamplerVisible = bSpatialDataSamplerVisible || (isCurveValidDataSampler && !(curves[i] instanceof SinglePoint)) && cr.getSelection() != null && cr.getSelection().getCurve() == curves[i];
}
}
}
}
//
firePropertyChange("timeDataSamplers", !bTimeDataSamplerVisible, bTimeDataSamplerVisible);
firePropertyChange("spatialDataSamplers", !bSpatialDataSamplerVisible, bSpatialDataSamplerVisible);
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method isValidDataSampler.
/**
* Insert the method's description here.
* Creation date: (7/6/2003 7:44:14 PM)
* @return boolean
* @param curve cbit.vcell.geometry.Curve
*/
private boolean isValidDataSampler(Curve curve) {
if (!curve.isValid()) {
return false;
}
VariableType vt = getPdeDataContext().getDataIdentifier().getVariableType();
boolean isCurveVisible = true;
//
if (vt.equals(VariableType.POSTPROCESSING) || vt.equals(VariableType.VOLUME) || vt.equals(VariableType.VOLUME_REGION)) {
//
if (membraneSamplerCurves != null && membraneSamplerCurves.contains(curve)) {
isCurveVisible = false;
} else {
isCurveVisible = true;
if (!(curve instanceof SinglePoint)) {
double zeroZ = Coordinate.convertAxisFromStandardXYZToNormal(curve.getSampledCurve().getControlPoint(0), Coordinate.Z_AXIS, getNormalAxis());
for (int i = 1; i < curve.getSampledCurve().getControlPointCount(); i++) {
double indexZ = Coordinate.convertAxisFromStandardXYZToNormal(curve.getSampledCurve().getControlPoint(i), Coordinate.Z_AXIS, getNormalAxis());
if (zeroZ != indexZ) {
isCurveVisible = false;
}
}
}
}
//
} else if (vt.equals(VariableType.MEMBRANE) || vt.equals(VariableType.MEMBRANE_REGION)) {
//
if (membraneSamplerCurves != null && membraneSamplerCurves.contains(curve)) {
isCurveVisible = (fetchSpatialSelections(curve, false) != null);
} else {
isCurveVisible = false;
}
//
}
//
return isCurveVisible;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class PDEDataContextPanel method isAddControlPointOK.
/**
* Insert the method's description here.
* Creation date: (7/4/2003 6:10:48 PM)
*/
public boolean isAddControlPointOK(int tool, Coordinate wc, Curve addedToThisCurve) {
//
CurveRenderer curveR = getImagePlaneManagerPanel().getCurveRenderer();
VariableType variableType = getPdeDataContext().getDataIdentifier().getVariableType();
if (variableType.equals(VariableType.POSTPROCESSING) || variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
return true;
}
if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
CurveSelectionInfo[] closeCSI = curveR.getCloseCurveSelectionInfos(wc);
if (closeCSI != null && closeCSI.length > 0) {
for (int i = 0; i < closeCSI.length; i += 1) {
if (tool == CurveEditorTool.TOOL_POINT && addedToThisCurve instanceof SinglePoint && membranesAndIndexes != null && membranesAndIndexes.containsKey(closeCSI[i].getCurve())) {
return true;
} else if (tool == CurveEditorTool.TOOL_LINE && addedToThisCurve instanceof CurveSelectionCurve) {
Curve sourceCurve = ((CurveSelectionCurve) (addedToThisCurve)).getSourceCurveSelectionInfo().getCurve();
if (sourceCurve == closeCSI[i].getCurve()) {
if (membranesAndIndexes != null && membranesAndIndexes.containsKey(sourceCurve)) {
return true;
}
}
}
}
}
}
return false;
}
use of cbit.vcell.geometry.SinglePoint in project vcell by virtualcell.
the class CurveEditorTool method mousePressed.
/**
* This method was created in VisualAge.
* @param event MouseEvent
*/
public void mousePressed(MouseEvent event) {
if (!getProperlyConfigured()) {
return;
}
if ((event.getModifiers() & event.BUTTON3_MASK) != 0) {
setTool(TOOL_SELECT);
return;
}
if (getTool() == TOOL_ADDCP) {
if (getCurveRenderer().getSelection() != null && getCurveRenderer().getSelection().getCurve() instanceof ControlPointCurve && ((ControlPointCurve) getCurveRenderer().getSelection().getCurve()).isControlPointAddable()) {
((ControlPointCurve) (getCurveRenderer().getSelection().getCurve())).insertControlPoint(getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint())), getCurveRenderer().getSelection().getControlPoint());
}
getVcellDrawable().repaint();
} else if (getTool() == TOOL_LINE || getTool() == TOOL_SPLINE || getTool() == TOOL_POINT) {
CurveSelectionInfo selectedCSI = getCurveRenderer().getSelection();
if (selectedCSI == null || getTool() == TOOL_POINT) {
boolean wasFromCVP = false;
if (getCurveValueProvider() != null && getCurveValueProvider().providesInitalCurve(getTool(), getWorldCoordinateValue(event.getPoint()))) {
// Returns null if curve shouldn't be started at this point
selectedCSI = getCurveValueProvider().getInitalCurveSelection(getTool(), getWorldCoordinateValue(event.getPoint()));
wasFromCVP = true;
} else if (getTool() == TOOL_LINE) {
selectedCSI = new CurveSelectionInfo(new PolyLine());
} else if (getTool() == TOOL_SPLINE) {
selectedCSI = new CurveSelectionInfo(new Spline());
} else if (getTool() == TOOL_POINT) {
selectedCSI = new CurveSelectionInfo(new SinglePoint());
}
if (selectedCSI != null) {
if (getCurveValueProvider() != null) {
getCurveValueProvider().setDescription(selectedCSI.getCurve());
}
getCurveRenderer().addCurve(selectedCSI.getCurve());
getCurveRenderer().renderPropertySubSelectionType(selectedCSI.getCurve(), CurveRenderer.SUBSELECTION_CONTROL_POINT);
getCurveRenderer().renderPropertyEditable(selectedCSI.getCurve(), (!wasFromCVP ? true : false));
}
}
//
if (selectedCSI != null && selectedCSI.getCurve() instanceof ControlPointCurve && (getCurveValueProvider() == null || !getCurveValueProvider().providesInitalCurve(getTool(), getWorldCoordinateValue(event.getPoint())) || getCurveValueProvider().isAddControlPointOK(getTool(), getWorldCoordinateValue(event.getPoint()), selectedCSI.getCurve()))) {
if ((!(selectedCSI.getCurve() instanceof CurveSelectionCurve)) && getCurveValueProvider().isAddControlPointOK(getTool(), getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint())), selectedCSI.getCurve())) {
((ControlPointCurve) (selectedCSI.getCurve())).appendControlPoint(getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint())));
} else if (getCurveValueProvider().isAddControlPointOK(getTool(), getWorldCoordinateValue(event.getPoint()), selectedCSI.getCurve())) {
try {
if (selectedCSI.getCurve() instanceof CurveSelectionCurve) {
ControlPointCurve targetCurve = (ControlPointCurve) (((CurveSelectionCurve) selectedCSI.getCurve()).getSourceCurveSelectionInfo().getCurve());
double dist = targetCurve.getDistanceTo(getWorldCoordinateValue(event.getPoint()));
int segmentIndex = targetCurve.pickSegment(getWorldCoordinateValue(event.getPoint()), dist * 1.1);
Coordinate[] coordArr = targetCurve.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);
((ControlPointCurve) (selectedCSI.getCurve())).appendControlPoint(getWorldCoordinateCalculator().snapWorldCoordinateFace(middleCoord));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (selectedCSI != null && !selectedCSI.getCurve().isValid()) {
int subSel = getCurveRenderer().getRenderPropertySubSelectionType(selectedCSI.getCurve());
boolean bEdit = getCurveRenderer().getRenderPropertyEditable(selectedCSI.getCurve());
getCurveRenderer().setSelection(null);
getCurveRenderer().addCurve(selectedCSI.getCurve());
getCurveRenderer().renderPropertyEditable(selectedCSI.getCurve(), bEdit);
getCurveRenderer().renderPropertySubSelectionType(selectedCSI.getCurve(), subSel);
}
getCurveRenderer().setSelection(selectedCSI);
if (getCurveValueProvider() != null && selectedCSI != null && selectedCSI.getCurve().isValid()) {
getCurveValueProvider().curveAdded(selectedCSI.getCurve());
}
getVcellDrawable().repaint();
} else if (getTool() == TOOL_SELECT) {
CurveSelectionInfo invalidCSI = null;
if (getCurveRenderer().getSelection() != null && !getCurveRenderer().getSelection().getCurve().isValid()) {
invalidCSI = getCurveRenderer().getSelection();
}
//
lastSnappedWorldCoord = getWorldCoordinateCalculator().snapWorldCoordinate(getWorldCoordinateValue(event.getPoint()));
CurveSelectionInfo csi = getCurveRenderer().pick(getWorldCoordinateValue(event.getPoint()));
if (csi != null && getCurveRenderer().getRenderPropertySelectable(csi.getCurve())) {
getCurveRenderer().setSelection(csi);
} else {
getCurveRenderer().selectNothing();
}
//
if (getCurveValueProvider() != null) {
if (invalidCSI != null) {
getCurveValueProvider().curveRemoved(invalidCSI.getCurve());
} else {
getCurveValueProvider().curveAdded(null);
}
}
//
getVcellDrawable().repaint();
}
//
}
Aggregations