CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Classes | Macros | Functions
Collaboration diagram for Core:

Classes

class  ctkAbstractFactory< BaseClassType >
 ctkAbstractFactory is the base class of all the factory where items need to be registered before being instantiated. More...
 
class  ctkAbstractFactoryFileBasedItem< BaseClassType >
 
class  ctkAbstractFactoryItem< BaseClassType >
 
class  ctkAbstractFileBasedFactory< BaseClassType >
 
class  ctkAbstractLibraryFactory< BaseClassType >
 
class  ctkAbstractObjectFactory< BaseClassType >
 
class  ctkAbstractPluginFactory< BaseClassType >
 
class  ctkAbstractQObjectFactory< BaseClassType >
 
class  ctkBackTrace
 Obtains a back trace from the current execution context. More...
 
class  ctkBinaryFileDescriptor
 
class  ctkBooleanMapper
 
class  ctkCallback
 
class  ctkCommandLineParser
 
class  ctkCorePythonQtDecorators
 
class  ctkDependencyGraph
 Class to implement a dependency graph, converted to STL instead of Qt. More...
 
class  ctkErrorLogAbstractMessageHandler
 
struct  ctkErrorLogContext
 
class  ctkErrorLogFDMessageHandler
 
class  ctkErrorLogLevel
 
class  ctkErrorLogQtMessageHandler
 
class  ctkErrorLogStreamMessageHandler
 
class  ctkErrorLogTerminalOutput
 
class  ctkException
 The base class for all exceptions defined in CTK. More...
 
class  ctkFactoryLibraryItem< BaseClassType >
 
class  ctkFactoryObjectItem< BaseClassType, ClassType >
 
class  ctkFactoryPluginItem< BaseClassType >
 
class  ctkFileLogger
 
class  ctkHighPrecisionTimer
 A fast and high precision timer. More...
 
class  ctkLinearValueProxy
 Implementation of an affine value proxy. The ctkLinearValueProxy takes a coefficient and an offset, effectively implementing a value proxy such as: valueProxy = coefficient * value + offset Note: If the coefficient is null then the property value given by value = (valueProxy - offset) / coefficient can give bad results (+ or - infinity depending on the sign of valueProxy - offset). More...
 
class  ctkLogger
 
class  ctkModelTester
 
class  ctkScopedCurrentDir
 Use this class to change the current application directory in a given scope and automatically restore it. More...
 
class  ctkValueProxy
 Base class for value proxies. Value proxy allows to decouple the displayed value from the values accessed within the program. For example, one may want to display Fahrenheit while still working with Celsius. More...
 
class  ctkWorkflow
 ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctkWorkflowStep. More...
 
class  ctkWorkflowInterstepTransition
 
struct  ctkWorkflowInterstepTransitionEvent
 
class  ctkWorkflowIntrastepTransition
 
struct  ctkWorkflowIntrastepTransitionEvent
 Custom transitions for use with ctkWorkflow. More...
 
class  ctkWorkflowStep
 ctkWorkflowStep is the basis for a workflow step. More...
 

Macros

#define CTK_DECLARE_EXCEPTION(API, CLS, BASE)
 Quickly declare a ctkException sub-class. More...
 
#define CTK_IMPLEMENT_EXCEPTION(CLS, BASE, NAME)
 Quickly implement a ctkException sub-class. More...
 

Functions

double CTK_CORE_EXPORT ctk::closestPowerOfTen (double value)
 
bool CTK_CORE_EXPORT ctk::copyDirRecursively (const QString &srcPath, const QString &dstPath)
 
QString CTK_CORE_EXPORT ctk::extensionToRegExp (const QString &extension)
 
qint64 CTK_CORE_EXPORT ctk::msecsTo (const QDateTime &t1, const QDateTime &t2)
 Compute the milli seconds from one QDateTime to an other. More...
 
QStringList CTK_CORE_EXPORT ctk::nameFiltersToExtensions (const QStringList &nameFilters)
 
QRegExp CTK_CORE_EXPORT ctk::nameFiltersToRegExp (const QStringList &nameFilters)
 
QStringList CTK_CORE_EXPORT ctk::nameFilterToExtensions (const QString &nameFilter)
 
CTK_CORE_EXPORT QDebug operator<< (QDebug dbg, const ctkException &exc)
 
CTK_CORE_EXPORT QDebug operator<< (QDebug dbg, const ctkException::TraceManipulator &trace)
 
int CTK_CORE_EXPORT ctk::orderOfMagnitude (double value)
 
void CTK_CORE_EXPORT ctk::qListToSTLVector (const QStringList &list, std::vector< char * > &vector)
 
void CTK_CORE_EXPORT ctk::qListToSTLVector (const QStringList &list, std::vector< std::string > &vector)
 
QString CTK_CORE_EXPORT ctk::qtHandleToString (Qt::HANDLE handle)
 
bool CTK_CORE_EXPORT ctk::removeDirRecursively (const QString &dirName)
 
int CTK_CORE_EXPORT ctk::significantDecimals (double value, int defaultDecimals=-1)
 
void CTK_CORE_EXPORT ctk::stlVectorToQList (const std::vector< std::string > &vector, QStringList &list)
 
#define CTK_CONSTRUCTOR_NO_ARG_CPP(PUB)
 
#define CTK_CONSTRUCTOR_1_ARG_CPP(PUB, _ARG1)
 
#define CTK_SET_CPP(PUB, _TYPE, _NAME, _VARNAME)
 
#define CTK_GET_CPP(PUB, _TYPE, _NAME, _VARNAME)
 
#define CTK_SINGLETON_DECLARE(NAME)
 Inspired from VTK/Utilities/kwsys/SystemTools class. More...
 
#define CTK_SINGLETON_DECLARE_INITIALIZER(EXPORT_DIRECTIVE, NAME)
 Should be added at the bottom of the header file, after the class declaration. More...
 
#define CTK_SINGLETON_DEFINE_INITIALIZER(NAME)
 Implementation of NAME##Initialize class. More...
 
#define CTK_SINGLETON_DEFINE(NAME)
 This should be added at the end of the CPP file. More...
 

Detailed Description

The CTK Core library provides generally useful utility classes.

Macro Definition Documentation

◆ CTK_CONSTRUCTOR_1_ARG_CPP

#define CTK_CONSTRUCTOR_1_ARG_CPP (   PUB,
  _ARG1 
)
Value:
PUB::PUB(_ARG1 _parent) \
: Superclass( _parent ) \
, d_ptr(new PUB##Private) \
{ \
}

Define a public class constructor with one argument

Also make sure the Pimpl is initalized

See also
CTK Pimpl Macros

Definition at line 158 of file ctkPimpl.h.

◆ CTK_CONSTRUCTOR_NO_ARG_CPP

#define CTK_CONSTRUCTOR_NO_ARG_CPP (   PUB)
Value:
PUB::PUB(): d_ptr(new PUB##Private) \
{ \
}

Define a public class constructor with no argument

Also make sure the Pimpl is initalized

See also
CTK Pimpl Macros

Definition at line 147 of file ctkPimpl.h.

◆ CTK_DECLARE_EXCEPTION

#define CTK_DECLARE_EXCEPTION (   API,
  CLS,
  BASE 
)
Value:
class API CLS : public BASE \
{ \
public: \
explicit CLS(const QString& msg); \
CLS(const QString& msg, const ctkException& exc); \
CLS(const CLS& exc); \
~CLS() throw(); \
CLS& operator = (const CLS& exc); \
const char* name() const throw(); \
CLS* clone() const; \
void rethrow() const ; \
};
The base class for all exceptions defined in CTK.
Definition: ctkException.h:46

Quickly declare a ctkException sub-class.

Parameters
APIThe export macro.
CLSThe class name for the ctkException sub-class.
BASEThe class name of the actual super class.

Definition at line 196 of file ctkException.h.

◆ CTK_GET_CPP

#define CTK_GET_CPP (   PUB,
  _TYPE,
  _NAME,
  _VARNAME 
)
Value:
_TYPE PUB::_NAME()const \
{ \
Q_D(const PUB); \
return d->_VARNAME; \
}

Define the setter in the public class.

This should be put in the .cxx file of the public class. The parameter are the name of the public class (PUB), the type of the argument to return (_TYPE), the name of the setter(_NAME) and the name of the variable in the Private class(_VARNAME).

See also
CTK Pimpl Macros

Definition at line 188 of file ctkPimpl.h.

◆ CTK_IMPLEMENT_EXCEPTION

#define CTK_IMPLEMENT_EXCEPTION (   CLS,
  BASE,
  NAME 
)
Value:
CLS::CLS(const QString& msg) : BASE(msg) \
{ } \
CLS::CLS(const QString& msg, const ctkException& exc) : BASE(msg, exc) \
{ } \
CLS::CLS(const CLS& exc) : BASE(exc) \
{ } \
CLS::~CLS() throw() \
{ } \
CLS& CLS::operator = (const CLS& exc) \
{ \
BASE::operator = (exc); \
return *this; \
} \
const char* CLS::name() const throw() \
{ \
return NAME; \
} \
CLS* CLS::clone() const \
{ \
return new CLS(*this); \
} \
void CLS::rethrow() const \
{ \
throw *this; \
}

Quickly implement a ctkException sub-class.

Parameters
CLSThe class name for the ctkException sub-class.
BASEThe class name of the actual super class.
NAMEA human-readable name for this exception class.

Definition at line 219 of file ctkException.h.

◆ CTK_SET_CPP

#define CTK_SET_CPP (   PUB,
  _TYPE,
  _NAME,
  _VARNAME 
)
Value:
void PUB::_NAME(_TYPE var) \
{ \
Q_D(PUB); \
d->_VARNAME = var; \
}

Define the setter in the public class.

This should be put in the .cxx file of the public class. The parameter are the name of the public class (PUB), the type of the argument to return (_TYPE), the name of the getter(_NAME) and the name of the variable in the Private class(_VARNAME).

See also
CTK Pimpl Macros

Definition at line 173 of file ctkPimpl.h.

◆ CTK_SINGLETON_DECLARE

#define CTK_SINGLETON_DECLARE (   NAME)
Value:
static NAME* Instance; \
static void classInitialize(); \
static void classFinalize(); \
friend class NAME##Initialize; \
typedef NAME Self;

Inspired from VTK/Utilities/kwsys/SystemTools class.

Singleton definition and declaration helpers See http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12 and http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Nifty_Counter Should be included as a class protected member

Definition at line 38 of file ctkSingleton.h.

◆ CTK_SINGLETON_DECLARE_INITIALIZER

#define CTK_SINGLETON_DECLARE_INITIALIZER (   EXPORT_DIRECTIVE,
  NAME 
)
Value:
class EXPORT_DIRECTIVE NAME##Initialize \
{ \
public: \
typedef NAME##Initialize Self; \
\
NAME##Initialize(); \
~NAME##Initialize(); \
private: \
static unsigned int Count; \
}; \
\
static NAME##Initialize NAME##Initializer;

Should be added at the bottom of the header file, after the class declaration.

Help macro allowing to declare the utility class to make sure NAME is initialized before it is used. The instance (NAME##Initializer) will show up in any translation unit that uses NAME. It will make sure NAME is initialized before it is used.

Definition at line 54 of file ctkSingleton.h.

◆ CTK_SINGLETON_DEFINE

#define CTK_SINGLETON_DEFINE (   NAME)
Value:
void NAME::classInitialize() \
{ \
Self::Instance = new NAME; \
} \
\
void NAME::classFinalize() \
{ \
delete Self::Instance; \
} \
#define CTK_SINGLETON_DEFINE_INITIALIZER(NAME)
Implementation of NAME##Initialize class.
Definition: ctkSingleton.h:76

This should be added at the end of the CPP file.

Definition at line 97 of file ctkSingleton.h.

◆ CTK_SINGLETON_DEFINE_INITIALIZER

#define CTK_SINGLETON_DEFINE_INITIALIZER (   NAME)
Value:
NAME##Initialize::NAME##Initialize() \
{ \
if(++Self::Count == 1) \
{ NAME::classInitialize(); } \
} \
\
NAME##Initialize::~NAME##Initialize() \
{ \
if(--Self::Count == 0) \
{ NAME::classFinalize(); } \
} \
\
unsigned int NAME##Initialize::Count; \
NAME* NAME::Instance;

Implementation of NAME##Initialize class.

Note: NAME##Initialize::Count and NAME::Instance Must NOT be initialized. Default initialization to zero is necessary.

Definition at line 76 of file ctkSingleton.h.

Function Documentation

◆ closestPowerOfTen()

double CTK_CORE_EXPORT ctk::closestPowerOfTen ( double  value)

Return the order of magnitude of a number. e.g.: closestPowerOfTen(11) returns 10 closestPowerOfTen(-40) returns -10 closestPowerOfTen(99) returns 100 closestPowerOfTen(0.012) returns 0.010 closestPowerOfTen(0.) returns 0 See more cases in the test ctkUtilsClosestPowerOfTenTest1

◆ copyDirRecursively()

bool CTK_CORE_EXPORT ctk::copyDirRecursively ( const QString &  srcPath,
const QString &  dstPath 
)

Copy a directory recursively

Parameters
srcPathThe directory to be copied
dstPathThe directory where the file should be copied
Returns
true on success, false otherwise.
See also
QFile::copy

◆ extensionToRegExp()

QString CTK_CORE_EXPORT ctk::extensionToRegExp ( const QString &  extension)

Convert a wildcar extension filter ("*.jpg") into a regular expression string "*.jpg" -> ".*\\.jpg?$"

◆ msecsTo()

qint64 CTK_CORE_EXPORT ctk::msecsTo ( const QDateTime &  t1,
const QDateTime &  t2 
)

Compute the milli seconds from one QDateTime to an other.

This function can be used to correctly compute the amount of milli seconds from t1 to t2. The QDateTime objects are converted to Qt::UTC to take daylight saving time into account. This is for back-wards compatibility with Qt 4.6. Since Qt 4.7 there exists a QDateTime::msecsTo() method which should be used instead, after bumping the minimum required Qt version for CTK.

◆ nameFiltersToExtensions()

QStringList CTK_CORE_EXPORT ctk::nameFiltersToExtensions ( const QStringList &  nameFilters)

Convert a nameFilter to a list of file extensions: "Images (*.png *.jpg *.tiff)", "Text (*.txt)" -> "*.png", "*.jpg", "*.tiff", "*.txt"

◆ nameFiltersToRegExp()

QRegExp CTK_CORE_EXPORT ctk::nameFiltersToRegExp ( const QStringList &  nameFilters)

Convert a list of wildcar extension filters ("*.jpg") into a regular expression string "*.jpg", "*.txt" -> "(.*\\.jpg?$|.*\\.txt?$)"

◆ nameFilterToExtensions()

QStringList CTK_CORE_EXPORT ctk::nameFilterToExtensions ( const QString &  nameFilter)

Convert a nameFilter to a list of file extensions: "Images (*.png *.jpg *.tiff)" -> "*.png", "*.jpg", "*.tiff" Note: the nameFilter can be a simple wildcard "*.jpg" in that case, it will simply return it.

See also
nameFiltersToExtensions

◆ operator<<() [1/2]

CTK_CORE_EXPORT QDebug operator<< ( QDebug  dbg,
const ctkException exc 
)

◆ operator<<() [2/2]

CTK_CORE_EXPORT QDebug operator<< ( QDebug  dbg,
const ctkException::TraceManipulator trace 
)

◆ orderOfMagnitude()

int CTK_CORE_EXPORT ctk::orderOfMagnitude ( double  value)

Return the order of magnitude of a number or numeric_limits<int>::min() if the order of magnitude can't be computed (e.g. 0, inf, Nan, denorm)... e.g.: orderOfMagnitude(1) returns 0 orderOfMagnitude(10) returns 1 orderOfMagnitude(99) returns 1 orderOfMagnitude(101) returns 2 orderOfMagnitude(0.1) returns -1 orderOfMagnitude(0.15) returns -1 orderOfMagnitude(0.) returns NaN See more cases in the test ctkUtilsOrderOfMagnitudeTest1

◆ qListToSTLVector() [1/2]

void CTK_CORE_EXPORT ctk::qListToSTLVector ( const QStringList &  list,
std::vector< char * > &  vector 
)

Convert a QStringList to Vector of char* Caller will be responsible to delete the content of the vector

◆ qListToSTLVector() [2/2]

void CTK_CORE_EXPORT ctk::qListToSTLVector ( const QStringList &  list,
std::vector< std::string > &  vector 
)

Convert a QStringList to a Vector of string

◆ qtHandleToString()

QString CTK_CORE_EXPORT ctk::qtHandleToString ( Qt::HANDLE  handle)

Convert Qt::HANDLE to string

See also
Qt::HANDLE

◆ removeDirRecursively()

bool CTK_CORE_EXPORT ctk::removeDirRecursively ( const QString &  dirName)

Remove a directory recursively.

Parameters
dirNameThe directory to remove
Returns
true on success, false otherwise.
See also
QDir::rmdir

◆ significantDecimals()

int CTK_CORE_EXPORT ctk::significantDecimals ( double  value,
int  defaultDecimals = -1 
)

Return a "smart" number of decimals needed to display (in a gui) a floating number. 16 is the max that can be returned, -1 for NaN numbers. When the number of decimals is not obvious, it defaults to defaultDecimals if it is different from -1, 16 otherwise. e.g. significantDecimals(120.01) returns 2 significantDecimals(123456.1333333) returns 3 significantDecimals(123456.26999999999999996) returns 2 significantDecimals(123456.12345678901234567, 3) return 3 See more cases in the test ctkUtilsSignificantDecimalsTest1

◆ stlVectorToQList()

void CTK_CORE_EXPORT ctk::stlVectorToQList ( const std::vector< std::string > &  vector,
QStringList &  list 
)

Convert a Vector of string to QStringList