[med-svn] [Git][med-team/edfbrowser][upstream] New upstream version 1.94+dfsg

Étienne Mollier (@emollier) gitlab at salsa.debian.org
Wed Jun 22 23:29:23 BST 2022



Étienne Mollier pushed to branch upstream at Debian Med / edfbrowser


Commits:
89376c68 by Étienne Mollier at 2022-06-23T00:10:03+02:00
New upstream version 1.94+dfsg
- - - - -


23 changed files:

- README
- cdsa_dock.cpp
- cnvs/biox2edf.cpp
- cnvs/manscan2edf.cpp
- cnvs/mit2edf.cpp
- doc/manual.html
- edit_annotation_dock.cpp
- export_filtered_signals.cpp
- global.h
- header_editor.cpp
- import_annotations.cpp
- mainwindow.cpp
- mainwindow.h
- mainwindow_constr.cpp
- options_dialog.cpp
- options_dialog.h
- print_to_bdf.cpp
- print_to_edf.cpp
- read_write_settings.cpp
- version.txt
- view_session_dialog.cpp
- viewcurve.cpp
- viewcurve.h


Changes:

=====================================
README
=====================================
@@ -23,8 +23,8 @@ Qmake is part of your Qt installation.
 Compiling and installing on Ubuntu Linux and derivatives
 ========================================================
 
-sudo apt-get update
-sudo apt-get install g++ make git qtbase5-dev-tools qtbase5-dev qt5-default
+sudo apt update
+sudo apt install g++ make git qtbase5-dev-tools qtbase5-dev
 git clone https://gitlab.com/Teuniz/EDFbrowser.git
 cd EDFbrowser
 qmake


=====================================
cdsa_dock.cpp
=====================================
@@ -107,7 +107,7 @@ UI_cdsa_dock::UI_cdsa_dock(QWidget *w_parent, struct cdsa_dock_param_struct par)
   grid_layout->addWidget(color_indic_label, 1, 2);
 
   cdsa_dock = new QDockWidget(str, mainwindow);
-  cdsa_dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
+  cdsa_dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   cdsa_dock->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea);
   cdsa_dock->setAttribute(Qt::WA_DeleteOnClose);
   cdsa_dock->setContextMenuPolicy(Qt::CustomContextMenu);


=====================================
cnvs/biox2edf.cpp
=====================================
@@ -176,12 +176,8 @@ void UI_BIOX2EDFwindow::SelectFileButton()
     return;
   }
 
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-
   sf = *((unsigned short *)str);
 
-#pragma GCC diagnostic warning "-Wstrict-aliasing"
-
   if((sf != 128) && (sf != 256))
   {
     snprintf(txt_string, 2048, "Invalid parameter (samplefrequency) in file: %iHz\n", sf);


=====================================
cnvs/manscan2edf.cpp
=====================================
@@ -124,7 +124,7 @@ void UI_MANSCAN2EDFwindow::SelectFileButton()
 
   double d_tmp;
 
-  struct segment_prop_struct *segment_properties;
+  struct segment_prop_struct *segment_properties=NULL;
 
   union{
          int one;
@@ -169,7 +169,7 @@ void UI_MANSCAN2EDFwindow::SelectFileButton()
     return;
   }
 
-  segment_properties = (struct segment_prop_struct *)malloc(sizeof(struct segment_prop_struct));
+  segment_properties = (struct segment_prop_struct *)calloc(1, sizeof(struct segment_prop_struct));
   if(segment_properties == NULL)
   {
     textEdit1->append("Malloc error (struct segment_prop_struct)");
@@ -980,7 +980,14 @@ int UI_MANSCAN2EDFwindow::get_recorder_version(struct segment_prop_struct *segpr
     return -1;
   }
 
+#if __GNUC__ > 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
   strncpy(segprop->recorder_version, linebuf + 25, 100);
+#if __GNUC__ > 7
+#pragma GCC diagnostic pop
+#endif
 
   return 0;
 }
@@ -1040,7 +1047,14 @@ int UI_MANSCAN2EDFwindow::get_filter_settings(struct segment_prop_struct *segpro
     return -1;
   }
 
+#if __GNUC__ > 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
   strncpy(segprop->recorder_brand, linebuf + 8, 13);
+#if __GNUC__ > 7
+#pragma GCC diagnostic pop
+#endif
 
   chrpntr = linebuf + 18;
 


=====================================
cnvs/mit2edf.cpp
=====================================
@@ -1249,8 +1249,6 @@ OUT1:
           break;
         }
 
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-
         if(*((unsigned short *)a_buf) == 0)  // end of file
         {
           break;
@@ -1288,8 +1286,6 @@ OUT1:
               {
                 tc += *((unsigned short *)a_buf) & 0x3ff;
 
-#pragma GCC diagnostic warning "-Wstrict-aliasing"
-
                 if(annot_code < 42)
                 {
                   edfwrite_annotation_latin1(hdl, (tc * 10000LL) / mit_hdr.sf_base_fl, -1, annotdescrlist[annot_code]);


=====================================
doc/manual.html
=====================================
@@ -21,7 +21,7 @@
     </style>
 </head><body>
 
-<h1>EDFbrowser 1.93 manual</h1>
+<h1>EDFbrowser 1.94 manual</h1>
 
 <p><br></p>
 
@@ -456,14 +456,15 @@
   - set the description<br>
   - set the onset time<br>
   - set the duration<br>
-  - advance the viewtime (file position) with the page /epoch time<br>
-  Keyboard shortcuts for the user buttons are: Ctrl + 1, Ctrl + 2, Ctrl + 3, etc.<br><br>
+  - advance the viewtime (file position) with the stage /epoch time<br>
+  Keyboard shortcuts for the user buttons are: '1', '2', '3', etc.<br><br>
 
-  Note: It's possible to let the viewtime automatically stay on an integer multiple of the page /epoch time when using the user buttons to create annotations.<br>
+  Note: It's possible to let the viewtime automatically stay on an integer multiple of the stage /epoch time when using the user buttons to create annotations.<br>
   I.e. the viewtime and pagetime will allways be at the epoch boundary. This can be setup in: Settings -> Options -> Annotation editor.<br><br>
 
   Note: It's possible to let advance the viewtime automatically when using the user buttons to create annotations.<br>
-  I.e. the viewtime will advance with the selected page / epoch time when clicking on a user button. This can be setup in: Settings -> Options -> Annotation editor.<br><br>
+  I.e. the viewtime will advance with the selected stage / epoch time when clicking on a user button. This can be setup in: Settings -> Options -> Annotation editor.<br>
+  Keeping the shift-key pressed while hitting a user button will cause the viewtime to jump backwards.<br><br>
 
   Signal linked annotations can be created by using a suffix "@@" followed by the signal label in the annotation description.<br>
   e.g.: "sleep spindle@@C3-A2"<br><br>
@@ -475,6 +476,9 @@
   onset and duration will be set according to the rectangle drawn.<br>
   You can setup the predefined descriptions in: Settings -> Options -> Annotation editor.<br><br>
 
+  Alternatively, press 'a' when one or two crosshairs are enabled (on the same signal) in order to create a signal linked annotation.<br>
+  The second crosshair will be used to set the duration of the event. If not present, an annotation without duration will be created.<br><br>
+
   Note: The annotation editor will limit the precision of the onset-time of the annotations to 1 milliSecond.
 </p>
 


=====================================
edit_annotation_dock.cpp
=====================================
@@ -112,7 +112,8 @@ UI_AnnotationEditwindow::UI_AnnotationEditwindow(struct edfhdrblock *e_hdr, QWid
   {
     user_button[i] = new QPushButton;
     user_button[i]->setText(mainwindow->annot_edit_user_button_name[i]);
-    user_button[i]->setShortcut(QKeySequence(Qt::CTRL + (Qt::Key_1 + i)));
+//    user_button[i]->setShortcut(QKeySequence(Qt::CTRL + (Qt::Key_1 + i)));
+    user_button[i]->setShortcut(QKeySequence(Qt::Key_1 + i));
     if(!mainwindow->annot_edit_user_button_enabled[i])
     {
       user_button[i]->setVisible(false);
@@ -651,7 +652,7 @@ void UI_AnnotationEditwindow::user_button_clicked(int button)
   {
     if(mainwindow->annot_editor_user_button_stay_on_epoch_boundary)
     {
-      mainwindow->pagetime = mainwindow->annot_editor_user_button_epoch_len;
+      mainwindow->pagetime = mainwindow->annot_editor_user_button_page_len;
 
       mainwindow->edfheaderlist[mainwindow->sel_viewtime]->viewtime /= mainwindow->annot_editor_user_button_epoch_len;
       mainwindow->edfheaderlist[mainwindow->sel_viewtime]->viewtime *= mainwindow->annot_editor_user_button_epoch_len;
@@ -665,19 +666,33 @@ void UI_AnnotationEditwindow::user_button_clicked(int button)
 
   if(mainwindow->annot_editor_user_button_update_annot_onset)
   {
-    annotEditSetOnset(mainwindow->edfheaderlist[mainwindow->sel_viewtime]->viewtime);
+    if(mainwindow->annot_editor_user_button_onset_on_page_middle[button])
+    {
+      annotEditSetOnset(mainwindow->edfheaderlist[mainwindow->sel_viewtime]->viewtime + (mainwindow->pagetime / 2));
+    }
+    else
+    {
+      annotEditSetOnset(mainwindow->edfheaderlist[mainwindow->sel_viewtime]->viewtime);
+    }
   }
 
   if(mainwindow->annot_editor_user_button_update_annot_duration)
   {
-    annotEditSetDuration(mainwindow->pagetime);
+    annotEditSetDuration(mainwindow->annot_editor_user_button_epoch_len);
   }
 
   createButtonClicked();
 
   if(mainwindow->annot_editor_user_button_jump_to_next_page)
   {
-    mainwindow->next_page();
+    if(QApplication::keyboardModifiers() == Qt::ShiftModifier)
+    {
+      mainwindow->next_epoch(-mainwindow->annot_editor_user_button_epoch_len);
+    }
+    else
+    {
+      mainwindow->next_epoch(mainwindow->annot_editor_user_button_epoch_len);
+    }
   }
 }
 


=====================================
export_filtered_signals.cpp
=====================================
@@ -451,7 +451,8 @@ void UI_ExportFilteredSignalsWindow::StartExport()
       digmax,
       value;
 
-  char scratchpad[4096];
+  char scratchpad[4096]={""},
+       str[1024]={""};
 
   double *filtered_blockread_buf[MAXSIGNALS],
          bitvalue,
@@ -811,7 +812,15 @@ void UI_ExportFilteredSignalsWindow::StartExport()
   }
   for(i=0; i<new_edfsignals; i++)
   {
-    snprintf(scratchpad, 256, "%f", edfhdr->edfparam[signalslist[i]].phys_min);
+    if((((int)(edfhdr->edfparam[signalslist[i]].phys_min * signalcomp[i]->polarity)) < -9999999) && (signalcomp[i]->polarity == -1))
+    {
+      snprintf(str, 1024,
+               "signal %i has been set to \"inverted\" but the physical minimum field has no free space left to write the minus sign",
+               i + 1);
+      showpopupmessage("Error", str);
+      goto END_4;
+    }
+    snprintf(scratchpad, 256, "%f", edfhdr->edfparam[signalslist[i]].phys_min * signalcomp[i]->polarity);
     convert_trailing_zeros_to_spaces(scratchpad);
     if(scratchpad[7]=='.')
     {
@@ -826,7 +835,15 @@ void UI_ExportFilteredSignalsWindow::StartExport()
   }
   for(i=0; i<new_edfsignals; i++)
   {
-    snprintf(scratchpad, 256, "%f", edfhdr->edfparam[signalslist[i]].phys_max);
+    if((((int)(edfhdr->edfparam[signalslist[i]].phys_max * signalcomp[i]->polarity)) < -9999999) && (signalcomp[i]->polarity == -1))
+    {
+      snprintf(str, 1024,
+               "signal %i has been set to \"inverted\" but the physical maximum field has no free space left to write the minus sign",
+               i + 1);
+      showpopupmessage("Error", str);
+      goto END_4;
+    }
+    snprintf(scratchpad, 256, "%f", edfhdr->edfparam[signalslist[i]].phys_max * signalcomp[i]->polarity);
     convert_trailing_zeros_to_spaces(scratchpad);
     if(scratchpad[7]=='.')
     {


=====================================
global.h
=====================================
@@ -28,7 +28,15 @@
 #ifndef EDFBROWSER_GLOBAL_H
 #define EDFBROWSER_GLOBAL_H
 
-#if !defined(__GNUC__)
+#if defined(__GNUC__)
+
+#define GCC_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
+
+#if (GCC_VERSION >= 70100)
+#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
+
+#else
 #if defined(__APPLE__) || defined(__MACH__) || defined(__APPLE_CC__)
 /* nothing */
 #else
@@ -36,6 +44,8 @@
 #endif
 #endif
 
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+
 #if defined(__LP64__) || defined(__MINGW64__)
 #define THIS_APP_BITS_W   "64-bit"
 #else
@@ -56,10 +66,8 @@
 
 #endif
 
-#define QT_NO_DEPRECATED_WARNINGS
-
 #define PROGRAM_NAME                "EDFbrowser"
-#define PROGRAM_VERSION                   "1.93"
+#define PROGRAM_VERSION                   "1.94"
 #define PROGRAM_BETA_SUFFIX                   ""
 #define MINIMUM_QT4_VERSION             0x040701
 #define MINIMUM_QT5_VERSION             0x050901
@@ -405,3 +413,6 @@ struct annot_filter_struct{
 
 
 
+
+
+


=====================================
header_editor.cpp
=====================================
@@ -1369,7 +1369,7 @@ void UI_headerEditorWindow::save_hdr()
   }
 
   fseeko(file, 244LL, SEEK_SET);
-  fread(scratchpad, 8, 1, file);
+  if(fread(scratchpad, 8, 1, file) != 1) {};  //FIXME
   scratchpad[8] = 0;
   if(!strcmp(scratchpad, "0       "))
   {


=====================================
import_annotations.cpp
=====================================
@@ -790,8 +790,6 @@ int UI_ImportAnnotationswindow::import_from_mitwfdb(void)
       break;
     }
 
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-
     if(*((unsigned short *)a_buf) == 0)  // end of file
     {
       break;
@@ -859,8 +857,6 @@ int UI_ImportAnnotationswindow::import_from_mitwfdb(void)
         {
           tc += *((unsigned short *)a_buf) & 0x3ff;
 
-#pragma GCC diagnostic warning "-Wstrict-aliasing"
-
           if(import_std_annots)
           {
             if((!ignore_consecutive) || (annot_code != last_std_code))


=====================================
mainwindow.cpp
=====================================
@@ -1949,6 +1949,45 @@ void UI_Mainwindow::next_page()
 }
 
 
+void UI_Mainwindow::next_epoch(long long epoch_len)
+{
+  int i;
+
+  if(!files_open)  return;
+
+  if(video_player->status == VIDEO_STATUS_PLAYING)
+  {
+    if(epoch_len < 2)  return;
+
+    video_player_seek((int)((edfheaderlist[sel_viewtime]->viewtime + epoch_len + (epoch_len / 2LL)) / TIME_DIMENSION));
+
+    return;
+  }
+
+  if(video_player->status == VIDEO_STATUS_PAUSED)
+  {
+    if(epoch_len < 2)  return;
+
+    video_player_seek((int)((edfheaderlist[sel_viewtime]->viewtime + epoch_len + (epoch_len / 2LL)) / TIME_DIMENSION));
+  }
+
+  if((viewtime_sync==VIEWTIME_SYNCED_OFFSET)||(viewtime_sync==VIEWTIME_SYNCED_ABSOLUT)||(viewtime_sync==VIEWTIME_USER_DEF_SYNCED))
+  {
+    for(i=0; i<files_open; i++)
+    {
+      edfheaderlist[i]->viewtime += epoch_len;
+    }
+  }
+
+  if(viewtime_sync==VIEWTIME_UNSYNCED)
+  {
+    edfheaderlist[sel_viewtime]->viewtime += epoch_len;
+  }
+
+  setup_viewbuf();
+}
+
+
 void UI_Mainwindow::shift_page_up()
 {
   int i;


=====================================
mainwindow.h
=====================================
@@ -254,6 +254,7 @@ public:
       hrvdock_height,
       aeegdock_height,
       annot_edit_user_button_enabled[8],
+      annot_editor_user_button_onset_on_page_middle[8],
       annot_editor_user_button_update_annot_description,
       annot_editor_user_button_update_annot_onset,
       annot_editor_user_button_update_annot_duration,
@@ -288,6 +289,7 @@ public:
 volatile int rc_cmd_in_progress;
 
 long long annot_editor_user_button_epoch_len,
+          annot_editor_user_button_page_len,
           hypnogram_epoch_len_threshold,
           session_video_starttime;
 
@@ -623,6 +625,7 @@ public slots:
   void shift_page_up();
   void shift_page_down();
   void next_page();
+  void next_epoch(long long);
   void dig_min_max_overflow_timer_func();
   void set_viewtime(long long);
   void fit_signals_to_pane(int n=-1);


=====================================
mainwindow_constr.cpp
=====================================
@@ -146,6 +146,8 @@ UI_Mainwindow::UI_Mainwindow()
 
   annot_editor_user_button_epoch_len = 30LL * TIME_DIMENSION;
 
+  annot_editor_user_button_page_len = 30LL * TIME_DIMENSION;
+
   hypnogram_epoch_len_threshold = TIME_DIMENSION / 10LL;
 
   hypnogram_use_epoch_len = 0;
@@ -170,6 +172,7 @@ UI_Mainwindow::UI_Mainwindow()
   for(i=0; i<8; i++)
   {
     annot_edit_user_button_enabled[i] = 0;
+    annot_editor_user_button_onset_on_page_middle[i] = 0;
     annot_edit_user_button_name[i][0] = 0;
   }
   strlcpy(annot_edit_user_button_name[0], "W", 64);


=====================================
options_dialog.cpp
=====================================
@@ -577,23 +577,54 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
 
     lineedit7_1[i] = new QLineEdit;
     lineedit7_1[i]->setMaxLength(16);
-    lineedit7_1[i]->setToolTip("Description of the new annotation");
     lineedit7_1[i]->setText(QString::fromUtf8(mainwindow->annot_edit_user_button_name[i]));
     if(checkbox7_1[i]->checkState() != Qt::Checked)
     {
       lineedit7_1[i]->setEnabled(false);
     }
+    lineedit7_1[i]->setToolTip("Description of the new annotation");
+
+    checkbox7_8[i] = new QCheckBox("Page middle");
+    checkbox7_8[i]->setTristate(false);
+    if(mainwindow->annot_editor_user_button_onset_on_page_middle[i])
+    {
+      checkbox7_8[i]->setCheckState(Qt::Checked);
+    }
+    else
+    {
+      checkbox7_8[i]->setCheckState(Qt::Unchecked);
+    }
+    if(checkbox7_1[i]->checkState() != Qt::Checked)
+    {
+      checkbox7_8[i]->setEnabled(false);
+    }
+    checkbox7_8[i]->setToolTip("If enabled, set the onset time at the middle of the page instead of at the start of the page.");
+
+//     hlayout_tmp = new QHBoxLayout;
+//     hlayout_tmp->setAlignment(Qt::AlignCenter);
+//     hlayout_tmp->addWidget(checkbox7_8[i]);
+//     hlayout_tmp->addStretch(1000);
+//     flayout7_2->addRow("Onset on page middle", hlayout_tmp);
+//     QObject::connect(checkbox7_8[i], SIGNAL(stateChanged(int)), this, SLOT(checkbox7_8[i]Clicked(int)));
+//     flayout7_2->labelForField(hlayout_tmp)->setToolTip("If enabled, set the onset time at the middle of the page instead of at the start of the page.");
+//     if(!mainwindow->annot_editor_user_button_update_annot_onset)
+//     {
+//       checkbox7_8[i]->setEnabled(false);
+//     }
 
     hlayout_tmp = new QHBoxLayout;
     hlayout_tmp->setAlignment(Qt::AlignCenter);
     hlayout_tmp->addWidget(checkbox7_1[i]);
     hlayout_tmp->addWidget(lineedit7_1[i]);
+    hlayout_tmp->addWidget(checkbox7_8[i]);
     hlayout_tmp->addStretch(1000);
     snprintf(str, 512, "Button %i", i + 1);
     flayout7_1->addRow(str, hlayout_tmp);
     flayout7_1->labelForField(hlayout_tmp)->setToolTip("If enabled, it creates a button to quickly create a predefined annotation");
   }
 
+  flayout7_1->addRow("Keyboard shortcuts are '1', '2', '3', etc.", (QWidget *)NULL);
+
   flayout7_1->addRow(" ", (QWidget *)NULL);
 
   QFrame *hline7_1 = new QFrame;
@@ -648,7 +679,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(checkbox7_5);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("set annotation editor description", hlayout_tmp);
+  flayout7_2->addRow("Set annotation editor description", hlayout_tmp);
   QObject::connect(checkbox7_5, SIGNAL(stateChanged(int)), this, SLOT(checkbox7_5Clicked(int)));
   flayout7_2->labelForField(hlayout_tmp)->setToolTip("Enabling this option will automatically update the description field of the annotation editor\n"
                                                      "with the name of the user button when that button is clicked.");
@@ -669,7 +700,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(checkbox7_3);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("set annotation editor onsettime", hlayout_tmp);
+  flayout7_2->addRow("Set annotation editor onsettime", hlayout_tmp);
   QObject::connect(checkbox7_3, SIGNAL(stateChanged(int)), this, SLOT(checkbox7_3Clicked(int)));
   flayout7_2->labelForField(hlayout_tmp)->setToolTip("Enabling this option will automatically update the onset time field of the annotation-editor\n"
                                                      "with the current viewtime (file position) when a user button is clicked.");
@@ -677,7 +708,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   checkbox7_4 = new QCheckBox;
   checkbox7_4->setTristate(false);
   checkbox7_4->setToolTip("Enabling this option will automatically update the duration field of the annotation-editor\n"
-                          "with the current pagetime when a user button is clicked.");
+                          "with the stage / epoch length when a user button is clicked.");
   if(mainwindow->annot_editor_user_button_update_annot_duration)
   {
     checkbox7_4->setCheckState(Qt::Checked);
@@ -690,14 +721,14 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(checkbox7_4);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("set annotation editor duration", hlayout_tmp);
+  flayout7_2->addRow("Set annotation editor duration", hlayout_tmp);
   QObject::connect(checkbox7_4, SIGNAL(stateChanged(int)), this, SLOT(checkbox7_4Clicked(int)));
   flayout7_2->labelForField(hlayout_tmp)->setToolTip("Enabling this option will automatically update the duration field of the annotation-editor\n"
-                                                     "with the current pagetime when a user button is clicked.");
+                                                     "with the stage / epoch length when a user button is clicked.");
 
   checkbox7_6 = new QCheckBox;
   checkbox7_6->setTristate(false);
-  checkbox7_6->setToolTip("Enabling this option will automatically change the viewtime (file position) and jump to the next page / epoch.");
+  checkbox7_6->setToolTip("Enabling this option will automatically change the viewtime (file position) and jump to the next stage / epoch.");
   if(mainwindow->annot_editor_user_button_jump_to_next_page)
   {
     checkbox7_6->setCheckState(Qt::Checked);
@@ -710,15 +741,13 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(checkbox7_6);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("jump to next page", hlayout_tmp);
+  flayout7_2->addRow("Jump to next page", hlayout_tmp);
   QObject::connect(checkbox7_6, SIGNAL(stateChanged(int)), this, SLOT(checkbox7_6Clicked(int)));
-  flayout7_2->labelForField(hlayout_tmp)->setToolTip("Enabling this option will automatically change the viewtime (file position) and jump to the next page / epoch.");
-
-  flayout7_2->addRow("Keyboard shortcuts are Ctrl + 1, Ctrl + 2, Ctrl + 3, etc.", (QWidget *)NULL);
+  flayout7_2->labelForField(hlayout_tmp)->setToolTip("Enabling this option will automatically change the viewtime (file position) and jump to the next stage / epoch.");
 
   checkbox7_7 = new QCheckBox;
   checkbox7_7->setTristate(false);
-  checkbox7_7->setToolTip("If enabled, the page will always start at an integer multiple of the page / epoch length.");
+  checkbox7_7->setToolTip("If enabled, the page will always start at an integer multiple of the stage / epoch length.");
   if(mainwindow->annot_editor_user_button_stay_on_epoch_boundary)
   {
     checkbox7_7->setCheckState(Qt::Checked);
@@ -735,9 +764,24 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(checkbox7_7);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("Viewtime must stay on page / epoch boundary", hlayout_tmp);
+  flayout7_2->addRow("Viewtime must stay on stage / epoch boundary", hlayout_tmp);
   QObject::connect(checkbox7_7, SIGNAL(stateChanged(int)), this, SLOT(checkbox7_7Clicked(int)));
-  flayout7_2->labelForField(hlayout_tmp)->setToolTip("If enabled, the page will always start at an integer multiple of the page / epoch length.");
+  flayout7_2->labelForField(hlayout_tmp)->setToolTip("If enabled, the page will always start at an integer multiple of the stage / epoch length.");
+
+  spinbox7_2 = new QSpinBox;
+  spinbox7_2->setSuffix(" sec.");
+  spinbox7_2->setRange(1, 300);
+  spinbox7_2->setValue((int)(mainwindow->annot_editor_user_button_page_len / TIME_DIMENSION));
+  if(!mainwindow->annot_editor_user_button_jump_to_next_page)
+  {
+    spinbox7_2->setEnabled(false);
+  }
+  hlayout_tmp = new QHBoxLayout;
+  hlayout_tmp->setAlignment(Qt::AlignCenter);
+  hlayout_tmp->addWidget(spinbox7_2);
+  hlayout_tmp->addStretch(1000);
+  flayout7_2->addRow("Page length (timescale)", hlayout_tmp);
+  QObject::connect(spinbox7_2, SIGNAL(valueChanged(int)), this, SLOT(spinBox7_2ValueChanged(int)));
 
   spinbox7_1 = new QSpinBox;
   spinbox7_1->setSuffix(" sec.");
@@ -751,7 +795,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   hlayout_tmp->setAlignment(Qt::AlignCenter);
   hlayout_tmp->addWidget(spinbox7_1);
   hlayout_tmp->addStretch(1000);
-  flayout7_2->addRow("Page / epoch length", hlayout_tmp);
+  flayout7_2->addRow("Stage / epoch length", hlayout_tmp);
   QObject::connect(spinbox7_1, SIGNAL(valueChanged(int)), this, SLOT(spinBox7_1ValueChanged(int)));
 
   QFrame *hline7_2 = new QFrame;
@@ -802,6 +846,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   {
     QObject::connect(checkbox7_1[i], SIGNAL(stateChanged(int)),   this, SLOT(tab7_settings_changed()));
     QObject::connect(lineedit7_1[i], SIGNAL(textEdited(QString)), this, SLOT(tab7_settings_changed()));
+    QObject::connect(checkbox7_8[i], SIGNAL(stateChanged(int)),   this, SLOT(tab7_settings_changed()));
   }
 
   for(i=0; i<MAX_ANNOTEDIT_SIDE_MENU_ANNOTS; i++)
@@ -1500,7 +1545,7 @@ UI_OptionsDialog::UI_OptionsDialog(QWidget *w_parent)
   mainLayout->addSpacing(20);
   mainLayout->addLayout(horLayout);
 
-  optionsdialog->setMinimumSize(900 * mainwindow->w_scaling, 575 * mainwindow->h_scaling);
+  optionsdialog->setMinimumSize(900 * mainwindow->w_scaling, 600 * mainwindow->h_scaling);
 
   optionsdialog->setLayout(mainLayout);
 
@@ -2199,6 +2244,8 @@ void UI_OptionsDialog::checkbox7_6Clicked(int state)
     checkbox7_7->setEnabled(true);
 
     spinbox7_1->setEnabled(true);
+
+    spinbox7_2->setEnabled(true);
   }
   else
   {
@@ -2207,6 +2254,8 @@ void UI_OptionsDialog::checkbox7_6Clicked(int state)
     checkbox7_7->setEnabled(false);
 
     spinbox7_1->setEnabled(false);
+
+    spinbox7_2->setEnabled(false);
   }
 }
 
@@ -2230,6 +2279,12 @@ void UI_OptionsDialog::spinBox7_1ValueChanged(int val)
 }
 
 
+void UI_OptionsDialog::spinBox7_2ValueChanged(int val)
+{
+  mainwindow->annot_editor_user_button_page_len = val * TIME_DIMENSION;
+}
+
+
 void UI_OptionsDialog::checkbox4_8Clicked(int state)
 {
   if(state==Qt::Checked)
@@ -3341,14 +3396,25 @@ void UI_OptionsDialog::tab7_settings_changed()
     if(checkbox7_1[i]->checkState() == Qt::Checked)
     {
       lineedit7_1[i]->setEnabled(true);
+      checkbox7_8[i]->setEnabled(true);
       mainwindow->annot_edit_user_button_enabled[i] = 1;
     }
     else
     {
       lineedit7_1[i]->setEnabled(false);
+      checkbox7_8[i]->setEnabled(false);
       mainwindow->annot_edit_user_button_enabled[i] = 0;
     }
 
+    if(checkbox7_8[i]->checkState() == Qt::Checked)
+    {
+      mainwindow->annot_editor_user_button_onset_on_page_middle[i] = 1;
+    }
+    else
+    {
+      mainwindow->annot_editor_user_button_onset_on_page_middle[i] = 0;
+    }
+
     strlcpy(mainwindow->annot_edit_user_button_name[i], lineedit7_1[i]->text().toUtf8().data(), 64);
 
     str_replace_ctrl_chars(mainwindow->annot_edit_user_button_name[i], '!');


=====================================
options_dialog.h
=====================================
@@ -100,7 +100,8 @@ QSpinBox       *spinbox1_1,
                *spinbox4_5,
                *spinbox5_1,
                *spinbox5_2,
-               *spinbox7_1;
+               *spinbox7_1,
+               *spinbox7_2;
 
 QDoubleSpinBox *dspinbox3_2,
                *dspinbox4_4;
@@ -134,6 +135,7 @@ QCheckBox      *checkbox1,
                *checkbox2_2,
                *checkbox2_3,
                *checkbox7_1[8],
+               *checkbox7_8[8],
                *checkbox7_2,
                *checkbox7_3,
                *checkbox7_4,
@@ -249,6 +251,7 @@ void spinBox5_2ValueChanged(int);
 void ApplyButton5Clicked();
 void DefaultButton5Clicked();
 void spinBox7_1ValueChanged(int);
+void spinBox7_2ValueChanged(int);
 void tab7_settings_changed();
 void tabholder_idx_changed(int);
 


=====================================
print_to_bdf.cpp
=====================================
@@ -64,10 +64,11 @@ void print_screen_to_bdf(UI_Mainwindow *mainwindow)
             preamble=0LL,
             smpls_preamble[MAXSIGNALS];
 
-  char path[MAX_PATH_LENGTH],
-       scratchpad[4096],
-       datrecduration[32],
-       *viewbuf;
+  char path[MAX_PATH_LENGTH]={""},
+       scratchpad[4096]={""},
+       datrecduration[32]={""},
+       str[1024]={""},
+       *viewbuf=NULL;
 
   double frequency,
          frequency2,
@@ -586,6 +587,46 @@ void print_screen_to_bdf(UI_Mainwindow *mainwindow)
         fclose(outputfile);
         return;
       }
+      if(signalcomp[i]->polarity == -1)
+      {
+        if(scratchpad[0] == '+')
+        {
+          scratchpad[0] = '-';
+        }
+        else if(scratchpad[0] == '-')
+          {
+            for(j=0; j<7; j++)
+            {
+              scratchpad[j] = scratchpad[j+1];
+            }
+            scratchpad[7] = ' ';
+          }
+          else
+          {
+            if(scratchpad[7] != ' ')
+            {
+              for(j=0; j<8; j++)
+              {
+                if(scratchpad[j] == '.')  break;
+              }
+              if(j == 8)
+              {
+                snprintf(str, 1024,
+                         "signal %i has been set to \"inverted\" but the physical minimum field has no free space left to write the minus sign",
+                         i + 1);
+                QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
+                messagewindow.exec();
+                fclose(outputfile);
+                return;
+              }
+            }
+            for(j=7; j>0; j--)
+            {
+              scratchpad[j] = scratchpad[j-1];
+            }
+            scratchpad[0] = '-';
+          }
+      }
       if(fwrite(scratchpad, 8, 1, outputfile)!=1)
       {
         QMessageBox messagewindow(QMessageBox::Critical, "Error", "An error occurred while writing to outputfile.");
@@ -641,6 +682,46 @@ void print_screen_to_bdf(UI_Mainwindow *mainwindow)
         fclose(outputfile);
         return;
       }
+      if(signalcomp[i]->polarity == -1)
+      {
+        if(scratchpad[0] == '+')
+        {
+          scratchpad[0] = '-';
+        }
+        else if(scratchpad[0] == '-')
+          {
+            for(j=0; j<7; j++)
+            {
+              scratchpad[j] = scratchpad[j+1];
+            }
+            scratchpad[7] = ' ';
+          }
+          else
+          {
+            if(scratchpad[7] != ' ')
+            {
+              for(j=0; j<8; j++)
+              {
+                if(scratchpad[j] == '.')  break;
+              }
+              if(j == 8)
+              {
+                snprintf(str, 1024,
+                         "signal %i has been set to \"inverted\" but the physical maximum field has no free space left to write the minus sign",
+                         i + 1);
+                QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
+                messagewindow.exec();
+                fclose(outputfile);
+                return;
+              }
+            }
+            for(j=7; j>0; j--)
+            {
+              scratchpad[j] = scratchpad[j-1];
+            }
+            scratchpad[0] = '-';
+          }
+      }
       if(fwrite(scratchpad, 8, 1, outputfile)!=1)
       {
         QMessageBox messagewindow(QMessageBox::Critical, "Error", "An error occurred while writing to outputfile.");


=====================================
print_to_edf.cpp
=====================================
@@ -64,10 +64,11 @@ void print_screen_to_edf(UI_Mainwindow *mainwindow)
             preamble=0LL,
             smpls_preamble[MAXSIGNALS];
 
-  char path[MAX_PATH_LENGTH],
-       scratchpad[4096],
-       datrecduration[32],
-       *viewbuf;
+  char path[MAX_PATH_LENGTH]={""},
+       scratchpad[4096]={""},
+       datrecduration[32]={""},
+       str[1024]={""},
+       *viewbuf=NULL;
 
   double frequency,
          frequency2,
@@ -578,6 +579,46 @@ void print_screen_to_edf(UI_Mainwindow *mainwindow)
         fclose(outputfile);
         return;
       }
+      if(signalcomp[i]->polarity == -1)
+      {
+        if(scratchpad[0] == '+')
+        {
+          scratchpad[0] = '-';
+        }
+        else if(scratchpad[0] == '-')
+          {
+            for(j=0; j<7; j++)
+            {
+              scratchpad[j] = scratchpad[j+1];
+            }
+            scratchpad[7] = ' ';
+          }
+          else
+          {
+            if(scratchpad[7] != ' ')
+            {
+              for(j=0; j<8; j++)
+              {
+                if(scratchpad[j] == '.')  break;
+              }
+              if(j == 8)
+              {
+                snprintf(str, 1024,
+                         "signal %i has been set to \"inverted\" but the physical minimum field has no free space left to write the minus sign",
+                         i + 1);
+                QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
+                messagewindow.exec();
+                fclose(outputfile);
+                return;
+              }
+            }
+            for(j=7; j>0; j--)
+            {
+              scratchpad[j] = scratchpad[j-1];
+            }
+            scratchpad[0] = '-';
+          }
+      }
       if(fwrite(scratchpad, 8, 1, outputfile)!=1)
       {
         QMessageBox messagewindow(QMessageBox::Critical, "Error", "An error occurred while writing to outputfile.");
@@ -633,6 +674,46 @@ void print_screen_to_edf(UI_Mainwindow *mainwindow)
         fclose(outputfile);
         return;
       }
+      if(signalcomp[i]->polarity == -1)
+      {
+        if(scratchpad[0] == '+')
+        {
+          scratchpad[0] = '-';
+        }
+        else if(scratchpad[0] == '-')
+          {
+            for(j=0; j<7; j++)
+            {
+              scratchpad[j] = scratchpad[j+1];
+            }
+            scratchpad[7] = ' ';
+          }
+          else
+          {
+            if(scratchpad[7] != ' ')
+            {
+              for(j=0; j<8; j++)
+              {
+                if(scratchpad[j] == '.')  break;
+              }
+              if(j == 8)
+              {
+                snprintf(str, 1024,
+                         "signal %i has been set to \"inverted\" but the physical maximum field has no free space left to write the minus sign",
+                         i + 1);
+                QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
+                messagewindow.exec();
+                fclose(outputfile);
+                return;
+              }
+            }
+            for(j=7; j>0; j--)
+            {
+              scratchpad[j] = scratchpad[j-1];
+            }
+            scratchpad[0] = '-';
+          }
+      }
       if(fwrite(scratchpad, 8, 1, outputfile)!=1)
       {
         QMessageBox messagewindow(QMessageBox::Critical, "Error", "An error occurred while writing to outputfile.");


=====================================
read_write_settings.cpp
=====================================
@@ -1754,6 +1754,30 @@ void UI_Mainwindow::read_general_settings()
         {
           annot_edit_user_button_enabled[i] = 1;
         }
+        else
+        {
+          annot_edit_user_button_enabled[i] = 0;
+        }
+
+        xml_go_up(xml_hdl);
+      }
+
+      if(!(xml_goto_nth_element_inside(xml_hdl, "annot_editor_user_button_onset_on_page_middle", i)))
+      {
+        if(xml_get_content_of_element(xml_hdl, result, XML_STRBUFLEN))
+        {
+          xml_close(xml_hdl);
+          return;
+        }
+
+        if(atoi(result) == 1)
+        {
+          annot_editor_user_button_onset_on_page_middle[i] = 1;
+        }
+        else
+        {
+          annot_editor_user_button_onset_on_page_middle[i] = 0;
+        }
 
         xml_go_up(xml_hdl);
       }
@@ -1803,6 +1827,10 @@ void UI_Mainwindow::read_general_settings()
       {
         annot_editor_user_button_update_annot_description = 1;
       }
+      else
+      {
+        annot_editor_user_button_update_annot_description = 0;
+      }
 
       xml_go_up(xml_hdl);
     }
@@ -1819,6 +1847,10 @@ void UI_Mainwindow::read_general_settings()
       {
         annot_editor_user_button_update_annot_onset = 1;
       }
+      else
+      {
+        annot_editor_user_button_update_annot_onset = 0;
+      }
 
       xml_go_up(xml_hdl);
     }
@@ -1835,6 +1867,10 @@ void UI_Mainwindow::read_general_settings()
       {
         annot_editor_user_button_update_annot_duration = 1;
       }
+      else
+      {
+        annot_editor_user_button_update_annot_duration = 0;
+      }
 
       xml_go_up(xml_hdl);
     }
@@ -1851,6 +1887,10 @@ void UI_Mainwindow::read_general_settings()
       {
         annot_editor_user_button_jump_to_next_page = 1;
       }
+      else
+      {
+        annot_editor_user_button_jump_to_next_page = 0;
+      }
 
       xml_go_up(xml_hdl);
     }
@@ -1867,6 +1907,10 @@ void UI_Mainwindow::read_general_settings()
       {
         annot_editor_user_button_stay_on_epoch_boundary = 1;
       }
+      else
+      {
+        annot_editor_user_button_stay_on_epoch_boundary = 0;
+      }
 
       xml_go_up(xml_hdl);
     }
@@ -1888,6 +1932,23 @@ void UI_Mainwindow::read_general_settings()
       xml_go_up(xml_hdl);
     }
 
+    if(!(xml_goto_nth_element_inside(xml_hdl, "annot_editor_user_button_page_len", 0)))
+    {
+      if(xml_get_content_of_element(xml_hdl, result, XML_STRBUFLEN))
+      {
+        xml_close(xml_hdl);
+        return;
+      }
+
+      annot_editor_user_button_page_len = atoll(result);
+      if((annot_editor_user_button_page_len < TIME_DIMENSION) || (annot_editor_user_button_page_len > (300LL * TIME_DIMENSION)))
+      {
+        annot_editor_user_button_page_len = 30LL * TIME_DIMENSION;
+      }
+
+      xml_go_up(xml_hdl);
+    }
+
     xml_go_up(xml_hdl);
   }
 
@@ -3376,6 +3437,10 @@ void UI_Mainwindow::write_settings()
       xml_strlcpy_encode_entity(str, annot_edit_user_button_name[i], 1024);
       fprintf(cfgfile, "      <annot_edit_user_button_name>%s</annot_edit_user_button_name>\n", str);
     }
+    for(i=0; i<8; i++)
+    {
+      fprintf(cfgfile, "      <annot_editor_user_button_onset_on_page_middle>%i</annot_editor_user_button_onset_on_page_middle>\n", annot_editor_user_button_onset_on_page_middle[i]);
+    }
     fprintf(cfgfile, "      <annot_editor_user_button_update_annot_description>%i</annot_editor_user_button_update_annot_description>\n", annot_editor_user_button_update_annot_description);
     fprintf(cfgfile, "      <annot_editor_user_button_update_annot_onset>%i</annot_editor_user_button_update_annot_onset>\n", annot_editor_user_button_update_annot_onset);
     fprintf(cfgfile, "      <annot_editor_user_button_update_annot_duration>%i</annot_editor_user_button_update_annot_duration>\n", annot_editor_user_button_update_annot_duration);
@@ -3383,8 +3448,10 @@ void UI_Mainwindow::write_settings()
     fprintf(cfgfile, "      <annot_editor_user_button_stay_on_epoch_boundary>%i</annot_editor_user_button_stay_on_epoch_boundary>\n", annot_editor_user_button_stay_on_epoch_boundary);
 #ifdef Q_OS_WIN32
     __mingw_fprintf(cfgfile, "      <annot_editor_user_button_epoch_len>%lli</annot_editor_user_button_epoch_len>\n", annot_editor_user_button_epoch_len);
+    __mingw_fprintf(cfgfile, "      <annot_editor_user_button_page_len>%lli</annot_editor_user_button_page_len>\n", annot_editor_user_button_page_len);
 #else
     fprintf(cfgfile, "      <annot_editor_user_button_epoch_len>%lli</annot_editor_user_button_epoch_len>\n", annot_editor_user_button_epoch_len);
+    fprintf(cfgfile, "      <annot_editor_user_button_page_len>%lli</annot_editor_user_button_page_len>\n", annot_editor_user_button_page_len);
 #endif
     for(i=0; i<MAX_ANNOTEDIT_SIDE_MENU_ANNOTS; i++)
     {


=====================================
version.txt
=====================================
@@ -1,4 +1,21 @@
 
+ version 1.94      June 19, 2022
+ --------------
+
+ - Annotation editor: now you can select different lengths for stage/epoch and pagetime/timescale for
+   userbuttons when "jump to next page" is enabled. Go to Settings -> Options -> Annotation editor.
+   Keeping the Shift key pressed while hitting the create button or a user button will cause the onset
+   time of the annotation to be lowered with the annotation's duration.
+   Press 'a' when both crosshairs are enabled on the same signal in order to create a signal linked annotation.
+   The short-cuts for the user buttons have changed from "Ctl+1", "Ctl+2", etc. to '1', '2', etc.
+
+ - View saved sessions: fixed a bug that caused the session viewer to report an error in case an aEEG is present in the session.
+
+ - Print to EDF/BDF: in case a signal is inverted, change polarity of physmax and physmin in outputfile.
+
+ - Export filtered signals: in case a signal is inverted, change polarity of physmax and physmin in outputfile.
+
+
  version 1.93      May 14, 2022
  --------------
 


=====================================
view_session_dialog.cpp
=====================================
@@ -160,7 +160,7 @@ void UI_ViewSessionwindow::SelectButtonClicked()
          max_voltage=0,
          bp_min_hz=0,
          bp_max_hz=0,
-         ravg_len=0,
+         lp_hz=0,
          scale_max_amp=0;
 
   FILE *f_test=NULL;
@@ -328,11 +328,11 @@ void UI_ViewSessionwindow::SelectButtonClicked()
 
     if(i == ref_file)
     {
-      snprintf(edf_path, 2048, "File (reference): %s", result);
+      snprintf(edf_path, 2048, "File (reference): %.2000s", result);
     }
     else
     {
-      snprintf(edf_path, 2048, "File: %s", result);
+      snprintf(edf_path, 2048, "File: %.2000s", result);
     }
 
     if(use_relative_path)
@@ -2074,7 +2074,7 @@ void UI_ViewSessionwindow::SelectButtonClicked()
       xml_go_up(xml_hdl);
     }
 
-    if(xml_goto_nth_element_inside(xml_hdl, "ravg_len", 0))
+    if(xml_goto_nth_element_inside(xml_hdl, "lp_hz", 0))
     {
       view_session_format_error(__FILE__, __LINE__, xml_hdl);
       return;
@@ -2087,14 +2087,14 @@ void UI_ViewSessionwindow::SelectButtonClicked()
         return;
       }
 
-      ravg_len = atof(result);
-      if(ravg_len < 0.4999)
+      lp_hz = atof(result);
+      if((lp_hz < 0.009999) || (lp_hz > 5.00001))
       {
         view_session_format_error(__FILE__, __LINE__, xml_hdl);
         return;
       }
 
-      snprintf(str2, 2048, "Smoothing length: %.1f sec", ravg_len);
+      snprintf(str2, 2048, "Envelope lowpass filter: %.2f sec", lp_hz);
       aeegItem->appendRow(new QStandardItem(str2));
 
       xml_go_up(xml_hdl);
@@ -2152,7 +2152,7 @@ void UI_ViewSessionwindow::SelectButtonClicked()
         return;
       }
 
-      snprintf(video_path, 2048, "Video: %s", result);
+      snprintf(video_path, 2048, "Video: %.2000s", result);
 
       if(use_relative_path)
       {


=====================================
viewcurve.cpp
=====================================
@@ -53,6 +53,11 @@ ViewCurve::ViewCurve(QWidget *w_parent) : QWidget(w_parent)
   average_annot_act = new QAction("Average", this);
   context_menu->addAction(average_annot_act);
 
+  annot_sidemenu_act = new QAction("Select annotation", this);
+//  annot_sidemenu_act->setShortcut(QKeySequence("Ctrl+Shift+A"));
+  annot_sidemenu_act->setShortcut(QKeySequence("A"));
+  addAction(annot_sidemenu_act);
+
   active_markers = (struct active_markersblock *)calloc(1, sizeof(struct active_markersblock));
 
   annot_marker_moving = 0;
@@ -178,8 +183,9 @@ ViewCurve::ViewCurve(QWidget *w_parent) : QWidget(w_parent)
 
   arrowkeys_shortcuts_global_set_enabled(true);
 
-  QObject::connect(select_annot_act,  SIGNAL(triggered(bool)), this, SLOT(select_annot(bool)));
-  QObject::connect(average_annot_act, SIGNAL(triggered(bool)), this, SLOT(average_annot(bool)));
+  QObject::connect(select_annot_act,   SIGNAL(triggered(bool)), this, SLOT(select_annot(bool)));
+  QObject::connect(average_annot_act,  SIGNAL(triggered(bool)), this, SLOT(average_annot(bool)));
+  QObject::connect(annot_sidemenu_act, SIGNAL(triggered(bool)), this, SLOT(annot_sidemenu_act_by_crosshair(bool)));
 }
 
 
@@ -254,6 +260,42 @@ void ViewCurve::arrowkeys_shortcuts_global_set_enabled(bool enabled)
 }
 
 
+void ViewCurve::annot_sidemenu_act_by_crosshair(bool)
+{
+  int i;
+
+  if((!mainwindow->annot_editor_active) ||
+     (mainwindow->annotationEditDock == NULL) ||
+     (!mainwindow->signalcomps) ||
+     (!crosshair_1.active))  return;
+
+  for(i=0; i<mainwindow->signalcomps; i++)
+  {
+    if(mainwindow->signalcomp[i]->hascursor1)
+    {
+      break;
+    }
+  }
+  if(i == mainwindow->signalcomps)  return;
+
+  mainwindow->signalcomp[i]->annot_created_by_rect_draw_onset = crosshair_1.time_relative;
+
+  mainwindow->signalcomp[i]->annot_created_by_rect_draw_duration = -TIME_DIMENSION;
+
+  if(mainwindow->signalcomp[i]->hascursor2)
+  {
+    if(crosshair_2.time_relative > crosshair_1.time_relative)
+    {
+      mainwindow->signalcomp[i]->annot_created_by_rect_draw_duration = crosshair_2.time_relative - crosshair_1.time_relative;
+    }
+  }
+
+  mainwindow->signalcomp[i]->annot_created_by_rect_draw_active = 1;
+
+  emit annot_created_by_rect_draw();
+}
+
+
 void ViewCurve::wheelEvent(QWheelEvent *wheel_event)
 {
   int i;
@@ -733,7 +775,11 @@ void ViewCurve::mousePressEvent(QMouseEvent *press_event)
     }
   }
 
+#if QT_VERSION >= 0x050F00
+  if(press_event->button()==Qt::MiddleButton)
+#else
   if(press_event->button()==Qt::MidButton)
+#endif
   {
     for(i=0; i<mainwindow->files_open; i++)
     {
@@ -779,25 +825,19 @@ void ViewCurve::mouseReleaseEvent(QMouseEvent *release_event)
 
   if(release_event->button()==Qt::LeftButton)
   {
-    if(crosshair_1.moving)
+    if(mainwindow->annotationEditDock != NULL)
     {
-      if(mainwindow->annotationEditDock != NULL)
+      if(crosshair_1.moving)
       {
         mainwindow->annotationEditDock->annotEditSetOnset(crosshair_1.time_relative);
-      }
 
-      if(crosshair_2.active)
-      {
-        if(mainwindow->annotationEditDock != NULL)
+        if(crosshair_2.active)
         {
           mainwindow->annotationEditDock->annotEditSetDuration(crosshair_2.time_relative - mainwindow->annotationEditDock->annotEditGetOnset());
         }
       }
-    }
 
-    if(crosshair_2.moving)
-    {
-      if(mainwindow->annotationEditDock != NULL)
+      if(crosshair_2.moving)
       {
           // Don't update the onset time when changing file position
 //      mainwindow->annotationEditDock->annotEditSetDuration(crosshair_2.time_relative - crosshair_1.time_relative);
@@ -848,7 +888,7 @@ void ViewCurve::mouseReleaseEvent(QMouseEvent *release_event)
       {
         if(QApplication::keyboardModifiers() == Qt::ControlModifier)
         {
-          if(mainwindow->annot_editor_active)
+          if((mainwindow->annot_editor_active) && (mainwindow->annotationEditDock != NULL) && signalcomps)
           {
             n = 0;
 
@@ -1001,7 +1041,11 @@ void ViewCurve::mouseReleaseEvent(QMouseEvent *release_event)
     }
   }
 
+#if QT_VERSION >= 0x050F00
+  if(release_event->button()==Qt::MiddleButton)
+#else
   if(release_event->button()==Qt::MidButton)
+#endif
   {
     use_move_events = 0;
     setMouseTracking(false);


=====================================
viewcurve.h
=====================================
@@ -252,7 +252,8 @@ private:
   QMenu       *context_menu;
 
   QAction     *select_annot_act,
-              *average_annot_act;
+              *average_annot_act,
+              *annot_sidemenu_act;
 
   int         printing,
               w,
@@ -293,6 +294,7 @@ protected slots:
 
   void select_annot(bool);
   void average_annot(bool);
+  void annot_sidemenu_act_by_crosshair(bool);
 
 protected:
   void paintEvent(QPaintEvent *);



View it on GitLab: https://salsa.debian.org/med-team/edfbrowser/-/commit/89376c68372bfb1a2c915706f91a036b903197fb

-- 
View it on GitLab: https://salsa.debian.org/med-team/edfbrowser/-/commit/89376c68372bfb1a2c915706f91a036b903197fb
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220622/46a87eb4/attachment-0001.htm>


More information about the debian-med-commit mailing list