--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>704</width>
+ <height>459</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Change Coordinates</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QCheckBox" name="cb_changeCoordSystem">
+ <property name="text">
+ <string>Change coordinates system</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBoxIn">
+ <property name="title">
+ <string>Input</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="lb_medFileIn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>MED file</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="le_medFileIn"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="pb_medFileIn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lb_offsetXin">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Offset X</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="dsb_offsetXin">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>X coordinate of origin of input mesh</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="minimum">
+ <double>-10000000.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>10000000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="lb_offsetYin">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Offset Y</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="dsb_offsetYin">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Y coordinate of origin of input mesh</string>
+ </property>
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="minimum">
+ <double>-10000000.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>10000000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10000.000000000000000</double>
+ </property>
+ <property name="stepType">
+ <enum>QAbstractSpinBox::DefaultStepType</enum>
+ </property>
+ <property name="value">
+ <double>0.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Coord System</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cmb_systemIn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBoxOut">
+ <property name="title">
+ <string>Output</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="lb_medFileOut">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>MED File</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="le_medFileOut">
+ <property name="statusTip">
+ <string>directory to store shapefiles and output mesh file if kept</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="pb_medFileOut">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lb_offsetXout">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Offset X</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="dsb_offsetXout">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>X coordinate of origin of input mesh</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="minimum">
+ <double>-10000000.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>10000000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="lb_offsetYout">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Offset Y</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="dsb_offsetYout">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Y coordinate of origin of input mesh</string>
+ </property>
+ <property name="decimals">
+ <number>0</number>
+ </property>
+ <property name="minimum">
+ <double>-10000000.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>10000000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10000.000000000000000</double>
+ </property>
+ <property name="stepType">
+ <enum>QAbstractSpinBox::DefaultStepType</enum>
+ </property>
+ <property name="value">
+ <double>0.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Coord System</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cmb_systemOut"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>66</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QDialogButtonBox" name="pb_ok">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pb_help">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Help</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>cb_changeCoordSystem</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cmb_systemIn</receiver>
+ <slot>setVisible(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>348</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>348</x>
+ <y>181</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>cb_changeCoordSystem</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>cmb_systemOut</receiver>
+ <slot>setVisible(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>348</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>348</x>
+ <y>355</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+# Copyright (C) 2012-2013 EDF
+#
+# This file is part of SALOME HYDRO module.
+#
+# SALOME HYDRO module is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SALOME HYDRO module is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+from PyQt5 import uic
+
+import pyproj
+from pyproj import CRS
+
+from salome.hydrotools.changeCoords import changeCoords
+
+import sysconfig
+pythonVersion = 'python' + sysconfig.get_python_version()
+hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', pythonVersion, 'site-packages', 'salome', 'salome', 'hydro')
+
+class changeCoordsDialog(QDialog):
+ """
+ """
+
+ def __init__(self, parent = None, modal = 0):
+ QDialog.__init__(self, parent)
+ uic.loadUi(os.path.join(hydro_solver_root, 'changeCoords.ui'), self )
+
+ # Connections
+ self.pb_medFileIn.clicked.connect(self.on_med_file_in_browse)
+ self.pb_medFileOut.clicked.connect(self.on_med_file_out_browse)
+ self.pb_help.clicked.connect(self.on_help)
+ self.pb_ok.accepted.connect(self.on_accept)
+ self.pb_ok.rejected.connect(self.on_reject)
+ self.medFileIn = None
+ self.medFileOut = None
+ EPSG_list = (2154, 27561, 27562, 27563, 27564, 27571, 27572, 27573, 27574 )
+ for epsg in EPSG_list:
+ crs_code = CRS.from_epsg(epsg)
+ codeName = str(epsg) + ' ' + crs_code.name
+ self.cmb_systemIn.addItem(codeName)
+ self.cmb_systemOut.addItem(codeName)
+ self.cb_changeCoordSystem.setChecked(True)
+ self.cb_changeCoordSystem.setChecked(False)
+
+ def on_med_file_in_browse(self):
+ """
+ Select input MED file
+ """
+ print("on_med_file_in_browse")
+ self.medFileIn, filt = QFileDialog.getOpenFileName(self, self.tr("Input MED file"), "", self.tr("MED files (*.med)"))
+ print(self.medFileIn)
+ if not self.medFileIn:
+ return
+ self.le_medFileIn.setText(self.medFileIn)
+ a = os.path.splitext(self.medFileIn)
+ self.medFileOut = a[0] + '_coo' + a[1]
+ self.le_medFileOut.setText(self.medFileOut)
+
+ def on_med_file_out_browse(self):
+ """
+ Select output MED file
+ """
+ print("on_med_file_out_browse")
+ self.medFileOut, filt = QFileDialog.getSaveFileName(self, self.tr("Output MED file"), "", self.tr("MED files (*.med)"))
+ print(self.medFileOut)
+ if not self.medFileOut:
+ return
+ self.le_medFileOut.setText(self.medFileOut)
+
+ def on_help(self):
+ """
+ display a help message
+ """
+ msg = """
+ <h2>Change mesh coordinates dialog</h2>
+
+ This dialog is used to change the nodes coordinates in a mesh. It is used either for a simple translation, a change of coordinates system
+ (for instance from Lambert II to Lambert-93), or a combination.
+ <br><br>
+ The modified mesh is saved in a new file.
+ <br>
+ If there is a change of coordinates system, the input mesh is first translated, when it uses a local origin.
+ After the change of coordinates system, the output mesh can be translated (new local origin).
+ <br>
+ When there is only a simple translation, the operation is: Xout = Xin + offsetXin -offsetXout, Yout = Yin + offsetYin -offsetYout.
+ <br><br>
+ Below is the description of the dialog controls.
+
+ <h3>Change coordinates system</h3>
+ If this checkbox is checked, the output mesh will be removed after calculation of the shapes.
+
+ <h3>Input MED file</h3>
+ This field allows the selection of a med file (via the standard file open dialog).
+ The filling of this field is mandatory.
+
+ <h3>Input offsetX, offsetY</h3>
+ These fields are used to set the Origin of the local coordinates system of the input mesh, if any.
+
+ <h3>Input Coord System</h3>
+ This combo box is use to select the coordinate system of the input mesh.
+
+ <h3>Output MED file</h3>
+ This field allows the definition of a med file (via the standard file save dialog).
+ The filling of this field is mandatory.
+
+ <h3>Output offsetX, offsetY</h3>
+ These fields are used to set the Origin of the local coordinates system of the output mesh, if any.
+
+ <h3>Output Coord System</h3>
+ This combo box is use to select the coordinate system of the output mesh.
+ """
+ QMessageBox.about(self, self.tr("About mesh edges to shapes dialog"), msg);
+
+
+ def on_accept(self):
+ print("accept")
+ #TODO check medfile in and out not empty
+ #TODO preset for medFileOut
+ medFileIn = self.le_medFileIn.text()
+ medFileOut = self.le_medFileOut.text()
+ offsetXin = self.dsb_offsetXin.value()
+ offsetYin = self.dsb_offsetYin.value()
+ offsetXout = self.dsb_offsetXout.value()
+ offsetYout = self.dsb_offsetYout.value()
+ isChangeCoordSystem = self.cb_changeCoordSystem.isChecked()
+ epsgIn = 2154
+ epsgOut = 2154
+ if isChangeCoordSystem:
+ epsgIn = int(self.cmb_systemIn.currentText().split()[0])
+ epsgOut = int(self.cmb_systemOut.currentText().split()[0])
+ print(medFileIn)
+ print(medFileOut)
+ print(isChangeCoordSystem)
+ print(offsetXin, offsetYin)
+ print(offsetXout, offsetYout)
+ print(epsgIn, epsgOut)
+ if not os.path.isfile(medFileIn):
+ msgBox = QMessageBox()
+ msgBox.setText( "Input MED file does not exist" )
+ msgBox.exec_()
+ return
+ dir = os.path.dirname(medFileOut)
+ base = os.path.basename(medFileOut)
+ ext = os.path.splitext(medFileOut)[1]
+ if not os.path.isdir(dir) or (base == "") or (ext.lower() != ".med"):
+ msgBox = QMessageBox()
+ msgBox.setText( "Output MED file is not a valid path" )
+ msgBox.exec_()
+ return
+ self.accept()
+ changeCoords(medFileIn, medFileOut, epsgIn, epsgOut, offsetXin, offsetYin, offsetXout, offsetYout)
+
+ def on_reject(self):
+ print("reject")
+ self.reject()
+
+
+def execDialog(context):
+ print("execDialog")
+ # get context study, salomeGui
+ study = context.study
+ sg = context.sg
+ dlg = changeCoordsDialog()
+ dlg.exec_()