31 #include <boost/signals2.hpp> 35 #if (QT_VERSION < 0x050300) 41 , blocked(object && object->blockSignals(true))
47 if (
object && !inhibited)
48 object->blockSignals(blocked);
53 object->blockSignals(
true);
59 object->blockSignals(blocked);
92 std::ostream& (*f_)(std::ostream&, T);
95 manipulator(std::ostream& (*f)(std::ostream&, T), T i) : i_(i), f_(f)
100 return m.f_(os, m.i_);
104 inline std::ostream&
tabsN(std::ostream& os,
int n)
106 for (
int i=0;i<n;i++)
111 inline std::ostream&
blanksN(std::ostream& os,
int n)
113 for (
int i=0;i<n;i++)
131 inline T
clamp (T num, T lower, T upper)
133 return std::max<T>(std::min<T>(upper,num),lower);
142 return (t > 0) ? T(1) : T(-1);
146 #define M_PI 3.14159265358979323846 152 return static_cast<T>((d*
M_PI)/180.0);
158 return static_cast<T>((r/
M_PI)*180.0);
162 inline T
fmod(T numerator, T denominator)
164 T modulo =
std::fmod(numerator, denominator);
165 return (modulo >= T(0)) ? modulo : modulo + denominator;
179 std::string toString(
int ms)
const;
188 template<
typename Flag=
bool>
215 template<
typename Status,
class Object>
220 { old_value = obj->testStatus(status); obj->setStatus(status, value); }
222 { obj->setStatus(status, old_value); }
235 { old_value = lock; lock = value; }
237 { lock = old_value; }
250 : flags(flags), flag(flag)
251 { oldValue = flags.test(flag); flags.set(flag,value); }
253 { flags.set(flag,oldValue); }
263 typedef boost::signals2::connection Connection;
264 typedef boost::signals2::shared_connection_block ConnectionBlock;
265 ConnectionBlock blocker;
278 static std::string getUniqueName(
const std::string&,
const std::vector<std::string>&,
int d=0);
279 static std::string addNumber(
const std::string&,
unsigned int,
int d=0);
280 static std::string getIdentifier(
const std::string&);
281 static std::wstring widen(
const std::string& str);
282 static std::string narrow(
const std::wstring& str);
283 static QString escapeEncodeString(
const QString& s);
284 static std::string escapeEncodeString(
const std::string& s);
285 static QString escapeEncodeFilename(
const QString& s);
286 static std::string escapeEncodeFilename(
const std::string& s);
293 static inline std::string
toStdString(
const QString& s) { QByteArray tmp = s.toUtf8();
return std::string(tmp.constData(), tmp.size()); }
300 static inline QString
fromStdString(
const std::string & s) {
return QString::fromUtf8(s.c_str(), (int)s.size()); }
manipulator< int > blanks(int n)
Definition: Tools.h:123
~FlagToggler()
Definition: Tools.h:207
~BitsetLocker()
Definition: Tools.h:252
QSignalBlocker(QObject *object)
Definition: Tools.h:39
FlagToggler(Flag &_flag)
Definition: Tools.h:194
T operator()()
Definition: Tools.h:79
void unblock()
Definition: Tools.h:56
manipulator< int > tabs(int n)
Definition: Tools.h:118
~ObjectStatusLocker()
Definition: Tools.h:221
BitsetLocker(T &flags, std::size_t flag, bool value=true)
Definition: Tools.h:249
friend std::ostream & operator<<(std::ostream &os, manipulator m)
Definition: Tools.h:98
void reblock()
Definition: Tools.h:50
FlagToggler(Flag &_flag, Flag check)
Definition: Tools.h:200
ObjectStatusLocker(Status s, Object *o, bool value=true)
Definition: Tools.h:219
T toRadians(T d)
Definition: Tools.h:150
std::ostream & blanksN(std::ostream &os, int n)
Definition: Tools.h:111
StateLocker(bool &flag, bool value=true)
Definition: Tools.h:234
std::ostream & tabsN(std::ostream &os, int n)
Definition: Tools.h:104
~StateLocker()
Definition: Tools.h:236
Flag & flag
Definition: Tools.h:191
ConnectionBlocker(Connection &c)
Definition: Tools.h:268
T clamp(T num, T lower, T upper)
Definition: Tools.h:131
T sgn(T t)
Definition: Tools.h:137
~QSignalBlocker()
Definition: Tools.h:45
T toDegrees(T r)
Definition: Tools.h:156
Definition: AbstractXMLReader.h:5
T fmod(T numerator, T denominator)
Definition: Tools.h:162
~ConnectionBlocker()
Definition: Tools.h:270
bool toggled
Definition: Tools.h:192
Status
Definition: CoreDocument.h:152
manipulator(std::ostream &(*f)(std::ostream &, T), T i)
Definition: Tools.h:95
iotaGen(T v)
Definition: Tools.h:80