/usr/include/OpenMS/VISUAL/Spectrum1DCanvas.h is in libopenms-dev 1.11.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | // --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Timo Sachsenberg$
// $Authors: Marc Sturm $
// --------------------------------------------------------------------------
#ifndef OPENMS_VISUAL_SPECTRUM1DCANVAS_H
#define OPENMS_VISUAL_SPECTRUM1DCANVAS_H
// STL
#include <vector>
#include <utility>
// OpenMS
#include <OpenMS/VISUAL/SpectrumCanvas.h>
//QT
class QAction;
namespace OpenMS
{
/**
@brief Canvas for visualization of one or several spectra.
@image html Spectrum1DCanvas.png
The example image shows %Spectrum1DCanvas displaying a raw data layer and a peak data layer.
@todo Use spectrum StringDataArray with name 'label' for peak annotations (Hiwi, Johannes)
@htmlinclude OpenMS_Spectrum1DCanvas.parameters
@ingroup SpectrumWidgets
*/
class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
public SpectrumCanvas
{
Q_OBJECT
public:
/// Label modes (percentage or absolut) of x axis and y axis
enum LabelMode
{
LM_XABSOLUTE_YABSOLUTE,
LM_XPERCENT_YABSOLUTE,
LM_XABSOLUTE_YPERCENT,
LM_XPERCENT_YPERCENT
};
/// Default constructor
Spectrum1DCanvas(const Param & preferences, QWidget * parent = 0);
/// Destructor
virtual ~Spectrum1DCanvas();
///Enumerate all avaiable paint styles
enum DrawModes
{
DM_PEAKS, //< draw data as peak
DM_CONNECTEDLINES //< draw as connected lines
};
/// Returns the draw mode of the current layer
DrawModes getDrawMode() const;
/// Sets draw mode of the current layer
void setDrawMode(DrawModes mode);
// Docu in base class
virtual void showCurrentLayerPreferences();
// Docu in base class
virtual void saveCurrentLayer(bool visible);
/// Returns whether flipped layers exist or not
bool flippedLayersExist();
/// Flips the layer with @p index up/downwards
void flipLayer(Size index);
/// Returns whether this widget is currently in mirror mode
bool mirrorModeActive();
/// Sets whether this widget is currently in mirror mode
void setMirrorModeActive(bool b);
/// For convenience - calls dataToWidget
void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
/// Calls SpectrumCanvas::dataToWidget_(), takes mirror mode into account
void dataToWidget(DoubleReal x, DoubleReal y, QPoint & point, bool flipped = false, bool percentage = false);
/// For convenience - calls widgetToData
PointType widgetToData(const QPoint & pos, bool percentage = false);
/// Calls SpectrumCanvas::widgetToData_(), takes mirror mode into account
PointType widgetToData(DoubleReal x, DoubleReal y, bool percentage = false);
/// ----- Annotations
/// Add an annotation item for the given peak
Annotation1DItem * addPeakAnnotation(PeakIndex peak_index, QString text, QColor color);
/// Draws all annotation items of @p layer_index on @p painter
void drawAnnotations(Size layer_index, QPainter & painter);
/// ----- Alignment
/// Performs an alignment of the layers with @p layer_index_1 and @p layer_index_2
void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
/// Resets alignment_
void resetAlignment();
/// Draws the alignment on @p painter
void drawAlignment(QPainter & painter);
/// Returns the number of aligned pairs of peaks
Size getAlignmentSize();
/// Returns the score of the alignment
DoubleReal getAlignmentScore();
/// Returns aligned_peaks_indices_
std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
/// Sets current spectrum index of current layer to @p index
void activateSpectrum(Size index, bool repaint = true);
/// is the widget shown vertically? (for projections)
void setSwappedAxis(bool swapped);
/// Set's the Qt PenStyle of the active layer
void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
/// Actual painting takes place here
void paint(QPainter * paint_device, QPaintEvent * e);
signals:
/// Requests to display all spectra in 2D plot
void showCurrentPeaksAs2D();
/// Requests to display all spectra in 3D plot
void showCurrentPeaksAs3D();
public slots:
// Docu in base class
void activateLayer(Size layer_index);
// Docu in base class
void removeLayer(Size layer_index);
//docu in base class
virtual void updateLayer(Size i);
/**
@brief Sets the visible area.
Sets the visible area to a new value. Note that it does not emit visibleAreaChanged()
@param range the new visible area
*/
void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
// Docu in base class
virtual void horizontalScrollBarChange(int value);
protected slots:
/// Reacts on changed layer paramters
void currentLayerParamtersChanged_();
protected:
// Docu in base class
bool finishAdding_();
/// Draws the coordinates (or coordinate deltas) to the widget's upper left corner
void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
/// Draws the coordinates (or coordinate deltas) to the widget's upper left corner
void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
/**
@brief Changes visible area interval
This method is for convenience only. It calls changeVisibleArea_(const AreaType&, bool, bool) .
*/
void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
/// Draws a highlighted peak; if draw_elongation is true, the elongation line is drawn (for measuring)
void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
/// Draws a dashed line using the highlighted peak color parameter
void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
/// Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE)
void updatePercentageFactor_(Size layer_index);
/**
@brief Sets the visible area
Changes the visible area, adjustes the zoom stack and notifies interested clients about the change.
If parts of the area are outside of the data area, the new area will be adjusted.
@param new_area The new visible area.
@param repaint if repainting of the widget should ne triggered
@param add_to_stack If the new area is to add to the zoom_stack_
*/
virtual void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false);
// Docu in base class
virtual void recalculateSnapFactor_();
// Docu in base class
virtual void updateScrollbars_();
// Docu in base class
virtual void intensityModeChange_();
/// Draw modes (for each spectrum)
std::vector<DrawModes> draw_modes_;
/// Draw style
std::vector<Qt::PenStyle> peak_penstyle_;
/// start point of "ruler" for measure mode
QPoint measurement_start_point_;
/// Indicates whether this widget is currently in mirror mode
bool mirror_mode_;
/// Indicates whether annotation items are just being moved on the canvas
bool moving_annotations_;
/// Indicates whether an alignment is currently visualized
bool show_alignment_;
/// Layer index of the first alignment layer
Size alignment_layer_1_;
/// Layer index of the second alignment layer
Size alignment_layer_2_;
/// Stores the alignment as MZ values of pairs of aligned peaks in both spectra
std::vector<std::pair<DoubleReal, DoubleReal> > aligned_peaks_mz_delta_;
/// Stores the peak indizes of pairs of aligned peaks in both spectra
std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
/// Stores the score of the last alignment
DoubleReal alignment_score_;
/// is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only)
bool is_swapped_;
/// Find peak next to the given position
PeakIndex findPeakAtPosition_(QPoint);
/// Shows dialog and calls addLabelAnnotation_
void addUserLabelAnnotation_(const QPoint & screen_position);
/// Adds an annotation item at the given screen position
void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
/// Shows dialog and calls addPeakAnnotation_
void addUserPeakAnnotation_(PeakIndex near_peak);
/// Ensure that all annotations are within data range
void ensureAnnotationsWithinDataRange_();
/** @name Reimplemented QT events */
//@{
void paintEvent(QPaintEvent * e);
void mousePressEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e);
void mouseMoveEvent(QMouseEvent * e);
void keyPressEvent(QKeyEvent * e);
void contextMenuEvent(QContextMenuEvent * e);
//@}
///Go forward in zoom history
virtual void zoomForward_();
/// docu in base class
virtual void zoom_(int x, int y, bool zoom_in);
//docu in base class
virtual void translateLeft_();
//docu in base class
virtual void translateRight_();
//docu in base class
virtual void paintGridLines_(QPainter & painter);
};
} // namespace OpenMS
#endif
|