On Mon, Dec 7, 2015 at 3:27 PM, Rolf Huehne <rhue...@leibniz-fli.de> wrote:
> Hi all,
>
> I started working with loading multiple files simultaneously in Jmol.
> The reason is mainly to be able to switch very fast between different
> structures and not to display them simultaneously.
>
> For selections the setting 'set selectAllModels FALSE' will be able to
> help to prevent unwanted selections in other loaded structures while
> working with one of them (after the bug there is removed, see other
> thread).
>
yes, that's working
> But I ran into a problem with the 'display/hide' commands because they
> always act on all loaded structures and I couldn't find a way to prevent
> this.
>
> Q: Is there a simple way to prevent this?
>
>
No. They always do what they say they do.
> If not, it would be very helpful if an option similar to 'set
> selectAllModels FALSE' would be avilable.
>
>
The problem is that these commands actually go in and change settings, not
just the current selection. I suppose the following would do it:
function displayModel(atoms, mode) {
var a = {selected}
select @atoms
switch (mode) {
case "add":
display add selected
break
case "remove":
display remove selected
break
default:
if (selectAllModels) {
display selected
} else {
set selectAllModels true
display displayed and modelIndex!=_modelIndex or selected
set selectAllModels false
}
break
}
select @a
}
function hideModel(atoms, mode) {
var a = {selected}
select @atoms
switch (mode) {
case "add":
display remove selected
break
case "remove":
display add selected
break
default:
if (selectAllModels) {
hide selected
} else {
set selectAllModels true
hide hidden and modelIndex!=_modelIndex or selected
set selectAllModels false
}
break
}
select @a
}
> I tried to build replacement functions for 'display' and 'hide' (see
> below) but one problem there is that 'display BONDS' always acts on all
> bonds in all structures and I couldn't find a way to prevent this.
>
>
that's true. Bonds are not selectable by model.
> Another problem is that I haven't understood the syntax of 'display
> [{default: ...}]' from the scripting documentation so that I couldn't
> even try to mimic it yet.
>
that should read:
display [{...}]
This is a "bondset"
The way to select bonds for the current model is:
a = {modelindex=_modelIndex}.bonds
so then you could AND that with any desired bondset to get just the bonds
to atoms in the current model.
> And a disadvantage is that I would always have to monitor the
> 'display/hide' commands in future versions for any changes like
> additional keywords and check if my replacements still work as expected
> or if they must be expanded.
>
I don't have any plans to do that. I think they are working properly.
Just a few coding comments:
>
> ----- 'display' command substitution ----------------
> function getFileNumberList(atomBitset) {
> if (atomBitset.type != "bitset") {
> atomBitset = {visible};
> }
You can use _arguments.count here:
if (!_arguments) atomBitset = {visible}
var fileNumberInfo = atomBitset.file.all.count();
> var fileNumberList = [];
>
> if (fileNumberInfo.type == "array") {
> for (var i from [1, fileNumberInfo.size]) {
> var fileNumber = fileNumberInfo[i].[1];
> fileNumberList.push(fileNumber);
> }
> }
> return fileNumberList;
> }
>
not sure I see the need for the above
> function display(keyword, atomExpression) {
> var oneParameter = false;
> if (atomExpression == "") { # only one parameter?
> atomExpression = keyword;
> oneParameter = true;
> }
>
here you could use
if (_argumentCount < 2) {
atomExpression = keyword
keyword = ""
}
> var atomExpressionUpperCase = ("" + atomExpression) % 9999; #
> convert to upper case
>
This isn't really necessary; for historical reasons, Jmol "==" testing is
not case-sensitive. If you want it to be, you need to use LIKE instead of
"=="
> if (atomExpressionUpperCase == "ADD" || atomExpressionUpperCase ==
> "REMOVE") {
> print "ERROR: no atom expression provided in call of 'display'
> command or keyword '" + atomExpressionUpperCase + "' provided as second
> parameter instead of first";
> } else if (atomExpressionUpperCase == "BONDS") {
> display BONDS;
> } else {
> if (oneParameter == false) {
>
here I would use
if (keyword) {
var keywordUpperCase = ("" + keyword) % 9999; # convert to upper
> case
> if (keywordUpperCase == "ADD" || kewordUpperCase == "REMOVE") {
> atomExpression = keywordUpperCase + " " + atomExpression;
> display @atomExpression;
>
I don't see how that would work;
> } else if (keywordUpperCase == "BONDS") {
> print "ERROR: no atom expression allowed for keyword 'BONDS' in
> command 'display'";
> }
> } else {
> var fileNumberList = getFileNumberList;
> atomExpression = "(displayed and file!=fileNumberList) or " +
> atomExpression;
>
hmmm...
> display @atomExpression;
> }
> }
> }
> -----------------------------------------------------
>
> Regards,
> Rolf
>
> --
>
> Rolf Huehne
> Postdoc
>
> Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
> Beutenbergstrasse 11
> 07745 Jena, Germany
>
> Phone: +49 3641 65 6205
> Fax: +49 3641 65 6210
> E-Mail: rhue...@leibniz-fli.de
> Website: http://www.leibniz-fli.de
>
> Scientific Director: Prof. Dr. K. Lenhard Rudolph
> Head of Administration: Dr. Daniele Barthel
> Chairman of Board of Trustees: Burkhard Zinner
>
> VAT No: DE 153 925 464
> Register of Associations: No. 230296, Amtsgericht Jena
> Tax Number: 162/141/08228
>
>
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
If nature does not answer first what we want,
it is better to take what answer we get.
-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users