<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: acctable.hxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 02:56:00 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _ACCTABLE_HXX
#define _ACCTABLE_HXX
#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETABLE_HPP_
#include <com/sun/star/accessibility/XAccessibleTable.hpp>
#endif

#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESELECTION_HPP_
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#endif

#ifndef _ACCCONTEXT_HXX
#include "acccontext.hxx"
#endif

#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
#include <com/sun/star/uno/RuntimeException.hpp>
#endif

class SwTabFrm;
class SwAccessibleTableData_Impl;
class SwAccessibleTableEventList_Impl;
class SwTableBox;

class SwAccessibleTable :
        public SwAccessibleContext,
        public ::com::sun::star::accessibility::XAccessibleTable,
        public ::com::sun::star::accessibility::XAccessibleSelection,
        public SwClient
{
    SwAccessibleTableData_Impl *mpTableData;    // the table's data, prot by Sol-Mutex
    ::rtl::OUString sDesc;
    const SwSelBoxes *GetSelBoxes() const;

    void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );

    /** get the SwTableBox* for the given child */
    const SwTableBox* GetTableBox( sal_Int32 ) const;

    sal_Bool IsChildSelected( sal_Int32 nChildIndex ) const;

    sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;

protected:

    // Set states for getAccessibleStateSet.
    // This drived class additinaly sets MULTISELECTABLE(+)
    virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet );

    virtual ~SwAccessibleTable();

    // force update of table data
    void UpdateTableData();

    // remove the current table data
    void ClearTableData();

    // get table data, update if necessary
    inline SwAccessibleTableData_Impl& GetTableData();

    // Is table data evailable?
    sal_Bool HasTableData() const { return (mpTableData != 0); }

public:

    SwAccessibleTable( SwAccessibleMap *pMap, const SwTabFrm *pTableFrm );

    virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew);

    //=====  XInterface  ======================================================

    // (XInterface methods need to be implemented to disambigouate
    // between those inherited through SwAcessibleContext and
    // XAccessibleTable).

    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
        const ::com::sun::star::uno::Type& aType )
        throw (::com::sun::star::uno::RuntimeException);

    virtual void SAL_CALL acquire(  ) throw ()
        { SwAccessibleContext::acquire(); };

    virtual void SAL_CALL release(  ) throw ()
        { SwAccessibleContext::release(); };

    //====== XTypeProvider ====================================================
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);

    //=====  XAccessibleContext  ==============================================

    /// Return this object's description.
    virtual ::rtl::OUString SAL_CALL
        getAccessibleDescription (void)
        throw (com::sun::star::uno::RuntimeException);

    //=====  XAccessibleTable  ================================================

    virtual sal_Int32 SAL_CALL getAccessibleRowCount()
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumnCount(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription(
            sal_Int32 nRow )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription(
            sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
               sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::accessibility::XAccessibleTable >
        SAL_CALL getAccessibleRowHeaders(  )
           throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::accessibility::XAccessibleTable >
        SAL_CALL getAccessibleColumnHeaders(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
        getSelectedAccessibleRows(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
        getSelectedAccessibleColumns(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleCaption(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleSummary(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleSelected(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleIndex(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);

    //=====  XServiceInfo  ====================================================

    /** Returns an identifier for the implementation of this object.
    */
    virtual ::rtl::OUString SAL_CALL
        getImplementationName (void)
        throw (::com::sun::star::uno::RuntimeException);

    /** Return whether the specified service is supported by this class.
    */
    virtual sal_Bool SAL_CALL
        supportsService (const ::rtl::OUString& sServiceName)
        throw (::com::sun::star::uno::RuntimeException);

    /** Returns a list of all supported services.  In this case that is just
        the AccessibleContext service.
    */
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
        getSupportedServiceNames (void)
        throw (::com::sun::star::uno::RuntimeException);

    //===== C++ interface ======================================================

    // The object has been moved by the layout
    virtual void InvalidatePosOrSize( const SwRect& rOldBox );

    // The object is not visible an longer and should be destroyed
    virtual void Dispose( sal_Bool bRecursive = sal_False );

    virtual void DisposeChild( const SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive );
    virtual void InvalidateChildPosOrSize( const SwFrmOrObj& rFrmOrObj,
                                        const SwRect& rFrm );

    //=====  XAccessibleSelection  ============================================

    virtual void SAL_CALL selectAccessibleChild(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

    virtual sal_Bool SAL_CALL isAccessibleChildSelected(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

    virtual void SAL_CALL clearAccessibleSelection(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual void SAL_CALL selectAllAccessibleChildren(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
        sal_Int32 nSelectedChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);

    // --> OD 2004-11-16 #111714# - index has to be treated as global child index.
    virtual void SAL_CALL deselectAccessibleChild(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

};

inline SwAccessibleTableData_Impl& SwAccessibleTable::GetTableData()
{
    if( !mpTableData )
        UpdateTableData();
    return *mpTableData;
}

#endif

<commit_msg>INTEGRATION: CWS writercorehandoff (1.13.278); FILE MERGED 2005/09/13 13:03:04 tra 1.13.278.3: RESYNC: (1.13-1.14); FILE MERGED 2005/06/07 14:13:08 fme 1.13.278.2: #i50348# General cleanup - removed unused header files, functions, members, declarations etc. 2005/06/06 09:26:49 tra 1.13.278.1: Unnecessary includes removed #i50348#<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: acctable.hxx,v $
 *
 *  $Revision: 1.15 $
 *
 *  last change: $Author: hr $ $Date: 2006-08-14 15:47:22 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _ACCTABLE_HXX
#define _ACCTABLE_HXX
#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETABLE_HPP_
#include <com/sun/star/accessibility/XAccessibleTable.hpp>
#endif
#ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESELECTION_HPP_
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#endif

#ifndef _ACCCONTEXT_HXX
#include "acccontext.hxx"
#endif

class SwTabFrm;
class SwAccessibleTableData_Impl;
class SwTableBox;

class SwAccessibleTable :
        public SwAccessibleContext,
        public ::com::sun::star::accessibility::XAccessibleTable,
        public ::com::sun::star::accessibility::XAccessibleSelection,
        public SwClient
{
    SwAccessibleTableData_Impl *mpTableData;    // the table's data, prot by Sol-Mutex
    ::rtl::OUString sDesc;
    const SwSelBoxes *GetSelBoxes() const;

    void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );

    /** get the SwTableBox* for the given child */
    const SwTableBox* GetTableBox( sal_Int32 ) const;

    sal_Bool IsChildSelected( sal_Int32 nChildIndex ) const;

    sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;

protected:

    // Set states for getAccessibleStateSet.
    // This drived class additinaly sets MULTISELECTABLE(+)
    virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet );

    virtual ~SwAccessibleTable();

    // force update of table data
    void UpdateTableData();

    // remove the current table data
    void ClearTableData();

    // get table data, update if necessary
    inline SwAccessibleTableData_Impl& GetTableData();

    // Is table data evailable?
    sal_Bool HasTableData() const { return (mpTableData != 0); }

public:

    SwAccessibleTable( SwAccessibleMap *pMap, const SwTabFrm *pTableFrm );

    virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew);

    //=====  XInterface  ======================================================

    // (XInterface methods need to be implemented to disambigouate
    // between those inherited through SwAcessibleContext and
    // XAccessibleTable).

    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
        const ::com::sun::star::uno::Type& aType )
        throw (::com::sun::star::uno::RuntimeException);

    virtual void SAL_CALL acquire(  ) throw ()
        { SwAccessibleContext::acquire(); };

    virtual void SAL_CALL release(  ) throw ()
        { SwAccessibleContext::release(); };

    //====== XTypeProvider ====================================================
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);

    //=====  XAccessibleContext  ==============================================

    /// Return this object's description.
    virtual ::rtl::OUString SAL_CALL
        getAccessibleDescription (void)
        throw (com::sun::star::uno::RuntimeException);

    //=====  XAccessibleTable  ================================================

    virtual sal_Int32 SAL_CALL getAccessibleRowCount()
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumnCount(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription(
            sal_Int32 nRow )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription(
            sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
               sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::accessibility::XAccessibleTable >
        SAL_CALL getAccessibleRowHeaders(  )
           throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
                ::com::sun::star::accessibility::XAccessibleTable >
        SAL_CALL getAccessibleColumnHeaders(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
        getSelectedAccessibleRows(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
        getSelectedAccessibleColumns(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleCaption(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference<
        ::com::sun::star::accessibility::XAccessible > SAL_CALL
        getAccessibleSummary(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL isAccessibleSelected(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleIndex(
            sal_Int32 nRow, sal_Int32 nColumn )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
        throw (::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);

    //=====  XServiceInfo  ====================================================

    /** Returns an identifier for the implementation of this object.
    */
    virtual ::rtl::OUString SAL_CALL
        getImplementationName (void)
        throw (::com::sun::star::uno::RuntimeException);

    /** Return whether the specified service is supported by this class.
    */
    virtual sal_Bool SAL_CALL
        supportsService (const ::rtl::OUString& sServiceName)
        throw (::com::sun::star::uno::RuntimeException);

    /** Returns a list of all supported services.  In this case that is just
        the AccessibleContext service.
    */
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
        getSupportedServiceNames (void)
        throw (::com::sun::star::uno::RuntimeException);

    //===== C++ interface ======================================================

    // The object has been moved by the layout
    virtual void InvalidatePosOrSize( const SwRect& rOldBox );

    // The object is not visible an longer and should be destroyed
    virtual void Dispose( sal_Bool bRecursive = sal_False );

    virtual void DisposeChild( const SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive );
    virtual void InvalidateChildPosOrSize( const SwFrmOrObj& rFrmOrObj,
                                        const SwRect& rFrm );

    //=====  XAccessibleSelection  ============================================

    virtual void SAL_CALL selectAccessibleChild(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

    virtual sal_Bool SAL_CALL isAccessibleChildSelected(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

    virtual void SAL_CALL clearAccessibleSelection(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual void SAL_CALL selectAllAccessibleChildren(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  )
        throw ( ::com::sun::star::uno::RuntimeException );

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
        sal_Int32 nSelectedChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException);

    // --> OD 2004-11-16 #111714# - index has to be treated as global child index.
    virtual void SAL_CALL deselectAccessibleChild(
        sal_Int32 nChildIndex )
        throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
                ::com::sun::star::uno::RuntimeException );

};

inline SwAccessibleTableData_Impl& SwAccessibleTable::GetTableData()
{
    if( !mpTableData )
        UpdateTableData();
    return *mpTableData;
}

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: flyincnt.cxx,v $
 *
 *  $Revision: 1.17 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-16 21:18:31 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#include "cntfrm.hxx"
#include "doc.hxx"
#include "flyfrm.hxx"
#include "frmtool.hxx"
#include "frmfmt.hxx"
#include "hints.hxx"

#ifndef _FMTORNT_HXX //autogen
#include <fmtornt.hxx>
#endif
#ifndef _FMTFSIZE_HXX //autogen
#include <fmtfsize.hxx>
#endif
#include "txtfrm.hxx"       //fuer IsLocked()
#include "flyfrms.hxx"
// OD 2004-01-19 #110582#
#ifndef _DFLYOBJ_HXX
#include <dflyobj.hxx>
#endif

//aus FlyCnt.cxx
void DeepCalc( const SwFrm *pFrm );

/*************************************************************************
|*
|*  SwFlyInCntFrm::SwFlyInCntFrm(), ~SwFlyInCntFrm()
|*
|*  Ersterstellung      MA 01. Dec. 92
|*  Letzte Aenderung    MA 09. Apr. 99
|*
|*************************************************************************/
SwFlyInCntFrm::SwFlyInCntFrm( SwFlyFrmFmt *pFmt, SwFrm *pAnch ) :
    SwFlyFrm( pFmt, pAnch )
{
    bInCnt = bInvalidLayout = bInvalidCntnt = TRUE;
    SwTwips nRel = pFmt->GetVertOrient().GetPos();
    // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
    Point aRelPos;
    if( pAnch && pAnch->IsVertical() )
        aRelPos.X() = pAnch->IsReverse() ? nRel : -nRel;
    else
        aRelPos.Y() = nRel;
    SetCurrRelPos( aRelPos );
}

SwFlyInCntFrm::~SwFlyInCntFrm()
{
    //und Tschuess.
    if ( !GetFmt()->GetDoc()->IsInDtor() && GetAnchorFrm() )
    {
        SwRect aTmp( GetObjRectWithSpaces() );
        SwFlyInCntFrm::NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_LEAVE );
    }
}

// --> OD 2004-06-29 #i28701#
TYPEINIT1(SwFlyInCntFrm,SwFlyFrm);
// <--
/*************************************************************************
|*
|*  SwFlyInCntFrm::SetRefPoint(),
|*
|*  Ersterstellung      MA 01. Dec. 92
|*  Letzte Aenderung    MA 06. Aug. 95
|*
|*************************************************************************/
void SwFlyInCntFrm::SetRefPoint( const Point& rPoint,
                                 const Point& rRelAttr,
                                 const Point& rRelPos )
{
    // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
    ASSERT( rPoint != aRef || rRelAttr != GetCurrRelPos(), "SetRefPoint: no change" );
    SwFlyNotify *pNotify = NULL;
    // No notify at a locked fly frame, if a fly frame is locked, there's
    // already a SwFlyNotify object on the stack (MakeAll).
    if( !IsLocked() )
        pNotify = new SwFlyNotify( this );
    aRef = rPoint;
    SetCurrRelPos( rRelAttr );
    SWRECTFN( GetAnchorFrm() )
    (Frm().*fnRect->fnSetPos)( rPoint + rRelPos );
    // --> OD 2006-08-25 #i68520#
    InvalidateObjRectWithSpaces();
    // <--
    if( pNotify )
    {
        InvalidatePage();
        bValidPos = FALSE;
        bInvalid  = TRUE;
        Calc();
        delete pNotify;
    }
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::Modify()
|*
|*  Ersterstellung      MA 16. Dec. 92
|*  Letzte Aenderung    MA 02. Sep. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
{
    BOOL bCallPrepare = FALSE;
    USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
    if( RES_ATTRSET_CHG == nWhich )
    {
        if( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
            GetItemState( RES_SURROUND, FALSE ) ||
            SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
            GetItemState( RES_FRMMACRO, FALSE ) )
        {
            SwAttrSetChg aOld( *(SwAttrSetChg*)pOld );
            SwAttrSetChg aNew( *(SwAttrSetChg*)pNew );

            aOld.ClearItem( RES_SURROUND );
            aNew.ClearItem( RES_SURROUND );
            aOld.ClearItem( RES_FRMMACRO );
            aNew.ClearItem( RES_FRMMACRO );
            if( aNew.Count() )
            {
                SwFlyFrm::Modify( &aOld, &aNew );
                bCallPrepare = TRUE;
            }
        }
        else if( ((SwAttrSetChg*)pNew)->GetChgSet()->Count())
        {
            SwFlyFrm::Modify( pOld, pNew );
            bCallPrepare = TRUE;
        }
    }
    else if( nWhich != RES_SURROUND && RES_FRMMACRO != nWhich )
    {
        SwFlyFrm::Modify( pOld, pNew );
        bCallPrepare = TRUE;
    }

    if ( bCallPrepare && GetAnchorFrm() )
        AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, GetFmt() );
}
/*************************************************************************
|*
|*  SwFlyInCntFrm::Format()
|*
|*  Beschreibung:       Hier wird der Inhalt initial mit Formatiert.
|*  Ersterstellung      MA 16. Dec. 92
|*  Letzte Aenderung    MA 19. May. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::Format( const SwBorderAttrs *pAttrs )
{
    if ( !Frm().Height() )
    {
        Lock(); //nicht hintenherum den Anker formatieren.
        SwCntntFrm *pCntnt = ContainsCntnt();
        while ( pCntnt )
        {   pCntnt->Calc();
            pCntnt = pCntnt->GetNextCntntFrm();
        }
        Unlock();
    }
    SwFlyFrm::Format( pAttrs );
}
/*************************************************************************
|*
|*  SwFlyInCntFrm::MakeFlyPos()
|*
|*  Beschreibung        Im Unterschied zu anderen Frms wird hier nur die
|*      die RelPos berechnet. Die absolute Position wird ausschliesslich
|*      per SetAbsPos errechnet.
|*  Ersterstellung      MA 03. Dec. 92
|*  Letzte Aenderung    MA 12. Apr. 96
|*
|*************************************************************************/
// OD 2004-03-23 #i26791#
//void SwFlyInCntFrm::MakeFlyPos()
void SwFlyInCntFrm::MakeObjPos()
{
    if ( !bValidPos )
    {
        // --> OD 2004-08-12 #i32795# - calling methods <::DeepCalc(..)> and
        // <GetAnchorFrm()->GetFormatted()> no longer needed due to the changed
        // formatting of floating screen objects. It also causes layout loops.
//        if ( !GetAnchorFrm()->IsTxtFrm() || !((SwTxtFrm*)GetAnchorFrm())->IsLocked() )
//            ::DeepCalc( GetAnchorFrm() );
//        if( GetAnchorFrm()->IsTxtFrm() )
//            ((SwTxtFrm*)GetAnchorFrm())->GetFormatted();
        // <--
        bValidPos = TRUE;
        SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)GetFmt();
        const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
        //Und ggf. noch die aktuellen Werte im Format updaten, dabei darf
        //zu diesem Zeitpunkt natuerlich kein Modify verschickt werden.
        SWRECTFN( GetAnchorFrm() )
        SwTwips nOld = rVert.GetPos();
        SwTwips nAct = bVert ? -GetCurrRelPos().X() : GetCurrRelPos().Y();
        if( bRev )
            nAct = -nAct;
        if( nAct != nOld )
        {
            SwFmtVertOrient aVert( rVert );
            aVert.SetPos( nAct );
            pFmt->LockModify();
            pFmt->SetAttr( aVert );
            pFmt->UnlockModify();
        }
    }
}

// --> OD 2004-12-02 #115759#
void SwFlyInCntFrm::_ActionOnInvalidation( const InvalidationType _nInvalid )
{
    switch ( _nInvalid )
    {
        case INVALID_POS:
        case INVALID_ALL:
        {
            AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, &GetFrmFmt() );
        }
        break;
    }
}
// <--
/*************************************************************************
|*
|*  SwFlyInCntFrm::NotifyBackground()
|*
|*  Ersterstellung      MA 03. Dec. 92
|*  Letzte Aenderung    MA 26. Aug. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::NotifyBackground( SwPageFrm *, const SwRect& rRect,
                                       PrepareHint eHint)
{
    if ( eHint == PREP_FLY_ATTR_CHG )
        AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG );
    else
        AnchorFrm()->Prepare( eHint, (void*)&rRect );
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::GetRelPos()
|*
|*  Ersterstellung      MA 04. Dec. 92
|*  Letzte Aenderung    MA 04. Dec. 92
|*
|*************************************************************************/
const Point SwFlyInCntFrm::GetRelPos() const
{
    Calc();
    return GetCurrRelPos();
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::RegistFlys()
|*
|*  Ersterstellung      MA 26. Nov. 93
|*  Letzte Aenderung    MA 26. Nov. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::RegistFlys()
{
    // vgl. SwRowFrm::RegistFlys()
    SwPageFrm *pPage = FindPageFrm();
    ASSERT( pPage, "Flys ohne Seite anmelden?" );
    ::RegistFlys( pPage, this );
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::MakeAll()
|*
|*  Ersterstellung      MA 18. Feb. 94
|*  Letzte Aenderung    MA 13. Jun. 96
|*
|*************************************************************************/
void SwFlyInCntFrm::MakeAll()
{
    // OD 2004-01-19 #110582#
    if ( !GetFmt()->GetDoc()->IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
    {
        return;
    }

    if ( !GetAnchorFrm() || IsLocked() || IsColLocked() || !FindPageFrm() )
        return;

    Lock(); //Der Vorhang faellt

        //uebernimmt im DTor die Benachrichtigung
    const SwFlyNotify aNotify( this );
    SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
    const SwBorderAttrs &rAttrs = *aAccess.Get();

    if ( IsClipped() )
        bValidSize = bHeightClipped = bWidthClipped = FALSE;

    while ( !bValidPos || !bValidSize || !bValidPrtArea )
    {
        //Nur einstellen wenn das Flag gesetzt ist!!
        if ( !bValidSize )
        {
            bValidPrtArea = FALSE;
/*
            // This is also done in the Format function, so I think
            // this code is not necessary anymore:
            long nOldWidth = aFrm.Width();
            const Size aRelSize( CalcRel( rFrmSz ) );
            aFrm.Width( aRelSize.Width() );

            if ( aFrm.Width() > nOldWidth )
                //Damit sich der Inhalt anpasst
                aFrm.Height( aRelSize.Height() );
*/
        }

        if ( !bValidPrtArea )
            MakePrtArea( rAttrs );

        if ( !bValidSize )
            Format( &rAttrs );

        if ( !bValidPos )
        {
            // OD 2004-03-23 #i26791#
            //MakeFlyPos();
            MakeObjPos();
        }

        // --> OD 2006-04-13 #b6402800#
        // re-activate clipping of as-character anchored Writer fly frames
        // depending on compatibility option <ClipAsCharacterAnchoredWriterFlyFrames>
        if ( bValidPos && bValidSize &&
             GetFmt()->getIDocumentSettingAccess()->get( IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME ) )
        {
            SwFrm* pFrm = AnchorFrm();
            if ( Frm().Left() == (pFrm->Frm().Left()+pFrm->Prt().Left()) &&
                 Frm().Width() > pFrm->Prt().Width() )
            {
                Frm().Width( pFrm->Prt().Width() );
                bValidPrtArea = FALSE;
                bWidthClipped = TRUE;
            }
        }
        // <--
    }
    Unlock();
}
<commit_msg>INTEGRATION: CWS swwarnings (1.17.222); FILE MERGED 2007/03/08 08:23:46 fme 1.17.222.1: #i69287# Warning free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: flyincnt.cxx,v $
 *
 *  $Revision: 1.18 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 09:02:35 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#include "cntfrm.hxx"
#include "doc.hxx"
#include "flyfrm.hxx"
#include "frmtool.hxx"
#include "frmfmt.hxx"
#include "hints.hxx"

#ifndef _FMTORNT_HXX //autogen
#include <fmtornt.hxx>
#endif
#ifndef _FMTFSIZE_HXX //autogen
#include <fmtfsize.hxx>
#endif
#include "txtfrm.hxx"       //fuer IsLocked()
#include "flyfrms.hxx"
// OD 2004-01-19 #110582#
#ifndef _DFLYOBJ_HXX
#include <dflyobj.hxx>
#endif

//aus FlyCnt.cxx
void DeepCalc( const SwFrm *pFrm );

/*************************************************************************
|*
|*  SwFlyInCntFrm::SwFlyInCntFrm(), ~SwFlyInCntFrm()
|*
|*  Ersterstellung      MA 01. Dec. 92
|*  Letzte Aenderung    MA 09. Apr. 99
|*
|*************************************************************************/
SwFlyInCntFrm::SwFlyInCntFrm( SwFlyFrmFmt *pFmt, SwFrm *pAnch ) :
    SwFlyFrm( pFmt, pAnch )
{
    bInCnt = bInvalidLayout = bInvalidCntnt = TRUE;
    SwTwips nRel = pFmt->GetVertOrient().GetPos();
    // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
    Point aRelPos;
    if( pAnch && pAnch->IsVertical() )
        aRelPos.X() = pAnch->IsReverse() ? nRel : -nRel;
    else
        aRelPos.Y() = nRel;
    SetCurrRelPos( aRelPos );
}

SwFlyInCntFrm::~SwFlyInCntFrm()
{
    //und Tschuess.
    if ( !GetFmt()->GetDoc()->IsInDtor() && GetAnchorFrm() )
    {
        SwRect aTmp( GetObjRectWithSpaces() );
        SwFlyInCntFrm::NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_LEAVE );
    }
}

// --> OD 2004-06-29 #i28701#
TYPEINIT1(SwFlyInCntFrm,SwFlyFrm);
// <--
/*************************************************************************
|*
|*  SwFlyInCntFrm::SetRefPoint(),
|*
|*  Ersterstellung      MA 01. Dec. 92
|*  Letzte Aenderung    MA 06. Aug. 95
|*
|*************************************************************************/
void SwFlyInCntFrm::SetRefPoint( const Point& rPoint,
                                 const Point& rRelAttr,
                                 const Point& rRelPos )
{
    // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
    ASSERT( rPoint != aRef || rRelAttr != GetCurrRelPos(), "SetRefPoint: no change" );
    SwFlyNotify *pNotify = NULL;
    // No notify at a locked fly frame, if a fly frame is locked, there's
    // already a SwFlyNotify object on the stack (MakeAll).
    if( !IsLocked() )
        pNotify = new SwFlyNotify( this );
    aRef = rPoint;
    SetCurrRelPos( rRelAttr );
    SWRECTFN( GetAnchorFrm() )
    (Frm().*fnRect->fnSetPos)( rPoint + rRelPos );
    // --> OD 2006-08-25 #i68520#
    InvalidateObjRectWithSpaces();
    // <--
    if( pNotify )
    {
        InvalidatePage();
        bValidPos = FALSE;
        bInvalid  = TRUE;
        Calc();
        delete pNotify;
    }
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::Modify()
|*
|*  Ersterstellung      MA 16. Dec. 92
|*  Letzte Aenderung    MA 02. Sep. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
{
    BOOL bCallPrepare = FALSE;
    USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
    if( RES_ATTRSET_CHG == nWhich )
    {
        if( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
            GetItemState( RES_SURROUND, FALSE ) ||
            SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
            GetItemState( RES_FRMMACRO, FALSE ) )
        {
            SwAttrSetChg aOld( *(SwAttrSetChg*)pOld );
            SwAttrSetChg aNew( *(SwAttrSetChg*)pNew );

            aOld.ClearItem( RES_SURROUND );
            aNew.ClearItem( RES_SURROUND );
            aOld.ClearItem( RES_FRMMACRO );
            aNew.ClearItem( RES_FRMMACRO );
            if( aNew.Count() )
            {
                SwFlyFrm::Modify( &aOld, &aNew );
                bCallPrepare = TRUE;
            }
        }
        else if( ((SwAttrSetChg*)pNew)->GetChgSet()->Count())
        {
            SwFlyFrm::Modify( pOld, pNew );
            bCallPrepare = TRUE;
        }
    }
    else if( nWhich != RES_SURROUND && RES_FRMMACRO != nWhich )
    {
        SwFlyFrm::Modify( pOld, pNew );
        bCallPrepare = TRUE;
    }

    if ( bCallPrepare && GetAnchorFrm() )
        AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, GetFmt() );
}
/*************************************************************************
|*
|*  SwFlyInCntFrm::Format()
|*
|*  Beschreibung:       Hier wird der Inhalt initial mit Formatiert.
|*  Ersterstellung      MA 16. Dec. 92
|*  Letzte Aenderung    MA 19. May. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::Format( const SwBorderAttrs *pAttrs )
{
    if ( !Frm().Height() )
    {
        Lock(); //nicht hintenherum den Anker formatieren.
        SwCntntFrm *pCntnt = ContainsCntnt();
        while ( pCntnt )
        {   pCntnt->Calc();
            pCntnt = pCntnt->GetNextCntntFrm();
        }
        Unlock();
    }
    SwFlyFrm::Format( pAttrs );
}
/*************************************************************************
|*
|*  SwFlyInCntFrm::MakeFlyPos()
|*
|*  Beschreibung        Im Unterschied zu anderen Frms wird hier nur die
|*      die RelPos berechnet. Die absolute Position wird ausschliesslich
|*      per SetAbsPos errechnet.
|*  Ersterstellung      MA 03. Dec. 92
|*  Letzte Aenderung    MA 12. Apr. 96
|*
|*************************************************************************/
// OD 2004-03-23 #i26791#
//void SwFlyInCntFrm::MakeFlyPos()
void SwFlyInCntFrm::MakeObjPos()
{
    if ( !bValidPos )
    {
        // --> OD 2004-08-12 #i32795# - calling methods <::DeepCalc(..)> and
        // <GetAnchorFrm()->GetFormatted()> no longer needed due to the changed
        // formatting of floating screen objects. It also causes layout loops.
//        if ( !GetAnchorFrm()->IsTxtFrm() || !((SwTxtFrm*)GetAnchorFrm())->IsLocked() )
//            ::DeepCalc( GetAnchorFrm() );
//        if( GetAnchorFrm()->IsTxtFrm() )
//            ((SwTxtFrm*)GetAnchorFrm())->GetFormatted();
        // <--
        bValidPos = TRUE;
        SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)GetFmt();
        const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
        //Und ggf. noch die aktuellen Werte im Format updaten, dabei darf
        //zu diesem Zeitpunkt natuerlich kein Modify verschickt werden.
        const bool bVert = GetAnchorFrm()->IsVertical();
        const bool bRev = GetAnchorFrm()->IsReverse();
        SwTwips nOld = rVert.GetPos();
        SwTwips nAct = bVert ? -GetCurrRelPos().X() : GetCurrRelPos().Y();
        if( bRev )
            nAct = -nAct;
        if( nAct != nOld )
        {
            SwFmtVertOrient aVert( rVert );
            aVert.SetPos( nAct );
            pFmt->LockModify();
            pFmt->SetAttr( aVert );
            pFmt->UnlockModify();
        }
    }
}

// --> OD 2004-12-02 #115759#
void SwFlyInCntFrm::_ActionOnInvalidation( const InvalidationType _nInvalid )
{
    if ( INVALID_POS == _nInvalid || INVALID_ALL == _nInvalid )
        AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, &GetFrmFmt() );
}
// <--
/*************************************************************************
|*
|*  SwFlyInCntFrm::NotifyBackground()
|*
|*  Ersterstellung      MA 03. Dec. 92
|*  Letzte Aenderung    MA 26. Aug. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::NotifyBackground( SwPageFrm *, const SwRect& rRect,
                                       PrepareHint eHint)
{
    if ( eHint == PREP_FLY_ATTR_CHG )
        AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG );
    else
        AnchorFrm()->Prepare( eHint, (void*)&rRect );
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::GetRelPos()
|*
|*  Ersterstellung      MA 04. Dec. 92
|*  Letzte Aenderung    MA 04. Dec. 92
|*
|*************************************************************************/
const Point SwFlyInCntFrm::GetRelPos() const
{
    Calc();
    return GetCurrRelPos();
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::RegistFlys()
|*
|*  Ersterstellung      MA 26. Nov. 93
|*  Letzte Aenderung    MA 26. Nov. 93
|*
|*************************************************************************/
void SwFlyInCntFrm::RegistFlys()
{
    // vgl. SwRowFrm::RegistFlys()
    SwPageFrm *pPage = FindPageFrm();
    ASSERT( pPage, "Flys ohne Seite anmelden?" );
    ::RegistFlys( pPage, this );
}

/*************************************************************************
|*
|*  SwFlyInCntFrm::MakeAll()
|*
|*  Ersterstellung      MA 18. Feb. 94
|*  Letzte Aenderung    MA 13. Jun. 96
|*
|*************************************************************************/
void SwFlyInCntFrm::MakeAll()
{
    // OD 2004-01-19 #110582#
    if ( !GetFmt()->GetDoc()->IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
    {
        return;
    }

    if ( !GetAnchorFrm() || IsLocked() || IsColLocked() || !FindPageFrm() )
        return;

    Lock(); //Der Vorhang faellt

        //uebernimmt im DTor die Benachrichtigung
    const SwFlyNotify aNotify( this );
    SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
    const SwBorderAttrs &rAttrs = *aAccess.Get();

    if ( IsClipped() )
        bValidSize = bHeightClipped = bWidthClipped = FALSE;

    while ( !bValidPos || !bValidSize || !bValidPrtArea )
    {
        //Nur einstellen wenn das Flag gesetzt ist!!
        if ( !bValidSize )
        {
            bValidPrtArea = FALSE;
/*
            // This is also done in the Format function, so I think
            // this code is not necessary anymore:
            long nOldWidth = aFrm.Width();
            const Size aRelSize( CalcRel( rFrmSz ) );
            aFrm.Width( aRelSize.Width() );

            if ( aFrm.Width() > nOldWidth )
                //Damit sich der Inhalt anpasst
                aFrm.Height( aRelSize.Height() );
*/
        }

        if ( !bValidPrtArea )
            MakePrtArea( rAttrs );

        if ( !bValidSize )
            Format( &rAttrs );

        if ( !bValidPos )
        {
            // OD 2004-03-23 #i26791#
            //MakeFlyPos();
            MakeObjPos();
        }

        // --> OD 2006-04-13 #b6402800#
        // re-activate clipping of as-character anchored Writer fly frames
        // depending on compatibility option <ClipAsCharacterAnchoredWriterFlyFrames>
        if ( bValidPos && bValidSize &&
             GetFmt()->getIDocumentSettingAccess()->get( IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME ) )
        {
            SwFrm* pFrm = AnchorFrm();
            if ( Frm().Left() == (pFrm->Frm().Left()+pFrm->Prt().Left()) &&
                 Frm().Width() > pFrm->Prt().Width() )
            {
                Frm().Width( pFrm->Prt().Width() );
                bValidPrtArea = FALSE;
                bWidthClipped = TRUE;
            }
        }
        // <--
    }
    Unlock();
}
<|endoftext|>


<commit_before>// CS 372 Project 2
// CPS: C++ to PostScript
// Noah Betzen, William Showalter, Saira Walia
// Star.cpp

#include "Star.h"

#include <cmath>

Star::Star(double sideLength):_sideLength(sideLength)
{
	setBoundingBox(calculateBoundingBox());
	setPostScript(getBoundingCenterPostScript());
	setPostScript(getDrawBoundingBoxPostScript());
	setPostScript(calculatePostScript());
}

BoundingBox Star::calculateBoundingBox()
{
	double x = 0, y = 0, xMin = 0, xMax = 0, yMin = 0, yMax = 0;
	double theta = -144*PI/180; // the constant rotate angle for a star

	//for (double theta = 0.0; theta < 2*PI; theta += 2.0*PI/_numSides)
	for(int i = 0; i < 4; ++i)
	{
		x = _sideLength*std::cos(theta)+x;
		y = _sideLength*std::sin(theta)+y;
		if (x > xMax)
			xMax = x;
		if (x < xMin)
			xMin = x;
		if (y > yMax)
			yMax = y;
		if (y < yMin)
			yMin = y;
	}

	//180-144=36

	return BoundingBox(_sideLength,_sideLength*std::sin(36));
	// TODO: Drawing the bounding box gives slightly different results than this.
}

std::string Star::calculatePostScript()
{
	std::stringstream ps;

	ps << "% BEGIN STAR\n";

	// save point
	ps << "gsave\n";
	ps << "newpath\n";
	ps << "0 0 moveto\n";

	// TODO: remove magic numbers from this line
	ps << (int)(-getBoundingBox()._width/2) << " " << (int)((-getBoundingBox()._height/2)-_sideLength/2.6) << " rmoveto\n";

	ps << "currentpoint translate\n";
	ps << "4 {\n";
	ps << _sideLength << " 0 lineto\n";
	ps << "currentpoint translate\n"; // move origin
	ps << "-144 rotate\n";
	ps << "} repeat\n";
	ps << "closepath\n";
	ps << "stroke\n";

	// restore point
	ps << "grestore\n";

	ps << "% END STAR\n\n";

	return ps.str();
}

<commit_msg>Update Star.cpp<commit_after>// CS 372 Project 2
// CPS: C++ to PostScript
// Noah Betzen, William Showalter, Saira Walia
// Star.cpp

#include "Star.h"

#include <cmath>

Star::Star(double sideLength):_sideLength(sideLength)
{
	setBoundingBox(calculateBoundingBox());
	setPostScript(getBoundingCenterPostScript());
	setPostScript(getDrawBoundingBoxPostScript());
	setPostScript(calculatePostScript());
}

BoundingBox Star::calculateBoundingBox()
{
	double x = 0, y = 0, xMin = 0, xMax = 0, yMin = 0, yMax = 0;
	double theta = -144*PI/180; // the constant rotate angle for a star

	//for (double theta = 0.0; theta < 2*PI; theta += 2.0*PI/_numSides)
	for(int i = 0; i < 4; ++i)
	{
		x = _sideLength*std::cos(theta)+x;
		y = _sideLength*std::sin(theta)+y;
		if (x > xMax)
			xMax = x;
		if (x < xMin)
			xMin = x;
		if (y > yMax)
			yMax = y;
		if (y < yMin)
			yMin = y;
	}

	//180-144=36

	return BoundingBox(_sideLength,_sideLength*std::sin(36));
	// TODO: Drawing the bounding box gives slightly different results than this.
}

std::string Star::calculatePostScript()
{
	std::stringstream ps;

	ps << "% BEGIN STAR\n";

	// save point
	ps << "gsave\n";
	ps << "newpath\n";
	ps << "0 0 moveto\n";

	// TODO: remove magic numbers from this line
	ps << (int)(-getBoundingBox()._width/2) << " " << (int)((-getBoundingBox()._height/2)-_sideLength/2.6) << " rmoveto\n";

	ps << "currentpoint translate\n";
	//currentpoint, which pushes the x and y coordinates of the current point on the stack.
	//The origin is moved to the end of the line segment we just added to our path.
	ps << "4 {\n";
	ps << _sideLength << " 0 lineto\n";
	ps << "currentpoint translate\n"; // move origin
	ps << "-144 rotate\n";
	ps << "} repeat\n";
	ps << "closepath\n";
	ps << "stroke\n";

	// restore point
	ps << "grestore\n";

	ps << "% END STAR\n\n";

	return ps.str();
}

<|endoftext|>


<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/*
$Log$
*/

//
//
//
//
#include "AliDimuCombinator.h"
#include "AliRun.h"
#include "TRandom.h"
//
ClassImp(AliDimuCombinator)
//
//                       Iterators
//
 TParticle* AliDimuCombinator::FirstMuon()
     {
	 fimuon1=fimin1;
	 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
	     fimuon1++;
	     if (fimuon1 >= fimax1) {fmuon1=0; break;}
	     fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 }
	 return fmuon1;
     }

 TParticle* AliDimuCombinator::FirstMuonSelected()
     {
	 TParticle * muon=FirstMuon();
	 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
	 return muon;
     }

 TParticle* AliDimuCombinator::NextMuon()
     {
	 fimuon1++;
	 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}

	 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 while(Type(fmuon1)!=5 && Type(fmuon1)!=6) {
	     fimuon1++;
	     if (fimuon1>=fimax1) {fmuon1 = 0; break;}
	     fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 }
	 return fmuon1;
     }

TParticle* AliDimuCombinator::NextMuonSelected()
     {
	 TParticle * muon=NextMuon();
	 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
	 return muon;
     }

 void AliDimuCombinator::FirstPartner()
     {
	 if (fimin1==fimin2) {
	     fimuon2=fimuon1+1;
	 } else {
	     fimuon2=fimin2;
	 }
	 if (fimuon2 >= fimax2) {fmuon2=0; return;}
	 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
	     fimuon2++;
	     if (fimuon2 >= fimax2) {fmuon2=0; break;}
	     fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 }
     }
void AliDimuCombinator::FirstPartnerSelected()
{
	 FirstPartner();
	 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
}

 void AliDimuCombinator::NextPartner()
     {
	 fimuon2++;
	 if (fimuon2>=fimax2) {fmuon2 = 0; return;}

	 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);

	 while(Type(fmuon2)!=5 && Type(fmuon2)!=6) {
	     fimuon2++;
	     if (fimuon2>=fimax2) {fmuon2 = 0; break;}
	     fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 }

     }

void AliDimuCombinator::NextPartnerSelected()
{
	 NextPartner();
	 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
}

 TParticle*  AliDimuCombinator::Partner()
     {
	 return fmuon2;
     }

void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
     {
	 FirstMuon();
	 FirstPartner();
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
     {
	 NextPartner();
	 if (!Partner()) {
	     NextMuon();
	     FirstPartner();
	 }
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
     {
	 FirstMuonSelected();
	 FirstPartnerSelected();
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
     {
	 NextPartnerSelected();
	 if (!Partner()) {
	     NextMuonSelected();
	     FirstPartnerSelected();
	 }
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::ResetRange()
{
    fimin1=fimin2=0;
    fimax1=fimax2=fNParticle;
}

void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
{
    fimin1=from;
    fimax1=to;
    if (fimax1 > fNParticle) fimax1=fNParticle;
}

void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
{
    fimin2=from;
    fimax2=to;
    if (fimax2 > fNParticle) fimax2=fNParticle;
}
//
//                       Selection
//

Bool_t AliDimuCombinator::Selected(TParticle* part)
{
//
//
    if (part==0) {return 0;}

    if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
	return 1;
    } else {
	return 0;
    }

}

Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
{
     return Selected(part1)*Selected(part2);
}
//
//                       Kinematics
//
Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
{
    Float_t px,py,pz,e;
    px=part1->Px()+part2->Px();
    py=part1->Py()+part2->Py();
    pz=part1->Pz()+part2->Pz();
    e =part1->Energy()+part2->Energy();
    Float_t p=px*px+py*py+pz*pz;
    if (e*e < p) {
	return -1;
    } else {
	return TMath::Sqrt(e*e-p);
    }
}

Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
{
    Float_t px,py;
    px=part1->Px()+part2->Px();
    py=part1->Py()+part2->Py();
    return TMath::Sqrt(px*px+py*py);
}

Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
{
    return part1->Pz()+part2->Pz();
}

Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
{
    Float_t pz,e;
    pz=part1->Pz()+part2->Pz();
    e =part1->Energy()+part2->Energy();
    return 0.5*TMath::Log((e+pz)/(e-pz));
}
//                  Response
//
void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
{
    value+=gRandom->Gaus(0, width);
}
//              Weighting
//

Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
{
    Float_t d, h, theta, CTau;
    TParticle* parent = Parent(part);
    Int_t ipar=Type(parent);
    if (ipar==8 || ipar==9) {
	CTau=780.4;
    } else if (ipar==11 || ipar==12) {
	CTau=370.9;
    } else {
	CTau=0;
    }

    Float_t GammaBeta=(parent->P())/(parent->GetMass());
//
// this part is still very ALICE muon-arm specific
//
    theta=parent->Theta();
    h=90*TMath::Tan(theta);

    if (h<4) {
	d=4/TMath::Sin(theta);
    } else {
	d=90/TMath::Cos(theta);
    }

    if (CTau > 0) {
	return 1-TMath::Exp(-d/CTau/GammaBeta);
    } else {
	return 1;
    }
}

Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
{
    Float_t wgt=(part1->GetWeight())*(part2->GetWeight());

    if (Correlated(part1, part2)) {
	return wgt/(Parent(part1)->GetWeight())*fRate1;
    } else {
	return wgt*fRate1*fRate2;
    }
}

Float_t AliDimuCombinator::Weight(TParticle* part)
{
    return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
}
Bool_t  AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
{
    if (Origin(part1) == Origin(part2)) {
	return kTRUE;
    } else {
	return kFALSE;
    }
}

TParticle* AliDimuCombinator::Parent(TParticle* part)
{
    return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
}

Int_t AliDimuCombinator::Origin(TParticle* part)
{
    Int_t iparent= part->GetFirstMother();
    if (iparent < 0) return iparent;
    Int_t ip;
    while(1) {
	ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
	if (ip < 0) {
	    break;
	} else {
	    iparent=ip;
	}
    }
    return iparent;
}

<commit_msg>Change muon particle code to PDG code.<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/*
$Log$
Revision 1.3  1999/09/29 09:24:08  fca
Introduction of the Copyright and cvs Log

*/

//
//
//
//
#include "AliDimuCombinator.h"
#include "AliRun.h"
#include "AliPDG.h"
#include "TRandom.h"
//
ClassImp(AliDimuCombinator)
//
//                       Iterators
//
 TParticle* AliDimuCombinator::FirstMuon()
     {
	 fimuon1=fimin1;
	 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
	     fimuon1++;
	     if (fimuon1 >= fimax1) {fmuon1=0; break;}
	     fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 }
	 return fmuon1;
     }

 TParticle* AliDimuCombinator::FirstMuonSelected()
     {
	 TParticle * muon=FirstMuon();
	 while(muon!=0 && !Selected(muon)) {muon=NextMuon();}
	 return muon;
     }

 TParticle* AliDimuCombinator::NextMuon()
     {
	 fimuon1++;
	 if (fimuon1>=fNParticle) {fmuon1 = 0; return fmuon1;}

	 fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 while(Type(fmuon1)!=kMuonPlus && Type(fmuon1)!=kMuonMinus) {
	     fimuon1++;
	     if (fimuon1>=fimax1) {fmuon1 = 0; break;}
	     fmuon1 = (TParticle*) fPartArray->UncheckedAt(fimuon1);
	 }
	 return fmuon1;
     }

TParticle* AliDimuCombinator::NextMuonSelected()
     {
	 TParticle * muon=NextMuon();
	 while(muon !=0 && !Selected(muon)) {muon=NextMuon();}
	 return muon;
     }

 void AliDimuCombinator::FirstPartner()
     {
	 if (fimin1==fimin2) {
	     fimuon2=fimuon1+1;
	 } else {
	     fimuon2=fimin2;
	 }
	 if (fimuon2 >= fimax2) {fmuon2=0; return;}
	 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
	     fimuon2++;
	     if (fimuon2 >= fimax2) {fmuon2=0; break;}
	     fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 }
     }
void AliDimuCombinator::FirstPartnerSelected()
{
	 FirstPartner();
	 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
}

 void AliDimuCombinator::NextPartner()
     {
	 fimuon2++;
	 if (fimuon2>=fimax2) {fmuon2 = 0; return;}

	 fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);

	 while(Type(fmuon2)!=kMuonPlus && Type(fmuon2)!=kMuonMinus) {
	     fimuon2++;
	     if (fimuon2>=fimax2) {fmuon2 = 0; break;}
	     fmuon2 = (TParticle*) fPartArray->UncheckedAt(fimuon2);
	 }

     }

void AliDimuCombinator::NextPartnerSelected()
{
	 NextPartner();
	 while(fmuon2 !=0 && !Selected(fmuon2)) {NextPartner();}
}

 TParticle*  AliDimuCombinator::Partner()
     {
	 return fmuon2;
     }

void AliDimuCombinator::FirstMuonPair(TParticle* & muon1, TParticle* & muon2)
     {
	 FirstMuon();
	 FirstPartner();
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::NextMuonPair(TParticle* & muon1, TParticle* & muon2)
     {
	 NextPartner();
	 if (!Partner()) {
	     NextMuon();
	     FirstPartner();
	 }
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::FirstMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
     {
	 FirstMuonSelected();
	 FirstPartnerSelected();
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::NextMuonPairSelected(TParticle* & muon1, TParticle* & muon2)
     {
	 NextPartnerSelected();
	 if (!Partner()) {
	     NextMuonSelected();
	     FirstPartnerSelected();
	 }
	 muon1=fmuon1;
	 muon2=fmuon2;
     }
void AliDimuCombinator::ResetRange()
{
    fimin1=fimin2=0;
    fimax1=fimax2=fNParticle;
}

void AliDimuCombinator::SetFirstRange(Int_t from, Int_t to)
{
    fimin1=from;
    fimax1=to;
    if (fimax1 > fNParticle) fimax1=fNParticle;
}

void AliDimuCombinator::SetSecondRange(Int_t from, Int_t to)
{
    fimin2=from;
    fimax2=to;
    if (fimax2 > fNParticle) fimax2=fNParticle;
}
//
//                       Selection
//

Bool_t AliDimuCombinator::Selected(TParticle* part)
{
//
//
    if (part==0) {return 0;}

    if (part->Pt() > fPtMin && part->Eta()>fEtaMin && part->Eta()<fEtaMax) {
	return 1;
    } else {
	return 0;
    }

}

Bool_t AliDimuCombinator::Selected(TParticle* part1, TParticle* part2)
{
     return Selected(part1)*Selected(part2);
}
//
//                       Kinematics
//
Float_t AliDimuCombinator::Mass(TParticle* part1, TParticle* part2)
{
    Float_t px,py,pz,e;
    px=part1->Px()+part2->Px();
    py=part1->Py()+part2->Py();
    pz=part1->Pz()+part2->Pz();
    e =part1->Energy()+part2->Energy();
    Float_t p=px*px+py*py+pz*pz;
    if (e*e < p) {
	return -1;
    } else {
	return TMath::Sqrt(e*e-p);
    }
}

Float_t AliDimuCombinator::PT(TParticle* part1, TParticle* part2)
{
    Float_t px,py;
    px=part1->Px()+part2->Px();
    py=part1->Py()+part2->Py();
    return TMath::Sqrt(px*px+py*py);
}

Float_t AliDimuCombinator::Pz(TParticle* part1, TParticle* part2)
{
    return part1->Pz()+part2->Pz();
}

Float_t AliDimuCombinator::Y(TParticle* part1, TParticle* part2)
{
    Float_t pz,e;
    pz=part1->Pz()+part2->Pz();
    e =part1->Energy()+part2->Energy();
    return 0.5*TMath::Log((e+pz)/(e-pz));
}
//                  Response
//
void AliDimuCombinator::SmearGauss(Float_t width, Float_t & value)
{
    value+=gRandom->Gaus(0, width);
}
//              Weighting
//

Float_t AliDimuCombinator::Decay_Prob(TParticle* part)
{
    Float_t d, h, theta, CTau;
    TParticle* parent = Parent(part);
    Int_t ipar=Type(parent);
    if (ipar==8 || ipar==9) {
	CTau=780.4;
    } else if (ipar==11 || ipar==12) {
	CTau=370.9;
    } else {
	CTau=0;
    }

    Float_t GammaBeta=(parent->P())/(parent->GetMass());
//
// this part is still very ALICE muon-arm specific
//
    theta=parent->Theta();
    h=90*TMath::Tan(theta);

    if (h<4) {
	d=4/TMath::Sin(theta);
    } else {
	d=90/TMath::Cos(theta);
    }

    if (CTau > 0) {
	return 1-TMath::Exp(-d/CTau/GammaBeta);
    } else {
	return 1;
    }
}

Float_t AliDimuCombinator::Weight(TParticle* part1, TParticle* part2)
{
    Float_t wgt=(part1->GetWeight())*(part2->GetWeight());

    if (Correlated(part1, part2)) {
	return wgt/(Parent(part1)->GetWeight())*fRate1;
    } else {
	return wgt*fRate1*fRate2;
    }
}

Float_t AliDimuCombinator::Weight(TParticle* part)
{
    return (part->GetWeight())*(Parent(part)->GetWeight())*fRate1;
}
Bool_t  AliDimuCombinator::Correlated(TParticle* part1, TParticle* part2)
{
    if (Origin(part1) == Origin(part2)) {
	return kTRUE;
    } else {
	return kFALSE;
    }
}

TParticle* AliDimuCombinator::Parent(TParticle* part)
{
    return (TParticle*) (fPartArray->UncheckedAt(part->GetFirstMother()));
}

Int_t AliDimuCombinator::Origin(TParticle* part)
{
    Int_t iparent= part->GetFirstMother();
    if (iparent < 0) return iparent;
    Int_t ip;
    while(1) {
	ip=((TParticle*) fPartArray->UncheckedAt(iparent))->GetFirstMother();
	if (ip < 0) {
	    break;
	} else {
	    iparent=ip;
	}
    }
    return iparent;
}

<|endoftext|>


<commit_before>// @(#)root/gl:$Id$
// Author: Matevz Tadel, Aug 2009

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGLFBO.h"
#include <TMath.h>
#include <TString.h>
#include <TError.h>

#include <GL/glew.h>

#include <stdexcept>

//______________________________________________________________________________
//
// Frame-buffer object.
//
// Requires GL-1.5.
//
// Taken from Gled project, see:
//   http://www.gled.org/cgi-bin/viewcvs.cgi/trunk/libsets/GledCore/Pupils/
// See also:
//   http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt

ClassImp(TGLFBO);

Bool_t TGLFBO::fgRescaleToPow2       = kTRUE; // For ATI.
Bool_t TGLFBO::fgMultiSampleNAWarned = kFALSE;

TGLFBO::TGLFBO() :
   fFrameBuffer  (0),
   fColorTexture (0),
   fDepthBuffer  (0),
   fMSFrameBuffer(0),
   fMSColorBuffer(0),
   fW (-1),
   fH (-1),
   fMSSamples  (0),
   fMSCoverageSamples (0),
   fWScale     (1),
   fHScale     (1),
   fIsRescaled (kFALSE)
{
   // Constructor.
}

//______________________________________________________________________________
TGLFBO::~TGLFBO()
{
   // Destructor.

   Release();
}

//______________________________________________________________________________
void TGLFBO::Init(int w, int h, int ms_samples)
{
   // Acquire GL resources for given width, height and number of
   // multi-sampling samples.

   static const std::string eh("TGLFBO::Init ");

   // Should be replaced with ARB_framebuffer_object (SLC6).
   if (!GLEW_EXT_framebuffer_object)
   {
      throw std::runtime_error(eh + "GL_EXT_framebuffer_object extension required for FBO.");
   }

   fIsRescaled = kFALSE;
   if (fgRescaleToPow2)
   {
      Int_t nw = 1 << TMath::CeilNint(TMath::Log2(w));
      Int_t nh = 1 << TMath::CeilNint(TMath::Log2(h));
      if (nw != w || nh != h)
      {
         fWScale = ((Float_t)w) / nw;
         fHScale = ((Float_t)h) / nh;
         w = nw; h = nh;
         fIsRescaled = kTRUE;
      }
   }

   if (ms_samples > 0 && ! GLEW_EXT_framebuffer_multisample)
   {
      if (!fgMultiSampleNAWarned)
      {
         Info(eh.c_str(), "GL implementation does not support multi-sampling for FBOs.");
         fgMultiSampleNAWarned = kTRUE;
      }
      ms_samples = 0;
   }

   if (fFrameBuffer != 0)
   {
      if (fW == w && fH == h && fMSSamples == ms_samples)
         return;
      Release();
   }

   Int_t maxSize;
   glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &maxSize);
   if (w > maxSize || h > maxSize)
   {
      throw std::runtime_error(eh + Form("maximum size supported by GL implementation is %d.", maxSize));
   }

   fW = w; fH = h; fMSSamples = ms_samples;

   if (fMSSamples > 0)
   {
      if (GLEW_NV_framebuffer_multisample_coverage)
      {
         GLint n_modes;
         glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV, &n_modes);
         GLint *modes = new GLint[2*n_modes];
         glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV, modes);

         for (int i = 0; i < n_modes; ++i)
         {
            if (modes[i*2+1] == fMSSamples && modes[i*2] > fMSCoverageSamples)
               fMSCoverageSamples = modes[i*2];
         }

         delete [] modes;
      }
      Info(eh.c_str(), "InitMultiSample coverage_samples=%d, color_samples=%d.", fMSCoverageSamples, fMSSamples);
      InitMultiSample();
   }
   else
   {
      printf("TGLFBO::Init InitStandard ...\n");
      InitStandard();
   }

   GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);

   glBindFramebufferEXT (GL_FRAMEBUFFER_EXT,  0);
   glBindTexture        (GL_TEXTURE_2D,       0);

   switch (status)
   {
      case GL_FRAMEBUFFER_COMPLETE_EXT:
         if (gDebug > 0)
            printf("%sConstructed TGLFBO ... all fine.\n", eh.c_str());
         break;
      case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
         Release();
         throw std::runtime_error(eh + "Constructed TGLFBO not supported, choose different formats.");
         break;
      default:
         Release();
         throw std::runtime_error(eh + "Constructed TGLFBO is not complete, unexpected error.");
         break;
   }
}

//______________________________________________________________________________
void TGLFBO::Release()
{
   // Release the allocated GL resources.

   glDeleteFramebuffersEXT (1, &fFrameBuffer);
   glDeleteRenderbuffersEXT(1, &fDepthBuffer);

   if (fMSFrameBuffer) glDeleteFramebuffersEXT (1, &fMSFrameBuffer);
   if (fMSColorBuffer) glDeleteRenderbuffersEXT(1, &fMSColorBuffer);
   if (fColorTexture)  glDeleteTextures        (1, &fColorTexture);

   fW = fH = -1; fMSSamples = fMSCoverageSamples = 0;
   fFrameBuffer = fColorTexture = fDepthBuffer = fMSFrameBuffer = fMSColorBuffer = 0;

}

//______________________________________________________________________________
void TGLFBO::Bind()
{
   // Bind the frame-buffer object.

   if (fMSSamples > 0) {
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fMSFrameBuffer);
      // On by default
      //   glEnable(GL_MULTISAMPLE);
      // Experimenting:
      //   glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
      //   glEnable(GL_SAMPLE_COVERAGE_ARB);
   } else {
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);
   }
}

//______________________________________________________________________________
void TGLFBO::Unbind()
{
   // Unbind the frame-buffer object.

   if (fMSSamples > 0)
   {
      glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fMSFrameBuffer);
      glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fFrameBuffer);
      glBlitFramebufferEXT(0, 0, fW, fH, 0, 0, fW, fH, GL_COLOR_BUFFER_BIT, GL_NEAREST);
   }

   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

//______________________________________________________________________________
void TGLFBO::BindTexture()
{
   // Bind texture.

   glPushAttrib(GL_TEXTURE_BIT);
   glBindTexture(GL_TEXTURE_2D, fColorTexture);
   glEnable(GL_TEXTURE_2D);

   if (fIsRescaled)
   {
      glMatrixMode(GL_TEXTURE);
      glPushMatrix();
      glScalef(fWScale, fHScale, 1);
      glMatrixMode(GL_MODELVIEW);
   }
}

//______________________________________________________________________________
void TGLFBO::UnbindTexture()
{
   // Unbind texture.

   if (fIsRescaled)
   {
      glMatrixMode(GL_TEXTURE);
      glPopMatrix();
      glMatrixMode(GL_MODELVIEW);
   }

   glPopAttrib();
}

//______________________________________________________________________________
void TGLFBO::SetAsReadBuffer()
{
   glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fFrameBuffer);
}

//==============================================================================

//______________________________________________________________________________
void TGLFBO::InitStandard()
{
   glGenFramebuffersEXT(1, &fFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);

   fDepthBuffer  = CreateAndAttachRenderBuffer(GL_DEPTH_COMPONENT24, GL_DEPTH_ATTACHMENT);
   fColorTexture = CreateAndAttachColorTexture();
}

//______________________________________________________________________________
void TGLFBO::InitMultiSample()
{
   glGenFramebuffersEXT(1, &fMSFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fMSFrameBuffer);

   fMSColorBuffer = CreateAndAttachRenderBuffer(GL_RGBA8,             GL_COLOR_ATTACHMENT0);
   fDepthBuffer   = CreateAndAttachRenderBuffer(GL_DEPTH_COMPONENT24, GL_DEPTH_ATTACHMENT);
   // fDepthBuffer   = CreateAndAttachRenderBuffer(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT);

   glGenFramebuffersEXT(1, &fFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);

   fColorTexture = CreateAndAttachColorTexture();
}

//______________________________________________________________________________
UInt_t TGLFBO::CreateAndAttachRenderBuffer(Int_t format, Int_t type)
{
   UInt_t id = 0;

   glGenRenderbuffersEXT(1, &id);
   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id);

   if (fMSSamples > 0)
   {
      if (fMSCoverageSamples > 0)
         glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER_EXT, fMSCoverageSamples, fMSSamples, format, fW, fH);
      else
         glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, fMSSamples, format, fW, fH);
   }
   else
   {
      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, fW, fH);
   }

   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, type, GL_RENDERBUFFER_EXT, id);

   return id;
}

//______________________________________________________________________________
UInt_t TGLFBO::CreateAndAttachColorTexture()
{
   // Initialize color-texture and attach it to current FB.

   UInt_t id = 0;

   glGenTextures(1, &id);

   glBindTexture(GL_TEXTURE_2D, id);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, fW, fH, 0, GL_RGBA,
                GL_UNSIGNED_BYTE, NULL);

   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                             GL_TEXTURE_2D, id, 0);

   return id;
}
<commit_msg>Print out info about FBO multi-sampling settings only when gDebug > 0.<commit_after>// @(#)root/gl:$Id$
// Author: Matevz Tadel, Aug 2009

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGLFBO.h"
#include <TMath.h>
#include <TString.h>
#include <TError.h>

#include <GL/glew.h>

#include <stdexcept>

//______________________________________________________________________________
//
// Frame-buffer object.
//
// Requires GL-1.5.
//
// Taken from Gled project, see:
//   http://www.gled.org/cgi-bin/viewcvs.cgi/trunk/libsets/GledCore/Pupils/
// See also:
//   http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt

ClassImp(TGLFBO);

Bool_t TGLFBO::fgRescaleToPow2       = kTRUE; // For ATI.
Bool_t TGLFBO::fgMultiSampleNAWarned = kFALSE;

TGLFBO::TGLFBO() :
   fFrameBuffer  (0),
   fColorTexture (0),
   fDepthBuffer  (0),
   fMSFrameBuffer(0),
   fMSColorBuffer(0),
   fW (-1),
   fH (-1),
   fMSSamples  (0),
   fMSCoverageSamples (0),
   fWScale     (1),
   fHScale     (1),
   fIsRescaled (kFALSE)
{
   // Constructor.
}

//______________________________________________________________________________
TGLFBO::~TGLFBO()
{
   // Destructor.

   Release();
}

//______________________________________________________________________________
void TGLFBO::Init(int w, int h, int ms_samples)
{
   // Acquire GL resources for given width, height and number of
   // multi-sampling samples.

   static const std::string eh("TGLFBO::Init ");

   // Should be replaced with ARB_framebuffer_object (SLC6).
   if (!GLEW_EXT_framebuffer_object)
   {
      throw std::runtime_error(eh + "GL_EXT_framebuffer_object extension required for FBO.");
   }

   fIsRescaled = kFALSE;
   if (fgRescaleToPow2)
   {
      Int_t nw = 1 << TMath::CeilNint(TMath::Log2(w));
      Int_t nh = 1 << TMath::CeilNint(TMath::Log2(h));
      if (nw != w || nh != h)
      {
         fWScale = ((Float_t)w) / nw;
         fHScale = ((Float_t)h) / nh;
         w = nw; h = nh;
         fIsRescaled = kTRUE;
      }
   }

   if (ms_samples > 0 && ! GLEW_EXT_framebuffer_multisample)
   {
      if (!fgMultiSampleNAWarned)
      {
         Info(eh.c_str(), "GL implementation does not support multi-sampling for FBOs.");
         fgMultiSampleNAWarned = kTRUE;
      }
      ms_samples = 0;
   }

   if (fFrameBuffer != 0)
   {
      if (fW == w && fH == h && fMSSamples == ms_samples)
         return;
      Release();
   }

   Int_t maxSize;
   glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &maxSize);
   if (w > maxSize || h > maxSize)
   {
      throw std::runtime_error(eh + Form("maximum size supported by GL implementation is %d.", maxSize));
   }

   fW = w; fH = h; fMSSamples = ms_samples;

   if (fMSSamples > 0)
   {
      if (GLEW_NV_framebuffer_multisample_coverage)
      {
         GLint n_modes;
         glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV, &n_modes);
         GLint *modes = new GLint[2*n_modes];
         glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV, modes);

         for (int i = 0; i < n_modes; ++i)
         {
            if (modes[i*2+1] == fMSSamples && modes[i*2] > fMSCoverageSamples)
               fMSCoverageSamples = modes[i*2];
         }

         delete [] modes;
      }
      if (gDebug > 0) {
         Info(eh.c_str(), "InitMultiSample coverage_samples=%d, color_samples=%d.", fMSCoverageSamples, fMSSamples);
      }
      InitMultiSample();
   }
   else
   {
      if (gDebug > 0) {
         Info(eh.c_str(), "InitStandard (no multi-sampling).");
      }
      InitStandard();
   }

   GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);

   glBindFramebufferEXT (GL_FRAMEBUFFER_EXT,  0);
   glBindTexture        (GL_TEXTURE_2D,       0);

   switch (status)
   {
      case GL_FRAMEBUFFER_COMPLETE_EXT:
         if (gDebug > 0)
            printf("%sConstructed TGLFBO ... all fine.\n", eh.c_str());
         break;
      case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
         Release();
         throw std::runtime_error(eh + "Constructed TGLFBO not supported, choose different formats.");
         break;
      default:
         Release();
         throw std::runtime_error(eh + "Constructed TGLFBO is not complete, unexpected error.");
         break;
   }
}

//______________________________________________________________________________
void TGLFBO::Release()
{
   // Release the allocated GL resources.

   glDeleteFramebuffersEXT (1, &fFrameBuffer);
   glDeleteRenderbuffersEXT(1, &fDepthBuffer);

   if (fMSFrameBuffer) glDeleteFramebuffersEXT (1, &fMSFrameBuffer);
   if (fMSColorBuffer) glDeleteRenderbuffersEXT(1, &fMSColorBuffer);
   if (fColorTexture)  glDeleteTextures        (1, &fColorTexture);

   fW = fH = -1; fMSSamples = fMSCoverageSamples = 0;
   fFrameBuffer = fColorTexture = fDepthBuffer = fMSFrameBuffer = fMSColorBuffer = 0;

}

//______________________________________________________________________________
void TGLFBO::Bind()
{
   // Bind the frame-buffer object.

   if (fMSSamples > 0) {
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fMSFrameBuffer);
      // On by default
      //   glEnable(GL_MULTISAMPLE);
      // Experimenting:
      //   glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
      //   glEnable(GL_SAMPLE_COVERAGE_ARB);
   } else {
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);
   }
}

//______________________________________________________________________________
void TGLFBO::Unbind()
{
   // Unbind the frame-buffer object.

   if (fMSSamples > 0)
   {
      glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fMSFrameBuffer);
      glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fFrameBuffer);
      glBlitFramebufferEXT(0, 0, fW, fH, 0, 0, fW, fH, GL_COLOR_BUFFER_BIT, GL_NEAREST);
   }

   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

//______________________________________________________________________________
void TGLFBO::BindTexture()
{
   // Bind texture.

   glPushAttrib(GL_TEXTURE_BIT);
   glBindTexture(GL_TEXTURE_2D, fColorTexture);
   glEnable(GL_TEXTURE_2D);

   if (fIsRescaled)
   {
      glMatrixMode(GL_TEXTURE);
      glPushMatrix();
      glScalef(fWScale, fHScale, 1);
      glMatrixMode(GL_MODELVIEW);
   }
}

//______________________________________________________________________________
void TGLFBO::UnbindTexture()
{
   // Unbind texture.

   if (fIsRescaled)
   {
      glMatrixMode(GL_TEXTURE);
      glPopMatrix();
      glMatrixMode(GL_MODELVIEW);
   }

   glPopAttrib();
}

//______________________________________________________________________________
void TGLFBO::SetAsReadBuffer()
{
   glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fFrameBuffer);
}

//==============================================================================

//______________________________________________________________________________
void TGLFBO::InitStandard()
{
   glGenFramebuffersEXT(1, &fFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);

   fDepthBuffer  = CreateAndAttachRenderBuffer(GL_DEPTH_COMPONENT24, GL_DEPTH_ATTACHMENT);
   fColorTexture = CreateAndAttachColorTexture();
}

//______________________________________________________________________________
void TGLFBO::InitMultiSample()
{
   glGenFramebuffersEXT(1, &fMSFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fMSFrameBuffer);

   fMSColorBuffer = CreateAndAttachRenderBuffer(GL_RGBA8,             GL_COLOR_ATTACHMENT0);
   fDepthBuffer   = CreateAndAttachRenderBuffer(GL_DEPTH_COMPONENT24, GL_DEPTH_ATTACHMENT);
   // fDepthBuffer   = CreateAndAttachRenderBuffer(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT);

   glGenFramebuffersEXT(1, &fFrameBuffer);
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFrameBuffer);

   fColorTexture = CreateAndAttachColorTexture();
}

//______________________________________________________________________________
UInt_t TGLFBO::CreateAndAttachRenderBuffer(Int_t format, Int_t type)
{
   UInt_t id = 0;

   glGenRenderbuffersEXT(1, &id);
   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id);

   if (fMSSamples > 0)
   {
      if (fMSCoverageSamples > 0)
         glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER_EXT, fMSCoverageSamples, fMSSamples, format, fW, fH);
      else
         glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, fMSSamples, format, fW, fH);
   }
   else
   {
      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, fW, fH);
   }

   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, type, GL_RENDERBUFFER_EXT, id);

   return id;
}

//______________________________________________________________________________
UInt_t TGLFBO::CreateAndAttachColorTexture()
{
   // Initialize color-texture and attach it to current FB.

   UInt_t id = 0;

   glGenTextures(1, &id);

   glBindTexture(GL_TEXTURE_2D, id);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, fW, fH, 0, GL_RGBA,
                GL_UNSIGNED_BYTE, NULL);

   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                             GL_TEXTURE_2D, id, 0);

   return id;
}
<|endoftext|>


<commit_before>// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef _SFIDL_UTILS_HH_
#define _SFIDL_UTILS_HH_
#include <sfi/glib-extra.hh>
#include <sfi/sfi.hh>
#include <list>
#include <vector>

/// The Sfidl namespace contains implementation and API of the Sfi IDL compiler.
namespace Sfidl {

using Bse::String;

String string_tolower   (const String &str);
String string_from_int  (int64 value);
String string_from_uint (uint64_t value);
String string_format    (const char *format, ...) __attribute__ ((__format__ (printf, 1, 2)));
void   printerr         (const char *format, ...) __attribute__ ((__format__ (printf, 1, 2)));

/* common data structures */
using std::list;
using std::vector;

bool            isCxxTypeName (const String& str);
list<String>    symbolToList (const String& symbol);

} // Sfidl

#endif /* _SFIDL_UTILS_HH_ */
/* vim:set ts=8 sts=2 sw=2: */
<commit_msg>SFI: sfidl-utils: replace Bse types and helper macros<commit_after>// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef _SFIDL_UTILS_HH_
#define _SFIDL_UTILS_HH_
#include <sfi/glib-extra.hh>
#include <list>
#include <vector>

// Import simple types into global scope
typedef uint8_t         uint8;          ///< An 8-bit unsigned integer.
typedef uint16_t        uint16;         ///< A 16-bit unsigned integer.
typedef uint32_t        uint32;         ///< A 32-bit unsigned integer.
typedef uint64_t        uint64;         ///< A 64-bit unsigned integer, use PRI*64 in format strings.
typedef int8_t          int8;           ///< An 8-bit signed integer.
typedef int16_t         int16;          ///< A 16-bit signed integer.
typedef int32_t         int32;          ///< A 32-bit signed integer.
typedef int64_t         int64;          ///< A 64-bit unsigned integer, use PRI*64 in format strings.
typedef uint32_t        unichar;        ///< A 32-bit unsigned integer used for Unicode characters.

#define assert_return_unreached(...)    g_assert_not_reached()
#define assert_return(cond, ...)        do { if (cond) break; g_warning ("assertion failed: %s", #cond); return __VA_ARGS__; } while (0)

/// The Sfidl namespace contains implementation and API of the Sfi IDL compiler.
namespace Sfidl {

typedef std::string String;

String string_tolower   (const String &str);
String string_from_int  (int64 value);
String string_from_uint (uint64_t value);
String string_format    (const char *format, ...) __attribute__ ((__format__ (printf, 1, 2)));
void   printerr         (const char *format, ...) __attribute__ ((__format__ (printf, 1, 2)));

/* common data structures */
using std::list;
using std::vector;

bool            isCxxTypeName (const String& str);
list<String>    symbolToList (const String& symbol);

} // Sfidl

#endif /* _SFIDL_UTILS_HH_ */
/* vim:set ts=8 sts=2 sw=2: */
<|endoftext|>