2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
|
|
|
* @file sch_polyline.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SCH_POLYLINE_H_
|
|
|
|
#define _SCH_POLYLINE_H_
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_item_struct.h>
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SCH_POLYLINE : public SCH_ITEM
|
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
int m_width; // Thickness
|
2011-12-08 15:45:01 +00:00
|
|
|
std::vector<wxPoint> m_points; // list of points (>= 2)
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SCH_POLYLINE( int layer = LAYER_NOTES );
|
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
~SCH_POLYLINE();
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxString GetClass() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return wxT( "SCH_POLYLINE" );
|
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
|
|
|
int aDrawMode, int aColor = -1 );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
bool Save( FILE* aFile ) const;
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool Load( LINE_READER& aLine, wxString& aErrorMsg );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AddPoint
|
2011-12-08 15:45:01 +00:00
|
|
|
* add a corner to m_points
|
2010-12-21 15:13:09 +00:00
|
|
|
*/
|
|
|
|
void AddPoint( const wxPoint& point )
|
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
m_points.push_back( point );
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetPoint
|
|
|
|
* sets the point at \a aIndex in the list to \a aPoint.
|
|
|
|
*
|
|
|
|
* @param aIndex The index in the point list.
|
|
|
|
* @param aPoint The new point value.
|
|
|
|
*/
|
|
|
|
void SetPoint( int aIndex, const wxPoint& aPoint )
|
|
|
|
{
|
|
|
|
// (unsigned) excludes aIndex<0 also
|
|
|
|
wxCHECK_RET( (unsigned)aIndex < m_points.size(),
|
|
|
|
wxT( "Invalid SCH_POLYLINE point list index." ) );
|
|
|
|
|
|
|
|
m_points[ aIndex ] = aPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
|
|
|
* Function GetCornerCount
|
|
|
|
* @return the number of corners
|
|
|
|
*/
|
2011-12-08 15:45:01 +00:00
|
|
|
unsigned GetCornerCount() const { return m_points.size(); }
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
int GetPenSize() const;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Move( const wxPoint& aMoveVector )
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_points[ii] += aMoveVector;
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void MirrorY( int aYaxis_position );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void MirrorX( int aXaxis_position );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void Rotate( wxPoint aPosition );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxString GetSelectMenuText() const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
BITMAP_DEF GetMenuImage() const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
/**
|
|
|
|
* Function operator[]
|
|
|
|
* is used for read only access and returns the point at \a aIndex.
|
|
|
|
* @param aIndex The index of the list of points to return.
|
|
|
|
* @return A wxPoint object containing the point at \a aIndex.
|
|
|
|
*/
|
|
|
|
wxPoint operator[]( int aIndex ) const
|
|
|
|
{
|
|
|
|
// (unsigned) excludes aIndex<0 also
|
|
|
|
wxCHECK_MSG( (unsigned)aIndex < m_points.size(), wxDefaultPosition,
|
|
|
|
wxT( "Invalid SCH_POLYLINE point list index." ) );
|
|
|
|
|
|
|
|
return m_points[ aIndex ];
|
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxPoint GetPosition() const { return m_points[0]; }
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition );
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
|
2012-03-15 14:31:16 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained = false,
|
2012-03-15 14:31:16 +00:00
|
|
|
int aAccuracy = 0 ) const;
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
EDA_ITEM* Clone() const;
|
2012-03-17 14:39:27 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
|
|
|
#endif
|
2010-12-21 15:13:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _SCH_POLYLINE_H_
|