use of cbit.vcell.client.DocumentWindowManager.GeometrySelectionInfo in project vcell by virtualcell.
the class TopLevelWindowManager method selectGeometry.
GeometrySelectionInfo selectGeometry(boolean bShowCurrentGeomChoice, String dialogText) throws Exception, UserCancelException {
final int ANALYTIC_1D = 0;
final int ANALYTIC_2D = 1;
final int ANALYTIC_3D = 2;
final int IMAGE_FILE = 3;
final int MESH_FILE = 4;
final int FROM_SCRATCH = 5;
final int CSGEOMETRY_3D = 6;
final int FIJI_IMAGEJ = 7;
final int BLENDER_SURF = 8;
int[] geomType = null;
String[][] choices = new String[][] { { "Analytic Equations (1D)" }, { "Analytic Equations (2D)" }, { "Analytic Equations (3D)" }, { "Image based (import from file, zip or directory)" }, { "Mesh based (import from STL file)" }, { "New Blank Image Canvas" }, { "Constructed Solid Geometry (3D)" }, { "Import from Fiji/Imagej" }, { "Import from Blender" } };
geomType = DialogUtils.showComponentOKCancelTableList(getComponent(), dialogText, new String[] { "Geometry Type" }, choices, ListSelectionModel.SINGLE_SELECTION);
VCDocument.DocumentCreationInfo documentCreationInfo = null;
if (geomType[0] == ANALYTIC_1D) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_1D);
} else if (geomType[0] == ANALYTIC_2D) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_2D);
} else if (geomType[0] == ANALYTIC_3D) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_3D);
} else if (geomType[0] == IMAGE_FILE || geomType[0] == MESH_FILE) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FILE);
} else if (geomType[0] == FROM_SCRATCH) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FROM_SCRATCH);
} else if (geomType[0] == CSGEOMETRY_3D) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_CSGEOMETRY_3D);
} else if (geomType[0] == FIJI_IMAGEJ) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FIJI_IMAGEJ);
} else if (geomType[0] == BLENDER_SURF) {
documentCreationInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_BLENDER);
} else {
throw new IllegalArgumentException("Error selecting geometry, Unknown Geometry type " + geomType[0]);
}
DocumentWindowManager.GeometrySelectionInfo geometrySelectionInfo = null;
if (documentCreationInfo != null) {
geometrySelectionInfo = new DocumentWindowManager.GeometrySelectionInfo(documentCreationInfo);
}
return geometrySelectionInfo;
}
use of cbit.vcell.client.DocumentWindowManager.GeometrySelectionInfo in project vcell by virtualcell.
the class TopLevelWindowManager method createGeometry.
void createGeometry(final Geometry currentGeometry, final AsynchClientTask[] afterTasks, String selectDialogTitle, final String applyGeometryButtonText, DocumentWindowManager.GeometrySelectionInfo preSelect) {
boolean bCancellable = false;
try {
final Hashtable<String, Object> hash = new Hashtable<String, Object>();
Vector<AsynchClientTask> createGeomTaskV = new Vector<AsynchClientTask>();
final DocumentWindowManager.GeometrySelectionInfo geometrySelectionInfo = (preSelect == null ? selectGeometry(currentGeometry != null && currentGeometry.getDimension() > 0, selectDialogTitle) : preSelect);
hash.put(B_SHOW_OLD_GEOM_EDITOR, false);
if (geometrySelectionInfo.getDocumentCreationInfo() != null) {
if (ClientRequestManager.isImportGeometryType(geometrySelectionInfo.getDocumentCreationInfo())) {
bCancellable = geometrySelectionInfo.getDocumentCreationInfo().getOption() == VCDocument.GEOM_OPTION_FIJI_IMAGEJ || geometrySelectionInfo.getDocumentCreationInfo().getOption() == VCDocument.GEOM_OPTION_BLENDER;
// Create imported Geometry
createGeomTaskV.addAll(Arrays.asList(((ClientRequestManager) getRequestManager()).createNewGeometryTasks(this, geometrySelectionInfo.getDocumentCreationInfo(), afterTasks, applyGeometryButtonText)));
} else {
// Create Analytic Geometry
hash.put(B_SHOW_OLD_GEOM_EDITOR, true);
createGeomTaskV.addAll(Arrays.asList(((ClientRequestManager) getRequestManager()).createNewDocument(this, geometrySelectionInfo.getDocumentCreationInfo())));
createGeomTaskV.addAll(Arrays.asList(afterTasks));
}
hash.put("guiParent", (Component) getComponent());
hash.put("requestManager", getRequestManager());
} else {
// Copy from WorkSpace
createGeomTaskV.add(new AsynchClientTask("loading Geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
final Vector<AsynchClientTask> runtimeTasksV = new Vector<AsynchClientTask>();
VCDocument.DocumentCreationInfo workspaceDocCreateInfo = null;
if (currentGeometry.getGeometrySpec().getNumAnalyticOrCSGSubVolumes() > 0 && currentGeometry.getGeometrySpec().getImage() == null) {
workspaceDocCreateInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FROM_WORKSPACE_ANALYTIC);
} else if (currentGeometry.getGeometrySpec().getImage() != null && currentGeometry.getGeometrySpec().getNumAnalyticOrCSGSubVolumes() == 0) {
workspaceDocCreateInfo = new VCDocument.DocumentCreationInfo(VCDocumentType.GEOMETRY_DOC, VCDocument.GEOM_OPTION_FROM_WORKSPACE_IMAGE);
} else {
throw new Exception("Unexpected image configuration for workspace geometry.");
}
runtimeTasksV.addAll(Arrays.asList(((ClientRequestManager) getRequestManager()).createNewGeometryTasks(TopLevelWindowManager.this, workspaceDocCreateInfo, afterTasks, applyGeometryButtonText)));
hashTable.put("guiParent", (Component) getComponent());
hashTable.put("requestManager", getRequestManager());
hashTable.put(ClientRequestManager.GEOM_FROM_WORKSPACE, currentGeometry);
new Thread(new Runnable() {
public void run() {
ClientTaskDispatcher.dispatch(getComponent(), hash, runtimeTasksV.toArray(new AsynchClientTask[0]), false, false, null, true);
}
}).start();
}
});
}
ClientTaskDispatcher.dispatch(getComponent(), hash, createGeomTaskV.toArray(new AsynchClientTask[0]), false, bCancellable, null, true);
} catch (UserCancelException e1) {
return;
} catch (Exception e1) {
e1.printStackTrace();
DialogUtils.showErrorDialog(getComponent(), e1.getMessage(), e1);
}
}
Aggregations