Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_VISUAL_SPECTRUM1DCANVAS_H
00036 #define OPENMS_VISUAL_SPECTRUM1DCANVAS_H
00037
00038
00039 #include <vector>
00040 #include <utility>
00041
00042
00043 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00044
00045
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,
00087 DM_CONNECTEDLINES
00088 };
00089
00091 DrawModes getDrawMode() const;
00092
00094 void setDrawMode(DrawModes mode);
00095
00096
00097 virtual void showCurrentLayerPreferences();
00098
00099
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
00173 void activateLayer(Size layer_index);
00174
00175 void removeLayer(Size layer_index);
00176
00177 virtual void updateLayer(Size i);
00178
00185 void setVisibleArea(DRange<2> range);
00186
00187 virtual void horizontalScrollBarChange(int value);
00188
00189 protected slots:
00190
00192 void currentLayerParamtersChanged_();
00193
00194 protected:
00195
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
00231 virtual void recalculateSnapFactor_();
00232
00233 virtual void updateScrollbars_();
00234
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
00292 virtual void translateLeft_();
00293
00294 virtual void translateRight_();
00295
00296 virtual void paintGridLines_(QPainter & painter);
00297 };
00298 }
00299
00300 #endif