2009-12-02 21:44:03 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* Schematic marker object implementation. */
|
|
|
|
/*******************************************/
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
2010-09-05 17:01:48 +00:00
|
|
|
#include "trigo.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
#include "class_marker_sch.h"
|
|
|
|
#include "erc.h"
|
|
|
|
|
|
|
|
/* 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
|
|
|
/**************************/
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER::SCH_MARKER() : SCH_ITEM( NULL, TYPE_SCH_MARKER ), 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 ) :
|
|
|
|
SCH_ITEM( NULL, TYPE_SCH_MARKER ),
|
2009-07-08 15:42:45 +00:00
|
|
|
MARKER_BASE( 0, pos, text, pos )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER::~SCH_MARKER()
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER* SCH_MARKER::GenCopy()
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER* newitem = new SCH_MARKER( GetPos(),
|
2010-09-05 17:01:48 +00:00
|
|
|
GetReporter().GetMainText() );
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
newitem->SetMarkerType( GetMarkerType() );
|
|
|
|
newitem->SetErrorLevel( GetErrorLevel() );
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
return newitem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void SCH_MARKER::Draw( WinEDA_DrawPanel* 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-03-16 18:22:59 +00:00
|
|
|
bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData )
|
|
|
|
{
|
|
|
|
if( !SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) )
|
|
|
|
return SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData );
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
EDA_Rect SCH_MARKER::GetBoundingBox()
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
|
|
|
return GetBoundingBoxMarker();
|
|
|
|
}
|
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
void SCH_MARKER::DisplayInfo( WinEDA_DrawFrame* aFrame )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|