Search in sources :

Example 1 with CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class BioModelEditor method setRightBottomPanelOnSelection.

@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
    if (selections == null) {
        return;
    }
    // TODO: here
    JComponent bottomComponent = rightBottomEmptyPanel;
    JComponent annotationComponent = rightBottomEmptyAnnotationsPanel;
    // properties panel
    int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
    // annotations panel
    int annComponentIndex = DocumentEditorTabID.annotations.ordinal();
    boolean bShowInDatabaseProperties = false;
    boolean bShowPathway = false;
    if (selections.length == 1) {
        annotationComponent = getAnnotationsPanel();
        Object singleSelection = selections[0];
        if (singleSelection instanceof ReactionStep) {
            bottomComponent = getReactionPropertiesPanel();
        } else if (singleSelection instanceof ReactionRule) {
            bottomComponent = getReactionRulePropertiesPanel();
        } else if (singleSelection instanceof SpeciesContext) {
            bottomComponent = getSpeciesPropertiesPanel();
        } else if (singleSelection instanceof MolecularType) {
            bottomComponent = getMolecularTypePropertiesPanel();
        } else if (singleSelection instanceof RbmObservable) {
            bottomComponent = getObservablePropertiesPanel();
        } else if (singleSelection instanceof Structure) {
            bottomComponent = getStructurePropertiesPanel();
            getStructurePropertiesPanel().setModel(bioModel.getModel());
        } else if (singleSelection instanceof Parameter) {
            bottomComponent = getParameterPropertiesPanel();
        } else if (singleSelection instanceof SimulationContext) {
            bottomComponent = getApplicationPropertiesPanel();
        } else if (singleSelection instanceof ParameterEstimationTask) {
            bottomComponent = parameterEstimationTaskPropertiesPanel;
        } else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
            bottomComponent = getReactionParticipantPropertiesPanel();
        } else if (singleSelection instanceof BioModelNode.PublicationInfoNode) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof BioModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof MathModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = mathModelMetaDataPanel;
        } else if (singleSelection instanceof GeometryInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = geometryMetaDataPanel;
        } else if (singleSelection instanceof SpeciesContextSpec) {
            bottomComponent = getSpeciesContextSpecPanel();
        } else if (singleSelection instanceof ReactionSpec) {
            bottomComponent = getKineticsTypeTemplatePanel();
        } else if (singleSelection instanceof ReactionRuleSpec) {
            // 
            bottomComponent = getReactionRuleSpecPropertiesPanel();
        } else if (singleSelection instanceof BioModelsNetModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = getBioModelsNetPropertiesPanel();
        } else if (singleSelection instanceof Simulation) {
            bottomComponent = getSimulationSummaryPanel();
        } else if (singleSelection instanceof DataSymbol) {
            bottomComponent = getDataSymbolsSpecPanel();
        } else if (singleSelection instanceof BioEvent) {
            bottomComponent = getEventPanel();
        } else if (singleSelection instanceof SpatialObject) {
            bottomComponent = getSpatialObjectPropertyPanel();
        } else if (singleSelection instanceof SpatialProcess) {
            bottomComponent = getSpatialProcessPropertyPanel();
        } else if (singleSelection instanceof BioPaxObject) {
            bottomComponent = bioPaxObjectPropertiesPanel;
        } else if (singleSelection instanceof BioModel) {
            // only contains Notes, is displayed in the Object Properties Panel
            bottomComponent = bioModelEditorAnnotationPanel;
        } else if (singleSelection instanceof VCMetaData) {
            bottomComponent = bioModelEditorAnnotationPanel;
        } else if (singleSelection instanceof PathwayData) {
            bShowPathway = true;
            bottomComponent = getBioModelEditorPathwayPanel();
        } else if (singleSelection instanceof Model) {
        } else if (singleSelection instanceof RuleParticipantSignature) {
            bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
        } else if (singleSelection instanceof CSGObject) {
            bottomComponent = csgObjectPropertiesPanel;
            csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
        } else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
            DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
            if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionPropertiesPanel();
            } else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionRulePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
                bottomComponent = getStructurePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
                bottomComponent = getSpeciesPropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
                bottomComponent = getMolecularTypePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
                bottomComponent = getObservablePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
                bottomComponent = getApplicationsPropertiesPanel();
                getApplicationsPropertiesPanel().setBioModel(bioModel);
            } else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
                bottomComponent = parameterEstimationTaskPropertiesPanel;
            }
        } else if (singleSelection instanceof SelectionManager.AnnotationNavigator) {
            Object entity = ((SelectionManager.AnnotationNavigator) singleSelection).getEntity();
            if (entity instanceof ReactionStep) {
                bottomComponent = getReactionPropertiesPanel();
            } else if (entity instanceof SpeciesContext) {
                bottomComponent = getSpeciesPropertiesPanel();
            } else if (entity instanceof Structure) {
                // Observables. MolecularType, Structures
                bottomComponent = getStructurePropertiesPanel();
            } else if (entity instanceof MolecularType) {
                bottomComponent = getMolecularTypePropertiesPanel();
            } else if (entity instanceof RbmObservable) {
                bottomComponent = getObservablePropertiesPanel();
            } else {
                bottomComponent = bioModelEditorAnnotationPanel;
            }
        }
    }
    if (bShowPathway) {
        int numTabs = rightBottomTabbedPane.getTabCount();
        for (destComponentIndex = 0; destComponentIndex < numTabs; destComponentIndex++) {
            Component current = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (current == bottomComponent) {
                break;
            }
        }
        String tabTitle = "Pathway Preview";
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
        }
    } else if (bShowInDatabaseProperties) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
                break;
            }
        }
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
        }
    }
    if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
        bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
        annotationComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
        rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
        rightBottomTabbedPane.setComponentAt(annComponentIndex, annotationComponent);
        rightSplitPane.repaint();
    }
    Component selectedComponent = rightBottomTabbedPane.getSelectedComponent();
    if (selections.length == 1 && selections[0] instanceof BioModel && bottomComponent instanceof BioModelEditorAnnotationPanel) {
        // if the biomodel name is selected in the upper left tree, we select the Annotations tab
        rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    } else if (selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && selections[0] instanceof SelectionManager.AnnotationNavigator) {
        // we want to navigate to the AnnotationPanel
        rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    // } else if(selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && bottomComponent instanceof BioModelEditorAnnotationPanel) {
    // // we want to navigate to the AnnotationPanel (old way)
    // rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    } else if (selectedComponent != bottomComponent) /* && rightBottomTabbedPane.getSelectedComponent() != annotationComponent */
    {
        rightBottomTabbedPane.setSelectedComponent(bottomComponent);
    }
}
Also used : RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) BioPaxObject(org.vcell.pathway.BioPaxObject) Product(cbit.vcell.model.Product) PathwayData(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayData) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Reactant(cbit.vcell.model.Reactant) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) GeometryInfo(cbit.vcell.geometry.GeometryInfo) Structure(cbit.vcell.model.Structure) CSGObject(cbit.vcell.geometry.CSGObject) Component(java.awt.Component) JComponent(javax.swing.JComponent) PublicationInfoNode(cbit.vcell.desktop.BioModelNode.PublicationInfoNode) ReactionRule(cbit.vcell.model.ReactionRule) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) RbmObservable(cbit.vcell.model.RbmObservable) JComponent(javax.swing.JComponent) BioModelInfo(org.vcell.util.document.BioModelInfo) DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) DocumentEditorTreeFolderClass(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass) MolecularType(org.vcell.model.rbm.MolecularType) ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) DataSymbol(cbit.vcell.data.DataSymbol) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) ListSelectionModel(javax.swing.ListSelectionModel) BioModel(cbit.vcell.biomodel.BioModel) Parameter(cbit.vcell.model.Parameter) BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) BioEvent(cbit.vcell.mapping.BioEvent)

Example 2 with CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class GeometryGuiTest method getExampleGeometryCSG.

public static Geometry getExampleGeometryCSG() throws PropertyVetoException, ExpressionException, GeometryException, ImageException {
    // translated rotated cube
    CSGPrimitive cube = new CSGPrimitive("cube", CSGPrimitive.PrimitiveType.CUBE);
    CSGRotation rotatedCube = new CSGRotation("Rotation", new Vect3d(1, 2, 3), Math.PI / 4.0);
    rotatedCube.setChild(cube);
    // translated sphere
    CSGTranslation translatedSphere = new CSGTranslation("translation", new Vect3d(0.5, 0.5, 0.5));
    CSGPrimitive sphere = new CSGPrimitive("sphere", CSGPrimitive.PrimitiveType.SPHERE);
    translatedSphere.setChild(sphere);
    // union
    CSGSetOperator csgSetOperator = new CSGSetOperator("difference", OperatorType.DIFFERENCE);
    csgSetOperator.addChild(rotatedCube);
    csgSetOperator.addChild(translatedSphere);
    // scaled union
    CSGScale csgScale = new CSGScale("scale", new Vect3d(3, 3, 3));
    csgScale.setChild(csgSetOperator);
    CSGTranslation csgTranslatedUnion = new CSGTranslation("translationUnion", new Vect3d(5, 5, 5));
    csgTranslatedUnion.setChild(csgScale);
    Geometry geometry = new Geometry("csg", 3);
    CSGObject csgObject = new CSGObject(null, "obj1", 1);
    csgObject.setRoot(csgTranslatedUnion);
    geometry.getGeometrySpec().addSubVolume(new AnalyticSubVolume("background", new Expression(1.0)));
    geometry.getGeometrySpec().addSubVolume(csgObject, true);
    geometry.refreshDependencies();
    geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
    return geometry;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) CSGTranslation(cbit.vcell.geometry.CSGTranslation) Expression(cbit.vcell.parser.Expression) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGObject(cbit.vcell.geometry.CSGObject) CSGRotation(cbit.vcell.geometry.CSGRotation) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) Vect3d(cbit.vcell.render.Vect3d) CSGScale(cbit.vcell.geometry.CSGScale)

Example 3 with CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method addNode.

private boolean addNode(CSGNode newCsgNode) {
    if (newCsgNode == null) {
        return false;
    }
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return false;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject == csgObject) {
        csgObject.setRoot(newCsgNode);
        return true;
    }
    if (selectedUserObject instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) selectedUserObject;
        csgSetOperator.addChild(newCsgNode);
        return true;
    }
    if (selectedUserObject instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) selectedUserObject;
        csgTransformation.setChild(newCsgNode);
        return true;
    }
    return false;
}
Also used : CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

Example 4 with CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method showPopupMenu.

private void showPopupMenu(MouseEvent e) {
    if (!e.isPopupTrigger()) {
        return;
    }
    if (popupMenu == null) {
        popupMenu = new JPopupMenu();
    }
    if (popupMenu.isShowing()) {
        return;
    }
    selectClickPath(e);
    TreePath[] selectedPaths = csgObjectTree.getSelectionPaths();
    boolean bShowPopup = true;
    boolean bTransform = false;
    boolean bApplySetOperator = false;
    boolean bAddPrimitive = false;
    boolean bAddTransformation = false;
    boolean bAddOperator = false;
    boolean bEdit = false;
    boolean bDelete = true;
    if (selectedPaths == null) {
        return;
    }
    for (TreePath tp : selectedPaths) {
        Object obj = tp.getLastPathComponent();
        if (obj == null || !(obj instanceof BioModelNode)) {
            continue;
        }
        BioModelNode selectedNode = (BioModelNode) obj;
        Object userObject = selectedNode.getUserObject();
        if (userObject == csgObject) {
            bDelete = false;
            if (csgObject.getRoot() == null) {
                bAddPrimitive = true;
                bAddOperator = true;
                bAddTransformation = true;
            }
        } else if (userObject instanceof CSGPrimitive) {
            bApplySetOperator = true;
            bTransform = true;
            bAddPrimitive = false;
            bAddOperator = false;
            bAddTransformation = false;
        } else if (userObject instanceof CSGSetOperator) {
            bApplySetOperator = true;
            bTransform = true;
            bAddPrimitive = true;
            bAddOperator = true;
            bAddTransformation = true;
        } else if (userObject instanceof CSGTransformation) {
            bApplySetOperator = true;
            bTransform = true;
            bEdit = true;
            if (((CSGTransformation) userObject).getChild() == null) {
                bAddPrimitive = true;
                bAddOperator = true;
                bAddTransformation = true;
            }
        }
    }
    if (bShowPopup) {
        popupMenu.removeAll();
        if (bAddPrimitive || bAddTransformation || bAddOperator) {
            getAddPrimitiveMenu().setEnabled(bAddPrimitive);
            getAddTransformationMenu().setEnabled(bAddTransformation);
            getAddSetOperatorMenu().setEnabled(bAddOperator);
            popupMenu.add(getAddMenu());
        }
        if (popupMenu.getComponents().length > 0) {
            popupMenu.add(new JSeparator());
        }
        // everything can be renamed
        popupMenu.add(getRenameMenuItem());
        if (bEdit) {
            popupMenu.add(getEditMenuItem());
        }
        if (bDelete) {
            popupMenu.add(getDeleteMenuItem());
        }
        if (bTransform) {
            if (popupMenu.getComponents().length > 0) {
                popupMenu.add(new JSeparator());
            }
            popupMenu.add(getTransformMenu());
        }
        if (bApplySetOperator) {
            if (popupMenu.getComponents().length > 0 && !bTransform) {
                popupMenu.add(new JSeparator());
            }
            popupMenu.add(getApplySetOperatorMenu());
        }
        Point mousePoint = e.getPoint();
        popupMenu.show(csgObjectTree, mousePoint.x, mousePoint.y);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Example 5 with CSGObject

use of cbit.vcell.geometry.CSGObject in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method transformOrApplySetOperator.

private boolean transformOrApplySetOperator(CSGNode newCsgNode) {
    if (newCsgNode == null) {
        return false;
    }
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return false;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (!(selectedUserObject instanceof CSGNode)) {
        return false;
    }
    CSGNode selectedCSGNode = (CSGNode) selectedUserObject;
    TreeNode parentNode = selectedNode.getParent();
    if (parentNode == null || !(parentNode instanceof BioModelNode)) {
        return false;
    }
    Object parentObject = ((BioModelNode) parentNode).getUserObject();
    if (newCsgNode instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) newCsgNode;
        csgTransformation.setChild(selectedCSGNode);
    } else if (newCsgNode instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) newCsgNode;
        csgSetOperator.addChild(selectedCSGNode);
    }
    if (parentObject == csgObject) {
        csgObject.setRoot(newCsgNode);
    } else if (parentObject instanceof CSGSetOperator) {
        CSGSetOperator parentCSGSetOperator = (CSGSetOperator) parentObject;
        int index = parentCSGSetOperator.indexOf(selectedCSGNode);
        if (index >= 0) {
            parentCSGSetOperator.setChild(index, newCsgNode);
            return true;
        }
    } else if (parentObject instanceof CSGTransformation) {
        CSGTransformation parentCSGTransformation = (CSGTransformation) parentObject;
        parentCSGTransformation.setChild(newCsgNode);
        return true;
    }
    return false;
}
Also used : TreeNode(javax.swing.tree.TreeNode) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGNode(cbit.vcell.geometry.CSGNode) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator)

Aggregations

CSGObject (cbit.vcell.geometry.CSGObject)23 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)11 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)8 Expression (cbit.vcell.parser.Expression)7 CSGNode (cbit.vcell.geometry.CSGNode)6 CSGSetOperator (cbit.vcell.geometry.CSGSetOperator)6 SubVolume (cbit.vcell.geometry.SubVolume)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 BioModelNode (cbit.vcell.desktop.BioModelNode)5 CSGTransformation (cbit.vcell.geometry.CSGTransformation)5 Geometry (cbit.vcell.geometry.Geometry)5 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 Hashtable (java.util.Hashtable)5 BioModel (cbit.vcell.biomodel.BioModel)4 CSGPrimitive (cbit.vcell.geometry.CSGPrimitive)4 CSGScale (cbit.vcell.geometry.CSGScale)4 CSGTranslation (cbit.vcell.geometry.CSGTranslation)4 SimulationContext (cbit.vcell.mapping.SimulationContext)4 PropertyVetoException (java.beans.PropertyVetoException)4