ATLAS Offline Software
Loading...
Searching...
No Matches
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.
void detachNodes (SoNode *simple, SoNode *detailed)

Private Member Functions

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

Private Attributes

Imp * m_d

Friends

class TrackHandleBase
class TrackHandleBase::Imp

Detailed Description

Definition at line 203 of file TrackHandleBase.h.

Constructor & Destructor Documentation

◆ AssocObjAttachmentHandle() [1/2]

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

Definition at line 1699 of file TrackHandleBase.cxx.

1700 : m_d ( new Imp(tlh,th) )
1701{
1702 if (!tlh)
1703 VP1Msg::message("AssocObjAttachmentHandle ERROR: constructed with null LOD handle!");
1704 if (!Imp::dummymaterial) {
1705 Imp::dummymaterial = new SoMaterial;
1706 Imp::dummymaterial->ref();
1707 }
1708}
friend class TrackHandleBase::Imp
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30

◆ ~AssocObjAttachmentHandle()

AssocObjAttachmentHandle::~AssocObjAttachmentHandle ( )
private

Definition at line 1711 of file TrackHandleBase.cxx.

1712{
1713 if (VP1Msg::verbose()) {
1714 if ((m_d->septrack_detailed && m_d->pickStyleChildIdx != m_d->septrack_detailed->findChild(Imp::pickStyle))
1715 ||(m_d->septrack_simple&&m_d->pickStyleChildIdx != m_d->septrack_simple->findChild(Imp::pickStyle))) {
1716 VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes detected wrong pickStyleChildIdx");
1717 return;
1718 }
1719 }
1720
1721 if (Imp::pickStyle) {
1722 Imp::pickStyle->unref();
1723 if ( Imp::pickStyle->getRefCount()==1 ) {
1724 Imp::pickStyle->unref();
1725 Imp::pickStyle = nullptr;
1726 }
1727 }
1728
1729 if (m_d->septrack_simple)
1730 m_d->septrack_simple->unref();
1731 if (m_d->septrack_detailed)
1732 m_d->septrack_detailed->unref();
1733 if (m_d->trackmat)
1734 m_d->trackmat->unref();
1735 delete m_d;
1736}
static bool verbose()
Definition VP1Msg.h:31

◆ AssocObjAttachmentHandle() [2/2]

AssocObjAttachmentHandle::AssocObjAttachmentHandle ( const AssocObjAttachmentHandle & )
private

Member Function Documentation

◆ attachNodes()

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

Definition at line 1783 of file TrackHandleBase.cxx.

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

◆ detachNodes()

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

Definition at line 1918 of file TrackHandleBase.cxx.

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

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

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

◆ trackMaterialChanged()

void AssocObjAttachmentHandle::trackMaterialChanged ( )
private

Definition at line 1739 of file TrackHandleBase.cxx.

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

◆ trackVisibilityChanged()

void AssocObjAttachmentHandle::trackVisibilityChanged ( )
private

Definition at line 1687 of file TrackHandleBase.cxx.

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

◆ TrackHandleBase

friend class TrackHandleBase
friend

Definition at line 209 of file TrackHandleBase.h.

◆ TrackHandleBase::Imp

friend class TrackHandleBase::Imp
friend

Definition at line 210 of file TrackHandleBase.h.

Member Data Documentation

◆ m_d

Imp* AssocObjAttachmentHandle::m_d
private

Definition at line 218 of file TrackHandleBase.h.


The documentation for this class was generated from the following files: