2009-07-06 18:02:26 +00:00
|
|
|
/**********************************************************************************
|
|
|
|
* class MARKER_BASE; markers are used to show something (usually a drc/erc problem)
|
|
|
|
* Markers in pcbnew and eeschema are derived from this basic class
|
|
|
|
**********************************************************************************/
|
|
|
|
|
|
|
|
/* file class_marker_base.cpp
|
2009-07-07 17:50:02 +00:00
|
|
|
*/
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "class_base_screen.h"
|
|
|
|
#include "common.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
#include "macros.h"
|
2009-07-06 18:02:26 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "class_marker_base.h"
|
2009-07-13 15:25:41 +00:00
|
|
|
#include "dialog_display_info_HTML_base.h"
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
// Default marquer shape:
|
|
|
|
#define M_SHAPE_SCALE 6 // default scaling factor for MarkerShapeCorners coordinates
|
|
|
|
#define CORNERS_COUNT 8
|
2009-07-09 17:02:15 +00:00
|
|
|
/* corners of the default shape
|
|
|
|
* real coordinates are these values * .m_ScalingFactor
|
|
|
|
*/
|
|
|
|
static const wxPoint MarkerShapeCorners[CORNERS_COUNT] =
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
wxPoint( 0, 0 ),
|
|
|
|
wxPoint( 8, 1 ),
|
|
|
|
wxPoint( 4, 3 ),
|
|
|
|
wxPoint( 13, 8 ),
|
|
|
|
wxPoint( 9, 9 ),
|
|
|
|
wxPoint( 8, 13 ),
|
|
|
|
wxPoint( 3, 4 ),
|
|
|
|
wxPoint( 1, 8 )
|
2009-07-06 18:02:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
/* Classe MARKER_BASE */
|
|
|
|
/*******************/
|
|
|
|
|
|
|
|
void MARKER_BASE::init()
|
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
m_MarkerType = 0;
|
|
|
|
m_Color = RED;
|
2009-07-09 17:02:15 +00:00
|
|
|
wxPoint start = MarkerShapeCorners[0];
|
|
|
|
wxPoint end = MarkerShapeCorners[0];
|
2009-07-07 17:50:02 +00:00
|
|
|
for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ )
|
|
|
|
{
|
|
|
|
wxPoint corner = MarkerShapeCorners[ii];
|
|
|
|
m_Corners.push_back( corner );
|
2009-07-09 17:02:15 +00:00
|
|
|
start.x = MIN( start.x, corner.x);
|
|
|
|
start.y = MIN( start.y, corner.y);
|
|
|
|
end.x = MAX( end.x, corner.x);
|
|
|
|
end.y = MAX( end.y, corner.y);
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
2009-07-09 17:02:15 +00:00
|
|
|
|
|
|
|
m_ShapeBoundingBox.SetOrigin(start);
|
|
|
|
m_ShapeBoundingBox.SetEnd(end);
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker )
|
|
|
|
{
|
|
|
|
m_Pos = aMarker.m_Pos;
|
|
|
|
m_Corners = aMarker.m_Corners;
|
|
|
|
m_MarkerType = aMarker.m_MarkerType;
|
|
|
|
m_Color = aMarker.m_Color;
|
|
|
|
m_ShapeBoundingBox = aMarker.m_ShapeBoundingBox;
|
|
|
|
m_ScalingFactor = aMarker.m_ScalingFactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
MARKER_BASE::MARKER_BASE()
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
m_ScalingFactor = M_SHAPE_SCALE;
|
2009-07-06 18:02:26 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
2009-07-07 17:50:02 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos,
|
|
|
|
const wxString& bText, const wxPoint& bPos )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
m_ScalingFactor = M_SHAPE_SCALE;
|
2009-07-06 18:02:26 +00:00
|
|
|
init();
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
SetData( aErrorCode, aMarkerPos,
|
|
|
|
aText, aPos,
|
|
|
|
bText, bPos );
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
|
2009-07-07 17:50:02 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
m_ScalingFactor = M_SHAPE_SCALE;
|
2009-07-06 18:02:26 +00:00
|
|
|
init();
|
|
|
|
SetData( aErrorCode, aMarkerPos, aText, aPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MARKER_BASE::~MARKER_BASE()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
2009-07-07 17:50:02 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos,
|
|
|
|
const wxString& bText, const wxPoint& bPos )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
|
|
|
m_Pos = aMarkerPos;
|
|
|
|
m_drc.SetData( aErrorCode,
|
2009-07-07 17:50:02 +00:00
|
|
|
aText, bText, aPos, bPos );
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
2009-07-07 17:50:02 +00:00
|
|
|
const wxString& aText, const wxPoint& aPos )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
|
|
|
m_Pos = aMarkerPos;
|
|
|
|
m_drc.SetData( aErrorCode,
|
2009-07-07 17:50:02 +00:00
|
|
|
aText, aPos );
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-09 17:02:15 +00:00
|
|
|
wxPoint rel_pos = refPos - m_Pos;
|
|
|
|
rel_pos.x /= m_ScalingFactor;
|
|
|
|
rel_pos.y /= m_ScalingFactor;
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
return m_ShapeBoundingBox.Contains( rel_pos );
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2009-07-09 17:02:15 +00:00
|
|
|
wxSize realsize = m_ShapeBoundingBox.GetSize();
|
|
|
|
wxPoint realposition = m_ShapeBoundingBox.GetPosition();
|
|
|
|
realsize.x *= m_ScalingFactor;
|
|
|
|
realsize.y *= m_ScalingFactor;
|
|
|
|
realposition.x *= m_ScalingFactor;
|
|
|
|
realposition.y *= m_ScalingFactor;
|
|
|
|
realposition += m_Pos;
|
2010-12-10 19:47:44 +00:00
|
|
|
return EDA_Rect( m_Pos, realsize );
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
|
|
|
|
const wxPoint& aOffset )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
wxPoint corners[CORNERS_COUNT];
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
for( unsigned ii = 0; ii < m_Corners.size(); ii++ )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
corners[ii] = m_Corners[ii];
|
|
|
|
corners[ii].x *= m_ScalingFactor;
|
|
|
|
corners[ii].y *= m_ScalingFactor;
|
|
|
|
corners[ii] += m_Pos + aOffset;
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
GRClosedPoly( &aPanel->m_ClipBox, aDC, CORNERS_COUNT, corners,
|
|
|
|
true, // = Filled
|
|
|
|
0, // outline width
|
|
|
|
m_Color, // outline color
|
|
|
|
m_Color // fill collor
|
|
|
|
);
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
2009-07-13 15:25:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MARKER_BASE::DisplayMarkerInfo( WinEDA_DrawFrame* aFrame )
|
|
|
|
{
|
|
|
|
wxString msg = m_drc.ShowHtml();
|
2010-12-21 15:13:09 +00:00
|
|
|
DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ),
|
|
|
|
wxGetMousePosition(), wxSize( 550, 140 ) );
|
2009-07-13 15:25:41 +00:00
|
|
|
|
|
|
|
infodisplay.m_htmlWindow->SetPage( msg );
|
|
|
|
infodisplay.ShowModal();
|
|
|
|
}
|