2014-02-27 17:29:08 +01:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
|
|
|
#include "edit_points.h"
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
|
|
|
|
EDIT_POINTS::EDIT_POINTS( EDA_ITEM* aParent ) :
|
|
|
|
EDA_ITEM( NOT_USED ), m_parent( aParent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation )
|
|
|
|
{
|
|
|
|
float size = m_view->ToWorld( EDIT_POINT::POINT_SIZE );
|
|
|
|
|
|
|
|
std::deque<EDIT_POINT>::iterator it, itEnd;
|
|
|
|
for( it = m_points.begin(), itEnd = m_points.end(); it != itEnd; ++it )
|
|
|
|
{
|
|
|
|
EDIT_POINT& point = *it;
|
|
|
|
|
|
|
|
if( point.WithinPoint( aLocation, size ) )
|
|
|
|
return &point;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
|
|
|
|
{
|
2014-03-06 14:41:25 +01:00
|
|
|
aGal->SetFillColor( KIGFX::COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
2014-02-27 17:29:08 +01:00
|
|
|
aGal->SetIsFill( true );
|
|
|
|
aGal->SetIsStroke( false );
|
|
|
|
aGal->PushDepth();
|
|
|
|
aGal->SetLayerDepth( -512.0 ); // TODO no hardcoded depths?
|
|
|
|
|
|
|
|
float size = m_view->ToWorld( EDIT_POINT::POINT_SIZE );
|
|
|
|
|
|
|
|
BOOST_FOREACH( const EDIT_POINT& point, m_points )
|
|
|
|
aGal->DrawRectangle( point.GetPosition() - size / 2, point.GetPosition() + size / 2 );
|
|
|
|
|
|
|
|
aGal->PopDepth();
|
|
|
|
}
|