diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dce53c9a5d40c88ddf999bb8875da1ab688894df..900ec2efd5ae238de5c86f769802d1429390e1eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,8 +25,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #FIND_PACKAGE( Pappsomspp REQUIRED ) -SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") -#SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") +#SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") +SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/build/src/libpappsomspp-qt4.so") @@ -52,10 +52,24 @@ SET(CPP_FILES utils/readspectrum.cpp ) +set(QTLIBS ${Qt5Xml_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Svg_LIBRARIES}) + +# we need this to be able to include headers produced by uic in our code +# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) + +SET(XTPCPP_SRCS + ./gui/mainwindow.cpp +) + SET (GUI_UIS + ./gui/main.ui ) SET(XTPCPP_MOC_HDRS + + ./gui/mainwindow.h ) @@ -65,15 +79,10 @@ QT4_WRAP_UI( GUI_UI_HDRS ${GUI_UIS} ) QT4_WRAP_CPP( XTPCPP_MOC_SRCS ${XTPCPP_MOC_HDRS} ) +MESSAGE("XTPCPP_SRCS: ${XTPCPP_SRCS}") -set(QTLIBS ${Qt5Xml_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Svg_LIBRARIES}) - -# we need this to be able to include headers produced by uic in our code -# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) -ADD_EXECUTABLE(xtpcpp ${CPP_FILES} ${GUI_UI_HDRS} ${XTPCPP_MOC_SRCS}) +ADD_EXECUTABLE(xtpcpp main.cpp ${CPP_FILES} ${XTPCPP_SRCS} ${GUI_UI_HDRS} ${XTPCPP_MOC_SRCS}) target_include_directories (xtpcpp PUBLIC ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTSVG_INCLUDE_DIR}) SET_TARGET_PROPERTIES(xtpcpp PROPERTIES OUTPUT_NAME xtpcpp diff --git a/src/gui/main.ui b/src/gui/main.ui new file mode 100644 index 0000000000000000000000000000000000000000..c9ed6bdcc0b02513fb2fb1b458eb5dff4f4138dd --- /dev/null +++ b/src/gui/main.ui @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Main</class> + <widget class="QMainWindow" name="Main"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>286</width> + <height>372</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"/> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>286</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionLoad"/> + </widget> + <addaction name="menuFile"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <action name="actionLoad"> + <property name="text"> + <string>Load</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e89d99beea6a4f6a873a9c8dbbf8e5a4770d29ef --- /dev/null +++ b/src/gui/mainwindow.cpp @@ -0,0 +1,66 @@ + +/******************************************************************************* +* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation +******************************************************************************/ + +#include "mainwindow.h" + +#include "ui_main.h" + + +MainWindow::MainWindow(QWidget *parent): + QMainWindow(parent), + ui(new Ui::Main) +{ + ui->setupUi(this); + + PwizLoaderThread *worker = new PwizLoaderThread; + worker->moveToThread(&workerThread); +#if QT_VERSION >= 0x050000 + // Qt5 code + /* + connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); + connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad); + connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile); +*/ +#else +// Qt4 code +/* + connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); + connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString))); + connect(worker, SIGNAL(msDataReady(pwiz::msdata::MSDataFile *)), this, SLOT(handleMsDataFile(pwiz::msdata::MSDataFile *))); + */ +#endif + /* + */ + workerThread.start(); + + +} + +MainWindow::~MainWindow() +{ + workerThread.quit(); + workerThread.wait(); + //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + delete ui; + +} \ No newline at end of file diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h new file mode 100644 index 0000000000000000000000000000000000000000..0141c55363df9f70f509ba86d5ea1327762a97de --- /dev/null +++ b/src/gui/mainwindow.h @@ -0,0 +1,81 @@ + +/******************************************************************************* +* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation +******************************************************************************/ + + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QThread> +#include <QFileInfo> +#include <pappsomspp/types.h> +#include <pappsomspp/peptide/peptide.h> +#include <pappsomspp/spectrum/spectrum.h> +#include <pwiz/data/msdata/MSDataFile.hpp> +#include "../utils/readspectrum.h" + + + +namespace Ui { +class Main; +} + + +class PwizLoaderThread : public QObject +{ + Q_OBJECT + public: + +public slots: + void doMsDataFileLoad(const QString & parameter) { + pwiz::msdata::MSDataFile* p_ms_data_file = getPwizMSDataFile(parameter); + /* ... here is the expensive or blocking operation ... */ + emit msDataReady(p_ms_data_file); + } + +signals: + void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file); +}; + +class MainWindow: public QMainWindow { + Q_OBJECT + QThread workerThread; + +public: + + explicit MainWindow(QWidget * parent = 0); + ~MainWindow(); + +public slots: + //void peptideEdited(QString peptideStr); + // void setColor(const QColor &color); + // void setShape(Shape shape); +signals: + //void peptideChanged(pappso::PeptideSp peptide); + +private: + Ui::Main *ui; + +}; + +#endif // MAINWINDOW_H diff --git a/src/main.cpp b/src/main.cpp index d6375538653e730f6e2f794b1d34e9a56ca39b85..d942d30b356e3f839606957b5eb49e57373809e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,8 +23,9 @@ #include <QApplication> #include <iostream> -#include "ptspectrumviewer.h" -#include "qspectrumwidget.h" +#include <pappsomspp/pappsoexception.h> +#include "config.h" +#include "gui/mainwindow.h" using namespace std; @@ -37,7 +38,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName("PAPPSO"); QCoreApplication::setOrganizationDomain("pappso.inra.fr"); QCoreApplication::setApplicationName("xtpcpp"); - PtSpectrumViewer window; + MainWindow window; window.show(); return app.exec();