Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

anchor.cpp

00001 /*****************************************************************************
00002  * anchor.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: anchor.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *          Olivier Teulière <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 #include "anchor.hpp"
00026 
00027 
00028 bool Anchor::isHanging( const Anchor &rOther ) const
00029 {
00030     if( m_priority <= rOther.m_priority )
00031         return false;
00032 
00033     // Compute delta coordinates between anchors, since the Bezier class
00034     // uses coordinates relative to (0;0)
00035     int deltaX = getXPosAbs() - rOther.getXPosAbs();
00036     int deltaY = getYPosAbs() - rOther.getYPosAbs();
00037 
00038     // One of the anchors (at least) must be a point, else it has no meaning
00039     return (isPoint() && rOther.m_rCurve.getMinDist( deltaX, deltaY ) == 0) ||
00040            (rOther.isPoint() && m_rCurve.getMinDist( -deltaX, -deltaY ) == 0);
00041 }
00042 
00043 
00044 bool Anchor::canHang( const Anchor &rOther, int &xOffset, int &yOffset ) const
00045 {
00046     int deltaX = getXPosAbs() - (rOther.getXPosAbs() + xOffset);
00047     int deltaY = getYPosAbs() - (rOther.getYPosAbs() + yOffset);
00048 
00049     // One of the anchors (at least) must be a point, else it has no meaning
00050     if( (isPoint() && rOther.m_rCurve.getMinDist( deltaX, deltaY ) < m_range) )
00051     {
00052         // Compute the coordinates of the nearest point of the curve
00053         int xx, yy;
00054         float p = rOther.m_rCurve.getNearestPercent( deltaX, deltaY );
00055         rOther.m_rCurve.getPoint( p, xx, yy );
00056 
00057         xOffset = getXPosAbs() - (rOther.getXPosAbs() + xx);
00058         yOffset = getYPosAbs() - (rOther.getYPosAbs() + yy);
00059         return true;
00060     }
00061     else if( (rOther.isPoint() &&
00062               m_rCurve.getMinDist( -deltaX, -deltaY ) < m_range) )
00063     {
00064         // Compute the coordinates of the nearest point of the curve
00065         int xx, yy;
00066         float p = m_rCurve.getNearestPercent( -deltaX, -deltaY );
00067         m_rCurve.getPoint( p, xx, yy );
00068 
00069         xOffset = (getXPosAbs() + xx) - rOther.getXPosAbs();
00070         yOffset = (getYPosAbs() + yy) - rOther.getYPosAbs();
00071         return true;
00072     }
00073     else
00074     {
00075         return false;
00076     }
00077 }

Generated on Tue Dec 20 10:14:42 2005 for vlc-0.8.4a by  doxygen 1.4.2