wolfhece 2.1.109__py3-none-any.whl → 2.1.111__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/PyDraw.py CHANGED
@@ -116,6 +116,12 @@ except ImportError as e:
116
116
  print(e)
117
117
  raise ImportError("Error importing pyshields, pyviews, PyConfig, GraphProfile, pybridges, tools_mpl, wolf_tiles, lagrangian.particle_system_ui, opengl.py3d, pyGui1D. Please check your installation.")
118
118
 
119
+ try:
120
+ from .apps.curvedigitizer import Digitizer
121
+ except ImportError as e:
122
+ print(e)
123
+ raise ImportError("Error importing apps.curvedigitizer. Please check your installation.")
124
+
119
125
  ID_SELECTCS = 1000
120
126
  ID_SORTALONG = 1001
121
127
  ID_LOCMINMAX = 1002
@@ -1363,6 +1369,7 @@ class WolfMapViewer(wx.Frame):
1363
1369
  self.menu_contour_from_arrays = self.tools_menu.Append(wx.ID_ANY, _("Create contour from checked arrays..."), _("Create contour"))
1364
1370
  self.menu_calculator = self.tools_menu.Append(wx.ID_ANY, _("Calculator..."), _("Calculator"))
1365
1371
  self.menu_views = self.tools_menu.Append(wx.ID_ANY, _("Memory views..."), _("Memory views"))
1372
+ self.menu_digitizer = self.tools_menu.Append(wx.ID_ANY, _("Image digitizer..."), _("Image Digitizer"))
1366
1373
  self.calculator = None
1367
1374
  self.memory_views = None
1368
1375
  self._memory_views_gui = None
@@ -1708,6 +1715,8 @@ class WolfMapViewer(wx.Frame):
1708
1715
 
1709
1716
  self._menuinteractptri = self.trianglesmenu.Append(wx.ID_ANY, _("Interpolate on active triangulation..."), _("InterpolateTri"))
1710
1717
  self._menucomparetri = self.trianglesmenu.Append(wx.ID_ANY, _("Compare triangles to array..."), _("Comparison"))
1718
+ self._menumovetri = self.trianglesmenu.Append(wx.ID_ANY, _("Move triangles..."), _("Move triangles"))
1719
+ self._menurotatetri = self.trianglesmenu.Append(wx.ID_ANY, _("Rotate triangles..."), _("Rotate triangles"))
1711
1720
 
1712
1721
 
1713
1722
  def create_cloud_menu(self):
@@ -3143,6 +3152,20 @@ class WolfMapViewer(wx.Frame):
3143
3152
 
3144
3153
  self.active_array.compare_tri(self.active_tri)
3145
3154
 
3155
+ def move_triangles(self):
3156
+ """ Move the active triangles """
3157
+ if self.active_tri is None:
3158
+ logging.warning(_('No active triangles -- Please activate triangles first'))
3159
+ return
3160
+ self.start_action('move triangles', 'Move the current triangulation -- Please select 2 points to define the translation vector')
3161
+
3162
+ def rotate_triangles(self):
3163
+ """ Rotate the active triangles """
3164
+ if self.active_tri is None:
3165
+ logging.warning(_('No active triangles -- Please activate triangles first'))
3166
+ return
3167
+ self.start_action('rotate triangles', 'Rotate the current triangulation -- Please select 1 point for the center')
3168
+
3146
3169
  def copy_canvasogl(self, mpl:bool= True, ds:float= 0., figsizes= [10.,10.], palette:wolfpalette = None):
3147
3170
  """
3148
3171
  Generate image based on UI context and copy to the Clipboard
@@ -6270,6 +6293,14 @@ class WolfMapViewer(wx.Frame):
6270
6293
  autoscale = False
6271
6294
  self.compare_tri2array()
6272
6295
 
6296
+ elif itemlabel == _("Move triangles..."):
6297
+ autoscale = False
6298
+ self.move_triangles()
6299
+
6300
+ elif itemlabel == _("Rotate triangles..."):
6301
+ autoscale = False
6302
+ self.rotate_triangles()
6303
+
6273
6304
  elif itemlabel == _("Create contour from checked arrays..."):
6274
6305
  autoscale = False
6275
6306
 
@@ -6285,6 +6316,11 @@ class WolfMapViewer(wx.Frame):
6285
6316
  else:
6286
6317
  self.calculator.Show()
6287
6318
 
6319
+ elif itemlabel == _('Image digitizer...'):
6320
+ autoscale = False
6321
+
6322
+ new_digitizer = Digitizer()
6323
+
6288
6324
  elif itemlabel == _("Memory views..."):
6289
6325
  autoscale = False
6290
6326
 
@@ -7029,49 +7065,59 @@ class WolfMapViewer(wx.Frame):
7029
7065
 
7030
7066
  if loadfromfile :
7031
7067
  newpal.readfile()
7032
- else:
7033
- with wx.lib.busy.BusyInfo(_('Compute unique colormap from all arrays')):
7034
- wait = wx.BusyCursor()
7035
-
7036
- curarray:WolfArray
7037
- curres2d:Wolfresults_2D
7038
7068
 
7039
- for curarray in self.myarrays:
7040
- if curarray.plotted:
7041
- workingarray.append(curarray.get_working_array())
7042
- nbnotnull+=curarray.nbnotnull
7043
-
7044
- for curres2d in self.myres2D:
7045
- if curres2d.plotted:
7046
- workingarray.append(curres2d.get_working_array())
7047
- nbnotnull+=curres2d.nbnotnull
7048
-
7049
- workingarray = np.concatenate(workingarray)
7069
+ if not newpal.is_valid():
7070
+ logging.warning(_('Palette not valid !'))
7071
+ return
7072
+ else:
7073
+ nb = len(self.myarrays) + len(self.myres2D)
7074
+ pgbar = wx.ProgressDialog(_('Compute unique colormap'), _('Compute unique colormap from all arrays'), maximum=nb, parent=self, style=wx.PD_APP_MODAL|wx.PD_AUTO_HIDE)
7050
7075
 
7051
- newpal.default16()
7052
- newpal.isopop(workingarray, nbnotnull)
7053
- del wait
7076
+ curarray:WolfArray
7077
+ curres2d:Wolfresults_2D
7054
7078
 
7055
- with wx.lib.busy.BusyInfo(_('Apply unique colormap to all arrays')):
7056
- wait = wx.BusyCursor()
7057
7079
  for curarray in self.myarrays:
7058
7080
  if curarray.plotted:
7059
- curarray.mypal.automatic = False
7060
- curarray.myops.palauto.SetValue(0)
7061
- curarray.mypal.values = newpal.values.copy()
7062
- curarray.mypal.colors = newpal.colors.copy()
7063
- curarray.mypal.fill_segmentdata()
7064
- curarray.reset_plot()
7081
+ workingarray.append(curarray.get_working_array())
7082
+ nbnotnull+=curarray.nbnotnull
7083
+ pgbar.Update(pgbar.GetValue() + 1, _('Compute unique colormap from array : ') + curarray.idx)
7065
7084
 
7066
7085
  for curres2d in self.myres2D:
7067
7086
  if curres2d.plotted:
7068
- curres2d.mypal.automatic = False
7069
- curres2d.mypal.nb = newpal.nb
7070
- curres2d.mypal.values = newpal.values.copy()
7071
- curres2d.mypal.colors = newpal.colors.copy()
7072
- curres2d.mypal.fill_segmentdata()
7073
- curres2d.reset_plot()
7074
- del wait
7087
+ workingarray.append(curres2d.get_working_array())
7088
+ nbnotnull+=curres2d.nbnotnull
7089
+ pgbar.Update(pgbar.GetValue() + 1, _('Compute unique colormap from 2D result : ') + curres2d.idx)
7090
+
7091
+ pgbar.Destroy()
7092
+
7093
+ workingarray = np.concatenate(workingarray)
7094
+
7095
+ newpal.default16()
7096
+ newpal.isopop(workingarray, nbnotnull)
7097
+
7098
+ nb = len(self.myarrays) + len(self.myres2D)
7099
+ pgbar = wx.ProgressDialog(_('Applying colormap'), _('Applying colormap to all arrays'), maximum=nb, parent=self, style=wx.PD_APP_MODAL|wx.PD_AUTO_HIDE)
7100
+ for curarray in self.myarrays:
7101
+ if curarray.plotted:
7102
+ curarray.mypal.automatic = False
7103
+ curarray.myops.palauto.SetValue(0)
7104
+ curarray.mypal.values = newpal.values.copy()
7105
+ curarray.mypal.colors = newpal.colors.copy()
7106
+ curarray.mypal.fill_segmentdata()
7107
+ curarray.reset_plot()
7108
+ pgbar.Update(pgbar.GetValue() + 1, _('Applying colormap to array : ') + curarray.idx)
7109
+
7110
+ for curres2d in self.myres2D:
7111
+ if curres2d.plotted:
7112
+ curres2d.mypal.automatic = False
7113
+ curres2d.mypal.nb = newpal.nb
7114
+ curres2d.mypal.values = newpal.values.copy()
7115
+ curres2d.mypal.colors = newpal.colors.copy()
7116
+ curres2d.mypal.fill_segmentdata()
7117
+ curres2d.reset_plot()
7118
+ pgbar.Update(pgbar.GetValue() + 1, _('Applying colormap to 2D result : ') + curres2d.idx)
7119
+
7120
+ pgbar.Destroy()
7075
7121
 
7076
7122
  def loadnap_and_apply(self):
7077
7123
 
@@ -9042,6 +9088,54 @@ class WolfMapViewer(wx.Frame):
9042
9088
 
9043
9089
  self.rightdown = (x, y)
9044
9090
 
9091
+ elif self.action == 'move triangles':
9092
+
9093
+ if self.active_tri is None:
9094
+ logging.warning(_('No triangles selected -- Please select a triangulation first !'))
9095
+ return
9096
+
9097
+ if self.active_tri._start_move is None:
9098
+ self.active_tri._start_move = (x, y)
9099
+ return
9100
+
9101
+ delta_x = x - self.active_tri._start_move[0]
9102
+ delta_y = y - self.active_tri._start_move[1]
9103
+
9104
+ if shiftdown:
9105
+ delta_y = 0.
9106
+
9107
+ if alt:
9108
+ delta_x = 0.
9109
+
9110
+ self.active_tri.move(delta_x, delta_y)
9111
+ self.active_tri.reset_plot()
9112
+ self.active_tri._start_move = None
9113
+ self.active_tri.clear_cache()
9114
+ self.end_action(_('End move triangulation'))
9115
+
9116
+ elif self.action == 'rotate triangles':
9117
+
9118
+ if self.active_tri is None:
9119
+ logging.warning(_('No vector selected -- Please select a triangulation first !'))
9120
+ return
9121
+
9122
+ if self.active_tri._rotation_center is None:
9123
+ self.active_tri._rotation_center = (x,y)
9124
+ return
9125
+
9126
+ if shiftdown:
9127
+ if ctrl:
9128
+ self.active_tri._rotation_step = None
9129
+ else:
9130
+ # Set the rotation step
9131
+ self.active_tri._rotation_step = np.degrees(np.arctan2(y - self.active_tri._rotation_center[1], x - self.active_tri._rotation_center[0]))
9132
+
9133
+ self.active_tri.rotate_xy(x, y)
9134
+ self.active_tri._rotation_center = None
9135
+ self.active_tri.clear_cache()
9136
+ self.active_tri.reset_plot()
9137
+ self.end_action(_('End rotate triangulation'))
9138
+
9045
9139
  elif 'pick landmap' in self.action:
9046
9140
  # Pick a landmap if loaded
9047
9141
 
@@ -9691,7 +9785,7 @@ class WolfMapViewer(wx.Frame):
9691
9785
 
9692
9786
  i, j, curbloc = locarray.get_blockij_from_xy(x, y)
9693
9787
 
9694
- if i != '-':
9788
+ if i != '-' and i != -1:
9695
9789
  curpar = 'Indices (i;j;bloc) (1-based)'
9696
9790
 
9697
9791
  self.mytooltip.add_param(groupname = curgroup,
@@ -9813,8 +9907,10 @@ class WolfMapViewer(wx.Frame):
9813
9907
  if self.linked:
9814
9908
  for curFrame in self.linkedList:
9815
9909
  if not curFrame is self:
9910
+ title = curFrame.GetTitle() if curFrame.GetTitle() != 'Wolf - main data manager' else 'Main'
9911
+
9816
9912
  for locarray in curFrame.myarrays:
9817
- curgroup = locarray.idx
9913
+ curgroup = title + ' -' + locarray.idx
9818
9914
  if locarray.plotted:
9819
9915
 
9820
9916
  try:
@@ -9825,7 +9921,7 @@ class WolfMapViewer(wx.Frame):
9825
9921
  i, j, curbloc = locarray.get_blockij_from_xy(x, y)
9826
9922
  curpar = 'Indices (i;j;bloc) (1-based)'
9827
9923
 
9828
- self.mytooltip.add_param(groupname = locarray.idx,
9924
+ self.mytooltip.add_param(groupname = curgroup,
9829
9925
  name = curpar,
9830
9926
  value = '(' + str(i+1) + ';' + str(j+1) + ';' + str(curbloc) + ')',
9831
9927
  type = Type_Param.String,
@@ -9835,7 +9931,7 @@ class WolfMapViewer(wx.Frame):
9835
9931
  i, j = locarray.get_ij_from_xy(x, y)
9836
9932
  curpar = 'Indices (i;j) (1-based)'
9837
9933
 
9838
- self.mytooltip.add_param(groupname = locarray.idx,
9934
+ self.mytooltip.add_param(groupname = curgroup,
9839
9935
  name = curpar,
9840
9936
  value = '(' + str(i+1) + ';' + str(j+1) + ')',
9841
9937
  type = Type_Param.String,
@@ -9844,7 +9940,7 @@ class WolfMapViewer(wx.Frame):
9844
9940
  curpar = 'Value'
9845
9941
 
9846
9942
  if val is np.nan:
9847
- self.mytooltip.add_param(groupname = locarray.idx,
9943
+ self.mytooltip.add_param(groupname = curgroup,
9848
9944
  name = 'Value',
9849
9945
  value = "Nan",
9850
9946
  type = Type_Param.String,
@@ -9852,32 +9948,91 @@ class WolfMapViewer(wx.Frame):
9852
9948
 
9853
9949
  elif np.ma.is_masked(val):
9854
9950
 
9855
- self.mytooltip.add_param(groupname = locarray.idx,
9951
+ self.mytooltip.add_param(groupname = curgroup,
9856
9952
  name = 'Value',
9857
9953
  value = "Masked",
9858
9954
  type = Type_Param.String,
9859
9955
  comment = '')
9860
9956
 
9861
9957
  elif isinstance(val, str):
9862
- self.mytooltip.add_param(groupname = locarray.idx,
9958
+ self.mytooltip.add_param(groupname = curgroup,
9863
9959
  name = curpar,
9864
9960
  value = val,
9865
9961
  type = Type_Param.String,
9866
9962
  comment = '')
9867
9963
  elif isinstance(val, int):
9868
- self.mytooltip.add_param(groupname = locarray.idx,
9964
+ self.mytooltip.add_param(groupname = curgroup,
9869
9965
  name = curpar,
9870
9966
  value = int(val),
9871
9967
  type = Type_Param.Integer,
9872
9968
  comment = '')
9873
9969
  else:
9874
- self.mytooltip.add_param(groupname = locarray.idx,
9970
+ self.mytooltip.add_param(groupname = curgroup,
9875
9971
  name = curpar,
9876
9972
  value = float(val),
9877
9973
  type = Type_Param.Float,
9878
9974
  comment = '')
9879
9975
  except:
9880
- logging.warning(_('Error in linked frame -- Please check !'))
9976
+ logging.warning(_('Error in linked frame Arrays -- Please check !'))
9977
+
9978
+ for locarray in curFrame.myres2D:
9979
+ locarray:Wolfresults_2D
9980
+ curgroup = title + ' - ' + locarray.idx
9981
+ if locarray.checked:
9982
+ try:
9983
+ vals,labs = locarray.get_values_labels(x,y)
9984
+
9985
+ i, j, curbloc = locarray.get_blockij_from_xy(x, y)
9986
+
9987
+ if i != '-' and i != -1:
9988
+ curpar = 'Indices (i;j;bloc) (1-based)'
9989
+
9990
+ self.mytooltip.add_param(groupname = curgroup,
9991
+ name = curpar,
9992
+ value = '(' + str(i) + ';' + str(j) + ';' + str(curbloc) + ')',
9993
+ type = Type_Param.String,
9994
+ comment = '')
9995
+
9996
+ for val,curpar in zip(vals,labs):
9997
+
9998
+ if val is np.nan:
9999
+ self.mytooltip.add_param(groupname = curgroup,
10000
+ name = 'Value',
10001
+ value = "Nan",
10002
+ type = Type_Param.String,
10003
+ comment = '')
10004
+
10005
+ elif np.ma.is_masked(val):
10006
+
10007
+ self.mytooltip.add_param(groupname = curgroup,
10008
+ name = 'Value',
10009
+ value = "Masked",
10010
+ type = Type_Param.String,
10011
+ comment = '')
10012
+
10013
+ elif isinstance(val, str):
10014
+ self.mytooltip.add_param(groupname = curgroup,
10015
+ name = curpar,
10016
+ value = val,
10017
+ type = Type_Param.String,
10018
+ comment = '')
10019
+
10020
+ elif isinstance(val, int):
10021
+ self.mytooltip.add_param(groupname = curgroup,
10022
+ name = curpar,
10023
+ value = int(val),
10024
+ type = Type_Param.Integer,
10025
+ comment = '')
10026
+
10027
+ else:
10028
+ self.mytooltip.add_param(groupname = curgroup,
10029
+ name = curpar,
10030
+ value = float(val),
10031
+ type = Type_Param.Float,
10032
+ comment = '')
10033
+
10034
+ except:
10035
+ logging.warning(_('Error in linked frame Results2D -- Please check !'))
9881
10036
 
9882
10037
  for loc_ps in self.mypartsystems:
9883
10038
  if loc_ps.checked:
@@ -9989,11 +10144,34 @@ class WolfMapViewer(wx.Frame):
9989
10144
 
9990
10145
  self.active_vector.move(delta_x, delta_y)
9991
10146
 
10147
+ if self.action == 'move triangles':
10148
+ if self.active_tri is not None:
10149
+ if self.active_tri._start_move is not None:
10150
+
10151
+ delta_x = x - self.active_tri._start_move[0]
10152
+ delta_y = y - self.active_tri._start_move[1]
10153
+
10154
+ if shiftdown:
10155
+ delta_y = 0.
10156
+
10157
+ if altdown:
10158
+ delta_x = 0.
10159
+
10160
+ self.active_tri.move(delta_x, delta_y)
10161
+
10162
+ self.active_tri.reset_plot()
10163
+
9992
10164
  if self.action == 'rotate vector':
9993
10165
  if self.active_vector is not None:
9994
10166
  if self.active_vector._rotation_center is not None:
9995
10167
  self.active_vector.rotate_xy(x, y)
9996
10168
 
10169
+ if self.action == 'rotate triangles':
10170
+ if self.active_tri is not None:
10171
+ if self.active_tri._rotation_center is not None:
10172
+ self.active_tri.rotate_xy(x, y)
10173
+ self.active_tri.reset_plot()
10174
+
9997
10175
  if self.action == 'move zone':
9998
10176
  if self.active_zone is not None:
9999
10177
  if self.active_zone._start_move is not None:
wolfhece/PyPalette.py CHANGED
@@ -671,6 +671,21 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
671
671
 
672
672
  self.fill_segmentdata()
673
673
 
674
+ def is_valid(self):
675
+ """Vérification de la validité de la palette"""
676
+
677
+ if self.nb < 2:
678
+ return False
679
+
680
+ if self.values[0] >= self.values[-1]:
681
+ return False
682
+
683
+ for i in range(1, self.nb):
684
+ if self.values[i] <= self.values[i-1]:
685
+ return False
686
+
687
+ return True
688
+
674
689
  def savefile(self, *args):
675
690
  """Lecture de la palette sur base d'un fichier WOLF .pal"""
676
691
  if len(args) > 0:
@@ -59,6 +59,12 @@ class Triangulation(Element_To_Draw):
59
59
  self.nb_tri = len(tri)
60
60
  self.nb_pts = len(pts)
61
61
 
62
+ self._start_move = None
63
+ self._move_step = None # step for a move
64
+ self._rotation_center = None
65
+ self._rotation_step = None
66
+ self._cache = None
67
+
62
68
  if fn !='':
63
69
  self.filename=fn
64
70
  self.read(fn)
@@ -370,6 +376,7 @@ class Triangulation(Element_To_Draw):
370
376
  glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)
371
377
 
372
378
  glEndList()
379
+ glCallList(self.id_list)
373
380
  except:
374
381
  logging.warning('Problem with OpenGL plot - Triangulation.plot')
375
382
  else:
@@ -420,6 +427,67 @@ class Triangulation(Element_To_Draw):
420
427
  self.nb_pts = len(self.pts)
421
428
  self.nb_tri = len(self.tri)
422
429
  self.valid_format()
430
+
431
+ def set_cache(self):
432
+ """ Set the cache for the vertices """
433
+
434
+ self._cache = self.pts.copy()
435
+
436
+ def clear_cache(self):
437
+ """ Clear the cache for the vertices """
438
+
439
+ self._cache = None
440
+
441
+ def move(self, delta_x:float, delta_y:float, use_cache:bool = True):
442
+ """ Move the vertices by a delta_x and delta_y
443
+
444
+ :param delta_x: delta x [m]
445
+ :param delta_y: delta y [m]
446
+ """
447
+
448
+ if use_cache and self._cache is None:
449
+ self.set_cache()
450
+
451
+ if use_cache:
452
+ self.pts[:,0] = self._cache[:,0] + delta_x
453
+ self.pts[:,1] = self._cache[:,1] + delta_y
454
+ else:
455
+ self.pts[:,0] += delta_x
456
+ self.pts[:,1] += delta_y
457
+
458
+ def rotate(self, angle:float, center:tuple, use_cache:bool = True):
459
+ """ Rotate the vertices around a center
460
+
461
+ :param angle: angle in degrees -- positive for clockwise rotation
462
+ :param center: center of rotation
463
+ """
464
+ angle = np.radians(angle)
465
+ c,s = np.cos(angle), np.sin(angle)
466
+ R = np.array([[c,-s],[s,c]])
467
+
468
+ if use_cache and self._cache is None:
469
+ self.set_cache()
470
+
471
+ if use_cache:
472
+ locxy = self._cache[:,:2] - np.array(center)
473
+ self.pts[:,:2] = np.dot(R,locxy.T).T + np.array(center)
474
+ else:
475
+ locxy = self.pts[:,:2] - np.array(center)
476
+ self.pts[:,:2] = np.dot(R,locxy.T).T + np.array(center)
477
+
478
+ def rotate_xy(self, x:float, y:float, use_cache:bool = True):
479
+ """ Rotate the vector around the rotation center and a xy point """
480
+
481
+ if self._rotation_center is None:
482
+ logging.error('No rotation center defined -- set it before rotating by this routine')
483
+ return self
484
+
485
+ angle = np.degrees(np.arctan2(-(y-self._rotation_center[1]), x-self._rotation_center[0]))
486
+
487
+ if self._rotation_step is not None:
488
+ angle = np.round(angle/self._rotation_step)*self._rotation_step
489
+
490
+ return self.rotate(-angle, center=self._rotation_center, use_cache=use_cache)
423
491
  class vectorproperties:
424
492
  """ Vector properties """
425
493
  used:bool
@@ -1743,7 +1811,8 @@ class vector:
1743
1811
 
1744
1812
  :param only_firstlast: si True, on ne recherche que les coordonnées du premier et du dernier vertex
1745
1813
  """
1746
- if len(self.myvertices)>0:
1814
+
1815
+ if self.nbvertices > 0:
1747
1816
 
1748
1817
  if only_firstlast:
1749
1818
  self.xmin=min(self.myvertices[0].x, self.myvertices[-1].x)
@@ -1755,6 +1824,11 @@ class vector:
1755
1824
  self.ymin=min(vert.y for vert in self.myvertices)
1756
1825
  self.xmax=max(vert.x for vert in self.myvertices)
1757
1826
  self.ymax=max(vert.y for vert in self.myvertices)
1827
+ else:
1828
+ self.xmin=-99999.
1829
+ self.ymin=-99999.
1830
+ self.xmax=-99999.
1831
+ self.ymax=-99999.
1758
1832
 
1759
1833
  @property
1760
1834
  def has_interior(self):
@@ -2952,10 +3026,10 @@ class zone:
2952
3026
  self.active_vector=None # current active vector
2953
3027
  self.parent=parent # parent object - type(Zones)
2954
3028
 
2955
- self.xmin = 0.
2956
- self.ymin = 0.
2957
- self.xmax = 0.
2958
- self.ymax = 0.
3029
+ self.xmin = -99999.
3030
+ self.ymin = -99999.
3031
+ self.xmax = -99999.
3032
+ self.ymax = -99999.
2959
3033
 
2960
3034
  self.has_legend = False # indicate if at least one vector in the zone has a legend
2961
3035
  self.has_image = False # indicate if at least one vector in the zone has an image
@@ -3282,22 +3356,21 @@ class zone:
3282
3356
  self.xmax=-99999.
3283
3357
  self.ymax=-99999.
3284
3358
  else:
3285
- minsx=np.asarray([vect.xmin for vect in self.myvectors])
3286
- minsy=np.asarray([vect.ymin for vect in self.myvectors])
3287
- maxsx=np.asarray([vect.xmax for vect in self.myvectors])
3288
- maxsy=np.asarray([vect.ymax for vect in self.myvectors])
3289
-
3290
- # if len(minsx)>1: # FIXME what if more than one vector is empty.
3291
- if max(max(minsx),max(minsy), max(maxsx), max(maxsy)) != -99999.:
3292
- self.xmin=np.min(minsx[np.where(minsx!=-99999.)])
3293
- self.xmax=np.max(maxsx[np.where(maxsx!=-99999.)])
3294
- self.ymin=np.min(minsy[np.where(minsy!=-99999.)])
3295
- self.ymax=np.max(maxsy[np.where(maxsy!=-99999.)])
3359
+ minsx=np.asarray([vect.xmin for vect in self.myvectors if vect.xmin!=-99999.])
3360
+ minsy=np.asarray([vect.ymin for vect in self.myvectors if vect.ymin!=-99999.])
3361
+ maxsx=np.asarray([vect.xmax for vect in self.myvectors if vect.xmax!=-99999.])
3362
+ maxsy=np.asarray([vect.ymax for vect in self.myvectors if vect.ymax!=-99999.])
3363
+
3364
+ if minsx.size == 0:
3365
+ self.xmin=-99999.
3366
+ self.ymin=-99999.
3367
+ self.xmax=-99999.
3368
+ self.ymax=-99999.
3296
3369
  else:
3297
- self.xmin=minsx[0]
3298
- self.xmax=maxsx[0]
3299
- self.ymin=minsy[0]
3300
- self.ymax=maxsy[0]
3370
+ self.xmin = minsx.min()
3371
+ self.xmax = maxsx.max()
3372
+ self.ymin = minsy.min()
3373
+ self.ymax = maxsy.max()
3301
3374
 
3302
3375
  def prep_listogl(self):
3303
3376
  """
@@ -4852,6 +4925,9 @@ class Zones(wx.Frame, Element_To_Draw):
4852
4925
 
4853
4926
  self.xmin=ox
4854
4927
  self.ymin=oy
4928
+
4929
+ self._first_find_minmax:bool = True
4930
+
4855
4931
  self.tx=tx
4856
4932
  self.ty=ty
4857
4933
  self.myzones=[]
@@ -5502,32 +5578,29 @@ class Zones(wx.Frame, Element_To_Draw):
5502
5578
  :param update : si True, force la MAJ des minmax dans chaque zone; si False, compile les minmax déjà présents
5503
5579
  :param only_firstlast : si True, ne prend en compte que le premier et le dernier vertex de chaque vecteur
5504
5580
  """
5505
- if update:
5581
+
5582
+ if update or self._first_find_minmax:
5506
5583
  for zone in self.myzones:
5507
- zone.find_minmax(update, only_firstlast)
5584
+ zone.find_minmax(update or self._first_find_minmax, only_firstlast)
5585
+ self._first_find_minmax = False
5508
5586
 
5509
- if len(self.myzones)>0:
5587
+ if self.nbzones > 0:
5510
5588
 
5511
- minsx=np.asarray([zone.xmin for zone in self.myzones])
5512
- minsy=np.asarray([zone.ymin for zone in self.myzones])
5513
- maxsx=np.asarray([zone.xmax for zone in self.myzones])
5514
- maxsy=np.asarray([zone.ymax for zone in self.myzones])
5589
+ minsx = np.asarray([zone.xmin for zone in self.myzones if zone.xmin!=-99999.])
5590
+ minsy = np.asarray([zone.ymin for zone in self.myzones if zone.ymin!=-99999.])
5591
+ maxsx = np.asarray([zone.xmax for zone in self.myzones if zone.xmax!=-99999.])
5592
+ maxsy = np.asarray([zone.ymax for zone in self.myzones if zone.ymax!=-99999.])
5515
5593
 
5516
- if len(minsx)>1:
5517
- self.xmin=np.min(minsx[np.where(minsx!=-99999.)])
5518
- self.xmax=np.max(maxsx[np.where(maxsx!=-99999.)])
5519
- self.ymin=np.min(minsy[np.where(minsy!=-99999.)])
5520
- self.ymax=np.max(maxsy[np.where(maxsy!=-99999.)])
5594
+ if minsx.size == 0:
5595
+ self.xmin = 0.
5596
+ self.ymin = 0.
5597
+ self.xmax = 1.
5598
+ self.ymax = 1.
5521
5599
  else:
5522
- self.xmin=minsx[0]
5523
- self.xmax=maxsx[0]
5524
- self.ymin=minsy[0]
5525
- self.ymax=maxsy[0]
5526
- else:
5527
- self.xmin=0.
5528
- self.ymin=0.
5529
- self.xmax=1.
5530
- self.ymax=1.
5600
+ self.xmin = minsx.min()
5601
+ self.xmax = maxsx.max()
5602
+ self.ymin = minsy.min()
5603
+ self.ymax = maxsy.max()
5531
5604
 
5532
5605
  def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
5533
5606
  """