Warning, /firebird/firebird-ng/src/lib-root-geometry/root-geo-attribute-bits.ts is written in an unsupported language. File is not indexed.
0001 /**
0002 * @date Created on July 10, 2024
0003 * @author jsroot project
0004 *
0005 * @license This file is part of the Firebird display, which is released under a license agreement
0006 * available in the LICENSE file located in the root directory of this project source tree. This
0007 * file is subject to that license and is intended to be used in accordance with it.
0008 *
0009 * @summary This module defines utilities for manipulating and testing attribute bits (GeoAttBits)
0010 * within the CERN ROOT framework geometry package. It includes functions to set, toggle, and test various
0011 * visibility and attribute flags defined by the GeoAttBits enum.
0012 */
0013
0014
0015 /** @summary TGeo Attribute Bits */
0016 export enum GeoAttBits {
0017 kVisOverride = 1 << 0, // volume's vis. attributes are overwritten
0018 kVisNone= 1 << 1, // the volume/node is invisible, as well as daughters
0019 kVisThis= 1 << 2, // this volume/node is visible
0020 kVisDaughters= 1 << 3, // all leaves are visible
0021 kVisOneLevel= 1 << 4, // first level daughters are visible (not used
0022 kVisStreamed= 1 << 5, // true if attributes have been streamed
0023 kVisTouched= 1 << 6, // true if attributes are changed after closing geom
0024 kVisOnScreen= 1 << 7, // true if volume is visible on screen
0025 kVisContainers= 1 << 12, // all containers visible
0026 kVisOnly= 1 << 13, // just this visible
0027 kVisBranch= 1 << 14, // only a given branch visible
0028 kVisRaytrace= 1 << 15 // raytracing flag
0029 }
0030
0031 /** @summary Test fGeoAtt bits
0032 * @private */
0033 export function testGeoBit(volume:any , f: GeoAttBits) {
0034 const att = volume.fGeoAtt;
0035 return att === undefined ? false : ((att & f) !== 0);
0036 }
0037
0038
0039 /** @summary Set fGeoAtt bit
0040 * @private */
0041 export function setGeoBit(volume:any, f: GeoAttBits, value: number) {
0042 if (volume.fGeoAtt === undefined) return;
0043 volume.fGeoAtt = value ? (volume.fGeoAtt | f) : (volume.fGeoAtt & ~f);
0044 }
0045
0046 /** @summary Toggle fGeoAttBit
0047 * @private */
0048 export function toggleGeoBit(volume:any, f: GeoAttBits) {
0049 if (volume.fGeoAtt !== undefined)
0050 volume.fGeoAtt = volume.fGeoAtt ^ (f & 0xffffff);
0051 }
0052
0053 /** @summary Prints the status of all geoBITS flags for a given volume
0054 * @param {Object} volume - The volume object to check
0055 * @private */
0056 export function printAllGeoBitsStatus(volume:any) {
0057 const bitDescriptions = [
0058 { name: 'kVisOverride ', bit: GeoAttBits.kVisOverride },
0059 { name: 'kVisNone ', bit: GeoAttBits.kVisNone },
0060 { name: 'kVisThis ', bit: GeoAttBits.kVisThis },
0061 { name: 'kVisDaughters ', bit: GeoAttBits.kVisDaughters },
0062 { name: 'kVisOneLevel ', bit: GeoAttBits.kVisOneLevel },
0063 { name: 'kVisStreamed ', bit: GeoAttBits.kVisStreamed },
0064 { name: 'kVisTouched ', bit: GeoAttBits.kVisTouched },
0065 { name: 'kVisOnScreen ', bit: GeoAttBits.kVisOnScreen },
0066 { name: 'kVisContainers', bit: GeoAttBits.kVisContainers },
0067 { name: 'kVisOnly ', bit: GeoAttBits.kVisOnly },
0068 { name: 'kVisBranch ', bit: GeoAttBits.kVisBranch },
0069 { name: 'kVisRaytrace ', bit: GeoAttBits.kVisRaytrace }
0070 ];
0071
0072 console.log(`fGeoAttr for ${volume._typename}: ${volume.fName}`);
0073 bitDescriptions.forEach(desc => {
0074 const isSet = testGeoBit(volume, desc.bit);
0075 console.log(` ${desc.name}: ${isSet ? 'Yes' : 'No'}`);
0076 });
0077 }