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);
}
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations