vvToolBase(vvMainWindowBase * m);
static void Initialize(); // can't be virtual, must be overwritten
- static void SetToolName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolName = n; }
- static void SetToolMenuName(QString n) { vvToolCreator<ToolType>::mSingleton->mToolMenuName = n; }
- static void SetToolIconFilename(QString n) { vvToolCreator<ToolType>::mSingleton->mToolIconFilename = n; }
- static void SetToolTip(QString n) { vvToolCreator<ToolType>::mSingleton->mToolTip = n; }
- static void SetToolExperimental(bool exp) { vvToolCreator<ToolType>::mSingleton->mExperimental = exp; }
+ static void SetToolName(QString n) { vvToolCreator<ToolType>::GetInstance()->mToolName = n; }
+ static void SetToolMenuName(QString n) { vvToolCreator<ToolType>::GetInstance()->mToolMenuName = n; }
+ static void SetToolIconFilename(QString n) { vvToolCreator<ToolType>::GetInstance()->mToolIconFilename = n; }
+ static void SetToolTip(QString n) { vvToolCreator<ToolType>::GetInstance()->mToolTip = n; }
+ static void SetToolExperimental(bool exp) { vvToolCreator<ToolType>::GetInstance()->mExperimental = exp; }
void AddImage(vvImage::Pointer image,std::string filename) {
CREATOR(ToolType)->GetMainWindow()->AddImage(image,filename);
template<class ToolType>
class vvToolCreator: public vvToolCreatorBase {
public:
- vvToolCreator(QString name):vvToolCreatorBase(name) {;}
+ static vvToolCreator<ToolType> *&GetInstance();
virtual void InsertToolInMenu(vvMainWindowBase * m);
virtual void MenuSpecificToolSlot() { CreateTool<ToolType>(); }
+private:
+ vvToolCreator():vvToolCreatorBase(mToolCreatorName) {;}
static vvToolCreator<ToolType> * mSingleton;
+ static const QString mToolCreatorName;
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::mSingleton
+#define CREATOR(CLASSNAME) vvToolCreator<CLASSNAME>::GetInstance()
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-#define ADD_TOOL(NAME) \
- template<> \
- vvToolCreator<NAME> * vvToolCreator<NAME>::mSingleton = \
- new vvToolCreator<NAME>(#NAME);
+// Initiliazes the static parameters and creates a dummy pointer (required for windows)
+#define ADD_TOOL(NAME) \
+ template<> const QString vvToolCreator<NAME>::mToolCreatorName = #NAME; \
+ template<> vvToolCreator<NAME> *vvToolCreator<NAME>::mSingleton = NULL; \
+ const vvToolCreator<NAME> *dummy##NAME = vvToolCreator<NAME>::GetInstance();
//------------------------------------------------------------------------------
#include "vvToolCreator.txx"
vvToolCreatorBase::InsertToolInMenu(mMainWindow);
}
//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+template<class ToolType>
+vvToolCreator<ToolType>* & vvToolCreator<ToolType>::GetInstance() {
+ if(!mSingleton)
+ mSingleton = new vvToolCreator<ToolType>;
+ return mSingleton;
+}
+//------------------------------------------------------------------------------