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
|
2017-11-18 13:10:32 +00:00
|
|
|
* Copyright (C) 1992-2017 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sch_marker.cpp
|
|
|
|
* @brief Class SCH_MARKER implementation
|
|
|
|
*/
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#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>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <erc.h>
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, SCH_MARKER_T ), MARKER_BASE()
|
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 ),
|
2009-07-08 15:42:45 +00:00
|
|
|
MARKER_BASE( 0, pos, text, pos )
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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:
|
2009-12-02 21:44:03 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
|
|
|
<< GetPos() << "/>\n";
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2017-02-20 16:57:41 +00:00
|
|
|
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D color = m_Color;
|
|
|
|
COLOR4D tmp = 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
|
|
|
{
|
2015-07-29 18:48:20 +00:00
|
|
|
color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ?
|
|
|
|
GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
if( aColor == COLOR4D::UNSPECIFIED )
|
2009-07-07 17:50:02 +00:00
|
|
|
m_Color = color;
|
|
|
|
else
|
2012-09-02 12:06:47 +00:00
|
|
|
m_Color = aColor;
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
DrawMarker( aPanel, aDC, aDrawMode, aOffset );
|
|
|
|
m_Color = tmp;
|
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2015-01-20 12:06:44 +00:00
|
|
|
bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
|
|
|
|
wxPoint * aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2015-01-20 12:06:44 +00:00
|
|
|
if( SCH_ITEM::Matches( m_drc.GetErrorText(), aSearchData ) ||
|
|
|
|
SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) ||
|
|
|
|
SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData ) )
|
2010-10-20 19:43:58 +00:00
|
|
|
{
|
2015-01-20 12:06:44 +00:00
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = m_Pos;
|
|
|
|
|
|
|
|
return true;
|
2010-10-20 19:43:58 +00:00
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2015-01-20 12:06:44 +00:00
|
|
|
return false;
|
2010-03-16 18:22:59 +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
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
void SCH_MARKER::GetMsgPanelInfo( EDA_UNITS_T 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
|
|
|
|
|
|
|
|
|
|
|
bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
|
|
|
|
{
|
|
|
|
bool previousState = IsSelected();
|
|
|
|
|
|
|
|
if( aRect.Contains( m_Pos ) )
|
2013-03-30 19:55:26 +00:00
|
|
|
SetFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
else
|
2013-03-30 19:55:26 +00:00
|
|
|
ClearFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
return previousState != IsSelected();
|
|
|
|
}
|
2010-12-13 15:59:00 +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
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
return HitTestMarker( aPosition );
|
2010-12-13 15:59:00 +00:00
|
|
|
}
|