Commit 1206177c authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: minor enhancement. Boost::Polygon: commit forgotten file

parent bd022c23
......@@ -56,7 +56,7 @@ int g_DrawBgColor = WHITE;
#define USE_CLIP_FILLED_POLYGONS
#ifdef USE_CLIP_FILLED_POLYGONS
void ClipAndDrawFilledPoly( EDA_Rect * ClipBox, wxDC * DC, wxPoint Points[], int n );
static void ClipAndDrawFilledPoly( EDA_Rect * ClipBox, wxDC * DC, wxPoint Points[], int n );
#endif
/* These functions are used by corresponding functions
......@@ -1281,7 +1281,11 @@ static void GRSClosedPoly( EDA_Rect* ClipBox,
{
GRSMoveTo( aPoints[aPointCount - 1].x, aPoints[aPointCount - 1].y );
GRSetBrush( DC, BgColor, FILLED );
DC->DrawPolygon( aPointCount, aPoints, 0, 0, wxODDEVEN_RULE );
#ifdef USE_CLIP_FILLED_POLYGONS
ClipAndDrawFilledPoly( ClipBox, DC, aPoints, aPointCount );
#else
DC->DrawPolygon( aPointCount, aPoints ); // does not work very well under linux
#endif
}
else
{
......
......@@ -26,6 +26,7 @@ set(GERBVIEW_SRCS
dialog_print_using_printer.cpp
dialog_print_using_printer_base.cpp
dummy_functions.cpp
draw_gerber_screen.cpp
edit.cpp
export_to_pcbnew.cpp
files.cpp
......@@ -46,8 +47,7 @@ set(GERBVIEW_SRCS
rs274d.cpp
rs274x.cpp
select_layers_to_pcb.cpp
toolbars_gerber.cpp
tracepcb.cpp )
toolbars_gerber.cpp )
###
# We need some extra sources from pcbnew
......
This diff is collapsed.
......@@ -119,6 +119,18 @@ public:
void DrawBasicShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC,
int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of the shape of some primitives
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int GetShapeDim( GERBER_DRAW_ITEM* aParent );
private:
/** function ConvertShapeToPolygon
......@@ -127,7 +139,7 @@ private:
* Useful when a shape is not a graphic primitive (shape with hole,
* rotated shape ... ) and cannot be easily drawn.
*/
void ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, std::vector<wxPoint>& aBuffer, bool aUnitsMetric);
void ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, std::vector<wxPoint>& aBuffer );
};
......@@ -155,6 +167,19 @@ struct APERTURE_MACRO
*/
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC,
int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of a shape using many primitives
* one cannot calculate the "size" of a shape (only abounding box)
* but most of aperture macro are using one or few primitives
* and the "dimension" of the shape is the diameter of the primitive
* (or the max diameter of primitives)
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int GetShapeDim( GERBER_DRAW_ITEM* aParent );
};
......
......@@ -98,6 +98,47 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
return ret;
}
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of some shapes,
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line if the shape is a line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
{
int dim = -1;
switch( m_Shape )
{
case APT_CIRCLE:
case APT_LINE:
dim = m_Size.x;
break;
case APT_RECT:
case APT_OVAL:
dim = MIN( m_Size.x, m_Size.y );
break;
case APT_POLYGON:
dim = MIN( m_Size.x, m_Size.y );
break;
case APT_MACRO:
if( m_Macro )
dim = m_Macro->GetShapeDim( aParent );
break;
default:
break;
}
return dim;
}
/** Function Read_D_Code_File
* Can be useful only with old RS274D Gerber file format.
......
......@@ -228,6 +228,18 @@ public:
* rotated shape ... ) and cannot be easily drawn.
*/
void ConvertShapeToPolygon();
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of some shapes,
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line if the shape is a line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int GetShapeDim( GERBER_DRAW_ITEM* aParent );
};
......
......@@ -177,19 +177,24 @@ void Show_Items_DCode_Value( WinEDA_DrawPanel* aPanel, wxDC* aDC, BOARD* aPcb, i
Line.Printf( wxT( "D%d" ), gerb_item->m_DCode );
width = MIN( gerb_item->m_Size.x, gerb_item->m_Size.y );
if( gerb_item->GetDcodeDescr() )
width = gerb_item->GetDcodeDescr()->GetShapeDim( gerb_item );
else
width = MIN( gerb_item->m_Size.x, gerb_item->m_Size.y );
orient = TEXT_ORIENT_HORIZ;
if( gerb_item->m_Flashed )
{
// A reasonnable size for text is width/3 because most ot time this text has 3 chars.
width /= 3;
}
else // lines
else // this item is a line
{
int dx, dy;
dx = gerb_item->m_Start.x - gerb_item->m_End.x;
dy = gerb_item->m_Start.y - gerb_item->m_End.y;
if( abs( dx ) < abs( dy ) )
wxPoint delta = gerb_item->m_Start - gerb_item->m_End;
if( abs( delta.x ) < abs( delta.y ) )
orient = TEXT_ORIENT_VERT;
// A reasonnable size for text is width/2 because text needs margin below and above it.
// a margin = width/4 seems good
width /= 2;
}
......
/*
Copyright 2008 Intel Corporation
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
*/
#ifndef BOOST_POLYGON_SORT_ADAPTOR_HPP
#define BOOST_POLYGON_SORT_ADAPTOR_HPP
#ifdef __ICC
#pragma warning(disable:2022)
#pragma warning(disable:2023)
#endif
#include <algorithm>
//! @brief gtlsort_adaptor default implementation that calls std::sort
namespace boost {
namespace polygon {
template<typename iterator_type>
struct dummy_to_delay_instantiation{
typedef int unit_type; // default GTL unit
};
//! @brief gtlsort_adaptor default implementation that calls std::sort
template<typename T>
struct gtlsort_adaptor {
//! @brief wrapper that mimics std::sort() function and takes
// the same arguments
template<typename RandomAccessIterator_Type>
static void sort(RandomAccessIterator_Type _First,
RandomAccessIterator_Type _Last)
{
std::sort(_First, _Last);
}
//! @brief wrapper that mimics std::sort() function overload and takes
// the same arguments
template<typename RandomAccessIterator_Type, typename Pred_Type>
static void sort(RandomAccessIterator_Type _First,
RandomAccessIterator_Type _Last,
const Pred_Type& _Comp)
{
std::sort(_First, _Last, _Comp);
}
};
//! @brief user level wrapper for sorting quantities
template <typename iter_type>
void gtlsort(iter_type _b_, iter_type _e_)
{
gtlsort_adaptor<typename dummy_to_delay_instantiation<iter_type>::unit_type>::sort(_b_, _e_);
}
//! @brief user level wrapper for sorting quantities that takes predicate
// as additional argument
template <typename iter_type, typename pred_type>
void gtlsort(iter_type _b_, iter_type _e_, const pred_type& _pred_)
{
gtlsort_adaptor<typename dummy_to_delay_instantiation<iter_type>::unit_type>::sort(_b_, _e_, _pred_);
}
} // namespace polygon
} // namespace boost
#endif
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