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>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <widgets/ui_common.h>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <erc_item.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
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
SCH_MARKER::SCH_MARKER( TYPEMARKER aType ) :
|
|
|
|
SCH_ITEM( nullptr, SCH_MARKER_T ),
|
|
|
|
MARKER_BASE( SCALING_FACTOR, new ERC_ITEM(), aType )
|
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
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
|
|
|
aCount = 2;
|
|
|
|
|
|
|
|
switch( g_ErcSettings->m_Severities[ m_rcItem->GetErrorCode() ] )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SEVERITY::RPT_SEVERITY_ERROR: aLayers[0] = LAYER_ERC_ERR; break;
|
|
|
|
case SEVERITY::RPT_SEVERITY_WARNING: aLayers[0] = LAYER_ERC_WARN; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_LAYER_ID SCH_MARKER::GetColorLayer() const
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2020-02-28 00:05:40 +00:00
|
|
|
if( IsExcluded() )
|
2020-03-16 11:05:01 +00:00
|
|
|
return LAYER_HIDDEN;
|
|
|
|
|
|
|
|
switch( g_ErcSettings->m_Severities[ m_rcItem->GetErrorCode() ] )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SEVERITY::RPT_SEVERITY_ERROR: return LAYER_ERC_ERR;
|
|
|
|
case SEVERITY::RPT_SEVERITY_WARNING: return LAYER_ERC_WARN;
|
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
KIGFX::COLOR4D SCH_MARKER::getColor() const
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
return colors->GetColor( GetColorLayer() );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void SCH_MARKER::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
PrintMarker( aSettings, aOffset );
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
|
2018-10-21 12:50:31 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
return SCH_ITEM::Matches( m_rcItem->GetErrorText(), aSearchData )
|
|
|
|
|| SCH_ITEM::Matches( m_rcItem->GetMainText(), aSearchData )
|
|
|
|
|| SCH_ITEM::Matches( m_rcItem->GetAuxText(), aSearchData );
|
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" ),
|
2020-03-16 11:05:01 +00:00
|
|
|
m_rcItem->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
|
|
|
}
|