Commit 201e2d38 authored by eric pellegrini's avatar eric pellegrini

The job plugins can now be plugged in a data plugin or in a molecular

viewer
Bug fix when closing a lugin pane
Bug fix with DL_POLY converter plugin
parent 9e59725f
......@@ -65,9 +65,9 @@ class AngularCorrelation(IJob):
label = "Angular Correlation"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -54,9 +54,9 @@ class AreaPerMolecule(IJob):
label = "Area Per Molecule"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{'default':os.path.join('..','..','..','Data','Trajectories','MMTK','dmpc_in_periodic_universe.nc')})
......
......@@ -51,9 +51,9 @@ class BoxCenteredTrajectory(IJob):
label = "Box Translated Trajectory"
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -49,9 +49,9 @@ class CenterOfMassesTrajectory(IJob):
label = "Center Of Masses Trajectory"
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -287,7 +287,7 @@ class DL_POLYConverter(Converter):
type = 'dl_poly'
label = "DL_POLY"
label = "DL-POLY"
settings = collections.OrderedDict()
settings['field_file'] = ('input_file',{'wildcard':"FIELD files|FIELD*|All files|*",
......
......@@ -46,9 +46,9 @@ class CoordinationNumber(DistanceHistogram):
label = "Coordination Number"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -47,9 +47,9 @@ class CroppedTrajectory(IJob):
label = "Cropped Trajectory"
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -54,9 +54,9 @@ class CurrentCorrelationFunction(IJob):
label = "Current Correlation Function"
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -45,9 +45,9 @@ class Density(IJob):
label = "Density"
category = ('Thermodynamics',)
category = ('Analysis','Thermodynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -49,9 +49,9 @@ class DensityOfStates(IJob):
label = "Density Of States"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -52,9 +52,9 @@ class DensityProfile(IJob):
label = "Density Profile"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -45,9 +45,9 @@ class DipoleAutoCorrelationFunction(IJob):
label = "Dipole AutoCorrelation Function"
category = ('Infrared',)
category = ('Analysis','Infrared',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -55,9 +55,9 @@ class DynamicCoherentStructureFactor(IJob):
label = "Dynamic Coherent Structure Factor"
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -50,9 +50,9 @@ class DynamicIncoherentStructureFactor(IJob):
label = "Dynamic Incoherent Structure Factor"
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory']=('mmtk_trajectory',{})
......
......@@ -86,9 +86,9 @@ class Eccentricity(IJob):
label = "Eccentricity"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -54,9 +54,9 @@ class ElasticIncoherentStructureFactor(IJob):
label = "Elastic Incoherent Structure Factor"
# The category of the analysis.
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -50,9 +50,9 @@ class GaussianDynamicIncoherentStructureFactor(IJob):
label = "Gaussian Dynamic Incoherent Structure Factor"
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -47,9 +47,9 @@ class GeneralAutoCorrelationFunction(IJob):
label = "General AutoCorrelation Function"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -63,9 +63,9 @@ class GlobalMotionFilteredTrajectory(IJob):
label = "Global Motion Filtered Trajectory"
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -32,12 +32,7 @@ class JobStatus(Status):
self.save_status()
def finish_status(self,message):
status = message
if status != self:
return
def finish_status(self):
self.cleanup()
......@@ -47,9 +42,7 @@ class JobStatus(Status):
return self._state
def cleanup(self):
return
try:
os.unlink(self._state['temporary_file'])
except:
......
......@@ -70,9 +70,9 @@ class McStasVirtualInstrument(IJob):
label = "McStas Virtual Instrument"
category = ('Virtual Instruments',)
category = ('Analysis','Virtual Instruments',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory', {'default':os.path.join('..','..','..','Data','Trajectories', 'MMTK', 'protein_in_periodic_universe.nc')})
......
......@@ -48,7 +48,7 @@ class MeanSquareDisplacement(IJob):
since molecules undergo collisions. The path is to a good approximation to a random walk.
Mathematically, a random walk is a series of steps where each step is taken in a completely
random direction from the one before, as analysed by Albert Einstein
random direction from the one before, as analyzed by Albert Einstein
in a study of Brownian motion. The MSD of a particle in this case
is proportional to the time elapsed:
......@@ -68,7 +68,7 @@ class MeanSquareDisplacement(IJob):
label = "Mean Square Displacement"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory","molecular_viewer"]
......
......@@ -56,9 +56,9 @@ class MolecularTrace(IJob):
label = "Molecular Trace"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -75,9 +75,9 @@ class OrderParameter(IJob):
label = "Order parameter"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory', {'default':os.path.join('..','..','..','Data','Trajectories', 'MMTK', 'protein_in_periodic_universe.nc')})
......
......@@ -55,9 +55,9 @@ class PairDistributionFunction(DistanceHistogram):
label = "Pair Distribution Function"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
def finalize(self):
"""
......
......@@ -47,9 +47,9 @@ class PositionAutoCorrelationFunction(IJob):
label = "Position AutoCorrelation Function"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -49,9 +49,9 @@ class RadiusOfGyration(IJob):
label = "Radius of Gyration"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -52,9 +52,9 @@ class RefoldedMembraneTrajectory(IJob):
label = "Refolded Membrane Trajectory"
category = ('Macromolecules','Lipids')
category = ('Analysis','Macromolecules','Lipids')
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{'default':os.path.join('..','..','..','Data','Trajectories','MMTK','dmpc_in_periodic_universe.nc')})
......
......@@ -53,9 +53,9 @@ class RigidBodyTrajectory(IJob):
label = 'Rigid Body Trajectory'
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory']=('mmtk_trajectory',{})
......
......@@ -52,9 +52,9 @@ class RootMeanSquareDeviation(IJob):
label = "Root Mean Square Deviation"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -48,9 +48,9 @@ class RootMeanSquareFluctuation(IJob):
label = "Root Mean Square Fluctuation"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -64,9 +64,9 @@ class SolventAccessibleSurface(IJob):
label = "Solvent Accessible Surface"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -37,7 +37,7 @@ import numpy
from MDANSE.Extensions import sd_fast_calc
from MDANSE.Framework.Jobs.IJob import IJob
from MDANSE.Mathematics.Geometry import build_cartesian_axes, center_of_mass
from MDANSE.Mathematics.Geometry import build_cartesian_axes
class SpatialDensity(IJob):
"""The Spatial Density (SD) computes the 3D histograms of atomic coordinates of the a given set of target molecules
......@@ -58,9 +58,9 @@ class SpatialDensity(IJob):
label = "Spatial Density"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory', {'default':os.path.join('..','..','..','Data','Trajectories', 'MMTK', 'protein_in_periodic_universe.nc')})
......
......@@ -47,9 +47,9 @@ class StaticStructureFactor(DistanceHistogram):
label = "Static Structure Factor"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -45,9 +45,9 @@ class StructureFactorFromScatteringFunction(IJob):
label = "Structure Factor From Scattering Function"
category = ('Scattering',)
category = ('Analysis','Scattering',)
ancestor = ["netcdf_data"]
ancestor = ["netcdf_data","mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['netcdf_input_file'] = ('netcdf_input_file', {'variables':['time','f(q,t)_total'],
......
......@@ -55,9 +55,9 @@ class Temperature(IJob):
label = "Temperature"
category = ('Thermodynamics',)
category = ('Analysis','Thermodynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -64,9 +64,9 @@ class UnfoldedTrajectory(IJob):
label = "Unfolded Trajectory"
category = ('Trajectory',)
category = ('Analysis','Trajectory',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -70,9 +70,9 @@ class VelocityAutoCorrelationFunction(IJob):
label = "Velocity AutoCorrelation Function"
category = ('Dynamics',)
category = ('Analysis','Dynamics',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -61,9 +61,9 @@ class Voronoi(IJob):
label = "Voronoi"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -66,9 +66,9 @@ class StaticStructureFactor(DistanceHistogram):
label = "XRay Static Structure Factor"
category = ('Structure',)
category = ('Analysis','Structure',)
ancestor = ["mmtk_trajectory"]
ancestor = ["mmtk_trajectory","molecular_viewer"]
settings = collections.OrderedDict()
settings['trajectory'] = ('mmtk_trajectory',{})
......
......@@ -31,9 +31,7 @@ Created on Mar 30, 2015
'''
import wx
import wx.aui as wxaui
from MDANSE import REGISTRY
from MDANSE.Externals.pubsub import pub
from MDANSE.GUI import DATA_CONTROLLER
......@@ -53,7 +51,7 @@ def get_data_plugin(window):
class DataPlugin(IPlugin):
type = 'data'
type = None
ancestor = []
......@@ -95,31 +93,7 @@ class DataPlugin(IPlugin):
@property
def dataplugin(self):
return self
def drop(self, pluginName):
# If no plugin match the name of the dropped plugin, do nothing.
plugin = REGISTRY["plugin"].get(pluginName,None)
if plugin is None:
return
klasses = tuple([REGISTRY['plugin'][anc] for anc in plugin.ancestor])
if not issubclass(self.__class__,klasses):
return
plugin = plugin(self)
self._mgr.AddPane(plugin, wxaui.AuiPaneInfo().Caption(getattr(plugin, "label", pluginName)))
self._mgr.Update()
plugin.plug()
plugin.SetFocus()
self._currentWindow = plugin
def on_changing_pane(self, event):
window = plugin_parent(event.GetWindow())
......@@ -128,5 +102,5 @@ class DataPlugin(IPlugin):
return
self._currentWindow = window
pub.sendMessage('msg_set_plugins_tree', plugin=window)
......@@ -114,22 +114,13 @@ class IPlugin(wx.Panel):
def parent(self):
return self._parent
def close_children(self):
childrenPlugins = [p.window for p in self._mgr.GetAllPanes()]
for plugin in childrenPlugins:
try:
plugin.close_children()
except AttributeError:
continue
self.close()
def is_parent(self,window):
if window == self:
return True
if window is None:
return False
return self.is_parent(window.Parent)
......@@ -138,13 +129,19 @@ class IPlugin(wx.Panel):
pass
def on_close_pane(self, event):
d = wx.MessageDialog(None, 'Closing this plugin will also close all the other ones you plugged in in so far. Do you really want to close ?', 'Question', wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION)
if d.ShowModal() == wx.ID_NO:
return
plugin = event.GetPane().window
window = event.GetPane().window
# if isinstance(window,IPlugin):
# window.close_children()
try:
plugin.close_children()
except AttributeError:
plugin.Close()
self._mgr.DetachPane(window)
window.Destroy()
self._mgr.Update()
self.SetFocus()
......@@ -168,10 +165,15 @@ class IPlugin(wx.Panel):
plugin = REGISTRY["plugin"].get(pluginName,None)
if plugin is None:
return
klasses = tuple([REGISTRY['plugin'][anc] for anc in plugin.ancestor])
if not issubclass(self.__class__,klasses):
self.parent.drop(pluginName)
# Get the list of ancestors of the plugin that will host the plugin to be dropped in.
ancestors = IPlugin.get_ancestors(plugin)
# klasses = tuple([REGISTRY['plugin'][anc] for anc in plugin.ancestor])
# if not issubclass(self.__class__,klasses):
# self.parent.drop(pluginName)
# return
if not plugin.ancestor[0] in ancestors:
return
plugin = plugin(self)
......@@ -182,4 +184,16 @@ class IPlugin(wx.Panel):
plugin.plug()
plugin.SetFocus()
\ No newline at end of file
plugin.SetFocus()
@staticmethod
def get_ancestors(plugin):
if plugin.ancestor == ['empty_data']:
return [plugin.type]
parentPlugin = REGISTRY['plugin'][plugin.ancestor[0]]
return [plugin.type] + IPlugin.get_ancestors(parentPlugin)
\ No newline at end of file
......@@ -42,6 +42,7 @@ import wx.aui as aui
from MDANSE import PLATFORM,REGISTRY
from MDANSE.Externals.pubsub import pub