ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
AssocObjAttachmentHandle Class Reference

#include <TrackHandleBase.h>

Collaboration diagram for AssocObjAttachmentHandle:

Classes

class  Imp
 

Public Member Functions

void attachNodes (SoNode *simple, SoNode *detailed, bool unpickable)
 
void setPickableStateOfNodes (SoNode *simple, SoNode *detailed, bool unpickable)
 Will attach if not currently attached. More...
 
void detachNodes (SoNode *simple, SoNode *detailed)
 

Private Member Functions

 AssocObjAttachmentHandle (TrackLODHandle *, TrackHandleBase *)
 
 ~AssocObjAttachmentHandle ()
 
 AssocObjAttachmentHandle (const AssocObjAttachmentHandle &)
 
AssocObjAttachmentHandleoperator= (const AssocObjAttachmentHandle &)
 
void trackMaterialChanged ()
 
void trackVisibilityChanged ()
 

Private Attributes

Impm_d
 

Friends

class TrackHandleBase
 
class TrackHandleBase::Imp
 

Detailed Description

Definition at line 202 of file TrackHandleBase.h.

Constructor & Destructor Documentation

◆ AssocObjAttachmentHandle() [1/2]

AssocObjAttachmentHandle::AssocObjAttachmentHandle ( TrackLODHandle tlh,
TrackHandleBase th 
)
private

Definition at line 1701 of file TrackHandleBase.cxx.

1702  : m_d ( new Imp(tlh,th) )
1703 {
1704  if (!tlh)
1705  VP1Msg::message("AssocObjAttachmentHandle ERROR: constructed with null LOD handle!");
1706  if (!Imp::dummymaterial) {
1707  Imp::dummymaterial = new SoMaterial;
1708  Imp::dummymaterial->ref();
1709  }
1710 }

◆ ~AssocObjAttachmentHandle()

AssocObjAttachmentHandle::~AssocObjAttachmentHandle ( )
private

Definition at line 1713 of file TrackHandleBase.cxx.

1714 {
1715  if (VP1Msg::verbose()) {
1718  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes detected wrong pickStyleChildIdx");
1719  return;
1720  }
1721  }
1722 
1723  if (Imp::pickStyle) {
1724  Imp::pickStyle->unref();
1725  if ( Imp::pickStyle->getRefCount()==1 ) {
1726  Imp::pickStyle->unref();
1727  Imp::pickStyle = nullptr;
1728  }
1729  }
1730 
1731  if (m_d->septrack_simple)
1732  m_d->septrack_simple->unref();
1733  if (m_d->septrack_detailed)
1734  m_d->septrack_detailed->unref();
1735  if (m_d->trackmat)
1736  m_d->trackmat->unref();
1737  delete m_d;
1738 }

◆ AssocObjAttachmentHandle() [2/2]

AssocObjAttachmentHandle::AssocObjAttachmentHandle ( const AssocObjAttachmentHandle )
private

Member Function Documentation

◆ attachNodes()

void AssocObjAttachmentHandle::attachNodes ( SoNode *  simple,
SoNode *  detailed,
bool  unpickable 
)

Definition at line 1785 of file TrackHandleBase.cxx.

1786 {
1787  if (!m_d->trackhandle->visible())
1788  return;
1789  m_d->ensureInit();
1790  if (!m_d->trackmat) {
1791  SoMaterial * m = m_d->trackhandle->currentMaterial();
1792  if (!m)
1793  m = Imp::dummymaterial;//For now we attach a dummy material.
1794  m_d->trackmat=m;
1795  m->ref();
1796  m_d->septrack_simple->addChild(m);
1797  m_d->septrack_detailed->addChild(m);
1798  }
1799 
1800  if (VP1Msg::verbose()) {
1803  VP1Msg::message("ERROR: AssocObjAttachmentHandle::attachNodes detected wrong pickStyleChildIdx");
1804  return;
1805  }
1806  if (m_d->septrack_simple->findChild(simple)>-1||m_d->septrack_detailed->findChild(detailed)>-1) {
1807  VP1Msg::message("ERROR: AssocObjAttachmentHandle::attachNodes Already attached!");
1808  return;
1809  }
1810  }
1811  if (unpickable) {
1812  if (m_d->pickStyleChildIdx==-1) {
1813  m_d->pickStyleChildIdx = m_d->septrack_simple->getNumChildren();
1814  m_d->septrack_simple->addChild(Imp::pickStyle);
1815  m_d->septrack_detailed->addChild(Imp::pickStyle);
1816  }
1817  m_d->septrack_simple->addChild(simple);
1818  m_d->septrack_detailed->addChild(detailed);
1819  } else {
1820  if (m_d->pickStyleChildIdx>-1) {
1821  m_d->septrack_simple->insertChild(simple,m_d->pickStyleChildIdx);
1822  m_d->septrack_detailed->insertChild(detailed,m_d->pickStyleChildIdx);
1823  ++(m_d->pickStyleChildIdx);
1824  } else {
1825  m_d->septrack_simple->addChild(simple);
1826  m_d->septrack_detailed->addChild(detailed);
1827  }
1828  }
1829 
1830  //Should we update the overall attachment status?:
1831  if (m_d->trackhandle->visible() && m_d->septrack_simple->getNumChildren() == 2 + (m_d->pickStyleChildIdx==-1?0:1)) {
1832  m_d->ensureAttached();
1833  }
1834 }

◆ detachNodes()

void AssocObjAttachmentHandle::detachNodes ( SoNode *  simple,
SoNode *  detailed 
)

Definition at line 1920 of file TrackHandleBase.cxx.

1921 {
1922  if (!m_d->trackmat)
1923  return;
1924  int isimple = m_d->septrack_simple->findChild(simple);
1925  if (VP1Msg::verbose()) {
1926  if (!simple||!detailed) {
1927  VP1Msg::messageVerbose("AssocObjAttachmentHandle::detach ERROR: Called with null pointers!");
1928  return;
1929  }
1930  if (m_d->septrack_simple->getNumChildren()!=m_d->septrack_detailed->getNumChildren()) {
1931  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes septrack_simple->getNumChildren()"
1932  "!=m_d->septrack_detailed->getNumChildren().");
1933  return;
1934  }
1937  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes detected wrong pickStyleChildIdx");
1938  return;
1939  }
1940  if (isimple==-1) {
1941  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes Not previously attached!");
1942  return;
1943  }
1944  if (m_d->septrack_detailed->findChild(detailed)!=isimple) {
1945  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes"
1946  " called with simple and detailed nodes that are not at same child idx!");
1947  return;
1948  }
1949  }
1950  m_d->septrack_simple->removeChild(simple);
1951  m_d->septrack_detailed->removeChild(detailed);
1952  if ( m_d->pickStyleChildIdx!=-1
1953  && isimple>m_d->pickStyleChildIdx
1954  && m_d->pickStyleChildIdx==m_d->septrack_simple->getNumChildren()-1 ) {
1955  VP1Msg::messageVerbose("AssocObjAttachmentHandle::detachNodes detaching pickstyle");
1956  m_d->septrack_simple->removeChild(Imp::pickStyle);
1957  m_d->septrack_detailed->removeChild(Imp::pickStyle);
1958  m_d->pickStyleChildIdx = -1;
1959  }
1960 
1961  //Should we update the overall attachment status?:
1962  if (m_d->trackhandle->visible() && m_d->septrack_simple->getNumChildren() == 1 + (m_d->pickStyleChildIdx==-1?0:1))
1963  m_d->ensureDetached();
1964 }

◆ operator=()

AssocObjAttachmentHandle& AssocObjAttachmentHandle::operator= ( const AssocObjAttachmentHandle )
private

◆ setPickableStateOfNodes()

void AssocObjAttachmentHandle::setPickableStateOfNodes ( SoNode *  simple,
SoNode *  detailed,
bool  unpickable 
)

Will attach if not currently attached.

Definition at line 1837 of file TrackHandleBase.cxx.

1838 {
1839  if (VP1Msg::verbose()) {
1840  VP1Msg::messageVerbose("AssocObjAttachmentHandle::setPickableStateOfNodes called with unpickable = "
1841  +QString(unpickable?"true":"false"));
1842  if (!simple||!detailed) {
1843  VP1Msg::messageVerbose("AssocObjAttachmentHandle::setPickableStateOfNodes ERROR: Called with null pointers!");
1844  return;
1845  }
1846  }
1847  m_d->ensureInit();
1848  int isimple = m_d->septrack_simple->findChild(simple);
1849  if (VP1Msg::verbose()) {
1850  if (m_d->septrack_simple->getNumChildren()!=m_d->septrack_detailed->getNumChildren()) {
1851  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes septrack_simple->getNumChildren()"
1852  "!=m_d->septrack_detailed->getNumChildren().");
1853  return;
1854  }
1855  int idetailed = m_d->septrack_detailed->findChild(detailed);
1856  if (idetailed!=isimple) {
1857  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes"
1858  " called with simple and detailed nodes that are not at same child idx!");
1859  return;
1860  }
1863  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes detected wrong pickStyleChildIdx");
1864  return;
1865  }
1866  }
1867  if (isimple<0) {
1868  VP1Msg::messageDebug( "WARNING: AssocObjAttachmentHandle::setPickableStateOfNodes"
1869  " called with nodes that are not currently children. Calling attachNodes(..)." );
1870  attachNodes(simple, detailed, unpickable);
1871  return;
1872  }
1873  if (unpickable == (m_d->pickStyleChildIdx>-1&&isimple>m_d->pickStyleChildIdx)) {
1874  VP1Msg::messageDebug("WARNING: AssocObjAttachmentHandle::setPickableStateOfNodes"
1875  " already in correct state.");
1876  return;
1877  }
1878 
1879  simple->ref();//To avoid deletion upon removeChild calls.
1880  detailed->ref();
1881  if (unpickable) {
1882  m_d->septrack_simple->removeChild(simple);
1883  m_d->septrack_detailed->removeChild(detailed);
1884  if (m_d->pickStyleChildIdx==-1) {
1885  m_d->pickStyleChildIdx = m_d->septrack_simple->getNumChildren();
1886  m_d->septrack_simple->addChild(Imp::pickStyle);
1887  m_d->septrack_detailed->addChild(Imp::pickStyle);
1888  } else {
1889  --(m_d->pickStyleChildIdx);
1890  }
1891  m_d->septrack_simple->addChild(simple);
1892  m_d->septrack_detailed->addChild(detailed);
1893  } else {
1894  if (m_d->pickStyleChildIdx==-1) {
1895  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes Inconsistent logic");
1896  simple->unref();
1897  detailed->unref();
1898  return;
1899  }
1900  if (m_d->pickStyleChildIdx==isimple-1&&isimple==m_d->septrack_simple->getNumChildren()-1) {
1901  //pickStyle object no longer needed:
1902  VP1Msg::messageVerbose("AssocObjAttachmentHandle::setPickableStateOfNodes detaching pickstyle");
1903  m_d->septrack_simple->removeChild(Imp::pickStyle);
1904  m_d->septrack_detailed->removeChild(Imp::pickStyle);
1905  m_d->pickStyleChildIdx = -1;
1906  } else {
1907  //Move children left of the pickstyle object.
1908  m_d->septrack_simple->removeChild(simple);
1909  m_d->septrack_detailed->removeChild(detailed);
1910  m_d->septrack_simple->insertChild(simple,m_d->pickStyleChildIdx);
1911  m_d->septrack_detailed->insertChild(detailed,m_d->pickStyleChildIdx);
1912  ++(m_d->pickStyleChildIdx);
1913  }
1914  }
1915  simple->unref();
1916  detailed->unref();
1917 }

◆ trackMaterialChanged()

void AssocObjAttachmentHandle::trackMaterialChanged ( )
private

Definition at line 1741 of file TrackHandleBase.cxx.

1742 {
1743  SoMaterial * m = m_d->trackhandle->currentMaterial();
1744  if (m_d->trackmat==m)
1745  return;
1746  if (!m) {
1747  if (m_d->trackhandle->visible())
1748  VP1Msg::message("ERROR: track is visible but has no current material!!");
1750  }
1751  m->ref();
1752  if (m_d->trackmat) {
1753  if ( m_d->septrack_simple && m_d->septrack_simple->findChild(m_d->trackmat) > -1 )
1754  m_d->septrack_simple->replaceChild(m_d->trackmat,m);
1755  if ( m_d->septrack_detailed && m_d->septrack_detailed->findChild(m_d->trackmat) > -1 )
1756  m_d->septrack_detailed->replaceChild(m_d->trackmat,m);
1757  m_d->trackmat->unref();
1758  }
1759  m_d->trackmat = m;
1760 }

◆ trackVisibilityChanged()

void AssocObjAttachmentHandle::trackVisibilityChanged ( )
private

Definition at line 1689 of file TrackHandleBase.cxx.

1690 {
1691  bool b = m_d->trackhandle->visible();
1692  if (b&&!m_d->trackhandle->currentMaterial())
1693  VP1Msg::message("ERROR: track is visible but has not current material!!");
1694  if (b)
1695  m_d->ensureAttached();
1696  else
1697  m_d->ensureDetached();
1698 }

Friends And Related Function Documentation

◆ TrackHandleBase

friend class TrackHandleBase
friend

Definition at line 208 of file TrackHandleBase.h.

◆ TrackHandleBase::Imp

friend class TrackHandleBase::Imp
friend

Definition at line 209 of file TrackHandleBase.h.

Member Data Documentation

◆ m_d

Imp* AssocObjAttachmentHandle::m_d
private

Definition at line 217 of file TrackHandleBase.h.


The documentation for this class was generated from the following files:
AssocObjAttachmentHandle::Imp::ensureInit
void ensureInit()
Definition: TrackHandleBase.cxx:1763
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
AssocObjAttachmentHandle::Imp::septrack_simple
SoSeparator * septrack_simple
Definition: TrackHandleBase.cxx:1659
AssocObjAttachmentHandle::Imp::pickStyleChildIdx
int pickStyleChildIdx
Definition: TrackHandleBase.cxx:1663
AssocObjAttachmentHandle::Imp::trackmat
SoMaterial * trackmat
Definition: TrackHandleBase.cxx:1657
AssocObjAttachmentHandle::Imp::trackhandle
TrackHandleBase * trackhandle
Definition: TrackHandleBase.cxx:1656
AssocObjAttachmentHandle::Imp::septrack_detailed
SoSeparator * septrack_detailed
Definition: TrackHandleBase.cxx:1660
python.TriggerHandler.th
th
Definition: TriggerHandler.py:296
AssocObjAttachmentHandle::attachNodes
void attachNodes(SoNode *simple, SoNode *detailed, bool unpickable)
Definition: TrackHandleBase.cxx:1785
TrackHandleBase::visible
bool visible() const
Definition: TrackHandleBase.h:67
AssocObjAttachmentHandle::Imp::pickStyle
static SoPickStyle * pickStyle
Definition: TrackHandleBase.cxx:1662
TrackHandleBase::currentMaterial
SoMaterial * currentMaterial() const
Definition: TrackHandleBase.h:76
AssocObjAttachmentHandle::m_d
Imp * m_d
Definition: TrackHandleBase.h:216
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
AssocObjAttachmentHandle::Imp::dummymaterial
static SoMaterial * dummymaterial
Definition: TrackHandleBase.cxx:1683
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
AssocObjAttachmentHandle::Imp::ensureDetached
void ensureDetached()
Definition: TrackHandleBase.cxx:1674
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
AssocObjAttachmentHandle::Imp::ensureAttached
void ensureAttached()
Definition: TrackHandleBase.cxx:1665