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
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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 <wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <trigo.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <general.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <erc.h>
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
/* Marker are mainly used to show an ERC error
|
2009-12-02 21:44:03 +00:00
|
|
|
* but they could be used to give a specific info
|
2009-07-08 15:42:45 +00:00
|
|
|
*/
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
const wxChar* NameMarqueurType[] =
|
|
|
|
{
|
|
|
|
wxT( "" ),
|
|
|
|
wxT( "ERC" ),
|
|
|
|
wxT( "PCB" ),
|
|
|
|
wxT( "SIMUL" ),
|
2013-04-07 11:55:18 +00:00
|
|
|
wxT( "???" )
|
2009-07-07 17:50:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
/********************/
|
2009-12-02 21:44:03 +00:00
|
|
|
/* class SCH_MARKER */
|
2012-03-15 14:31:16 +00:00
|
|
|
/********************/
|
2009-07-07 17:50:02 +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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_MARKER::~SCH_MARKER()
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
/**
|
2009-07-10 12:29:31 +00:00
|
|
|
* Function Save (do nothing : markers are no more saved in files )
|
2009-07-07 17:50:02 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
bool SCH_MARKER::Save( FILE* aFile ) const
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2009-07-10 12:29:31 +00:00
|
|
|
return true;
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2012-09-02 12:06:47 +00:00
|
|
|
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2012-09-28 17:47:41 +00:00
|
|
|
EDA_COLOR_T color = m_Color;
|
2012-03-26 23:47:08 +00:00
|
|
|
EDA_COLOR_T tmp = color;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
if( GetMarkerType() == MARK_ERC )
|
|
|
|
{
|
2013-04-04 21:35:01 +00:00
|
|
|
color = ( GetErrorLevel() == WAR ) ? GetLayerColor( LAYER_ERC_WARN ) :
|
|
|
|
GetLayerColor( LAYER_ERC_ERR );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
if( aColor < 0 )
|
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
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, wxPoint * aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
if( !SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) )
|
2010-10-20 19:43:58 +00:00
|
|
|
{
|
|
|
|
if( SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData ) )
|
|
|
|
{
|
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = m_Pos;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = m_Pos;
|
2010-03-16 18:22:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
/**
|
|
|
|
* Function GetBoundingBox
|
|
|
|
* returns the orthogonal, bounding box of this object for display purposes.
|
|
|
|
* This box should be an enclosing perimeter for visible components of this
|
|
|
|
* object, and the units should be in the pcb or schematic coordinate system.
|
|
|
|
* It is OK to overestimate the size by a few counts.
|
|
|
|
*/
|
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
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
void SCH_MARKER::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
2010-04-06 14:09:52 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|