[med-svn] [aghermann] 13/85: patterns, rk1968 WIP

andrei zavada hmmr-guest at alioth.debian.org
Thu Sep 26 23:46:23 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch master
in repository aghermann.

commit 18414408f8efc53ad103c082d309e5e3ec55634f
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Mon Sep 9 01:52:43 2013 +0300

    patterns, rk1968 WIP
---
 upstream/configure.ac                              |    3 -
 upstream/data/Makefile.am                          |    4 +-
 upstream/data/aghermann.gresource.xml              |    1 +
 upstream/data/sf-rk1968.glade                      |  524 ++++++++++++++++++++
 upstream/data/sf.glade                             |   26 +-
 upstream/src/Makefile.am                           |    7 +-
 upstream/src/aghermann/expdesign/Makefile.am       |    3 +-
 upstream/src/aghermann/expdesign/expdesign.cc      |   16 +
 upstream/src/aghermann/expdesign/expdesign.hh      |   15 +-
 upstream/src/aghermann/patterns/Makefile.am        |    3 +-
 upstream/src/aghermann/patterns/forward-decls.hh   |    8 +-
 upstream/src/aghermann/patterns/patterns.cc        |  138 +++---
 upstream/src/aghermann/patterns/patterns.hh        |  255 +++++++---
 upstream/src/aghermann/patterns/patterns.ii        |   12 +-
 upstream/src/aghermann/rk1968/Makefile.am          |    4 +-
 upstream/src/aghermann/rk1968/rk1968-profiles.cc   |  129 +++++
 upstream/src/aghermann/rk1968/rk1968.cc            |   13 +-
 upstream/src/aghermann/rk1968/rk1968.hh            |   34 +-
 upstream/src/aghermann/ui/mw/splash.cc             |    4 +-
 upstream/src/aghermann/ui/sf/Makefile.am           |    7 +-
 upstream/src/aghermann/ui/sf/channel.cc            |    5 +-
 upstream/src/aghermann/ui/sf/channel.hh            |    5 +-
 upstream/src/aghermann/ui/sf/d/patterns-draw.cc    |    6 +-
 .../src/aghermann/ui/sf/d/patterns-profiles.cc     |  127 ++---
 .../src/aghermann/ui/sf/d/patterns-profiles_cb.cc  |   52 +-
 upstream/src/aghermann/ui/sf/d/patterns.cc         |   19 +-
 upstream/src/aghermann/ui/sf/d/rk1968-construct.cc |   65 +++
 upstream/src/aghermann/ui/sf/d/rk1968-profiles.cc  |  126 +++++
 upstream/src/aghermann/ui/sf/d/rk1968.cc           |   44 ++
 upstream/src/aghermann/ui/sf/d/rk1968.hh           |  210 ++------
 upstream/src/aghermann/ui/sf/d/rk1968_cb.cc        |   43 ++
 upstream/src/aghermann/ui/sf/hypnogram_cb.cc       |    8 +-
 upstream/src/aghermann/ui/sf/mainmenu_cb.cc        |    4 +-
 upstream/src/aghermann/ui/sf/sf.cc                 |    1 +
 upstream/src/tools/Makefile.am                     |    3 +-
 upstream/src/tools/edfhed-gtk.cc                   |    2 +-
 36 files changed, 1444 insertions(+), 482 deletions(-)

diff --git a/upstream/configure.ac b/upstream/configure.ac
index 737b0ea..4ef78c0 100644
--- a/upstream/configure.ac
+++ b/upstream/configure.ac
@@ -180,9 +180,6 @@ if test x$enable_update_mime_database = xyes ; then
 	fi
 fi
 
-PKGDATADIR=$prefix/share/$PACKAGE
-AC_SUBST(PKGDATADIR)
-
 dnl Any private defines
 AC_SUBST(user, [`whoami`@`hostname`])
 AC_SUBST(build_date, [`date +"%F"`])
diff --git a/upstream/data/Makefile.am b/upstream/data/Makefile.am
index 96f099b..ea76bd8 100644
--- a/upstream/data/Makefile.am
+++ b/upstream/data/Makefile.am
@@ -18,7 +18,7 @@ EXTRA_DIST := \
 	aghermann.gresource.xml \
 	sm.glade \
 	mw.glade mw-dialogs.glade \
-	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade \
+	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
 	mf.glade \
 	edfhed.glade \
 	idle-bg.svg equations1.png equation-uc.png \
@@ -31,7 +31,7 @@ CLEANFILES := \
 GRESOURCES := \
 	sm.glade \
 	mw.glade mw-dialogs.glade \
-	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade \
+	sf.glade sf-artifacts.glade sf-artifacts-simple.glade sf-filters.glade sf-patterns.glade sf-phasediff.glade sf-rk1968.glade \
 	mf.glade edfhed.glade \
 	aghermann.png equations1.png equation-uc.png
 
diff --git a/upstream/data/aghermann.gresource.xml b/upstream/data/aghermann.gresource.xml
index 01bbfb7..222a536 100644
--- a/upstream/data/aghermann.gresource.xml
+++ b/upstream/data/aghermann.gresource.xml
@@ -14,6 +14,7 @@
     <file compressed="true">sf-filters.glade</file>
     <file compressed="true">sf-patterns.glade</file>
     <file compressed="true">sf-phasediff.glade</file>
+    <file compressed="true">sf-rk1968.glade</file>
     <file compressed="true">mf.glade</file>
   </gresource>
 </gresources>
diff --git a/upstream/data/sf-rk1968.glade b/upstream/data/sf-rk1968.glade
new file mode 100644
index 0000000..1be3f98
--- /dev/null
+++ b/upstream/data/sf-rk1968.glade
@@ -0,0 +1,524 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkAdjustment" id="jSFRKNremThetaDeltaRatio">
+    <property name="lower">0.01</property>
+    <property name="upper">30</property>
+    <property name="value">1.5</property>
+    <property name="step_increment">0.10000000000000001</property>
+    <property name="page_increment">1</property>
+  </object>
+  <object class="GtkDialog" id="wSFRK">
+    <property name="can_focus">False</property>
+    <property name="border_width">10</property>
+    <property name="title" translatable="yes">Find/manage patterns</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">normal</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="gravity">north</property>
+    <signal name="close" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <signal name="response" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox19">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area19">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="bSFRKDismiss">
+                <property name="label" translatable="yes">_Dismiss</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="relief">half</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkBox" id="box12">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="homogeneous">True</property>
+                <child>
+                  <object class="GtkButton" id="bSFRKRun">
+                    <property name="label" translatable="yes">Try</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</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="lSFRKWorking">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="valign">center</property>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">Working …</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="bSFRKModify">
+                    <property name="label" translatable="yes">Modify</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</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>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box9">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkBox" id="box11">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">5</property>
+                <property name="margin_bottom">5</property>
+                <child>
+                  <object class="GtkLabel" id="label45">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">5</property>
+                    <property name="label" translatable="yes">Rechtschaffen & Kales</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                      <attribute name="scale" value="1.1000000000000001"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="cSFRKLabelBox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkComboBox" id="eSFRKProfileList">
+                        <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="pack_type">end</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bSFRKProfileRevert">
+                        <property name="label" translatable="yes">Revert</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bSFRKProfileSave">
+                        <property name="label" translatable="yes">_Save</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="relief">half</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="bSFRKProfileDiscard">
+                        <property name="label" translatable="yes">Dis_card</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="relief">half</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </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">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator" id="separator9">
+                <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>
+            <child>
+              <object class="GtkHBox" id="hbox6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">5</property>
+                <property name="spacing">8</property>
+                <child>
+                  <object class="GtkTable" id="cSFRKControls">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">5</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="eSFRKNremThetaDeltaRatio">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">•</property>
+                        <property name="xalign">1</property>
+                        <property name="adjustment">jSFRKNremThetaDeltaRatio</property>
+                        <property name="digits">2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">NREM Delta/Theta power ratio:</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">2</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </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="GtkSeparator" id="separator18">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_top">5</property>
+            <property name="margin_bottom">5</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-1">bSFRKDismiss</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="wSFRKProfileSave">
+    <property name="width_request">200</property>
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Save pattern</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="transient_for">wSFRK</property>
+    <signal name="close" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <signal name="response" handler="gtk_widget_hide_on_delete" swapped="no"/>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin_left">5</property>
+        <property name="margin_right">5</property>
+        <property name="margin_top">5</property>
+        <property name="margin_bottom">5</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">10</property>
+        <child>
+          <object class="GtkFrame" id="frame2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkEntry" id="eSFRKProfileSaveName">
+                <property name="width_request">130</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="margin_top">5</property>
+                <property name="margin_bottom">5</property>
+                <property name="invisible_char">•</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes"><b>Profile name</b></property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="frame1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkBox" id="box13">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_left">3</property>
+                <property name="margin_right">3</property>
+                <property name="margin_top">3</property>
+                <property name="margin_bottom">3</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
+                <child>
+                  <object class="GtkRadioButton" id="eSFFDPatternSaveOriginUser">
+                    <property name="label" translatable="yes">_User</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="eSFFDPatternSaveOriginExperiment">
+                    <property name="label" translatable="yes">_Experiment</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">eSFFDPatternSaveOriginUser</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="eSFFDPatternSaveOriginSubject">
+                    <property name="label" translatable="yes">_Subject</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">eSFFDPatternSaveOriginUser</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label51">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes"><b>Scope</b></property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="focus_on_click">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="bSFFDPatternSaveOK">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+                <property name="focus_on_click">False</property>
+                <accelerator key="Return" signal="activate"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">button1</action-widget>
+      <action-widget response="-5">bSFFDPatternSaveOK</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/upstream/data/sf.glade b/upstream/data/sf.glade
index 3b06d44..57fc200 100644
--- a/upstream/data/sf.glade
+++ b/upstream/data/sf.glade
@@ -570,7 +570,7 @@
       <object class="GtkMenuItem" id="iSFScoreAssist">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">_Assist</property>
+        <property name="label" translatable="yes">_Assist...</property>
         <property name="use_underline">True</property>
       </object>
     </child>
@@ -1474,6 +1474,18 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkSeparator" id="separator6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">9</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkTable" id="cSFSleepStageStats">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
@@ -1606,18 +1618,6 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSeparator" id="separator6">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">9</property>
-                      </packing>
-                    </child>
-                    <child>
                       <object class="GtkSeparator" id="separator4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
diff --git a/upstream/src/Makefile.am b/upstream/src/Makefile.am
index 4ffd280..d0438a6 100644
--- a/upstream/src/Makefile.am
+++ b/upstream/src/Makefile.am
@@ -33,7 +33,6 @@ BUILT_SOURCES = \
 	libsigfile/tsv.hh.gch \
 	libsigfile/source-base.hh.gch \
 	libsigfile/all.hh.gch \
-	libsigfile/forward-decls.hh.gch \
 	libmetrics/mc-artifacts.hh.gch \
 	libmetrics/mc.hh.gch \
 	libmetrics/psd.hh.gch \
@@ -41,16 +40,13 @@ BUILT_SOURCES = \
 	libmetrics/all.hh.gch \
 	libmetrics/page-metrics-base.hh.gch \
 	libmetrics/bands.hh.gch \
-	libmetrics/forward-decls.hh.gch \
 	aghermann/model/achermann-tunable.hh.gch \
 	aghermann/model/achermann.hh.gch \
 	aghermann/model/beersma.hh.gch \
-	aghermann/model/forward-decls.hh.gch \
 	aghermann/expdesign/subject.hh.gch \
 	aghermann/expdesign/recording.hh.gch \
 	aghermann/expdesign/profile.hh.gch \
 	aghermann/expdesign/expdesign.hh.gch \
-	aghermann/expdesign/forward-decls.hh.gch \
 	aghermann/rk1968/rk1968.hh.gch \
 	aghermann/globals.hh.gch \
 	aghermann/patterns/patterns.hh.gch \
@@ -73,8 +69,7 @@ BUILT_SOURCES = \
 	aghermann/ui/mw/mw.hh.gch \
 	aghermann/ui/mw/mw_cb.hh.gch \
 	aghermann/ui/mw/widgets.hh.gch \
-	aghermann/ui/ui++.hh.gch \
-	aghermann/ui/forward-decls.hh.gch
+	aghermann/ui/ui++.hh.gch
 
 %.hh.gch: %.hh
 # for some reason $(CXXCOMPILE) is just... "c", whereas when seen in
diff --git a/upstream/src/aghermann/expdesign/Makefile.am b/upstream/src/aghermann/expdesign/Makefile.am
index 37e742f..261b0ff 100644
--- a/upstream/src/aghermann/expdesign/Makefile.am
+++ b/upstream/src/aghermann/expdesign/Makefile.am
@@ -1,7 +1,8 @@
 AM_CXXFLAGS := \
 	-Wall -std=c++0x -fno-rtti \
 	$(OPENMP_CXXFLAGS) \
-	-I$(top_srcdir)/src
+	-I$(top_srcdir)/src \
+	-DPACKAGE_DATADIR=\"$(datadir)\"
 
 noinst_LIBRARIES := liba.a
 
diff --git a/upstream/src/aghermann/expdesign/expdesign.cc b/upstream/src/aghermann/expdesign/expdesign.cc
index 00c797b..175ff28 100644
--- a/upstream/src/aghermann/expdesign/expdesign.cc
+++ b/upstream/src/aghermann/expdesign/expdesign.cc
@@ -26,6 +26,22 @@ using namespace std;
 
 using agh::confval::SValidator;
 
+const char*
+agh::
+exp_dir_level_s( agh::TExpDirLevel x)
+{
+        switch (x) {
+        case TExpDirLevel::transient:   return "~";
+        case TExpDirLevel::subject:     return "[S]";
+        case TExpDirLevel::experiment:  return "[E]";
+        case TExpDirLevel::user:        return "[U]";
+        case TExpDirLevel::system:      return "<S>";
+        default: return "?";
+        }
+};
+
+
+
 const char
         *const agh::CExpDesign::FreqBandNames[metrics::TBand::TBand_total] = {
         "Delta", "Theta", "Alpha", "Beta", "Gamma",
diff --git a/upstream/src/aghermann/expdesign/expdesign.hh b/upstream/src/aghermann/expdesign/expdesign.hh
index d49a7f0..7c0c354 100644
--- a/upstream/src/aghermann/expdesign/expdesign.hh
+++ b/upstream/src/aghermann/expdesign/expdesign.hh
@@ -39,8 +39,21 @@ namespace agh {
 using namespace std;
 
 
+
+enum class TExpDirLevel {
+        transient,
+        subject,
+        experiment,
+        user,
+        system,
+};
+
+const char* exp_dir_level_s( agh::TExpDirLevel);
+
+
+
 class CJGroup
-      : public list<CSubject> {
+  : public list<CSubject> {
 
         void operator=( const CJGroup&) = delete;
     public:
diff --git a/upstream/src/aghermann/patterns/Makefile.am b/upstream/src/aghermann/patterns/Makefile.am
index a32f72d..22d58c0 100644
--- a/upstream/src/aghermann/patterns/Makefile.am
+++ b/upstream/src/aghermann/patterns/Makefile.am
@@ -1,6 +1,7 @@
 AM_CXXFLAGS := \
 	-Wall -std=c++0x -fno-rtti \
-	-I$(top_srcdir)/src
+	-I$(top_srcdir)/src \
+	-DPACKAGE_DATADIR=\"$(datadir)\"
 
 noinst_LIBRARIES := liba.a
 
diff --git a/upstream/src/aghermann/patterns/forward-decls.hh b/upstream/src/aghermann/patterns/forward-decls.hh
index 0078781..546deed 100644
--- a/upstream/src/aghermann/patterns/forward-decls.hh
+++ b/upstream/src/aghermann/patterns/forward-decls.hh
@@ -9,9 +9,10 @@
  *         License:  GPL
  */
 
-#ifndef SIGPROC_PATTERNS_FORWARD_DECLS_H_
-#define SIGPROC_PATTERNS_FORWARD_DECLS_H_
+#ifndef AGH_AGHERMANN_PATTERNS_FORWARD_DECLS_H_
+#define AGH_AGHERMANN_PATTERNS_FORWARD_DECLS_H_
 
+namespace agh {
 namespace pattern {
 
 template <typename T> class CMatch;
@@ -19,7 +20,8 @@ template <typename T> struct SPatternPPack;
 template <typename T> class CPatternTool;
 template <typename T> struct SPattern;
 
-} // namespace pattern
+}
+}
 
 
 #endif
diff --git a/upstream/src/aghermann/patterns/patterns.cc b/upstream/src/aghermann/patterns/patterns.cc
index 2ca84b3..b4289d9 100644
--- a/upstream/src/aghermann/patterns/patterns.cc
+++ b/upstream/src/aghermann/patterns/patterns.cc
@@ -15,35 +15,31 @@
 #include <sys/stat.h>
 
 #include "common/fs.hh"
+#include "aghermann/expdesign/expdesign.hh"
 #include "patterns.hh"
 
 using namespace std;
+using namespace agh::pattern;
 
-template pattern::CPatternTool<TFloat>::CPatternTool( const sigproc::SSignalRef<TFloat>&, size_t, size_t, const SPatternPPack<TFloat>&);
-template int pattern::CPatternTool<TFloat>::do_search( const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, size_t);
-template int pattern::CPatternTool<TFloat>::do_search( const sigproc::SSignalRef<TFloat>&, size_t);
-template int pattern::CPatternTool<TFloat>::do_search( const valarray<TFloat>&, size_t);
 
+template CPatternTool<TFloat>::CPatternTool( const sigproc::SSignalRef<TFloat>&, const TContext&, const SPatternPPack<TFloat>&);
+template int CPatternTool<TFloat>::do_search( const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, size_t);
+template int CPatternTool<TFloat>::do_search( const sigproc::SSignalRef<TFloat>&, size_t);
+template int CPatternTool<TFloat>::do_search( const valarray<TFloat>&, size_t);
 
 
-namespace {
-int
-scandir_filter( const struct dirent *e)
-{
-        return strcmp( e->d_name, ".") && strcmp( e->d_name, "..");
-}
-}
 
 
-namespace pattern {
 
+namespace agh {
+namespace pattern {
 
 template <>
-SPattern<TFloat>
-load_pattern( const char* fname) throw(invalid_argument)
+int
+agh::pattern::SPattern<TFloat>::
+load( const string& fname_)
 {
-        SPattern<TFloat>
-                P;
+        const auto& fname = fname_.c_str();
 
         FILE *fd = fopen( fname, "r");
         if ( fd ) {
@@ -54,34 +50,31 @@ load_pattern( const char* fname) throw(invalid_argument)
                              " %lg %lg %lg %lg"
                              " %zu %zu %zu %zu\n"
                              "--DATA--\n",
-                             &P.Pp.env_scope,
-                             &P.Pp.bwf_order, &P.Pp.bwf_ffrom, &P.Pp.bwf_fupto,
-                             &P.Pp.dzcdf_step, &P.Pp.dzcdf_sigma, &P.Pp.dzcdf_smooth,
+                             &Pp.env_scope,
+                             &Pp.bwf_order, &Pp.bwf_ffrom, &Pp.bwf_fupto,
+                             &Pp.dzcdf_step, &Pp.dzcdf_sigma, &Pp.dzcdf_smooth,
                              &t1, &t2, &t3, &t4,
-                             &P.samplerate, &P.context_before, &P.context_after,
+                             &samplerate, &context.first, &context.second,
                              &full_sample) == 15 ) {
 
-                        get<0>(P.criteria) = t1;
-                        get<1>(P.criteria) = t2;
-                        get<2>(P.criteria) = t3;
-                        get<3>(P.criteria) = t4;
+                        criteria = CMatch<float>(t1, t2, t3, t4);
 
-                        if ( P.samplerate == 0 || P.samplerate > 4096 ||
-                             full_sample == 0 || full_sample > P.samplerate * 10 ||
-                             P.context_before > P.samplerate * 2 ||
-                             P.context_after > P.samplerate * 2 ||
-                             not P.Pp.sane() ) {
+                        if ( samplerate == 0 || samplerate > 4096 ||
+                             full_sample == 0 || full_sample > samplerate * 10 ||
+                             context.first > samplerate * 2 ||
+                             context.second > samplerate * 2 ||
+                             not Pp.is_sane() ) {
                                 string msg = agh::str::sasprintf(
                                         "load_pattern(\"%s\"): bogus data in header; removing file",
                                         fname);
                                 fprintf( stderr, "%s\n", msg.c_str());
-                                P.thing.resize( 0);
+                                thing.resize( 0);
                                 fclose( fd);
                                 unlink( fname);
-                                throw invalid_argument (msg);
+                                return -3;
                         }
 
-                        P.thing.resize( full_sample);
+                        thing.resize( full_sample);
                         for ( size_t i = 0; i < full_sample; ++i ) {
                                 double d;
                                 if ( fscanf( fd, "%la", &d) != 1 ) {
@@ -89,22 +82,21 @@ load_pattern( const char* fname) throw(invalid_argument)
                                                 "load_pattern(\"%s\"): short read at sample %zu; removing file",
                                                 fname, i);
                                         fprintf( stderr, "%s\n", msg.c_str());
-                                        P.thing.resize( 0);
+                                        thing.resize( 0);
                                         fclose( fd);
                                         unlink( fname);
                                         throw invalid_argument (msg);
                                 } else
-                                        P.thing[i] = d;
+                                        thing[i] = d;
                         }
 
                 } else {
-                        P.thing.resize( 0);
+                        thing.resize( 0);
                         string msg = agh::str::sasprintf( "load_pattern(\"%s\"): bad header, so removing file", fname);
                         fprintf( stderr, "%s\n", msg.c_str());
-                        P.thing.resize( 0);
                         fclose( fd);
                         unlink( fname);
-                        throw invalid_argument (msg);
+                        return -2;
                 }
 
                 fclose( fd);
@@ -112,28 +104,33 @@ load_pattern( const char* fname) throw(invalid_argument)
         } else {
                 string msg = agh::str::sasprintf( "Failed to open pattern %s", fname);
                 fprintf( stderr, "%s\n", msg.c_str());
-                throw invalid_argument (msg);
+                return -1;
         }
 
         printf( "loaded pattern in %s\n", fname);
-        P.saved = true;
-        P.name = agh::str::tokens( fname, "/").back();
-        P.path = fname;
-        return P;
+        saved = true;
+        name = agh::str::tokens( fname, "/").back();
+        path = fname;
+
+        return 0;
 }
 
 
 template <>
 int
-save_pattern( SPattern<TFloat>& P, const char* fname)
+agh::pattern::SPattern<TFloat>::
+save()
 {
-        if ( agh::fs::mkdir_with_parents( agh::fs::dirname(fname)) ) {
-                fprintf( stderr, "save_pattern(\"%s\"): mkdir %s failed\n", fname, agh::fs::dirname(fname).c_str());
+        if ( saved || origin == agh::TExpDirLevel::transient || origin == agh::TExpDirLevel::system )
+                return 0;
+
+        if ( agh::fs::mkdir_with_parents( agh::fs::dirname(path)) ) {
+                fprintf( stderr, "save_pattern(\"%s\"): mkdir failed\n", path.c_str());
                 return -1;
         }
-        printf( "saving pattern in %s\n", fname);
+        printf( "saving pattern in %s\n", path.c_str());
 
-        FILE *fd = fopen( fname, "w");
+        FILE *fd = fopen( path.c_str(), "w");
         try {
                 if ( !fd )
                         throw -2;
@@ -142,23 +139,25 @@ save_pattern( SPattern<TFloat>& P, const char* fname)
                               "%g  %u %g %g  %g %g %u  %g %g %g %g\n"
                               "%zu  %zu %zu %zu\n"
                               "--DATA--\n",
-                              P.Pp.env_scope,
-                              P.Pp.bwf_order, P.Pp.bwf_ffrom, P.Pp.bwf_fupto,
-                              P.Pp.dzcdf_step, P.Pp.dzcdf_sigma, P.Pp.dzcdf_smooth,
-                              get<0>(P.criteria), get<1>(P.criteria), get<2>(P.criteria), get<3>(P.criteria),
-                              P.samplerate, P.context_before, P.context_after,
-                              P.thing.size()) < 1 ) {
-                        fprintf( stderr, "save_pattern(\"%s\"): write failed\n", fname);
+                              Pp.env_scope,
+                              Pp.bwf_order, Pp.bwf_ffrom, Pp.bwf_fupto,
+                              Pp.dzcdf_step, Pp.dzcdf_sigma, Pp.dzcdf_smooth,
+                              get<0>(criteria), get<1>(criteria), get<2>(criteria), get<3>(criteria),
+                              samplerate, context.first, context.second,
+                              thing.size()) < 1 ) {
+                        fprintf( stderr, "save_pattern(\"%s\"): write failed\n", path.c_str());
                         throw -3;
                 }
 
-                for ( size_t i = 0; i < P.thing.size(); ++i )
-                        if ( fprintf( fd, "%a\n", (double)P.thing[i]) < 1 ) {
-                                fprintf( stderr, "save_pattern(\"%s\"): write failed\n", fname);
+                for ( size_t i = 0; i < thing.size(); ++i )
+                        if ( fprintf( fd, "%a\n", (double)thing[i]) < 1 ) {
+                                fprintf( stderr, "save_pattern(\"%s\"): write failed\n", path.c_str());
                                 throw -3;
                         }
                 fclose( fd);
 
+                saved = true;
+
                 return 0;
 
         } catch (int ret) {
@@ -171,15 +170,26 @@ save_pattern( SPattern<TFloat>& P, const char* fname)
 
 template <>
 int
-delete_pattern( const SPattern<TFloat>& P)
+SPattern<TFloat>::
+delete_file()
 {
-        return unlink( P.path.c_str());
+        return unlink( path.c_str());
+}
+
+
+
+namespace {
+int
+scandir_filter( const struct dirent *e)
+{
+        return strcmp( e->d_name, ".") && strcmp( e->d_name, "..");
+}
 }
 
 
 template <>
-list<pattern::SPattern<TFloat>>
-load_patterns_from_location<TFloat>( const string& loc, pattern::TOrigin origin)
+list<agh::pattern::SPattern<TFloat>>
+load_patterns_from_location<TFloat>( const string& loc, agh::TExpDirLevel origin)
 {
         list<SPattern<TFloat>>
                 ret;
@@ -190,8 +200,7 @@ load_patterns_from_location<TFloat>( const string& loc, pattern::TOrigin origin)
         if ( total != -1 ) {
                 for ( int i = 0; i < total; ++i ) {
                         try {
-                                ret.push_back(
-                                        load_pattern<TFloat>( (loc + '/' + eps[i]->d_name).c_str()));
+                                ret.emplace_back( loc + '/' + eps[i]->d_name);
                                 ret.back().origin = origin;
                         } catch (invalid_argument& ex) {
                                 ;
@@ -205,7 +214,8 @@ load_patterns_from_location<TFloat>( const string& loc, pattern::TOrigin origin)
 }
 
 
-} // namespace pattern
+}
+} // namespace agh::pattern
 
 // Local Variables:
 // Mode: c++
diff --git a/upstream/src/aghermann/patterns/patterns.hh b/upstream/src/aghermann/patterns/patterns.hh
index d412864..629ac26 100644
--- a/upstream/src/aghermann/patterns/patterns.hh
+++ b/upstream/src/aghermann/patterns/patterns.hh
@@ -9,8 +9,8 @@
  *         License:  GPL
  */
 
-#ifndef _SIGPROC_PATTERNS_H
-#define _SIGPROC_PATTERNS_H
+#ifndef AGH_AGHERMANN_PATTERNS_H_
+#define AGH_AGHERMANN_PATTERNS_H_
 
 #include <stdexcept>
 #include <tuple>
@@ -19,6 +19,7 @@
 #include <gsl/gsl_math.h>
 
 #include "libsigproc/sigproc.hh"
+#include "aghermann/expdesign/expdesign.hh"  // for enum TExpDirLevel
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -26,6 +27,7 @@
 
 using namespace std;
 
+namespace agh {
 namespace pattern {
 
 template <typename T>
@@ -35,6 +37,9 @@ class CMatch
         CMatch ()
               : tuple<T, T, T, T> (.1, .1, .1, .1) // empirically ok default
                 {}
+        CMatch (T t1, T t2, T t3, T t4)
+              : tuple<T, T, T, T> (t1, t2, t3, t4)
+                {}
 
         bool good_enough( const CMatch<T>& rv) const
                 {
@@ -47,6 +52,11 @@ class CMatch
 
 template <typename T>
 struct SPatternPPack {
+        SPatternPPack ()
+                {
+                        make_sane();
+                }
+
         double  env_scope;
         double  bwf_ffrom,
                 bwf_fupto;
@@ -54,7 +64,9 @@ struct SPatternPPack {
         double  dzcdf_step,
                 dzcdf_sigma;
         int     dzcdf_smooth;
-        bool operator==( const SPatternPPack<T>& rv) const // cannot be defaulted!
+
+        bool
+        operator==( const SPatternPPack<T>& rv) const
                 {
                         return  env_scope == rv.env_scope &&
                                 bwf_ffrom == rv.bwf_ffrom &&
@@ -64,7 +76,8 @@ struct SPatternPPack {
                                 dzcdf_sigma == rv.dzcdf_sigma &&
                                 dzcdf_smooth == rv.dzcdf_smooth;
                 }
-        bool sane() const
+        bool
+        is_sane() const
                 {
                         return  env_scope > 0. && env_scope <= 1. &&
                                 bwf_ffrom < bwf_fupto &&
@@ -75,10 +88,24 @@ struct SPatternPPack {
                                 dzcdf_sigma > 0. && dzcdf_sigma <= 1. &&
                                 dzcdf_smooth >= 0 && dzcdf_smooth <= 50;
                 }
-}; // keep fields in order, or edit ctor by initializer_list
 
+        void
+        make_sane()
+                {
+                        env_scope = .25;
+                        bwf_ffrom = 0.;
+                        bwf_fupto = 1.5;
+                        bwf_order = 1;
+                        dzcdf_step = .1;
+                        dzcdf_sigma = .5;
+                        dzcdf_smooth = 3;
+                }
+};
 
 
+
+using TContext = pair<size_t, size_t>;
+
 template <typename T>
 class CPatternTool
   : public SPatternPPack<T> {
@@ -92,42 +119,42 @@ class CPatternTool
       // (d) instantaneous frequency at fine intervals;
 
         CPatternTool (const sigproc::SSignalRef<T>& thing,
-                      size_t ctx_before_, size_t ctx_after_,
+                      const TContext& context_,
                       const SPatternPPack<T>& Pp_)
               : SPatternPPack<T> (Pp_),
-                penv (thing),
-                ptarget_freq (thing),
-                pdzcdf (thing),
-                samplerate (thing.samplerate),
-                ctx_before (ctx_before_), ctx_after (ctx_after_)
+                penv             (thing),
+                ptarget_freq     (thing),
+                pdzcdf           (thing),
+                samplerate       (thing.samplerate),
+                context          (context_)
                 {
-                        if ( ctx_before + ctx_after >= thing.signal.size() )
+                        if ( context.first + context.second >= thing.signal.size() )
                                 throw invalid_argument ("pattern size too small");
                 }
 
-        int do_search( const sigproc::SSignalRef<T>& field,
-                       size_t inc);
-        int do_search( const valarray<T>& field,
-                       size_t inc);
-        int do_search( const valarray<T>& env_u,  // broken-down field
-                       const valarray<T>& env_l,
-                       const valarray<T>& target_freq,
-                       const valarray<T>& dzcdf,
-                       size_t inc);
+        int
+        do_search( const sigproc::SSignalRef<T>& field,
+                   size_t inc);
+        int
+        do_search( const valarray<T>& field,
+                   size_t inc);
+        int
+        do_search( const valarray<T>& env_u,  // field broken down
+                   const valarray<T>& env_l,
+                   const valarray<T>& target_freq,
+                   const valarray<T>& dzcdf,
+                   size_t inc);
+
+        size_t
+        size_with_context() const
+                { return ptarget_freq.signal.size(); }
+        size_t
+        size_essential() const
+                { return size_with_context() - context.first - context.second; }
 
         vector<CMatch<T>>
                 diff;
 
-        size_t size_with_context() const
-                {
-                        return ptarget_freq.signal.size();
-                }
-        size_t size_essential() const
-                {
-                        return size_with_context()
-                                - ctx_before - ctx_after;
-                }
-
     private:
         sigproc::SCachedEnvelope<T>
                 penv;
@@ -137,8 +164,8 @@ class CPatternTool
                 pdzcdf;
 
         size_t  samplerate;
-        size_t  ctx_before,
-                ctx_after;
+        TContext
+                context;
 
         T       crit_linear_unity;
         double  crit_dzcdf_unity;
@@ -146,75 +173,159 @@ class CPatternTool
 
 
 
-enum TOrigin { transient, subject, experiment, user, system };
-
-extern const char*
-        origin_markers[5];
-
 
 template <typename T>
 struct SPattern {
+
+        SPattern<T> ()
+              : name   ("(unnamed)"),
+                origin (agh::TExpDirLevel::transient),
+                saved  (false),
+                samplerate (0),
+                context ({0, 0})
+                {}
+
+        explicit SPattern<T> (const SPattern<T>& rv)
+              : name       (rv.name),
+                path       (rv.path),
+                origin     (rv.origin),
+                saved      (rv.saved),
+                thing      (rv.thing),
+                samplerate (rv.samplerate),
+                context    (rv.context),
+                Pp         (rv.Pp),
+                criteria   (rv.criteria)
+                {}
+        explicit SPattern<T> (SPattern<T>&& rv)
+              : name       (move(rv.name)),
+                path       (move(rv.path)),
+                origin     (rv.origin),
+                saved      (rv.saved),
+                thing      (move(rv.thing)),
+                samplerate (rv.samplerate),
+                context    (rv.context),
+                Pp         (move(rv.Pp)),
+                criteria   (move(rv.criteria))
+                {}
+
+        SPattern<T> (valarray<T>&& thing_,
+                     size_t samplerate_,
+                     const TContext& context_,
+                     const SPatternPPack<TFloat>& Pp_,
+                     CMatch<T> criteria_)
+              : name       ("(unnamed)"),
+                origin     (agh::TExpDirLevel::transient),
+                saved      (false),
+                thing      (move(thing_)),
+                samplerate (samplerate_),
+                context    (context_),
+                Pp         (Pp_),
+                criteria   (criteria_)
+                {}
+
+        explicit SPattern<T> (const string& fname)
+                {
+                        load( fname);
+                }
+
+        SPattern&
+        operator=( SPattern<T>&& rv)
+                {
+                        swap       (name, rv.name);
+                        swap       (path, rv.path);
+                        origin      = rv.origin;
+                        saved       = rv.saved;
+                        swap       (thing, rv.thing);
+                        samplerate  = rv.samplerate;
+                        context     = rv.context;
+                        swap       (Pp, rv.Pp);
+                        swap       (criteria, rv.criteria);
+                        return *this;
+                }
+
+        bool
+        operator==( const SPattern<T>& rv) const
+                { return origin == rv.origin && name == rv.name; }
+
+        size_t
+        pattern_size_essential() const
+                { return thing.size() - context.first - context.second; }
+
+        double
+        pattern_length() const // in seconds
+                { return (double)thing.size() / samplerate; }
+
+        double
+        pattern_length_essential() const
+                { return (double)pattern_size_essential() / samplerate; }
+
+        int
+        load( const string&);
+
+        int
+        save();
+
+        int
+        delete_file();
+
         string  name,
                 path;
 
-        TOrigin origin;
+        TExpDirLevel
+                origin;
 
         bool    saved:1;
 
         valarray<T>
                 thing;
         size_t  samplerate;
-        size_t  context_before,
-                context_after;
+        pair<size_t,size_t>
+                context;
         static const size_t
                 context_pad = 100;
-        size_t pattern_size_essential() const
-                {
-                        return thing.size() - context_before - context_after;
-                }
-
-        double pattern_length() const // in seconds
-                {
-                        return (double)thing.size() / samplerate;
-                }
-
-        double pattern_length_essential() const
-                {
-                        return (double)pattern_size_essential() / samplerate;
-                }
 
         SPatternPPack<TFloat>
                 Pp;
         CMatch<T>
                 criteria;
-
-        bool operator==( const SPattern<T>& rv) const
-                {
-                        return origin == rv.origin && name == rv.name;
-                }
 };
 
 
 template <typename T>
 list<SPattern<T>>
-load_patterns_from_location( const string&, TOrigin);
+load_patterns_from_location( const string&, TExpDirLevel);
 
-template <typename T>
-SPattern<T>
-load_pattern( const char*) throw(invalid_argument);
 
-template <typename T>
-int
-save_pattern( SPattern<T>&, const char*);
+inline string
+make_system_location()
+{
+        return PACKAGE_DATADIR "/patterns";
+}
 
-template <typename T>
-int
-delete_pattern( const SPattern<T>&);
+inline string
+make_user_location()
+{
+        return move(agh::str::sasprintf( "%s/.local/share/aghermann/patterns", getenv("HOME")));
+}
 
-#include "patterns.ii"
+inline string
+make_experiment_location( const agh::CExpDesign& ED)
+{
+        return move(agh::str::sasprintf( "%s/.patterns", ED.session_dir()));
+}
+
+inline string
+make_subject_location( const agh::CExpDesign& ED, const agh::CSubject& J)
+{
+        return move(agh::str::sasprintf( "%s/.patterns", ED.subject_dir( J).c_str()));
+}
 
 
-} // namespace pattern
+
+#include "patterns.ii"
+
+}
+} // namespace agh::pattern
 
 
 #endif
diff --git a/upstream/src/aghermann/patterns/patterns.ii b/upstream/src/aghermann/patterns/patterns.ii
index b97a84e..034ea76 100644
--- a/upstream/src/aghermann/patterns/patterns.ii
+++ b/upstream/src/aghermann/patterns/patterns.ii
@@ -9,7 +9,7 @@
  *         License:  GPL
  */
 
-extern template CPatternTool<TFloat>::CPatternTool( const sigproc::SSignalRef<TFloat>&, size_t, size_t, const SPatternPPack&);
+extern template CPatternTool<TFloat>::CPatternTool( const sigproc::SSignalRef<TFloat>&, const TContext&, const SPatternPPack&);
 extern template int CPatternTool<TFloat>::do_search( const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, const valarray<TFloat>&, size_t);
 extern template int CPatternTool<TFloat>::do_search( const sigproc::SSignalRef<TFloat>&, size_t);
 extern template int CPatternTool<TFloat>::do_search( const valarray<TFloat>&, size_t);
@@ -48,7 +48,7 @@ do_search( const valarray<T>& fenv_l,
 
         size_t        essential_part = size_essential();
         for ( ssize_t i = 0; i+inc < fsize - essential_part; i += inc ) {
-                auto        p0 = penv.centre( SPatternPPack<T>::env_scope),
+                auto    p0 = penv.centre( SPatternPPack<T>::env_scope),
                         p1 = penv.breadth( SPatternPPack<T>::env_scope),
                         p2 = ptarget_freq( SPatternPPack<T>::bwf_ffrom,
                                            SPatternPPack<T>::bwf_fupto,
@@ -59,10 +59,10 @@ do_search( const valarray<T>& fenv_l,
 
                 T        d0 = 0., d1 = 0., d2 = 0., d3 = 0.;
                 for ( size_t j = 0; j < essential_part; ++j ) {
-                        d0 += gsl_pow_2( p0[ctx_before + j] - (fenv_u[i+j] + fenv_l[i+j])/2);
-                        d1 += gsl_pow_2( p1[ctx_before + j] - (fenv_u[i+j] - fenv_l[i+j]));
-                        d2 += gsl_pow_2( p2[ctx_before + j] - ftarget_freq[i+j]);
-                        d3 += gsl_pow_2( p3[ctx_before + j] - fdzcdf[i+j]);
+                        d0 += gsl_pow_2( p0[context.first + j] - (fenv_u[i+j] + fenv_l[i+j])/2);
+                        d1 += gsl_pow_2( p1[context.first + j] - (fenv_u[i+j] - fenv_l[i+j]));
+                        d2 += gsl_pow_2( p2[context.first + j] - ftarget_freq[i+j]);
+                        d3 += gsl_pow_2( p3[context.first + j] - fdzcdf[i+j]);
                 }
 
                 get<0>(diff[i]) = sqrt(d0 / essential_part) / crit_linear_unity; // normalise
diff --git a/upstream/src/aghermann/rk1968/Makefile.am b/upstream/src/aghermann/rk1968/Makefile.am
index 2f5d2ed..233fffa 100644
--- a/upstream/src/aghermann/rk1968/Makefile.am
+++ b/upstream/src/aghermann/rk1968/Makefile.am
@@ -1,9 +1,11 @@
 AM_CXXFLAGS := \
 	-Wall -std=c++0x -fno-rtti \
-	-I$(top_srcdir)/src
+	-I$(top_srcdir)/src \
+	-DPACKAGE_DATADIR=\"$(datadir)\"
 
 noinst_LIBRARIES := liba.a
 
 liba_a_SOURCES := \
+	rk1968-profiles.cc \
 	rk1968.cc \
 	rk1968.hh
diff --git a/upstream/src/aghermann/rk1968/rk1968-profiles.cc b/upstream/src/aghermann/rk1968/rk1968-profiles.cc
new file mode 100644
index 0000000..ead52b9
--- /dev/null
+++ b/upstream/src/aghermann/rk1968/rk1968-profiles.cc
@@ -0,0 +1,129 @@
+/*
+ *       File name:  aghermann/rk1968/rk1968-profiles.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-09-09
+ *
+ *         Purpose:  scoring assistant, profiles handling
+ *
+ *         License:  GPL
+ */
+
+
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include "common/fs.hh"
+#include "aghermann/expdesign/subject.hh"
+#include "aghermann/expdesign/expdesign.hh"
+
+#include "rk1968.hh"
+
+
+using namespace std;
+using namespace agh::rk1968;
+
+
+string
+make_system_profiles_location()
+{
+        return  PACKAGE_DATADIR "/rk1968_profiles";
+}
+
+string
+make_user_profiles_location()
+{
+        return agh::str::sasprintf( "%s/.local/share/aghermann/rk1968_profiles", getenv("HOME"));
+}
+
+string
+make_experiment_profiles_location( const agh::CExpDesign& ED)
+{
+        return agh::str::sasprintf( "%s/.rk1968_profiles", ED.session_dir());
+}
+
+string
+make_subject_profiles_location( const agh::CExpDesign& ED, const agh::CSubject& J)
+{
+        return agh::str::sasprintf( "%s/.rk1968_profiles", ED.subject_dir( J).c_str());
+}
+
+
+
+int
+CScoreAssistant::
+load()
+{
+	
+	return 0;
+}
+
+
+int
+CScoreAssistant::
+save()
+{
+        if ( saved || origin == agh::TExpDirLevel::transient || origin == agh::TExpDirLevel::system )
+                return 0;
+
+        if ( agh::fs::mkdir_with_parents( agh::fs::dirname(path)) ) {
+                fprintf( stderr, "save_profile(\"%s\"): mkdir failed\n", path.c_str());
+                return -1;
+        }
+
+	
+	saved = true;
+	return 0;
+}
+
+int
+CScoreAssistant::
+delete_file()
+{
+        return unlink( path.c_str());
+}
+
+
+
+namespace {
+int
+scandir_filter( const struct dirent *e)
+{
+        return strcmp( e->d_name, ".") && strcmp( e->d_name, "..");
+}
+}
+
+list<CScoreAssistant>
+load_profiles_from_location( const string& loc, agh::TExpDirLevel origin)
+{
+        list<CScoreAssistant>
+                ret;
+
+        struct dirent **eps;
+        int     total = scandir( loc.c_str(), &eps, scandir_filter, alphasort);
+
+        if ( total != -1 ) {
+                for ( int i = 0; i < total; ++i ) {
+                        try {
+                                ret.emplace_back( loc + '/' + eps[i]->d_name);
+                                ret.back().origin = origin;
+                        } catch (invalid_argument& ex) {
+                                ;
+                        }
+                        free( eps[i]);
+                }
+                free( (void*)eps);
+        }
+
+        return move(ret);
+}
+
+
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index a6fc75f..ac30af2 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -25,6 +25,15 @@
 using namespace std;
 using namespace agh::rk1968;
 
+
+CScoreAssistant::
+CScoreAssistant (const string& fname)
+{
+	
+}
+
+
+
 int
 CScoreAssistant::
 score( agh::SEpisode& E)
@@ -55,7 +64,7 @@ score( agh::SEpisode& E)
                 int decision = 0;
                 for ( ; Di != courses_delta.end(); ++Di, ++Ti )
                         decision +=
-                                ( (*Di)[p] > (*Ti)[p] * nrem3_delta_theta_ratio );
+                                ( (*Di)[p] > (*Ti)[p] * Pp.nrem3_delta_theta_ratio );
                 if ( decision > 0 )
                         firstsource[p].mark( sigfile::SPage::TScore::nrem3);
         }
@@ -63,6 +72,8 @@ score( agh::SEpisode& E)
 }
 
 
+
+
 // Local Variables:
 // Mode: c++
 // indent-tabs-mode: nil
diff --git a/upstream/src/aghermann/rk1968/rk1968.hh b/upstream/src/aghermann/rk1968/rk1968.hh
index 84bfd7d..1b37368 100644
--- a/upstream/src/aghermann/rk1968/rk1968.hh
+++ b/upstream/src/aghermann/rk1968/rk1968.hh
@@ -9,10 +9,14 @@
  *         License:  GPL
  */
 
-#ifndef _AGH_RK1968_H
-#define _AGH_RK1968_H
+#ifndef AGH_AGHERMANN_RK1968_H_
+#define AGH_AGHERMANN_RK1968_H_
 
-#include "aghermann/expdesign/forward-decls.hh"
+#include <string>
+#include <list>
+#include "aghermann/expdesign/expdesign.hh"
+
+using namespace std;
 
 namespace agh {
 namespace rk1968 {
@@ -26,18 +30,36 @@ struct SScoreAssistantPPack {
                 {}
 };
 
-class CScoreAssistant
-  : public SScoreAssistantPPack {
+class CScoreAssistant {
 
     public:
+        CScoreAssistant (const string& fname);
+
         int score( agh::SEpisode&);
+
+        int save();
+        int load();
+        int delete_file();
+
+        string  name,
+                path;
+
+        TExpDirLevel
+                origin;
+
+        bool    saved:1;
+
+        SScoreAssistantPPack
+                Pp;
 };
 
+list<CScoreAssistant>
+load_profiles_from_location( const string& loc, agh::TExpDirLevel);
 
 } // namespace rk1968
 } // namespace agh
 
-#endif // _AGH_RK1968_H
+#endif
 
 // Local Variables:
 // Mode: c++
diff --git a/upstream/src/aghermann/ui/mw/splash.cc b/upstream/src/aghermann/ui/mw/splash.cc
index cae4c82..1a8b833 100644
--- a/upstream/src/aghermann/ui/mw/splash.cc
+++ b/upstream/src/aghermann/ui/mw/splash.cc
@@ -106,7 +106,7 @@ show_empty_experiment_blurb()
         gtk_box_pack_start(
                 (GtkBox*)cMeasurements,
                 (GtkWidget*)gtk_image_new_from_file(
-                        PACKAGE_DATADIR "/" PACKAGE "/idle-bg.svg"),
+                        PACKAGE_DATADIR "/idle-bg.svg"),
                 TRUE, FALSE, 0);
 
         gtk_widget_show_all( (GtkWidget*)cMeasurements);
@@ -141,7 +141,7 @@ try_download()
         const char *argv[] = {
                 "/bin/sh", // vte_get_user_shell(),
                 "-c",
-                "source " PACKAGE_DATADIR "/" PACKAGE "/experiment-dl.sh",
+                "source " PACKAGE_DATADIR "/experiment-dl.sh",
                 NULL
         };
         vte_terminal_fork_command_full(
diff --git a/upstream/src/aghermann/ui/sf/Makefile.am b/upstream/src/aghermann/ui/sf/Makefile.am
index 8f42c13..841d52c 100644
--- a/upstream/src/aghermann/ui/sf/Makefile.am
+++ b/upstream/src/aghermann/ui/sf/Makefile.am
@@ -46,4 +46,9 @@ liba_a_SOURCES := \
 	d/phasediff.hh \
 	d/phasediff.cc \
 	d/phasediff-construct.cc \
-	d/phasediff_cb.cc
+	d/phasediff_cb.cc \
+	d/rk1968.hh \
+	d/rk1968.cc \
+	d/rk1968-construct.cc \
+	d/rk1968-profiles.cc \
+	d/rk1968_cb.cc
diff --git a/upstream/src/aghermann/ui/sf/channel.cc b/upstream/src/aghermann/ui/sf/channel.cc
index 0828b52..346c298 100644
--- a/upstream/src/aghermann/ui/sf/channel.cc
+++ b/upstream/src/aghermann/ui/sf/channel.cc
@@ -16,6 +16,7 @@
 #include "common/config-validate.hh"
 #include "libsigproc/exstrom.hh"
 #include "libmetrics/bands.hh"
+#include "aghermann/patterns/patterns.hh"
 #include "aghermann/ui/globals.hh"
 #include "aghermann/ui/mw/mw.hh"
 
@@ -27,10 +28,6 @@
 using namespace std;
 using namespace agh::ui;
 
-pattern::SPatternPPack<TFloat>
-        SScoringFacility::SChannel::pattern_params =
-                {.25,  0., 1.5, 1,  .1, .5, 3};
-
 using agh::confval::SValidator;
 
 SScoringFacility::SChannel::
diff --git a/upstream/src/aghermann/ui/sf/channel.hh b/upstream/src/aghermann/ui/sf/channel.hh
index eb2b52d..fdd2d90 100644
--- a/upstream/src/aghermann/ui/sf/channel.hh
+++ b/upstream/src/aghermann/ui/sf/channel.hh
@@ -25,7 +25,7 @@
 #include "libmetrics/mc-artifacts.hh"
 #include "libmetrics/page-metrics-base.hh"
 #include "libmetrics/bands.hh"
-#include "aghermann/patterns/forward-decls.hh"
+#include "aghermann/patterns/patterns.hh"
 #include "aghermann/expdesign/forward-decls.hh"
 #include "aghermann/expdesign/recording.hh"
 
@@ -99,8 +99,9 @@ struct SScoringFacility::SChannel {
         in_annotations( double time) const;
 
       // signal metrics
-	static pattern::SPatternPPack<TFloat>
+        agh::pattern::SPatternPPack<TFloat>
                 pattern_params;
+
         sigproc::SCachedLowPassCourse<TFloat>
                 signal_lowpass;
         sigproc::SCachedBandPassCourse<TFloat>
diff --git a/upstream/src/aghermann/ui/sf/d/patterns-draw.cc b/upstream/src/aghermann/ui/sf/d/patterns-draw.cc
index 88597d1..74e8b58 100644
--- a/upstream/src/aghermann/ui/sf/d/patterns-draw.cc
+++ b/upstream/src/aghermann/ui/sf/d/patterns-draw.cc
@@ -88,9 +88,9 @@ draw_thing( cairo_t *cr)
         // lines marking out context
         cairo_set_source_rgba( cr, 0.9, 0.9, 0.9, .5);
         cairo_set_line_width( cr, 1.);
-        cairo_rectangle( cr, 0., 0., (float)current_pattern->context_before / current_pattern->thing.size() * da_thing_wd, da_thing_ht);
-        cairo_rectangle( cr, (float)(current_pattern->context_before + run) / current_pattern->thing.size() * da_thing_wd, 0,
-                         (float)(current_pattern->context_after) / current_pattern->thing.size() * da_thing_wd, da_thing_ht);
+        cairo_rectangle( cr, 0., 0., (float)current_pattern->context.first / current_pattern->thing.size() * da_thing_wd, da_thing_ht);
+        cairo_rectangle( cr, (float)(current_pattern->context.first + run) / current_pattern->thing.size() * da_thing_wd, 0,
+                         (float)(current_pattern->context.second) / current_pattern->thing.size() * da_thing_wd, da_thing_ht);
         cairo_fill( cr);
         cairo_stroke( cr);
 
diff --git a/upstream/src/aghermann/ui/sf/d/patterns-profiles.cc b/upstream/src/aghermann/ui/sf/d/patterns-profiles.cc
index 277db4a..95f67ec 100644
--- a/upstream/src/aghermann/ui/sf/d/patterns-profiles.cc
+++ b/upstream/src/aghermann/ui/sf/d/patterns-profiles.cc
@@ -20,6 +20,21 @@ using namespace std;
 using namespace agh::ui;
 
 
+list<agh::pattern::SPattern<TFloat>>::iterator
+SScoringFacility::SPatternsDialog::
+pattern_by_idx( size_t idx)
+{
+        size_t i = 0;
+        for ( auto I = patterns.begin(); I != patterns.end(); ++I )
+                if ( i == idx )
+                        return I;
+                else
+                        ++i;
+        throw invalid_argument ("Current pattern index invalid");
+}
+
+
+
 int
 SScoringFacility::SPatternsDialog::
 import_from_selection( SScoringFacility::SChannel& field)
@@ -44,26 +59,27 @@ import_from_selection( SScoringFacility::SChannel& field)
                      "Sure to proceed with search?") )
                 return -3;
 
-        size_t  context_before = // agh::alg::ensure_within(
-                (field.selection_start < current_pattern->context_pad)
+        size_t  context_before // agh::alg::ensure_within(
+                = (field.selection_start < current_pattern->context_pad)
                 ? pattern::SPattern<TFloat>::context_pad - field.selection_start
                 : pattern::SPattern<TFloat>::context_pad,
-                context_after  = (field.selection_end + pattern::SPattern<TFloat>::context_pad > field.n_samples())
+                context_after
+                = (field.selection_end + pattern::SPattern<TFloat>::context_pad > field.n_samples())
                 ? field.n_samples() - field.selection_end
                 : pattern::SPattern<TFloat>::context_pad,
                 full_sample = run + context_before + context_after;
-        pattern::SPattern<TFloat> tim {
-                "(unnamed)", "", pattern::TOrigin::transient, false,
-                {field.signal_filtered[ slice (field.selection_start - context_before, full_sample, 1) ]},
-                field.samplerate(),
-                context_before, context_after,
-                Pp2, criteria};
+
         // transient is always the last
-        ((not patterns.empty() and patterns.back().origin == pattern::TOrigin::transient)
-         ? patterns.back()
-         : (patterns.push_back( pattern::SPattern<TFloat> ()), patterns.back())
-                ) = tim;
+        if ( patterns.empty() || patterns.back().origin != TExpDirLevel::transient )
+                patterns.emplace_back();
+        patterns.back() = pattern::SPattern<TFloat> (
+                {{field.signal_filtered[ slice (field.selection_start - context_before, full_sample, 1) ]},
+                field.samplerate(),
+                {context_before, context_after},
+                Pp2, criteria});
+
         current_pattern = prev(patterns.end());
+
         populate_combo();
 
         field_channel_saved = field_channel = &field;
@@ -83,39 +99,6 @@ import_from_selection( SScoringFacility::SChannel& field)
 
 
 
-namespace {
-const char*
-        origin_markers[5] = {
-        "~", "[S]", "[E]", "[U]", "<S>",
-};
-}
-
-
-string
-make_system_patterns_location()
-{
-        return agh::str::sasprintf( "%s/patterns", PACKAGE_DATADIR);
-}
-
-string
-make_user_patterns_location()
-{
-        return agh::str::sasprintf( "%s/.local/share/aghermann/patterns", getenv("HOME"));
-}
-
-string
-make_experiment_patterns_location( const agh::CExpDesign& ED)
-{
-        return agh::str::sasprintf( "%s/.patterns", ED.session_dir());
-}
-
-string
-make_subject_patterns_location( const agh::CExpDesign& ED, const agh::CSubject& J)
-{
-        return agh::str::sasprintf( "%s/.patterns", ED.subject_dir( J).c_str());
-}
-
-
 
 void
 SScoringFacility::SPatternsDialog::
@@ -123,22 +106,28 @@ load_patterns()
 {
         patterns.clear();
 
+        using namespace agh;
+        using pattern::load_patterns_from_location;
         patterns.splice(
-                patterns.end(), pattern::load_patterns_from_location<TFloat>(
-                        make_system_patterns_location(),
-                        pattern::TOrigin::system));
+                patterns.end(),
+                load_patterns_from_location<TFloat>(
+                        pattern::make_system_location(),
+                        TExpDirLevel::system));
         patterns.splice(
-                patterns.end(), pattern::load_patterns_from_location<TFloat>(
-                        make_user_patterns_location(),
-                        pattern::TOrigin::user));
+                patterns.end(),
+                load_patterns_from_location<TFloat>(
+                        pattern::make_user_location(),
+                        TExpDirLevel::user));
         patterns.splice(
-                patterns.end(), pattern::load_patterns_from_location<TFloat>(
-                        make_experiment_patterns_location( *_p._p.ED),
-                        pattern::TOrigin::experiment));
+                patterns.end(),
+                load_patterns_from_location<TFloat>(
+                        pattern::make_experiment_location( *_p._p.ED),
+                        TExpDirLevel::experiment));
         patterns.splice(
-                patterns.end(), pattern::load_patterns_from_location<TFloat>(
-                        make_subject_patterns_location( *_p._p.ED, _p.csubject()),
-                        pattern::TOrigin::subject));
+                patterns.end(),
+                load_patterns_from_location<TFloat>(
+                        pattern::make_subject_location( *_p._p.ED, _p.csubject()),
+                        TExpDirLevel::subject));
 
         current_pattern = patterns.end();
 }
@@ -157,7 +146,7 @@ populate_combo()
                         gtk_list_store_append( mSFFDPatterns, &iter);
                         gtk_list_store_set(
                                 mSFFDPatterns, &iter,
-                                0, snprintf_buf( "%s %s", origin_markers[I->origin], I->name.c_str()),
+                                0, snprintf_buf( "%s %s", agh::exp_dir_level_s(I->origin), I->name.c_str()),
                                 -1);
                         if ( I == current_pattern )
                                 current_pattern_iter = iter;
@@ -177,23 +166,7 @@ SScoringFacility::SPatternsDialog::
 save_patterns()
 {
         for ( auto& P : patterns )
-                if ( not P.saved ) {
-                        switch ( P.origin ) {
-                        case pattern::TOrigin::transient: // never save these two
-                        case pattern::TOrigin::system:
-                            break;
-                        case pattern::TOrigin::user:
-                                pattern::save_pattern( P, (make_user_patterns_location() + '/' + P.name).c_str());
-                            break;
-                        case pattern::TOrigin::experiment:
-                                pattern::save_pattern( P, (make_experiment_patterns_location(*_p._p.ED) + '/' + P.name).c_str());
-                            break;
-                        case pattern::TOrigin::subject:
-                                pattern::save_pattern( P, (make_subject_patterns_location(*_p._p.ED, _p.csubject()) + '/' + P.name).c_str());
-                            break;
-                        }
-                        P.saved = true;
-                }
+                P.save();
 }
 
 
@@ -206,7 +179,7 @@ discard_current_pattern()
 
         auto todelete = current_pattern;
         current_pattern = next(current_pattern);
-        pattern::delete_pattern( *todelete);
+        todelete->delete_file();
         patterns.erase( todelete);
 }
 
diff --git a/upstream/src/aghermann/ui/sf/d/patterns-profiles_cb.cc b/upstream/src/aghermann/ui/sf/d/patterns-profiles_cb.cc
index 3b05808..baff403 100644
--- a/upstream/src/aghermann/ui/sf/d/patterns-profiles_cb.cc
+++ b/upstream/src/aghermann/ui/sf/d/patterns-profiles_cb.cc
@@ -13,6 +13,9 @@
 
 #include "aghermann/ui/misc.hh"
 #include "aghermann/ui/sf/channel.hh"
+#include "aghermann/ui/sf/sf.hh"
+#include "aghermann/ui/mw/mw.hh"
+#include "aghermann/expdesign/expdesign.hh"
 #include "patterns.hh"
 
 
@@ -61,25 +64,31 @@ bSFFDProfileSave_clicked_cb(
 
         g_signal_emit_by_name( FD.eSFFDPatternSaveName, "changed");
 
-        if ( gtk_dialog_run( FD.wSFFDPatternSave) == GTK_RESPONSE_OK ) {
-                pattern::SPattern<TFloat> P (*FD.current_pattern);
+        if ( GTK_RESPONSE_OK == gtk_dialog_run( FD.wSFFDPatternSave) ) {
+                using namespace agh;
+
+                // replace unnamed, else make a duplicate
+                auto& P = (FD.current_pattern->origin == agh::TExpDirLevel::transient)
+                        ? *FD.current_pattern
+                        : (FD.patterns.insert(FD.current_pattern, *FD.current_pattern),
+                           *(++FD.current_pattern));
+
                 P.name = gtk_entry_get_text( FD.eSFFDPatternSaveName);
-                P.origin = gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
-                        ? pattern::TOrigin::subject
+
+                tie(P.origin, P.path) =
+                        gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
+                        ? make_tuple(
+                                TExpDirLevel::subject,
+                                pattern::make_subject_location( *FD._p._p.ED, FD._p.csubject()))
                         : gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginExperiment)
-                        ? pattern::TOrigin::experiment
-                        : pattern::TOrigin::user;
-                P.saved = false;
+                        ? make_tuple(
+                                TExpDirLevel::experiment,
+                                pattern::make_experiment_location( *FD._p._p.ED))
+                        : make_tuple(
+                                TExpDirLevel::user,
+                                pattern::make_user_location());
 
-                if ( FD.current_pattern->origin == pattern::TOrigin::transient ) // replace unnamed
-                        FD.patterns.back() = P;
-                else {
-                        auto found = find( FD.patterns.begin(), FD.patterns.end(), P);
-                        if ( found == FD.patterns.end() )
-                                FD.patterns.insert( FD.current_pattern, move(P));
-                        else
-                                *(FD.current_pattern = found) = P;
-                }
+                P.saved = false;
 
                 FD.populate_combo();
                 FD.set_profile_manage_buttons_visibility();
@@ -97,12 +106,13 @@ hildebranden( const gpointer userdata)
                 (GtkWidget*)FD.bSFFDPatternSaveOK,
                 gtk_entry_get_text_length( FD.eSFFDPatternSaveName) > 0);
 
+        using namespace agh;
         auto this_name = gtk_entry_get_text( FD.eSFFDPatternSaveName);
         auto this_origin = gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginSubject)
-                        ? pattern::TOrigin::subject
+                        ? TExpDirLevel::subject
                         : gtk_toggle_button_get_active( FD.eSFFDPatternSaveOriginExperiment)
-                        ? pattern::TOrigin::experiment
-                        : pattern::TOrigin::user;
+                        ? TExpDirLevel::experiment
+                        : TExpDirLevel::user;
 
         bool overwriting =
                 find_if( FD.patterns.begin(), FD.patterns.end(),
@@ -141,7 +151,7 @@ bSFFDProfileDiscard_clicked_cb(
         gint ci = gtk_combo_box_get_active( FD.eSFFDPatternList);
 
         assert ( FD.current_pattern != FD.patterns.end() );
-        assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
+        assert ( FD.current_pattern->origin != agh::TExpDirLevel::transient );
         assert ( ci != -1 );
         assert ( ci < (int)FD.patterns.size() );
 
@@ -170,7 +180,7 @@ bSFFDProfileRevert_clicked_cb(
         auto& FD = *(SScoringFacility::SPatternsDialog*)userdata;
 
         assert ( FD.current_pattern != FD.patterns.end() );
-        assert ( FD.current_pattern->origin != pattern::TOrigin::transient );
+        assert ( FD.current_pattern->origin != agh::TExpDirLevel::transient );
 
         FD.Pp2 = FD.current_pattern->Pp;
         FD.criteria = FD.current_pattern->criteria;
diff --git a/upstream/src/aghermann/ui/sf/d/patterns.cc b/upstream/src/aghermann/ui/sf/d/patterns.cc
index 090980c..674d4ad 100644
--- a/upstream/src/aghermann/ui/sf/d/patterns.cc
+++ b/upstream/src/aghermann/ui/sf/d/patterns.cc
@@ -29,7 +29,6 @@ patterns_d()
 SScoringFacility::SPatternsDialog::
 SPatternsDialog (SScoringFacility& parent)
       : SPatternsDialogWidgets (parent),
-        Pp2 {.25,  0., 1.5, 1,  .1, .5, 3},
         increment (.03),
         field_profile_type (metrics::TType::mc),
         suppress_redraw (false),
@@ -69,20 +68,6 @@ SScoringFacility::SPatternsDialog::
 
 
 
-list<pattern::SPattern<TFloat>>::iterator
-SScoringFacility::SPatternsDialog::
-pattern_by_idx( size_t idx)
-{
-        size_t i = 0;
-        for ( auto I = patterns.begin(); I != patterns.end(); ++I )
-                if ( i == idx )
-                        return I;
-                else
-                        ++i;
-        throw invalid_argument ("Current pattern index invalid");
-}
-
-
 
 
 void
@@ -96,7 +81,7 @@ search()
 
         pattern::CPatternTool<TFloat> cpattern
                 ({current_pattern->thing, current_pattern->samplerate},
-                 current_pattern->context_before, current_pattern->context_after,
+                 current_pattern->context,
                  Pp2); // use this for the case when modiified current_pattern changes have not been committed
         diff_line =
                 (cpattern.do_search(
@@ -229,7 +214,7 @@ SScoringFacility::SPatternsDialog::
 set_profile_manage_buttons_visibility()
 {
         bool    have_any = current_pattern != patterns.end(),
-                is_transient = have_any && current_pattern->origin == pattern::TOrigin::transient,
+                is_transient = have_any && current_pattern->origin == agh::TExpDirLevel::transient,
                 is_modified  = have_any && not (current_pattern->Pp == Pp2) and not (current_pattern->criteria == criteria);
         gtk_widget_set_visible( (GtkWidget*)bSFFDProfileSave, have_any);
         gtk_widget_set_visible( (GtkWidget*)bSFFDProfileRevert, have_any and not is_transient and is_modified);
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968-construct.cc b/upstream/src/aghermann/ui/sf/d/rk1968-construct.cc
new file mode 100644
index 0000000..f206b8d
--- /dev/null
+++ b/upstream/src/aghermann/ui/sf/d/rk1968-construct.cc
@@ -0,0 +1,65 @@
+/*
+ *       File name:  aghermann/ui/sf/d/rk1968-construct.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-09-07
+ *
+ *         Purpose:  scoring facility RK1968 dialog construct
+ *
+ *         License:  GPL
+ */
+
+#include <stdexcept>
+
+#include "aghermann/ui/ui.hh"
+
+#include "rk1968.hh"
+
+using namespace std;
+using namespace agh::ui;
+
+SRK1968DialogWidgets::
+SRK1968DialogWidgets ()
+{
+        builder = gtk_builder_new();
+        if ( !gtk_builder_add_from_resource( builder, "/org/gtk/aghermann/sf-rk1968.glade", NULL) )
+                throw runtime_error( "Failed to load SF::rk1968 glade resource");
+        gtk_builder_connect_signals( builder, NULL);
+
+        if ( !AGH_GBGETOBJ (GtkDialog,     wSFRK) ||
+             !AGH_GBGETOBJ (GtkButton,     bSFRKProfileRevert) ||
+             !AGH_GBGETOBJ (GtkButton,     bSFRKProfileSave) ||
+             !AGH_GBGETOBJ (GtkButton,     bSFRKProfileDiscard) ||
+             !AGH_GBGETOBJ (GtkComboBox,   eSFRKProfileList) ||
+
+             !AGH_GBGETOBJ (GtkSpinButton, eSFRKNremThetaDeltaRatio) ||
+
+             !AGH_GBGETOBJ (GtkButton,     bSFRKRun) ||
+             !AGH_GBGETOBJ (GtkButton,     bSFRKModify) ||
+             !AGH_GBGETOBJ (GtkLabel,      lSFRKWorking) )
+                throw runtime_error ("Failed to construct SRK1968DialogWidgets");
+
+        mSFRKProfiles =
+                gtk_list_store_new( 1, G_TYPE_STRING);
+
+        gtk_combo_box_set_model_properly( eSFRKProfileList, mSFRKProfiles);
+        eSFRKProfileList_changed_cb_handler_id =
+                G_CONNECT_1 (eSFRKProfileList, changed);
+
+        
+}
+
+
+SRK1968DialogWidgets::
+~SRK1968DialogWidgets ()
+{
+        gtk_widget_destroy( (GtkWidget*)wSFRK);
+        g_object_unref( (GObject*)builder);
+}
+
+
+// Local Variables:
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968-profiles.cc b/upstream/src/aghermann/ui/sf/d/rk1968-profiles.cc
new file mode 100644
index 0000000..72170c8
--- /dev/null
+++ b/upstream/src/aghermann/ui/sf/d/rk1968-profiles.cc
@@ -0,0 +1,126 @@
+/*
+ *       File name:  aghermann/ui/sf/d/rk1968-profiles.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-09-07
+ *
+ *         Purpose:  scoring facility rk1968 profiles (enumerating & io)
+ *
+ *         License:  GPL
+ */
+
+#include <tuple>
+
+#include "aghermann/ui/misc.hh"
+#include "aghermann/ui/sf/channel.hh"
+#include "rk1968.hh"
+
+using namespace std;
+using namespace agh::ui;
+
+
+
+
+
+list<agh::rk1968::CScoreAssistant>::iterator
+SScoringFacility::SRK1968Dialog::
+profile_by_idx( size_t idx)
+{
+        size_t i = 0;
+        for ( auto I = profiles.begin(); I != profiles.end(); ++I )
+                if ( i == idx )
+                        return I;
+                else
+                        ++i;
+        throw invalid_argument ("Current profile index invalid");
+}
+
+
+
+
+void
+SScoringFacility::SRK1968Dialog::
+load_profiles()
+{
+        profiles.clear();
+
+        // profiles.splice(
+        //         profiles.end(), agh::rk1968::load_profile_from_location(
+        //                 make_system_profiles_location(),
+        //                 pattern::TOrigin::system));
+        
+        // patterns.splice(
+        //         patterns.end(), pattern::load_patterns_from_location<TFloat>(
+        //                 make_user_patterns_location(),
+        //                 pattern::TOrigin::user));
+        // patterns.splice(
+        //         patterns.end(), pattern::load_patterns_from_location<TFloat>(
+        //                 make_experiment_patterns_location( *_p._p.ED),
+        //                 pattern::TOrigin::experiment));
+        // patterns.splice(
+        //         patterns.end(), pattern::load_patterns_from_location<TFloat>(
+        //                 make_subject_patterns_location( *_p._p.ED, _p.csubject()),
+        //                 pattern::TOrigin::subject));
+
+        current_profile = profiles.end();
+}
+
+
+void
+SScoringFacility::SRK1968Dialog::
+populate_combo()
+{
+        g_signal_handler_block( eSFRKProfileList, eSFRKProfileList_changed_cb_handler_id);
+        gtk_list_store_clear( mSFRKProfiles);
+
+        if ( not profiles.empty() ) {
+                GtkTreeIter iter, current_profile_iter;
+                for ( auto I = profiles.begin(); I != profiles.end(); ++I ) {
+                        gtk_list_store_append(
+                                mSFRKProfiles, &iter);
+                        gtk_list_store_set(
+                                mSFRKProfiles, &iter,
+                                0, snprintf_buf( "%s %s", agh::exp_dir_level_s(I->origin), I->name.c_str()),
+                                -1);
+                        if ( I == current_profile )
+                                current_profile_iter = iter;
+                }
+
+                gtk_combo_box_set_active_iter( eSFRKProfileList, &current_profile_iter);
+        } else
+                gtk_combo_box_set_active_iter( eSFRKProfileList, NULL);
+
+        g_signal_handler_unblock( eSFRKProfileList, eSFRKProfileList_changed_cb_handler_id);
+}
+
+
+
+void
+SScoringFacility::SRK1968Dialog::
+save_profiles()
+{
+        for ( auto& P : profiles )
+                P.save();
+}
+
+
+void
+SScoringFacility::SRK1968Dialog::
+discard_current_profile()
+{
+        if ( current_profile == profiles.end() )
+                return;
+
+        auto todelete = current_profile;
+        current_profile = next(current_profile);
+        todelete->delete_file();
+        profiles.erase( todelete);
+}
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968.cc b/upstream/src/aghermann/ui/sf/d/rk1968.cc
new file mode 100644
index 0000000..384e496
--- /dev/null
+++ b/upstream/src/aghermann/ui/sf/d/rk1968.cc
@@ -0,0 +1,44 @@
+/*
+ *       File name:  aghermann/ui/sf/d/rk1968.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-01-25
+ *
+ *         Purpose:  scoring facility: rk1968 dialog
+ *
+ *         License:  GPL
+ */
+
+#include "rk1968.hh"
+
+using namespace std;
+using namespace agh::ui;
+
+SScoringFacility::SRK1968Dialog&
+SScoringFacility::
+rk1968_d()
+{
+        if ( not _rk1968_d )
+                _rk1968_d = new SRK1968Dialog(*this);
+        return *_rk1968_d;
+}
+
+
+SScoringFacility::SRK1968Dialog::
+SRK1968Dialog (SScoringFacility& p_)
+      : _p (p_)
+{
+        //W_V.reg( eSFRKNremThetaDeltaRatio,        &A.nrem3_delta_theta_ratio);
+
+        load_profiles();
+}
+
+
+
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968.hh b/upstream/src/aghermann/ui/sf/d/rk1968.hh
index 3a05e6a..a852a70 100644
--- a/upstream/src/aghermann/ui/sf/d/rk1968.hh
+++ b/upstream/src/aghermann/ui/sf/d/rk1968.hh
@@ -12,6 +12,8 @@
 #ifndef AGH_AGHERMANN_UI_SF_D_RK1968_H_
 #define AGH_AGHERMANN_UI_SF_D_RK1968_H_
 
+#include "aghermann/rk1968/rk1968.hh"
+#include "aghermann/ui/ui++.hh"
 #include "aghermann/ui/sf/sf.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
@@ -20,147 +22,63 @@
 
 using namespace std;
 
-namespace aghui {
-
+namespace agh {
+namespace ui {
 
 struct SRK1968DialogWidgets {
 
-        explicit SRK1968DialogWidgets (SScoringFacility&); // need access to mAllChannels
+        SRK1968DialogWidgets ();
        ~SRK1968DialogWidgets ();
 
         GtkBuilder
                 *builder;
-        
-        GtkListStore
-                *mSFFDPatterns,
-                *mSFFDChannels;
+
         GtkDialog
-                *wSFFD;
-        GtkComboBox
-                *eSFFDChannel,
-                *eSFFDPatternList;
-        GtkScrolledWindow
-                *swSFFDThing,
-                *swSFFDField;
-        GtkTable
-                *cSFFDParameters,
-                *cSFFDCriteria,
-                *cSFFDSearchButton,
-                *cSFFDAgainButton;
-        GtkBox  *cSFFDSearching;
-        GtkDrawingArea
-                *daSFFDThing,
-                *daSFFDField;
-        GtkMenuBar
-                *iibSFFDMenu;
-        GtkMenu *iiSFFDField,
-                *iiSFFDFieldProfileTypes;
-        GtkCheckMenuItem
-                *iSFFDFieldDrawMatchIndex;
-        GtkMenuItem
-                *iSFFDMarkPhasicEventSpindles,
-                *iSFFDMarkPhasicEventKComplexes,
-                *iSFFDMarkPlain;
-        GtkRadioMenuItem
-                *iSFFDFieldProfileTypeRaw,
-                *iSFFDFieldProfileTypePSD,
-                *iSFFDFieldProfileTypeMC,
-                *iSFFDFieldProfileTypeSWU;
+                *wSFRK;
+
+        GtkListStore
+                *mSFRKProfiles;
         GtkButton
-                *bSFFDSearch, *bSFFDAgain,
-                *bSFFDProfileSave, *bSFFDProfileDiscard, *bSFFDProfileRevert;
+                *bSFRKProfileRevert,
+                *bSFRKProfileSave,
+                *bSFRKProfileDiscard;
+        GtkComboBox
+                *eSFRKProfileList;
+        gulong  eSFRKProfileList_changed_cb_handler_id;
+
         GtkSpinButton
-                *eSFFDEnvTightness,
-                *eSFFDBandPassFrom, *eSFFDBandPassUpto, *eSFFDBandPassOrder,
-                *eSFFDDZCDFStep, *eSFFDDZCDFSigma, *eSFFDDZCDFSmooth,
-                *eSFFDParameterA, *eSFFDParameterB,
-                *eSFFDParameterC, *eSFFDParameterD,
-                *eSFFDIncrement;
-        GtkHBox
-                *cSFFDLabelBox;
-        GtkLabel
-                *lSFFDParametersBrief,
-                *lSFFDFoundInfo;
-        GtkDialog
-                *wSFFDPatternSave;
-        GtkEntry
-                *eSFFDPatternSaveName;
-        GtkToggleButton
-                *eSFFDPatternSaveOriginSubject,
-                *eSFFDPatternSaveOriginExperiment,
-                *eSFFDPatternSaveOriginUser;
+                *eSFRKNremThetaDeltaRatio;
+
         GtkButton
-                *bSFFDPatternSaveOK;
-        gulong  eSFFDChannel_changed_cb_handler_id,
-                eSFFDPatternList_changed_cb_handler_id;
+                *bSFRKRun,
+                *bSFRKModify;
+        GtkLabel
+                *lSFRKWorking;
 };
 
 
-struct SScoringFacility::SPatternsDialog
-  : public SPatternsDialogWidgets{
+struct SScoringFacility::SRK1968Dialog
+  : public SRK1968DialogWidgets {
 
-        DELETE_DEFAULT_METHODS (SPatternsDialog);
+        DELETE_DEFAULT_METHODS (SRK1968Dialog);
 
       // ctor, dtor
-        explicit SPatternsDialog (SScoringFacility& parent);
-       ~SPatternsDialog ();
-
-      // saved patterns
-        list<pattern::SPattern<TFloat>>
-                patterns;
-        list<pattern::SPattern<TFloat>>::iterator
-                current_pattern;
-        list<pattern::SPattern<TFloat>>::iterator
-        pattern_by_idx( size_t);
-
-        int import_from_selection( SScoringFacility::SChannel&);
-        void load_patterns();
-        void save_patterns();
-        void discard_current_pattern();
+        explicit SRK1968Dialog (SScoringFacility&);
+       ~SRK1968Dialog ();
+
+      // saved profiles
+        list<agh::rk1968::CScoreAssistant>
+                profiles;
+        list<agh::rk1968::CScoreAssistant>::iterator
+                current_profile;
+        list<agh::rk1968::CScoreAssistant>::iterator
+        profile_by_idx( size_t);
+
+        void load_profiles();
+        void save_profiles();
+        void discard_current_profile();
         void populate_combo();
 
-      // finding tool
-          pattern::SPatternPPack<TFloat>
-                Pp2;
-        double  increment; // in seconds
-
-      // matches
-        pattern::CMatch<TFloat>
-                criteria;
-        vector<pattern::CMatch<TFloat>>
-                diff_line;
-        vector<size_t>
-                occurrences;
-        size_t  highlighted_occurrence;
-        void search();
-        size_t find_occurrences();
-        size_t nearest_occurrence( double) const;
-        int     now_tweaking; // limit draw similarity index to this item
-
-      // field
-        SScoringFacility::SChannel
-                *field_channel,
-                *field_channel_saved;
-        list<sigfile::SAnnotation>
-                saved_annotations;
-        void occurrences_to_annotations( sigfile::SAnnotation::TType = sigfile::SAnnotation::TType::plain);
-        void save_annotations();
-        void restore_annotations();
-
-        metrics::TType
-                field_profile_type; // where appropriate; otherwise draw compressed raw
-        void update_field_check_menu_items();
-
-      // draw
-        bool    suppress_w_v:1,
-                suppress_redraw:1,
-                draw_details:1,
-                draw_match_index:1;
-        void draw_thing( cairo_t*);
-        void draw_field( cairo_t*);
-        float   thing_display_scale,
-                field_display_scale;
-
       // widgets
         SUIVarCollection
                 W_V;
@@ -171,57 +89,17 @@ struct SScoringFacility::SPatternsDialog
                         suppress_w_v = false;
                 }
 
-        void preselect_channel( int) const;
-
-        void setup_controls_for_find();
-        void setup_controls_for_wait();
-        void setup_controls_for_tune();
-        void set_profile_manage_buttons_visibility();
-
-        static const int
-                da_thing_ht = 200,
-                da_field_ht = 160;
-        int     da_thing_wd,
-                da_field_wd;
-        void set_thing_da_width( int);
-        void set_field_da_width( int);
+        bool    suppress_w_v;
 
-        aghui::SScoringFacility&
+        SScoringFacility&
                 _p;
 };
 
 
-} // namespace aghui
+}} // namespace aghui
 
 extern "C" {
-void eSFFDPatternList_changed_cb( GtkComboBox*, gpointer);
-void eSFFDChannel_changed_cb( GtkComboBox*, gpointer);
-gboolean daSFFDField_draw_cb( GtkWidget*, cairo_t*, gpointer);
-gboolean daSFFDField_scroll_event_cb( GtkWidget*, GdkEventScroll*, gpointer);
-gboolean daSFFDField_button_press_event_cb( GtkWidget*, GdkEventButton*, gpointer);
-gboolean daSFFDField_motion_notify_event_cb( GtkWidget*, GdkEventMotion*, gpointer);
-gboolean daSFFDThing_draw_cb( GtkWidget*, cairo_t*, gpointer);
-gboolean daSFFDThing_button_press_event_cb( GtkWidget*, GdkEventButton*, gpointer);
-gboolean daSFFDThing_scroll_event_cb( GtkWidget*, GdkEventScroll*, gpointer);
-void bSFFDSearch_clicked_cb( GtkButton*, gpointer);
-void bSFFDAgain_clicked_cb( GtkButton*, gpointer);
-void bSFFDProfileSave_clicked_cb( GtkButton*, gpointer);
-void bSFFDProfileDiscard_clicked_cb( GtkButton*, gpointer);
-void bSFFDProfileRevert_clicked_cb( GtkButton*, gpointer);
-gboolean eSFFD_any_criteria_focus_in_event_cb(GtkWidget*, GdkEvent*, gpointer);
-void wSFFD_show_cb( GtkWidget*, gpointer);
-void wSFFD_hide_cb( GtkWidget*, gpointer);
-gboolean wSFFD_configure_event_cb( GtkWidget*, GdkEventConfigure*, gpointer);
-void iSFFDFieldDrawMatchIndex_toggled_cb( GtkCheckMenuItem*, gpointer);
-void iSFFDMarkPhasicEventSpindles_activate_cb( GtkMenuItem*, gpointer);
-void iSFFDMarkPhasicEventKComplexes_activate_cb( GtkMenuItem*, gpointer);
-void iSFFDMarkPlain_activate_cb( GtkMenuItem*, gpointer);
-void eSFFDPatternSaveName_changed_cb(GtkEditable*, gpointer);
-
-void eSFFD_any_pattern_origin_toggled_cb(GtkRadioButton*, gpointer);
-void eSFFD_any_pattern_value_changed_cb( GtkSpinButton*, gpointer);
-void eSFFD_any_criteria_value_changed_cb( GtkSpinButton*, gpointer);
-void iSFFD_any_field_profile_type_toggled_cb( GtkRadioMenuItem*, gpointer);
+void eSFRKProfileList_changed_cb( GtkComboBox*, gpointer);
 }
 
 #endif // AGH_AGHERMANN_UI_SF_D_RK1968_H_
diff --git a/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
new file mode 100644
index 0000000..7b6cb54
--- /dev/null
+++ b/upstream/src/aghermann/ui/sf/d/rk1968_cb.cc
@@ -0,0 +1,43 @@
+/*
+ *       File name:  aghermann/ui/sf/d/rk1968_cb.cc
+ *         Project:  Aghermann
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2013-09-07
+ *
+ *         Purpose:  scoring facility: RK1968 dialog callbacks
+ *
+ *         License:  GPL
+ */
+
+#include "rk1968.hh"
+
+using namespace std;
+using namespace agh::ui;
+
+extern "C" {
+void eSFRKProfileList_changed_cb(
+        GtkComboBox* combo,
+        gpointer userdata)
+{
+        auto& RK = *(SScoringFacility::SRK1968Dialog*)userdata;
+
+        if ( RK.current_profile != RK.profiles.end() ) {
+                // RK.current_pattern-> = RK.;
+        }
+
+        gint ci = gtk_combo_box_get_active( combo);
+        if ( ci != -1 ) {
+                RK.current_profile = RK.profile_by_idx(ci);
+                //FD.Pp2 = FD.current_pattern->Pp;
+                RK.atomic_up();
+        }
+                //gtk_label_set_text( RK.lSFFDParametersBrief, "");
+}
+
+} // extern "C"
+
+// Local Variables:
+// indent-tabs-mode: nil
+// tab-width: 8
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/aghermann/ui/sf/hypnogram_cb.cc b/upstream/src/aghermann/ui/sf/hypnogram_cb.cc
index 26ebfab..ee16920 100644
--- a/upstream/src/aghermann/ui/sf/hypnogram_cb.cc
+++ b/upstream/src/aghermann/ui/sf/hypnogram_cb.cc
@@ -12,6 +12,7 @@
 #include "aghermann/rk1968/rk1968.hh"
 #include "aghermann/ui/globals.hh"
 #include "sf.hh"
+#include "d/rk1968.hh"
 
 using namespace std;
 using namespace agh::ui;
@@ -105,12 +106,7 @@ iSFScoreAssist_activate_cb(
 {
         auto& SF = *(SScoringFacility*)userdata;
 
-        if ( agh::rk1968::CScoreAssistant().score( SF.sepisode()) == 0 ) {
-                SF.get_hypnogram();
-                SF.calculate_scored_percent();
-                //SF.repaint_score_stats();
-                SF.queue_redraw_all();
-        }
+        gtk_widget_show( (GtkWidget*)SF.rk1968_d().wSFRK);
 }
 
 
diff --git a/upstream/src/aghermann/ui/sf/mainmenu_cb.cc b/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
index 8171150..0a983aa 100644
--- a/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
+++ b/upstream/src/aghermann/ui/sf/mainmenu_cb.cc
@@ -14,6 +14,7 @@
 #include "sf.hh"
 #include "d/patterns.hh"
 #include "d/phasediff.hh"
+#include "d/rk1968.hh"
 
 using namespace std;
 using namespace agh::ui;
@@ -178,7 +179,8 @@ iSFMontageScoreAssist_activate_cb(
         gpointer userdata)
 {
         auto& SF = *(SScoringFacility*)userdata;
-        
+
+        gtk_widget_show( (GtkWidget*)SF.rk1968_d().wSFRK);
 }
 
 void
diff --git a/upstream/src/aghermann/ui/sf/sf.cc b/upstream/src/aghermann/ui/sf/sf.cc
index ea3fc1e..8b096ed 100644
--- a/upstream/src/aghermann/ui/sf/sf.cc
+++ b/upstream/src/aghermann/ui/sf/sf.cc
@@ -97,6 +97,7 @@ SScoringFacility (agh::CSubject& J,
         _phasediff_d (nullptr),
         _artifacts_d (nullptr),
         _artifacts_simple_d (nullptr),
+        _rk1968_d (nullptr),
         using_channel (nullptr),
         da_wd (800), // gets properly set in a configure_event cb
         da_ht (NAN) // bad value, to be estimated unless previously saved
diff --git a/upstream/src/tools/Makefile.am b/upstream/src/tools/Makefile.am
index 982be97..5e1591c 100644
--- a/upstream/src/tools/Makefile.am
+++ b/upstream/src/tools/Makefile.am
@@ -1,6 +1,7 @@
 AM_CXXFLAGS := \
 	-Wall -std=c++0x -fno-rtti \
-	-I$(top_srcdir)/src
+	-I$(top_srcdir)/src \
+	-DPACKAGE_DATADIR=\"$(datadir)\"
 
 bin_PROGRAMS := \
 	edfcat \
diff --git a/upstream/src/tools/edfhed-gtk.cc b/upstream/src/tools/edfhed-gtk.cc
index fecbb0b..f9515c5 100644
--- a/upstream/src/tools/edfhed-gtk.cc
+++ b/upstream/src/tools/edfhed-gtk.cc
@@ -389,7 +389,7 @@ ui_init()
 {
       // load glade
         __builder = gtk_builder_new();
-        if ( !gtk_builder_add_from_file( __builder, PACKAGE_DATADIR "/" PACKAGE "/edfhed.glade", NULL) ) {
+        if ( !gtk_builder_add_from_file( __builder, PACKAGE_DATADIR "/edfhed.glade", NULL) ) {
                 pop_ok_message( NULL, "Failed to load UI description file.");
                 return -1;
         }

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list