Commit baa278a3 authored by charras's avatar charras
Browse files

More about ERC and markers in eeschema ( work in progress )

parent e4656c44
Loading
Loading
Loading
Loading
+28 −24
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@
// Default marquer shape:
#define M_SHAPE_SCALE 6     // default scaling factor for MarkerShapeCorners coordinates
#define CORNERS_COUNT 8
// corners of the default shape
static wxPoint MarkerShapeCorners[CORNERS_COUNT] =
/* corners of the default shape
 * real coordinates are these values * .m_ScalingFactor
*/
static const wxPoint MarkerShapeCorners[CORNERS_COUNT] =
{
    wxPoint( 0,  0 ),
    wxPoint( 8,  1 ),
@@ -39,13 +41,20 @@ void MARKER_BASE::init()
{
    m_MarkerType = 0;
    m_Color = RED;
    wxPoint start = MarkerShapeCorners[0];
    wxPoint end = MarkerShapeCorners[0];
    for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ )
    {
        wxPoint corner = MarkerShapeCorners[ii];
        m_Corners.push_back( corner );
        m_Size.x = MAX( m_Size.x, corner.x);
        m_Size.y = MAX( m_Size.y, corner.y);
        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);
    }

    m_ShapeBoundingBox.SetOrigin(start);
    m_ShapeBoundingBox.SetEnd(end);
}


@@ -103,24 +112,15 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
}


/**********************************************/
/******************************************************/
bool MARKER_BASE::HitTestMarker( const wxPoint& refPos )
/**********************************************/
/******************************************************/
{
    int     dx = refPos.x - m_Pos.x;
    int     dy = refPos.y - m_Pos.y;

    wxSize Realsize = m_Size;
    Realsize.x *= m_ScalingFactor;
    Realsize.y *= m_ScalingFactor;

    /* is refPos in the box: Marker size to right an bottom,
     *  or size/2 to left or top */
    if( dx <= Realsize.x  && dy <= Realsize.y
        && dx >= -Realsize.x / 2  && dy >= -Realsize.y / 2 )
        return true;
    else
        return false;
    wxPoint rel_pos = refPos - m_Pos;
    rel_pos.x /= m_ScalingFactor;
    rel_pos.y /= m_ScalingFactor;

    return m_ShapeBoundingBox.Inside(rel_pos);
}

/**
@@ -132,10 +132,14 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos )
 */
EDA_Rect MARKER_BASE::GetBoundingBoxMarker()
{
    wxSize Realsize = m_Size;
    Realsize.x *= m_ScalingFactor;
    Realsize.y *= m_ScalingFactor;
    return EDA_Rect( m_Pos,Realsize );
    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;
    return EDA_Rect( m_Pos,realsize );
}

/**********************************************************************/
+12 −3
Original line number Diff line number Diff line
@@ -11,20 +11,29 @@

DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	this->SetSizeHints( wxSize( 400,170 ), wxDefaultSize );
	
	wxBoxSizer* bMainSizer;
	bMainSizer = new wxBoxSizer( wxVERTICAL );
	
	m_htmlWindow = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
	m_htmlWindow->SetMinSize( wxSize( 400,150 ) );
	
	bMainSizer->Add( m_htmlWindow, 1, wxALL|wxEXPAND, 5 );
	
	m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonClose->SetDefault(); 
	bMainSizer->Add( m_buttonClose, 0, wxALL|wxALIGN_RIGHT, 5 );
	
	this->SetSizer( bMainSizer );
	this->Layout();
	
	// Connect Events
	m_htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this );
	m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnCloseButtonClick ), NULL, this );
}

DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE()
{
	// Disconnect Events
	m_htmlWindow->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this );
	m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnCloseButtonClick ), NULL, this );
}
+57 −5
Original line number Diff line number Diff line
@@ -29,10 +29,10 @@
            <property name="hidden">0</property>
            <property name="id">wxID_ANY</property>
            <property name="maximum_size"></property>
            <property name="minimum_size"></property>
            <property name="minimum_size">400,170</property>
            <property name="name">DIALOG_DISPLAY_HTML_TEXT_BASE</property>
            <property name="pos"></property>
            <property name="size">291,165</property>
            <property name="size">431,170</property>
            <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
            <property name="subclass"></property>
            <property name="title"></property>
@@ -71,7 +71,7 @@
            <event name="OnSize"></event>
            <event name="OnUpdateUI"></event>
            <object class="wxBoxSizer" expanded="1">
                <property name="minimum_size"></property>
                <property name="minimum_size">-1,-1</property>
                <property name="name">bMainSizer</property>
                <property name="orient">wxVERTICAL</property>
                <property name="permission">none</property>
@@ -88,7 +88,7 @@
                        <property name="hidden">0</property>
                        <property name="id">wxID_ANY</property>
                        <property name="maximum_size"></property>
                        <property name="minimum_size">400,150</property>
                        <property name="minimum_size">-1,-1</property>
                        <property name="name">m_htmlWindow</property>
                        <property name="permission">public</property>
                        <property name="pos"></property>
@@ -104,7 +104,59 @@
                        <event name="OnEraseBackground"></event>
                        <event name="OnHtmlCellClicked"></event>
                        <event name="OnHtmlCellHover"></event>
                        <event name="OnHtmlLinkClicked"></event>
                        <event name="OnHtmlLinkClicked">OnHTMLLinkClicked</event>
                        <event name="OnKeyDown"></event>
                        <event name="OnKeyUp"></event>
                        <event name="OnKillFocus"></event>
                        <event name="OnLeaveWindow"></event>
                        <event name="OnLeftDClick"></event>
                        <event name="OnLeftDown"></event>
                        <event name="OnLeftUp"></event>
                        <event name="OnMiddleDClick"></event>
                        <event name="OnMiddleDown"></event>
                        <event name="OnMiddleUp"></event>
                        <event name="OnMotion"></event>
                        <event name="OnMouseEvents"></event>
                        <event name="OnMouseWheel"></event>
                        <event name="OnPaint"></event>
                        <event name="OnRightDClick"></event>
                        <event name="OnRightDown"></event>
                        <event name="OnRightUp"></event>
                        <event name="OnSetFocus"></event>
                        <event name="OnSize"></event>
                        <event name="OnUpdateUI"></event>
                    </object>
                </object>
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="flag">wxALL|wxALIGN_RIGHT</property>
                    <property name="proportion">0</property>
                    <object class="wxButton" expanded="1">
                        <property name="bg"></property>
                        <property name="context_help"></property>
                        <property name="default">1</property>
                        <property name="enabled">1</property>
                        <property name="fg"></property>
                        <property name="font"></property>
                        <property name="hidden">0</property>
                        <property name="id">wxID_CANCEL</property>
                        <property name="label">Close</property>
                        <property name="maximum_size"></property>
                        <property name="minimum_size"></property>
                        <property name="name">m_buttonClose</property>
                        <property name="permission">protected</property>
                        <property name="pos"></property>
                        <property name="size"></property>
                        <property name="style"></property>
                        <property name="subclass"></property>
                        <property name="tooltip"></property>
                        <property name="window_extra_style"></property>
                        <property name="window_name"></property>
                        <property name="window_style"></property>
                        <event name="OnButtonClick">OnCloseButtonClick</event>
                        <event name="OnChar"></event>
                        <event name="OnEnterWindow"></event>
                        <event name="OnEraseBackground"></event>
                        <event name="OnKeyDown"></event>
                        <event name="OnKeyUp"></event>
                        <event name="OnKillFocus"></event>
+17 −6
Original line number Diff line number Diff line
@@ -86,19 +86,30 @@ void MARKER_SCH::Show( int nestLevel, std::ostream& os )
 * 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.
 * Currently: do nothing (markers are no more saved in files)
 */
bool MARKER_SCH::Save( FILE* aFile ) const
{
    bool     success = true;
    wxString msg     = GetReporter().GetMainText();
#if 0
    wxString msg     = m_drc.GetMainText();

    if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X T=%X\n",
    if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\"",
                GetMarkerType() + 'A', GetPos().x, GetPos().y,
                CONV_TO_UTF8( msg ), GetErrorLevel(), GetReporter().GetErrorCode() ) == EOF )
                CONV_TO_UTF8( msg ) ) == EOF )
        success = false;

    if ( m_drc.HasSecondItem() )
    {
            msg     = GetReporter().GetAuxiliaryText();
        if( fprintf( aFile, " \"%s\" %-4d %-4d",
                    GetMarkerType() + 'A', m_drc.GetPointB().x, m_drc.GetPointB().y,
                    CONV_TO_UTF8( msg ) ) == EOF )
            success = false;
    }

    if( fprintf( aFile, " F=%X T=%X\n",
                GetErrorLevel(), GetReporter().GetErrorCode() ) == EOF )
#endif
    return success;
}

@@ -149,7 +160,7 @@ void MARKER_SCH::DisplayMarkerInfo( WinEDA_SchematicFrame* aFrame )
    wxString msg = GetReporter().ShowHtml();

    DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( aFrame, -1, wxEmptyString,
                                              wxGetMousePosition(), wxSize( 550, 130 ) );
                                              wxGetMousePosition(), wxSize( 550, 170 ) );

    infodisplay.m_htmlWindow->SetPage( msg );
    infodisplay.ShowModal();
+0 −11
Original line number Diff line number Diff line
@@ -124,17 +124,6 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
    wxString       msg;
    int            ii;

    DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), MARKERITEM );
    if( DrawStruct )
    {
        MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct;
        Text = Marker->GetReporter().GetErrorText();
        ii = Marker->GetMarkerType();
        msg = NameMarqueurType[ii]; msg << wxT( " " ) << Text;
        Affiche_Message( msg );
        return DrawStruct;
    }

    DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), NOCONNECTITEM );
    if( DrawStruct )
    {
Loading