Open cleblond opened 4 years ago
The following code may help to shrink the large structures to fit the client of composer:
var editor = composer.getEditor();
var objBox = editor.getObjectsContainerBox(editor.getChemSpace().getChildren());
var visualBox = chemEditor.getVisibleClientScreenBox();
if (objBox && visualBox)
{
var sx = (visualBox.x2 - visualBox.x1) / (objBox.x2 - objBox.x1);
var sy = (visualBox.y2 - visualBox.y1) / (objBox.y2 - objBox.y1);
var ratio = Math.min(sx, sy);
if (ratio < 1)
{
chemEditor.setZoom(chemEditor.getCurrZoom() * ratio);
chemEditor.scrollClientToObject(chemEditor.getChemSpace().getChildren());
}
}
What's the best way autofit or autozoom large structures/mechanisms in composer?