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

Spectrum2DCanvas.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 $
00033 // --------------------------------------------------------------------------
00034 
00035 
00036 #ifndef OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00037 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00038 
00039 // OpenMS
00040 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00041 #include <OpenMS/VISUAL/Spectrum1DCanvas.h>
00042 #include <OpenMS/KERNEL/PeakIndex.h>
00043 
00044 // QT
00045 class QPainter;
00046 class QMouseEvent;
00047 
00048 namespace OpenMS
00049 {
00067   class OPENMS_GUI_DLLAPI Spectrum2DCanvas :
00068     public SpectrumCanvas
00069   {
00070     Q_OBJECT
00071 
00072 public:
00074     Spectrum2DCanvas(const Param & preferences, QWidget * parent = 0);
00075 
00077     ~Spectrum2DCanvas();
00078 
00079     // Docu in base class
00080     virtual void showCurrentLayerPreferences();
00081 
00082     // Docu in base class
00083     virtual void saveCurrentLayer(bool visible);
00084 
00086     void mergeIntoLayer(Size i, FeatureMapSharedPtrType map);
00087 
00089     void mergeIntoLayer(Size i, ConsensusMapSharedPtrType map);
00090 
00092     void mergeIntoLayer(Size i, std::vector<PeptideIdentification> & peptides);
00093 
00095     void recalculateCurrentLayerDotGradient();
00096 
00097 signals:
00099     void showProjectionHorizontal(ExperimentSharedPtrType, Spectrum1DCanvas::DrawModes);
00101     void showProjectionVertical(ExperimentSharedPtrType, Spectrum1DCanvas::DrawModes);
00103     void showProjectionInfo(int, double, double);
00105     void toggleProjections();
00107     void showSpectrumAs1D(int index);
00108     void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
00110     void showCurrentPeaksAs3D();
00111 
00112 public slots:
00113     // Docu in base class
00114     void activateLayer(Size layer_index);
00115     // Docu in base class
00116     void removeLayer(Size layer_index);
00117     //docu in base class
00118     virtual void updateLayer(Size i);
00119     // Docu in base class
00120     virtual void horizontalScrollBarChange(int value);
00121     // Docu in base class
00122     virtual void verticalScrollBarChange(int value);
00132     void updateProjections();
00133 
00134 protected slots:
00135 
00137     void currentLayerParametersChanged_();
00138 
00139 protected:
00140     // Docu in base class
00141     bool finishAdding_();
00142 
00144     void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
00146     void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
00147 
00150     void mousePressEvent(QMouseEvent * e);
00151     void mouseReleaseEvent(QMouseEvent * e);
00152     void mouseMoveEvent(QMouseEvent * e);
00153     void paintEvent(QPaintEvent * e);
00154     void contextMenuEvent(QContextMenuEvent * e);
00155     void keyPressEvent(QKeyEvent * e);
00156     void keyReleaseEvent(QKeyEvent * e);
00157     void mouseDoubleClickEvent(QMouseEvent * e);
00159 
00160     // Docu in base class
00161     virtual void updateScrollbars_();
00162 
00171     void paintDots_(Size layer_index, QPainter & p);
00172 
00173     void paintAllIntensities_(Size layer_index, DoubleReal pen_width, QPainter & painter);
00174 
00184     void paintMaximumIntensities_(Size layer_index, Size rt_pixel_count, Size mz_pixel_count, QPainter & p);
00185 
00192     void paintPrecursorPeaks_(Size layer_index, QPainter & painter);
00193 
00200     void paintFeatureData_(Size layer_index, QPainter & p);
00201 
00208     void paintTraceConvexHulls_(Size layer_index, QPainter & p);
00209 
00216     void paintFeatureConvexHulls_(Size layer_index, QPainter & p);
00217 
00224     void paintIdentifications_(Size layer_index, QPainter & p);
00225 
00232     void paintConsensusElements_(Size layer_index, QPainter & p);
00233 
00242     void paintConsensusElement_(Size layer_index, const ConsensusFeature & cf, QPainter & p, bool use_buffer);
00243 
00250     bool isConsensusFeatureVisible_(const ConsensusFeature & ce, Size layer_index);
00251 
00258     void paintConvexHulls_(const std::vector<ConvexHull2D> & hulls, bool hasIdentifications, QPainter & p);
00259 
00260     // Docu in base class
00261     virtual void intensityModeChange_();
00262     // DOcu in base class
00263     virtual void recalculateSnapFactor_();
00264 
00266     ExperimentType projection_mz_;
00268     ExperimentType projection_rt_;
00269 
00275     inline Int precalculatedColorIndex_(Real val, const MultiGradient & gradient, DoubleReal snap_factor)
00276     {
00277       Real gradientPos;
00278       switch (intensity_mode_)
00279       {
00280       case IM_NONE:
00281         gradientPos = val;
00282         break;
00283       case IM_PERCENTAGE:
00284         gradientPos = val * percentage_factor_;
00285         break;
00286       case IM_SNAP:
00287         gradientPos = val * snap_factor;
00288         break;
00289       case IM_LOG:
00290         gradientPos = std::log(val + 1);
00291         break;
00292       default:
00293         throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00294       }
00295       return gradient.precalculatedColorIndex( gradientPos );
00296     }
00297 
00303     inline QColor heightColor_(Real val, const MultiGradient & gradient, DoubleReal snap_factor)
00304     {
00305       return gradient.precalculatedColorByIndex( precalculatedColorIndex_( val, gradient, snap_factor ) );
00306     }
00307 
00316     inline void dataToWidget_(DoubleReal x, DoubleReal y, QPoint & point)
00317     {
00318       if (!isMzToXAxis())
00319       {
00320         point.setX(int((y - visible_area_.minY()) / visible_area_.height() * width()));
00321         point.setY(height() - int((x - visible_area_.minX()) / visible_area_.width() * height()));
00322       }
00323       else
00324       {
00325         point.setX(int((x - visible_area_.minX()) / visible_area_.width() * width()));
00326         point.setY(height() - int((y - visible_area_.minY()) / visible_area_.height() * height()));
00327       }
00328     }
00329 
00331     void recalculateDotGradient_(Size layer);
00332 
00334     void highlightPeak_(QPainter & p, const PeakIndex & peak);
00335 
00337     PeakIndex findNearestPeak_(const QPoint & pos);
00338 
00340     void paintIcon_(const QPoint & pos, const QRgb & color, const String & icon, Size s, QPainter & p) const;
00341 
00343     PeakIndex selected_peak_;
00345     PeakIndex measurement_start_;
00346 
00348     virtual void translateVisibleArea_( DoubleReal mzShiftRel, DoubleReal rtShiftRel );
00349 
00350     //docu in base class
00351     virtual void translateLeft_();
00352     //docu in base class
00353     virtual void translateRight_();
00354     //docu in base class
00355     virtual void translateForward_();
00356     //docu in base class
00357     virtual void translateBackward_();
00358 
00360     void finishContextMenu_(QMenu * context_menu, QMenu * settings_menu);
00361   };
00362 }
00363 
00364 #endif

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