Search in sources :

Example 21 with Vect3d

use of cbit.vcell.render.Vect3d in project vcell by virtualcell.

the class CSGObjectTreeCellEditor method getTreeCellEditorComponent.

@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
    if (!(value instanceof BioModelNode)) {
        return null;
    }
    Object userObject = ((BioModelNode) value).getUserObject();
    CSGObjectTreeCellRenderer.CSGNodeLabel csgNodeLabel = new CSGObjectTreeCellRenderer.CSGNodeLabel();
    CSGObjectTreeCellRenderer.getCSGNodeLabel(userObject, csgNodeLabel);
    renderer.setOpenIcon(csgNodeLabel.icon);
    renderer.setClosedIcon(csgNodeLabel.icon);
    renderer.setLeafIcon(csgNodeLabel.icon);
    Component component = null;
    if (bRenaming) {
        realEditor = defaultCellEditor;
        component = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
        if (editingComponent instanceof JTextField) {
            String text = null;
            JTextField textField = (JTextField) editingComponent;
            if (userObject instanceof CSGObject) {
                text = ((CSGObject) userObject).getName();
            } else if (userObject instanceof CSGNode) {
                text = ((CSGNode) userObject).getName();
            }
            textField.setText(text);
        }
    } else {
        if (userObject instanceof CSGScale || userObject instanceof CSGTranslation) {
            realEditor = getVect3dCellEditor();
            Vect3d vect3d = null;
            if (userObject instanceof CSGScale) {
                vect3d = ((CSGScale) userObject).getScale();
            } else if (userObject instanceof CSGTranslation) {
                vect3d = ((CSGTranslation) userObject).getTranslation();
            }
            component = super.getTreeCellEditorComponent(tree, vect3d, isSelected, expanded, leaf, row);
        } else if (userObject instanceof CSGRotation) {
            realEditor = getRotationCellEditor();
            component = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
        }
    }
    return component;
}
Also used : CSGTranslation(cbit.vcell.geometry.CSGTranslation) CSGNode(cbit.vcell.geometry.CSGNode) BioModelNode(cbit.vcell.desktop.BioModelNode) JTextField(javax.swing.JTextField) CSGRotation(cbit.vcell.geometry.CSGRotation) CSGScale(cbit.vcell.geometry.CSGScale) Vect3d(cbit.vcell.render.Vect3d) CSGObject(cbit.vcell.geometry.CSGObject) Component(java.awt.Component) CSGObject(cbit.vcell.geometry.CSGObject)

Example 22 with Vect3d

use of cbit.vcell.render.Vect3d in project vcell by virtualcell.

the class RegionImage method verifyQuadVertexOrdering.

public void verifyQuadVertexOrdering(double maxAngleDegrees) {
    if (maxAngleDegrees > 180 || maxAngleDegrees < 0) {
        throw new IllegalArgumentException("maxAngleDegrees must be between 0 and 180");
    }
    for (int s = 0; s < surfaceCollection.getSurfaceCount(); s++) {
        Surface surface = surfaceCollection.getSurfaces(s);
        for (int p = 0; p < surface.getPolygonCount(); p++) {
            Quadrilateral quad = (Quadrilateral) surface.getPolygons(p);
            // average the polygon vertices to get the center of the quad
            // this is also halfway between the coordinates of the inside and outside volume elements.
            cbit.vcell.geometry.surface.Node[] nodes = quad.getNodes();
            // have normal go in direction from low region index to high region index
            int lowVolumeIndex = quad.getVolIndexNeighbor1();
            int hiVolumeIndex = quad.getVolIndexNeighbor2();
            int lowRegionIndex = getRegionInfoFromOffset(quad.getVolIndexNeighbor1()).getRegionIndex();
            int hiRegionIndex = getRegionInfoFromOffset(quad.getVolIndexNeighbor2()).getRegionIndex();
            if (lowRegionIndex > hiRegionIndex) {
                int temp = lowVolumeIndex;
                lowVolumeIndex = hiVolumeIndex;
                hiVolumeIndex = temp;
                temp = lowRegionIndex;
                lowRegionIndex = hiRegionIndex;
                hiRegionIndex = temp;
            }
            if (surface.getInteriorRegionIndex() != lowRegionIndex || surface.getExteriorRegionIndex() != hiRegionIndex) {
                StringBuffer buffer = new StringBuffer();
                buffer.append("Surface interiorRegionIndex=" + surface.getInteriorRegionIndex() + " and exteriorRegionIndex=" + surface.getExteriorRegionIndex());
                buffer.append("Polygon lowRegionIndex=" + lowRegionIndex + ", hiRegionIndex=" + hiRegionIndex);
                throw new RuntimeException("surface and polygon indices don't agree\n" + buffer.toString());
            }
            Vect3d v0 = new Vect3d(nodes[0].getX(), nodes[0].getY(), nodes[0].getZ());
            Vect3d v1 = new Vect3d(nodes[1].getX(), nodes[1].getY(), nodes[1].getZ());
            Vect3d v2 = new Vect3d(nodes[2].getX(), nodes[2].getY(), nodes[2].getZ());
            Vect3d v3 = new Vect3d(nodes[3].getX(), nodes[3].getY(), nodes[3].getZ());
            int volumeIndexNormalDiff = hiVolumeIndex - lowVolumeIndex;
            Vect3d v01 = Vect3d.sub(v1, v0);
            Vect3d v02 = Vect3d.sub(v2, v0);
            Vect3d unit012 = v01.cross(v02);
            unit012.unit();
            Vect3d v03 = Vect3d.sub(v3, v0);
            Vect3d unit023 = v02.cross(v03);
            unit023.unit();
            Vect3d gridNormal = null;
            if (volumeIndexNormalDiff == 1) {
                // y-z plane, normal is [1 0 0]
                gridNormal = new Vect3d(1, 0, 0);
            } else if (volumeIndexNormalDiff == -1) {
                // y-z plane, normal is [-1 0 0]
                gridNormal = new Vect3d(-1, 0, 0);
            } else if (volumeIndexNormalDiff == getNumX()) {
                // y-z plane, normal is [0 1 0]
                gridNormal = new Vect3d(0, 1, 0);
            } else if (volumeIndexNormalDiff == -getNumX()) {
                // y-z plane, normal is [0 -1 0]
                gridNormal = new Vect3d(0, -1, 0);
            } else if (volumeIndexNormalDiff == getNumX() * getNumY()) {
                // y-z plane, normal is [0 0 1]
                gridNormal = new Vect3d(0, 0, 1);
            } else if (volumeIndexNormalDiff == -getNumX() * getNumY()) {
                // y-z plane, normal is [0 0 -1]
                gridNormal = new Vect3d(0, 0, -1);
            }
            if (this.filterCutoffFrequency < NO_SMOOTHING) {
                // after smoothing ... should point in general direction (<90 degrees).
                if (unit012.dot(unit023) < Math.cos(maxAngleDegrees / 180.0 * Math.PI)) {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("normal_012 = [" + unit012.getX() + " " + unit012.getY() + " " + unit012.getZ() + "]\n");
                    buffer.append("normal_023 = [" + unit023.getX() + " " + unit023.getY() + " " + unit023.getZ() + "]\n");
                    buffer.append("gridNormal = [" + gridNormal.getX() + " " + gridNormal.getY() + " " + gridNormal.getZ() + "]\n");
                    throw new RuntimeException("quad(" + p + ") on surface(" + s + "): two triangles from same quad (norm1.dot(norm2)=" + unit012.dot(unit023) + ") are > " + maxAngleDegrees + " degrees or inner product < " + Math.cos(maxAngleDegrees / 180.0 * Math.PI) + ":\n" + buffer.toString());
                } else if (unit012.dot(gridNormal) < Math.cos(maxAngleDegrees / 180.0 * Math.PI)) {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("normal_012 = [" + unit012.getX() + " " + unit012.getY() + " " + unit012.getZ() + "]\n");
                    buffer.append("normal_023 = [" + unit023.getX() + " " + unit023.getY() + " " + unit023.getZ() + "]\n");
                    buffer.append("gridNormal = [" + gridNormal.getX() + " " + gridNormal.getY() + " " + gridNormal.getZ() + "]\n");
                    throw new RuntimeException("quad(" + p + ") on surface(" + s + "): quad normal compared with grid normal (norm.dot(gridNormal)=" + unit012.dot(unit023) + ") is > " + maxAngleDegrees + " degrees or inner product < " + Math.cos(maxAngleDegrees / 180.0 * Math.PI) + " from orginal staircase:\n" + buffer.toString());
                } else {
                // System.out.println("normals ok");
                }
            } else {
                // no smoothing ... both triangle normals must light up exactly
                if (Math.abs(unit012.dot(unit023) - 1.0) > 1e-8) {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("two triangles contradicted themselves\n");
                    buffer.append("normal_012 = [" + unit012.getX() + " " + unit012.getY() + " " + unit012.getZ() + "]\n");
                    buffer.append("normal_023 = [" + unit023.getX() + " " + unit023.getY() + " " + unit023.getZ() + "]\n");
                    buffer.append("gridNormal = [" + gridNormal.getX() + " " + gridNormal.getY() + " " + gridNormal.getZ() + "]\n");
                    throw new RuntimeException("two triangles from same quad have normals that are in opposite directions:\n" + buffer.toString());
                } else if (Math.abs(unit012.dot(gridNormal) - 1.0) > 1e-8) {
                    StringBuffer buffer = new StringBuffer();
                    buffer.append("normal_012 = [" + unit012.getX() + " " + unit012.getY() + " " + unit012.getZ() + "]\n");
                    buffer.append("normal_023 = [" + unit023.getX() + " " + unit023.getY() + " " + unit023.getZ() + "]\n");
                    buffer.append("gridNormal = [" + gridNormal.getX() + " " + gridNormal.getY() + " " + gridNormal.getZ() + "]\n");
                    throw new RuntimeException("triangles contradict grid normal:\n" + buffer.toString());
                } else {
                // System.out.println("normals ok");
                }
            }
        }
    }
}
Also used : Quadrilateral(cbit.vcell.geometry.surface.Quadrilateral) Node(cbit.util.graph.Node) OrigSurface(cbit.vcell.geometry.surface.OrigSurface) Surface(cbit.vcell.geometry.surface.Surface) Vect3d(cbit.vcell.render.Vect3d)

Example 23 with Vect3d

use of cbit.vcell.render.Vect3d in project vcell by virtualcell.

the class ROIMultiPaintManager method showGUI.

public Geometry showGUI(final String okButtonText, final String sourceDataName, final Component parentComponent, String initalAnnotation, final VCPixelClass[] vcPixelClasses, UserPreferences userPreferences, boolean bFieldData) {
    originalAnnotation = initalAnnotation;
    final Geometry[] finalGeometryHolder = new Geometry[1];
    if (overlayEditorPanelJAI == null) {
        overlayEditorPanelJAI = new OverlayEditorPanelJAI();
        overlayEditorPanelJAI.setCalcCoords(new CalcCoords());
        overlayEditorPanelJAI.setUserPreferences(userPreferences);
        overlayEditorPanelJAI.setMinimumSize(new Dimension(700, 600));
        overlayEditorPanelJAI.setPreferredSize(new Dimension(700, 600));
        overlayEditorPanelJAI.addPropertyChangeListener(ROIMultiPaintManager.this);
    }
    // delete all names
    overlayEditorPanelJAI.deleteROIName(null);
    // when user selects image "from DB" or "from current geometry"
    applyPixelClasses(vcPixelClasses, parentComponent);
    if (getImageDataset().length > 1) {
        String[] channelNames = new String[getImageDataset().length];
        for (int i = 0; i < channelNames.length; i++) {
            channelNames[i] = "channel " + i;
        }
        overlayEditorPanelJAI.setChannelNames(channelNames);
    } else {
        overlayEditorPanelJAI.setChannelNames(null);
    }
    updateUnderlayHistogramDisplay();
    overlayEditorPanelJAI.setContrastToMinMax();
    overlayEditorPanelJAI.setAllROICompositeImage(roiComposite, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
    final JDialog jDialog = new JDialog(JOptionPane.getFrameForComponent(parentComponent));
    jDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    jDialog.setTitle("Geometry Editor (" + sourceDataName + ")");
    jDialog.setModal(true);
    final JButton cancelJButton = new JButton("Cancel");
    cancelJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final String QUIT_ANSWER = "Quit Geometry Editor";
            String result = DialogUtils.showWarningDialog(jDialog, "Confirm cancel", "Quit geometry editor and lose all changes?", new String[] { QUIT_ANSWER, "back" }, QUIT_ANSWER);
            if (result != null && result.equals(QUIT_ANSWER)) {
                jDialog.dispose();
            }
        }
    });
    jDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent e) {
            super.windowOpened(e);
            if (bHasOriginalData) {
                calculateHistogram();
            }
            updateUndoAfter(false);
            if (vcPixelClasses == null) {
                askInitialize(false);
            }
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // TODO Auto-generated method stub
            super.windowClosing(e);
            cancelJButton.doClick();
        }
    });
    final JPanel okCancelJPanel = new JPanel(new FlowLayout());
    JButton okJButton = new JButton(okButtonText);
    okJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                VCImage finalImage = checkAll();
                finalImage.setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
                finalGeometryHolder[0] = new Geometry((String) null, finalImage);
                finalGeometryHolder[0].getGeometrySpec().setOrigin((editedGeometryAttributes != null ? editedGeometryAttributes.origin : originalOrigin));
                finalGeometryHolder[0].getGeometrySpec().setExtent((editedGeometryAttributes != null ? editedGeometryAttributes.extent : originalExtent));
                finalGeometryHolder[0].setDescription((editedGeometryAttributes != null ? editedGeometryAttributes.annotation : originalAnnotation));
                jDialog.dispose();
            } catch (UserCancelException uce) {
            } catch (Exception exc) {
                DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Error validating compartments.\n" + exc.getMessage(), exc);
            }
        }
    });
    JButton attributesJButton = new JButton("Attributes...");
    attributesJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                editedGeometryAttributes = showEditGeometryAttributes(jDialog, editedGeometryAttributes);
            } catch (UserCancelException uce) {
            // ignore
            }
        }
    });
    // JButton surfaceButton = new JButton("View Surfaces...");
    // surfaceButton.addActionListener(new ActionListener() {
    // public void actionPerformed(ActionEvent e) {
    // showDataValueSurfaceViewer(geomAttr);
    // }
    // });
    JButton fieldDataJButton = null;
    if (bFieldData) {
        fieldDataJButton = new JButton("FieldData...");
        fieldDataJButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Component c = overlayEditorPanelJAI;
                    do {
                        System.out.println(c.getClass().getName());
                        if (c instanceof DocumentWindow) {
                            // BeanUtils.printComponentInfo((Container)c);
                            ArrayList<Component> comps = new ArrayList<Component>();
                            BeanUtils.findComponent((Container) c, InitialConditionsPanel.class, comps);
                            InitialConditionsPanel initialConditionsPanel = (InitialConditionsPanel) comps.get(0);
                            SpeciesContextSpec[] speciesContextSpecs = initialConditionsPanel.getInitConditionVars();
                            Object[][] objs = new Object[speciesContextSpecs.length][1];
                            for (int i = 0; i < speciesContextSpecs.length; i++) {
                                if (speciesContextSpecs[i].getSimulationContext() == initialConditionsPanel.getSimulationContext()) {
                                    objs[i][0] = speciesContextSpecs[i].getSpeciesContext().getName();
                                }
                            }
                            int[] select = DialogUtils.showComponentOKCancelTableList(overlayEditorPanelJAI, "Select species to add InitialCondition Field Data, App:'" + initialConditionsPanel.getSimulationContext().getName() + "'", new String[] { "speciesContext" }, objs, ListSelectionModel.SINGLE_SELECTION);
                            if (select != null && select.length > 0) {
                                // try {
                                String scName = speciesContextSpecs[select[0]].getSpeciesContext().getName();
                                Origin orig = (editedGeometryAttributes != null ? editedGeometryAttributes.origin : originalOrigin);
                                Extent extent = (editedGeometryAttributes != null ? editedGeometryAttributes.extent : originalExtent);
                                String fieldDataName = null;
                                boolean bDone = false;
                                do {
                                    try {
                                        fieldDataName = DialogUtils.showInputDialog0(ROIMultiPaintManager.this.overlayEditorPanelJAI, "Enter FieldData name", (fieldDataName == null ? ROIMultiPaintManager.this.importSourceName : fieldDataName));
                                        createFD(false, fieldDataName, ROIMultiPaintManager.this.importSourceName, extent, orig, new String[] { scName }, new double[] { 0.0 }, initImageDataSetChannels[0].getISize());
                                        bDone = true;
                                    } catch (UtilCancelException uce) {
                                        return;
                                    } catch (Exception e1) {
                                        e1.printStackTrace();
                                        if (e1.getMessage().toUpperCase().contains("ORA-00001")) {
                                            DialogUtils.showWarningDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, fieldDataName + " already used, enter a different name");
                                            continue;
                                        }
                                        throw e1;
                                    }
                                } while (!bDone);
                                initialConditionsPanel.setGeneratedFieldData(scName, "vcField('" + fieldDataName + "','" + scName + "',0.0,'Volume')");
                            // if(true) {
                            // return;
                            // }
                            // ISize iSize = initImageDataSetChannels[0].getISize();
                            // Extent extent = initImageDataSetChannels[0].getExtent();
                            // Origin orig = (editedGeometryAttributes!=null?editedGeometryAttributes.origin:originalOrigin);
                            // Extent extent = (editedGeometryAttributes!=null?editedGeometryAttributes.extent:originalExtent);
                            // createFD(false, fieldDataName, ROIMultiPaintManager.this.importSourceName, extent, orig, new String[] {scName}, new double[] {0.0},initImageDataSetChannels[0].getISize());
                            // export();
                            // ORA-00001
                            // } catch (Exception e1) {
                            // if(e1 instanceof UserCancelException) {
                            // return;
                            // }
                            // e1.printStackTrace();
                            // DialogUtils.showErrorDialog(overlayEditorPanelJAI, e1.getMessage());
                            // }
                            }
                        }
                    } while ((c = c.getParent()) != null);
                } catch (Exception e2) {
                    e2.printStackTrace();
                    if (e2 instanceof UserCancelException || e2 instanceof UtilCancelException) {
                        return;
                    }
                    DialogUtils.showErrorDialog(ROIMultiPaintManager.this.overlayEditorPanelJAI, e2.getMessage());
                }
            }
        });
    }
    JButton exportJButton = new JButton("Export...");
    exportJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            export();
        }
    });
    JButton importJButton = new JButton("Import stl...");
    importJButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser importJFC = new JFileChooser(ClientRequestManager.getPreferredPath(UserPreferences.getLastUserPreferences()));
            importJFC.setDialogTitle("Choose .stl file(s) to import");
            importJFC.setMultiSelectionEnabled(true);
            int result = importJFC.showOpenDialog(overlayEditorPanelJAI);
            if (result == JFileChooser.APPROVE_OPTION) {
                File[] selectedFiles = importJFC.getSelectedFiles();
                if (selectedFiles != null && selectedFiles.length > 0) {
                    ClientRequestManager.setPreferredPath(UserPreferences.getLastUserPreferences(), selectedFiles[0]);
                    Vect3d sampleSize = new Vect3d(getImageDataset()[0].getISize().getX(), getImageDataset()[0].getISize().getY(), getImageDataset()[0].getISize().getZ());
                    ArrayList<AsynchClientTask> stlImportTasks = getImportSTLtasks(selectedFiles, sampleSize, new Vect3d(0, 0, 0));
                    ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<>(), stlImportTasks.toArray(new AsynchClientTask[0]));
                } else {
                    DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Select at least 1 .stl file for import.");
                }
            }
        }
    });
    okCancelJPanel.add(okJButton);
    okCancelJPanel.add(attributesJButton);
    okCancelJPanel.add(exportJButton);
    okCancelJPanel.add(importJButton);
    // okCancelJPanel.add(surfaceButton);
    if (bFieldData) {
        okCancelJPanel.add(fieldDataJButton);
    }
    this.overlayEditorPanelJAI.translateToolButton.setVisible(bFieldData);
    this.overlayEditorPanelJAI.scaleToolButton.setVisible(bFieldData);
    okCancelJPanel.add(cancelJButton);
    jDialog.getContentPane().add(overlayEditorPanelJAI, BorderLayout.CENTER);
    jDialog.getContentPane().add(okCancelJPanel, BorderLayout.SOUTH);
    jDialog.setSize(700, 600);
    DialogUtils.showModalJDialogOnTop(jDialog, parentComponent);
    if (finalGeometryHolder[0] == null) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    return finalGeometryHolder[0];
}
Also used : Origin(org.vcell.util.Origin) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) Extent(org.vcell.util.Extent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) ArrayList(java.util.ArrayList) WindowAdapter(java.awt.event.WindowAdapter) VCImage(cbit.image.VCImage) Container(java.awt.Container) InitialConditionsPanel(cbit.vcell.mapping.gui.InitialConditionsPanel) Component(java.awt.Component) UtilCancelException(org.vcell.util.UtilCancelException) Hashtable(java.util.Hashtable) Dimension(java.awt.Dimension) Point(java.awt.Point) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException) Vect3d(cbit.vcell.render.Vect3d) Geometry(cbit.vcell.geometry.Geometry) DocumentWindow(cbit.vcell.client.desktop.DocumentWindow) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) WindowEvent(java.awt.event.WindowEvent) JDialog(javax.swing.JDialog)

Example 24 with Vect3d

use of cbit.vcell.render.Vect3d in project vcell by virtualcell.

the class SurfaceCanvas method setDisplacement.

/**
 * Insert the method's description here.
 * Creation date: (10/5/2005 12:15:25 PM)
 * @param newDisplacement cbit.vcell.render.Vect3d
 */
public void setDisplacement(cbit.vcell.render.Vect3d newDisplacement) {
    Vect3d oldDisplacement = displacement;
    displacement = newDisplacement;
    firePropertyChange("displacement", oldDisplacement, displacement);
    invalidate();
// repaint();
}
Also used : Vect3d(cbit.vcell.render.Vect3d)

Example 25 with Vect3d

use of cbit.vcell.render.Vect3d in project vcell by virtualcell.

the class CSGObjectTreeCellRenderer method getCSGNodeLabel.

static CSGNodeLabel getCSGNodeLabel(Object object, CSGNodeLabel csgNodeLabel) {
    if (object instanceof CSGObject) {
        CSGObject csgObject = (CSGObject) object;
        csgNodeLabel.text = csgObject.getName();
        java.awt.Color handleColor = new java.awt.Color(getColorMap()[csgObject.getHandle()]);
        csgNodeLabel.icon = new ColorIcon(15, 15, handleColor);
    } else if (object instanceof CSGNode) {
        CSGNode csgNode = (CSGNode) object;
        csgNodeLabel.text = csgNode.getName();
        if (csgNode instanceof CSGPrimitive) {
            CSGPrimitive csgPrimitive = (CSGPrimitive) csgNode;
            switch(csgPrimitive.getType()) {
                case CONE:
                    csgNodeLabel.icon = VCellIcons.csgConeIcon;
                    break;
                case CUBE:
                    csgNodeLabel.icon = VCellIcons.csgCubeIcon;
                    break;
                case CYLINDER:
                    csgNodeLabel.icon = VCellIcons.csgCylinderIcon;
                    break;
                case SPHERE:
                    csgNodeLabel.icon = VCellIcons.csgSphereIcon;
                    break;
            }
            return csgNodeLabel;
        }
        if (csgNode instanceof CSGSetOperator) {
            CSGSetOperator csgSetOperator = (CSGSetOperator) csgNode;
            switch(csgSetOperator.getOpType()) {
                case DIFFERENCE:
                    csgNodeLabel.icon = VCellIcons.csgSetDifferenceIcon;
                    break;
                case INTERSECTION:
                    csgNodeLabel.icon = VCellIcons.csgSetIntersectionIcon;
                    break;
                case UNION:
                    csgNodeLabel.icon = VCellIcons.csgSetUnionIcon;
                    break;
            }
        }
        if (csgNode instanceof CSGTransformation) {
            if (csgNode instanceof CSGRotation) {
                CSGRotation csgRotation = (CSGRotation) csgNode;
                Vect3d axis = csgRotation.getAxis();
                double radius = csgRotation.getRotationRadians();
                csgNodeLabel.text += ", radian=" + radius + ", axis=" + CSGObjectPropertiesPanel.getVect3dDescription(axis);
                csgNodeLabel.icon = VCellIcons.csgRotationIcon;
            } else if (csgNode instanceof CSGTranslation) {
                CSGTranslation csgTranslation = (CSGTranslation) csgNode;
                Vect3d translation = csgTranslation.getTranslation();
                csgNodeLabel.text += ", Translation=" + CSGObjectPropertiesPanel.getVect3dDescription(translation);
                csgNodeLabel.icon = VCellIcons.csgTranslationIcon;
            } else if (csgNode instanceof CSGScale) {
                CSGScale csgScale = (CSGScale) csgNode;
                Vect3d scale = csgScale.getScale();
                csgNodeLabel.text += ", Scale=" + CSGObjectPropertiesPanel.getVect3dDescription(scale);
                csgNodeLabel.icon = VCellIcons.csgScaleIcon;
            } else if (csgNode instanceof CSGHomogeneousTransformation) {
                csgNodeLabel.icon = null;
            }
        }
    }
    return null;
}
Also used : ColorIcon(org.vcell.util.gui.ColorIcon) CSGTranslation(cbit.vcell.geometry.CSGTranslation) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGNode(cbit.vcell.geometry.CSGNode) CSGRotation(cbit.vcell.geometry.CSGRotation) Vect3d(cbit.vcell.render.Vect3d) CSGScale(cbit.vcell.geometry.CSGScale) CSGHomogeneousTransformation(cbit.vcell.geometry.CSGHomogeneousTransformation) CSGObject(cbit.vcell.geometry.CSGObject) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

Aggregations

Vect3d (cbit.vcell.render.Vect3d)31 CSGObject (cbit.vcell.geometry.CSGObject)7 ArrayList (java.util.ArrayList)7 CSGNode (cbit.vcell.geometry.CSGNode)5 CSGScale (cbit.vcell.geometry.CSGScale)5 CSGTranslation (cbit.vcell.geometry.CSGTranslation)5 Geometry (cbit.vcell.geometry.Geometry)5 Polygon (cbit.vcell.geometry.surface.Polygon)5 VCImage (cbit.image.VCImage)4 CSGRotation (cbit.vcell.geometry.CSGRotation)4 ImageException (cbit.image.ImageException)3 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)3 CSGPrimitive (cbit.vcell.geometry.CSGPrimitive)3 GeometrySpec (cbit.vcell.geometry.GeometrySpec)3 SubVolume (cbit.vcell.geometry.SubVolume)3 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)3 Surface (cbit.vcell.geometry.surface.Surface)3 SurfaceCollection (cbit.vcell.geometry.surface.SurfaceCollection)3 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)3 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)3