karbon

vtransformnodes.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 
00021 #include "vpath.h"
00022 #include "vsegment.h"
00023 #include "vtransformnodes.h"
00024 
00025 
00026 VTransformNodes::VTransformNodes( const QWMatrix& m )
00027     : m_matrix( m )
00028 {
00029 }
00030 
00031 void
00032 VTransformNodes::visitVSubpath( VSubpath& path )
00033 {
00034     path.first();
00035     while( path.current() )
00036     {
00037         if( path.current()->isCurve() )
00038         {
00039             if( !path.current()->knotIsSelected() &&
00040                 path.current()->pointIsSelected( 1 ) &&
00041                 path.current()->next() &&
00042                 path.current()->next()->isCurve() &&
00043                 !path.current()->next()->pointIsSelected( 0 ) &&
00044                 path.current()->isSmooth() )
00045             {
00046                 // Do extra reverse trafo for smooth beziers
00047                 QWMatrix m2( m_matrix.m11(), m_matrix.m12(), m_matrix.m21(), m_matrix.m22(),
00048                             -m_matrix.dx(), -m_matrix.dy() );
00049                 path.current()->next()->setPoint( 0, path.current()->next()->point( 0 ).transform( m2 ) );
00050             }
00051             if( path.current()->pointIsSelected( 0 ) &&
00052                 path.current()->prev() &&
00053                 path.current()->prev()->isCurve() &&
00054                 !path.current()->prev()->knotIsSelected() &&
00055                 !path.current()->prev()->pointIsSelected( 1 ) &&
00056                 path.current()->prev()->isSmooth() )
00057             {
00058                 // Do extra reverse trafo for smooth beziers
00059                 QWMatrix m2( m_matrix.m11(), m_matrix.m12(), m_matrix.m21(), m_matrix.m22(),
00060                             -m_matrix.dx(), -m_matrix.dy() );
00061                 path.current()->prev()->setPoint( 1, path.current()->prev()->point( 1 ).transform( m2 ) );
00062             }
00063         }
00064 
00065         for( uint i = 0; i < path.current()->degree(); ++i )
00066         {
00067             if( path.current()->pointIsSelected( i ) )
00068                 path.current()->setPoint( i, path.current()->point( i ).transform( m_matrix ) );
00069         }
00070 
00071         if( !success() )
00072             setSuccess();
00073         path.next();
00074     }
00075 }
00076 
KDE Home | KDE Accessibility Home | Description of Access Keys