Commit 6d930ede authored by charras's avatar charras

work in progress about ERC and markers in eeschema

parent 0d2ee0c0
...@@ -4,51 +4,54 @@ ...@@ -4,51 +4,54 @@
**********************************************************************************/ **********************************************************************************/
/* file class_marker_base.cpp /* file class_marker_base.cpp
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "class_base_screen.h" #include "class_base_screen.h"
#include "common.h" #include "common.h"
#include "macros.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "class_marker_base.h" #include "class_marker_base.h"
/* Default bitmap shape for markers */ // Default marquer shape:
static char Default_MarkerBitmap[] = #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] =
{ {
12, 12, /* x and y size of the bitmap */ wxPoint( 0, 0 ),
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, /* bitmap: 1 = color, 0 = notrace */ wxPoint( 8, 1 ),
1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, wxPoint( 4, 3 ),
1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, wxPoint( 13, 8 ),
1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, wxPoint( 9, 9 ),
1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, wxPoint( 8, 13 ),
1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, wxPoint( 3, 4 ),
1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, wxPoint( 1, 8 )
0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
}; };
/*******************/ /*******************/
/* Classe MARKER_BASE */ /* Classe MARKER_BASE */
/*******************/ /*******************/
void MARKER_BASE::init() void MARKER_BASE::init()
{ {
m_Bitmap = NULL;
m_MarkerType = 0; m_MarkerType = 0;
m_Color = RED; m_Color = RED;
m_Bitmap = Default_MarkerBitmap; for( unsigned ii = 0; ii < CORNERS_COUNT; ii++ )
m_Size.x = Default_MarkerBitmap[0]; {
m_Size.y = Default_MarkerBitmap[1]; 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);
}
} }
MARKER_BASE::MARKER_BASE( )
MARKER_BASE::MARKER_BASE()
{ {
m_ScalingFactor = M_SHAPE_SCALE;
init(); init();
} }
...@@ -57,18 +60,20 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -57,18 +60,20 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos, const wxString& aText, const wxPoint& aPos,
const wxString& bText, const wxPoint& bPos ) const wxString& bText, const wxPoint& bPos )
{ {
m_ScalingFactor = M_SHAPE_SCALE;
init(); init();
SetData( aErrorCode,aMarkerPos, SetData( aErrorCode, aMarkerPos,
aText, aPos, aText, aPos,
bText, bPos ); bText, bPos );
} }
MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
const wxString& aText, const wxPoint& aPos ) const wxString& aText, const wxPoint& aPos )
{ {
m_ScalingFactor = M_SHAPE_SCALE;
init(); init();
SetData( aErrorCode, aMarkerPos, aText, aPos ); SetData( aErrorCode, aMarkerPos, aText, aPos );
} }
...@@ -86,9 +91,6 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -86,9 +91,6 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
m_Pos = aMarkerPos; m_Pos = aMarkerPos;
m_drc.SetData( aErrorCode, m_drc.SetData( aErrorCode,
aText, bText, aPos, bPos ); aText, bText, aPos, bPos );
// @todo: switch on error code to set error code specific color, and possibly bitmap.
m_Color = WHITE;
} }
...@@ -98,78 +100,55 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -98,78 +100,55 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos,
m_Pos = aMarkerPos; m_Pos = aMarkerPos;
m_drc.SetData( aErrorCode, m_drc.SetData( aErrorCode,
aText, aPos ); aText, aPos );
// @todo: switch on error code to set error code specific color, and possibly bitmap.
m_Color = WHITE;
} }
/**********************************************/ /**********************************************/
bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) bool MARKER_BASE::HitTestMarker( const wxPoint& refPos )
/**********************************************/ /**********************************************/
{ {
// the MARKER_BASE is 12 pixels by 12 pixels, but is not resized with zoom, so int dx = refPos.x - m_Pos.x;
// as zoom changes, the effective real size (in user units) of the MARKER_BASE changes. int dy = refPos.y - m_Pos.y;
wxSize TrueSize = m_Size; wxSize Realsize = m_Size;
if ( ActiveScreen ) Realsize.x *= m_ScalingFactor;
{ Realsize.y *= m_ScalingFactor;
ActiveScreen->Unscale( TrueSize );
}
wxPoint pos = m_Pos;
int dx = refPos.x - pos.x;
int dy = refPos.y - pos.y;
/* is refPos in the box: Marker size to right an bottom, /* is refPos in the box: Marker size to right an bottom,
or size/2 to left or top */ * or size/2 to left or top */
if( dx <= TrueSize.x && dy <= TrueSize.y && if( dx <= Realsize.x && dy <= Realsize.y
dx >= -TrueSize.x/2 && dy >= -TrueSize.y/2 ) && dx >= -Realsize.x / 2 && dy >= -Realsize.y / 2 )
return true; return true;
else else
return false; return false;
} }
/**********************************************************************/ /**********************************************************************/
void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode, void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
const wxPoint& offset ) const wxPoint& aOffset )
/**********************************************************************/ /**********************************************************************/
/* /** Function DrawMarker
* Trace un repere sur l'ecran au point de coordonnees PCB pos * The shape is the polygon defined in m_Corners (array of wxPoints)
* Le marqueur est defini par un tableau de 2 + (lig*col) elements:
* 1er element: dim nbre ligne
* 2er element: dim nbre col
* suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel
*/ */
{ {
int ii, jj; wxPoint corners[CORNERS_COUNT];
char* pt_bitmap = m_Bitmap;
if( pt_bitmap == NULL ) return;
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( aDC, aDrawMode );
wxPoint pos = m_Pos; for( unsigned ii = 0; ii < m_Corners.size(); ii++ )
pos.x = GRMapX( pos.x );
pos.y = GRMapY( pos.y );
/* Get the bitmap size */
m_Size.x = *(pt_bitmap++);
m_Size.y = *(pt_bitmap++);
/* Draw the bitmap */
for( ii = 0; ii < m_Size.x; ii++ )
{
for( jj = 0; jj < m_Size.y; jj++, pt_bitmap++ )
{ {
if( *pt_bitmap ) corners[ii] = m_Corners[ii];
GRSPutPixel( &panel->m_ClipBox, DC, corners[ii].x *= m_ScalingFactor;
pos.x + ii, pos.y + jj, m_Color ); corners[ii].y *= m_ScalingFactor;
} corners[ii] += m_Pos + aOffset;
} }
GRClosedPoly( &aPanel->m_ClipBox, aDC, CORNERS_COUNT, corners,
true, // = Filled
0, // outline width
m_Color, // outline color
m_Color // fill collor
);
} }
...@@ -5,7 +5,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ...@@ -5,7 +5,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
) )
set(EESCHEMA_SRCS set(EESCHEMA_SRCS
# affiche.cpp
annotate.cpp annotate.cpp
annotate_dialog.cpp annotate_dialog.cpp
backanno.cpp backanno.cpp
...@@ -21,6 +20,7 @@ set(EESCHEMA_SRCS ...@@ -21,6 +20,7 @@ set(EESCHEMA_SRCS
class_libentry.cpp class_libentry.cpp
class_libentry_fields.cpp class_libentry_fields.cpp
class_library.cpp class_library.cpp
class_marker_sch.cpp
class_pin.cpp class_pin.cpp
class_sch_cmp_field.cpp class_sch_cmp_field.cpp
class_schematic_items.cpp class_schematic_items.cpp
...@@ -62,7 +62,6 @@ set(EESCHEMA_SRCS ...@@ -62,7 +62,6 @@ set(EESCHEMA_SRCS
edit_component_in_schematic.cpp edit_component_in_schematic.cpp
edit_label.cpp edit_label.cpp
eeconfig.cpp eeconfig.cpp
# eecreate.cpp
eelayer.cpp eelayer.cpp
eelibs_draw_components.cpp eelibs_draw_components.cpp
eelibs_read_libraryfiles.cpp eelibs_read_libraryfiles.cpp
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h"
/* Variables Locales */ /* Variables Locales */
......
/***********************************************************************/
/* Methodes de base de gestion des classes des elements de schematique */
/***********************************************************************/
#include "fctsys.h"
#include "class_drawpanel.h"
#include "common.h"
#include "program.h"
#include "general.h"
#include "class_marker_sch.h"
#include "erc.h"
/* Marker are mainly used to show an ERC error
* but they could be used to give a specifi info
*/
const wxChar* NameMarqueurType[] =
{
wxT( "" ),
wxT( "ERC" ),
wxT( "PCB" ),
wxT( "SIMUL" ),
wxT( "?????" )
};
/**************************/
/* class MARKER_SCH */
/**************************/
MARKER_SCH::MARKER_SCH( ) :
SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ),
MARKER_BASE( )
{
}
MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ),
MARKER_BASE(0, pos, text, pos)
{
}
MARKER_SCH::~MARKER_SCH()
{
}
MARKER_SCH* MARKER_SCH::GenCopy()
{
MARKER_SCH* newitem = new MARKER_SCH( GetPos(), GetErrorText() );
newitem->SetMarkerType( GetMarkerType());
newitem->SetErrorLevel( GetErrorLevel());
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.
*/
void MARKER_SCH::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos()
<< "/>\n";
}
#endif
/**
* Function Save
* 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.
*/
bool MARKER_SCH::Save( FILE* aFile ) const
{
bool success = true;
wxString msg = GetErrorText();
if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n",
GetMarkerType() + 'A', GetPos().x, GetPos().y,
CONV_TO_UTF8( msg ), GetErrorLevel() ) == EOF )
{
success = false;
}
return success;
}
/****************************************************************************/
void MARKER_SCH::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDrawMode, int aColor )
/****************************************************************************/
{
EDA_Colors color = (EDA_Colors) m_Color;
EDA_Colors tmp = color;
if( GetMarkerType() == MARK_ERC )
{
color = (GetErrorLevel() == WAR ) ?
(EDA_Colors)g_LayerDescr.LayerColor[LAYER_ERC_WARN] :
(EDA_Colors)g_LayerDescr.LayerColor[LAYER_ERC_ERR];
}
if ( aColor < 0 )
m_Color = color;
else
m_Color = (EDA_Colors) aColor;
DrawMarker( aPanel, aDC, aDrawMode, aOffset );
m_Color = tmp;
}
/***************************************************/
/* classes to handle markers used in schematic ... */
/***************************************************/
#ifndef _CLASS_MARKER_SCH_H_
#define _CLASS_MARKER_SCH_H_
#include "class_marker_base.h"
/* Marker are mainly used to show an ERC error
*/
enum TypeMarker { /* Markers type */
MARK_UNSPEC,
MARK_ERC,
MARK_PCB,
MARK_SIMUL,
MARK_NMAX /* Lats value: end of list */
};
/* Names for corresponding types of markers: */
extern const wxChar* NameMarqueurType[];
class MARKER_SCH : public SCH_ITEM , public MARKER_BASE
{
public:
MARKER_SCH( );
MARKER_SCH( const wxPoint& aPos, const wxString& aText );
~MARKER_SCH();
virtual wxString GetClass() const
{
return wxT( "MARKER_SCH" );
}
MARKER_SCH* GenCopy();
virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDraw_mode,
int aColor = -1 );
wxString GetErrorText( ) const
{
wxString text = m_drc.GetMainText();
return text;
}
void SetErrorText( wxString aText)
{
SetData( m_drc.GetErrorCode(), GetPos(), aText, GetPos() );
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* for a marker, has no meaning, but it is necessary to satisfy the SCH_ITEM class requirements
*/
virtual int GetPenSize( ) { return 0; };
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef )
{
return HitTestMarker( aPosRef );
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};
#endif /* _CLASS_MARKER_SCH_H_ */
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "id.h"
#include "protos.h" #include "protos.h"
...@@ -23,16 +22,6 @@ ...@@ -23,16 +22,6 @@
/* class DrawBusEntryStruct */ /* class DrawBusEntryStruct */
/***************************/ /***************************/
const wxChar* NameMarqueurType[] =
{
wxT( "" ),
wxT( "ERC" ),
wxT( "PCB" ),
wxT( "SIMUL" ),
wxT( "?????" )
};
DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) : DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) :
SCH_ITEM( NULL, DRAW_BUSENTRY_STRUCT_TYPE ) SCH_ITEM( NULL, DRAW_BUSENTRY_STRUCT_TYPE )
{ {
...@@ -362,94 +351,6 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -362,94 +351,6 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
} }
/**************************/
/* class MARKER_SCH */
/**************************/
MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ),
MARKER_BASE(0, pos, text, pos)
{
}
MARKER_SCH::~MARKER_SCH()
{
}
MARKER_SCH* MARKER_SCH::GenCopy()
{
MARKER_SCH* newitem = new MARKER_SCH( GetPos(), GetErrorText() );
newitem->SetMarkerType( GetMarkerType());
newitem->SetErrorLevel( GetErrorLevel());
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.
*/
void MARKER_SCH::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos()
<< "/>\n";
}
#endif
/**
* Function Save
* 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.
*/
bool MARKER_SCH::Save( FILE* aFile ) const
{
bool success = true;
wxString msg = GetErrorText();
if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n",
GetMarkerType() + 'A', GetPos().x, GetPos().y,
CONV_TO_UTF8( msg ), GetErrorLevel() ) == EOF )
{
success = false;
}
return success;
}
void MARKER_SCH::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
{
#define WAR 1 // see erc.cpp
if( GetMarkerType() == MARQ_ERC )
{
if( Color <= 0 )
{
Color = (GetErrorLevel() == WAR ) ?
g_LayerDescr.LayerColor[LAYER_ERC_WARN] :
g_LayerDescr.LayerColor[LAYER_ERC_ERR];
}
}
m_Color = Color;
DrawMarker( panel, DC, DrawMode, offset );
}
/***************************/ /***************************/
/* Class EDA_DrawLineStruct */ /* Class EDA_DrawLineStruct */
/***************************/ /***************************/
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef CLASS_SCHEMATIC_ITEMS_H #ifndef CLASS_SCHEMATIC_ITEMS_H
#define CLASS_SCHEMATIC_ITEMS_H #define CLASS_SCHEMATIC_ITEMS_H
#include "class_marker_base.h"
#define DRAWJUNCTION_DIAMETER 32 /* Size (diameter) of junctions between wires */ #define DRAWJUNCTION_DIAMETER 32 /* Size (diameter) of junctions between wires */
#define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */ #define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */
...@@ -15,19 +13,6 @@ ...@@ -15,19 +13,6 @@
#define BUS_TO_BUS 1 #define BUS_TO_BUS 1
enum TypeMarker { /* Type des Marqueurs */
MARQ_UNSPEC,
MARQ_ERC,
MARQ_PCB,
MARQ_SIMUL,
MARQ_NMAX /* Derniere valeur: fin de tableau */
};
/* Messages correspondants aux types des marqueurs */
extern const wxChar* NameMarqueurType[];
/** /**
* Class EDA_DrawLineStruct * Class EDA_DrawLineStruct
* is a segment decription base class to describe items which have 2 end * is a segment decription base class to describe items which have 2 end
...@@ -90,63 +75,6 @@ public: ...@@ -90,63 +75,6 @@ public:
}; };
class MARKER_SCH : public SCH_ITEM , public MARKER_BASE
{
public:
MARKER_SCH( const wxPoint& aPos, const wxString& aText );
~MARKER_SCH();
virtual wxString GetClass() const
{
return wxT( "MARKER_SCH" );
}
MARKER_SCH* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
wxString GetErrorText( ) const
{
wxString text = m_drc.GetMainText();
return text;
}
void SetErrorText( wxString aText)
{
SetData( m_drc.GetErrorCode(), GetPos(), aText, GetPos() );
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
* for a marker, has no meaning, but it is necessary to satisfy the SCH_ITEM class requirements
*/
virtual int GetPenSize( ) { return 0; };
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef )
{
return HitTestMarker( aPosRef );
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};
class DrawNoConnectStruct : public SCH_ITEM /* Symboles de non connexion */ class DrawNoConnectStruct : public SCH_ITEM /* Symboles de non connexion */
{ {
public: public:
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h"
/**************************************************************************************/ /**************************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin ) SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin )
/**************************************************************************************/ /**************************************************************************************/
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h"
/********************************************************************************/ /********************************************************************************/
......
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
#include "dialog_erc.h" #include "dialog_erc.h"
#include "erc.h"
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
...@@ -71,7 +73,7 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event ) ...@@ -71,7 +73,7 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
/* Delete the old ERC markers, over the whole hierarchy /* Delete the old ERC markers, over the whole hierarchy
*/ */
{ {
DeleteAllMarkers( MARQ_ERC ); DeleteAllMarkers( MARK_ERC );
m_MessagesList->Clear(); m_MessagesList->Clear();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
...@@ -216,3 +218,99 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -216,3 +218,99 @@ void DIALOG_ERC::ReBuildMatrixPanel()
m_Initialized = TRUE; m_Initialized = TRUE;
} }
/** Function DisplayERC_MarkersList
* read the schematic and display the list of ERC markers
*/
void DIALOG_ERC::DisplayERC_MarkersList()
{
EDA_SheetList SheetList;
for( DrawSheetPath* Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
{
SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE )
continue;
/* Marqueur trouve */
MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue;
/* Display diag */
wxString msg;
msg.Printf( _( "sheet %s (loc X=%f" ", Y=%f" "): %s\n" ),
Sheet->PathHumanReadable().GetData(),
(float) Marker->m_Pos.x / 1000, (float) Marker->m_Pos.y / 1000,
Marker->GetErrorText().GetData() );
m_MessagesList->AppendText( msg );
}
}
}
/**************************************************************/
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
/**************************************************************/
/* Remet aux valeurs par defaut la matrice de diagnostic
*/
{
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
ReBuildMatrixPanel();
}
/************************************************************/
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
/************************************************************/
/* Change the error level for the pressed button, on the matrix table
*/
{
int id, level, ii, x, y;
wxBitmapButton* Butt;
const char** new_bitmap_xpm = NULL;
wxPoint pos;
id = event.GetId();
ii = id - ID_MATRIX_0;
Butt = (wxBitmapButton*) event.GetEventObject();
pos = Butt->GetPosition();
x = ii / PIN_NMAX; y = ii % PIN_NMAX;
level = DiagErc[y][x];
switch( level )
{
case OK:
level = WAR;
new_bitmap_xpm = warning_xpm;
break;
case WAR:
level = ERR;
new_bitmap_xpm = error_xpm;
break;
case ERR:
level = OK;
new_bitmap_xpm = erc_green_xpm;
break;
}
if( new_bitmap_xpm )
{
delete Butt;
Butt = new wxBitmapButton( m_PanelERCOptions, id,
wxBitmap( new_bitmap_xpm ), pos );
m_ButtonList[y][x] = Butt;
DiagErc[y][x] = DiagErc[x][y] = level;
}
}
...@@ -20,12 +20,6 @@ extern const wxChar* CommentERC_V[]; ...@@ -20,12 +20,6 @@ extern const wxChar* CommentERC_V[];
/* Control identifiers */ /* Control identifiers */
#define ID_MATRIX_0 1800 #define ID_MATRIX_0 1800
#define OK 0
#define WAR 1
#define ERR 2
#define UNC 3
/*! /*!
* DIALOG_ERC class declaration * DIALOG_ERC class declaration
*/ */
......
This diff is collapsed.
This diff is collapsed.
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2009 Jea-Pierre.Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _ERC_H
#define _ERC_H
/* For ERC markers: error types (used in diags, and to set the color):
*/
enum errortype
{
OK = 0,
WAR, // Error: severity = warning
ERR, // Error: severity = error
UNC // Error: unconnected pin
};
/// DRC error codes:
#define ERCE_UNSPECIFIED 0
#define ERCE_DUPLICATE_SHEET_NAME 1 //duplicate sheet names within a given sheet
#define ERCE_PIN_NOT_CONNECTED 2 //pin not connected and not no connect symbol
#define ERCE_PIN_NOT_DRIVEN 3 //pin connected to some others pins but no pin to drive it
#define ERCE_PIN_TO_PIN_WARNING 4 //pin connected to an other pin: warning level
#define ERCE_PIN_TO_PIN_ERROR 5 //pin connected to an other pin: error level
#define ERCE_HIERACHICAL_LABEL 6 //mismatch between hierarchical labels and pins sheets
#define ERCE_NOCONNECT_CONNECTED 7 //a no connect symbol is connected to more than 1 pin
#endif // _ERC_H
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h"
/* Variables Locales */ /* Variables Locales */
static int s_ItemsCount, s_MarkerCount; static int s_ItemsCount, s_MarkerCount;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h"
/* in read_from_file_schematic_items_description.cpp */ /* in read_from_file_schematic_items_description.cpp */
SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine, SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine,
...@@ -339,8 +340,8 @@ at line %d, aborted" ), ...@@ -339,8 +340,8 @@ at line %d, aborted" ),
ii = ReadDelimitedText( BufLine, Line, 256 ); ii = ReadDelimitedText( BufLine, Line, 256 );
int type = (TypeMarker) ( (Name1[0] & 255) - 'A' ); int type = (TypeMarker) ( (Name1[0] & 255) - 'A' );
if( type < 0 ) if( type < 0 || type >= MARK_NMAX)
type = MARQ_UNSPEC; type = MARK_UNSPEC;
Marker->SetMarkerType( type ); Marker->SetMarkerType( type );
if( ii ) if( ii )
Marker->SetErrorText( CONV_FROM_UTF8( BufLine ) ); Marker->SetErrorText( CONV_FROM_UTF8( BufLine ) );
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "trigo.h" #include "trigo.h"
#include "macros.h" #include "macros.h"
#include "class_drawpickedstruct.h" #include "class_drawpickedstruct.h"
#include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "general.h" #include "general.h"
#include "id.h" #include "id.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h"
/* Functions to undo and redo edit commands. /* Functions to undo and redo edit commands.
* commmands to undo are in CurrentScreen->m_UndoList * commmands to undo are in CurrentScreen->m_UndoList
......
...@@ -12,11 +12,11 @@ class MARKER_BASE ...@@ -12,11 +12,11 @@ class MARKER_BASE
public: public:
wxPoint m_Pos; ///< position of the marker wxPoint m_Pos; ///< position of the marker
protected: protected:
char* m_Bitmap; ///< Shape (bitmap) std::vector <wxPoint> m_Corners; ///< Corner list for shape definition (a polygon)
int m_MarkerType; ///< Can be used as a flag int m_MarkerType; ///< Can be used as a flag
int m_Color; ///< color EDA_Colors m_Color; ///< color
wxSize m_Size; ///< Size of the graphic symbol wxSize m_Size; ///< Size of the graphic symbol, used for Hit Tests
int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can set the physical size
DRC_ITEM m_drc; DRC_ITEM m_drc;
void init(); void init();
...@@ -65,13 +65,21 @@ public: ...@@ -65,13 +65,21 @@ public:
} }
/** Function SetColor
* Set the color of this marker
*/
void SetColor(EDA_Colors aColor )
{
m_Color = aColor;
}
/** Function to set/get error levels (warning, fatal ..) /** Function to set/get error levels (warning, fatal ..)
* this value is stored in m_MarkerType * this value is stored in m_MarkerType
*/ */
void SetErrorLevel(int aErrorLevel ) void SetErrorLevel(int aErrorLevel )
{ {
m_MarkerType &= 0xFF00; m_MarkerType &= ~0xFF00;
m_MarkerType &= 0xFF; aErrorLevel &= 0xFF;
m_MarkerType |= aErrorLevel << 8; m_MarkerType |= aErrorLevel << 8;
} }
...@@ -86,7 +94,7 @@ public: ...@@ -86,7 +94,7 @@ public:
*/ */
void SetMarkerType(int aMarkerType ) void SetMarkerType(int aMarkerType )
{ {
m_MarkerType &= 0xFF; m_MarkerType &= ~0xFF;
aMarkerType &= 0xFF; aMarkerType &= 0xFF;
m_MarkerType |= aMarkerType; m_MarkerType |= aMarkerType;
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "class_marker.h" #include "class_marker.h"
#define SCALING_FACTOR 30 // Adjust the actual size of markers, when using default shape
/*******************/ /*******************/
/* Classe MARKER */ /* Classe MARKER */
...@@ -22,6 +22,8 @@ MARKER::MARKER( BOARD_ITEM* aParent ) : ...@@ -22,6 +22,8 @@ MARKER::MARKER( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, TYPE_MARKER ), BOARD_ITEM( aParent, TYPE_MARKER ),
MARKER_BASE( ) MARKER_BASE( )
{ {
m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR;
} }
...@@ -32,6 +34,8 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -32,6 +34,8 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ) MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos )
{ {
m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR;
} }
MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
...@@ -39,6 +43,8 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -39,6 +43,8 @@ MARKER::MARKER( int aErrorCode, const wxPoint& aMarkerPos,
BOARD_ITEM( NULL, TYPE_MARKER ), // parent set during BOARD::Add() BOARD_ITEM( NULL, TYPE_MARKER ), // parent set during BOARD::Add()
MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos ) MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos )
{ {
m_Color = WHITE;
m_ScalingFactor = SCALING_FACTOR;
} }
......
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