OpenMS  2.4.0
MultiGradient.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2018.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 //OpenMS
41 #include <OpenMS/CONCEPT/Types.h>
42 #include <OpenMS/CONCEPT/Macros.h>
45 
46 //QT
47 #include <QtGui/QColor>
48 
49 //STL
50 #include <map>
51 #include <vector>
52 #include <cmath>
53 
54 namespace OpenMS
55 {
56 
67  class OPENMS_GUI_DLLAPI MultiGradient
68  {
69 public:
71  static MultiGradient getDefaultGradientLinearIntensityMode();
72 
74  static MultiGradient getDefaultGradientLogarithmicIntensityMode();
75 
78  {
80  IM_STAIRS
81  };
82 
84  MultiGradient();
85 
87  MultiGradient(const MultiGradient & multigradient);
88 
90  ~MultiGradient();
91 
93  MultiGradient & operator=(const MultiGradient & rhs);
94 
96  void insert(double position, QColor color);
98  bool remove(double position);
100  bool exists(double position);
106  UInt position(UInt index);
112  QColor color(UInt index);
113 
114 
121  QColor interpolatedColorAt(double position) const;
128  QColor interpolatedColorAt(double position, double min, double max) const;
129 
131  void activatePrecalculationMode(double min, double max, UInt steps);
133  void deactivatePrecalculationMode();
134 
136  inline Int precalculatedColorIndex( double position ) const
137  {
138  OPENMS_PRECONDITION(pre_.size() != 0, "MultiGradient::precalculatedColorIndex(double): Precalculation mode not activated!");
139  OPENMS_PRECONDITION(position >= pre_min_, (String("MultiGradient::precalculatedColorIndex(double): position ") + position + " out of specified range (" + pre_min_ + "-" + (pre_min_ + pre_size_) + ")!").c_str());
140 
141  Int index = (Int)((position - pre_min_) / pre_size_ * pre_steps_);
142 
143  return qBound( 0, index, (Int)pre_.size() - 1 );
144  }
145 
147  inline QColor precalculatedColorByIndex( Int index ) const
148  {
149  OPENMS_PRECONDITION(pre_.size() != 0, "MultiGradient::precalculatedColorByIndex(Int): Precalculation mode not activated!");
150  OPENMS_PRECONDITION( index >= 0, "MultiGradient::precalculatedColorByIndex(Int): negative indexes not allowed");
151  OPENMS_PRECONDITION( index < (Int)pre_.size(), (String("MultiGradient::indexedColor(Int): index ") + index + " out of specified range (0-" + pre_.size() + ")!").c_str());
152 
153  return pre_[index];
154  }
155 
163  inline QColor precalculatedColorAt(double position) const
164  {
165  return precalculatedColorByIndex( precalculatedColorIndex( position ) );
166  }
167 
169  Size size() const;
170 
173  {
174  return pre_.size();
175  }
176 
178  void setInterpolationMode(InterpolationMode mode);
180  InterpolationMode getInterpolationMode() const;
181 
183  std::string toString() const;
199  void fromString(const std::string & gradient);
200 
201 protected:
203  std::map<double, QColor> pos_col_;
207  std::vector<QColor> pre_;
209  double pre_min_;
211  double pre_size_;
214 
215  };
216 
217 }
OpenMS::MultiGradient
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
ConsensusXMLFile.h
MzTabFile.h
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:150
OpenMS::ExperimentalDesign
Representation of the Experimental Design in OpenMS. Instances can be loaded via the ExperimentalDesi...
Definition: ExperimentalDesign.h:85
OpenMS::ExperimentalDesignFile::load
static ExperimentalDesign load(const String &tsv_file, bool require_spectra_files)
Loads an experimental design from a tabular separated file.
FileHandler.h
OpenMS::TextFile::addLine
void addLine(const StringType &line)
Definition: TextFile.h:112
TextFile.h
Types.h
ExperimentalDesignFile.h
Int
OpenMS::File::basename
static String basename(const String &file)
Returns the basename of the file (without the path).
OpenMS::MultiGradient::pre_size_
double pre_size_
Width of the precalculated color range.
Definition: MultiGradient.h:211
OpenMS::String
A more convenient string class.
Definition: String.h:57
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:55
OpenMS::PeptideEvidence::setProteinAccession
void setProteinAccession(const String &s)
set the protein accession the peptide matches to. If not available set to empty string.
OpenMS::FileTypes::CONSENSUSXML
@ CONSENSUSXML
OpenMS consensus map format (.consensusXML)
Definition: FileTypes.h:67
OpenMS::TextFile
This class provides some basic file handling methods for text files.
Definition: TextFile.h:46
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
FeatureXMLFile.h
OpenMS::ConsensusMap::getPrimaryMSRunPath
void getPrimaryMSRunPath(StringList &toFill) const
returns the MS run path (stored in ColumnHeaders)
OpenMS::ConsensusFeature::HandleSetType
std::set< FeatureHandle, FeatureHandle::IndexLess > HandleSetType
Type definitions.
Definition: ConsensusFeature.h:75
OpenMS::operator<
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
OPENMS_PRECONDITION
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:106
OpenMS::MultiGradient::pre_min_
double pre_min_
Minimum of the precalculated color range.
Definition: MultiGradient.h:209
OpenMS::BaseFeature::getPeptideIdentifications
const std::vector< PeptideIdentification > & getPeptideIdentifications() const
returns a const reference to the PeptideIdentification vector
OpenMS::MultiGradient::InterpolationMode
InterpolationMode
Interpolation mode.
Definition: MultiGradient.h:77
OpenMS::MultiGradient::interpolation_mode_
InterpolationMode interpolation_mode_
Current interpolation mode.
Definition: MultiGradient.h:205
OpenMS::ExperimentalDesign::getPathLabelToFractionMapping
std::map< std::pair< String, unsigned >, unsigned > getPathLabelToFractionMapping(bool) const
return <file_path, label> to fraction mapping
OpenMS::MultiGradient::precalculatedColorIndex
Int precalculatedColorIndex(double position) const
index of color in precalculated table by position in gradient
Definition: MultiGradient.h:136
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
Macros.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
Exception.h
OpenMS::PeptideHit::PeakAnnotation::charge
int charge
Definition: PeptideHit.h:85
LOG_WARN
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged.
Definition: LogStream.h:450
OpenMS::PeptideHit::PeakAnnotation::annotation
String annotation
Definition: PeptideHit.h:84
OpenMS::MultiGradient::pre_
std::vector< QColor > pre_
Precalculated colors.
Definition: MultiGradient.h:207
double
OpenMS::MultiGradient::precalculatedColorByIndex
QColor precalculatedColorByIndex(Int index) const
precalculated color by its index in the table
Definition: MultiGradient.h:147
OpenMS::ExperimentalDesign::SampleSection
Definition: ExperimentalDesign.h:105
OpenMS::ExperimentalDesign::getNumberOfLabels
unsigned getNumberOfLabels() const
OpenMS::MultiGradient::pre_steps_
UInt pre_steps_
Steps of the precalculated color range.
Definition: MultiGradient.h:213
OpenMS::FileTypes::Type
Type
Actual file types enum.
Definition: FileTypes.h:58
OpenMS::PeptideEvidence
Representation of a peptide evidence.
Definition: PeptideEvidence.h:50
OpenMS::ConsensusFeature
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:69
OpenMS::MultiGradient::precalculatedSize
Size precalculatedSize() const
size of precalculated colors table
Definition: MultiGradient.h:172
LOG_FATAL_ERROR
#define LOG_FATAL_ERROR
Macro to be used if fatal error are reported (processing stops)
Definition: LogStream.h:442
OpenMS::FileHandler::getType
static FileTypes::Type getType(const String &filename)
Tries to determine the file type (by name or content)
OpenMS::MultiGradient::IM_LINEAR
@ IM_LINEAR
IM_LINEAR returns the linear interpolation (default).
Definition: MultiGradient.h:79
MzTab.h
OpenMS::MultiGradient::pos_col_
std::map< double, QColor > pos_col_
Map of index and color.
Definition: MultiGradient.h:203
OpenMS::ExperimentalDesign::MSFileSectionEntry
Definition: ExperimentalDesign.h:94
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:75
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
OpenMS::ExperimentalDesign::SampleSection::getFactorValue
String getFactorValue(unsigned sample, const String &factor)
OpenMS::ConsensusXMLFile::load
void load(const String &filename, ConsensusMap &map)
Loads a consensus map from file and calls updateRanges.
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::ExperimentalDesign::SampleSection::hasFactor
bool hasFactor(const String &factor) const
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
ExperimentalDesign.h
OpenMS::ExperimentalDesign::MSFileSection
std::vector< MSFileSectionEntry > MSFileSection
Definition: ExperimentalDesign.h:147
OpenMS::ExperimentalDesign::isFractionated
bool isFractionated() const
OpenMS::ExperimentalDesign::getSampleSection
const ExperimentalDesign::SampleSection & getSampleSection() const
OpenMS::ConsensusMap::getColumnHeaders
const ColumnHeaders & getColumnHeaders() const
Non-mutable access to the file descriptions.
OpenMS::PeptideIdentification
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:62
OpenMS::ExperimentalDesign::getPathLabelToSampleMapping
std::map< std::pair< String, unsigned >, unsigned > getPathLabelToSampleMapping(bool) const
return <file_path, label> to sample mapping
String.h
OpenMS::TextFile::store
void store(const String &filename)
Writes the data to a file.
OpenMS::ExperimentalDesign::getMSFileSection
const MSFileSection & getMSFileSection() const
OpenMS::ExperimentalDesign::getPathLabelToFractionGroupMapping
std::map< std::pair< String, unsigned >, unsigned > getPathLabelToFractionGroupMapping(bool) const
return <file_path, label> to fraction_group mapping
seqan::position
Size< TNeedle >::Type position(const PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:561
OpenMS::PeptideHit::PeakAnnotation
Contains annotations of a peak.
Definition: PeptideHit.h:82
OpenMS::StringConversions::toString
String toString(T i)
toString functions (single argument)
Definition: StringUtils.h:68
OpenMS::MultiGradient::precalculatedColorAt
QColor precalculatedColorAt(double position) const
Returns a precalculated color.
Definition: MultiGradient.h:163
File.h
TOPPBase.h
float
OpenMS::ConsensusXMLFile
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLFile.h:61
OpenMS::ConsensusMap::ColumnHeaders
std::map< UInt64, ColumnHeader > ColumnHeaders
Definition: ConsensusMap.h:136
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:54