Miew.prototype._onLoad = function()

in packages/miew/src/Miew.js [2182:2279]


Miew.prototype._onLoad = function (dataSource, opts) {
  const gfx = this._gfx;
  let visualName = null;

  if (opts.animation) {
    this._refreshTitle();
    this._startAnimation(dataSource);
    return null;
  }
  this._stopAnimation();
  if (!opts || !opts.keepRepsInfo) {
    this._opts.reps = null;
    this._opts._objects = null;
  }

  if (dataSource.id === 'Complex') {
    const complex = dataSource;

    // update title
    if (opts.fileName) {
      complex.name = complex.name || removeExtension(opts.fileName).toUpperCase();
    } else if (opts.amberFileName) {
      complex.name = complex.name || removeExtension(opts.amberFileName).toUpperCase();
    } else {
      complex.name = `Dynamic ${opts.fileType} molecule`;
    }

    visualName = this._addVisual(new ComplexVisual(complex.name, complex));
    this._curVisualName = visualName;

    const desc = this.info();
    this.logger.info(`Parsed ${opts.fileName} (${
      desc.atoms} atoms, ${
      desc.bonds} bonds, ${
      desc.residues} residues, ${
      desc.chains} chains).`);

    if (_.isNumber(this._opts.unit)) {
      complex.setCurrentUnit(this._opts.unit);
    }

    if (opts.preset) {
      // ...removed server access...
    } else if (settings.now.autoPreset) {
      switch (opts.fileType) {
        case 'cml':
          this.resetReps('small');
          break;
        case 'pdb':
        case 'mmtf':
        case 'cif':
          if (hasValidResidues(complex)) {
            this.resetReps('macro');
          } else {
            this.resetReps('small');
          }
          break;
        default:
          this.resetReps('default');
          break;
      }
    } else {
      this.resetReps('default');
    }
  } else if (dataSource.id === 'Volume') {
    this.resetEd();
    visualName = this._onLoadEd(dataSource);
  }

  gfx.camera.updateProjectionMatrix();
  this._updateFog();

  // reset global transform
  gfx.root.resetTransform();
  this.resetPivot();

  // set scale to fit everything on the screen
  this._objectControls.setScale(settings.now.radiusToFit / this._getBSphereRadius());

  this._resetObjects();

  if (settings.now.autoResolution) {
    this._tweakResolution();
  }

  if (settings.now.shadow.on) {
    this._updateShadowCamera();
  }

  if (this._opts.view) {
    this.view(this._opts.view);
    delete this._opts.view;
  }

  this._refreshTitle();

  return visualName;
};