Skip to content
Snippets Groups Projects
Commit ddaa970f authored by Alexander Rose's avatar Alexander Rose
Browse files

take ply property type into account for ui

parent a14236c4
No related branches found
No related tags found
Loading
...@@ -154,6 +154,7 @@ function parseTableElement(state: State, spec: TableElementSpec) { ...@@ -154,6 +154,7 @@ function parseTableElement(state: State, spec: TableElementSpec) {
const { count, properties } = spec const { count, properties } = spec
const propertyCount = properties.length const propertyCount = properties.length
const propertyNames: string[] = [] const propertyNames: string[] = []
const propertyTypes: PlyType[] = []
const propertyTokens: Tokens[] = [] const propertyTokens: Tokens[] = []
const propertyColumns = new Map<string, Column<number>>() const propertyColumns = new Map<string, Column<number>>()
...@@ -175,6 +176,7 @@ function parseTableElement(state: State, spec: TableElementSpec) { ...@@ -175,6 +176,7 @@ function parseTableElement(state: State, spec: TableElementSpec) {
const { type, name } = properties[i] const { type, name } = properties[i]
const column = TokenColumn(propertyTokens[i], getColumnSchema(type)) const column = TokenColumn(propertyTokens[i], getColumnSchema(type))
propertyNames.push(name) propertyNames.push(name)
propertyTypes.push(type)
propertyColumns.set(name, column) propertyColumns.set(name, column)
} }
...@@ -182,6 +184,7 @@ function parseTableElement(state: State, spec: TableElementSpec) { ...@@ -182,6 +184,7 @@ function parseTableElement(state: State, spec: TableElementSpec) {
kind: 'table', kind: 'table',
rowCount: count, rowCount: count,
propertyNames, propertyNames,
propertyTypes,
getProperty: (name: string) => propertyColumns.get(name) getProperty: (name: string) => propertyColumns.get(name)
}) })
} }
...@@ -225,6 +228,7 @@ function parseListElement(state: State, spec: ListElementSpec) { ...@@ -225,6 +228,7 @@ function parseListElement(state: State, spec: ListElementSpec) {
kind: 'list', kind: 'list',
rowCount: count, rowCount: count,
name: property.name, name: property.name,
type: property.dataType,
value: (row: number) => { value: (row: number) => {
const start = offsets[row] const start = offsets[row]
const end = offsets[row + 1] const end = offsets[row + 1]
......
...@@ -61,6 +61,7 @@ export interface PlyTable { ...@@ -61,6 +61,7 @@ export interface PlyTable {
readonly kind: 'table' readonly kind: 'table'
readonly rowCount: number readonly rowCount: number
readonly propertyNames: ReadonlyArray<string> readonly propertyNames: ReadonlyArray<string>
readonly propertyTypes: ReadonlyArray<PlyType>
getProperty(name: string): Column<number> | undefined getProperty(name: string): Column<number> | undefined
} }
...@@ -73,5 +74,6 @@ export interface PlyList { ...@@ -73,5 +74,6 @@ export interface PlyList {
readonly kind: 'list' readonly kind: 'list'
readonly rowCount: number, readonly rowCount: number,
readonly name: string, readonly name: string,
readonly type: PlyType,
value: (row: number) => PlyListValue value: (row: number) => PlyListValue
} }
\ No newline at end of file
...@@ -22,12 +22,19 @@ import { deepClone } from 'mol-util/object'; ...@@ -22,12 +22,19 @@ import { deepClone } from 'mol-util/object';
// TODO support 'edge' and 'material' elements, see https://www.mathworks.com/help/vision/ug/the-ply-format.html // TODO support 'edge' and 'material' elements, see https://www.mathworks.com/help/vision/ug/the-ply-format.html
function createPlyShapeParams(vertex?: PlyTable) { function createPlyShapeParams(vertex?: PlyTable) {
const options: [string, string][] = [['', '']] const groupOptions: [string, string][] = [['', '']]
const colorOptions: [string, string][] = [['', '']]
const defaultValues = { group: '', red: '', green: '', blue: '' } const defaultValues = { group: '', red: '', green: '', blue: '' }
if (vertex) { if (vertex) {
for (let i = 0, il = vertex.propertyNames.length; i < il; ++i) { for (let i = 0, il = vertex.propertyNames.length; i < il; ++i) {
const name = vertex.propertyNames[i] const name = vertex.propertyNames[i]
options.push([ name, name ]) const type = vertex.propertyTypes[i]
if (
type === 'uchar' || type === 'uint8' ||
type === 'ushort' || type === 'uint16' ||
type === 'uint' || type === 'uint32'
) groupOptions.push([ name, name ])
if (type === 'uchar' || type === 'uint8') colorOptions.push([ name, name ])
} }
// TODO hardcoded as convenience for data provided by MegaMol // TODO hardcoded as convenience for data provided by MegaMol
...@@ -43,9 +50,9 @@ function createPlyShapeParams(vertex?: PlyTable) { ...@@ -43,9 +50,9 @@ function createPlyShapeParams(vertex?: PlyTable) {
coloring: PD.MappedStatic(defaultValues.red && defaultValues.green && defaultValues.blue ? 'vertex' : 'uniform', { coloring: PD.MappedStatic(defaultValues.red && defaultValues.green && defaultValues.blue ? 'vertex' : 'uniform', {
vertex: PD.Group({ vertex: PD.Group({
red: PD.Select(defaultValues.red, options, { label: 'Red Property' }), red: PD.Select(defaultValues.red, colorOptions, { label: 'Red Property' }),
green: PD.Select(defaultValues.green, options, { label: 'Green Property' }), green: PD.Select(defaultValues.green, colorOptions, { label: 'Green Property' }),
blue: PD.Select(defaultValues.blue, options, { label: 'Blue Property' }), blue: PD.Select(defaultValues.blue, colorOptions, { label: 'Blue Property' }),
}, { isFlat: true }), }, { isFlat: true }),
uniform: PD.Group({ uniform: PD.Group({
color: PD.Color(ColorNames.grey) color: PD.Color(ColorNames.grey)
...@@ -53,7 +60,7 @@ function createPlyShapeParams(vertex?: PlyTable) { ...@@ -53,7 +60,7 @@ function createPlyShapeParams(vertex?: PlyTable) {
}), }),
grouping: PD.MappedStatic(defaultValues.group ? 'vertex' : 'none', { grouping: PD.MappedStatic(defaultValues.group ? 'vertex' : 'none', {
vertex: PD.Group({ vertex: PD.Group({
group: PD.Select(defaultValues.group, options, { label: 'Group Property' }), group: PD.Select(defaultValues.group, groupOptions, { label: 'Group Property' }),
}, { isFlat: true }), }, { isFlat: true }),
none: PD.Group({ }) none: PD.Group({ })
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment