OpenMS
OpenMS::GUIHelpers Namespace Reference

Classes

class  OverlapDetector
 A heuristic: Given a set of levels (rows), try to add items at to topmost row which does not overlap an already placed item in this row (according to its x-coordinate) More...
 
class  GUILock
 RAII class to disable the GUI and set a busy cursor and go back to the original state when this class is destroyed. More...
 
class  ColorBrewer
 

Functions

void openFolder (const QString &folder)
 
QString getSaveFilename (QWidget *parent, const QString &caption, const QString &dir, const FileTypeList &supported_file_types, bool add_all_filter, const FileTypes::Type fallback_extension)
 Open a dialog to select a filename to save data to. More...
 
bool startTOPPView (QStringList args)
 
void openURL (const QString &target)
 
void drawText (QPainter &painter, const QStringList &text, const QPoint &where, const QColor &col_fg=QColor("invalid"), const QColor &col_bg=QColor("invalid"), const QFont &font=QFont("Courier"))
 draw a multi-line text at coordinates XY using a specific font and color More...
 
QRectF getTextDimension (const QStringList &text, const QFont &font, int &line_spacing)
 Obtains the bounding rectangle of a text (useful to determine overlaps etc) More...
 
QPointF nearestPoint (const QPointF &origin, const QList< QPointF > &list)
 Returns the point in the list that is nearest to origin. More...
 
QPointF intersectionPoint (const QRectF &rect, const QPointF &p)
 Find the point on a rectangle where a ray/line from a point p to its center would intersect at. More...
 
StringList convert (const QStringList &in)
 
QStringList convert (const StringList &in)
 

Detailed Description

Namespace which holds static GUI-related helper functions.

Function Documentation

◆ convert() [1/2]

StringList OpenMS::GUIHelpers::convert ( const QStringList &  in)

◆ convert() [2/2]

QStringList OpenMS::GUIHelpers::convert ( const StringList in)

◆ drawText()

void OpenMS::GUIHelpers::drawText ( QPainter &  painter,
const QStringList &  text,
const QPoint &  where,
const QColor &  col_fg = QColor("invalid"),
const QColor &  col_bg = QColor("invalid"),
const QFont &  font = QFont("Courier") 
)

draw a multi-line text at coordinates XY using a specific font and color

Internally used getTextDimension() to figure out the size of the text-block/background which needs to be painted.

Parameters
painterWhere to draw
textEach item is a new line
whereCoordinates where to start drawing (upper left corner of text)
col_fgOptional text color; if invalid (=default) will use the current painter's color
col_bgOptional background color of bounding rectangle; if invalid (=default) no background will be painted
fontFont to use; will use Courier by default

◆ getSaveFilename()

QString OpenMS::GUIHelpers::getSaveFilename ( QWidget parent,
const QString &  caption,
const QString &  dir,
const FileTypeList supported_file_types,
bool  add_all_filter,
const FileTypes::Type  fallback_extension 
)

Open a dialog to select a filename to save data to.

◆ getTextDimension()

QRectF OpenMS::GUIHelpers::getTextDimension ( const QStringList &  text,
const QFont &  font,
int &  line_spacing 
)

Obtains the bounding rectangle of a text (useful to determine overlaps etc)

◆ intersectionPoint()

QPointF OpenMS::GUIHelpers::intersectionPoint ( const QRectF &  rect,
const QPointF &  p 
)

Find the point on a rectangle where a ray/line from a point p to its center would intersect at.

Parameters
rectRectangle which intersects with the line from p to its center
pA point outside the rectangle
Returns
The intersection point or the center() of rect if p is inside the rectangle

Referenced by Annotation1DCaret< DataPoint >::draw(), and Annotation1DPeakItem< DataPoint >::draw().

◆ nearestPoint()

QPointF OpenMS::GUIHelpers::nearestPoint ( const QPointF &  origin,
const QList< QPointF > &  list 
)

Returns the point in the list that is nearest to origin.

◆ openFolder()

void OpenMS::GUIHelpers::openFolder ( const QString &  folder)

Open a folder in file explorer Will show a message box on failure

◆ openURL()

void OpenMS::GUIHelpers::openURL ( const QString &  target)

Open a certain URL (in a browser) Will show a message box on failure

Referenced by TOPPASBase::showURL().

◆ startTOPPView()

bool OpenMS::GUIHelpers::startTOPPView ( QStringList  args)

Open TOPPView (e.g. from within TOPPAS) as a detached process (i.e. will continue running when this process ends)

Returns
true if process started successfully

Referenced by TOPPASBase::openFilesInTOPPView().