Commit 7e199737 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW Deprecated message warning now generated at compile time

parent 3285a4b4
......@@ -78,6 +78,22 @@ extern double rint(double x);
#include <QMap>
#include <QString>
// -----------------------------------------------------------------------
// warning when using deprecated methods
//
// prefix each deprecated method by the CAMITK_API_DEPRECATED keyword
// CAMITK_API_DEPRECATED("Please use myNewMethod(..) instead") mymethod(...)
//
// see https://stackoverflow.com/a/295229
#if defined(__GNUC__) || defined(__clang__)
#define CAMITK_API_DEPRECATED(X) __attribute__((deprecated(X)))
#elif defined(_MSC_VER)
#define CAMITK_API_DEPRECATED(X) __declspec(deprecated(X))
#else
#pragma message("WARNING: You need to implement CAMITK_API_DEPRECATED(X) for this compiler")
#define CAMITK_API_DEPRECATED(X)
#endif
// -----------------------------------------------------------------------
// -- Definition of some useful CamiTK container types
namespace camitk {
......
......@@ -131,7 +131,7 @@ public:
* This method is now called showDockViewer.
*/
/// set the visibility for the given viewer (if it is in a dock)
virtual void showViewer(Viewer*, bool);
CAMITK_API_DEPRECATED("This method is now called showDockViewer(..)") virtual void showViewer(Viewer*, bool);
///@endcond
/// set the visibility for the given docked viewer and its toolbar
......@@ -228,7 +228,7 @@ protected:
* @param viewer The viewer to remove.
* @return True if removing succeeded, false otherwise.
*/
bool removeViewer(Viewer* viewer);
CAMITK_API_DEPRECATED("Removing viewers can be harmful. Central viewer is now simply hidden, therefore there is no need to remove it.") bool removeViewer(Viewer* viewer);
///@endcond
/**
......
......@@ -773,6 +773,17 @@ vtkSmartPointer<vtkAxesActor> Component::getFrameAxisActor() {
}
}
// -------------------- setFrameVisibility --------------------
void Component::setFrameVisibility(Viewer *v, bool visibility) {
if (myFrame == nullptr) {
CAMITK_ERROR(tr("myFrame is not instantiated."))
}
else {
CAMITK_WARNING(tr("setFrameVisibility(Viewer*,bool) method is now deprecated and will be removed from CamiTK API, please use setFrameVisibility(QString,bool) instead"))
myFrame->setFrameVisibility(v->getName(), visibility);
}
}
// -------------------- getFrameVisibility --------------------
bool Component::getFrameVisibility(QString viewerName) const {
if (myFrame == nullptr) {
......@@ -790,7 +801,8 @@ bool Component::getFrameVisibility(Viewer* viewer) const {
return false;
}
else {
return myFrame->getFrameVisibility(viewer);
CAMITK_WARNING(tr("getFrameVisibility(Viewer*) method is now deprecated and will be removed from CamiTK API, please use getFrameVisibility(QString) instead"))
return myFrame->getFrameVisibility(viewer->getName());
}
}
......
......@@ -368,17 +368,17 @@ public:
///@cond
/**
* TODO CAMITK_DEPRECATED. This section list all the methods marked as deprecated. They are to be removed in CamiTK 5.0
* TODO CAMITK_API_DEPRECATED. This section list all the methods marked as deprecated. They are to be removed in CamiTK 5.0
* @deprecated
*
* DEPRECATED (CamiTK 5.0) -> to be removed
* Use the setVisibility(QString, bool) / getVisibility(QString, bool) methods
* Use setVisibility(QString, bool) / getVisibility(QString, bool) methods
*/
/// set the visibility for a viewer
virtual void setVisibility(Viewer*, bool);
CAMITK_API_DEPRECATED("Please use setVisibility(QString viewerName, bool) instead") virtual void setVisibility(Viewer*, bool);
/// get the visibility of a viewer
virtual bool getVisibility(Viewer*) const;
CAMITK_API_DEPRECATED("Please use getVisibility(QString viewerName, bool) instead") virtual bool getVisibility(Viewer*) const;
///@endcond
/// set the visibility inside the viewer of the given name (the viewer needs to be a registered viewer)
......@@ -780,11 +780,11 @@ public:
* @deprecated
*
* DEPRECATED (CamiTK 5.0) -> to be removed
* Use the setVisibility(QString, bool) / getVisibility(QString, bool) methods
* Use the setFrameVisibility(QString, bool) / getFrameVisibility(QString, bool) methods
*/
delegate2(myFrame, setFrameVisibility, Viewer*, bool)
bool getFrameVisibility(Viewer* viewer) const override;
/*CAMITK_API_DEPRECATED("Please use Component::setFrameVisibility(QString viewerName, bool) instead") */virtual void setFrameVisibility(Viewer*,bool) override;
/*CAMITK_API_DEPRECATED("Please use Component::getFrameVisibility(QString viewerName, bool) instead") */virtual bool getFrameVisibility(Viewer*) const override;
///@endcond
delegate2(myFrame, setFrameVisibility, QString, bool)
......
......@@ -186,13 +186,13 @@ public:
*/
/**
* Set the Component Frame visible for a given viewer
*/
void setFrameVisibility(Viewer*, bool ) override;
*/
CAMITK_API_DEPRECATED("Please use Frame::setFrameVisibility(QString viewerName, bool) instead") void setFrameVisibility(Viewer*, bool ) override;
/**
* Get the Component Frame visibility for a given viewer
*/
bool getFrameVisibility(Viewer*) const override;
CAMITK_API_DEPRECATED("Please use Frame::getFrameVisibility(QString viewerName, bool) instead") bool getFrameVisibility(Viewer*) const override;
///@endcond
/**
......
......@@ -200,12 +200,12 @@ public:
/**
* Set the Component Frame visible for a given viewer
*/
virtual void setFrameVisibility(Viewer*, bool ) = 0;
CAMITK_API_DEPRECATED("Please use InterfaceFrame::setFrameVisibility(QString viewerName, bool) instead") virtual void setFrameVisibility(Viewer*, bool ) = 0;
/**
* Get the Component Frame visibility for a given viewer
*/
virtual bool getFrameVisibility(Viewer*) const = 0;
CAMITK_API_DEPRECATED("Please use InterfaceFrame::getFrameVisibility(QString viewerName, bool) instead") virtual bool getFrameVisibility(Viewer*) const = 0;
///@endcond
/**
......
......@@ -109,8 +109,9 @@ public:
* Use the setVisibility(QString, bool) method
*/
/// set the visibility for a viewer (override required to manage the specific case of the 3D viewer)
virtual void setVisibility(Viewer*, bool) override;
CAMITK_API_DEPRECATED("Please use setVisibility(QString viewerName, bool) instead") virtual void setVisibility(Viewer*, bool) override;
///@endcond
/// set the visibility inside the viewer of the given name (override required to manage the specific case of the 3D viewer)
virtual void setVisibility(QString, bool) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment