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

Spectrum1DCanvas.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 #ifndef OPENMS_VISUAL_SPECTRUM1DCANVAS_H
00036 #define OPENMS_VISUAL_SPECTRUM1DCANVAS_H
00037 
00038 // STL
00039 #include <vector>
00040 #include <utility>
00041 
00042 // OpenMS
00043 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00044 
00045 //QT
00046 class QAction;
00047 
00048 namespace OpenMS
00049 {
00063   class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
00064     public SpectrumCanvas
00065   {
00066     Q_OBJECT
00067 
00068 public:
00070     enum LabelMode
00071     {
00072       LM_XABSOLUTE_YABSOLUTE,
00073       LM_XPERCENT_YABSOLUTE,
00074       LM_XABSOLUTE_YPERCENT,
00075       LM_XPERCENT_YPERCENT
00076     };
00077 
00079     Spectrum1DCanvas(const Param & preferences, QWidget * parent = 0);
00081     virtual ~Spectrum1DCanvas();
00082 
00084     enum DrawModes
00085     {
00086       DM_PEAKS,                                 //< draw data as peak
00087       DM_CONNECTEDLINES                 //< draw as connected lines
00088     };
00089 
00091     DrawModes getDrawMode() const;
00092 
00094     void setDrawMode(DrawModes mode);
00095 
00096     // Docu in base class
00097     virtual void showCurrentLayerPreferences();
00098 
00099     // Docu in base class
00100     virtual void saveCurrentLayer(bool visible);
00101 
00103     bool flippedLayersExist();
00104 
00106     void flipLayer(Size index);
00107 
00109     bool mirrorModeActive();
00110 
00112     void setMirrorModeActive(bool b);
00113 
00115     void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
00116 
00118     void dataToWidget(DoubleReal x, DoubleReal y, QPoint & point, bool flipped = false, bool percentage = false);
00119 
00121     PointType widgetToData(const QPoint & pos, bool percentage = false);
00122 
00124     PointType widgetToData(DoubleReal x, DoubleReal y, bool percentage = false);
00125 
00127 
00129     Annotation1DItem * addPeakAnnotation(PeakIndex peak_index, QString text, QColor color);
00130 
00132     void drawAnnotations(Size layer_index, QPainter & painter);
00133 
00135 
00137     void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
00138 
00140     void resetAlignment();
00141 
00143     void drawAlignment(QPainter & painter);
00144 
00146     Size getAlignmentSize();
00147 
00149     DoubleReal getAlignmentScore();
00150 
00152     std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
00153 
00155     void activateSpectrum(Size index, bool repaint = true);
00156 
00158     void setSwappedAxis(bool swapped);
00159 
00161     void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
00162 
00164     void paint(QPainter * paint_device, QPaintEvent * e);
00165 signals:
00167     void showCurrentPeaksAs2D();
00169     void showCurrentPeaksAs3D();
00170 
00171 public slots:
00172     // Docu in base class
00173     void activateLayer(Size layer_index);
00174     // Docu in base class
00175     void removeLayer(Size layer_index);
00176     //docu in base class
00177     virtual void updateLayer(Size i);
00178 
00185     void setVisibleArea(DRange<2> range);         //Do not change this to AreaType the signal needs QT needs the exact type...
00186     // Docu in base class
00187     virtual void horizontalScrollBarChange(int value);
00188 
00189 protected slots:
00190 
00192     void currentLayerParamtersChanged_();
00193 
00194 protected:
00195     // Docu in base class
00196     bool finishAdding_();
00197 
00199     void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
00201     void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
00202 
00208     void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
00209 
00211     void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
00212 
00214     void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
00215 
00217     void updatePercentageFactor_(Size layer_index);
00218 
00229     virtual void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false);
00230     // Docu in base class
00231     virtual void recalculateSnapFactor_();
00232     // Docu in base class
00233     virtual void updateScrollbars_();
00234     // Docu in base class
00235     virtual void intensityModeChange_();
00236 
00238     std::vector<DrawModes> draw_modes_;
00240     std::vector<Qt::PenStyle> peak_penstyle_;
00241 
00243     QPoint measurement_start_point_;
00245     bool mirror_mode_;
00246 
00248     bool moving_annotations_;
00249 
00251     bool show_alignment_;
00253     Size alignment_layer_1_;
00255     Size alignment_layer_2_;
00257     std::vector<std::pair<DoubleReal, DoubleReal> > aligned_peaks_mz_delta_;
00259     std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
00260 
00262     DoubleReal alignment_score_;
00264     bool is_swapped_;
00265 
00267     PeakIndex findPeakAtPosition_(QPoint);
00268 
00270     void addUserLabelAnnotation_(const QPoint & screen_position);
00272     void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
00274     void addUserPeakAnnotation_(PeakIndex near_peak);
00275 
00277     void ensureAnnotationsWithinDataRange_();
00278 
00281     void paintEvent(QPaintEvent * e);
00282     void mousePressEvent(QMouseEvent * e);
00283     void mouseReleaseEvent(QMouseEvent * e);
00284     void mouseMoveEvent(QMouseEvent * e);
00285     void keyPressEvent(QKeyEvent * e);
00286     void contextMenuEvent(QContextMenuEvent * e);
00288 
00290     virtual void zoomForward_();
00291     //docu in base class
00292     virtual void translateLeft_();
00293     //docu in base class
00294     virtual void translateRight_();
00295     //docu in base class
00296     virtual void paintGridLines_(QPainter & painter);
00297   };
00298 } // namespace OpenMS
00299 
00300 #endif

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