OASYS2-XRayServer 1.0.0__tar.gz
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.
- oasys2_xrayserver-1.0.0/LICENSE +28 -0
- oasys2_xrayserver-1.0.0/MANIFEST.in +6 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/PKG-INFO +35 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/SOURCES.txt +32 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/dependency_links.txt +1 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/entry_points.txt +5 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/not-zip-safe +1 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/requires.txt +3 -0
- oasys2_xrayserver-1.0.0/OASYS2_XRayServer.egg-info/top_level.txt +1 -0
- oasys2_xrayserver-1.0.0/PKG-INFO +35 -0
- oasys2_xrayserver-1.0.0/README.md +3 -0
- oasys2_xrayserver-1.0.0/orangecontrib/__init__.py +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/__init__.py +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/util/__init__.py +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/util/list_utility.py +34 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/util/xrayserver_util.py +128 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/__init__.py +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/gui/__init__.py +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/gui/ow_xrayserver_widget.py +153 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/__init__.py +20 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/gidsl.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/list.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/no_standing_waves_result.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/tersl.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/x0h.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/x0p.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/icons/xrayserver.png +0 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/ow_gid_sl.py +939 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/ow_ter_sl.py +661 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/ow_x0h.py +427 -0
- oasys2_xrayserver-1.0.0/orangecontrib/xrayserver/widgets/xrayserver/ow_x0p.py +249 -0
- oasys2_xrayserver-1.0.0/pyproject.toml +3 -0
- oasys2_xrayserver-1.0.0/setup.cfg +4 -0
- oasys2_xrayserver-1.0.0/setup.py +81 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Organization managing the OASYS project
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OASYS2-XRayServer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: X-Ray Server: Sergey Stepanov's X-Ray Server on OASYS 2
|
|
5
|
+
Home-page: https://github.com/oasys-kit/OASYS2-XRayServer
|
|
6
|
+
Download-URL: https://github.com/oasys-kit/OASYS2-XRayServer
|
|
7
|
+
Author: Luca Rebuffi
|
|
8
|
+
Author-email: lrebuffi@anl.gov
|
|
9
|
+
License: GPLv3
|
|
10
|
+
Keywords: X-ray optics,simulator,oasys2
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Environment :: Plugins
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: oasys2>=0.0.1
|
|
19
|
+
Requires-Dist: PyQtWebEngine>=5.15.7
|
|
20
|
+
Requires-Dist: dabax
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: download-url
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: summary
|
|
32
|
+
|
|
33
|
+
#XRayServer
|
|
34
|
+
|
|
35
|
+
This is the project for XRayServer (Sergey Stepanov's X-Ray Server) under OASYS 2
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
OASYS2_XRayServer.egg-info/PKG-INFO
|
|
7
|
+
OASYS2_XRayServer.egg-info/SOURCES.txt
|
|
8
|
+
OASYS2_XRayServer.egg-info/dependency_links.txt
|
|
9
|
+
OASYS2_XRayServer.egg-info/entry_points.txt
|
|
10
|
+
OASYS2_XRayServer.egg-info/not-zip-safe
|
|
11
|
+
OASYS2_XRayServer.egg-info/requires.txt
|
|
12
|
+
OASYS2_XRayServer.egg-info/top_level.txt
|
|
13
|
+
orangecontrib/__init__.py
|
|
14
|
+
orangecontrib/xrayserver/__init__.py
|
|
15
|
+
orangecontrib/xrayserver/util/__init__.py
|
|
16
|
+
orangecontrib/xrayserver/util/list_utility.py
|
|
17
|
+
orangecontrib/xrayserver/util/xrayserver_util.py
|
|
18
|
+
orangecontrib/xrayserver/widgets/__init__.py
|
|
19
|
+
orangecontrib/xrayserver/widgets/gui/__init__.py
|
|
20
|
+
orangecontrib/xrayserver/widgets/gui/ow_xrayserver_widget.py
|
|
21
|
+
orangecontrib/xrayserver/widgets/xrayserver/__init__.py
|
|
22
|
+
orangecontrib/xrayserver/widgets/xrayserver/ow_gid_sl.py
|
|
23
|
+
orangecontrib/xrayserver/widgets/xrayserver/ow_ter_sl.py
|
|
24
|
+
orangecontrib/xrayserver/widgets/xrayserver/ow_x0h.py
|
|
25
|
+
orangecontrib/xrayserver/widgets/xrayserver/ow_x0p.py
|
|
26
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/gidsl.png
|
|
27
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/list.png
|
|
28
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/no_standing_waves_result.png
|
|
29
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/tersl.png
|
|
30
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/x0h.png
|
|
31
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/x0p.png
|
|
32
|
+
orangecontrib/xrayserver/widgets/xrayserver/icons/xrayserver.png
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
orangecontrib
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OASYS2-XRayServer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: X-Ray Server: Sergey Stepanov's X-Ray Server on OASYS 2
|
|
5
|
+
Home-page: https://github.com/oasys-kit/OASYS2-XRayServer
|
|
6
|
+
Download-URL: https://github.com/oasys-kit/OASYS2-XRayServer
|
|
7
|
+
Author: Luca Rebuffi
|
|
8
|
+
Author-email: lrebuffi@anl.gov
|
|
9
|
+
License: GPLv3
|
|
10
|
+
Keywords: X-ray optics,simulator,oasys2
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Environment :: Plugins
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: oasys2>=0.0.1
|
|
19
|
+
Requires-Dist: PyQtWebEngine>=5.15.7
|
|
20
|
+
Requires-Dist: dabax
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: download-url
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: summary
|
|
32
|
+
|
|
33
|
+
#XRayServer
|
|
34
|
+
|
|
35
|
+
This is the project for XRayServer (Sergey Stepanov's X-Ray Server) under OASYS 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from orangecontrib.xrayserver.util.xrayserver_util import HttpManager
|
|
2
|
+
|
|
3
|
+
APPLICATION = "/cgi/www_dbli.exe"
|
|
4
|
+
|
|
5
|
+
class ListUtility:
|
|
6
|
+
@classmethod
|
|
7
|
+
def get_list(cls, x0hdb=""):
|
|
8
|
+
|
|
9
|
+
parameters = {}
|
|
10
|
+
parameters.update({"x0hdb" : x0hdb})
|
|
11
|
+
parameters.update({"textout" : "1" })
|
|
12
|
+
parameters.update({"namesonly" : "1"})
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
response = HttpManager.send_xray_server_request_GET(APPLICATION, parameters)
|
|
16
|
+
|
|
17
|
+
list = response.split('\n')
|
|
18
|
+
return [x.strip() for x in list[1:len(list)-1]]
|
|
19
|
+
|
|
20
|
+
except Exception as e:
|
|
21
|
+
return []
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def get_help(cls, x0hdb=""):
|
|
26
|
+
|
|
27
|
+
parameters = {}
|
|
28
|
+
parameters.update({"x0hdb" : x0hdb})
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
return HttpManager.send_xray_server_request_GET(APPLICATION, parameters)
|
|
32
|
+
|
|
33
|
+
except Exception as e:
|
|
34
|
+
return ""
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from orangewidget import gui
|
|
4
|
+
|
|
5
|
+
from PyQt5 import QtWidgets
|
|
6
|
+
from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView
|
|
7
|
+
|
|
8
|
+
import matplotlib
|
|
9
|
+
import urllib
|
|
10
|
+
|
|
11
|
+
from dabax.dabax_xraylib import DabaxXraylib
|
|
12
|
+
|
|
13
|
+
dabax = DabaxXraylib()
|
|
14
|
+
|
|
15
|
+
XRAY_SERVER_URL = "https://x-server.gmca.aps.anl.gov"
|
|
16
|
+
TMP_FILE = "xrayserver_tmp.txt"
|
|
17
|
+
|
|
18
|
+
import ssl
|
|
19
|
+
ssl._create_default_https_context = ssl._create_unverified_context
|
|
20
|
+
|
|
21
|
+
class HttpManager():
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def send_xray_server_request_GET(cls, application, parameters):
|
|
25
|
+
# this code prevent the real X-Ray Server to see Oasys as a bot.
|
|
26
|
+
opener = urllib.request.build_opener()
|
|
27
|
+
opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')]
|
|
28
|
+
urllib.request.install_opener(opener)
|
|
29
|
+
urllib.request.urlretrieve(XRAY_SERVER_URL + application + "?" + urllib.parse.urlencode(parameters), TMP_FILE)
|
|
30
|
+
|
|
31
|
+
with open(TMP_FILE) as f:
|
|
32
|
+
content = f.read()
|
|
33
|
+
f.close()
|
|
34
|
+
|
|
35
|
+
try: os.remove(TMP_FILE)
|
|
36
|
+
except: pass
|
|
37
|
+
|
|
38
|
+
return content
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def send_xray_server_direct_request(cls, url, decode=True):
|
|
42
|
+
resp = urllib.request.urlopen(url=XRAY_SERVER_URL+url)
|
|
43
|
+
|
|
44
|
+
if decode: return resp.read().decode('ascii')
|
|
45
|
+
else: return resp.read()
|
|
46
|
+
|
|
47
|
+
class XRayServerPhysics:
|
|
48
|
+
@classmethod
|
|
49
|
+
def getMaterialDensity(cls, material_formula):
|
|
50
|
+
if material_formula is None: return 0.0
|
|
51
|
+
if str(material_formula.strip()) == "": return 0.0
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
compoundData = dabax.CompoundParser(material_formula)
|
|
55
|
+
|
|
56
|
+
if compoundData["nElements"] == 1:
|
|
57
|
+
return dabax.ElementDensity(compoundData["Elements"][0])
|
|
58
|
+
else:
|
|
59
|
+
return 0.0
|
|
60
|
+
except:
|
|
61
|
+
return 0.0
|
|
62
|
+
|
|
63
|
+
class XRayServerGui:
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def format_scientific(cls, lineedit):
|
|
67
|
+
lineedit.setText("{:.2e}".format(float(lineedit.text().replace("+", ""))))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def combobox_text(cls, widget, master, value, box=None, label=None, labelWidth=None,
|
|
72
|
+
orientation='vertical', items=(), callback=None,
|
|
73
|
+
sendSelectedValue=False, selectedValue=None,
|
|
74
|
+
**misc):
|
|
75
|
+
|
|
76
|
+
combo = gui.comboBox(widget, master, value, box=box, label=label, labelWidth=labelWidth, orientation=orientation,
|
|
77
|
+
items=items, callback=callback, sendSelectedValue=sendSelectedValue, **misc)
|
|
78
|
+
try:
|
|
79
|
+
combo.setCurrentIndex(items.index(selectedValue))
|
|
80
|
+
except:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
return combo
|
|
84
|
+
|
|
85
|
+
class XRayServerPlot:
|
|
86
|
+
|
|
87
|
+
@classmethod
|
|
88
|
+
def plot_histo(cls, plot_window, x, y, title, xtitle, ytitle):
|
|
89
|
+
matplotlib.rcParams['axes.formatter.useoffset']='False'
|
|
90
|
+
|
|
91
|
+
plot_window.addCurve(x, y, title, symbol='', color='blue', replace=True) #'+', '^', ','
|
|
92
|
+
if not xtitle is None: plot_window.setGraphXLabel(xtitle)
|
|
93
|
+
if not ytitle is None: plot_window.setGraphYLabel(ytitle)
|
|
94
|
+
if not title is None: plot_window.setGraphTitle(title)
|
|
95
|
+
|
|
96
|
+
if min(y) < 0:
|
|
97
|
+
plot_window.setGraphYLimits(1.01*min(y), max(y)*1.01)
|
|
98
|
+
else:
|
|
99
|
+
plot_window.setGraphYLimits(min(y), max(y)*1.01)
|
|
100
|
+
plot_window.replot()
|
|
101
|
+
|
|
102
|
+
class ShowHtmlDialog(QtWidgets.QDialog):
|
|
103
|
+
|
|
104
|
+
def __init__(self, title, html_text, width=650, height=400, parent=None):
|
|
105
|
+
QtWidgets.QDialog.__init__(self, parent)
|
|
106
|
+
self.setModal(True)
|
|
107
|
+
self.setWindowTitle(title)
|
|
108
|
+
layout = QtWidgets.QVBoxLayout(self)
|
|
109
|
+
|
|
110
|
+
web_view = QWebView(self)
|
|
111
|
+
web_view.setHtml(html_text)
|
|
112
|
+
|
|
113
|
+
text_area = QtWidgets.QScrollArea(self)
|
|
114
|
+
text_area.setWidget(web_view)
|
|
115
|
+
text_area.setWidgetResizable(True)
|
|
116
|
+
text_area.setFixedHeight(height)
|
|
117
|
+
text_area.setFixedWidth(width)
|
|
118
|
+
|
|
119
|
+
bbox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok)
|
|
120
|
+
|
|
121
|
+
bbox.accepted.connect(self.accept)
|
|
122
|
+
layout.addWidget(text_area)
|
|
123
|
+
layout.addWidget(bbox)
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def show_html(cls, title, html_text, width=650, height=400, parent=None):
|
|
127
|
+
dialog = ShowHtmlDialog(title, html_text, width, height, parent)
|
|
128
|
+
dialog.show()
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import numpy
|
|
2
|
+
|
|
3
|
+
from oasys2.widget.widget import OWWidget, OWAction
|
|
4
|
+
|
|
5
|
+
from PyQt5.QtWidgets import QApplication, QSizePolicy
|
|
6
|
+
from PyQt5.QtCore import QRect
|
|
7
|
+
|
|
8
|
+
import oasys2.widget.gui as oasysgui
|
|
9
|
+
from oasys2.canvas.util.canvas_util import ShowTextDialog
|
|
10
|
+
|
|
11
|
+
from orangecontrib.xrayserver.util.xrayserver_util import HttpManager, XRayServerPlot
|
|
12
|
+
from orangecontrib.xrayserver.util.list_utility import ListUtility
|
|
13
|
+
|
|
14
|
+
class XrayServerWidget(OWWidget):
|
|
15
|
+
plot_canvas = []
|
|
16
|
+
|
|
17
|
+
MAX_WIDTH = 1400
|
|
18
|
+
MAX_HEIGHT = 700
|
|
19
|
+
|
|
20
|
+
def __init__(self):
|
|
21
|
+
super().__init__()
|
|
22
|
+
|
|
23
|
+
self.runaction = OWAction("Submit Request", self)
|
|
24
|
+
self.runaction.triggered.connect(self.submit)
|
|
25
|
+
self.addAction(self.runaction)
|
|
26
|
+
|
|
27
|
+
geom = QApplication.desktop().availableGeometry()
|
|
28
|
+
self.setGeometry(QRect(round(geom.width()*0.05),
|
|
29
|
+
round(geom.height()*0.05),
|
|
30
|
+
round(min(geom.width()*0.98, self.MAX_WIDTH)),
|
|
31
|
+
round(min(geom.height()*0.95, self.MAX_HEIGHT))))
|
|
32
|
+
|
|
33
|
+
self.setMaximumHeight(self.geometry().height())
|
|
34
|
+
self.setMaximumWidth(self.geometry().width())
|
|
35
|
+
|
|
36
|
+
self.left_side.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
|
|
37
|
+
self.left_side.setMaximumWidth(self.getLeftPartWidth())
|
|
38
|
+
self.left_side.updateGeometry()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def getLeftPartWidth(self):
|
|
42
|
+
return 515
|
|
43
|
+
|
|
44
|
+
def get_lines(self):
|
|
45
|
+
return ListUtility.get_list("waves")
|
|
46
|
+
|
|
47
|
+
def help_lines(self):
|
|
48
|
+
ShowTextDialog.show_text("Help Waves", ListUtility.get_help("waves"), width=350, parent=self)
|
|
49
|
+
|
|
50
|
+
def get_crystals(self):
|
|
51
|
+
return ListUtility.get_list("crystals")
|
|
52
|
+
|
|
53
|
+
def help_crystals(self):
|
|
54
|
+
ShowTextDialog.show_text("Help Crystals", ListUtility.get_help("crystals"), parent=self)
|
|
55
|
+
|
|
56
|
+
def get_others(self):
|
|
57
|
+
return ListUtility.get_list("amorphous+atoms")
|
|
58
|
+
|
|
59
|
+
def help_others(self):
|
|
60
|
+
ShowTextDialog.show_text("Help Others", ListUtility.get_help("amorphous+atoms"), parent=self)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def get_parameters_from_form(self, form):
|
|
64
|
+
parameters = {}
|
|
65
|
+
|
|
66
|
+
for row in form:
|
|
67
|
+
if "input" in row and "hidden" in row:
|
|
68
|
+
temp = (row.split("name=\"")[1]).split("\"")
|
|
69
|
+
key = temp[0]
|
|
70
|
+
|
|
71
|
+
if len(temp) == 2:
|
|
72
|
+
value = ((temp[1].split("value=")[1]).split(">")[0]).strip()
|
|
73
|
+
else:
|
|
74
|
+
value = temp[2].strip()
|
|
75
|
+
|
|
76
|
+
parameters.update({key : value})
|
|
77
|
+
|
|
78
|
+
return parameters
|
|
79
|
+
|
|
80
|
+
def get_data_file_from_response(self, response):
|
|
81
|
+
rows = response.split("\n")
|
|
82
|
+
|
|
83
|
+
job_id = None
|
|
84
|
+
data = None
|
|
85
|
+
|
|
86
|
+
for row in rows:
|
|
87
|
+
if "Job ID" in row:
|
|
88
|
+
job_id = (row.split("<b>"))[1].split("</b>")[0]
|
|
89
|
+
|
|
90
|
+
if not job_id is None:
|
|
91
|
+
if not job_id+".png" in response:
|
|
92
|
+
raise XrayServerException(response)
|
|
93
|
+
|
|
94
|
+
if job_id+".dat" in row:
|
|
95
|
+
data = HttpManager.send_xray_server_direct_request((row.split("href=\"")[1]).split("\"")[0])
|
|
96
|
+
break
|
|
97
|
+
|
|
98
|
+
if not data is None:
|
|
99
|
+
rows = data.split("\n")
|
|
100
|
+
|
|
101
|
+
x = []
|
|
102
|
+
y = []
|
|
103
|
+
|
|
104
|
+
for row in rows:
|
|
105
|
+
values_string = row.strip().split(" ")
|
|
106
|
+
|
|
107
|
+
if len(values_string) > 1:
|
|
108
|
+
x.append(float(values_string[0].strip()))
|
|
109
|
+
y.append(float(values_string[len(values_string)-1].strip()))
|
|
110
|
+
|
|
111
|
+
return x, y
|
|
112
|
+
else:
|
|
113
|
+
if job_id is None:
|
|
114
|
+
raise Exception("Job ID not present")
|
|
115
|
+
else:
|
|
116
|
+
raise Exception("Empty data file: " + job_id + ".dat")
|
|
117
|
+
|
|
118
|
+
def get_plots_from_form(self, application, form):
|
|
119
|
+
response = HttpManager.send_xray_server_request_GET(application, self.get_parameters_from_form(form))
|
|
120
|
+
|
|
121
|
+
return self.get_data_file_from_response(response)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""):
|
|
125
|
+
|
|
126
|
+
if numpy.sum(y) == 0: raise Exception(title + ": no data to plot (all Y column values==0)")
|
|
127
|
+
|
|
128
|
+
if self.plot_canvas[plot_canvas_index] is None:
|
|
129
|
+
self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(roi=False, control=False, position=True)
|
|
130
|
+
self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True)
|
|
131
|
+
self.plot_canvas[plot_canvas_index].setActiveCurveStyle(color='blue')
|
|
132
|
+
self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(True)
|
|
133
|
+
|
|
134
|
+
self.tabs[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index])
|
|
135
|
+
|
|
136
|
+
XRayServerPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle)
|
|
137
|
+
|
|
138
|
+
self.progressBarSet(progressBarValue)
|
|
139
|
+
|
|
140
|
+
class XrayServerException(Exception):
|
|
141
|
+
|
|
142
|
+
response = None
|
|
143
|
+
|
|
144
|
+
def __init__(self, response):
|
|
145
|
+
super().__init__()
|
|
146
|
+
|
|
147
|
+
self.response = XrayServerException.clear_response(response)
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def clear_response(cls, response):
|
|
151
|
+
return response.split("<p><b>Download ZIPped results:")[0] + "\n</body></html>"
|
|
152
|
+
|
|
153
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
=========
|
|
3
|
+
Associate
|
|
4
|
+
=========
|
|
5
|
+
|
|
6
|
+
Widgets for association rules.
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Category description for the widget registry
|
|
11
|
+
|
|
12
|
+
NAME = "X-Ray Server"
|
|
13
|
+
|
|
14
|
+
DESCRIPTION = "Widgets for X-Ray Server "
|
|
15
|
+
|
|
16
|
+
BACKGROUND = "#CAB244"
|
|
17
|
+
|
|
18
|
+
ICON = "icons/xrayserver.png"
|
|
19
|
+
|
|
20
|
+
PRIORITY = 3001
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|