wolfhece 2.1.118__py3-none-any.whl → 2.1.120__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.
@@ -46,6 +46,7 @@ from .PyVertex import wolfvertex,getIfromRGB,getRGBfromI, cloud_vertices
46
46
  from .PyParams import Wolf_Param, Type_Param, new_json
47
47
  from .wolf_texture import Text_Image_Texture,Text_Infos
48
48
  from .drawing_obj import Element_To_Draw
49
+ from .matplotlib_fig import Matplotlib_Figure as MplFig
49
50
 
50
51
  class Triangulation(Element_To_Draw):
51
52
  def __init__(self, fn='', pts=[], tri=[], idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) -> None:
@@ -2626,6 +2627,83 @@ class vector:
2626
2627
 
2627
2628
  return fig,ax
2628
2629
 
2630
+ def plot_linked_wx(self, fig:MplFig, linked_arrays:dict):
2631
+ """
2632
+ Graphique Matplolib de valeurs dans les matrices liées.
2633
+
2634
+ Version pour wxPython
2635
+ """
2636
+
2637
+ colors=['red','blue','green']
2638
+
2639
+ exit=True
2640
+ for curlabel, curarray in linked_arrays.items():
2641
+ if curarray.plotted:
2642
+ exit=False
2643
+
2644
+ if exit:
2645
+ return
2646
+
2647
+ k=0
2648
+
2649
+ myls = self.asshapely_ls()
2650
+ length = myls.length
2651
+ tol=length/10.
2652
+ fig.cur_ax.set_xlim(0-tol,length+tol)
2653
+
2654
+ zmin=99999.
2655
+ zmax=-99999.
2656
+ nullvalue = -99999
2657
+
2658
+ for curlabel, curarray in linked_arrays.items():
2659
+ if curarray.plotted:
2660
+
2661
+ ds = curarray.get_dxdy_min()
2662
+
2663
+ nb = int(np.ceil(length/ds*2))
2664
+
2665
+ alls = np.linspace(0,int(length),nb)
2666
+
2667
+ pts = [myls.interpolate(curs) for curs in alls]
2668
+
2669
+ allz = np.asarray([curarray.get_value(curpt.x,curpt.y, nullvalue= nullvalue) for curpt in pts])
2670
+
2671
+ zmaxloc=np.max(allz[allz!=nullvalue])
2672
+ zminloc=np.min(allz[allz!=nullvalue])
2673
+
2674
+ zmax=max(zmax,zmaxloc)
2675
+ zmin=min(zmin,zminloc)
2676
+
2677
+ if np.max(allz)>nullvalue:
2678
+ # select parts
2679
+ if nullvalue in allz:
2680
+ # find all parts separated by nullvalue
2681
+ nulls = np.argwhere(allz==nullvalue)
2682
+ nulls = np.insert(nulls,0,-1)
2683
+ nulls = np.append(nulls,len(allz))
2684
+
2685
+ addlabel = True
2686
+ for i in range(len(nulls)-1):
2687
+ if nulls[i+1]-nulls[i]>1:
2688
+ fig.plot(alls[nulls[i]+1:nulls[i+1]],allz[nulls[i]+1:nulls[i+1]],
2689
+ color=colors[np.mod(k,3)],
2690
+ lw=2.0,
2691
+ label=curlabel if addlabel else None)
2692
+ addlabel = False
2693
+
2694
+ else:
2695
+ fig.plot(alls,allz,
2696
+ color=colors[np.mod(k,3)],
2697
+ lw=2.0,
2698
+ label=curlabel)
2699
+ k+=1
2700
+
2701
+ fig.cur_ax.set_ylim(zmin,zmax)
2702
+ fig.cur_ax.legend()
2703
+ fig.cur_ax.grid()
2704
+
2705
+ return fig
2706
+
2629
2707
  def plot_mpl(self,show=False,forceaspect=True,fig:Figure=None,ax:Axes=None,labels:dict={}):
2630
2708
  """
2631
2709
  Graphique Matplolib du vecteur
@@ -4814,6 +4892,227 @@ class zone:
4814
4892
  ax.set_yticks(np.arange(zmodmin,zmax,.25))
4815
4893
  fig.canvas.draw()
4816
4894
 
4895
+ def plot_linked_polygons_wx(self, fig:MplFig,
4896
+ linked_arrays:dict, linked_vec:dict[str,"Zones"]=None,
4897
+ linestyle:str='-', onlymedian:bool=False,
4898
+ withtopography:bool = True, ds:float = None):
4899
+ """
4900
+ Création d'un graphique sur base des polygones
4901
+
4902
+ Chaque polygone se positionnera sur base de la valeur Z de ses vertices
4903
+ - façon conventionnelle de définir une longueur
4904
+ - ceci est normalement fait lors de l'appel à 'create_polygon_from_parallel'
4905
+ - si les polygones sont créés manuellement, il faut donc prendre soin de fournir l'information adhoc ou alors utiliser l'rgument 'ds'
4906
+
4907
+ ATTENTION : Les coordonnées Z ne sont sauvegardées sur disque que si le fichier est 3D, autrement dit au format '.vecz'
4908
+
4909
+ :param fig: Figure
4910
+ :param ax: Axes
4911
+ :param linked_arrays: dictionnaire contenant les matrices à lier -- les clés sont les labels
4912
+ :param linked_vec: dictionnaire contenant les instances Zones à lier -- Besoin d'une zone et d'un vecteur 'trace/trace' pour convertir les positions en coordonnées curvilignes
4913
+ :param linestyle: style de ligne
4914
+ :param onlymedian: affiche uniquement la médiane
4915
+ :param withtopography: affiche la topographie
4916
+ :param ds: pas spatial le long de l'axe
4917
+
4918
+ """
4919
+
4920
+ colors=['red','blue','green','darkviolet','fuchsia','lime']
4921
+
4922
+ #Vérifie qu'au moins une matrice liée est fournie, sinon rien à faire
4923
+ exit=True
4924
+ for curlabel, curarray in linked_arrays.items():
4925
+ if curarray.plotted:
4926
+ exit=False
4927
+ if exit:
4928
+ return
4929
+
4930
+ k=0
4931
+
4932
+ zmin=99999.
4933
+ zmax=-99999.
4934
+
4935
+ if ds is None:
4936
+ # Récupération des positions
4937
+ srefs=np.asarray([curpol.myvertices[0].z for curpol in self.myvectors])
4938
+ else:
4939
+ # Création des positions sur base de 'ds'
4940
+ srefs=np.arange(0., float(self.nbvectors) * ds, ds)
4941
+
4942
+ for idx, (curlabel, curarray) in enumerate(linked_arrays.items()):
4943
+ if curarray.plotted:
4944
+
4945
+ logging.info(_('Plotting linked polygons for {}'.format(curlabel)))
4946
+ logging.info(_('Number of polygons : {}'.format(self.nbvectors)))
4947
+ logging.info(_('Extracting values inside polygons...'))
4948
+
4949
+ vals= [curarray.get_values_insidepoly(curpol) for curpol in self.myvectors]
4950
+
4951
+ logging.info(_('Computing stats...'))
4952
+
4953
+ values = np.asarray([cur[0] for cur in vals],dtype=object)
4954
+ valel = np.asarray([cur[1] for cur in vals],dtype=object)
4955
+
4956
+ zmaxloc=np.asarray([np.max(curval) if len(curval) >0 else -99999. for curval in values])
4957
+ zminloc=np.asarray([np.min(curval) if len(curval) >0 else -99999. for curval in values])
4958
+
4959
+ zmax=max(zmax,np.max(zmaxloc[np.where(zmaxloc>-99999.)]))
4960
+ zmin=min(zmin,np.min(zminloc[np.where(zminloc>-99999.)]))
4961
+
4962
+ if zmax>-99999:
4963
+
4964
+ zloc = np.asarray([np.median(curpoly) if len(curpoly) >0 else -99999. for curpoly in values])
4965
+
4966
+ fig.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
4967
+ color=colors[np.mod(k,3)],
4968
+ lw=2.0,
4969
+ linestyle=linestyle,
4970
+ label=curlabel+'_median')
4971
+
4972
+ zloc = np.asarray([np.min(curpoly) if len(curpoly) >0 else -99999. for curpoly in values])
4973
+
4974
+ if not onlymedian:
4975
+
4976
+ fig.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
4977
+ color=colors[np.mod(k,3)],alpha=.3,
4978
+ lw=2.0,
4979
+ linestyle=linestyle,
4980
+ label=curlabel+'_min')
4981
+
4982
+ zloc = np.asarray([np.max(curpoly) if len(curpoly) >0 else -99999. for curpoly in values])
4983
+
4984
+ fig.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
4985
+ color=colors[np.mod(k,3)],alpha=.3,
4986
+ lw=2.0,
4987
+ linestyle=linestyle,
4988
+ label=curlabel+'_max')
4989
+
4990
+ if withtopography and idx==0:
4991
+ if valel[0] is not None:
4992
+ zmaxloc=np.asarray([np.max(curval) if len(curval) >0 else -99999. for curval in valel])
4993
+ zminloc=np.asarray([np.min(curval) if len(curval) >0 else -99999. for curval in valel])
4994
+
4995
+ zmax=max(zmax,np.max(zmaxloc[np.where(zmaxloc>-99999.)]))
4996
+ zmin=min(zmin,np.min(zminloc[np.where(zminloc>-99999.)]))
4997
+
4998
+ if zmax>-99999:
4999
+
5000
+ zloc = np.asarray([np.median(curpoly) if len(curpoly) >0 else -99999. for curpoly in valel])
5001
+
5002
+ fig.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
5003
+ color='black',
5004
+ lw=2.0,
5005
+ linestyle=linestyle,
5006
+ label=curlabel+'_top_median')
5007
+
5008
+ # if not onlymedian:
5009
+ # zloc = np.asarray([np.min(curpoly) for curpoly in valel])
5010
+
5011
+ # ax.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
5012
+ # color='black',alpha=.3,
5013
+ # lw=2.0,
5014
+ # linestyle=linestyle,
5015
+ # label=curlabel+'_top_min')
5016
+
5017
+ # zloc = np.asarray([np.max(curpoly) for curpoly in valel])
5018
+
5019
+ # ax.plot(srefs[np.where(zloc!=-99999.)],zloc[np.where(zloc!=-99999.)],
5020
+ # color='black',alpha=.3,
5021
+ # lw=2.0,
5022
+ # linestyle=linestyle,
5023
+ # label=curlabel+'_top_max')
5024
+
5025
+ k+=1
5026
+
5027
+ for curlabel, curzones in linked_vec.items():
5028
+ curzones:Zones
5029
+ names = [curzone.myname for curzone in curzones.myzones]
5030
+ trace = None
5031
+ tracels = None
5032
+
5033
+ logging.info(_('Plotting linked zones for {}'.format(curlabel)))
5034
+
5035
+ curzone: zone
5036
+ if 'trace' in names:
5037
+ curzone = curzones.get_zone('trace')
5038
+ trace = curzone.get_vector('trace')
5039
+
5040
+ if trace is None:
5041
+ if curzone is not None:
5042
+ if curzone.nbvectors>0:
5043
+ trace = curzone.myvectors[0]
5044
+
5045
+ if trace is not None:
5046
+ tracels = trace.asshapely_ls()
5047
+ else:
5048
+ logging.warning(_('No trace found in the vectors {}'.format(curlabel)))
5049
+ break
5050
+
5051
+ if ('marks' in names) or ('repères' in names):
5052
+ if ('marks' in names):
5053
+ curzone = curzones.myzones[names.index('marks')]
5054
+ else:
5055
+ curzone = curzones.myzones[names.index('repères')]
5056
+
5057
+ logging.info(_('Plotting marks for {}'.format(curlabel)))
5058
+ logging.info(_('Number of marks : {}'.format(curzone.nbvectors)))
5059
+
5060
+ for curvect in curzone.myvectors:
5061
+ curls = curvect.asshapely_ls()
5062
+
5063
+ if curls.intersects(tracels):
5064
+ inter = curls.intersection(tracels)
5065
+ curs = float(tracels.project(inter))
5066
+
5067
+ fig.plot([curs, curs], [zmin, zmax], linestyle='--', label=curvect.myname)
5068
+ fig.text(curs, zmax, curvect.myname, fontsize=8, ha='center', va='bottom')
5069
+
5070
+ if ('banks' in names) or ('berges' in names):
5071
+
5072
+ if ('banks' in names):
5073
+ curzone = curzones.myzones[names.index('banks')]
5074
+ else:
5075
+ curzone = curzones.myzones[names.index('berges')]
5076
+
5077
+ logging.info(_('Plotting banks for {}'.format(curlabel)))
5078
+ logging.info(_('Number of banks : {}'.format(curzone.nbvectors)))
5079
+
5080
+ for curvect in curzone.myvectors:
5081
+ curvect: vector
5082
+
5083
+ curproj = curvect.projectontrace(trace)
5084
+ sz = curproj.asnparray()
5085
+ fig.plot(sz[:,0], sz[:,1], label=curvect.myname)
5086
+
5087
+ if ('bridges' in names) or ('ponts' in names):
5088
+ if ('bridges' in names):
5089
+ curzone = curzones.myzones[names.index('bridges')]
5090
+ else:
5091
+ curzone = curzones.myzones[names.index('ponts')]
5092
+
5093
+ logging.info(_('Plotting bridges for {}'.format(curlabel)))
5094
+
5095
+ for curvect in curzone.myvectors:
5096
+ curvect: vector
5097
+ curls = curvect.asshapely_ls()
5098
+
5099
+ if curls.intersects(tracels):
5100
+
5101
+ logging.info(_('Bridge {} intersects the trace'.format(curvect.myname)))
5102
+
5103
+ inter = curls.intersection(tracels)
5104
+ curs = float(tracels.project(inter))
5105
+ locz = np.asarray([vert.z for vert in curvect.myvertices])
5106
+ zmin = np.amin(locz)
5107
+ zmax = np.amax(locz)
5108
+
5109
+ fig.plot(curs, zmin, label=curvect.myname + ' min', marker='x')
5110
+ fig.plot(curs, zmax, label=curvect.myname + ' max', marker='x')
5111
+
5112
+ fig.cur_ax.set_ylim(zmin,zmax)
5113
+ zmodmin= np.floor_divide(zmin*100,25)*25/100
5114
+ fig.cur_ax.set_yticks(np.arange(zmodmin,zmax,.25))
5115
+
4817
5116
  def reset_listogl(self):
4818
5117
  """
4819
5118
  Reset OpenGL lists.
@@ -7673,6 +7972,11 @@ class Zones(wx.Frame, Element_To_Draw):
7673
7972
 
7674
7973
  if self.active_vector is None:
7675
7974
  logging.warning(_('No vector in the active zone'))
7975
+ if self.parent is not None:
7976
+ try:
7977
+ self.parent.Active_zone(self.active_zone)
7978
+ except:
7979
+ raise Warning(_('Not supported in the current parent -- see PyVertexVectors in Activate_zone function'))
7676
7980
  else:
7677
7981
  self.labelactvect.SetLabel(self.active_vector.myname)
7678
7982
 
@@ -58,6 +58,45 @@ def main():
58
58
  ret += 'Wolfhece not installed properly\n Please install the VC++ redistributable\n from https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads\n\n'
59
59
  ret += 'Error : ' + str(e) + '\n\n'
60
60
 
61
+ from pathlib import Path
62
+ dirlaz = Path(__file__).parent.parent / 'lazviewer'
63
+ dirs_to_test = [dirlaz / 'libs', dirlaz / 'libs/qt_plugins', dirlaz / 'libs/qt_plugins/platforms']
64
+
65
+ for d in dirs_to_test:
66
+ if not d.exists() or not d.is_dir():
67
+ ret += str(d) + ' does not exist\n\n'
68
+
69
+ curdir = dirlaz / 'libs/qt_plugins/platforms'
70
+ files_to_test = [curdir / 'qwindows.dll']
71
+
72
+ for f in files_to_test:
73
+ if not f.exists() or not f.is_file():
74
+ ret += str(f) + ' does not exist\n\n'
75
+
76
+ curdir = dirlaz / 'libs'
77
+ files_to_test = [curdir / 'icudt53.dll', curdir / 'icuin53.dll', curdir / 'icuuc53.dll',
78
+ curdir / 'msvcp120.dll', curdir / 'msvcr120.dll', curdir / 'Qt5Core.dll',
79
+ curdir / 'Qt5Gui.dll', curdir / 'Qt5Network.dll', curdir / 'Qt5Widgets.dll',
80
+ curdir / 'tbb.dll', curdir / 'tbbmalloc.dll', curdir / 'vcomp120.dll']
81
+
82
+ for f in files_to_test:
83
+ if not f.exists() or not f.is_file():
84
+ ret += str(f) + ' does not exist\n\n'
85
+
86
+ try:
87
+ from ..lazviewer.viewer import viewer
88
+ import numpy as np
89
+
90
+ pts = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
91
+ myview = viewer.viewer(pts, debug = True)
92
+
93
+ ret += 'LAZ viewer created in debug mode -- check for errors if reported\n\n'
94
+
95
+ except ImportError as e:
96
+ ret += 'Could not import/create LAZ viewer\n\n'
97
+ ret += 'Wolfhece not installed properly\n Please check if QT \n\n'
98
+ ret += 'Error : ' + str(e) + '\n\n'
99
+
61
100
  print(ret)
62
101
 
63
102
  if __name__=='__main__':
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 = 118
8
+ self.patch = 120
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -1,23 +1,23 @@
1
- import os
2
- import os.path
3
- import sys
4
- import platform
1
+ # import os
2
+ # import os.path
3
+ # import sys
4
+ # import platform
5
5
 
6
6
 
7
- def _add_path():
8
- _root_dir = os.path.dirname(os.path.realpath(__file__))
7
+ # def _add_path():
8
+ # _root_dir = os.path.dirname(os.path.realpath(__file__))
9
9
 
10
- # manual specify list of dll directories, with paths relative to _root_dir
11
- _dll_dirs = ['libs']
10
+ # # manual specify list of dll directories, with paths relative to _root_dir
11
+ # _dll_dirs = ['libs']
12
12
 
13
- if platform.system() == 'Windows':
14
- os.environ.setdefault('PATH', '')
15
- paths = os.environ['PATH'].split(';')
16
- for x in _dll_dirs:
17
- x = os.path.join(_root_dir, x)
18
- if os.path.isdir(x) and x not in paths:
19
- paths = [x] + paths
20
- os.environ['PATH'] = ';'.join(paths)
13
+ # if platform.system() == 'Windows':
14
+ # os.environ.setdefault('PATH', '')
15
+ # paths = os.environ['PATH'].split(';')
16
+ # for x in _dll_dirs:
17
+ # x = os.path.join(_root_dir, x)
18
+ # if os.path.isdir(x) and x not in paths:
19
+ # paths = [x] + paths
20
+ # os.environ['PATH'] = ';'.join(paths)
21
21
 
22
22
 
23
- _add_path()
23
+ # _add_path()