Fix some minor coverity warnings. Fix a bug in pcad2kicad plugin. Scripting: map BASE_SET. Rename some python bom scripts with better names. Fix erroneous comments and add comments

This commit is contained in:
jean-pierre charras 2015-03-02 09:28:49 +01:00
parent 25b9a42ea3
commit 4bab8dde65
14 changed files with 37 additions and 26 deletions

View File

@ -227,15 +227,18 @@ static void DrawGraphicTextPline( EDA_RECT* aClipBox,
coord[ik + 1].x, coord[ik + 1].y ); coord[ik + 1].x, coord[ik + 1].y );
} }
} }
else if( aSketchMode ) else if( aDC )
{ {
for( int ik = 0; ik < (point_count - 1); ik++ ) if( aSketchMode )
GRCSegm( aClipBox, aDC, coord[ik].x, coord[ik].y, {
coord[ik + 1].x, coord[ik + 1].y, aWidth, aColor ); for( int ik = 0; ik < (point_count - 1); ik++ )
GRCSegm( aClipBox, aDC, coord[ik].x, coord[ik].y,
coord[ik + 1].x, coord[ik + 1].y, aWidth, aColor );
}
else
GRPoly( aClipBox, aDC, point_count, coord, 0,
aWidth, aColor, aColor );
} }
else
GRPoly( aClipBox, aDC, point_count, coord, 0,
aWidth, aColor, aColor );
} }

View File

@ -48,6 +48,7 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType
m_modal_loop( 0 ), m_modal_resultant_parent( 0 ) m_modal_loop( 0 ), m_modal_resultant_parent( 0 )
{ {
// DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
m_modal_ret_val = 0;
} }

View File

@ -258,7 +258,7 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
// If the selectedField is still not in the templateField range now, // If the selectedField is still not in the templateField range now,
// make sure we stay in range and when there are no fields present // make sure we stay in range and when there are no fields present
// move to -1 // move to -1
if( selectedField >= templateFields.size() ) if( selectedField >= int( templateFields.size() ) )
selectedField = templateFields.size() - 1; selectedField = templateFields.size() - 1;
// Update the display to reflect the new data // Update the display to reflect the new data

View File

@ -44,13 +44,13 @@ protected:
* edit panel * edit panel
* selectedField = -1 when no valid item selected * selectedField = -1 when no valid item selected
*/ */
size_t selectedField; int selectedField;
/** @brief return true if aFieldId is a valid field selection /** @brief return true if aFieldId is a valid field selection
*/ */
bool fieldSelectionValid( size_t aFieldId ) bool fieldSelectionValid( int aFieldId )
{ {
return ( aFieldId >= 0 ) && ( aFieldId < templateFields.size() ); return ( aFieldId >= 0 ) && ( aFieldId < int( templateFields.size() ) );
} }
/** /**

View File

@ -116,7 +116,8 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
lastTextItalic = textItem->IsItalic(); lastTextItalic = textItem->IsItalic();
lastTextOrientation = textItem->GetOrientation(); lastTextOrientation = textItem->GetOrientation();
if( (aType == SCH_GLOBAL_LABEL_T) || (aType == SCH_HIERARCHICAL_LABEL_T) ) if( ( textItem->Type() == SCH_GLOBAL_LABEL_T ) ||
( textItem->Type() == SCH_HIERARCHICAL_LABEL_T ) )
{ {
lastGlobalLabelShape = textItem->GetShape(); lastGlobalLabelShape = textItem->GetShape();
} }

View File

@ -296,12 +296,12 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
if( LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ) ) if( LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ) )
{ {
wxCHECK_RET( (unit >= 1) && (unit <= part->GetUnitCount()), int unitCount = part->GetUnitCount();
wxCHECK_RET( (unit >= 1) && (unit <= unitCount),
wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) + wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) +
part->GetName() ); part->GetName() );
int unitCount = part->GetUnitCount();
if( unitCount <= 1 || component->GetUnit() == unit ) if( unitCount <= 1 || component->GetUnit() == unit )
return; return;

View File

@ -115,6 +115,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
SCH_ITEM( aParent, SCH_COMPONENT_T ) SCH_ITEM( aParent, SCH_COMPONENT_T )
{ {
Init( aPos ); Init( aPos );
m_currentSheetPath = NULL;
} }
@ -128,6 +129,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
m_convert = convert; m_convert = convert;
m_part_name = aPart.GetName(); m_part_name = aPart.GetName();
m_part = aPart.SharedPtr(); m_part = aPart.SharedPtr();
m_currentSheetPath = NULL;
SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() );

View File

@ -1035,13 +1035,11 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
* but: * but:
* - the footprint position is not modified. * - the footprint position is not modified.
* - the relative (local) coordinates of these items are modified * - the relative (local) coordinates of these items are modified
* - Draw coordinates are updated
*/ */
wxPoint footprintPos = GetPosition();
/* Update the relative coordinates: // Update (move) the relative coordinates relative to the new anchor point.
* The coordinates are relative to the anchor point.
* Calculate deltaX and deltaY from the anchor. */
wxPoint moveVector = aMoveVector; wxPoint moveVector = aMoveVector;
RotatePoint( &moveVector, -GetOrientation() ); RotatePoint( &moveVector, -GetOrientation() );

View File

@ -207,7 +207,7 @@ void PCB_PAD::AddToModule( MODULE* aModule, int aRotation, bool aEncapsulatedPad
pad->SetDrillSize( wxSize( m_hole, m_hole ) ); pad->SetDrillSize( wxSize( m_hole, m_hole ) );
pad->SetSize( wxSize( m_hole, m_hole ) ); pad->SetSize( wxSize( m_hole, m_hole ) );
pad->SetLayerSet( LSET::AllCuMask() | LSET( 3, B_Mask, F_Mask ) ); pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
} }
else else
{ {

View File

@ -28,6 +28,7 @@
*/ */
%include <std_vector.i> %include <std_vector.i>
%include <std_basic_string.i>
%include <std_string.i> %include <std_string.i>
%include <std_map.i> %include <std_map.i>
@ -65,6 +66,7 @@
#include <wx_python_helpers.h> #include <wx_python_helpers.h>
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
#include <bitset>
#include <class_title_block.h> #include <class_title_block.h>
#include <class_colors_design_settings.h> #include <class_colors_design_settings.h>
@ -114,6 +116,12 @@
%template(intVector) std::vector<int>; %template(intVector) std::vector<int>;
%template(str_utf8_Map) std::map< std::string,UTF8 >; %template(str_utf8_Map) std::map< std::string,UTF8 >;
// wrapper of BASE_SEQ (see typedef std::vector<LAYER_ID> BASE_SEQ;)
%template(base_seqVect) std::vector<enum LAYER_ID>;
// TODO: wrapper of BASE_SET (see std::bitset<LAYER_ID_COUNT> BASE_SET;)
/* KiCad plugin handling */ /* KiCad plugin handling */
%include "kicadplugins.i" %include "kicadplugins.i"

View File

@ -1,7 +1,7 @@
# #
# Example python script to generate a BOM from a KiCad generic netlist # Example python script to generate a BOM from a KiCad generic netlist
# #
# Example: Sorted and Grouped HTML BOM with more advanced grouping # Example: Sorted and Grouped HTML BOM with advanced grouping
# #
""" """
@ -75,7 +75,7 @@ def myEqu(self, other):
kicad_netlist_reader.comp.__equ__ = myEqu kicad_netlist_reader.comp.__equ__ = myEqu
# Generate an instance of a generic netlist, and load the netlist tree from # Generate an instance of a generic netlist, and load the netlist tree from
# video.tmp. If the file doesn't exist, execution will stop # <file>.tmp. If the file doesn't exist, execution will stop
net = kicad_netlist_reader.netlist(sys.argv[1]) net = kicad_netlist_reader.netlist(sys.argv[1])
# Open a file to write too, if the file cannot be opened output to stdout # Open a file to write too, if the file cannot be opened output to stdout

View File

@ -9,10 +9,8 @@
""" """
@package @package
Generate a HTML BOM list. Helper module for interpreting generic netlist and build custom
Components are sorted and grouped by value bom generators or netlists in foreign format
Fields are (if exist)
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
""" """