Merge branch 'develop' into feature/JAL-3390hideUnmappedStructure
[jalview.git] / src / jalview / ext / pymol / PymolCommands.java
index 36957f5..8bf1c9f 100644 (file)
@@ -23,6 +23,12 @@ import jalview.structure.StructureCommandsBase;
  */
 public class PymolCommands extends StructureCommandsBase
 {
+  private static final StructureCommand SHOW_RIBBON = new StructureCommand("show", "ribbon");
+
+  private static final StructureCommand SHOW_CARTOON = new StructureCommand("show", "cartoon");
+
+  private static final StructureCommand HIDE_EVERYTHING = new StructureCommand("hide", "everything");
+
   // https://pymol.org/dokuwiki/doku.php?id=command:zoom
   // not currently documented on
   // https://pymolwiki.org/index.php/Category:Commands
@@ -37,7 +43,6 @@ public class PymolCommands extends StructureCommandsBase
   // https://pymolwiki.org/index.php/Category:Commands
   private static final StructureCommand COLOUR_BY_CHAIN = new StructureCommand(
           "spectrum", "chain");
-
   private static final List<StructureCommandI> COLOR_BY_CHARGE = Arrays
           .asList(new StructureCommand("color", "white", "*"),
                   new StructureCommand("color", "red", "resn ASP resn GLU"),
@@ -88,23 +93,6 @@ public class PymolCommands extends StructureCommandsBase
   }
 
   @Override
-  public List<StructureCommandI> showChains(List<String> toShow)
-  {
-    // https://pymolwiki.org/index.php/Show
-    List<StructureCommandI> commands = new ArrayList<>();
-    commands.add(new StructureCommand("hide", "everything"));
-    commands.add(new StructureCommand("show", "lines"));
-    StringBuilder chains = new StringBuilder();
-    for (String chain : toShow)
-    {
-      chains.append(" chain ").append(chain);
-    }
-    commands.add(
-            new StructureCommand("show", "cartoon", chains.toString()));
-    return commands;
-  }
-
-  @Override
   public List<StructureCommandI> superposeStructures(AtomSpecModel refAtoms,
           AtomSpecModel atomSpec)
   {
@@ -326,9 +314,33 @@ public class PymolCommands extends StructureCommandsBase
   }
 
   @Override
+  public StructureCommandI showStructures(AtomSpecModel restrictTo)
+  {
+    if (restrictTo == null)
+    {
+      return SHOW_CARTOON;
+    }
+    else
+    {
+      return new StructureCommand("show", "cartoon",
+              getAtomSpec(restrictTo, false));
+    }
+  }
+
+  @Override
+  public StructureCommandI hideChain(String modelId, String chainId)
+  {
+    return new StructureCommand("hide", modelId + "//" + chainId + "//");
+  }
+
+  @Override
+  public StructureCommandI hideAll()
+  {
+    return HIDE_EVERYTHING;
+  }
+    
   public StructureCommandI closeViewer()
   {
-    // https://pymolwiki.org/index.php/Quit
     return CLOSE_PYMOL;
   }