removed the need for RTTI/runtime type checking/dynamic_cast in glui. It is unnecessary to overhaul the build systems just for this feature. Replaced by upcasting virtual methods

if ( !dynamic_cast<GLUI_Rollout*>(this) &&
becomes
if ( !this->dynamicCastGLUI_Rollout() &&
etc.
This commit is contained in:
ejcoumans
2007-10-21 03:02:11 +00:00
parent fb1a4bd37e
commit 11a0589732
8 changed files with 158 additions and 47 deletions

View File

@@ -58,7 +58,7 @@ GLUI_Tree *GLUI_TreePanel::ab(const char *name, GLUI_Tree *root)
curr_root = temp;
curr_branch = NULL; /* Currently at leaf */
if (dynamic_cast<GLUI_Tree*>(temp))
if (temp->dynamicCastGLUI_Tree())
((GLUI_Tree *)temp)->set_current(true);
//refresh();
// glui->deactivate_current_control();
@@ -86,7 +86,7 @@ void GLUI_TreePanel::fb(GLUI_Tree *branch)
if (branch != NULL) {
if ( dynamic_cast<GLUI_Tree*>(branch) )
if ( branch->dynamicCastGLUI_Tree() )
((GLUI_Tree *)branch)->set_current(false);
curr_branch = (GLUI_Tree *)branch->next();
@@ -95,13 +95,14 @@ void GLUI_TreePanel::fb(GLUI_Tree *branch)
if (curr_branch == NULL && (curr_root->collapsed_node).first_child() != NULL)
curr_branch = (GLUI_Tree *)(curr_root->collapsed_node).first_child();
if ( dynamic_cast<GLUI_Tree*>(curr_root) )
if ( curr_root->dynamicCastGLUI_Tree() )
((GLUI_Tree *)curr_root)->set_current(true);
} else {
if (curr_root != NULL) { /* up one parent */
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->set_current(false);
curr_branch = (GLUI_Tree *) curr_root->next();
@@ -110,7 +111,7 @@ void GLUI_TreePanel::fb(GLUI_Tree *branch)
if (curr_branch == NULL && (curr_root->collapsed_node).first_child() != NULL)
curr_branch = (GLUI_Tree *)(curr_root->collapsed_node).first_child();
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->set_current(true);
}
@@ -139,15 +140,15 @@ void GLUI_TreePanel::initNode(GLUI_Tree *temp)
int level = temp->get_level();
int child_number = 1;
GLUI_Tree *ptree = dynamic_cast<GLUI_Tree*>(temp->parent());
GLUI_Tree *ptree = temp->parent()->dynamicCastGLUI_Tree();
if (ptree) {
level = ptree->get_level() + 1;
GLUI_Tree *prevTree = dynamic_cast<GLUI_Tree*>(temp->prev());
GLUI_Tree *prevTree = temp->prev()->dynamicCastGLUI_Tree();
if (prevTree) {
child_number = prevTree->get_child_number() + 1;
}
} else if (dynamic_cast<GLUI_Tree*>(temp) &&
dynamic_cast<GLUI_TreePanel*>(temp->parent())) {
} else if (temp->dynamicCastGLUI_Tree() &&
temp->parent()->dynamicCastGLUI_TreePanel()) {
child_number = ++root_children;
}
temp->set_id(uniqueID()); // -1 if unset
@@ -173,7 +174,7 @@ void GLUI_TreePanel::formatNode(GLUI_Tree *temp)
glui_format_str(level_name, "%d", level);
}
if (format & GLUI_TREEPANEL_HIERARCHY_NUMERICDOT) {
if ( dynamic_cast<GLUI_Tree*>(temp->parent()) )
if ( temp->parent()->dynamicCastGLUI_Tree() )
glui_format_str(level_name, "%s.%d",
((GLUI_Tree *)(temp->parent()))->level_name.c_str(),
child_number);
@@ -206,12 +207,12 @@ void GLUI_TreePanel::formatNode(GLUI_Tree *temp)
} else {
if (format & GLUI_TREEPANEL_DISABLE_DEEPEST_BAR) {
temp->disable_bar();
if ( dynamic_cast<GLUI_Tree*>(curr_root) )
if ( curr_root->dynamicCastGLUI_Tree() )
((GLUI_Tree *)curr_root)->enable_bar();
} else
if (format & GLUI_TREEPANEL_CONNECT_CHILDREN_ONLY) {
temp->disable_bar();
if (temp->prev() && dynamic_cast<GLUI_Tree*>(temp->prev()) )
if (temp->prev() && temp->prev()->dynamicCastGLUI_Tree() )
{
((GLUI_Tree *)temp->prev())->enable_bar();
}
@@ -229,11 +230,11 @@ void GLUI_TreePanel::update_all()
GLUI_Tree *saved_branch = curr_branch;
root_children = 0;
resetToRoot(this);
if (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch))
if (curr_branch && curr_branch->dynamicCastGLUI_Tree())
formatNode((GLUI_Tree *)curr_branch);
next();
while (curr_root && curr_branch != this->first_child()) {
if (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch)) {
if (curr_branch && curr_branch->dynamicCastGLUI_Tree()) {
formatNode((GLUI_Tree *)curr_branch);
}
next();
@@ -250,11 +251,11 @@ void GLUI_TreePanel::expand_all()
GLUI_Tree *saved_branch = curr_branch;
resetToRoot(this);
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree*)curr_root)->open();
next();
while (curr_root != NULL && curr_branch != this->first_child()) {
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree*)curr_root)->open();
next();
}
@@ -273,7 +274,7 @@ void GLUI_TreePanel::collapse_all()
resetToRoot(this);
next();
while (curr_root != NULL && curr_branch != this->first_child()) {
if (dynamic_cast<GLUI_Tree*>(curr_root) &&
if (curr_root->dynamicCastGLUI_Tree() &&
curr_branch == NULL) { /* we want to close everything leaf-first */
((GLUI_Tree*)curr_root)->close();
/* Rather than simply next(), we need to manually move the
@@ -318,11 +319,11 @@ void GLUI_TreePanel::db(GLUI_Tree *root)
delete curr_root;
curr_branch = (GLUI_Tree *) temp_branch;
curr_root = (GLUI_Panel *) temp_root;
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->open();
if ((format & GLUI_TREEPANEL_DISABLE_DEEPEST_BAR) == GLUI_TREEPANEL_DISABLE_DEEPEST_BAR) {
if (dynamic_cast<GLUI_Tree*>(curr_root) && ((GLUI_Tree *)curr_root->next()) == NULL)
if (curr_root->dynamicCastGLUI_Tree() && ((GLUI_Tree *)curr_root->next()) == NULL)
((GLUI_Tree *)curr_root)->disable_bar();
}
//refresh();
@@ -337,7 +338,7 @@ void GLUI_TreePanel::descendBranch(GLUI_Panel *root) {
else
resetToRoot(curr_root);
if (curr_branch != NULL && curr_branch != ((GLUI_Panel *)this)) {
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->set_current(false);
descendBranch(curr_branch);
}
@@ -355,7 +356,7 @@ void GLUI_TreePanel::next()
if (curr_branch != NULL && curr_branch != ((GLUI_Panel *)this)) { /* Descend into branch */
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->set_current(false);
resetToRoot(curr_branch);
} else if (curr_branch == NULL) {
@@ -372,7 +373,7 @@ void GLUI_TreePanel::resetToRoot(GLUI_Panel *new_root)
if (new_root != NULL)
root = new_root;
curr_root = root;
if (dynamic_cast<GLUI_Tree*>(curr_root))
if (curr_root->dynamicCastGLUI_Tree())
((GLUI_Tree *)curr_root)->set_current(true);
curr_branch = (GLUI_Tree *)root->first_child();
@@ -381,7 +382,7 @@ void GLUI_TreePanel::resetToRoot(GLUI_Panel *new_root)
if (curr_branch == NULL && (root->collapsed_node).first_child() != NULL) {
curr_branch = (GLUI_Tree *)(root->collapsed_node).first_child();
}
while (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch)) {
while (curr_branch && curr_branch->dynamicCastGLUI_Tree()) {
curr_branch=(GLUI_Tree *)curr_branch->next();
}
}