wolfhece 1.8.12__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. wolfhece/GraphNotebook.py +0 -1
  2. wolfhece/PyCrosssections.py +591 -5
  3. wolfhece/PyDraw.py +1151 -413
  4. wolfhece/PyGui.py +2 -4
  5. wolfhece/PyParams.py +1515 -852
  6. wolfhece/PyVertex.py +73 -73
  7. wolfhece/PyVertexvectors.py +226 -808
  8. wolfhece/RatingCurve.py +19 -6
  9. wolfhece/apps/wolf2D.py +11 -0
  10. wolfhece/apps/wolfcompare2Darrays.py +51 -22
  11. wolfhece/bernoulli/NetworkOpenGL.py +337 -341
  12. wolfhece/drawing_obj.py +25 -0
  13. wolfhece/hydrology/Catchment.py +77 -77
  14. wolfhece/hydrology/Optimisation.py +206 -53
  15. wolfhece/hydrology/PostProcessHydrology.py +22 -22
  16. wolfhece/hydrology/SubBasin.py +17 -17
  17. wolfhece/hydrology/constant.py +4 -0
  18. wolfhece/hydrology/cst_exchanges.py +2 -1
  19. wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
  20. wolfhece/lazviewer/vfuncs/vfuncs.cp310-win_amd64.pyd +0 -0
  21. wolfhece/libs/WolfDll.dll +0 -0
  22. wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
  23. wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
  24. wolfhece/mesh2d/wolf2dprev.py +4 -4
  25. wolfhece/multiprojects.py +13 -13
  26. wolfhece/pylogging.py +1 -1
  27. wolfhece/pyshields.py +213 -136
  28. wolfhece/pyviews.py +23 -23
  29. wolfhece/wolf_array.py +69 -152
  30. wolfhece/wolf_texture.py +39 -16
  31. wolfhece/wolfresults_2D.py +4 -4
  32. {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/METADATA +3 -2
  33. {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/RECORD +38 -34
  34. wolfhece/apps/wolfgpu.py +0 -19
  35. /wolfhece/lazviewer/processing/estimate_normals/{estimate_normals.pyd → estimate_normals.cp39-win_amd64.pyd} +0 -0
  36. /wolfhece/lazviewer/vfuncs/{vfuncs.pyd → vfuncs.cp39-win_amd64.pyd} +0 -0
  37. {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/LICENCE +0 -0
  38. {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/WHEEL +0 -0
  39. {wolfhece-1.8.12.dist-info → wolfhece-2.0.0.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py CHANGED
@@ -4,6 +4,7 @@ import numpy as np
4
4
  from wx import dataview, TreeCtrl
5
5
  import wx
6
6
  import wx.propgrid as pg
7
+ # from wxasync import AsyncBind
7
8
  from wx.core import VERTICAL, BoxSizer, Height, ListCtrl, StaticText, TextCtrl, Width
8
9
  from wx.glcanvas import GLCanvas, GLContext
9
10
  from wx.dataview import TreeListCtrl
@@ -18,7 +19,8 @@ import cv2
18
19
  from time import sleep
19
20
  from datetime import timedelta
20
21
  from multiprocessing import Pool
21
- import pathlib
22
+ from pathlib import Path
23
+ from time import sleep
22
24
 
23
25
  try:
24
26
  from OpenGL.GL import *
@@ -49,15 +51,21 @@ from .PyTranslate import _
49
51
  from .PyVertex import cloud_vertices, getIfromRGB
50
52
  from .RatingCurve import SPWMIGaugingStations, SPWDCENNGaugingStations
51
53
  from .wolf_array import WOLF_ARRAY_MB, SelectionData, WolfArray, WolfArray_Sim2D, WolfArrayMB, CropDialog, header_wolf, WolfArrayMNAP
52
- from .PyParams import Wolf_Param
54
+ from .PyParams import Wolf_Param, key_Param, Type_Param
53
55
  from .mesh2d.bc_manager import BcManager
54
56
  from .PyVertexvectors import *
55
57
  from .Results2DGPU import wolfres2DGPU
56
- from .PyCrosssections import crosssections, profile
58
+ from .PyCrosssections import crosssections, profile, Interpolator, Interpolators
57
59
  from .GraphNotebook import PlotNotebook
58
60
  from .lazviewer.laz_viewer import myviewer, read_laz, clip_data_xyz, xyz_laz_grids, choices_laz_colormap, Classification_LAZ
59
61
  from . import Lidar2002
60
- from .hydrometry.kiwis_hece import hydrometry_hece
62
+
63
+ try:
64
+ from .hydrometry.kiwis_hece import hydrometry_hece as hydrometry
65
+ except:
66
+ logging.warning(_('Hydrometry HECE module not found - Load hydrometry instead of hydrometry_hece'))
67
+ from .hydrometry.kiwis import hydrometry
68
+
61
69
  from .pyshields import get_d_cr
62
70
  from .pyviews import WolfViews
63
71
  from .PyConfig import handle_configuration_dialog, WolfConfiguration, ConfigurationKeys
@@ -65,6 +73,7 @@ from .GraphProfile import ProfileNotebook
65
73
  from .pybridges import Bridges, Bridge, Weirs, Weir
66
74
  from .tools_mpl import *
67
75
  from .wolf_tiles import Tiles
76
+ from .lagrangian.particle_system_ui import Particle_system_to_draw as Particle_system
68
77
 
69
78
  ID_SELECTCS = 1000
70
79
  ID_SORTALONG = 1001
@@ -72,12 +81,16 @@ ID_LOCMINMAX = 1002
72
81
  ID_PLOTCS = 1003 #Manageactions ID for profile plots
73
82
 
74
83
  class draw_type(Enum):
84
+ # FIXME: change this to be more robust -> Done !
85
+ # Be careful with the enum name, it must be the same than the one used to create the tree list elements, but in lower case
86
+ # see : self.treelist.AppendItem in __init__
75
87
  ARRAYS = 'arrays'
76
88
  BRIDGES= 'bridges'
77
89
  WEIRS = 'weirs'
78
90
  VECTORS = 'vectors'
79
91
  CLOUD = 'clouds'
80
92
  TRIANGULATION = 'triangulations'
93
+ PARTICLE_SYSTEM = 'particle systems'
81
94
  CROSS_SECTIONS = 'cross_sections'
82
95
  OTHER = 'others'
83
96
  VIEWS = 'views'
@@ -94,15 +107,16 @@ class WolfMapViewer(wx.Frame):
94
107
 
95
108
  mybc: list[BcManager] # Gestionnaire de CL
96
109
  myarrays: list # matrices ajoutées
97
- myvectors: list # zones vectorielles ajoutées
98
- myclouds: list # nuages de vertices
99
- mytri: list # triangulations
110
+ myvectors: list[Zones] # zones vectorielles ajoutées
111
+ myclouds: list[cloud_vertices] # nuages de vertices
112
+ mytri: list[Triangulation] # triangulations
100
113
  myothers: list
101
- myviews:list
114
+ myviews:list[views_2D]
102
115
  mywmsback: list
103
116
  mywmsfore: list
104
117
  myres2D: list
105
- mytiles: list
118
+ mytiles: list[Tiles]
119
+ mypartsystems: list[Particle_system]
106
120
 
107
121
  canvas: ogl.ShapeCanvas # GLCanvas # canvas OpenGL
108
122
  context: GLContext # context OpenGL
@@ -122,6 +136,7 @@ class WolfMapViewer(wx.Frame):
122
136
  active_cs: crosssections
123
137
  active_tri: Triangulation
124
138
  active_tile: Tiles
139
+ active_particle_system: Particle_system
125
140
 
126
141
  def __init__(self, wxparent, title, w=500, h=500, treewidth=200, wolfparent=None):
127
142
 
@@ -186,6 +201,8 @@ class WolfMapViewer(wx.Frame):
186
201
  self.menubar = wx.MenuBar()
187
202
 
188
203
  self.menuwolf2d = None
204
+ self.menuparticlesystem = None
205
+ self.timer_ps = None
189
206
  self.menusim2D = None
190
207
  self.menulaz = None
191
208
  self.menutiles = None
@@ -230,6 +247,7 @@ class WolfMapViewer(wx.Frame):
230
247
  createmanager2D = self.menucreateobj.Append(wx.ID_ANY, _('Create Wolf2D manager ...'), _('New manager 2D'))
231
248
  createscenario2D = self.menucreateobj.Append(wx.ID_ANY, _('Create scenarios manager ...'), _('New scenarios manager 2D'))
232
249
  createbcmanager2D = self.menucreateobj.Append(wx.ID_ANY, _('Create BC manager Wolf2D...'), _('New BC manager 2D'))
250
+ createpartsystem = self.menucreateobj.Append(wx.ID_ANY, _('Create particle system...'), _('Create a particle system - Lagrangian view'))
233
251
 
234
252
  self.filemenu.AppendSeparator()
235
253
 
@@ -249,6 +267,7 @@ class WolfMapViewer(wx.Frame):
249
267
  addprofiles = self.menuaddobj.Append(wx.ID_FILE4, _('Add cross sections...'), _('Add cross sections'))
250
268
  addres2D = self.menuaddobj.Append(wx.ID_ANY, _('Add Wolf2D results...'), _('Add Wolf 2D results'))
251
269
  addres2Dgpu = self.menuaddobj.Append(wx.ID_ANY, _('Add Wolf2D GPU results...'), _('Add Wolf 2D GPU results'))
270
+ addpartsystem = self.menuaddobj.Append(wx.ID_ANY, _('Add particle system...'), _('Add a particle system - Lagrangian view'))
252
271
  addbridges = self.menuaddobj.Append(wx.ID_ANY, _('Add bridges...'), _('Add bridges from directory'))
253
272
  addweirs = self.menuaddobj.Append(wx.ID_ANY, _('Add weirs...'), _('Add bridges from directory'))
254
273
  addview = self.menuaddobj.Append(wx.ID_ANY, _('Add view...'), _('Add view from project file'))
@@ -346,6 +365,7 @@ class WolfMapViewer(wx.Frame):
346
365
  self.active_cs = None
347
366
  self.active_profile = None
348
367
  self.active_res2d = None
368
+ self.active_particle_system = None
349
369
  self.selected_treeitem = None
350
370
 
351
371
  curtool = self.tools[ID_SORTALONG] = {}
@@ -387,23 +407,17 @@ class WolfMapViewer(wx.Frame):
387
407
  self.myitemscloud = self.treelist.AppendItem(self.root, _("Clouds"))
388
408
  self.myitemstri = self.treelist.AppendItem(self.root, _("Triangulations"))
389
409
  self.myitemsres2d = self.treelist.AppendItem(self.root, _("Wolf2D"))
410
+ self.myitemsps = self.treelist.AppendItem(self.root, _("Particle systems"))
390
411
  self.myitemsothers = self.treelist.AppendItem(self.root, _("Others"))
391
412
  self.myitemsviews = self.treelist.AppendItem(self.root, _("Views"))
392
413
  self.myitemswmsback = self.treelist.AppendItem(self.root, _("WMS-background"))
393
414
  self.myitemswmsfore = self.treelist.AppendItem(self.root, _("WMS-foreground"))
394
415
 
416
+ # dictionnaire contenant les objets par catégorie
417
+ #FIXME : Useful? the lists can be accessed directly and idx attributes contains the key of the dictionary
395
418
  self.added = {}
396
419
  for curkey in draw_type:
397
- self.added[curkey.value] = {}
398
- # self.added['arrays'] = {}
399
- # self.added['vectors'] = {}
400
- # self.added['clouds'] = {}
401
- # self.added['triangulations'] = {}
402
- # self.added['wolf2d'] = {}
403
- # self.added['others'] = {}
404
- # self.added['views'] = {}
405
- # self.added['wms-background'] = {}
406
- # self.added['wms-foreground'] = {}
420
+ self.added[curkey]:dict[str:Element_To_Draw] = {}
407
421
 
408
422
  width, height = self.GetClientSize()
409
423
  self.bordersize = int((w - width + self.treewidth) / 2)
@@ -599,6 +613,239 @@ class WolfMapViewer(wx.Frame):
599
613
  self.menu2d_video = self.menuwolf2d.Append(wx.ID_ANY, _("Create video..."), _("Video/Movie"))
600
614
  self.menubar.Append(self.menuwolf2d, _('Options 2D'))
601
615
 
616
+ def menu_particlesystem(self):
617
+ if self.menuparticlesystem is None:
618
+
619
+ self.menuparticlesystem = wx.Menu()
620
+ self.menuparticlesystem_load = wx.Menu()
621
+
622
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Set..."), _("Set arrays as the domain/uv of the particle system -- Must be a 2D array - Mask will be used to separate water and land"))
623
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Set emitter from selected nodes"), _("Set the selected nodes as emitters of the particle system"))
624
+ self.menuparticlesystem.AppendSubMenu(self.menuparticlesystem_load, _("Load..."), _('Load data for the particle system in the UI'))
625
+
626
+ self.menuparticlesystem_load.Append(wx.ID_ANY, _("Load domain..."), _("Loading the domain in the UI"))
627
+ self.menuparticlesystem_load.Append(wx.ID_ANY, _("Load ~domain..."), _("Loading the negative of the domain in the UI"))
628
+ self.menuparticlesystem_load.Append(wx.ID_ANY, _("Load emitters..."), _("Loading the emitters in the UI"))
629
+ self.menuparticlesystem_load.Append(wx.ID_ANY, _("Load uv..."), _("Loading the UV velocity field in the UI"))
630
+ self.menuparticlesystem_load.Append(wx.ID_ANY, _("Load uv norm..."), _("Loading the norm of the velocity field in the UI"))
631
+ # self.menuparticlesystem.Append(wx.ID_ANY, _("Set emitters..."), _("Set active zones as the emitters of the particle system -- Each checked zone will be used as an emitter"))
632
+ # self.menuparticlesystem.Append(wx.ID_ANY, _("Set emitter..."), _("Set only the active vector as an emitters of the particle system"))
633
+ # self.menuparticlesystem.Append(wx.ID_ANY, _("Set uv..."), _("Choose U and V arrays for the particle system -- Must be 2D arrays"))
634
+ self.menuparticlesystem.AppendSeparator()
635
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Check"), _("Check if the particle system is ready to be computed"))
636
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Bake"), _("Compute the particle system"))
637
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Reset"), _("Clear all results but keep the particle system settings"))
638
+ self.menuparticlesystem.AppendSeparator()
639
+ # self.menuparticlesystem.AppendSeparator()
640
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Start"), _("Run all steps"))
641
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Stop"), _("Stop the current animation"))
642
+ self.menuparticlesystem.Append(wx.ID_ANY, _("Resume"), _("Resume animation"))
643
+
644
+ self.timer_ps = wx.Timer(self)
645
+
646
+ self.menuparticlesystem.Bind(wx.EVT_MENU, self.action_menu_particlesystem)
647
+ self.Bind(wx.EVT_TIMER, self.update_particlesystem, self.timer_ps)
648
+
649
+ self.menubar.Append(self.menuparticlesystem, _('Particle system'))
650
+
651
+ def action_menu_particlesystem(self, event: wx.Event):
652
+ """ Action to perform when the timer is triggered """
653
+
654
+ if self.active_particle_system is not None:
655
+
656
+ itemlabel = self.menuparticlesystem.FindItemById(event.GetId()).GetItemLabelText()
657
+
658
+
659
+ if itemlabel == _("Start"):
660
+
661
+ if self.active_particle_system is not None:
662
+ self.active_particle_system.current_step = 0
663
+ self.active_particle_system.current_step_idx = 0
664
+ self.timer_ps.Start(1000. / self.active_particle_system.fps)
665
+
666
+ elif itemlabel == _("Stop"):
667
+
668
+ self.timer_ps.Stop()
669
+
670
+ elif itemlabel == _("Resume"):
671
+
672
+ self.timer_ps.Start(1000. / self.active_particle_system.fps)
673
+
674
+ elif itemlabel == _("Load domain..."):
675
+ domain = self.active_particle_system.get_domain(output_type='wolf')
676
+ self.add_object('array', id=domain.idx, newobj=domain, ToCheck=True)
677
+ self.Refresh()
678
+
679
+ elif itemlabel == _("Load ~domain..."):
680
+ domain:WolfArray = self.active_particle_system.get_domain(output_type='wolf')
681
+ domain.idx = domain.idx + '_neg'
682
+ domain.mask_reset()
683
+
684
+ ones = np.where(domain.array.data == 1)
685
+ domain.array[:,:] = 1
686
+ domain.array[ones] = 0
687
+
688
+ domain.mask_data(domain.nullvalue)
689
+ self.add_object('array', id=domain.idx, newobj=domain, ToCheck=True)
690
+ self.Refresh()
691
+
692
+ elif itemlabel == _("Load emitters..."):
693
+ emitters = self.active_particle_system.get_emitters(output_type='wolf')
694
+ self.add_object('vector', id=emitters.idx, newobj=emitters, ToCheck=True)
695
+ self.Refresh()
696
+
697
+ elif itemlabel == _("Load uv..."):
698
+ u = self.active_particle_system.get_u(output_type='wolf')
699
+ v = self.active_particle_system.get_v(output_type='wolf')
700
+ self.add_object('array', id=u.idx, newobj=u, ToCheck=True)
701
+ self.add_object('array', id=v.idx, newobj=v, ToCheck=True)
702
+ self.Refresh()
703
+
704
+ elif itemlabel == _("Load uv norm..."):
705
+ uvnorm = self.active_particle_system.get_uv_absolute(output_type='wolf')
706
+ self.add_object('array', id=uvnorm.idx, newobj=uvnorm, ToCheck=True)
707
+ self.Refresh()
708
+
709
+ elif itemlabel == _("Bake"):
710
+ check, msg = self.active_particle_system.bake()
711
+
712
+ if not check:
713
+ dlg = wx.MessageDialog(self, msg, _('Error'), wx.OK | wx.ICON_ERROR)
714
+ dlg.ShowModal()
715
+ dlg.Destroy()
716
+ return
717
+ elif itemlabel == _("Reset"):
718
+ self.active_particle_system.reset()
719
+
720
+ elif itemlabel == _("Set..."):
721
+ from .ui.wolf_multiselection_collapsiblepane import Wolf_MultipleSelection
722
+
723
+ setter = Wolf_MultipleSelection(self,
724
+ title=_("Set particle system"),
725
+ message=_("Choose arrays/emitters for the particle system"),
726
+ values_dict={'domain': self.get_list_keys(draw_type.ARRAYS),
727
+ 'u': self.get_list_keys(draw_type.ARRAYS),
728
+ 'v': self.get_list_keys(draw_type.ARRAYS),
729
+ 'emitters': self.get_list_keys(draw_type.VECTORS)},
730
+ info='Set : \n - domain (1 value)\n - u and v (multiple values)\n - emitters (multiple values)',
731
+ styles=[wx.LB_SINGLE, wx.LB_EXTENDED, wx.LB_EXTENDED, wx.LB_EXTENDED],
732
+ max_choices=[1, None, None, None],
733
+ delete_if_transfer = [True, False, False, True],
734
+ destroyOK=False)
735
+ setter.ShowModal()
736
+ ret_dict = setter.get_values()
737
+ setter.Destroy()
738
+
739
+ if 'domain' in ret_dict:
740
+ if len(ret_dict['domain']) == 1:
741
+ domain =self.added[draw_type.ARRAYS][ret_dict['domain'][0]]
742
+ self.active_particle_system.set_domain(domain)
743
+ if 'u' in ret_dict and 'v' in ret_dict:
744
+ if len(ret_dict['u']) >0:
745
+ assert len(ret_dict['u']) == len(ret_dict['v']), _('Please select the same number of u and v arrays')
746
+
747
+ time = 0.
748
+ for u,v in zip(ret_dict['u'], ret_dict['v']):
749
+ u = self.added[draw_type.ARRAYS][u]
750
+ v = self.added[draw_type.ARRAYS][v]
751
+ u:WolfArray
752
+ v:WolfArray
753
+ assert u.array.shape == v.array.shape, _('Please select arrays with the same shape')
754
+ assert u.origx == v.origx and u.origy == v.origy, _('Please select arrays with the same origin')
755
+ assert u.dx == v.dx and u.dy == v.dy, _('Please select arrays with the same resolution')
756
+ self.active_particle_system.set_uv((u, v),
757
+ (u.origx, u.origy, u.dx, u.dy),
758
+ time = time)
759
+ time += 1.
760
+
761
+ if 'emitters' in ret_dict:
762
+ if len(ret_dict['emitters'])>0:
763
+ emitters = [self.added[draw_type.VECTORS][cur] for cur in ret_dict['emitters']]
764
+ self.active_particle_system.set_emitters(emitters)
765
+
766
+ if self.active_particle_system._ui is not None:
767
+ self.active_particle_system.show_properties()
768
+
769
+ elif itemlabel == _("Set emitter from selected nodes"):
770
+ if self.active_array is None:
771
+ logging.warning(_('No active array -- Please activate an array first'))
772
+ return
773
+ if len(self.active_array.mngselection.myselection) == 0 and len(self.active_array.mngselection.selections) ==0:
774
+ logging.warning(_('No selection -- Please select some nodes first'))
775
+ return
776
+
777
+ from .lagrangian.emitter import Emitter
778
+
779
+ newemitters=[]
780
+ if len(self.active_array.mngselection.myselection) > 0:
781
+ indices = [self.active_array.get_ij_from_xy(cur[0], cur[1]) for cur in self.active_array.mngselection.myselection]
782
+ newemitters = [Emitter(indices,
783
+ header = (self.active_array.origx, self.active_array.origy, self.active_array.dx, self.active_array.dy))]
784
+
785
+ if len(self.active_array.mngselection.selections) > 0:
786
+
787
+ for cursel in self.active_array.mngselection.selections.values():
788
+ indices = [self.active_array.get_ij_from_xy(cur[0], cur[1]) for cur in cursel['select']]
789
+ newemitters += [Emitter(indices, header = (self.active_array.origx, self.active_array.origy, self.active_array.dx, self.active_array.dy))]
790
+
791
+ self.active_particle_system.set_emitters(newemitters)
792
+
793
+ if self.active_particle_system._ui is not None:
794
+ self.active_particle_system.show_properties()
795
+
796
+ # elif itemlabel == _("Set emitters..."):
797
+
798
+ # if self.active_zones is None:
799
+ # logging.warning(_('No active zones -- Please activate zones first'))
800
+ # return
801
+
802
+ # self.active_particle_system.set_emitters(self.active_zones)
803
+
804
+ # elif itemlabel == _("Set emitter..."):
805
+
806
+ # if self.active_vector is None:
807
+ # logging.warning(_('No active vector -- Please activate a vector first'))
808
+ # return
809
+
810
+ # self.active_particle_system.set_emitter(self.active_vector)
811
+
812
+ # elif itemlabel == _("Set uv..."):
813
+
814
+ # list_arrays = self.multiple_choice_object(draw_type.ARRAYS, message=_('Choose U and V arrays for the particle system -- first == u ; second == v'), titel='UV choice' )
815
+
816
+ # if len(list_arrays) != 2:
817
+ # logging.error(_('Please select two arrays and ONLY two arrays'))
818
+ # return
819
+
820
+ # self.active_particle_system.set_uv(tuple(list_arrays))
821
+
822
+ elif itemlabel == _("Check"):
823
+ check, msg = self.active_particle_system.check()
824
+
825
+ if not check:
826
+ dlg = wx.MessageDialog(self, msg, _('Error'), wx.OK | wx.ICON_ERROR)
827
+ dlg.ShowModal()
828
+ dlg.Destroy()
829
+ return
830
+ else:
831
+ dlg = wx.MessageDialog(self, _('All is fine -- You can bake you system !'), _('Chesk particle system'), wx.OK | wx.ICON_INFORMATION)
832
+ dlg.ShowModal()
833
+ dlg.Destroy()
834
+ return
835
+
836
+ def update_particlesystem(self, event: wx.Event):
837
+ """ Animation of the particle system """
838
+
839
+ if self.active_particle_system is not None:
840
+
841
+ nb = self.active_particle_system.nb_steps
842
+ self.active_particle_system.current_step_idx += 1
843
+ self.Paint()
844
+ self._update_mytooltip()
845
+
846
+ if self.active_particle_system.current_step_idx == nb-1:
847
+ self.timer_ps.Stop()
848
+
602
849
  def menu_sim2D(self):
603
850
  if self.menusim2D is None:
604
851
  self.menusim2D = wx.Menu()
@@ -1275,6 +1522,7 @@ class WolfMapViewer(wx.Frame):
1275
1522
 
1276
1523
  self.mybc = []
1277
1524
  self.myarrays = []
1525
+ self.mypartsystems = []
1278
1526
  self.myvectors = []
1279
1527
  self.mytiles = []
1280
1528
  self.myclouds = []
@@ -1285,7 +1533,8 @@ class WolfMapViewer(wx.Frame):
1285
1533
  self.mywmsfore = []
1286
1534
  self.myres2D = []
1287
1535
 
1288
- self.all_lists = [self.myarrays, self.myvectors, self.myclouds, self.mytri, self.myothers, self.myviews, self.myres2D, self.mytiles]
1536
+ # liste des éléments modifiable dans l'arbre
1537
+ self.all_lists = [self.myarrays, self.myvectors, self.myclouds, self.mytri, self.myothers, self.myviews, self.myres2D, self.mytiles, self.mypartsystems]
1289
1538
 
1290
1539
  if self.get_configuration() is not None:
1291
1540
  self.menu_options = wx.Menu()
@@ -2016,12 +2265,12 @@ class WolfMapViewer(wx.Frame):
2016
2265
  with wx.lib.busy.BusyInfo(_('Opening project')):
2017
2266
  wait = wx.BusyCursor()
2018
2267
  if 'which' in myproject.myparams.keys():
2019
- which = myproject.myparams['which']['action']['value']
2268
+ which = myproject.myparams['which']['action'][key_Param.VALUE]
2020
2269
  if which == 'compare':
2021
2270
  ListCompare = []
2022
2271
  if 'array' in myproject.myparams.keys():
2023
2272
  for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
2024
- ListCompare.append(WolfArray(normpath(curname['value'])))
2273
+ ListCompare.append(WolfArray(normpath(curname[key_Param.VALUE])))
2025
2274
 
2026
2275
  self.set_compare(ListCompare)
2027
2276
  return
@@ -2030,9 +2279,9 @@ class WolfMapViewer(wx.Frame):
2030
2279
  for curid, curname in zip(myproject.myparams['cross_sections'].keys(),
2031
2280
  myproject.myparams['cross_sections'].values()):
2032
2281
  if curid != 'format' and curid != 'dirlaz':
2033
- mycs = crosssections(curname['value'],
2034
- format=myproject.myparams['cross_sections']['format']['value'],
2035
- dirlaz=myproject.myparams['cross_sections']['dirlaz']['value'])
2282
+ mycs = crosssections(curname[key_Param.VALUE],
2283
+ format=myproject.myparams['cross_sections']['format'][key_Param.VALUE],
2284
+ dirlaz=myproject.myparams['cross_sections']['dirlaz'][key_Param.VALUE])
2036
2285
 
2037
2286
  self.add_object('cross_sections', newobj=mycs, id=curid)
2038
2287
 
@@ -2059,54 +2308,54 @@ class WolfMapViewer(wx.Frame):
2059
2308
 
2060
2309
  if 'vector' in myproject.myparams.keys():
2061
2310
  for curid, curname in zip(myproject.myparams['vector'].keys(), myproject.myparams['vector'].values()):
2062
- if exists(curname['value']):
2063
- myvec = Zones(curname['value'], parent=self)
2311
+ if exists(curname[key_Param.VALUE]):
2312
+ myvec = Zones(curname[key_Param.VALUE], parent=self)
2064
2313
  self.add_object('vector', newobj=myvec, id=curid)
2065
2314
  else:
2066
- logging.info(_('Bad parameter in project file - vector : ')+ curname['value'])
2315
+ logging.info(_('Bad parameter in project file - vector : ')+ curname[key_Param.VALUE])
2067
2316
 
2068
2317
  if 'array' in myproject.myparams.keys():
2069
2318
  for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
2070
2319
 
2071
- if exists(curname['value']):
2072
- curarray = WolfArray(curname['value'])
2320
+ if exists(curname[key_Param.VALUE]):
2321
+ curarray = WolfArray(curname[key_Param.VALUE])
2073
2322
  self.add_object('array', newobj=curarray, id=curid)
2074
2323
  else:
2075
- logging.info(_('Bad parameter in project file - array : ')+ curname['value'])
2324
+ logging.info(_('Bad parameter in project file - array : ')+ curname[key_Param.VALUE])
2076
2325
 
2077
2326
 
2078
2327
  if 'wolf2d' in myproject.myparams.keys():
2079
2328
  for curid, curname in zip(myproject.myparams['wolf2d'].keys(), myproject.myparams['wolf2d'].values()):
2080
- if exists(curname['value']):
2081
- curwolf = Wolfresults_2D(curname['value'])
2329
+ if exists(curname[key_Param.VALUE]):
2330
+ curwolf = Wolfresults_2D(curname[key_Param.VALUE])
2082
2331
  self.add_object('res2d', newobj=curwolf, id=curid)
2083
2332
  else:
2084
- logging.info(_('Bad parameter in project file - wolf2d : ')+ curname['value'])
2333
+ logging.info(_('Bad parameter in project file - wolf2d : ')+ curname[key_Param.VALUE])
2085
2334
 
2086
2335
  self.menu_wolf2d()
2087
2336
 
2088
2337
  if 'palette' in myproject.myparams.keys():
2089
2338
  self.project_pal = {}
2090
2339
  for curid, curname in zip(myproject.myparams['palette'].keys(), myproject.myparams['palette'].values()):
2091
- if exists(curname['value']):
2340
+ if exists(curname[key_Param.VALUE]):
2092
2341
  mypal = wolfpalette(None, '')
2093
- mypal.readfile(curname['value'])
2342
+ mypal.readfile(curname[key_Param.VALUE])
2094
2343
  mypal.automatic = False
2095
2344
 
2096
2345
  self.project_pal[curid] = mypal
2097
2346
  else:
2098
- logging.info(_('Bad parameter in project file - palette : ')+ curname['value'])
2347
+ logging.info(_('Bad parameter in project file - palette : ')+ curname[key_Param.VALUE])
2099
2348
 
2100
2349
  if 'palette-array' in myproject.myparams.keys():
2101
2350
  curarray: WolfArray
2102
2351
  if self.project_pal is not None:
2103
2352
  for curid, curname in zip(myproject.myparams['palette-array'].keys(),
2104
2353
  myproject.myparams['palette-array'].values()):
2105
- if curname['value'] in self.project_pal.keys():
2354
+ if curname[key_Param.VALUE] in self.project_pal.keys():
2106
2355
  curarray = self.getobj(curid)
2107
2356
  if curarray is not None:
2108
2357
  mypal:wolfpalette
2109
- mypal = self.project_pal[curname['value']]
2358
+ mypal = self.project_pal[curname[key_Param.VALUE]]
2110
2359
  curarray.mypal = mypal
2111
2360
  if mypal.automatic:
2112
2361
  curarray.myops.palauto.SetValue(1)
@@ -2119,26 +2368,31 @@ class WolfMapViewer(wx.Frame):
2119
2368
 
2120
2369
  if 'cross_sections_link' in myproject.myparams.keys():
2121
2370
  if 'linkzones' in myproject.myparams['cross_sections_link'].keys():
2122
- idx = myproject.myparams['cross_sections_link']['linkzones']['value']
2371
+ idx = myproject.myparams['cross_sections_link']['linkzones'][key_Param.VALUE]
2123
2372
 
2124
- for curvect in self.added['vectors']:
2125
- myzones: Zones
2126
- myzones = self.added['vectors'][curvect]['values']
2127
- if myzones.idx == idx:
2128
- self.active_cs.link_external_zones(myzones)
2373
+ for curzones in self.iterator_over_objects(draw_type.VECTORS):
2374
+ curzones: Zones
2375
+ if curzones.idx == idx:
2376
+ self.active_cs.link_external_zones(curzones)
2377
+
2378
+ # for curvect in self.added[draw_type.VECTORS.value]:
2379
+ # myzones: Zones
2380
+ # myzones = self.added[draw_type.VECTORS.value][curvect]['values']
2381
+ # if myzones.idx == idx:
2382
+ # self.active_cs.link_external_zones(myzones)
2129
2383
 
2130
2384
  zonename = ''
2131
2385
  vecname = ''
2132
2386
 
2133
2387
  if 'sortzone' in myproject.myparams['cross_sections_link'].keys():
2134
- zonename = myproject.myparams['cross_sections_link']['sortzone']['value']
2388
+ zonename = myproject.myparams['cross_sections_link']['sortzone'][key_Param.VALUE]
2135
2389
  if 'sortname' in myproject.myparams['cross_sections_link'].keys():
2136
- vecname = myproject.myparams['cross_sections_link']['sortname']['value']
2390
+ vecname = myproject.myparams['cross_sections_link']['sortname'][key_Param.VALUE]
2137
2391
 
2138
2392
  if zonename != '' and vecname != '':
2139
- names = [cur.myname for cur in myzones.myzones]
2393
+ names = [cur.myname for cur in curzones.myzones]
2140
2394
  idx = names.index(zonename)
2141
- curzone = myzones.myzones[idx]
2395
+ curzone = curzones.myzones[idx]
2142
2396
  names = [cur.myname for cur in curzone.myvectors]
2143
2397
  idx = names.index(vecname)
2144
2398
  curvec = curzone.myvectors[idx]
@@ -2153,7 +2407,7 @@ class WolfMapViewer(wx.Frame):
2153
2407
  locvec = None
2154
2408
  locarray = None
2155
2409
  for curvec in self.myvectors:
2156
- if curvec.idx == curname['value'].lower():
2410
+ if curvec.idx == curname[key_Param.VALUE].lower():
2157
2411
  locvec=curvec
2158
2412
  break
2159
2413
 
@@ -2170,7 +2424,7 @@ class WolfMapViewer(wx.Frame):
2170
2424
 
2171
2425
  logging.warning(_('Bad vec-array association in project file !'))
2172
2426
  logging.warning(curid)
2173
- logging.warning(curname['value'])
2427
+ logging.warning(curname[key_Param.VALUE])
2174
2428
  del wait
2175
2429
 
2176
2430
  def save_project(self, fn):
@@ -2182,53 +2436,65 @@ class WolfMapViewer(wx.Frame):
2182
2436
  """
2183
2437
  # myproject.myparams['which']={}
2184
2438
  # myproject.myparams['which']['action']={}
2185
- # myproject.myparams['which']['action']['value']
2439
+ # myproject.myparams['which']['action'][key_Param.VALUE]
2186
2440
 
2187
2441
  # mycs = self.active_cs
2188
2442
  # if mycs is not None:
2189
2443
  # myproject.myparams['cross_sections']={}
2190
2444
  # myproject.myparams['cross_sections']['mycs']={}
2191
- # myproject.myparams['cross_sections']['mycs']['value']=mycs.filename
2445
+ # myproject.myparams['cross_sections']['mycs'][key_Param.VALUE]=mycs.filename
2192
2446
 
2193
2447
  # myproject.myparams['vector']={}
2194
2448
  # myproject.myparams['vector']['river']={}
2195
- # myproject.myparams['vector']['river']['value']=self.added['vectors'][0].filename
2449
+ # myproject.myparams['vector']['river'][key_Param.VALUE]=self.added[draw_type.VECTORS.value][0].filename
2196
2450
 
2197
2451
  # if 'array' in myproject.myparams.key():
2198
2452
  # for curid,curname in zip(myproject.myparams['array'].keys(),myproject.myparams['array'].values()):
2199
- # curarray=WolfArray(curname['value'])
2453
+ # curarray=WolfArray(curname[key_Param.VALUE])
2200
2454
  # self.add_object('array',newobj=curarray,id=curid)
2201
2455
  """
2202
- # Dessin des matrices
2456
+ # matrices
2203
2457
  try:
2204
- for curarray in self.added['arrays']:
2205
- if self.added['arrays'][curarray]['checked']:
2206
- locarray: WolfArray
2207
- locarray = self.added['arrays'][curarray]['values']
2208
- myproject['array'][locarray.idx] = {}
2209
- myproject['array'][locarray.idx]['value'] = locarray.filename
2458
+ for curel in self.iterator_over_objects(draw_type.ARRAYS):
2459
+ myproject['array'][curel.idx] = {}
2460
+ myproject['array'][curel.idx][key_Param.VALUE] = curel.filename
2461
+
2462
+ # for curarray in self.added[draw_type.ARRAYS.value]:
2463
+ # if self.added[draw_type.ARRAYS.value][curarray]['checked']:
2464
+ # locarray: WolfArray
2465
+ # locarray = self.added[draw_type.ARRAYS.value][curarray]['values']
2466
+ # myproject['array'][locarray.idx] = {}
2467
+ # myproject['array'][locarray.idx][key_Param.VALUE] = locarray.filename
2210
2468
  except:
2211
2469
  pass
2212
2470
 
2213
- # Dessin des résultats 2D
2471
+ # résultats 2D
2214
2472
  try:
2215
- for curarray in self.added['wolf2d']:
2216
- if self.added['wolf2d'][curarray]['checked']:
2217
- locarray: wolf2dprev
2218
- locarray = self.added['wolf2d'][curarray]['values']
2219
- myproject['wolf2d'][locarray.idx] = {}
2220
- myproject['wolf2d'][locarray.idx]['value'] = locarray.filename
2473
+ for curel in self.iterator_over_objects(draw_type.RES2D):
2474
+ myproject['wolf2d'][curel.idx] = {}
2475
+ myproject['wolf2d'][curel.idx][key_Param.VALUE] = curel.filename
2476
+
2477
+ # for curarray in self.added[draw_type.RES2D.value]:
2478
+ # if self.added[draw_type.RES2D.value][curarray]['checked']:
2479
+ # locarray: wolf2dprev
2480
+ # locarray = self.added[draw_type.RES2D.value][curarray]['values']
2481
+ # myproject['wolf2d'][locarray.idx] = {}
2482
+ # myproject['wolf2d'][locarray.idx][key_Param.VALUE] = locarray.filename
2221
2483
  except:
2222
2484
  pass
2223
2485
 
2224
- # Dessin des vecteurs
2486
+ # vecteurs
2225
2487
  try:
2226
- for curvect in self.added['vectors']:
2227
- if self.added['vectors'][curvect]['checked']:
2228
- curvec: Zones
2229
- curvec = self.added['vectors'][curvect]['values']
2230
- myproject['wolf2d'][curvec.idx] = {}
2231
- myproject['wolf2d'][curvec.idx]['value'] = curvec.filename
2488
+ for curel in self.iterator_over_objects(draw_type.VECTORS):
2489
+ myproject['vector'][curel.idx] = {}
2490
+ myproject['vector'][curel.idx][key_Param.VALUE] = curel.filename
2491
+
2492
+ # for curvect in self.added[draw_type.VECTORS.value]:
2493
+ # if self.added[draw_type.VECTORS.value][curvect]['checked']:
2494
+ # curvec: Zones
2495
+ # curvec = self.added[draw_type.VECTORS.value][curvect]['values']
2496
+ # myproject['wolf2d'][curvec.idx] = {}
2497
+ # myproject['wolf2d'][curvec.idx][key_Param.VALUE] = curvec.filename
2232
2498
  except:
2233
2499
  pass
2234
2500
 
@@ -2254,7 +2520,6 @@ class WolfMapViewer(wx.Frame):
2254
2520
  if self.active_array is not None:
2255
2521
  copy_vec = vector()
2256
2522
  copy_vec.myvertices = self.active_vector.myvertices.copy()
2257
- copy_vec.nbvertices = self.active_vector.nbvertices
2258
2523
  copy_vec.split(abs(self.active_array.dx)/2., False)
2259
2524
  copy_vec.get_values_on_vertices(self.active_array)
2260
2525
  s,z = copy_vec.get_sz()
@@ -2411,37 +2676,54 @@ class WolfMapViewer(wx.Frame):
2411
2676
 
2412
2677
  def read_last_result(self):
2413
2678
  """Lecture du dernier résultat pour les modèles ajoutés et plottés"""
2679
+
2414
2680
  self.currently_readresults = True
2415
2681
 
2416
- for curmodel in self.added['wolf2d']:
2417
- if self.added['wolf2d'][curmodel]['checked']:
2418
- locmodel: Wolfresults_2D
2419
- locmodel = self.added['wolf2d'][curmodel]['values']
2682
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2683
+ curmodel: Wolfresults_2D
2684
+ logging.info(_('Updating {} - Last result'.format(curmodel.idx)))
2420
2685
 
2421
- logging.info(_('Updating {}'.format(locmodel.idx)))
2686
+ curmodel.read_oneresult()
2687
+ curmodel.set_currentview()
2422
2688
 
2423
- locmodel.read_oneresult()
2424
- locmodel.set_currentview()
2689
+ # for curmodel in self.added[draw_type.RES2D.value]:
2690
+ # if self.added[draw_type.RES2D.value][curmodel]['checked']:
2691
+ # locmodel: Wolfresults_2D
2692
+ # locmodel = self.added[draw_type.RES2D.value][curmodel]['values']
2693
+
2694
+ # logging.info(_('Updating {}'.format(locmodel.idx)))
2695
+
2696
+ # locmodel.read_oneresult()
2697
+ # locmodel.set_currentview()
2425
2698
 
2426
2699
  self.Refresh()
2427
2700
  self.currently_readresults = False
2428
2701
  self._update_mytooltip()
2429
2702
 
2430
- def read_one_result(self, which):
2703
+ def read_one_result(self, which:int):
2431
2704
  """
2432
2705
  Lecture d'un résultat spécific pour les modèles ajoutés et plottés
2433
2706
  """
2434
2707
  self.currently_readresults = True
2435
2708
 
2436
- for curmodel in self.added['wolf2d']:
2437
- if self.added['wolf2d'][curmodel]['checked']:
2438
- locmodel: Wolfresults_2D
2439
- locmodel = self.added['wolf2d'][curmodel]['values']
2709
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2710
+ curmodel: Wolfresults_2D
2711
+ if curmodel.checked:
2712
+ logging.info(_('Updating {} - Specific result {}'.format(curmodel.idx, which)))
2713
+
2714
+ curmodel.read_oneresult(which)
2715
+ curmodel.set_currentview()
2716
+
2717
+
2718
+ # for curmodel in self.added[draw_type.RES2D.value]:
2719
+ # if self.added[draw_type.RES2D.value][curmodel]['checked']:
2720
+ # locmodel: Wolfresults_2D
2721
+ # locmodel = self.added[draw_type.RES2D.value][curmodel]['values']
2440
2722
 
2441
- logging.info(_('Updating {}'.format(locmodel.idx)))
2723
+ # logging.info(_('Updating {}'.format(locmodel.idx)))
2442
2724
 
2443
- locmodel.read_oneresult(which)
2444
- locmodel.set_currentview()
2725
+ # locmodel.read_oneresult(which)
2726
+ # locmodel.set_currentview()
2445
2727
 
2446
2728
  self.Refresh()
2447
2729
  self.currently_readresults = False
@@ -2454,35 +2736,73 @@ class WolfMapViewer(wx.Frame):
2454
2736
  """
2455
2737
  self.currently_readresults = True
2456
2738
 
2457
- for curmodel in self.added['wolf2d']:
2458
- if self.added['wolf2d'][curmodel]['checked']:
2459
- locmodel: Wolfresults_2D
2460
- locmodel = self.added['wolf2d'][curmodel]['values']
2739
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2740
+ curmodel: Wolfresults_2D
2741
+ logging.info(_('Updating {} - Previous result'.format(curmodel.idx)))
2461
2742
 
2462
- logging.info(_('Updating {}'.format(locmodel.idx)))
2743
+ curmodel.read_previous()
2744
+ curmodel.set_currentview()
2463
2745
 
2464
- locmodel.read_previous()
2465
- locmodel.set_currentview()
2746
+ # for curmodel in self.added[draw_type.RES2D.value]:
2747
+ # if self.added[draw_type.RES2D.value][curmodel]['checked']:
2748
+ # locmodel: Wolfresults_2D
2749
+ # locmodel = self.added[draw_type.RES2D.value][curmodel]['values']
2750
+
2751
+ # logging.info(_('Updating {}'.format(locmodel.idx)))
2752
+
2753
+ # locmodel.read_previous()
2754
+ # locmodel.set_currentview()
2466
2755
 
2467
2756
  self.Refresh()
2468
2757
  self.currently_readresults = False
2469
2758
  self._update_mytooltip()
2470
2759
 
2760
+ def particle_next_step(self):
2761
+ """ Mise à jour au pas suivant """
2762
+
2763
+ for curps in self.iterator_over_objects(draw_type.PARTICLE_SYSTEM):
2764
+ curps: Particle_system
2765
+ logging.info(_('Updating {} - Next result'.format(curps.idx)))
2766
+
2767
+ curps.next_step()
2768
+
2769
+ self._update_mytooltip()
2770
+ self.Refresh()
2771
+
2772
+ def particle_previous_step(self):
2773
+ """ Mise à jour au pas précédent """
2774
+
2775
+ for curps in self.iterator_over_objects(draw_type.PARTICLE_SYSTEM):
2776
+ curps: Particle_system
2777
+ logging.info(_('Updating {} - Next result'.format(curps.idx)))
2778
+
2779
+ curps.previous_step()
2780
+
2781
+ self._update_mytooltip()
2782
+ self.Refresh()
2783
+
2471
2784
  def simul_next_step(self):
2472
2785
  """
2473
2786
  Mise à jour au pas suivant
2474
2787
  """
2475
2788
  self.currently_readresults = True
2476
2789
 
2477
- for curmodel in self.added['wolf2d']:
2478
- if self.added['wolf2d'][curmodel]['checked']:
2479
- locmodel: Wolfresults_2D
2480
- locmodel = self.added['wolf2d'][curmodel]['values']
2790
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2791
+ curmodel: Wolfresults_2D
2792
+ logging.info(_('Updating {} - Next result'.format(curmodel.idx)))
2481
2793
 
2482
- logging.info(_('Updating {}'.format(locmodel.idx)))
2794
+ curmodel.read_next()
2795
+ curmodel.set_currentview()
2483
2796
 
2484
- locmodel.read_next()
2485
- locmodel.set_currentview()
2797
+ # for curmodel in self.added[draw_type.RES2D.value]:
2798
+ # if self.added[draw_type.RES2D.value][curmodel]['checked']:
2799
+ # locmodel: Wolfresults_2D
2800
+ # locmodel = self.added[draw_type.RES2D.value][curmodel]['values']
2801
+
2802
+ # logging.info(_('Updating {}'.format(locmodel.idx)))
2803
+
2804
+ # locmodel.read_next()
2805
+ # locmodel.set_currentview()
2486
2806
 
2487
2807
  self.Refresh()
2488
2808
  self.currently_readresults = False
@@ -2711,23 +3031,35 @@ class WolfMapViewer(wx.Frame):
2711
3031
  linkedarrays = {}
2712
3032
 
2713
3033
  # Matrices 2D
2714
- for curarray in self.added['arrays']:
2715
- if self.added['arrays'][curarray]['checked']:
2716
- locarray = self.added['arrays'][curarray]['values']
2717
- linkedarrays[locarray.idx] = locarray
3034
+ for curarray in self.iterator_over_objects(draw_type.ARRAYS):
3035
+ curarray: WolfArray
3036
+ linkedarrays[curarray.idx] = curarray
3037
+
3038
+ # for curarray in self.added[draw_type.ARRAYS.value]:
3039
+ # if self.added[draw_type.ARRAYS.value][curarray]['checked']:
3040
+ # locarray = self.added[draw_type.ARRAYS.value][curarray]['values']
3041
+ # linkedarrays[locarray.idx] = locarray
2718
3042
 
2719
3043
  # Résultats 2D
2720
- for curarray in self.added['wolf2d']:
2721
- if self.added['wolf2d'][curarray]['checked']:
2722
- locarray = self.added['wolf2d'][curarray]['values']
2723
- linkedarrays[locarray.idx] = locarray
3044
+ for curarray in self.iterator_over_objects(draw_type.RES2D):
3045
+ curarray: Wolfresults_2D
3046
+ linkedarrays[curarray.idx] = curarray
3047
+
3048
+ # for curarray in self.added[draw_type.RES2D.value]:
3049
+ # if self.added[draw_type.RES2D.value][curarray]['checked']:
3050
+ # locarray = self.added[draw_type.RES2D.value][curarray]['values']
3051
+ # linkedarrays[locarray.idx] = locarray
2724
3052
 
2725
3053
  linkedvecs={}
2726
- for curvect in self.added['vectors']:
2727
- if self.added['vectors'][curvect]['checked']:
2728
- myzones: Zones
2729
- myzones = self.added['vectors'][curvect]['values']
2730
- linkedvecs[myzones.idx] = myzones
3054
+ for curvect in self.iterator_over_objects(draw_type.VECTORS):
3055
+ curvect: Zones
3056
+ linkedvecs[curvect.idx] = curvect
3057
+
3058
+ # for curvect in self.added[draw_type.VECTORS.value]:
3059
+ # if self.added[draw_type.VECTORS.value][curvect]['checked']:
3060
+ # myzones: Zones
3061
+ # myzones = self.added[draw_type.VECTORS.value][curvect]['values']
3062
+ # linkedvecs[myzones.idx] = myzones
2731
3063
 
2732
3064
  if len(plotzone) > 1:
2733
3065
  for curzone in plotzone:
@@ -2779,7 +3111,7 @@ class WolfMapViewer(wx.Frame):
2779
3111
  logging.warning(_("Bad value -- Rety"))
2780
3112
  return
2781
3113
 
2782
- if len(self.added['wolf2d'])>1:
3114
+ if len(self.added[draw_type.RES2D])>1:
2783
3115
 
2784
3116
  dlg = wx.MessageDialog(None, _('Apply to all results?'), style=wx.YES_NO)
2785
3117
  ret = dlg.ShowModal()
@@ -2789,14 +3121,21 @@ class WolfMapViewer(wx.Frame):
2789
3121
  self.active_res2d.load_default_colormap('shields_cst')
2790
3122
  self.active_res2d.set_currentview(method, True)
2791
3123
  else:
2792
- for curarray in self.added['wolf2d']:
2793
- if self.added['wolf2d'][curarray]['checked']:
2794
- locarray:Wolfresults_2D
2795
- locarray = self.added['wolf2d'][curarray]['values']
2796
- if diamsize is not None:
2797
- locarray.sediment_diameter = diamsize
2798
- locarray.load_default_colormap('shields_cst')
2799
- locarray.set_currentview(method)
3124
+ for curarray in self.iterator_over_objects(draw_type.RES2D):
3125
+ curarray:Wolfresults_2D
3126
+ if diamsize is not None:
3127
+ curarray.sediment_diameter = diamsize
3128
+ curarray.load_default_colormap('shields_cst')
3129
+ curarray.set_currentview(method)
3130
+
3131
+ # for curarray in self.added[draw_type.RES2D.value]:
3132
+ # if self.added[draw_type.RES2D.value][curarray]['checked']:
3133
+ # locarray:Wolfresults_2D
3134
+ # locarray = self.added[draw_type.RES2D.value][curarray]['values']
3135
+ # if diamsize is not None:
3136
+ # locarray.sediment_diameter = diamsize
3137
+ # locarray.load_default_colormap('shields_cst')
3138
+ # locarray.set_currentview(method)
2800
3139
  else:
2801
3140
  if diamsize is not None:
2802
3141
  self.active_res2d.sediment_diameter = diamsize
@@ -2825,18 +3164,26 @@ class WolfMapViewer(wx.Frame):
2825
3164
  dlg.Destroy()
2826
3165
  return
2827
3166
 
2828
- for curmodel in self.added['wolf2d']:
2829
- if self.added['wolf2d'][curmodel]['checked']:
2830
- locmodel: Wolfresults_2D
2831
- locmodel = self.added['wolf2d'][curmodel]['values']
2832
- locmodel.epsilon = neweps
2833
- locmodel._epsilon_default = neweps
2834
- locmodel.read_oneresult(locmodel.current_result)
2835
- locmodel.set_currentview()
3167
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
3168
+ curmodel: Wolfresults_2D
3169
+ curmodel.epsilon = neweps
3170
+ curmodel._epsilon_default = neweps
3171
+ curmodel.read_oneresult(curmodel.current_result)
3172
+ curmodel.set_currentview()
3173
+
3174
+ # for curmodel in self.added[draw_type.RES2D.value]:
3175
+ # if self.added[draw_type.RES2D.value][curmodel]['checked']:
3176
+ # locmodel: Wolfresults_2D
3177
+ # locmodel = self.added[draw_type.RES2D.value][curmodel]['values']
3178
+ # locmodel.epsilon = neweps
3179
+ # locmodel._epsilon_default = neweps
3180
+ # locmodel.read_oneresult(locmodel.current_result)
3181
+ # locmodel.set_currentview()
2836
3182
 
2837
3183
  elif itemlabel == _("Manage boundary conditions..."):
3184
+
2838
3185
  if self.active_res2d is not None:
2839
- self.active_res2d.myparams.editing_bc(self.added['wolf2d'])
3186
+ self.active_res2d.myparams.editing_bc(self.added[draw_type.RES2D])
2840
3187
 
2841
3188
  elif itemlabel ==_("Create video..."):
2842
3189
  if self.active_res2d is not None:
@@ -3125,8 +3472,8 @@ class WolfMapViewer(wx.Frame):
3125
3472
 
3126
3473
  first = WolfArray(ListArrays[0], preload=False)
3127
3474
  sec = WolfArray(ListArrays[1], preload=False)
3128
- first.read_txt_header(ListArrays[0])
3129
- sec.read_txt_header(ListArrays[1])
3475
+ first.read_txt_header()
3476
+ sec.read_txt_header()
3130
3477
 
3131
3478
  if first.nbx == sec.nbx and first.nby == sec.nby and first.origx == sec.origx and first.origy == sec.origy:
3132
3479
  first.preload = True
@@ -3190,11 +3537,22 @@ class WolfMapViewer(wx.Frame):
3190
3537
  self.add_object(which='cloud', ToCheck=True)
3191
3538
  elif itemlabel == _('Add triangulation...'):
3192
3539
  self.add_object(which='triangulation', ToCheck=True)
3540
+
3541
+ elif itemlabel == _('Add particle system...'):
3542
+ self.add_object(which = 'particlesystem', ToCheck = True)
3543
+ self.menu_particlesystem()
3544
+
3545
+ elif itemlabel == _('Create particle system...'):
3546
+ self.active_particlesystem = newpart = Particle_system()
3547
+ self.add_object(which='particlesystem', newobj=newpart, ToCheck=True)
3548
+ self.menu_particlesystem()
3549
+
3193
3550
  elif id == wx.ID_FILE4:
3194
3551
  self.add_object(which='cross_sections', ToCheck=True)
3195
3552
  elif itemlabel == _('Add Wolf2D results...'):
3196
3553
  self.add_object(which='res2d', ToCheck=True)
3197
3554
  self.menu_wolf2d()
3555
+
3198
3556
  elif itemlabel == _('Add Wolf2D GPU results...'):
3199
3557
  self.add_object(which='res2d_gpu', ToCheck=True)
3200
3558
  self.menu_wolf2d()
@@ -3322,24 +3680,41 @@ class WolfMapViewer(wx.Frame):
3322
3680
  self.ManageActions(id)
3323
3681
  elif id == wx.ID_SAVE:
3324
3682
 
3325
- for curarray in self.added['arrays']:
3326
- if self.added['arrays'][curarray]['checked']:
3327
- obj: WolfArray
3328
- obj = self.added['arrays'][curarray]['values']
3683
+ for obj in self.iterator_over_objects(draw_type.ARRAYS):
3684
+ obj: WolfArray
3329
3685
 
3330
- if obj.filename == '':
3331
- filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3332
- fdlg = wx.FileDialog(self, "Choose file", wildcard=filterArray, style=wx.FD_SAVE)
3333
- fdlg.ShowModal()
3334
- if fdlg.ShowModal() == wx.ID_OK:
3335
- obj.filename = fdlg.GetPath()
3686
+ if obj.filename == '':
3687
+ filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3688
+ fdlg = wx.FileDialog(self, "Choose file", wildcard=filterArray, style=wx.FD_SAVE)
3689
+ fdlg.ShowModal()
3690
+ if fdlg.ShowModal() == wx.ID_OK:
3691
+ obj.filename = fdlg.GetPath()
3692
+
3693
+ obj.write_all()
3336
3694
 
3337
- obj.write_all()
3338
3695
 
3339
- for curvect in self.added['vectors']:
3340
- if self.added['vectors'][curvect]['checked']:
3341
- obj = self.added['vectors'][curvect]['values']
3342
- obj.saveas()
3696
+ # for curarray in self.added[draw_type.ARRAYS.value]:
3697
+ # if self.added[draw_type.ARRAYS.value][curarray]['checked']:
3698
+ # obj: WolfArray
3699
+ # obj = self.added[draw_type.ARRAYS.value][curarray]['values']
3700
+
3701
+ # if obj.filename == '':
3702
+ # filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3703
+ # fdlg = wx.FileDialog(self, "Choose file", wildcard=filterArray, style=wx.FD_SAVE)
3704
+ # fdlg.ShowModal()
3705
+ # if fdlg.ShowModal() == wx.ID_OK:
3706
+ # obj.filename = fdlg.GetPath()
3707
+
3708
+ # obj.write_all()
3709
+
3710
+ for obj in self.iterator_over_objects(draw_type.VECTORS):
3711
+ obj:Zones
3712
+ obj.saveas()
3713
+
3714
+ # for curvect in self.added[draw_type.VECTORS.value]:
3715
+ # if self.added[draw_type.VECTORS.value][curvect]['checked']:
3716
+ # obj = self.added[draw_type.VECTORS.value][curvect]['values']
3717
+ # obj.saveas()
3343
3718
 
3344
3719
  elif itemlabel == 'Save to image...':
3345
3720
  autoscale = False
@@ -3487,37 +3862,62 @@ class WolfMapViewer(wx.Frame):
3487
3862
 
3488
3863
  elif id == wx.ID_SAVEAS:
3489
3864
 
3490
- for curarray in self.added['arrays']:
3491
- if self.added['arrays'][curarray]['checked']:
3492
- obj: WolfArray
3493
- obj = self.added['arrays'][curarray]['values']
3865
+ for obj in self.iterator_over_objects(draw_type.ARRAYS):
3866
+ obj: WolfArray
3494
3867
 
3495
- filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3496
- fdlg = wx.FileDialog(self, "Choose file name for Array : " + obj.idx, wildcard=filterArray,
3497
- style=wx.FD_SAVE)
3498
- ret = fdlg.ShowModal()
3499
- if ret == wx.ID_OK:
3500
- obj.filename = fdlg.GetPath()
3501
- obj.write_all()
3868
+ filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3869
+ fdlg = wx.FileDialog(self, "Choose file name for Array : " + obj.idx, wildcard=filterArray,
3870
+ style=wx.FD_SAVE)
3871
+ ret = fdlg.ShowModal()
3872
+ if ret == wx.ID_OK:
3873
+ obj.filename = fdlg.GetPath()
3874
+ obj.write_all()
3502
3875
 
3503
- for curvect in self.added['vectors']:
3504
- if curvect == 'grid':
3505
- pass
3506
- elif self.added['vectors'][curvect]['checked']:
3507
- obj = self.added['vectors'][curvect]['values']
3508
3876
 
3877
+ # for curarray in self.added[draw_type.ARRAYS.value]:
3878
+ # if self.added[draw_type.ARRAYS.value][curarray]['checked']:
3879
+ # obj: WolfArray
3880
+ # obj = self.added[draw_type.ARRAYS.value][curarray]['values']
3881
+
3882
+ # filterArray = "bin (*.bin)|*.bin|all (*.*)|*.*"
3883
+ # fdlg = wx.FileDialog(self, "Choose file name for Array : " + obj.idx, wildcard=filterArray,
3884
+ # style=wx.FD_SAVE)
3885
+ # ret = fdlg.ShowModal()
3886
+ # if ret == wx.ID_OK:
3887
+ # obj.filename = fdlg.GetPath()
3888
+ # obj.write_all()
3889
+
3890
+ for obj in self.iterator_over_objects(draw_type.VECTORS):
3891
+ obj:Zones
3892
+ if obj.idx=='grid':
3893
+ pass
3894
+ else:
3509
3895
  filterArray = "vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|all (*.*)|*.*"
3510
3896
  fdlg = wx.FileDialog(self, "Choose file name for Vector :" + obj.idx, wildcard=filterArray,
3511
3897
  style=wx.FD_SAVE)
3512
3898
  ret = fdlg.ShowModal()
3513
3899
  if ret == wx.ID_OK:
3514
3900
  obj.saveas(fdlg.GetPath())
3901
+
3902
+ # for curvect in self.added[draw_type.VECTORS.value]:
3903
+ # if curvect == 'grid':
3904
+ # pass
3905
+ # elif self.added[draw_type.VECTORS.value][curvect]['checked']:
3906
+ # obj = self.added[draw_type.VECTORS.value][curvect]['values']
3907
+
3908
+ # filterArray = "vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|all (*.*)|*.*"
3909
+ # fdlg = wx.FileDialog(self, "Choose file name for Vector :" + obj.idx, wildcard=filterArray,
3910
+ # style=wx.FD_SAVE)
3911
+ # ret = fdlg.ShowModal()
3912
+ # if ret == wx.ID_OK:
3913
+ # obj.saveas(fdlg.GetPath())
3914
+
3515
3915
  # elif id == ID_RUN_SIMULATION:
3516
3916
  # from ..debug.test_glsim.wolf_gpu import load_sim_to_gpu
3517
3917
  # print("Simulation")
3518
3918
  # load_sim_to_gpu()
3519
3919
 
3520
- if len(self.myarrays) + len(self.myvectors) + len(self.myclouds) + len(self.mytri) + len(self.myres2D) + len(self.mytiles) == 2 and autoscale:
3920
+ if len(self.myarrays) + len(self.myvectors) + len(self.myclouds) + len(self.mytri) + len(self.myres2D) + len(self.mytiles) + len(self.mypartsystems) == 2 and autoscale:
3521
3921
  # Trouve les bornzs si un seul élément est présent, sinon on conserve l'état du zoom
3522
3922
  self.Autoscale()
3523
3923
 
@@ -3805,15 +4205,21 @@ class WolfMapViewer(wx.Frame):
3805
4205
  def get_linked_arrays(self) -> dict:
3806
4206
  linkedarrays = {}
3807
4207
 
3808
- for curarray in self.added['arrays']:
3809
- if self.added['arrays'][curarray]['checked']:
3810
- locarray = self.added['arrays'][curarray]['values']
3811
- linkedarrays[locarray.idx] = locarray
4208
+ for locarray in self.iterator_over_objects(draw_type.ARRAYS):
4209
+ linkedarrays[locarray.idx] = locarray
4210
+
4211
+ for locarray in self.iterator_over_objects(draw_type.RES2D):
4212
+ linkedarrays[locarray.idx] = locarray
3812
4213
 
3813
- for curarray in self.added['wolf2d']:
3814
- if self.added['wolf2d'][curarray]['checked']:
3815
- locarray = self.added['wolf2d'][curarray]['values']
3816
- linkedarrays[locarray.idx] = locarray
4214
+ # for curarray in self.added[draw_type.ARRAYS.value]:
4215
+ # if self.added[draw_type.ARRAYS.value][curarray]['checked']:
4216
+ # locarray = self.added[draw_type.ARRAYS.value][curarray]['values']
4217
+ # linkedarrays[locarray.idx] = locarray
4218
+
4219
+ # for curarray in self.added[draw_type.RES2D.value]:
4220
+ # if self.added[draw_type.RES2D.value][curarray]['checked']:
4221
+ # locarray = self.added[draw_type.RES2D.value][curarray]['values']
4222
+ # linkedarrays[locarray.idx] = locarray
3817
4223
 
3818
4224
  return linkedarrays
3819
4225
 
@@ -3842,6 +4248,7 @@ class WolfMapViewer(wx.Frame):
3842
4248
  'views',
3843
4249
  'res2d',
3844
4250
  'res2d_gpu',
4251
+ 'particlesystem',
3845
4252
  'wmsback',
3846
4253
  'wmsfore'] = 'array',
3847
4254
  filename='',
@@ -3853,7 +4260,8 @@ class WolfMapViewer(wx.Frame):
3853
4260
  Add object to current Frame/Drawing area
3854
4261
  """
3855
4262
 
3856
- filterArray = "bin (*.bin)|*.bin|Elevation WOLF2D (*.top)|*.top|Geotif (*.tif)|*.tif|Float ESRI (*.flt)|*.flt|Numpy (*.npy)|*.npy|all (*.*)|*.*"
4263
+ filterArray = "bin (*.bin)|*.bin|Elevation WOLF2D (*.top)|*.top|Geotif (*.tif)|*.tif|Float ESRI (*.flt)|*.flt|Numpy (*.npy)|*.npy|Numpy named arrays(*.npz)|*.npz|all (*.*)|*.*"
4264
+ filterjson = "json (*.json)|*.json|all (*.*)|*.*"
3857
4265
  filterall = "all (*.*)|*.*"
3858
4266
  filterres2d = "all (*.*)|*.*"
3859
4267
  filterVector = "vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|dxf (*.dxf)|*.dxf|shp (*.shp)|*.shp|all (*.*)|*.*"
@@ -3865,6 +4273,8 @@ class WolfMapViewer(wx.Frame):
3865
4273
  # ouverture d'une boîte de dialogue
3866
4274
  if which.lower() == 'array' or which.lower() == 'array_crop':
3867
4275
  file = wx.FileDialog(self, "Choose file", wildcard=filterArray)
4276
+ elif which.lower() == 'particlesystem':
4277
+ file = wx.FileDialog(self, "Choose file", wildcard=filterjson)
3868
4278
  elif which.lower() == 'array_lidar_first' or which.lower() == 'array_lidar_second':
3869
4279
  file = wx.DirDialog(self, "Choose directory containing Lidar data")
3870
4280
  elif which.lower() == 'array_xyz':
@@ -3910,28 +4320,77 @@ class WolfMapViewer(wx.Frame):
3910
4320
  return
3911
4321
 
3912
4322
  if which.lower() == 'array' or which.lower() == 'array_crop':
3913
- curdict = self.added['arrays']
4323
+ curdict = self.added[draw_type.ARRAYS]
3914
4324
  curtree = self.myitemsarray
3915
4325
 
3916
4326
  if newobj is None:
3917
4327
 
3918
- testobj = WolfArray()
3919
- testobj.filename = filename
3920
- testobj.read_txt_header(filename)
4328
+ if filename.endswith('.npz'):
4329
+
4330
+ wait = wx.BusyCursor()
4331
+ logging.info(_('Start of importing arrays from npz file'))
4332
+
4333
+ with np.load(filename) as data:
4334
+ if 'header' in data.keys():
4335
+ header = data['header']
4336
+
4337
+ if len(header) == 6:
4338
+ logging.info(_('Header found in npz file'))
3921
4339
 
3922
- if testobj.wolftype in WOLF_ARRAY_MB:
3923
- with wx.lib.busy.BusyInfo(_('Importing array')):
3924
- wait = wx.BusyCursor()
3925
- newobj = WolfArrayMB(filename, mapviewer=self)
3926
- del wait
4340
+ origx, origy, dx, dy, nbx, nby = header
4341
+
4342
+ logging.info(_('Origin X : ') + str(origx))
4343
+ logging.info(_('Origin Y : ') + str(origy))
4344
+ logging.info(_('dx : ') + str(dx))
4345
+ logging.info(_('dy : ') + str(dy))
4346
+ logging.info(_('nbx : ') + str(nbx))
4347
+ logging.info(_('nby : ') + str(nby))
4348
+ nbx, nby = int(nbx), int(nby)
4349
+ else:
4350
+ logging.warning(_('Header found in npz file but not complete -- Only {} values found - Must be 6').format(len(header)))
4351
+
4352
+ for key, curarray in data.items():
4353
+ if isinstance(curarray, np.ndarray):
4354
+ if curarray.shape == (nby, nbx):
4355
+ logging.info("Importing array : " + key)
4356
+ curhead = header_wolf()
4357
+ curhead.origx, curhead.origy, curhead.dx, curhead.dy, curhead.nbx, curhead.nby = origx, origy, dx, dy, nbx, nby
4358
+ newobj = WolfArray(srcheader=curhead, idx = key)
4359
+ newobj.set_array_from_numpy(curarray)
4360
+ self.add_object('array', newobj= newobj, id= key)
4361
+ else:
4362
+ origx, origy, dx, dy, nbx, nby = 0.,0.,1,1.,1,1
4363
+ for key, curarray in data.items():
4364
+ if isinstance(curarray, np.ndarray):
4365
+ logging.info(_('No header found in npz file - Using default values for header'))
4366
+ logging.info("Importing array : " + key)
4367
+ curhead = header_wolf()
4368
+ curhead.origx, curhead.origy, curhead.dx, curhead.dy, curhead.nbx, curhead.nby = 0., 0., 1., 1., curarray.shape[0], curarray.shape[1]
4369
+ newobj = WolfArray(srcheader=curhead, idx = key)
4370
+ newobj.set_array_from_numpy(curarray)
4371
+ self.add_object('array', newobj= newobj, id= key)
4372
+
4373
+ logging.info(_('End of importing arrays from npz file'))
4374
+ del wait
4375
+ return
3927
4376
  else:
3928
- if which.lower() == 'array_crop':
3929
- newobj = WolfArray(filename, mapviewer=self, crop='newcrop')
3930
- else:
4377
+ testobj = WolfArray()
4378
+ testobj.filename = filename
4379
+ testobj.read_txt_header()
4380
+
4381
+ if testobj.wolftype in WOLF_ARRAY_MB:
3931
4382
  with wx.lib.busy.BusyInfo(_('Importing array')):
3932
4383
  wait = wx.BusyCursor()
3933
- newobj = WolfArray(filename, mapviewer=self)
4384
+ newobj = WolfArrayMB(filename, mapviewer=self)
3934
4385
  del wait
4386
+ else:
4387
+ if which.lower() == 'array_crop':
4388
+ newobj = WolfArray(filename, mapviewer=self, crop='newcrop')
4389
+ else:
4390
+ with wx.lib.busy.BusyInfo(_('Importing array')):
4391
+ wait = wx.BusyCursor()
4392
+ newobj = WolfArray(filename, mapviewer=self)
4393
+ del wait
3935
4394
 
3936
4395
  if newobj is not None:
3937
4396
  if newobj.dx==0. or newobj.dy==0.:
@@ -3981,7 +4440,7 @@ class WolfMapViewer(wx.Frame):
3981
4440
  self._set_active_bc()
3982
4441
 
3983
4442
  elif which.lower() == 'bridges':
3984
- curdict = self.added['vectors']
4443
+ curdict = self.added[draw_type.VECTORS]
3985
4444
  curtree = self.myitemsvector
3986
4445
 
3987
4446
  if newobj is None:
@@ -3992,7 +4451,7 @@ class WolfMapViewer(wx.Frame):
3992
4451
  self.myvectors.append(newobj)
3993
4452
 
3994
4453
  elif which.lower() == 'weirs':
3995
- curdict = self.added['vectors']
4454
+ curdict = self.added[draw_type.VECTORS]
3996
4455
  curtree = self.myitemsvector
3997
4456
 
3998
4457
  if newobj is None:
@@ -4003,7 +4462,7 @@ class WolfMapViewer(wx.Frame):
4003
4462
  self.myvectors.append(newobj)
4004
4463
 
4005
4464
  elif which.lower() in ['tiles', 'tilescomp']:
4006
- curdict = self.added['vectors']
4465
+ curdict = self.added[draw_type.VECTORS]
4007
4466
  curtree = self.myitemsvector
4008
4467
 
4009
4468
  if newobj is None:
@@ -4041,7 +4500,7 @@ class WolfMapViewer(wx.Frame):
4041
4500
 
4042
4501
  elif which.lower() == 'array_xyz':
4043
4502
 
4044
- curdict = self.added['arrays']
4503
+ curdict = self.added[draw_type.ARRAYS]
4045
4504
  curtree = self.myitemsarray
4046
4505
 
4047
4506
  msg = wx.MessageDialog(self, _('Do you want to crop the data?'), style=wx.YES_NO | wx.YES_DEFAULT)
@@ -4116,7 +4575,7 @@ class WolfMapViewer(wx.Frame):
4116
4575
  self._set_active_bc()
4117
4576
 
4118
4577
  elif which.lower() == 'array_lidar_first' or which.lower() == 'array_lidar_second':
4119
- curdict = self.added['arrays']
4578
+ curdict = self.added[draw_type.ARRAYS]
4120
4579
  curtree = self.myitemsarray
4121
4580
 
4122
4581
  newcrop = CropDialog(None)
@@ -4170,7 +4629,7 @@ class WolfMapViewer(wx.Frame):
4170
4629
  id = 'lidar2002_secondecho'
4171
4630
 
4172
4631
  elif which.lower() == 'res2d':
4173
- curdict = self.added['wolf2d']
4632
+ curdict = self.added[draw_type.RES2D]
4174
4633
  curtree = self.myitemsres2d
4175
4634
 
4176
4635
  if newobj is None:
@@ -4179,12 +4638,13 @@ class WolfMapViewer(wx.Frame):
4179
4638
  newobj = Wolfresults_2D(filename, mapviewer=self)
4180
4639
  del wait
4181
4640
 
4641
+ newobj.get_nbresults(True)
4182
4642
  newobj.updatepalette()
4183
4643
  self.myres2D.append(newobj)
4184
4644
  self.active_res2d = newobj
4185
4645
 
4186
4646
  elif which.lower() == 'res2d_gpu':
4187
- curdict = self.added['wolf2d']
4647
+ curdict = self.added[draw_type.RES2D]
4188
4648
  curtree = self.myitemsres2d
4189
4649
 
4190
4650
  if newobj is None:
@@ -4193,12 +4653,13 @@ class WolfMapViewer(wx.Frame):
4193
4653
  newobj = wolfres2DGPU(filename, mapviewer=self)
4194
4654
  del wait
4195
4655
 
4656
+ newobj.get_nbresults(True)
4196
4657
  newobj.updatepalette()
4197
4658
  self.myres2D.append(newobj)
4198
4659
  self.active_res2d = newobj
4199
4660
 
4200
4661
  elif which.lower() == 'vector':
4201
- curdict = self.added['vectors']
4662
+ curdict = self.added[draw_type.VECTORS]
4202
4663
  curtree = self.myitemsvector
4203
4664
  if newobj is None:
4204
4665
  with wx.lib.busy.BusyInfo(_('Importing file')):
@@ -4208,7 +4669,7 @@ class WolfMapViewer(wx.Frame):
4208
4669
  self.myvectors.append(newobj)
4209
4670
 
4210
4671
  elif which.lower() == 'cross_sections':
4211
- curdict = self.added['vectors']
4672
+ curdict = self.added[draw_type.VECTORS]
4212
4673
  curtree = self.myitemsvector
4213
4674
 
4214
4675
  if newobj is None:
@@ -4252,7 +4713,7 @@ class WolfMapViewer(wx.Frame):
4252
4713
  newobj.mapviewer = self
4253
4714
 
4254
4715
  elif which.lower() == 'cloud':
4255
- curdict = self.added['clouds']
4716
+ curdict = self.added[draw_type.CLOUD]
4256
4717
  curtree = self.myitemscloud
4257
4718
  if newobj is None:
4258
4719
 
@@ -4281,7 +4742,7 @@ class WolfMapViewer(wx.Frame):
4281
4742
  self.create_cloud_menu()
4282
4743
 
4283
4744
  elif which.lower() == 'triangulation':
4284
- curdict = self.added['triangulations']
4745
+ curdict = self.added[draw_type.TRIANGULATION]
4285
4746
  curtree = self.myitemstri
4286
4747
  if newobj is None:
4287
4748
  with wx.lib.busy.BusyInfo(_('Importing triangulation')):
@@ -4294,48 +4755,67 @@ class WolfMapViewer(wx.Frame):
4294
4755
 
4295
4756
  elif which.lower() == 'other':
4296
4757
  if not newobj is None:
4297
- curdict = self.added['others']
4758
+ curdict = self.added[draw_type.OTHER]
4298
4759
  curtree = self.myitemsothers
4299
4760
  self.myothers.append(newobj)
4300
4761
 
4301
4762
  elif which.lower() == 'views':
4302
4763
  if newobj is None:
4303
4764
  newobj = WolfViews(plotted=ToCheck, mapviewer=self)
4304
- newobj.read_from_file(file)
4765
+ newobj.read_from_file(filename)
4305
4766
 
4306
- curdict = self.added['views']
4767
+ curdict = self.added[draw_type.VIEWS]
4307
4768
  curtree = self.myitemsviews
4308
4769
  self.myviews.append(newobj)
4309
4770
 
4310
4771
  elif which.lower() == 'wmsback':
4311
4772
  if not newobj is None:
4312
- curdict = self.added[draw_type.WMSBACK.value]
4773
+ curdict = self.added[draw_type.WMSBACK]
4313
4774
  curtree = self.myitemswmsback
4314
4775
  self.mywmsback.append(newobj)
4315
4776
 
4316
4777
  elif which.lower() == 'wmsfore':
4317
4778
  if not newobj is None:
4318
- curdict = self.added[draw_type.WMSFORE.value]
4779
+ curdict = self.added[draw_type.WMSFORE]
4319
4780
  curtree = self.myitemswmsfore
4320
4781
  self.mywmsfore.append(newobj)
4321
4782
 
4783
+ elif which.lower() == 'particlesystem':
4784
+ curdict = self.added[draw_type.PARTICLE_SYSTEM]
4785
+ curtree = self.myitemsps
4786
+ if newobj is None:
4787
+ newobj = Particle_system()
4788
+ newobj.load(filename)
4789
+
4790
+ self.mypartsystems.append(newobj)
4791
+ self.active_particle_system = newobj
4792
+
4322
4793
  if id == '':
4323
- dlg = wx.TextEntryDialog(self, 'ID ? (case insensitive)', 'Choose an identifier', _('NewObject'))
4324
- dlg.SetValue('')
4794
+ dlg = wx.TextEntryDialog(self, 'ID ? (case insensitive)', 'Choose an identifier', '')
4795
+ if filename != '':
4796
+ dlg.SetValue((Path(filename).with_suffix('')).name)
4797
+ else:
4798
+ dlg.SetValue('')
4799
+
4325
4800
  if len(curdict) == 0:
4326
4801
  if dlg.ShowModal() == wx.ID_OK:
4327
4802
  id = dlg.GetValue()
4803
+ if id =='':
4804
+ id = '001'
4328
4805
  else:
4329
4806
  id = list(curdict.keys())[0]
4330
4807
  while id.lower() in curdict:
4331
4808
  if dlg.ShowModal() == wx.ID_OK:
4332
4809
  id = dlg.GetValue()
4810
+ if id =='':
4811
+ id = '001'
4333
4812
  dlg.Destroy()
4334
4813
 
4335
4814
  if id.lower() in curdict:
4336
- endid = '_'
4337
- while id.lower() in curdict:
4338
- id += endid
4815
+ # endid = '_'
4816
+ endid = 1
4817
+ while (id + str(endid).zfill(3)).lower() in curdict:
4818
+ endid += 1
4339
4819
 
4340
4820
  newobj.idx = id.lower()
4341
4821
 
@@ -4347,13 +4827,10 @@ class WolfMapViewer(wx.Frame):
4347
4827
 
4348
4828
  newobj.check_plot()
4349
4829
 
4350
- loc = curdict[id.lower()] = {}
4830
+ curdict[id.lower()] = newobj
4351
4831
  if filename != '':
4352
- loc['listname'] = filename.lower()
4353
- loc['filename'] = filename.lower()
4354
- loc['values'] = newobj
4355
- # loc['listitem'] = myitem
4356
- loc['checked'] = ToCheck
4832
+ newobj._filename = filename.lower() # FIXME useful ??
4833
+ newobj.checked = ToCheck
4357
4834
 
4358
4835
  if isinstance(newobj,crosssections):
4359
4836
  self.add_object('cloud',newobj=newobj.cloud,id=newobj.idx+'_intersect',ToCheck=False)
@@ -4376,13 +4853,108 @@ class WolfMapViewer(wx.Frame):
4376
4853
 
4377
4854
  """ Find the object associated with id """
4378
4855
 
4379
- for curdict in self.added:
4380
- if id.lower() in self.added[curdict].keys():
4856
+ for curdict in draw_type:
4857
+ keys = self.get_list_keys(curdict, checked_state=None)
4858
+ if id.lower() in keys:
4381
4859
  try:
4382
- return self.added[curdict][id.lower()]['values']
4860
+ idx = keys.index(id.lower())
4861
+ return self.get_list_objects(curdict, checked_state=None)[idx]
4383
4862
  except:
4384
4863
  return None
4385
4864
 
4865
+ # for curdict in self.added:
4866
+ # if id.lower() in self.added[curdict].keys():
4867
+ # try:
4868
+ # return self.added[curdict][id.lower()]['values']
4869
+ # except:
4870
+ # return None
4871
+
4872
+ def get_list_keys(self, drawing_type:draw_type, checked_state:bool=True):
4873
+ """ Create a list of keys of type draw_type """
4874
+ if checked_state is None:
4875
+ return [key for key, curobj in self.added[drawing_type].items()]
4876
+ else:
4877
+ return [key for key, curobj in self.added[drawing_type].items() if curobj.checked == checked_state]
4878
+
4879
+ def get_list_objects(self, drawing_type:draw_type, checked_state:bool=True):
4880
+ """ Create a list of objects of type draw_type """
4881
+ if checked_state is None:
4882
+ return [curobj for key, curobj in self.added[drawing_type].items()]
4883
+ else:
4884
+ return [curobj for key, curobj in self.added[drawing_type].items() if curobj.checked == checked_state]
4885
+
4886
+ def single_choice_key(self, draw_type:draw_type, checked_state:bool=True, message:str=_('Make a choice'), title:str=_('Choice')):
4887
+ """ Create wx dialog to choose a key object of type draw_type """
4888
+
4889
+ keys = self.get_list_keys(draw_type, checked_state)
4890
+ dlg = wx.SingleChoiceDialog(None, message, title, keys, style=wx.CHOICEDLG_STYLE)
4891
+ ret = dlg.ShowModal()
4892
+
4893
+ if ret != wx.ID_OK:
4894
+ dlg.Destroy()
4895
+ return None
4896
+
4897
+ idx = dlg.GetSelection()
4898
+ dlg.Destroy()
4899
+
4900
+ return keys[idx]
4901
+
4902
+ def single_choice_object(self, draw_type:draw_type, checked_state:bool=True, message:str=_('Make a choice'), title:str=_('Choice')):
4903
+ """ Create wx dialog to choose an object of type draw_type """
4904
+
4905
+ keys = self.get_list_keys(draw_type, checked_state)
4906
+ obj = self.get_list_objects
4907
+ dlg = wx.SingleChoiceDialog(None, message, title, keys, style=wx.CHOICEDLG_STYLE)
4908
+ ret = dlg.ShowModal()
4909
+
4910
+ if ret != wx.ID_OK:
4911
+ dlg.Destroy()
4912
+ return None
4913
+
4914
+ idx = dlg.GetSelection()
4915
+ dlg.Destroy()
4916
+
4917
+ return obj[idx]
4918
+
4919
+ def multiple_choice_key(self, draw_type:draw_type, checked_state:bool=True, message:str=_('Make a choice'), title:str=_('Choice')):
4920
+ """ Create wx dialog to choose multiple keys object of type draw_type """
4921
+
4922
+ keys = self.get_list_keys(draw_type, checked_state)
4923
+ dlg = wx.MultiChoiceDialog(None, message, title, keys, style=wx.CHOICEDLG_STYLE)
4924
+ ret = dlg.ShowModal()
4925
+
4926
+ if ret != wx.ID_OK:
4927
+ dlg.Destroy()
4928
+ return None
4929
+
4930
+ idx = dlg.GetSelections()
4931
+ dlg.Destroy()
4932
+
4933
+ return [keys[i] for i in idx]
4934
+
4935
+ def multiple_choice_object(self, draw_type:draw_type, checked_state:bool=True, message:str=_('Make a choice'), title:str=_('Choice')):
4936
+ """ Create wx dialog to choose multiple objects of type draw_type """
4937
+
4938
+ keys = self.get_list_keys(draw_type, checked_state)
4939
+ obj = self.get_list_objects
4940
+ dlg = wx.MultiChoiceDialog(None, message, title, keys, style=wx.CHOICEDLG_STYLE)
4941
+ ret = dlg.ShowModal()
4942
+
4943
+ if ret != wx.ID_OK:
4944
+ dlg.Destroy()
4945
+ return None
4946
+
4947
+ idx = dlg.GetSelections()
4948
+ dlg.Destroy()
4949
+
4950
+ return [obj[i] for i in idx]
4951
+
4952
+ def iterator_over_objects(self, drawing_type:draw_type, checked_state:bool=True) -> Element_To_Draw:
4953
+ """ Create iterator over objects of type draw_type """
4954
+
4955
+ for obj in self.get_list_objects(drawing_type, checked_state):
4956
+ yield obj
4957
+
4386
4958
  def gettreeitem(self, obj):
4387
4959
 
4388
4960
  """ Find the tree item associated with obj """
@@ -4567,6 +5139,8 @@ class WolfMapViewer(wx.Frame):
4567
5139
  self.selobj.saveas()
4568
5140
  elif type(self.selobj) is Triangulation:
4569
5141
  self.selobj.saveas()
5142
+ elif isinstance(self.selobj, Particle_system):
5143
+ self.selobj.save()
4570
5144
  elif text==_('Up'):
4571
5145
  self.upobj()
4572
5146
  elif text == _('Down'):
@@ -4601,6 +5175,8 @@ class WolfMapViewer(wx.Frame):
4601
5175
  break
4602
5176
 
4603
5177
  elif text == _('Save as'):
5178
+ # save objet to file, choosing the file name
5179
+
4604
5180
  if self.selobj is not None:
4605
5181
  if type(self.selobj) is WolfArray or type(self.selobj) is WolfArray_Sim2D:
4606
5182
  filterArray = "bin (*.bin)|*.bin|tif (*.tif)|*.tif|all (*.*)|*.*"
@@ -4631,11 +5207,20 @@ class WolfMapViewer(wx.Frame):
4631
5207
  self.selobj.saveas(fdlg.GetPath())
4632
5208
 
4633
5209
  fdlg.Destroy()
5210
+ elif isinstance(self.selobj, Particle_system):
5211
+ filterArray = "json (*.json)|*.json|all (*.*)|*.*"
5212
+ fdlg = wx.FileDialog(self, "Choose file name for particle system :" + self.selobj.idx, wildcard=filterArray,
5213
+ style=wx.FD_SAVE)
5214
+ ret = fdlg.ShowModal()
5215
+ if ret == wx.ID_OK:
5216
+ self.selobj.save(fdlg.GetPath())
5217
+
5218
+ fdlg.Destroy()
4634
5219
 
4635
5220
  elif text == _('Properties'):
4636
5221
 
4637
5222
  myobj = self.selobj
4638
- if type(myobj) in [WolfArray, WolfArray_Sim2D, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU]:
5223
+ if type(myobj) in [WolfArray, WolfArray_Sim2D, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system]:
4639
5224
  myobj.show_properties()
4640
5225
 
4641
5226
 
@@ -4682,7 +5267,10 @@ class WolfMapViewer(wx.Frame):
4682
5267
 
4683
5268
  if nameparent != '':
4684
5269
  curobj = self.getobj(nameitem)
4685
- self.added[nameparent][nameitem]['checked'] = bool(check)
5270
+ if curobj is None:
5271
+ return
5272
+ # curobj.checked = bool(check)
5273
+ # self.added[nameparent][nameitem]['checked'] = bool(check)
4686
5274
 
4687
5275
  if bool(check):
4688
5276
  try:
@@ -4708,6 +5296,8 @@ class WolfMapViewer(wx.Frame):
4708
5296
  size = float(dlg.GetValue())
4709
5297
  curobj.creategrid(size, self.xmin, self.ymin, self.xmax, self.ymax)
4710
5298
 
5299
+ self.Refresh()
5300
+
4711
5301
  def getXY(self, pospix):
4712
5302
 
4713
5303
  width, height = self.canvas.GetSize()
@@ -4726,11 +5316,15 @@ class WolfMapViewer(wx.Frame):
4726
5316
  """
4727
5317
  Récupération du premier objet crosssections disponible
4728
5318
  """
4729
- for curvect in self.added['vectors']:
4730
- if self.added['vectors'][curvect]['checked']:
4731
- obj = self.added['vectors'][curvect]['values']
4732
- if type(obj) is crosssections:
4733
- return obj
5319
+ for obj in self.iterator_over_objects(draw_type.VECTORS):
5320
+ if isinstance(obj,crosssections):
5321
+ return obj
5322
+
5323
+ # for curvect in self.added[draw_type.VECTORS.value]:
5324
+ # if self.added[draw_type.VECTORS.value][curvect]['checked']:
5325
+ # obj = self.added[draw_type.VECTORS.value][curvect]['values']
5326
+ # if type(obj) is crosssections:
5327
+ # return obj
4734
5328
 
4735
5329
  return None
4736
5330
 
@@ -5051,6 +5645,7 @@ class WolfMapViewer(wx.Frame):
5051
5645
  return
5052
5646
 
5053
5647
  def OnActivateTreeElem(self, e): #:dataview.TreeListEvent ):
5648
+ """ Activate the selected item in the tree list """
5054
5649
  curzones: Zones
5055
5650
  curzone: zone
5056
5651
  curvect: vector
@@ -5070,10 +5665,15 @@ class WolfMapViewer(wx.Frame):
5070
5665
  self.selobj = myobj
5071
5666
  self.selitem.SetLabel(nameitem)
5072
5667
 
5668
+ #FIXME : To generalize using draw_type
5073
5669
  if type(myobj) == Zones:
5074
5670
  if ctrl:
5075
5671
  myobj.show_properties()
5076
5672
 
5673
+ elif type(myobj) == Particle_system:
5674
+ if ctrl:
5675
+ myobj.show_properties()
5676
+
5077
5677
  elif type(myobj) == Tiles:
5078
5678
  self.active_tile= myobj
5079
5679
 
@@ -5140,103 +5740,130 @@ class WolfMapViewer(wx.Frame):
5140
5740
  self.mytooltip.myparams[curgroup] = {}
5141
5741
 
5142
5742
  curpar = 'Pixel'
5143
- self.mytooltip.myparams[curgroup][curpar] = {}
5144
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Pixel'
5145
- self.mytooltip.myparams[curgroup][curpar]['value'] = '(' + str(pos[0]) + ' ; ' + str(pos[1]) + ')'
5146
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5147
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5148
-
5149
- curpar = 'x'
5150
- self.mytooltip.myparams[curgroup][curpar] = {}
5151
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Coordinate X'
5152
- self.mytooltip.myparams[curgroup][curpar]['value'] = '{:3f}'.format(x)
5153
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5154
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5155
-
5156
- curpar = 'y'
5157
- self.mytooltip.myparams[curgroup][curpar] = {}
5158
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Coordinate Y'
5159
- self.mytooltip.myparams[curgroup][curpar]['value'] = '{:3f}'.format(y)
5160
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5161
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5743
+ self.mytooltip.add_param(groupname = curgroup,
5744
+ name = curpar,
5745
+ value = '(' + str(pos[0]) + ' ; ' + str(pos[1]) + ')',
5746
+ type = Type_Param.String,
5747
+ comment = '')
5748
+
5749
+ curpar = 'Coordinate X'
5750
+ self.mytooltip.add_param(groupname = curgroup,
5751
+ name = curpar,
5752
+ value = '{:3f}'.format(x),
5753
+ type = Type_Param.String,
5754
+ comment = '')
5755
+
5756
+ curpar = 'Coordinate Y'
5757
+ self.mytooltip.add_param(groupname = curgroup,
5758
+ name = curpar,
5759
+ value = '{:3f}'.format(y),
5760
+ type = Type_Param.String,
5761
+ comment = '')
5162
5762
 
5163
5763
  for locarray in self.myres2D:
5164
5764
  locarray:Wolfresults_2D
5165
5765
  curgroup = locarray.idx
5166
- if self.added['wolf2d'][curgroup]['checked']:
5766
+ if locarray.checked:
5167
5767
  try:
5168
-
5169
5768
  vals,labs = locarray.get_values_labels(x,y)
5170
5769
 
5171
5770
  i, j, curbloc = locarray.get_blockij_from_xy(x, y)
5172
5771
 
5173
5772
  if i != '-':
5174
- self.mytooltip.myparams[curgroup] = {}
5175
- curpar = 'Indices (1-based)'
5176
- self.mytooltip.myparams[curgroup][curpar] = {}
5177
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Indice (i;j;bloc)'
5178
- self.mytooltip.myparams[curgroup][curpar]['value'] = '(' + str(i) + ';' + str(j) + ';' + str(curbloc) + ')'
5179
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5180
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5773
+ curpar = 'Indices (i;j;bloc) (1-based)'
5774
+
5775
+ self.mytooltip.add_param(groupname = curgroup,
5776
+ name = curpar,
5777
+ value = '(' + str(i) + ';' + str(j) + ';' + str(curbloc) + ')',
5778
+ type = Type_Param.String,
5779
+ comment = '')
5181
5780
 
5182
5781
  for val,curpar in zip(vals,labs):
5183
- self.mytooltip.myparams[curgroup][curpar] = {}
5184
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Value'
5782
+
5185
5783
  if val is np.nan:
5186
- self.mytooltip.myparams[curgroup][curpar]['value'] = "Nan"
5784
+ self.mytooltip.add_param(groupname = curgroup,
5785
+ name = 'Value',
5786
+ value = "Nan",
5787
+ type = Type_Param.String,
5788
+ comment = '')
5789
+ elif isinstance(val, str):
5790
+ self.mytooltip.add_param(groupname = curgroup,
5791
+ name = curpar,
5792
+ value = val,
5793
+ type = Type_Param.String,
5794
+ comment = '')
5795
+ elif isinstance(val, int):
5796
+ self.mytooltip.add_param(groupname = curgroup,
5797
+ name = curpar,
5798
+ value = int(val),
5799
+ type = Type_Param.Integer,
5800
+ comment = '')
5187
5801
  else:
5188
- if isinstance(val, str):
5189
- self.mytooltip.myparams[curgroup][curpar]['value'] = val
5190
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5191
- elif isinstance(val, int):
5192
- self.mytooltip.myparams[curgroup][curpar]['value'] = int(val)
5193
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'Integer'
5194
- else:
5195
- self.mytooltip.myparams[curgroup][curpar]['value'] = float(val)
5196
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'Float'
5197
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5802
+ self.mytooltip.add_param(groupname = curgroup,
5803
+ name = curpar,
5804
+ value = float(val),
5805
+ type = Type_Param.Float,
5806
+ comment = '')
5807
+
5198
5808
  except:
5199
5809
  pass
5200
5810
 
5201
5811
  for locarray in self.myarrays:
5202
- curgroup = locarray.idx
5203
- if self.added['arrays'][curgroup]['checked']:
5812
+ if locarray.checked:
5813
+ curgroup = locarray.idx
5204
5814
 
5205
5815
  try:
5206
5816
  val = locarray.get_value(x, y)
5207
5817
 
5208
5818
  if val != -99999.:
5209
- self.mytooltip.myparams[curgroup] = {}
5210
5819
 
5211
5820
  if locarray.wolftype in WOLF_ARRAY_MB:
5212
5821
  i, j, curbloc = locarray.get_blockij_from_xy(x, y)
5213
- curpar = 'Indices (1-based)'
5214
- self.mytooltip.myparams[curgroup][curpar] = {}
5215
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Indice (i;j;bloc)'
5216
- self.mytooltip.myparams[curgroup][curpar]['value'] = '(' + str(i + 1) + ';' + str(
5217
- j + 1) + ';' + str(curbloc) + ')'
5218
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5219
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5822
+ curpar = 'Indices (i;j;bloc) (1-based)'
5823
+
5824
+ self.mytooltip.add_param(groupname = curgroup,
5825
+ name = curpar,
5826
+ value = '(' + str(i+1) + ';' + str(j+1) + ';' + str(curbloc) + ')',
5827
+ type = Type_Param.String,
5828
+ comment = '')
5829
+
5220
5830
  else:
5221
5831
  i, j = locarray.get_ij_from_xy(x, y)
5222
- curpar = 'Indices (1-based)'
5223
- self.mytooltip.myparams[curgroup][curpar] = {}
5224
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Indice (i;j)'
5225
- self.mytooltip.myparams[curgroup][curpar]['value'] = '(' + str(i + 1) + ';' + str(
5226
- j + 1) + ')'
5227
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5228
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5832
+ curpar = 'Indices (i;j) (1-based)'
5833
+
5834
+ self.mytooltip.add_param(groupname = curgroup,
5835
+ name = curpar,
5836
+ value = '(' + str(i+1) + ';' + str(j+1) + ')',
5837
+ type = Type_Param.String,
5838
+ comment = '')
5229
5839
 
5230
5840
  curpar = 'Value'
5231
- self.mytooltip.myparams[curgroup][curpar] = {}
5232
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Value'
5841
+
5233
5842
  if val is np.nan:
5234
- self.mytooltip.myparams[curgroup][curpar]['value'] = "Nan"
5843
+ self.mytooltip.add_param(groupname = curgroup,
5844
+ name = 'Value',
5845
+ value = "Nan",
5846
+ type = Type_Param.String,
5847
+ comment = '')
5848
+ elif isinstance(val, str):
5849
+ self.mytooltip.add_param(groupname = curgroup,
5850
+ name = curpar,
5851
+ value = val,
5852
+ type = Type_Param.String,
5853
+ comment = '')
5854
+ elif isinstance(val, int):
5855
+ self.mytooltip.add_param(groupname = curgroup,
5856
+ name = curpar,
5857
+ value = int(val),
5858
+ type = Type_Param.Integer,
5859
+ comment = '')
5235
5860
  else:
5236
- self.mytooltip.myparams[curgroup][curpar]['value'] = float(val)
5237
- # self.mytooltip.myparams[curgroup][curpar]['value'] = val
5238
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'Float'
5239
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5861
+ self.mytooltip.add_param(groupname = curgroup,
5862
+ name = curpar,
5863
+ value = float(val),
5864
+ type = Type_Param.Float,
5865
+ comment = '')
5866
+
5240
5867
  except:
5241
5868
  pass
5242
5869
 
@@ -5246,29 +5873,76 @@ class WolfMapViewer(wx.Frame):
5246
5873
  for locarray in curFrame.myarrays:
5247
5874
  curgroup = locarray.idx
5248
5875
  if curFrame.added['arrays'][curgroup]['checked']:
5249
- self.mytooltip.myparams[curgroup] = {}
5250
5876
 
5251
5877
  try:
5252
5878
  val = locarray.get_value(x, y)
5253
- i, j = locarray.get_ij_from_xy(x, y)
5254
5879
 
5255
- curpar = 'Indices (1-based)'
5256
- self.mytooltip.myparams[curgroup][curpar] = {}
5257
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Indice (i;j)'
5258
- self.mytooltip.myparams[curgroup][curpar]['value'] = '(' + str(i + 1) + ';' + str(
5259
- j + 1) + ')'
5260
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'String'
5261
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5880
+ if locarray.wolftype in WOLF_ARRAY_MB:
5881
+ i, j, curbloc = locarray.get_blockij_from_xy(x, y)
5882
+ curpar = 'Indices (i;j;bloc) (1-based)'
5883
+
5884
+ self.mytooltip.add_param(groupname = curgroup,
5885
+ name = curpar,
5886
+ value = '(' + str(i+1) + ';' + str(j+1) + ';' + str(curbloc) + ')',
5887
+ type = Type_Param.String,
5888
+ comment = '')
5889
+
5890
+ else:
5891
+ i, j = locarray.get_ij_from_xy(x, y)
5892
+ curpar = 'Indices (i;j) (1-based)'
5893
+
5894
+ self.mytooltip.add_param(groupname = curgroup,
5895
+ name = curpar,
5896
+ value = '(' + str(i+1) + ';' + str(j+1) + ')',
5897
+ type = Type_Param.String,
5898
+ comment = '')
5262
5899
 
5263
5900
  curpar = 'Value'
5264
- self.mytooltip.myparams[curgroup][curpar] = {}
5265
- self.mytooltip.myparams[curgroup][curpar]['name'] = 'Value'
5266
- self.mytooltip.myparams[curgroup][curpar]['value'] = val
5267
- self.mytooltip.myparams[curgroup][curpar]['type'] = 'Float'
5268
- self.mytooltip.myparams[curgroup][curpar]['comment'] = ''
5901
+
5902
+ if val is np.nan:
5903
+ self.mytooltip.add_param(groupname = curgroup,
5904
+ name = 'Value',
5905
+ value = "Nan",
5906
+ type = Type_Param.String,
5907
+ comment = '')
5908
+ elif isinstance(val, str):
5909
+ self.mytooltip.add_param(groupname = curgroup,
5910
+ name = curpar,
5911
+ value = val,
5912
+ type = Type_Param.String,
5913
+ comment = '')
5914
+ elif isinstance(val, int):
5915
+ self.mytooltip.add_param(groupname = curgroup,
5916
+ name = curpar,
5917
+ value = int(val),
5918
+ type = Type_Param.Integer,
5919
+ comment = '')
5920
+ else:
5921
+ self.mytooltip.add_param(groupname = curgroup,
5922
+ name = curpar,
5923
+ value = float(val),
5924
+ type = Type_Param.Float,
5925
+ comment = '')
5269
5926
  except:
5270
5927
  pass
5271
5928
 
5929
+ for loc_ps in self.mypartsystems:
5930
+ if loc_ps.checked:
5931
+ curgroup = loc_ps.idx
5932
+ try:
5933
+ self.mytooltip.add_param(groupname = curgroup,
5934
+ name = _('Step [s]'),
5935
+ value = loc_ps.current_step,
5936
+ type = Type_Param.Float,
5937
+ comment = 'Step in seconds')
5938
+ self.mytooltip.add_param(groupname = curgroup,
5939
+ name = _('Step [-]'),
5940
+ value = loc_ps.current_step_idx,
5941
+ type = Type_Param.Integer,
5942
+ comment = 'Step index')
5943
+ except:
5944
+ pass
5945
+
5272
5946
  self.mytooltip.PopulateOnePage()
5273
5947
 
5274
5948
 
@@ -5334,6 +6008,8 @@ class WolfMapViewer(wx.Frame):
5334
6008
  if self.action == 'dynamic parallel':
5335
6009
  self.active_zone.parallel_active(self.dynapar_dist)
5336
6010
 
6011
+ self.Refresh()
6012
+
5337
6013
  self._last_mouse_pos = (x,y,pos)
5338
6014
  self._update_mytooltip()
5339
6015
 
@@ -5350,6 +6026,8 @@ class WolfMapViewer(wx.Frame):
5350
6026
  self.mytooltip.Show(True)
5351
6027
 
5352
6028
  def Autoscale(self, update_backfore=True):
6029
+ """ Redimensionnement de la fenêtre pour afficher tous les objets """
6030
+
5353
6031
  self.findminmax()
5354
6032
  self.width = self.xmax - self.xmin
5355
6033
  self.height = self.ymax - self.ymin
@@ -5377,13 +6055,19 @@ class WolfMapViewer(wx.Frame):
5377
6055
 
5378
6056
  if update_backfore:
5379
6057
  # dessin du background
5380
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSBACK.value].items()):
5381
- if curmap['checked']:
5382
- curmap['values'].reload()
6058
+ for obj in self.iterator_over_objects(draw_type.WMSBACK):
6059
+ obj.reload()
6060
+
6061
+ # for id, (key, curmap) in enumerate(self.added[draw_type.WMSBACK.value].items()):
6062
+ # if curmap['checked']:
6063
+ # curmap['values'].reload()
5383
6064
  # dessin du foreground
5384
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSFORE.value].items()):
5385
- if curmap['checked']:
5386
- curmap['values'].reload()
6065
+ for obj in self.iterator_over_objects(draw_type.WMSFORE):
6066
+ obj.reload()
6067
+
6068
+ # for id, (key, curmap) in enumerate(self.added[draw_type.WMSFORE.value].items()):
6069
+ # if curmap['checked']:
6070
+ # curmap['values'].reload()
5387
6071
 
5388
6072
  self.setbounds()
5389
6073
 
@@ -5394,7 +6078,6 @@ class WolfMapViewer(wx.Frame):
5394
6078
  inside_under = 'inside' in self.action
5395
6079
  self.action = None
5396
6080
 
5397
- self.active_vector.nbvertices = self.active_vector.nbvertices - 1
5398
6081
  self.active_vector.myvertices.pop(-1)
5399
6082
 
5400
6083
  if inside_under:
@@ -5405,13 +6088,11 @@ class WolfMapViewer(wx.Frame):
5405
6088
 
5406
6089
  if self.action == 'laz tmp vector':
5407
6090
  self.action = None
5408
- self.active_vector.nbvertices = self.active_vector.nbvertices - 1
5409
6091
  self.active_vector.myvertices.pop(-1)
5410
6092
  self.plot_laz_around_active_vec()
5411
6093
 
5412
6094
  if self.action == 'create polygon - tiles':
5413
6095
  self.action = None
5414
- self.active_vector.nbvertices = self.active_vector.nbvertices - 1
5415
6096
  self.active_vector.myvertices.pop(-1)
5416
6097
  self.active_vector.close_force()
5417
6098
 
@@ -5450,7 +6131,6 @@ class WolfMapViewer(wx.Frame):
5450
6131
 
5451
6132
  if self.action == 'capture vertices':
5452
6133
  self.action = None
5453
- self.active_vector.nbvertices = self.active_vector.nbvertices - 1
5454
6134
  self.active_vector.myvertices.pop(-1)
5455
6135
  r = wx.MessageDialog(
5456
6136
  None,
@@ -5471,7 +6151,6 @@ class WolfMapViewer(wx.Frame):
5471
6151
  self.action = None
5472
6152
 
5473
6153
  if self.action == 'dynamic parallel':
5474
- self.active_vector.nbvertices -= 1
5475
6154
  self.active_vector.myvertices.pop(-1)
5476
6155
  self.active_zone.parallel_active(self.dynapar_dist)
5477
6156
 
@@ -5485,6 +6164,7 @@ class WolfMapViewer(wx.Frame):
5485
6164
 
5486
6165
  self.copyfrom = None
5487
6166
 
6167
+ self.Refresh()
5488
6168
  self.mimicme()
5489
6169
 
5490
6170
  def OnHotKey(self, e: wx.KeyEvent):
@@ -5492,15 +6172,21 @@ class WolfMapViewer(wx.Frame):
5492
6172
  Gestion des touches clavier
5493
6173
  F1 : mise à jour du dernier pas de résultat
5494
6174
  F2 : mise à jour du résultat pas suivant
6175
+ F4 : mise à jour du particle system au pas suivant
5495
6176
  Shift+F2 : mise à jour du résultat pas précédent
6177
+ Shift+F4 : mise à jour du particle system au pas précédent
5496
6178
  CTRL+F2 : choix du pas
6179
+ CTRL+F4 : choix du pas (particle system)
5497
6180
  CTRL+Shift+F2 : choix du pas sur base du temps
6181
+ CTRL+Shift+F4 : choix du pas sur base du temps (particle system)
5498
6182
  F5 : autoscale
5499
6183
  F7 : refresh
5500
6184
  F9 : sélection de toutes les mailles dans la matrice courante
5501
6185
  F11 : sélection sur matrice courante
5502
6186
  F12 : opération sur matrice courante
5503
6187
 
6188
+ ESPACE : pause/resume animation
6189
+
5504
6190
  Z : zoom avant
5505
6191
  z : zoom artrière
5506
6192
  Flèches : déplacements latéraux
@@ -5557,6 +6243,7 @@ class WolfMapViewer(wx.Frame):
5557
6243
 
5558
6244
  self.active_res2d.read_oneresult(nb-1)
5559
6245
  self.active_res2d.set_currentview()
6246
+ self.Refresh()
5560
6247
 
5561
6248
  else:
5562
6249
  logging.info(_('Please activate a simulation before search a specific result'))
@@ -5584,10 +6271,57 @@ class WolfMapViewer(wx.Frame):
5584
6271
 
5585
6272
  self.active_res2d.read_oneresult(choices.index(keyvalue))
5586
6273
  self.active_res2d.set_currentview()
6274
+ self.Refresh()
6275
+
6276
+ else:
6277
+ logging.info(_('Please activate a simulation before searching a specific result'))
6278
+
6279
+ if key == wx.WXK_F4 and not e.ShiftDown():
6280
+
6281
+ if self.active_particle_system is not None:
6282
+
6283
+ nb = self.active_particle_system.nb_steps
6284
+ dlg = wx.NumberEntryDialog(None,_('Please choose a step (1 -> {})'.format(nb)),'Step :', _('Select a specific step'), nb, min=1, max=nb)
6285
+ ret = dlg.ShowModal()
6286
+
6287
+ nb = dlg.GetValue()
6288
+ dlg.Destroy()
6289
+
6290
+ self.active_particle_system.current_step = nb-1
6291
+ self.Refresh()
6292
+ self._update_mytooltip()
6293
+
6294
+ else:
6295
+ logging.info(_('Please activate a particle system before searching a specific result'))
6296
+
6297
+ elif key == wx.WXK_F4 and e.ShiftDown():
6298
+
6299
+ if self.active_particle_system is not None:
6300
+
6301
+ choices = ['{:.3f} [s] - {} [h:m:s]'.format(cur, timedelta(seconds=int(cur),
6302
+ milliseconds=int(cur-int(cur))*1000))
6303
+ for cur in self.active_particle_system.get_times()]
6304
+
6305
+ dlg = wx.SingleChoiceDialog(None,
6306
+ _('Please choose a time step'),
6307
+ _('Select a specific step'),
6308
+ choices)
6309
+ ret = dlg.ShowModal()
6310
+ if ret == wx.ID_CANCEL:
6311
+ dlg.Destroy()
6312
+ return
6313
+
6314
+ keyvalue = dlg.GetStringSelection()
6315
+ dlg.Destroy()
6316
+
6317
+ self.active_particle_system.current_step = choices.index(keyvalue)
6318
+ self.Refresh()
6319
+ self._update_mytooltip()
5587
6320
 
5588
6321
  else:
5589
6322
  logging.info(_('Please activate a simulation before search a specific result'))
5590
6323
 
6324
+
5591
6325
  elif key == 388: #+ from numpad
5592
6326
  if self.active_res2d is not None:
5593
6327
  self.active_res2d.update_zoom_2(1.1)
@@ -5709,6 +6443,16 @@ class WolfMapViewer(wx.Frame):
5709
6443
  if key == wx.WXK_DELETE:
5710
6444
  self.removeobj()
5711
6445
 
6446
+ elif key == wx.WXK_SPACE:
6447
+ if self.timer_ps is not None and self.active_particle_system is not None :
6448
+ if self.timer_ps.IsRunning():
6449
+ self.timer_ps.Stop()
6450
+ else:
6451
+ if self.active_particle_system.current_step_idx == self.active_particle_system.nb_steps-1:
6452
+ self.active_particle_system.current_step_idx = 0
6453
+ self.active_particle_system.current_step = 0
6454
+ self.timer_ps.Start(1000. / self.active_particle_system.fps)
6455
+
5712
6456
  elif key == 388: #+ from numpad
5713
6457
  if self.active_res2d is not None:
5714
6458
  self.active_res2d.update_arrowpixelsize_vectorfield(-1)
@@ -5747,6 +6491,12 @@ class WolfMapViewer(wx.Frame):
5747
6491
  elif key == wx.WXK_F2 and e.ShiftDown():
5748
6492
  self.simul_previous_step()
5749
6493
 
6494
+ elif key == wx.WXK_F4 and e.ShiftDown():
6495
+ self.particle_previous_step()
6496
+
6497
+ elif key == wx.WXK_F4:
6498
+ self.particle_next_step()
6499
+
5750
6500
  elif key == wx.WXK_F2:
5751
6501
  self.simul_next_step()
5752
6502
 
@@ -5841,27 +6591,55 @@ class WolfMapViewer(wx.Frame):
5841
6591
 
5842
6592
  def update(self):
5843
6593
  # dessin du background
5844
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSBACK.value].items()):
5845
- if curmap['checked']:
5846
- curmap['values'].reload()
6594
+ for obj in self.iterator_over_objects(draw_type.WMSBACK):
6595
+ obj.reload()
6596
+
6597
+ # for id, (key, curmap) in enumerate(self.added[draw_type.WMSBACK.value].items()):
6598
+ # if curmap['checked']:
6599
+ # curmap['values'].reload()
5847
6600
  # dessin du foreground
5848
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSFORE.value].items()):
5849
- if curmap['checked']:
5850
- curmap['values'].reload()
6601
+ for obj in self.iterator_over_objects(draw_type.WMSFORE):
6602
+ obj.reload()
6603
+
6604
+ # for id, (key, curmap) in enumerate(self.added[draw_type.WMSFORE.value].items()):
6605
+ # if curmap['checked']:
6606
+ # curmap['values'].reload()
5851
6607
 
5852
6608
  if self.locminmax.IsChecked() or self.update_absolute_minmax:
5853
- for id, (key, curmap) in enumerate(self.added['arrays'].items()):
5854
- if curmap['checked']:
5855
- curarray: WolfArray
5856
- curarray = curmap['values']
5857
- if self.update_absolute_minmax:
5858
- curarray.updatepalette()
5859
- self.update_absolute_minmax = False
5860
- else:
5861
- curarray.updatepalette(onzoom=[self.xmin, self.xmax, self.ymin, self.ymax])
5862
- curarray.delete_lists()
6609
+ for curarray in self.iterator_over_objects(draw_type.ARRAYS):
6610
+ curarray: WolfArray
6611
+ if self.update_absolute_minmax:
6612
+ curarray.updatepalette()
6613
+ self.update_absolute_minmax = False
6614
+ else:
6615
+ curarray.updatepalette(onzoom=[self.xmin, self.xmax, self.ymin, self.ymax])
6616
+ curarray.delete_lists()
6617
+
6618
+ # for id, (key, curmap) in enumerate(self.added[draw_type.ARRAYS.value].items()):
6619
+ # if curmap['checked']:
6620
+ # curarray: WolfArray
6621
+ # curarray = curmap['values']
6622
+ # if self.update_absolute_minmax:
6623
+ # curarray.updatepalette()
6624
+ # self.update_absolute_minmax = False
6625
+ # else:
6626
+ # curarray.updatepalette(onzoom=[self.xmin, self.xmax, self.ymin, self.ymax])
6627
+ # curarray.delete_lists()
5863
6628
  self.Paint()
5864
6629
 
6630
+ def _plotting(self, drawing_type: draw_type, checked_state: bool = True):
6631
+ """ Drawing objets on canvas"""
6632
+
6633
+ try:
6634
+ for curobj in self.iterator_over_objects(drawing_type, checked_state=checked_state):
6635
+ if not curobj.plotting:
6636
+ curobj.plotting = True
6637
+ curobj.plot(sx = self.sx, sy=self.sy, xmin=self.xmin, ymin=self.ymin, xmax=self.xmax, ymax=self.ymax, size = (self.xmax - self.xmin) / 100.)
6638
+ curobj.plotting = False
6639
+ except:
6640
+ curobj.plotting = False
6641
+ logging.error(_('Error while plotting objects of type {}').format(drawing_type.name))
6642
+
5865
6643
  def Paint(self):
5866
6644
 
5867
6645
  if self.currently_readresults:
@@ -5890,92 +6668,38 @@ class WolfMapViewer(wx.Frame):
5890
6668
  glLoadIdentity()
5891
6669
 
5892
6670
  # dessin du background
5893
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSBACK.value].items()):
5894
- if curmap['checked']:
5895
- curmap['values'].paint()
6671
+ self._plotting(draw_type.WMSBACK)
5896
6672
 
5897
6673
  # Dessin des matrices
5898
- try:
5899
- for curarray in self.added['arrays']:
5900
- if self.added['arrays'][curarray]['checked']:
5901
- locarray = self.added['arrays'][curarray]['values']
5902
- if not locarray.plotting:
5903
- locarray.plotting = True
5904
- self.added['arrays'][curarray]['values'].plot(self.sx, self.sy, self.xmin, self.ymin,
5905
- self.xmax, self.ymax)
5906
- locarray.plotting = False
5907
- except:
5908
- pass
6674
+ self._plotting(draw_type.ARRAYS)
5909
6675
 
5910
6676
  # Dessin des résultats 2D
5911
- try:
5912
- for curarray in self.added['wolf2d']:
5913
- if self.added['wolf2d'][curarray]['checked']:
5914
- locarray = self.added['wolf2d'][curarray]['values']
5915
- if not locarray.plotting:
5916
- locarray.plotting = True
5917
- self.added['wolf2d'][curarray]['values'].plot(self.sx, self.sy, self.xmin, self.ymin,
5918
- self.xmax, self.ymax)
5919
- locarray.plotting = False
5920
- except:
5921
- pass
6677
+ self._plotting(draw_type.RES2D)
5922
6678
 
5923
6679
  # Dessin des vecteurs
5924
- try:
5925
- for curvect in self.added['vectors']:
5926
- if self.added['vectors'][curvect]['checked']:
5927
- self.added['vectors'][curvect]['values'].plot()
5928
- except:
5929
- pass
6680
+ self._plotting(draw_type.VECTORS)
5930
6681
 
5931
6682
  if self.active_vector is not None:
5932
6683
  if self.active_vector.parentzone is None:
5933
6684
  self.active_vector.plot()
5934
6685
 
5935
6686
  # Dessin des triangulations
5936
- try:
5937
- for curvect in self.added['triangulations']:
5938
- if self.added['triangulations'][curvect]['checked']:
5939
- self.added['triangulations'][curvect]['values'].plot()
5940
- except:
5941
- pass
6687
+ self._plotting(draw_type.TRIANGULATION)
5942
6688
 
5943
6689
  # Dessin des nuages
5944
- try:
5945
- for curcloud in self.added['clouds']:
5946
- if self.added['clouds'][curcloud]['checked']:
5947
- self.added['clouds'][curcloud]['values'].plot()
5948
- except:
5949
- pass
6690
+ self._plotting(draw_type.CLOUD)
5950
6691
 
5951
6692
  # Dessin des vues
5952
- try:
5953
- for curobj in self.added['views']:
5954
- if self.added['views'][curobj]['checked']:
5955
- curobj = self.added['views'][curobj]['values']
5956
- curobj.plot(self.sx, self.sy, self.xmin, self.ymin,self.xmax, self.ymax)
5957
- except:
5958
- pass
6693
+ self._plotting(draw_type.VIEWS)
5959
6694
 
5960
- # Dessin du reste
5961
- try:
5962
- for curobj in self.added['others']:
5963
- if self.added['others'][curobj]['checked']:
5964
- curobj = self.added['others'][curobj]['values']
5965
- if type(curobj) is SPWDCENNGaugingStations or \
5966
- type(curobj) is SPWMIGaugingStations or \
5967
- type(curobj) is hydrometry_hece:
5968
- curobj.plot((self.xmax - self.xmin) / 100.)
5969
- elif type(curobj) is genericImagetexture:
5970
- curobj.paint()
6695
+ # Dessin des "particule systems"
6696
+ self._plotting(draw_type.PARTICLE_SYSTEM)
5971
6697
 
5972
- except:
5973
- pass
6698
+ # Dessin du reste
6699
+ self._plotting(draw_type.OTHER)
5974
6700
 
5975
6701
  # Dessin du Front
5976
- for id, (key, curmap) in enumerate(self.added[draw_type.WMSFORE.value].items()):
5977
- if curmap['checked']:
5978
- curmap['values'].paint()
6702
+ self._plotting(draw_type.WMSFORE)
5979
6703
 
5980
6704
  # Gestion des BC (si actif)
5981
6705
  try:
@@ -5991,12 +6715,16 @@ class WolfMapViewer(wx.Frame):
5991
6715
  'Opengl setcurrent -- maybe a conflict with an existing opengl32.dll file - please rename the opengl32.dll in the libs directory and retry')
5992
6716
 
5993
6717
  def OnPaint(self, e):
5994
-
6718
+ """ event handler for paint event"""
5995
6719
  self.Paint()
5996
6720
  if e is not None:
5997
6721
  e.Skip()
5998
6722
 
5999
6723
  def findminmax(self, force=False):
6724
+ """ Find min/max of all objects """
6725
+
6726
+ # FIXME : use iterator
6727
+
6000
6728
  xmin = 1.e30
6001
6729
  ymin = 1.e30
6002
6730
  xmax = -1.e30
@@ -6004,7 +6732,7 @@ class WolfMapViewer(wx.Frame):
6004
6732
 
6005
6733
  k = 0
6006
6734
  for locarray in self.myarrays:
6007
- if self.added['arrays'][locarray.idx]['checked'] or force:
6735
+ if self.added[draw_type.ARRAYS][locarray.idx].checked or force:
6008
6736
  xmin = min(locarray.origx + locarray.translx, xmin)
6009
6737
  xmax = max(locarray.origx + locarray.translx + float(locarray.nbx) * locarray.dx, xmax)
6010
6738
  ymin = min(locarray.origy + locarray.transly, ymin)
@@ -6012,7 +6740,7 @@ class WolfMapViewer(wx.Frame):
6012
6740
  k += 1
6013
6741
 
6014
6742
  for locvector in self.myvectors:
6015
- if self.added['vectors'][locvector.idx]['checked'] or force:
6743
+ if self.added[draw_type.VECTORS][locvector.idx].checked or force:
6016
6744
  if locvector.idx != 'grid':
6017
6745
  locvector.find_minmax()
6018
6746
  if isinstance(locvector,Zones):
@@ -6033,7 +6761,7 @@ class WolfMapViewer(wx.Frame):
6033
6761
  k += 1
6034
6762
 
6035
6763
  for locvector in self.mytiles:
6036
- if self.added['vectors'][locvector.idx]['checked'] or force:
6764
+ if self.added[draw_type.VECTORS][locvector.idx].checked or force:
6037
6765
  if locvector.idx != 'grid':
6038
6766
  locvector.find_minmax()
6039
6767
  if isinstance(locvector,Zones):
@@ -6054,7 +6782,7 @@ class WolfMapViewer(wx.Frame):
6054
6782
  k += 1
6055
6783
 
6056
6784
  for loccloud in self.myclouds:
6057
- if self.added['clouds'][loccloud.idx]['checked'] or force:
6785
+ if self.added['clouds'][loccloud.idx].checked or force:
6058
6786
  loccloud.find_minmax(force)
6059
6787
  xmin = min(loccloud.xbounds[0], xmin)
6060
6788
  xmax = max(loccloud.xbounds[1], xmax)
@@ -6063,7 +6791,7 @@ class WolfMapViewer(wx.Frame):
6063
6791
  k += 1
6064
6792
 
6065
6793
  for loctri in self.mytri:
6066
- if self.added['triangulations'][loctri.idx]['checked'] or force:
6794
+ if self.added['triangulations'][loctri.idx].checked or force:
6067
6795
  loctri.find_minmax(force)
6068
6796
  xmin = min(loctri.minx, xmin)
6069
6797
  xmax = max(loctri.maxx, xmax)
@@ -6073,7 +6801,7 @@ class WolfMapViewer(wx.Frame):
6073
6801
 
6074
6802
  for locres2d in self.myres2D:
6075
6803
  locres2d:Wolfresults_2D
6076
- if self.added['wolf2d'][locres2d.idx]['checked'] or force:
6804
+ if self.added[draw_type.RES2D][locres2d.idx].checked or force:
6077
6805
  locres2d.find_minmax(force)
6078
6806
  xmin = min(locres2d.xmin, xmin)
6079
6807
  xmax = max(locres2d.xmax, xmax)
@@ -6081,6 +6809,16 @@ class WolfMapViewer(wx.Frame):
6081
6809
  ymax = max(locres2d.ymax, ymax)
6082
6810
  k += 1
6083
6811
 
6812
+ for locps in self.mypartsystems:
6813
+ locps:Particle_system
6814
+ if self.added[draw_type.PARTICLE_SYSTEM][locps.idx].checked or force:
6815
+ locps.find_minmax(force)
6816
+ xmin = min(locps.xmin, xmin)
6817
+ xmax = max(locps.xmax, xmax)
6818
+ ymin = min(locps.ymin, ymin)
6819
+ ymax = max(locps.ymax, ymax)
6820
+ k += 1
6821
+
6084
6822
  for locview in self.myviews:
6085
6823
  locview.find_minmax(force)
6086
6824
  xmin = locview.xmin
@@ -6169,10 +6907,10 @@ class WolfMapViewer(wx.Frame):
6169
6907
  logging.info(_('Activating zone : ' + zone.myname))
6170
6908
 
6171
6909
  def list_background(self):
6172
- return self.added[draw_type.WMSBACK.value].keys()
6910
+ return self.added[draw_type.WMSBACK].keys()
6173
6911
 
6174
6912
  def list_foreground(self):
6175
- return self.added[draw_type.WMSFORE.value].keys()
6913
+ return self.added[draw_type.WMSFORE].keys()
6176
6914
 
6177
6915
  def check_id(self, id=str, gridsize = 100.):
6178
6916
  curobj = self.getobj(id)
@@ -6183,7 +6921,7 @@ class WolfMapViewer(wx.Frame):
6183
6921
 
6184
6922
  for curlist in self.added.values():
6185
6923
  if id in curlist.keys():
6186
- curlist[id]['checked'] = True
6924
+ curlist[id].checked = True
6187
6925
 
6188
6926
  curobj.check_plot()
6189
6927
 
@@ -6202,7 +6940,7 @@ class WolfMapViewer(wx.Frame):
6202
6940
 
6203
6941
  for curlist in self.added.values():
6204
6942
  if id in curlist.keys():
6205
- curlist[id]['checked'] = False
6943
+ curlist[id].checked = False
6206
6944
 
6207
6945
  if type(curobj) in [WolfArray, WolfArrayMB]:
6208
6946
  curobj.uncheck_plot(unload, forceresetOGL, askquestion)