import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
import jalview.api.AlignmentViewPanel;
-import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
String lastHighlightCommand;
- private Thread chimeraMonitor;
-
/**
* Open a PDB structure file in Chimera and set up mappings from Jalview.
*
}
/**
- * Starts a thread that waits for the Chimera process to finish, so that we can
- * then close the associated resources. This avoids leaving orphaned Chimera
- * viewer panels in Jalview if the user closes Chimera.
- */
- protected void startChimeraProcessMonitor()
- {
- final Process p = chimeraManager.getChimeraProcess();
- chimeraMonitor = new Thread(new Runnable()
- {
-
- @Override
- public void run()
- {
- try
- {
- p.waitFor();
- JalviewStructureDisplayI display = getViewer();
- if (display != null)
- {
- display.closeViewer(false);
- }
- } catch (InterruptedException e)
- {
- // exit thread if Chimera Viewer is closed in Jalview
- }
- }
- });
- chimeraMonitor.start();
- }
-
- /**
* Start a dedicated HttpServer to listen for Chimera notifications, and tell it
* to start listening
*/
public void closeViewer(boolean closeChimera)
{
super.closeViewer(closeChimera);
- if (closeChimera)
- {
- chimeraManager.exitChimera();
- }
if (this.chimeraListener != null)
{
chimeraListener.shutdown();
chimeraListener = null;
}
+ chimeraManager.clearOnChimeraExit();
chimeraManager = null;
-
- if (chimeraMonitor != null)
- {
- chimeraMonitor.interrupt();
- }
}
/**
boolean launched = chimeraManager.launchChimera(getChimeraPaths());
if (launched)
{
- startChimeraProcessMonitor();
+ startExternalViewerMonitor(chimeraManager.getChimeraProcess());
}
else
{
atomSpecs.add(spec);
} catch (IllegalArgumentException e)
{
- System.err.println("Failed to parse atomspec: " + atomSpec);
+ Cache.log.error("Failed to parse atomspec: " + atomSpec);
}
}
return atomSpecs;
}
/**
- * Ask Chimera to open a session file. Returns true if successful, else false.
- * The filename must have a .py (Chimera) or .cxs (ChimeraX) extension for
- * this command to work.
- *
- * @param filepath
- * @return
- */
- public boolean openSession(String filepath)
- {
- /*
- * Chimera: https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/open.html
- * ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html
- */
- executeCommand(getCommandGenerator().loadFile(filepath), true);
- // todo: test for failure - how?
- return true;
- }
-
- /**
* Send a 'show' command for all atoms in the currently selected columns
*
* TODO: pull up to abstract structure viewer interface