Ejemplo n.º 1
0
  render() {
    if (!this.state.ready) {
      return (
        <Spin
          spinning
          size="large"
          style={{
            position: "fixed",
            top: "64px",
            left: "0px",
            right: "0px",
            bottom: "0px",
            display: "flex",
            justifyContent: "center",
            alignItems: "center",
            zIndex: 1000,
          }}
        />
      );
    }
    const state = Store.getState();
    const allowedModes = Store.getState().tracing.restrictions.allowedModes;
    const mode = this.props.viewMode;

    if (!allowedModes.includes(mode)) {
      // Since this mode is not allowed, render nothing. A warning about this will be
      // triggered in the model. Don't throw an error since the store might change so that
      // the render function can succeed.
      return null;
    }

    const isArbitrary = constants.MODES_ARBITRARY.includes(mode);
    const isPlane = constants.MODES_PLANE.includes(mode);

    if (isArbitrary) {
      return <ArbitraryController onRender={this.updateStats} viewMode={mode} />;
    } else if (isPlane) {
      switch (state.tracing.type) {
        case "volume": {
          return <VolumeTracingPlaneController onRender={this.updateStats} />;
        }
        case "skeleton": {
          return <SkeletonTracingPlaneController onRender={this.updateStats} />;
        }
        default: {
          return <PlaneController onRender={this.updateStats} />;
        }
      }
    } else {
      // At the moment, all possible view modes consist of the union of MODES_ARBITRARY and MODES_PLANE
      // In case we add new viewmodes, the following error will be thrown.
      throw new Error("The current mode is none of the four known mode types");
    }
  }
Ejemplo n.º 2
0
 calculateZoomLevel(): number {
   const zoom = getPlaneScalingFactor(this.props.flycam);
   let width;
   const viewMode = Store.getState().temporaryConfiguration.viewMode;
   if (constants.MODES_PLANE.includes(viewMode)) {
     width = constants.PLANE_WIDTH;
   } else if (constants.MODES_ARBITRARY.includes(viewMode)) {
     width = constants.VIEWPORT_WIDTH;
   } else {
     throw new Error(`Model mode not recognized: ${viewMode}`);
   }
   // unit is nm
   const baseVoxel = getBaseVoxel(this.props.dataset.dataSource.scale);
   return zoom * width * baseVoxel;
 }