Commit fdb18547 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix bug 676532. Minor enhancements.

parent 67b14484
......@@ -463,6 +463,27 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
/**
* Function GetStyleName
* @return a wwString withe the style name( Normal, Italic, Bold, Bold+Italic)
*/
wxString EDA_TextStruct::GetTextStyleName()
{
int style = 0;
if( m_Italic )
style = 1;
if( m_Bold )
style += 2;
wxString stylemsg[4] = {
_("Normal"),
_("Italic"),
_("Bold"),
_("Bold+Italic")
};
return stylemsg[style];
}
/******************/
/* Class EDA_Rect */
......@@ -666,3 +687,23 @@ void EDA_Rect::Merge( const EDA_Rect& aRect )
end.y = MAX( end.y, rect_end.y );
SetEnd( end );
}
/**
* Function Merge
* modifies Position and Size of this in order to contain the given point
* mainly used to calculate bounding boxes
* @param aPoint = given point to merge with this
*/
void EDA_Rect::Merge( const wxPoint& aPoint )
{
Normalize(); // ensure width and height >= 0
wxPoint end = GetEnd();
// Change origin and size in order to contain the given rect
m_Pos.x = MIN( m_Pos.x, aPoint.x );
m_Pos.y = MIN( m_Pos.y, aPoint.y );
end.x = MAX( end.x, aPoint.x );
end.y = MAX( end.y, aPoint.y );
SetEnd( end );
}
......@@ -56,8 +56,8 @@ set(EESCHEMA_SRCS
dialog_libedit_dimensions_base.cpp
dialog_lib_edit_draw_item.cpp
dialog_lib_edit_draw_item_base.cpp
dialog_lib_edit_pin.cpp
dialog_lib_edit_pin_base.cpp
dialogs/dialog_lib_edit_pin.cpp
dialogs/dialog_lib_edit_pin_base.cpp
dialog_lib_new_component.cpp
dialog_lib_new_component_base.cpp
dialogs/dialog_print_using_printer_base.cpp
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,10 @@
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_LIB_EDIT_PIN_BASE, wxDialog )
EVT_CHECKBOX( wxID_ANY, DIALOG_LIB_EDIT_PIN_BASE::_wxFB_OnCBpartSelection )
END_EVENT_TABLE()
DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_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 );
......@@ -101,10 +105,10 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 0, wxEXPAND, 3 );
......@@ -120,10 +124,10 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 3 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
mainSizer->Add( fgSizer1, 0, wxALL|wxEXPAND, 12 );
......@@ -131,16 +135,13 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID
boarderSizer = new wxBoxSizer( wxVERTICAL );
m_checkApplyToAllParts = new wxCheckBox( this, wxID_ANY, _("Add to all &parts in package"), wxDefaultPosition, wxDefaultSize, 0 );
boarderSizer->Add( m_checkApplyToAllParts, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkApplyToAllConversions = new wxCheckBox( this, wxID_ANY, _("Add to all alternate &body styles (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
boarderSizer->Add( m_checkApplyToAllConversions, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_checkShow = new wxCheckBox( this, wxID_ANY, _("&Visible"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkShow->SetValue(true);
m_checkShow->SetValue(true);
boarderSizer->Add( m_checkShow, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -32,7 +32,12 @@ class wxBitmapComboBox;
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIB_EDIT_PIN_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnCBpartSelection( wxCommandEvent& event ){ OnCBpartSelection( event ); }
protected:
wxStaticText* m_staticText1;
......@@ -71,8 +76,13 @@ class DIALOG_LIB_EDIT_PIN_BASE : public wxDialog
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCBpartSelection( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIB_EDIT_PIN_BASE();
......
......@@ -232,6 +232,11 @@ public:
return EDA_BaseStruct::GetBoundingBox();
}
/**
* Displays basic info (type, part and convert) about item
* in msg panel
* @param aFrame = main frame where the message manel info is.
*/
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**
......
......@@ -298,7 +298,10 @@ void LIB_FIELD::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint&
int color;
int linewidth = GetPenSize();
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( m_Bold )
linewidth = GetPenSizeForBold( m_Size.x );
else
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) )
{
......@@ -339,8 +342,7 @@ void LIB_FIELD::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint&
EDA_Rect bBox = GetBoundingBox();
m_Text = tmp;
bBox.Inflate( 1, 1 );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
GRRect( &aPanel->m_ClipBox, aDC, bBox, 0, LIGHTMAGENTA );
#endif
}
......@@ -703,3 +705,28 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition )
Move( m_initialPos + aPosition - m_initialCursorPos );
}
}
void LIB_FIELD::DisplayInfo( WinEDA_DrawFrame* aFrame )
{
wxString msg;
LIB_DRAW_ITEM::DisplayInfo( aFrame );
// Display style:
msg = GetTextStyleName();
aFrame->AppendMsgPanel( _( "Style" ), msg, MAGENTA );
msg = ReturnStringFromValue( g_UserUnit, m_Size.x, EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Size X" ), msg, BLUE );
msg = ReturnStringFromValue( g_UserUnit, m_Size.y, EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Size Y" ), msg, BLUE );
// Display field name (ref, value ...)
msg = GetName();
aFrame->AppendMsgPanel( _( "Field" ), msg, BROWN );
// Display field text:
aFrame->AppendMsgPanel( _( "Value" ), m_Text, BROWN );
}
......@@ -107,6 +107,13 @@ public:
*/
virtual EDA_Rect GetBoundingBox();
/**
* Displays info (type, part convert filed name and value)
* in msg panel
* @param aFrame = main frame where the message manel info is.
*/
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
/**
* Test if the given point is within the bounds of this object.
*
......
......@@ -58,6 +58,7 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy()
newitem->SetEdge( GetEdge() );
newitem->m_Shape = m_Shape;
newitem->m_Size = m_Size;
newitem->SetNumber( GetNumber() );
return newitem;
}
......
......@@ -243,6 +243,14 @@ public:
* @param aRect = given rect to merge with this
*/
void Merge( const EDA_Rect& aRect );
/**
* Function Merge
* Modify Position and Size of this in order to contain the given point
* mainly used to calculate bounding boxes
* @param aPoint = given point to merge with this
*/
void Merge( const wxPoint& aPoint );
};
......@@ -676,6 +684,12 @@ public:
{
return (( m_Size.y * 14 ) / 10) + m_Width;
}
/**
* Function GetTextStyleName
* @return a wwString withe the style name( Normal, Italic, Bold, Bold+Italic)
*/
wxString GetTextStyleName();
};
#endif /* BASE_STRUCT_H */
......@@ -155,7 +155,7 @@ int CPolyLine::NormalizeWithKbool( std::vector<CPolyLine*> * aExtraPolyList, boo
{
// find the polygon that contains this hole
// testing one corner inside is enought because a hole is entirely inside the polygon
// sowe test only the first corner
// so we test only the first corner
int x = (*hole)[0];
int y = (*hole)[1];
if( TestPointInside( x, y ) )
......@@ -1196,169 +1196,167 @@ void CPolyLine::Hatch()
int layer = GetLayer();
if( GetClosed() ) // If not closed, the poly is beeing created and not finalised. Not not hatch
if( !GetClosed() ) // If not closed, the poly is beeing created and not finalised. Not not hatch
return;
enum {
MAXPTS = 100
};
int xx[MAXPTS], yy[MAXPTS];
// define range for hatch lines
int min_x = corner[0].x;
int max_x = corner[0].x;
int min_y = corner[0].y;
int max_y = corner[0].y;
for( unsigned ic = 1; ic < corner.size(); ic++ )
{
enum {
MAXPTS = 100
};
int xx[MAXPTS], yy[MAXPTS];
// define range for hatch lines
int min_x = corner[0].x;
int max_x = corner[0].x;
int min_y = corner[0].y;
int max_y = corner[0].y;
for( unsigned ic = 1; ic < corner.size(); ic++ )
{
if( corner[ic].x < min_x )
min_x = corner[ic].x;
if( corner[ic].x > max_x )
max_x = corner[ic].x;
if( corner[ic].y < min_y )
min_y = corner[ic].y;
if( corner[ic].y > max_y )
max_y = corner[ic].y;
}
if( corner[ic].x < min_x )
min_x = corner[ic].x;
if( corner[ic].x > max_x )
max_x = corner[ic].x;
if( corner[ic].y < min_y )
min_y = corner[ic].y;
if( corner[ic].y > max_y )
max_y = corner[ic].y;
}
int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
double slope = 0.707106 * slope_flag;
int spacing;
if( m_HatchStyle == DIAGONAL_EDGE )
spacing = 10 * PCBU_PER_MIL;
else
spacing = 50 * PCBU_PER_MIL;
int max_a, min_a;
if( slope_flag == 1 )
{
max_a = (int) (max_y - slope * min_x);
min_a = (int) (min_y - slope * max_x);
}
else
{
max_a = (int) (max_y - slope * max_x);
min_a = (int) (min_y - slope * min_x);
}
min_a = (min_a / spacing) * spacing;
int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
double slope = 0.707106 * slope_flag;
int spacing;
if( m_HatchStyle == DIAGONAL_EDGE )
spacing = 10 * PCBU_PER_MIL;
else
spacing = 50 * PCBU_PER_MIL;
int max_a, min_a;
if( slope_flag == 1 )
{
max_a = (int) (max_y - slope * min_x);
min_a = (int) (min_y - slope * max_x);
}
else
{
max_a = (int) (max_y - slope * max_x);
min_a = (int) (min_y - slope * min_x);
}
min_a = (min_a / spacing) * spacing;
// calculate an offset depending on layer number, for a better display of hatches on a multilayer board
int offset = (layer * 7) / 8;
min_a += offset;
// calculate an offset depending on layer number, for a better display of hatches on a multilayer board
int offset = (layer * 7) / 8;
min_a += offset;
// now calculate and draw hatch lines
int nc = corner.size();
// now calculate and draw hatch lines
int nc = corner.size();
// loop through hatch lines
for( int a = min_a; a<max_a; a += spacing )
{
// get intersection points for this hatch line
int nloops = 0;
int npts;
// loop through hatch lines
for( int a = min_a; a<max_a; a += spacing )
{
// get intersection points for this hatch line
int nloops = 0;
int npts;
// make this a loop in case my homebrew hatching algorithm screws up
do
// make this a loop in case my homebrew hatching algorithm screws up
do
{
npts = 0;
int i_start_contour = 0;
for( int ic = 0; ic<nc; ic++ )
{
npts = 0;
int i_start_contour = 0;
for( int ic = 0; ic<nc; ic++ )
double x, y, x2, y2;
int ok;
if( corner[ic].end_contour || ( ic == (int) (corner.size() - 1) ) )
{
double x, y, x2, y2;
int ok;
if( corner[ic].end_contour || ( ic == (int) (corner.size() - 1) ) )
{
ok = FindLineSegmentIntersection( a, slope,
corner[ic].x, corner[ic].y,
corner[i_start_contour].x,
corner[i_start_contour].y,
side_style[ic],
&x, &y, &x2, &y2 );
i_start_contour = ic + 1;
}
else
{
ok = FindLineSegmentIntersection( a, slope,
corner[ic].x, corner[ic].y,
corner[ic + 1].x, corner[ic + 1].y,
side_style[ic],
&x, &y, &x2, &y2 );
}
if( ok )
{
xx[npts] = (int) x;
yy[npts] = (int) y;
npts++;
wxASSERT( npts<MAXPTS ); // overflow
}
if( ok == 2 )
{
xx[npts] = (int) x2;
yy[npts] = (int) y2;
npts++;
wxASSERT( npts<MAXPTS ); // overflow
}
ok = FindLineSegmentIntersection( a, slope,
corner[ic].x, corner[ic].y,
corner[i_start_contour].x,
corner[i_start_contour].y,
side_style[ic],
&x, &y, &x2, &y2 );
i_start_contour = ic + 1;
}
else
{
ok = FindLineSegmentIntersection( a, slope,
corner[ic].x, corner[ic].y,
corner[ic + 1].x, corner[ic + 1].y,
side_style[ic],
&x, &y, &x2, &y2 );
}
if( ok )
{
xx[npts] = (int) x;
yy[npts] = (int) y;
npts++;
wxASSERT( npts<MAXPTS ); // overflow
}
if( ok == 2 )
{
xx[npts] = (int) x2;
yy[npts] = (int) y2;
npts++;
wxASSERT( npts<MAXPTS ); // overflow
}
}
nloops++;
a += PCBU_PER_MIL / 100;
} while( npts % 2 != 0 && nloops < 3 );
nloops++;
a += PCBU_PER_MIL / 100;
} while( npts % 2 != 0 && nloops < 3 );
/* DICK 1/22/08: this was firing repeatedly on me, needed to comment out to get
* my work done:
* wxASSERT( npts%2==0 ); // odd number of intersection points, error
*/
* my work done:
* wxASSERT( npts%2==0 ); // odd number of intersection points, error
*/
// sort points in order of descending x (if more than 2)
if( npts>2 )
// sort points in order of descending x (if more than 2)
if( npts>2 )
{
for( int istart = 0; istart<(npts - 1); istart++ )
{
for( int istart = 0; istart<(npts - 1); istart++ )
int max_x = INT_MIN;
int imax = INT_MIN;
for( int i = istart; i<npts; i++ )
{
int max_x = INT_MIN;
int imax = INT_MIN;
for( int i = istart; i<npts; i++ )
if( xx[i] > max_x )
{
if( xx[i] > max_x )
{
max_x = xx[i];
imax = i;
}
max_x = xx[i];
imax = i;
}
int temp = xx[istart];
xx[istart] = xx[imax];
xx[imax] = temp;
temp = yy[istart];
yy[istart] = yy[imax];
yy[imax] = temp;
}
int temp = xx[istart];
xx[istart] = xx[imax];
xx[imax] = temp;
temp = yy[istart];
yy[istart] = yy[imax];
yy[imax] = temp;
}
}
// draw lines
for( int ip = 0; ip<npts; ip += 2 )
// draw lines
for( int ip = 0; ip<npts; ip += 2 )
{
double dx = xx[ip + 1] - xx[ip];
if( m_HatchStyle == DIAGONAL_FULL || fabs( dx ) < 40 * NM_PER_MIL )
{
double dx = xx[ip + 1] - xx[ip];
if( m_HatchStyle == DIAGONAL_FULL || fabs( dx ) < 40 * NM_PER_MIL )
{
m_HatchLines.push_back( CSegment( xx[ip], yy[ip], xx[ip + 1], yy[ip + 1] ) );
}
m_HatchLines.push_back( CSegment( xx[ip], yy[ip], xx[ip + 1], yy[ip + 1] ) );
}
else
{
double dy = yy[ip + 1] - yy[ip];
double slope = dy / dx;
if( dx > 0 )
dx = 20 * NM_PER_MIL;
else
{
double dy = yy[ip + 1] - yy[ip];
double slope = dy / dx;
if( dx > 0 )
dx = 20 * NM_PER_MIL;
else
dx = -20 * NM_PER_MIL;
double x1 = xx[ip] + dx;
double x2 = xx[ip + 1] - dx;
double y1 = yy[ip] + dx * slope;
double y2 = yy[ip + 1] - dx * slope;
m_HatchLines.push_back( CSegment( xx[ip], yy[ip], to_int( x1 ), to_int( y1 ) ) );
m_HatchLines.push_back( CSegment( xx[ip + 1], yy[ip + 1], to_int( x2 ),
to_int( y2 ) ) );
}
dx = -20 * NM_PER_MIL;
double x1 = xx[ip] + dx;
double x2 = xx[ip + 1] - dx;
double y1 = yy[ip] + dx * slope;
double y2 = yy[ip + 1] - dx * slope;
m_HatchLines.push_back( CSegment( xx[ip], yy[ip], to_int( x1 ), to_int( y1 ) ) );
m_HatchLines.push_back( CSegment( xx[ip + 1], yy[ip + 1], to_int( x2 ),
to_int( y2 ) ) );
}
}
// end for
}
}
......
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