wolfhece 2.0.55__py3-none-any.whl → 2.1.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.
- wolfhece/PyDraw.py +890 -295
- wolfhece/PyGui.py +1924 -661
- wolfhece/PyPalette.py +47 -0
- wolfhece/PyParams.py +377 -76
- wolfhece/PyVertex.py +14 -1
- wolfhece/PyVertexvectors.py +45 -18
- wolfhece/Results2DGPU.py +1 -2
- wolfhece/apps/version.py +2 -2
- wolfhece/bernoulli/__init__.py +0 -0
- wolfhece/bernoulli/chamber.py +93 -0
- wolfhece/bernoulli/fluids.py +10 -0
- wolfhece/bernoulli/losses.py +100 -0
- wolfhece/bernoulli/network.py +128 -0
- wolfhece/bernoulli/pipe.py +194 -0
- wolfhece/lagrangian/example_domain.py +1 -1
- wolfhece/mesh2d/bc_manager.py +66 -5
- wolfhece/mesh2d/config_manager.py +1 -1
- wolfhece/mesh2d/cst_2D_boundary_conditions.py +59 -2
- wolfhece/mesh2d/wolf2dprev.py +11605 -2678
- wolfhece/models/walous_niv1.pal +29 -0
- wolfhece/models/walous_niv2.pal +77 -0
- wolfhece/pywalous.py +400 -46
- wolfhece/scenario/config_manager.py +14 -5
- wolfhece/wolf_array.py +1487 -458
- wolfhece/wolf_vrt.py +31 -8
- wolfhece/wolfresults_2D.py +230 -91
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.0.dist-info}/METADATA +3 -2
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.0.dist-info}/RECORD +31 -23
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.0.dist-info}/WHEEL +0 -0
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.0.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.0.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py
CHANGED
@@ -12,6 +12,7 @@ from PIL.PngImagePlugin import PngInfo
|
|
12
12
|
import io
|
13
13
|
import json
|
14
14
|
import glob
|
15
|
+
import traceback
|
15
16
|
try:
|
16
17
|
from osgeo import gdal
|
17
18
|
except ModuleNotFoundError:
|
@@ -50,7 +51,7 @@ from .wolfresults_2D import Wolfresults_2D, views_2D
|
|
50
51
|
from .PyTranslate import _
|
51
52
|
from .PyVertex import cloud_vertices, getIfromRGB
|
52
53
|
from .RatingCurve import SPWMIGaugingStations, SPWDCENNGaugingStations
|
53
|
-
from .wolf_array import WOLF_ARRAY_MB, SelectionData, WolfArray,
|
54
|
+
from .wolf_array import WOLF_ARRAY_MB, SelectionData, WolfArray, WolfArrayMB, CropDialog, header_wolf, WolfArrayMNAP, WOLF_ARRAY_FULL_SINGLE, WOLF_ARRAY_FULL_INTEGER8, WOLF_ARRAY_FULL_INTEGER16, WOLF_ARRAY_FULL_DOUBLE, WOLF_ARRAY_FULL_INTEGER
|
54
55
|
from .PyParams import Wolf_Param, key_Param, Type_Param
|
55
56
|
from .mesh2d.bc_manager import BcManager
|
56
57
|
from .PyVertexvectors import *
|
@@ -151,7 +152,27 @@ class WolfMapViewer(wx.Frame):
|
|
151
152
|
active_particle_system: Particle_system
|
152
153
|
active_viewer3d: Wolf_Viewer3D
|
153
154
|
|
154
|
-
def __init__(self,
|
155
|
+
def __init__(self,
|
156
|
+
wxparent = None,
|
157
|
+
title:str = _('Default Wolf Map Viewer'),
|
158
|
+
w:int=500,
|
159
|
+
h:int=500,
|
160
|
+
treewidth:int=200,
|
161
|
+
wolfparent=None,
|
162
|
+
wxlogging=None):
|
163
|
+
|
164
|
+
"""
|
165
|
+
Create a Viewer for WOLF data/simulation
|
166
|
+
|
167
|
+
:params wxparent: wx parent - set to None if main window
|
168
|
+
:params title: title of the window
|
169
|
+
:params w: width of the window in pixels
|
170
|
+
:params h: height of the window in pixels
|
171
|
+
:params treewidth: width of the tree list in pixels
|
172
|
+
:params wolfparent: WOLF object parent -- see PyGui.py
|
173
|
+
:params wxlogging: wx logging object
|
174
|
+
|
175
|
+
"""
|
155
176
|
|
156
177
|
self._wxlogging = wxlogging
|
157
178
|
self.action = None # Action à entreprendre
|
@@ -220,6 +241,7 @@ class WolfMapViewer(wx.Frame):
|
|
220
241
|
self.menu2d_cache_setup = None
|
221
242
|
self.menuparticlesystem = None
|
222
243
|
self.menu2dGPU = None
|
244
|
+
self.menuwalous = None
|
223
245
|
self.timer_ps = None
|
224
246
|
self.menusim2D = None
|
225
247
|
self.menulaz = None
|
@@ -245,9 +267,16 @@ class WolfMapViewer(wx.Frame):
|
|
245
267
|
updategltf = self.menugltf.Append(wx.ID_ANY, _('Update...'), _('Update data from gltf files'))
|
246
268
|
|
247
269
|
self.filemenu.AppendSeparator()
|
248
|
-
|
270
|
+
|
271
|
+
# SIMULATION 2D
|
272
|
+
|
273
|
+
sim2d = self.filemenu.Append(wx.ID_ANY, _('Create/Open multiblock model'), _('Create or open a multiblock model in a new viewer'))
|
274
|
+
check2D = self.filemenu.Append(wx.ID_ANY, _('Check headers'), _('Check the header .txt files from an existing 2D simulation'))
|
249
275
|
|
250
276
|
self.filemenu.AppendSeparator()
|
277
|
+
|
278
|
+
# MULTIVIEWER
|
279
|
+
|
251
280
|
compareitem = self.filemenu.Append(wx.ID_ANY, _('Set comparison'), _('Set comparison'))
|
252
281
|
multiview = self.filemenu.Append(wx.ID_ANY, _('Multiviewer'), _('Multiviewer'))
|
253
282
|
viewer3d = self.filemenu.Append(wx.ID_ANY, _('3D viewer'), _('3D viewer'))
|
@@ -387,6 +416,8 @@ class WolfMapViewer(wx.Frame):
|
|
387
416
|
curtool['menu'] = self.plot_cs
|
388
417
|
curtool['name'] = 'Plot cross section'
|
389
418
|
|
419
|
+
self.mybc = []
|
420
|
+
|
390
421
|
self.active_vector = None
|
391
422
|
self.active_zone = None
|
392
423
|
self.active_zones = None
|
@@ -515,6 +546,32 @@ class WolfMapViewer(wx.Frame):
|
|
515
546
|
def wxlogging(self, value):
|
516
547
|
self._wxlogging = value
|
517
548
|
|
549
|
+
|
550
|
+
def create_2D_MB_model(self):
|
551
|
+
""" Create a 2D model """
|
552
|
+
|
553
|
+
from .PyGui import Wolf2DModel
|
554
|
+
|
555
|
+
newview = Wolf2DModel(splash = False)
|
556
|
+
|
557
|
+
def check_2D_MB_headers(self):
|
558
|
+
""" Check headers of a 2D simulation without opening viewer"""
|
559
|
+
|
560
|
+
# Check 2D simulation
|
561
|
+
dlg = wx.FileDialog(self, _("Choose 2D simulation file"), wildcard="all (*.*)|*.*", style=wx.FD_OPEN)
|
562
|
+
if dlg.ShowModal() == wx.ID_CANCEL:
|
563
|
+
dlg.Destroy()
|
564
|
+
return
|
565
|
+
|
566
|
+
filename = dlg.GetPath()
|
567
|
+
dlg.Destroy()
|
568
|
+
|
569
|
+
from .mesh2d.wolf2dprev import prev_sim2D
|
570
|
+
|
571
|
+
sim = prev_sim2D(filename)
|
572
|
+
sim.verify_files()
|
573
|
+
|
574
|
+
|
518
575
|
def get_mapviewer(self):
|
519
576
|
""" Retourne une instance WolfMapViewer """
|
520
577
|
return self
|
@@ -654,16 +711,345 @@ class WolfMapViewer(wx.Frame):
|
|
654
711
|
|
655
712
|
if self.menuwolf2d is None:
|
656
713
|
self.menuwolf2d = wx.Menu()
|
714
|
+
|
657
715
|
self.menu2d_curentview = self.menuwolf2d.Append(wx.ID_ANY, _("Change current view"), _("Current view"))
|
658
716
|
self.menu2d_lastres = self.menuwolf2d.Append(wx.ID_ANY, _("Read last result"), _("Current view"))
|
659
717
|
self.menu2d_epsilon = self.menuwolf2d.Append(wx.ID_ANY, _("Set epsilon water depth"), _("Set the epsilon used in the mask"))
|
660
718
|
|
661
719
|
self.menu_filter_independent = self.menuwolf2d.Append(wx.ID_ANY, _("Filter independent"), _("Filter independent"), kind=wx.ITEM_CHECK)
|
662
720
|
|
663
|
-
self.menu2d_bc = self.menuwolf2d.Append(wx.ID_ANY, _("Manage boundary conditions..."), _("BC manager"))
|
721
|
+
# self.menu2d_bc = self.menuwolf2d.Append(wx.ID_ANY, _("Manage boundary conditions..."), _("BC manager"))
|
664
722
|
self.menu2d_video = self.menuwolf2d.Append(wx.ID_ANY, _("Create video..."), _("Video/Movie"))
|
665
723
|
|
666
|
-
self.menubar.Append(self.menuwolf2d, _('
|
724
|
+
self.menubar.Append(self.menuwolf2d, _('Results 2D'))
|
725
|
+
|
726
|
+
self.menuwolf2d.Bind(wx.EVT_MENU, self.Onmenuwolf2d)
|
727
|
+
|
728
|
+
def menu_walous(self):
|
729
|
+
|
730
|
+
if self.menuwalous is None:
|
731
|
+
self.menuwalous = wx.Menu()
|
732
|
+
|
733
|
+
self.menuwalous_crop = self.menuwalous.Append(wx.ID_ANY, _("Crop on active array"), _("Crop active array"))
|
734
|
+
self.menuwalous_cropscreen = self.menuwalous.Append(wx.ID_ANY, _("Crop on screen"), _("Crop screen"))
|
735
|
+
self.menuwalous_map = self.menuwalous.Append(wx.ID_ANY, _("Map active array"), _("Map active array"))
|
736
|
+
self.menuwalous_legend = self.menuwalous.Append(wx.ID_ANY, _("Legend"), _("Legend"))
|
737
|
+
self._walous_filepath = None
|
738
|
+
self._walous_layer = None
|
739
|
+
self._walous_map = None
|
740
|
+
|
741
|
+
self.menubar.Append(self.menuwalous, _('Walous'))
|
742
|
+
|
743
|
+
self.menuwalous.Bind(wx.EVT_MENU, self.Onmenuwalous)
|
744
|
+
|
745
|
+
|
746
|
+
def get_canvas_bounds(self, gridsize:float = None):
|
747
|
+
""" Retourne les limites de la zone d'affichage """
|
748
|
+
|
749
|
+
if gridsize is None:
|
750
|
+
|
751
|
+
return [self.xmin, self.ymin, self.xmax, self.ymax]
|
752
|
+
|
753
|
+
else:
|
754
|
+
|
755
|
+
xmin = float(np.rint(self.xmin / gridsize) * gridsize)
|
756
|
+
ymin = float(np.rint(self.ymin / gridsize) * gridsize)
|
757
|
+
xmax = float(np.rint(self.xmax / gridsize) * gridsize)
|
758
|
+
ymax = float(np.rint(self.ymax / gridsize) * gridsize)
|
759
|
+
|
760
|
+
return [xmin, ymin, xmax, ymax]
|
761
|
+
|
762
|
+
def Onmenuwalous(self, event: wx.MenuEvent):
|
763
|
+
|
764
|
+
id = event.GetId()
|
765
|
+
item = self.menubar.FindItemById(event.GetId())
|
766
|
+
|
767
|
+
if item is None:
|
768
|
+
return
|
769
|
+
|
770
|
+
itemlabel = item.ItemLabel
|
771
|
+
|
772
|
+
if itemlabel in [_("Crop on active array"), _("Crop on screen")]:
|
773
|
+
|
774
|
+
|
775
|
+
if itemlabel == _("Crop on screen"):
|
776
|
+
|
777
|
+
bounds = self.get_canvas_bounds(gridsize=1.)
|
778
|
+
|
779
|
+
def_outdrir = ''
|
780
|
+
spatial_res = 1.
|
781
|
+
|
782
|
+
if self.active_array is not None:
|
783
|
+
spatial_res = self.active_array.dx
|
784
|
+
|
785
|
+
dlg = wx.TextEntryDialog(None,_("Spatial resolution [m] ?"), value = str(spatial_res))
|
786
|
+
|
787
|
+
dlg.ShowModal()
|
788
|
+
try:
|
789
|
+
spatial_res = float(dlg.GetValue())
|
790
|
+
dlg.Destroy()
|
791
|
+
except:
|
792
|
+
dlg.Destroy()
|
793
|
+
logging.warning(_("Bad value -- Rety"))
|
794
|
+
return
|
795
|
+
|
796
|
+
else:
|
797
|
+
|
798
|
+
if self.active_array is None:
|
799
|
+
logging.warning(_('No active array -- Please activate data first'))
|
800
|
+
return
|
801
|
+
|
802
|
+
bounds = self.active_array.get_bounds()
|
803
|
+
def_outdrir = Path(self.active_array.filename).parent
|
804
|
+
spatial_res = self.active_array.dx
|
805
|
+
|
806
|
+
from .pywalous import Walous_data, WALOUS2MANNING_MAJ_NIV1, WALOUS2MANNING_MAJ_NIV2, update_palette_walous
|
807
|
+
|
808
|
+
if self._walous_filepath is None:
|
809
|
+
dlg = wx.FileDialog(self, _("Choose the Walous shape file"), wildcard="Shapefile (*.shp)|*.shp|all (*.*)|*.*", style=wx.FD_OPEN)
|
810
|
+
if dlg.ShowModal() == wx.ID_CANCEL:
|
811
|
+
dlg.Destroy()
|
812
|
+
return
|
813
|
+
|
814
|
+
self._walous_filepath = Path(dlg.GetPath())
|
815
|
+
dlg.Destroy()
|
816
|
+
|
817
|
+
|
818
|
+
dlg = wx.FileDialog(self, _("Choose the output file"), wildcard="Geotif (*.tif)|*.tif|all (*.*)|*.*", style=wx.FD_SAVE, defaultDir=def_outdrir)
|
819
|
+
if dlg.ShowModal() == wx.ID_CANCEL:
|
820
|
+
dlg.Destroy()
|
821
|
+
return
|
822
|
+
|
823
|
+
output = Path(dlg.GetPath())
|
824
|
+
dlg.Destroy()
|
825
|
+
|
826
|
+
# choix de la couche entre MAJ_NIV1 et MAJ_NIV2
|
827
|
+
dlg = wx.SingleChoiceDialog(None, _("Choose a layer"), "Choices", ['MAJ_NIV1', 'MAJ_NIV2'])
|
828
|
+
ret = dlg.ShowModal()
|
829
|
+
if ret == wx.ID_CANCEL:
|
830
|
+
dlg.Destroy()
|
831
|
+
return
|
832
|
+
|
833
|
+
self._walous_layer = dlg.GetStringSelection()
|
834
|
+
|
835
|
+
locwalous = Walous_data(self._walous_filepath.parent, self._walous_filepath.name)
|
836
|
+
ret = locwalous.rasterize(bounds=bounds,
|
837
|
+
layer=self._walous_layer,
|
838
|
+
fn_out=output,
|
839
|
+
pixel_size=spatial_res)
|
840
|
+
|
841
|
+
if isinstance(ret, int):
|
842
|
+
logging.error(_('Error {}').format(ret))
|
843
|
+
return
|
844
|
+
|
845
|
+
if Path(output).exists():
|
846
|
+
logging.info(_('File {} created').format(output))
|
847
|
+
else:
|
848
|
+
logging.error(_('File {} not created').format(output))
|
849
|
+
return
|
850
|
+
|
851
|
+
dlg = wx.MessageDialog(self, _('Do you want to load the created file ?'), _('Load file'), wx.YES_NO | wx.ICON_QUESTION)
|
852
|
+
ret = dlg.ShowModal()
|
853
|
+
|
854
|
+
if ret == wx.ID_CANCEL:
|
855
|
+
dlg.Destroy()
|
856
|
+
return
|
857
|
+
|
858
|
+
elif ret == wx.ID_YES:
|
859
|
+
walousarray = WolfArray(fname=output)
|
860
|
+
update_palette_walous(self._walous_layer, walousarray.mypal)
|
861
|
+
self.add_object('array', newobj=walousarray, id = 'walous_crop')
|
862
|
+
dlg.Destroy()
|
863
|
+
|
864
|
+
elif itemlabel == _("Legend"):
|
865
|
+
|
866
|
+
from .pywalous import WalousLegend
|
867
|
+
|
868
|
+
newlegend = WalousLegend(self)
|
869
|
+
newlegend.Show()
|
870
|
+
|
871
|
+
elif itemlabel == _("Map active array"):
|
872
|
+
|
873
|
+
from .pywalous import DlgMapWalous, WALOUS2MANNING_MAJ_NIV1, WALOUS2MANNING_MAJ_NIV2
|
874
|
+
|
875
|
+
if self.active_array is None:
|
876
|
+
logging.warning(_('No active array -- Please activate data first'))
|
877
|
+
return
|
878
|
+
|
879
|
+
vals = self.active_array.get_unique_values()
|
880
|
+
|
881
|
+
if self._walous_layer is None:
|
882
|
+
|
883
|
+
if vals[0] > 10:
|
884
|
+
self._walous_layer = 'MAJ_NIV2'
|
885
|
+
else:
|
886
|
+
self._walous_layer = 'MAJ_NIV1'
|
887
|
+
|
888
|
+
dlg = DlgMapWalous(self, which=self._walous_layer)
|
889
|
+
|
890
|
+
ret = dlg.ShowModal()
|
891
|
+
|
892
|
+
if ret == wx.ID_CANCEL:
|
893
|
+
dlg.Destroy()
|
894
|
+
return
|
895
|
+
|
896
|
+
mapvals = dlg.get_mapping()
|
897
|
+
dlg.Destroy()
|
898
|
+
|
899
|
+
if mapvals == -1:
|
900
|
+
logging.error(_('Bad values -- retry'))
|
901
|
+
return
|
902
|
+
|
903
|
+
self.active_array.map_values(mapvals)
|
904
|
+
|
905
|
+
self.active_array.reset_plot()
|
906
|
+
|
907
|
+
def Onmenuwolf2d(self, event: wx.MenuEvent):
|
908
|
+
|
909
|
+
id = event.GetId()
|
910
|
+
item = self.menubar.FindItemById(event.GetId())
|
911
|
+
|
912
|
+
if item is None:
|
913
|
+
return
|
914
|
+
|
915
|
+
itemlabel = item.ItemLabel
|
916
|
+
|
917
|
+
|
918
|
+
if itemlabel == _("Read last result"):
|
919
|
+
|
920
|
+
self.read_last_result()
|
921
|
+
|
922
|
+
elif itemlabel == _("Change current view"):
|
923
|
+
|
924
|
+
# Change view for results
|
925
|
+
|
926
|
+
autoscale = False
|
927
|
+
choices = [cur.value for cur in views_2D]
|
928
|
+
dlg = wx.SingleChoiceDialog(None, _("Pick a view"), "Choices", choices)
|
929
|
+
ret = dlg.ShowModal()
|
930
|
+
if ret == wx.ID_CANCEL:
|
931
|
+
dlg.Destroy()
|
932
|
+
return
|
933
|
+
|
934
|
+
method = dlg.GetStringSelection()
|
935
|
+
|
936
|
+
method = list(views_2D)[choices.index(method)]
|
937
|
+
|
938
|
+
dlg.Destroy()
|
939
|
+
|
940
|
+
diamsize = None
|
941
|
+
if method == views_2D.SHIELDS_NUMBER :
|
942
|
+
|
943
|
+
if self.active_res2d is not None:
|
944
|
+
sediment_diam = self.active_res2d.sediment_diameter
|
945
|
+
sediment_density = self.active_res2d.sediment_density
|
946
|
+
elif self.compare_results is not None:
|
947
|
+
sediment_diam = 0.001
|
948
|
+
sediment_density = 2.650
|
949
|
+
else:
|
950
|
+
logging.warning(_('No active 2D result or comparison !'))
|
951
|
+
return
|
952
|
+
|
953
|
+
dlg = wx.TextEntryDialog(None,_("Diameter grain size [m] ?"), value = str(sediment_diam))
|
954
|
+
ret = dlg.ShowModal()
|
955
|
+
if ret == wx.ID_CANCEL:
|
956
|
+
dlg.Destroy()
|
957
|
+
return
|
958
|
+
try:
|
959
|
+
diamsize = float(dlg.GetValue())
|
960
|
+
except:
|
961
|
+
dlg.Destroy()
|
962
|
+
logging.warning(_("Bad value -- Rety"))
|
963
|
+
return
|
964
|
+
|
965
|
+
dlg = wx.TextEntryDialog(None,_("Density grain [-] ?"), value = str(sediment_density))
|
966
|
+
ret = dlg.ShowModal()
|
967
|
+
if ret == wx.ID_CANCEL:
|
968
|
+
dlg.Destroy()
|
969
|
+
return
|
970
|
+
try:
|
971
|
+
density = float(dlg.GetValue())
|
972
|
+
except:
|
973
|
+
dlg.Destroy()
|
974
|
+
logging.warning(_("Bad value -- Rety"))
|
975
|
+
return
|
976
|
+
|
977
|
+
if len(self.myres2D)>1:
|
978
|
+
|
979
|
+
dlg = wx.MessageDialog(None, _('Apply to all results?'), style=wx.YES_NO)
|
980
|
+
ret = dlg.ShowModal()
|
981
|
+
if ret == wx.ID_NO:
|
982
|
+
if diamsize is not None:
|
983
|
+
self.active_res2d.sediment_diameter = diamsize
|
984
|
+
self.active_res2d.sediment_density = density
|
985
|
+
self.active_res2d.load_default_colormap('shields_cst')
|
986
|
+
|
987
|
+
self.active_res2d.set_currentview(method, force_wx = True, force_updatepal = True)
|
988
|
+
else:
|
989
|
+
for curarray in self.iterator_over_objects(draw_type.RES2D):
|
990
|
+
curarray:Wolfresults_2D
|
991
|
+
if diamsize is not None:
|
992
|
+
curarray.sediment_diameter = diamsize
|
993
|
+
curarray.sediment_density = density
|
994
|
+
curarray.load_default_colormap('shields_cst')
|
995
|
+
|
996
|
+
curarray.set_currentview(method, force_wx = True, force_updatepal = True)
|
997
|
+
|
998
|
+
else:
|
999
|
+
if self.active_res2d is not None:
|
1000
|
+
if diamsize is not None:
|
1001
|
+
self.active_res2d.sediment_diameter = diamsize
|
1002
|
+
self.active_res2d.sediment_density = density
|
1003
|
+
self.active_res2d.load_default_colormap('shields_cst')
|
1004
|
+
self.active_res2d.set_currentview(method, force_wx = True, force_updatepal = True)
|
1005
|
+
|
1006
|
+
if self.compare_results is not None:
|
1007
|
+
# update compare results
|
1008
|
+
if diamsize is not None:
|
1009
|
+
self.compare_results.set_shields_param(diamsize, density)
|
1010
|
+
self.compare_results.update_type_result(method)
|
1011
|
+
|
1012
|
+
elif itemlabel == _("Set epsilon water depth"):
|
1013
|
+
|
1014
|
+
dlg = wx.TextEntryDialog(self, _('Enter an epsilon [m]'),value='0.0')
|
1015
|
+
|
1016
|
+
ret = dlg.ShowModal()
|
1017
|
+
|
1018
|
+
if ret == wx.ID_CANCEL:
|
1019
|
+
dlg.Destroy()
|
1020
|
+
return
|
1021
|
+
|
1022
|
+
try:
|
1023
|
+
neweps = float(dlg.GetValue())
|
1024
|
+
dlg.Destroy()
|
1025
|
+
except:
|
1026
|
+
logging.error(_('Bad value -- retry !'))
|
1027
|
+
dlg.Destroy()
|
1028
|
+
return
|
1029
|
+
|
1030
|
+
for curmodel in self.iterator_over_objects(draw_type.RES2D):
|
1031
|
+
curmodel: Wolfresults_2D
|
1032
|
+
curmodel.epsilon = neweps
|
1033
|
+
curmodel._epsilon_default = neweps
|
1034
|
+
curmodel.read_oneresult(curmodel.current_result)
|
1035
|
+
curmodel.set_currentview()
|
1036
|
+
|
1037
|
+
elif itemlabel == _("Filter independent"):
|
1038
|
+
|
1039
|
+
self.menu_filter_independent.IsChecked = not self.menu_filter_independent.IsChecked
|
1040
|
+
|
1041
|
+
for curmodel in self.iterator_over_objects(draw_type.RES2D):
|
1042
|
+
curmodel: Wolfresults_2D
|
1043
|
+
curmodel.to_filter_independent = not self.menu_filter_independent.IsChecked
|
1044
|
+
|
1045
|
+
# elif itemlabel == _("Manage boundary conditions..."):
|
1046
|
+
|
1047
|
+
# if self.active_res2d is not None:
|
1048
|
+
# self.active_res2d.myparams.editing_bc(self.myres2D)
|
1049
|
+
|
1050
|
+
elif itemlabel ==_("Create video..."):
|
1051
|
+
if self.active_res2d is not None:
|
1052
|
+
self.create_video()
|
667
1053
|
|
668
1054
|
def menu_2dgpu(self):
|
669
1055
|
|
@@ -903,21 +1289,21 @@ class WolfMapViewer(wx.Frame):
|
|
903
1289
|
if self.active_array is None:
|
904
1290
|
logging.warning(_('No active array -- Please activate an array first'))
|
905
1291
|
return
|
906
|
-
if len(self.active_array.
|
1292
|
+
if len(self.active_array.SelectionData.myselection) == 0 and len(self.active_array.SelectionData.selections) ==0:
|
907
1293
|
logging.warning(_('No selection -- Please select some nodes first'))
|
908
1294
|
return
|
909
1295
|
|
910
1296
|
from .lagrangian.emitter import Emitter
|
911
1297
|
|
912
1298
|
newemitters=[]
|
913
|
-
if len(self.active_array.
|
914
|
-
indices = [self.active_array.get_ij_from_xy(cur[0], cur[1]) for cur in self.active_array.
|
1299
|
+
if len(self.active_array.SelectionData.myselection) > 0:
|
1300
|
+
indices = [self.active_array.get_ij_from_xy(cur[0], cur[1]) for cur in self.active_array.SelectionData.myselection]
|
915
1301
|
newemitters = [Emitter(indices,
|
916
1302
|
header = (self.active_array.origx, self.active_array.origy, self.active_array.dx, self.active_array.dy))]
|
917
1303
|
|
918
|
-
if len(self.active_array.
|
1304
|
+
if len(self.active_array.SelectionData.selections) > 0:
|
919
1305
|
|
920
|
-
for cursel in self.active_array.
|
1306
|
+
for cursel in self.active_array.SelectionData.selections.values():
|
921
1307
|
indices = [self.active_array.get_ij_from_xy(cur[0], cur[1]) for cur in cursel['select']]
|
922
1308
|
newemitters += [Emitter(indices, header = (self.active_array.origx, self.active_array.origy, self.active_array.dx, self.active_array.dy))]
|
923
1309
|
|
@@ -980,18 +1366,162 @@ class WolfMapViewer(wx.Frame):
|
|
980
1366
|
self.timer_ps.Stop()
|
981
1367
|
|
982
1368
|
def menu_sim2D(self):
|
1369
|
+
""" Menu for 2D simulations """
|
1370
|
+
|
983
1371
|
if self.menusim2D is None:
|
984
1372
|
self.menusim2D = wx.Menu()
|
985
1373
|
self.menubar.Append(self.menusim2D, _('Tools 2D'))
|
986
1374
|
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
1375
|
+
menu2d_options = self.menusim2D.Append(wx.ID_ANY, _("Parameters..."), _("Parameters"))
|
1376
|
+
menu2d_zbin2hbin = self.menusim2D.Append(wx.ID_ANY, _("Convert zbin to hbin"), _("Convert zbin to hbin"))
|
1377
|
+
menu2d_hbin2zbin = self.menusim2D.Append(wx.ID_ANY, _("Convert hbin to zbin"), _("Convert hbin to zbin"))
|
1378
|
+
menu2D_zbinb2hbinb = self.menusim2D.Append(wx.ID_ANY, _("Convert zbinb to hbinb"), _("Convert zbinb to hbinb"))
|
1379
|
+
menu2d_hbinb2zbinb = self.menusim2D.Append(wx.ID_ANY, _("Convert hbinb to zbinb"), _("Convert hbinb to zbinb"))
|
1380
|
+
menu2d_forcemask = self.menusim2D.Append(wx.ID_ANY, _("Reset mask of all arrays"), _("Reset mask"))
|
1381
|
+
|
1382
|
+
# update = self.menusim2D.Append(wx.ID_ANY, _('Update model from current mask'), _('Update model'))
|
1383
|
+
# updateblocfile = self.menusim2D.Append(wx.ID_ANY, _('Update .bloc file'), _('Update bloc'))
|
1384
|
+
# updatefreesurface = self.menusim2D.Append(wx.ID_ANY, _('Update free surface elevation - IC'), _('Update free surface elevation'))
|
1385
|
+
# updaterough = self.menusim2D.Append(wx.ID_ANY, _('Update roughness coeff'), _('Update roughness coefficient'))
|
1386
|
+
# updateic = self.menusim2D.Append(wx.ID_ANY, _('Update IC reading mode'), _('Update IC'))
|
1387
|
+
# menu2d_tft_ic = self.menusim2D.Append(wx.ID_ANY,_("Transfer initial conditions..."),_("Transfer IC"))
|
1388
|
+
|
1389
|
+
self.menusim2D.Bind(wx.EVT_MENU, self.Onmenusim2D)
|
1390
|
+
|
1391
|
+
def Onmenusim2D(self, event: wx.MenuEvent):
|
1392
|
+
""" Action to perform whern menu 2D entry is selected """
|
1393
|
+
|
1394
|
+
id = event.GetId()
|
1395
|
+
item = self.menubar.FindItemById(event.GetId())
|
1396
|
+
|
1397
|
+
if item is None:
|
1398
|
+
return
|
1399
|
+
|
1400
|
+
itemlabel = item.ItemLabel
|
1401
|
+
|
1402
|
+
from .PyGui import Wolf2DModel
|
1403
|
+
|
1404
|
+
if not isinstance(self.wolfparent, Wolf2DModel):
|
1405
|
+
logging.error(_('This is not a 2D model'))
|
1406
|
+
return
|
1407
|
+
|
1408
|
+
self.wolfparent:Wolf2DModel
|
1409
|
+
|
1410
|
+
if itemlabel == _('Update .bloc file'):
|
1411
|
+
|
1412
|
+
msg = _('If you continue the .bloc file will be relpaced !')+'\n'
|
1413
|
+
msg += '\n'
|
1414
|
+
msg += _('Continue ?')+'\n'
|
1415
|
+
|
1416
|
+
dlg = wx.MessageDialog(self,msg,caption = _('Attention'), style = wx.YES_NO)
|
1417
|
+
ret = dlg.ShowModal()
|
1418
|
+
dlg.Destroy()
|
1419
|
+
if ret == wx.ID_NO:
|
1420
|
+
return
|
1421
|
+
|
1422
|
+
self.wolfparent.write_bloc_file()
|
1423
|
+
|
1424
|
+
elif itemlabel == _('Reset mask of all arrays'):
|
1425
|
+
|
1426
|
+
self.wolfparent.sim.force_mask()
|
1427
|
+
|
1428
|
+
elif itemlabel == _('Convert zbin to hbin'):
|
1429
|
+
|
1430
|
+
if self.wolfparent.sim._zbin is not None:
|
1431
|
+
self.wolfparent.sim.zbin2hbin()
|
1432
|
+
self.wolfparent.sim.hbin.reset_plot()
|
1433
|
+
|
1434
|
+
elif itemlabel == _('Convert hbin to zbin'):
|
1435
|
+
|
1436
|
+
if self.wolfparent.sim._hbin is not None:
|
1437
|
+
self.wolfparent.sim.hbin2zbin()
|
1438
|
+
self.wolfparent.sim.zbin.reset_plot()
|
1439
|
+
|
1440
|
+
elif itemlabel == _('Convert zbinb to hbinb'):
|
1441
|
+
|
1442
|
+
if self.wolfparent.sim._zbinb is not None:
|
1443
|
+
self.wolfparent.sim.zbinb2hbinb()
|
1444
|
+
self.wolfparent.sim.hbinb.reset_plot()
|
1445
|
+
|
1446
|
+
elif itemlabel == _('Convert hbinb to zbinb'):
|
1447
|
+
|
1448
|
+
if self.wolfparent.sim._hbinb is not None:
|
1449
|
+
self.wolfparent.sim.hbinb2zbinb()
|
1450
|
+
self.wolfparent.sim.zbinb.reset_plot()
|
1451
|
+
|
1452
|
+
elif itemlabel == _("Transfer initial conditions..."):
|
1453
|
+
|
1454
|
+
if self.active_array is not None:
|
1455
|
+
from .PyGui import Wolf2DModel
|
1456
|
+
if isinstance(self.wolfparent,Wolf2DModel):
|
1457
|
+
self.wolfparent.transfer_ic(self.active_vector)
|
1458
|
+
|
1459
|
+
elif itemlabel == _("Parameters..."):
|
1460
|
+
self.wolfparent.show_properties()
|
1461
|
+
|
1462
|
+
elif itemlabel == _('Update free surface elevation - IC'):
|
1463
|
+
|
1464
|
+
if len(self.active_array.SelectionData.myselection)==0:
|
1465
|
+
|
1466
|
+
msg = _('There is none selected nodes in the active array !')+'\n'
|
1467
|
+
msg += '\n'
|
1468
|
+
msg += _('Please select the desired zone and retry !')+'\n'
|
1469
|
+
|
1470
|
+
logging.warning(msg)
|
1471
|
+
return
|
1472
|
+
|
1473
|
+
self.wolfparent.extend_freesurface_elevation(self.active_array.SelectionData.myselection)
|
1474
|
+
|
1475
|
+
elif itemlabel== _('Update roughness coeff'):
|
1476
|
+
|
1477
|
+
if len(self.active_array.SelectionData.myselection)==0:
|
1478
|
+
|
1479
|
+
msg = _('There is none selected nodes in the active array !')+'\n'
|
1480
|
+
msg += '\n'
|
1481
|
+
msg += _('Please select the desired zone and retry !')+'\n'
|
1482
|
+
|
1483
|
+
logging.warning(msg)
|
1484
|
+
return
|
1485
|
+
|
1486
|
+
self.wolfparent.extend_roughness(self.active_array.SelectionData.myselection)
|
1487
|
+
|
1488
|
+
# elif itemlabel == _('Update IC reading mode'):
|
1489
|
+
|
1490
|
+
# self.wolfparent.set_type_ic()
|
1491
|
+
|
1492
|
+
elif itemlabel == _('Update model from current mask'):
|
1493
|
+
|
1494
|
+
if type(self.active_array) not in [WolfArray]:
|
1495
|
+
msg = _('Please select a mono-block array !')+'\n'
|
1496
|
+
dlg=wx.MessageBox(msg,style=wx.OK)
|
1497
|
+
return
|
1498
|
+
|
1499
|
+
msg = _('If you continue, the mask of all arrays will be replaced by the current mask !')+'\n'
|
1500
|
+
msg += _('The external contour in the .bloc file will also be relpaced.')+'\n'
|
1501
|
+
msg += '\n'
|
1502
|
+
msg += _('Continue ?')+'\n'
|
1503
|
+
|
1504
|
+
dlg = wx.MessageDialog(self,msg,caption = _('Attention'), style = wx.YES_NO)
|
1505
|
+
ret = dlg.ShowModal()
|
1506
|
+
dlg.Destroy()
|
1507
|
+
if ret == wx.ID_NO:
|
1508
|
+
return
|
1509
|
+
|
1510
|
+
with wx.lib.busy.BusyInfo(_('Updating 2D model')):
|
1511
|
+
wait = wx.BusyCursor()
|
1512
|
+
|
1513
|
+
sux,suy,cont,interior = self.active_array.suxsuy_contour(self.wolfparent.filenamegen,True)
|
1514
|
+
|
1515
|
+
self.wolfparent.mimic_mask(self.active_array)
|
1516
|
+
self.wolfparent.replace_external_contour(cont,interior)
|
1517
|
+
|
1518
|
+
del wait
|
1519
|
+
|
1520
|
+
self.wolfparent.extend_bed_elevation()
|
993
1521
|
|
994
1522
|
def get_configuration(self) -> Union[WolfConfiguration, None]:
|
1523
|
+
""" Get global configuration parameters """
|
1524
|
+
|
995
1525
|
# At this point, I'm not too sure about
|
996
1526
|
# which window/frame does what. So to be on
|
997
1527
|
# the safe side, I make sure that the configuration
|
@@ -1748,6 +2278,8 @@ class WolfMapViewer(wx.Frame):
|
|
1748
2278
|
self.all_lists = [self.myarrays, self.myvectors, self.myclouds, self.mytri, self.myothers, self.myviews, self.myres2D, self.mytiles, self.mypartsystems, self.myviewers3d]
|
1749
2279
|
|
1750
2280
|
if self.get_configuration() is not None:
|
2281
|
+
# see PyGui.py if necessary
|
2282
|
+
|
1751
2283
|
self.menu_options = wx.Menu()
|
1752
2284
|
self.menubar.Append(self.menu_options, _('Options'))
|
1753
2285
|
self.option_global = self.menu_options.Append(wx.ID_ANY,_("Global"),_("Modify global options"))
|
@@ -1809,9 +2341,30 @@ class WolfMapViewer(wx.Frame):
|
|
1809
2341
|
mydiag = wx.MessageDialog(self, msg, _('Sort along'))
|
1810
2342
|
mydiag.ShowModal()
|
1811
2343
|
|
2344
|
+
def center_view_on(self, cx, cy):
|
2345
|
+
"""
|
2346
|
+
Center the view on the point of (map) coordinates (x,y)
|
2347
|
+
"""
|
2348
|
+
|
2349
|
+
self.mousex, self.mousey = cx, cy
|
2350
|
+
|
2351
|
+
# retrouve la taille de la fenêtre OpenGL
|
2352
|
+
width, height = self.canvas.GetSize()
|
2353
|
+
|
2354
|
+
# calcule la taille selon X et Y en coordonnées réelles
|
2355
|
+
width = width / self.sx
|
2356
|
+
height = height / self.sy
|
2357
|
+
|
2358
|
+
# retrouve les bornes min et max sur base de la valeur centrale qui est censée ne pas bouger
|
2359
|
+
self.xmin = self.mousex - width / 2.
|
2360
|
+
self.xmax = self.xmin + width
|
2361
|
+
self.ymin = self.mousey - height / 2.
|
2362
|
+
self.ymax = self.ymin + height
|
2363
|
+
|
1812
2364
|
def setbounds(self,updatescale=True):
|
1813
2365
|
"""
|
1814
|
-
Calcule les limites visibles de la fenêtrte graphique sur base des
|
2366
|
+
Calcule les limites visibles de la fenêtrte graphique sur base des
|
2367
|
+
facteurs d'échelle courants
|
1815
2368
|
"""
|
1816
2369
|
|
1817
2370
|
if updatescale:
|
@@ -1858,7 +2411,11 @@ class WolfMapViewer(wx.Frame):
|
|
1858
2411
|
self.canvas.SetClientSize(width, height)
|
1859
2412
|
|
1860
2413
|
def updatescalefactors(self):
|
1861
|
-
""" Mise à jour des facteurs d'échelle
|
2414
|
+
""" Mise à jour des facteurs d'échelle
|
2415
|
+
This one updates the scale factors based on the relative sizes
|
2416
|
+
of the GLCanvas and the footprint that should fit in it.
|
2417
|
+
"""
|
2418
|
+
|
1862
2419
|
width, height = self.canvas.GetSize()
|
1863
2420
|
|
1864
2421
|
self.sx = 1
|
@@ -1873,6 +2430,7 @@ class WolfMapViewer(wx.Frame):
|
|
1873
2430
|
|
1874
2431
|
def add_viewer_and_link(self):
|
1875
2432
|
""" Ajout d'une nouvelle fenêtre de visualisation et liaison avec la fenêtre courante """
|
2433
|
+
|
1876
2434
|
dlg = wx.TextEntryDialog(self, _('Enter a caption for the new window'))
|
1877
2435
|
|
1878
2436
|
ret = dlg.ShowModal()
|
@@ -1901,6 +2459,7 @@ class WolfMapViewer(wx.Frame):
|
|
1901
2459
|
|
1902
2460
|
def add_grid(self):
|
1903
2461
|
""" Ajout d'une grille """
|
2462
|
+
|
1904
2463
|
mygrid = Grid(1000.)
|
1905
2464
|
self.add_object('vector', newobj=mygrid, ToCheck=False, id='Grid')
|
1906
2465
|
|
@@ -3166,80 +3725,6 @@ class WolfMapViewer(wx.Frame):
|
|
3166
3725
|
os.chdir(os.path.dirname(filename))
|
3167
3726
|
self.read_project(filename)
|
3168
3727
|
|
3169
|
-
elif itemlabel == _('Update .bloc file'):
|
3170
|
-
|
3171
|
-
msg = _('If you continue the .bloc file will be relpaced !')+'\n'
|
3172
|
-
msg += '\n'
|
3173
|
-
msg += _('Continue ?')+'\n'
|
3174
|
-
|
3175
|
-
dlg = wx.MessageDialog(self,msg,caption = _('Attention'), style = wx.YES_NO)
|
3176
|
-
ret = dlg.ShowModal()
|
3177
|
-
dlg.Destroy()
|
3178
|
-
if ret == wx.ID_NO:
|
3179
|
-
return
|
3180
|
-
|
3181
|
-
self.wolfparent.write_bloc_file()
|
3182
|
-
|
3183
|
-
elif itemlabel == _('Update free surface elevation - IC'):
|
3184
|
-
|
3185
|
-
if len(self.active_array.mngselection.myselection)==0:
|
3186
|
-
|
3187
|
-
msg = _('There is none selected nodes in the active array !')+'\n'
|
3188
|
-
msg += '\n'
|
3189
|
-
msg += _('Please select the desired zone and retry !')+'\n'
|
3190
|
-
|
3191
|
-
logging.warning(msg)
|
3192
|
-
return
|
3193
|
-
|
3194
|
-
self.wolfparent.extend_freesurface_elevation(self.active_array.mngselection.myselection)
|
3195
|
-
|
3196
|
-
elif itemlabel== _('Update roughness coeff'):
|
3197
|
-
|
3198
|
-
if len(self.active_array.mngselection.myselection)==0:
|
3199
|
-
|
3200
|
-
msg = _('There is none selected nodes in the active array !')+'\n'
|
3201
|
-
msg += '\n'
|
3202
|
-
msg += _('Please select the desired zone and retry !')+'\n'
|
3203
|
-
|
3204
|
-
logging.warning(msg)
|
3205
|
-
return
|
3206
|
-
|
3207
|
-
self.wolfparent.extend_roughness(self.active_array.mngselection.myselection)
|
3208
|
-
|
3209
|
-
elif itemlabel == _('Update IC reading mode'):
|
3210
|
-
|
3211
|
-
self.wolfparent.set_type_ic()
|
3212
|
-
|
3213
|
-
elif itemlabel == _('Update model from current mask'):
|
3214
|
-
|
3215
|
-
if type(self.active_array) != WolfArray_Sim2D:
|
3216
|
-
msg = _('Please select a mono-block array !')+'\n'
|
3217
|
-
dlg=wx.MessageBox(msg,style=wx.OK)
|
3218
|
-
return
|
3219
|
-
|
3220
|
-
msg = _('If you continue, the mask of all arrays will be replaced by the current mask !')+'\n'
|
3221
|
-
msg += _('The external contour in the .bloc file will also be relpaced.')+'\n'
|
3222
|
-
msg += '\n'
|
3223
|
-
msg += _('Continue ?')+'\n'
|
3224
|
-
|
3225
|
-
dlg = wx.MessageDialog(self,msg,caption = _('Attention'), style = wx.YES_NO)
|
3226
|
-
ret = dlg.ShowModal()
|
3227
|
-
dlg.Destroy()
|
3228
|
-
if ret == wx.ID_NO:
|
3229
|
-
return
|
3230
|
-
|
3231
|
-
with wx.lib.busy.BusyInfo(_('Updating 2D model')):
|
3232
|
-
wait = wx.BusyCursor()
|
3233
|
-
|
3234
|
-
sux,suy,cont,interior = self.active_array.suxsuy_contour(self.wolfparent.filenamegen,True)
|
3235
|
-
|
3236
|
-
self.wolfparent.mimic_mask(self.active_array)
|
3237
|
-
self.wolfparent.replace_external_contour(cont,interior)
|
3238
|
-
|
3239
|
-
del wait
|
3240
|
-
|
3241
|
-
self.wolfparent.extend_bed_elevation()
|
3242
|
-
|
3243
3728
|
elif itemlabel == _('Shortcuts'):
|
3244
3729
|
# show shortcuts in log
|
3245
3730
|
self.print_shortcuts(True)
|
@@ -3297,7 +3782,7 @@ class WolfMapViewer(wx.Frame):
|
|
3297
3782
|
elif unknown == _('Head'):
|
3298
3783
|
unknown = 'head'
|
3299
3784
|
|
3300
|
-
fig, ax = self.active_res2d.plot_h(self.active_res2d.
|
3785
|
+
fig, ax = self.active_res2d.plot_h(self.active_res2d.SelectionData.myselection,
|
3301
3786
|
unknown, toshow=True)
|
3302
3787
|
|
3303
3788
|
elif itemlabel == _("Plot stats unknown (inside active vector)..."):
|
@@ -3532,141 +4017,141 @@ class WolfMapViewer(wx.Frame):
|
|
3532
4017
|
ax.legend()
|
3533
4018
|
fig.show()
|
3534
4019
|
|
3535
|
-
elif itemlabel == _("Change current view"):
|
3536
|
-
|
3537
|
-
|
3538
|
-
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3544
|
-
|
3545
|
-
|
3546
|
-
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
|
3556
|
-
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3563
|
-
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3607
|
-
|
3608
|
-
|
3609
|
-
|
3610
|
-
|
3611
|
-
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
elif itemlabel == _("Read last result"):
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3629
|
-
elif itemlabel == _("Filter independent"):
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
elif itemlabel == _("Set epsilon water depth"):
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
elif itemlabel == _("Manage boundary conditions..."):
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
elif itemlabel ==_("Create video..."):
|
3668
|
-
|
3669
|
-
|
4020
|
+
# elif itemlabel == _("Change current view"):
|
4021
|
+
|
4022
|
+
# # Change view for results
|
4023
|
+
|
4024
|
+
# autoscale = False
|
4025
|
+
# choices = [cur.value for cur in views_2D]
|
4026
|
+
# dlg = wx.SingleChoiceDialog(None, _("Pick a view"), "Choices", choices)
|
4027
|
+
# ret = dlg.ShowModal()
|
4028
|
+
# if ret == wx.ID_CANCEL:
|
4029
|
+
# dlg.Destroy()
|
4030
|
+
# return
|
4031
|
+
|
4032
|
+
# method = dlg.GetStringSelection()
|
4033
|
+
|
4034
|
+
# method = list(views_2D)[choices.index(method)]
|
4035
|
+
|
4036
|
+
# dlg.Destroy()
|
4037
|
+
|
4038
|
+
# diamsize = None
|
4039
|
+
# if method == views_2D.SHIELDS_NUMBER :
|
4040
|
+
|
4041
|
+
# if self.active_res2d is not None:
|
4042
|
+
# sediment_diam = self.active_res2d.sediment_diameter
|
4043
|
+
# sediment_density = self.active_res2d.sediment_density
|
4044
|
+
# elif self.compare_results is not None:
|
4045
|
+
# sediment_diam = 0.001
|
4046
|
+
# sediment_density = 2.650
|
4047
|
+
# else:
|
4048
|
+
# logging.warning(_('No active 2D result or comparison !'))
|
4049
|
+
# return
|
4050
|
+
|
4051
|
+
# dlg = wx.TextEntryDialog(None,_("Diameter grain size [m] ?"), value = str(sediment_diam))
|
4052
|
+
# ret = dlg.ShowModal()
|
4053
|
+
# if ret == wx.ID_CANCEL:
|
4054
|
+
# dlg.Destroy()
|
4055
|
+
# return
|
4056
|
+
# try:
|
4057
|
+
# diamsize = float(dlg.GetValue())
|
4058
|
+
# except:
|
4059
|
+
# dlg.Destroy()
|
4060
|
+
# logging.warning(_("Bad value -- Rety"))
|
4061
|
+
# return
|
4062
|
+
|
4063
|
+
# dlg = wx.TextEntryDialog(None,_("Density grain [-] ?"), value = str(sediment_density))
|
4064
|
+
# ret = dlg.ShowModal()
|
4065
|
+
# if ret == wx.ID_CANCEL:
|
4066
|
+
# dlg.Destroy()
|
4067
|
+
# return
|
4068
|
+
# try:
|
4069
|
+
# density = float(dlg.GetValue())
|
4070
|
+
# except:
|
4071
|
+
# dlg.Destroy()
|
4072
|
+
# logging.warning(_("Bad value -- Rety"))
|
4073
|
+
# return
|
4074
|
+
|
4075
|
+
# if len(self.myres2D)>1:
|
4076
|
+
|
4077
|
+
# dlg = wx.MessageDialog(None, _('Apply to all results?'), style=wx.YES_NO)
|
4078
|
+
# ret = dlg.ShowModal()
|
4079
|
+
# if ret == wx.ID_NO:
|
4080
|
+
# if diamsize is not None:
|
4081
|
+
# self.active_res2d.sediment_diameter = diamsize
|
4082
|
+
# self.active_res2d.sediment_density = density
|
4083
|
+
# self.active_res2d.load_default_colormap('shields_cst')
|
4084
|
+
|
4085
|
+
# self.active_res2d.set_currentview(method, force_wx = True, force_updatepal = True)
|
4086
|
+
# else:
|
4087
|
+
# for curarray in self.iterator_over_objects(draw_type.RES2D):
|
4088
|
+
# curarray:Wolfresults_2D
|
4089
|
+
# if diamsize is not None:
|
4090
|
+
# curarray.sediment_diameter = diamsize
|
4091
|
+
# curarray.sediment_density = density
|
4092
|
+
# curarray.load_default_colormap('shields_cst')
|
4093
|
+
|
4094
|
+
# curarray.set_currentview(method, force_wx = True, force_updatepal = True)
|
4095
|
+
|
4096
|
+
# else:
|
4097
|
+
# if self.active_res2d is not None:
|
4098
|
+
# if diamsize is not None:
|
4099
|
+
# self.active_res2d.sediment_diameter = diamsize
|
4100
|
+
# self.active_res2d.sediment_density = density
|
4101
|
+
# self.active_res2d.load_default_colormap('shields_cst')
|
4102
|
+
# self.active_res2d.set_currentview(method, force_wx = True, force_updatepal = True)
|
4103
|
+
|
4104
|
+
# if self.compare_results is not None:
|
4105
|
+
# # update compare results
|
4106
|
+
# if diamsize is not None:
|
4107
|
+
# self.compare_results.set_shields_param(diamsize, density)
|
4108
|
+
# self.compare_results.update_type_result(method)
|
4109
|
+
|
4110
|
+
# elif itemlabel == _("Read last result"):
|
4111
|
+
|
4112
|
+
# self.read_last_result()
|
4113
|
+
|
4114
|
+
# elif itemlabel == _("Filter independent"):
|
4115
|
+
|
4116
|
+
# self.menu_filter_independent.IsChecked = not self.menu_filter_independent.IsChecked
|
4117
|
+
|
4118
|
+
# for curmodel in self.iterator_over_objects(draw_type.RES2D):
|
4119
|
+
# curmodel: Wolfresults_2D
|
4120
|
+
# curmodel.to_filter_independent = not self.menu_filter_independent.IsChecked
|
4121
|
+
|
4122
|
+
# elif itemlabel == _("Set epsilon water depth"):
|
4123
|
+
|
4124
|
+
# dlg = wx.TextEntryDialog(self, _('Enter an epsilon [m]'),value='0.0')
|
4125
|
+
|
4126
|
+
# ret = dlg.ShowModal()
|
4127
|
+
|
4128
|
+
# if ret == wx.ID_CANCEL:
|
4129
|
+
# dlg.Destroy()
|
4130
|
+
# return
|
4131
|
+
|
4132
|
+
# try:
|
4133
|
+
# neweps = float(dlg.GetValue())
|
4134
|
+
# dlg.Destroy()
|
4135
|
+
# except:
|
4136
|
+
# logging.error(_('Bad value -- retry !'))
|
4137
|
+
# dlg.Destroy()
|
4138
|
+
# return
|
4139
|
+
|
4140
|
+
# for curmodel in self.iterator_over_objects(draw_type.RES2D):
|
4141
|
+
# curmodel: Wolfresults_2D
|
4142
|
+
# curmodel.epsilon = neweps
|
4143
|
+
# curmodel._epsilon_default = neweps
|
4144
|
+
# curmodel.read_oneresult(curmodel.current_result)
|
4145
|
+
# curmodel.set_currentview()
|
4146
|
+
|
4147
|
+
# elif itemlabel == _("Manage boundary conditions..."):
|
4148
|
+
|
4149
|
+
# if self.active_res2d is not None:
|
4150
|
+
# self.active_res2d.myparams.editing_bc(self.myres2D)
|
4151
|
+
|
4152
|
+
# elif itemlabel ==_("Create video..."):
|
4153
|
+
# if self.active_res2d is not None:
|
4154
|
+
# self.create_video()
|
3670
4155
|
|
3671
4156
|
elif itemlabel == _("Setup cache..."):
|
3672
4157
|
|
@@ -3737,13 +4222,6 @@ class WolfMapViewer(wx.Frame):
|
|
3737
4222
|
|
3738
4223
|
self.active_res2d.show_tiles()
|
3739
4224
|
|
3740
|
-
elif itemlabel == _("Transfer initial conditions..."):
|
3741
|
-
|
3742
|
-
if self.active_array is not None:
|
3743
|
-
from .PyGui import Wolf2DModel
|
3744
|
-
if isinstance(self.wolfparent,Wolf2DModel):
|
3745
|
-
self.wolfparent.transfer_ic(self.active_vector)
|
3746
|
-
|
3747
4225
|
elif itemlabel == _("Manage banks..."):
|
3748
4226
|
if self.active_vector is None:
|
3749
4227
|
msg = _('Active vector is None\nPlease activate the one desired')
|
@@ -3998,22 +4476,13 @@ class WolfMapViewer(wx.Frame):
|
|
3998
4476
|
|
3999
4477
|
pass
|
4000
4478
|
|
4001
|
-
elif itemlabel == _('
|
4002
|
-
|
4003
|
-
# Check 2D simulation
|
4004
|
-
dlg = wx.FileDialog(self, _("Choose 2D simulation file"), wildcard="all (*.*)|*.*", style=wx.FD_OPEN)
|
4005
|
-
if dlg.ShowModal() == wx.ID_CANCEL:
|
4006
|
-
dlg.Destroy()
|
4007
|
-
return
|
4008
|
-
|
4009
|
-
filename = dlg.GetPath()
|
4010
|
-
dlg.Destroy()
|
4479
|
+
elif itemlabel == _('Create/Open multiblock model'):
|
4011
4480
|
|
4012
|
-
|
4481
|
+
self.create_2D_MB_model()
|
4013
4482
|
|
4014
|
-
|
4015
|
-
sim.verify_files()
|
4483
|
+
elif itemlabel == _('Check headers'):
|
4016
4484
|
|
4485
|
+
self.check_2D_MB_headers()
|
4017
4486
|
|
4018
4487
|
elif itemlabel == _('Set comparison'):
|
4019
4488
|
|
@@ -4417,14 +4886,19 @@ class WolfMapViewer(wx.Frame):
|
|
4417
4886
|
self.Autoscale()
|
4418
4887
|
|
4419
4888
|
def pop_boundary_manager(self, which:BcManager):
|
4420
|
-
"""
|
4889
|
+
""" Pop a boundary condition manager after Destroying """
|
4890
|
+
|
4421
4891
|
idx = self.mybc.index(which)
|
4422
4892
|
if self.active_bc is which:
|
4423
4893
|
self.active_bc = None
|
4424
4894
|
self.mybc.pop(idx)
|
4425
4895
|
|
4896
|
+
self.Refresh()
|
4897
|
+
|
4898
|
+
|
4426
4899
|
def get_boundary_manager(self, which:WolfArray):
|
4427
|
-
"""
|
4900
|
+
""" Get a boundary manager """
|
4901
|
+
|
4428
4902
|
for curbc in self.mybc:
|
4429
4903
|
if curbc.linked_array is which:
|
4430
4904
|
return curbc
|
@@ -4835,6 +5309,7 @@ class WolfMapViewer(wx.Frame):
|
|
4835
5309
|
logging.warning("Warning : the following file is not present here : " + filename)
|
4836
5310
|
return -1
|
4837
5311
|
|
5312
|
+
curtree = None
|
4838
5313
|
if which.lower() == 'array' or which.lower() == 'array_crop':
|
4839
5314
|
curdict = self.myarrays
|
4840
5315
|
curtree = self.myitemsarray
|
@@ -4941,9 +5416,9 @@ class WolfMapViewer(wx.Frame):
|
|
4941
5416
|
newobj.dx = tmpdx
|
4942
5417
|
newobj.dy = tmpdy
|
4943
5418
|
|
4944
|
-
if newobj.
|
4945
|
-
newobj.
|
4946
|
-
newobj.
|
5419
|
+
if newobj.SelectionData is not None:
|
5420
|
+
newobj.SelectionData.dx = tmpdx
|
5421
|
+
newobj.SelectionData.dy = tmpdy
|
4947
5422
|
|
4948
5423
|
if cropini[0][0] != 99999. and cropini[1][0]!=99999.:
|
4949
5424
|
newobj.origx = cropini[0][0]
|
@@ -5370,13 +5845,16 @@ class WolfMapViewer(wx.Frame):
|
|
5370
5845
|
|
5371
5846
|
newobj.idx = id.lower()
|
5372
5847
|
|
5373
|
-
|
5848
|
+
if curtree is not None:
|
5849
|
+
myitem = self.treelist.AppendItem(curtree, id, data=newobj)
|
5374
5850
|
|
5375
|
-
|
5376
|
-
|
5377
|
-
|
5851
|
+
if ToCheck:
|
5852
|
+
self.treelist.CheckItem(myitem)
|
5853
|
+
self.treelist.CheckItem(self.treelist.GetItemParent(myitem))
|
5378
5854
|
|
5379
|
-
|
5855
|
+
newobj.check_plot()
|
5856
|
+
else:
|
5857
|
+
logging.info(f'No tree item for this object {newobj.idx}')
|
5380
5858
|
|
5381
5859
|
# curdict[id.lower()] = newobj
|
5382
5860
|
if filename != '':
|
@@ -5455,6 +5933,7 @@ class WolfMapViewer(wx.Frame):
|
|
5455
5933
|
|
5456
5934
|
def get_list_keys(self, drawing_type:draw_type, checked_state:bool=True):
|
5457
5935
|
""" Create a list of keys of type draw_type """
|
5936
|
+
|
5458
5937
|
if checked_state is None:
|
5459
5938
|
return [curobj.idx for curobj in self._get_list(drawing_type)]
|
5460
5939
|
else:
|
@@ -5462,6 +5941,7 @@ class WolfMapViewer(wx.Frame):
|
|
5462
5941
|
|
5463
5942
|
def get_list_objects(self, drawing_type:draw_type, checked_state:bool=True):
|
5464
5943
|
""" Create a list of objects of type draw_type """
|
5944
|
+
|
5465
5945
|
if checked_state is None:
|
5466
5946
|
return [curobj for curobj in self._get_list(drawing_type)]
|
5467
5947
|
else:
|
@@ -5683,7 +6163,7 @@ class WolfMapViewer(wx.Frame):
|
|
5683
6163
|
|
5684
6164
|
if text == _('Save'):
|
5685
6165
|
if self.selected_object is not None:
|
5686
|
-
if type(self.selected_object)
|
6166
|
+
if issubclass(type(self.selected_object), WolfArray):
|
5687
6167
|
self.selected_object.write_all()
|
5688
6168
|
elif type(self.selected_object) is Zones:
|
5689
6169
|
self.selected_object.saveas()
|
@@ -5721,7 +6201,7 @@ class WolfMapViewer(wx.Frame):
|
|
5721
6201
|
newlab = dlg.GetValue()
|
5722
6202
|
dlg.Destroy()
|
5723
6203
|
|
5724
|
-
if isinstance(self.selected_object, WolfArray) and (not type(self.selected_object) in [WolfArrayMB, WolfArrayMNAP
|
6204
|
+
if isinstance(self.selected_object, WolfArray) and (not type(self.selected_object) in [WolfArrayMB, WolfArrayMNAP]):
|
5725
6205
|
|
5726
6206
|
curtype = self.selected_object.dtype
|
5727
6207
|
|
@@ -5778,7 +6258,7 @@ class WolfMapViewer(wx.Frame):
|
|
5778
6258
|
# save objet to file, choosing the file name
|
5779
6259
|
|
5780
6260
|
if self.selected_object is not None:
|
5781
|
-
if type(self.selected_object)
|
6261
|
+
if issubclass(type(self.selected_object), WolfArray):
|
5782
6262
|
filterArray = "bin (*.bin)|*.bin|Geotif (*.tif)|*.tif|Numpy (*.npy)|*.npy|all (*.*)|*.*"
|
5783
6263
|
fdlg = wx.FileDialog(self, "Choose file name for Array : " + self.selected_object.idx, wildcard=filterArray,
|
5784
6264
|
style=wx.FD_SAVE)
|
@@ -5820,7 +6300,7 @@ class WolfMapViewer(wx.Frame):
|
|
5820
6300
|
elif text == _('Properties'):
|
5821
6301
|
|
5822
6302
|
myobj = self.selected_object
|
5823
|
-
if type(myobj) in [WolfArray,
|
6303
|
+
if type(myobj) in [WolfArray, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system, Picc_data, Cadaster_data, hydrometry_wolfgui]:
|
5824
6304
|
myobj.show_properties()
|
5825
6305
|
|
5826
6306
|
elif text == _('Boundary conditions'):
|
@@ -5828,6 +6308,41 @@ class WolfMapViewer(wx.Frame):
|
|
5828
6308
|
if bc is not None:
|
5829
6309
|
bc.Show()
|
5830
6310
|
|
6311
|
+
elif _('Convert to mono-block') in text:
|
6312
|
+
|
6313
|
+
if isinstance(self.selected_object, WolfArrayMB):
|
6314
|
+
mono = self.selected_object.as_WolfArray()
|
6315
|
+
self.add_object('array', newobj=mono, id=self.selected_object.idx + '_mono')
|
6316
|
+
logging.info(_('Mono-block created and added to the viewer'))
|
6317
|
+
|
6318
|
+
elif isinstance(self.selected_object, Wolfresults_2D):
|
6319
|
+
mono = self.selected_object.as_WolfArray()
|
6320
|
+
|
6321
|
+
if isinstance(mono, WolfArrayMB):
|
6322
|
+
mono = mono.as_WolfArray()
|
6323
|
+
|
6324
|
+
self.add_object('array', newobj=mono, id=self.selected_object.idx + '_mono')
|
6325
|
+
logging.info(_('Mono-block created and added to the viewer'))
|
6326
|
+
|
6327
|
+
else:
|
6328
|
+
logging.warning(_('Convert to mono-blocks not yet implemented for this type of object'))
|
6329
|
+
|
6330
|
+
elif _('Convert to multi-blocks') in text:
|
6331
|
+
|
6332
|
+
if isinstance(self.selected_object, Wolfresults_2D):
|
6333
|
+
mb = self.selected_object.as_WolfArray(force_mb=True)
|
6334
|
+
|
6335
|
+
if isinstance(mb, WolfArrayMB):
|
6336
|
+
logging.info(_('Multi-blocks created and added to the viewer'))
|
6337
|
+
|
6338
|
+
elif isinstance(mb, WolfArray):
|
6339
|
+
logging.warning(_('Mono-blocks created and added to the viewer -- Instead of multi-blocks as only one block was found'))
|
6340
|
+
|
6341
|
+
self.add_object('array', newobj=mb, id=self.selected_object.idx + '_mb')
|
6342
|
+
else:
|
6343
|
+
logging.warning(_('Convert to multi-blocks not yet implemented for this type of object'))
|
6344
|
+
|
6345
|
+
|
5831
6346
|
def OnClose(self, event):
|
5832
6347
|
nb = 0
|
5833
6348
|
if self.linked:
|
@@ -5900,7 +6415,7 @@ class WolfMapViewer(wx.Frame):
|
|
5900
6415
|
wx.LogMessage(str(ex))
|
5901
6416
|
wx.MessageBox(str(ex), _("Error"), wx.ICON_ERROR)
|
5902
6417
|
else:
|
5903
|
-
if type(curobj)
|
6418
|
+
if issubclass(type(curobj), WolfArray):
|
5904
6419
|
curobj.uncheck_plot(not ctrl,ctrl)
|
5905
6420
|
else:
|
5906
6421
|
curobj.uncheck_plot()
|
@@ -6176,13 +6691,13 @@ class WolfMapViewer(wx.Frame):
|
|
6176
6691
|
|
6177
6692
|
if 'results' in self.action:
|
6178
6693
|
curobj:Wolfresults_2D
|
6179
|
-
curobj = self.active_res2d.
|
6694
|
+
curobj = self.active_res2d.SelectionData
|
6180
6695
|
else:
|
6181
6696
|
curobj: WolfArray
|
6182
|
-
curobj = self.active_array.
|
6697
|
+
curobj = self.active_array.SelectionData
|
6183
6698
|
|
6184
6699
|
curobj.add_node_to_selection(x, y)
|
6185
|
-
curobj.
|
6700
|
+
curobj.update_nb_nodes_selection()
|
6186
6701
|
self.Paint()
|
6187
6702
|
|
6188
6703
|
elif 'select by tmp vector' in self.action or 'select by vector' in self.action:
|
@@ -6295,6 +6810,7 @@ class WolfMapViewer(wx.Frame):
|
|
6295
6810
|
altdown = e.AltDown()
|
6296
6811
|
ctrldown = e.ControlDown()
|
6297
6812
|
shiftdown = e.ShiftDown()
|
6813
|
+
spacedown = wx.GetKeyState(wx.WXK_SPACE)
|
6298
6814
|
|
6299
6815
|
if self.action == 'dynamic parallel' and shiftdown and not ctrldown:
|
6300
6816
|
self.dynapar_dist *= (1 - .1 * (r / max(d, 1)))
|
@@ -6324,9 +6840,34 @@ class WolfMapViewer(wx.Frame):
|
|
6324
6840
|
self.Refresh()
|
6325
6841
|
return
|
6326
6842
|
|
6843
|
+
# Allow the user to zoom onto the pixel where the
|
6844
|
+
# mouse cursor is
|
6845
|
+
|
6846
|
+
# Step1: move the map so that the pixem under the mouse cursor
|
6847
|
+
# ends up right in the middle of the screen (this move is
|
6848
|
+
# not visible from the end user point of view, it's just
|
6849
|
+
# here to make computation seasier)
|
6850
|
+
if spacedown:
|
6851
|
+
self.center_view_on( *self.getXY( e.GetPosition()))
|
6852
|
+
|
6853
|
+
# Zoom/dezoom, center pf the tranfromation is the center of the screen
|
6327
6854
|
self.width = self.width * (1 - .1 * (r / max(d, 1)))
|
6328
6855
|
self.height = self.height * (1 - .1 * (r / max(d, 1)))
|
6329
6856
|
|
6857
|
+
if spacedown:
|
6858
|
+
self.updatescalefactors() # not base on mousex
|
6859
|
+
|
6860
|
+
# Translate back the pixel at the center of the screen to where the
|
6861
|
+
# mouse cursor is. For that we measure the delta in screen coordinates
|
6862
|
+
# and transform it to map space coordinates.
|
6863
|
+
x_mid, y_mid = self.canvas.GetSize()
|
6864
|
+
x_mid, y_mid = self.getXY((0.5*x_mid, y_mid*0.5))
|
6865
|
+
x, y = self.getXY( e.GetPosition())
|
6866
|
+
dx, dy = x_mid - x, y_mid - y
|
6867
|
+
self.mousex += dx
|
6868
|
+
self.mousey += dy
|
6869
|
+
|
6870
|
+
# will translate and rescale the map view so that it fits the window.
|
6330
6871
|
self.setbounds()
|
6331
6872
|
|
6332
6873
|
def OnRDClick(self, e):
|
@@ -6414,7 +6955,7 @@ class WolfMapViewer(wx.Frame):
|
|
6414
6955
|
elif type(myobj) == Tiles:
|
6415
6956
|
self.active_tile= myobj
|
6416
6957
|
|
6417
|
-
elif type(myobj)
|
6958
|
+
elif issubclass(type(myobj), WolfArray):
|
6418
6959
|
if ctrl:
|
6419
6960
|
myobj.show_properties()
|
6420
6961
|
# myobj.myops.SetTitle(_('Operations on array: ')+myobj.idx)
|
@@ -6422,8 +6963,22 @@ class WolfMapViewer(wx.Frame):
|
|
6422
6963
|
|
6423
6964
|
logging.info(_('Activating array : ' + nameitem))
|
6424
6965
|
self.active_array = myobj
|
6966
|
+
|
6967
|
+
# If BC maneger is attached to the array, we activate it
|
6425
6968
|
self._set_active_bc()
|
6426
6969
|
|
6970
|
+
#Print info in the status bar
|
6971
|
+
txt = 'Dx : {:4f} ; Dy : {:4f}'.format(self.active_array.dx, self.active_array.dy)
|
6972
|
+
txt += ' ; Xmin : {:4f} ; Ymin : {:4f}'.format(self.active_array.xmin, self.active_array.ymin)
|
6973
|
+
txt += ' ; Xmax : {:4f} ; Ymax : {:4f}'.format(self.active_array.xmax, self.active_array.ymax)
|
6974
|
+
txt += ' ; Nx : {:d} ; Ny : {:d}'.format(self.active_array.nbx, self.active_array.nby)
|
6975
|
+
|
6976
|
+
if self.active_array.nb_blocks > 0:
|
6977
|
+
txt += ' ; Nb blocks : {:d}'.format(self.active_array.nb_blocks)
|
6978
|
+
|
6979
|
+
self.StatusBar.SetStatusText(txt)
|
6980
|
+
|
6981
|
+
|
6427
6982
|
elif type(myobj) in [WolfViews]:
|
6428
6983
|
logging.info(_('Activating view : ' + nameitem))
|
6429
6984
|
self.active_view = myobj
|
@@ -6874,9 +7429,9 @@ class WolfMapViewer(wx.Frame):
|
|
6874
7429
|
|
6875
7430
|
if inside_under:
|
6876
7431
|
self.active_vector.close_force()
|
6877
|
-
self.active_array.
|
7432
|
+
self.active_array.SelectionData.select_insidepoly(self.active_vector)
|
6878
7433
|
else:
|
6879
|
-
self.active_array.
|
7434
|
+
self.active_array.SelectionData.select_underpoly(self.active_vector)
|
6880
7435
|
|
6881
7436
|
if 'tmp' in locaction:
|
6882
7437
|
# we must reset the temporary vector
|
@@ -6947,7 +7502,7 @@ class WolfMapViewer(wx.Frame):
|
|
6947
7502
|
# Le test not(self in self.linkedList) permet de ne pas créer le liste OpenGL en cas de multi-viewers
|
6948
7503
|
# car une liste OpenGL ne sera pas tracée sur les autres fenêtres
|
6949
7504
|
# C'est donc plus lent mais plus sûr pour que l'affichage dynamique soit correct
|
6950
|
-
self.active_vector.parentzone.plot(prep = not(self in self.linkedList))
|
7505
|
+
self.active_vector.parentzone.plot(prep = self.linkedList is None or not(self in self.linkedList))
|
6951
7506
|
|
6952
7507
|
elif self.action == 'modify vertices':
|
6953
7508
|
|
@@ -6958,7 +7513,7 @@ class WolfMapViewer(wx.Frame):
|
|
6958
7513
|
# Le test not(self in self.linkedList) permet de ne pas créer le liste OpenGL en cas de multi-viewers
|
6959
7514
|
# car une liste OpenGL ne sera pas tracée sur les autres fenêtres
|
6960
7515
|
# C'est donc plus lent mais plus sûr pour que l'affichage dynamique soit correct
|
6961
|
-
self.active_vector.parentzone.plot(prep = not(self in self.linkedList))
|
7516
|
+
self.active_vector.parentzone.plot(prep = self.linkedList is None or not(self in self.linkedList))
|
6962
7517
|
self.active_zones.find_minmax(True)
|
6963
7518
|
|
6964
7519
|
self.active_vertex = None
|
@@ -6970,7 +7525,7 @@ class WolfMapViewer(wx.Frame):
|
|
6970
7525
|
# Le test not(self in self.linkedList) permet de ne pas créer le liste OpenGL en cas de multi-viewers
|
6971
7526
|
# car une liste OpenGL ne sera pas tracée sur les autres fenêtres
|
6972
7527
|
# C'est donc plus lent mais plus sûr pour que l'affichage dynamique soit correct
|
6973
|
-
self.active_vector.parentzone.plot(prep = not(self in self.linkedList))
|
7528
|
+
self.active_vector.parentzone.plot(prep = self.linkedList is None or not(self in self.linkedList))
|
6974
7529
|
self.active_zones.find_minmax(True)
|
6975
7530
|
|
6976
7531
|
self.active_vertex = None
|
@@ -6986,7 +7541,7 @@ class WolfMapViewer(wx.Frame):
|
|
6986
7541
|
# Le test not(self in self.linkedList) permet de ne pas créer le liste OpenGL en cas de multi-viewers
|
6987
7542
|
# car une liste OpenGL ne sera pas tracée sur les autres fenêtres
|
6988
7543
|
# C'est donc plus lent mais plus sûr pour que l'affichage dynamique soit correct
|
6989
|
-
self.active_vector.parentzone.plot(prep = not(self in self.linkedList))
|
7544
|
+
self.active_vector.parentzone.plot(prep = self.linkedList is None or not(self in self.linkedList))
|
6990
7545
|
|
6991
7546
|
self.active_vertex = None
|
6992
7547
|
|
@@ -7363,7 +7918,7 @@ class WolfMapViewer(wx.Frame):
|
|
7363
7918
|
self.copyfrom = self.active_array
|
7364
7919
|
self.mimicme_copyfrom() # force le recopiage de copyfrom dans les autres matrices liées
|
7365
7920
|
|
7366
|
-
self.active_array.
|
7921
|
+
self.active_array.SelectionData.copy_to_clipboard()
|
7367
7922
|
|
7368
7923
|
elif key == ord('C') and ctrldown and altdown:
|
7369
7924
|
if self.active_array is None:
|
@@ -7378,7 +7933,7 @@ class WolfMapViewer(wx.Frame):
|
|
7378
7933
|
self.copyfrom = self.active_array
|
7379
7934
|
self.mimicme_copyfrom() # force le recopiage de copyfrom dans les autres matrices liées
|
7380
7935
|
|
7381
|
-
self.active_array.
|
7936
|
+
self.active_array.SelectionData.copy_to_clipboard(typestr='script')
|
7382
7937
|
|
7383
7938
|
elif key == ord('V') and ctrldown:
|
7384
7939
|
# CTRL+V
|
@@ -7406,16 +7961,16 @@ class WolfMapViewer(wx.Frame):
|
|
7406
7961
|
logging.warning(_('No selection to be pasted !'))
|
7407
7962
|
return
|
7408
7963
|
|
7409
|
-
cursel = fromarray.
|
7964
|
+
cursel = fromarray.SelectionData.myselection
|
7410
7965
|
|
7411
7966
|
if e.AltDown():
|
7412
7967
|
logging.info(_('Paste selection position'))
|
7413
7968
|
|
7414
7969
|
if cursel == 'all':
|
7415
|
-
self.active_array.
|
7970
|
+
self.active_array.SelectionData.OnAllSelect(0)
|
7416
7971
|
elif len(cursel) > 0:
|
7417
|
-
self.active_array.
|
7418
|
-
self.active_array.
|
7972
|
+
self.active_array.SelectionData.myselection = cursel.copy()
|
7973
|
+
self.active_array.SelectionData.update_nb_nodes_selection()
|
7419
7974
|
|
7420
7975
|
else:
|
7421
7976
|
logging.info(_('Copy selection values'))
|
@@ -7423,7 +7978,7 @@ class WolfMapViewer(wx.Frame):
|
|
7423
7978
|
self.active_array.paste_all(fromarray)
|
7424
7979
|
|
7425
7980
|
elif len(cursel) > 0:
|
7426
|
-
z = fromarray.
|
7981
|
+
z = fromarray.SelectionData.get_values_sel()
|
7427
7982
|
self.active_array.set_values_sel(cursel, z)
|
7428
7983
|
|
7429
7984
|
self.Refresh()
|
@@ -7447,6 +8002,8 @@ class WolfMapViewer(wx.Frame):
|
|
7447
8002
|
self.active_vertex = None
|
7448
8003
|
self.active_cloud = None
|
7449
8004
|
|
8005
|
+
self.StatusBar.SetStatusText(_('Esc pressed - No more action in progress'))
|
8006
|
+
|
7450
8007
|
elif key == ord('C'):
|
7451
8008
|
|
7452
8009
|
self.copy_canvasogl(mpl = False)
|
@@ -7492,7 +8049,7 @@ class WolfMapViewer(wx.Frame):
|
|
7492
8049
|
if idx > 8:
|
7493
8050
|
idx -= 9
|
7494
8051
|
|
7495
|
-
self.active_array.
|
8052
|
+
self.active_array.SelectionData.move_selectionto(str(idx+1), colors[idx])
|
7496
8053
|
|
7497
8054
|
elif key == wx.WXK_F1:
|
7498
8055
|
self.read_last_result()
|
@@ -7526,8 +8083,8 @@ class WolfMapViewer(wx.Frame):
|
|
7526
8083
|
elif key == wx.WXK_F9:
|
7527
8084
|
|
7528
8085
|
if self.active_array is not None:
|
7529
|
-
if self.active_array.
|
7530
|
-
self.active_array.
|
8086
|
+
if self.active_array.SelectionData is not None:
|
8087
|
+
self.active_array.SelectionData.myselection = 'all'
|
7531
8088
|
logging.info(_('Selecting all nodes in the active array !'))
|
7532
8089
|
else:
|
7533
8090
|
logging.warning(_('No selection manager for this array !'))
|
@@ -7593,34 +8150,69 @@ class WolfMapViewer(wx.Frame):
|
|
7593
8150
|
|
7594
8151
|
def paste_values(self,fromarray:WolfArray):
|
7595
8152
|
logging.info(_('Copy selection values'))
|
7596
|
-
cursel = fromarray.
|
8153
|
+
cursel = fromarray.SelectionData.myselection
|
7597
8154
|
if cursel == 'all':
|
7598
8155
|
self.active_array.paste_all(fromarray)
|
7599
8156
|
elif len(cursel) > 0:
|
7600
|
-
z = fromarray.
|
8157
|
+
z = fromarray.SelectionData.get_values_sel()
|
7601
8158
|
self.active_array.set_values_sel(cursel, z)
|
7602
8159
|
|
7603
8160
|
def paste_selxy(self,fromarray:WolfArray):
|
7604
8161
|
logging.info(_('Paste selection position'))
|
7605
|
-
cursel = fromarray.
|
8162
|
+
cursel = fromarray.SelectionData.myselection
|
7606
8163
|
if cursel == 'all':
|
7607
|
-
self.active_array.
|
8164
|
+
self.active_array.SelectionData.OnAllSelect(0)
|
7608
8165
|
elif len(cursel) > 0:
|
7609
|
-
self.active_array.
|
7610
|
-
self.active_array.
|
8166
|
+
self.active_array.SelectionData.myselection = cursel.copy()
|
8167
|
+
self.active_array.SelectionData.update_nb_nodes_selection()
|
7611
8168
|
|
7612
8169
|
def OntreeRight(self, e: wx.MouseEvent):
|
7613
8170
|
""" Gestion du menu contextuel sur l'arbre des objets """
|
7614
8171
|
|
7615
8172
|
if self.selected_object is not None:
|
8173
|
+
|
8174
|
+
# On va nettoyer le menu contextuel car certaines entrées ne sont
|
8175
|
+
# pas nécessairement pertinentes
|
8176
|
+
|
8177
|
+
# Chaînes à supprimer
|
8178
|
+
tracks=[]
|
8179
|
+
tracks.append(_('Boundary conditions'))
|
8180
|
+
tracks.append(_('Convert to mono-block'))
|
8181
|
+
tracks.append(_('Convert to mono-block (result)'))
|
8182
|
+
tracks.append(_('Convert to multi-blocks (result)'))
|
8183
|
+
|
8184
|
+
# Récupération des items du menu contextuel
|
8185
|
+
menuitems = self.popupmenu.GetMenuItems()
|
8186
|
+
text = [cur.GetItemLabelText() for cur in menuitems]
|
8187
|
+
|
8188
|
+
# Liste des indices à supprimer
|
8189
|
+
# Pas possible de supprimer à la volée car cela modifie la liste
|
8190
|
+
to_delete = []
|
8191
|
+
for track in tracks:
|
8192
|
+
if track in text:
|
8193
|
+
to_delete.append(text.index(track))
|
8194
|
+
|
8195
|
+
# Suppression des items
|
8196
|
+
if len(to_delete) > 0:
|
8197
|
+
# Suppression en ordre décroissant pour ne pas décaler les indices
|
8198
|
+
to_delete.sort(reverse=True)
|
8199
|
+
for idx in to_delete:
|
8200
|
+
self.popupmenu.Remove(menuitems[idx])
|
8201
|
+
|
8202
|
+
# Add specific menu items for WolfArray
|
7616
8203
|
if isinstance(self.selected_object, WolfArray):
|
7617
8204
|
bc = self.get_boundary_manager(self.selected_object)
|
7618
8205
|
if bc is not None:
|
7619
8206
|
self.popupmenu.Append(wx.ID_ANY, _('Boundary conditions'), _('Boundary conditions'))
|
7620
|
-
|
7621
|
-
|
7622
|
-
|
7623
|
-
|
8207
|
+
|
8208
|
+
# Add specific menu items for WolfArrayMB
|
8209
|
+
if isinstance(self.selected_object, WolfArrayMB):
|
8210
|
+
self.popupmenu.Append(wx.ID_ANY, _('Convert to mono-block'), _('Convert to mono-block'))
|
8211
|
+
|
8212
|
+
# Add specific menu items for Wolfresults_2D
|
8213
|
+
if isinstance(self.selected_object, Wolfresults_2D):
|
8214
|
+
self.popupmenu.Append(wx.ID_ANY, _('Convert to mono-block (result)'), _('Convert to mono-block'))
|
8215
|
+
self.popupmenu.Append(wx.ID_ANY, _('Convert to multi-blocks (result)'), _('Convert to multi-blocks'))
|
7624
8216
|
|
7625
8217
|
self.treelist.PopupMenu(self.popupmenu)
|
7626
8218
|
|
@@ -7654,10 +8246,13 @@ class WolfMapViewer(wx.Frame):
|
|
7654
8246
|
curobj.plotting = True
|
7655
8247
|
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.)
|
7656
8248
|
curobj.plotting = False
|
7657
|
-
except:
|
8249
|
+
except Exception as ex:
|
7658
8250
|
curobj.plotting = False
|
7659
8251
|
logging.error(_('Error while plotting objects of type {}').format(drawing_type.name))
|
7660
8252
|
|
8253
|
+
traceback.print_exc()
|
8254
|
+
logging.error(ex)
|
8255
|
+
|
7661
8256
|
def get_MVP_Viewport_matrix(self):
|
7662
8257
|
""" Get the modelview projection matrix """
|
7663
8258
|
|
@@ -7990,7 +8585,7 @@ class WolfMapViewer(wx.Frame):
|
|
7990
8585
|
logging.warning('Bad id')
|
7991
8586
|
return
|
7992
8587
|
|
7993
|
-
if type(curobj)
|
8588
|
+
if issubclass(type(curobj), WolfArray):
|
7994
8589
|
curobj.uncheck_plot(unload, forceresetOGL, askquestion)
|
7995
8590
|
else:
|
7996
8591
|
curobj.uncheck_plot()
|