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

TOPPViewBase.h (Maintainer: Marc Sturm)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Marc Sturm $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_APPLICATIONS_TOPPVIEWBASE_H
00028 #define OPENMS_APPLICATIONS_TOPPVIEWBASE_H
00029 
00030 //OpenMS
00031 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00032 #include <OpenMS/VISUAL/DIALOGS/OpenDialog.h>
00033 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00034 #include <OpenMS/VISUAL/SpectrumWidget.h>
00035 #include <OpenMS/VISUAL/EnhancedTabBar.h>
00036 
00037 //STL
00038 #include <map>
00039 
00040 //QT
00041 #include <QtGui/QMainWindow>
00042 #include <QtGui/QWorkspace>
00043 #include <QtCore/QStringList>
00044 
00045 class QAction;
00046 class QComboBox;
00047 class QLabel;
00048 class QListWidget;
00049 class QListWidgetItem;
00050 class QDockWidget;
00051 class QToolButton;
00052 class QCloseEvent;
00053 class QTextEdit;
00054 
00055 namespace OpenMS
00056 {
00057   class MultiGradientSelector;
00058   class Spectrum1DWidget;
00059   class Spectrum2DWidget;
00060   class Spectrum3DWidget;
00061 
00069   class TOPPViewBase 
00070     : public QMainWindow, 
00071       public DefaultParamHandler
00072   {
00073       Q_OBJECT
00074 
00075     public:
00077       TOPPViewBase(QWidget* parent=0);
00079       ~TOPPViewBase();
00080       
00092       void addSpectrum(const String& filename, bool as_new_window=true, bool maps_as_2d=true, bool maximize=false, OpenDialog::Mower use_mower=OpenDialog::NO_MOWER, FileHandler::Type force_type=FileHandler::UNKNOWN, String caption="");
00102       void addDBSpectrum(UInt db_id, bool as_new_window=true, bool maps_as_2d=true, bool maximize=false, OpenDialog::Mower use_mower=OpenDialog::NO_MOWER);
00103 
00105       void maximizeActiveSpectrum();
00107       template <class StringListIterator>
00108       void loadFiles(const StringListIterator& begin, const StringListIterator& end)
00109       {
00110         //use mower?
00111         OpenDialog::Mower mow = OpenDialog::NO_MOWER;
00112         if ( (String)param_.getValue("preferences:intensity_cutoff")=="noise_estimator")
00113         {
00114           mow = OpenDialog::NOISE_ESTIMATOR;
00115         }
00116         
00117         bool last_was_plus = false;
00118         for (StringListIterator it=begin; it!=end; ++it)
00119         {
00120           if (*it=="+")
00121           {
00122             last_was_plus = true;
00123             continue;
00124           }
00125           else if (*it=="@bw")
00126           {
00127             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00128             {
00129               Param tmp = activeCanvas_()->getCurrentLayer().param;
00130               tmp.setValue("dot:gradient", "Linear|0,#ffffff;100,#000000");
00131               activeCanvas_()->setCurrentLayerParameters(tmp);
00132             }
00133           }
00134           else if (*it=="@bg")
00135           {
00136             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00137             {
00138               Param tmp = activeCanvas_()->getCurrentLayer().param;
00139               tmp.setValue("dot:gradient", "Linear|0,#dddddd;100,#000000");
00140               activeCanvas_()->setCurrentLayerParameters(tmp);
00141             }
00142           }
00143           else if (*it=="@b")
00144           {
00145             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00146             {
00147               Param tmp = activeCanvas_()->getCurrentLayer().param;
00148               tmp.setValue("dot:gradient", "Linear|0,#000000;100,#000000");
00149               activeCanvas_()->setCurrentLayerParameters(tmp);
00150             }
00151           }
00152           else if (*it=="@r")
00153           {
00154             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00155             {
00156               Param tmp = activeCanvas_()->getCurrentLayer().param;
00157               tmp.setValue("dot:gradient", "Linear|0,#ff0000;100,#ff0000");
00158               activeCanvas_()->setCurrentLayerParameters(tmp);
00159             }
00160           }
00161           else if (*it=="@g")
00162           {
00163             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00164             {
00165               Param tmp = activeCanvas_()->getCurrentLayer().param;
00166               tmp.setValue("dot:gradient", "Linear|0,#00ff00;100,#00ff00");
00167               activeCanvas_()->setCurrentLayerParameters(tmp);
00168             }
00169           }
00170           else if (*it=="@m")
00171           {
00172             if ( (active2DWindow_()!=0 || active3DWindow_()!=0) && activeCanvas_()!=0 )
00173             {
00174               Param tmp = activeCanvas_()->getCurrentLayer().param;
00175               tmp.setValue("dot:gradient", "Linear|0,#ff00ff;100,#ff00ff");
00176               activeCanvas_()->setCurrentLayerParameters(tmp);
00177             }
00178           }
00179           else if (!last_was_plus)
00180           {
00181             addSpectrum(*it,true,(String)param_.getValue("preferences:default_map_view")=="2d",true,mow);
00182           }
00183           else 
00184           {
00185             last_was_plus = false;
00186             addSpectrum(*it,false,(String)param_.getValue("preferences:default_map_view")=="2d",true,mow);
00187           }
00188         }
00189         maximizeActiveSpectrum();
00190       }
00191 
00197       void loadPreferences(String filename="");
00199       void savePreferences();
00200       
00202       const LayerData* getCurrentLayer() const;
00203       
00204     public slots:
00206       void openSpectrumDialog();
00208       void gotoDialog();
00210       void preferencesDialog();
00212       void layerStatistics();
00214       void editMetadata();
00216       void closeFile();
00218       void updateToolBar();
00220       void updateLayerBar();
00222       void updateFilterBar();
00224       void updateTabBar(QWidget* w);
00226       void tileVertical();
00228       void tileHorizontal();
00230       void linkActiveTo(int);
00237       void showStatusMessage(std::string msg, OpenMS::UInt time);
00239       void showCursorStatus(double mz, double intensity, double rt);
00241       void showTOPPDialog();
00243       void annotateWithID();
00245       void showCurrentPeaksAs3D();
00247       void showSpectrumAs1D(int index);
00249       void showAboutDialog();
00250       
00251     protected slots:
00255 
00256       void layerSelectionChange(int);
00258       void layerContextMenu(const QPoint& pos);
00260       void layerVisibilityChange(QListWidgetItem* item);
00262       void filterContextMenu(const QPoint& pos);
00264       void filterEdit(QListWidgetItem* item);
00266       
00270 
00271       void closeByTab(int index);
00273       void focusByTab(int index);
00275       void removeTab(int id);
00277       void openRecentFile();
00279       
00283       void setActionMode(int);
00284       void setDrawMode1D(int);
00285       void setIntensityMode(int);
00286       void changeLayerFlag(bool);
00287       void resetZoom();
00288       void showProjections();
00290     
00292       void updateProcessLog();
00293     
00294     protected:
00296       void addTab_(SpectrumWidget*, const String&);
00304 
00305       Param getSpectrumParameters_(UInt dim);
00306       
00307       void showAsWindow_(SpectrumWidget* sw, const String& caption);
00309       SpectrumWidget* window_(int id) const;
00311       SpectrumWidget*  activeWindow_() const;
00313       SpectrumCanvas*  activeCanvas_() const;
00315       Spectrum1DWidget* active1DWindow_() const;
00317       Spectrum2DWidget* active2DWindow_() const;
00319       Spectrum3DWidget* active3DWindow_() const;
00321       float estimateNoise_(const SpectrumCanvas::ExperimentType& exp);
00322 
00324       QListWidget* layer_manager_;
00325 
00327       QListWidget* filters_;
00328 
00329 
00331       QTextEdit* log_;
00332 
00336       QToolBar* tool_bar_;
00337       //common actions
00338       QButtonGroup* action_group_;
00339       //common intensity modes
00340       QButtonGroup* intensity_group_;
00341       //1D specific stuff
00342       QToolBar* tool_bar_1d_;
00343       QButtonGroup* draw_group_1d_;
00344       QComboBox* link_box_;
00345       //2D specific stuff
00346       QToolBar* tool_bar_2d_;
00347       QAction* dm_precursors_2d_;
00348       QAction* dm_hull_2d_;
00349       QAction* dm_hulls_2d_;
00350       QAction* dm_numbers_2d_;
00351       QAction* projections_2d_;
00353 
00355       QWorkspace* ws_;
00356 
00358       EnhancedTabBar* tab_bar_;
00359 
00363 
00364       QLabel* message_label_;
00366       QLabel* mz_label_;
00368       QLabel* int_label_;
00370       QLabel* rt_label_;
00372       
00378       std::map<int,int> link_map_;
00379 
00383 
00384       void addRecentFile_(const String& filename);
00386       void updateRecentMenu_();
00388       QStringList recent_files_;
00390       QAction* recent_as_new_layer_;
00391 
00393       std::vector<QAction*> recent_actions_;
00395 
00397       void checkPreferences_();
00398       
00399       void closeEvent(QCloseEvent* event); 
00400   }
00401   ; //class
00402 
00403 } //namespace
00404 
00405 #endif // OPENMS_APPLICATIONS_TOPPVIEWBASE_H

Generated Tue Apr 1 15:36:39 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1