Search in sources :

Example 1 with GeometrySelectionInfo

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;
}
Also used : VCDocument(org.vcell.util.document.VCDocument) GeometrySelectionInfo(cbit.vcell.client.DocumentWindowManager.GeometrySelectionInfo)

Example 2 with 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);
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) UserCancelException(org.vcell.util.UserCancelException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) Component(java.awt.Component) Vector(java.util.Vector) GeometrySelectionInfo(cbit.vcell.client.DocumentWindowManager.GeometrySelectionInfo)

Aggregations

GeometrySelectionInfo (cbit.vcell.client.DocumentWindowManager.GeometrySelectionInfo)2 VCDocument (org.vcell.util.document.VCDocument)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 Component (java.awt.Component)1 Hashtable (java.util.Hashtable)1 Vector (java.util.Vector)1 DataAccessException (org.vcell.util.DataAccessException)1 UserCancelException (org.vcell.util.UserCancelException)1