Commit 36dac0c1 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew nanometer: fix hatch lines issue in polyline.cpp

Some minor code cleaning.
parent e730219b
#ifndef CONVERT_TO_BIU_H
#define CONVERT_TO_BIU_H
#include <config.h> // USE_PCBNEW_NANOMETRES is defined here
/**
* @file convert_to_biu.h
*/
/**
* @brief inline convert functions to convert a value in decimils (or mils)
* to the internal unit used in pcbnew or cvpcb(nanometer or decimil)
* depending on compil option
*/
/// Convert mils to PCBNEW internal units (iu).
inline int Mils2iu( int mils )
{
#if defined( USE_PCBNEW_NANOMETRES )
return int( mils * 25.4e3 + 0.5 );
#else
return mils * 10;
#endif
}
/// Convert deci-mils to PCBNEW internal units (iu).
inline int DMils2iu( int dmils )
{
#if defined( USE_PCBNEW_NANOMETRES )
return int( dmils * 25.4e2 + 0.5 );
#else
return dmils;
#endif
}
#endif // #define CONVERT_TO_BIU_H
...@@ -71,13 +71,6 @@ BOARD::BOARD() : ...@@ -71,13 +71,6 @@ BOARD::BOARD() :
BOARD::~BOARD() BOARD::~BOARD()
{ {
/* @todo
NO! this has nothing to do with a BOARD
Do this in the UI, not in the storage container please.
if( m_PcbFrame && m_PcbFrame->GetScreen() )
m_PcbFrame->GetScreen()->ClearUndoRedoList();
*/
while( m_ZoneDescriptorList.size() ) while( m_ZoneDescriptorList.size() )
{ {
ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0]; ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0];
......
...@@ -272,6 +272,14 @@ public: ...@@ -272,6 +272,14 @@ public:
*/ */
static wxString GetDefaultLayerName( int aLayerNumber ); static wxString GetDefaultLayerName( int aLayerNumber );
/**
* Function ReturnFlippedLayerNumber
* @return the layer number after flipping an item
* some (not all) layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
static int ReturnFlippedLayerNumber( int oldlayer );
/** /**
* Function Add * Function Add
* adds the given item to this BOARD and takes ownership of its memory. * adds the given item to this BOARD and takes ownership of its memory.
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <colors_selection.h> #include <colors_selection.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <protos.h>
#include <richio.h> #include <richio.h>
#include <class_board.h> #include <class_board.h>
...@@ -200,7 +199,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) ...@@ -200,7 +199,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle )
void DIMENSION::Flip( const wxPoint& aCentre ) void DIMENSION::Flip( const wxPoint& aCentre )
{ {
Mirror( aCentre ); Mirror( aCentre );
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
......
...@@ -107,7 +107,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre ) ...@@ -107,7 +107,7 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
NEGATE( m_Angle ); NEGATE( m_Angle );
} }
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
......
...@@ -189,7 +189,7 @@ void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle) ...@@ -189,7 +189,7 @@ void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle)
void PCB_TARGET::Flip(const wxPoint& aCentre ) void PCB_TARGET::Flip(const wxPoint& aCentre )
{ {
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
......
...@@ -11,15 +11,18 @@ ...@@ -11,15 +11,18 @@
#include <macros.h> #include <macros.h>
#include <protos.h> #include <protos.h>
#include <class_board.h>
#include <class_pad.h> #include <class_pad.h>
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <class_module.h> #include <class_module.h>
/* Calculate the layer number for changing cu / cmp layers for Cu / CMP
* (Copper, Mask, Paste, solder) /* Returns the layer number after flipping an item
* some layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/ */
int ChangeSideNumLayer( int oldlayer ) int BOARD::ReturnFlippedLayerNumber( int oldlayer )
{ {
int newlayer; int newlayer;
...@@ -155,7 +158,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -155,7 +158,7 @@ void MODULE::Flip( const wxPoint& aCentre )
SetPosition( finalPos ); SetPosition( finalPos );
// Flip layer // Flip layer
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
// Reverse mirror orientation. // Reverse mirror orientation.
NEGATE( m_Orient ); NEGATE( m_Orient );
...@@ -174,7 +177,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -174,7 +177,7 @@ void MODULE::Flip( const wxPoint& aCentre )
pt_texte->m_Mirror = false; pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() ); pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK ) if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK ); pt_texte->SetLayer( SILKSCREEN_N_BACK );
...@@ -195,7 +198,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -195,7 +198,7 @@ void MODULE::Flip( const wxPoint& aCentre )
pt_texte->m_Mirror = false; pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() ); pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK ) if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK ); pt_texte->SetLayer( SILKSCREEN_N_BACK );
...@@ -236,7 +239,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -236,7 +239,7 @@ void MODULE::Flip( const wxPoint& aCentre )
em->SetAngle( -em->GetAngle() ); em->SetAngle( -em->GetAngle() );
} }
em->SetLayer( ChangeSideNumLayer( em->GetLayer() ) ); em->SetLayer( BOARD::ReturnFlippedLayerNumber( em->GetLayer() ) );
} }
break; break;
...@@ -251,7 +254,7 @@ void MODULE::Flip( const wxPoint& aCentre ) ...@@ -251,7 +254,7 @@ void MODULE::Flip( const wxPoint& aCentre )
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() ); pt_texte->SetLayer( GetLayer() );
pt_texte->SetLayer( ChangeSideNumLayer( pt_texte->GetLayer() ) ); pt_texte->SetLayer( BOARD::ReturnFlippedLayerNumber( pt_texte->GetLayer() ) );
if( GetLayer() == LAYER_N_BACK ) if( GetLayer() == LAYER_N_BACK )
pt_texte->SetLayer( SILKSCREEN_N_BACK ); pt_texte->SetLayer( SILKSCREEN_N_BACK );
......
...@@ -165,7 +165,7 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre ) ...@@ -165,7 +165,7 @@ void TEXTE_PCB::Flip(const wxPoint& aCentre )
{ {
m_Mirror = not m_Mirror; /* inverse mirror */ m_Mirror = not m_Mirror; /* inverse mirror */
} }
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
......
...@@ -392,7 +392,7 @@ void TRACK::Flip( const wxPoint& aCentre ) ...@@ -392,7 +392,7 @@ void TRACK::Flip( const wxPoint& aCentre )
} }
else else
{ {
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
} }
......
...@@ -824,7 +824,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle ) ...@@ -824,7 +824,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
void ZONE_CONTAINER::Flip( const wxPoint& aCentre ) void ZONE_CONTAINER::Flip( const wxPoint& aCentre )
{ {
Mirror( aCentre ); Mirror( aCentre );
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( BOARD::ReturnFlippedLayerNumber( GetLayer() ) );
} }
...@@ -876,7 +876,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src ) ...@@ -876,7 +876,8 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
m_PadConnection = src->m_PadConnection; m_PadConnection = src->m_PadConnection;
m_ThermalReliefGap = src->m_ThermalReliefGap; m_ThermalReliefGap = src->m_ThermalReliefGap;
m_ThermalReliefCopperBridge = src->m_ThermalReliefCopperBridge; m_ThermalReliefCopperBridge = src->m_ThermalReliefCopperBridge;
m_Poly->m_HatchStyle = src->m_Poly->GetHatchStyle(); m_Poly->SetHatchStyle( src->m_Poly->GetHatchStyle() );
m_Poly->SetHatchPitch( src->m_Poly->GetHatchPitch() );
m_Poly->m_HatchLines = src->m_Poly->m_HatchLines; // Copy vector <CSegment> m_Poly->m_HatchLines = src->m_Poly->m_HatchLines; // Copy vector <CSegment>
m_FilledPolysList.clear(); m_FilledPolysList.clear();
m_FilledPolysList = src->m_FilledPolysList; m_FilledPolysList = src->m_FilledPolysList;
......
...@@ -73,7 +73,7 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c ...@@ -73,7 +73,7 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c
aTarget.m_FillMode = m_FillMode; aTarget.m_FillMode = m_FillMode;
aTarget.m_ZoneClearance = m_ZoneClearance; aTarget.m_ZoneClearance = m_ZoneClearance;
aTarget.m_ZoneMinThickness = m_ZoneMinThickness; aTarget.m_ZoneMinThickness = m_ZoneMinThickness;
aTarget.m_Poly->SetHatch( m_Zone_HatchingStyle ); aTarget.m_Poly->SetHatch( m_Zone_HatchingStyle, Mils2iu( 20 ) );
aTarget.m_ArcToSegmentsCount = m_ArcToSegmentsCount; aTarget.m_ArcToSegmentsCount = m_ArcToSegmentsCount;
aTarget.m_ThermalReliefGap = m_ThermalReliefGap; aTarget.m_ThermalReliefGap = m_ThermalReliefGap;
aTarget.m_ThermalReliefCopperBridge = m_ThermalReliefCopperBridge; aTarget.m_ThermalReliefCopperBridge = m_ThermalReliefCopperBridge;
......
...@@ -1980,7 +1980,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) ...@@ -1980,7 +1980,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
} }
// Set hatch here, when outlines corners are read // Set hatch here, when outlines corners are read
m_Poly->SetHatch( outline_hatch ); m_Poly->SetHatch( outline_hatch, Mils2iu( m_Poly->GetDefaultHatchPitchMils() ) );
return error ? 0 : 1; return error ? 0 : 1;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
* *
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
#include <3d_struct.h> #include <3d_struct.h>
#include <pcb_plot_params.h> #include <pcb_plot_params.h>
#include <drawtxt.h> #include <drawtxt.h>
#include <convert_to_biu.h>
#include <trigo.h> #include <trigo.h>
#include <wx/ffile.h> #include <wx/ffile.h>
...@@ -2286,7 +2286,8 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() ...@@ -2286,7 +2286,8 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
} }
// Set hatch here, after outlines corners are read // Set hatch here, after outlines corners are read
zc->m_Poly->SetHatch( outline_hatch ); zc->m_Poly->SetHatch( outline_hatch,
Mils2iu( zc->m_Poly->GetDefaultHatchPitchMils() ) );
m_board->Add( zc.release() ); m_board->Add( zc.release() );
} }
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#include <drag.h> #include <drag.h>
static void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
static void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC );
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <fctsys.h> // PCB_INTERNAL_UNIT and EESCHEMA_INTERNAL_UNIT definitions. #include <fctsys.h> // PCB_INTERNAL_UNIT and EESCHEMA_INTERNAL_UNIT definitions.
#include <base_struct.h> // IS_DRAGGED and IN_EDIT definitions. #include <base_struct.h> // IS_DRAGGED and IN_EDIT definitions.
#include <convert_to_biu.h> // to define DMils2iu() conversion function
#define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT) #define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT)
...@@ -34,19 +34,6 @@ ...@@ -34,19 +34,6 @@
#define DIM_ANCRE_TEXTE 2 /* Anchor size (Text center) */ #define DIM_ANCRE_TEXTE 2 /* Anchor size (Text center) */
#if defined(PCBNEW)
/// Convert deci-mils to PCBNEW internal units (iu).
inline int DMils2iu( int dmils )
{
#if defined( USE_PCBNEW_NANOMETRES )
return int( dmils * 25.4e2 + 0.5 );
#else
return dmils;
#endif
}
#endif
#define TEXTS_MIN_SIZE DMils2iu( 50 ) ///< Minimum text size in Pcbnew units value (50 * 0.0001 mils) #define TEXTS_MIN_SIZE DMils2iu( 50 ) ///< Minimum text size in Pcbnew units value (50 * 0.0001 mils)
#define TEXTS_MAX_SIZE DMils2iu( 10000 ) ///< Maximum text size in Pcbnew units value (1 inch) ) #define TEXTS_MAX_SIZE DMils2iu( 10000 ) ///< Maximum text size in Pcbnew units value (1 inch) )
#define TEXTS_MAX_WIDTH DMils2iu( 5000 ) ///< Maximum text width in Pcbnew units value (0.5 inches) #define TEXTS_MAX_WIDTH DMils2iu( 5000 ) ///< Maximum text width in Pcbnew units value (0.5 inches)
......
...@@ -6,18 +6,13 @@ ...@@ -6,18 +6,13 @@
#define PROTO_H #define PROTO_H
#include <vector>
class wxDC; class wxDC;
class wxPoint; class wxPoint;
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
class BOARD_ITEM; class BOARD_ITEM;
class D_PAD;
class TRACK; class TRACK;
class MODULE; class MODULE;
/** /**
* Function SwapData * Function SwapData
* Used in undo / redo command: * Used in undo / redo command:
...@@ -63,15 +58,7 @@ void DrawTraces( EDA_DRAW_PANEL* panel, ...@@ -63,15 +58,7 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
*/ */
int ChangeSideMaskLayer( int aMask ); int ChangeSideMaskLayer( int aMask );
/**
* Function ChangeSideNumLayer
* calculates the layer number for changing cu / cmp layers for Cu / CMP.
* (Copper, Mask, Paste, solder)
*/
int ChangeSideNumLayer( int oldlayer );
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module ); void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module );
void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase );
/****************/ /****************/
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <zones.h> #include <zones.h>
#include <protos.h>
/* Local functions */ /* Local functions */
......
...@@ -8,18 +8,11 @@ ...@@ -8,18 +8,11 @@
#include <algorithm> #include <algorithm>
#include <fctsys.h> #include <fctsys.h>
#include <config.h> // to define KICAD_NANOMETRE
#include <PolyLine.h> #include <PolyLine.h>
#include <bezier_curves.h> #include <bezier_curves.h>
#include <polygon_test_point_inside.h> #include <polygon_test_point_inside.h>
#if defined(KICAD_NANOMETRE)
#define PCBU_PER_MIL (1000.0*25.4)
#else
#define PCBU_PER_MIL 10
#endif
#define to_int( x ) wxRound( (x) ) #define to_int( x ) wxRound( (x) )
...@@ -34,7 +27,8 @@ ...@@ -34,7 +27,8 @@
CPolyLine::CPolyLine() CPolyLine::CPolyLine()
{ {
m_HatchStyle = 0; m_hatchStyle = NO_HATCH;
m_hatchPitch = 0;
m_Width = 0; m_Width = 0;
utility = 0; utility = 0;
m_Kbool_Poly_Engine = NULL; m_Kbool_Poly_Engine = NULL;
...@@ -794,7 +788,7 @@ int CPolyLine::RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine ...@@ -794,7 +788,7 @@ int CPolyLine::RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine
void CPolyLine::Start( int layer, int x, int y, int hatch ) void CPolyLine::Start( int layer, int x, int y, int hatch )
{ {
m_layer = layer; m_layer = layer;
m_HatchStyle = hatch; SetHatchStyle( (enum hatch_style) hatch );
CPolyPt poly_pt( x, y ); CPolyPt poly_pt( x, y );
poly_pt.end_contour = false; poly_pt.end_contour = false;
...@@ -1379,7 +1373,7 @@ void CPolyLine::Hatch() ...@@ -1379,7 +1373,7 @@ void CPolyLine::Hatch()
{ {
m_HatchLines.clear(); m_HatchLines.clear();
if( m_HatchStyle == NO_HATCH ) if( m_hatchStyle == NO_HATCH || m_hatchPitch == 0 )
return; return;
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
...@@ -1404,13 +1398,13 @@ void CPolyLine::Hatch() ...@@ -1404,13 +1398,13 @@ void CPolyLine::Hatch()
// Calculate spacing betwwen 2 hatch lines // Calculate spacing betwwen 2 hatch lines
int spacing; int spacing;
if( m_HatchStyle == DIAGONAL_EDGE ) if( m_hatchStyle == DIAGONAL_EDGE )
spacing = 20 * PCBU_PER_MIL; spacing = m_hatchPitch;
else else
spacing = 50 * PCBU_PER_MIL; spacing = m_hatchPitch * 2;
// set the "lenght" of hatch lines (the lenght on horizontal axis) // set the "lenght" of hatch lines (the lenght on horizontal axis)
double hatch_line_len = 20 * PCBU_PER_MIL; double hatch_line_len = m_hatchPitch;
// To have a better look, give a slope depending on the layer // To have a better look, give a slope depending on the layer
int layer = GetLayer(); int layer = GetLayer();
...@@ -1438,7 +1432,7 @@ void CPolyLine::Hatch() ...@@ -1438,7 +1432,7 @@ void CPolyLine::Hatch()
int nc = corner.size(); int nc = corner.size();
// loop through hatch lines // loop through hatch lines
#define MAXPTS 200 // Usually we store only few values #define MAXPTS 200 // Usually we store only few values per one hatch line
// depending on the compexity of the zone outline // depending on the compexity of the zone outline
static std::vector <CPoint> pointbuffer; static std::vector <CPoint> pointbuffer;
...@@ -1514,7 +1508,7 @@ void CPolyLine::Hatch() ...@@ -1514,7 +1508,7 @@ void CPolyLine::Hatch()
// Push only one line for diagonal hatch, // Push only one line for diagonal hatch,
// or for small lines < twice the line len // or for small lines < twice the line len
// else push 2 small lines // else push 2 small lines
if( m_HatchStyle == DIAGONAL_FULL || fabs( dx ) < 2 * hatch_line_len ) if( m_hatchStyle == DIAGONAL_FULL || fabs( dx ) < 2 * hatch_line_len )
{ {
m_HatchLines.push_back( CSegment( pointbuffer[ip].x, m_HatchLines.push_back( CSegment( pointbuffer[ip].x,
pointbuffer[ip].y, pointbuffer[ip].y,
...@@ -1583,7 +1577,8 @@ bool CPolyLine::TestPointInside( int px, int py ) ...@@ -1583,7 +1577,8 @@ bool CPolyLine::TestPointInside( int px, int py )
void CPolyLine::Copy( CPolyLine* src ) void CPolyLine::Copy( CPolyLine* src )
{ {
UnHatch(); UnHatch();
m_HatchStyle = src->m_HatchStyle; m_hatchStyle = src->m_hatchStyle;
m_hatchPitch = src->m_hatchPitch;
// copy corners, using vector copy // copy corners, using vector copy
corner = src->corner; corner = src->corner;
// copy side styles, using vector copy // copy side styles, using vector copy
......
...@@ -108,8 +108,8 @@ public: ...@@ -108,8 +108,8 @@ public:
class CPolyLine class CPolyLine
{ {
public: public:
enum { STRAIGHT, ARC_CW, ARC_CCW }; // side styles enum side_style { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
enum { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles enum hatch_style { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
// constructors/destructor // constructors/destructor
CPolyLine(); CPolyLine();
...@@ -180,13 +180,25 @@ public: ...@@ -180,13 +180,25 @@ public:
int GetUtility( int ic ) { return corner[ic].utility; }; int GetUtility( int ic ) { return corner[ic].utility; };
void SetUtility( int ic, int utility ) { corner[ic].utility = utility; }; void SetUtility( int ic, int utility ) { corner[ic].utility = utility; };
int GetSideStyle( int is ); int GetSideStyle( int is );
int GetHatchPitch() { return m_hatchPitch; }
int GetHatchStyle() { return m_HatchStyle; } int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils
void SetHatch( int hatch ) { m_HatchStyle = hatch; Hatch(); };
enum hatch_style GetHatchStyle() { return m_hatchStyle; }
void SetHatch( int hatch, int pitch )
{
SetHatchPitch( pitch );
m_hatchStyle = (enum hatch_style ) hatch;
Hatch();
}
void SetX( int ic, int x ); void SetX( int ic, int x );
void SetY( int ic, int y ); void SetY( int ic, int y );
void SetEndContour( int ic, bool end_contour ); void SetEndContour( int ic, bool end_contour );
void SetSideStyle( int is, int style ); void SetSideStyle( int is, int style );
void SetHatchStyle( enum hatch_style style )
{
m_hatchStyle = style;
}
void SetHatchPitch( int pitch ) { m_hatchPitch = pitch; }
int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa = NULL ); int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa = NULL );
...@@ -260,15 +272,18 @@ public: ...@@ -260,15 +272,18 @@ public:
private: private:
int m_layer; // layer to draw on int m_layer; // layer to draw on
int m_Width; // lines width when drawing. Provided but not really used int m_Width; // lines width when drawing. Provided but not really used
enum hatch_style m_hatchStyle; // hatch style, see enum above
int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines
// and the len of eacvh segment
// for DIAGONAL_FULL, the pitch is twice this value
int utility; int utility;
Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data
public: public:
std::vector <CPolyPt> corner; // array of points for corners std::vector <CPolyPt> corner; // array of points for corners
std::vector <int> side_style; // array of styles for sides std::vector <int> side_style; // array of styles for sides
int m_HatchStyle; // hatch style, see enum above
std::vector <CSegment> m_HatchLines; // hatch lines std::vector <CSegment> m_HatchLines; // hatch lines
}; };
......
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