2012-03-15 14:31:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2019-04-04 22:49:49 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-03-15 14:31:16 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trigo.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-12-19 14:07:07 +00:00
|
|
|
#include <base_units.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <sch_marker.h>
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2018-12-19 14:07:07 +00:00
|
|
|
/// Factor to convert the maker unit shape to internal units:
|
|
|
|
#define SCALING_FACTOR Millimeter2iu( 0.1 )
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE( SCALING_FACTOR )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
|
2010-12-10 19:47:44 +00:00
|
|
|
SCH_ITEM( NULL, SCH_MARKER_T ),
|
2018-12-19 18:53:27 +00:00
|
|
|
MARKER_BASE( 0, pos, text, pos, SCALING_FACTOR )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_MARKER::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_MARKER( *this );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-29 21:17:26 +00:00
|
|
|
void SCH_MARKER::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
std::swap( *((SCH_MARKER*) this), *((SCH_MARKER*) aItem ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
// for now, make it look like XML:
|
2019-08-07 18:23:59 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos() << "/>\n";
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
void SCH_MARKER::Print( wxDC* aDC, const wxPoint& aOffset )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
COLOR4D tmp = m_Color;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
if( GetMarkerType() == MARKER_BASE::MARKER_ERC )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2019-04-04 22:49:49 +00:00
|
|
|
m_Color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ?
|
|
|
|
GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
PrintMarker( aDC, aOffset );
|
2009-07-07 17:50:02 +00:00
|
|
|
m_Color = tmp;
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2019-05-19 21:04:04 +00:00
|
|
|
return SCH_ITEM::Matches( m_drc.GetErrorText(), aSearchData )
|
|
|
|
|| SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData )
|
|
|
|
|| SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData );
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-21 12:50:31 +00:00
|
|
|
void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
2019-08-07 18:23:59 +00:00
|
|
|
aCount = 2;
|
|
|
|
aLayers[0] = this->m_ErrorLevel == MARKER_SEVERITY_ERROR ? LAYER_ERC_ERR : LAYER_ERC_WARN;
|
|
|
|
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
2018-10-21 12:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_MARKER::GetBoundingBox() const
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
|
|
|
return GetBoundingBoxMarker();
|
|
|
|
}
|
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
void SCH_MARKER::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList )
|
2010-04-06 14:09:52 +00:00
|
|
|
{
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
|
2013-01-12 17:32:24 +00:00
|
|
|
GetReporter().GetErrorText(), DARKRED ) );
|
2010-04-06 14:09:52 +00:00
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF SCH_MARKER::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return erc_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_MARKER::Rotate( wxPoint aPosition )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
RotatePoint( &m_Pos, aPosition, 900 );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_MARKER::MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
m_Pos.y -= aXaxis_position;
|
|
|
|
m_Pos.y = -m_Pos.y;
|
|
|
|
m_Pos.y += aXaxis_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_MARKER::MirrorY( int aYaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
m_Pos.x -= aYaxis_position;
|
|
|
|
m_Pos.x = -m_Pos.x;
|
|
|
|
m_Pos.x += aYaxis_position;
|
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2019-05-05 10:33:34 +00:00
|
|
|
return HitTestMarker( aPosition, aAccuracy );
|
2010-12-13 15:59:00 +00:00
|
|
|
}
|