Index: sansview/docs/note2.txt
===================================================================
--- sansview/docs/note2.txt	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
+++ sansview/docs/note2.txt	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
@@ -0,0 +1,1 @@
+1- the combox must contains class.__name__ or model name?
Index: sansview/perspectives/fitting/models.py
===================================================================
--- sansview/perspectives/fitting/models.py	(revision aa92772847a721d319785cd1ff15afdf17279082)
+++ sansview/perspectives/fitting/models.py	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
@@ -1,22 +1,19 @@
 import wx
-import os
+import imp
+import os,sys
 import os.path
 
 (ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent()
+def log(message):
+    print message
+    out = open("plugins.log", 'a')
+    out.write("%10g:  %s\n" % (time.clock(), message))
+    out.close()
+
 def findModels():
     print "looking for models"
-    try:
-        cwd= os.path.split(__file__)[0]
-    except:
-        cwd= os.getcwd()
-    print "models cwd",cwd
-    dir=os.path.join(cwd,'plugins')
-    print "models: find plugins",dir
-    if os.path.isdir(dir):
-        return _findModels(dir)
-    else:
-        return []
-    
-    
+    if os.path.isdir('plugins'):
+        return _findModels('plugins')
+    return []
     
 def _findModels(dir):
@@ -27,7 +24,5 @@
         list = os.listdir(dir)
         for item in list:
-            print "models: _findModels:",item
             toks = os.path.splitext(os.path.basename(item))
-            print "models: toks:",toks
             if toks[1]=='.py' and not toks[0]=='__init__':
                 name = toks[0]
@@ -37,5 +32,7 @@
                 try:
                     (file, path, info) = imp.find_module(name, path)
+                    print "models:module ",file
                     module = imp.load_module( name, file, item, info )
+                    print "models:module ",module
                     if hasattr(module, "Model"):
                         try:
@@ -44,5 +41,5 @@
                             log("Error accessing Model in %s\n  %s" % (name, sys.exc_value))
                 except:
-                    pass
+                    log("Error accessing Model in %s\n  %s" % (name, sys.exc_value))
                 finally:
                     if not file==None:
@@ -51,7 +48,4 @@
         pass
     return plugins
-    
-
-
 class ModelManager:
     
@@ -59,4 +53,6 @@
     model_list = {}
     model_list_box = {}
+    custom_models={}
+    plugins=[]
     ## Event owner
     event_owner = None
@@ -80,5 +76,7 @@
         from sans.guitools.LineModel import LineModel
         self.model_list[str(wx.NewId())]  = LineModel
-      
+        self.plugins =findModels()
+        
+        print "models: plugings",self.plugins
         return 0
 
@@ -96,5 +94,7 @@
         self._getModelList()
         self.event_owner = event_owner
-
+        shape_submenu= wx.Menu() 
+        indep_submenu = wx.Menu()
+        added_models = wx.Menu()
         for id_str,value in self.model_list.iteritems():
             item = self.model_list[id_str]
@@ -105,9 +105,27 @@
                 
             self.model_list_box[name] =value
-            
-            modelmenu.Append(int(id_str), name, name)
-            wx.EVT_MENU(event_owner, int(id_str), self._on_model)       
-        plugings=findModels()
-        print "models: plugings",plugings
+
+               
+            shape_submenu.Append(int(id_str), name, name)
+            wx.EVT_MENU(event_owner, int(id_str), self._on_model)
+        modelmenu.AppendMenu(wx.NewId(), "Shapes...", shape_submenu, "List of shape-based models")
+        modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models")
+        
+        id = wx.NewId()
+        if len(self.custom_models) == 0:
+            print self.plugins
+            for item in self.plugins:
+                if item not in self.custom_models.keys():
+                    self.custom_models[str(id)] = item
+                    self.model_list[str(id)]=item
+                    added_models.Append(id, item.name, item.name)
+                    wx.EVT_MENU(event_owner, int(id), self._on_model)
+                    id = wx.NewId()
+       
+           
+        modelmenu.AppendMenu(wx.NewId(),"Added models...", added_models, "List of additional models")
+        
+        
+        
         return 0
     
Index: sansview/plugins/testmodel.py
===================================================================
--- sansview/plugins/testmodel.py	(revision aa92772847a721d319785cd1ff15afdf17279082)
+++ sansview/plugins/testmodel.py	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
@@ -2,14 +2,56 @@
     Test plug-in model
 """
-try:
-    from DataPlugin import *
-except:
-    import sys, os
-    print os.path.abspath('..')
-    sys.path.insert(1,os.path.abspath('..'))
-    from DataPlugin import *
-    print "Running independently"
+#try:
+#    from DataPlugin import *
+#except:
+#    import sys, os
+#    print os.path.abspath('..')
+#    sys.path.insert(1,os.path.abspath('..'))
+#    from DataPlugin import *
+#    print "Running independently"
+#
+import math
+from sans.models.BaseComponent import BaseComponent
+import math
+class Model1DPlugin(BaseComponent):
+    ## Name of the model
+    name = "Plugin Model"
 
-import math
+    def __init__(self):
+        """ Initialization """
+        self.details = {}
+        self.params  = {}
+        
+    def function(self, x):
+        """
+            Function to be implemented by the plug-in writer
+        """
+        return x
+        
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: input x, or [x, phi] [radian]
+            @return: function value
+        """
+        if x.__class__.__name__ == 'list':
+            x_val = x[0]*math.cos(x[1])
+            y_val = x[0]*math.sin(x[1])
+            return self.function(x_val)*self.function(y_val)
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self.function(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: input x, or [x, y] 
+            @return: function value
+        """
+        if x.__class__.__name__ == 'list':
+            return self.function(x[0])*self.function(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self.function(x)
 
 # Your model HAS to be called Model
@@ -23,6 +65,5 @@
     def __init__(self):
         """ Initialization """
-        
-        Model1DPlugin.__init__(self)
+      
         
         ## Parameters definition and defaults
Index: sansview/setup_exe.py
===================================================================
--- sansview/setup_exe.py	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
+++ sansview/setup_exe.py	(revision b30f001fa5fa36cb40396b5855f07fb22b7ab742)
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+
+#
+# The setup to create a single exe file.
+#
+
+import os, sys
+
+from distutils.core import setup
+
+from distutils.filelist import findall
+
+import matplotlib
+
+import py2exe
+
+manifest = """
+   <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+   <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
+   manifestVersion="1.0">
+   <assemblyIdentity
+       version="0.64.1.0"
+       processorArchitecture="x86"
+       name="Controls"
+       type="win32"
+   />
+   <description>PrView</description>
+   <dependency>
+       <dependentAssembly>
+           <assemblyIdentity
+               type="win32"
+               name="Microsoft.Windows.Common-Controls"
+               version="6.0.0.0"
+               processorArchitecture="X86"
+               publicKeyToken="6595b64144ccf1df"
+               language="*"
+           />
+       </dependentAssembly>
+   </dependency>
+   </assembly>
+  """
+
+    
+class Target:
+    def __init__(self, **kw):
+        self.__dict__.update(kw)
+        # for the versioninfo resources
+        self.version = "0.1"
+        self.company_name = "U Tennessee"
+        self.copyright = "copyright 2008"
+        self.name = "PrView"
+        
+#
+# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
+# to use the MatPlotLib.
+#
+matplotlibdatadir = matplotlib.get_data_path()
+matplotlibdata = findall(matplotlibdatadir)
+matplotlibdata_files = []
+
+for f in matplotlibdata:
+    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
+    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))
+
+#
+# packages
+#
+packages = [
+    'matplotlib', 'pytz'
+    ]
+
+includes = []
+excludes = ['OpenGL'] 
+
+dll_excludes = [
+    'libgdk_pixbuf-2.0-0.dll', 
+    'libgobject-2.0-0.dll',
+    'libgdk-win32-2.0-0.dll',
+    ]
+
+## This is the client for PARK: run on wx
+target_wx_client = Target(
+    description = 'fit  viewer',
+    script = 'sansview.py',
+    #other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="AppJob"))],
+    icon_resources = [(1, "images/ball.ico")],
+    other_resources = [(24,1,manifest)],
+    dest_base = "sansView"
+    )
+
+
+
+setup(
+    windows=[target_wx_client],
+    console=[],
+    
+    options={
+        'py2exe': {
+            'dll_excludes': dll_excludes,
+            'packages' : packages,
+            'includes':includes,
+            'excludes':excludes,
+            "compressed": 1,
+            "optimize": 0,
+            "bundle_files":2,
+            },
+    },
+    data_files=matplotlibdata_files
+    
+    # Do something like this to add images to the distribution
+    #data_files=[ ("prog",["kategorien.xml",])]
+)
+
+
