Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

TOPPViewBase.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Timo Sachsenberg$
00032 // $Authors: Marc Sturm, Timo Sachsenberg $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_VISUAL_APPLICATIONS_TOPPVIEWBASE_H
00036 #define OPENMS_VISUAL_APPLICATIONS_TOPPVIEWBASE_H
00037 
00038 //OpenMS
00039 #include <OpenMS/KERNEL/StandardTypes.h>
00040 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00041 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00042 #include <OpenMS/VISUAL/SpectrumWidget.h>
00043 #include <OpenMS/SYSTEM/FileWatcher.h>
00044 #include <OpenMS/VISUAL/SpectraViewWidget.h>
00045 #include <OpenMS/VISUAL/SpectraIdentificationViewWidget.h>
00046 
00047 #include <OpenMS/VISUAL/TOPPViewBehaviorInterface.h>
00048 #include <OpenMS/VISUAL/TOPPViewSpectraViewBehavior.h>
00049 #include <OpenMS/VISUAL/TOPPViewIdentificationViewBehavior.h>
00050 
00051 //STL
00052 #include <map>
00053 
00054 //QT
00055 #include <QtGui/QMainWindow>
00056 #include <QtGui/QButtonGroup>
00057 #include <QtGui/QActionGroup>
00058 #include <QtCore/QStringList>
00059 #include <QtCore/QProcess>
00060 
00061 class QAction;
00062 class QComboBox;
00063 class QLabel;
00064 class QLineEdit;
00065 class QListWidget;
00066 class QListWidgetItem;
00067 class QTreeWidget;
00068 class QTreeWidgetItem;
00069 class QDockWidget;
00070 class QToolButton;
00071 class QCloseEvent;
00072 class QTextEdit;
00073 class QCheckBox;
00074 class QSplashScreen;
00075 class QToolButton;
00076 class QWorkspace;
00077 
00078 namespace OpenMS
00079 {
00080   class EnhancedWorkspace;
00081   class EnhancedTabBar;
00082   class Spectrum1DWidget;
00083   class Spectrum2DWidget;
00084   class Spectrum3DWidget;
00085   class ToolsDialog;
00086   class MultiGradientSelector;
00087   class DBConnection;
00088   class FileWatcher;
00089 
00104   class OPENMS_GUI_DLLAPI TOPPViewBase :
00105     public QMainWindow,
00106     public DefaultParamHandler
00107   {
00108     Q_OBJECT
00109 
00110     friend class TestTOPPView;
00111 
00112 public:
00114 
00115     //Feature map type
00116     typedef LayerData::FeatureMapType FeatureMapType;
00117     //Feature map managed type
00118     typedef LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType;
00119 
00120     //Consensus feature map type
00121     typedef LayerData::ConsensusMapType ConsensusMapType;
00122     //Consensus  map managed type
00123     typedef LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType;
00124 
00125     //Peak map type
00126     typedef LayerData::ExperimentType ExperimentType;
00127     //Main managed data type (experiment)
00128     typedef LayerData::ExperimentSharedPtrType ExperimentSharedPtrType;
00130     typedef ExperimentType::SpectrumType SpectrumType;
00132 
00134     TOPPViewBase(QWidget* parent = 0);
00136     ~TOPPViewBase();
00137 
00150     void addDataFile(const String& filename, bool show_options, bool add_to_recent, String caption = "", UInt window_id = 0, Size spectrum_id = 0);
00161     void addDataDB(UInt db_id, bool show_options, String caption = "", UInt window_id = 0);
00162 
00178     void addData(FeatureMapSharedPtrType feature_map, ConsensusMapSharedPtrType consensus_map, std::vector<PeptideIdentification>& peptides, ExperimentSharedPtrType peak_map, LayerData::DataType data_type, bool show_as_1d, bool show_options, bool as_new_window = true, const String& filename = "", const String& caption = "", UInt window_id = 0, Size spectrum_id = 0);
00179 
00181     void loadFiles(const StringList& list, QSplashScreen* splash_screen);
00182 
00188     void loadPreferences(String filename = "");
00189 
00191     void savePreferences();
00192 
00194     Param getSpectrumParameters(UInt dim);
00195 
00197     const LayerData* getCurrentLayer() const;
00198 
00199     //@name Accessors for the main gui components.
00200     //@brief The top level enhanced workspace and the EnhancedTabWidgets resing in the EnhancedTabBar.
00202 
00203     EnhancedWorkspace* getWorkspace() const;
00204 
00206     SpectrumWidget* getActiveSpectrumWidget() const;
00207 
00209     Spectrum1DWidget* getActive1DWidget() const;
00210 
00212     Spectrum2DWidget* getActive2DWidget() const;
00213 
00215     Spectrum3DWidget* getActive3DWidget() const;
00217 
00219     SpectrumCanvas* getActiveCanvas() const;
00220 
00221 
00223     SpectraIdentificationViewWidget* getSpectraIdentificationViewWidget();
00224 
00226     void showSpectrumWidgetInWindow(SpectrumWidget* sw, const String& caption);
00227 
00228 public slots:
00230     void updateCurrentPath();
00232     void showURL();
00234     void openFileDialog();
00236     void openExampleDialog();
00238     void openDatabaseDialog();
00240     void showGoToDialog();
00242     void preferencesDialog();
00244     void layerStatistics();
00246     void editMetadata();
00248     void layerActivated();
00250     void layerZoomChanged();
00252     void linkZoom();
00254     void layerDeactivated();
00256     void activate1DSpectrum(int index);
00258     void activate1DSpectrum(std::vector<int, std::allocator<int> > indices);
00260     void deactivate1DSpectrum(int index);
00262     void closeFile();
00264     void updateToolBar();
00266     void updateLayerBar();
00268     void updateViewBar();
00270     void viewChanged(int);
00272     void updateFilterBar();
00274     void updateMenu();
00276     void updateTabBar(QWidget* w);
00278     void tileVertical();
00280     void tileHorizontal();
00287     void showStatusMessage(std::string msg, OpenMS::UInt time);
00289     void showCursorStatus(double mz, double rt);
00291     void showCursorStatusInvert(double mz, double rt);
00293     void showTOPPDialog();
00295     void annotateWithID();
00297     void showSpectrumGenerationDialog();
00299     void showSpectrumAlignmentDialog();
00301     void showSpectrumAs1D(int index);
00302     void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
00304     void showCurrentPeaksAs2D();
00306     void showCurrentPeaksAs3D();
00308     void showAboutDialog();
00310     void saveLayerAll();
00312     void saveLayerVisible();
00314     void toggleGridLines();
00316     void toggleAxisLegends();
00318     void showPreferences();
00320     void metadataDatabaseDialog();
00322     void metadataFileDialog();
00323 
00327     void setDrawMode1D(int);
00328     void setIntensityMode(int);
00329     void changeLayerFlag(bool);
00330     void changeLabel(QAction*);
00331     void changeUnassigned(QAction*);
00332     void resetZoom();
00333     void toggleProjections();
00335 
00337     void loadFile(QString);
00338 
00339 protected slots:
00343 
00344     void layerSelectionChange(int);
00346     void layerFilterVisibilityChange(bool);
00348     void layerContextMenu(const QPoint& pos);
00350     void logContextMenu(const QPoint& pos);
00352     void layerVisibilityChange(QListWidgetItem* item);
00354     void filterContextMenu(const QPoint& pos);
00356     void filterEdit(QListWidgetItem* item);
00358     void layerEdit(QListWidgetItem* /*item*/);
00360 
00362     void finishTOPPToolExecution(int exitCode, QProcess::ExitStatus exitStatus);
00364     void abortTOPPTool();
00366     void rerunTOPPTool();
00368     void showSpectrumBrowser();
00370     void showSpectrumMetaData(int spectrum_index);
00371 
00375 
00376     void closeByTab(int id);
00378     void enhancedWorkspaceWindowChanged(int id);
00380     void openRecentFile();
00382     void copyLayer(const QMimeData* data, QWidget* source, int id = -1);
00384 
00386     void updateProcessLog();
00387 
00389     void fileChanged_(const String&);
00390 protected:
00392     void initializeDefaultParameters_();
00393 
00395     std::set<String> getFilenamesOfOpenFiles_();
00396 
00398     void connectToDB_(DBConnection& db);
00402     QStringList getFileList_(const String& path_overwrite = "");
00403 
00405     EnhancedTabBarWidgetInterface* window_(int id) const;
00406 
00408 
00409     QDockWidget* layer_dock_widget_;
00410     QDockWidget* views_dockwidget_;
00411     QDockWidget* filter_dock_widget_;
00413 
00415 
00416     SpectraViewWidget* spectra_view_widget_;
00417     SpectraIdentificationViewWidget* spectra_identification_view_widget_;
00419 
00421     QListWidget* layer_manager_;
00422 
00424 
00425     QListWidget* filters_;
00426     QCheckBox* filters_check_box_;
00428 
00430     FileWatcher* watcher_;
00431 
00433     bool watcher_msgbox_;
00434 
00436     bool zoom_together_;
00437 
00438     QAction* linkZoom_action_;
00439 
00441     QTextEdit* log_;
00442 
00446     QToolBar* tool_bar_;
00447     //common intensity modes
00448 
00449     QButtonGroup* intensity_button_group_;
00450     //1D specific stuff
00451 
00452     QToolBar* tool_bar_1d_;
00453     QButtonGroup* draw_group_1d_;
00454 
00455     //2D specific stuff
00456     QToolBar* tool_bar_2d_peak_;
00457     QToolBar* tool_bar_2d_feat_;
00458     QToolBar* tool_bar_2d_cons_;
00459     QToolBar* tool_bar_2d_ident_;
00460     QAction* dm_precursors_2d_;
00461     QAction* dm_hull_2d_;
00462     QAction* dm_hulls_2d_;
00463     QToolButton* dm_label_2d_;
00464     QActionGroup* group_label_2d_;
00465     QToolButton* dm_unassigned_2d_;
00466     QActionGroup* group_unassigned_2d_;
00467     QAction* dm_elements_2d_;
00468     QAction* projections_2d_;
00469     QAction* dm_ident_2d_;
00471 
00473     EnhancedWorkspace* ws_;
00474 
00476     EnhancedTabBar* tab_bar_;
00477 
00481 
00482     QLabel* message_label_;
00484     QLabel* mz_label_;
00486     QLabel* rt_label_;
00488 
00490 
00491 
00492     void addRecentFile_(const String& filename);
00494     void updateRecentMenu_();
00496     QStringList recent_files_;
00498     std::vector<QAction*> recent_actions_;
00500 
00501 
00503 
00504 
00505     void runTOPPTool_();
00507     struct
00508     {
00509       Param param;
00510       String tool;
00511       String in;
00512       String out;
00513       String file_name;
00514       String layer_name;
00515       UInt window_id;
00516       Size spectrum_id;
00517       QProcess* process;
00518       QTime timer;
00519       bool visible;
00520     } topp_;
00522 
00524     void checkPreferences_();
00526 
00527     void closeEvent(QCloseEvent* event);
00529 
00531     enum LogState
00532     {
00533       LS_NOTICE, 
00534       LS_WARNING, 
00535       LS_ERROR 
00536     };
00538     void showLogMessage_(LogState state, const String& heading, const String& body);
00539 
00541     QMenu* add_2d_context_;
00542 
00544     void showTOPPDialog_(bool visible);
00545 
00548     String current_path_;
00549 
00551     QTabWidget* views_tabwidget_;
00553     TOPPViewBehaviorInterface* view_behavior_;
00555     TOPPViewIdentificationViewBehavior* identificationview_behavior_;
00557     TOPPViewSpectraViewBehavior* spectraview_behavior_;
00558 
00559     // static helper functions
00560 public:
00562     static bool containsMS1Scans(const ExperimentType& exp);
00563 
00565     float estimateNoiseFromRandomMS1Scans(const ExperimentType& exp, UInt n_scans = 10);
00566 
00568     static UInt countMS1Zeros(const ExperimentType& exp);
00569 
00571     static bool hasPeptideIdentifications(const ExperimentType& map);
00572 
00573 private:
00575     static const String CAPTION_3D_SUFFIX_;
00576   }; //class
00577 
00578 } //namespace
00579 
00580 #endif

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:46 using doxygen 1.7.1