#include <Iguana/GLModels/interface/Ig3DBaseModel.h>
Public Types | |
enum | EventType { ModelChanged } |
typedef lat::Callback1 < Ig3DBaseModelEvent > | Listener |
Public Member Functions | |
virtual void | add (Ig3DBaseRep *rep) |
virtual Ig3DBaseRep * | attachPoint (void) const |
virtual void | change (Ig3DBaseRep *rep) |
virtual void | changed (void) |
Ig3DBaseModel (IgState *state) | |
virtual void | listen (EventType event, const Listener &listener) |
virtual Ig3DBaseRep * | lookup (SoGroup *node) const |
virtual void | remove (Ig3DBaseRep *rep, bool search=false) |
virtual SoGroup * | sceneGraph (void) const |
virtual IgState * | state (void) const |
virtual void | unlisten (EventType event, const Listener &listener) |
~Ig3DBaseModel (void) | |
Static Public Member Functions | |
static std::string | decode (const SbName &name) |
static std::string | decode (const std::string &name) |
static SbString | encode (const std::string &name) |
Private Types | |
typedef std::vector< Listener > | Listeners |
Private Member Functions | |
Ig3DBaseModel (const Ig3DBaseModel &) | |
Ig3DBaseModel & | operator= (const Ig3DBaseModel &) |
Private Attributes | |
Ig3DBaseRep * | m_attachPoint |
Listeners | m_listeners |
SoGroup * | m_sceneGraph |
IgState * | m_state |
Definition at line 27 of file Ig3DBaseModel.h.
Definition at line 30 of file Ig3DBaseModel.h.
typedef std::vector<Listener> Ig3DBaseModel::Listeners [private] |
Definition at line 55 of file Ig3DBaseModel.h.
Ig3DBaseModel::Ig3DBaseModel | ( | IgState * | state | ) |
Definition at line 23 of file Ig3DBaseModel.cc.
References ASSERT, m_attachPoint, and m_sceneGraph.
00024 : m_state (state), 00025 m_sceneGraph (new SoSelection), 00026 m_attachPoint (0) 00027 { 00028 // ASSERT ("attachPoint is the scene graph or within it"); 00029 m_sceneGraph->ref (); 00030 m_sceneGraph->setName ("IGUANA_SCENE_GRAPH_V2"); 00031 Ig3DBaseRep *rep = new Ig3DBaseRep (this, 0, 0, new SoSeparator); 00032 ASSERT (m_attachPoint == rep); 00033 }
Ig3DBaseModel::~Ig3DBaseModel | ( | void | ) |
Definition at line 35 of file Ig3DBaseModel.cc.
References m_sceneGraph.
00036 { m_sceneGraph->unref (); }
Ig3DBaseModel::Ig3DBaseModel | ( | const Ig3DBaseModel & | ) | [private] |
void Ig3DBaseModel::add | ( | Ig3DBaseRep * | rep | ) | [virtual] |
Definition at line 74 of file Ig3DBaseModel.cc.
References ASSERT, changed(), m_attachPoint, and m_sceneGraph.
Referenced by Ig3DBaseRep::Ig3DBaseRep().
00075 { 00076 ASSERT (rep); 00077 00078 if (! m_attachPoint) 00079 { 00080 // Initialising: creating the root rep. 00081 ASSERT (m_sceneGraph->getNumChildren () == 0); 00082 m_sceneGraph->addChild (m_attachPoint = rep); 00083 } 00084 else 00085 { 00086 ASSERT (m_attachPoint->findChild (rep) == -1); 00087 m_attachPoint->addChild (rep); 00088 changed (); 00089 } 00090 }
Ig3DBaseRep * Ig3DBaseModel::attachPoint | ( | void | ) | const [virtual] |
Definition at line 144 of file Ig3DBaseModel.cc.
References m_attachPoint.
Referenced by Ig3DAnimsCategory::buildDefaults(), Ig3DSlicersCategory::buildDefaults(), Ig3DLightsCategory::buildDefaults(), Ig3DGridCategory::buildDefaults(), Ig3DClipsCategory::buildDefaults(), Ig2DModel::closestMatchName(), Ig3DClipsCategory::deleteOne(), Ig3DAnimsCategory::deleteOne(), Ig3DGridCategory::deleteOne(), Ig3DSlicersCategory::deleteOne(), Ig3DLightsCategory::deleteOne(), IgSpareBrowser::drawGrid(), IgRPhiBrowser::drawGrid(), Ig2DModel::fullMatch(), Ig2DModel::getLayer(), Ig2DModel::Ig2DModel(), Ig3DBaseBrowser::Ig3DBaseBrowser(), IgIVView::IgIVView(), IgRPhiBrowser::IgRPhiBrowser(), IgSpareBrowser::IgSpareBrowser(), Ig3DLightsCategory::lightTypeChanged(), Ig3DGridCategory::makeCustomOne(), Ig3DLightsCategory::makeOne(), Ig3DAnimsCategory::makeOne(), Ig3DSlicersCategory::makeOne(), Ig3DClipsCategory::makeOne(), Ig3DGridCategory::makeOne(), Ig3DGridCategory::openIVFile(), Ig3DLightsCategory::reconstruct(), Ig3DClipsCategory::reconstruct(), Ig3DAnimsCategory::reconstruct(), Ig3DSlicersCategory::reconstruct(), Ig3DGridCategory::reconstruct(), Ig3DViewpointsCategory::registerBrowser(), Ig3DGridCategory::removeGrids(), Ig3DGridCategory::saveIVFile(), Ig2DModel::setCutTransform(), and Ig3DLightsCategory::toggleOne().
00145 { return m_attachPoint; }
void Ig3DBaseModel::change | ( | Ig3DBaseRep * | rep | ) | [virtual] |
Definition at line 132 of file Ig3DBaseModel.cc.
References ASSERT, and changed().
Referenced by Ig3DBaseRep::Ig3DBaseRep(), Ig3DBaseRep::magic(), and Ig3DBaseRep::node().
Definition at line 59 of file Ig3DBaseModel.cc.
References event(), and m_listeners.
Referenced by add(), change(), and remove().
00060 { 00061 Ig3DBaseModelEvent event (this); 00062 for (Listeners::iterator pos = m_listeners.begin (); 00063 pos != m_listeners.end (); ++pos) 00064 (*pos) (event); 00065 }
std::string Ig3DBaseModel::decode | ( | const SbName & | name | ) | [static] |
std::string Ig3DBaseModel::decode | ( | const std::string & | name | ) | [static] |
Definition at line 182 of file Ig3DBaseModel.cc.
References ASSERT, code, first, i, HLT_VtxMuL3::result, and edm::second().
Referenced by Ig3DObjectCategory< T >::add(), Ig3DNodeCategory::addFields(), Ig3DNodeCategory::addNode(), Ig3DFieldPlanesCategory::addOne(), IgSoTwig::buildFromReps(), IgSoTwig::buildFromVis(), decode(), Ig3DSlicersCategory::makeOne(), Ig3DClipsCategory::makeOne(), Ig3DGridCategory::makeOne(), Ig3DViewpointsCategory::renameItem(), Ig3DSlicersCategory::renameItem(), Ig3DLightsCategory::renameItem(), Ig3DGridCategory::renameItem(), Ig3DClipsCategory::renameItem(), Ig3DAnimsCategory::renameItem(), and Ig3DFieldPlanesCategory::renameItem().
00183 { 00184 // Encode names so that they use valid OpenInventor characters and 00185 // thre rest is escaped as `_X<hex code>', and decode them when 00186 // reading in the files. 00187 static const char hexdigits [] = "0123456789abcdef"; 00188 std::string result; 00189 const char *first; 00190 const char *second; 00191 00192 for (std::string::size_type i = 0; i < name.size (); ++i) 00193 if (name[i] != '_' 00194 || i > name.size () - 4 00195 || name[i+1] != 'X' 00196 || !(first = strchr (hexdigits, name[i+2])) 00197 || !(second = strchr (hexdigits, name[i+3]))) 00198 result.append (1, name[i]); 00199 else 00200 { 00201 # if UCHAR_MAX != 255 || CHAR_BIT != 8 00202 # error expected 8-bit characters 00203 # endif 00204 unsigned int code = ((unsigned) (first - hexdigits) << 4) 00205 + ((unsigned) (second - hexdigits)); 00206 ASSERT (code <= UCHAR_MAX); 00207 result += static_cast<char> (code); 00208 i += 3; 00209 } 00210 00211 return result; 00212 }
SbString Ig3DBaseModel::encode | ( | const std::string & | name | ) | [static] |
Definition at line 149 of file Ig3DBaseModel.cc.
References i, and HLT_VtxMuL3::result.
Referenced by Ig3DLightsCategory::addExtraLights(), Ig3DFieldPlanesCategory::addOne(), Ig3DAnimsCategory::buildDefaults(), Ig3DLightsCategory::buildDefaults(), IgSoTwig::cleared(), Ig2DModel::closestMatchName(), Ig2DModel::createFull(), Ig3DAnimsCategory::deleteOne(), Ig3DLightsCategory::deleteOne(), IgSpareBrowser::drawGrid(), IgRPhiBrowser::drawGrid(), Ig3DBaseBrowser::drawGrid(), Ig2DModel::fullMatch(), Ig2DModel::getLayer(), Ig2DModel::Ig2DModel(), Ig3DBaseBrowser::Ig3DBaseBrowser(), Ig3DViewpointsCategory::Ig3DViewpointsCategory(), IgRPhiBrowser::IgRPhiBrowser(), IgSoTwig::IgSoTwig(), IgSpareBrowser::IgSpareBrowser(), Ig3DLightsCategory::lightTypeChanged(), Ig3DViewpointsCategory::load(), Ig3DClipsCategory::makeClip(), Ig3DGridCategory::makeGrid(), Ig3DLightsCategory::makeOne(), Ig3DAnimsCategory::makeOne(), Ig3DViewpointsCategory::makeOne(), Ig3DSlicersCategory::makeSlicer(), MMM_DEFUN_FUNC(), Ig3DGridCategory::openIVFile(), Ig3DWindow::printViews(), Ig3DLightsCategory::reconstruct(), Ig3DAnimsCategory::reconstruct(), Ig3DClipsCategory::reconstruct(), Ig3DGridCategory::reconstruct(), Ig3DSlicersCategory::reconstruct(), Ig3DViewpointsCategory::registerBrowser(), Ig3DLightsCategory::registerBrowser(), Ig3DGridCategory::removeGrids(), Ig3DObjectCategory< T >::rename(), Ig3DClipsCategory::repClips(), Ig3DGridCategory::repGrids(), Ig3DSlicersCategory::repSlicers(), Ig3DGridCategory::saveIVFile(), Ig3DLightsCategory::toggleOne(), VisPSimHitTwig::update(), VisBasicClusterCollectionTwig::update(), and VisSuperClusterCollectionTwig::update().
00150 { 00151 // Encode names so that they use valid OpenInventor characters and 00152 // thre rest is escaped as `_X<hex code>', and decode them when 00153 // reading in the files. 00154 static const char hexdigits [] = "0123456789abcdef"; 00155 std::string result; 00156 00157 if (! SbName::isBaseNameStartChar (name [0])) 00158 { 00159 result += '_'; 00160 } 00161 00162 for (std::string::size_type i = 0; i < name.size (); ++i) 00163 if (SbName::isBaseNameChar (name[i])) 00164 result.append (1, name[i]); 00165 else if (i > 0 && SbName::isBaseNameStartChar (name[i])) 00166 result.append (1, name[i]); 00167 else 00168 { 00169 # if UCHAR_MAX != 255 || CHAR_BIT != 8 00170 # error expected 8-bit characters 00171 # endif 00172 result += '_'; 00173 result += 'X'; 00174 result += hexdigits [((unsigned char) name[i]>>4)&0xf]; 00175 result += hexdigits [(unsigned char) name[i]&0xf]; 00176 } 00177 00178 return result.c_str (); 00179 }
Definition at line 45 of file Ig3DBaseModel.cc.
References m_listeners.
Referenced by Ig3DBaseBrowser::initWidget().
00046 { m_listeners.push_back (listener); }
Ig3DBaseRep * Ig3DBaseModel::lookup | ( | SoGroup * | node | ) | const [virtual] |
Definition at line 69 of file Ig3DBaseModel.cc.
References ASSERT.
00070 { ASSERT (false); return dynamic_cast<Ig3DBaseRep *> (node); }
Ig3DBaseModel& Ig3DBaseModel::operator= | ( | const Ig3DBaseModel & | ) | [private] |
void Ig3DBaseModel::remove | ( | Ig3DBaseRep * | rep, | |
bool | search = false | |||
) | [virtual] |
Definition at line 93 of file Ig3DBaseModel.cc.
References ASSERT, changed(), index, m_attachPoint, p, and dbtoconf::parent.
Referenced by Ig3DBaseRep::zap().
00094 { 00095 ASSERT (rep); 00096 // Be conservative -- the rep has no way of knowing it has been 00097 // added to a model or to a parent. 00098 int index; 00099 if ((index = m_attachPoint->findChild (rep)) != -1) 00100 m_attachPoint->removeChild (index); 00101 00102 if (search) 00103 { 00104 // NB: The object rep can be attached in only one place. We 00105 // end up here if the rep is being deleted via its object 00106 // going away and the rep doesn't know where it belongs to, 00107 // asking us to do the hard work. 00108 // 00109 // Find the parent. Since this is a rep, the parent must 00110 // always be a rep (a separator) and not hidden inside 00111 // switches. It might have been in the attach point but we 00112 // already removed that one, so we know the path must be at 00113 // least two levels. 00114 SoSearchAction searcher; 00115 searcher.setNode (rep); 00116 searcher.apply (m_attachPoint); 00117 00118 if (searcher.getPath ()) 00119 { 00120 ASSERT (searcher.getPath ()->getLength () > 1); 00121 SoNode *parent = searcher.getPath ()->getNodeFromTail (1); 00122 ASSERT (parent && parent->isOfType(SoSeparator::getClassTypeId())); 00123 SoSeparator *p = static_cast<SoSeparator *> (parent); 00124 p->removeChild (rep); 00125 } 00126 } 00127 00128 changed (); 00129 }
SoGroup * Ig3DBaseModel::sceneGraph | ( | void | ) | const [virtual] |
Definition at line 140 of file Ig3DBaseModel.cc.
References m_sceneGraph.
Referenced by Ig3DBaseBrowser::focusIn(), Ig3DBaseBrowser::focusOut(), Ig3DBaseBrowser::initWidget(), Ig3DBaseBrowser::repSeekTo(), Ig3DBaseBrowser::save(), Ig3DBaseBrowser::select(), and IgOIVBrowser::setCamera().
00141 { return m_sceneGraph; }
Definition at line 49 of file Ig3DBaseModel.cc.
References ASSERT, find(), and m_listeners.
Referenced by Ig3DBaseBrowser::~Ig3DBaseBrowser().
00050 { 00051 Listeners::iterator pos = std::find (m_listeners.begin (), 00052 m_listeners.end(), 00053 listener); 00054 ASSERT (pos != m_listeners.end ()); 00055 m_listeners.erase (pos); 00056 }
Ig3DBaseRep* Ig3DBaseModel::m_attachPoint [private] |
Definition at line 60 of file Ig3DBaseModel.h.
Referenced by add(), attachPoint(), Ig3DBaseModel(), and remove().
Listeners Ig3DBaseModel::m_listeners [private] |
SoGroup* Ig3DBaseModel::m_sceneGraph [private] |
Definition at line 59 of file Ig3DBaseModel.h.
Referenced by add(), Ig3DBaseModel(), sceneGraph(), and ~Ig3DBaseModel().
IgState* Ig3DBaseModel::m_state [private] |