karbon

vselectnodes.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 "vselectnodes.h"
00024 #include "vlayer.h"
00025 #include "vdocument.h"
00026 
00027 void
00028 VSelectNodes::visitVSubpath( VSubpath& path )
00029 {
00030     path.first();
00031 
00032     // skip "begin":
00033     while( path.current() )
00034     {
00035         if( m_rect.isEmpty() )
00036         {
00037             for( int i = 0; i < path.current()->degree(); i++ )
00038                 path.current()->selectPoint( i, m_select );
00039 
00040             setSuccess();
00041         }
00042         else
00043         {
00044             if( m_exclusive )
00045             {
00046                 for( int i = 0; i < path.current()->degree(); i++ )
00047                     path.current()->selectPoint( i, false );
00048             }
00049 
00050             if( path.current()->isCurve() )
00051             {
00052                 if( m_rect.contains( path.current()->point( 0 ) ) )
00053                 {
00054                     path.current()->selectPoint( 0, m_select );
00055                     setSuccess();
00056                 }
00057 
00058                 if( m_rect.contains( path.current()->point( 1 ) ) )
00059                 {
00060                     path.current()->selectPoint( 1, m_select );
00061                     setSuccess();
00062                 }
00063             }
00064             if( path.current()->prev() &&
00065                 path.current()->prev()->isSmooth() )
00066                     path.current()->selectPoint( 0, path.current()->prev()->knotIsSelected() );
00067 
00068             if( m_rect.contains( path.current()->knot() ) )
00069             {
00070                 path.current()->selectKnot( m_select );
00071                 if( path.current()->isCurve() )
00072                 {
00073                     path.current()->selectPoint( 1, m_select );
00074                 }
00075 
00076                 setSuccess();
00077             }
00078         }
00079         path.next();
00080     }
00081     // select first node as well
00082     if( path.isClosed() && path.getLast()->knotIsSelected() )
00083         path.getFirst()->selectKnot();
00084 }
00085 
00086 void
00087 VSelectNodes::visitVLayer( VLayer& layer )
00088 {
00089     VDocument* doc = (VDocument*)layer.parent();
00090     if ( ( layer.state() != VObject::deleted ) &&
00091          ( ( doc->selectionMode() == VDocument::AllLayers ) ||
00092            ( doc->selectionMode() == VDocument::VisibleLayers && ( layer.state() == VObject::normal || layer.state() == VObject::normal_locked ) ) ||
00093            ( doc->selectionMode() == VDocument::SelectedLayers && layer.selected() ) ||
00094            ( doc->selectionMode() == VDocument::ActiveLayer && doc->activeLayer() == &layer ) ) )
00095     {
00096         VObjectListIterator itr( layer.objects() );
00097         for( ; itr.current(); ++itr )
00098             itr.current()->accept( *this );
00099     }
00100 }
00101 
00102 void
00103 VTestNodes::visitVSubpath( VSubpath& path )
00104 {
00105     path.first();
00106 
00107     while( path.current() )
00108     {
00109         for( int i = 0; i < path.current()->degree(); i++ )
00110             if( m_rect.contains( path.current()->point( i ) ) ) //&&
00111                 //path.current()->pointIsSelected( i ) )
00112                 {
00113                     m_segments.append( path.current() );
00114                     setSuccess();
00115                 }
00116 
00117         path.next();
00118     }
00119 }
00120 
00121 void
00122 VTestNodes::visitVLayer( VLayer& layer )
00123 {
00124     VDocument* doc = (VDocument*)layer.parent();
00125     if ( ( layer.state() != VObject::deleted ) &&
00126          ( ( doc->selectionMode() == VDocument::AllLayers ) ||
00127            ( doc->selectionMode() == VDocument::VisibleLayers && ( layer.state() == VObject::normal || layer.state() == VObject::normal_locked ) ) ||
00128            ( doc->selectionMode() == VDocument::SelectedLayers && layer.selected() ) ||
00129            ( doc->selectionMode() == VDocument::ActiveLayer && doc->activeLayer() == &layer ) ) )
00130     {
00131         VObjectListIterator itr( layer.objects() );
00132         for( ; itr.current(); ++itr )
00133             itr.current()->accept( *this );
00134     }
00135 }
00136 
KDE Home | KDE Accessibility Home | Description of Access Keys