[med-svn] [Git][med-team/sigviewer][master] 3 commits: Revert changes in upstream files

Andreas Tille gitlab at salsa.debian.org
Fri Dec 18 15:42:43 GMT 2020



Andreas Tille pushed to branch master at Debian Med / sigviewer


Commits:
34693c8c by Andreas Tille at 2020-12-18T16:34:24+01:00
Revert changes in upstream files

- - - - -
a4c8848e by Andreas Tille at 2020-12-18T16:36:58+01:00
Make sure upstream code is identical to code inside tarball

- - - - -
0cd1e87a by Andreas Tille at 2020-12-18T16:41:18+01:00
Upload to unstable

- - - - -


9 changed files:

- README.md
- debian/changelog
- deploy/windows/packages/org.sigviewer.sigviewer/meta/installscript.qs
- deploy/windows/packages/org.sigviewer.sigviewer/meta/package.xml
- src/file_handling_impl/biosig_reader.cpp
- src/file_handling_impl/biosig_writer.h
- src/file_handling_impl/evt_writer.cpp
- src/gui_impl/commands/open_file_gui_command.cpp
- src/gui_impl/commands/save_gui_command.cpp


Changes:

=====================================
README.md
=====================================
@@ -19,7 +19,7 @@ Building SigViewer
 ------------------
 SigViewer requires a standard-compliant C++11 build toolchain, for example recent versions of [GCC](https://gcc.gnu.org/) or [Clang](https://clang.llvm.org/). Other compilers such as [MSVC](https://en.wikipedia.org/wiki/Visual_C%2B%2B) might work, but are not tested. Furthermore, SigViewer depends on [Qt](https://www.qt.io/). Current SigViewer builds use Qt 5.9 (previous or future versions are not guaranteed to work).
 
-SigViewer also depends on [libbiosig](http://biosig.sourceforge.net/) and [libxdf](https://github.com/xdf-modules/libxdf). There are two options to get these external dependencies for your platform:
+SigViewer depends on [libbiosig](http://biosig.sourceforge.net/) and [libxdf](https://github.com/Yida-Lin/libxdf). There are two options to get these external dependencies for your platform:
 
 1. Build these dependencies yourself (see separate descriptions below).
 2. Use our pre-built binaries. The corresponding archive contains binary versions of libbiosig and libxdf and must be extracted into SigViewer’s source folder (which we denote as `$sigviewer`).
@@ -52,7 +52,7 @@ Mac OS X (now renamed to macOS) 10.9 or later is required. First, install XCode
 1. To create a stand-alone version of SigViewer, open a terminal, change into `$sigviewer/bin/release` and run `macdeployqt sigviewer.app -dmg`. This creates a disk image with the app, which can then be dragged to the Applications folder.
 
 ### Linux
-Install the GNU build toolchain and Qt 5 with your native package manager. You can either build on the command line or with Qt Creator (which you then need to install).
+Install the GNU toolchain and Qt 5 with your native package manager. You can either build on the command line or with Qt Creator (which you then need to install).
 
 1. Download and unzip the [SigViewer source](https://github.com/cbrnr/sigviewer/archive/v0.6.2.zip).
 1. Provide all external dependencies:


=====================================
debian/changelog
=====================================
@@ -1,4 +1,4 @@
-sigviewer (0.6.4-1) UNRELEASED; urgency=medium
+sigviewer (0.6.4-1) unstable; urgency=medium
 
   * Team upload.
 
@@ -22,7 +22,7 @@ sigviewer (0.6.4-1) UNRELEASED; urgency=medium
   * Fix FTCBFS: Let dh_auto_configure pass cross flags to qmake.
     Closes: #922571
 
- -- Andreas Tille <tille at debian.org>  Sat, 14 Nov 2020 18:23:18 +0100
+ -- Andreas Tille <tille at debian.org>  Fri, 18 Dec 2020 16:37:05 +0100
 
 sigviewer (0.6.2-2) unstable; urgency=medium
 


=====================================
deploy/windows/packages/org.sigviewer.sigviewer/meta/installscript.qs
=====================================


=====================================
deploy/windows/packages/org.sigviewer.sigviewer/meta/package.xml
=====================================


=====================================
src/file_handling_impl/biosig_reader.cpp
=====================================
@@ -121,6 +121,10 @@ QString BioSigReader::open (QString const& file_name)
 QString BioSigReader::loadFixedHeader(const QString& file_name)
 {
     QMutexLocker locker (&biosig_access_lock_);
+    char *c_file_name = new char[file_name.length() + 1];
+    strcpy (c_file_name, file_name.toLocal8Bit ().data());
+    c_file_name[file_name.length()] = '\0';
+
     tzset();
 
     if(biosig_header_==NULL)
@@ -130,7 +134,7 @@ QString BioSigReader::loadFixedHeader(const QString& file_name)
         biosig_header_->FLAG.OVERFLOWDETECTION = 1;
     }
 
-    biosig_header_ = sopen(file_name.toStdString().c_str(), "r", biosig_header_ );
+    biosig_header_ = sopen(c_file_name, "r", biosig_header_ );
 
     basic_header_ = QSharedPointer<BasicHeader>
                     (new BiosigBasicHeader (biosig_header_, file_name));
@@ -141,6 +145,8 @@ QString BioSigReader::loadFixedHeader(const QString& file_name)
         destructHDR(biosig_header_);
         biosig_header_ = NULL;
 
+        delete[] c_file_name;
+
         qDebug() << "File doesn't exist.";
         QMessageBox msgBox;
         msgBox.setIcon(QMessageBox::Warning);
@@ -161,11 +167,17 @@ QString BioSigReader::loadFixedHeader(const QString& file_name)
         destructHDR(biosig_header_);
         biosig_header_ = NULL;
 
+        delete[] c_file_name;
+
         return "file not supported";
     }
 
     convert2to4_eventtable(biosig_header_);
 
+    delete[] c_file_name;
+
+    c_file_name = NULL;
+
     basic_header_->setNumberEvents(biosig_header_->EVENT.N);
 
     if (biosig_header_->EVENT.SampleRate)


=====================================
src/file_handling_impl/biosig_writer.h
=====================================
@@ -8,10 +8,10 @@
 
 #include "file_handling/file_signal_writer.h"
 
-#include <biosig.h>
+#include "biosig.h"
 
 
-namespace sigviewer 
+namespace sigviewer
 {
 
 //-----------------------------------------------------------------------------


=====================================
src/file_handling_impl/evt_writer.cpp
=====================================
@@ -6,7 +6,7 @@
 #include "evt_writer.h"
 #include "file_handling/file_signal_writer_factory.h"
 
-#include <biosig.h>
+#include "biosig.h"
 
 namespace sigviewer
 {


=====================================
src/gui_impl/commands/open_file_gui_command.cpp
=====================================
@@ -2,7 +2,7 @@
 // Licensed under the GNU General Public License (GPL)
 // https://www.gnu.org/licenses/gpl
 
-#include <biosig.h>
+
 #include "open_file_gui_command.h"
 #include "gui_impl/gui_helper_functions.h"
 
@@ -182,64 +182,114 @@ void OpenFileGuiCommand::importEvents ()
     if (file_path.isEmpty())
         return;
 
-    QList<QSharedPointer<SignalEvent const> > events;
-    QSharedPointer<EventManager> event_manager = applicationContext()->getCurrentFileContext()->getEventManager();
-    double sampleRate = event_manager->getSampleRate();
-    std::set<EventType> types = event_manager->getEventTypes();
-    int numberChannels = applicationContext()->getCurrentFileContext()->getChannelManager().getNumberChannels();
-
-    // try reading event file through biosig
-    HDRTYPE* evtHDR = sopen(file_path.toStdString().c_str(), "r", NULL );
-    if (!serror2(evtHDR)) {
-        /* Note: evtSampleRate and transition rate can be NaN,
-           indicating sample rate is not specified in event file
-         */
-	double evtSampleRate   = biosig_get_eventtable_samplerate(evtHDR);
-	double transition_rate = sampleRate / evtSampleRate;
-	size_t NumEvents       = biosig_get_number_of_events(evtHDR);
-	for (size_t k = 0; k < NumEvents; k++) {
-            uint16_t typ; uint32_t pos; uint16_t chn; uint32_t dur;
-            gdf_time timestamp;
-            const char *desc;
-            biosig_get_nth_event(evtHDR, k, &typ, &pos, &chn, &dur, &timestamp, &desc);
-
-            if (transition_rate > 0) {
-                pos = lround(pos*transition_rate);
-                dur = lround(dur*transition_rate);
+    FileSignalReader* file_signal_reader = FileSignalReaderFactory::getInstance()->getHandler (file_path);
+    if (file_signal_reader != 0) {
+        QList<QSharedPointer<SignalEvent const> > events = file_signal_reader->getEvents ();
+        QSharedPointer<EventManager> event_manager = applicationContext()->getCurrentFileContext()->getEventManager();
+        QList<QSharedPointer<QUndoCommand> > creation_commands;
+        foreach (QSharedPointer<SignalEvent const> event, events) {
+               QSharedPointer<QUndoCommand> creation_command (new NewEventUndoCommand (event_manager, event));
+               creation_commands.append (creation_command);
+        }
+        MacroUndoCommand* macro_command = new MacroUndoCommand (creation_commands);
+        applicationContext()->getCurrentCommandExecuter()->executeCommand (macro_command);
+        delete file_signal_reader;
+        return;
+    }
+
+    std::fstream file;
+    file.open(file_path.toStdString());
+
+    if (file.is_open())
+    {
+        std::string line;
+        std::getline(file, line);
+
+        if (line.compare("position,duration,channel,type,name"))
+        {
+            QMessageBox::critical(0, file_path, tr("This is not a valid event CSV file!"));
+            return;
+        }
+
+        QList<QSharedPointer<SignalEvent const> > events;
+        QSharedPointer<EventManager> event_manager
+                = applicationContext()->getCurrentFileContext()->getEventManager();
+        double sampleRate = event_manager->getSampleRate();
+        std::set<EventType> types = event_manager->getEventTypes();
+        int numberChannels = applicationContext()->getCurrentFileContext()->getChannelManager().getNumberChannels();
+
+        while (std::getline(file, line))
+        {
+            QStringList Qline = QString::fromStdString(line).split(',');
+
+            size_t position = Qline[0].toUInt();
+            size_t duration = Qline[1].toULongLong();
+            ChannelID channel = Qline[2].toInt();
+            EventType type = Qline[3].toInt();
+
+            if (type <= 254 && do_not_show_warning_message == false)
+            {
+                QMessageBox msgBox;
+                msgBox.setText("Currently customized event text cannot be properly imported.");
+                msgBox.setIcon(QMessageBox::Warning);
+                msgBox.addButton(QMessageBox::Ok);
+                msgBox.addButton(QMessageBox::Cancel);
+                msgBox.setDefaultButton(QMessageBox::Cancel);
+                QCheckBox* dontShowCheckBox = new QCheckBox("Don't show this message again");
+                msgBox.setCheckBox(dontShowCheckBox);
+                int32_t userReply = msgBox.exec();
+                if (userReply == QMessageBox::Ok)
+                {
+                    if(dontShowCheckBox->checkState() == Qt::Checked)
+                    {
+                        QSettings settings;
+                        settings.setValue("DoNotShowWarningMessage", true);
+                        do_not_show_warning_message = true;
+                    }
+                }
+                else if (userReply == QMessageBox::Cancel)
+                {
+                    if(dontShowCheckBox->checkState() == Qt::Checked)
+                    {
+                        QSettings settings;
+                        settings.setValue("DoNotShowWarningMessage", true);
+
+                        do_not_show_warning_message = true;
+                        return;
+                    }
+
+                    return;
+                }
             }
 
-            /* biosig uses a 1-based channel index, and 0 refers to all channels,
-               sigviewer uses a 0-based indexing, and -1 indicates all channels */
             //boundary check & error handling
-            if (pos > event_manager->getMaxEventPosition()
-                    || pos + dur > event_manager->getMaxEventPosition()
-                    || chn > numberChannels
-                    || !types.count(typ))
+            if (position > event_manager->getMaxEventPosition()
+                    || position + duration > event_manager->getMaxEventPosition()
+                    || channel >= numberChannels
+                    || !types.count(type))
                 continue;
 
-            QSharedPointer<SignalEvent> event = QSharedPointer<SignalEvent>(new SignalEvent(pos,
-                    typ, sampleRate, -1, chn-1, dur));
+            QSharedPointer<SignalEvent> event = QSharedPointer<SignalEvent>(new SignalEvent(position,
+                    type, sampleRate, channel, duration));
 
             events << event;
         }
-        sclose(evtHDR);
-        destructHDR(evtHDR);
-    } else
-    {
-        // if the file can not be read with biosig, try this approach
-        destructHDR(evtHDR);
-        QMessageBox::critical(0, file_path, tr("Cannot open file.\nIs the target file open in another application?"));
-        return;
-    }
 
-    QList<QSharedPointer<QUndoCommand> > creation_commands;
-    foreach (QSharedPointer<SignalEvent const> event, events)
-    {
+
+        QList<QSharedPointer<QUndoCommand> > creation_commands;
+        foreach (QSharedPointer<SignalEvent const> event, events)
+        {
             QSharedPointer<QUndoCommand> creation_command (new NewEventUndoCommand (event_manager, event));
             creation_commands.append (creation_command);
+        }
+        MacroUndoCommand* macro_command = new MacroUndoCommand (creation_commands);
+        applicationContext()->getCurrentCommandExecuter()->executeCommand (macro_command);
+    }
+    else
+    {
+        QMessageBox::critical(0, file_path, tr("Cannot open file.\nIs the target file open in another application?"));
+        return;
     }
-    MacroUndoCommand* macro_command = new MacroUndoCommand (creation_commands);
-    applicationContext()->getCurrentCommandExecuter()->executeCommand (macro_command);
 }
 
 //-------------------------------------------------------------------------


=====================================
src/gui_impl/commands/save_gui_command.cpp
=====================================
@@ -299,17 +299,14 @@ void SaveGuiCommand::exportEventsToCSV ()
 
         for (unsigned int i = 0; i < event_manager_pt->getNumberOfEvents(); i++)
         {
-            auto evt = event_manager_pt->getEvent(i);
-            if (evt != NULL) {
-                row tmp = {
-                    evt->getPosition(),
-                    evt->getDuration(),
-                    evt->getChannel(),
-                    evt->getType(),
-                    event_manager_pt->getNameOfEvent(i)
-                };
-                events.append(tmp);
-            }
+            row tmp = {
+                event_manager_pt->getEvent(i)->getPosition(),
+                event_manager_pt->getEvent(i)->getDuration(),
+                event_manager_pt->getEvent(i)->getChannel(),
+                event_manager_pt->getEvent(i)->getType(),
+                event_manager_pt->getNameOfEvent(i)
+            };
+            events.append(tmp);
         }
 
         std::sort(events.begin(),
@@ -350,7 +347,7 @@ void SaveGuiCommand::evaluateEnabledness ()
         no_gdf_file_open = !(applicationContext()->getCurrentFileContext()->getFileName().endsWith("gdf"));
         file_changed = (getFileState () == FILE_STATE_CHANGED);
         has_events = applicationContext()->getCurrentFileContext()->getEventManager()->getNumberOfEvents() > 0;
-
+      
         if (applicationContext()->getCurrentFileContext()->getFileName().endsWith("xdf"))
             no_gdf_file_open = false;//Disabled because currently XDF to GDF conversion doesn't work
     }



View it on GitLab: https://salsa.debian.org/med-team/sigviewer/-/compare/673759f1a0c4016b418af3f4453dacfedbdabadc...0cd1e87a45c91988d621965689a008e8a7668a30

-- 
View it on GitLab: https://salsa.debian.org/med-team/sigviewer/-/compare/673759f1a0c4016b418af3f4453dacfedbdabadc...0cd1e87a45c91988d621965689a008e8a7668a30
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/20201218/1781d598/attachment-0001.html>


More information about the debian-med-commit mailing list