浏览代码

check if carbs are applicable without calculating them

Alexander Rose 5 年之前
父节点
当前提交
f5667411d7
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 3 1
      src/mol-repr/structure/representation/carbohydrate.ts
  2. 3 1
      src/mol-theme/color/carbohydrate-symbol.ts

+ 3 - 1
src/mol-repr/structure/representation/carbohydrate.ts

@@ -45,5 +45,7 @@ export const CarbohydrateRepresentationProvider = StructureRepresentationProvide
     defaultValues: PD.getDefaultValues(CarbohydrateParams),
     defaultColorTheme: { name: 'carbohydrate-symbol' },
     defaultSizeTheme: { name: 'uniform' },
-    isApplicable: (structure: Structure) => structure.carbohydrates.elements.length > 0
+    isApplicable: (structure: Structure) => {
+        return structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0
+    }
 })

+ 3 - 1
src/mol-theme/color/carbohydrate-symbol.ts

@@ -67,5 +67,7 @@ export const CarbohydrateSymbolColorThemeProvider: ColorTheme.Provider<Carbohydr
     factory: CarbohydrateSymbolColorTheme,
     getParams: getCarbohydrateSymbolColorThemeParams,
     defaultValues: PD.getDefaultValues(CarbohydrateSymbolColorThemeParams),
-    isApplicable: (ctx: ThemeDataContext) => !!ctx.structure && ctx.structure.carbohydrates.elements.length > 0
+    isApplicable: (ctx: ThemeDataContext) => {
+        return !!ctx.structure && ctx.structure.models.reduce((a, v) => a + v.properties.saccharideComponentMap.size, 0) > 0
+    }
 }