summaryrefslogtreecommitdiff
path: root/lidt
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-08-18 21:14:27 +0200
committerKarel Kočí <cynerd@email.cz>2016-09-04 13:46:24 +0200
commit61a78fb16b031f839d5395047ff7c3171b70db5c (patch)
treed3eed83889bb9df5bdb403ef0e14eda12af23113 /lidt
downloadlidt-calc-tool-master.tar.gz
lidt-calc-tool-master.tar.bz2
lidt-calc-tool-master.zip
Initial commitHEADmaster
Diffstat (limited to 'lidt')
-rw-r--r--lidt/__init__.py95
-rw-r--r--lidt/form.glade1026
-rw-r--r--lidt/lidt.py174
-rw-r--r--lidt/plotout.py121
4 files changed, 1416 insertions, 0 deletions
diff --git a/lidt/__init__.py b/lidt/__init__.py
new file mode 100644
index 0000000..5966a98
--- /dev/null
+++ b/lidt/__init__.py
@@ -0,0 +1,95 @@
+# LIDT
+# Copyright (C) 2016 Karel Kočí
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk
+
+#from . import lidt
+import lidt
+#from . import plotout
+import plotout
+
+L = None
+builder = None
+
+label_list = [
+ "actarea",
+ "spotzise",
+ "numspots",
+ "disttestsitess",
+ "disttestsitesshex",
+ "numpulsperstep",
+ "numsitespulsstep",
+ "numofsiteseng",
+ "numengavsample",
+ "numofneededsites",
+ "numofneededsitesbool"
+ ]
+
+def updategtk():
+ if builder is None:
+ return
+ #print("render")
+ for edt in label_list:
+ #print(edt)
+ edtobj = builder.get_object(edt)
+ edtobj.set_text(str(eval("L." + edt)))
+
+class Handler:
+ def __init__(self, lidt):
+ self.lidt = lidt
+
+ def onDeleteWindow(self, *args):
+ Gtk.main_quit(*args)
+
+ def onRootChange(self, editable):
+ #print("signal " + Gtk.Buildable.get_name(editable))
+ try:
+ eval("self.lidt.set_" + Gtk.Buildable.get_name(editable) + "(float(editable.get_text()))")
+ self.lidt.calc()
+ except ValueError:
+ print("Invalid input!")
+
+ def render_click(widg, _):
+ plotout.grid_render(window, L.disttestsitess, L.beamdia)
+
+
+def main():
+ global L
+ L = lidt.Lidt(updategtk)
+
+ glade_file = os.path.join(os.path.dirname(__file__), "form.glade")
+
+ global builder
+ builder = Gtk.Builder()
+ builder.add_from_file(glade_file)
+ builder.connect_signals(Handler(L))
+
+ updategtk()
+
+ global window
+ window = builder.get_object("window")
+ window.show_all()
+
+ Gtk.main()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/lidt/form.glade b/lidt/form.glade
new file mode 100644
index 0000000..0faa5e7
--- /dev/null
+++ b/lidt/form.glade
@@ -0,0 +1,1026 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">LIDT</property>
+ <signal name="delete-event" handler="onDeleteWindow" swapped="no"/>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="samplediabox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Sample diameter:</property>
+ <property name="justify">right</property>
+ <property name="width_chars">19</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="smdia">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">6</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Active area diameter:</property>
+ <property name="justify">right</property>
+ <property name="width_chars">19</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="acaredia">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">5</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Beam diameter:</property>
+ <property name="justify">right</property>
+ <property name="width_chars">19</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="beamdia">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">0.1</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Active area: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="actarea">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="justify">right</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm^2]</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Spot size:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="spotzise">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="justify">right</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[mm^2]</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of spots: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numspots">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="justify">right</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[-]</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Distance between test sites (square):</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="disttestsitess">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="justify">right</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Distance between test sites (hex):</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="disttestsitesshex">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="justify">right</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"> </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Min number of pulses: </property>
+ <property name="justify">right</property>
+ <property name="width_chars">20</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="minnumpulse">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">100</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Max number of pulses:</property>
+ <property name="justify">right</property>
+ <property name="width_chars">20</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="maxnumpulse">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">5000</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of steps: </property>
+ <property name="justify">right</property>
+ <property name="width_chars">20</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="numsteps">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">5</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">[cm]</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of pulses per. step: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numpulsperstep">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">NaN</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">2</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of sites for pulse step: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numsitespulsstep">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">NaN</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Placeholder: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Procedure 1</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of pulses S: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="numpulses">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">18</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of sites for single energy acording to S (=5*int(1 + log S)):</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numofsiteseng">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">NaN</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of energy steps available for sample: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numengavsample">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">NaN</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of desired energy steps: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="numdesengstep">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="text" translatable="yes">5</property>
+ <property name="input_purpose">number</property>
+ <signal name="changed" handler="onRootChange" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Number of needed sites: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numofneededsites">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">NaN</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">2</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="numofneededsitesbool">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Possible</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">4</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Procedure 2</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Render</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="render_click" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Grid</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/lidt/lidt.py b/lidt/lidt.py
new file mode 100644
index 0000000..ba5ca39
--- /dev/null
+++ b/lidt/lidt.py
@@ -0,0 +1,174 @@
+# LIDT
+# Copyright (C) 2016 Karel Kočí
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import sys
+import math
+
+
+class Lidt:
+ def __init__(self, updatecall):
+ self.updt = updatecall # Callback to GTK window for variable download
+
+ # Root calculations
+ self.smdia = 6 # Sample diameter
+ self.acaredia = 5 # Active area diameter
+ self.beamdia = 0.1 # Beam diameter
+
+ # Procedure 1 calculations
+ self.minnumpulse = 100 # Min number of pulses
+ self.maxnumpulse = 5000 # Max number of pulses
+ self.numsteps = 5 # Number of steps
+
+ # Procedure 2 calculations
+ self.numpulses = 18 # Number of pulses S
+ self.numdesengstep = 5 # Number of desired energy steps
+
+ self.calc()
+
+
+ def set_smdia(self, val):
+ "Set Sample Diameter"
+ if val < 0:
+ return False
+ #print("houhou")
+ self.smdia = val
+ self.calc()
+ return True
+
+
+ def set_acaredia(self, val):
+ "Set Active area diameter"
+ if val < 0:
+ return False
+ self.acaredia = val
+ self.calc()
+ return True
+
+
+ def set_beamdia(self, val):
+ "Set Beam diameter"
+ if val < 0:
+ return False
+ self.beamdia = val
+ self.calc()
+ return True
+
+
+ def set_minnumpulse(self, val):
+ "Set Min number of pulses"
+ if val < 0:
+ return False
+ if self.maxnumpulse <= val:
+ return False
+ self.minnumpulse = val
+ self.calc()
+ return True
+
+
+ def set_maxnumpulse(self, val):
+ "Set Max number of pulses"
+ if val < 0:
+ return False
+ if self.minnumpulse >= val:
+ return False
+ self.maxnumpulse = val
+ self.calc()
+ return True
+
+
+ def set_numsteps(self, val):
+ "Set Number of steps"
+ if val < 0:
+ return False
+ self.numsteps = int(val)
+ self.calc()
+ return True
+
+
+ def set_numpulses(self, val):
+ "Set Number of pulses S"
+ if val < 0:
+ return False
+ self.numpulses = val
+ self.calc()
+ return True
+
+
+ def set_numdesengstep(self, val):
+ "Set Number of desired energy steps"
+ if val < 0:
+ return False
+ self.numdesengstep = val
+ self.calc()
+ return True
+
+
+ def calc(self):
+ ## Root
+ # Active area
+ self.actarea = math.pi * self.acaredia * self.acaredia / 4
+
+ # Spot size
+ self.spotzise = (math.pi * self.beamdia * self.beamdia / 4) * 0.9
+
+ # Number of spots
+ self.numspots = math.pi * self.acaredia * self.acaredia / \
+ (4 * self.actarea * self.spotzise)
+
+ # Distance between test sites (square)
+ self.disttestsitess = math.sqrt(self.actarea) / self.numspots
+
+ # Distance between test sites (hex)
+ self.disttestsitesshex = math.sqrt(2*self.actarea) / \
+ self.numspots * 5.1961524
+
+ ## Procedure 1
+ # Number of pulses per step
+ # Lets normalize this to <0,1>
+ arr = []
+ for a in range(1, self.numsteps):
+ # Using normalization to <0,1> for exact calculations
+ # ea = log(e^0 + (a/steps * e^1))
+ ea = math.log(1 + ((a/self.numsteps) * math.e))
+ # Append real logarithmic step
+ # ea = (r - min) / (max - min)
+ # r = ea * (max - min) + min
+ arr.append(str(
+ (ea * (self.maxnumpulse - self.minnumpulse)) \
+ + self.minnumpulse
+ ))
+ self.numpulsperstep = ",".join(arr)
+ # TODO round result numbers to most significant number
+
+ # Number of sites for pulse step
+ self.numsitespulsstep = 5 * (1 + math.log10(self.numspots))
+
+ ## Procedure 2
+ # Number of sites for single energy according to S
+ self.numofsiteseng = 5 * (1 + math.log10(self.numpulses))
+
+ # Number of energy steps available for sample
+ self.numengavsample = self.numspots / self.numofsiteseng
+
+ # Number of needed sites
+ self.numofneededsites = self.numofsiteseng * self.numdesengstep
+
+ # Number of needed sites - possibility
+ self.numofneededsitesbool = not self.numofneededsites > self.numspots
+
+ # Invoke Gtk form
+ self.updt()
diff --git a/lidt/plotout.py b/lidt/plotout.py
new file mode 100644
index 0000000..cb3b838
--- /dev/null
+++ b/lidt/plotout.py
@@ -0,0 +1,121 @@
+# LIDT
+# Copyright (C) 2016 Karel Kočí
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+import math
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk, Gdk
+
+grid = None
+grid_bot = None
+step = 50
+dia = 300
+selectx = None
+selecty = None
+grid_h = 1
+
+def __grid_draw(wd, cr):
+ w = wd.get_allocated_width()
+ h = wd.get_allocated_height()
+ if w < h:
+ s = w
+ else:
+ s = h
+ cr.set_source_rgb(0, 0, 0)
+ h = s / 2 # half of the size of drawing area
+ global grid_h
+ grid_h = h
+ st = (h / dia) * step
+
+ cr.rectangle(0, 0, s, s)
+ cr.fill()
+
+ cr.move_to(0, h)
+ cr.arc(h, h, h, 0, 2 * math.pi)
+ cr.set_source_rgb(1, 1, 1)
+ cr.fill()
+
+ cr.set_source_rgb(0, 0, 0)
+ i = 0
+ while i < h:
+ cr.move_to(h + i, 0)
+ cr.line_to(h + i, s)
+ cr.move_to(h - i, 0)
+ cr.line_to(h - i, s)
+ cr.move_to(0, h + i)
+ cr.line_to(s, h + i)
+ cr.move_to(0, h - i)
+ cr.line_to(s, h - i)
+ i = i + st
+ cr.set_line_width(1)
+ cr.stroke()
+
+ if selectx is not None:
+ slx = (h / dia) * selectx
+ sly = (h / dia) * selecty
+ cr.move_to(h +slx - 5, h + sly)
+ cr.arc(h + slx, h + sly, 5, 0, 2 * math.pi)
+ cr.set_source_rgb(0, 1, 0)
+ cr.fill()
+
+def __grid_button(widg, button):
+ global selectx
+ global selecty
+ selectx = (button.x - grid_h) * (dia / grid_h)
+ selecty = (button.y - grid_h) * (dia / grid_h)
+ selectx = round(selectx / step) * step
+ selecty = round(selecty / step) * step
+ grid_bot.set_text(str(selectx) + ':' + str(selecty))
+ grid.queue_draw()
+
+def test():
+ grid_render(None, 1, 1)
+ grid.connect("delete-event", Gtk.main_quit)
+ Gtk.main()
+
+
+def grid_render(win, st, di):
+ global grid
+ if not grid is None:
+ grid.destroy()
+ global step
+ step = st
+ global dia
+ dia = di
+ global selectx
+ selectx = None
+ global selecty
+ selecty = None
+ grid = Gtk.Window()
+ grid.set_title("LIDT: Grid")
+ grid.set_attached_to(win)
+ grid.set_destroy_with_parent(True)
+
+ box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
+ grid.add(box)
+
+ drawarea = Gtk.DrawingArea()
+ drawarea.set_size_request(512, 512)
+ drawarea.set_events(drawarea.get_events() | Gdk.EventMask.BUTTON_PRESS_MASK)
+ drawarea.connect('draw', __grid_draw)
+ drawarea.connect('button-press-event', __grid_button)
+ box.pack_start(drawarea, True, True, 0)
+
+ global grid_bot
+ grid_bot = Gtk.Label('')
+ box.pack_start(grid_bot, False, False, 0)
+
+ grid.show_all()