Commit baa278a3 authored by charras's avatar charras

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

parent e4656c44
......@@ -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 );
}
/**********************************************************************/
......
......@@ -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 );
}
......@@ -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>
......
......@@ -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();
......
......@@ -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 )
{
......
......@@ -165,6 +165,53 @@ static int MinimalReq[PIN_NMAX][PIN_NMAX] =
};
/**Function TestDuplicateSheetNames( )
* inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
*/
int TestDuplicateSheetNames( )
{
int err_count = 0;
EDA_ScreenList ScreenList; // Created the list of screen
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
{
for( SCH_ITEM* ref_item = Screen->EEDrawList; ref_item != NULL; ref_item = ref_item->Next() )
{
// search for a scheet;
if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL;
item_to_test = item_to_test->Next() )
{
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
// We have found a second sheet: compare names
if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase( ( (DrawSheetStruct*)
item_to_test )->
m_SheetName ) == 0 )
{
/* Create a new marker type ERC error*/
MARKER_SCH* Marker = new MARKER_SCH();
Marker->m_TimeStamp = GetTimeStamp();
Marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
( (DrawSheetStruct*) item_to_test )->m_Pos,
_( "Duplicate Sheet name" ),
( (DrawSheetStruct*) item_to_test )->m_Pos );
Marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( ERR );
Marker->SetNext( Screen->EEDrawList );
Screen->EEDrawList = Marker;
err_count++;
}
}
}
}
return err_count;
}
/**************************************************/
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/**************************************************/
......@@ -219,43 +266,10 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/* Test duplicate sheet names
* inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
* Test screens is enought
*/
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
{
for( SCH_ITEM* ref_item = Screen->EEDrawList; ref_item != NULL; ref_item = ref_item->Next() )
{
// serach for a scheet;
if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL;
item_to_test = item_to_test->Next() )
{
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
// We have found a second sheet: compare names
if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase( ( (DrawSheetStruct*)
item_to_test )->
m_SheetName ) == 0 )
{
/* Create a new marker type ERC error*/
MARKER_SCH* Marker = new MARKER_SCH();
Marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
( (DrawSheetStruct*) item_to_test )->m_Pos,
_( "Duplicate Sheet name" ),
( (DrawSheetStruct*) item_to_test )->m_Pos );
Marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( ERR );
Marker->SetNext( Screen->EEDrawList );
Screen->EEDrawList = Marker;
g_EESchemaVar.NbErrorErc++;
g_EESchemaVar.NbWarningErc++;
}
}
}
}
int errcnt = TestDuplicateSheetNames( );
g_EESchemaVar.NbErrorErc += errcnt;
g_EESchemaVar.NbWarningErc += errcnt;
m_Parent->BuildNetListBase();
......@@ -388,6 +402,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
/* Creation du nouveau marqueur type Erreur ERC */
Marker = new MARKER_SCH();
Marker->m_TimeStamp = GetTimeStamp();
Marker->SetMarkerType( MARK_ERC );
Marker->SetErrorLevel( WAR );
......@@ -430,7 +445,8 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
if( aMinConn == NOC ) /* 1 seul element dans le net */
{
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
cmp_ref.GetData(), string_pinnum.GetData(), MsgPinElectricType[ii] );
cmp_ref.GetData(), string_pinnum.GetData(),
MsgPinElectricType[ii] );
Marker->SetData( ERCE_PIN_NOT_CONNECTED,
aNetItemRef->m_Start,
msg,
......@@ -522,15 +538,15 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
NetItemTst = netstart;
local_minconn = NOC;
/* Examen de la liste des Pins connectees a NetItemRef */
/* Test pins Pins connected to NetItemRef */
for( ; ; NetItemTst++ )
{
if( NetItemRef == NetItemTst )
continue;
/* Est - on toujours dans le meme net ? */
if( (NetItemTst >= Lim) // fin de liste (donc fin de net)
|| ( NetItemRef->GetNet() != NetItemTst->GetNet() ) ) // fin de net
/* We examine only a given net. We stop the search if the net changes */
if( (NetItemTst >= Lim) // End of list
|| ( NetItemRef->GetNet() != NetItemTst->GetNet() ) ) // End of net
{
/* Fin de netcode trouve: Tst connexion minimum */
if( (*MinConnexion < NET_NC )
......
......@@ -50,7 +50,6 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen,
DrawPolylineStruct* PolylineStruct;
EDA_DrawLineStruct* SegmentStruct;
DrawBusEntryStruct* RaccordStruct;
MARKER_SCH* Marker;
DrawNoConnectStruct* NoConnectStruct;
int LineCount;
wxString MsgDiag; /* Error and log messages */
......@@ -325,6 +324,7 @@ at line %d, aborted" ),
break;
case 'K': /* It is a Marker item. */
#if 0 // Markers are no more read from file
if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 )
{
MsgDiag.Printf( wxT( "EESchema file marker struct error line %d, aborted" ),
......@@ -338,7 +338,7 @@ at line %d, aborted" ),
char BufLine[1024];
BufLine[0] = 0;
int errtype = 0;
Marker = new MARKER_SCH( );
MARKER_SCH* Marker = new MARKER_SCH( );
ii = ReadDelimitedText( BufLine, Line, 1024 );
int type = (TypeMarker) ( (Name1[0] & 255) - 'A' );
if( type < 0 || type >= MARK_NMAX)
......@@ -360,6 +360,7 @@ at line %d, aborted" ),
Marker->SetNext( screen->EEDrawList );
screen->EEDrawList = Marker;
}
#endif
break;
case 'T': /* It is a text item. */
......
......@@ -12,6 +12,8 @@
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
static wxArrayString s_CmpNameList;
......@@ -369,6 +371,10 @@ void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->MouseToCursorSchema();
break;
case DRAW_MARKER_STRUCT_TYPE:
((MARKER_SCH*)DrawStruct)->DisplayMarkerInfo( this);
break;
default:
break;
}
......
......@@ -15,7 +15,7 @@ protected:
std::vector <wxPoint> m_Corners; ///< Corner list for shape definition (a polygon)
int m_MarkerType; ///< Can be used as a flag
EDA_Colors m_Color; ///< color
wxSize m_Size; ///< Size of the graphic symbol, used for Hit Tests
EDA_Rect m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative to the position of the shape, used for Hit Tests
int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can set the physical size
DRC_ITEM m_drc;
......@@ -23,7 +23,7 @@ protected:
public:
MARKER_BASE( );
MARKER_BASE();
/**
* Constructor
......@@ -37,6 +37,7 @@ public:
MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos );
/**
* Constructor
* @param aErrorCode The categorizing identifier for an error
......@@ -68,22 +69,24 @@ public:
/** Function SetColor
* Set the color of this marker
*/
void SetColor(EDA_Colors aColor )
void SetColor( EDA_Colors aColor )
{
m_Color = aColor;
}
/** Function to set/get error levels (warning, fatal ..)
* this value is stored in m_MarkerType
*/
void SetErrorLevel(int aErrorLevel )
void SetErrorLevel( int aErrorLevel )
{
m_MarkerType &= ~0xFF00;
aErrorLevel &= 0xFF;
m_MarkerType |= aErrorLevel << 8;
}
int GetErrorLevel( ) const
int GetErrorLevel() const
{
return (m_MarkerType >> 8) & 0xFF;
}
......@@ -92,18 +95,20 @@ public:
/** Functions to set/get marker type (DRC, ERC, or other)
* this value is stored in m_MarkerType
*/
void SetMarkerType(int aMarkerType )
void SetMarkerType( int aMarkerType )
{
m_MarkerType &= ~0xFF;
aMarkerType &= 0xFF;
m_MarkerType |= aMarkerType;
}
int GetMarkerType( ) const
int GetMarkerType() const
{
return m_MarkerType & 0xFF;
}
/**
* Function SetData
* fills in all the reportable data associated with a MARKER.
......@@ -140,6 +145,7 @@ public:
m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
}
/**
* Function GetReporter
* returns the DRC_ITEM held within this MARKER so that its
......
......@@ -16,6 +16,7 @@
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
......@@ -30,10 +31,16 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public wxDialog
private:
protected:
wxButton* m_buttonClose;
// Virtual event handlers, overide them in your derived class
virtual void OnHTMLLinkClicked( wxHtmlLinkEvent& event ){ event.Skip(); }
virtual void OnCloseButtonClick( wxCommandEvent& event ){ event.Skip(); }
public:
wxHtmlWindow* m_htmlWindow;
DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 291,165 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 431,180 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_DISPLAY_HTML_TEXT_BASE();
};
......
No preview for this file type
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment