2009-12-02 21:44:03 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* Schematic marker object implementation. */
|
|
|
|
/*******************************************/
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxstruct.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "common.h"
|
2010-09-05 17:01:48 +00:00
|
|
|
#include "trigo.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "general.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_marker.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
#include "erc.h"
|
|
|
|
|
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" ),
|
|
|
|
wxT( "?????" )
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**************************/
|
2009-12-02 21:44:03 +00:00
|
|
|
/* class SCH_MARKER */
|
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( const SCH_MARKER& aMarker ) :
|
|
|
|
SCH_ITEM( aMarker ),
|
|
|
|
MARKER_BASE( aMarker )
|
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
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
EDA_ITEM* SCH_MARKER::doClone() const
|
|
|
|
{
|
|
|
|
return new SCH_MARKER( *this );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void SCH_MARKER::Show( int nestLevel, std::ostream& os )
|
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,
|
2009-07-08 15:42:45 +00:00
|
|
|
const wxPoint& aOffset, int aDrawMode, int aColor )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
EDA_Colors color = (EDA_Colors) m_Color;
|
2009-07-08 15:42:45 +00:00
|
|
|
EDA_Colors tmp = color;
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
if( GetMarkerType() == MARK_ERC )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
color = ( GetErrorLevel() == WAR ) ?
|
2009-07-08 15:42:45 +00:00
|
|
|
(EDA_Colors) g_LayerDescr.LayerColor[LAYER_ERC_WARN] :
|
|
|
|
(EDA_Colors) g_LayerDescr.LayerColor[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
|
|
|
|
m_Color = (EDA_Colors) aColor;
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
EDA_Rect SCH_MARKER::GetBoundingBox() const
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
|
|
|
return GetBoundingBoxMarker();
|
|
|
|
}
|
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_MARKER::DisplayInfo( EDA_DRAW_FRAME* aFrame )
|
2010-04-06 14:09:52 +00:00
|
|
|
{
|
|
|
|
if( aFrame == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
aFrame->ClearMsgPanel();
|
|
|
|
aFrame->AppendMsgPanel( _( "Electronics rule check error" ),
|
|
|
|
GetReporter().GetErrorText(), DARKRED );
|
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_MARKER::Rotate( wxPoint rotationPoint )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_Pos, rotationPoint, 900 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_MARKER::Mirror_X( int aXaxis_position )
|
|
|
|
{
|
|
|
|
m_Pos.y -= aXaxis_position;
|
|
|
|
m_Pos.y = -m_Pos.y;
|
|
|
|
m_Pos.y += aXaxis_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_MARKER::Mirror_Y( int aYaxis_position )
|
|
|
|
{
|
|
|
|
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 ) )
|
|
|
|
m_Flags |= SELECTED;
|
|
|
|
else
|
|
|
|
m_Flags &= ~SELECTED;
|
|
|
|
|
|
|
|
return previousState != IsSelected();
|
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
bool SCH_MARKER::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
|
|
|
if( !( aFilter & MARKER_T ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return HitTestMarker( aPoint );
|
|
|
|
}
|
|
|
|
|