Package diffpy :: Package pdfgui :: Package control :: Module structureviewer :: Class StructureViewer
[hide private]
[frames] | no frames]

Class StructureViewer

source code

object --+
         |
        StructureViewer

Class for plotting structure in general structure viewer.
It takes care of creating temporary structure file in a desired
format and launching structure viewer as a background process.
The temporary files are removed when StructureViewer instance
goes out of scope.

Data attributes:

executable -- full path to the structure viewer executable or an executable
              that can be found in system PATH.  By default '' (not set).
argstr     -- argument string for the viewer program, it can use shell
              quoting.  Instances of '%s' in the string are replaced with
              temporary structure file.  By default '%s'
fileformat -- structure format that can be loaded by the viewer.
              Must be one of output formats supported by diffpy.Structure
              package.  By default 'pdb'.
_tmpdir    -- Temporary directory for structure files opened by the viewer.
              tmpdir is None before the first call to plot.  The directory
              and everything inside is removed when StructureViewer goes
              out of the scope.
_plotcount -- Number of plots created by this viewer.



Instance Methods [hide private]
 
__init__(self, executable=None, argstr=None, fileformat=None)
Create StructureViewer instance.
source code
 
getConfig(self)
Return current configuration of StructureViewer instance.
source code
 
setConfig(self, cfg)
Configure StructureViewer instance using values in a dictionary.
source code
 
plot(self, stru)
Launch new structure viewer and open a temporary copy of stru.
source code
 
__del__(self)
Remove temporary files created by this instance of StructureViewer.
source code
 
_getArgumentList(self, strupath)
Convert self.argstr to a list of string arguments.
source code
 
_writeTemporaryStructure(self, stru)
Create new temporary structure file in specified fileformat.
source code
 
_createTemporaryDirectory(self)
Create new numbered temporary directory below self._tmpdir.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
getFileFormats()
Return list of valid values for the fileformat attribute.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, executable=None, argstr=None, fileformat=None)
(Constructor)

source code 
Create StructureViewer instance.  All arguments are optional,
they override defaults described in class docstring.  The
configuration can be changed later using setConfig method.


executable -- path to the structure viewer executable
argstr     -- argument string for the viewer program, it can use
              shell quoting.  Instances of '%s' are replaced with
              temporary structure file.
fileformat -- structure format supported by diffpy.Structure package.

Overrides: object.__init__

getConfig(self)

source code 
Return current configuration of StructureViewer instance.

Returns new dictionary with the following keys:
('executable', 'argstr', 'fileformat')

setConfig(self, cfg)

source code 
Configure StructureViewer instance using values in a dictionary.

cfg     -- configuration dictionary, with the same keys as returned
           by getConfig().  Any other keys are ignored.

No return value.

plot(self, stru)

source code 
Launch new structure viewer and open a temporary copy of stru.

stru    -- instance of Structure class from diffpy.Structure

No return value.
Raise ControlConfigError if structure viewer could not be launched.

_getArgumentList(self, strupath)

source code 
Convert self.argstr to a list of string arguments.

strupath -- path to temporary structure file.  Replaces every
            instance of '%s' in self.argstr.

Return list of arguments (not including the viewer executable).

_writeTemporaryStructure(self, stru)

source code 
Create new temporary structure file in specified fileformat.

stru -- instance of Structure class

Return full path to the temporary file.

_createTemporaryDirectory(self)

source code 
Create new numbered temporary directory below self._tmpdir.

Create _tmpdir if it does not exist yet.

Return full path to the new temporary directory.