Ngl: Is it possible to change text size of distance, angle and dihedral angle?

Created on 11 Dec 2020  路  4Comments  路  Source: nglviewer/ngl

Dear,
I'm trying to visualize molecule from mol file and it works well. And I would like to change text size of angle, distance and dihedral angles. Because It seems small.
Are there any way to do it?
Thanks.

Most helpful comment

I'm not sure there's a neat way to override the defaults

You can use NGL.setMeasurementDefaultParams 馃檪

Options available are as defined in NGL globals in MeasurementDefaultParams, any options not overwritten remain as the defaults:

https://github.com/nglviewer/ngl/blob/6174bc6feea2957e82472746c849c107059d1d04/src/globals.ts#L62-L79

All 4 comments

The distance/angle/dihedral representations all have a labelSize parameter. If you're picking atoms to create measurements, then it's actually just updating a special representation that's automatically created for each molecule, e.g. to set the labelSize to 2.0 (default is 0.7) on the first component's dihedral measurements you can do:

stage.compList[0].dihedralRepresentation.setParameters({labelSize: 2.0})

I'm not sure there's a neat way to override the defaults, but if you always want them at a particular value you could add a listener to the componentAdded signal, this means every time you load a molecule the labelSize will be set to 2 on the relevant representations:

stage.signals.componentAdded.add(function(c) {
  var p = {labelSize: 2.0}
  c.distanceRepresentation.setParameters(p)
  c.angleRepresentation.setParameters(p)
  c.dihedralRepresentation.setParameters(p)
})

I'm not sure there's a neat way to override the defaults

You can use NGL.setMeasurementDefaultParams 馃檪

Options available are as defined in NGL globals in MeasurementDefaultParams, any options not overwritten remain as the defaults:

https://github.com/nglviewer/ngl/blob/6174bc6feea2957e82472746c849c107059d1d04/src/globals.ts#L62-L79

Yes, what he said! Thanks Harry!

Hi @fredludlow @harryjubb,
Thanks for prompt reply!
NGL.setMeasurementDefaultParams works very well.
I appreciate your kind support!
Thanks ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

harryjubb picture harryjubb  路  7Comments

martingraham picture martingraham  路  4Comments

Dom1L picture Dom1L  路  4Comments

arose picture arose  路  6Comments

arose picture arose  路  3Comments