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 &)
AssocObjAttachmentHandleoperator= (const AssocObjAttachmentHandle &)
void trackMaterialChanged ()
void trackVisibilityChanged ()

Private Attributes

Impm_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 1700 of file TrackHandleBase.cxx.

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

◆ ~AssocObjAttachmentHandle()

AssocObjAttachmentHandle::~AssocObjAttachmentHandle ( )
private

Definition at line 1712 of file TrackHandleBase.cxx.

1713{
1714 if (VP1Msg::verbose()) {
1715 if ((m_d->septrack_detailed && m_d->pickStyleChildIdx != m_d->septrack_detailed->findChild(Imp::pickStyle))
1716 ||(m_d->septrack_simple&&m_d->pickStyleChildIdx != m_d->septrack_simple->findChild(Imp::pickStyle))) {
1717 VP1Msg::message("ERROR: AssocObjAttachmentHandle::setPickableStateOfNodes detected wrong pickStyleChildIdx");
1718 return;
1719 }
1720 }
1721
1722 if (Imp::pickStyle) {
1723 Imp::pickStyle->unref();
1724 if ( Imp::pickStyle->getRefCount()==1 ) {
1725 Imp::pickStyle->unref();
1726 Imp::pickStyle = nullptr;
1727 }
1728 }
1729
1730 if (m_d->septrack_simple)
1731 m_d->septrack_simple->unref();
1732 if (m_d->septrack_detailed)
1733 m_d->septrack_detailed->unref();
1734 if (m_d->trackmat)
1735 m_d->trackmat->unref();
1736 delete m_d;
1737}
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 1784 of file TrackHandleBase.cxx.

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

◆ detachNodes()

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

Definition at line 1919 of file TrackHandleBase.cxx.

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

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

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

◆ trackVisibilityChanged()

void AssocObjAttachmentHandle::trackVisibilityChanged ( )
private

Definition at line 1688 of file TrackHandleBase.cxx.

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

◆ 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: