MeVisLab Toolbox Reference
ManagedActionTrigger.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2014, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef MANAGED_ACTION_TRIGGER_H
14 #define MANAGED_ACTION_TRIGGER_H
15 
17 #include <ThirdPartyWarningsDisable.h>
18 #include <string>
19 #include <list>
20 #include <ThirdPartyWarningsRestore.h>
21 
22 // undef macros defined in X.h (Linux), which might collide with our enums:
23 #ifdef Button1Mask
24 #undef Button1Mask
25 #endif
26 #ifdef Button2Mask
27 #undef Button2Mask
28 #endif
29 #ifdef Button3Mask
30 #undef Button3Mask
31 #endif
32 #ifdef AllButtonsMask
33 #undef AllButtonsMask
34 #endif
35 
36 #ifdef ShiftMask
37 #undef ShiftMask
38 #endif
39 #ifdef CtrlMask
40 #undef CtrlMask
41 #endif
42 #ifdef AltMask
43 #undef AltMask
44 #endif
45 #ifdef AllModifiersMask
46 #undef AllModifiersMask
47 #endif
48 
52 {
53 public:
56  enum {
57  NoModifier = 0,
58  ShiftModifier = 0x10,
59  ControlModifier = 0x20,
60  AltModifier = 0x40,
61  AllModifiersMask = 0x70,
62  };
63 
65  enum {
66  Button1Mask = 1,
67  Button2Mask = 2,
68  Button3Mask = 4,
69  AllButtonsMask = 0x07,
70  };
71 
75  static std::list<std::string> splitString(const std::string& s, char c, bool doNotSplitAtLastChar = false);
77  static std::string strip(const std::string& s);
79  template<typename T>
80  static std::string join(const std::list<T>& l, const std::string& s);
82 };
83 
84 template<typename T>
85 std::string ManagedActionTrigger::join(const std::list<T>& l, const std::string& s)
86 {
87  if (l.empty()) {
88  return std::string();
89  } else {
90  typename std::list<T>::const_iterator pos = l.begin();
91  std::string result = (*pos).toString();
92  ++pos;
93  while (pos != l.end()) {
94  result += s;
95  result += (*pos).toString();
96  ++pos;
97  }
98  return result;
99  }
100 }
101 
102 #endif // __ManagedActionTrigger_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
ManagedActionTrigger is a base class for all triggers of managed interactions.
static std::string join(const std::list< T > &l, const std::string &s)
Joins a list of objects having a .toString() method, using a separator string s.
static std::string strip(const std::string &s)
Strips whitespaces away.
static std::list< std::string > splitString(const std::string &s, char c, bool doNotSplitAtLastChar=false)