[33afff7] | 1 | |
---|
[d89f09b] | 2 | import wx |
---|
[bb18ef1] | 3 | import wx.lib.newevent |
---|
[b30f001] | 4 | import imp |
---|
[9466f2d6] | 5 | import os |
---|
| 6 | import sys |
---|
| 7 | import math |
---|
[d89f09b] | 8 | import os.path |
---|
[33afff7] | 9 | # Time is needed by the log method |
---|
| 10 | import time |
---|
[23ccf07] | 11 | import logging |
---|
[5d1c1f4] | 12 | import py_compile |
---|
[96814e1] | 13 | import shutil |
---|
[9466f2d6] | 14 | from sans.guiframe.events import StatusEvent |
---|
[33afff7] | 15 | # Explicitly import from the pluginmodel module so that py2exe |
---|
| 16 | # places it in the distribution. The Model1DPlugin class is used |
---|
| 17 | # as the base class of plug-in models. |
---|
| 18 | from sans.models.pluginmodel import Model1DPlugin |
---|
[9466f2d6] | 19 | |
---|
[8ab3302] | 20 | PLUGIN_DIR = 'plugin_models' |
---|
[9466f2d6] | 21 | |
---|
[b30f001] | 22 | def log(message): |
---|
[5062bbf] | 23 | """ |
---|
| 24 | """ |
---|
[b30ed8f] | 25 | dir = os.path.join(os.path.expanduser("~"),'.sansview', PLUGIN_DIR) |
---|
| 26 | out = open(os.path.join(dir, "plugins.log"), 'a') |
---|
[b30f001] | 27 | out.write("%10g: %s\n" % (time.clock(), message)) |
---|
| 28 | out.close() |
---|
| 29 | |
---|
[9466f2d6] | 30 | |
---|
[bfe4644] | 31 | def _check_plugin(model, name): |
---|
| 32 | """ |
---|
[5062bbf] | 33 | Do some checking before model adding plugins in the list |
---|
| 34 | |
---|
| 35 | :param model: class model to add into the plugin list |
---|
| 36 | :param name:name of the module plugin |
---|
| 37 | |
---|
| 38 | :return model: model if valid model or None if not valid |
---|
| 39 | |
---|
[bfe4644] | 40 | """ |
---|
| 41 | #Check is the plugin is of type Model1DPlugin |
---|
| 42 | if not issubclass(model, Model1DPlugin): |
---|
[9a22655] | 43 | msg = "Plugin %s must be of type Model1DPlugin \n"%str(name) |
---|
[bfe4644] | 44 | log(msg) |
---|
[8d78399] | 45 | return None |
---|
[bfe4644] | 46 | if model.__name__!="Model": |
---|
| 47 | msg= "Plugin %s class name must be Model \n"%str(name) |
---|
| 48 | log(msg) |
---|
[8d78399] | 49 | return None |
---|
[bfe4644] | 50 | try: |
---|
| 51 | new_instance= model() |
---|
| 52 | except: |
---|
| 53 | msg="Plugin %s error in __init__ \n\t: %s %s\n"%(str(name), |
---|
| 54 | str(sys.exc_type),sys.exc_value) |
---|
| 55 | log(msg) |
---|
[8d78399] | 56 | return None |
---|
[bfe4644] | 57 | |
---|
| 58 | new_instance= model() |
---|
| 59 | if hasattr(new_instance,"function"): |
---|
| 60 | try: |
---|
| 61 | value=new_instance.function() |
---|
| 62 | except: |
---|
| 63 | msg="Plugin %s: error writing function \n\t :%s %s\n "%(str(name), |
---|
| 64 | str(sys.exc_type),sys.exc_value) |
---|
| 65 | log(msg) |
---|
[8d78399] | 66 | return None |
---|
[bfe4644] | 67 | else: |
---|
| 68 | msg="Plugin %s needs a method called function \n"%str(name) |
---|
| 69 | log(msg) |
---|
[8d78399] | 70 | return None |
---|
[bfe4644] | 71 | return model |
---|
| 72 | |
---|
[5d1c1f4] | 73 | def find_plugins_dir(): |
---|
[5062bbf] | 74 | """ |
---|
[96814e1] | 75 | Find path of the plugins directory. |
---|
| 76 | The plugin directory is located in the user's home directory. |
---|
[5062bbf] | 77 | """ |
---|
[8ab3302] | 78 | dir = os.path.join(os.path.expanduser("~"),'.sansview', PLUGIN_DIR) |
---|
[96814e1] | 79 | |
---|
| 80 | # If the plugin directory doesn't exist, create it |
---|
[a0986f6] | 81 | if not os.path.isdir(dir): |
---|
[96814e1] | 82 | os.makedirs(dir) |
---|
| 83 | |
---|
[8ab3302] | 84 | # Find paths needed |
---|
| 85 | try: |
---|
| 86 | # For source |
---|
| 87 | if os.path.isdir(os.path.dirname(__file__)): |
---|
| 88 | p_dir = os.path.join(os.path.dirname(__file__), PLUGIN_DIR) |
---|
| 89 | else: |
---|
| 90 | raise |
---|
| 91 | except: |
---|
| 92 | # Check for data path next to exe/zip file. |
---|
| 93 | #Look for maximum n_dir up of the current dir to find plugins dir |
---|
| 94 | n_dir = 12 |
---|
| 95 | p_dir = None |
---|
| 96 | f_dir = os.path.join(os.path.dirname(__file__)) |
---|
| 97 | for i in range(n_dir): |
---|
| 98 | if i > 1: |
---|
| 99 | f_dir, _ = os.path.split(f_dir) |
---|
| 100 | plugin_path = os.path.join(f_dir, PLUGIN_DIR) |
---|
| 101 | if os.path.isdir(plugin_path): |
---|
| 102 | p_dir = plugin_path |
---|
| 103 | break |
---|
| 104 | if not p_dir: |
---|
| 105 | raise |
---|
| 106 | |
---|
[96814e1] | 107 | # Place example user models as needed |
---|
[8ab3302] | 108 | for file in os.listdir(p_dir): |
---|
| 109 | file_path = os.path.join(p_dir, file) |
---|
| 110 | if os.path.isfile(file_path): |
---|
| 111 | if file.split(".")[-1] == 'py' and\ |
---|
| 112 | file.split(".")[0] != '__init__': |
---|
| 113 | if not os.path.isfile(os.path.join(dir, file)): |
---|
| 114 | shutil.copy(file_path, dir) |
---|
[5d1c1f4] | 115 | return dir |
---|
| 116 | |
---|
| 117 | class ReportProblem: |
---|
| 118 | def __nonzero__(self): |
---|
| 119 | type, value, traceback = sys.exc_info() |
---|
| 120 | if type is not None and issubclass(type, py_compile.PyCompileError): |
---|
| 121 | print "Problem with", repr(value) |
---|
| 122 | raise type, value, traceback |
---|
| 123 | return 1 |
---|
| 124 | |
---|
| 125 | report_problem = ReportProblem() |
---|
| 126 | |
---|
| 127 | def compile_file(dir): |
---|
| 128 | """ |
---|
| 129 | Compile a py file |
---|
| 130 | """ |
---|
| 131 | try: |
---|
| 132 | import compileall |
---|
| 133 | compileall.compile_dir(dir=dir, ddir=dir, force=1, quiet=report_problem) |
---|
| 134 | except: |
---|
| 135 | type, value, traceback = sys.exc_info() |
---|
| 136 | return value |
---|
| 137 | return None |
---|
| 138 | |
---|
| 139 | def _findModels(dir): |
---|
| 140 | """ |
---|
| 141 | """ |
---|
| 142 | # List of plugin objects |
---|
| 143 | plugins = {} |
---|
| 144 | # Go through files in plug-in directory |
---|
| 145 | #always recompile the folder plugin |
---|
| 146 | import compileall |
---|
| 147 | dir = find_plugins_dir() |
---|
[a0986f6] | 148 | if not os.path.isdir(dir): |
---|
| 149 | msg = "SansView couldn't locate Model plugin folder." |
---|
| 150 | msg += """ "%s" does not exist""" % dir |
---|
| 151 | logging.warning(msg) |
---|
| 152 | return plugins |
---|
| 153 | else: |
---|
| 154 | log("looking for models in: %s" % str(dir)) |
---|
[5d1c1f4] | 155 | compile_file(dir) |
---|
[a0986f6] | 156 | logging.info("pluging model dir: %s\n" % str(dir)) |
---|
[1c66bc5] | 157 | try: |
---|
| 158 | list = os.listdir(dir) |
---|
| 159 | for item in list: |
---|
| 160 | toks = os.path.splitext(os.path.basename(item)) |
---|
| 161 | if toks[1]=='.py' and not toks[0]=='__init__': |
---|
| 162 | name = toks[0] |
---|
| 163 | |
---|
| 164 | path = [os.path.abspath(dir)] |
---|
| 165 | file = None |
---|
| 166 | try: |
---|
| 167 | (file, path, info) = imp.find_module(name, path) |
---|
| 168 | module = imp.load_module( name, file, item, info ) |
---|
| 169 | if hasattr(module, "Model"): |
---|
| 170 | try: |
---|
[bfe4644] | 171 | if _check_plugin(module.Model, name)!=None: |
---|
[b2d9826] | 172 | plugins[name] = module.Model |
---|
[1c66bc5] | 173 | except: |
---|
[bfe4644] | 174 | msg="Error accessing Model" |
---|
| 175 | msg+="in %s\n %s %s\n" % (name, |
---|
| 176 | str(sys.exc_type), sys.exc_value) |
---|
| 177 | log(msg) |
---|
[1c66bc5] | 178 | except: |
---|
[bfe4644] | 179 | msg="Error accessing Model" |
---|
| 180 | msg +=" in %s\n %s %s \n" %(name, |
---|
| 181 | str(sys.exc_type), sys.exc_value) |
---|
| 182 | log(msg) |
---|
[1c66bc5] | 183 | finally: |
---|
[a92d51b] | 184 | |
---|
[1c66bc5] | 185 | if not file==None: |
---|
| 186 | file.close() |
---|
| 187 | except: |
---|
[33afff7] | 188 | # Don't deal with bad plug-in imports. Just skip. |
---|
[23ccf07] | 189 | msg = "Could not import model plugin: %s\n" % sys.exc_value |
---|
| 190 | log(msg) |
---|
[1c66bc5] | 191 | pass |
---|
| 192 | return plugins |
---|
[bb18ef1] | 193 | |
---|
| 194 | class ModelList(object): |
---|
| 195 | """ |
---|
[5062bbf] | 196 | Contains dictionary of model and their type |
---|
[bb18ef1] | 197 | """ |
---|
| 198 | def __init__(self): |
---|
[5062bbf] | 199 | """ |
---|
| 200 | """ |
---|
| 201 | self.mydict = {} |
---|
[bb18ef1] | 202 | |
---|
| 203 | def set_list(self, name, mylist): |
---|
| 204 | """ |
---|
[5062bbf] | 205 | :param name: the type of the list |
---|
| 206 | :param mylist: the list to add |
---|
| 207 | |
---|
[bb18ef1] | 208 | """ |
---|
| 209 | if name not in self.mydict.keys(): |
---|
[916f5c0] | 210 | self.reset_list(name, mylist) |
---|
[bb18ef1] | 211 | |
---|
[916f5c0] | 212 | def reset_list(self, name, mylist): |
---|
| 213 | """ |
---|
| 214 | :param name: the type of the list |
---|
| 215 | :param mylist: the list to add |
---|
| 216 | """ |
---|
| 217 | self.mydict[name] = mylist |
---|
[bb18ef1] | 218 | |
---|
| 219 | def get_list(self): |
---|
| 220 | """ |
---|
[5062bbf] | 221 | return all the list stored in a dictionary object |
---|
[bb18ef1] | 222 | """ |
---|
| 223 | return self.mydict |
---|
| 224 | |
---|
[bb9f322] | 225 | class ModelManagerBase: |
---|
[5062bbf] | 226 | """ |
---|
| 227 | """ |
---|
[bb18ef1] | 228 | ## external dict for models |
---|
| 229 | model_combobox = ModelList() |
---|
| 230 | ## Dictionary of form models |
---|
| 231 | form_factor_dict = {} |
---|
| 232 | ## dictionary of other |
---|
| 233 | struct_factor_dict = {} |
---|
| 234 | ##list of form factors |
---|
[b2d9826] | 235 | shape_list = [] |
---|
[bb18ef1] | 236 | ## independent shape model list |
---|
| 237 | shape_indep_list = [] |
---|
| 238 | ##list of structure factors |
---|
[b2d9826] | 239 | struct_list = [] |
---|
[376916c] | 240 | ##list of model allowing multiplication |
---|
[b2d9826] | 241 | multiplication_factor = [] |
---|
[e87f9fc] | 242 | ##list of multifunctional shapes |
---|
[b2d9826] | 243 | multi_func_list = [] |
---|
[bb18ef1] | 244 | ## list of added models |
---|
[b2d9826] | 245 | plugins = [] |
---|
[bb18ef1] | 246 | ## Event owner (guiframe) |
---|
[d89f09b] | 247 | event_owner = None |
---|
[9466f2d6] | 248 | last_time_dir_modified = 0 |
---|
[6bbeacd4] | 249 | def __init__(self): |
---|
| 250 | """ |
---|
| 251 | """ |
---|
[b2d9826] | 252 | self.stored_plugins = {} |
---|
[6bbeacd4] | 253 | self._getModelList() |
---|
| 254 | |
---|
[9466f2d6] | 255 | def findModels(self): |
---|
| 256 | """ |
---|
| 257 | find plugin model in directory of plugin .recompile all file |
---|
| 258 | in the directory if file were modified |
---|
| 259 | """ |
---|
[23ccf07] | 260 | temp = {} |
---|
[9466f2d6] | 261 | if self.is_changed(): |
---|
[a0986f6] | 262 | return _findModels(dir) |
---|
[23ccf07] | 263 | logging.info("pluging model : %s\n" % str(temp)) |
---|
| 264 | return temp |
---|
| 265 | |
---|
[d89f09b] | 266 | def _getModelList(self): |
---|
| 267 | """ |
---|
[5062bbf] | 268 | List of models we want to make available by default |
---|
| 269 | for this application |
---|
| 270 | |
---|
| 271 | :return: the next free event ID following the new menu events |
---|
[e7b1ccf] | 272 | |
---|
[d89f09b] | 273 | """ |
---|
[7c8d3093] | 274 | # regular model names only |
---|
| 275 | self.model_name_list = [] |
---|
[442895f] | 276 | from sans.models.SphereModel import SphereModel |
---|
[bb18ef1] | 277 | self.shape_list.append(SphereModel) |
---|
[376916c] | 278 | self.multiplication_factor.append(SphereModel) |
---|
[7c8d3093] | 279 | self.model_name_list.append(SphereModel.__name__) |
---|
[442895f] | 280 | |
---|
[1a395a6] | 281 | from sans.models.BinaryHSModel import BinaryHSModel |
---|
| 282 | self.shape_list.append(BinaryHSModel) |
---|
[7c8d3093] | 283 | self.model_name_list.append(BinaryHSModel.__name__) |
---|
[1a395a6] | 284 | |
---|
[ce07fa8] | 285 | from sans.models.FuzzySphereModel import FuzzySphereModel |
---|
| 286 | self.shape_list.append(FuzzySphereModel) |
---|
| 287 | self.multiplication_factor.append(FuzzySphereModel) |
---|
[7c8d3093] | 288 | self.model_name_list.append(FuzzySphereModel.__name__) |
---|
[7289627] | 289 | |
---|
[442895f] | 290 | from sans.models.CoreShellModel import CoreShellModel |
---|
[bb18ef1] | 291 | self.shape_list.append(CoreShellModel) |
---|
[5eb9154] | 292 | self.multiplication_factor.append(CoreShellModel) |
---|
[7c8d3093] | 293 | self.model_name_list.append(CoreShellModel.__name__) |
---|
[4523b68] | 294 | |
---|
[7289627] | 295 | from sans.models.Core2ndMomentModel import Core2ndMomentModel |
---|
| 296 | self.shape_list.append(Core2ndMomentModel) |
---|
| 297 | self.model_name_list.append(Core2ndMomentModel.__name__) |
---|
| 298 | |
---|
[4523b68] | 299 | from sans.models.CoreMultiShellModel import CoreMultiShellModel |
---|
| 300 | self.shape_list.append(CoreMultiShellModel) |
---|
| 301 | self.multiplication_factor.append(CoreMultiShellModel) |
---|
[a1b2471] | 302 | self.multi_func_list.append(CoreMultiShellModel) |
---|
[fb59ed9] | 303 | |
---|
[eddff027] | 304 | from sans.models.VesicleModel import VesicleModel |
---|
| 305 | self.shape_list.append(VesicleModel) |
---|
[5eb9154] | 306 | self.multiplication_factor.append(VesicleModel) |
---|
[7c8d3093] | 307 | self.model_name_list.append(VesicleModel.__name__) |
---|
[5eb9154] | 308 | |
---|
| 309 | from sans.models.MultiShellModel import MultiShellModel |
---|
| 310 | self.shape_list.append(MultiShellModel) |
---|
| 311 | self.multiplication_factor.append(MultiShellModel) |
---|
[7c8d3093] | 312 | self.model_name_list.append(MultiShellModel.__name__) |
---|
[eddff027] | 313 | |
---|
[1a395a6] | 314 | from sans.models.OnionExpShellModel import OnionExpShellModel |
---|
| 315 | self.shape_list.append(OnionExpShellModel) |
---|
| 316 | self.multiplication_factor.append(OnionExpShellModel) |
---|
| 317 | self.multi_func_list.append(OnionExpShellModel) |
---|
[463eb76e] | 318 | |
---|
[1a395a6] | 319 | from sans.models.SphericalSLDModel import SphericalSLDModel |
---|
| 320 | self.shape_list.append(SphericalSLDModel) |
---|
| 321 | self.multiplication_factor.append(SphericalSLDModel) |
---|
| 322 | self.multi_func_list.append(SphericalSLDModel) |
---|
[cee6867] | 323 | |
---|
[d9547e7] | 324 | from sans.models.LinearPearlsModel import LinearPearlsModel |
---|
| 325 | self.shape_list.append(LinearPearlsModel) |
---|
| 326 | self.model_name_list.append(LinearPearlsModel.__name__) |
---|
| 327 | |
---|
[4ad076b] | 328 | from sans.models.PearlNecklaceModel import PearlNecklaceModel |
---|
| 329 | self.shape_list.append(PearlNecklaceModel) |
---|
[7c8d3093] | 330 | self.model_name_list.append(PearlNecklaceModel.__name__) |
---|
[4ad076b] | 331 | #self.multiplication_factor.append(PearlNecklaceModel) |
---|
| 332 | |
---|
[eddff027] | 333 | from sans.models.CylinderModel import CylinderModel |
---|
| 334 | self.shape_list.append(CylinderModel) |
---|
| 335 | self.multiplication_factor.append(CylinderModel) |
---|
[7c8d3093] | 336 | self.model_name_list.append(CylinderModel.__name__) |
---|
[eddff027] | 337 | |
---|
| 338 | from sans.models.CoreShellCylinderModel import CoreShellCylinderModel |
---|
| 339 | self.shape_list.append(CoreShellCylinderModel) |
---|
[5eb9154] | 340 | self.multiplication_factor.append(CoreShellCylinderModel) |
---|
[7c8d3093] | 341 | self.model_name_list.append(CoreShellCylinderModel.__name__) |
---|
[cee6867] | 342 | |
---|
[543d1bd] | 343 | from sans.models.CoreShellBicelleModel import CoreShellBicelleModel |
---|
| 344 | self.shape_list.append(CoreShellBicelleModel) |
---|
| 345 | self.multiplication_factor.append(CoreShellBicelleModel) |
---|
| 346 | self.model_name_list.append(CoreShellBicelleModel.__name__) |
---|
| 347 | |
---|
[cee6867] | 348 | from sans.models.HollowCylinderModel import HollowCylinderModel |
---|
| 349 | self.shape_list.append(HollowCylinderModel) |
---|
[5eb9154] | 350 | self.multiplication_factor.append(HollowCylinderModel) |
---|
[7c8d3093] | 351 | self.model_name_list.append(HollowCylinderModel.__name__) |
---|
[eddff027] | 352 | |
---|
| 353 | from sans.models.FlexibleCylinderModel import FlexibleCylinderModel |
---|
| 354 | self.shape_list.append(FlexibleCylinderModel) |
---|
[7c8d3093] | 355 | self.model_name_list.append(FlexibleCylinderModel.__name__) |
---|
[72f719b] | 356 | |
---|
[ce07fa8] | 357 | from sans.models.FlexCylEllipXModel import FlexCylEllipXModel |
---|
| 358 | self.shape_list.append(FlexCylEllipXModel) |
---|
[7c8d3093] | 359 | self.model_name_list.append(FlexCylEllipXModel.__name__) |
---|
[eddff027] | 360 | |
---|
| 361 | from sans.models.StackedDisksModel import StackedDisksModel |
---|
| 362 | self.shape_list.append(StackedDisksModel) |
---|
[5eb9154] | 363 | self.multiplication_factor.append(StackedDisksModel) |
---|
[7c8d3093] | 364 | self.model_name_list.append(StackedDisksModel.__name__) |
---|
[eddff027] | 365 | |
---|
| 366 | from sans.models.ParallelepipedModel import ParallelepipedModel |
---|
| 367 | self.shape_list.append(ParallelepipedModel) |
---|
[72f719b] | 368 | self.multiplication_factor.append(ParallelepipedModel) |
---|
[7c8d3093] | 369 | self.model_name_list.append(ParallelepipedModel.__name__) |
---|
[cee6867] | 370 | |
---|
[fb59ed9] | 371 | from sans.models.CSParallelepipedModel import CSParallelepipedModel |
---|
| 372 | self.shape_list.append(CSParallelepipedModel) |
---|
| 373 | self.multiplication_factor.append(CSParallelepipedModel) |
---|
[7c8d3093] | 374 | self.model_name_list.append(CSParallelepipedModel.__name__) |
---|
[fb59ed9] | 375 | |
---|
[442895f] | 376 | from sans.models.EllipticalCylinderModel import EllipticalCylinderModel |
---|
[bb18ef1] | 377 | self.shape_list.append(EllipticalCylinderModel) |
---|
[72f719b] | 378 | self.multiplication_factor.append(EllipticalCylinderModel) |
---|
[7c8d3093] | 379 | self.model_name_list.append(EllipticalCylinderModel.__name__) |
---|
[fb59ed9] | 380 | |
---|
| 381 | from sans.models.BarBellModel import BarBellModel |
---|
| 382 | self.shape_list.append(BarBellModel) |
---|
[7c8d3093] | 383 | self.model_name_list.append(BarBellModel.__name__) |
---|
[fb59ed9] | 384 | # not implemeted yet! |
---|
| 385 | #self.multiplication_factor.append(BarBellModel) |
---|
| 386 | |
---|
| 387 | from sans.models.CappedCylinderModel import CappedCylinderModel |
---|
| 388 | self.shape_list.append(CappedCylinderModel) |
---|
[7c8d3093] | 389 | self.model_name_list.append(CappedCylinderModel.__name__) |
---|
[fb59ed9] | 390 | # not implemeted yet! |
---|
| 391 | #self.multiplication_factor.append(CappedCylinderModel) |
---|
| 392 | |
---|
[442895f] | 393 | from sans.models.EllipsoidModel import EllipsoidModel |
---|
[bb18ef1] | 394 | self.shape_list.append(EllipsoidModel) |
---|
[376916c] | 395 | self.multiplication_factor.append(EllipsoidModel) |
---|
[7c8d3093] | 396 | self.model_name_list.append(EllipsoidModel.__name__) |
---|
[eddff027] | 397 | |
---|
| 398 | from sans.models.CoreShellEllipsoidModel import CoreShellEllipsoidModel |
---|
| 399 | self.shape_list.append(CoreShellEllipsoidModel) |
---|
[5eb9154] | 400 | self.multiplication_factor.append(CoreShellEllipsoidModel) |
---|
[7c8d3093] | 401 | self.model_name_list.append(CoreShellEllipsoidModel.__name__) |
---|
[bb18ef1] | 402 | |
---|
[e65050e] | 403 | from sans.models.TriaxialEllipsoidModel import TriaxialEllipsoidModel |
---|
| 404 | self.shape_list.append(TriaxialEllipsoidModel) |
---|
[9002927] | 405 | self.multiplication_factor.append(TriaxialEllipsoidModel) |
---|
[7c8d3093] | 406 | self.model_name_list.append(TriaxialEllipsoidModel.__name__) |
---|
[e65050e] | 407 | |
---|
| 408 | from sans.models.LamellarModel import LamellarModel |
---|
| 409 | self.shape_list.append(LamellarModel) |
---|
[7c8d3093] | 410 | self.model_name_list.append(LamellarModel.__name__) |
---|
[e65050e] | 411 | |
---|
| 412 | from sans.models.LamellarFFHGModel import LamellarFFHGModel |
---|
| 413 | self.shape_list.append(LamellarFFHGModel) |
---|
[7c8d3093] | 414 | self.model_name_list.append(LamellarFFHGModel.__name__) |
---|
[e65050e] | 415 | |
---|
| 416 | from sans.models.LamellarPSModel import LamellarPSModel |
---|
| 417 | self.shape_list.append(LamellarPSModel) |
---|
[7c8d3093] | 418 | self.model_name_list.append(LamellarPSModel.__name__) |
---|
[7a69683] | 419 | |
---|
[e65050e] | 420 | from sans.models.LamellarPSHGModel import LamellarPSHGModel |
---|
| 421 | self.shape_list.append(LamellarPSHGModel) |
---|
[7c8d3093] | 422 | self.model_name_list.append(LamellarPSHGModel.__name__) |
---|
[fb59ed9] | 423 | |
---|
| 424 | from sans.models.LamellarPCrystalModel import LamellarPCrystalModel |
---|
| 425 | self.shape_list.append(LamellarPCrystalModel) |
---|
[7c8d3093] | 426 | self.model_name_list.append(LamellarPCrystalModel.__name__) |
---|
[fb59ed9] | 427 | |
---|
| 428 | from sans.models.SCCrystalModel import SCCrystalModel |
---|
| 429 | self.shape_list.append(SCCrystalModel) |
---|
[7c8d3093] | 430 | self.model_name_list.append(SCCrystalModel.__name__) |
---|
[fb59ed9] | 431 | |
---|
| 432 | from sans.models.FCCrystalModel import FCCrystalModel |
---|
| 433 | self.shape_list.append(FCCrystalModel) |
---|
[7c8d3093] | 434 | self.model_name_list.append(FCCrystalModel.__name__) |
---|
[fb59ed9] | 435 | |
---|
| 436 | from sans.models.BCCrystalModel import BCCrystalModel |
---|
| 437 | self.shape_list.append(BCCrystalModel) |
---|
[7c8d3093] | 438 | self.model_name_list.append(BCCrystalModel.__name__) |
---|
[7a69683] | 439 | |
---|
[376916c] | 440 | ## Structure factor |
---|
[8346667] | 441 | from sans.models.SquareWellStructure import SquareWellStructure |
---|
[bb18ef1] | 442 | self.struct_list.append(SquareWellStructure) |
---|
[7c8d3093] | 443 | self.model_name_list.append(SquareWellStructure.__name__) |
---|
[8346667] | 444 | |
---|
| 445 | from sans.models.HardsphereStructure import HardsphereStructure |
---|
[bb18ef1] | 446 | self.struct_list.append(HardsphereStructure) |
---|
[7c8d3093] | 447 | self.model_name_list.append(HardsphereStructure.__name__) |
---|
[bb18ef1] | 448 | |
---|
[8346667] | 449 | from sans.models.StickyHSStructure import StickyHSStructure |
---|
[bb18ef1] | 450 | self.struct_list.append(StickyHSStructure) |
---|
[7c8d3093] | 451 | self.model_name_list.append(StickyHSStructure.__name__) |
---|
[8346667] | 452 | |
---|
| 453 | from sans.models.HayterMSAStructure import HayterMSAStructure |
---|
[bb18ef1] | 454 | self.struct_list.append(HayterMSAStructure) |
---|
[7c8d3093] | 455 | self.model_name_list.append(HayterMSAStructure.__name__) |
---|
[fb59ed9] | 456 | |
---|
| 457 | ##shape-independent models |
---|
[ce07fa8] | 458 | from sans.models.PowerLawAbsModel import PowerLawAbsModel |
---|
| 459 | self.shape_indep_list.append( PowerLawAbsModel ) |
---|
[7c8d3093] | 460 | self.model_name_list.append(PowerLawAbsModel.__name__) |
---|
[ce07fa8] | 461 | |
---|
[442895f] | 462 | from sans.models.BEPolyelectrolyte import BEPolyelectrolyte |
---|
[bb18ef1] | 463 | self.shape_indep_list.append(BEPolyelectrolyte ) |
---|
[7c8d3093] | 464 | self.model_name_list.append(BEPolyelectrolyte.__name__) |
---|
[bb18ef1] | 465 | self.form_factor_dict[str(wx.NewId())] = [SphereModel] |
---|
[fb59ed9] | 466 | |
---|
| 467 | from sans.models.BroadPeakModel import BroadPeakModel |
---|
| 468 | self.shape_indep_list.append(BroadPeakModel) |
---|
[7c8d3093] | 469 | self.model_name_list.append(BroadPeakModel.__name__) |
---|
[fb59ed9] | 470 | |
---|
| 471 | from sans.models.CorrLengthModel import CorrLengthModel |
---|
| 472 | self.shape_indep_list.append(CorrLengthModel) |
---|
[7c8d3093] | 473 | self.model_name_list.append(CorrLengthModel.__name__) |
---|
[fb59ed9] | 474 | |
---|
[442895f] | 475 | from sans.models.DABModel import DABModel |
---|
[bb18ef1] | 476 | self.shape_indep_list.append(DABModel ) |
---|
[7c8d3093] | 477 | self.model_name_list.append(DABModel.__name__) |
---|
[442895f] | 478 | |
---|
[ce07fa8] | 479 | from sans.models.DebyeModel import DebyeModel |
---|
| 480 | self.shape_indep_list.append(DebyeModel ) |
---|
[7c8d3093] | 481 | self.model_name_list.append(DebyeModel.__name__) |
---|
[ce07fa8] | 482 | |
---|
[fb59ed9] | 483 | #FractalModel (a c-model)is now being used instead of FractalAbsModel. |
---|
[ce07fa8] | 484 | from sans.models.FractalModel import FractalModel |
---|
| 485 | self.shape_indep_list.append(FractalModel ) |
---|
[7c8d3093] | 486 | self.model_name_list.append(FractalModel.__name__) |
---|
[bb18ef1] | 487 | |
---|
[fb59ed9] | 488 | from sans.models.FractalCoreShellModel import FractalCoreShellModel |
---|
| 489 | self.shape_indep_list.append(FractalCoreShellModel ) |
---|
[7c8d3093] | 490 | self.model_name_list.append(FractalCoreShellModel.__name__) |
---|
[fb59ed9] | 491 | |
---|
| 492 | from sans.models.GaussLorentzGelModel import GaussLorentzGelModel |
---|
| 493 | self.shape_indep_list.append(GaussLorentzGelModel) |
---|
[7c8d3093] | 494 | self.model_name_list.append(GaussLorentzGelModel.__name__) |
---|
[fb59ed9] | 495 | |
---|
| 496 | from sans.models.GuinierModel import GuinierModel |
---|
| 497 | self.shape_indep_list.append(GuinierModel ) |
---|
[7c8d3093] | 498 | self.model_name_list.append(GuinierModel.__name__) |
---|
[fb59ed9] | 499 | |
---|
| 500 | from sans.models.GuinierPorodModel import GuinierPorodModel |
---|
| 501 | self.shape_indep_list.append(GuinierPorodModel ) |
---|
[7c8d3093] | 502 | self.model_name_list.append(GuinierPorodModel.__name__) |
---|
[fb59ed9] | 503 | |
---|
[ce07fa8] | 504 | from sans.models.LorentzModel import LorentzModel |
---|
| 505 | self.shape_indep_list.append( LorentzModel) |
---|
[7c8d3093] | 506 | self.model_name_list.append(LorentzModel.__name__) |
---|
[51da9dc] | 507 | |
---|
| 508 | from sans.models.MassFractalModel import MassFractalModel |
---|
| 509 | self.shape_indep_list.append(MassFractalModel) |
---|
| 510 | self.model_name_list.append(MassFractalModel.__name__) |
---|
| 511 | |
---|
| 512 | from sans.models.MassSurfaceFractal import MassSurfaceFractal |
---|
| 513 | self.shape_indep_list.append(MassSurfaceFractal) |
---|
| 514 | self.model_name_list.append(MassSurfaceFractal.__name__) |
---|
[442895f] | 515 | |
---|
[cee6867] | 516 | from sans.models.PeakGaussModel import PeakGaussModel |
---|
| 517 | self.shape_indep_list.append(PeakGaussModel) |
---|
[7c8d3093] | 518 | self.model_name_list.append(PeakGaussModel.__name__) |
---|
[cee6867] | 519 | |
---|
| 520 | from sans.models.PeakLorentzModel import PeakLorentzModel |
---|
| 521 | self.shape_indep_list.append(PeakLorentzModel) |
---|
[7c8d3093] | 522 | self.model_name_list.append( PeakLorentzModel.__name__) |
---|
[cee6867] | 523 | |
---|
[ce07fa8] | 524 | from sans.models.Poly_GaussCoil import Poly_GaussCoil |
---|
| 525 | self.shape_indep_list.append(Poly_GaussCoil) |
---|
[7c8d3093] | 526 | self.model_name_list.append(Poly_GaussCoil.__name__) |
---|
[fb59ed9] | 527 | |
---|
| 528 | from sans.models.PolymerExclVolume import PolymerExclVolume |
---|
| 529 | self.shape_indep_list.append(PolymerExclVolume) |
---|
[7c8d3093] | 530 | self.model_name_list.append(PolymerExclVolume.__name__) |
---|
[fb59ed9] | 531 | |
---|
[ce07fa8] | 532 | from sans.models.PorodModel import PorodModel |
---|
[7c8d3093] | 533 | self.shape_indep_list.append(PorodModel ) |
---|
| 534 | self.model_name_list.append(PorodModel.__name__) |
---|
[442895f] | 535 | |
---|
[fb59ed9] | 536 | from sans.models.RPA10Model import RPA10Model |
---|
| 537 | self.shape_indep_list.append(RPA10Model) |
---|
| 538 | self.multi_func_list.append(RPA10Model) |
---|
[51da9dc] | 539 | |
---|
| 540 | from sans.models.SurfaceFractalModel import SurfaceFractalModel |
---|
| 541 | self.shape_indep_list.append(SurfaceFractalModel) |
---|
| 542 | self.model_name_list.append(SurfaceFractalModel.__name__) |
---|
[81bece4] | 543 | |
---|
[442895f] | 544 | from sans.models.TeubnerStreyModel import TeubnerStreyModel |
---|
[bb18ef1] | 545 | self.shape_indep_list.append(TeubnerStreyModel ) |
---|
[7c8d3093] | 546 | self.model_name_list.append(TeubnerStreyModel.__name__) |
---|
[eddff027] | 547 | |
---|
[fb59ed9] | 548 | from sans.models.TwoLorentzianModel import TwoLorentzianModel |
---|
| 549 | self.shape_indep_list.append(TwoLorentzianModel ) |
---|
[7c8d3093] | 550 | self.model_name_list.append(TwoLorentzianModel.__name__) |
---|
[fb59ed9] | 551 | |
---|
| 552 | from sans.models.TwoPowerLawModel import TwoPowerLawModel |
---|
| 553 | self.shape_indep_list.append(TwoPowerLawModel ) |
---|
[7c8d3093] | 554 | self.model_name_list.append(TwoPowerLawModel.__name__) |
---|
[fb59ed9] | 555 | |
---|
| 556 | from sans.models.UnifiedPowerRgModel import UnifiedPowerRgModel |
---|
| 557 | self.shape_indep_list.append(UnifiedPowerRgModel ) |
---|
| 558 | self.multi_func_list.append(UnifiedPowerRgModel) |
---|
| 559 | |
---|
[eddff027] | 560 | from sans.models.LineModel import LineModel |
---|
| 561 | self.shape_indep_list.append(LineModel) |
---|
[7c8d3093] | 562 | self.model_name_list.append(LineModel.__name__) |
---|
[5062bbf] | 563 | |
---|
[fb59ed9] | 564 | from sans.models.ReflectivityModel import ReflectivityModel |
---|
| 565 | self.multi_func_list.append(ReflectivityModel) |
---|
[1cc23fd] | 566 | |
---|
| 567 | from sans.models.ReflectivityIIModel import ReflectivityIIModel |
---|
| 568 | self.multi_func_list.append(ReflectivityIIModel) |
---|
[fb59ed9] | 569 | |
---|
[49b7efa] | 570 | #Looking for plugins |
---|
[9466f2d6] | 571 | self.stored_plugins = self.findModels() |
---|
[b2d9826] | 572 | self.plugins = self.stored_plugins.values() |
---|
[fb59ed9] | 573 | self.plugins.append(ReflectivityModel) |
---|
[1cc23fd] | 574 | self.plugins.append(ReflectivityIIModel) |
---|
[b2d9826] | 575 | self._get_multifunc_models() |
---|
| 576 | |
---|
[d89f09b] | 577 | return 0 |
---|
| 578 | |
---|
[9466f2d6] | 579 | def is_changed(self): |
---|
| 580 | """ |
---|
| 581 | check the last time the plugin dir has changed and return true |
---|
| 582 | is the directory was modified else return false |
---|
| 583 | """ |
---|
| 584 | is_modified = False |
---|
[96814e1] | 585 | plugin_dir = find_plugins_dir() |
---|
| 586 | if os.path.isdir(plugin_dir): |
---|
| 587 | temp = os.path.getmtime(plugin_dir) |
---|
[9466f2d6] | 588 | if self.last_time_dir_modified != temp: |
---|
| 589 | is_modified = True |
---|
| 590 | self.last_time_dir_modified = temp |
---|
[bb9f322] | 591 | |
---|
[9466f2d6] | 592 | return is_modified |
---|
[d89f09b] | 593 | |
---|
[b2d9826] | 594 | def update(self): |
---|
| 595 | """ |
---|
[9466f2d6] | 596 | return a dictionary of model if |
---|
| 597 | new models were added else return empty dictionary |
---|
[b2d9826] | 598 | """ |
---|
[9466f2d6] | 599 | new_plugins = self.findModels() |
---|
| 600 | if len(new_plugins) > 0: |
---|
| 601 | for name, plug in new_plugins.iteritems(): |
---|
| 602 | if name not in self.stored_plugins.keys(): |
---|
| 603 | self.stored_plugins[name] = plug |
---|
| 604 | self.plugins.append(plug) |
---|
| 605 | self.model_combobox.set_list("Customized Models", self.plugins) |
---|
| 606 | return self.model_combobox.get_list() |
---|
| 607 | else: |
---|
| 608 | return {} |
---|
[5d1c1f4] | 609 | |
---|
[916f5c0] | 610 | def pulgins_reset(self): |
---|
| 611 | """ |
---|
| 612 | return a dictionary of model |
---|
| 613 | """ |
---|
| 614 | self.plugins = [] |
---|
| 615 | new_plugins = _findModels(dir) |
---|
| 616 | for name, plug in new_plugins.iteritems(): |
---|
| 617 | for stored_name, stored_plug in self.stored_plugins.iteritems(): |
---|
| 618 | if name == stored_name: |
---|
| 619 | del self.stored_plugins[name] |
---|
| 620 | break |
---|
| 621 | self.stored_plugins[name] = plug |
---|
| 622 | self.plugins.append(plug) |
---|
| 623 | from sans.models.ReflectivityModel import ReflectivityModel |
---|
| 624 | from sans.models.ReflectivityIIModel import ReflectivityIIModel |
---|
| 625 | self.plugins.append(ReflectivityModel) |
---|
| 626 | self.plugins.append(ReflectivityIIModel) |
---|
| 627 | self.model_combobox.reset_list("Customized Models", self.plugins) |
---|
| 628 | return self.model_combobox.get_list() |
---|
| 629 | |
---|
[d89f09b] | 630 | def populate_menu(self, modelmenu, event_owner): |
---|
| 631 | """ |
---|
[5062bbf] | 632 | Populate a menu with our models |
---|
| 633 | |
---|
| 634 | :param id: first menu event ID to use when binding the menu events |
---|
| 635 | :param modelmenu: wx.Menu object to populate |
---|
| 636 | :param event_owner: wx object to bind the menu events to |
---|
| 637 | |
---|
| 638 | :return: the next free event ID following the new menu events |
---|
| 639 | |
---|
[d89f09b] | 640 | """ |
---|
[bb18ef1] | 641 | ## Fill model lists |
---|
[d89f09b] | 642 | self._getModelList() |
---|
[bb18ef1] | 643 | ## store reference to model menu of guiframe |
---|
| 644 | self.modelmenu = modelmenu |
---|
| 645 | ## guiframe reference |
---|
[d89f09b] | 646 | self.event_owner = event_owner |
---|
[bb18ef1] | 647 | |
---|
| 648 | shape_submenu = wx.Menu() |
---|
| 649 | shape_indep_submenu = wx.Menu() |
---|
| 650 | structure_factor = wx.Menu() |
---|
[b30f001] | 651 | added_models = wx.Menu() |
---|
[376916c] | 652 | multip_models = wx.Menu() |
---|
[bb18ef1] | 653 | ## create menu with shape |
---|
[5062bbf] | 654 | self._fill_simple_menu(menuinfo=["Shapes",shape_submenu," simple shape"], |
---|
| 655 | list1=self.shape_list) |
---|
[376916c] | 656 | |
---|
[5062bbf] | 657 | self._fill_simple_menu(menuinfo=["Shape-Independent",shape_indep_submenu, |
---|
[bb18ef1] | 658 | "List of shape-independent models"], |
---|
[5062bbf] | 659 | list1=self.shape_indep_list ) |
---|
[bb18ef1] | 660 | |
---|
[5062bbf] | 661 | self._fill_simple_menu(menuinfo=["Structure Factors",structure_factor, |
---|
[bb18ef1] | 662 | "List of Structure factors models" ], |
---|
[5062bbf] | 663 | list1=self.struct_list) |
---|
[bb18ef1] | 664 | |
---|
[5062bbf] | 665 | self._fill_plugin_menu(menuinfo=["Customized Models", added_models, |
---|
[376916c] | 666 | "List of additional models"], |
---|
[5062bbf] | 667 | list1=self.plugins) |
---|
[376916c] | 668 | |
---|
| 669 | self._fill_menu(menuinfo=["P(Q)*S(Q)",multip_models, |
---|
| 670 | "mulplication of 2 models"], |
---|
[5062bbf] | 671 | list1=self.multiplication_factor , |
---|
| 672 | list2= self.struct_list) |
---|
[d89f09b] | 673 | return 0 |
---|
| 674 | |
---|
[5062bbf] | 675 | def _fill_plugin_menu(self, menuinfo, list1): |
---|
[bfe4644] | 676 | """ |
---|
[5062bbf] | 677 | fill the plugin menu with costumized models |
---|
[bfe4644] | 678 | """ |
---|
| 679 | if len(list1)==0: |
---|
| 680 | id = wx.NewId() |
---|
| 681 | msg= "No model available check plugins.log for errors to fix problem" |
---|
| 682 | menuinfo[1].Append(int(id),"Empty",msg) |
---|
| 683 | self._fill_simple_menu( menuinfo,list1) |
---|
| 684 | |
---|
[5062bbf] | 685 | def _fill_simple_menu(self, menuinfo, list1): |
---|
[bb18ef1] | 686 | """ |
---|
[5062bbf] | 687 | Fill the menu with list item |
---|
| 688 | |
---|
| 689 | :param modelmenu: the menu to fill |
---|
| 690 | :param menuinfo: submenu item for the first column of this modelmenu |
---|
| 691 | with info.Should be a list : |
---|
| 692 | [name(string) , menu(wx.menu), help(string)] |
---|
| 693 | :param list1: contains item (form factor )to fill modelmenu second column |
---|
| 694 | |
---|
[bb18ef1] | 695 | """ |
---|
| 696 | if len(list1)>0: |
---|
| 697 | self.model_combobox.set_list(menuinfo[0],list1) |
---|
[e7b1ccf] | 698 | |
---|
[bb18ef1] | 699 | for item in list1: |
---|
[e7b1ccf] | 700 | try: |
---|
| 701 | id = wx.NewId() |
---|
| 702 | struct_factor=item() |
---|
| 703 | struct_name = struct_factor.__class__.__name__ |
---|
| 704 | if hasattr(struct_factor, "name"): |
---|
| 705 | struct_name = struct_factor.name |
---|
| 706 | |
---|
| 707 | menuinfo[1].Append(int(id),struct_name,struct_name) |
---|
| 708 | if not item in self.struct_factor_dict.itervalues(): |
---|
| 709 | self.struct_factor_dict[str(id)]= item |
---|
| 710 | wx.EVT_MENU(self.event_owner, int(id), self._on_model) |
---|
| 711 | except: |
---|
| 712 | msg= "Error Occured: %s"%sys.exc_value |
---|
| 713 | wx.PostEvent(self.event_owner, StatusEvent(status=msg)) |
---|
[bb18ef1] | 714 | |
---|
| 715 | id = wx.NewId() |
---|
| 716 | self.modelmenu.AppendMenu(id, menuinfo[0],menuinfo[1],menuinfo[2]) |
---|
| 717 | |
---|
[5062bbf] | 718 | def _fill_menu(self, menuinfo, list1, list2): |
---|
[bb18ef1] | 719 | """ |
---|
[5062bbf] | 720 | Fill the menu with list item |
---|
| 721 | |
---|
| 722 | :param menuinfo: submenu item for the first column of this modelmenu |
---|
| 723 | with info.Should be a list : |
---|
| 724 | [name(string) , menu(wx.menu), help(string)] |
---|
| 725 | :param list1: contains item (form factor )to fill modelmenu second column |
---|
| 726 | :param list2: contains item (Structure factor )to fill modelmenu |
---|
| 727 | third column |
---|
| 728 | |
---|
[bb18ef1] | 729 | """ |
---|
| 730 | if len(list1)>0: |
---|
| 731 | self.model_combobox.set_list(menuinfo[0],list1) |
---|
| 732 | |
---|
| 733 | for item in list1: |
---|
| 734 | form_factor= item() |
---|
| 735 | form_name = form_factor.__class__.__name__ |
---|
| 736 | if hasattr(form_factor, "name"): |
---|
| 737 | form_name = form_factor.name |
---|
| 738 | ### store form factor to return to other users |
---|
| 739 | newmenu= wx.Menu() |
---|
| 740 | if len(list2)>0: |
---|
| 741 | for model in list2: |
---|
| 742 | id = wx.NewId() |
---|
| 743 | struct_factor = model() |
---|
| 744 | name = struct_factor.__class__.__name__ |
---|
| 745 | if hasattr(struct_factor, "name"): |
---|
| 746 | name = struct_factor.name |
---|
| 747 | newmenu.Append(id,name, name) |
---|
| 748 | wx.EVT_MENU(self.event_owner, int(id), self._on_model) |
---|
| 749 | ## save form_fact and struct_fact |
---|
| 750 | self.form_factor_dict[int(id)] = [form_factor,struct_factor] |
---|
| 751 | |
---|
| 752 | form_id= wx.NewId() |
---|
| 753 | menuinfo[1].AppendMenu(int(form_id), form_name,newmenu,menuinfo[2]) |
---|
| 754 | id=wx.NewId() |
---|
| 755 | self.modelmenu.AppendMenu(id,menuinfo[0],menuinfo[1], menuinfo[2]) |
---|
| 756 | |
---|
[d89f09b] | 757 | def _on_model(self, evt): |
---|
| 758 | """ |
---|
[5062bbf] | 759 | React to a model menu event |
---|
| 760 | |
---|
| 761 | :param event: wx menu event |
---|
| 762 | |
---|
[d89f09b] | 763 | """ |
---|
[bb18ef1] | 764 | if int(evt.GetId()) in self.form_factor_dict.keys(): |
---|
| 765 | from sans.models.MultiplicationModel import MultiplicationModel |
---|
| 766 | model1, model2 = self.form_factor_dict[int(evt.GetId())] |
---|
[5062bbf] | 767 | model = MultiplicationModel(model1, model2) |
---|
[bb18ef1] | 768 | else: |
---|
| 769 | model= self.struct_factor_dict[str(evt.GetId())]() |
---|
[6886000] | 770 | evt = ModelEvent(model=model) |
---|
[bb18ef1] | 771 | wx.PostEvent(self.event_owner, evt) |
---|
[d89f09b] | 772 | |
---|
[fb59ed9] | 773 | def _get_multifunc_models(self): |
---|
| 774 | """ |
---|
| 775 | Get the multifunctional models |
---|
| 776 | """ |
---|
| 777 | for item in self.plugins: |
---|
| 778 | try: |
---|
| 779 | # check the multiplicity if any |
---|
| 780 | if item.multiplicity_info[0] > 1: |
---|
| 781 | self.multi_func_list.append(item) |
---|
| 782 | except: |
---|
| 783 | # pass to other items |
---|
| 784 | pass |
---|
| 785 | |
---|
[d89f09b] | 786 | def get_model_list(self): |
---|
[5062bbf] | 787 | """ |
---|
| 788 | return dictionary of models for fitpanel use |
---|
| 789 | |
---|
| 790 | """ |
---|
[6bbeacd4] | 791 | self.model_combobox.set_list("Shapes", self.shape_list) |
---|
| 792 | self.model_combobox.set_list("Shape-Independent", self.shape_indep_list) |
---|
| 793 | self.model_combobox.set_list("Structure Factors", self.struct_list) |
---|
| 794 | self.model_combobox.set_list("Customized Models", self.plugins) |
---|
| 795 | self.model_combobox.set_list("P(Q)*S(Q)", self.multiplication_factor) |
---|
[376916c] | 796 | self.model_combobox.set_list("multiplication", self.multiplication_factor) |
---|
[e87f9fc] | 797 | self.model_combobox.set_list("Multi-Functions", self.multi_func_list) |
---|
[b2d9826] | 798 | return self.model_combobox.get_list() |
---|
[d89f09b] | 799 | |
---|
[7c8d3093] | 800 | def get_model_name_list(self): |
---|
| 801 | """ |
---|
| 802 | return regular model name list |
---|
| 803 | """ |
---|
| 804 | return self.model_name_list |
---|
[376916c] | 805 | |
---|
[bb18ef1] | 806 | |
---|
[bb9f322] | 807 | class ModelManager(object): |
---|
| 808 | """ |
---|
| 809 | implement model |
---|
| 810 | """ |
---|
| 811 | __modelmanager = ModelManagerBase() |
---|
| 812 | |
---|
| 813 | def findModels(self): |
---|
| 814 | return self.__modelmanager.findModels() |
---|
| 815 | |
---|
| 816 | def _getModelList(self): |
---|
| 817 | return self.__modelmanager._getModelList() |
---|
| 818 | |
---|
| 819 | def is_changed(self): |
---|
| 820 | return self.__modelmanager.is_changed() |
---|
| 821 | |
---|
| 822 | def update(self): |
---|
| 823 | return self.__modelmanager.update() |
---|
| 824 | |
---|
[916f5c0] | 825 | def pulgins_reset(self): |
---|
| 826 | return self.__modelmanager.pulgins_reset() |
---|
| 827 | |
---|
[bb9f322] | 828 | def populate_menu(self, modelmenu, event_owner): |
---|
| 829 | return self.__modelmanager.populate_menu(modelmenu, event_owner) |
---|
| 830 | |
---|
| 831 | def _on_model(self, evt): |
---|
| 832 | return self.__modelmanager._on_model(evt) |
---|
| 833 | |
---|
| 834 | def _get_multifunc_models(self): |
---|
| 835 | return self.__modelmanager._get_multifunc_models() |
---|
| 836 | |
---|
| 837 | def get_model_list(self): |
---|
| 838 | return self.__modelmanager.get_model_list() |
---|
[bb18ef1] | 839 | |
---|
[7c8d3093] | 840 | def get_model_name_list(self): |
---|
| 841 | return self.__modelmanager.get_model_name_list() |
---|
| 842 | |
---|
[d89f09b] | 843 | |
---|
[bb18ef1] | 844 | |
---|