#include <Iguana/Studio/interface/IgTwigOps.h>
Public Slots | |
void | actionEnable (int id) |
void | actionHide (int n) |
void | actionShow (int n) |
void | actionVisible (int id) |
Public Member Functions | |
void | menuAction (IgQtObjectMenuMessage message) |
void | menuUpdate (void) |
Static Public Attributes | |
static const int | HS_ALL_CHILDREN = -2 |
static const int | HS_ALL_LEAVES = -1 |
static const int | HS_N = -3 |
static const int | MENU_ENABLE = 1 |
static const int | MENU_ENABLE_UP = 2 |
static const int | MENU_HIDE_1 = 5102 |
static const int | MENU_HIDE_2 = 5103 |
static const int | MENU_HIDE_3 = 5104 |
static const int | MENU_HIDE_CHILDREN = 5101 |
static const int | MENU_HIDE_LEAVES = 5100 |
static const int | MENU_HIDE_LEVEL = 51 |
static const int | MENU_HIDE_N = 5105 |
static const int | MENU_HIDE_SEP = 50 |
static const int | MENU_SHOW_1 = 1302 |
static const int | MENU_SHOW_2 = 1303 |
static const int | MENU_SHOW_3 = 1304 |
static const int | MENU_SHOW_CHILDREN = 1301 |
static const int | MENU_SHOW_LEAVES = 1300 |
static const int | MENU_SHOW_LEVEL = 13 |
static const int | MENU_SHOW_N = 1305 |
static const int | MENU_SHOW_ONLY = 12 |
static const int | MENU_SHOW_SEP = 10 |
static const int | MENU_SHOW_THIS = 11 |
Private Member Functions | |
void | doHide (int n, IgTwig *twig) |
void | doShow (int n, IgTwig *twig) |
Private Attributes | |
IgQtObjectMenu * | m_menu |
IgTwig * | m_twig |
(FIXME: This belogs elsewhere, e.g. in IgQtTwigBrowser!).
Definition at line 23 of file IgTwigOps.h.
Definition at line 90 of file IgTwigOps.cc.
References ASSERT, IgTwig::FLAGS_MASK, IgRepSet::invalidate(), m_twig, MENU_ENABLE, MENU_ENABLE_UP, IgTwig::parent(), IgTwig::selfTraverse(), IgTwig::STRUCTURE_MASK, and t.
Referenced by actionShow(), actionVisible(), and menuAction().
00091 { 00092 ASSERT (m_twig); 00093 QApplication::setOverrideCursor (Qt::waitCursor); 00094 switch (id) 00095 { 00096 case MENU_ENABLE_UP: 00097 for (IgTwig *t = m_twig->parent (); t; t = t->parent ()) 00098 { 00099 if (! t->selfTraverse ()) 00100 t->selfTraverse (true); 00101 if (! t->parent ()) 00102 IgRepSet::invalidate (t, IgTwig::FLAGS_MASK|IgTwig::STRUCTURE_MASK); 00103 } 00104 break; 00105 00106 case MENU_ENABLE: 00107 m_twig->selfTraverse (! m_twig->selfTraverse ()); 00108 IgRepSet::invalidate (m_twig, IgTwig::FLAGS_MASK | IgTwig::STRUCTURE_MASK); 00109 break; 00110 00111 default: 00112 ASSERT (false); 00113 } 00114 QApplication::restoreOverrideCursor (); 00115 }
Definition at line 167 of file IgTwigOps.cc.
References doHide(), IgTwig::FLAGS_MASK, HS_N, IgRepSet::invalidate(), m_twig, and IgTwig::STRUCTURE_MASK.
Referenced by menuAction().
00168 { 00169 if (n == HS_N) 00170 { 00171 bool ok = false; 00172 n = QInputDialog::getInteger ("IGUANA", 00173 "Please enter the number of levels", 00174 4, 1, INT_MAX, 1, &ok); 00175 if (! ok) 00176 return; 00177 } 00178 00179 QApplication::setOverrideCursor (Qt::waitCursor); 00180 doHide (n, m_twig); 00181 IgRepSet::invalidate (m_twig, IgTwig::FLAGS_MASK | IgTwig::STRUCTURE_MASK); 00182 QApplication::restoreOverrideCursor (); 00183 }
Definition at line 148 of file IgTwigOps.cc.
References actionEnable(), doShow(), HS_N, m_twig, and MENU_ENABLE_UP.
Referenced by menuAction().
00149 { 00150 if (n == HS_N) 00151 { 00152 bool ok = false; 00153 n = QInputDialog::getInteger ("IGUANA", 00154 "Please enter the number of levels", 00155 4, 1, INT_MAX, 1, &ok); 00156 if (! ok) 00157 return; 00158 } 00159 00160 QApplication::setOverrideCursor (Qt::waitCursor); 00161 doShow (n, m_twig); 00162 actionEnable (MENU_ENABLE_UP); 00163 QApplication::restoreOverrideCursor (); 00164 }
Definition at line 118 of file IgTwigOps.cc.
References actionEnable(), ASSERT, doHide(), IgTwig::FLAGS_MASK, HS_ALL_CHILDREN, IgRepSet::invalidate(), m_twig, MENU_ENABLE_UP, MENU_SHOW_ONLY, MENU_SHOW_THIS, IgTwig::root(), IgTwig::selfVisible(), IgTwig::STRUCTURE_MASK, and t.
Referenced by menuAction().
00119 { 00120 ASSERT (m_twig); 00121 IgTwig *t; 00122 00123 QApplication::setOverrideCursor (Qt::waitCursor); 00124 switch (id) 00125 { 00126 case MENU_SHOW_THIS: 00127 m_twig->selfVisible (true); 00128 actionEnable (MENU_ENABLE_UP); 00129 // Action already forced update notification. 00130 break; 00131 00132 case MENU_SHOW_ONLY: 00133 // Hide the whole tree then make `m_twig' visible. 00134 t = m_twig->root (); 00135 t->selfVisible (false); 00136 doHide (HS_ALL_CHILDREN, t); 00137 m_twig->selfVisible (true); 00138 IgRepSet::invalidate (t, IgTwig::FLAGS_MASK | IgTwig::STRUCTURE_MASK); 00139 break; 00140 00141 default: 00142 ASSERT (false); 00143 } 00144 QApplication::restoreOverrideCursor (); 00145 }
Definition at line 215 of file IgTwigOps.cc.
References ASSERT, IgTwig::child(), IgTwig::children(), HS_ALL_CHILDREN, HS_ALL_LEAVES, i, and IgTwig::selfVisible().
Referenced by actionHide(), and actionVisible().
00216 { 00217 ASSERT (twig); 00218 if (n == 0) 00219 return; 00220 00221 // Twigs are by default is not visible, so no need to expand the tree 00222 // (FIXME: is this a valid assumption?) 00223 for (unsigned i = twig->children (); i; --i) 00224 { 00225 IgTwig *child = twig->child (i-1); 00226 doHide (n > 0 ? n-1 : n, child); 00227 00228 switch (n) 00229 { 00230 case HS_ALL_CHILDREN: 00231 child->selfVisible (false); 00232 break; 00233 case HS_ALL_LEAVES: 00234 if (child->children () == 0) 00235 child->selfVisible (false); 00236 break; 00237 default: 00238 if (n >= 0) 00239 child->selfVisible (false); 00240 break; 00241 } 00242 } 00243 }
Definition at line 186 of file IgTwigOps.cc.
References ASSERT, IgTwig::child(), IgTwig::children(), IgTwig::expand(), HS_ALL_CHILDREN, HS_ALL_LEAVES, i, IgTwig::selfTraverse(), and IgTwig::selfVisible().
Referenced by actionShow().
00187 { 00188 ASSERT (twig); 00189 if (n == 0) 00190 return; 00191 00192 twig->selfTraverse (true); 00193 twig->expand (); 00194 for (unsigned i = twig->children (); i; --i) 00195 { 00196 IgTwig *child = twig->child (i-1); 00197 doShow (n > 0 ? n-1 : n, child); 00198 00199 switch (n) 00200 { 00201 case HS_ALL_CHILDREN: 00202 child->selfVisible (true); 00203 break; 00204 case HS_ALL_LEAVES: 00205 child->selfVisible (child->children () == 0); 00206 break; 00207 default: 00208 child->selfVisible (n == 1); 00209 break; 00210 } 00211 } 00212 }
void IgTwigOps::menuAction | ( | IgQtObjectMenuMessage | message | ) |
Definition at line 23 of file IgTwigOps.cc.
References actionEnable(), actionHide(), actionShow(), actionVisible(), ASSERT, HS_ALL_CHILDREN, HS_ALL_LEAVES, HS_N, IgQtObjectMenu::insertFromDefs(), m_menu, m_twig, IgQtObjectMenuMessage::menu(), MENU_ENABLE, MENU_HIDE_1, MENU_HIDE_2, MENU_HIDE_3, MENU_HIDE_CHILDREN, MENU_HIDE_LEAVES, MENU_HIDE_LEVEL, MENU_HIDE_N, MENU_HIDE_SEP, MENU_SHOW_1, MENU_SHOW_2, MENU_SHOW_3, MENU_SHOW_CHILDREN, MENU_SHOW_LEAVES, MENU_SHOW_LEVEL, MENU_SHOW_N, MENU_SHOW_ONLY, MENU_SHOW_SEP, MENU_SHOW_THIS, menuUpdate(), IgQtObjectMenuMessage::object(), and IgQtObjectMenu::removeFromDefs().
Referenced by VisSimContent::init(), VisSimQtActions::init(), VisEventCoreContent::init(), and VisG4ExampleSetup::setup().
00024 { 00025 static const IgQtObjectMenu::ItemDef defs [] = { 00026 { -1, MENU_ENABLE, "Enable Children", 00027 SLOT(actionEnable(int)), MENU_ENABLE }, 00028 00029 { -1, MENU_SHOW_SEP, 0, 0, -1 }, 00030 { -1, MENU_SHOW_THIS, "Show This", 00031 SLOT(actionVisible(int)), MENU_SHOW_THIS }, 00032 { -1, MENU_SHOW_ONLY, "Show Only This", 00033 SLOT(actionVisible(int)), MENU_SHOW_ONLY }, 00034 { -1, MENU_SHOW_LEVEL, "Show By Level", 0, -1 }, 00035 { MENU_SHOW_LEVEL, MENU_SHOW_LEAVES, "&Leaves", 00036 SLOT(actionShow(int)), HS_ALL_LEAVES }, 00037 { MENU_SHOW_LEVEL, MENU_SHOW_CHILDREN, "&Every Level", 00038 SLOT(actionShow(int)), HS_ALL_CHILDREN }, 00039 { MENU_SHOW_LEVEL, MENU_SHOW_1, "&1 Level Down", 00040 SLOT(actionShow(int)), 1 }, 00041 { MENU_SHOW_LEVEL, MENU_SHOW_2, "&2 Levels Down", 00042 SLOT(actionShow(int)), 2 }, 00043 { MENU_SHOW_LEVEL, MENU_SHOW_3, "&3 Levels Down", 00044 SLOT(actionShow(int)), 3 }, 00045 { MENU_SHOW_LEVEL, MENU_SHOW_N, "&N Levels Down...", 00046 SLOT(actionShow(int)), HS_N }, 00047 00048 { -1, MENU_HIDE_SEP, 0, 0, -1 }, 00049 { -1, MENU_HIDE_LEVEL, "Hide By Level", 0, -1 }, 00050 { MENU_HIDE_LEVEL, MENU_HIDE_LEAVES, "&Leaves", 00051 SLOT(actionHide(int)), HS_ALL_LEAVES }, 00052 { MENU_HIDE_LEVEL, MENU_HIDE_CHILDREN, "&Every Level", 00053 SLOT(actionHide(int)), HS_ALL_CHILDREN }, 00054 { MENU_HIDE_LEVEL, MENU_HIDE_1, "&1 Level Down", 00055 SLOT(actionHide(int)), 1 }, 00056 { MENU_HIDE_LEVEL, MENU_HIDE_2, "&2 Levels Down", 00057 SLOT(actionHide(int)), 2 }, 00058 { MENU_HIDE_LEVEL, MENU_HIDE_3, "&3 Levels Down", 00059 SLOT(actionHide(int)), 3 }, 00060 { MENU_HIDE_LEVEL, MENU_HIDE_N, "&N Levels Down...", 00061 SLOT(actionHide(int)), HS_N }, 00062 }; 00063 00064 static const int ndefs = sizeof (defs)/sizeof (defs [0]); 00065 00066 m_menu = message.menu (); 00067 ASSERT (m_menu); 00068 00069 if (! (m_twig = dynamic_cast<IgTwig *> (message.object ()))) 00070 // An irrelevant object, remove our items. 00071 m_menu->removeFromDefs (defs, ndefs); 00072 else 00073 { 00074 // Add our items if they aren't there yet. 00075 m_menu->insertFromDefs (this, defs, ndefs); 00076 menuUpdate (); 00077 } 00078 }
Definition at line 81 of file IgTwigOps.cc.
References ASSERT, IgQtObjectMenu::changeItem(), m_menu, m_twig, MENU_ENABLE, and IgTwig::selfTraverse().
Referenced by menuAction().
00082 { 00083 ASSERT (m_menu); 00084 // Update items to reflect the state of this twig. 00085 m_menu->changeItem (MENU_ENABLE, m_twig->selfTraverse () 00086 ? "Disable Children" : "Enable Children"); 00087 }
const int IgTwigOps::HS_ALL_CHILDREN = -2 [static] |
Definition at line 28 of file IgTwigOps.h.
Referenced by actionVisible(), doHide(), doShow(), and menuAction().
const int IgTwigOps::HS_ALL_LEAVES = -1 [static] |
const int IgTwigOps::HS_N = -3 [static] |
Definition at line 29 of file IgTwigOps.h.
Referenced by actionHide(), actionShow(), and menuAction().
IgQtObjectMenu* IgTwigOps::m_menu [private] |
IgTwig* IgTwigOps::m_twig [private] |
Definition at line 72 of file IgTwigOps.h.
Referenced by actionEnable(), actionHide(), actionShow(), actionVisible(), menuAction(), and menuUpdate().
const int IgTwigOps::MENU_ENABLE = 1 [static] |
Definition at line 31 of file IgTwigOps.h.
Referenced by actionEnable(), menuAction(), and menuUpdate().
const int IgTwigOps::MENU_ENABLE_UP = 2 [static] |
Definition at line 32 of file IgTwigOps.h.
Referenced by actionEnable(), actionShow(), and actionVisible().
const int IgTwigOps::MENU_HIDE_1 = 5102 [static] |
const int IgTwigOps::MENU_HIDE_2 = 5103 [static] |
const int IgTwigOps::MENU_HIDE_3 = 5104 [static] |
const int IgTwigOps::MENU_HIDE_CHILDREN = 5101 [static] |
const int IgTwigOps::MENU_HIDE_LEAVES = 5100 [static] |
const int IgTwigOps::MENU_HIDE_LEVEL = 51 [static] |
const int IgTwigOps::MENU_HIDE_N = 5105 [static] |
const int IgTwigOps::MENU_HIDE_SEP = 50 [static] |
const int IgTwigOps::MENU_SHOW_1 = 1302 [static] |
const int IgTwigOps::MENU_SHOW_2 = 1303 [static] |
const int IgTwigOps::MENU_SHOW_3 = 1304 [static] |
const int IgTwigOps::MENU_SHOW_CHILDREN = 1301 [static] |
const int IgTwigOps::MENU_SHOW_LEAVES = 1300 [static] |
const int IgTwigOps::MENU_SHOW_LEVEL = 13 [static] |
const int IgTwigOps::MENU_SHOW_N = 1305 [static] |
const int IgTwigOps::MENU_SHOW_ONLY = 12 [static] |
const int IgTwigOps::MENU_SHOW_SEP = 10 [static] |
const int IgTwigOps::MENU_SHOW_THIS = 11 [static] |