Hi Stephen,
It sounds like you have 3 problems.
1) How does the user figure out a scale factor for printing.
2) How to make a vrml file that includes the right scale factor, so the file is all you need to print.
3) How to make thicknesses of struts and ribbons automatically adjust as you zoom the Chimera view.
For 1 and 2 you can just have the user zoom the model so its size on the screen is the desired size, then they press the export button on your extension, it writes the x3d, then your code modifies the resulting file by putting in the needed top level scaling transform, then runs the x3d2vrml conversion. I guess the user will still need to know what the units are for that VRML file, centimeters or millimeters or inches…. Unless the printer software can recognize a units field in the vrml file I don’t see anything you can do about that.
For 3, your extension could be notified on every zoom and adjust the strut and ribbon sizes. You are right this will probably be to slow to be usable for a modest size protein because I believe it will recompute the ribbon at each zoom step. The strut size changes would probably be fast enough. Maybe the ribbon resize would be for a small protein. You’d have to try it to know.
All our development effort has been on our next generation ChimeraX software the past year, we just do maintenance on Chimera. So adding the scale factor support for x3d output isn’t likely to happen, although we will do it for ChimeraX. Putting in support to automatically scale strut and ribbon thicknesses so they remain fixed in screen pixel size during zooming is not likely to happen — it is too much complexity added to the code benefitting too few users. We have few programmers maintaining an large range of Chimera functionality and can't take that on.
Tom
On Jul 20, 2016, at 9:37 AM, Stephen Norris wrote:
Hello Tom,
First of all, my comment about the units in chimera being arbitrary was in respect to how they are useless without knowing the corresponding scale that the model will be printed at. This is a problem for us because as I mentioned we don't really have a good method currently of determining the scale we want to print at in chimera and then transferring that scale to the printer software. Additionally it is difficult to compare sizes for printing as we need to have both a saved build file from the printing software and an original chimera session. This is because both the scale of printing and original settings used in chimera affect the actual size when printed. What we can do however is pick up a pair of calipers and actually measure the width of segments of models we've printed.
Also, I should be clear and try to explain what the extension currently does as it may clear things up. The extension uses the monitor's physical dimensions/DPI, which it tries to automatically get using the Tk winfo commands as you mentioned. I've found that the DPI isn't actually reported on some systems such as ubuntu (The X11 developers are at fault for that but don't get me started) so there is an option to manually determine these parameters. The extension can then use the horizontal dpi to determine the physical width of the viewer window and use set the view size to be the actual physical size (in inches). This then means the viewer's scalefactor is then the printing scale factor to get a model the same size as what is displayed on the screen (in inches, but can be converted easily). In addition there is a grid and ruler system so if you wanted a model 10cm across you can turn on the grid and simply zoom the model so that it fits into 10cm.
So, for exporting the model it would be good to have the scaling built into the export. Your point about surfaces is good, for that side point I was only thinking about simple ball and stick kind of stuff but that idea doesn't really pan out when it comes to making it work for everything else. The main working idea I have though is to modify the x3d export so that all the models are placed under a single transform node that holds the printing scaling. This can be done by simply nesting it just inside the group tag. From what I can tell this works fine even with the x3d2vrml conversion program with a test x3d file I modified by hand.
For setting style parameters the idea is that the extension can use the current scalefactor to determine the size in angstroms to set each parameter. So if we wanted struts of diameter 3mm and the model was currently at 50% scale, the extension can convert 3mm to inches and then divide by the scale to get struts of 3mm. What would be great would be to be able to set them to be 3mm but have them update to stay 3mm when the scale factor changes. This could be done by setting every parameter every time the scale factor changes but I'm guessing this would be too expensive to work in real time smoothly.
Stephen