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 197 of file TrackHandleBase.h.

Constructor & Destructor Documentation

◆ AssocObjAttachmentHandle() [1/2]

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

Definition at line 1684 of file TrackHandleBase.cxx.

1685  : m_d ( new Imp(tlh,th) )
1686 {
1687  if (!tlh)
1688  VP1Msg::message("AssocObjAttachmentHandle ERROR: constructed with null LOD handle!");
1689  if (!Imp::dummymaterial) {
1690  Imp::dummymaterial = new SoMaterial;
1691  Imp::dummymaterial->ref();
1692  }
1693 }

◆ ~AssocObjAttachmentHandle()

AssocObjAttachmentHandle::~AssocObjAttachmentHandle ( )
private

Definition at line 1696 of file TrackHandleBase.cxx.

1697 {
1698  if (VP1Msg::verbose()) {
1701  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes detected wrong pickStyleChildIdx");
1702  return;
1703  }
1704  }
1705 
1706  if (Imp::pickStyle) {
1707  Imp::pickStyle->unref();
1708  if ( Imp::pickStyle->getRefCount()==1 ) {
1709  Imp::pickStyle->unref();
1710  Imp::pickStyle = nullptr;
1711  }
1712  }
1713 
1714  if (m_d->septrack_simple)
1715  m_d->septrack_simple->unref();
1716  if (m_d->septrack_detailed)
1717  m_d->septrack_detailed->unref();
1718  if (m_d->trackmat)
1719  m_d->trackmat->unref();
1720  delete m_d;
1721 }

◆ AssocObjAttachmentHandle() [2/2]

AssocObjAttachmentHandle::AssocObjAttachmentHandle ( const AssocObjAttachmentHandle )
private

Member Function Documentation

◆ attachNodes()

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

Definition at line 1768 of file TrackHandleBase.cxx.

1769 {
1770  if (!m_d->trackhandle->visible())
1771  return;
1772  m_d->ensureInit();
1773  if (!m_d->trackmat) {
1774  SoMaterial * m = m_d->trackhandle->currentMaterial();
1775  if (!m)
1776  m = Imp::dummymaterial;//For now we attach a dummy material.
1777  m_d->trackmat=m;
1778  m->ref();
1779  m_d->septrack_simple->addChild(m);
1780  m_d->septrack_detailed->addChild(m);
1781  }
1782 
1783  if (VP1Msg::verbose()) {
1786  VP1Msg::message("ERROR: AssocObjAttachmentHandle::attachNodes detected wrong pickStyleChildIdx");
1787  return;
1788  }
1789  if (m_d->septrack_simple->findChild(simple)>-1||m_d->septrack_detailed->findChild(detailed)>-1) {
1790  VP1Msg::message("ERROR: AssocObjAttachmentHandle::attachNodes Already attached!");
1791  return;
1792  }
1793  }
1794  if (unpickable) {
1795  if (m_d->pickStyleChildIdx==-1) {
1796  m_d->pickStyleChildIdx = m_d->septrack_simple->getNumChildren();
1797  m_d->septrack_simple->addChild(Imp::pickStyle);
1798  m_d->septrack_detailed->addChild(Imp::pickStyle);
1799  }
1800  m_d->septrack_simple->addChild(simple);
1801  m_d->septrack_detailed->addChild(detailed);
1802  } else {
1803  if (m_d->pickStyleChildIdx>-1) {
1804  m_d->septrack_simple->insertChild(simple,m_d->pickStyleChildIdx);
1805  m_d->septrack_detailed->insertChild(detailed,m_d->pickStyleChildIdx);
1806  ++(m_d->pickStyleChildIdx);
1807  } else {
1808  m_d->septrack_simple->addChild(simple);
1809  m_d->septrack_detailed->addChild(detailed);
1810  }
1811  }
1812 
1813  //Should we update the overall attachment status?:
1814  if (m_d->trackhandle->visible() && m_d->septrack_simple->getNumChildren() == 2 + (m_d->pickStyleChildIdx==-1?0:1)) {
1815  m_d->ensureAttached();
1816  }
1817 }

◆ detachNodes()

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

Definition at line 1903 of file TrackHandleBase.cxx.

1904 {
1905  if (!m_d->trackmat)
1906  return;
1907  int isimple = m_d->septrack_simple->findChild(simple);
1908  if (VP1Msg::verbose()) {
1909  if (!simple||!detailed) {
1910  VP1Msg::messageVerbose("AssocObjAttachmentHandle::detach ERROR: Called with null pointers!");
1911  return;
1912  }
1913  if (m_d->septrack_simple->getNumChildren()!=m_d->septrack_detailed->getNumChildren()) {
1914  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes septrack_simple->getNumChildren()"
1915  "!=m_d->septrack_detailed->getNumChildren().");
1916  return;
1917  }
1920  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes detected wrong pickStyleChildIdx");
1921  return;
1922  }
1923  if (isimple==-1) {
1924  VP1Msg::message("ERROR: AssocObjAttachmentHandle::detachNodes Not previously attached!");
1925  return;
1926  }
1927  if (m_d->septrack_detailed->findChild(detailed)!=isimple) {
1928  VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes"
1929  " called with simple and detailed nodes that are not at same child idx!");
1930  return;
1931  }
1932  }
1933  m_d->septrack_simple->removeChild(simple);
1934  m_d->septrack_detailed->removeChild(detailed);
1935  if ( m_d->pickStyleChildIdx!=-1
1936  && isimple>m_d->pickStyleChildIdx
1937  && m_d->pickStyleChildIdx==m_d->septrack_simple->getNumChildren()-1 ) {
1938  VP1Msg::messageVerbose("AssocObjAttachmentHandle::detachNodes detaching pickstyle");
1939  m_d->septrack_simple->removeChild(Imp::pickStyle);
1940  m_d->septrack_detailed->removeChild(Imp::pickStyle);
1941  m_d->pickStyleChildIdx = -1;
1942  }
1943 
1944  //Should we update the overall attachment status?:
1945  if (m_d->trackhandle->visible() && m_d->septrack_simple->getNumChildren() == 1 + (m_d->pickStyleChildIdx==-1?0:1))
1946  m_d->ensureDetached();
1947 }

◆ 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 1820 of file TrackHandleBase.cxx.

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

◆ trackMaterialChanged()

void AssocObjAttachmentHandle::trackMaterialChanged ( )
private

Definition at line 1724 of file TrackHandleBase.cxx.

1725 {
1726  SoMaterial * m = m_d->trackhandle->currentMaterial();
1727  if (m_d->trackmat==m)
1728  return;
1729  if (!m) {
1730  if (m_d->trackhandle->visible())
1731  VP1Msg::message("ERROR: track is visible but has no current material!!");
1733  }
1734  m->ref();
1735  if (m_d->trackmat) {
1736  if ( m_d->septrack_simple && m_d->septrack_simple->findChild(m_d->trackmat) > -1 )
1737  m_d->septrack_simple->replaceChild(m_d->trackmat,m);
1738  if ( m_d->septrack_detailed && m_d->septrack_detailed->findChild(m_d->trackmat) > -1 )
1739  m_d->septrack_detailed->replaceChild(m_d->trackmat,m);
1740  m_d->trackmat->unref();
1741  }
1742  m_d->trackmat = m;
1743 }

◆ trackVisibilityChanged()

void AssocObjAttachmentHandle::trackVisibilityChanged ( )
private

Definition at line 1672 of file TrackHandleBase.cxx.

1673 {
1674  bool b = m_d->trackhandle->visible();
1675  if (b&&!m_d->trackhandle->currentMaterial())
1676  VP1Msg::message("ERROR: track is visible but has not current material!!");
1677  if (b)
1678  m_d->ensureAttached();
1679  else
1680  m_d->ensureDetached();
1681 }

Friends And Related Function Documentation

◆ TrackHandleBase

friend class TrackHandleBase
friend

Definition at line 203 of file TrackHandleBase.h.

◆ TrackHandleBase::Imp

friend class TrackHandleBase::Imp
friend

Definition at line 204 of file TrackHandleBase.h.

Member Data Documentation

◆ m_d

Imp* AssocObjAttachmentHandle::m_d
private

Definition at line 212 of file TrackHandleBase.h.


The documentation for this class was generated from the following files:
AssocObjAttachmentHandle::Imp::ensureInit
void ensureInit()
Definition: TrackHandleBase.cxx:1746
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
AssocObjAttachmentHandle::Imp::septrack_simple
SoSeparator * septrack_simple
Definition: TrackHandleBase.cxx:1642
AssocObjAttachmentHandle::Imp::pickStyleChildIdx
int pickStyleChildIdx
Definition: TrackHandleBase.cxx:1646
AssocObjAttachmentHandle::Imp::trackmat
SoMaterial * trackmat
Definition: TrackHandleBase.cxx:1640
AssocObjAttachmentHandle::Imp::trackhandle
TrackHandleBase * trackhandle
Definition: TrackHandleBase.cxx:1639
AssocObjAttachmentHandle::Imp::septrack_detailed
SoSeparator * septrack_detailed
Definition: TrackHandleBase.cxx:1643
python.TriggerHandler.th
th
Definition: TriggerHandler.py:296
AssocObjAttachmentHandle::attachNodes
void attachNodes(SoNode *simple, SoNode *detailed, bool unpickable)
Definition: TrackHandleBase.cxx:1768
TrackHandleBase::visible
bool visible() const
Definition: TrackHandleBase.h:67
AssocObjAttachmentHandle::Imp::pickStyle
static SoPickStyle * pickStyle
Definition: TrackHandleBase.cxx:1645
TrackHandleBase::currentMaterial
SoMaterial * currentMaterial() const
Definition: TrackHandleBase.h:76
AssocObjAttachmentHandle::m_d
Imp * m_d
Definition: TrackHandleBase.h:211
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:1666
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:1657
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
AssocObjAttachmentHandle::Imp::ensureAttached
void ensureAttached()
Definition: TrackHandleBase.cxx:1648