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
00036 #ifndef OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00037 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00038
00039
00040 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00041 #include <OpenMS/VISUAL/Spectrum1DCanvas.h>
00042 #include <OpenMS/KERNEL/PeakIndex.h>
00043
00044
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
00080 virtual void showCurrentLayerPreferences();
00081
00082
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
00114 void activateLayer(Size layer_index);
00115
00116 void removeLayer(Size layer_index);
00117
00118 virtual void updateLayer(Size i);
00119
00120 virtual void horizontalScrollBarChange(int value);
00121
00122 virtual void verticalScrollBarChange(int value);
00132 void updateProjections();
00133
00134 protected slots:
00135
00137 void currentLayerParametersChanged_();
00138
00139 protected:
00140
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
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
00261 virtual void intensityModeChange_();
00262
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
00351 virtual void translateLeft_();
00352
00353 virtual void translateRight_();
00354
00355 virtual void translateForward_();
00356
00357 virtual void translateBackward_();
00358
00360 void finishContextMenu_(QMenu * context_menu, QMenu * settings_menu);
00361 };
00362 }
00363
00364 #endif