wolfhece 2.1.0__py3-none-any.whl → 2.1.2__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.
wolfhece/GraphProfile.py CHANGED
@@ -547,7 +547,7 @@ class PlotCSAll(ProfilePanel):
547
547
  self.mapviewer.set_active_vector(self.mycs) #To avoid visual confusions, we set the profile as the active vector in wolfhece.pydraw
548
548
  self.mycs.color_active_profile(plot_opengl= True) #we thicken and color the profile in red.
549
549
  size = 200
550
- self.mapviewer.zoomon_active_profile(size=size) #We zoom on the profile in the gui.
550
+ self.mapviewer.zoom_on_active_profile(size=size) #We zoom on the profile in the gui.
551
551
  self.mapviewer.Paint() #We take the visual information in the GUI necessary for a screen shot.
552
552
  self.mapviewer.display_canvasogl(fig= fig, ax = ax3) #We return a clear screen shot of the wolfpy GUI as a matplolib graph (ax).
553
553
  else:
wolfhece/PyDraw.py CHANGED
@@ -108,6 +108,108 @@ class draw_type(Enum):
108
108
  WMSFORE = 'wms-foreground'
109
109
  TILES = 'tiles'
110
110
 
111
+
112
+ class DragdropFileTarget(wx.FileDropTarget):
113
+ def __init__(self, window:"WolfMapViewer"):
114
+ wx.FileDropTarget.__init__(self)
115
+ self.window = window
116
+
117
+ def OnDropFiles(self, x, y, filenames):
118
+
119
+ def test_if_array(filename):
120
+
121
+ ext = Path(filename).suffix
122
+
123
+ if ext.lower() in ['.bin', '.npy', '.hbin', '.qxin','.qybin', '.top',
124
+ '.kbin', '.epsbin', '.tif', '.frot', '.topini_fine']:
125
+ return True
126
+ else:
127
+ return False
128
+
129
+ def test_if_arrayMB(filename):
130
+
131
+ ext = Path(filename).suffix
132
+
133
+ if ext.lower() in ['.hbinb', '.qxbinb','.qybinb', '.kbinb',
134
+ '.epsbinb', '.topini', '.frotini']:
135
+ return True
136
+ else:
137
+ return False
138
+
139
+ def test_if_vector(filename):
140
+ ext = Path(filename).suffix
141
+
142
+ if ext.lower() in ['.vec', '.vecz', '.shp', '.dxf']:
143
+ return True
144
+ else:
145
+ return False
146
+
147
+ def test_if_cloud(filename):
148
+ ext = Path(filename).suffix
149
+
150
+ if ext.lower() in ['.xyz']:
151
+ return True
152
+ else:
153
+ return False
154
+
155
+ for name in filenames:
156
+
157
+ if Path(name).is_dir():
158
+ for file in scandir(name):
159
+ if file.is_file():
160
+ self.OnDropFiles(x, y, [file.path])
161
+ continue
162
+
163
+ if test_if_array(name):
164
+ ids = self.window.get_list_keys(draw_type.ARRAYS)
165
+ id = Path(name).stem
166
+ while id in ids:
167
+ id = id + '_1'
168
+
169
+ try:
170
+ newobj = WolfArray(fname=name)
171
+ self.window.add_object('array', newobj = newobj, id = id)
172
+ except:
173
+ logging.error(_('Error while loading array : ') + name)
174
+
175
+ elif test_if_arrayMB(name):
176
+ ids = self.window.get_list_keys(draw_type.ARRAYS)
177
+ id = Path(name).stem
178
+ while id in ids:
179
+ id = id + '_1'
180
+
181
+ try:
182
+ newobj = WolfArrayMB(fname=name)
183
+ self.window.add_object('array', newobj = newobj, id = id)
184
+ except:
185
+ logging.error(_('Error while loading array : ') + name)
186
+
187
+ elif test_if_vector(name):
188
+ ids = self.window.get_list_keys(draw_type.VECTORS)
189
+ id = Path(name).stem
190
+ while id in ids:
191
+ id = id + '_1'
192
+
193
+ try:
194
+ newobj = Zones(filename=name)
195
+ self.window.add_object('vector', newobj = newobj, id = id)
196
+ except:
197
+ logging.error(_('Error while loading vector : ') + name)
198
+
199
+ elif test_if_cloud(name):
200
+ ids = self.window.get_list_keys(draw_type.CLOUD)
201
+ id = Path(name).stem
202
+ while id in ids:
203
+ id = id + '_1'
204
+
205
+ try:
206
+ newobj = cloud_vertices(fname=name)
207
+ self.window.add_object('cloud', newobj = newobj, id = id)
208
+ except:
209
+ logging.error(_('Error while loading cloud : ') + name)
210
+
211
+ return True
212
+
111
213
  class WolfMapViewer(wx.Frame):
112
214
  """
113
215
  Fenêtre de visualisation de données WOLF grâce aux WxWidgets
@@ -228,6 +330,9 @@ class WolfMapViewer(wx.Frame):
228
330
  self.treewidth = treewidth
229
331
  super(WolfMapViewer, self).__init__(wxparent, title=title, size=(w + self.treewidth, h))
230
332
 
333
+ self._dragdrop = DragdropFileTarget(self)
334
+ self.SetDropTarget(self._dragdrop)
335
+
231
336
  # Gestion des menus
232
337
  self.popupmenu = wx.Menu()
233
338
  self.popupmenu.Bind(wx.EVT_MENU, self.OnPopupItemSelected)
@@ -328,30 +433,40 @@ class WolfMapViewer(wx.Frame):
328
433
  self.filemenu.AppendSeparator()
329
434
  addscan = self.filemenu.Append(wx.ID_FILE5, _('Recursive scan...'), _('Add recursively'))
330
435
 
331
- self.toolsmenu = wx.Menu()
332
- self.link_cs_zones = self.toolsmenu.Append(wx.ID_ANY, _("Link cross sections to active zones"),
436
+ # Tools
437
+ # ----------------
438
+
439
+ self.tools_menu = wx.Menu()
440
+
441
+ self.menu_contour_from_arrays = self.tools_menu.Append(wx.ID_ANY, _("Create contour from checked arrays..."), _("Create contour"))
442
+
443
+ # Cross sections
444
+ # ----------------
445
+
446
+ self.cs_menu = wx.Menu()
447
+ self.link_cs_zones = self.cs_menu.Append(wx.ID_ANY, _("Link cross sections to active zones"),
333
448
  _("Link cross section"))
334
- self.sortalong = self.toolsmenu.Append(ID_SORTALONG, _("Sort along..."),
449
+ self.sortalong = self.cs_menu.Append(ID_SORTALONG, _("Sort along..."),
335
450
  _("Sort cross sections along support vector"))
336
- self.select_cs = self.toolsmenu.Append(ID_SELECTCS, _("Pick one cross section"), _("Select cross section"),
451
+ self.select_cs = self.cs_menu.Append(ID_SELECTCS, _("Pick one cross section"), _("Select cross section"),
337
452
  kind=wx.ITEM_CHECK)
338
- self.menumanagebanks = self.toolsmenu.Append(wx.ID_ANY, _("Manage banks..."), _("Manage banks"))
339
- self.menucreatenewbanks = self.toolsmenu.Append(wx.ID_ANY, _("Create banks from vertices..."),
453
+ self.menumanagebanks = self.cs_menu.Append(wx.ID_ANY, _("Manage banks..."), _("Manage banks"))
454
+ self.menucreatenewbanks = self.cs_menu.Append(wx.ID_ANY, _("Create banks from vertices..."),
340
455
  _("Manage banks"))
341
- self.renamecs = self.toolsmenu.Append(wx.ID_ANY, _("Rename cross sections..."), _("Rename"))
342
- self.menutrianglecs = self.toolsmenu.Append(wx.ID_ANY, _("Triangulate cross sections..."), _("Triangulate"))
343
- self.menuexportgltfonebyone = self.toolsmenu.Append(wx.ID_ANY, _("Export cross sections to gltf..."),
456
+ self.renamecs = self.cs_menu.Append(wx.ID_ANY, _("Rename cross sections..."), _("Rename"))
457
+ self.menutrianglecs = self.cs_menu.Append(wx.ID_ANY, _("Triangulate cross sections..."), _("Triangulate"))
458
+ self.menuexportgltfonebyone = self.cs_menu.Append(wx.ID_ANY, _("Export cross sections to gltf..."),
344
459
  _("Export gltf"))
345
- self.menupontgltfonebyone = self.toolsmenu.Append(wx.ID_ANY, _("Create bridge and export gltf..."),
460
+ self.menupontgltfonebyone = self.cs_menu.Append(wx.ID_ANY, _("Create bridge and export gltf..."),
346
461
  _("Bridge gltf"))
347
462
  # self.menuimport3dfaces_from_DXF = self.toolsmenu.Append(wx.ID_ANY, _("Import triangulation..."), _("DXF"))
348
- self.menuinteractptri = self.toolsmenu.Append(wx.ID_ANY, _("Interpolate on active triangulation..."), _("InterpolateTri"))
349
- self.menucomparecloud = self.toolsmenu.Append(wx.ID_ANY, _("Compare cloud to array..."), _("Comparison"))
350
- self.menucomparetri = self.toolsmenu.Append(wx.ID_ANY, _("Compare triangles to array..."), _("Comparison"))
463
+ self.menuinteractptri = self.cs_menu.Append(wx.ID_ANY, _("Interpolate on active triangulation..."), _("InterpolateTri"))
464
+ self.menucomparecloud = self.cs_menu.Append(wx.ID_ANY, _("Compare cloud to array..."), _("Comparison"))
465
+ self.menucomparetri = self.cs_menu.Append(wx.ID_ANY, _("Compare triangles to array..."), _("Comparison"))
351
466
 
352
467
  #Profile plots
353
468
  #The action for plotting cross section's profile is initialised.
354
- self.plot_cs = self.toolsmenu.Append(ID_PLOTCS, _("Plot cross section"),_("Plot cross section"),kind=wx.ITEM_CHECK)
469
+ self.plot_cs = self.cs_menu.Append(ID_PLOTCS, _("Plot cross section"),_("Plot cross section"),kind=wx.ITEM_CHECK)
355
470
 
356
471
  self.menuviewerinterpcs = None
357
472
  self.menuinterpcs = None
@@ -455,7 +570,8 @@ class WolfMapViewer(wx.Frame):
455
570
  # ajout du menu pour les données LAZ
456
571
  self.menu_laz()
457
572
 
458
- self.menubar.Append(self.toolsmenu, _('&Cross sections'))
573
+ self.menubar.Append(self.tools_menu, _('&Tools'))
574
+ self.menubar.Append(self.cs_menu, _('&Cross sections'))
459
575
 
460
576
  self.menubar.Append(self.minmaxmenu, _('&Colormap'))
461
577
  self.menubar.Append(self.analyzemenu, _('&Analyze'))
@@ -465,6 +581,8 @@ class WolfMapViewer(wx.Frame):
465
581
 
466
582
  # Ajout du conteneur OpenGL
467
583
  self.canvas = GLCanvas(self)
584
+ self.canvas.SetDropTarget(self._dragdrop)
585
+
468
586
  self.context = GLContext(self.canvas)
469
587
  self.mybackisloaded = False
470
588
  self.myfrontisloaded = False
@@ -1615,10 +1733,10 @@ class WolfMapViewer(wx.Frame):
1615
1733
  self.add_object('vector', newobj=self.myinterp.myzones, ToCheck=False, id='Interp_mesh')
1616
1734
 
1617
1735
  if self.menuviewerinterpcs is None:
1618
- self.menuviewerinterpcs = self.toolsmenu.Append(wx.ID_ANY, _("New cloud Viewer..."),
1736
+ self.menuviewerinterpcs = self.cs_menu.Append(wx.ID_ANY, _("New cloud Viewer..."),
1619
1737
  _("Cloud viewer Interpolate"))
1620
1738
  if self.menuinterpcs is None:
1621
- self.menuinterpcs = self.toolsmenu.Append(wx.ID_ANY, _("Interpolate on active array..."), _("Interpolate"))
1739
+ self.menuinterpcs = self.cs_menu.Append(wx.ID_ANY, _("Interpolate on active array..."), _("Interpolate"))
1622
1740
 
1623
1741
  def interpolate_cloud(self):
1624
1742
  """
@@ -3023,6 +3141,113 @@ class WolfMapViewer(wx.Frame):
3023
3141
  if cur is not self:
3024
3142
  cur.update()
3025
3143
 
3144
+ def zoom_on_id(self, id:str, draw_type:draw_type = draw_type.ARRAYS, forceupdate=True, canvas_height=1024):
3145
+ """
3146
+ Zoom on id
3147
+
3148
+ :param id: id of the object to zoom on
3149
+ :param drawtype: type of object to zoom on - Different types elements can have the same id
3150
+
3151
+ """
3152
+
3153
+ if draw_type not in [draw_type.ARRAYS, draw_type.VECTORS]:
3154
+ logging.warning(_('Draw type must be either ARRAYS or VECTORS'))
3155
+ return
3156
+
3157
+ obj = self.get_obj_from_id(id, draw_type)
3158
+
3159
+ if obj is None:
3160
+ logging.warning(_('No object found with id {} and drawtype {}'.format(id, draw_type)))
3161
+ return
3162
+
3163
+ if draw_type == draw_type.ARRAYS:
3164
+ self.zoom_on_array(obj, forceupdate=forceupdate, canvas_height=canvas_height)
3165
+ elif draw_type == draw_type.VECTORS:
3166
+ self.zoom_on_vector(obj, forceupdate=forceupdate, canvas_height=canvas_height)
3167
+
3168
+ def zoom_on_array(self, array:WolfArray, forceupdate=True, canvas_height=1024):
3169
+ """ Zoom on array """
3170
+
3171
+ if array.xmin == -99999:
3172
+ array.find_minmax()
3173
+
3174
+ bounds = array.get_bounds()
3175
+
3176
+ center = [(bounds[0][1] + bounds[0][0]) / 2., (bounds[1][1] + bounds[1][0]) / 2.]
3177
+ width = bounds[0][1] - bounds[0][0]
3178
+ height = bounds[1][1] - bounds[1][0]
3179
+
3180
+ self.zoom_on({'center':center, 'width':width, 'height':height}, forceupdate=forceupdate, canvas_height=canvas_height)
3181
+
3182
+ def zoom_on_vector(self, vector:vector, forceupdate=True, canvas_height=1024):
3183
+ """ Zoom on vector """
3184
+
3185
+ if vector.xmin == -99999:
3186
+ vector.find_minmax()
3187
+
3188
+ bounds = vector.get_bounds_xx_yy()
3189
+
3190
+ center = [(bounds[0][1] + bounds[0][0]) / 2., (bounds[1][1] + bounds[1][0]) / 2.]
3191
+ width = bounds[0][1] - bounds[0][0]
3192
+ height = bounds[1][1] - bounds[1][0]
3193
+
3194
+ self.zoom_on({'center':center, 'width':width, 'height':height}, forceupdate=forceupdate, canvas_height=canvas_height)
3195
+
3196
+ def create_Zones_from_arrays(self, arrays:list[WolfArray], id:str = None, add_legend:bool=True) -> Zones:
3197
+ """
3198
+ Create a Zones instance from list of WolfArrays
3199
+
3200
+ One zone per array.
3201
+
3202
+ One vector per zone with the masked contour.
3203
+
3204
+ :param arrays: list of WolfArrays
3205
+ :param id: id of the Zones instance
3206
+ :param add_legend: add legend to the vector -- centroid of the contour
3207
+
3208
+ """
3209
+
3210
+ # création de l'instance de Zones
3211
+ new_zones = Zones(idx = 'contour' if id is None else id.lower(), mapviewer=self)
3212
+
3213
+ for curarray in arrays:
3214
+
3215
+ if isinstance(curarray, WolfArray):
3216
+
3217
+ curarray.nullify_border(1)
3218
+
3219
+ new_zone = zone(name = curarray.idx)
3220
+ new_zones.add_zone(new_zone, forceparent=True)
3221
+
3222
+ sux, sux, curvect, interior = curarray.suxsuy_contour()
3223
+ new_zone.add_vector(curvect, forceparent=True)
3224
+
3225
+ curvect.set_legend_to_centroid(curarray.idx)
3226
+ curvect.myprop.width = 2
3227
+
3228
+ rectvect = vector(name = 'rect_boundary')
3229
+ new_zone.add_vector(rectvect, forceparent=True)
3230
+
3231
+ bounds = curarray.get_bounds()
3232
+
3233
+ rectvect.add_vertex(wolfvertex(bounds[0][0], bounds[1][0]))
3234
+ rectvect.add_vertex(wolfvertex(bounds[0][1], bounds[1][0]))
3235
+ rectvect.add_vertex(wolfvertex(bounds[0][1], bounds[1][1]))
3236
+ rectvect.add_vertex(wolfvertex(bounds[0][0], bounds[1][1]))
3237
+ rectvect.close_force()
3238
+
3239
+ rectvect.myprop.color = getIfromRGB([255,0,0])
3240
+ rectvect.myprop.width = 2
3241
+
3242
+ logging.info(_('{} treated'.format(curarray.idx)))
3243
+ else:
3244
+ logging.warning(_('All elements in the list must be of type WolfArray'))
3245
+
3246
+ new_zones.find_minmax(update=True)
3247
+
3248
+ return new_zones
3249
+
3250
+
3026
3251
  def zoom_on(self, zoom_dict = None, width = 500, height = 500, center = None, xll = None, yll = None, forceupdate=True, canvas_height=1024):
3027
3252
  """
3028
3253
  Zoom on a specific area
@@ -3102,7 +3327,7 @@ class WolfMapViewer(wx.Frame):
3102
3327
  if cur is not self:
3103
3328
  cur.update()
3104
3329
 
3105
- def zoomon_active_profile(self, size:float=500., forceupdate:bool=True):
3330
+ def zoom_on_active_profile(self, size:float=500., forceupdate:bool=True):
3106
3331
  """ Zoom on active profile """
3107
3332
 
3108
3333
  curvec = self.active_profile
@@ -4280,6 +4505,12 @@ class WolfMapViewer(wx.Frame):
4280
4505
  elif itemlabel==_("Compare triangles to array..."):
4281
4506
  self.compare_tri2array()
4282
4507
 
4508
+ elif itemlabel == _("Create contour from checked arrays..."):
4509
+
4510
+ # Create contour from checked arrays and add it to the list of objects
4511
+ newzones = self.create_Zones_from_arrays(self.get_list_objects(draw_type.ARRAYS, checked_state=True))
4512
+ self.add_object('vector', newobj=newzones, ToCheck=True, id='Contours from arrays')
4513
+
4283
4514
  elif itemlabel == _("Create bridge and export gltf..."):
4284
4515
 
4285
4516
  if self.active_cs is None:
@@ -5873,6 +6104,7 @@ class WolfMapViewer(wx.Frame):
5873
6104
 
5874
6105
  def get_obj_from_treeitem(self, treeitem):
5875
6106
  """ Find the object associated with treeitem """
6107
+
5876
6108
  return self.treelist.GetItemData(treeitem)
5877
6109
 
5878
6110
  def getobj_from_id(self, id: str):
@@ -5887,6 +6119,24 @@ class WolfMapViewer(wx.Frame):
5887
6119
  except:
5888
6120
  return None
5889
6121
 
6122
+ def get_obj_from_id(self, id: str, drawtype: draw_type):
6123
+ """ Find the object associated with id in a specifid drawtype
6124
+
6125
+ If you want to search in all drawtypes, use getobj_from_id instead.
6126
+
6127
+ :param id: str : id of the object
6128
+ :param drawtype: draw_type : type of object to search
6129
+
6130
+ """
6131
+
6132
+ keys = self.get_list_keys(draw_type, checked_state=None)
6133
+ if id.lower() in keys:
6134
+ try:
6135
+ idx = keys.index(id.lower())
6136
+ return self.get_list_objects(draw_type, checked_state=None)[idx]
6137
+ except:
6138
+ return None
6139
+
5890
6140
  def _get_list(self, drawing_type:draw_type):
5891
6141
  """ return the list of objects of type drawing_type """
5892
6142
 
@@ -6610,7 +6860,7 @@ class WolfMapViewer(wx.Frame):
6610
6860
 
6611
6861
  #on met le profil en rouge et plus épais
6612
6862
  self.active_profile.color_active_profile()
6613
- self.zoomon_active_profile()
6863
+ self.zoom_on_active_profile()
6614
6864
 
6615
6865
  self.Paint()
6616
6866
 
@@ -8564,6 +8814,8 @@ class WolfMapViewer(wx.Frame):
8564
8814
  return [cur.idx for cur in self.mywmsfore]
8565
8815
 
8566
8816
  def check_id(self, id=str, gridsize = 100.):
8817
+ """ Check an element from its id """
8818
+
8567
8819
  curobj = self.getobj_from_id(id)
8568
8820
 
8569
8821
  if curobj is None:
@@ -8579,6 +8831,8 @@ class WolfMapViewer(wx.Frame):
8579
8831
  curobj.creategrid(gridsize, self.xmin, self.ymin, self.xmax, self.ymax)
8580
8832
 
8581
8833
  def uncheck_id(self, id=str, unload=True, forceresetOGL=True, askquestion=False):
8834
+ """ Uncheck an element from its id """
8835
+
8582
8836
  curobj = self.getobj_from_id(id)
8583
8837
 
8584
8838
  if curobj is None:
@@ -8594,6 +8848,12 @@ class WolfMapViewer(wx.Frame):
8594
8848
  self.treelist.CheckItem(curitem, False)
8595
8849
 
8596
8850
  def get_current_zoom(self):
8851
+ """
8852
+ Get the current zoom
8853
+
8854
+ :return: dict with keys 'center', 'xmin', 'xmax', 'ymin', 'ymax', 'width', 'height'
8855
+
8856
+ """
8597
8857
 
8598
8858
  return {'center': (self.mousex, self.mousey),
8599
8859
  'xmin' : self.xmin,
@@ -8604,12 +8864,15 @@ class WolfMapViewer(wx.Frame):
8604
8864
  'height' : self.ymax-self.ymin}
8605
8865
 
8606
8866
  def save_current_zoom(self, filepath):
8867
+ """ Save the current zoom in a json file """
8607
8868
 
8608
8869
  zoom = self.get_current_zoom()
8609
8870
  with open(filepath, 'w') as fp:
8610
8871
  json.dump(zoom, fp)
8611
8872
 
8612
8873
  def read_current_zoom(self, filepath):
8874
+ """ Read the current zoom from a json file """
8875
+
8613
8876
  if exists(filepath):
8614
8877
  with open(filepath, 'r') as fp:
8615
8878
  zoom = json.load(fp)
wolfhece/PyVertex.py CHANGED
@@ -27,14 +27,18 @@ from .textpillow import Text_Image, Text_Infos, Font_Priority
27
27
  from .wolf_texture import Text_Image_Texture
28
28
 
29
29
 
30
- def getRGBfromI(rgbint):
30
+ def getRGBfromI(rgbint:int):
31
+ """ Convert integer to RGB """
32
+
31
33
  blue = rgbint & 255
32
34
  green = (rgbint >> 8) & 255
33
35
  red = (rgbint >> 16) & 255
34
36
  return red, green, blue
35
37
 
36
38
 
37
- def getIfromRGB(rgb):
39
+ def getIfromRGB(rgb:Union[list, tuple]):
40
+ """ Convert RGB to integer """
41
+
38
42
  red = int(rgb[0])
39
43
  green = int(rgb[1])
40
44
  blue = int(rgb[2])
@@ -887,6 +887,7 @@ if :\n \
887
887
  return 'SanSerif'
888
888
  else:
889
889
  return 'Arial'
890
+
890
891
  class vector:
891
892
  """
892
893
  Objet de gestion d'informations vectorielles
@@ -1050,6 +1051,9 @@ class vector:
1050
1051
  """
1051
1052
  Return tuple with :
1052
1053
  - (lower-left corner), (upper-right corner)
1054
+
1055
+ If you want [[xmin,xmax],[ymin,ymax]], use get_bounds_xx_yy() instead.
1056
+
1053
1057
  """
1054
1058
  if grid is None:
1055
1059
  return ((self.xmin, self.ymin), (self.xmax, self.ymax))
@@ -1065,6 +1069,9 @@ class vector:
1065
1069
  """
1066
1070
  Return tuple with :
1067
1071
  - (xmin,xmax), (ymin, ymax)
1072
+
1073
+ If you want [[lower-left corner],[upper-right corner]], use get_bounds() instead.
1074
+
1068
1075
  """
1069
1076
  if grid is None:
1070
1077
  return ((self.xmin, self.xmax), (self.ymin, self.ymax))
@@ -1098,6 +1105,7 @@ class vector:
1098
1105
  """
1099
1106
  Mise en évidence
1100
1107
  """
1108
+
1101
1109
  self._oldcolor = self.myprop.color
1102
1110
  self._oldwidth = self.myprop.color
1103
1111
 
@@ -1108,6 +1116,7 @@ class vector:
1108
1116
  """
1109
1117
  Mise en retrait
1110
1118
  """
1119
+
1111
1120
  try:
1112
1121
  self.myprop.color = self._oldcolor
1113
1122
  self.myprop.width = self._oldwidth
@@ -2384,8 +2393,13 @@ class zone:
2384
2393
  def add_vector(self, addedvect:vector, index=-99999, forceparent=False):
2385
2394
  """
2386
2395
  Ajout d'une instance 'vector'
2387
- Le compteur est incrémenté
2396
+
2397
+ :param addedvect: instance 'vector' à ajouter
2398
+ :param index: position d'insertion
2399
+ :param forceparent: True = forcer le parent à être la zone dans lequel le vecteur est ajouté
2400
+
2388
2401
  """
2402
+
2389
2403
  if index==-99999 or index >self.nbvectors:
2390
2404
  self.myvectors.append(addedvect)
2391
2405
  else:
@@ -2489,8 +2503,13 @@ class zone:
2489
2503
  if self.idgllist!=-99999:
2490
2504
  glCallList(self.idgllist)
2491
2505
  else:
2506
+ self.has_legend = False
2507
+ self.has_image = False
2508
+
2492
2509
  for curvect in self.myvectors:
2493
2510
  curvect.plot()
2511
+ self.has_legend |= curvect.myprop.legendvisible
2512
+ self.has_image |= curvect.myprop.imagevisible
2494
2513
 
2495
2514
  if self.has_legend:
2496
2515
  for curvect in self.myvectors:
@@ -4421,6 +4440,7 @@ class Zones(wx.Frame, Element_To_Draw):
4421
4440
  boxright.Add(self.capturevertices,0,wx.EXPAND)
4422
4441
  boxright.Add(self.dynapar,0,wx.EXPAND)
4423
4442
  boxright.Add(self.createapar,0,wx.EXPAND)
4443
+ boxright.Add(self.reverseorder,0,wx.EXPAND)
4424
4444
  boxright.Add(self.modifyvertices,0,wx.EXPAND)
4425
4445
  boxright.Add(self.insertvertices,0,wx.EXPAND)
4426
4446
  boxright.Add(self.splitvertices,0,wx.EXPAND)
@@ -4722,8 +4742,56 @@ class Zones(wx.Frame, Element_To_Draw):
4722
4742
  """
4723
4743
  Remplissage de la structure wx
4724
4744
  """
4745
+
4746
+ def store_tree_state(tree:TreeListCtrl):
4747
+
4748
+ expended_items = []
4749
+ root = tree.GetRootItem()
4750
+
4751
+ if root is None:
4752
+ return
4753
+
4754
+ def traverse_and_store(item):
4755
+ if not item.IsOk():
4756
+ return
4757
+ if tree.IsExpanded(item):
4758
+ expended_items.append(tree.GetItemData(item))
4759
+
4760
+ child = tree.GetFirstChild(item)
4761
+ while child.IsOk():
4762
+ traverse_and_store(child)
4763
+ child = tree.GetNextItem(child)
4764
+
4765
+ traverse_and_store(root)
4766
+
4767
+ return expended_items
4768
+
4769
+ def restore_tree_state(tree:TreeListCtrl, expended_items):
4770
+
4771
+ root = tree.GetRootItem()
4772
+
4773
+ if root is None:
4774
+ return
4775
+
4776
+ def traverse_and_restore(item):
4777
+ if not item.IsOk():
4778
+ return
4779
+
4780
+ if tree.GetItemData(item) in expended_items:
4781
+ tree.Expand(item)
4782
+
4783
+ child = tree.GetFirstChild(item)
4784
+ while child.IsOk():
4785
+ traverse_and_restore(child)
4786
+ child = tree.GetNextItem(child)
4787
+
4788
+ traverse_and_restore(root)
4789
+
4725
4790
  if self.wx_exists:
4726
4791
  if self.xls is not None:
4792
+
4793
+ expanded = store_tree_state(self.treelist)
4794
+
4727
4795
  self.treelist.DeleteAllItems()
4728
4796
 
4729
4797
  root = self.treelist.GetRootItem()
@@ -4735,6 +4803,8 @@ class Zones(wx.Frame, Element_To_Draw):
4735
4803
 
4736
4804
  self.treelist.Expand(mynode)
4737
4805
 
4806
+ restore_tree_state(self.treelist, expanded)
4807
+
4738
4808
  def expand_tree(self, objzone=None):
4739
4809
  """
4740
4810
  Développe la structure pour un objet spécifique stocké dans la self.treelist
@@ -5617,17 +5687,54 @@ class Zones(wx.Frame, Element_To_Draw):
5617
5687
  else:
5618
5688
  myitemdata.unuse()
5619
5689
 
5690
+ def _callback_destroy_props(self):
5691
+
5692
+ self.myprops = None
5693
+
5694
+ def _callback_prop(self):
5695
+
5696
+ if self._myprops is None:
5697
+ logging.warning(_('No properties available'))
5698
+ return
5699
+
5700
+ for curzone in self.myzones:
5701
+ for curvec in curzone.myvectors:
5702
+ curvec.myprop.fill_property(self._myprops, updateOGL = False)
5703
+
5704
+ if self.mapviewer is not None:
5705
+ self.prep_listogl()
5706
+ self.mapviewer.Refresh()
5707
+
5708
+
5709
+ def _edit_all_properties(self):
5710
+ """ Show properties of the zone --> will be applied to all vectors int he zone """
5711
+
5712
+ locvec = vector()
5713
+ locvec.myprop.show()
5714
+
5715
+ self._myprops = locvec.myprop.myprops
5716
+
5717
+ self._myprops[('Legend','X')] = 99999.
5718
+ self._myprops[('Legend','Y')] = 99999.
5719
+ self._myprops[('Legend','Text')] = _('Not used')
5720
+ self._myprops.Populate()
5721
+ self._myprops.set_callbacks(self._callback_prop, self._callback_destroy_props)
5722
+
5723
+
5620
5724
  def OnRDown(self, event:TreeListEvent):
5621
5725
  """
5622
5726
  Affiche les propriétés du vecteur courant
5623
5727
  Clicl-droit
5624
5728
  """
5625
5729
  if self.wx_exists:
5626
- if self.verify_activevec() and self.verify_activezone():
5627
- return
5730
+ if self.active_zone is None and self.active_zone is None:
5628
5731
 
5629
- if isinstance(self.last_active, vector):
5732
+ logging.info(_('You will edit the properties of the entire instance (all zones and all vectors)'))
5733
+ self._edit_all_properties()
5734
+
5735
+ elif isinstance(self.last_active, vector):
5630
5736
  self.active_vector.myprop.show()
5737
+
5631
5738
  elif isinstance(self.last_active, zone):
5632
5739
  self.active_zone.show_properties()
5633
5740
 
@@ -5643,6 +5750,9 @@ class Zones(wx.Frame, Element_To_Draw):
5643
5750
  self.Activate_vector(myitemdata)
5644
5751
  elif isinstance(myitemdata,zone):
5645
5752
  self.Activate_zone(myitemdata)
5753
+ else:
5754
+ self.Activate_vector(None)
5755
+ self.Activate_zone(None)
5646
5756
 
5647
5757
  self.last_active = myitemdata
5648
5758
 
@@ -5654,6 +5764,12 @@ class Zones(wx.Frame, Element_To_Draw):
5654
5764
  """
5655
5765
  if self.wx_exists:
5656
5766
  self.active_vector = object
5767
+
5768
+ if self.active_vector is None:
5769
+ logging.info(_('Active vector is now set to None'))
5770
+ self.xls.ClearGrid()
5771
+ return
5772
+
5657
5773
  self.xls_active_vector()
5658
5774
 
5659
5775
  if object.parentzone is not None:
@@ -5679,6 +5795,12 @@ class Zones(wx.Frame, Element_To_Draw):
5679
5795
  """
5680
5796
  if self.wx_exists:
5681
5797
  self.active_zone = object
5798
+
5799
+ if self.active_zone is None:
5800
+ logging.info(_('Active zone is now set to None'))
5801
+ self.xls.ClearGrid()
5802
+ return
5803
+
5682
5804
  if object.active_vector is not None:
5683
5805
  self.active_vector = object.active_vector
5684
5806
  elif object.nbvectors>0:
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 0
8
+ self.patch = 2
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -11449,10 +11449,11 @@ class prev_sim2D():
11449
11449
  Alias de myparam.add_weak_bc_y
11450
11450
  """
11451
11451
 
11452
+ lst = self.list_pot_bc_y()
11453
+
11452
11454
  if len(lst) == 0:
11453
11455
  logging.warning('No potential BC found -- Test can not be performed -- I continue anyway')
11454
11456
  else:
11455
- lst = self.list_pot_bc_y()
11456
11457
  if i not in lst[0] or j not in lst[1]:
11457
11458
  logging.error(f'Invalid indices ({i},{j}) - BC not added')
11458
11459
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.1.0
3
+ Version: 2.1.2
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  License: AGPL-v3 License
6
6
  Project-URL: Homepage, https://uee.uliege.be/hece
@@ -1,12 +1,12 @@
1
1
  wolfhece/CpGrid.py,sha256=ke4n1khTUoed2asJl1GR25PsEkI4TpiBDCo4u0aSo9M,10658
2
2
  wolfhece/GraphNotebook.py,sha256=oBn0LBBFDX5b9KO8VnyqA0nYzv4MmTnQNhmgMBPsG2w,27723
3
- wolfhece/GraphProfile.py,sha256=GU4dsjbY7WWvcwIaHY8mqafdfAKnTfqUlsBwmtD4_as,69436
3
+ wolfhece/GraphProfile.py,sha256=YKwZ7xcZ-jcKUZdnkCA1IaKYsF2tDMsWLYAbg6JTgR4,69437
4
4
  wolfhece/Lidar2002.py,sha256=sXZ6p8_EKI5l8fJswIMAABT6dqHKVexU52Tjl1uuisU,5770
5
5
  wolfhece/ManageParams.py,sha256=Wgt5Zh7QBtyiwTAltPHunSLqt4XuVuRH76GTUrXabS4,219
6
6
  wolfhece/Model1D.py,sha256=-cMz-ePSYzrKVVDidiDOz6cojEZ3y6u9gIb7RPwT6Y8,476593
7
7
  wolfhece/PyConfig.py,sha256=oGSL1WsLM9uinlNP4zGBLK3uHPmBfduUi7R-VtWuRFA,8034
8
8
  wolfhece/PyCrosssections.py,sha256=f4dNYRUGZKePruaaBiTcn5vlrw8TFTj9XwTDrdiF_uU,112450
9
- wolfhece/PyDraw.py,sha256=SkPF3w7X-r0n8EHBNhB6HtCr76kMGf5ZZcpbs0BrTmA,367549
9
+ wolfhece/PyDraw.py,sha256=IOw6MBqsBCgsgmlomqRpPPscb27lapkCx6_tfvnZFh0,376860
10
10
  wolfhece/PyGui.py,sha256=TTRvqRiZ0gTaxOfDTMVLFYQ56QvdDMS032fRXcXxvUs,104024
11
11
  wolfhece/PyGuiHydrology.py,sha256=wKhR-KthPRyzJ887NmsozmUpm2CIQIwO3IbYORCYjrE,7290
12
12
  wolfhece/PyHydrographs.py,sha256=GKK8U0byI45H9O_e4LAOOi7Aw0Tg7Q0Lx322stPg5IQ,3453
@@ -14,8 +14,8 @@ wolfhece/PyPalette.py,sha256=_Nm2Lc4UxYlZgK8ifZDioG8a0at8oiteYC0x_4XugFc,24384
14
14
  wolfhece/PyParams.py,sha256=361iy9b9zTjoPCj9gh8-OIo0TBW5laLG87AkWE6f_eg,96290
15
15
  wolfhece/PyPictures.py,sha256=-mJB0JL2YYiEK3D7_ssDkvYiMWK4ve9kXhozQXNeSx8,2216
16
16
  wolfhece/PyTranslate.py,sha256=4appkmNeHHZLFmUtaA_k5_5QL-5ymxnbVN4R2OblmtE,622
17
- wolfhece/PyVertex.py,sha256=X8MjsM4wLkgCrZ94CQw6PzxigH0_0jr8enUy7uYO2_I,39993
18
- wolfhece/PyVertexvectors.py,sha256=DccCNN-6_gC_ocykV2DKcWEzKdG_ZXXOIIDp9BYfi7o,218663
17
+ wolfhece/PyVertex.py,sha256=dHTjyYYTn0F_NWerlAOBKHV79RUzEEtMJMldQtVc1Cs,40092
18
+ wolfhece/PyVertexvectors.py,sha256=Av1OqFrDtZUAXAjaTnoGGErzK4W9gJhVx0LxgULLcTA,222335
19
19
  wolfhece/PyWMS.py,sha256=t6jVZpTxTNSLJxABk8A79cEMWTKoRM_S_SXRipsHLzw,4493
20
20
  wolfhece/RatingCurve.py,sha256=YSQvSvdMHE6hSlWVBF5Oe0-Fh3waNMpOdmcymaCCTis,21706
21
21
  wolfhece/RatingCurveData.py,sha256=5UvnIm89BwqjnEbLCcY3CA8WoFd_xHJbooNy62fX5iY,57660
@@ -66,7 +66,7 @@ wolfhece/apps/check_install.py,sha256=jrKR-njqnpIh6ZJqvP6KbDUPVCfwTNQj4glQhcyzs9
66
66
  wolfhece/apps/curvedigitizer.py,sha256=avWERHuVxPnJBOD_ibczwW_XG4vAenqWS8W1zjhBox8,4898
67
67
  wolfhece/apps/isocurrent.py,sha256=4XnNWPa8mYUK7V4zdDRFrHFIXNG2AN2og3TqWKKcqjY,3811
68
68
  wolfhece/apps/splashscreen.py,sha256=m9hMTqzhSUcTudApyNNjoAK9e2u5vgEkJVV79xmfM1s,2118
69
- wolfhece/apps/version.py,sha256=0MeamvB2goEEVvP6-zQV9wXDJs5IkNiRkC7xNVWzBtQ,387
69
+ wolfhece/apps/version.py,sha256=8FWwKWXkTZJMeOYjVCu-NBqI7zTtYTAJV6YcWW87LJE,387
70
70
  wolfhece/apps/wolf.py,sha256=gqfm-ZaUJqNsfCzmdtemSeqLw-GVdSVix-evg5WArJI,293
71
71
  wolfhece/apps/wolf2D.py,sha256=gWD9ee2-1pw_nUxjgRaJMuSe4kUT-RWhOeoTt_Lh1mM,267
72
72
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -217,7 +217,7 @@ wolfhece/mesh2d/bc_manager.py,sha256=OzN4NPlDniv9HsLTUQrJkBY6U_a3SkqNpvjIw0TcguI
217
217
  wolfhece/mesh2d/cell_tracker.py,sha256=AR-Bty-QnrY1ni8Lwak2kU2UWMAJSBCF2ugl2YpfsB4,8660
218
218
  wolfhece/mesh2d/config_manager.py,sha256=qQE5sPbHj9cNZe3uGk1pkuogsS28kJZNx3xybZ6CfCM,14438
219
219
  wolfhece/mesh2d/cst_2D_boundary_conditions.py,sha256=cZrHvtfqqTWtUcWnUe9iy9ZY6lAWAJnDoVupV6H7Zw4,4710
220
- wolfhece/mesh2d/wolf2dprev.py,sha256=Cz0hX7FMc0adY_L29l-pfa-kv5wO-9BPEVPL20rDyrY,491039
220
+ wolfhece/mesh2d/wolf2dprev.py,sha256=55kgOxPucmaFaOYdGVLkBP3ubbQbSe6AO34HTA8Rm-Y,491037
221
221
  wolfhece/models/HECE_169.pptx,sha256=OWJtsWz504A-REFaaxw8lwStHyQU2l7KEeiE7IZvtbk,3396930
222
222
  wolfhece/models/blue.pal,sha256=NnjJnjnYVdQkG54RyPXvo4Tl9ytB0cN7zpiHtj1N6bw,33
223
223
  wolfhece/models/diff16.pal,sha256=Pkp9kQ1GvmAKz3lgwohsw8eQySjVVKHbjhoWw-gZ6Nc,303
@@ -264,8 +264,8 @@ wolfhece/sounds/sonsw2.wav,sha256=pFLVt6By0_EPQNt_3KfEZ9a1uSuYTgQSX1I_Zurv9Rc,11
264
264
  wolfhece/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
265
265
  wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=yGbU_JsF56jsmms0gh7mxa7tbNQ_SxqhpAZxhm-mTy4,14860
266
266
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=wCxGRnE3kzEkWlWA6-3X8ADOFux_B0a5QWJ2GnXTgJw,4709
267
- wolfhece-2.1.0.dist-info/METADATA,sha256=38MZXcyMY5-cpEkQmA8qHKviR0lxMmwlcZBssNyCyOo,2281
268
- wolfhece-2.1.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
269
- wolfhece-2.1.0.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
270
- wolfhece-2.1.0.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
271
- wolfhece-2.1.0.dist-info/RECORD,,
267
+ wolfhece-2.1.2.dist-info/METADATA,sha256=rIXLM3y8Jweh0AI8rdzYq-iDSgIdL7Y53wNqzzRfm-Q,2281
268
+ wolfhece-2.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
269
+ wolfhece-2.1.2.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
270
+ wolfhece-2.1.2.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
271
+ wolfhece-2.1.2.dist-info/RECORD,,