Commit a6257ac2 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED Component manages a list of viewer's name

...not a list of viewer's pointer.
parent f98376eb
......@@ -38,12 +38,6 @@
#include <utility>
namespace camitk {
// --------------------------------------------------------
// -------------------- static members --------------------
// --------------------------------------------------------
QSet<Viewer*> Component::allViewers;
// -------------------- constructor --------------------
Component::Component(QString file, QString n, Representation s) : myParentNode(nullptr), myFileName(std::move(file)), myService(s), myName(std::move(n)) {
init();
......@@ -266,16 +260,16 @@ Component* Component::getTopLevelComponent() {
// -------------------- setVisibility --------------------
void Component::setVisibility(QString viewerName, bool b) {
// get the viewer pointer
// first check if viewer is registered
Viewer* v = Application::getViewer(viewerName);
// only insert real non-null viewers
// only insert registered viewers
if (v != nullptr) {
QMap<Viewer*, bool>::iterator it = myViewers.find(v);
auto it = myViewers.find(viewerName);
if (it == myViewers.end()) {
// insert the new viewer with the corresponding boolean
myViewers.insert(v, b);
myViewers.insert(viewerName, b);
}
else {
it.value() = b;
......@@ -287,13 +281,13 @@ void Component::setVisibility(QString viewerName, bool b) {
void Component::setVisibility(Viewer* v, bool b) {
CAMITK_WARNING(tr("setVisibility(Viewer*,bool) method is now deprecated and will be removed from CamiTK API, please use setVisibility(QString,bool) instead"))
// only insert real non-null viewers
if (v != nullptr) {
QMap<Viewer*, bool>::iterator it = myViewers.find(v);
// only insert non-null and registered viewers
if (v != nullptr && Application::getViewer(v->getName()) != nullptr) {
auto it = myViewers.find(v->getName());
if (it == myViewers.end()) {
// insert the new viewer with the corresponding boolean
myViewers.insert(v, b);
myViewers.insert(v->getName(), b);
}
else {
it.value() = b;
......@@ -303,28 +297,22 @@ void Component::setVisibility(Viewer* v, bool b) {
// -------------------- getVisibility --------------------
bool Component::getVisibility(QString viewerName) const {
// get the viewer pointer
Viewer* v = Application::getViewer(viewerName);
auto it = myViewers.constFind(viewerName);
// only insert real non-null viewers
if (v != nullptr) {
auto it = myViewers.constFind(v);
if (it == myViewers.end()) {
return false;
}
else {
return it.value();
}
if (it == myViewers.end()) {
return false;
}
else {
return it.value();
}
}
bool Component::getVisibility(Viewer* v) const {
CAMITK_WARNING(tr("getVisibility(Viewer*) method is now deprecated and will be removed from CamiTK API, please use getVisibility(QString) instead"))
auto it = myViewers.constFind(v);
auto it = myViewers.constFind(v->getName());
if (it == myViewers.end()) {
if (v == nullptr || it == myViewers.end()) {
return false;
}
else {
......@@ -334,18 +322,18 @@ bool Component::getVisibility(Viewer* v) const {
// -------------------- refresh --------------------
void Component::refresh() const {
for (QMap<Viewer*, bool>::const_iterator it = myViewers.begin(); it != myViewers.end(); it++) {
for (auto it = myViewers.begin(); it != myViewers.end(); it++) {
if (it.value()) {
it.key()->refresh();
Application::getViewer(it.key())->refresh();
}
}
}
// -------------------- refreshInterfaceNode --------------------
void Component::refreshInterfaceNode() {
for (QMap<Viewer*, bool>::const_iterator it = myViewers.begin(); it != myViewers.end(); it++) {
for (auto it = myViewers.begin(); it != myViewers.end(); it++) {
if (it.value()) {
it.key()->refreshInterfaceNode(this);
Application::getViewer(it.key())->refreshInterfaceNode(this);
}
}
}
......@@ -808,3 +796,4 @@ bool Component::getFrameVisibility(Viewer* viewer) const {
}
......@@ -381,7 +381,7 @@ public:
virtual bool getVisibility(Viewer*) const;
///@endcond
/// set the visibility inside the viewer of the given name
/// set the visibility inside the viewer of the given name (the viewer needs to be a registered viewer)
virtual void setVisibility(QString, bool);
/// get the visibility inside the viewer of the given name
......@@ -846,8 +846,8 @@ private:
*/
virtual void initRepresentation() = 0;
/// Where is this Component currently viewed
QMap<Viewer*, bool> myViewers;
/// Name of the viewers where this Component would like to be viewed in
QMap<QString, bool> myViewers;
/// the action menu for this component
QMenu* actionsMenu;
......@@ -859,14 +859,6 @@ private:
QMap<QString, Property*> propertyMap;
///@}
/** @name Static members
* All the static member (manage the application-wide list of Component + the application-wide current selection + viewers)
*/
///@{
/// set of used viewers
static QSet<Viewer*> allViewers;
///@}
};
......
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