From: Miguel <mi...@jm...> - 2004-12-12 21:06:45
|
David wrote: > While in this vein, I have a problem that may be related (but may be > not) with a set of buttons that select different residues in a > protein. This is a simple use of the applet without using js. The > buttons are generated on the fly, and it can happen that one gets a > situation: > > Button 1: res 3, res 4, res 5 > Button 2: res 34, res 35, res 36 > Button 3: res 36, res 37, res 38 > > All buttons are off by default. If the user turns on button 1 to > select and colour residues 3-4 and then turns on buttons 2 and 3, it > is ok if he then turns off button 1, leaving buttons 2 and 3 on. If > he next turns off button 2, he deselects residue 36 which is part of > the group for button 3, which is still on. If I were programming this > within the applet in Java it would be quite easy to prevent this > happening, but I see no way with simple select/deselect type commands > of the rasmol-type scripting language. Since Eric pointed out that one can redefine sets then here is a way to accomplish this. It is a bit ugly, but it should work: at the beginning of the world: =23these variables need to be defined, or Jmol will complain. define button2_36 none define button3_36 none button 2 on script: select 34,35,36; cpk on; =23 or whatever define button2_36 36 button 2 off script: select 34,35,36 & =21button3_36; cpk off; =23 or whatever define button2_36 none button 3 on script: select 36,37,38 cpk on; =23 or whatever define button3_36 36 button 3 off script: select 36,37,37 & =21button2_36; cpk off; =23 or whatever define button3_36 none The idea is that each of the buttons leaves a *flag* indicating whether o= r not it wants residue 36 turned on. When it comes time to turn it off, it uses the flag from the other button to determine whether or not to turn off residue 36. (I have not tested this code, but it should work). Miguel |