MorphoGraphX  2.0-1-227
ProcessUtils.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef PROCESS_UTILS_HPP
12 #define PROCESS_UTILS_HPP
13 
14 #include <Config.hpp>
15 
16 #include <Vector.hpp>
17 #include <Util.hpp>
18 
19 #include <QStringList>
20 #include <QHash>
21 
22 class QTreeWidgetItem;
23 class QTreeWidget;
24 class QRegularExpression;
25 
26 namespace mgx
27 {
35  QTreeWidgetItem* getFolder(QString name, QHash<QString, QTreeWidgetItem*> &folders,
36  QTreeWidget *tree);
37 
44  void filterProcesses(QTreeWidget *tree, const QString &filter_text);
45 
46 
52  template <size_t dim, typename T>
53  bool fromQString(Vector<dim, T> &p, const QString &s, QString sep = " ")
54  {
55  QStringList l = s.split(sep);
56  size_t sz = min(dim, size_t(l.size()));
57  for(size_t i = 0; i < sz; ++i)
58  p[i] = l[i].toDouble();
59  if(sz == dim)
60  return true;
61 
62  return false;
63  }
64 }
65 #endif
66 
Vector.hpp
mgx::fromQString
bool fromQString(Vector< dim, T > &p, const QString &s, QString sep=" ")
Convert a QString to a Point.
Definition: ProcessUtils.hpp:53
mgx::getFolder
QTreeWidgetItem * getFolder(QString name, QHash< QString, QTreeWidgetItem * > &folders, QTreeWidget *tree)
Find or create a folder from a process tree.
mgx::filterProcesses
void filterProcesses(QTreeWidget *tree, const QString &filter_text)
Show only processes whose name match the regular expression.
mgx
Distributed matrix library.
Definition: Assert.hpp:26
Util.hpp
mgx::Vector
Namespace containing all the utility classes.
Definition: Vector.hpp:48
mgx::min
CU_HOST_DEVICE T min(const T a, const T b)
Definition: Util.hpp:26