Search in sources :

Example 6 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)

Example 7 with CSGObject

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

the class CSGObjectPropertiesPanel method setCSGObject.

private void setCSGObject(CSGObject newValue) {
    if (csgObject == newValue) {
        return;
    }
    CSGObject oldValue = csgObject;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(eventHandler);
        oldValue.removePropertyChangeListener(csgObjectTreeModel);
    }
    if (newValue != null) {
        newValue.addPropertyChangeListener(eventHandler);
        newValue.addPropertyChangeListener(csgObjectTreeModel);
    }
    csgObject = newValue;
    csgObjectTreeModel.populateTree();
    if (csgObject != null) {
        titleLabel.setText("Properties for " + csgObject.getName());
    }
}
Also used : CSGObject(cbit.vcell.geometry.CSGObject)

Example 8 with CSGObject

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

the class CSGObjectPropertiesPanel method deleteNode.

private void deleteNode() {
    Object obj = csgObjectTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (!(selectedUserObject instanceof CSGNode)) {
        return;
    }
    CSGNode selectedCSGNode = (CSGNode) selectedUserObject;
    TreeNode parentNode = selectedNode.getParent();
    if (parentNode == null || !(parentNode instanceof BioModelNode)) {
        return;
    }
    Object parentObject = ((BioModelNode) parentNode).getUserObject();
    if (parentObject == csgObject) {
        csgObject.setRoot(null);
    } else if (parentObject instanceof CSGSetOperator) {
        CSGSetOperator csgSetOperator = (CSGSetOperator) parentObject;
        csgSetOperator.removeChild(selectedCSGNode);
    } else if (parentObject instanceof CSGTransformation) {
        CSGTransformation csgTransformation = (CSGTransformation) parentObject;
        csgTransformation.setChild(null);
    }
    updateCSGObject(parentObject);
}
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)

Example 9 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 10 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;
    }
    JComponent bottomComponent = rightBottomEmptyPanel;
    int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
    boolean bShowInDatabaseProperties = false;
    boolean bShowPathway = false;
    if (selections.length == 1) {
        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 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 || 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;
            }
        }
    }
    if (bShowPathway) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            if (rightBottomTabbedPane.getComponentAt(destComponentIndex) == 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);
        rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
        rightSplitPane.repaint();
    }
    if (rightBottomTabbedPane.getSelectedComponent() != bottomComponent) {
        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) 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)

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 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 ImageException (cbit.image.ImageException)3 CSGRotation (cbit.vcell.geometry.CSGRotation)3