Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
bc5d9a75
Commit
bc5d9a75
authored
Nov 23, 2009
by
stambaughw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete comment translation of common source.
parent
d21bf859
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
2523 additions
and
2658 deletions
+2523
-2658
base_screen.cpp
common/base_screen.cpp
+22
-45
base_struct.cpp
common/base_struct.cpp
+1
-3
basicframe.cpp
common/basicframe.cpp
+10
-29
block_commande.cpp
common/block_commande.cpp
+25
-48
class_marker_base.cpp
common/class_marker_base.cpp
+0
-1
class_plotter.cpp
common/class_plotter.cpp
+114
-124
common.cpp
common/common.cpp
+30
-85
common_plotDXF_functions.cpp
common/common_plotDXF_functions.cpp
+95
-115
common_plotGERBER_functions.cpp
common/common_plotGERBER_functions.cpp
+62
-88
common_plotHPGL_functions.cpp
common/common_plotHPGL_functions.cpp
+341
-278
common_plotPS_functions.cpp
common/common_plotPS_functions.cpp
+204
-220
common_plot_functions.cpp
common/common_plot_functions.cpp
+100
-76
confirm.cpp
common/confirm.cpp
+42
-41
copy_to_clipboard.cpp
common/copy_to_clipboard.cpp
+12
-14
displlst.cpp
common/displlst.cpp
+10
-44
drawframe.cpp
common/drawframe.cpp
+51
-99
drawpanel.cpp
common/drawpanel.cpp
+112
-151
eda_dde.cpp
common/eda_dde.cpp
+22
-30
eda_doc.cpp
common/eda_doc.cpp
+46
-52
gestfich.cpp
common/gestfich.cpp
+110
-113
gr_basic.cpp
common/gr_basic.cpp
+508
-349
hotkeys_basic.cpp
common/hotkeys_basic.cpp
+75
-92
msgpanel.cpp
common/msgpanel.cpp
+14
-29
pcbcommon.cpp
common/pcbcommon.cpp
+12
-9
projet_config.cpp
common/projet_config.cpp
+21
-36
pyhandler.cpp
common/pyhandler.cpp
+156
-60
selcolor.cpp
common/selcolor.cpp
+1
-11
string.cpp
common/string.cpp
+33
-66
toolbars.cpp
common/toolbars.cpp
+6
-7
trigo.cpp
common/trigo.cpp
+96
-121
worksheet.cpp
common/worksheet.cpp
+114
-120
wxwineda.cpp
common/wxwineda.cpp
+67
-76
zoom.cpp
common/zoom.cpp
+11
-26
No files found.
common/base_screen.cpp
View file @
bc5d9a75
/********************************************************
*******
/
/* base_screen.cpp -
fonctions des classes du type BASE_SCREEN
*/
/********************************************************
*******
/
/********************************************************/
/* base_screen.cpp -
BASE_SCREEN object implementation.
*/
/********************************************************/
#ifdef __GNUG__
#pragma implementation
...
...
@@ -19,16 +19,14 @@ WX_DEFINE_OBJARRAY( GridArray );
BASE_SCREEN
*
ActiveScreen
=
NULL
;
/* defines locaux
*/
#define CURSOR_SIZE 12
/* taille de la croix du curseur PCB */
#define CURSOR_SIZE 12
/* size of the cross cursor.
*/
/*******************************************************/
/* Class BASE_SCREEN: classe de gestion d'un affichage */
/*******************************************************/
BASE_SCREEN
::
BASE_SCREEN
(
KICAD_T
aType
)
:
EDA_BaseStruct
(
aType
)
{
EEDrawList
=
NULL
;
/* Schematic items list */
m_UndoRedoCountMax
=
10
;
/* undo/Redo command Max depth, 10 is a reasonnable value */
m_UndoRedoCountMax
=
10
;
/* undo/Redo command Max depth, 10 is a
* reasonable value */
m_FirstRedraw
=
TRUE
;
m_ScreenNumber
=
1
;
m_NumberOfScreen
=
1
;
/* Hierarchy: Root: ScreenNumber = 1 */
...
...
@@ -45,16 +43,12 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
}
/******************************/
BASE_SCREEN
::~
BASE_SCREEN
()
/******************************/
{
}
/*******************************/
void
BASE_SCREEN
::
InitDatas
()
/*******************************/
{
if
(
m_Center
)
{
...
...
@@ -73,16 +67,15 @@ void BASE_SCREEN::InitDatas()
SetCurItem
(
NULL
);
/* indicateurs divers */
m_FlagRefreshReq
=
0
;
/* Redraw screen requste flag */
m_FlagModified
=
0
;
// Set when any change is made on borad
m_FlagRefreshReq
=
0
;
/* Redraw screen request flag */
m_FlagModified
=
0
;
// Set when any change is made on broad
m_FlagSave
=
1
;
// Used in auto save: set when an auto save is made
}
/**
* Get screen units scalar.
*
* Default impl
i
mentation returns scalar used for schematic screen. The
* Default impl
e
mentation returns scalar used for schematic screen. The
* internal units used by the schematic screen is 1 mil (0.001"). Override
* this in derived classes that require internal units other than 1 mil.
*/
...
...
@@ -91,9 +84,8 @@ int BASE_SCREEN::GetInternalUnits( void )
return
EESCHEMA_INTERNAL_UNIT
;
}
/************************************/
wxSize
BASE_SCREEN
::
ReturnPageSize
(
void
)
/************************************/
{
int
internal_units
=
GetInternalUnits
();
...
...
@@ -107,9 +99,7 @@ wxSize BASE_SCREEN::ReturnPageSize( void )
* @return the position in user units of location ScreenPos
* @param ScreenPos = the screen (in pixel) position co convert
*/
/******************************************************************/
wxPoint
BASE_SCREEN
::
CursorRealPosition
(
const
wxPoint
&
ScreenPos
)
/******************************************************************/
{
wxPoint
curpos
=
ScreenPos
;
Unscale
(
curpos
);
...
...
@@ -122,7 +112,7 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
}
/** Function SetScalingFactor
* calculates the .m_Zoom member to have a given scaling fac
ort
* calculates the .m_Zoom member to have a given scaling fac
tor
* @param the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( )
*/
...
...
@@ -163,6 +153,7 @@ int BASE_SCREEN::Scale( int coord )
#endif
}
double
BASE_SCREEN
::
Scale
(
double
coord
)
{
#ifdef WX_ZOOM
...
...
@@ -178,12 +169,14 @@ double BASE_SCREEN::Scale( double coord )
#endif
}
void
BASE_SCREEN
::
Scale
(
wxPoint
&
pt
)
{
pt
.
x
=
Scale
(
pt
.
x
);
pt
.
y
=
Scale
(
pt
.
y
);
}
void
BASE_SCREEN
::
Scale
(
wxRealPoint
&
pt
)
{
#ifdef WX_ZOOM
...
...
@@ -336,12 +329,7 @@ bool BASE_SCREEN::SetLastZoom()
}
/********************************************/
void
BASE_SCREEN
::
SetGridList
(
GridArray
&
gridlist
)
/********************************************/
/* init liste des zoom (NULL terminated)
*/
{
if
(
!
m_GridList
.
IsEmpty
()
)
m_GridList
.
Clear
();
...
...
@@ -350,9 +338,7 @@ void BASE_SCREEN::SetGridList( GridArray& gridlist )
}
/**********************************************/
void
BASE_SCREEN
::
SetGrid
(
const
wxRealPoint
&
size
)
/**********************************************/
{
wxASSERT
(
!
m_GridList
.
IsEmpty
()
);
...
...
@@ -380,6 +366,7 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
size
.
x
,
size
.
y
,
m_Grid
.
m_Size
.
x
,
m_Grid
.
m_Size
.
y
);
}
/* Set grid size from command ID. */
void
BASE_SCREEN
::
SetGrid
(
int
id
)
{
...
...
@@ -403,6 +390,7 @@ void BASE_SCREEN::SetGrid( int id )
m_Grid
.
m_Size
.
y
);
}
void
BASE_SCREEN
::
AddGrid
(
const
GRID_TYPE
&
grid
)
{
size_t
i
;
...
...
@@ -432,6 +420,7 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
m_GridList
.
Add
(
grid
);
}
void
BASE_SCREEN
::
AddGrid
(
const
wxRealPoint
&
size
,
int
id
)
{
GRID_TYPE
grid
;
...
...
@@ -441,6 +430,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
AddGrid
(
grid
);
}
void
BASE_SCREEN
::
AddGrid
(
const
wxRealPoint
&
size
,
int
units
,
int
id
)
{
double
x
,
y
;
...
...
@@ -490,25 +480,19 @@ int BASE_SCREEN::GetGridId()
}
/*****************************************/
void
BASE_SCREEN
::
ClearUndoRedoList
()
/*****************************************/
/* free the undo and the redo lists
*/
void
BASE_SCREEN
::
ClearUndoRedoList
()
{
ClearUndoORRedoList
(
m_UndoList
);
ClearUndoORRedoList
(
m_RedoList
);
}
/***********************************************************/
void
BASE_SCREEN
::
PushCommandToUndoList
(
PICKED_ITEMS_LIST
*
aNewitem
)
/************************************************************/
/* Put aNewitem in top of undo list
* Deletes old
s
items if > count max.
* Deletes old items if > count max.
*/
void
BASE_SCREEN
::
PushCommandToUndoList
(
PICKED_ITEMS_LIST
*
aNewitem
)
{
m_UndoList
.
PushCommand
(
aNewitem
);
...
...
@@ -519,9 +503,7 @@ void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
}
/***********************************************************/
void
BASE_SCREEN
::
PushCommandToRedoList
(
PICKED_ITEMS_LIST
*
aNewitem
)
/***********************************************************/
{
m_RedoList
.
PushCommand
(
aNewitem
);
...
...
@@ -532,17 +514,13 @@ void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
}
/*****************************************************/
PICKED_ITEMS_LIST
*
BASE_SCREEN
::
PopCommandFromUndoList
(
)
/*****************************************************/
{
return
m_UndoList
.
PopCommand
(
);
}
/******************************************************/
PICKED_ITEMS_LIST
*
BASE_SCREEN
::
PopCommandFromRedoList
(
)
/******************************************************/
{
return
m_RedoList
.
PopCommand
(
);
}
...
...
@@ -572,4 +550,3 @@ void BASE_SCREEN::Show( int nestLevel, std::ostream& os )
NestedSpace
(
nestLevel
,
os
)
<<
"</"
<<
GetClass
().
Lower
().
mb_str
()
<<
">
\n
"
;
}
#endif
common/base_struct.cpp
View file @
bc5d9a75
...
...
@@ -4,8 +4,6 @@
/* EDA_TextStruct */
/****************************************/
/* Fichier base_struct.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "trigo.h"
...
...
@@ -28,7 +26,7 @@ EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
{
InitVars
();
m_StructType
=
idType
;
m_Parent
=
parent
;
/* Chainage hierarchique sur struct racine */
m_Parent
=
parent
;
}
...
...
common/basicframe.cpp
View file @
bc5d9a75
...
...
@@ -23,7 +23,6 @@
/*
* Class constructor for WinEDA_BasicFrame general options
*/
/**********************************************************/
WinEDA_BasicFrame
::
WinEDA_BasicFrame
(
wxWindow
*
father
,
int
idtype
,
const
wxString
&
title
,
...
...
@@ -45,32 +44,27 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
SetSizeHints
(
minsize
.
x
,
minsize
.
y
,
-
1
,
-
1
,
-
1
,
-
1
);
/* Verification des parametres de creation */
if
(
(
size
.
x
<
minsize
.
x
)
||
(
size
.
y
<
minsize
.
y
)
)
if
(
(
size
.
x
<
minsize
.
x
)
||
(
size
.
y
<
minsize
.
y
)
)
SetSize
(
0
,
0
,
minsize
.
x
,
minsize
.
y
);
// Create child subwindows.
GetClientSize
(
&
m_FrameSize
.
x
,
&
m_FrameSize
.
y
);
/* dimx, dimy = dimensions utiles de la
* zone utilisateur de la fenetre principale */
GetClientSize
(
&
m_FrameSize
.
x
,
&
m_FrameSize
.
y
);
/* dimensions of the user
* area of the main
* window */
m_FramePos
.
x
=
m_FramePos
.
y
=
0
;
m_FrameSize
.
y
-=
m_MsgFrameHeight
;
}
/*
*
*/
/******************************************/
WinEDA_BasicFrame
::~
WinEDA_BasicFrame
()
/******************************************/
{
if
(
wxGetApp
().
m_HtmlCtrl
)
delete
wxGetApp
().
m_HtmlCtrl
;
wxGetApp
().
m_HtmlCtrl
=
NULL
;
/* This needed for OSX: avoids furter OnDraw processing after this
destructor
* and before the native window is destroyed
/* This needed for OSX: avoids furter OnDraw processing after this
*
destructor
and before the native window is destroyed
*/
this
->
Freeze
(
);
}
...
...
@@ -79,9 +73,7 @@ WinEDA_BasicFrame::~WinEDA_BasicFrame()
/*
* Virtual function
*/
/***********************************/
void
WinEDA_BasicFrame
::
ReCreateMenuBar
()
/***********************************/
{
}
...
...
@@ -158,9 +150,7 @@ void WinEDA_BasicFrame::SaveSettings()
}
/******************************************************/
void
WinEDA_BasicFrame
::
PrintMsg
(
const
wxString
&
text
)
/******************************************************/
{
SetStatusText
(
text
);
}
...
...
@@ -169,9 +159,7 @@ void WinEDA_BasicFrame::PrintMsg( const wxString& text )
/*
* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
*/
/*************************************************************************/
void
WinEDA_BasicFrame
::
DisplayActivity
(
int
PerCent
,
const
wxString
&
Text
)
/*************************************************************************/
{
wxString
Line
;
...
...
@@ -188,11 +176,9 @@ void WinEDA_BasicFrame::DisplayActivity( int PerCent, const wxString& Text )
/*
*
Met a jour la liste des anciens projets
*
Update the list of past projects.
*/
/*******************************************************************/
void
WinEDA_BasicFrame
::
SetLastProject
(
const
wxString
&
FullFileName
)
/*******************************************************************/
{
wxGetApp
().
m_fileHistory
.
AddFileToHistory
(
FullFileName
);
ReCreateMenuBar
();
...
...
@@ -202,10 +188,8 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
/*
* Fetch the file name from the file history list.
*/
/*********************************************************************/
wxString
WinEDA_BasicFrame
::
GetFileFromHistory
(
int
cmdId
,
const
wxString
&
type
)
/*********************************************************************/
{
wxString
fn
,
msg
;
size_t
i
;
...
...
@@ -236,9 +220,7 @@ wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId,
/*
*
*/
/**************************************************************/
void
WinEDA_BasicFrame
::
GetKicadHelp
(
wxCommandEvent
&
event
)
/**************************************************************/
{
wxString
msg
;
...
...
@@ -257,7 +239,8 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
}
else
{
msg
.
Printf
(
_
(
"Help file %s not found"
),
GetChars
(
wxGetApp
().
m_HelpFileName
)
);
msg
.
Printf
(
_
(
"Help file %s not found"
),
GetChars
(
wxGetApp
().
m_HelpFileName
)
);
DisplayError
(
this
,
msg
);
}
...
...
@@ -273,7 +256,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument
(
this
,
helpFile
);
#else
#
error Help files format not defined
#
error Help files format not defined
#endif
}
...
...
@@ -281,9 +264,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/*
*
*/
/***********************************************************************/
void
WinEDA_BasicFrame
::
GetKicadAbout
(
wxCommandEvent
&
WXUNUSED
(
event
)
)
/***********************************************************************/
{
wxAboutDialogInfo
info
;
InitKiCadAbout
(
info
);
...
...
common/block_commande.cpp
View file @
bc5d9a75
/****************************************************/
/* Routines de gestion des commandes sur blocks */
/* (section commune eeschema/pcbnew... */
/****************************************************/
/* Fichier common.cpp */
/********************************************/
/* Routines for managing on block commands. */
/* (Common section Eeschema / pcbnew ... */
/********************************************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -17,36 +15,25 @@
#include "block_commande.h"
/*******************/
/* BLOCK_SELECTOR */
/*******************/
/****************************************************************************/
BLOCK_SELECTOR
::
BLOCK_SELECTOR
()
:
EDA_BaseStruct
(
BLOCK_LOCATE_STRUCT_TYPE
),
EDA_Rect
()
/****************************************************************************/
{
m_State
=
STATE_NO_BLOCK
;
/*
Etat (enum BlockState) du block
*/
m_Command
=
BLOCK_IDLE
;
/* Type (enum CmdBlockType)
d'operation
*/
m_State
=
STATE_NO_BLOCK
;
/*
State (enum BlockState) of block.
*/
m_Command
=
BLOCK_IDLE
;
/* Type (enum CmdBlockType)
of operation.
*/
m_Color
=
BROWN
;
}
/****************************************/
BLOCK_SELECTOR
::~
BLOCK_SELECTOR
()
/****************************************/
{
}
/***************************************************************/
void
BLOCK_SELECTOR
::
SetMessageBlock
(
WinEDA_DrawFrame
*
frame
)
/***************************************************************/
/*
* Print block command message (Block move, Block copy ...) in status bar
*/
void
BLOCK_SELECTOR
::
SetMessageBlock
(
WinEDA_DrawFrame
*
frame
)
{
wxString
msg
;
...
...
@@ -109,12 +96,10 @@ void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame )
}
/**************************************************************/
void
BLOCK_SELECTOR
::
Draw
(
WinEDA_DrawPanel
*
aPanel
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
int
aDrawMode
,
int
aColor
)
/**************************************************************/
{
int
w
=
aPanel
->
GetScreen
()
->
Scale
(
GetWidth
()
);
int
h
=
aPanel
->
GetScreen
()
->
Scale
(
GetHeight
()
);
...
...
@@ -129,13 +114,11 @@ void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
}
/*************************************************************************/
void
BLOCK_SELECTOR
::
InitData
(
WinEDA_DrawPanel
*
aPanel
,
const
wxPoint
&
startpos
)
/*************************************************************************/
/** function InitData
* Init the initial values of a BLOCK_SELECTOR, before starting a block command
*/
void
BLOCK_SELECTOR
::
InitData
(
WinEDA_DrawPanel
*
aPanel
,
const
wxPoint
&
startpos
)
{
m_State
=
STATE_BLOCK_INIT
;
SetOrigin
(
startpos
);
...
...
@@ -147,7 +130,8 @@ void BLOCK_SELECTOR::InitData( WinEDA_DrawPanel* aPanel, const wxPoint& startpos
/** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data
* itself
*/
void
BLOCK_SELECTOR
::
ClearItemsList
()
{
...
...
@@ -155,7 +139,8 @@ void BLOCK_SELECTOR::ClearItemsList()
}
/** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted
* by m_Item
*/
void
BLOCK_SELECTOR
::
ClearListAndDeleteItems
()
{
...
...
@@ -173,14 +158,11 @@ void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem )
/*************************************************************************/
bool
WinEDA_DrawFrame
::
HandleBlockBegin
(
wxDC
*
DC
,
int
key
,
const
wxPoint
&
startpos
)
/*************************************************************************/
/* First command block function:
* Init the Block infos: command type, initial position, and other variables..
*/
bool
WinEDA_DrawFrame
::
HandleBlockBegin
(
wxDC
*
DC
,
int
key
,
const
wxPoint
&
startpos
)
{
BLOCK_SELECTOR
*
Block
=
&
GetBaseScreen
()
->
m_BlockLocate
;
...
...
@@ -204,7 +186,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
case
BLOCK_DELETE
:
/* Delete */
case
BLOCK_SAVE
:
/* Save */
case
BLOCK_ROTATE
:
/* Rotate 90 deg */
case
BLOCK_FLIP
:
/* Flip */
case
BLOCK_FLIP
:
/* Flip */
case
BLOCK_ZOOM
:
/* Window Zoom */
case
BLOCK_MIRROR_X
:
case
BLOCK_MIRROR_Y
:
/* mirror */
...
...
@@ -228,7 +210,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
{
Block
->
m_ItemsSelection
.
ClearItemsList
();
DisplayError
(
this
,
wxT
(
"WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL"
)
);
wxT
(
"WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL"
)
);
return
TRUE
;
}
Block
->
m_State
=
STATE_BLOCK_MOVE
;
...
...
@@ -249,15 +231,14 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
return
TRUE
;
}
/********************************************************************************/
void
DrawAndSizingBlockOutlines
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
bool
erase
)
/********************************************************************************/
/* Redraw the outlines of the block which shows the search area for block commands
/* Redraw the outlines of the block which shows the search area for block
* commands
* The first point of the rectangle showing the area is initialised
* by Initm_BlockLocateDatas().
* The other point of the rectangle is the mouse cursor
*/
void
DrawAndSizingBlockOutlines
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
bool
erase
)
{
BLOCK_SELECTOR
*
PtBlock
;
...
...
@@ -265,7 +246,6 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
PtBlock
->
m_MoveVector
=
wxPoint
(
0
,
0
);
/* Effacement ancien cadre */
if
(
erase
)
PtBlock
->
Draw
(
panel
,
DC
,
wxPoint
(
0
,
0
),
g_XorMode
,
PtBlock
->
m_Color
);
...
...
@@ -277,25 +257,23 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if
(
PtBlock
->
m_State
==
STATE_BLOCK_INIT
)
{
if
(
PtBlock
->
GetWidth
()
||
PtBlock
->
GetHeight
()
)
/* 2
ieme point existant: le rectangle n'est pas de surface null
e */
/* 2
nd point exists: the rectangle is not surface anywher
e */
PtBlock
->
m_State
=
STATE_BLOCK_END
;
}
}
/******************************************************************/
void
AbortBlockCurrentCommand
(
WinEDA_DrawPanel
*
Panel
,
wxDC
*
DC
)
/******************************************************************/
/*
* Cancel Current block operation.
*/
void
AbortBlockCurrentCommand
(
WinEDA_DrawPanel
*
Panel
,
wxDC
*
DC
)
{
BASE_SCREEN
*
screen
=
Panel
->
GetScreen
();
if
(
Panel
->
ManageCurseur
)
/* Erase current drawing on screen */
if
(
Panel
->
ManageCurseur
)
/* Erase current drawing
* on screen */
{
Panel
->
ManageCurseur
(
Panel
,
DC
,
FALSE
);
/* Efface dessin fantome
*/
Panel
->
ManageCurseur
(
Panel
,
DC
,
FALSE
);
/* Clear block outline.
*/
Panel
->
ManageCurseur
=
NULL
;
Panel
->
ForceCloseManageCurseur
=
NULL
;
screen
->
SetCurItem
(
NULL
);
...
...
@@ -314,4 +292,3 @@ void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
screen
->
m_BlockLocate
.
m_Command
=
BLOCK_IDLE
;
Panel
->
m_Parent
->
DisplayToolMsg
(
wxEmptyString
);
}
common/class_marker_base.cpp
View file @
bc5d9a75
...
...
@@ -88,7 +88,6 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
}
/* Effacement memoire de la structure */
MARKER_BASE
::~
MARKER_BASE
()
{
}
...
...
common/class_plotter.cpp
View file @
bc5d9a75
...
...
@@ -11,7 +11,6 @@
#include "fctsys.h"
//#include "gr_basic.h"
#include "trigo.h"
#include "wxstruct.h"
#include "base_struct.h"
...
...
@@ -37,27 +36,24 @@ PLOTTER::PLOTTER( PlotFormat aPlotType )
}
/********************************************************/
/* Modifies coordinates pos.x and pos.y trace according to the orientation,
* scale factor, and offsets trace
*/
void
PLOTTER
::
user_to_device_coordinates
(
wxPoint
&
pos
)
/********************************************************/
/* modifie les coord pos.x et pos.y pour le trace selon l'orientation,
* l'echelle, les offsets de trace */
{
pos
.
x
=
(
int
)
(
(
pos
.
x
-
plot_offset
.
x
)
*
plot_scale
*
device_scale
);
if
(
plot_orient_options
==
PLOT_MIROIR
)
pos
.
y
=
(
int
)
(
(
pos
.
y
-
plot_offset
.
y
)
*
plot_scale
*
device_scale
);
pos
.
y
=
(
int
)
(
(
pos
.
y
-
plot_offset
.
y
)
*
plot_scale
*
device_scale
);
else
pos
.
y
=
(
int
)
(
(
paper_size
.
y
-
(
pos
.
y
-
plot_offset
.
y
)
*
plot_scale
)
*
device_scale
);
pos
.
y
=
(
int
)
(
(
paper_size
.
y
-
(
pos
.
y
-
plot_offset
.
y
)
*
plot_scale
)
*
device_scale
);
}
/********************************************************************/
void
PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
rayon
,
FILL_T
fill
,
int
width
)
/********************************************************************/
/* Generic arc rendered as a polyline */
void
PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
radius
,
FILL_T
fill
,
int
width
)
{
wxPoint
start
,
end
;
const
int
delta
=
50
;
/* increment (in 0.1 degrees) to draw circles */
...
...
@@ -69,54 +65,48 @@ void PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
set_current_line_width
(
width
);
/* Please NOTE the different sign due to Y-axis flip */
alpha
=
StAngle
/
1800.0
*
M_PI
;
start
.
x
=
centre
.
x
+
(
int
)
(
ra
yon
*
cos
(
-
alpha
)
);
start
.
y
=
centre
.
y
+
(
int
)
(
ra
yon
*
sin
(
-
alpha
)
);
start
.
x
=
centre
.
x
+
(
int
)
(
ra
dius
*
cos
(
-
alpha
)
);
start
.
y
=
centre
.
y
+
(
int
)
(
ra
dius
*
sin
(
-
alpha
)
);
move_to
(
start
);
for
(
int
ii
=
StAngle
+
delta
;
ii
<
EndAngle
;
ii
+=
delta
)
{
alpha
=
ii
/
1800.0
*
M_PI
;
end
.
x
=
centre
.
x
+
(
int
)
(
ra
yon
*
cos
(
-
alpha
)
);
end
.
y
=
centre
.
y
+
(
int
)
(
ra
yon
*
sin
(
-
alpha
)
);
end
.
x
=
centre
.
x
+
(
int
)
(
ra
dius
*
cos
(
-
alpha
)
);
end
.
y
=
centre
.
y
+
(
int
)
(
ra
dius
*
sin
(
-
alpha
)
);
line_to
(
end
);
}
alpha
=
EndAngle
/
1800.0
*
M_PI
;
end
.
x
=
centre
.
x
+
(
int
)
(
ra
yon
*
cos
(
-
alpha
)
);
end
.
y
=
centre
.
y
+
(
int
)
(
ra
yon
*
sin
(
-
alpha
)
);
end
.
x
=
centre
.
x
+
(
int
)
(
ra
dius
*
cos
(
-
alpha
)
);
end
.
y
=
centre
.
y
+
(
int
)
(
ra
dius
*
sin
(
-
alpha
)
);
finish_to
(
end
);
}
/*
**********************************
*/
/*
Modifies size size.x and size.y trace according to the scale factor.
*/
void
PLOTTER
::
user_to_device_size
(
wxSize
&
size
)
/************************************/
/* modifie les dimension size.x et size.y pour le trace selon l'echelle */
{
size
.
x
=
(
int
)
(
size
.
x
*
plot_scale
*
device_scale
);
size
.
y
=
(
int
)
(
size
.
y
*
plot_scale
*
device_scale
);
}
/************************************/
double
PLOTTER
::
user_to_device_size
(
double
size
)
/************************************/
{
return
size
*
plot_scale
*
device_scale
;
}
/************************************************************************************/
void
PLOTTER
::
center_square
(
const
wxPoint
&
position
,
int
diametre
,
FILL_T
fill
)
/************************************************************************************/
{
int
ra
yon
=
wxRound
(
diametre
/
2.8284
);
int
ra
dius
=
wxRound
(
diametre
/
2.8284
);
int
coord
[
10
]
=
{
position
.
x
+
ra
yon
,
position
.
y
+
rayon
,
position
.
x
+
ra
yon
,
position
.
y
-
rayon
,
position
.
x
-
ra
yon
,
position
.
y
-
rayon
,
position
.
x
-
ra
yon
,
position
.
y
+
rayon
,
position
.
x
+
ra
yon
,
position
.
y
+
rayon
position
.
x
+
ra
dius
,
position
.
y
+
radius
,
position
.
x
+
ra
dius
,
position
.
y
-
radius
,
position
.
x
-
ra
dius
,
position
.
y
-
radius
,
position
.
x
-
ra
dius
,
position
.
y
+
radius
,
position
.
x
+
ra
dius
,
position
.
y
+
radius
};
if
(
fill
)
...
...
@@ -130,18 +120,17 @@ void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill
}
/************************************************************************************/
void
PLOTTER
::
center_lozenge
(
const
wxPoint
&
position
,
int
diametre
,
FILL_T
fill
)
/************************************************************************************/
void
PLOTTER
::
center_lozenge
(
const
wxPoint
&
position
,
int
diametre
,
FILL_T
fill
)
{
int
ra
yon
=
diametre
/
2
;
int
ra
dius
=
diametre
/
2
;
int
coord
[
10
]
=
{
position
.
x
,
position
.
y
+
ra
yon
,
position
.
x
+
ra
yon
,
position
.
y
,
position
.
x
,
position
.
y
-
ra
yon
,
position
.
x
-
ra
yon
,
position
.
y
,
position
.
x
,
position
.
y
+
ra
yon
,
position
.
x
,
position
.
y
+
ra
dius
,
position
.
x
+
ra
dius
,
position
.
y
,
position
.
x
,
position
.
y
-
ra
dius
,
position
.
x
-
ra
dius
,
position
.
y
,
position
.
x
,
position
.
y
+
ra
dius
,
};
if
(
fill
)
...
...
@@ -155,17 +144,14 @@ void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill
}
/************************************************************************************/
void
PLOTTER
::
marker
(
const
wxPoint
&
position
,
int
diametre
,
int
aShapeId
)
/************************************************************************************/
/* Trace un motif de numero de forme aShapeId, aux coord x0, y0.
* x0, y0 = coordonnees tables
* diametre = diametre (coord table) du trou
* aShapeId = index ( permet de generer des formes caract )
/* Draw a pattern shape number aShapeId, to coord x0, y0.
* x0, y0 = coordinates tables
* Diameter diameter = (coord table) hole
* AShapeId = index (used to generate forms characters)
*/
void
PLOTTER
::
marker
(
const
wxPoint
&
position
,
int
diametre
,
int
aShapeId
)
{
int
ra
yon
=
diametre
/
2
;
int
ra
dius
=
diametre
/
2
;
int
x0
,
y0
;
...
...
@@ -173,84 +159,84 @@ void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
switch
(
aShapeId
)
{
case
0
:
/* vias :
forme en X
*/
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
-
rayon
)
);
line_to
(
wxPoint
(
x0
+
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
+
ra
yon
,
y0
-
rayon
)
);
finish_to
(
wxPoint
(
x0
-
ra
yon
,
y0
+
rayon
)
);
case
0
:
/* vias :
X shape
*/
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
-
radius
)
);
line_to
(
wxPoint
(
x0
+
ra
dius
,
y0
+
radius
)
);
move_to
(
wxPoint
(
x0
+
ra
dius
,
y0
-
radius
)
);
finish_to
(
wxPoint
(
x0
-
ra
dius
,
y0
+
radius
)
);
break
;
case
1
:
/* C
e
rcle */
case
1
:
/* C
i
rcle */
circle
(
position
,
diametre
,
NO_FILL
);
break
;
case
2
:
/*
forme en +
*/
move_to
(
wxPoint
(
x0
,
y0
-
ra
yon
)
);
line_to
(
wxPoint
(
x0
,
y0
+
ra
yon
)
);
move_to
(
wxPoint
(
x0
+
ra
yon
,
y0
)
);
finish_to
(
wxPoint
(
x0
-
ra
yon
,
y0
)
);
case
2
:
/*
+ shape
*/
move_to
(
wxPoint
(
x0
,
y0
-
ra
dius
)
);
line_to
(
wxPoint
(
x0
,
y0
+
ra
dius
)
);
move_to
(
wxPoint
(
x0
+
ra
dius
,
y0
)
);
finish_to
(
wxPoint
(
x0
-
ra
dius
,
y0
)
);
break
;
case
3
:
/*
forme en X ce
rcle */
case
3
:
/*
X shape in ci
rcle */
circle
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
-
rayon
)
);
line_to
(
wxPoint
(
x0
+
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
+
ra
yon
,
y0
-
rayon
)
);
finish_to
(
wxPoint
(
x0
-
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
-
radius
)
);
line_to
(
wxPoint
(
x0
+
ra
dius
,
y0
+
radius
)
);
move_to
(
wxPoint
(
x0
+
ra
dius
,
y0
-
radius
)
);
finish_to
(
wxPoint
(
x0
-
ra
dius
,
y0
+
radius
)
);
break
;
case
4
:
/*
forme en cercle barre de -
*/
case
4
:
/*
circle with bar - shape
*/
circle
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
)
);
finish_to
(
wxPoint
(
x0
+
ra
yon
,
y0
)
);
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
)
);
finish_to
(
wxPoint
(
x0
+
ra
dius
,
y0
)
);
break
;
case
5
:
/*
forme en cercle barre de |
*/
case
5
:
/*
circle with bar | shape
*/
circle
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
yon
)
);
finish_to
(
wxPoint
(
x0
,
y0
+
ra
yon
)
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
dius
)
);
finish_to
(
wxPoint
(
x0
,
y0
+
ra
dius
)
);
break
;
case
6
:
/*
forme en car
re */
case
6
:
/*
squa
re */
center_square
(
position
,
diametre
,
NO_FILL
);
break
;
case
7
:
/*
forme en losange
*/
case
7
:
/*
diamond
*/
center_lozenge
(
position
,
diametre
,
NO_FILL
);
break
;
case
8
:
/*
forme en carre barre par u
n X*/
case
8
:
/*
square with a
n X*/
center_square
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
-
rayon
)
);
line_to
(
wxPoint
(
x0
+
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
+
ra
yon
,
y0
-
rayon
)
);
finish_to
(
wxPoint
(
x0
-
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
-
radius
)
);
line_to
(
wxPoint
(
x0
+
ra
dius
,
y0
+
radius
)
);
move_to
(
wxPoint
(
x0
+
ra
dius
,
y0
-
radius
)
);
finish_to
(
wxPoint
(
x0
-
ra
dius
,
y0
+
radius
)
);
break
;
case
9
:
/*
forme en losange barre par un
+*/
case
9
:
/*
diamond with a
+*/
center_lozenge
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
yon
)
);
line_to
(
wxPoint
(
x0
,
y0
+
ra
yon
)
);
move_to
(
wxPoint
(
x0
+
ra
yon
,
y0
)
);
finish_to
(
wxPoint
(
x0
-
ra
yon
,
y0
)
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
dius
)
);
line_to
(
wxPoint
(
x0
,
y0
+
ra
dius
)
);
move_to
(
wxPoint
(
x0
+
ra
dius
,
y0
)
);
finish_to
(
wxPoint
(
x0
-
ra
dius
,
y0
)
);
break
;
case
10
:
/*
forme en carre barre par un
'/' */
case
10
:
/*
square with a
'/' */
center_square
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
-
rayon
)
);
finish_to
(
wxPoint
(
x0
+
ra
yon
,
y0
+
rayon
)
);
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
-
radius
)
);
finish_to
(
wxPoint
(
x0
+
ra
dius
,
y0
+
radius
)
);
break
;
case
11
:
/*
forme en losange barre par un
|*/
case
11
:
/*
square with a
|*/
center_lozenge
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
yon
)
);
finish_to
(
wxPoint
(
x0
,
y0
+
ra
yon
)
);
move_to
(
wxPoint
(
x0
,
y0
-
ra
dius
)
);
finish_to
(
wxPoint
(
x0
,
y0
+
ra
dius
)
);
break
;
case
12
:
/*
forme en losange barre par un
-*/
case
12
:
/*
square with a
-*/
center_lozenge
(
position
,
diametre
,
NO_FILL
);
move_to
(
wxPoint
(
x0
-
ra
yon
,
y0
)
);
finish_to
(
wxPoint
(
x0
+
ra
yon
,
y0
)
);
move_to
(
wxPoint
(
x0
-
ra
dius
,
y0
)
);
finish_to
(
wxPoint
(
x0
+
ra
dius
,
y0
)
);
break
;
default
:
...
...
@@ -260,12 +246,10 @@ void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
}
/*
*************************************************************
*/
/*
Convert a thick segment and plot it as an oval
*/
void
PLOTTER
::
segment_as_oval
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
/***************************************************************/
{
/* Convert a thick segment and plot it as an oval */
wxPoint
center
(
(
start
.
x
+
end
.
x
)
/
2
,
(
start
.
y
+
end
.
y
)
/
2
);
wxSize
size
(
end
.
x
-
start
.
x
,
end
.
y
-
start
.
y
);
int
orient
;
...
...
@@ -275,64 +259,70 @@ void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
else
if
(
size
.
x
==
0
)
orient
=
900
;
else
orient
=
-
(
int
)
(
atan2
(
(
double
)
size
.
y
,
(
double
)
size
.
x
)
*
1800.0
/
M_PI
);
size
.
x
=
(
int
)
sqrt
(
(
(
double
)
size
.
x
*
size
.
x
)
+
(
(
double
)
size
.
y
*
size
.
y
)
)
+
width
;
orient
=
-
(
int
)
(
atan2
(
(
double
)
size
.
y
,
(
double
)
size
.
x
)
*
1800.0
/
M_PI
);
size
.
x
=
(
int
)
sqrt
(
(
(
double
)
size
.
x
*
size
.
x
)
+
(
(
double
)
size
.
y
*
size
.
y
)
)
+
width
;
size
.
y
=
width
;
flash_pad_oval
(
center
,
size
,
orient
,
tracemode
);
}
/***************************************************************/
void
PLOTTER
::
sketch_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
int
width
)
/***************************************************************/
{
set_current_line_width
(
width
);
width
=
current_pen_width
;
int
rayon
,
deltaxy
,
cx
,
cy
;
int
radius
,
deltaxy
,
cx
,
cy
;
if
(
size
.
x
>
size
.
y
)
{
EXCHG
(
size
.
x
,
size
.
y
);
orient
+=
900
;
EXCHG
(
size
.
x
,
size
.
y
);
orient
+=
900
;
if
(
orient
>=
3600
)
orient
-=
3600
;
}
deltaxy
=
size
.
y
-
size
.
x
;
/* = distance entre centres de l'ovale */
rayon
=
(
size
.
x
-
width
)
/
2
;
cx
=
-
rayon
;
cy
=
-
deltaxy
/
2
;
deltaxy
=
size
.
y
-
size
.
x
;
/* distance between centers of the oval */
radius
=
(
size
.
x
-
width
)
/
2
;
cx
=
-
radius
;
cy
=
-
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
move_to
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
)
);
cx
=
-
rayon
;
cy
=
deltaxy
/
2
;
cx
=
-
radius
;
cy
=
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
finish_to
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
)
);
cx
=
rayon
;
cy
=
-
deltaxy
/
2
;
cx
=
radius
;
cy
=
-
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
move_to
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
)
);
cx
=
rayon
;
cy
=
deltaxy
/
2
;
cx
=
radius
;
cy
=
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
finish_to
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
)
);
cx
=
0
;
cy
=
deltaxy
/
2
;
cx
=
0
;
cy
=
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
arc
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
orient
+
1800
,
orient
+
3600
,
rayon
,
NO_FILL
);
cx
=
0
;
cy
=
-
deltaxy
/
2
;
radius
,
NO_FILL
);
cx
=
0
;
cy
=
-
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
arc
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
orient
,
orient
+
1800
,
ra
yon
,
NO_FILL
);
ra
dius
,
NO_FILL
);
}
/***************************************************************/
void
PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
/***************************************************************/
/* Plot 1 segment like a track segment
*/
void
PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
{
switch
(
tracemode
)
{
...
...
@@ -351,24 +341,26 @@ void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
}
void
PLOTTER
::
thick_arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
ra
yon
,
void
PLOTTER
::
thick_arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
ra
dius
,
int
width
,
GRTraceMode
tracemode
)
{
switch
(
tracemode
)
{
case
FILAIRE
:
set_current_line_width
(
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
ra
yon
,
NO_FILL
,
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
ra
dius
,
NO_FILL
,
-
1
);
break
;
case
FILLED
:
arc
(
centre
,
StAngle
,
EndAngle
,
ra
yon
,
NO_FILL
,
width
);
arc
(
centre
,
StAngle
,
EndAngle
,
ra
dius
,
NO_FILL
,
width
);
break
;
case
SKETCH
:
set_current_line_width
(
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
rayon
-
(
width
-
current_pen_width
)
/
2
,
NO_FILL
,
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
rayon
+
(
width
-
current_pen_width
)
/
2
,
NO_FILL
,
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
radius
-
(
width
-
current_pen_width
)
/
2
,
NO_FILL
,
-
1
);
arc
(
centre
,
StAngle
,
EndAngle
,
radius
+
(
width
-
current_pen_width
)
/
2
,
NO_FILL
,
-
1
);
break
;
}
}
...
...
@@ -426,14 +418,12 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
}
/*************************************************************************************/
void
PLOTTER
::
set_paper_size
(
Ki_PageDescr
*
asheet
)
/*************************************************************************************/
{
wxASSERT
(
!
output_file
);
sheet
=
asheet
;
// Sheets are in mils, plotter works with decim
i
ls
// Sheets are in mils, plotter works with decim
a
ls
paper_size
.
x
=
sheet
->
m_Size
.
x
*
10
;
paper_size
.
y
=
sheet
->
m_Size
.
y
*
10
;
}
common/common.cpp
View file @
bc5d9a75
/**********************************************************/
/* Routines d'affichage de parametres et caracteristiques */
/**********************************************************/
/**************/
/* common.cpp */
/**************/
#include "fctsys.h"
#include "gr_basic.h"
#include "trigo.h"
...
...
@@ -31,8 +32,10 @@ Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) );
Ki_PageDescr
g_Sheet_C
(
wxSize
(
22000
,
17000
),
wxPoint
(
0
,
0
),
wxT
(
"C"
)
);
Ki_PageDescr
g_Sheet_D
(
wxSize
(
34000
,
22000
),
wxPoint
(
0
,
0
),
wxT
(
"D"
)
);
Ki_PageDescr
g_Sheet_E
(
wxSize
(
44000
,
34000
),
wxPoint
(
0
,
0
),
wxT
(
"E"
)
);
Ki_PageDescr
g_Sheet_GERBER
(
wxSize
(
32000
,
32000
),
wxPoint
(
0
,
0
),
wxT
(
"GERBER"
)
);
Ki_PageDescr
g_Sheet_user
(
wxSize
(
17000
,
11000
),
wxPoint
(
0
,
0
),
wxT
(
"User"
)
);
Ki_PageDescr
g_Sheet_GERBER
(
wxSize
(
32000
,
32000
),
wxPoint
(
0
,
0
),
wxT
(
"GERBER"
)
);
Ki_PageDescr
g_Sheet_user
(
wxSize
(
17000
,
11000
),
wxPoint
(
0
,
0
),
wxT
(
"User"
)
);
Ki_PageDescr
*
g_SheetSizeList
[
NB_ITEMS
+
1
]
=
{
...
...
@@ -44,7 +47,7 @@ Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
/* File extension definitions. Please do not changes these. If a different
* file extension is needed, create a new definition in the application.
* Please note, just because they are defined as const do
sen't guare
ntee
* Please note, just because they are defined as const do
esn't guara
ntee
* that they cannot be changed. */
const
wxString
ProjectFileExtension
(
wxT
(
"pro"
)
);
const
wxString
SchematicFileExtension
(
wxT
(
"sch"
)
);
...
...
@@ -74,7 +77,7 @@ int g_KeyPressed;
wxString
g_Prj_Default_Config_FullFilename
;
wxString
g_Prj_Config_LocalFilename
;
// Handle the preferd editor for browsing report files:
// Handle the prefer
re
d editor for browsing report files:
int
g_UnitMetric
;
// display units mm = 1, inches = 0, cm = 2
/* Draw color for moving objects: */
...
...
@@ -134,16 +137,16 @@ wxString GetAboutBuildVersion()
/** function SetLocaleTo_C_standard
* because kicad is internationalized, switch interna
t
ization to "C" standard
* because kicad is internationalized, switch interna
l
ization to "C" standard
* i.e. uses the . (dot) as separator in print/read float numbers
* (some contries (France, Germany ..) use , (comma) as separator)
* This function must be called before read or write ascii files using float numbers in data
* the SetLocaleTo_C_standard function must be called after reading or writing the file
* (some countries (France, Germany ..) use , (comma) as separator)
* This function must be called before read or write ascii files using float
* numbers in data the SetLocaleTo_C_standard function must be called after
* reading or writing the file
*
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
* but could make more easier an optional use of locale in kicad
*/
/********************************/
void
SetLocaleTo_C_standard
(
void
)
{
setlocale
(
LC_NUMERIC
,
"C"
);
// Switch the locale to standard C
...
...
@@ -151,26 +154,22 @@ void SetLocaleTo_C_standard( void )
/** function SetLocaleTo_Default
* because kicad is internationalized, switch interna
t
ization to default
* because kicad is internationalized, switch interna
l
ization to default
* to use the default separator in print/read float numbers
* (. (dot) but some contries (France, Germany ..) use , (comma) as separator)
* (. (dot) but some co
u
ntries (France, Germany ..) use , (comma) as separator)
* This function must be called after a call to SetLocaleTo_C_standard
*
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
* but could make more easier an optional use of locale in kicad
*/
/********************************/
void
SetLocaleTo_Default
(
void
)
/********************************/
{
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
}
/********************************************************************/
bool
EnsureTextCtrlWidth
(
wxTextCtrl
*
aCtrl
,
const
wxString
*
aString
)
/********************************************************************/
{
wxWindow
*
window
=
aCtrl
->
GetParent
();
...
...
@@ -205,11 +204,9 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
}
/*********************************************************************************************/
Ki_PageDescr
::
Ki_PageDescr
(
const
wxSize
&
size
,
const
wxPoint
&
offset
,
const
wxString
&
name
)
/*********************************************************************************************/
{
// All sizes are in 1/1000 inch
m_Size
=
size
;
...
...
@@ -228,9 +225,7 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size,
}
/************************************/
wxString
ReturnUnitSymbol
(
int
Units
)
/************************************/
{
wxString
label
;
...
...
@@ -281,9 +276,7 @@ wxString GetUnitsLabel( int units )
* Add string " (mm):" or " ("):" to the static text Stext.
* Used in dialog boxes for entering values depending on selected units
*/
/**************************************************/
void
AddUnitSymbol
(
wxStaticText
&
Stext
,
int
Units
)
/**************************************************/
{
wxString
msg
=
Stext
.
GetLabel
();
msg
+=
ReturnUnitSymbol
(
Units
);
...
...
@@ -296,9 +289,7 @@ void AddUnitSymbol( wxStaticText& Stext, int Units )
* Convert the number Value in a string according to the internal units
* and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl
*/
/******************************************/
void
PutValueInLocalUnits
(
wxTextCtrl
&
TextCtr
,
int
Value
,
int
Internal_Unit
)
/*****************************************/
{
wxString
msg
=
ReturnStringFromValue
(
g_UnitMetric
,
Value
,
Internal_Unit
);
...
...
@@ -310,9 +301,7 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
* Convert the Value in the wxTextCtrl TextCtrl in an integer,
* according to the internal units and the selected unit (g_UnitMetric)
*/
/***************************************************/
int
ReturnValueFromTextCtrl
(
const
wxTextCtrl
&
TextCtr
,
int
Internal_Unit
)
/***************************************************/
{
int
value
;
wxString
msg
=
TextCtr
.
GetValue
();
...
...
@@ -330,12 +319,11 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
* @param aValue = value in Internal_Unit
* @param aInternal_Unit = units per inch for Value
* @param aAdd_unit_symbol = true to add symbol unit to the string value
* @return a wxString what contains value and optionnaly the sumbol unit (like 2.000 mm)
* @return a wxString what contains value and optionally the symbol unit
* (like 2.000 mm)
*/
/*******************************************/
wxString
ReturnStringFromValue
(
int
aUnits
,
int
aValue
,
int
aInternal_Unit
,
bool
aAdd_unit_symbol
)
/*******************************************/
{
wxString
StringValue
;
double
value_to_print
;
...
...
@@ -344,9 +332,11 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
StringValue
<<
aValue
;
else
{
value_to_print
=
To_User_Unit
(
(
bool
)
aUnits
,
(
double
)
aValue
,
aInternal_Unit
);
StringValue
.
Printf
(
(
aInternal_Unit
>
1000
)
?
wxT
(
"%.4f"
)
:
wxT
(
"%.3f"
),
value_to_print
);
value_to_print
=
To_User_Unit
(
(
bool
)
aUnits
,
(
double
)
aValue
,
aInternal_Unit
);
StringValue
.
Printf
(
(
aInternal_Unit
>
1000
)
?
wxT
(
"%.4f"
)
:
wxT
(
"%.3f"
),
value_to_print
);
}
if
(
aAdd_unit_symbol
)
...
...
@@ -375,10 +365,8 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
* Value = text
* Internal_Unit = units per inch for computed value
*/
/****************************************************************************/
int
ReturnValueFromString
(
int
Units
,
const
wxString
&
TextValue
,
int
Internal_Unit
)
/****************************************************************************/
{
int
Value
;
double
dtmp
=
0
;
...
...
@@ -400,9 +388,7 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
* @param txt : wxString : a String text
* @param splitter : wxChar : the 'split' character
*/
/**********************************************************/
wxArrayString
*
wxStringSplit
(
wxString
txt
,
wxChar
splitter
)
/**********************************************************/
{
wxArrayString
*
list
=
new
wxArrayString
();
...
...
@@ -427,10 +413,6 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter )
}
/******************************************************************/
double
To_User_Unit
(
bool
is_metric
,
double
val
,
int
internal_unit_value
)
/******************************************************************/
/**
* Function To_User_Unit
* Convert in inch or mm the variable "val" (double)given in internal units
...
...
@@ -439,6 +421,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value )
* @param val : double : the given value
* @param internal_unit_value = internal units per inch
*/
double
To_User_Unit
(
bool
is_metric
,
double
val
,
int
internal_unit_value
)
{
double
value
;
...
...
@@ -454,9 +437,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value )
/*
* Return in internal units the value "val" given in inch or mm
*/
/*****************************************/
int
From_User_Unit
(
bool
is_metric
,
double
val
,
int
internal_unit_value
)
/*****************************************/
{
double
value
;
...
...
@@ -472,9 +453,7 @@ int From_User_Unit( bool is_metric, double val, int internal_unit_value )
/*
* Return the string date "day month year" like "23 jun 2005"
*/
/********/
wxString
GenDate
()
/********/
{
static
const
wxString
mois
[
12
]
=
{
...
...
@@ -498,9 +477,7 @@ wxString GenDate()
/*
* My memory allocation
*/
/***********************************/
void
*
MyMalloc
(
size_t
nb_octets
)
/***********************************/
{
void
*
pt_mem
;
...
...
@@ -527,9 +504,7 @@ void* MyMalloc( size_t nb_octets )
* @param aFlags The same args as allowed for wxExecute()
* @return bool - true if success, else false
*/
/********************************************/
bool
ProcessExecute
(
const
wxString
&
aCommandLine
,
int
aFlags
)
/********************************************/
{
#ifdef __WINDOWS__
int
pid
=
wxExecute
(
aCommandLine
);
...
...
@@ -544,9 +519,7 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags )
/*
* My memory allocation, memory space is cleared
*/
/*****************************/
void
*
MyZMalloc
(
size_t
nb_octets
)
/*****************************/
{
void
*
pt_mem
=
MyMalloc
(
nb_octets
);
...
...
@@ -556,9 +529,7 @@ void* MyZMalloc( size_t nb_octets )
}
/*******************************/
void
MyFree
(
void
*
pt_mem
)
/*******************************/
{
if
(
pt_mem
)
free
(
pt_mem
);
...
...
@@ -570,9 +541,7 @@ void MyFree( void* pt_mem )
* if omitSpacePadding == TRUE, the name can be used for a file name
* (no spaces, replaced by _)
*/
/**************************************************************/
wxString
ReturnPcbLayerName
(
int
layer_number
,
bool
omitSpacePadding
)
/**************************************************************/
{
const
unsigned
LAYER_LIMIT
=
29
;
...
...
@@ -615,13 +584,14 @@ enum textbox {
ID_TEXTBOX_LIST
=
8010
};
BEGIN_EVENT_TABLE
(
WinEDA_TextFrame
,
wxDialog
)
EVT_LISTBOX_DCLICK
(
ID_TEXTBOX_LIST
,
WinEDA_TextFrame
::
D_ClickOnList
)
EVT_LISTBOX
(
ID_TEXTBOX_LIST
,
WinEDA_TextFrame
::
D_ClickOnList
)
EVT_CLOSE
(
WinEDA_TextFrame
::
OnClose
)
EVT_LISTBOX_DCLICK
(
ID_TEXTBOX_LIST
,
WinEDA_TextFrame
::
D_ClickOnList
)
EVT_LISTBOX
(
ID_TEXTBOX_LIST
,
WinEDA_TextFrame
::
D_ClickOnList
)
EVT_CLOSE
(
WinEDA_TextFrame
::
OnClose
)
END_EVENT_TABLE
()
/***************************************************************************/
WinEDA_TextFrame
::
WinEDA_TextFrame
(
wxWindow
*
parent
,
const
wxString
&
title
)
:
wxDialog
(
parent
,
...
...
@@ -631,14 +601,7 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
wxDEFAULT_DIALOG_STYLE
|
wxFRAME_FLOAT_ON_PARENT
|
MAYBE_RESIZE_BORDER
)
/***************************************************************************/
{
/*
* TODO background and foreground colors of WinEDA_TextFrame should be
* controllable / settable with project settings or config file and not
* hardcoded in binairy !
*/
wxSize
size
;
m_Parent
=
parent
;
...
...
@@ -653,27 +616,17 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
0
,
NULL
,
wxLB_ALWAYS_SB
|
wxLB_SINGLE
);
/* The color of the text in the wxListBox (black) */
m_List
->
SetBackgroundColour
(
wxColour
(
255
,
255
,
255
)
);
/* The foreground color of the wxListBox (white) */
m_List
->
SetForegroundColour
(
wxColour
(
0
,
0
,
0
)
);
SetReturnCode
(
-
1
);
}
/***************************************************/
void
WinEDA_TextFrame
::
Append
(
const
wxString
&
text
)
/***************************************************/
{
m_List
->
Append
(
text
);
}
/**********************************************************/
void
WinEDA_TextFrame
::
D_ClickOnList
(
wxCommandEvent
&
event
)
/**********************************************************/
{
int
ii
=
m_List
->
GetSelection
();
...
...
@@ -681,27 +634,21 @@ void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event )
}
/*************************************************/
void
WinEDA_TextFrame
::
OnClose
(
wxCloseEvent
&
event
)
/*************************************************/
{
EndModal
(
-
1
);
}
/*****************************************************************************/
void
Affiche_1_Parametre
(
WinEDA_DrawFrame
*
frame
,
int
pos_X
,
const
wxString
&
texte_H
,
const
wxString
&
texte_L
,
int
color
)
/*****************************************************************************/
{
frame
->
MsgPanel
->
Affiche_1_Parametre
(
pos_X
,
texte_H
,
texte_L
,
color
);
}
/***********************/
int
GetTimeStamp
()
/***********************/
{
static
int
OldTimeStamp
,
NewTimeStamp
;
...
...
@@ -736,9 +683,7 @@ const wxString& valeur_param( int valeur, wxString& buf_texte )
/*
*
*/
/**********************************/
wxString
&
operator
<<
(
wxString
&
aString
,
const
wxPoint
&
aPos
)
/*********************************/
{
wxString
temp
;
...
...
common/common_plotDXF_functions.cpp
View file @
bc5d9a75
/***********************************
*******
/
/***********************************/
/* Kicad: Common plot DXF Routines */
/***********************************
*******
/
/***********************************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -11,13 +11,11 @@
#include "macros.h"
#include "kicad_string.h"
/***********************************************************************************/
void
DXF_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
/***********************************************************************************/
/* Set the plot offset for the current plotting
*/
void
DXF_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
{
wxASSERT
(
!
output_file
);
plot_offset
=
offset
;
...
...
@@ -29,16 +27,13 @@ void DXF_PLOTTER::set_viewport( wxPoint offset,
}
/*****************************************************************/
void
DXF_PLOTTER
::
start_plot
(
FILE
*
fout
)
/*****************************************************************/
{
wxASSERT
(
!
output_file
);
output_file
=
fout
;
/* DXF HEADER - Boilerplate */
fputs
(
"0
\n
SECTION
\n
2
\n
HEADER
\n
9
\n
$ANGBASE
\n
50
\n
0.0
\n
9
\n
$ANGDIR
\n
70
\n
0
\n
0
\n
ENDSEC
\n
0
\n
SECTION
\n
2
\n
TABLES
\n
0
\n
TABLE
\n
2
\n
LTYPE
\n
70
\n
1
\n
0
\n
LTYPE
\n
2
\n
CONTINUOUS
\n
70
\n
0
\n
3
\n
Solid line
\n
72
\n
65
\n
73
\n
0
\n
40
\n
0.0
\n
0
\n
ENDTAB
\n
"
,
output_file
);
fputs
(
"0
\n
SECTION
\n
2
\n
HEADER
\n
9
\n
$ANGBASE
\n
50
\n
0.0
\n
9
\n
$ANGDIR
\n
70
\n
0
\n
0
\n
ENDSEC
\n
0
\n
SECTION
\n
2
\n
TABLES
\n
0
\n
TABLE
\n
2
\n
LTYPE
\n
70
\n
1
\n
0
\n
LTYPE
\n
2
\n
CONTINUOUS
\n
70
\n
0
\n
3
\n
Solid line
\n
72
\n
65
\n
73
\n
0
\n
40
\n
0.0
\n
0
\n
ENDTAB
\n
"
,
output_file
);
/* Layer table - one layer per color */
fprintf
(
output_file
,
"0
\n
TABLE
\n
2
\n
LAYER
\n
70
\n
%d
\n
"
,
NBCOLOR
);
for
(
int
i
=
0
;
i
<
NBCOLOR
;
i
++
)
...
...
@@ -53,9 +48,7 @@ void DXF_PLOTTER::start_plot( FILE* fout )
}
/**********************************/
void
DXF_PLOTTER
::
end_plot
()
/**********************************/
{
wxASSERT
(
output_file
);
/* DXF FOOTER */
...
...
@@ -65,27 +58,22 @@ void DXF_PLOTTER::end_plot()
}
/******************************/
void
DXF_PLOTTER
::
set_color
(
int
color
)
/******************************/
/*
* color = color index in ColorRefs[]
*/
void
DXF_PLOTTER
::
set_color
(
int
color
)
{
wxASSERT
(
output_file
);
if
(
(
color
>=
0
&&
color_mode
)
||
(
color
==
BLACK
)
||
(
color
==
WHITE
)
)
if
(
(
color
>=
0
&&
color_mode
)
||
(
color
==
BLACK
)
||
(
color
==
WHITE
)
)
{
current_color
=
color
;
}
}
/************************************************************/
void
DXF_PLOTTER
::
rect
(
wxPoint
p1
,
wxPoint
p2
,
FILL_T
fill
,
int
width
)
/************************************************************/
{
wxASSERT
(
output_file
);
move_to
(
p1
);
...
...
@@ -96,32 +84,27 @@ void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
}
/************************************************************/
void
DXF_PLOTTER
::
circle
(
wxPoint
centre
,
int
diameter
,
FILL_T
fill
,
int
width
)
/************************************************************/
{
wxASSERT
(
output_file
);
double
ra
yon
=
user_to_device_size
(
diameter
/
2
);
double
ra
dius
=
user_to_device_size
(
diameter
/
2
);
user_to_device_coordinates
(
centre
);
if
(
ra
yon
>
0
)
if
(
ra
dius
>
0
)
{
wxString
cname
=
ColorRefs
[
current_color
].
m_Name
;
fprintf
(
output_file
,
"0
\n
CIRCLE
\n
8
\n
%s
\n
10
\n
%d.0
\n
20
\n
%d.0
\n
40
\n
%g
\n
"
,
CONV_TO_UTF8
(
cname
),
centre
.
x
,
centre
.
y
,
ra
yon
);
centre
.
x
,
centre
.
y
,
ra
dius
);
}
}
/*****************************************************/
void
DXF_PLOTTER
::
poly
(
int
nb
,
int
*
coord
,
FILL_T
fill
,
int
width
)
/*****************************************************/
/* Trace un polygone (ferme si rempli) en format DXF
* coord = tableau des coord des sommets
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
* fill : si != 0 polygone rempli
/* Draw a polygon (closed if completed) in DXF format
* coord = coord table tops
* nb = number of coord (coord 1 = 2 elements: X and Y table)
* fill: if != 0 filled polygon
*/
void
DXF_PLOTTER
::
poly
(
int
nb
,
int
*
coord
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
if
(
nb
<=
1
)
...
...
@@ -131,27 +114,23 @@ void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
for
(
int
ii
=
1
;
ii
<
nb
;
ii
++
)
line_to
(
wxPoint
(
coord
[
ii
*
2
],
coord
[(
ii
*
2
)
+
1
]
)
);
/*
Fermeture eventuelle du polygone
*/
/*
Close polygon.
*/
if
(
fill
)
{
int
ii
=
(
nb
-
1
)
*
2
;
if
(
(
coord
[
ii
]
!=
coord
[
0
]
)
||
(
coord
[
ii
+
1
]
!=
coord
[
1
]
)
)
if
(
(
coord
[
ii
]
!=
coord
[
0
]
)
||
(
coord
[
ii
+
1
]
!=
coord
[
1
]
)
)
line_to
(
wxPoint
(
coord
[
0
],
coord
[
1
]
)
);
}
pen_finish
();
}
/**********************************************/
void
DXF_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
/**********************************************/
/*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
* en position x,y
* Unites en Unites DESSIN
* Si plume = 'Z' lever de plume sans deplacement
* Move the pen up (pen = 'U') or down (feather = 'D') at position x, y
* Unit to unit DRAWING
* If pen = 'Z' without lifting pen displacement
*/
void
DXF_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
{
wxASSERT
(
output_file
);
if
(
plume
==
'Z'
)
...
...
@@ -179,15 +158,14 @@ void DXF_PLOTTER::set_dash( bool dashed )
}
void
DXF_PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
/** Function Plot a filled segment (track)
* @param start = starting point
* @param end = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
*/
void
DXF_PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
{
wxASSERT
(
output_file
);
...
...
@@ -201,47 +179,44 @@ void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
}
/********************************************************************/
void
DXF_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
rayon
,
FILL_T
fill
,
int
width
)
/********************************************************************/
/* trace d'un arc de cercle:
* centre = coord du centre
* StAngle, EndAngle = angle de debut et fin
* rayon = rayon de l'arc
/* Plot an arc in DXF format.
* center = center coord
* StAngle, EndAngle = angle of beginning and end
* Radius = radius of the arc
*/
void
DXF_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
radius
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
if
(
ra
yon
<=
0
)
if
(
ra
dius
<=
0
)
return
;
user_to_device_coordinates
(
centre
);
ra
yon
=
user_to_device_size
(
rayon
);
ra
dius
=
user_to_device_size
(
radius
);
/* DXF ARC */
wxString
cname
=
ColorRefs
[
current_color
].
m_Name
;
fprintf
(
output_file
,
"0
\n
ARC
\n
8
\n
%s
\n
10
\n
%d.0
\n
20
\n
%d.0
\n
40
\n
%d.0
\n
50
\n
%d.0
\n
51
\n
%d.0
\n
"
,
fprintf
(
output_file
,
"0
\n
ARC
\n
8
\n
%s
\n
10
\n
%d.0
\n
20
\n
%d.0
\n
40
\n
%d.0
\n
50
\n
%d.0
\n
51
\n
%d.0
\n
"
,
CONV_TO_UTF8
(
cname
),
centre
.
x
,
centre
.
y
,
ra
yon
,
centre
.
x
,
centre
.
y
,
ra
dius
,
StAngle
/
10
,
EndAngle
/
10
);
}
/*
*********************************************************************************
*/
/*
Plot oval pad at position.
*/
void
DXF_PLOTTER
::
flash_pad_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{
wxASSERT
(
output_file
);
/*
la pastille est ramenee a une pastille ovale avec
size.y > size.x
*
( ovale vertical en orientation 0
) */
/*
The chip is reduced to an oval tablet with
size.y > size.x
*
(Oval vertical orientation 0
) */
if
(
size
.
x
>
size
.
y
)
{
EXCHG
(
size
.
x
,
size
.
y
);
orient
+=
900
;
EXCHG
(
size
.
x
,
size
.
y
);
orient
+=
900
;
if
(
orient
>=
3600
)
orient
-=
3600
;
}
...
...
@@ -249,27 +224,20 @@ void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
}
/*
*****************************************************************************
*/
/*
Plot round pad or via.
*/
void
DXF_PLOTTER
::
flash_pad_circle
(
wxPoint
pos
,
int
diametre
,
GRTraceMode
trace_mode
)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos */
{
wxASSERT
(
output_file
);
circle
(
pos
,
diametre
,
NO_FILL
);
}
/**************************************************************************/
void
DXF_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
padsize
,
int
orient
,
GRTraceMode
trace_mode
)
/**************************************************************************/
/*
* Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire )
* donne par son centre et ses dimensions X et Y
* Units are user units
* Plot rectangular pad vertical or horizontal (rectangular Pad)
*/
void
DXF_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
padsize
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxSize
size
;
...
...
@@ -282,12 +250,14 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
if
(
size
.
y
<
0
)
size
.
y
=
0
;
/*
Si une des dimensions est nulle, le trace se reduit a 1 trait
*/
/*
If a dimension is zero, the trace is reduced to 1 line.
*/
if
(
size
.
x
==
0
)
{
ox
=
pos
.
x
;
oy
=
pos
.
y
-
size
.
y
;
ox
=
pos
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
;
fy
=
pos
.
y
+
size
.
y
;
fx
=
pos
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
...
...
@@ -295,28 +265,34 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
}
if
(
size
.
y
==
0
)
{
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
;
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
;
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
return
;
}
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
...
...
@@ -324,43 +300,47 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
}
/*******************************************************************/
void
DXF_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
/*******************************************************************/
/*
*
Trace 1 pad trapezoidal donne par :
*
son centre pos.x,
pos.y
*
ses dimensions dimX et dimY
*
les variations deltaX et
deltaY
*
son orientation orient et 0.1 degres
*
le mode de trace (FILLED, SKETCH, FILAIRE
)
*
Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou
deltaY
*
= 0.
*
Plot trapezoidal pad.
*
pos its center,
pos.y
*
Dimensions dim X and dimy
*
DeltaX and variations
deltaY
*
Orientation and 0.1 degrees east
*
Plot mode (FILLED, SKETCH, WIRED
)
*
The evidence is that a trapezoid, ie that deltaX or
deltaY
* = 0.
*
*
les notation des sommets sont ( vis a vis de la table tracante
)
*
The rating of the vertexes are (vis a vis the plotter
)
* 0 ------------- 3
* .
.
* .
.
* .
.
* .
.
* .
.
* .
.
* 1 --- 2
*/
void
DXF_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxPoint
polygone
[
4
];
/* coord
des sommets / centre du
pad */
wxPoint
coord
[
4
];
/* coord
reelles des sommets du trapeze a tracer
*/
int
moveX
,
moveY
;
/* variation de position plume selon axe X et Y , lors
* du remplissage du trapeze
*/
wxPoint
polygone
[
4
];
/* coord
of vertex or center of the
pad */
wxPoint
coord
[
4
];
/* coord
actual corners of a trapezoidal trace
*/
int
moveX
,
moveY
;
/* change pen position by X and Y axis to
* fill the trapezoid
*/
moveX
=
moveY
=
0
;
size
.
x
/=
2
;
size
.
y
/=
2
;
delta
.
x
/=
2
;
delta
.
y
/=
2
;
polygone
[
0
].
x
=
-
size
.
x
-
delta
.
y
;
polygone
[
0
].
y
=
+
size
.
y
+
delta
.
x
;
polygone
[
1
].
x
=
-
size
.
x
+
delta
.
y
;
polygone
[
1
].
y
=
-
size
.
y
-
delta
.
x
;
polygone
[
2
].
x
=
+
size
.
x
-
delta
.
y
;
polygone
[
2
].
y
=
-
size
.
y
+
delta
.
x
;
polygone
[
3
].
x
=
+
size
.
x
+
delta
.
y
;
polygone
[
3
].
y
=
+
size
.
y
-
delta
.
x
;
size
.
x
/=
2
;
size
.
y
/=
2
;
delta
.
x
/=
2
;
delta
.
y
/=
2
;
polygone
[
0
].
x
=
-
size
.
x
-
delta
.
y
;
polygone
[
0
].
y
=
+
size
.
y
+
delta
.
x
;
polygone
[
1
].
x
=
-
size
.
x
+
delta
.
y
;
polygone
[
1
].
y
=
-
size
.
y
-
delta
.
x
;
polygone
[
2
].
x
=
+
size
.
x
-
delta
.
y
;
polygone
[
2
].
y
=
-
size
.
y
+
delta
.
x
;
polygone
[
3
].
x
=
+
size
.
x
+
delta
.
y
;
polygone
[
3
].
y
=
+
size
.
y
-
delta
.
x
;
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
...
...
common/common_plotGERBER_functions.cpp
View file @
bc5d9a75
...
...
@@ -13,16 +13,13 @@
#include "kicad_string.h"
/***************************************************************************/
void
GERBER_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
/***************************************************************************/
/** function set_viewport
* Set the plot offset for the current plotting
* @param aOffset = plot offset
* @param aScale = coordinate scale (scale coefficient for coordinates)
*/
void
GERBER_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
{
wxASSERT
(
!
output_file
);
wxASSERT
(
orient
==
0
);
...
...
@@ -31,19 +28,16 @@ void GERBER_PLOTTER::set_viewport( wxPoint offset,
wxASSERT
(
aScale
==
1
);
plot_scale
=
1
;
device_scale
=
1
;
set_default_line_width
(
100
);
/* epaisseur du trait standard en 1/1000 pouce
*/
set_default_line_width
(
100
);
/* line thickness in 1 / 1000 inch
*/
}
/******************************************************************/
void
GERBER_PLOTTER
::
start_plot
(
FILE
*
aFile
)
/*****************************************************************/
/** Function start_plot
* Write GERBER header to file
* initialize global variable g_Plot_PlotOutputFile
* @param aFile: an opened file to write to
*/
void
GERBER_PLOTTER
::
start_plot
(
FILE
*
aFile
)
{
char
Line
[
1024
];
...
...
@@ -53,7 +47,8 @@ void GERBER_PLOTTER::start_plot( FILE* aFile )
output_file
=
work_file
;
DateAndTime
(
Line
);
wxString
Title
=
creator
+
wxT
(
" "
)
+
GetBuildVersion
();
fprintf
(
output_file
,
"G04 (created by %s) date %s*
\n
"
,
CONV_TO_UTF8
(
Title
),
Line
);
fprintf
(
output_file
,
"G04 (created by %s) date %s*
\n
"
,
CONV_TO_UTF8
(
Title
),
Line
);
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs
(
"G01*
\n
G70*
\n
G90*
\n
"
,
output_file
);
...
...
@@ -69,9 +64,7 @@ void GERBER_PLOTTER::start_plot( FILE* aFile )
}
/******************************************************************/
void
GERBER_PLOTTER
::
end_plot
()
/*****************************************************************/
{
char
line
[
1024
];
wxString
msg
;
...
...
@@ -84,7 +77,7 @@ void GERBER_PLOTTER::end_plot()
output_file
=
final_file
;
// Placement
des Apertures e
n RS274X
// Placement
of apertures i
n RS274X
while
(
fgets
(
line
,
1024
,
work_file
)
)
{
fputs
(
line
,
output_file
);
...
...
@@ -101,24 +94,18 @@ void GERBER_PLOTTER::end_plot()
}
/*************************************************************************************/
void
GERBER_PLOTTER
::
set_default_line_width
(
int
width
)
/*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting
*/
void
GERBER_PLOTTER
::
set_default_line_width
(
int
width
)
{
default_pen_width
=
width
;
// epaisseur du trait standard en 1/1000 pouce
default_pen_width
=
width
;
current_aperture
=
apertures
.
end
();
}
/***************************************/
void
GERBER_PLOTTER
::
set_current_line_width
(
int
width
)
/***************************************/
/* Set the Current line width (in 1/1000 inch) for the next plot
*/
void
GERBER_PLOTTER
::
set_current_line_width
(
int
width
)
{
int
pen_width
;
...
...
@@ -132,10 +119,8 @@ void GERBER_PLOTTER::set_current_line_width( int width )
}
/******************************************************/
std
::
vector
<
APERTURE
>::
iterator
GERBER_PLOTTER
::
get_aperture
(
const
wxSize
&
size
,
APERTURE
::
Aperture_Type
type
)
/******************************************************/
APERTURE
::
Aperture_Type
type
)
{
int
last_D_code
=
9
;
...
...
@@ -160,14 +145,14 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&
}
/******************************************************/
void
GERBER_PLOTTER
::
select_aperture
(
const
wxSize
&
size
,
APERTURE
::
Aperture_Type
type
)
/******************************************************/
void
GERBER_PLOTTER
::
select_aperture
(
const
wxSize
&
size
,
APERTURE
::
Aperture_Type
type
)
{
wxASSERT
(
output_file
);
if
(
(
current_aperture
==
apertures
.
end
()
)
||
(
current_aperture
->
type
!=
type
)
||
(
current_aperture
->
size
!=
size
)
)
||
(
current_aperture
->
type
!=
type
)
||
(
current_aperture
->
size
!=
size
)
)
{
/* Pick an existing aperture or create a new one */
current_aperture
=
get_aperture
(
size
,
type
);
...
...
@@ -176,14 +161,10 @@ void GERBER_PLOTTER::select_aperture( const wxSize& size, APERTURE::Aperture_Typ
}
/******************************************************/
void
GERBER_PLOTTER
::
write_aperture_list
()
/******************************************************/
/* Genere la liste courante des D_CODES
* Retourne le nombre de D_Codes utilises
* Genere une sequence RS274X
/*Generate list of D_CODES.
* Returns the number of D_Codes generated in RS274X format.
*/
void
GERBER_PLOTTER
::
write_aperture_list
()
{
wxASSERT
(
output_file
);
char
cbuf
[
1024
];
...
...
@@ -223,7 +204,6 @@ void GERBER_PLOTTER::write_aperture_list()
}
/**********************************************/
void
GERBER_PLOTTER
::
pen_to
(
wxPoint
aPos
,
char
plume
)
{
wxASSERT
(
output_file
);
...
...
@@ -246,9 +226,7 @@ void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume )
}
/**************************************************************************/
void
GERBER_PLOTTER
::
rect
(
wxPoint
p1
,
wxPoint
p2
,
FILL_T
fill
,
int
width
)
/**************************************************************************/
{
wxASSERT
(
output_file
);
int
coord
[
10
]
=
...
...
@@ -263,22 +241,21 @@ void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
}
/*************************************************************************************/
void
GERBER_PLOTTER
::
circle
(
wxPoint
aCentre
,
int
aDiameter
,
FILL_T
fill
,
int
aWidth
)
/*************************************************************************************/
/** Function circle
* writes a non filled circle to output file
* Plot one circle as segments (6 to 16 depending on its radius
* @param aCentre = cent
re coordin
tes
* @param aCentre = cent
er coordina
tes
* @param aDiameter = diameter of the circle
* @param aWidth = line width
*/
void
GERBER_PLOTTER
::
circle
(
wxPoint
aCentre
,
int
aDiameter
,
FILL_T
fill
,
int
aWidth
)
{
wxASSERT
(
output_file
);
wxPoint
start
,
end
;
double
radius
=
aDiameter
/
2
;
const
int
delta
=
3600
/
32
;
/* increment (in 0.1 degrees) to draw circles */
const
int
delta
=
3600
/
32
;
/* increment (in 0.1 degrees) to draw
* circles */
start
.
x
=
aCentre
.
x
+
wxRound
(
radius
);
start
.
y
=
aCentre
.
y
;
...
...
@@ -295,17 +272,15 @@ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T fill, int aW
}
/***************************************************************/
void
GERBER_PLOTTER
::
poly
(
int
aCornersCount
,
int
*
aCoord
,
FILL_T
aFill
,
int
aWidth
)
/***************************************************************/
/** Function PlotFilledPolygon_GERBER
* writes a filled polyline to output file
* @param aCornersCount = numer of corners
* @param aCornersCount = num
b
er of corners
* @param aCoord = buffer of corners coordinates
* @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
* @param aCoord = buffer of corners coordinates
*/
void
GERBER_PLOTTER
::
poly
(
int
aCornersCount
,
int
*
aCoord
,
FILL_T
aFill
,
int
aWidth
)
{
wxASSERT
(
output_file
);
wxPoint
pos
,
startpos
;
...
...
@@ -361,30 +336,29 @@ void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
}
/* Plot oval pad at position pos:
* Dimensions dx, dy,
* Orient Orient
* For a vertical or horizontal orientation, the shape is flashed
* For any orientation the shape is drawn as a segment
*/
void
GERBER_PLOTTER
::
flash_pad_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
/* Trace 1 pastille PAD_OVAL en position pos_X,Y:
* dimensions dx, dy,
* orientation orient
* Pour une orientation verticale ou horizontale, la forme est flashee
* Pour une orientation quelconque la forme est tracee comme un segment
*/
{
wxASSERT
(
output_file
);
int
x0
,
y0
,
x1
,
y1
,
delta
;
/*
Trace de la forme flashee
*/
/*
Plot a flashed shape.
*/
if
(
(
orient
==
0
||
orient
==
900
||
orient
==
1800
||
orient
==
2700
)
&&
trace_mode
==
FILLED
)
{
if
(
orient
==
900
||
orient
==
2700
)
/* orient
tournee de 90 deg
*/
if
(
orient
==
900
||
orient
==
2700
)
/* orient
ation turned 90 deg.
*/
EXCHG
(
size
.
x
,
size
.
y
);
user_to_device_coordinates
(
pos
);
select_aperture
(
size
,
APERTURE
::
Oval
);
fprintf
(
output_file
,
"X%5.5dY%5.5dD03*
\n
"
,
pos
.
x
,
pos
.
y
);
}
else
/*
Forme tracee comme un segment
*/
else
/*
Plot pad as a segment.
*/
{
if
(
size
.
x
>
size
.
y
)
{
...
...
@@ -396,7 +370,7 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
}
if
(
trace_mode
==
FILLED
)
{
/*
la pastille est ramenee a une pastille ovale avec
dy > dx */
/*
The pad is reduced to an oval with
dy > dx */
delta
=
size
.
y
-
size
.
x
;
x0
=
0
;
y0
=
-
delta
/
2
;
...
...
@@ -414,25 +388,26 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
}
/* Plot rectangular pad.
* Gives its center, size, and orientation
* For a vertical or horizontal shape, the shape is an aperture (Dcode) and
* it is flashed.
* For others shape the direction is plotted as a polygon.
*/
void
GERBER_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
/* Plot 1 rectangular pad
* donne par son centre, ses dimensions, et son orientation
* For a vertical or horizontal shape, the shape is an aperture (Dcode) and it is flashed
* For others orientations the shape is plotted as a polygon
*/
{
wxASSERT
(
output_file
);
/* Trace de la forme flashee */
/* Plot as flashed. */
switch
(
orient
)
{
case
900
:
case
2700
:
/* la rotation de 90 ou 270 degres revient a permutter de
s dimensions */
case
2700
:
/* rotation of 90 degrees or 270 return
s dimensions */
EXCHG
(
size
.
x
,
size
.
y
);
// Pass through
case
0
:
case
1800
:
switch
(
trace_mode
)
...
...
@@ -463,20 +438,16 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
}
void
GERBER_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
/* Trace 1 pad trapezoidal donne par :
* son centre pos.x,pos.y
* ses dimensions size.x et size.y
* les variations delta.x et delta.y ( 1 des deux au moins doit etre nulle)
* son orientation orient en 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
/* Plot trapezoidal pad.
* Pos is pad center
* Dimensions size.x and size.y
* Changes delta.x and delta.y (1 of at least two must be zero)
* Orientation east to 0.1 degrees
* Plot mode (FILLED, SKETCH, WIRED)
*
* Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y
* = 0.
* The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
*
*
les notation des sommets sont ( vis a vis de la table tracante
)
*
The rating of the vertexes are (vis a vis the plotter
)
*
* " 0 ------------- 3 "
* " . . "
...
...
@@ -485,7 +456,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " 1 ---- 2 "
*
*
*
exemple de Disposition pour
delta.y > 0, delta.x = 0
*
Example
delta.y > 0, delta.x = 0
* " 1 ---- 2 "
* " . . "
* " . O . "
...
...
@@ -493,7 +464,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " 0 ------------- 3 "
*
*
*
exemple de Disposition pour
delta.y = 0, delta.x > 0
*
Example
delta.y = 0, delta.x > 0
* " 0 "
* " . . "
* " . . "
...
...
@@ -506,6 +477,9 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " . . "
* " 1 "
*/
void
GERBER_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
int
ii
,
jj
;
...
...
@@ -514,7 +488,8 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int
coord
[
10
];
int
ddx
,
ddy
;
/* calcul des dimensions optimales du spot choisi = 1/4 plus petite dim */
/* Calculate the optimum size of the spot chosen by 1 / 4 of the
*smallest dimension */
dx
=
size
.
x
-
abs
(
delta
.
y
);
dy
=
size
.
y
-
abs
(
delta
.
x
);
...
...
@@ -532,8 +507,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
polygon
[
3
].
x
=
+
dx
+
ddy
;
polygon
[
3
].
y
=
+
dy
-
ddx
;
/* Dessin du polygone et Remplissage eventuel de l'interieur */
/* Draw the polygon and fill the interior as required. */
for
(
ii
=
0
,
jj
=
0
;
ii
<
4
;
ii
++
)
{
RotatePoint
(
&
polygon
[
ii
].
x
,
&
polygon
[
ii
].
y
,
orient
);
...
...
common/common_plotHPGL_functions.cpp
View file @
bc5d9a75
/************************************
******
/
/************************************/
/* Kicad: Common plot HPGL Routines */
/************************************
******
/
/************************************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -11,88 +11,83 @@
#include "macros.h"
#include "kicad_string.h"
/*
From decimils to plu
*/
/*
HPGL scale factor.
*/
const
double
SCALE_HPGL
=
0.102041
;
/***********************************************************************************/
void
HPGL_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
/***********************************************************************************/
/* Set the plot offset for the current plotting
*/
void
HPGL_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
{
wxASSERT
(
!
output_file
);
plot_offset
=
offset
;
plot_scale
=
aScale
;
wxASSERT
(
!
output_file
);
plot_offset
=
offset
;
plot_scale
=
aScale
;
device_scale
=
SCALE_HPGL
;
set_default_line_width
(
100
);
/* epaisseur du trait standard en 1/1000 pouce
*/
set_default_line_width
(
100
);
/* default line width in 1 / 1000 inch
*/
plot_orient_options
=
orient
;
}
/*****************************************************************/
void
HPGL_PLOTTER
::
start_plot
(
FILE
*
fout
)
/*****************************************************************/
void
HPGL_PLOTTER
::
start_plot
(
FILE
*
fout
)
{
wxASSERT
(
!
output_file
);
wxASSERT
(
!
output_file
);
output_file
=
fout
;
fprintf
(
output_file
,
"IN;VS%d;PU;PA;SP%d;
\n
"
,
pen_speed
,
pen_number
);
}
/**********************************/
void
HPGL_PLOTTER
::
end_plot
()
/**********************************/
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
fputs
(
"PU;PA;SP0;
\n
"
,
output_file
);
fclose
(
output_file
);
output_file
=
0
;
}
/************************************************************/
void
HPGL_PLOTTER
::
rect
(
wxPoint
p1
,
wxPoint
p2
,
FILL_T
fill
,
int
width
)
/************************************************************/
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
user_to_device_coordinates
(
p2
);
move_to
(
p1
);
move_to
(
p1
);
fprintf
(
output_file
,
"EA %d,%d;
\n
"
,
p2
.
x
,
p2
.
y
);
pen_finish
();
}
/************************************************************/
void
HPGL_PLOTTER
::
circle
(
wxPoint
centre
,
int
diameter
,
FILL_T
fill
,
int
width
)
/************************************************************/
void
HPGL_PLOTTER
::
circle
(
wxPoint
centre
,
int
diameter
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
double
rayon
=
user_to_device_size
(
diameter
/
2
);
wxASSERT
(
output_file
);
double
rayon
=
user_to_device_size
(
diameter
/
2
);
if
(
rayon
>
0
)
{
move_to
(
centre
);
fprintf
(
output_file
,
"CI %g;
\n
"
,
rayon
);
pen_finish
();
move_to
(
centre
);
fprintf
(
output_file
,
"CI %g;
\n
"
,
rayon
);
pen_finish
();
}
}
/*****************************************************/
void
HPGL_PLOTTER
::
poly
(
int
nb
,
int
*
coord
,
FILL_T
fill
,
int
width
)
/*****************************************************/
/*
Trace un polygone (ferme si rempli) en format
HPGL
* coord = tableau des coord des sommet
s
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau
)
* fill : si != 0 polygone rempli
/*
Plot a polygon (closed if completed) in
HPGL
* Coord = coord table top
s
* Nb = number of coord (coord 1 = 2 elements: X and Y table
)
* Fill: if! = 0 filled polygon
*/
void
HPGL_PLOTTER
::
poly
(
int
nb
,
int
*
coord
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
if
(
nb
<=
1
)
return
;
move_to
(
wxPoint
(
coord
[
0
],
coord
[
1
]
)
);
for
(
int
ii
=
1
;
ii
<
nb
;
ii
++
)
for
(
int
ii
=
1
;
ii
<
nb
;
ii
++
)
line_to
(
wxPoint
(
coord
[
ii
*
2
],
coord
[(
ii
*
2
)
+
1
]
)
);
/*
Fermeture eventuelle du polygone
*/
/*
Close polygon if filled.
*/
if
(
fill
)
{
int
ii
=
(
nb
-
1
)
*
2
;
...
...
@@ -102,50 +97,49 @@ void HPGL_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
pen_finish
();
}
/***************************/
void
HPGL_PLOTTER
::
pen_control
(
int
plume
)
/***************************/
/*
leve (plume = 'U') ou baisse (plume = 'D') la plume
/*
Set pen up ('U') or down ('D').
*/
void
HPGL_PLOTTER
::
pen_control
(
int
plume
)
{
wxASSERT
(
output_file
);
switch
(
plume
)
{
wxASSERT
(
output_file
);
switch
(
plume
)
{
case
'U'
:
if
(
pen_state
!=
'U'
)
{
{
fputs
(
"PU;"
,
output_file
);
pen_state
=
'U'
;
}
break
;
pen_state
=
'U'
;
}
break
;
case
'D'
:
if
(
pen_state
!=
'D'
)
{
{
fputs
(
"PD;"
,
output_file
);
pen_state
=
'D'
;
}
break
;
pen_state
=
'D'
;
}
break
;
case
'Z'
:
fputs
(
"PU;"
,
output_file
);
pen_state
=
'U'
;
pen_lastpos
.
x
=
-
1
;
pen_lastpos
.
y
=
-
1
;
break
;
fputs
(
"PU;"
,
output_file
);
pen_state
=
'U'
;
pen_lastpos
.
x
=
-
1
;
pen_lastpos
.
y
=
-
1
;
break
;
}
}
/**********************************************/
void
HPGL_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
/**********************************************/
/*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
* en position x,
y
* Unites en Unites DESSIN
* Si plume = 'Z' lever de plume sans deplacement
* Move the pen to position with pen up or down.
* At position x,
y
* Unit to unit DRAWING
* If pen = 'Z' without changing pen during move.
*/
void
HPGL_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
if
(
plume
==
'Z'
)
{
pen_control
(
'Z'
);
...
...
@@ -154,60 +148,61 @@ void HPGL_PLOTTER::pen_to( wxPoint pos, char plume )
pen_control
(
plume
);
user_to_device_coordinates
(
pos
);
if
(
pen_lastpos
!=
pos
)
fprintf
(
output_file
,
"PA %d,%d;
\n
"
,
pos
.
x
,
pos
.
y
);
if
(
pen_lastpos
!=
pos
)
fprintf
(
output_file
,
"PA %d,%d;
\n
"
,
pos
.
x
,
pos
.
y
);
pen_lastpos
=
pos
;
}
void
HPGL_PLOTTER
::
set_dash
(
bool
dashed
)
{
wxASSERT
(
output_file
);
if
(
dashed
)
fputs
(
"LI 2;
\n
"
,
stderr
);
wxASSERT
(
output_file
);
if
(
dashed
)
fputs
(
"LI 2;
\n
"
,
stderr
);
else
fputs
(
"LI;
\n
"
,
stderr
);
fputs
(
"LI;
\n
"
,
stderr
);
}
void
HPGL_PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
/** Function Plot a filled segment (track)
* @param start = starting point
* @param end = ending point
* @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH ..
*/
void
HPGL_PLOTTER
::
thick_segment
(
wxPoint
start
,
wxPoint
end
,
int
width
,
GRTraceMode
tracemode
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
wxPoint
center
;
wxSize
size
;
if
(
(
pen_diameter
>=
width
)
||
(
tracemode
==
FILAIRE
)
)
/* just a line is Ok */
if
(
(
pen_diameter
>=
width
)
||
(
tracemode
==
FILAIRE
)
)
/* just a line is
* Ok */
{
move_to
(
start
);
finish_to
(
end
);
}
else
segment_as_oval
(
start
,
end
,
width
,
tracemode
);
segment_as_oval
(
start
,
end
,
width
,
tracemode
);
}
/********************************************************************/
void
HPGL_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
rayon
,
FILL_T
fill
,
int
width
)
/********************************************************************/
/* trace d'un arc de cercle:
* centre = coord du centre
* StAngle, EndAngle = angle de debut et fin
* rayon = rayon de l'arc
* commande
* PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle, NbSegm; PU;
* ou PU;PA x,y;PD;AA start_arc_X, start_arc_Y, angle; PU;
/* Plot an arc:
* Center = center coord
* Stangl, endAngle = angle of beginning and end
* Radius = radius of the arc
* Command
* PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
* Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
*/
void
HPGL_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
rayon
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
wxPoint
cmap
;
/* point de depart */
wxPoint
cpos
;
/* centre */
float
angle
;
/* angle de l'arc*/
wxASSERT
(
output_file
);
wxPoint
cmap
;
wxPoint
cpos
;
float
angle
;
if
(
rayon
<=
0
)
return
;
...
...
@@ -216,72 +211,81 @@ void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
user_to_device_coordinates
(
cpos
);
if
(
plot_orient_options
==
PLOT_MIROIR
)
angle
=
(
StAngle
-
EndAngle
)
/
10.0
;
angle
=
(
StAngle
-
EndAngle
)
/
10.0
;
else
angle
=
(
EndAngle
-
StAngle
)
/
10.0
;
/* Calcul
des coord du point de depart :
*/
angle
=
(
EndAngle
-
StAngle
)
/
10.0
;
/* Calcul
ate start point,
*/
cmap
.
x
=
(
int
)
(
centre
.
x
+
(
rayon
*
cos
(
StAngle
*
M_PI
/
1800
)
)
);
cmap
.
y
=
(
int
)
(
centre
.
y
-
(
rayon
*
sin
(
StAngle
*
M_PI
/
1800
)
)
);
user_to_device_coordinates
(
cmap
);
fprintf
(
output_file
,
"PU;PA %d,%d;PD;AA %d,%d, "
,
cmap
.
x
,
cmap
.
y
,
cpos
.
x
,
cpos
.
y
);
fprintf
(
output_file
,
"PU;PA %d,%d;PD;AA %d,%d, "
,
cmap
.
x
,
cmap
.
y
,
cpos
.
x
,
cpos
.
y
);
fprintf
(
output_file
,
"%f"
,
angle
);
fprintf
(
output_file
,
";PU;
\n
"
);
pen_finish
();
}
/***********************************************************************************/
/* Plot oval pad.
*/
void
HPGL_PLOTTER
::
flash_pad_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
int
rayon
,
deltaxy
,
cx
,
cy
;
/* la pastille est ramenee a une pastille ovale avec size.y > size.x
* ( ovale vertical en orientation 0 ) */
/* The pad is reduced to an oval with size.y > size.x
* (Oval vertical orientation 0)
*/
if
(
size
.
x
>
size
.
y
)
{
EXCHG
(
size
.
x
,
size
.
y
);
orient
+=
900
;
if
(
orient
>=
3600
)
orient
-=
3600
;
}
deltaxy
=
size
.
y
-
size
.
x
;
/* = distance entre centres de l'ovale
*/
deltaxy
=
size
.
y
-
size
.
x
;
/* distance between centers of the oval
*/
rayon
=
size
.
x
/
2
;
if
(
trace_mode
==
FILLED
)
{
flash_pad_rect
(
pos
,
wxSize
(
size
.
x
,
deltaxy
+
wxRound
(
pen_diameter
)
),
orient
,
trace_mode
);
orient
,
trace_mode
);
cx
=
0
;
cy
=
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
flash_pad_circle
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
size
.
x
,
trace_mode
);
flash_pad_circle
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
size
.
x
,
trace_mode
);
cx
=
0
;
cy
=
-
deltaxy
/
2
;
RotatePoint
(
&
cx
,
&
cy
,
orient
);
flash_pad_circle
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
size
.
x
,
trace_mode
);
flash_pad_circle
(
wxPoint
(
cx
+
pos
.
x
,
cy
+
pos
.
y
),
size
.
x
,
trace_mode
);
}
else
/*
Trace en mode SKETCH
*/
else
/*
Plot in SKETCH mode.
*/
{
sketch_oval
(
pos
,
size
,
orient
,
wxRound
(
pen_diameter
)
);
sketch_oval
(
pos
,
size
,
orient
,
wxRound
(
pen_diameter
)
);
}
}
/*******************************************************************************/
void
HPGL_PLOTTER
::
flash_pad_circle
(
wxPoint
pos
,
int
diametre
,
GRTraceMode
trace_mode
)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos */
/* Plot round pad or via.
*/
void
HPGL_PLOTTER
::
flash_pad_circle
(
wxPoint
pos
,
int
diametre
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
int
rayon
,
delta
;
wxASSERT
(
output_file
);
int
rayon
,
delta
;
user_to_device_coordinates
(
pos
);
delta
=
wxRound
(
pen_diameter
-
pen_overlap
)
;
delta
=
wxRound
(
pen_diameter
-
pen_overlap
);
rayon
=
diametre
/
2
;
if
(
trace_mode
!=
FILAIRE
)
{
rayon
=
(
diametre
-
wxRound
(
pen_diameter
)
)
/
2
;
rayon
=
(
diametre
-
wxRound
(
pen_diameter
)
)
/
2
;
}
if
(
rayon
<
0
)
...
...
@@ -293,7 +297,8 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
user_to_device_size
(
rsize
);
fprintf
(
output_file
,
"PA %d,%d;CI %d;
\n
"
,
pos
.
x
,
pos
.
y
,
rsize
.
x
);
if
(
trace_mode
==
FILLED
)
/* Trace en mode Remplissage */
if
(
trace_mode
==
FILLED
)
/* Plot in filled mode. */
{
if
(
delta
>
0
)
{
...
...
@@ -301,7 +306,11 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
{
rsize
.
x
=
rsize
.
y
=
rayon
;
user_to_device_size
(
rsize
);
fprintf
(
output_file
,
"PA %d,%d; CI %d;
\n
"
,
pos
.
x
,
pos
.
y
,
rsize
.
x
);
fprintf
(
output_file
,
"PA %d,%d; CI %d;
\n
"
,
pos
.
x
,
pos
.
y
,
rsize
.
x
);
}
}
}
...
...
@@ -309,68 +318,77 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
return
;
}
/**************************************************************************/
void
HPGL_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
padsize
,
int
orient
,
GRTraceMode
trace_mode
)
/**************************************************************************/
/*
*
Trace 1 pad rectangulaire vertical ou horizontal ( Pad rectangulaire )
*
donne par son centre et ses dimensions X et
Y
*
Units are user units
*
Plot rectangular pad vertical or horizontal.
*
Gives its center and its dimensions X and
Y
* Units are user units
*/
void
HPGL_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
padsize
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
wxSize
size
;
int
delta
;
int
ox
,
oy
,
fx
,
fy
;
size
.
x
=
padsize
.
x
/
2
;
size
.
y
=
padsize
.
y
/
2
;
size
.
x
=
padsize
.
x
/
2
;
size
.
y
=
padsize
.
y
/
2
;
if
(
trace_mode
!=
FILAIRE
)
{
size
.
x
=
(
padsize
.
x
-
(
int
)
pen_diameter
)
/
2
;
size
.
y
=
(
padsize
.
y
-
(
int
)
pen_diameter
)
/
2
;
size
.
x
=
(
padsize
.
x
-
(
int
)
pen_diameter
)
/
2
;
size
.
y
=
(
padsize
.
y
-
(
int
)
pen_diameter
)
/
2
;
}
if
(
size
.
x
<
0
)
size
.
x
=
0
;
size
.
x
=
0
;
if
(
size
.
y
<
0
)
size
.
y
=
0
;
size
.
y
=
0
;
/*
Si une des dimensions est nulle, le trace se reduit a 1 trait
*/
/*
If a dimension is zero, the trace is reduced to 1 line.
*/
if
(
size
.
x
==
0
)
{
ox
=
pos
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
return
;
ox
=
pos
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
return
;
}
if
(
size
.
y
==
0
)
{
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
finish_to
(
wxPoint
(
fx
,
fy
)
);
return
;
}
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
...
...
@@ -378,82 +396,121 @@ void HPGL_PLOTTER::flash_pad_rect(wxPoint pos, wxSize padsize,
if
(
trace_mode
==
FILLED
)
{
/* Trace en mode Remplissage */
delta
=
(
int
)
(
pen_diameter
-
pen_overlap
);
if
(
delta
>
0
)
while
(
(
size
.
x
>
0
)
&&
(
size
.
y
>
0
)
)
{
size
.
x
-=
delta
;
size
.
y
-=
delta
;
if
(
size
.
x
<
0
)
size
.
x
=
0
;
if
(
size
.
y
<
0
)
size
.
y
=
0
;
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
finish_to
(
wxPoint
(
ox
,
oy
)
);
}
/* Plot in filled mode. */
delta
=
(
int
)
(
pen_diameter
-
pen_overlap
);
if
(
delta
>
0
)
while
(
(
size
.
x
>
0
)
&&
(
size
.
y
>
0
)
)
{
size
.
x
-=
delta
;
size
.
y
-=
delta
;
if
(
size
.
x
<
0
)
size
.
x
=
0
;
if
(
size
.
y
<
0
)
size
.
y
=
0
;
ox
=
pos
.
x
-
size
.
x
;
oy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
ox
,
&
oy
,
pos
.
x
,
pos
.
y
,
orient
);
move_to
(
wxPoint
(
ox
,
oy
)
);
fx
=
pos
.
x
-
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
+
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
fx
=
pos
.
x
+
size
.
x
;
fy
=
pos
.
y
-
size
.
y
;
RotatePoint
(
&
fx
,
&
fy
,
pos
.
x
,
pos
.
y
,
orient
);
line_to
(
wxPoint
(
fx
,
fy
)
);
finish_to
(
wxPoint
(
ox
,
oy
)
);
}
}
}
/*******************************************************************/
void
HPGL_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
/*******************************************************************/
/*
* Trace 1 pad trapezoidal donne par :
* son centre pos.x,pos.y
* ses dimensions dimX et dimY
* les variations deltaX et deltaY
* son orientation orient et 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
/* Plot trapezoidal pad.
* Pos is pad center
* Dimensions size.x and size.y
* Changes delta.x and delta.y (1 of at least two must be zero)
* Orientation east to 0.1 degrees
* Plot mode (FILLED, SKETCH, WIRED)
*
* The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
*
* The rating of the vertexes are (vis a vis the plotter)
*
* les notation des sommets sont ( vis a vis de la table tracante )
* 0 ------------- 3
* . .
* . .
* . .
* 1 --- 2
* " 0 ------------- 3 "
* " . . "
* " . O . "
* " . . "
* " 1 ---- 2 "
*
*
* Example delta.y > 0, delta.x = 0
* " 1 ---- 2 "
* " . . "
* " . O . "
* " . . "
* " 0 ------------- 3 "
*
*
* Example delta.y = 0, delta.x > 0
* " 0 "
* " . . "
* " . . "
* " . 3 "
* " . . "
* " . O . "
* " . . "
* " . 2 "
* " . . "
* " . . "
* " 1 "
*/
void
HPGL_PLOTTER
::
flash_pad_trapez
(
wxPoint
pos
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxPoint
polygone
[
4
];
/* coord des sommets / centre du pad */
wxPoint
coord
[
4
];
/* coord reelles des sommets du trapeze a tracer */
int
moveX
,
moveY
;
/* variation de position plume selon axe X et Y , lors
* du remplissage du trapeze */
moveX
=
moveY
=
wxRound
(
pen_diameter
);
size
.
x
/=
2
;
size
.
y
/=
2
;
delta
.
x
/=
2
;
delta
.
y
/=
2
;
polygone
[
0
].
x
=
-
size
.
x
-
delta
.
y
;
polygone
[
0
].
y
=
+
size
.
y
+
delta
.
x
;
polygone
[
1
].
x
=
-
size
.
x
+
delta
.
y
;
polygone
[
1
].
y
=
-
size
.
y
-
delta
.
x
;
polygone
[
2
].
x
=
+
size
.
x
-
delta
.
y
;
polygone
[
2
].
y
=
-
size
.
y
+
delta
.
x
;
polygone
[
3
].
x
=
+
size
.
x
+
delta
.
y
;
polygone
[
3
].
y
=
+
size
.
y
-
delta
.
x
;
wxASSERT
(
output_file
);
wxPoint
polygone
[
4
];
wxPoint
coord
[
4
];
int
moveX
,
moveY
;
/* Trace du contour */
polygone
[
0
].
x
+=
moveX
;
polygone
[
0
].
y
-=
moveY
;
polygone
[
1
].
x
+=
moveX
;
polygone
[
1
].
y
+=
moveY
;
polygone
[
2
].
x
-=
moveX
;
polygone
[
2
].
y
+=
moveY
;
polygone
[
3
].
x
-=
moveX
;
polygone
[
3
].
y
-=
moveY
;
moveX
=
moveY
=
wxRound
(
pen_diameter
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
size
.
x
/=
2
;
size
.
y
/=
2
;
delta
.
x
/=
2
;
delta
.
y
/=
2
;
polygone
[
0
].
x
=
-
size
.
x
-
delta
.
y
;
polygone
[
0
].
y
=
+
size
.
y
+
delta
.
x
;
polygone
[
1
].
x
=
-
size
.
x
+
delta
.
y
;
polygone
[
1
].
y
=
-
size
.
y
-
delta
.
x
;
polygone
[
2
].
x
=
+
size
.
x
-
delta
.
y
;
polygone
[
2
].
y
=
-
size
.
y
+
delta
.
x
;
polygone
[
3
].
x
=
+
size
.
x
+
delta
.
y
;
polygone
[
3
].
y
=
+
size
.
y
-
delta
.
x
;
/* Trace the outline. */
polygone
[
0
].
x
+=
moveX
;
polygone
[
0
].
y
-=
moveY
;
polygone
[
1
].
x
+=
moveX
;
polygone
[
1
].
y
+=
moveY
;
polygone
[
2
].
x
-=
moveX
;
polygone
[
2
].
y
+=
moveY
;
polygone
[
3
].
x
-=
moveX
;
polygone
[
3
].
y
-=
moveY
;
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
coord
[
ii
].
x
=
polygone
[
ii
].
x
+
pos
.
x
;
coord
[
ii
].
y
=
polygone
[
ii
].
y
+
pos
.
y
;
...
...
@@ -469,63 +526,69 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
if
(
trace_mode
==
FILLED
)
{
int
jj
;
/* Fill the shape */
moveX
=
moveY
=
wxRound
(
pen_diameter
-
pen_overlap
);
/* calcul de jj = hauteur du remplissage */
if
(
delta
.
y
)
/* Trapeze horizontal */
{
jj
=
size
.
y
-
(
int
)
(
pen_diameter
+
(
2
*
pen_overlap
)
);
}
else
{
jj
=
size
.
x
-
(
int
)
(
pen_diameter
+
(
2
*
pen_overlap
)
);
}
/* Calcul de jj = nombre de segments a tracer pour le remplissage */
jj
=
jj
/
(
int
)
(
pen_diameter
-
pen_overlap
);
/* Trace du contour */
for
(
;
jj
>
0
;
jj
--
)
{
polygone
[
0
].
x
+=
moveX
;
polygone
[
0
].
y
-=
moveY
;
polygone
[
1
].
x
+=
moveX
;
polygone
[
1
].
y
+=
moveY
;
polygone
[
2
].
x
-=
moveX
;
polygone
[
2
].
y
+=
moveY
;
polygone
[
3
].
x
-=
moveX
;
polygone
[
3
].
y
-=
moveY
;
/* Test de limitation de variation des dimensions :
* si les sommets se "croisent", il ne faut plus modifier les
* coordonnees correspondantes */
if
(
polygone
[
0
].
x
>
polygone
[
3
].
x
)
{
/* croisement sur axe X des 2 sommets 0 et 3 */
polygone
[
0
].
x
=
polygone
[
3
].
x
=
0
;
}
if
(
polygone
[
1
].
x
>
polygone
[
2
].
x
)
{
/* croisement sur axe X des 2 sommets 1 et 2 */
polygone
[
1
].
x
=
polygone
[
2
].
x
=
0
;
}
if
(
polygone
[
1
].
y
>
polygone
[
0
].
y
)
{
/* croisement sur axe Y des 2 sommets 0 et 1 */
polygone
[
0
].
y
=
polygone
[
1
].
y
=
0
;
}
if
(
polygone
[
2
].
y
>
polygone
[
3
].
y
)
{
/* croisement sur axe Y des 2 sommets 2 et 3 */
polygone
[
2
].
y
=
polygone
[
3
].
y
=
0
;
}
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
coord
[
ii
].
x
=
polygone
[
ii
].
x
+
pos
.
x
;
coord
[
ii
].
y
=
polygone
[
ii
].
y
+
pos
.
y
;
RotatePoint
(
&
coord
[
ii
],
pos
,
orient
);
}
move_to
(
coord
[
0
]
);
line_to
(
coord
[
1
]
);
line_to
(
coord
[
2
]
);
line_to
(
coord
[
3
]
);
finish_to
(
coord
[
0
]
);
}
int
jj
;
/* Fill the shape */
moveX
=
moveY
=
wxRound
(
pen_diameter
-
pen_overlap
);
/* Calculate fill height. */
if
(
delta
.
y
)
/* Horizontal */
{
jj
=
size
.
y
-
(
int
)
(
pen_diameter
+
(
2
*
pen_overlap
)
);
}
else
{
jj
=
size
.
x
-
(
int
)
(
pen_diameter
+
(
2
*
pen_overlap
)
);
}
/* Calculation of dd = number of segments was traced to fill. */
jj
=
jj
/
(
int
)
(
pen_diameter
-
pen_overlap
);
/* Trace the outline. */
for
(
;
jj
>
0
;
jj
--
)
{
polygone
[
0
].
x
+=
moveX
;
polygone
[
0
].
y
-=
moveY
;
polygone
[
1
].
x
+=
moveX
;
polygone
[
1
].
y
+=
moveY
;
polygone
[
2
].
x
-=
moveX
;
polygone
[
2
].
y
+=
moveY
;
polygone
[
3
].
x
-=
moveX
;
polygone
[
3
].
y
-=
moveY
;
/* Test for crossed vertexes. */
if
(
polygone
[
0
].
x
>
polygone
[
3
].
x
)
/* X axis intersection on
*vertexes 0 and 3 */
{
polygone
[
0
].
x
=
polygone
[
3
].
x
=
0
;
}
if
(
polygone
[
1
].
x
>
polygone
[
2
].
x
)
/* X axis intersection on
*vertexes 1 and 2 */
{
polygone
[
1
].
x
=
polygone
[
2
].
x
=
0
;
}
if
(
polygone
[
1
].
y
>
polygone
[
0
].
y
)
/* Y axis intersection on
*vertexes 0 and 1 */
{
polygone
[
0
].
y
=
polygone
[
1
].
y
=
0
;
}
if
(
polygone
[
2
].
y
>
polygone
[
3
].
y
)
/* Y axis intersection on
*vertexes 2 and 3 */
{
polygone
[
2
].
y
=
polygone
[
3
].
y
=
0
;
}
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
coord
[
ii
].
x
=
polygone
[
ii
].
x
+
pos
.
x
;
coord
[
ii
].
y
=
polygone
[
ii
].
y
+
pos
.
y
;
RotatePoint
(
&
coord
[
ii
],
pos
,
orient
);
}
move_to
(
coord
[
0
]
);
line_to
(
coord
[
1
]
);
line_to
(
coord
[
2
]
);
line_to
(
coord
[
3
]
);
finish_to
(
coord
[
0
]
);
}
}
}
common/common_plotPS_functions.cpp
View file @
bc5d9a75
...
...
@@ -11,40 +11,33 @@
#include "macros.h"
#include "kicad_string.h"
/*************************************************************************************/
void
PS_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
/*************************************************************************************/
/* Set the plot offset for the current plotting */
void
PS_PLOTTER
::
set_viewport
(
wxPoint
offset
,
double
aScale
,
int
orient
)
{
wxASSERT
(
!
output_file
);
wxASSERT
(
!
output_file
);
plot_orient_options
=
orient
;
plot_offset
=
offset
;
plot_scale
=
aScale
;
device_scale
=
1
;
/* PS references in decimi
ls */
set_default_line_width
(
100
);
/* epaisseur du trait standard en 1/1000 pouce
*/
plot_offset
=
offset
;
plot_scale
=
aScale
;
device_scale
=
1
;
/* PS references in decima
ls */
set_default_line_width
(
100
);
/* default line width in 1/1000 inch
*/
}
/*************************************************************************************/
void
PS_PLOTTER
::
set_default_line_width
(
int
width
)
/*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting
*/
void
PS_PLOTTER
::
set_default_line_width
(
int
width
)
{
default_pen_width
=
width
;
// epaisseur du trait standard en 1/1000 pouce
default_pen_width
=
width
;
// line width in 1/1000 inch
current_pen_width
=
-
1
;
}
/***************************************/
void
PS_PLOTTER
::
set_current_line_width
(
int
width
)
/***************************************/
/* Set the
C
urrent line width (in 1/1000 inch) for the next plot
/* Set the
c
urrent line width (in 1/1000 inch) for the next plot
*/
void
PS_PLOTTER
::
set_current_line_width
(
int
width
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
int
pen_width
;
if
(
width
>=
0
)
...
...
@@ -54,145 +47,138 @@ void PS_PLOTTER::set_current_line_width( int width )
if
(
pen_width
!=
current_pen_width
)
fprintf
(
output_file
,
"%g setlinewidth
\n
"
,
user_to_device_size
(
pen_width
)
);
user_to_device_size
(
pen_width
)
);
current_pen_width
=
pen_width
;
}
/******************************/
void
PS_PLOTTER
::
set_color
(
int
color
)
/******************************/
/* Print the postscript set color command:
* r g b setrgbcolor,
* r, g, b = color values (= 0 .. 1.0 )
*
* color = color index in ColorRefs[]
*/
void
PS_PLOTTER
::
set_color
(
int
color
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
/* Return at invalid color index */
if
(
color
<
0
)
return
;
/* Return at invalid color index */
if
(
color
<
0
)
return
;
if
(
color_mode
)
if
(
color_mode
)
{
if
(
negative_mode
)
{
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Red
/
255
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Green
/
255
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Blue
/
255
);
}
else
{
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
ColorRefs
[
color
].
m_Red
/
255
,
(
double
)
ColorRefs
[
color
].
m_Green
/
255
,
(
double
)
ColorRefs
[
color
].
m_Blue
/
255
);
}
if
(
negative_mode
)
{
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Red
/
255
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Green
/
255
,
(
double
)
1.0
-
ColorRefs
[
color
].
m_Blue
/
255
);
}
else
{
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
ColorRefs
[
color
].
m_Red
/
255
,
(
double
)
ColorRefs
[
color
].
m_Green
/
255
,
(
double
)
ColorRefs
[
color
].
m_Blue
/
255
);
}
}
else
/* B/W Mode - Use BLACK or WHITE for all items
* note the 2 colors are used in B&W mode, mainly by Pcbnew to draw holes in white on pads in black
*/
{
int
bwcolor
=
WHITE
;
/* B/W Mode - Use BLACK or WHITE for all items
* note the 2 colors are used in B&W mode, mainly by Pcbnew to draw
* holes in white on pads in black
*/
int
bwcolor
=
WHITE
;
if
(
color
!=
WHITE
)
bwcolor
=
BLACK
;
if
(
negative_mode
)
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Red
/
255
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Green
/
255
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Blue
/
255
);
else
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
ColorRefs
[
bwcolor
].
m_Red
/
255
,
(
double
)
ColorRefs
[
bwcolor
].
m_Green
/
255
,
(
double
)
ColorRefs
[
bwcolor
].
m_Blue
/
255
);
bwcolor
=
BLACK
;
if
(
negative_mode
)
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Red
/
255
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Green
/
255
,
(
double
)
1.0
-
ColorRefs
[
bwcolor
].
m_Blue
/
255
);
else
fprintf
(
output_file
,
"%.3g %.3g %.3g setrgbcolor
\n
"
,
(
double
)
ColorRefs
[
bwcolor
].
m_Red
/
255
,
(
double
)
ColorRefs
[
bwcolor
].
m_Green
/
255
,
(
double
)
ColorRefs
[
bwcolor
].
m_Blue
/
255
);
}
}
void
PS_PLOTTER
::
set_dash
(
bool
dashed
)
{
wxASSERT
(
output_file
);
if
(
dashed
)
fputs
(
"dashedline
\n
"
,
stderr
);
wxASSERT
(
output_file
);
if
(
dashed
)
fputs
(
"dashedline
\n
"
,
stderr
);
else
fputs
(
"solidline
\n
"
,
stderr
);
fputs
(
"solidline
\n
"
,
stderr
);
}
/***************************************************************/
void
PS_PLOTTER
::
rect
(
wxPoint
p1
,
wxPoint
p2
,
FILL_T
fill
,
int
width
)
/***************************************************************/
{
user_to_device_coordinates
(
p1
);
user_to_device_coordinates
(
p2
);
set_current_line_width
(
width
);
fprintf
(
output_file
,
"%d %d %d %d rect%d
\n
"
,
p1
.
x
,
p1
.
y
,
p2
.
x
-
p1
.
x
,
p2
.
y
-
p1
.
y
,
fill
);
p2
.
x
-
p1
.
x
,
p2
.
y
-
p1
.
y
,
fill
);
}
/******************************************************/
void
PS_PLOTTER
::
circle
(
wxPoint
pos
,
int
diametre
,
FILL_T
fill
,
int
width
)
/******************************************************/
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
user_to_device_coordinates
(
pos
);
double
ra
yon
=
user_to_device_size
(
diametre
/
2.0
);
double
ra
dius
=
user_to_device_size
(
diametre
/
2.0
);
if
(
ra
yon
<
1
)
ra
yon
=
1
;
if
(
ra
dius
<
1
)
ra
dius
=
1
;
set_current_line_width
(
width
);
fprintf
(
output_file
,
"%d %d %g cir%d
\n
"
,
pos
.
x
,
pos
.
y
,
rayon
,
fill
);
fprintf
(
output_file
,
"%d %d %g cir%d
\n
"
,
pos
.
x
,
pos
.
y
,
radius
,
fill
);
}
/**************************************************************************************/
void
PS_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
rayon
,
FILL_T
fill
,
int
width
)
/**************************************************************************************/
/* Plot an arc:
* StAngle, EndAngle = start and end arc in 0.1 degree
*/
void
PS_PLOTTER
::
arc
(
wxPoint
centre
,
int
StAngle
,
int
EndAngle
,
int
radius
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
if
(
ra
yon
<=
0
)
wxASSERT
(
output_file
);
if
(
ra
dius
<=
0
)
return
;
set_current_line_width
(
width
);
// Calcul
des coord du point de depart :
// Calcul
ate start point.
user_to_device_coordinates
(
centre
);
ra
yon
=
wxRound
(
user_to_device_size
(
rayon
)
);
ra
dius
=
wxRound
(
user_to_device_size
(
radius
)
);
if
(
plot_orient_options
==
PLOT_MIROIR
)
fprintf
(
output_file
,
"%d %d %d %g %g arc%d
\n
"
,
centre
.
x
,
centre
.
y
,
rayon
,
(
double
)
-
EndAngle
/
10
,
(
double
)
-
StAngle
/
10
,
fill
);
radius
,
(
double
)
-
EndAngle
/
10
,
(
double
)
-
StAngle
/
10
,
fill
);
else
fprintf
(
output_file
,
"%d %d %d %g %g arc%d
\n
"
,
centre
.
x
,
centre
.
y
,
rayon
,
(
double
)
StAngle
/
10
,
(
double
)
EndAngle
/
10
,
fill
);
radius
,
(
double
)
StAngle
/
10
,
(
double
)
EndAngle
/
10
,
fill
);
}
/*****************************************************************/
void
PS_PLOTTER
::
poly
(
int
nb_segm
,
int
*
coord
,
FILL_T
fill
,
int
width
)
/*****************************************************************/
/** Function poly
* @brief Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format
* @param nb_segm = corner count
* @param coord = corner list (a corner uses 2 int = X coordinate followed by Y coordinate
* @param coord = corner list (a corner uses 2 int = X coordinate followed by Y
* coordinate
* @param fill :if true : filled polygon
* @param width = line width
*/
void
PS_PLOTTER
::
poly
(
int
nb_segm
,
int
*
coord
,
FILL_T
fill
,
int
width
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
wxPoint
pos
;
if
(
nb_segm
<=
1
)
...
...
@@ -205,7 +191,7 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width )
user_to_device_coordinates
(
pos
);
fprintf
(
output_file
,
"newpath
\n
%d %d moveto
\n
"
,
pos
.
x
,
pos
.
y
);
for
(
int
ii
=
1
;
ii
<
nb_segm
;
ii
++
)
for
(
int
ii
=
1
;
ii
<
nb_segm
;
ii
++
)
{
pos
.
x
=
coord
[
2
*
ii
];
pos
.
y
=
coord
[
2
*
ii
+
1
];
...
...
@@ -214,43 +200,43 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width )
}
// Close path
fprintf
(
output_file
,
"poly%d
\n
"
,
fill
);
fprintf
(
output_file
,
"poly%d
\n
"
,
fill
);
}
/*************************************/
void
PS_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
/*************************************/
/* Routine to draw to a new position
*/
void
PS_PLOTTER
::
pen_to
(
wxPoint
pos
,
char
plume
)
{
wxASSERT
(
output_file
);
if
(
plume
==
'Z'
)
{
if
(
pen_state
!=
'Z'
)
{
fputs
(
"stroke
\n
"
,
output_file
);
pen_state
=
'Z'
;
pen_lastpos
.
x
=
-
1
;
pen_lastpos
.
y
=
-
1
;
}
wxASSERT
(
output_file
);
if
(
plume
==
'Z'
)
{
if
(
pen_state
!=
'Z'
)
{
fputs
(
"stroke
\n
"
,
output_file
);
pen_state
=
'Z'
;
pen_lastpos
.
x
=
-
1
;
pen_lastpos
.
y
=
-
1
;
}
return
;
}
user_to_device_coordinates
(
pos
);
if
(
pen_state
==
'Z'
)
{
fputs
(
"newpath
\n
"
,
output_file
);
if
(
pen_state
==
'Z'
)
{
fputs
(
"newpath
\n
"
,
output_file
);
}
if
(
pen_state
!=
plume
||
pos
!=
pen_lastpos
)
fprintf
(
output_file
,
"%d %d %sto
\n
"
,
pos
.
x
,
pos
.
y
,
(
plume
==
'D'
)
?
"line"
:
"move"
);
pen_state
=
plume
;
if
(
pen_state
!=
plume
||
pos
!=
pen_lastpos
)
fprintf
(
output_file
,
"%d %d %sto
\n
"
,
pos
.
x
,
pos
.
y
,
(
plume
==
'D'
)
?
"line"
:
"move"
);
pen_state
=
plume
;
pen_lastpos
=
pos
;
}
/***********************************************************/
void
PS_PLOTTER
::
start_plot
(
FILE
*
fout
)
/***********************************************************/
/* The code within this function (and the CloseFilePS function)
* creates postscript files whose contents comply with Adobe's
* Document Structuring Convention, as documented by assorted
...
...
@@ -263,12 +249,14 @@ void PS_PLOTTER::start_plot( FILE *fout)
* BBox is the boundary box (position and size of the "client rectangle"
* for drawings (page - margins) in mils (0.001 inch)
*/
void
PS_PLOTTER
::
start_plot
(
FILE
*
fout
)
{
wxASSERT
(
!
output_file
);
wxString
msg
;
wxASSERT
(
!
output_file
);
wxString
msg
;
output_file
=
fout
;
static
const
char
*
PSMacro
[]
=
{
static
const
char
*
PSMacro
[]
=
{
"/line {
\n
"
,
" newpath
\n
"
,
" moveto
\n
"
,
...
...
@@ -279,26 +267,28 @@ void PS_PLOTTER::start_plot( FILE *fout)
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def
\n
"
,
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def
\n
"
,
"/arc0 { newpath arc stroke } bind def
\n
"
,
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill grestore stroke } bind def
\n
"
,
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill grestore stroke } bind def
\n
"
,
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill "
,
"grestore stroke } bind def
\n
"
,
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill "
,
"grestore stroke } bind def
\n
"
,
"/poly0 { stroke } bind def
\n
"
,
"/poly1 { closepath gsave fill grestore stroke } bind def
\n
"
,
"/poly2 { closepath gsave fill grestore stroke } bind def
\n
"
,
"/rect0 { rectstroke } bind def
\n
"
,
"/rect1 { rectfill } bind def
\n
"
,
"/rect2 { rectfill } bind def
\n
"
,
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def
\n
"
,
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def
\n
"
,
"/dashedline { [50 50] 0 setdash } bind def
\n
"
,
"/solidline { [] 0 setdash } bind def
\n
"
,
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def
\n
"
,
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def
\n
"
,
"/dashedline { [50 50] 0 setdash } bind def
\n
"
,
"/solidline { [] 0 setdash } bind def
\n
"
,
"gsave
\n
"
,
"0.0072 0.0072 scale
\n
"
,
// Configure postscript for decimils
"0.0072 0.0072 scale
\n
"
,
// Configure postscript for decimals.
"linemode1
\n
"
,
NULL
};
const
double
DECIMIL_TO_INCH
=
0.0001
;
time_t
time1970
=
time
(
NULL
);
const
double
DECIMIL_TO_INCH
=
0.0001
;
time_t
time1970
=
time
(
NULL
);
fputs
(
"%!PS-Adobe-3.0
\n
"
,
output_file
);
// Print header
...
...
@@ -308,18 +298,18 @@ void PS_PLOTTER::start_plot( FILE *fout)
// because it is provided by the ctime() function.
fprintf
(
output_file
,
"%%%%CreationDate: %s"
,
ctime
(
&
time1970
)
);
fprintf
(
output_file
,
"%%%%Title: %s
\n
"
,
CONV_TO_UTF8
(
filename
)
);
fprintf
(
output_file
,
"%%%%Pages: 1
\n
"
);
fprintf
(
output_file
,
"%%%%Pages: 1
\n
"
);
fprintf
(
output_file
,
"%%%%PageOrder: Ascend
\n
"
);
// Print boundary box
en 1/72 pouce, box is in decimi
ls
// Print boundary box
in 1/72 pixels per inch, box is in decima
ls
const
double
CONV_SCALE
=
DECIMIL_TO_INCH
*
72
;
// The coordinates of the lower left corner of the boundary
// box need to be "rounded down", but the coordinates of its
// upper right corner need to be "rounded up" instead.
fprintf
(
output_file
,
"%%%%BoundingBox: 0 0 %d %d
\n
"
,
(
int
)
ceil
(
paper_size
.
y
*
CONV_SCALE
),
(
int
)
ceil
(
paper_size
.
x
*
CONV_SCALE
)
);
(
int
)
ceil
(
paper_size
.
y
*
CONV_SCALE
),
(
int
)
ceil
(
paper_size
.
x
*
CONV_SCALE
)
);
// Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size,
...
...
@@ -327,14 +317,14 @@ void PS_PLOTTER::start_plot( FILE *fout)
// otherwise use the name assigned by KiCad for each sheet size.)
//
// (The Document Structuring Convention also supports sheet weight,
// sheet colo
u
r, and sheet type properties being specified within a
// sheet color, and sheet type properties being specified within a
// %%DocumentMedia comment, but they are not being specified here;
// a zero and two null strings are subsequently provided instead.)
//
// (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
// the order in which they are specified is not wrong!)
// Also note sheet->m_Size is given in mils, not in decim
i
ls and must be
// sheet->m_Size * 10 in decim
i
ls
// Also note sheet->m_Size is given in mils, not in decim
a
ls and must be
// sheet->m_Size * 10 in decim
a
ls
if
(
sheet
->
m_Name
.
Cmp
(
wxT
(
"User"
)
)
==
0
)
fprintf
(
output_file
,
"%%%%DocumentMedia: Custom %d %d 0 () ()
\n
"
,
wxRound
(
sheet
->
m_Size
.
y
*
CONV_SCALE
),
...
...
@@ -358,7 +348,7 @@ void PS_PLOTTER::start_plot( FILE *fout)
// within the Document Structuring Convention.
fprintf
(
output_file
,
"%%%%Page: 1 1
\n
"
);
for
(
int
ii
=
0
;
PSMacro
[
ii
]
!=
NULL
;
ii
++
)
for
(
int
ii
=
0
;
PSMacro
[
ii
]
!=
NULL
;
ii
++
)
{
fputs
(
PSMacro
[
ii
],
output_file
);
}
...
...
@@ -366,43 +356,41 @@ void PS_PLOTTER::start_plot( FILE *fout)
// (If support for creating postscript files with a portrait orientation
// is ever provided, determine whether it would be necessary to provide
// an "else" command and then an appropriate "sprintf" command here.)
fprintf
(
output_file
,
"%d 0 translate 90 rotate
\n
"
,
paper_size
.
y
);
fprintf
(
output_file
,
"%d 0 translate 90 rotate
\n
"
,
paper_size
.
y
);
// Apply the scale adjustments
if
(
plot_scale_adjX
!=
1.0
||
plot_scale_adjY
!=
1.0
)
fprintf
(
output_file
,
"%g %g scale
\n
"
,
plot_scale_adjX
,
plot_scale_adjY
);
if
(
plot_scale_adjX
!=
1.0
||
plot_scale_adjY
!=
1.0
)
fprintf
(
output_file
,
"%g %g scale
\n
"
,
plot_scale_adjX
,
plot_scale_adjY
);
// Set default line width ( g_Plot_DefaultPenWidth is in user units )
fprintf
(
output_file
,
"%g setlinewidth
\n
"
,
user_to_device_size
(
default_pen_width
)
);
user_to_device_size
(
default_pen_width
)
);
}
/******************************************/
void
PS_PLOTTER
::
end_plot
()
/******************************************/
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
fputs
(
"showpage
\n
grestore
\n
%%EOF
\n
"
,
output_file
);
fclose
(
output_file
);
output_file
=
0
;
}
/***********************************************************************************/
void
PS_PLOTTER
::
flash_pad_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
modetrace
)
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y:
* dimensions dx,dy,
* orientation orient
* La forme est tracee comme un segment
/* Plot oval pad:
* pos - Position of pad.
* Dimensions dx, dy,
* Orient Orient
* The shape is drawn as a segment
*/
void
PS_PLOTTER
::
flash_pad_oval
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
modetrace
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
int
x0
,
y0
,
x1
,
y1
,
delta
;
//
la pastille est ramenee a une pastille ovale avec
dy > dx
//
The pad is reduced to an oval by
dy > dx
if
(
size
.
x
>
size
.
y
)
{
EXCHG
(
size
.
x
,
size
.
y
);
...
...
@@ -411,7 +399,7 @@ void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
orient
-=
3600
;
}
delta
=
size
.
y
-
size
.
x
;
delta
=
size
.
y
-
size
.
x
;
x0
=
0
;
y0
=
-
delta
/
2
;
x1
=
0
;
...
...
@@ -421,89 +409,81 @@ void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
if
(
modetrace
==
FILLED
)
thick_segment
(
wxPoint
(
pos
.
x
+
x0
,
pos
.
y
+
y0
),
wxPoint
(
pos
.
x
+
x1
,
pos
.
y
+
y1
),
size
.
x
,
modetrace
);
wxPoint
(
pos
.
x
+
x1
,
pos
.
y
+
y1
),
size
.
x
,
modetrace
);
else
sketch_oval
(
pos
,
size
,
orient
,
-
1
);
sketch_oval
(
pos
,
size
,
orient
,
-
1
);
}
/*******************************************************************************/
void
PS_PLOTTER
::
flash_pad_circle
(
wxPoint
pos
,
int
diametre
,
GRTraceMode
modetrace
)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y
/* Plot round pad or via.
*/
void
PS_PLOTTER
::
flash_pad_circle
(
wxPoint
pos
,
int
diametre
,
GRTraceMode
modetrace
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
if
(
modetrace
==
FILLED
)
{
set_current_line_width
(
0
);
circle
(
pos
,
diametre
,
FILLED_SHAPE
);
set_current_line_width
(
0
);
circle
(
pos
,
diametre
,
FILLED_SHAPE
);
}
else
{
set_current_line_width
(
-
1
);
int
w
=
current_pen_width
;
circle
(
pos
,
diametre
-
2
*
w
,
NO_FILL
);
set_current_line_width
(
-
1
);
int
w
=
current_pen_width
;
circle
(
pos
,
diametre
-
2
*
w
,
NO_FILL
);
}
}
/**************************************************************************/
void
PS_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
/**************************************************************************/
/*
* Trace 1 pad rectangulaire d'orientation quelconque
* donne par son centre, ses dimensions,
* et son orientation orient
/* Plot rectangular pad in any orientation.
*/
void
PS_PLOTTER
::
flash_pad_rect
(
wxPoint
pos
,
wxSize
size
,
int
orient
,
GRTraceMode
trace_mode
)
{
wxASSERT
(
output_file
);
wxASSERT
(
output_file
);
set_current_line_width
(
-
1
);
set_current_line_width
(
-
1
);
int
w
=
current_pen_width
;
size
.
x
-=
w
;
if
(
size
.
x
<
1
)
size
.
x
=
1
;
size
.
x
=
1
;
size
.
y
-=
w
;
if
(
size
.
y
<
1
)
size
.
y
=
1
;
size
.
y
=
1
;
int
dx
=
size
.
x
/
2
;
int
dy
=
size
.
y
/
2
;
int
dx
=
size
.
x
/
2
;
int
dy
=
size
.
y
/
2
;
int
coord
[
10
]
=
{
pos
.
x
-
dx
,
pos
.
y
+
dy
,
pos
.
x
-
dx
,
pos
.
y
-
dy
,
pos
.
x
+
dx
,
pos
.
y
-
dy
,
pos
.
x
+
dx
,
pos
.
y
+
dy
,
0
,
0
int
coord
[
10
]
=
{
pos
.
x
-
dx
,
pos
.
y
+
dy
,
pos
.
x
-
dx
,
pos
.
y
-
dy
,
pos
.
x
+
dx
,
pos
.
y
-
dy
,
pos
.
x
+
dx
,
pos
.
y
+
dy
,
0
,
0
};
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
RotatePoint
(
&
coord
[
ii
*
2
],
&
coord
[
ii
*
2
+
1
],
pos
.
x
,
pos
.
y
,
orient
);
RotatePoint
(
&
coord
[
ii
*
2
],
&
coord
[
ii
*
2
+
1
],
pos
.
x
,
pos
.
y
,
orient
);
}
coord
[
8
]
=
coord
[
0
];
coord
[
9
]
=
coord
[
1
];
poly
(
5
,
coord
,
trace_mode
==
FILLED
?
FILLED_SHAPE
:
NO_FILL
);
poly
(
5
,
coord
,
(
trace_mode
==
FILLED
)
?
FILLED_SHAPE
:
NO_FILL
);
}
/*******************************************************************/
void
PS_PLOTTER
::
flash_pad_trapez
(
wxPoint
centre
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
modetrace
)
/*******************************************************************/
/*
* Trace 1 pad trapezoidal donne par :
* son centre centre
* ses dimensions size
* les variations delta ( 1 des deux au moins doit etre nulle)
* son orientation orient en 0.1 degres
* le mode de trace (FILLED, SKETCH, FILAIRE)
/* Plot trapezoidal pad.
* Pos is pad center
* Dimensions size.x and size.y
* Changes delta.x and delta.y (1 of at least two must be zero)
* Orientation east to 0.1 degrees
* Plot mode (FILLED, SKETCH, WIRED)
*
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
* The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
*
*
les notation des sommets sont ( vis a vis de la table tracante
)
*
The rating of the vertexes are (vis a vis the plotter
)
*
* " 0 ------------- 3 "
* " . . "
...
...
@@ -512,7 +492,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " 1 ---- 2 "
*
*
*
exemple de Disposition pour deltaY > 0, deltaX
= 0
*
Example delta.y > 0, delta.x
= 0
* " 1 ---- 2 "
* " . . "
* " . O . "
...
...
@@ -520,7 +500,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " 0 ------------- 3 "
*
*
*
exemple de Disposition pour deltaY = 0, deltaX
> 0
*
Example delta.y = 0, delta.x
> 0
* " 0 "
* " . . "
* " . . "
...
...
@@ -533,33 +513,37 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " . . "
* " 1 "
*/
void
PS_PLOTTER
::
flash_pad_trapez
(
wxPoint
centre
,
wxSize
size
,
wxSize
delta
,
int
orient
,
GRTraceMode
modetrace
)
{
wxASSERT
(
output_file
);
set_current_line_width
(
-
1
);
wxASSERT
(
output_file
);
set_current_line_width
(
-
1
);
int
w
=
current_pen_width
;
int
dx
,
dy
;
int
ddx
,
ddy
;
int
dx
,
dy
;
int
ddx
,
ddy
;
dx
=
(
size
.
x
-
w
)
/
2
;
dy
=
(
size
.
y
-
w
)
/
2
;
dx
=
(
size
.
x
-
w
)
/
2
;
dy
=
(
size
.
y
-
w
)
/
2
;
ddx
=
delta
.
x
/
2
;
ddy
=
delta
.
y
/
2
;
int
coord
[
10
]
=
{
-
dx
-
ddy
,
+
dy
+
ddx
,
-
dx
+
ddy
,
-
dy
-
ddx
,
+
dx
-
ddy
,
-
dy
+
ddx
,
+
dx
+
ddy
,
+
dy
-
ddx
,
0
,
0
int
coord
[
10
]
=
{
-
dx
-
ddy
,
+
dy
+
ddx
,
-
dx
+
ddy
,
-
dy
-
ddx
,
+
dx
-
ddy
,
-
dy
+
ddx
,
+
dx
+
ddy
,
+
dy
-
ddx
,
0
,
0
};
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
RotatePoint
(
&
coord
[
ii
*
2
],
&
coord
[
ii
*
2
+
1
],
orient
);
coord
[
ii
*
2
]
+=
centre
.
x
;
coord
[
ii
*
2
+
1
]
+=
centre
.
y
;
RotatePoint
(
&
coord
[
ii
*
2
],
&
coord
[
ii
*
2
+
1
],
orient
);
coord
[
ii
*
2
]
+=
centre
.
x
;
coord
[
ii
*
2
+
1
]
+=
centre
.
y
;
}
coord
[
8
]
=
coord
[
0
];
coord
[
9
]
=
coord
[
1
];
poly
(
5
,
coord
,
modetrace
==
FILLED
?
FILLED_SHAPE
:
NO_FILL
);
poly
(
5
,
coord
,
(
modetrace
==
FILLED
)
?
FILLED_SHAPE
:
NO_FILL
);
}
common/common_plot_functions.cpp
View file @
bc5d9a75
...
...
@@ -14,13 +14,11 @@
#include "class_base_screen.h"
#include "drawtxt.h"
/**************************************************************************/
void
WinEDA_DrawFrame
::
PlotWorkSheet
(
PLOTTER
*
plotter
,
BASE_SCREEN
*
screen
)
/**************************************************************************/
/* Plot sheet references
* margin is in mils (1/1000 inch)
*/
void
WinEDA_DrawFrame
::
PlotWorkSheet
(
PLOTTER
*
plotter
,
BASE_SCREEN
*
screen
)
{
#define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr
*
Sheet
=
screen
->
m_CurrentSheetDesc
;
...
...
@@ -28,14 +26,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
wxSize
PageSize
;
wxPoint
pos
,
ref
;
EDA_Colors
color
;
int
conv_unit
=
screen
->
GetInternalUnits
()
/
1000
;
/* Scale to convert dimension in 1/1000 in into internal units
* (1/1000 inc for EESchema, 1/10000 for pcbnew */
wxString
msg
;
wxSize
text_size
;
int
UpperLimit
=
VARIABLE_BLOCK_START_POSITION
;
bool
italic
=
false
;
bool
bold
=
false
;
bool
thickness
=
0
;
//@todo : use current pen
/* Scale to convert dimension in 1/1000 in into internal units
* (1/1000 inc for EESchema, 1/10000 for pcbnew. */
int
conv_unit
=
screen
->
GetInternalUnits
()
/
1000
;
wxString
msg
;
wxSize
text_size
;
int
UpperLimit
=
VARIABLE_BLOCK_START_POSITION
;
bool
italic
=
false
;
bool
bold
=
false
;
bool
thickness
=
0
;
//@todo : use current pen
color
=
BLACK
;
plotter
->
set_color
(
color
);
...
...
@@ -43,30 +43,36 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
PageSize
.
x
=
Sheet
->
m_Size
.
x
;
PageSize
.
y
=
Sheet
->
m_Size
.
y
;
/*
trace de la bordure
*/
/*
Plot edge.
*/
ref
.
x
=
Sheet
->
m_LeftMargin
*
conv_unit
;
ref
.
y
=
Sheet
->
m_TopMargin
*
conv_unit
;
/* Upper left corner */
xg
=
(
PageSize
.
x
-
Sheet
->
m_RightMargin
)
*
conv_unit
;
yg
=
(
PageSize
.
y
-
Sheet
->
m_BottomMargin
)
*
conv_unit
;
/* lower right corner */
ref
.
y
=
Sheet
->
m_TopMargin
*
conv_unit
;
xg
=
(
PageSize
.
x
-
Sheet
->
m_RightMargin
)
*
conv_unit
;
yg
=
(
PageSize
.
y
-
Sheet
->
m_BottomMargin
)
*
conv_unit
;
#if defined(KICAD_GOST)
plotter
->
move_to
(
ref
);
pos
.
x
=
xg
;
pos
.
y
=
ref
.
y
;
pos
.
x
=
xg
;
pos
.
y
=
ref
.
y
;
plotter
->
line_to
(
pos
);
pos
.
x
=
xg
;
pos
.
y
=
yg
;
pos
.
x
=
xg
;
pos
.
y
=
yg
;
plotter
->
line_to
(
pos
);
pos
.
x
=
ref
.
x
;
pos
.
y
=
yg
;
pos
.
x
=
ref
.
x
;
pos
.
y
=
yg
;
plotter
->
line_to
(
pos
);
plotter
->
finish_to
(
ref
);
#else
for
(
unsigned
ii
=
0
;
ii
<
2
;
ii
++
)
{
plotter
->
move_to
(
ref
);
pos
.
x
=
xg
;
pos
.
y
=
ref
.
y
;
pos
.
x
=
xg
;
pos
.
y
=
ref
.
y
;
plotter
->
line_to
(
pos
);
pos
.
x
=
xg
;
pos
.
y
=
yg
;
pos
.
x
=
xg
;
pos
.
y
=
yg
;
plotter
->
line_to
(
pos
);
pos
.
x
=
ref
.
x
;
pos
.
y
=
yg
;
pos
.
x
=
ref
.
x
;
pos
.
y
=
yg
;
plotter
->
line_to
(
pos
);
plotter
->
finish_to
(
ref
);
ref
.
x
+=
GRID_REF_W
*
conv_unit
;
...
...
@@ -77,22 +83,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif
/* trace des reperes */
text_size
.
x
=
WSTEXTSIZE
*
conv_unit
;
text_size
.
y
=
WSTEXTSIZE
*
conv_unit
;
ref
.
x
=
Sheet
->
m_LeftMargin
;
ref
.
y
=
Sheet
->
m_TopMargin
;
/* Upper left corner in 1/1000 inch */
xg
=
(
PageSize
.
x
-
Sheet
->
m_RightMargin
);
yg
=
(
PageSize
.
y
-
Sheet
->
m_BottomMargin
);
/* lower right corner in 1/1000 inch */
ref
.
y
=
Sheet
->
m_TopMargin
;
/* Upper left corner in
* 1/1000 inch */
xg
=
(
PageSize
.
x
-
Sheet
->
m_RightMargin
);
yg
=
(
PageSize
.
y
-
Sheet
->
m_BottomMargin
);
/* lower right corner
* in 1/1000 inch */
#if defined(KICAD_GOST)
for
(
Ki_WorkSheetData
*
WsItem
=
&
WS_Segm1_LU
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
yg
-
WsItem
->
m_Posy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
yg
-
WsItem
->
m_Posy
)
*
conv_unit
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
...
...
@@ -110,8 +117,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case
WS_SEGMENT_LU
:
plotter
->
move_to
(
pos
);
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
yg
-
WsItem
->
m_Endy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
yg
-
WsItem
->
m_Endy
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
break
;
}
...
...
@@ -121,15 +128,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
ref
.
x
+
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
WsItem
->
m_Posy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
+
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
WsItem
->
m_Posy
)
*
conv_unit
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
case
WS_SEGMENT_LT
:
plotter
->
move_to
(
pos
);
pos
.
x
=
(
ref
.
x
+
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
WsItem
->
m_Endy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
+
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
WsItem
->
m_Endy
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
break
;
}
...
...
@@ -137,21 +144,26 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#else
/*
Trace des reperes selon l'axe X
*/
ipas
=
(
xg
-
ref
.
x
)
/
PAS_REF
;
gxpas
=
(
xg
-
ref
.
x
)
/
ipas
;
/*
Plot legend along the X axis.
*/
ipas
=
(
xg
-
ref
.
x
)
/
PAS_REF
;
gxpas
=
(
xg
-
ref
.
x
)
/
ipas
;
for
(
int
ii
=
ref
.
x
+
gxpas
,
jj
=
1
;
ipas
>
0
;
ii
+=
gxpas
,
jj
++
,
ipas
--
)
{
msg
.
Empty
();
msg
<<
jj
;
msg
.
Empty
();
msg
<<
jj
;
if
(
ii
<
xg
-
PAS_REF
/
2
)
{
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
ref
.
y
*
conv_unit
;
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
ref
.
y
*
conv_unit
;
plotter
->
move_to
(
pos
);
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
GRID_REF_W
)
*
conv_unit
;
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
GRID_REF_W
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
}
pos
.
x
=
(
ii
-
gxpas
/
2
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
x
=
(
ii
-
gxpas
/
2
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
+
GRID_REF_W
/
2
)
*
conv_unit
;
plotter
->
text
(
pos
,
color
,
msg
,
TEXT_ORIENT_HORIZ
,
text_size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
...
...
@@ -159,37 +171,41 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
if
(
ii
<
xg
-
PAS_REF
/
2
)
{
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
yg
*
conv_unit
;
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
yg
*
conv_unit
;
plotter
->
move_to
(
pos
);
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
(
yg
-
GRID_REF_W
)
*
conv_unit
;
pos
.
x
=
ii
*
conv_unit
;
pos
.
y
=
(
yg
-
GRID_REF_W
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
}
pos
.
x
=
(
ii
-
gxpas
/
2
)
*
conv_unit
;
pos
.
y
=
(
yg
-
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
x
=
(
ii
-
gxpas
/
2
)
*
conv_unit
;
pos
.
y
=
(
yg
-
GRID_REF_W
/
2
)
*
conv_unit
;
plotter
->
text
(
pos
,
color
,
msg
,
TEXT_ORIENT_HORIZ
,
text_size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
thickness
,
italic
,
false
);
}
/*
Trace des reperes selon l'axe Y
*/
ipas
=
(
yg
-
ref
.
y
)
/
PAS_REF
;
gypas
=
(
yg
-
ref
.
y
)
/
ipas
;
/*
Plot legend along the Y axis.
*/
ipas
=
(
yg
-
ref
.
y
)
/
PAS_REF
;
gypas
=
(
yg
-
ref
.
y
)
/
ipas
;
for
(
int
ii
=
ref
.
y
+
gypas
,
jj
=
0
;
ipas
>
0
;
ii
+=
gypas
,
jj
++
,
ipas
--
)
{
if
(
jj
<
26
)
msg
.
Printf
(
wxT
(
"%c"
),
jj
+
'A'
);
else
// I hope 52 identifiers are enough
t
...
else
// I hope 52 identifiers are enough...
msg
.
Printf
(
wxT
(
"%c"
),
'a'
+
jj
-
26
);
if
(
ii
<
yg
-
PAS_REF
/
2
)
{
pos
.
x
=
ref
.
x
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
pos
.
x
=
ref
.
x
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
plotter
->
move_to
(
pos
);
pos
.
x
=
(
ref
.
x
+
GRID_REF_W
)
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
pos
.
x
=
(
ref
.
x
+
GRID_REF_W
)
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
plotter
->
finish_to
(
pos
);
}
pos
.
x
=
(
ref
.
x
+
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
y
=
(
ii
-
gypas
/
2
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
+
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
y
=
(
ii
-
gypas
/
2
)
*
conv_unit
;
plotter
->
text
(
pos
,
color
,
msg
,
TEXT_ORIENT_HORIZ
,
text_size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
...
...
@@ -197,13 +213,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
if
(
ii
<
yg
-
PAS_REF
/
2
)
{
pos
.
x
=
xg
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
pos
.
x
=
xg
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
plotter
->
move_to
(
pos
);
pos
.
x
=
(
xg
-
GRID_REF_W
)
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
pos
.
x
=
(
xg
-
GRID_REF_W
)
*
conv_unit
;
pos
.
y
=
ii
*
conv_unit
;
plotter
->
finish_to
(
pos
);
}
pos
.
x
=
(
xg
-
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
y
=
(
ii
-
gypas
/
2
)
*
conv_unit
;
pos
.
x
=
(
xg
-
GRID_REF_W
/
2
)
*
conv_unit
;
pos
.
y
=
(
ii
-
gypas
/
2
)
*
conv_unit
;
plotter
->
text
(
pos
,
color
,
msg
,
TEXT_ORIENT_HORIZ
,
text_size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
thickness
,
italic
,
false
);
...
...
@@ -211,21 +230,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif
/*
Trace du cartouche
*/
/*
Plot the worksheet.
*/
text_size
.
x
=
SIZETEXT
*
conv_unit
;
text_size
.
y
=
SIZETEXT
*
conv_unit
;
#if defined(KICAD_GOST)
ref
.
x
=
PageSize
.
x
-
Sheet
->
m_RightMargin
;
ref
.
y
=
PageSize
.
y
-
Sheet
->
m_BottomMargin
;
if
(
screen
->
m_ScreenNumber
==
1
)
{
for
(
Ki_WorkSheetData
*
WsItem
=
&
WS_Date
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
case
WS_DATE
:
...
...
@@ -288,8 +309,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case
WS_LEFT_SEGMENT
:
case
WS_SEGMENT
:
plotter
->
move_to
(
pos
);
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
break
;
}
...
...
@@ -301,9 +322,10 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
case
WS_CADRE
:
...
...
@@ -328,8 +350,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case
WS_LEFT_SEGMENT_D
:
case
WS_SEGMENT_D
:
plotter
->
move_to
(
pos
);
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;
plotter
->
finish_to
(
pos
);
break
;
}
...
...
@@ -343,8 +365,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
pos
.
x
=
(
ref
.
x
-
WsItem
->
m_Posx
)
*
conv_unit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
bold
=
false
;
if
(
WsItem
->
m_Legende
)
msg
=
WsItem
->
m_Legende
;
...
...
@@ -372,13 +394,17 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
break
;
case
WS_IDENTSHEET
:
msg
<<
screen
->
m_ScreenNumber
<<
wxT
(
"/"
)
<<
screen
->
m_NumberOfScreen
;
msg
<<
screen
->
m_ScreenNumber
<<
wxT
(
"/"
)
<<
screen
->
m_NumberOfScreen
;
break
;
case
WS_FILENAME
:
{
wxString
fname
,
fext
;
wxFileName
::
SplitPath
(
screen
->
m_FileName
,
(
wxString
*
)
NULL
,
&
fname
,
&
fext
);
wxFileName
::
SplitPath
(
screen
->
m_FileName
,
(
wxString
*
)
NULL
,
&
fname
,
&
fext
);
msg
<<
fname
<<
wxT
(
"."
)
<<
fext
;
}
break
;
...
...
@@ -428,16 +454,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
break
;
case
WS_LEFT_SEGMENT
:
WS_MostUpperLine
.
m_Posy
=
WS_MostUpperLine
.
m_Endy
=
WS_MostLeftLine
.
m_Posy
=
UpperLimit
;
WS_MostUpperLine
.
m_Posy
=
WS_MostUpperLine
.
m_Endy
=
WS_MostLeftLine
.
m_Posy
=
UpperLimit
;
pos
.
y
=
(
ref
.
y
-
WsItem
->
m_Posy
)
*
conv_unit
;
case
WS_SEGMENT
:
{
wxPoint
auxpos
;
auxpos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;;
auxpos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;;
auxpos
.
x
=
(
ref
.
x
-
WsItem
->
m_Endx
)
*
conv_unit
;;
auxpos
.
y
=
(
ref
.
y
-
WsItem
->
m_Endy
)
*
conv_unit
;;
plotter
->
move_to
(
pos
);
plotter
->
finish_to
(
auxpos
);
}
...
...
@@ -455,4 +480,3 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif
}
common/confirm.cpp
View file @
bc5d9a75
/************************
*
/
/* Menu "
CONFIRMATION "
*/
/*
fonction Get_Message
*/
/*
test demande ESC
*/
/************************
*
/
/************************/
/* Menu "
CONFIRMATION"
*/
/*
Function get_Message
*/
/*
Test requires ESC
*/
/************************/
#include "fctsys.h"
#include "common.h"
...
...
@@ -11,8 +11,17 @@ enum id_dialog {
ID_TIMOUT
=
1500
};
/* Classe d'affichage de messages, identique a wxMessageDialog,
* mais pouvant etre effacee au bout d'un time out donne
/* Class for displaying messages, similar to wxMessageDialog,
* but can be erased after a time out expires.
*
* @note - Do not use the time feature. It is broken by design because
* the dialog is shown as modal and wxWidgets will assert when
* compiled in the debug mode. This is because the dialog steals
* the event queue when dialog is modal so the timer event never
* gets to the dialog event handle. Using dialogs to display
* transient is brain dead anyway. Use the message panel or some
* other method.
*/
class
WinEDA_MessageDialog
:
public
wxMessageDialog
{
...
...
@@ -34,35 +43,35 @@ BEGIN_EVENT_TABLE( WinEDA_MessageDialog, wxMessageDialog )
EVT_TIMER
(
ID_TIMOUT
,
WinEDA_MessageDialog
::
OnTimeOut
)
END_EVENT_TABLE
()
/**********************************************************************************/
WinEDA_MessageDialog
::
WinEDA_MessageDialog
(
wxWindow
*
parent
,
const
wxString
&
msg
,
const
wxString
&
title
,
int
style
,
int
lifetime
)
:
WinEDA_MessageDialog
::
WinEDA_MessageDialog
(
wxWindow
*
parent
,
const
wxString
&
msg
,
const
wxString
&
title
,
int
style
,
int
lifetime
)
:
wxMessageDialog
(
parent
,
msg
,
title
,
style
)
/**********************************************************************************/
{
m_LifeTime
=
lifetime
;
m_Timer
.
SetOwner
(
this
,
ID_TIMOUT
);
if
(
m_LifeTime
>
0
)
m_Timer
.
Start
(
100
*
m_LifeTime
,
wxTIMER_ONE_SHOT
);
// m_LifeTime = duree en 0.1 secondes
m_Timer
.
Start
(
100
*
m_LifeTime
,
wxTIMER_ONE_SHOT
);
}
/********************************************************/
void
WinEDA_MessageDialog
::
OnTimeOut
(
wxTimerEvent
&
event
)
/********************************************************/
{
m_Timer
.
Stop
();
EndModal
(
wxID_YES
);
// Does not work, I do not know why (this function is correctly called after time out)
EndModal
(
wxID_YES
);
/* Does not work, I do not know why (this
* function is correctly called after time out).
* See not above as to why this doesn't work. */
}
/*****************************************************************************/
void
DisplayError
(
wxWindow
*
parent
,
const
wxString
&
text
,
int
displaytime
)
/*****************************************************************************/
/* Affiche un Message d'Erreur ou d'avertissement.
* si warn > 0 le dialogue disparait apres displaytime * 0.1 secondes
/* Display an error or warning message.
* If display time > 0 the dialog disappears after displayTime 0.1 seconds
*
*/
void
DisplayError
(
wxWindow
*
parent
,
const
wxString
&
text
,
int
displaytime
)
{
wxMessageDialog
*
dialog
;
...
...
@@ -79,13 +88,10 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
}
/**************************************************************************/
void
DisplayInfoMessage
(
wxWindow
*
parent
,
const
wxString
&
text
,
int
displaytime
)
/**************************************************************************/
/* Affiche un Message d'information.
/* Display an informational message.
*/
void
DisplayInfoMessage
(
wxWindow
*
parent
,
const
wxString
&
text
,
int
displaytime
)
{
wxMessageDialog
*
dialog
;
...
...
@@ -97,9 +103,7 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime
}
/**************************************************/
bool
IsOK
(
wxWindow
*
parent
,
const
wxString
&
text
)
/**************************************************/
{
int
ii
;
...
...
@@ -111,22 +115,19 @@ bool IsOK( wxWindow* parent, const wxString& text )
}
/***********************************************************************/
/* Get a text from user
* Title = title to display
* Buffer: enter text by user
* Leading and trailing spaces are removed
* If buffer != "Buffer is displayed
* Return:
* 0 if OK
* 0 if ESCAPE
*/
int
Get_Message
(
const
wxString
&
title
,
// The question
const
wxString
&
frame_caption
,
// The frame caption
wxString
&
buffer
,
// String input/return buffer
wxWindow
*
frame
)
/***********************************************************************/
/* Get a text from user
* titre = titre a afficher
* buffer : text enter by user
* leading and trailing spaces are removed
* if buffer != "" buffer is displayed
* return:
* 0 if OK
* != 0 if ESCAPE
*/
{
wxString
message
;
...
...
common/copy_to_clipboard.cpp
View file @
bc5d9a75
/////////////////////////////////////////////////////////////////////////////
// Name: copy_to_clipboard.cpp
// Author: jean-pierre Charras
// Created: 18 aug 2006
// Licence: License GNU
// Licence:
License GNU
/////////////////////////////////////////////////////////////////////////////
#include "wx/metafile.h"
...
...
@@ -24,12 +23,11 @@ static const bool Print_Sheet_Ref = TRUE;
static
bool
DrawPage
(
WinEDA_DrawPanel
*
panel
);
/************************************************************/
void
WinEDA_DrawFrame
::
CopyToClipboard
(
wxCommandEvent
&
event
)
/************************************************************/
/* calls the function to copy the current page or the current bock to the clipboard
/* calls the function to copy the current page or the current bock to
* the clipboard
*/
void
WinEDA_DrawFrame
::
CopyToClipboard
(
wxCommandEvent
&
event
)
{
DrawPage
(
DrawPanel
);
...
...
@@ -50,14 +48,11 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )
}
/*****************************************************************/
bool
DrawPage
(
WinEDA_DrawPanel
*
panel
)
/*****************************************************************/
/* copy the current page or block to the clipboard ,
* to export drawings to other applications (word processing ...)
* Thi is not suitable for copy command within eeschema or pcbnew
* Thi
s
is not suitable for copy command within eeschema or pcbnew
*/
bool
DrawPage
(
WinEDA_DrawPanel
*
panel
)
{
bool
success
=
TRUE
;
...
...
@@ -65,7 +60,7 @@ bool DrawPage( WinEDA_DrawPanel* panel )
int
tmpzoom
;
wxPoint
tmp_startvisu
;
wxPoint
old_org
;
wxPoint
DrawOffset
;
// Offset de trace
wxPoint
DrawOffset
;
int
ClipboardSizeX
,
ClipboardSizeY
;
bool
DrawBlock
=
FALSE
;
wxRect
DrawArea
;
...
...
@@ -83,7 +78,7 @@ bool DrawPage( WinEDA_DrawPanel* panel )
DrawArea
.
SetHeight
(
ActiveScreen
->
m_BlockLocate
.
GetHeight
()
);
}
/*
modification des cadrages et reglages locaux
*/
/*
Change frames and local settings.
*/
tmp_startvisu
=
ActiveScreen
->
m_StartVisu
;
tmpzoom
=
ActiveScreen
->
GetZoom
();
old_org
=
ActiveScreen
->
m_DrawOrg
;
...
...
@@ -102,16 +97,19 @@ bool DrawPage( WinEDA_DrawPanel* panel )
ClipboardSizeX
=
dc
.
MaxX
()
+
10
;
ClipboardSizeY
=
dc
.
MaxY
()
+
10
;
panel
->
m_ClipBox
.
SetX
(
0
);
panel
->
m_ClipBox
.
SetY
(
0
);
panel
->
m_ClipBox
.
SetWidth
(
0x7FFFFF0
);
panel
->
m_ClipBox
.
SetHeight
(
0x7FFFFF0
);
panel
->
m_ClipBox
.
SetWidth
(
0x7FFFFF0
);
panel
->
m_ClipBox
.
SetHeight
(
0x7FFFFF0
);
if
(
DrawBlock
)
{
dc
.
SetClippingRegion
(
DrawArea
);
}
panel
->
PrintPage
(
&
dc
,
Print_Sheet_Ref
,
-
1
,
false
);
screen
->
m_IsPrinting
=
false
;
panel
->
m_ClipBox
=
tmp
;
wxMetafile
*
mf
=
dc
.
Close
();
if
(
mf
)
{
success
=
mf
->
SetClipboard
(
ClipboardSizeX
,
ClipboardSizeY
);
...
...
common/displlst.cpp
View file @
bc5d9a75
/****************
****************
/
/*
MODULE displlst.cpp
*/
/****************
****************
/
/****************/
/*
displlst.cpp
*/
/****************/
#include "fctsys.h"
#include "wxstruct.h"
...
...
@@ -10,14 +10,11 @@
#include "kicad_string.h"
/***********************/
/* class WinEDAListBox */
/***********************/
enum
listbox
{
ID_LISTBOX_LIST
=
8000
};
BEGIN_EVENT_TABLE
(
WinEDAListBox
,
wxDialog
)
EVT_BUTTON
(
wxID_OK
,
WinEDAListBox
::
OnOkClick
)
EVT_BUTTON
(
wxID_CANCEL
,
WinEDAListBox
::
OnCancelClick
)
...
...
@@ -29,16 +26,11 @@ BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog )
END_EVENT_TABLE
()
/*******************************/
/* Constructeur et destructeur */
/*******************************/
/* Permet l'affichage d'une liste d'elements pour selection.
* itemlist = pointeur sur la liste des pinteurs de noms
* reftext = preselection
* movefct = fonction de cration de commentaires a afficher
/* Used to display a list of elements for selection.
* ITEMLIST* = pointer to the list of names
* = Reftext preselection
* = Movefct callback function to display comments
*/
WinEDAListBox
::
WinEDAListBox
(
WinEDA_DrawFrame
*
parent
,
const
wxString
&
title
,
const
wxChar
**
itemlist
,
const
wxString
&
reftext
,
void
(
*
movefct
)(
wxString
&
Text
)
,
...
...
@@ -126,9 +118,7 @@ WinEDAListBox::~WinEDAListBox()
}
/******************************************/
void
WinEDAListBox
::
MoveMouseToOrigin
()
/******************************************/
{
int
x
,
y
,
w
,
h
;
wxSize
list_size
=
m_List
->
GetSize
();
...
...
@@ -141,9 +131,7 @@ void WinEDAListBox::MoveMouseToOrigin()
}
/*********************************************/
wxString
WinEDAListBox
::
GetTextSelection
()
/*********************************************/
{
wxString
text
=
m_List
->
GetStringSelection
();
...
...
@@ -151,33 +139,25 @@ wxString WinEDAListBox::GetTextSelection()
}
/***************************************************************/
void
WinEDAListBox
::
Append
(
const
wxString
&
item
)
/***************************************************************/
{
m_List
->
Append
(
item
);
}
/******************************************************************************/
void
WinEDAListBox
::
InsertItems
(
const
wxArrayString
&
itemlist
,
int
position
)
/******************************************************************************/
{
m_List
->
InsertItems
(
itemlist
,
position
);
}
/************************************************/
void
WinEDAListBox
::
OnCancelClick
(
wxCommandEvent
&
event
)
/************************************************/
{
EndModal
(
-
1
);
}
/*****************************************************/
void
WinEDAListBox
::
ClickOnList
(
wxCommandEvent
&
event
)
/*****************************************************/
{
wxString
text
;
...
...
@@ -191,9 +171,7 @@ void WinEDAListBox::ClickOnList( wxCommandEvent& event )
}
/*******************************************************/
void
WinEDAListBox
::
D_ClickOnList
(
wxCommandEvent
&
event
)
/*******************************************************/
{
int
ii
=
m_List
->
GetSelection
();
...
...
@@ -201,9 +179,7 @@ void WinEDAListBox::D_ClickOnList( wxCommandEvent& event )
}
/***********************************************/
void
WinEDAListBox
::
OnOkClick
(
wxCommandEvent
&
event
)
/***********************************************/
{
int
ii
=
m_List
->
GetSelection
();
...
...
@@ -211,29 +187,21 @@ void WinEDAListBox::OnOkClick( wxCommandEvent& event )
}
/***********************************************/
void
WinEDAListBox
::
OnClose
(
wxCloseEvent
&
event
)
/***********************************************/
{
EndModal
(
-
1
);
}
/********************************************************************/
static
int
SortItems
(
const
wxString
**
ptr1
,
const
wxString
**
ptr2
)
/********************************************************************/
/* Routines de comparaison pour le tri tri alphabetique,
* avec traitement des nombres en tant que valeur numerique
/* Sort alphabetically, case insensitive.
*/
static
int
SortItems
(
const
wxString
**
ptr1
,
const
wxString
**
ptr2
)
{
return
StrNumICmp
(
(
*
ptr1
)
->
GetData
(),
(
*
ptr2
)
->
GetData
()
);
}
/************************************/
void
WinEDAListBox
::
SortList
()
/************************************/
{
int
ii
,
NbItems
=
m_List
->
GetCount
();
const
wxString
**
BufList
;
...
...
@@ -261,9 +229,7 @@ void WinEDAListBox:: SortList()
}
/****************************************************/
void
WinEDAListBox
::
OnKeyEvent
(
wxKeyEvent
&
event
)
/****************************************************/
{
event
.
Skip
();
}
common/drawframe.cpp
View file @
bc5d9a75
/*****************
*************************************************
/
/* drawframe.cpp
- fonctions des classes du type WinEDA_DrawFrame
*/
/*****************
*************************************************
/
/*****************/
/* drawframe.cpp */
/*****************/
#ifdef __GNUG__
#pragma implementation
...
...
@@ -38,10 +38,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
END_EVENT_TABLE
()
/*******************************************************/
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/*******************************************************/
WinEDA_DrawFrame
::
WinEDA_DrawFrame
(
wxWindow
*
father
,
int
idtype
,
const
wxString
&
title
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
...
...
@@ -63,11 +59,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_ID_current_state
=
0
;
m_ID_last_state
=
0
;
m_HTOOL_current_state
=
0
;
m_Draw_Axis
=
FALSE
;
// TRUE
pour avoir les axes dessines
m_Draw_Grid
=
FALSE
;
// TRUE
pour avoir la axes dessinee
m_Draw_Sheet_Ref
=
FALSE
;
// TRUE
pour avoir le cartouche dessin�
m_Print_Sheet_Ref
=
TRUE
;
// TRUE
pour avoir le cartouche imprim�
m_Draw_Auxiliary_Axis
=
FALSE
;
// TRUE
pour avoir les axes auxiliares dessines
m_Draw_Axis
=
FALSE
;
// TRUE
to draw axis.
m_Draw_Grid
=
FALSE
;
// TRUE
to show grid.
m_Draw_Sheet_Ref
=
FALSE
;
// TRUE
to display reference sheet.
m_Print_Sheet_Ref
=
TRUE
;
// TRUE
to print reference sheet.
m_Draw_Auxiliary_Axis
=
FALSE
;
// TRUE
draw auxilary axis.
m_UnitType
=
INTERNAL_UNIT_TYPE
;
// Internal unit = inch
m_CursorShape
=
0
;
m_LastGridSizeId
=
0
;
...
...
@@ -79,11 +75,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
SetSizeHints
(
minsize
.
x
,
minsize
.
y
,
-
1
,
-
1
,
-
1
,
-
1
);
/*
Verification des parametres de creation
*/
/*
Make sure window has a sane minimum size.
*/
if
(
(
size
.
x
<
minsize
.
x
)
||
(
size
.
y
<
minsize
.
y
)
)
SetSize
(
0
,
0
,
minsize
.
x
,
minsize
.
y
);
//
Creation de la ligne de status
//
Pane sizes for status bar.
#define ZOOM_DISPLAY_SIZE 60
#define COORD_DISPLAY_SIZE 156
#define UNITS_DISPLAY_SIZE 50
...
...
@@ -97,8 +93,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
SetStatusWidths
(
6
,
dims
);
// Create child subwindows.
GetClientSize
(
&
m_FrameSize
.
x
,
&
m_FrameSize
.
y
);
/* dimx, dimy = dimensions utiles de la
* zone utilisateur de la fenetre principale */
GetClientSize
(
&
m_FrameSize
.
x
,
&
m_FrameSize
.
y
);
m_FramePos
.
x
=
m_FramePos
.
y
=
0
;
m_FrameSize
.
y
-=
m_MsgFrameHeight
;
...
...
@@ -123,30 +118,23 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame()
}
/**************************************************************/
void
WinEDA_DrawFrame
::
Affiche_Message
(
const
wxString
&
message
)
/**************************************************************/
/*
* Display the message
on the bottom the frame
* Display the message
in the first pane of the status bar.
*/
void
WinEDA_DrawFrame
::
Affiche_Message
(
const
wxString
&
message
)
{
SetStatusText
(
message
,
0
);
}
/****************************************/
void
WinEDA_DrawFrame
::
EraseMsgBox
()
/****************************************/
{
if
(
MsgPanel
)
MsgPanel
->
EraseMsgBox
();
}
/*******************************************************/
void
WinEDA_DrawFrame
::
OnActivate
(
wxActivateEvent
&
event
)
/*******************************************************/
{
m_FrameIsActive
=
event
.
GetActive
();
if
(
DrawPanel
)
...
...
@@ -156,9 +144,7 @@ void WinEDA_DrawFrame::OnActivate( wxActivateEvent& event )
}
/****************************************************/
void
WinEDA_DrawFrame
::
OnMenuOpen
(
wxMenuEvent
&
event
)
/****************************************************/
{
if
(
DrawPanel
)
DrawPanel
->
m_CanStartBlock
=
-
1
;
...
...
@@ -166,35 +152,27 @@ void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event )
}
/*******************************************************/
void
WinEDA_DrawFrame
::
ReCreateAuxiliaryToolbar
()
/*******************************************************/
// Virtual function
void
WinEDA_DrawFrame
::
ReCreateAuxiliaryToolbar
()
{
}
/********************************************/
void
WinEDA_DrawFrame
::
ReCreateMenuBar
()
/********************************************/
// Virtual function
void
WinEDA_DrawFrame
::
ReCreateMenuBar
()
{
}
/
****************************************************/
/
/ Virtual function
void
WinEDA_DrawFrame
::
OnHotKey
(
wxDC
*
DC
,
int
hotkey
,
EDA_BaseStruct
*
DrawStruct
)
/****************************************************/
// Virtual function
{
}
/**************************************************************/
void
WinEDA_DrawFrame
::
ToolOnRightClick
(
wxCommandEvent
&
event
)
/**************************************************************/
// Virtual function
void
WinEDA_DrawFrame
::
ToolOnRightClick
(
wxCommandEvent
&
event
)
{
}
...
...
@@ -272,14 +250,14 @@ void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
void
WinEDA_DrawFrame
::
OnSelectZoom
(
wxCommandEvent
&
event
)
{
if
(
m_SelZoomBox
==
NULL
)
return
;
//
Ne devrait pas se produire
!
return
;
//
Should not happen
!
int
id
=
m_SelZoomBox
->
GetChoice
();
if
(
id
<
0
||
!
(
id
<
(
int
)
m_SelZoomBox
->
GetCount
()
)
)
return
;
if
(
id
==
0
)
// Auto zoom (Fit in Page)
if
(
id
==
0
)
// Auto zoom (Fit in Page)
{
Zoom_Automatique
(
true
);
}
...
...
@@ -295,35 +273,27 @@ void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event )
}
}
/***********************************/
int
WinEDA_DrawFrame
::
GetZoom
(
void
)
/***********************************/
/* Return the current zoom level */
int
WinEDA_DrawFrame
::
GetZoom
(
void
)
{
return
GetBaseScreen
()
->
GetZoom
();
}
/********************************************************/
void
WinEDA_DrawFrame
::
OnMouseEvent
(
wxMouseEvent
&
event
)
/********************************************************/
{
event
.
Skip
();
}
/***********************************************************************/
// Virtuelle
// Virtual
void
WinEDA_DrawFrame
::
OnLeftDClick
(
wxDC
*
DC
,
const
wxPoint
&
MousePos
)
/***********************************************************************/
{
}
/***************************************/
void
WinEDA_DrawFrame
::
SetToolbars
()
/***************************************/
{
DisplayUnitsMsg
();
...
...
@@ -334,20 +304,15 @@ void WinEDA_DrawFrame::SetToolbars()
}
/********************************************************/
void
WinEDA_DrawFrame
::
DisplayToolMsg
(
const
wxString
&
msg
)
/********************************************************/
{
SetStatusText
(
msg
,
5
);
}
/*******************************************/
void
WinEDA_DrawFrame
::
DisplayUnitsMsg
()
/********************************************/
/* Display current unit Selection on Statusbar
*/
void
WinEDA_DrawFrame
::
DisplayUnitsMsg
()
{
wxString
msg
;
...
...
@@ -370,9 +335,7 @@ void WinEDA_DrawFrame::DisplayUnitsMsg()
}
/***************************************/
void
WinEDA_DrawFrame
::
ReDrawPanel
()
/***************************************/
{
if
(
DrawPanel
==
NULL
)
return
;
...
...
@@ -384,12 +347,9 @@ void WinEDA_DrawFrame::ReDrawPanel()
}
/**************************************************/
void
WinEDA_DrawFrame
::
OnSize
(
wxSizeEvent
&
SizeEv
)
/**************************************************/
/* recalcule les dimensions des toolbars et du panel d'affichage
/* Recalculate the size of toolbars and display panel.
*/
void
WinEDA_DrawFrame
::
OnSize
(
wxSizeEvent
&
SizeEv
)
{
wxSize
size
;
wxSize
opt_size
;
...
...
@@ -401,21 +361,22 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
#if !defined(KICAD_AUIMANAGER)
size
.
y
-=
m_MsgFrameHeight
;
if
(
MsgPanel
)
// Positionnement en bas d'ecran
if
(
MsgPanel
)
// Resize the message panel.
{
MsgPanel
->
SetSize
(
0
,
size
.
y
,
size
.
x
,
m_MsgFrameHeight
);
}
if
(
m_AuxiliaryToolBar
)
// est sous le m_HToolBar
if
(
m_AuxiliaryToolBar
)
// Resize the auxilary horizontal tool bar.
{
Auxtoolbar_size
.
x
=
size
.
x
;
// = Largeur de la frame
Auxtoolbar_size
.
x
=
size
.
x
;
Auxtoolbar_size
.
y
=
m_AuxiliaryToolBar
->
GetSize
().
y
;
m_AuxiliaryToolBar
->
SetSize
(
Auxtoolbar_size
);
m_AuxiliaryToolBar
->
Move
(
0
,
0
);
size
.
y
-=
Auxtoolbar_size
.
y
;
}
if
(
m_VToolBar
)
// Toolbar de droite: hauteur = hauteur utile de la frame-Auxtoolbar
if
(
m_VToolBar
)
// Resize the main right vertial tool bar.
{
Vtoolbar_size
.
x
=
m_VToolBar
->
GetSize
().
x
;
Vtoolbar_size
.
y
=
size
.
y
;
...
...
@@ -424,7 +385,8 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
m_VToolBar
->
Refresh
();
}
if
(
m_AuxVToolBar
)
// auxiliary vertical right toolbar, showing tools fo microwave applications
if
(
m_AuxVToolBar
)
// Resize the auxiliary right vertical
// toolbar.
{
Vtoolbar_size
.
x
+=
m_AuxVToolBar
->
GetSize
().
x
;
Vtoolbar_size
.
y
=
size
.
y
;
...
...
@@ -461,20 +423,17 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
}
/*************************************************************************/
void
WinEDA_DrawFrame
::
SetToolID
(
int
id
,
int
new_cursor_id
,
const
wxString
&
title
)
/*************************************************************************/
/*
*
Active l'icone de l'outil selectionne dans le toolbar Vertical
*
( ou l'outil par defaut ID_NO_SELECT_BUTT si pas de nouvelle selection
)
*
if ( id >= 0
)
*
Met a jour toutes les variables associees
:
*
message, m_ID_current_state, curseu
r
*
si ( id < 0
)
*
Met a jour seulement les variables message et curseu
r
*
Enables the icon of the selected tool in the vertical toolbar.
*
(Or tool ID_NO_SELECT_BUTT default if no new selection
)
*
if (id >= 0
)
*
Updates all variables related
:
*
Message m_ID_current_state, curso
r
*
If (id < 0
)
*
Only updates the variables message and curso
r
*/
void
WinEDA_DrawFrame
::
SetToolID
(
int
id
,
int
new_cursor_id
,
const
wxString
&
title
)
{
// Change Cursor
if
(
DrawPanel
)
...
...
@@ -488,7 +447,7 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
if
(
id
<
0
)
return
;
// Old Tool I
nactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool
// Old Tool I
D_NO_SELECT_BUTT active or inactive if no new tool.
if
(
m_ID_current_state
)
{
if
(
m_VToolBar
)
...
...
@@ -511,7 +470,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
m_VToolBar
->
ToggleTool
(
ID_NO_SELECT_BUTT
,
TRUE
);
}
// New Tool Actif
if
(
id
)
{
if
(
m_VToolBar
)
...
...
@@ -560,9 +518,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
}
/*********************************************/
void
WinEDA_DrawFrame
::
AdjustScrollBars
()
/*********************************************/
{
int
xUnit
,
yUnit
;
wxSize
draw_size
,
panel_size
;
...
...
@@ -617,7 +573,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
xUnit
=
screen
->
Unscale
(
xUnit
);
yUnit
=
screen
->
Unscale
(
yUnit
);
// Calcul
de la position, curseur place au centre d'ecran
// Calcul
ate the position, place the cursor at the center of screen.
scrollbar_pos
=
screen
->
m_Curseur
-
screen
->
m_DrawOrg
;
scrollbar_pos
.
x
-=
panel_size
.
x
/
2
;
...
...
@@ -663,14 +619,11 @@ void WinEDA_DrawFrame::AdjustScrollBars()
}
/****************************************************/
void
WinEDA_DrawFrame
::
SetDrawBgColor
(
int
color_num
)
/****************************************************/
/* met a jour la couleur de fond pour les trac�s
* seules les couleurs BLACK ou WHITE sont autoris�es
* le parametre XorMode est mis a jour selon la couleur du fond
/* Updates the background color for drawing panel. The only valid colors
* are BLACK and WHITE.
* XorMode the parameter is updated according to the background color
*/
void
WinEDA_DrawFrame
::
SetDrawBgColor
(
int
color_num
)
{
if
(
(
color_num
!=
WHITE
)
&&
(
color_num
!=
BLACK
)
)
color_num
=
BLACK
;
...
...
@@ -687,15 +640,14 @@ void WinEDA_DrawFrame::SetDrawBgColor( int color_num )
}
if
(
DrawPanel
)
DrawPanel
->
SetBackgroundColour
(
wxColour
(
ColorRefs
[
g_DrawBgColor
].
m_Red
,
ColorRefs
[
g_DrawBgColor
].
m_Green
,
ColorRefs
[
g_DrawBgColor
].
m_Blue
)
);
DrawPanel
->
SetBackgroundColour
(
wxColour
(
ColorRefs
[
g_DrawBgColor
].
m_Red
,
ColorRefs
[
g_DrawBgColor
].
m_Green
,
ColorRefs
[
g_DrawBgColor
].
m_Blue
)
);
}
/********************************************************/
void
WinEDA_DrawFrame
::
SetLanguage
(
wxCommandEvent
&
event
)
/********************************************************/
{
int
id
=
event
.
GetId
();
...
...
common/drawpanel.cpp
View file @
bc5d9a75
/*****************
*************************
/
/* drawpanel.cpp
- WinEDA_DrawPanel class
*/
/*****************
*************************
/
/*****************/
/* drawpanel.cpp */
/*****************/
#include "fctsys.h"
#include "appl_wxstruct.h"
...
...
@@ -13,15 +13,13 @@
#include "wxstruct.h"
// Local defines
#define CURSOR_SIZE 12 // Cursor size in pixels
// Local variables
/* Used to inhibit a response to a mouse left button release, after a
double click
*
(when releasing the left button at the end of the second click
*
Used in eeschema to inhibit a mouse left release command when switching betwe
en
*
hierarchical sheets on a double click
/* Used to inhibit a response to a mouse left button release, after a
*
double click (when releasing the left button at the end of the second
*
click. Used in eeschema to inhibit a mouse left release command wh
en
*
switching between hierarchical sheets on a double click.
*/
static
bool
s_IgnoreNextLeftButtonRelease
=
false
;
...
...
@@ -41,9 +39,9 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
EVT_MENU_RANGE
(
ID_PAN_UP
,
ID_PAN_RIGHT
,
WinEDA_DrawPanel
::
OnPan
)
END_EVENT_TABLE
()
/***********************************************************************
*
/
/* WinEDA_DrawPanel bas
ic
functions (WinEDA_DrawPanel is the main panel)*/
/***********************************************************************
*
/
/***********************************************************************/
/* WinEDA_DrawPanel bas
e
functions (WinEDA_DrawPanel is the main panel)*/
/***********************************************************************/
WinEDA_DrawPanel
::
WinEDA_DrawPanel
(
WinEDA_DrawFrame
*
parent
,
int
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
)
:
...
...
@@ -99,11 +97,9 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
}
/*****************************************************************************
*
/*
* Draw the schematic cursor which is usually on grid
*
*****************************************************************************/
*/
void
WinEDA_DrawPanel
::
Trace_Curseur
(
wxDC
*
DC
,
int
color
)
{
if
(
m_CursorLevel
!=
0
||
DC
==
NULL
)
...
...
@@ -112,15 +108,15 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
wxPoint
Cursor
=
GetScreen
()
->
m_Curseur
;
GRSetDrawMode
(
DC
,
GR_XOR
);
if
(
m_Parent
->
m_CursorShape
==
1
)
/*
Trace d'un reticule
*/
if
(
m_Parent
->
m_CursorShape
==
1
)
/*
Draws a crosshair.
*/
{
int
dx
=
GetScreen
()
->
Unscale
(
m_ClipBox
.
GetWidth
()
);
int
dy
=
GetScreen
()
->
Unscale
(
m_ClipBox
.
GetHeight
()
);
GRLine
(
&
m_ClipBox
,
DC
,
Cursor
.
x
-
dx
,
Cursor
.
y
,
Cursor
.
x
+
dx
,
Cursor
.
y
,
0
,
color
);
//
axe Y
Cursor
.
x
+
dx
,
Cursor
.
y
,
0
,
color
);
//
Y axis
GRLine
(
&
m_ClipBox
,
DC
,
Cursor
.
x
,
Cursor
.
y
-
dx
,
Cursor
.
x
,
Cursor
.
y
+
dy
,
0
,
color
);
//
axe X
Cursor
.
x
,
Cursor
.
y
+
dy
,
0
,
color
);
//
X axis
}
else
{
...
...
@@ -134,26 +130,21 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
}
/*******************************************************************/
void
WinEDA_DrawPanel
::
CursorOff
(
wxDC
*
DC
)
/*******************************************************************/
/*
* Remove the grid cursor from the display in preparation for other drawing operations
* Remove the grid cursor from the display in preparation for other drawing
* operations
*/
void
WinEDA_DrawPanel
::
CursorOff
(
wxDC
*
DC
)
{
Trace_Curseur
(
DC
);
--
m_CursorLevel
;
}
/*******************************************************************/
void
WinEDA_DrawPanel
::
CursorOn
(
wxDC
*
DC
)
/*******************************************************************/
/*
* Display the grid cursor
*/
void
WinEDA_DrawPanel
::
CursorOn
(
wxDC
*
DC
)
{
++
m_CursorLevel
;
Trace_Curseur
(
DC
);
...
...
@@ -163,33 +154,25 @@ void WinEDA_DrawPanel::CursorOn( wxDC* DC )
}
/***********************************/
int
WinEDA_DrawPanel
::
GetZoom
()
/***********************************/
{
return
GetScreen
()
->
GetZoom
();
}
/***************************************/
void
WinEDA_DrawPanel
::
SetZoom
(
int
zoom
)
/***************************************/
{
GetScreen
()
->
SetZoom
(
zoom
);
}
/************************************/
wxRealPoint
WinEDA_DrawPanel
::
GetGrid
()
/************************************/
{
return
GetScreen
()
->
GetGridSize
();
}
/******************************************************/
void
WinEDA_DrawPanel
::
PrepareGraphicContext
(
wxDC
*
DC
)
/******************************************************/
{
GRResetPenAndBrush
(
DC
);
DC
->
SetBackgroundMode
(
wxTRANSPARENT
);
...
...
@@ -203,14 +186,11 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
}
/**********************************************************************/
wxPoint
WinEDA_DrawPanel
::
CursorRealPosition
(
const
wxPoint
&
ScreenPos
)
/**********************************************************************/
/** CursorRealPosition (used to calculate the cursor position in internal units)
/** Calculate the cursor position in internal units.
* @return position (in internal units)
* @param ScreenPos = absolute position in pixels
*/
wxPoint
WinEDA_DrawPanel
::
CursorRealPosition
(
const
wxPoint
&
ScreenPos
)
{
#ifdef WX_ZOOM
wxCoord
x
,
y
;
...
...
@@ -225,15 +205,12 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
}
/********************************************************/
bool
WinEDA_DrawPanel
::
IsPointOnDisplay
(
wxPoint
ref_pos
)
/********************************************************/
/** Function IsPointOnDisplay
* @param ref_pos is the position to test in pixels, relative to the panel.
* @return TRUE if ref_pos is a point currently visible on screen
* FALSE if ref_pos is out of screen
*/
bool
WinEDA_DrawPanel
::
IsPointOnDisplay
(
wxPoint
ref_pos
)
{
wxPoint
pos
;
EDA_Rect
display_rect
;
...
...
@@ -241,12 +218,12 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
SetBoundaryBox
();
display_rect
=
m_ClipBox
;
//
Reduction legere des dimension de l'ecran utile pour eviter cadrage
//
en limite d'ecran
//
Slightly decreased the size of the useful screen area to avoid drawing
//
limits.
#define PIXEL_MARGIN 8
display_rect
.
Inflate
(
-
PIXEL_MARGIN
,
-
PIXEL_MARGIN
);
// Conver
sion en coord physiques
// Conver
t physical coordinates.
pos
=
CalcUnscrolledPosition
(
display_rect
.
GetPosition
()
);
GetScreen
()
->
Unscale
(
pos
);
...
...
@@ -279,9 +256,7 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect )
}
/************************************************************************/
void
WinEDA_DrawPanel
::
ConvertPcbUnitsToPixelsUnits
(
EDA_Rect
*
aRect
)
/************************************************************************/
{
// Calculate the draw area origin in internal units:
wxPoint
pos
=
aRect
->
GetPosition
();
...
...
@@ -342,13 +317,11 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
}
/*********************************************************/
wxPoint
WinEDA_DrawPanel
::
GetScreenCenterRealPosition
(
void
)
/*********************************************************/
/** Function GetScreenCenterRealPosition()
* @return position (in internal units) of the current area centre showed on screen
* @return position (in internal units) of the current area center showed
* on screen
*/
wxPoint
WinEDA_DrawPanel
::
GetScreenCenterRealPosition
(
void
)
{
wxSize
size
;
wxPoint
realpos
;
...
...
@@ -370,12 +343,9 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
}
/**********************************************/
void
WinEDA_DrawPanel
::
MouseToCursorSchema
()
/**********************************************/
/* Move the mouse cursor to the current schematic cursor
*/
void
WinEDA_DrawPanel
::
MouseToCursorSchema
()
{
wxPoint
Mouse
=
CursorScreenPosition
();
...
...
@@ -383,13 +353,10 @@ void WinEDA_DrawPanel::MouseToCursorSchema()
}
/****************************************************/
void
WinEDA_DrawPanel
::
MouseTo
(
const
wxPoint
&
Mouse
)
/****************************************************/
/** Move the mouse cursor to the position "Mouse"
* @param Mouse = mouse cursor position, in pixels units
*/
void
WinEDA_DrawPanel
::
MouseTo
(
const
wxPoint
&
Mouse
)
{
int
x
,
y
,
xPpu
,
yPpu
;
wxPoint
screenPos
,
drawingPos
;
...
...
@@ -436,33 +403,27 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
}
/********************************************************/
void
WinEDA_DrawPanel
::
OnActivate
(
wxActivateEvent
&
event
)
/********************************************************/
/**
* Called on window activation.
* init the member m_CanStartBlock to avoid a block start command
* on activation (because a left mouse button can be pressed and no block command wanted
* This happens when enter on a hierarchycat sheet on double click
* on activation (because a left mouse button can be pressed and no block
* command wanted.
* This happens when enter on a hierarchy sheet on double click
*/
void
WinEDA_DrawPanel
::
OnActivate
(
wxActivateEvent
&
event
)
{
m_CanStartBlock
=
-
1
;
// Block Command can't start
event
.
Skip
();
}
/***********************************************************/
void
WinEDA_DrawPanel
::
OnEraseBackground
(
wxEraseEvent
&
event
)
/***********************************************************/
{
event
.
Skip
();
}
/*********************************************************/
void
WinEDA_DrawPanel
::
OnScroll
(
wxScrollWinEvent
&
event
)
/*********************************************************/
{
int
id
=
event
.
GetEventType
();
int
dir
,
value
=
0
;
...
...
@@ -504,22 +465,17 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
}
/*************************************************/
void
WinEDA_DrawPanel
::
OnSize
(
wxSizeEvent
&
event
)
/*************************************************/
{
SetBoundaryBox
();
event
.
Skip
();
}
/******************************************/
void
WinEDA_DrawPanel
::
SetBoundaryBox
()
/******************************************/
/** Function SetBoundaryBox()
* set the m_ClipBox member to the current displayed rectangle dimensions
*/
void
WinEDA_DrawPanel
::
SetBoundaryBox
()
{
BASE_SCREEN
*
Screen
=
GetScreen
();;
...
...
@@ -554,9 +510,7 @@ void WinEDA_DrawPanel::SetBoundaryBox()
}
/*********************************************/
void
WinEDA_DrawPanel
::
EraseScreen
(
wxDC
*
DC
)
/*********************************************/
{
GRSetDrawMode
(
DC
,
GR_COPY
);
...
...
@@ -569,8 +523,10 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
m_ClipBox
.
m_Pos
.
x
=
DC
->
DeviceToLogicalX
(
m_ClipBox
.
m_Pos
.
x
);
m_ClipBox
.
m_Pos
.
y
=
DC
->
DeviceToLogicalY
(
m_ClipBox
.
m_Pos
.
y
);
m_ClipBox
.
m_Size
.
SetWidth
(
DC
->
DeviceToLogicalXRel
(
m_ClipBox
.
m_Size
.
GetWidth
()
)
);
m_ClipBox
.
m_Size
.
SetHeight
(
DC
->
DeviceToLogicalYRel
(
m_ClipBox
.
m_Size
.
GetHeight
()
)
);
m_ClipBox
.
m_Size
.
SetWidth
(
DC
->
DeviceToLogicalXRel
(
m_ClipBox
.
m_Size
.
GetWidth
()
)
);
m_ClipBox
.
m_Size
.
SetHeight
(
DC
->
DeviceToLogicalYRel
(
m_ClipBox
.
m_Size
.
GetHeight
()
)
);
GRSFilledRect
(
&
m_ClipBox
,
DC
,
m_ClipBox
.
GetX
(),
m_ClipBox
.
GetY
(),
m_ClipBox
.
GetRight
(),
m_ClipBox
.
GetBottom
(),
...
...
@@ -589,9 +545,8 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
//#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC
#endif
/***************************************************/
void
WinEDA_DrawPanel
::
OnPaint
(
wxPaintEvent
&
event
)
/***************************************************/
{
if
(
GetScreen
()
==
NULL
)
{
...
...
@@ -601,8 +556,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#ifdef USE_GCDC_IN_KICAD
wxPaintDC
pDC
(
this
);
wxGCDC
paintDC
(
pDC
);
// Following line should be disabled on MSW and OS X
paintDC
.
GetGraphicsContext
()
->
Translate
(
0.5
,
0.5
);
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
// Following line should be disabled on MSW and OS X
wxGCDC
paintDC
(
pDC
);
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC
.
GetGraphicsContext
()
->
Translate
(
0.5
,
0.5
);
#else
wxPaintDC
paintDC
(
this
);
#endif
...
...
@@ -693,9 +650,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
}
/****************************************************/
void
WinEDA_DrawPanel
::
ReDraw
(
wxDC
*
DC
,
bool
erasebg
)
/****************************************************/
{
BASE_SCREEN
*
Screen
=
GetScreen
();
...
...
@@ -731,17 +686,14 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
}
/***********************************************/
void
WinEDA_DrawPanel
::
DrawBackGround
(
wxDC
*
DC
)
/***********************************************/
/** Function DrawBackGround
* @param DC = current Device Context
* Draws X , Y axis
* draws the grid
* - the grid is drawn only if the zoom level allows a good visibility
* - the grid is always centered on the screen cent
re
* - the grid is always centered on the screen cent
er
*/
void
WinEDA_DrawPanel
::
DrawBackGround
(
wxDC
*
DC
)
{
int
Color
=
BLUE
;
BASE_SCREEN
*
screen
=
GetScreen
();
...
...
@@ -846,14 +798,11 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
}
/********************************************************************/
void
WinEDA_DrawPanel
::
DrawAuxiliaryAxis
(
wxDC
*
DC
,
int
drawmode
)
/********************************************************************/
/** m_Draw_Auxiliary_Axis
* Draw the Auxiliary Axis, used in pcbnew which as origin coordinates
* for gerber and excellon files
*/
void
WinEDA_DrawPanel
::
DrawAuxiliaryAxis
(
wxDC
*
DC
,
int
drawmode
)
{
if
(
!
m_Parent
->
m_Draw_Auxiliary_Axis
||
(
m_Parent
->
m_Auxiliary_Axis_Position
.
x
==
0
...
...
@@ -883,13 +832,10 @@ void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode )
}
/*******************************************************/
bool
WinEDA_DrawPanel
::
OnRightClick
(
wxMouseEvent
&
event
)
/*******************************************************/
/** Build and display a Popup menu on a right mouse button click
* @return true if a popup menu is shown, or false
*/
bool
WinEDA_DrawPanel
::
OnRightClick
(
wxMouseEvent
&
event
)
{
wxPoint
pos
;
wxMenu
MasterMenu
;
...
...
@@ -910,13 +856,10 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
}
/
******************************************************/
/
/ Called when the canvas receives a mouse event leaving frame.
void
WinEDA_DrawPanel
::
OnMouseLeaving
(
wxMouseEvent
&
event
)
/*******************************************************/
// Called when the canvas receives a mouse event leaving frame. //
{
if
(
ManageCurseur
==
NULL
)
// Pas de commande encours
if
(
ManageCurseur
==
NULL
)
// No command in progress.
m_AutoPAN_Request
=
FALSE
;
if
(
!
m_AutoPAN_Enable
||
!
m_AutoPAN_Request
||
m_IgnoreMouseEvents
)
...
...
@@ -988,11 +931,9 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
GetEventHandler
()
->
ProcessEvent
(
cmd
);
}
/******************************************************/
void
WinEDA_DrawPanel
::
OnMouseEvent
(
wxMouseEvent
&
event
)
/*******************************************************/
// Called when the canvas receives a mouse event. //
// Called when the canvas receives a mouse event.
void
WinEDA_DrawPanel
::
OnMouseEvent
(
wxMouseEvent
&
event
)
{
int
localrealbutt
=
0
,
localbutt
=
0
,
localkey
=
0
;
BASE_SCREEN
*
screen
=
GetScreen
();
...
...
@@ -1000,14 +941,17 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if
(
!
screen
)
return
;
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
/* Adjust value to filter mouse displacement before
* consider the drag mouse is really a drag command, not just a movement while click
*/
static
int
MinDragEventCount
;
/* counts the drag events.
* used to filter mouse moves before starting a block command
* a block command can be started only if MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* in order to avoid spurious block commands
*/
/* Adjust value to filter mouse displacement before consider the drag
* mouse is really a drag command, not just a movement while click
*/
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
/* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if MinDragEventCount >
* MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block
* commands. */
static
int
MinDragEventCount
;
if
(
event
.
Leaving
()
||
event
.
Entering
()
)
{
m_CanStartBlock
=
-
1
;
...
...
@@ -1059,10 +1003,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
localrealbutt
|=
localbutt
;
/* compensation default wxGTK */
/* Compute absolute m_MousePosition in pixel units: */
screen
->
m_MousePositionInPixels
=
CalcUnscrolledPosition
(
event
.
GetPosition
()
);
screen
->
m_MousePositionInPixels
=
CalcUnscrolledPosition
(
event
.
GetPosition
()
);
/* Compute absolute m_MousePosition in user units: */
screen
->
m_MousePosition
=
CursorRealPosition
(
screen
->
m_MousePositionInPixels
);
screen
->
m_MousePosition
=
CursorRealPosition
(
screen
->
m_MousePositionInPixels
);
wxClientDC
DC
(
this
);
int
kbstat
=
0
;
...
...
@@ -1087,13 +1033,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
m_Parent
->
OnLeftDClick
(
&
DC
,
screen
->
m_MousePositionInPixels
);
// inhibit a response to the mouse left button release,
// because we have a double click, and we do not want a new OnLeftClick command at end of this Double Click
// because we have a double click, and we do not want a new
// OnLeftClick command at end of this Double Click
s_IgnoreNextLeftButtonRelease
=
true
;
}
else
if
(
event
.
LeftUp
()
)
{
if
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
// A block command is in progress: a left up is the end of block
&&
!
s_IgnoreNextLeftButtonRelease
)
// This is the end of a double click, already seen
// A block command is in progress: a left up is the end of block
// or this is the end of a double click, already seen
if
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
&&
!
s_IgnoreNextLeftButtonRelease
)
m_Parent
->
OnLeftClick
(
&
DC
,
screen
->
m_MousePositionInPixels
);
s_IgnoreNextLeftButtonRelease
=
false
;
...
...
@@ -1102,13 +1051,15 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if
(
!
event
.
LeftIsDown
()
)
{
/* be sure there is a response to a left button release command
* even when a LeftUp event is not seen
* happens when a double click opens a dialog box, and the release mouse button is made when the dialog box is open
* even when a LeftUp event is not seen. This happens when a
* double click opens a dialog box, and the release mouse button
* is made when the dialog box is open.
*/
s_IgnoreNextLeftButtonRelease
=
false
;
}
if
(
event
.
ButtonUp
(
2
)
&&
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
)
if
(
event
.
ButtonUp
(
2
)
&&
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
)
{
// The middle button has been released, with no block command:
// We use it for a zoom center at cursor position command
...
...
@@ -1136,7 +1087,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
/* A new command block can start after a release buttons
* and if the drag is enough
* This is to avoid a false start block when a dialog box is d
emiss
,
* This is to avoid a false start block when a dialog box is d
ismissed
,
* or when changing panels in hierarchy navigation
* or when clicking while and moving mouse
*/
...
...
@@ -1145,18 +1096,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
MinDragEventCount
=
0
;
m_CanStartBlock
=
0
;
/*
r
emember the last cursor position when a drag mouse starts
/*
R
emember the last cursor position when a drag mouse starts
* this is the last position ** before ** clicking a button
* this is useful to start a block command from the point where the mouse was clicked first
* (a filter creates a delay for the real block command start, and we must remember this point)
* this is useful to start a block command from the point where the
* mouse was clicked first
* (a filter creates a delay for the real block command start, and
* we must remember this point)
*/
m_CursorStartPos
=
screen
->
m_Curseur
;
}
if
(
m_Block_Enable
&&
!
(
localbutt
&
GR_M_DCLICK
)
)
{
if
(
(
screen
->
m_BlockLocate
.
m_Command
==
BLOCK_IDLE
)
||
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
)
if
(
(
screen
->
m_BlockLocate
.
m_Command
==
BLOCK_IDLE
)
||
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
)
{
screen
->
m_BlockLocate
.
SetOrigin
(
m_CursorStartPos
);
}
...
...
@@ -1169,11 +1122,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
s_IgnoreNextLeftButtonRelease
=
true
;
}
}
else
if
(
(
m_CanStartBlock
>=
0
)
else
if
(
(
m_CanStartBlock
>=
0
)
&&
(
event
.
LeftIsDown
()
||
event
.
MiddleIsDown
()
)
&&
ManageCurseur
==
NULL
&&
ForceCloseManageCurseur
==
NULL
)
{
// Mouse is dragging: if no block in progress: start a block command
{
// Mouse is dragging: if no block in progress, start a block
// command.
if
(
screen
->
m_BlockLocate
.
m_State
==
STATE_NO_BLOCK
)
{
// Start a block command
int
cmd_type
=
kbstat
;
...
...
@@ -1181,15 +1136,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if
(
event
.
MiddleIsDown
()
)
cmd_type
|=
MOUSE_MIDDLE
;
/* A block command is started if the drag is enough.
*
A small drag is ignored (it is certainly a little mouse move when clicking)
* not really a drag mouse
/* A block command is started if the drag is enough.
A small
*
drag is ignored (it is certainly a little mouse move when
*
clicking)
not really a drag mouse
*/
if
(
MinDragEventCount
<
MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
)
MinDragEventCount
++
;
else
{
if
(
!
m_Parent
->
HandleBlockBegin
(
&
DC
,
cmd_type
,
m_CursorStartPos
)
)
if
(
!
m_Parent
->
HandleBlockBegin
(
&
DC
,
cmd_type
,
m_CursorStartPos
)
)
{
// should not occurs: error
m_Parent
->
DisplayToolMsg
(
...
...
@@ -1207,17 +1163,21 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if
(
event
.
ButtonUp
(
1
)
||
event
.
ButtonUp
(
2
)
)
{
/* Release the mouse button: end of block.
* The command can finish (DELETE) or have a next command (MOVE, COPY).
* However the block command is canceled if the block size is small
* Because a block command filtering is already made, this case happens,
* but only when the on grid cursor has not moved.
* The command can finish (DELETE) or have a next command (MOVE,
* COPY). However the block command is canceled if the block
* size is small because a block command filtering is already
* made, this case happens, but only when the on grid cursor has
* not moved.
*/
#define BLOCK_MINSIZE_LIMIT 1
bool
BlockIsSmall
=
(
ABS
(
screen
->
Scale
(
screen
->
m_BlockLocate
.
GetWidth
()
)
)
<
BLOCK_MINSIZE_LIMIT
)
&&
(
ABS
(
screen
->
Scale
(
screen
->
m_BlockLocate
.
GetHeight
()
)
)
<
BLOCK_MINSIZE_LIMIT
);
(
ABS
(
screen
->
Scale
(
screen
->
m_BlockLocate
.
GetWidth
()
)
)
<
BLOCK_MINSIZE_LIMIT
)
&&
(
ABS
(
screen
->
Scale
(
screen
->
m_BlockLocate
.
GetHeight
()
)
)
<
BLOCK_MINSIZE_LIMIT
);
if
(
(
screen
->
m_BlockLocate
.
m_State
!=
STATE_NO_BLOCK
)
&&
BlockIsSmall
)
if
(
(
screen
->
m_BlockLocate
.
m_State
!=
STATE_NO_BLOCK
)
&&
BlockIsSmall
)
{
if
(
ForceCloseManageCurseur
)
{
...
...
@@ -1241,8 +1201,9 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
}
// End of block command on a double click
// To avoid an unwanted block move command if the mouse is moved while double clicking
if
(
localbutt
==
(
int
)
(
GR_M_LEFT_DOWN
|
GR_M_DCLICK
)
)
// To avoid an unwanted block move command if the mouse is moved while
// double clicking
if
(
localbutt
==
(
int
)
(
GR_M_LEFT_DOWN
|
GR_M_DCLICK
)
)
{
if
(
screen
->
m_BlockLocate
.
m_Command
!=
BLOCK_IDLE
)
{
...
...
@@ -1258,7 +1219,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#if 0
wxString msg_debug;
msg_debug.Printf( " block state %d, cmd %d",
screen->m_BlockLocate.m_State, screen->m_BlockLocate.m_Command );
screen->m_BlockLocate.m_State,
screen->m_BlockLocate.m_Command );
m_Parent->PrintMsg( msg_debug );
#endif
...
...
@@ -1266,9 +1228,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
}
/****************************************************/
void
WinEDA_DrawPanel
::
OnKeyEvent
(
wxKeyEvent
&
event
)
/****************************************************/
{
long
key
,
localkey
;
bool
escape
=
FALSE
;
...
...
@@ -1342,6 +1302,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
#endif
}
void
WinEDA_DrawPanel
::
OnPan
(
wxCommandEvent
&
event
)
{
int
x
,
y
;
...
...
common/eda_dde.cpp
View file @
bc5d9a75
///////////////////////
// Name: eda_dde.cpp //
///////////////////////
...
...
@@ -13,27 +12,28 @@
wxString
HOSTNAME
(
wxT
(
"localhost"
)
);
/* variables locales */
// buffer for read and write data in socket connections
#define IPC_BUF_SIZE 4096
static
char
client_ipc_buffer
[
IPC_BUF_SIZE
];
static
wxServer
*
server
;
void
(
*
RemoteFct
)(
const
char
*
cmd
);
void
SetupServerFunction
(
void
(
*
remotefct
)(
const
char
*
remotecmd
)
)
{
RemoteFct
=
remotefct
;
}
/*****************************/
/* Routines
liees au SERVEUR
*/
/*****************************/
/*****************************
*****
/
/* Routines
related to the server
*/
/*****************************
*****
/
/* F
onction d'initialisation d'un serveu
r socket
/* F
unction to initialize a serve
r socket
*/
WinEDA_Server
*
CreateServer
(
wxWindow
*
window
,
int
service
)
{
...
...
@@ -54,12 +54,9 @@ WinEDA_Server* CreateServer( wxWindow* window, int service )
}
/********************************************************/
void
WinEDA_DrawFrame
::
OnSockRequest
(
wxSocketEvent
&
evt
)
/********************************************************/
/* Fonction appelee a chaque demande d'un client
/* Function called on every client request.
*/
void
WinEDA_DrawFrame
::
OnSockRequest
(
wxSocketEvent
&
evt
)
{
size_t
len
;
wxSocketBase
*
sock
=
evt
.
GetSocket
();
...
...
@@ -69,8 +66,8 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
case
wxSOCKET_INPUT
:
sock
->
Read
(
client_ipc_buffer
,
1
);
if
(
sock
->
LastCount
()
==
0
)
break
;
// No data: O
ccurs on opening connection
break
;
// No data, o
ccurs on opening connection
sock
->
Read
(
client_ipc_buffer
+
1
,
IPC_BUF_SIZE
-
2
);
len
=
1
+
sock
->
LastCount
();
client_ipc_buffer
[
len
]
=
0
;
...
...
@@ -89,12 +86,9 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
}
/**************************************************************/
void
WinEDA_DrawFrame
::
OnSockRequestServer
(
wxSocketEvent
&
evt
)
/**************************************************************/
/* fonction appele lors d'une demande de connexion d'un client
/* Function called when a connection is requested by a client.
*/
void
WinEDA_DrawFrame
::
OnSockRequestServer
(
wxSocketEvent
&
evt
)
{
wxSocketBase
*
sock2
;
wxSocketServer
*
server
=
(
wxSocketServer
*
)
evt
.
GetSocket
();
...
...
@@ -109,21 +103,18 @@ void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
}
/****************************/
/* Routines liees au CLIENT */
/*****************************/
/**************************************************/
bool
SendCommand
(
int
service
,
const
char
*
cmdline
)
/**************************************************/
/**********************************/
/* Routines related to the CLIENT */
/**********************************/
/* Used by a client to sent (by a socket connection) a data to a server.
* - Open a Socket Client connection
* - Send the buffer cmdline
* - Close the socket connection
*
*
* service is the service number for the TC/IP connection
*/
bool
SendCommand
(
int
service
,
const
char
*
cmdline
)
{
wxSocketClient
*
sock_client
;
bool
success
=
FALSE
;
...
...
@@ -133,7 +124,8 @@ bool SendCommand( int service, const char* cmdline )
addr
.
Hostname
(
HOSTNAME
);
addr
.
Service
(
service
);
// Mini-tutorial for Connect() :-) (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample)
// Mini-tutorial for Connect() :-)
// (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample)
// ---------------------------
//
// There are two ways to use Connect(): blocking and non-blocking,
...
...
@@ -141,7 +133,7 @@ bool SendCommand( int service, const char* cmdline )
//
// Connect(addr, true) will wait until the connection completes,
// returning true on success and false on failure. This call blocks
// the GUI (this might be changed in future releases to hono
u
r the
// the GUI (this might be changed in future releases to honor the
// wxSOCKET_BLOCK flag).
//
// Connect(addr, false) will issue a nonblocking connection request
...
...
@@ -152,7 +144,7 @@ bool SendCommand( int service, const char* cmdline )
// events (please read the documentation).
//
// WaitOnConnect() itself never blocks the GUI (this might change
// in the future to hono
u
r the wxSOCKET_BLOCK flag). This call will
// in the future to honor the wxSOCKET_BLOCK flag). This call will
// return false on timeout, or true if the connection request
// completes, which in turn might mean:
//
...
...
@@ -181,7 +173,7 @@ bool SendCommand( int service, const char* cmdline )
// bool success = client->IsConnected();
//
// And that's all :-)
sock_client
=
new
wxSocketClient
();
sock_client
->
SetTimeout
(
2
);
// Time out in Seconds
sock_client
->
Connect
(
addr
,
FALSE
);
...
...
common/eda_doc.cpp
View file @
bc5d9a75
...
...
@@ -14,31 +14,25 @@
#include "macros.h"
/*****************************************/
void
WinEDA_App
::
ReadPdfBrowserInfos
()
/*****************************************/
/* Read from Common config the Pdf browser choice
*/
void
WinEDA_App
::
ReadPdfBrowserInfos
()
{
wxASSERT
(
m_EDA_CommonConfig
!=
NULL
);
m_PdfBrowserIsDefault
=
m_EDA_CommonConfig
->
Read
(
wxT
(
"PdfBrowserIsDefault"
),
true
);
m_PdfBrowserIsDefault
=
m_EDA_CommonConfig
->
Read
(
wxT
(
"PdfBrowserIsDefault"
),
true
);
m_PdfBrowser
=
m_EDA_CommonConfig
->
Read
(
wxT
(
"PdfBrowserName"
),
wxEmptyString
);
wxEmptyString
);
if
(
m_PdfBrowser
.
IsEmpty
()
)
m_PdfBrowserIsDefault
=
true
;
}
/*****************************************/
void
WinEDA_App
::
WritePdfBrowserInfos
()
/*****************************************/
/* Write into Common config the Pdf browser choice
*/
void
WinEDA_App
::
WritePdfBrowserInfos
()
{
wxASSERT
(
m_EDA_CommonConfig
!=
NULL
);
...
...
@@ -46,7 +40,7 @@ void WinEDA_App::WritePdfBrowserInfos()
m_PdfBrowserIsDefault
=
true
;
m_EDA_CommonConfig
->
Write
(
wxT
(
"PdfBrowserIsDefault"
),
m_PdfBrowserIsDefault
);
m_PdfBrowserIsDefault
);
m_EDA_CommonConfig
->
Write
(
wxT
(
"PdfBrowserName"
),
m_PdfBrowser
);
}
...
...
@@ -56,16 +50,18 @@ static wxMimeTypesManager* mimeDatabase;
static
const
wxFileTypeInfo
EDAfallbacks
[]
=
{
wxFileTypeInfo
(
wxT
(
"text/html"
),
wxT
(
"wxhtml %s"
),
wxT
(
"wxhtml %s"
),
wxT
(
"html document (from Kicad)"
),
wxT
(
"htm"
),
wxT
(
"html"
),
NULL
),
wxT
(
"wxhtml %s"
),
wxT
(
"wxhtml %s"
),
wxT
(
"html document (from Kicad)"
),
wxT
(
"htm"
),
wxT
(
"html"
),
NULL
),
wxFileTypeInfo
(
wxT
(
"application/sch"
),
wxT
(
"eeschema %s"
),
wxT
(
"eeschema -p %s"
),
wxT
(
"sch document (from Kicad)"
),
wxT
(
"sch"
),
wxT
(
"SCH"
),
NULL
),
wxT
(
"eeschema %s"
),
wxT
(
"eeschema -p %s"
),
wxT
(
"sch document (from Kicad)"
),
wxT
(
"sch"
),
wxT
(
"SCH"
),
NULL
),
// must terminate the table with this!
wxFileTypeInfo
()
...
...
@@ -75,14 +71,15 @@ static const wxFileTypeInfo EDAfallbacks[] =
/** Function GetAssociatedDocument
* open a document (file) with the suitable browser
* @param aFrame = main frame
* if DocName is starting by http: or ftp: or www. the default internet browser is launched
* if DocName is starting by http: or ftp: or www. the default internet
* browser is launched
* @param aDocName = filename of file to open (Full filename or short filename)
* @param aPaths = a wxPathList to explore.
* if NULL or aDocName is a full filename, aPath is not used.
*/
*
if NULL or aDocName is a full filename, aPath is not used.
*/
bool
GetAssociatedDocument
(
wxFrame
*
aFrame
,
const
wxString
&
aDocName
,
const
wxPathList
*
aPaths
)
const
wxString
&
aDocName
,
const
wxPathList
*
aPaths
)
{
wxString
docname
,
fullfilename
,
file_ext
;
...
...
@@ -91,7 +88,8 @@ bool GetAssociatedDocument( wxFrame* aFrame,
bool
success
=
FALSE
;
// Is an internet url
static
const
wxString
url_header
[
3
]
=
{
wxT
(
"http:"
),
wxT
(
"ftp:"
),
wxT
(
"www."
)
};
static
const
wxString
url_header
[
3
]
=
{
wxT
(
"http:"
),
wxT
(
"ftp:"
),
wxT
(
"www."
)
};
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
...
...
@@ -113,9 +111,10 @@ bool GetAssociatedDocument( wxFrame* aFrame,
/* Compute the full file name */
if
(
wxIsAbsolutePath
(
aDocName
)
||
aPaths
==
NULL
)
fullfilename
=
aDocName
;
/* If the file exists, this is a trivial case: return the filename "as this"
* the name can be an absolute path, or a relative path like ./filename or ../<filename>
*/
/* If the file exists, this is a trivial case: return the filename
* "as this". the name can be an absolute path, or a relative path
* like ./filename or ../<filename>
*/
else
if
(
wxFileName
::
FileExists
(
aDocName
)
)
fullfilename
=
aDocName
;
else
...
...
@@ -132,17 +131,15 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if
(
wxIsWild
(
fullfilename
)
)
{
fullfilename
=
EDA_FileSelector
(
_
(
"Doc Files"
),
/* Titre de la fenetre */
wxPathOnly
(
fullfilename
),
/* Chemin par defaut */
fullfilename
,
/* nom fichier par defaut */
extension
,
/* extension par defaut */
mask
,
/* Masque d'affichage */
aFrame
,
/* parent frame */
wxFD_OPEN
,
/* wxSAVE, wxFD_OPEN ..*/
TRUE
,
/* true = ne change pas le repertoire courant */
wxPoint
(
-
1
,
-
1
)
);
fullfilename
=
EDA_FileSelector
(
_
(
"Doc Files"
),
wxPathOnly
(
fullfilename
),
fullfilename
,
extension
,
mask
,
aFrame
,
wxFD_OPEN
,
TRUE
,
wxPoint
(
-
1
,
-
1
)
);
if
(
fullfilename
.
IsEmpty
()
)
return
FALSE
;
}
...
...
@@ -163,13 +160,13 @@ bool GetAssociatedDocument( wxFrame* aFrame,
return
success
;
}
/* Try to launch some browser (useful
l
under linux) */
/* Try to launch some browser (useful under linux) */
wxFileType
*
filetype
;
wxString
type
;
filetype
=
wxTheMimeTypesManager
->
GetFileTypeFromExtension
(
file_ext
);
if
(
!
filetype
)
// 2
ieme tentative
if
(
!
filetype
)
// 2
nd attempt.
{
mimeDatabase
=
new
wxMimeTypesManager
;
mimeDatabase
->
AddFallbacks
(
EDAfallbacks
);
...
...
@@ -199,17 +196,14 @@ bool GetAssociatedDocument( wxFrame* aFrame,
}
/******************************************************************/
int
KeyWordOk
(
const
wxString
&
KeyList
,
const
wxString
&
Database
)
/******************************************************************/
/* Recherche si dans le texte Database on retrouve tous les mots
* cles donnes dans KeyList ( KeyList = suite de mots cles
* separes par des espaces
* Retourne:
* 0 si aucun mot cle trouv
* 1 si mot cle trouv
/* Search if the text Database found all the words in the KeyList.
* Give articles in keylist (keylist = Following Keywords
* Separated by spaces
* Returns:
* 0 if no keyword found
* 1 if keyword found
*/
int
KeyWordOk
(
const
wxString
&
KeyList
,
const
wxString
&
Database
)
{
wxString
KeysCopy
,
DataList
;
...
...
common/gestfich.cpp
View file @
bc5d9a75
/******************************************
******
/
/*
MODULE: gestfich.cpp
*/
/*
ROLE: fonctions de gestion de fichiers
*/
/******************************************
******
/
/******************************************/
/*
File: gestfich.cpp
*/
/*
Purpose: Functions for file management
*/
/******************************************/
// For compilers that support precompilation, includes "wx.h".
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "confirm.h"
#ifdef __WINDOWS__
#ifndef _MSC_VER
//#include <dir.h>
#endif
#endif
#include "common.h"
#include "macros.h"
#include "gestfich.h"
...
...
@@ -24,30 +18,35 @@
/* List of default paths used to locate help files and kicad library files.
*
* Under windows, kicad search its files from the binary path file (first argument when running "main")
* So for a standard install, default paths are not mandatory, but they exist, just in case.
* kicad is often installed in c:/Program Files/kicad or c:/kicad (or d: or e: ... )
* and the directory "share" has no meaning under windows.
* Under windows, kicad search its files from the binary path file (first
* argument when running "main") So for a standard install, default paths
* are not mandatory, but they exist, just in case.
* kicad is often installed in c:/Program Files/kicad or c:/kicad (or d: or
* e: ... ) and the directory "share" has no meaning under windows.
*
* Under linux, the problem is more complex.
* In fact there are 3 cases:
* 1 - When released in a distribution:
* binaries are in /usr/bin, kicad libs in /usr/share/kicad/ and doc in /usr/share/doc/kicad/
* binaries are in /usr/bin, kicad libs in /usr/share/kicad/ and doc in
* /usr/share/doc/kicad/
* 2 - When compiled by an user:
* binaries also can be in /usr/local/bin, kicad libs in /usr/local/share/kicad/ and doc in /usr/local/share/doc/kicad/
* binaries also can be in /usr/local/bin, kicad libs in
* /usr/local/share/kicad/ and doc in /usr/local/share/doc/kicad/
* 3 - When in an "universal tarball" or build for a server:
* all files are in /usr/local/kicad
* This is mandatory when kicad is installed on a server (in a school for instance) because one can export /usr/local/kicad
* and obviously the others paths cannot be used
* (cannot be mounted by the client, because they are already used).
* This is mandatory when kicad is installed on a server (in a school for
* instance) because one can export /usr/local/kicad and obviously the others
* paths cannot be used (cannot be mounted by the client, because they are
* already used).
*
* in cases 1 and 2 kicad files cannot be found from the binary path.
* in case 3 kicad files can be found from the binary path only if this is a kicad binary file which is launched.
* But if an user creates a symbolic link to the actual binary file to run kicad, the binary path is not good
* and the defaults paths must be used
* in case 3 kicad files can be found from the binary path only if this is
* a kicad binary file which is launched.
* But if an user creates a symbolic link to the actual binary file to run
* kicad, the binary path is not good and the defaults paths must be used
*
* Note:
* kicad uses first the bin path lo loca
c
e kicad tree.
* kicad uses first the bin path lo loca
t
e kicad tree.
* if not found kicad uses the environment variable KICAD to find its files
* and at last kicad uses the default paths.
* So we can export (linux and windows) the variable KICAD:
...
...
@@ -64,12 +63,17 @@ static wxString s_HelpPathList[] = {
#else
wxT
(
"/usr/share/doc/kicad/help/"
),
wxT
(
"/usr/local/share/doc/kicad/help/"
),
wxT
(
"/usr/local/kicad/doc/help/"
),
// default install for "universal tarballs" and build for a server (new)
wxT
(
"/usr/local/kicad/help/"
),
// default install for "universal tarballs" and build for a server (old)
wxT
(
"/usr/local/kicad/doc/help/"
),
// default install for "universal
// tarballs" and build for a server
// (new)
wxT
(
"/usr/local/kicad/help/"
),
// default install for "universal
// tarballs" and build for a server
// (old)
#endif
wxT
(
"end_list"
)
// End of list symbol, do not change
wxT
(
"end_list"
)
// End of list symbol, do not change
};
// Path list for kicad data files
static
wxString
s_KicadDataPathList
[]
=
{
#ifdef __WINDOWS__
...
...
@@ -84,10 +88,14 @@ static wxString s_KicadDataPathList[] = {
#else
wxT
(
"/usr/share/kicad/"
),
wxT
(
"/usr/local/share/kicad/"
),
wxT
(
"/usr/local/kicad/share/"
),
// default data path for "universal tarballs" and build for a server (new)
wxT
(
"/usr/local/kicad/"
),
// default data path for "universal tarballs" and build for a server (old)
wxT
(
"/usr/local/kicad/share/"
),
// default data path for "universal
// tarballs" and build for a server
// (new)
wxT
(
"/usr/local/kicad/"
),
// default data path for "universal
// tarballs" and build for a server
// (old)
#endif
wxT
(
"end_list"
)
// End of list symbol, do not change
wxT
(
"end_list"
)
// End of list symbol, do not change
};
// Path list for kicad binary files
...
...
@@ -102,16 +110,10 @@ static wxString s_KicadBinaryPathList[] = {
wxT
(
"/usr/local/bin/"
),
wxT
(
"/usr/local/kicad/bin/"
),
#endif
wxT
(
"end_list"
)
// End of list symbol, do not change
wxT
(
"end_list"
)
// End of list symbol, do not change
};
/***************************************************************************/
wxString
MakeReducedFileName
(
const
wxString
&
fullfilename
,
const
wxString
&
default_path
,
const
wxString
&
default_ext
)
/***************************************************************************/
/** Function MakeReducedFileName
* Calculate the "reduced" filename from
* @param fullfilename = full filename
...
...
@@ -120,11 +122,14 @@ wxString MakeReducedFileName( const wxString& fullfilename,
*
* @return the "reduced" filename, i.e.:
* without path if it is default_path
* wi
ht
./ if the path is the current path
* wi
th
./ if the path is the current path
* without extension if extension is default_ext
*
* the new flename is in unix like notation ('/' as path separator)
*/
wxString
MakeReducedFileName
(
const
wxString
&
fullfilename
,
const
wxString
&
default_path
,
const
wxString
&
default_ext
)
{
wxString
reduced_filename
=
fullfilename
;
wxString
Cwd
,
ext
,
path
;
...
...
@@ -175,14 +180,11 @@ wxString MakeReducedFileName( const wxString& fullfilename,
}
/*******************************************/
void
AddDelimiterString
(
wxString
&
string
)
/*******************************************/
/** Function AddDelimiterString
* Add un " to the start and the end of string (if not already done).
* @param string = string to modify
*/
void
AddDelimiterString
(
wxString
&
string
)
{
wxString
text
;
...
...
@@ -199,21 +201,20 @@ void AddDelimiterString( wxString& string )
/* Selection Directory dialog box: */
/***********************************/
bool
EDA_DirectorySelector
(
const
wxString
&
Title
,
/* Titre de la fenetre */
wxString
&
Path
,
/* Chemin par defaut */
int
flag
,
/* reserve */
wxWindow
*
Frame
,
/* parent frame */
bool
EDA_DirectorySelector
(
const
wxString
&
Title
,
wxString
&
Path
,
int
flag
,
wxWindow
*
Frame
,
const
wxPoint
&
Pos
)
{
int
ii
;
bool
selected
=
FALSE
;
wxDirDialog
*
DirFrame
=
new
wxDirDialog
(
Frame
,
wxString
(
Title
),
Path
,
/* Chemin par defaut */
flag
,
Pos
);
wxDirDialog
*
DirFrame
=
new
wxDirDialog
(
Frame
,
wxString
(
Title
),
Path
,
flag
,
Pos
);
ii
=
DirFrame
->
ShowModal
();
if
(
ii
==
wxID_OK
)
...
...
@@ -227,18 +228,24 @@ bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre *
}
/******************************/
/* Selection file dialog box: */
/******************************/
wxString
EDA_FileSelector
(
const
wxString
&
Title
,
/* Dialog title */
const
wxString
&
Path
,
/* Default path */
const
wxString
&
FileName
,
/* default filename */
const
wxString
&
Ext
,
/* default filename extension */
const
wxString
&
Mask
,
/* filter for filename list */
wxWindow
*
Frame
,
/* parent frame */
int
flag
,
/* wxFD_SAVE, wxFD_OPEN ..*/
const
bool
keep_working_directory
,
/* true = keep the current path */
/* Selection file dialog box:
* Dialog title
* Default path
* default filename
* default filename extension
* filter for filename list
* parent frame
* wxFD_SAVE, wxFD_OPEN ..
* true = keep the current path
*/
wxString
EDA_FileSelector
(
const
wxString
&
Title
,
const
wxString
&
Path
,
const
wxString
&
FileName
,
const
wxString
&
Ext
,
const
wxString
&
Mask
,
wxWindow
*
Frame
,
int
flag
,
const
bool
keep_working_directory
,
const
wxPoint
&
Pos
)
{
wxString
fullfilename
;
...
...
@@ -255,15 +262,13 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
wxSetWorkingDirectory
(
defaultpath
);
#if 0 && defined (DEBUG)
printf(
"defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8( Ext ),
CONV_TO_UTF8( Mask ),
flag,
keep_working_directory
);
printf( "defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8( Ext ),
CONV_TO_UTF8( Mask ),
flag,
keep_working_directory );
#endif
fullfilename
=
wxFileSelector
(
wxString
(
Title
),
...
...
@@ -282,10 +287,6 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
}
/********************************************************/
wxString
FindKicadHelpPath
()
/********************************************************/
/** Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
...
...
@@ -306,6 +307,7 @@ wxString FindKicadHelpPath()
* default = en (if not found = fr)
*
*/
wxString
FindKicadHelpPath
()
{
wxString
FullPath
,
LangFullPath
,
tmp
;
wxString
LocaleString
;
...
...
@@ -373,10 +375,6 @@ wxString FindKicadHelpPath()
}
/********************************************************/
wxString
FindKicadFile
(
const
wxString
&
shortname
)
/********************************************************/
/* Search the executable file shortname in kicad binary path
* and return full file name if found or shortname
* kicad binary path is
...
...
@@ -385,20 +383,23 @@ wxString FindKicadFile( const wxString& shortname )
* kicad binary path is found from:
* BinDir
* or environment variable KICAD
* or (default) c:\kicad o
u
/usr/local/kicad
* or (default) c:\kicad o
r
/usr/local/kicad
* or default binary path
*/
wxString
FindKicadFile
(
const
wxString
&
shortname
)
{
wxString
FullFileName
;
/* test de la presence du fichier shortname dans le repertoire de
* des binaires de kicad */
/* Test the presence of the file in the directory shortname of
* the kicad binary path.
*/
FullFileName
=
wxGetApp
().
m_BinDir
+
shortname
;
if
(
wxFileExists
(
FullFileName
)
)
return
FullFileName
;
/* test de la presence du fichier shortname dans le repertoire
* defini par la variable d'environnement KICAD */
/* Test the presence of the file in the directory shortname
* defined by the environment variable KiCAD.
*/
if
(
wxGetApp
().
m_Env_Defined
)
{
FullFileName
=
wxGetApp
().
m_KicadEnv
+
shortname
;
...
...
@@ -448,31 +449,29 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
}
/***********************************/
wxString
ReturnKicadDatasPath
()
/***********************************/
/* Retourne le chemin des donnees communes de kicad.
* Si variable d'environnement KICAD definie (KICAD = chemin pour kicad),
* retourne <KICAD>/;
* Sinon retourne <Chemin des binaires>/ (si "kicad" est dans le nom du chemin)
* Sinon retourne /usr/share/kicad/
/* Return data path common kicad.
* If environment variable defined KiCAD (KiCAD = path to kicad)
* Returns <KICAD> /;
* Otherwise returns <path of binaries> / (if "kicad" is in the path name)
* Otherwise returns / usr / share / kicad /
*
*
Remarqu
e:
*
Les \ sont remplac�s par / (a la mode
Unix)
*
Not
e:
*
The \ are replaced by / (a la
Unix)
*/
wxString
ReturnKicadDatasPath
()
{
bool
PathFound
=
FALSE
;
wxString
data_path
;
if
(
wxGetApp
().
m_Env_Defined
)
// Chemin impose par la variable d'environnement
if
(
wxGetApp
().
m_Env_Defined
)
// Path defined by the KICAD environment
// variable.
{
data_path
=
wxGetApp
().
m_KicadEnv
;
PathFound
=
TRUE
;
}
else
//
Chemin cherche par le chemin des executables
else
//
Path of executables.
{
// le chemin est bindir../
wxString
tmp
=
wxGetApp
().
m_BinDir
;
#ifdef __WINDOWS__
tmp
.
MakeLower
();
...
...
@@ -529,26 +528,27 @@ wxString ReturnKicadDatasPath()
/*
* Return the prefered editor name
* Return the prefer
r
ed editor name
*/
wxString
&
WinEDA_App
::
GetEditorName
()
{
wxString
editorname
=
m_EditorName
;
// We get the prefered editor name from environment variable first.
// We get the prefer
r
ed editor name from environment variable first.
if
(
editorname
.
IsEmpty
()
)
{
wxGetEnv
(
wxT
(
"EDITOR"
),
&
editorname
);
}
if
(
editorname
.
IsEmpty
()
)
// We must get a prefered editor name
if
(
editorname
.
IsEmpty
()
)
// We must get a prefer
r
ed editor name
{
DisplayInfoMessage
(
NULL
,
_
(
"No default editor found, you must choose it"
)
);
DisplayInfoMessage
(
NULL
,
_
(
"No default editor found, you must choose it"
)
);
wxString
mask
(
wxT
(
"*"
)
);
#ifdef __WINDOWS__
mask
+=
wxT
(
".exe"
);
#endif
editorname
=
EDA_FileSelector
(
_
(
"Prefered Editor:"
),
wxEmptyString
,
editorname
=
EDA_FileSelector
(
_
(
"Prefer
r
ed Editor:"
),
wxEmptyString
,
wxEmptyString
,
wxEmptyString
,
mask
,
NULL
,
wxFD_OPEN
,
true
);
}
...
...
@@ -563,15 +563,12 @@ wxString& WinEDA_App::GetEditorName()
}
/***********************************/
bool
OpenPDF
(
const
wxString
&
file
)
/***********************************/
/** Function OpenPDF
* run the PDF viewer and display a PDF file
* @param file = PDF file to open
* @return true is success, false if no PDF viewer found
*/
bool
OpenPDF
(
const
wxString
&
file
)
{
wxString
command
;
wxString
filename
=
file
;
...
...
@@ -579,7 +576,7 @@ bool OpenPDF( const wxString& file )
bool
success
=
false
;
wxGetApp
().
ReadPdfBrowserInfos
();
if
(
!
wxGetApp
().
m_PdfBrowserIsDefault
)
// Run the prefered PDF Browser
if
(
!
wxGetApp
().
m_PdfBrowserIsDefault
)
// Run the prefer
r
ed PDF Browser
{
AddDelimiterString
(
filename
);
command
=
wxGetApp
().
m_PdfBrowser
+
wxT
(
" "
)
+
filename
;
...
...
@@ -594,7 +591,8 @@ bool OpenPDF( const wxString& file )
delete
filetype
;
#ifndef __WINDOWS__
// Bug ? under linux wxWidgets returns acroread as PDF viewer,even it not exists
// Bug ? under linux wxWidgets returns acroread as PDF viewer, even
// it does not exist.
if
(
command
.
StartsWith
(
wxT
(
"acroread"
)
)
)
// Workaround
success
=
false
;
#endif
...
...
@@ -661,9 +659,7 @@ bool OpenPDF( const wxString& file )
}
/*************************************/
void
OpenFile
(
const
wxString
&
file
)
/*************************************/
{
wxString
command
;
wxString
filename
=
file
;
...
...
@@ -672,7 +668,8 @@ void OpenFile( const wxString& file )
wxString
ext
,
type
;
ext
=
CurrentFileName
.
GetExt
();
wxFileType
*
filetype
=
wxTheMimeTypesManager
->
GetFileTypeFromExtension
(
ext
);
wxFileType
*
filetype
=
wxTheMimeTypesManager
->
GetFileTypeFromExtension
(
ext
);
bool
success
=
false
;
...
...
common/gr_basic.cpp
View file @
bc5d9a75
...
...
@@ -18,59 +18,63 @@
#endif
/* Important Note:
* These drawing functions clip draw item before send these items to wxDC draw functions.
* For guy who aks why i did it, see a sample of problems encounted when pixels
* These drawing functions clip draw item before send these items to wxDC draw
* functions. For guy who asks why i did it, see a sample of problems encountered
* when pixels
* coordinates overflow 16 bits values:
* http://trac.wxwidgets.org/ticket/10446
* Problems can be found under Windows **and** Linux (mainly when drawing arcs)
* (mainly at low zoom values (2, 1 or 0.5), in pcbnew)
* some of these problems could be now fixed in recent distributions.
*
* Currently (feb 2009) there are overflow problems when drawing solid (filled) polygons under linux without clipping
* Currently (feb 2009) there are overflow problems when drawing solid (filled)
* polygons under linux without clipping
*
* So before removing cliping functions, be aware these bug (they are not in kicad or wxWidgets)
* are fixed by testing how are drawn complex lines arcs and solid polygons under Windows and Linux
* and remember users can have old versions with bugs
* So before removing clipping functions, be aware these bug (they are not in
* kicad or wxWidgets) are fixed by testing how are drawn complex lines arcs
* and solid polygons under Windows and Linux and remember users can have old
* versions with bugs
*/
/* variables generales */
//
pour les tracÈs en mode XOR = GR_XOR ou GR_NXOR selon couleur de fond
//
For draw mode = XOR GR_XOR or GR_NXOR by background color
int
g_XorMode
=
GR_NXOR
;
// couleur de fond de la frame de dessin
// Background color of the design frame
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
);
void
ClipAndDrawFilledPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
wxPoint
Points
[],
int
n
);
#endif
/* global variables */
extern
BASE_SCREEN
*
ActiveScreen
;
/* Variables locales */
static
int
GRLastMoveToX
,
GRLastMoveToY
;
static
int
PenMinWidth
=
1
;
/* largeur minimum de la plume (DOIT etre
> 0)
* (utile pour trace sur imprimante)
*/
static
bool
ForceBlackPen
;
/* si != 0 : traces en noir (utilise pour trace
* sur imprimante
*/
static
int
xcliplo
=
0
,
ycliplo
=
0
,
xcliphi
=
2000
,
ycliphi
=
2000
;
/* coord de la surface de trace */
static
int
lastcolor
=
-
1
;
static
int
lastwidth
=
-
1
;
static
int
GRLastMoveToX
,
GRLastMoveToY
;
static
int
PenMinWidth
=
1
;
/* minimum pen width (must be
> 0)
* (Useful for printing)
*/
static
bool
ForceBlackPen
;
/* if true: draws in black instead of
* color for printing.
*/
static
int
xcliplo
=
0
,
ycliplo
=
0
,
xcliphi
=
2000
,
ycliphi
=
2000
;
static
int
lastcolor
=
-
1
;
static
int
lastwidth
=
-
1
;
static
int
s_Last_Pen_Style
=
-
1
;
static
wxDC
*
lastDC
=
NULL
;
/*
*
Macro de clipping du trace d'une lig
ne:
*
la ligne (x1,y1 x2,y2) est clippee pour rester dans le cadre
*
(xcliplo,ycliplo xcliphi,ycliphi) (variables globales,locales a ce fichier
)
*
Ceci est necessaire sous WIN95 car les coord de
trace
*
(bien que en int 32bits) sont tronquees en 16 bits (stupide
BG)
*
Macro clipping the trace of a li
ne:
*
Line (x1, y1 x2, y2) is clipped to remain within
*
(Xcliplo, ycliplo xcliphi, ycliphi) (global variables, local to this file
)
*
This is necessary because under WIN95 coord
trace
*
(Though an int 32 bits) are truncated to 16 bits (stupid
BG)
*/
#ifndef us
#define us unsigned int
...
...
@@ -260,9 +264,8 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
}
/* Routine de forcage de la reinit de la plume courante.
* Doit etre appelee par securite apres changement de contexte graphique
* avant tout trace
/* Forcing a reset of the current pen.
* Must be called after changing the graphical device before any trace.
*/
void
GRResetPenAndBrush
(
wxDC
*
DC
)
{
...
...
@@ -272,7 +275,6 @@ void GRResetPenAndBrush( wxDC* DC )
}
/* routine d'ajustage de la largeur mini de plume */
void
SetPenMinWidth
(
int
minwidth
)
{
PenMinWidth
=
minwidth
;
...
...
@@ -319,9 +321,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
}
/***********************************************/
void
GRSetBrush
(
wxDC
*
DC
,
int
Color
,
int
fill
)
/***********************************************/
{
if
(
ForceBlackPen
)
Color
=
BLACK
;
...
...
@@ -336,65 +336,59 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
}
/*************************************/
void
GRForceBlackPen
(
bool
flagforce
)
/*************************************/
/** function GRForceBlackPen
* @param flagforce True to force a black pen whenever the asked color
*/
void
GRForceBlackPen
(
bool
flagforce
)
{
ForceBlackPen
=
flagforce
;
}
/***********************************/
bool
GetGRForceBlackPenState
(
void
)
/***********************************/
/** function GetGRForceBlackPenState
* @return ForceBlackPen (True if a black pen was forced)
*/
bool
GetGRForceBlackPenState
(
void
)
{
return
ForceBlackPen
;
}
/*************************************
*********
/
/*
Routine pour selectionner le mode de trace
*/
/*************************************
*********
/
/*************************************/
/*
Set the device context draw mode.
*/
/*************************************/
void
GRSetDrawMode
(
wxDC
*
DC
,
int
draw_mode
)
{
if
(
draw_mode
&
GR_OR
)
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION(2,9,0) )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC
->
SetLogicalFunction
(
wxCOPY
);
#else
DC
->
SetLogicalFunction
(
wxOR
);
#endif
else
if
(
draw_mode
&
GR_XOR
)
DC
->
SetLogicalFunction
(
wxXOR
);
else
if
(
draw_mode
&
GR_NXOR
)
#if defined (__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION(2,9,0) )
DC
->
SetLogicalFunction
(
wxXOR
);
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC
->
SetLogicalFunction
(
wxXOR
);
#else
DC
->
SetLogicalFunction
(
wxEQUIV
);
DC
->
SetLogicalFunction
(
wxEQUIV
);
#endif
else
else
DC
->
SetLogicalFunction
(
wxCOPY
);
}
/*********************************************************************/
void
GRPutPixel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
Color
)
/*********************************************************************/
{
GRSPutPixel
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
Color
);
}
/********************************************************************/
void
GRSPutPixel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
Color
)
/********************************************************************/
{
if
(
ClipBox
&&
!
ClipBox
->
Inside
(
x
,
y
)
)
return
;
...
...
@@ -404,10 +398,6 @@ void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
}
/*******************************************/
/* int GRGetPixel(wxDC * DC, int x, int y) */
/*******************************************/
int
GRGetPixel
(
wxDC
*
DC
,
int
x
,
int
y
)
{
wxColour
colour
;
...
...
@@ -430,24 +420,39 @@ int GRGetPixel( wxDC* DC, int x, int y )
}
/****************************************************************************
* Routine to draw a line, in Object spaces. *
****************************************************************************/
void
GRLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
/*
* Draw a line, in object space.
*/
void
GRLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
GRSLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
void
GRLine
(
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
wxPoint
aStart
,
wxPoint
aEnd
,
int
aWidth
,
int
aColor
)
void
GRLine
(
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
wxPoint
aStart
,
wxPoint
aEnd
,
int
aWidth
,
int
aColor
)
{
GRSLine
(
aClipBox
,
aDC
,
GRMapX
(
aStart
.
x
),
GRMapY
(
aStart
.
y
),
GRMapX
(
aEnd
.
x
),
GRMapY
(
aEnd
.
y
),
ZoomValue
(
aWidth
),
aColor
);
GRSLine
(
aClipBox
,
aDC
,
GRMapX
(
aStart
.
x
),
GRMapY
(
aStart
.
y
),
GRMapX
(
aEnd
.
x
),
GRMapY
(
aEnd
.
y
),
ZoomValue
(
aWidth
),
aColor
);
}
/***************************************************/
/* Routine to draw a Dashed line, in Screen space. */
/***************************************************/
/*
* Draw a dashed line, in screen space.
*/
void
GRSDashedLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
...
...
@@ -467,7 +472,12 @@ void GRSDashedLine( EDA_Rect* ClipBox,
}
void
GRSDashedLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
void
GRSDashedLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
lastcolor
=
-
1
;
GRSetColorPen
(
DC
,
Color
,
width
,
wxSHORT_DASH
);
...
...
@@ -479,12 +489,18 @@ void GRSDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, in
}
/****************************************************************************
* Routine to draw a Dashed line, in Object spaces. *
****************************************************************************/
void
GRDashedLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
/*
* Draw a dashed line, in object space.
*/
void
GRDashedLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
GRSDashedLineTo
(
ClipBox
,
DC
,
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSDashedLineTo
(
ClipBox
,
DC
,
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
...
...
@@ -497,14 +513,14 @@ void GRDashedLine( EDA_Rect* ClipBox,
int
width
,
int
Color
)
{
GRSDashedLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSDashedLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
/*
***************************************************************************
* Routine to move to a new position, in Object space. *
***************************************************************************
*/
/*
* Move to a new position, in object space.
*/
void
GRMoveTo
(
int
x
,
int
y
)
{
GRLastMoveToX
=
GRMapX
(
x
);
...
...
@@ -512,22 +528,28 @@ void GRMoveTo( int x, int y )
}
/*
******************************************************/
/* Routine to draw to a new position, in Object space. */
/******************************************************
*/
/*
* Draw line to a new position, in object space.
*/
void
GRLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
{
int
GRLineToX
,
GRLineToY
;
GRLineToX
=
GRMapX
(
x
);
GRLineToY
=
GRMapY
(
y
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
ZoomValue
(
width
),
Color
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
ZoomValue
(
width
),
Color
);
}
/*
************************************************/
/* Routine to draw a Mixed line, in Object space */
/************************************************
*/
/*
* Draw a mixed line, in object space.
*/
void
GRMixedLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
...
...
@@ -537,14 +559,14 @@ void GRMixedLine( EDA_Rect* ClipBox,
int
width
,
int
Color
)
{
GRSMixedLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSMixedLine
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
/*
**********************************************************/
/* Routine to draw a Mixed line, in Screen (Pixels) space */
/**********************************************************
*/
/*
* Draw a mixed line, in screen (Pixels) space.
*/
void
GRSMixedLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
...
...
@@ -560,9 +582,9 @@ void GRSMixedLine( EDA_Rect* ClipBox,
}
/*
***************************************************************************
* Routine to move to a new position, in Screen (pixels) space. *
***************************************************************************
*/
/*
* Move to a new position, in screen (pixels) space.
*/
void
GRSMoveTo
(
int
x
,
int
y
)
{
GRLastMoveToX
=
x
;
...
...
@@ -570,30 +592,43 @@ void GRSMoveTo( int x, int y )
}
/****************************************************************************
* Routine to draw to a new position, in Screen (pixels) space. *
****************************************************************************/
void
GRSLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
/*
* Draw line to a new position, in screen (pixels) space.
*/
void
GRSLineTo
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
{
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
x
,
y
,
width
,
Color
);
GRLastMoveToX
=
x
;
GRLastMoveToY
=
y
;
GRLastMoveToX
=
x
;
GRLastMoveToY
=
y
;
}
/****************************************************************************
* Routine to draw to a new position, in Screen (pixels) space. *
****************************************************************************/
void
GRSLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
/*
* Draw line to a new position, in screen (pixels) space.
*/
void
GRSLine
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
WinClipAndDrawLine
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
Color
,
width
);
GRLastMoveToX
=
x2
;
GRLastMoveToY
=
y2
;
GRLastMoveToX
=
x2
;
GRLastMoveToY
=
y2
;
}
/****************************************************************************/
/* Routine to move to a new position relative to current one, as in Object */
/* space. */
/****************************************************************************/
/*
* Move to a new position relative to current one, in object space.
*/
void
GRMoveRel
(
int
x
,
int
y
)
{
GRLastMoveToX
+=
ZoomValue
(
x
);
...
...
@@ -601,11 +636,15 @@ void GRMoveRel( int x, int y )
}
/****************************************************************************
* Routine to line to a new position relative to current one, as in Object *
* space. *
****************************************************************************/
void
GRLineRel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
/*
* Draw a line to a new position relative to current one, in object space.
*/
void
GRLineRel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
{
int
GRLineToX
=
GRLastMoveToX
,
GRLineToY
=
GRLastMoveToY
;
...
...
@@ -613,15 +652,21 @@ void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color
GRLineToX
+=
ZoomValue
(
x
);
GRLineToY
+=
ZoomValue
(
y
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
ZoomValue
(
width
),
Color
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
ZoomValue
(
width
),
Color
);
}
/*
***************************************************************************
* Routine to move to a new position relative to current one, as in Screen *
* space (pixel coords.). *
***************************************************************************
*/
/*
* Move to a new position relative to current one, in screen space
* (pixel coords.).
*/
void
GRSMoveRel
(
int
x
,
int
y
)
{
GRLastMoveToX
+=
x
;
...
...
@@ -629,50 +674,58 @@ void GRSMoveRel( int x, int y )
}
/****************************************************************************
* Routine to line to a new position relative to current one, as in Screen *
* space (pixel coords.). *
****************************************************************************/
void
GRSLineRel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
/*
* Draw line to a new position relative to current one, in screen space
* (pixel coords.).
*/
void
GRSLineRel
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
width
,
int
Color
)
{
long
GRLineToX
=
GRLastMoveToX
+
x
,
GRLineToY
=
GRLastMoveToY
+
y
;
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
width
,
Color
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
GRLineToX
,
GRLineToY
,
width
,
Color
);
GRLastMoveToX
=
GRLineToX
;
GRLastMoveToY
=
GRLineToY
;
}
/**************************************************/
/* Routine de trace d'un segment a bouts arrondis */
/* Object space = real coords.). */
/**************************************************/
/*
* Draw segment with rounded ends in object space.
*/
void
GRCSegm
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
GRSCSegm
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSCSegm
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
/*******************************************************************
* Routine de trace d'un segment (plein) a bouts arrondis in Object *
* space (real coords.). *
********************************************************************/
/*
* Draw segment (full) with rounded ends in object space (real coords.).
*/
void
GRFillCSegm
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
GRSFillCSegm
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
GRSFillCSegm
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
ZoomValue
(
width
),
Color
);
}
/**********************************************************/
/* Routine de trace d'un segment (plein) a bouts arrondis */
/* ( Screen space = pixel coords.). */
/**********************************************************/
/*
* Draw segment with rounded ends in screen space.
*/
void
GRSFillCSegm
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
...
...
@@ -686,17 +739,23 @@ void GRSFillCSegm( EDA_Rect* ClipBox,
}
/****************************************************************/
/* Routine de trace d'un segment a bouts arrondis (Mode SKETCH) */
/* Screen space (pixel coords.). */
/****************************************************************/
void
GRSCSegm
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
/*
* Draw segment with rounded ends (SKETCH mode) in screen space
*/
void
GRSCSegm
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
long
ra
yon
;
long
ra
dius
;
int
dwx
,
dwy
;
long
dx
,
dy
,
dwx2
,
dwy2
;
long
sx1
,
sy1
,
ex1
,
ey1
;
/* coord du 1er bord */
long
sx2
,
sy2
,
ex2
,
ey2
;
/* coord du 1eme bord */
long
sx1
,
sy1
,
ex1
,
ey1
;
long
sx2
,
sy2
,
ex2
,
ey2
;
bool
swap_ends
=
FALSE
;
...
...
@@ -721,7 +780,7 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
}
if
(
width
<=
2
)
/*
ligne simple ou epaisse de 2 pixels
*/
if
(
width
<=
2
)
/*
single line or 2 pixels
*/
{
GRSetColorPen
(
DC
,
Color
,
width
);
DC
->
DrawLine
(
x1
,
y1
,
x2
,
y2
);
...
...
@@ -731,14 +790,14 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
GRSetColorPen
(
DC
,
Color
);
GRSetBrush
(
DC
,
Color
,
FALSE
);
ra
yon
=
(
width
+
1
)
>>
1
;
ra
dius
=
(
width
+
1
)
>>
1
;
dx
=
x2
-
x1
;
dy
=
y2
-
y1
;
if
(
dx
==
0
)
/* segment vertical */
{
dwx
=
ra
yon
;
dwx
=
ra
dius
;
if
(
dy
>=
0
)
dwx
=
-
dwx
;
...
...
@@ -760,7 +819,7 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
}
else
if
(
dy
==
0
)
/* segment horizontal */
{
dwy
=
ra
yon
;
dwy
=
ra
dius
;
if
(
dx
<
0
)
dwy
=
-
dwy
;
...
...
@@ -782,9 +841,9 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
}
else
{
if
(
ABS
(
dx
)
==
ABS
(
dy
)
)
/* segment
a 45 degre
*/
if
(
ABS
(
dx
)
==
ABS
(
dy
)
)
/* segment
45 degrees
*/
{
dwx
=
dwy
=
(
(
width
*
5
)
+
4
)
/
7
;
// = width
/
2 * 0.707
dwx
=
dwy
=
(
(
width
*
5
)
+
4
)
/
7
;
// = width
/
2 * 0.707
if
(
dy
<
0
)
{
if
(
dx
<=
0
)
...
...
@@ -847,7 +906,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
Xmin
=
Xmax
=
Points
[
0
].
x
;
Ymin
=
Ymax
=
Points
[
0
].
y
;
for
(
int
ii
=
1
;
ii
<
n
;
ii
++
)
// calcul
du rectangle d'encadrement
for
(
int
ii
=
1
;
ii
<
n
;
ii
++
)
// calcul
ate rectangle
{
Xmin
=
MIN
(
Xmin
,
Points
[
ii
].
x
);
Xmax
=
MAX
(
Xmax
,
Points
[
ii
].
x
);
...
...
@@ -873,11 +932,17 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
}
/************************************************************************/
/* Routine to draw a new polyline and fill it if Fill, in screen space. */
/************************************************************************/
static
void
GRSPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
n
,
wxPoint
Points
[],
bool
Fill
,
int
width
,
int
Color
,
int
BgColor
)
/*
* Draw a new polyline and fill it if Fill, in screen space.
*/
static
void
GRSPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
n
,
wxPoint
Points
[],
bool
Fill
,
int
width
,
int
Color
,
int
BgColor
)
{
if
(
!
IsGRSPolyDrawable
(
ClipBox
,
n
,
Points
)
)
return
;
...
...
@@ -889,13 +954,13 @@ static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool
GRSetBrush
(
DC
,
BgColor
,
FILLED
);
/* clip before send the filled polygon to wxDC, because under linux
(GTK?)
*
polygonsl
having large coordinates are incorrectly drawn
/* clip before send the filled polygon to wxDC, because under linux
*
(GTK?) polygons
having large coordinates are incorrectly drawn
*/
#ifdef USE_CLIP_FILLED_POLYGONS
ClipAndDrawFilledPoly
(
ClipBox
,
DC
,
Points
,
n
);
#else
DC
->
DrawPolygon
(
n
,
Points
);
//
does not work very well under linux
DC
->
DrawPolygon
(
n
,
Points
);
//
does not work very well under linux
#endif
}
else
...
...
@@ -913,11 +978,17 @@ static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool
}
/******************************************************************************/
/* Routine to draw a new closed polyline and fill it if Fill, in screen space */
/******************************************************************************/
static
void
GRSClosedPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
aPointCount
,
wxPoint
aPoints
[],
bool
Fill
,
int
width
,
int
Color
,
int
BgColor
)
/*
* Draw a new closed polyline and fill it if Fill, in screen space.
*/
static
void
GRSClosedPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
aPointCount
,
wxPoint
aPoints
[],
bool
Fill
,
int
width
,
int
Color
,
int
BgColor
)
{
if
(
!
IsGRSPolyDrawable
(
ClipBox
,
aPointCount
,
aPoints
)
)
return
;
...
...
@@ -935,18 +1006,25 @@ static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int aPointCount, wxPoint
GRSetBrush
(
DC
,
BgColor
);
DC
->
DrawLines
(
aPointCount
,
aPoints
);
/*
Fermeture du polygone
*/
/*
Close the polygon.
*/
if
(
aPoints
[
aPointCount
-
1
]
!=
aPoints
[
0
]
)
{
GRSLine
(
ClipBox
,
DC
,
aPoints
[
0
].
x
,
aPoints
[
0
].
y
,
aPoints
[
aPointCount
-
1
].
x
,
aPoints
[
aPointCount
-
1
].
y
,
width
,
Color
);
GRSLine
(
ClipBox
,
DC
,
aPoints
[
0
].
x
,
aPoints
[
0
].
y
,
aPoints
[
aPointCount
-
1
].
x
,
aPoints
[
aPointCount
-
1
].
y
,
width
,
Color
);
}
}
}
/* not used
* static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
* static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint
* Points[],
* bool Fill, int Color, int BgColor )
* {
* GRSClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
...
...
@@ -954,9 +1032,9 @@ static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int aPointCount, wxPoint
*/
/*
***********************************************************************/
/* Routine to draw a new polyline and fill it if Fill, in drawing space. */
/***********************************************************************
*/
/*
* Draw a new polyline and fill it if Fill, in drawing space.
*/
void
GRPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
n
,
wxPoint
Points
[],
bool
Fill
,
int
width
,
int
Color
,
int
BgColor
)
{
...
...
@@ -971,9 +1049,9 @@ void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
}
/*
*************************************************************************/
/* Routine to draw a closed polyline and fill it if Fill, in object space */
/*************************************************************************
*/
/*
* Draw a closed polyline and fill it if Fill, in object space.
*/
void
GRClosedPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
n
,
wxPoint
Points
[],
bool
Fill
,
int
Color
,
int
BgColor
)
{
...
...
@@ -995,38 +1073,39 @@ void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
}
/*
**********************************************/
/* Routine to draw a circle, in object space. */
/**********************************************
*/
/*
* Draw a circle, in object space.
*/
void
GRCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
r
,
int
Color
)
{
int
cx
=
GRMapX
(
x
);
int
cy
=
GRMapY
(
y
);
int
ra
yon
=
ZoomValue
(
r
);
int
cx
=
GRMapX
(
x
);
int
cy
=
GRMapY
(
y
);
int
ra
dius
=
ZoomValue
(
r
);
GRSCircle
(
ClipBox
,
DC
,
cx
,
cy
,
ra
yon
,
0
,
Color
);
GRSCircle
(
ClipBox
,
DC
,
cx
,
cy
,
ra
dius
,
0
,
Color
);
}
/*
****************************************************/
/* Routine to draw a Filled circle, in object space. */
/****************************************************
*/
/*
* Draw a filled circle, in object space.
*/
void
GRFilledCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
{
r
=
ZoomValue
(
r
);
width
=
ZoomValue
(
width
);
GRSFilledCircle
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
r
,
width
,
Color
,
BgColor
);
GRSFilledCircle
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
r
,
width
,
Color
,
BgColor
);
}
/*
*****************************************************/
/* Routine to draw a FILLED circle, in drawing space. */
/*****************************************************
*/
/*
* Draw a filled circle, in drawing space.
*/
void
GRSFilledCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
{
/*
suppression des cercles hors ecran
*/
/*
Clip circles off screen.
*/
if
(
ClipBox
)
{
int
x0
,
y0
,
xm
,
ym
;
...
...
@@ -1050,10 +1129,16 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
}
/***********************************************************/
/* Routine to draw a circle, in object space. */
/***********************************************************/
void
GRCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
r
,
int
width
,
int
Color
)
/*
* Draw a circle in object space.
*/
void
GRCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
r
,
int
width
,
int
Color
)
{
r
=
ZoomValue
(
r
);
width
=
ZoomValue
(
width
);
...
...
@@ -1061,12 +1146,18 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int
}
/***********************************************/
/* Routine to draw a circle, in drawing space. */
/***********************************************/
void
GRSCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
r
,
int
width
,
int
Color
)
{
/* suppression des cercles hors ecran */
/*
* Draw a circle in drawing space.
*/
void
GRSCircle
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
r
,
int
width
,
int
Color
)
{
/* Clip circles off screen. */
if
(
ClipBox
)
{
int
x0
,
y0
,
xm
,
ym
;
...
...
@@ -1074,13 +1165,13 @@ void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, i
y0
=
ClipBox
->
GetY
();
xm
=
ClipBox
->
GetRight
();
ym
=
ClipBox
->
GetBottom
();
if
(
xc
<
(
x0
-
r
-
width
)
)
if
(
xc
<
(
x0
-
r
-
width
)
)
return
;
if
(
yc
<
(
y0
-
r
-
width
)
)
if
(
yc
<
(
y0
-
r
-
width
)
)
return
;
if
(
xc
>
(
r
+
xm
+
width
)
)
if
(
xc
>
(
r
+
xm
+
width
)
)
return
;
if
(
yc
>
(
r
+
ym
+
width
)
)
if
(
yc
>
(
r
+
ym
+
width
)
)
return
;
}
...
...
@@ -1090,40 +1181,36 @@ void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, i
}
/************************************************/
/* Routine to draw an arc, in USER space. */
/* Debut et fin de l'arc donnes par leur coord. */
/************************************************/
/*
* Draw an arc in user space.
*/
void
GRArc1
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
xc
,
int
yc
,
int
Color
)
{
GRSArc1
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
),
0
,
Color
);
GRSArc1
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
),
0
,
Color
);
}
/************************************************/
/* Routine to draw an arc, width = width in USER space. */
/* Debut et fin de l'arc donnes par leur coord. */
/************************************************/
/*
* Draw an arc, width = width in user space.
*/
void
GRArc1
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
xc
,
int
yc
,
int
width
,
int
Color
)
{
GRSArc1
(
ClipBox
,
DC
,
GRMap
X
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMapY
(
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
),
ZoomValue
(
width
),
Color
);
GRSArc1
(
ClipBox
,
DC
,
GRMapX
(
x1
),
GRMapY
(
y1
),
GRMapX
(
x2
),
GRMap
Y
(
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
),
ZoomValue
(
width
),
Color
);
}
/************************************************/
/* Routine to draw an arc, width = width, in screen space. */
/* Debut et fin de l'arc donnes par leur coord. */
/************************************************/
/*
* Draw an arc, width = width, in screen space.
*/
void
GRSArc1
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
xc
,
int
yc
,
int
width
,
int
Color
)
{
/*
suppression des cercles hors ecran
*/
/*
Clip arcs off screen.
*/
if
(
ClipBox
)
{
int
x0
,
y0
,
xm
,
ym
,
r
;
...
...
@@ -1132,13 +1219,13 @@ void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
xm
=
ClipBox
->
GetRight
();
ym
=
ClipBox
->
GetBottom
();
r
=
(
int
)
hypot
(
x1
-
xc
,
y1
-
yc
);
if
(
xc
<
(
x0
-
r
)
)
if
(
xc
<
(
x0
-
r
)
)
return
;
if
(
yc
<
(
y0
-
r
)
)
if
(
yc
<
(
y0
-
r
)
)
return
;
if
(
xc
>
(
r
+
xm
)
)
if
(
xc
>
(
r
+
xm
)
)
return
;
if
(
yc
>
(
r
+
ym
)
)
if
(
yc
>
(
r
+
ym
)
)
return
;
}
...
...
@@ -1148,16 +1235,22 @@ void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
/********************************************************************/
/* Routine to draw an arc, in screen space. */
/* As the Y axe is inverted the Angles should be inverted as well. */
/********************************************************************/
void
GRSArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
)
/*
* Draw an arc in screen space.
*/
void
GRSArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
)
{
int
x1
,
y1
,
x2
,
y2
;
/*
suppression des cercles hors ecran
*/
/*
Clip arcs off screen.
*/
if
(
ClipBox
)
{
int
x0
,
y0
,
xm
,
ym
;
...
...
@@ -1165,20 +1258,22 @@ void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAn
y0
=
ClipBox
->
GetY
();
xm
=
ClipBox
->
GetRight
();
ym
=
ClipBox
->
GetBottom
();
if
(
xc
<
(
x0
-
r
-
width
)
)
if
(
xc
<
(
x0
-
r
-
width
)
)
return
;
if
(
yc
<
(
y0
-
r
-
width
)
)
if
(
yc
<
(
y0
-
r
-
width
)
)
return
;
if
(
xc
>
(
r
+
xm
+
width
)
)
if
(
xc
>
(
r
+
xm
+
width
)
)
return
;
if
(
yc
>
(
r
+
ym
+
width
)
)
if
(
yc
>
(
r
+
ym
+
width
)
)
return
;
}
x1
=
r
;
y1
=
0
;
x1
=
r
;
y1
=
0
;
RotatePoint
(
&
x1
,
&
y1
,
EndAngle
);
x2
=
r
;
y2
=
0
;
x2
=
r
;
y2
=
0
;
RotatePoint
(
&
x2
,
&
y2
,
StAngle
);
GRSetColorPen
(
DC
,
Color
,
width
);
...
...
@@ -1187,16 +1282,23 @@ void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAn
}
/********************************************************************/
/* Routine to draw an Filled arc, in screen space. */
/* As the Y axes is inverted the Angles should be inverted as well. */
/********************************************************************/
void
GRSFilledArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
/*
* Draw an filled arc in screen space.
*/
void
GRSFilledArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
{
int
x1
,
y1
,
x2
,
y2
;
/*
suppression des cercles hors ecra
n */
/*
Clip arcs off scree
n */
if
(
ClipBox
)
{
int
x0
,
y0
,
xm
,
ym
;
...
...
@@ -1204,20 +1306,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc,
y0
=
ClipBox
->
GetY
();
xm
=
ClipBox
->
GetRight
();
ym
=
ClipBox
->
GetBottom
();
if
(
xc
<
(
x0
-
r
-
1
)
)
if
(
xc
<
(
x0
-
r
-
1
)
)
return
;
if
(
yc
<
(
y0
-
r
-
1
)
)
if
(
yc
<
(
y0
-
r
-
1
)
)
return
;
if
(
xc
>
(
r
+
xm
+
1
)
)
if
(
xc
>
(
r
+
xm
+
1
)
)
return
;
if
(
yc
>
(
r
+
ym
+
1
)
)
if
(
yc
>
(
r
+
ym
+
1
)
)
return
;
}
x1
=
r
;
y1
=
0
;
x1
=
r
;
y1
=
0
;
RotatePoint
(
&
x1
,
&
y1
,
EndAngle
);
x2
=
r
;
y2
=
0
;
x2
=
r
;
y2
=
0
;
RotatePoint
(
&
x2
,
&
y2
,
StAngle
);
GRSetBrush
(
DC
,
BgColor
,
FILLED
);
...
...
@@ -1226,16 +1330,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc,
}
/********************************************************************/
/* Routine to draw a Filled arc, in drawing space. */
/* As the Y axes is inverted the Angles should be inverted as well. */
/********************************************************************/
void
GRFilledArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
/*
* Draw a filled arc in drawing space.
*/
void
GRFilledArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
,
int
BgColor
)
{
width
=
ZoomValue
(
width
);
GRSFilledArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
GRSFilledArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
ZoomValue
(
r
),
width
,
Color
,
BgColor
);
}
...
...
@@ -1243,126 +1353,155 @@ void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y,
void
GRFilledArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
Color
,
int
BgColor
)
{
GRSFilledArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
GRSFilledArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
ZoomValue
(
r
),
0
,
Color
,
BgColor
);
}
/********************************************************************/
/* Routine to draw an arc, in drawing space. */
/* As the Y axes is inverted the Angles should be inverted as well. */
/********************************************************************/
/*
* Draw an arc in drawing space.
*/
void
GRArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
xc
,
int
yc
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
Color
)
{
int
x1
,
y1
,
x2
,
y2
;
/*
suppression des cercles hors ecra
n */
/*
Clip arcs off scree
n */
if
(
ClipBox
)
{
int
ra
yon
=
ZoomValue
(
r
)
+
1
;
int
ra
dius
=
ZoomValue
(
r
)
+
1
;
int
x0
,
y0
,
xm
,
ym
,
x
,
y
;
x0
=
ClipBox
->
GetX
();
y0
=
ClipBox
->
GetY
();
xm
=
ClipBox
->
GetRight
();
ym
=
ClipBox
->
GetBottom
();
x
=
GRMapX
(
xc
);
y
=
GRMapY
(
yc
);
if
(
x
<
(
x0
-
rayon
)
)
if
(
x
<
(
x0
-
radius
)
)
return
;
if
(
y
<
(
y0
-
rayon
)
)
if
(
y
<
(
y0
-
radius
)
)
return
;
if
(
x
>
(
xm
+
rayon
)
)
if
(
x
>
(
xm
+
radius
)
)
return
;
if
(
y
>
(
ym
+
rayon
)
)
if
(
y
>
(
ym
+
radius
)
)
return
;
}
x1
=
r
;
y1
=
0
;
x1
=
r
;
y1
=
0
;
RotatePoint
(
&
x1
,
&
y1
,
EndAngle
);
x2
=
r
;
y2
=
0
;
x2
=
r
;
y2
=
0
;
RotatePoint
(
&
x2
,
&
y2
,
StAngle
);
GRSetColorPen
(
DC
,
Color
);
GRSetBrush
(
DC
,
Color
,
FALSE
);
DC
->
DrawArc
(
GRMapX
(
xc
+
x1
),
GRMapY
(
yc
-
y1
),
GRMapX
(
xc
+
x2
),
GRMapY
(
yc
-
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
)
);
DC
->
DrawArc
(
GRMapX
(
xc
+
x1
),
GRMapY
(
yc
-
y1
),
GRMapX
(
xc
+
x2
),
GRMapY
(
yc
-
y2
),
GRMapX
(
xc
),
GRMapY
(
yc
)
);
}
/********************************************************************/
/* Routine to draw an arc, width = width, in drawing space. */
/* As the Y axes is inverted the Angles should be inverted as well. */
/********************************************************************/
void
GRArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
)
/*
* Draw an arc with width = width in drawing space.
*/
void
GRArc
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x
,
int
y
,
int
StAngle
,
int
EndAngle
,
int
r
,
int
width
,
int
Color
)
{
GRSArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
ZoomValue
(
r
),
ZoomValue
(
width
),
Color
);
GRSArc
(
ClipBox
,
DC
,
GRMapX
(
x
),
GRMapY
(
y
),
StAngle
,
EndAngle
,
ZoomValue
(
r
),
ZoomValue
(
width
),
Color
);
}
/**************************************************/
/* Routine to draw a Rectangle, in drawing space. */
/**************************************************/
void
GRRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
)
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
/*
* Draw a rectangle in drawing space.
*/
void
GRRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
)
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
GRSRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
Color
);
}
/**************************************************/
/* Routine to draw a Rectangle, in drawing space. */
/**************************************************/
void
GRRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
/*
* Draw a rectangle in drawing space.
*/
void
GRRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
)
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
width
=
ZoomValue
(
width
);
GRSRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
width
,
Color
);
}
/************************************************************************************/
/*
* Draw a rectangle (filled with AreaColor) in drawing space.
*/
void
GRFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
,
int
BgColor
)
/************************************************************************************/
/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
GRSFilledRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
0
,
Color
,
BgColor
);
}
/************************************************************************************/
/*
* Draw a rectangle (filled with AreaColor) in drawing space.
*/
void
GRFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
,
int
BgColor
)
/************************************************************************************/
/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */
{
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
x1
=
GRMapX
(
x1
);
y1
=
GRMapY
(
y1
);
x2
=
GRMapX
(
x2
);
y2
=
GRMapY
(
y2
);
width
=
ZoomValue
(
width
);
GRSFilledRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
width
,
Color
,
BgColor
);
}
/*************************************************/
/* Routine to draw a Rectangle, in screen space. */
/*************************************************/
void
GRSRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
)
/*
* Draw a rectangle in screen space.
*/
void
GRSRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
)
{
GRSRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
0
,
Color
);
}
...
...
@@ -1376,7 +1515,6 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
if
(
y1
>
y2
)
EXCHG
(
y1
,
y2
);
/* Clipping des coordonnees */
if
(
ClipBox
)
{
int
xmin
=
ClipBox
->
GetX
();
...
...
@@ -1395,7 +1533,7 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
GRSetColorPen
(
DC
,
Color
,
width
);
if
(
(
x1
==
x2
)
||
(
y1
==
y2
)
)
if
(
(
x1
==
x2
)
||
(
y1
==
y2
)
)
DC
->
DrawLine
(
x1
,
y1
,
x2
,
y2
);
else
{
...
...
@@ -1405,20 +1543,31 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
/* Routine to draw a Filled Rectangle, in screen space. */
/***************************************************************************************/
void
GRSFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
,
int
BgColor
)
/***************************************************************************************/
/*
* Draw a filled rectangle in screen space.
*/
void
GRSFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
Color
,
int
BgColor
)
{
GRSFilledRect
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
0
,
Color
,
BgColor
);
}
/***************************************************************************************/
void
GRSFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
,
int
BgColor
)
/***************************************************************************************/
void
GRSFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
,
int
BgColor
)
{
if
(
x1
>
x2
)
EXCHG
(
x1
,
x2
);
...
...
@@ -1452,7 +1601,7 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
GRSetColorPen
(
DC
,
Color
,
width
);
if
(
(
x1
==
x2
)
||
(
y1
==
y2
)
)
if
(
(
x1
==
x2
)
||
(
y1
==
y2
)
)
DC
->
DrawLine
(
x1
,
y1
,
x2
,
y2
);
else
{
...
...
@@ -1466,14 +1615,17 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
/** Function ClipAndDrawFilledPoly
* Used to clip a polygon and draw it as Filled Polygon
* uses the Sutherland and Hodgman algo to clip the given poly against a
rectangle.
*
This rectangle is the drawing area
*
this is useful under Linux (2009) because filled polygons are incorrectly drawn
*
if they have
too large coordinates (seems due to integer overflows in calculations)
* Could be removed in some years, if become unnecesary.
* uses the Sutherland and Hodgman algo to clip the given poly against a
*
rectangle. This rectangle is the drawing area this is useful under
*
Linux (2009) because filled polygons are incorrectly drawn if they have
* too large coordinates (seems due to integer overflows in calculations)
* Could be removed in some years, if become unneces
s
ary.
*/
#include "SutherlandHodgmanClipPoly.h"
void
ClipAndDrawFilledPoly
(
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
wxPoint
aPoints
[],
int
n
)
void
ClipAndDrawFilledPoly
(
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
wxPoint
aPoints
[],
int
n
)
{
static
vector
<
wxPoint
>
clippedPolygon
;
static
pointVector
inputPolygon
,
outputPolygon
;
...
...
@@ -1482,24 +1634,31 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPoints[], in
outputPolygon
.
clear
();
clippedPolygon
.
clear
();
for
(
int
ii
=
0
;
ii
<
n
;
ii
++
)
inputPolygon
.
push_back
(
PointF
(
(
REAL
)
aPoints
[
ii
].
x
,
(
REAL
)
aPoints
[
ii
].
y
)
);
inputPolygon
.
push_back
(
PointF
(
(
REAL
)
aPoints
[
ii
].
x
,
(
REAL
)
aPoints
[
ii
].
y
)
);
RectF
window
(
(
REAL
)
aClipBox
->
GetX
(),
(
REAL
)
aClipBox
->
GetY
(),
(
REAL
)
aClipBox
->
GetWidth
(),
(
REAL
)
aClipBox
->
GetHeight
()
);
RectF
window
(
(
REAL
)
aClipBox
->
GetX
(),
(
REAL
)
aClipBox
->
GetY
(),
(
REAL
)
aClipBox
->
GetWidth
(),
(
REAL
)
aClipBox
->
GetHeight
()
);
SutherlandHodgman
sh
(
window
);
sh
.
Clip
(
inputPolygon
,
outputPolygon
);
for
(
cpointIterator
cit
=
outputPolygon
.
begin
();
cit
!=
outputPolygon
.
end
();
++
cit
)
for
(
cpointIterator
cit
=
outputPolygon
.
begin
();
cit
!=
outputPolygon
.
end
();
++
cit
)
{
clippedPolygon
.
push_back
(
wxPoint
(
wxRound
(
cit
->
X
),
wxRound
(
cit
->
Y
)
)
);
clippedPolygon
.
push_back
(
wxPoint
(
wxRound
(
cit
->
X
),
wxRound
(
cit
->
Y
)
)
);
}
if
(
clippedPolygon
.
size
()
)
if
(
clippedPolygon
.
size
()
)
aDC
->
DrawPolygon
(
clippedPolygon
.
size
(),
&
clippedPolygon
[
0
]
);
}
#endif
void
GRBezier
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
...
...
common/hotkeys_basic.cpp
View file @
bc5d9a75
...
...
@@ -27,6 +27,7 @@ wxString g_LibEditSectionTag( wxT( "[libedit]" ) );
wxString
g_BoardEditorSectionTag
(
wxT
(
"[pcbnew]"
)
);
wxString
g_ModuleEditSectionTag
(
wxT
(
"[footprinteditor]"
)
);
/* 0 = files are in Home directory (usefull under unix)
* 1 = kicad/template ( usefull only under windows )
* 2 ... = unused
...
...
@@ -35,15 +36,20 @@ int g_ConfigFileLocationChoice;
/* Class to handle hotkey commnands. hotkeys have a default value
* This class allows the real key code changed by user from a key code list file
* This class allows the real key code changed by user from a key code list
* file.
*/
Ki_HotkeyInfo
::
Ki_HotkeyInfo
(
const
wxChar
*
infomsg
,
int
idcommand
,
int
keycode
,
int
idmenuevent
)
Ki_HotkeyInfo
::
Ki_HotkeyInfo
(
const
wxChar
*
infomsg
,
int
idcommand
,
int
keycode
,
int
idmenuevent
)
{
m_KeyCode
=
keycode
;
// Key code (ascii value for ascii keys or wxWidgets code for function key
m_KeyCode
=
keycode
;
// Key code (ascii value for ascii keys
// or wxWidgets code for function key
m_InfoMsg
=
infomsg
;
// info message.
m_Idcommand
=
idcommand
;
// internal id for the corresponding command (see hotkey_id_commnand list)
m_IdMenuEvent
=
idmenuevent
;
// id to call the corresponding event (if any) (see id.h)
m_Idcommand
=
idcommand
;
// internal id for the corresponding
// command (see hotkey_id_commnand list)
m_IdMenuEvent
=
idmenuevent
;
// id to call the corresponding event
// (if any) (see id.h)
}
...
...
@@ -156,16 +162,14 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
};
/****************************************************/
wxString
ReturnKeyNameFromKeyCode
(
int
keycode
)
/****************************************************/
/*
* return the key name from the key code
* Only some wxWidgets key values are handled for function key ( see s_Hotkey_Name_List[] )
* Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] )
* @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name in a wxString
*/
wxString
ReturnKeyNameFromKeyCode
(
int
keycode
)
{
wxString
keyname
,
modifier
,
fullkeyname
;
int
ii
;
...
...
@@ -177,7 +181,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
if
(
(
keycode
&
GR_KB_SHIFT
)
!=
0
)
modifier
<<
wxT
(
"Shift "
);
keycode
&=
~
(
GR_KB_CTRL
|
GR_KB_ALT
|
GR_KB_SHIFT
);
keycode
&=
~
(
GR_KB_CTRL
|
GR_KB_ALT
|
GR_KB_SHIFT
);
for
(
ii
=
0
;
;
ii
++
)
{
if
(
s_Hotkey_Name_List
[
ii
].
m_KeyCode
==
0
)
...
...
@@ -197,16 +201,14 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
}
/**********************************************************************************/
wxString
AddHotkeyName
(
const
wxString
&
text
,
Ki_HotkeyInfo
**
List
,
int
CommandId
)
/**********************************************************************************/
/*
* Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification
*/
wxString
AddHotkeyName
(
const
wxString
&
text
,
Ki_HotkeyInfo
**
List
,
int
CommandId
)
{
wxString
msg
=
text
;
wxString
keyname
=
ReturnKeyNameFromCommandId
(
List
,
CommandId
);
...
...
@@ -217,18 +219,16 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandI
}
/***********************************************************/
wxString
AddHotkeyName
(
const
wxString
&
text
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
int
CommandId
)
/***********************************************************/
/*
* Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of commands
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor* DescrList of
* commands
* @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification
*/
wxString
AddHotkeyName
(
const
wxString
&
text
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
int
CommandId
)
{
wxString
msg
=
text
;
wxString
keyname
;
...
...
@@ -249,16 +249,13 @@ wxString AddHotkeyName( const wxString& text,
}
/*************************************************************************/
wxString
ReturnKeyNameFromCommandId
(
Ki_HotkeyInfo
**
List
,
int
CommandId
)
/*************************************************************************/
/*
* return the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value
* @return the key name in a wxString
*/
wxString
ReturnKeyNameFromCommandId
(
Ki_HotkeyInfo
**
List
,
int
CommandId
)
{
wxString
keyname
;
...
...
@@ -276,16 +273,14 @@ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId )
}
/************************************************************/
static
int
ReturnKeyCodeFromKeyName
(
const
wxString
&
keyname
)
/************************************************************/
/*
* return the key code from its key name
* Only some wxWidgets key values are handled for function key
* @param keyname = wxString key name to find in s_Hotkey_Name_List[], like F2 or space or an usual (ascii) char
* @param keyname = wxString key name to find in s_Hotkey_Name_List[],
* like F2 or space or an usual (ascii) char.
* @return the key code
*/
static
int
ReturnKeyCodeFromKeyName
(
const
wxString
&
keyname
)
{
int
ii
,
keycode
=
0
;
...
...
@@ -305,16 +300,15 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
}
/********************************************************************************************/
void
DisplayHotkeyList
(
WinEDA_DrawFrame
*
frame
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
)
/***************************************************************************************/
/*
* Displays the current hotkey list
* @param frame = current active frame
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list (Null terminated)
* @param List = pointer to a Ki_HotkeyInfoSectionDescriptor list
* (Null terminated)
* @return none
*/
void
DisplayHotkeyList
(
WinEDA_DrawFrame
*
frame
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
)
{
wxString
keyname
;
Ki_HotkeyInfo
**
List
;
...
...
@@ -337,16 +331,13 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame, struct Ki_HotkeyInfoSectionDesc
}
/************************************************************************/
Ki_HotkeyInfo
*
GetDescriptorFromHotkey
(
int
key
,
Ki_HotkeyInfo
**
List
)
/***********************************************************************/
/*
* Return a Ki_HotkeyInfo * pointer fron a key code for OnHotKey() function
* @param key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @return the corresponding Ki_HotkeyInfo
* pointer from the Ki_HotkeyInfo
List
* @return the corresponding Ki_HotkeyInfo
pointer from the Ki_HotkeyInfo
List
*/
Ki_HotkeyInfo
*
GetDescriptorFromHotkey
(
int
key
,
Ki_HotkeyInfo
**
List
)
{
for
(
;
*
List
!=
NULL
;
List
++
)
{
...
...
@@ -359,20 +350,19 @@ Ki_HotkeyInfo* GetDescriptorFromHotkey( int key, Ki_HotkeyInfo** List )
}
/*************************************************************************/
int
WinEDA_BasicFrame
::
WriteHotkeyConfigFile
(
const
wxString
&
Filename
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
bool
verbose
)
/*************************************************************************/
/*
* Create a configuration file (*.key) from the current hotkey list
* @param Filename = default full file name to create. If void, A filename will be asked
* @param Filename = default full file name to create. If void, A filename
* will be asked
* @param List = pointer to the current hotkey list.
* the ouput format is: shortcut "key" "function"
* lines starting with # are comments
*
*/
int
WinEDA_BasicFrame
::
WriteHotkeyConfigFile
(
const
wxString
&
Filename
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
bool
verbose
)
{
wxString
FullFilename
=
Filename
;
FILE
*
cfgfile
;
...
...
@@ -385,15 +375,15 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString&
Mask
=
wxT
(
"*."
)
+
Ext
;
Path
=
ReturnHotkeyConfigFilePath
(
g_ConfigFileLocationChoice
);
FullFilename
=
EDA_FileSelector
(
_
(
"Save Hotkey Configuration File:"
),
Path
,
/* Chemin par defaut */
FullFilename
,
/* nom fichier par defaut */
Ext
,
/* extension par defaut */
Mask
,
/* Masque d'affichage */
Path
,
FullFilename
,
Ext
,
Mask
,
this
,
wxFD_SAVE
,
TRUE
);
TRUE
);
}
if
(
FullFilename
.
IsEmpty
()
)
return
0
;
...
...
@@ -474,21 +464,22 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString&
}
/********************************************************************************************/
int
WinEDA_BasicFrame
::
ReadHotkeyConfigFile
(
const
wxString
&
Filename
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
bool
verbose
)
/********************************************************************************************/
/*
* Read a configuration file (<file>.key) and fill the current hotkey list with hotkeys
* @param Filename = default full file name to create. If void, A filename will be asked
* Read a configuration file (<file>.key) and fill the current hotkey list
* with hotkeys
* @param Filename = default full file name to create. If void, A filename
* will be asked
* @param DescList = current hotkey list descr. to initialise.
* the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify sections
* lines like [xxx] are tags (example: [common] or [libedit] which identify
* sections
*
*/
int
WinEDA_BasicFrame
::
ReadHotkeyConfigFile
(
const
wxString
&
Filename
,
struct
Ki_HotkeyInfoSectionDescriptor
*
DescList
,
bool
verbose
)
{
wxString
FullFilename
=
Filename
;
FILE
*
cfgfile
;
...
...
@@ -501,14 +492,13 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
Mask
=
wxT
(
"*."
)
+
Ext
;
Path
=
ReturnHotkeyConfigFilePath
(
g_ConfigFileLocationChoice
);
FullFilename
=
EDA_FileSelector
(
_
(
"Open Hotkey Configuration File:"
),
Path
,
/* Chemin par defaut */
FullFilename
,
/* nom fichier par defaut */
Ext
,
/* extension par defaut */
Mask
,
/* Masque d'affichage */
Path
,
FullFilename
,
Ext
,
Mask
,
this
,
wxFD_OPEN
,
TRUE
);
TRUE
);
if
(
FullFilename
.
IsEmpty
()
)
return
0
;
}
...
...
@@ -590,13 +580,10 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
}
/****************************************************/
wxString
ReturnHotkeyConfigFilePath
(
int
choice
)
/****************************************************/
/* return the hotkey config file path
* @param choice : 0 = home, 1 = kicad/share/template
*/
wxString
ReturnHotkeyConfigFilePath
(
int
choice
)
{
wxString
path
;
wxAppTraits
*
traits
=
wxGetApp
().
GetTraits
();
...
...
@@ -625,13 +612,10 @@ wxString ReturnHotkeyConfigFilePath( int choice )
}
/***************************************/
void
AddHotkeyConfigMenu
(
wxMenu
*
menu
)
/***************************************/
/** add hotkey config options submenu to a menu
* @param menu : initial menu
*/
void
AddHotkeyConfigMenu
(
wxMenu
*
menu
)
{
wxMenuItem
*
item
;
wxMenu
*
HotkeySubmenu
=
new
wxMenu
();
...
...
@@ -640,7 +624,8 @@ void AddHotkeyConfigMenu( wxMenu* menu )
return
;
/* Show hotkey configuration */
item
=
new
wxMenuItem
(
HotkeySubmenu
,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST
,
item
=
new
wxMenuItem
(
HotkeySubmenu
,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST
,
_
(
"Show"
),
_
(
"Show the current hotkey configuration"
)
);
item
->
SetBitmap
(
info_xpm
);
...
...
@@ -678,41 +663,39 @@ void AddHotkeyConfigMenu( wxMenu* menu )
wxMenu
*
HotkeyLocationSubmenu
=
new
wxMenu
();
/* Home directory */
item
=
new
wxMenuItem
(
HotkeyLocationSubmenu
,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME
,
item
=
new
wxMenuItem
(
HotkeyLocationSubmenu
,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME
,
_
(
"Home directory"
),
_
(
"Use home directory to load or store Hotkey config files"
),
wxITEM_CHECK
);
HotkeyLocationSubmenu
->
Append
(
item
);
/* KiCad template directory */
item
=
new
wxMenuItem
(
HotkeyLocationSubmenu
,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD
,
/* KiCad template directory */
item
=
new
wxMenuItem
(
HotkeyLocationSubmenu
,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD
,
_
(
"KiCad template directory"
),
_
(
"Use kicad/template directory to load or store Hotkey config files"
),
wxITEM_CHECK
);
HotkeyLocationSubmenu
->
Append
(
item
);
/* Append location submenu to HotkeySubmenu */
ADD_MENUITEM_WITH_HELP_AND_SUBMENU
(
HotkeySubmenu
,
HotkeyLocationSubmenu
,
-
1
,
_
(
"Location"
),
_
(
"Select hotkey configuration file location"
),
right_xpm
);
ADD_MENUITEM_WITH_HELP_AND_SUBMENU
(
HotkeySubmenu
,
HotkeyLocationSubmenu
,
-
1
,
_
(
"Location"
),
_
(
"Select hotkey configuration file location"
),
right_xpm
);
HotkeyLocationSubmenu
->
Check
(
ID_PREFERENCES_HOTKEY_PATH_IS_HOME
,
g_ConfigFileLocationChoice
==
0
);
g_ConfigFileLocationChoice
==
0
);
HotkeyLocationSubmenu
->
Check
(
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD
,
g_ConfigFileLocationChoice
==
1
);
g_ConfigFileLocationChoice
==
1
);
}
/************************************************************************/
void
HandleHotkeyConfigMenuSelection
(
WinEDA_DrawFrame
*
frame
,
int
id
)
/************************************************************************/
/* called on hotkey file location selecton menu
* @param frame = current WinEDA_DrawFrame
* @param id = selected menu id
* @return g_ConfigFileLocationChoice (global) = new selection
*/
void
HandleHotkeyConfigMenuSelection
(
WinEDA_DrawFrame
*
frame
,
int
id
)
{
wxMenuBar
*
menu
=
frame
->
GetMenuBar
();
...
...
common/msgpanel.cpp
View file @
bc5d9a75
/****************
**************************************************
/
/* msgpanel.cpp
- fonctions des classes du type WinEDA_MsgPanel
*/
/****************
**************************************************
/
/****************/
/* msgpanel.cpp */
/****************/
#ifdef __GNUG__
#pragma implementation
...
...
@@ -12,16 +12,11 @@
#include "colors.h"
/* table des evenements captes par un WinEDA_MsgPanel */
BEGIN_EVENT_TABLE
(
WinEDA_MsgPanel
,
wxPanel
)
EVT_PAINT
(
WinEDA_MsgPanel
::
OnPaint
)
END_EVENT_TABLE
()
/***********************************************************/
/* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */
/***********************************************************/
WinEDA_MsgPanel
::
WinEDA_MsgPanel
(
WinEDA_DrawFrame
*
parent
,
int
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
)
:
wxPanel
(
parent
,
id
,
pos
,
size
)
...
...
@@ -75,9 +70,7 @@ wxSize WinEDA_MsgPanel::computeTextSize( const wxString& text )
}
/*************************************************/
void
WinEDA_MsgPanel
::
OnPaint
(
wxPaintEvent
&
event
)
/*************************************************/
{
wxPaintDC
dc
(
this
);
...
...
@@ -128,22 +121,18 @@ void WinEDA_MsgPanel::AppendMessage( const wxString& textUpper,
Refresh
();
}
/*****************************************************************************/
void
WinEDA_MsgPanel
::
Affiche_1_Parametre
(
int
pos_X
,
const
wxString
&
texte_H
,
const
wxString
&
texte_L
,
int
color
)
/*****************************************************************************/
/*
* Routine d'affichage d'un parametre.
* pos_X = cadrage horizontal
* si pos_X < 0 : la position horizontale est la derniere
* valeur demandee >= 0
* texte_H = texte a afficher en ligne superieure.
* si "", par d'affichage sur cette ligne
* texte_L = texte a afficher en ligne inferieure.
* si "", par d'affichage sur cette ligne
* color = couleur d'affichage
* Display a parameter in message panel.
* pos_X = horizontal position
* If pos_X < 0: horizontal position is the last
* Required value >= 0
* Texte_H = text to be displayed in top line.
* Texte_L = text to be displayed in bottom line.
* Color = color display
*/
void
WinEDA_MsgPanel
::
Affiche_1_Parametre
(
int
pos_X
,
const
wxString
&
texte_H
,
const
wxString
&
texte_L
,
int
color
)
{
wxPoint
pos
;
wxSize
drawSize
=
GetClientSize
();
...
...
@@ -181,12 +170,12 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
if
(
m_Items
[
ndx
].
m_X
>
item
.
m_X
)
{
m_Items
.
insert
(
m_Items
.
begin
()
+
ndx
,
item
);
m_Items
.
insert
(
m_Items
.
begin
()
+
ndx
,
item
);
break
;
}
}
if
(
ndx
==
limit
)
// mutually exclusive with two above if tests
if
(
ndx
==
limit
)
// mutually exclusive with two above if tests
{
m_Items
.
push_back
(
item
);
}
...
...
@@ -219,18 +208,14 @@ void WinEDA_MsgPanel::showItem( wxDC& dc, const MsgItem& aItem )
}
/****************************************/
void
WinEDA_MsgPanel
::
EraseMsgBox
()
/****************************************/
{
m_Items
.
clear
();
m_last_x
=
0
;
Refresh
();
}
/*******************************************/
void
WinEDA_MsgPanel
::
erase
(
wxDC
*
DC
)
/*******************************************/
{
wxPen
pen
;
wxBrush
brush
;
...
...
common/pcbcommon.cpp
View file @
bc5d9a75
...
...
@@ -59,8 +59,10 @@ int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
wxString
g_ViaType_Name
[
4
]
=
{
_
(
"??? Via"
),
// Not used yet
_
(
"Micro Via"
),
// from external layer (TOP or BOTTOM) from the near neightbour inner layer only
_
(
"Blind/Buried Via"
),
// from inner or external to inner or external layer (no restriction)
_
(
"Micro Via"
),
// from external layer (TOP or BOTTOM) from
// the near neighbor inner layer only
_
(
"Blind/Buried Via"
),
// from inner or external to inner or external
// layer (no restriction)
_
(
"Through Via"
)
// Usual via (from TOP to BOTTOM layer only )
};
...
...
@@ -86,7 +88,7 @@ const wxString PcbFileWildcard(
int
g_CurrentVersionPCB
=
1
;
/* variables generales */
int
g_TimeOut
;
// Timer for automatic saving
int
g_SaveTime
;
// Time for next saving
...
...
@@ -97,7 +99,8 @@ int g_ModuleTextNOVColor = DARKGRAY;
int
g_PadCUColor
=
GREEN
;
int
g_PadCMPColor
=
RED
;
// Current designe settings:
// Current design settings:
class
EDA_BoardDesignSettings
g_DesignSettings
;
/**
...
...
@@ -116,13 +119,13 @@ int g_GridRoutingSize = 250;
bool
g_Zone_45_Only
=
FALSE
;
/* HPGL plot settings. */
int
g_HPGL_Pen_Num
=
1
;
/*
num de plume a charg
er */
int
g_HPGL_Pen_Speed
=
40
;
/*
vitesse e
n cm/s */
int
g_HPGL_Pen_Diam
;
/* diamet
re e
n mils */
int
g_HPGL_Pen_Recouvrement
;
/* reco
uvrement en mils ( pour remplissages
*/
int
g_HPGL_Pen_Num
=
1
;
/*
pen numb
er */
int
g_HPGL_Pen_Speed
=
40
;
/*
speed i
n cm/s */
int
g_HPGL_Pen_Diam
;
/* diamet
er i
n mils */
int
g_HPGL_Pen_Recouvrement
;
/* reco
very in mils ( for filling )
*/
float
Scale_X
;
float
Scale_Y
;
/*
coeff d'agrandissement en X et Y demande
s */
float
Scale_Y
;
/*
scale factor in X and Y axi
s */
int
PlotMarge
;
int
g_PlotLine_Width
;
...
...
common/projet_config.cpp
View file @
bc5d9a75
/*********************
*****************************
/
/* projet_config
: routines de trace du cartouche
*/
/*********************
*****************************
/
/*********************/
/* projet_config
.cpp
*/
/*********************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -23,14 +23,14 @@
/**
* Cre
e ou recree la configuration locale de kicad
(filename.pro)
*
initialis
e:
*
g
_Prj_Config
*
g
_Prj_Config_LocalFilename
*
g
_Prj_Default_Config_FullFilename
*
r
eturn:
*
true si config locale
*
false si
default config
* Cre
ates or recreates the kicad project file.
(filename.pro)
*
Initializ
e:
*
G
_Prj_Config
*
G
_Prj_Config_LocalFilename
*
G
_Prj_Default_Config_FullFilename
*
R
eturn:
*
True if local config
*
False if
default config
*/
bool
WinEDA_App
::
ReCreatePrjConfig
(
const
wxString
&
fileName
,
const
wxString
&
GroupName
,
...
...
@@ -49,7 +49,7 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
/* Check the file name does not a kicad project extension.
* This allows the user to enter a filename without extension
* or use an existing name to create te project file
*/
*/
if
(
fn
.
GetExt
()
!=
ProjectFileExtension
)
{
fn
.
SetExt
(
ProjectFileExtension
);
...
...
@@ -133,9 +133,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
ReCreatePrjConfig
(
fileName
,
GroupName
,
FORCE_LOCAL_CONFIG
);
/* Write
date ( surtout pour eviter bug de wxFileConfig
*
qui se trompe de rubrique si declaration [xx] en premiere ligne
*
(en fait si groupe vide) *
/
/* Write
time (especially to avoid bug wxFileConfig that writes the
*
wrong item if declaration [xx] in first line (If empty group)
*/
m_ProjectConfig
->
SetPath
(
wxCONFIG_PATH_SEPARATOR
);
msg
=
DateAndTime
();
...
...
@@ -145,7 +145,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig
->
Write
(
wxT
(
"last_client"
),
msg
);
/* Save parameters */
m_ProjectConfig
->
DeleteGroup
(
GroupName
);
// Erase all data
s
m_ProjectConfig
->
DeleteGroup
(
GroupName
);
// Erase all data
m_ProjectConfig
->
Flush
();
m_ProjectConfig
->
SetPath
(
GroupName
);
...
...
@@ -193,7 +193,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig
->
Write
(
wxT
(
"last_client"
),
GetAppName
()
);
/* Save parameters */
m_ProjectConfig
->
DeleteGroup
(
GroupName
);
// Erase all data
s
m_ProjectConfig
->
DeleteGroup
(
GroupName
);
// Erase all data
m_ProjectConfig
->
Flush
();
m_ProjectConfig
->
SetPath
(
GroupName
);
...
...
@@ -225,15 +225,12 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
}
/*****************************************************************/
void
WinEDA_App
::
SaveCurrentSetupValues
(
PARAM_CFG_BASE
**
aList
)
/*****************************************************************/
/** Function SaveCurrentSetupValues()
* Save the current setup values in m_EDA_Config
* saved parameters are parameters that have the .m_Setup member set to true
* @param aList = array of PARAM_CFG_BASE pointers
*/
void
WinEDA_App
::
SaveCurrentSetupValues
(
PARAM_CFG_BASE
**
aList
)
{
PARAM_CFG_BASE
*
pt_cfg
;
...
...
@@ -393,15 +390,12 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
}
/***************************************************************/
void
WinEDA_App
::
ReadCurrentSetupValues
(
PARAM_CFG_BASE
**
aList
)
/***************************************************************/
/** Function ReadCurrentSetupValues()
* Raed the current setup values previously saved, from m_EDA_Config
* saved parameters are parameters that have the .m_Setup member set to true
* @param aList = array of PARAM_CFG_BASE pointers
*/
void
WinEDA_App
::
ReadCurrentSetupValues
(
PARAM_CFG_BASE
**
aList
)
{
PARAM_CFG_BASE
*
pt_cfg
;
...
...
@@ -428,10 +422,6 @@ void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_ARRAY& List )
}
/**************************************************************/
/* Constructeurs des descripteurs de structs de configuration */
/**************************************************************/
PARAM_CFG_BASE
::
PARAM_CFG_BASE
(
const
wxChar
*
ident
,
const
paramcfg_id
type
,
const
wxChar
*
group
)
{
...
...
@@ -496,8 +486,6 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig )
}
/**************************************************************************/
PARAM_CFG_SETCOLOR
::
PARAM_CFG_SETCOLOR
(
const
wxChar
*
ident
,
int
*
ptparam
,
int
default_val
,
const
wxChar
*
group
)
:
...
...
@@ -614,8 +602,6 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig )
}
/***********************************************************************/
PARAM_CFG_BOOL
::
PARAM_CFG_BOOL
(
const
wxChar
*
ident
,
bool
*
ptparam
,
int
default_val
,
const
wxChar
*
group
)
:
PARAM_CFG_BASE
(
ident
,
PARAM_BOOL
,
group
)
...
...
@@ -664,7 +650,6 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig )
}
/*********************************************************************/
PARAM_CFG_WXSTRING
::
PARAM_CFG_WXSTRING
(
const
wxChar
*
ident
,
wxString
*
ptparam
,
const
wxChar
*
group
)
:
...
...
@@ -708,7 +693,6 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig )
}
/***************************************************************************/
PARAM_CFG_LIBNAME_LIST
::
PARAM_CFG_LIBNAME_LIST
(
const
wxChar
*
ident
,
wxArrayString
*
ptparam
,
const
wxChar
*
group
)
:
...
...
@@ -726,7 +710,8 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
{
if
(
m_Pt_param
==
NULL
||
aConfig
==
NULL
)
return
;
int
indexlib
=
1
;
// We start indexlib to 1 because first lib name is LibName1
int
indexlib
=
1
;
// We start indexlib to 1 because first
// lib name is LibName1
wxString
libname
,
id_lib
;
wxArrayString
*
libname_list
=
m_Pt_param
;
while
(
1
)
...
...
common/pyhandler.cpp
View file @
bc5d9a75
...
...
@@ -23,25 +23,39 @@ static object ChooseFile( str objTitle, str objMask, object objOpen )
int
open
=
extract
<
int
>
(
objOpen
);
wxString
script
=
EDA_FileSelector
(
PyHandler
::
MakeStr
(
objTitle
),
wxEmptyString
,
/* Chemin par defaut */
wxEmptyString
,
/* nom fichier par defaut */
mask
,
/* extension par defaut */
mask
,
/* Masque d'affichage */
NULL
,
open
?
wxFD_OPEN
:
wxFD_SAVE
,
TRUE
);
wxEmptyString
,
wxEmptyString
,
mask
,
mask
,
NULL
,
open
?
wxFD_OPEN
:
wxFD_SAVE
,
TRUE
);
return
PyHandler
::
Convert
(
script
);
}
static
void
Print
(
str
message
)
{
std
::
cout
<<
extract
<
char
*>
(
message
)
<<
std
::
endl
;
}
static
void
Print
(
str
message
)
{
std
::
cout
<<
extract
<
char
*>
(
message
)
<<
std
::
endl
;
}
static
void
Clear
()
{}
static
void
RegisterCb
(
str
objKey
,
object
callback
)
{
PyHandler
::
GetInstance
()
->
RegisterCallback
(
PyHandler
::
MakeStr
(
objKey
),
callback
);
}
{
PyHandler
::
GetInstance
()
->
RegisterCallback
(
PyHandler
::
MakeStr
(
objKey
),
callback
);
}
static
void
UnRegisterCb
(
str
objKey
,
object
callback
)
{
PyHandler
::
GetInstance
()
->
UnRegisterCallback
(
PyHandler
::
MakeStr
(
objKey
),
callback
);
}
{
PyHandler
::
GetInstance
()
->
UnRegisterCallback
(
PyHandler
::
MakeStr
(
objKey
),
callback
);
}
static
void
init_base_utils
()
{
...
...
@@ -54,7 +68,13 @@ static void init_base_utils()
def
(
"Clear"
,
&
Clear
);
}
static
void
InitPyModules
()
{
PyHandler
::
GetInstance
()
->
InitNextModule
();
}
// Dummy boost callback
// Dummy boost callback
static
void
InitPyModules
()
{
PyHandler
::
GetInstance
()
->
InitNextModule
();
}
/*****************************************************************************/
/* PyHandler */
...
...
@@ -63,9 +83,21 @@ static void InitPyModules() { PyHandler::GetInstance()->InitNextModule(); } // D
// std::vector< T > -> python object implicit conversion
template
<
typename
T
>
struct
std_vector_to_tuple
{
static
PyObject
*
makeItem
(
const
wxString
&
str
)
{
return
boost
::
python
::
incref
(
PyHandler
::
Convert
(
str
).
ptr
()
);
}
static
PyObject
*
makeItem
(
const
std
::
string
&
str
)
{
return
boost
::
python
::
incref
(
boost
::
python
::
str
(
str
.
c_str
()
).
ptr
()
);
}
static
PyObject
*
makeItem
(
int
item
)
{
return
boost
::
python
::
incref
(
PyInt_FromLong
(
item
)
);
}
static
PyObject
*
makeItem
(
const
wxString
&
str
)
{
return
boost
::
python
::
incref
(
PyHandler
::
Convert
(
str
).
ptr
()
);
}
static
PyObject
*
makeItem
(
const
std
::
string
&
str
)
{
return
boost
::
python
::
incref
(
boost
::
python
::
str
(
str
.
c_str
()
).
ptr
()
);
}
static
PyObject
*
makeItem
(
int
item
)
{
return
boost
::
python
::
incref
(
PyInt_FromLong
(
item
)
);
}
static
PyObject
*
convert
(
const
T
&
vect
)
{
...
...
@@ -80,24 +112,26 @@ template <typename T> struct std_vector_to_tuple
PyHandler
*
PyHandler
::
m_instance
=
NULL
;
PyHandler
*
PyHandler
::
GetInstance
()
/* Singleton implementation */
PyHandler
*
PyHandler
::
GetInstance
()
{
if
(
!
PyHandler
::
m_instance
)
if
(
!
PyHandler
::
m_instance
)
{
PyHandler
::
m_instance
=
new
PyHandler
();
}
return
PyHandler
::
m_instance
;
}
PyHandler
::
PyHandler
()
/* Init the Python env */
PyHandler
::
PyHandler
()
{
Py_Initialize
();
PyEval_InitThreads
();
m_ModulesLoaded
=
false
;
m_current
=
0
;
if
(
!
wxPyCoreAPI_IMPORT
()
)
if
(
!
wxPyCoreAPI_IMPORT
()
)
{
std
::
cerr
<<
"Can't get wx Python binding
\n
"
;
PyErr_Print
();
...
...
@@ -117,23 +151,30 @@ PyHandler::PyHandler()
// Register converters
to_python_converter
<
std
::
vector
<
std
::
string
>
,
std_vector_to_tuple
<
const
std
::
vector
<
std
::
string
>
>
>
();
to_python_converter
<
std
::
vector
<
wxString
>
,
std_vector_to_tuple
<
const
std
::
vector
<
wxString
>
>
>
();
to_python_converter
<
std
::
vector
<
std
::
string
>
,
std_vector_to_tuple
<
const
std
::
vector
<
std
::
string
>
>
>
();
to_python_converter
<
std
::
vector
<
wxString
>
,
std_vector_to_tuple
<
const
std
::
vector
<
wxString
>
>
>
();
}
void
PyHandler
::
DoInitModules
()
{
if
(
m_ModulesLoaded
)
return
;
if
(
m_ModulesLoaded
)
return
;
m_ModulesLoaded
=
true
;
for
(
unsigned
int
i
=
0
;
i
<
m_ModuleRegistry
.
size
();
i
++
)
{
detail
::
init_module
(
m_ModuleRegistry
[
i
].
name
.
mb_str
(),
&
InitPyModules
);
detail
::
init_module
(
m_ModuleRegistry
[
i
].
name
.
mb_str
(),
&
InitPyModules
);
}
}
int
PyHandler
::
GetModuleIndex
(
const
wxString
&
name
)
const
/* Returns the module index in the registry, -1 if not found*/
int
PyHandler
::
GetModuleIndex
(
const
wxString
&
name
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
m_ModuleRegistry
.
size
();
i
++
)
{
...
...
@@ -142,10 +183,14 @@ int PyHandler::GetModuleIndex( const wxString & name ) const
return
-
1
;
}
void
PyHandler
::
AddToModule
(
const
wxString
&
name
,
PyHandler
::
initfunc_t
initfunc
)
/* Adds an init function to a python module */
void
PyHandler
::
AddToModule
(
const
wxString
&
name
,
PyHandler
::
initfunc_t
initfunc
)
{
if
(
!
initfunc
)
return
;
if
(
!
initfunc
)
return
;
int
i
=
GetModuleIndex
(
name
);
if
(
-
1
==
i
)
...
...
@@ -158,38 +203,48 @@ void PyHandler::AddToModule( const wxString & name, PyHandler::initfunc_t initfu
}
void
PyHandler
::
InitNextModule
()
/* Called to initialize a module on py 'import module' */
void
PyHandler
::
InitNextModule
()
{
for
(
unsigned
int
j
=
0
;
j
<
m_ModuleRegistry
[
m_current
].
registry
.
size
()
;
j
++
)
for
(
unsigned
int
j
=
0
;
j
<
m_ModuleRegistry
[
m_current
].
registry
.
size
();
j
++
)
{
m_ModuleRegistry
[
m_current
].
registry
[
j
]();
}
m_current
++
;
}
PyHandler
::~
PyHandler
()
/* Closes the Python env */
PyHandler
::~
PyHandler
()
{
wxPyEndAllowThreads
(
m_mainTState
);
Py_Finalize
();
}
void
PyHandler
::
RunBaseScripts
(
const
wxString
&
base
)
/* Run scripts looking in 'base' directory */
void
PyHandler
::
RunBaseScripts
(
const
wxString
&
base
)
{
const
wxString
sep
=
wxFileName
().
GetPathSeparator
();
// check if we can have a kicad_startup.py around ?
wxString
script
=
base
+
wxT
(
"scripts"
)
+
sep
+
wxT
(
"kicad_startup.py"
);
if
(
wxFileExists
(
script
)
)
RunScript
(
script
);
if
(
wxFileExists
(
script
)
)
RunScript
(
script
);
// First find scripts/<name>.py and run it if found :
script
=
base
+
wxString
::
FromAscii
(
"scripts"
)
+
sep
+
m_appName
+
wxString
::
FromAscii
(
".py"
);
if
(
wxFileExists
(
script
)
)
RunScript
(
script
);
script
=
base
+
wxString
::
FromAscii
(
"scripts"
)
+
sep
+
m_appName
+
wxString
::
FromAscii
(
".py"
);
if
(
wxFileExists
(
script
)
)
RunScript
(
script
);
// Now lets see if we can find a suitable plugin directory (plugin/<name>) somewhere
// Now lets see if we can find a suitable plugin directory
// (plugin/<name>) somewhere
wxString
pluginDir
=
base
+
wxT
(
"plugins"
)
+
sep
+
m_appName
;
if
(
wxDirExists
(
pluginDir
)
)
...
...
@@ -205,8 +260,9 @@ void PyHandler::RunBaseScripts( const wxString & base )
}
}
void
PyHandler
::
RunScripts
()
/* Run application startup scripts */
void
PyHandler
::
RunScripts
()
{
// SYSTEMWIDE:
...
...
@@ -216,15 +272,19 @@ void PyHandler::RunScripts()
if
(
wxDirExists
(
dataPath
)
)
RunBaseScripts
(
dataPath
);
// USER Scripts:
wxString
userDir
=
wxGetUserHome
()
+
sep
+
wxString
::
FromAscii
(
".kicad.d"
)
+
sep
;
if
(
wxDirExists
(
userDir
)
)
RunBaseScripts
(
userDir
);
wxString
userDir
=
wxGetUserHome
()
+
sep
+
wxString
::
FromAscii
(
".kicad.d"
)
+
sep
;
if
(
wxDirExists
(
userDir
)
)
RunBaseScripts
(
userDir
);
userDir
=
wxGetUserHome
()
+
sep
+
wxString
::
FromAscii
(
"_kicad_d"
)
+
sep
;
if
(
wxDirExists
(
userDir
)
)
RunBaseScripts
(
userDir
);
if
(
wxDirExists
(
userDir
)
)
RunBaseScripts
(
userDir
);
}
bool
PyHandler
::
RunScript
(
const
wxString
&
name
)
/* Run the script specified by 'name' */
bool
PyHandler
::
RunScript
(
const
wxString
&
name
)
{
DoInitModules
();
...
...
@@ -253,7 +313,8 @@ bool PyHandler::RunScript( const wxString & name )
try
{
ns
[
"currentScript"
]
=
Convert
(
name
);
handle
<>
ignored
(
PyRun_File
(
file
,
name
.
mb_str
(),
Py_file_input
,
ns
.
ptr
(),
ns
.
ptr
()
)
);
handle
<>
ignored
(
PyRun_File
(
file
,
name
.
mb_str
(),
Py_file_input
,
ns
.
ptr
(),
ns
.
ptr
()
)
);
}
catch
(
error_already_set
)
{
...
...
@@ -268,6 +329,7 @@ bool PyHandler::RunScript( const wxString & name )
return
ret
;
}
bool
PyHandler
::
RunSimpleString
(
const
wxString
&
code
)
/* Run the code in 'code' */
{
...
...
@@ -292,80 +354,114 @@ void PyHandler::SetAppName( const wxString & name )
/* Set the application name in the python scope */
{
m_appName
=
name
;
object
module
(
(
handle
<>
(
borrowed
(
PyImport_AddModule
(
"__main__"
))))
);
object
module
(
(
handle
<>
(
borrowed
(
PyImport_AddModule
(
"__main__"
)
)
)
)
);
object
ns
=
module
.
attr
(
"__dict__"
);
try
{
try
{
ns
[
"kicadApp"
]
=
std
::
string
(
name
.
ToAscii
()
);
}
catch
(
error_already_set
)
catch
(
error_already_set
)
{
PyErr_Print
();
}
}
const
char
*
PyHandler
::
GetVersion
()
{
return
Py_GetVersion
();
}
// Event handling :
void
PyHandler
::
DeclareEvent
(
const
wxString
&
key
)
{
m_EventRegistry
.
push_back
(
Event
(
key
)
);
}
void
PyHandler
::
DeclareEvent
(
const
wxString
&
key
)
{
m_EventRegistry
.
push_back
(
Event
(
key
)
);
}
int
PyHandler
::
GetEventIndex
(
const
wxString
&
key
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_EventRegistry
.
size
();
i
++
)
{
if
(
m_EventRegistry
[
i
].
key
==
key
)
return
i
;
if
(
m_EventRegistry
[
i
].
key
==
key
)
return
i
;
}
return
-
1
;
}
void
PyHandler
::
TriggerEvent
(
const
wxString
&
key
)
{
TriggerEvent
(
key
,
str
(
""
)
);
}
void
PyHandler
::
TriggerEvent
(
const
wxString
&
key
)
{
TriggerEvent
(
key
,
str
(
""
)
);
}
void
PyHandler
::
TriggerEvent
(
const
wxString
&
key
,
const
object
&
param
)
{
int
i
=
GetEventIndex
(
key
);
if
(
-
1
==
i
)
return
;
if
(
-
1
==
i
)
return
;
wxPyBlock_t
blocked
=
wxPyBeginBlockThreads
();
for
(
unsigned
int
j
=
0
;
j
<
m_EventRegistry
[
i
].
functors
.
size
();
j
++
)
for
(
unsigned
int
j
=
0
;
j
<
m_EventRegistry
[
i
].
functors
.
size
();
j
++
)
{
try
{
m_EventRegistry
[
i
].
functors
[
j
](
param
);
}
catch
(
error_already_set
)
catch
(
error_already_set
)
{
std
::
cout
<<
"Error in event "
<<
key
.
mb_str
()
<<
" callback"
<<
std
::
endl
;
std
::
cout
<<
"Error in event "
<<
key
.
mb_str
()
<<
" callback"
<<
std
::
endl
;
PyErr_Print
();
}
}
wxPyEndBlockThreads
(
blocked
);
wxPyEndBlockThreads
(
blocked
);
}
void
PyHandler
::
RegisterCallback
(
const
wxString
&
key
,
const
object
&
callback
)
void
PyHandler
::
RegisterCallback
(
const
wxString
&
key
,
const
object
&
callback
)
{
int
i
=
GetEventIndex
(
key
);
if
(
-
1
==
i
)
return
;
if
(
-
1
==
i
)
return
;
m_EventRegistry
[
i
].
functors
.
push_back
(
callback
);
}
void
PyHandler
::
UnRegisterCallback
(
const
wxString
&
key
,
const
object
&
callback
)
void
PyHandler
::
UnRegisterCallback
(
const
wxString
&
key
,
const
object
&
callback
)
{
int
i
=
GetEventIndex
(
key
);
if
(
-
1
==
i
)
return
;
for
(
unsigned
int
j
=
0
;
j
<
m_EventRegistry
[
i
].
functors
.
size
()
;
j
++
)
if
(
-
1
==
i
)
return
;
for
(
unsigned
int
j
=
0
;
j
<
m_EventRegistry
[
i
].
functors
.
size
()
;
j
++
)
{
if
(
callback
==
m_EventRegistry
[
i
].
functors
[
j
]
)
{
m_EventRegistry
[
i
].
functors
.
erase
(
m_EventRegistry
[
i
].
functors
.
begin
()
+
j
);
m_EventRegistry
[
i
].
functors
.
erase
(
m_EventRegistry
[
i
].
functors
.
begin
()
+
j
);
break
;
}
}
}
// Object conversion:
wxString
PyHandler
::
MakeStr
(
const
object
&
objStr
)
{
return
wxString
(
extract
<
const
char
*>
(
objStr
),
wxConvLocal
);
}
wxString
PyHandler
::
MakeStr
(
const
object
&
objStr
)
{
return
wxString
(
extract
<
const
char
*>
(
objStr
),
wxConvLocal
);
}
object
PyHandler
::
Convert
(
const
wxString
&
wxStr
)
{
return
str
(
std
::
string
(
wxStr
.
mb_str
()
).
c_str
()
);
}
// vim: set tabstop=4 :
object
PyHandler
::
Convert
(
const
wxString
&
wxStr
)
{
return
str
(
std
::
string
(
wxStr
.
mb_str
()
).
c_str
()
);
}
common/selcolor.cpp
View file @
bc5d9a75
/****************/
/* SELCOLOR.CPP */
/****************/
/* Affichage et selection de la palette des couleurs disponibles
* dans une frame
/* Dialog for selecting color from the palette of available colors.
*/
#include "fctsys.h"
...
...
@@ -22,17 +20,10 @@ enum colors_id {
};
/*******************************************/
class
WinEDA_SelColorFrame
:
public
wxDialog
/*******************************************/
/* Frame d'affichage de la palette des couleurs disponibles
*/
{
private
:
public
:
// Constructor and destructor
WinEDA_SelColorFrame
(
wxWindow
*
parent
,
const
wxPoint
&
framepos
,
int
OldColor
);
~
WinEDA_SelColorFrame
()
{};
...
...
@@ -45,7 +36,6 @@ private:
};
/* Construction de la table des evenements pour FrameClassMain */
BEGIN_EVENT_TABLE
(
WinEDA_SelColorFrame
,
wxDialog
)
EVT_BUTTON
(
wxID_CANCEL
,
WinEDA_SelColorFrame
::
OnCancel
)
EVT_COMMAND_RANGE
(
ID_COLOR_BLACK
,
ID_COLOR_BLACK
+
31
,
...
...
common/string.cpp
View file @
bc5d9a75
/*********************************************/
/*
string.cpp
*/
/*
some useful functions to handle strings */
/*
string.cpp
*/
/*
some useful functions to handle strings */
/*********************************************/
#include "fctsys.h"
...
...
@@ -8,14 +8,11 @@
#include "kicad_string.h"
/*********************************************************************/
int
ReadDelimitedText
(
char
*
dest
,
char
*
source
,
int
NbMaxChar
)
/*********************************************************************/
/* read a double-quote delimited text from source and put it in in dest,
* read NbMaxChar bytes max
* return the char count read from source
*/
int
ReadDelimitedText
(
char
*
dest
,
char
*
source
,
int
NbMaxChar
)
{
int
ii
,
jj
,
flag
=
0
;
...
...
@@ -23,11 +20,11 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
{
if
(
*
source
==
0
)
break
;
/* E.O.L. */
if
(
*
source
==
'"'
)
/* delimite
ur trouve
*/
if
(
*
source
==
'"'
)
/* delimite
r is "
*/
{
if
(
flag
)
break
;
/*
Fin de texte delimite
*/
flag
=
1
;
/*
Marque 1er delimiteur trouve
*/
break
;
/*
End of delimited text
*/
flag
=
1
;
/*
First delimiter found.
*/
}
else
if
(
flag
)
{
...
...
@@ -35,29 +32,26 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
}
}
*
dest
=
0
;
/* Null termined */
*
dest
=
0
;
/* Null termin
at
ed */
return
jj
;
}
/********************************/
char
*
StrPurge
(
char
*
text
)
/********************************/
/* Remove training spaces in text
* return a pointer on the first non space char in text
*/
char
*
StrPurge
(
char
*
text
)
{
char
*
ptspace
;
if
(
text
==
NULL
)
return
NULL
;
while
(
(
*
text
<=
' '
)
&&
*
text
)
while
(
(
*
text
<=
' '
)
&&
*
text
)
text
++
;
ptspace
=
text
+
strlen
(
text
)
-
1
;
while
(
(
*
ptspace
<=
' '
)
&&
*
ptspace
&&
(
ptspace
>=
text
)
)
while
(
(
*
ptspace
<=
' '
)
&&
*
ptspace
&&
(
ptspace
>=
text
)
)
{
*
ptspace
=
0
;
ptspace
--
;
}
...
...
@@ -66,15 +60,12 @@ char* StrPurge( char* text )
}
/*****************************************************************/
char
*
GetLine
(
FILE
*
File
,
char
*
Line
,
int
*
LineNum
,
int
SizeLine
)
/*****************************************************************/
/* Read lines from File
* Skip void lines and comments (starting by #)
* return the first non void line.
* increments *LineNum for e
ca
h line
* increments *LineNum for e
ac
h line
*/
char
*
GetLine
(
FILE
*
File
,
char
*
Line
,
int
*
LineNum
,
int
SizeLine
)
{
do
{
if
(
fgets
(
Line
,
SizeLine
,
File
)
==
NULL
)
...
...
@@ -89,13 +80,10 @@ char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
}
/*******************************/
char
*
DateAndTime
(
char
*
aBuffer
)
/*******************************/
/* return in aBuffer the date and time
* time is the local time.
*/
char
*
DateAndTime
(
char
*
aBuffer
)
{
wxString
datetime
;
...
...
@@ -106,14 +94,12 @@ char* DateAndTime( char* aBuffer )
}
/*******************************/
wxString
DateAndTime
()
/*******************************/
/* return the date and time in a wxString
* note: does the same thing than strftime()
* time is the local time.
*/
wxString
DateAndTime
()
{
wxString
Line
;
...
...
@@ -126,20 +112,17 @@ wxString DateAndTime()
}
/************************************************************/
int
StrLenNumCmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
,
int
NbMax
)
/************************************************************/
/*
* sort() function
* Same as strncmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int
StrLenNumCmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
,
int
NbMax
)
{
int
i
;
int
nb1
=
0
,
nb2
=
0
;
if
(
(
str1
==
NULL
)
||
(
str2
==
NULL
)
)
if
(
(
str1
==
NULL
)
||
(
str2
==
NULL
)
)
return
0
;
for
(
i
=
0
;
i
<
NbMax
;
i
++
)
...
...
@@ -167,7 +150,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
return
-
1
;
if
(
*
str1
>
*
str2
)
return
1
;
if
(
(
*
str1
==
0
)
&&
(
*
str2
==
0
)
)
if
(
(
*
str1
==
0
)
&&
(
*
str2
==
0
)
)
return
0
;
str1
++
;
str2
++
;
}
...
...
@@ -176,34 +159,28 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
}
/***********************************************/
int
StrNumICmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
)
/***********************************************/
/*
* sort() function
* Same as stricmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int
StrNumICmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
)
{
return
StrLenNumICmp
(
str1
,
str2
,
32735
);
}
/**************************************************************/
int
StrLenNumICmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
,
int
NbMax
)
/**************************************************************/
/*
* sort() function
* Same as strnicmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int
StrLenNumICmp
(
const
wxChar
*
str1
,
const
wxChar
*
str2
,
int
NbMax
)
{
int
i
;
int
nb1
=
0
,
nb2
=
0
;
if
(
(
str1
==
NULL
)
||
(
str2
==
NULL
)
)
if
(
(
str1
==
NULL
)
||
(
str2
==
NULL
)
)
return
0
;
for
(
i
=
0
;
i
<
NbMax
;
i
++
)
...
...
@@ -240,16 +217,13 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
}
/***********************************************************************/
bool
WildCompareString
(
const
wxString
&
pattern
,
const
wxString
&
string_to_tst
,
bool
case_sensitive
)
/***********************************************************************/
/* compare a string to a pattern
* ( usual chars * and ? allowed).
* if case_sensitive == true, comparison is case sensitive
* return true if match else false
*/
bool
WildCompareString
(
const
wxString
&
pattern
,
const
wxString
&
string_to_tst
,
bool
case_sensitive
)
{
const
wxChar
*
cp
=
NULL
,
*
mp
=
NULL
;
const
wxChar
*
wild
,
*
string
;
...
...
@@ -270,9 +244,9 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
string
=
_string_to_tst
.
GetData
();
}
while
(
(
*
string
)
&&
(
*
wild
!=
'*'
)
)
while
(
(
*
string
)
&&
(
*
wild
!=
'*'
)
)
{
if
(
(
*
wild
!=
*
string
)
&&
(
*
wild
!=
'?'
)
)
if
(
(
*
wild
!=
*
string
)
&&
(
*
wild
!=
'?'
)
)
return
FALSE
;
wild
++
;
string
++
;
}
...
...
@@ -286,7 +260,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
mp
=
wild
;
cp
=
string
+
1
;
}
else
if
(
(
*
wild
==
*
string
)
||
(
*
wild
==
'?'
)
)
else
if
(
(
*
wild
==
*
string
)
||
(
*
wild
==
'?'
)
)
{
wild
++
;
string
++
;
...
...
@@ -307,15 +281,11 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
}
/***************************/
char
*
to_point
(
char
*
Text
)
/**************************/
/* convertit les , en . dans une chaine. utilise pour compenser
* l'internalisation de la fct printf
* qui genere les flottants avec une virgule au lieu du point
* Obsolete: use SetLocaleTo_C_standard insteed
/* Converts a string used to compensate for internalization of printf().
* Generated floats with a comma instead of point.
* Obsolete: use SetLocaleTo_C_standard instead
*/
char
*
to_point
(
char
*
Text
)
{
char
*
line
=
Text
;
...
...
@@ -331,13 +301,10 @@ char* to_point( char* Text )
}
/********************************/
char
*
strupper
(
char
*
Text
)
/********************************/
/* Change les caracteres 'a' ... 'z' en 'A' ... 'Z'. dans la chaine Text.
* Retourne Text
/* Convert string to upper case.
* Returns pointer to the converted string.
*/
char
*
strupper
(
char
*
Text
)
{
char
*
code
=
Text
;
...
...
@@ -345,7 +312,7 @@ char* strupper( char* Text )
{
while
(
*
code
)
{
if
(
(
*
code
>=
'a'
)
&&
(
*
code
<=
'z'
)
)
if
(
(
*
code
>=
'a'
)
&&
(
*
code
<=
'z'
)
)
*
code
+=
'A'
-
'a'
;
code
++
;
}
...
...
common/toolbars.cpp
View file @
bc5d9a75
/****************
**************************************************
/
/* toolbars.cpp
- fonctions des classes du type WinEDA_ttolbar
*/
/****************
**************************************************
/
/****************/
/* toolbars.cpp */
/****************/
#ifdef __GNUG__
#pragma implementation
...
...
@@ -9,15 +9,14 @@
#include "fctsys.h"
#include "wxstruct.h"
/*************************/
/* class WinEDA_HToolbar */
/*************************/
WinEDA_Toolbar
::
WinEDA_Toolbar
(
id_toolbar
type
,
wxWindow
*
parent
,
wxWindowID
id
,
bool
horizontal
)
:
#if defined(KICAD_AUITOOLBAR)
wxAuiToolBar
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
wxAUI_TB_DEFAULT_STYLE
|
(
horizontal
?
wxAUI_TB_HORZ_LAYOUT
:
wxAUI_TB_VERTICAL
))
wxAUI_TB_DEFAULT_STYLE
|
(
(
horizontal
)
?
wxAUI_TB_HORZ_LAYOUT
:
wxAUI_TB_VERTICAL
)
)
#else
wxToolBar
(
parent
,
id
,
wxPoint
(
-
1
,
-
1
),
wxSize
(
-
1
,
-
1
),
horizontal
?
wxTB_HORIZONTAL
:
wxTB_VERTICAL
)
...
...
common/trigo.cpp
View file @
bc5d9a75
/************************/
/* Routines de rotation */
/************************/
/* Fichier TRIGO.CPP */
/****************************/
/* Trigonometric functions. */
/****************************/
#include "fctsys.h"
#include "trigo.h"
...
...
@@ -24,16 +22,13 @@ bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist
}
/************************************************************************/
bool
DistanceTest
(
int
seuil
,
int
dx
,
int
dy
,
int
spot_cX
,
int
spot_cY
)
/************************************************************************/
/** Function DistanceTest
*
Calcul de la distance du curseur souris a un segment de droite :
*
retourne
:
*
false si distance > seuil
*
true si distance <= seuil
*
Calculate the distance from mouse cursor to a line segment.
*
Returns
:
*
False if distance > threshold
*
True if distance <= threshold
*/
bool
DistanceTest
(
int
seuil
,
int
dx
,
int
dy
,
int
spot_cX
,
int
spot_cY
)
{
/* We can have 4 cases::
* horizontal segment
...
...
@@ -41,156 +36,162 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
* 45 degrees segment
* other slopes
*/
int
cXrot
,
cYrot
,
/* coord du point (souris) dans le repere tourne */
segX
,
segY
;
/* coord extremite segment tj >= 0 */
int
pointX
,
pointY
;
/* coord point a tester dans repere modifie dans lequel
* segX et segY sont >=0 */
int
cXrot
,
cYrot
,
segX
,
segY
;
int
pointX
,
pointY
;
segX
=
dx
;
segY
=
dy
;
pointX
=
spot_cX
;
pointY
=
spot_cY
;
/*Recalcul
coord pour que le segment soit dans 1er
quadrant (coord >= 0)*/
if
(
segX
<
0
)
/*
mise en >0 par symetrie par rapport a l'axe Y
*/
/*Recalcul
ating coord for the segment is in 1st
quadrant (coord >= 0)*/
if
(
segX
<
0
)
/*
set > 0 by symmetry about the Y axis
*/
{
segX
=
-
segX
;
pointX
=
-
pointX
;
}
if
(
segY
<
0
)
/*
mise en > 0 par symetrie par rapport a l'axe X
*/
if
(
segY
<
0
)
/*
set > 0 by symmetry about the X axis
*/
{
segY
=
-
segY
;
pointY
=
-
pointY
;
}
if
(
segY
==
0
)
/*
piste Horizontale
*/
if
(
segY
==
0
)
/*
horizontal
*/
{
if
(
abs
(
pointY
)
<=
seuil
)
{
if
(
(
pointX
>=
0
)
&&
(
pointX
<=
segX
)
)
if
(
(
pointX
>=
0
)
&&
(
pointX
<=
segX
)
)
return
1
;
/* Etude des extremites : cercle de rayon seuil */
if
(
(
pointX
<
0
)
&&
(
pointX
>=
-
seuil
)
)
if
(
(
pointX
<
0
)
&&
(
pointX
>=
-
seuil
)
)
{
if
(
(
(
pointX
*
pointX
)
+
(
pointY
*
pointY
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
pointX
*
pointX
)
+
(
pointY
*
pointY
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
if
(
(
pointX
>
segX
)
&&
(
pointX
<=
(
segX
+
seuil
)
)
)
if
(
(
pointX
>
segX
)
&&
(
pointX
<=
(
segX
+
seuil
)
)
)
{
if
(
(
(
(
pointX
-
segX
)
*
(
pointX
-
segX
)
)
+
(
pointY
*
pointY
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
(
pointX
-
segX
)
*
(
pointX
-
segX
)
)
+
(
pointY
*
pointY
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
}
}
else
if
(
segX
==
0
)
/*
piste verticale
*/
else
if
(
segX
==
0
)
/*
vertical
*/
{
if
(
abs
(
pointX
)
<=
seuil
)
{
if
(
(
pointY
>=
0
)
&&
(
pointY
<=
segY
)
)
if
(
(
pointY
>=
0
)
&&
(
pointY
<=
segY
)
)
return
true
;
if
(
(
pointY
<
0
)
&&
(
pointY
>=
-
seuil
)
)
if
(
(
pointY
<
0
)
&&
(
pointY
>=
-
seuil
)
)
{
if
(
(
(
pointY
*
pointY
)
+
(
pointX
*
pointX
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
pointY
*
pointY
)
+
(
pointX
*
pointX
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
if
(
(
pointY
>
segY
)
&&
(
pointY
<=
(
segY
+
seuil
)
)
)
if
(
(
pointY
>
segY
)
&&
(
pointY
<=
(
segY
+
seuil
)
)
)
{
if
(
(
(
(
pointY
-
segY
)
*
(
pointY
-
segY
)
)
+
(
pointX
*
pointX
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
(
pointY
-
segY
)
*
(
pointY
-
segY
)
)
+
(
pointX
*
pointX
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
}
}
else
if
(
segX
==
segY
)
/*
piste a 45 degre
*/
else
if
(
segX
==
segY
)
/*
45 degrees
*/
{
/* on fait tourner les axes de 45 degre. la souris a alors les
* coord : x1 = x*cos45 + y*sin45
* y1 = y*cos45 - x*sin45
* et le segment de piste est alors horizontal.
* recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10
* remarque : sin ou cos45 = .707, et lors du recalcul des coord
* dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait 0.707 fois
* trop grands. (c.a.d trop petits)
* spot_cX,Y doit etre * par .707 * .707 = 0.5 */
/* Rotate axes of 45 degrees. mouse was then
* Coord: x1 = x * y * cos45 + sin45
* y1 = y * cos45 - sin45 x *
* And the segment of track is horizontal.
* Coord recalculation of the mouse (sin45 = cos45 = .707 = 7 / 10
* Note: sin or cos45 = .707, and when recalculating coord
* dx45 and dy45, lect coeff .707 is neglected, dx and dy are
* actually 0707 times
* Too big. (security hole too small)
* Spot_cX, Y * must be by .707 * .707 = 0.5
*/
cXrot
=
(
pointX
+
pointY
)
>>
1
;
cYrot
=
(
pointY
-
pointX
)
>>
1
;
/* recalcul des coord de l'extremite du segment , qui sera vertical
* suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY)
* et est en fait 1,414 plus grand , et dy45 = 0 */
/* Recalculating coord of segment extremity, which will be vertical
* following the orientation of axes on the screen: dx45 = pointx
* (or pointy) and 1.414 is actually greater, and dy45 = 0
*/
//
seuil doit etre * .707 pour tenir compte du coeff de reduction sur dx,
dy
//
* Threshold should be .707 to reflect the change in coeff dx,
dy
seuil
*=
7
;
seuil
/=
10
;
if
(
abs
(
cYrot
)
<=
seuil
)
/* ok
sur axe vertical)
*/
if
(
abs
(
cYrot
)
<=
seuil
)
/* ok
on vertical axis
*/
{
if
(
(
cXrot
>=
0
)
&&
(
cXrot
<=
segX
)
)
if
(
(
cXrot
>=
0
)
&&
(
cXrot
<=
segX
)
)
return
true
;
/*
Etude des extremites : cercle de rayon seuil
*/
if
(
(
cXrot
<
0
)
&&
(
cXrot
>=
-
seuil
)
)
/*
Check extremes using the radius of a circle.
*/
if
(
(
cXrot
<
0
)
&&
(
cXrot
>=
-
seuil
)
)
{
if
(
(
(
cXrot
*
cXrot
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
cXrot
*
cXrot
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
if
(
(
cXrot
>
segX
)
&&
(
cXrot
<=
(
segX
+
seuil
)
)
)
if
(
(
cXrot
>
segX
)
&&
(
cXrot
<=
(
segX
+
seuil
)
)
)
{
if
(
(
(
(
cXrot
-
segX
)
*
(
cXrot
-
segX
)
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
(
cXrot
-
segX
)
*
(
cXrot
-
segX
)
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
}
}
else
/*
orientation quelconque
*/
else
/*
any orientation
*/
{
/* On fait un changement d'axe (rotation) de facon a ce que le segment
* de piste soit horizontal dans le nouveau repere */
/* There is a change of axis (rotation), so that the segment
* track is horizontal in the new reference
*/
int
angle
;
angle
=
wxRound
(
(
atan2
(
(
double
)
segY
,
(
double
)
segX
)
*
1800.0
/
M_PI
)
);
angle
=
wxRound
(
(
atan2
(
(
double
)
segY
,
(
double
)
segX
)
*
1800.0
/
M_PI
)
);
cXrot
=
pointX
;
cYrot
=
pointY
;
RotatePoint
(
&
cXrot
,
&
cYrot
,
angle
);
/* Rotation du point a tester */
RotatePoint
(
&
segX
,
&
segY
,
angle
);
/* Rotation du segment */
/* la piste est Horizontale , par suite des modifs de coordonnes
* et d'axe, donc segX = longueur du segment */
RotatePoint
(
&
cXrot
,
&
cYrot
,
angle
);
/* Rotate the point to be tested */
RotatePoint
(
&
segX
,
&
segY
,
angle
);
/* Rotate the segment */
if
(
abs
(
cYrot
)
<=
seuil
)
/* ok sur axe vertical) */
/* The track is horizontal, following the amendments to coordinate
* axis and, therefore segX = length of segment
*/
if
(
abs
(
cYrot
)
<=
seuil
)
/* vertical axis */
{
if
(
(
cXrot
>=
0
)
&&
(
cXrot
<=
segX
)
)
if
(
(
cXrot
>=
0
)
&&
(
cXrot
<=
segX
)
)
return
true
;
/* Etude des extremites : cercle de rayon seuil */
if
(
(
cXrot
<
0
)
&&
(
cXrot
>=
-
seuil
)
)
if
(
(
cXrot
<
0
)
&&
(
cXrot
>=
-
seuil
)
)
{
if
(
(
(
cXrot
*
cXrot
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
cXrot
*
cXrot
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
if
(
(
cXrot
>
segX
)
&&
(
cXrot
<=
(
segX
+
seuil
)
)
)
if
(
(
cXrot
>
segX
)
&&
(
cXrot
<=
(
segX
+
seuil
)
)
)
{
if
(
(
(
(
cXrot
-
segX
)
*
(
cXrot
-
segX
)
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
if
(
(
(
(
cXrot
-
segX
)
*
(
cXrot
-
segX
)
)
+
(
cYrot
*
cYrot
)
)
<=
(
seuil
*
seuil
)
)
return
true
;
}
}
}
return
false
;
}
/***********************************/
int
ArcTangente
(
int
dy
,
int
dx
)
/***********************************/
/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
* entre -1800 et 1800
* Analogue a atan2 ( mais plus rapide pour les calculs si
* l'angle est souvent 0, -1800, ou +- 900
/* Return the arc tangent of 0.1 degrees coord vector dx, dy
* between -1800 and 1800
* Equivalent to atan2 (but faster for calculations if
* the angle is 0 to -1800, or + - 900
*/
int
ArcTangente
(
int
dy
,
int
dx
)
{
double
fangle
;
...
...
@@ -231,15 +232,11 @@ int ArcTangente( int dy, int dx )
}
/*********************************************/
void
RotatePoint
(
int
*
pX
,
int
*
pY
,
int
angle
)
/*********************************************/
/*
* Fonction surchargee!
* calcule les nouvelles coord du point de coord pX, pY,
* pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre)
* Calculate the new point of coord coord pX, pY,
* for a rotation center 0, 0, and angle in (1 / 10 degree)
*/
void
RotatePoint
(
int
*
pX
,
int
*
pY
,
int
angle
)
{
double
fpx
,
fpy
;
int
tmp
;
...
...
@@ -253,8 +250,7 @@ void RotatePoint( int* pX, int* pY, int angle )
if
(
angle
==
0
)
return
;
/* Calcul des coord :
* coord: xrot = y*sin + x*cos
/* coord: xrot = y*sin + x*cos
* yrot = y*cos - x*sin
*/
if
(
angle
==
900
)
/* sin = 1, cos = 0 */
...
...
@@ -276,8 +272,8 @@ void RotatePoint( int* pX, int* pY, int angle )
}
else
{
fpx
=
(
*
pY
*
fsinus
[
angle
])
+
(
*
pX
*
fcosinus
[
angle
]
);
fpy
=
(
*
pY
*
fcosinus
[
angle
])
-
(
*
pX
*
fsinus
[
angle
]
);
fpx
=
(
*
pY
*
fsinus
[
angle
]
)
+
(
*
pX
*
fcosinus
[
angle
]
);
fpy
=
(
*
pY
*
fcosinus
[
angle
]
)
-
(
*
pX
*
fsinus
[
angle
]
);
*
pX
=
wxRound
(
fpx
);
*
pY
=
wxRound
(
fpy
);
...
...
@@ -285,15 +281,11 @@ void RotatePoint( int* pX, int* pY, int angle )
}
/************************************************************/
void
RotatePoint
(
int
*
pX
,
int
*
pY
,
int
cx
,
int
cy
,
int
angle
)
/*************************************************************/
/*
* Fonction surchargee!
* calcule les nouvelles coord du point de coord pX, pY,
* pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre)
* Calculate the new point of coord coord pX, pY,
* for a rotation center cx, cy, and angle in (1 / 10 degree)
*/
void
RotatePoint
(
int
*
pX
,
int
*
pY
,
int
cx
,
int
cy
,
int
angle
)
{
int
ox
,
oy
;
...
...
@@ -307,15 +299,11 @@ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
}
/********************************************/
void
RotatePoint
(
wxPoint
*
point
,
int
angle
)
/********************************************/
/*
* Fonction surchargee!
* calcule les nouvelles coord du point point,
* pour une rotation d'angle angle ( en 1/10 degre)
* Calculates the new coord point point
* for a rotation angle in (1 / 10 degree)
*/
void
RotatePoint
(
wxPoint
*
point
,
int
angle
)
{
int
ox
,
oy
;
...
...
@@ -328,15 +316,11 @@ void RotatePoint( wxPoint* point, int angle )
}
/*****************************************************************/
void
RotatePoint
(
wxPoint
*
point
,
const
wxPoint
&
centre
,
int
angle
)
/*****************************************************************/
/*
* Fonction surchargee!
* calcule les nouvelles coord du point point,
* pour une rotation de centre centre, et d'angle angle ( en 1/10 degre)
* Calculates the new coord point point
* for a center rotation center and angle in (1 / 10 degree)
*/
void
RotatePoint
(
wxPoint
*
point
,
const
wxPoint
&
centre
,
int
angle
)
{
int
ox
,
oy
;
...
...
@@ -349,9 +333,7 @@ void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
}
/*************************************************************************/
void
RotatePoint
(
double
*
pX
,
double
*
pY
,
double
cx
,
double
cy
,
int
angle
)
/*************************************************************************/
{
double
ox
,
oy
;
...
...
@@ -365,14 +347,7 @@ void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
}
/*************************************************/
void
RotatePoint
(
double
*
pX
,
double
*
pY
,
int
angle
)
/*************************************************/
/* Calcul des coord :
* coord: xrot = y*sin + x*cos
* yrot = y*cos - x*sin
*/
{
double
tmp
;
...
...
common/worksheet.cpp
View file @
bc5d9a75
/*****************
*********************************
/
/* WORKSHEET.CPP
: routines de trace du cartouche
*/
/*****************
*********************************
/
/*****************/
/* WORKSHEET.CPP */
/*****************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -178,7 +178,7 @@ Ki_WorkSheetData WS_Comment4 =
NULL
,
NULL
};
Ki_WorkSheetData
WS_MostLeftLine
=
/*
segment vertical gauche
*/
Ki_WorkSheetData
WS_MostLeftLine
=
/*
Left vertical segment
*/
{
WS_LEFT_SEGMENT
,
#if defined(KICAD_GOST)
...
...
@@ -192,7 +192,8 @@ Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */
NULL
,
NULL
};
Ki_WorkSheetData
WS_SeparatorLine
=
/* horizontal segment between filename and comments*/
Ki_WorkSheetData
WS_SeparatorLine
=
/* horizontal segment between filename
* and comments */
{
WS_SEGMENT
,
&
WS_MostUpperLine
,
...
...
@@ -202,7 +203,7 @@ Ki_WorkSheetData WS_SeparatorLine = /* horizontal segment between filename and c
NULL
,
NULL
};
Ki_WorkSheetData
WS_MostUpperLine
=
/* s
egment horizontal superieur
*/
Ki_WorkSheetData
WS_MostUpperLine
=
/* s
uperior horizontal segment
*/
{
WS_UPPER_SEGMENT
,
&
WS_Segm3
,
...
...
@@ -216,7 +217,7 @@ Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm3
=
/*
segment horizontal au dessus de NAME COMPANY
*/
Ki_WorkSheetData
WS_Segm3
=
/*
horizontal segment above COMPANY NAME
*/
{
WS_SEGMENT
,
&
WS_Segm4
,
...
...
@@ -230,7 +231,7 @@ Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm4
=
/*
segment vertical a gauche de SHEET et REV
*/
Ki_WorkSheetData
WS_Segm4
=
/*
vertical segment of the left REV and SHEET
*/
{
WS_SEGMENT
,
&
WS_Segm5
,
...
...
@@ -244,7 +245,7 @@ Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm5
=
/* 1er segment horizontal */
Ki_WorkSheetData
WS_Segm5
=
{
WS_SEGMENT
,
&
WS_Segm6
,
...
...
@@ -258,7 +259,7 @@ Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm6
=
/* 2eme segment horizontal */
Ki_WorkSheetData
WS_Segm6
=
{
WS_SEGMENT
,
&
WS_Segm7
,
...
...
@@ -272,7 +273,7 @@ Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm7
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm7
=
{
WS_SEGMENT
,
#if defined(KICAD_GOST)
...
...
@@ -282,7 +283,7 @@ Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm8
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm8
=
{
WS_SEGMENT
,
&
WS_Segm9
,
...
...
@@ -291,7 +292,7 @@ Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm9
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm9
=
{
WS_SEGMENT
,
&
WS_Segm10
,
...
...
@@ -300,7 +301,7 @@ Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm10
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm10
=
{
WS_SEGMENT
,
&
WS_Segm11
,
...
...
@@ -309,7 +310,7 @@ Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm11
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm11
=
{
WS_SEGMENT
,
&
WS_Segm12
,
...
...
@@ -318,7 +319,7 @@ Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm12
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm12
=
{
WS_SEGMENT
,
&
WS_Segm13
,
...
...
@@ -327,7 +328,7 @@ Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm13
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm13
=
{
WS_SEGMENT
,
&
WS_Segm14
,
...
...
@@ -336,7 +337,7 @@ Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm14
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm14
=
{
WS_SEGMENT
,
&
WS_Segm15
,
...
...
@@ -345,7 +346,7 @@ Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm15
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm15
=
{
WS_SEGMENT
,
&
WS_Segm16
,
...
...
@@ -354,7 +355,7 @@ Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm16
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm16
=
{
WS_SEGMENT
,
&
WS_Segm17
,
...
...
@@ -363,7 +364,7 @@ Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm17
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm17
=
{
WS_SEGMENT
,
&
WS_Segm18
,
...
...
@@ -372,7 +373,7 @@ Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm18
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm18
=
{
WS_SEGMENT
,
&
WS_Segm19
,
...
...
@@ -381,7 +382,7 @@ Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm19
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm19
=
{
WS_SEGMENT
,
&
WS_Segm20
,
...
...
@@ -390,7 +391,7 @@ Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm20
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm20
=
{
WS_SEGMENT
,
&
WS_Segm21
,
...
...
@@ -399,7 +400,7 @@ Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm21
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm21
=
{
WS_SEGMENT
,
&
WS_Segm22
,
...
...
@@ -408,7 +409,7 @@ Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm22
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm22
=
{
WS_SEGMENT
,
&
WS_Segm23
,
...
...
@@ -417,7 +418,7 @@ Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm23
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm23
=
{
WS_SEGMENT
,
&
WS_Segm24
,
...
...
@@ -426,7 +427,7 @@ Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm24
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm24
=
{
WS_SEGMENT
,
&
WS_Segm25
,
...
...
@@ -435,7 +436,7 @@ Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */
NULL
,
NULL
};
Ki_WorkSheetData
WS_Segm25
=
/* segment vertical apres SIZE */
Ki_WorkSheetData
WS_Segm25
=
{
WS_SEGMENT
,
&
WS_Izm
,
...
...
@@ -826,8 +827,8 @@ Ki_WorkSheetData WS_Podp1_LU =
{
WS_PODPIS_LU
,
&
WS_Podp2_LU
,
STAMP_7
+
90
,
0
+
492
,
0
,
0
,
STAMP_7
+
90
,
0
+
492
,
0
,
0
,
wxT
(
"Инв.N подл."
),
NULL
};
...
...
@@ -835,8 +836,8 @@ Ki_WorkSheetData WS_Podp2_LU =
{
WS_PODPIS_LU
,
&
WS_Podp3_LU
,
STAMP_7
+
90
,
STAMP_25
+
688
,
0
,
0
,
STAMP_7
+
90
,
STAMP_25
+
688
,
0
,
0
,
wxT
(
"Подп. и дата"
),
NULL
};
...
...
@@ -844,8 +845,8 @@ Ki_WorkSheetData WS_Podp3_LU =
{
WS_PODPIS_LU
,
&
WS_Podp4_LU
,
STAMP_7
+
90
,
STAMP_60
+
492
,
0
,
0
,
STAMP_7
+
90
,
STAMP_60
+
492
,
0
,
0
,
wxT
(
"Взам.инв.N"
),
NULL
};
...
...
@@ -853,8 +854,8 @@ Ki_WorkSheetData WS_Podp4_LU =
{
WS_PODPIS_LU
,
&
WS_Podp5_LU
,
STAMP_7
+
90
,
STAMP_85
+
492
,
0
,
0
,
STAMP_7
+
90
,
STAMP_85
+
492
,
0
,
0
,
wxT
(
"Инв.N дубл."
),
NULL
};
...
...
@@ -862,8 +863,8 @@ Ki_WorkSheetData WS_Podp5_LU =
{
WS_PODPIS_LU
,
NULL
,
STAMP_7
+
90
,
STAMP_110
+
688
,
0
,
0
,
STAMP_7
+
90
,
STAMP_110
+
688
,
0
,
0
,
wxT
(
"Подп. и дата"
),
NULL
};
...
...
@@ -906,8 +907,8 @@ Ki_WorkSheetData WS_Segm5_LT =
{
WS_SEGMENT_LT
,
NULL
,
STAMP_X_70
,
STAMP_Y_14
,
STAMP_X_70
,
0
,
STAMP_X_70
,
STAMP_Y_14
,
STAMP_X_70
,
0
,
#else
NULL
,
BLOCK_OX
-
(
SIZETEXT
*
11
),
SIZETEXT
*
4
,
...
...
@@ -916,12 +917,11 @@ Ki_WorkSheetData WS_Segm5_LT =
NULL
,
NULL
};
/*************************************************************************************/
void
WinEDA_DrawFrame
::
TraceWorkSheet
(
wxDC
*
DC
,
BASE_SCREEN
*
screen
,
int
line_width
)
/*************************************************************************************/
/* Draw the
sheet references
/* Draw the
page reference sheet.
*/
void
WinEDA_DrawFrame
::
TraceWorkSheet
(
wxDC
*
DC
,
BASE_SCREEN
*
screen
,
int
line_width
)
{
if
(
!
m_Draw_Sheet_Ref
)
return
;
...
...
@@ -945,7 +945,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
if
(
Sheet
==
NULL
)
{
DisplayError
(
this
,
wxT
(
"WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet"
)
);
wxT
(
"WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet"
)
);
return
;
}
...
...
@@ -959,7 +959,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
}
GRSetDrawMode
(
DC
,
GR_COPY
);
/*
trace de la bordure
*/
/*
Draw the border.
*/
refx
=
Sheet
->
m_LeftMargin
;
refy
=
Sheet
->
m_TopMargin
;
/* Upper left corner */
xg
=
Sheet
->
m_Size
.
x
-
Sheet
->
m_RightMargin
;
...
...
@@ -981,14 +981,14 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
#endif
/*
trace des reperes
*/
/*
Draw the reference legends.
*/
refx
=
Sheet
->
m_LeftMargin
;
#if defined(KICAD_GOST)
refy
=
Sheet
->
m_Size
.
y
-
Sheet
->
m_BottomMargin
;
/* Lower left corner */
for
(
WsItem
=
&
WS_Segm1_LU
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
refx
-
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
pos
.
x
=
(
refx
-
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
...
...
@@ -1000,8 +1000,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
=
WsItem
->
m_Legende
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_VERT
,
size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_BOTTOM
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_BOTTOM
,
width
,
false
,
false
);
break
;
case
WS_SEGMENT_LU
:
...
...
@@ -1016,8 +1016,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
refy
=
Sheet
->
m_BottomMargin
;
/* Left Top corner */
for
(
WsItem
=
&
WS_Segm1_LT
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
refx
+
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
+
WsItem
->
m_Posy
)
*
scale
;
pos
.
x
=
(
refx
+
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
+
WsItem
->
m_Posy
)
*
scale
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
...
...
@@ -1035,39 +1035,37 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
xg
=
Sheet
->
m_Size
.
x
-
Sheet
->
m_RightMargin
;
yg
=
Sheet
->
m_Size
.
y
-
Sheet
->
m_BottomMargin
;
/* lower right corner */
/* Trace des reperes selon l'axe X */
ipas
=
(
xg
-
refx
)
/
PAS_REF
;
gxpas
=
(
xg
-
refx
)
/
ipas
;
ipas
=
(
xg
-
refx
)
/
PAS_REF
;
gxpas
=
(
xg
-
refx
)
/
ipas
;
for
(
ii
=
refx
+
gxpas
,
jj
=
1
;
ipas
>
0
;
ii
+=
gxpas
,
jj
++
,
ipas
--
)
{
Line
.
Printf
(
wxT
(
"%d"
),
jj
);
if
(
ii
<
xg
-
PAS_REF
/
2
)
{
GRLine
(
&
DrawPanel
->
m_ClipBox
,
DC
,
ii
*
scale
,
refy
*
scale
,
ii
*
scale
,
(
refy
+
GRID_REF_W
)
*
scale
,
width
,
Color
);
ii
*
scale
,
(
refy
+
GRID_REF_W
)
*
scale
,
width
,
Color
);
}
DrawGraphicText
(
DrawPanel
,
DC
,
wxPoint
(
(
ii
-
gxpas
/
2
)
*
scale
,
(
refy
+
GRID_REF_W
/
2
)
*
scale
)
,
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
wxPoint
(
(
ii
-
gxpas
/
2
)
*
scale
,
(
refy
+
GRID_REF_W
/
2
)
*
scale
)
,
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
if
(
ii
<
xg
-
PAS_REF
/
2
)
{
GRLine
(
&
DrawPanel
->
m_ClipBox
,
DC
,
ii
*
scale
,
yg
*
scale
,
ii
*
scale
,
(
yg
-
GRID_REF_W
)
*
scale
,
width
,
Color
);
ii
*
scale
,
(
yg
-
GRID_REF_W
)
*
scale
,
width
,
Color
);
}
DrawGraphicText
(
DrawPanel
,
DC
,
wxPoint
(
(
ii
-
gxpas
/
2
)
*
scale
,
(
yg
-
GRID_REF_W
/
2
)
*
scale
),
wxPoint
(
(
ii
-
gxpas
/
2
)
*
scale
,
(
yg
-
GRID_REF_W
/
2
)
*
scale
),
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
}
/* Trace des reperes selon l'axe Y */
ipas
=
(
yg
-
refy
)
/
PAS_REF
;
gypas
=
(
yg
-
refy
)
/
ipas
;
ipas
=
(
yg
-
refy
)
/
PAS_REF
;
gypas
=
(
yg
-
refy
)
/
ipas
;
for
(
ii
=
refy
+
gypas
,
jj
=
0
;
ipas
>
0
;
ii
+=
gypas
,
jj
++
,
ipas
--
)
{
if
(
jj
<
26
)
...
...
@@ -1077,23 +1075,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
if
(
ii
<
yg
-
PAS_REF
/
2
)
{
GRLine
(
&
DrawPanel
->
m_ClipBox
,
DC
,
refx
*
scale
,
ii
*
scale
,
(
refx
+
GRID_REF_W
)
*
scale
,
ii
*
scale
,
width
,
Color
);
(
refx
+
GRID_REF_W
)
*
scale
,
ii
*
scale
,
width
,
Color
);
}
DrawGraphicText
(
DrawPanel
,
DC
,
wxPoint
(
(
refx
+
GRID_REF_W
/
2
)
*
scale
,
(
ii
-
gypas
/
2
)
*
scale
),
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
wxPoint
(
(
refx
+
GRID_REF_W
/
2
)
*
scale
,
(
ii
-
gypas
/
2
)
*
scale
),
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
if
(
ii
<
yg
-
PAS_REF
/
2
)
{
GRLine
(
&
DrawPanel
->
m_ClipBox
,
DC
,
xg
*
scale
,
ii
*
scale
,
(
xg
-
GRID_REF_W
)
*
scale
,
ii
*
scale
,
width
,
Color
);
(
xg
-
GRID_REF_W
)
*
scale
,
ii
*
scale
,
width
,
Color
);
}
DrawGraphicText
(
DrawPanel
,
DC
,
wxPoint
(
(
xg
-
GRID_REF_W
/
2
)
*
scale
,
(
ii
-
gxpas
/
2
)
*
scale
),
wxPoint
(
(
xg
-
GRID_REF_W
/
2
)
*
scale
,
(
ii
-
gxpas
/
2
)
*
scale
),
Color
,
Line
,
TEXT_ORIENT_HORIZ
,
size_ref
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
...
...
@@ -1101,7 +1098,6 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
#endif
/* Trace du cartouche */
#if defined(KICAD_GOST)
refx
=
Sheet
->
m_Size
.
x
-
Sheet
->
m_RightMargin
;
refy
=
Sheet
->
m_Size
.
y
-
Sheet
->
m_BottomMargin
;
/* lower right corner */
...
...
@@ -1141,7 +1137,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
<<
screen
->
m_ScreenNumber
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
,
false
);
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
,
false
);
break
;
case
WS_SHEETS
:
...
...
@@ -1150,7 +1147,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
<<
screen
->
m_NumberOfScreen
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
,
false
);
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
,
false
);
break
;
case
WS_COMPANY_NAME
:
...
...
@@ -1173,10 +1171,9 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
case
WS_UPPER_SEGMENT
:
case
WS_LEFT_SEGMENT
:
WS_MostUpperLine
.
m_Posy
=
WS_MostUpperLine
.
m_Endy
=
WS_MostLeftLine
.
m_Posy
=
STAMP_OY
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
WS_MostUpperLine
.
m_Posy
=
WS_MostUpperLine
.
m_Endy
=
WS_MostLeftLine
.
m_Posy
=
STAMP_OY
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
case
WS_SEGMENT
:
xg
=
Sheet
->
m_Size
.
x
-
...
...
@@ -1193,8 +1190,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{
for
(
WsItem
=
&
WS_CADRE_D
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
pos
.
x
=
(
refx
-
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
pos
.
x
=
(
refx
-
WsItem
->
m_Posx
)
*
scale
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
msg
.
Empty
();
switch
(
WsItem
->
m_Type
)
{
...
...
@@ -1238,7 +1235,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
break
;
case
WS_LEFT_SEGMENT_D
:
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
pos
.
y
=
(
refy
-
WsItem
->
m_Posy
)
*
scale
;
case
WS_SEGMENT_D
:
xg
=
Sheet
->
m_Size
.
x
-
...
...
@@ -1253,7 +1250,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
}
#else
refx
=
Sheet
->
m_Size
.
x
-
Sheet
->
m_RightMargin
-
GRID_REF_W
;
refy
=
Sheet
->
m_Size
.
y
-
Sheet
->
m_BottomMargin
-
GRID_REF_W
;
/* lower right corner */
refy
=
Sheet
->
m_Size
.
y
-
Sheet
->
m_BottomMargin
-
GRID_REF_W
;
for
(
WsItem
=
&
WS_Date
;
WsItem
!=
NULL
;
WsItem
=
WsItem
->
Pnext
)
{
...
...
@@ -1269,8 +1266,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
+=
screen
->
m_Date
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
true
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
true
);
break
;
case
WS_REV
:
...
...
@@ -1291,8 +1288,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
+=
wxT
(
" "
)
+
GetBuildVersion
();
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
break
;
case
WS_SIZESHEET
:
...
...
@@ -1301,8 +1298,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
+=
Sheet
->
m_Name
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
break
;
...
...
@@ -1312,21 +1309,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
<<
screen
->
m_ScreenNumber
<<
wxT
(
"/"
)
<<
screen
->
m_NumberOfScreen
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
break
;
case
WS_FILENAME
:
{
wxString
fname
,
fext
;
wxFileName
::
SplitPath
(
screen
->
m_FileName
,
(
wxString
*
)
NULL
,
&
fname
,
&
fext
);
wxFileName
::
SplitPath
(
screen
->
m_FileName
,
(
wxString
*
)
NULL
,
&
fname
,
&
fext
);
if
(
WsItem
->
m_Legende
)
msg
=
WsItem
->
m_Legende
;
msg
<<
fname
<<
wxT
(
"."
)
<<
fext
;
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
}
break
;
...
...
@@ -1336,8 +1334,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg
+=
GetScreenDesc
();
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
break
;
...
...
@@ -1375,8 +1373,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
UpperLimit
=
MAX
(
UpperLimit
,
WsItem
->
m_Posy
+
SIZETEXT
);
}
break
;
...
...
@@ -1389,8 +1387,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
UpperLimit
=
MAX
(
UpperLimit
,
WsItem
->
m_Posy
+
SIZETEXT
);
}
break
;
...
...
@@ -1403,8 +1401,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
UpperLimit
=
MAX
(
UpperLimit
,
WsItem
->
m_Posy
+
SIZETEXT
);
}
break
;
...
...
@@ -1417,8 +1415,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{
DrawGraphicText
(
DrawPanel
,
DC
,
pos
,
Color
,
msg
,
TEXT_ORIENT_HORIZ
,
size
,
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
GR_TEXT_HJUSTIFY_LEFT
,
GR_TEXT_VJUSTIFY_CENTER
,
width
,
false
,
false
);
UpperLimit
=
MAX
(
UpperLimit
,
WsItem
->
m_Posy
+
SIZETEXT
);
}
break
;
...
...
@@ -1448,16 +1446,14 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
}
/************************************************************************************************/
wxString
WinEDA_DrawFrame
::
GetXYSheetReferences
(
BASE_SCREEN
*
aScreen
,
const
wxPoint
&
aPosition
)
/************************************************************************************************/
/** Function GetXYSheetReferences
* Return the X,Y sheet references where the point position is located
* @param aScreen = screen to use
* @param aPosition = position to identify by YX ref
* @return a wxString containing the message locator like A3 or B6 (or ?? if out of page limits)
*/
wxString
WinEDA_DrawFrame
::
GetXYSheetReferences
(
BASE_SCREEN
*
aScreen
,
const
wxPoint
&
aPosition
)
{
Ki_PageDescr
*
Sheet
=
aScreen
->
m_CurrentSheetDesc
;
int
ii
,
xg
,
yg
,
ipas
,
gxpas
,
gypas
;
...
...
@@ -1467,7 +1463,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
if
(
Sheet
==
NULL
)
{
DisplayError
(
this
,
wxT
(
"WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet"
)
);
wxT
(
"WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet"
)
);
return
msg
;
}
...
...
@@ -1481,9 +1477,9 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
msg
<<
wxT
(
"?"
);
else
{
ipas
=
(
yg
-
refy
)
/
PAS_REF
;
// ipas = Y count sections
gypas
=
(
yg
-
refy
)
/
ipas
;
// gypas = Y section size
ii
=
(
aPosition
.
y
-
refy
)
/
gypas
;
ipas
=
(
yg
-
refy
)
/
PAS_REF
;
// ipas = Y count sections
gypas
=
(
yg
-
refy
)
/
ipas
;
// gypas = Y section size
ii
=
(
aPosition
.
y
-
refy
)
/
gypas
;
msg
.
Printf
(
wxT
(
"%c"
),
'A'
+
ii
);
}
...
...
@@ -1492,10 +1488,10 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
msg
<<
wxT
(
"?"
);
else
{
ipas
=
(
xg
-
refx
)
/
PAS_REF
;
// ipas = X count sections
gxpas
=
(
xg
-
refx
)
/
ipas
;
// gxpas = X section size
ipas
=
(
xg
-
refx
)
/
PAS_REF
;
// ipas = X count sections
gxpas
=
(
xg
-
refx
)
/
ipas
;
// gxpas = X section size
ii
=
(
aPosition
.
x
-
refx
)
/
gxpas
;
ii
=
(
aPosition
.
x
-
refx
)
/
gxpas
;
msg
<<
ii
+
1
;
}
...
...
@@ -1503,9 +1499,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
}
/*********************************************************************/
wxString
WinEDA_DrawFrame
::
GetScreenDesc
()
/*********************************************************************/
{
wxString
msg
;
...
...
common/wxwineda.cpp
View file @
bc5d9a75
/***************
*******************************************
/
/* wxwineda.cpp
- fonctions des classes du type WinEDAxxxx
*/
/****************
******************************************
/
/***************/
/* wxwineda.cpp */
/****************/
#ifdef __GNUG__
#pragma implementation
...
...
@@ -11,9 +11,9 @@
#include "wxstruct.h"
/*
*********************************************************************************/
/* Classe WinEDA_EnterText pour entrer une ou plusieurs ligne texte au clavier dans les frames */
/*********************************************************************************
*/
/*
* Text entry dialog to enter one or more lines of text.
*/
WinEDA_EnterText
::
WinEDA_EnterText
(
wxWindow
*
parent
,
const
wxString
&
Title
,
const
wxString
&
TextToEdit
,
...
...
@@ -26,26 +26,26 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
m_Title
=
new
wxStaticText
(
parent
,
-
1
,
Title
);
BoxSizer
->
Add
(
m_Title
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
BoxSizer
->
Add
(
m_Title
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
long
style
=
0
;
if
(
Multiline
)
style
=
wxTE_MULTILINE
;
m_FrameText
=
new
wxTextCtrl
(
parent
,
-
1
,
TextToEdit
,
wxDefaultPosition
,
Size
,
style
);
m_FrameText
=
new
wxTextCtrl
(
parent
,
-
1
,
TextToEdit
,
wxDefaultPosition
,
Size
,
style
);
m_FrameText
->
SetInsertionPoint
(
1
);
BoxSizer
->
Add
(
m_FrameText
,
0
,
wxGROW
|
wxALIGN_CENTER_VERTICAL
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
0
,
wxGROW
|
wxALIGN_CENTER_VERTICAL
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
}
/****************************************/
wxString
WinEDA_EnterText
::
GetValue
()
/****************************************/
{
m_Modify
=
m_FrameText
->
IsModified
();
m_NewText
=
m_FrameText
->
GetValue
();
...
...
@@ -82,14 +82,17 @@ void WinEDA_EnterText::Enable( bool enbl )
}
/*******************************************************
**************
/
/* Class
e pour editer un texte graphique + dimension en INCHES ou
MM */
/*******************************************************
**************
/
WinEDA_GraphicTextCtrl
::
WinEDA_GraphicTextCtrl
(
wxWindow
*
parent
,
/*******************************************************/
/* Class
to edit a graphic + text size in INCHES or
MM */
/*******************************************************/
WinEDA_GraphicTextCtrl
::
WinEDA_GraphicTextCtrl
(
wxWindow
*
parent
,
const
wxString
&
Title
,
const
wxString
&
TextToEdit
,
int
textsize
,
int
units
,
wxBoxSizer
*
BoxSizer
,
int
framelen
,
int
internal_unit
)
const
wxString
&
TextToEdit
,
int
textsize
,
int
units
,
wxBoxSizer
*
BoxSizer
,
int
framelen
,
int
internal_unit
)
{
m_Units
=
units
;
m_Internal_Unit
=
internal_unit
;
...
...
@@ -97,7 +100,8 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
m_Title
=
new
wxStaticText
(
parent
,
-
1
,
Title
);
BoxSizer
->
Add
(
m_Title
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
BoxSizer
->
Add
(
m_Title
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
m_FrameText
=
new
wxTextCtrl
(
parent
,
-
1
,
TextToEdit
);
...
...
@@ -108,12 +112,14 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
wxString
msg
=
_
(
"Size"
)
+
ReturnUnitSymbol
(
m_Units
);
wxStaticText
*
text
=
new
wxStaticText
(
parent
,
-
1
,
msg
);
BoxSizer
->
Add
(
text
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxADJUST_MINSIZE
,
5
);
BoxSizer
->
Add
(
text
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxADJUST_MINSIZE
,
5
);
}
wxString
value
=
FormatSize
(
m_Internal_Unit
,
m_Units
,
textsize
);
m_FrameSize
=
new
wxTextCtrl
(
parent
,
-
1
,
value
,
wxDefaultPosition
,
wxSize
(
70
,
-
1
)
);
m_FrameSize
=
new
wxTextCtrl
(
parent
,
-
1
,
value
,
wxDefaultPosition
,
wxSize
(
70
,
-
1
)
);
BoxSizer
->
Add
(
m_FrameSize
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
}
...
...
@@ -128,11 +134,12 @@ WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl()
}
wxString
WinEDA_GraphicTextCtrl
::
FormatSize
(
int
internalUnit
,
int
units
,
int
textSize
)
wxString
WinEDA_GraphicTextCtrl
::
FormatSize
(
int
internalUnit
,
int
units
,
int
textSize
)
{
wxString
value
;
// Limit
ation de la taille du texte a de valeurs raisonnables
// Limit
ing the size of the text of reasonable values.
if
(
textSize
<
10
)
textSize
=
10
;
...
...
@@ -172,7 +179,8 @@ wxString WinEDA_GraphicTextCtrl::GetText()
}
int
WinEDA_GraphicTextCtrl
::
ParseSize
(
const
wxString
&
sizeText
,
int
internalUnit
,
int
units
)
int
WinEDA_GraphicTextCtrl
::
ParseSize
(
const
wxString
&
sizeText
,
int
internalUnit
,
int
units
)
{
int
textsize
;
...
...
@@ -205,16 +213,15 @@ void WinEDA_GraphicTextCtrl::Enable( bool state )
}
/*****************************************************************/
/* Classe pour afficher et editer une coordonne en INCHES ou MM */
/*****************************************************************/
WinEDA_PositionCtrl
::
WinEDA_PositionCtrl
(
wxWindow
*
parent
,
/********************************************************/
/* Class to display and edit a coordinated INCHES or MM */
/********************************************************/
WinEDA_PositionCtrl
::
WinEDA_PositionCtrl
(
wxWindow
*
parent
,
const
wxString
&
title
,
const
wxPoint
&
pos_to_edit
,
int
units
,
wxBoxSizer
*
BoxSizer
,
int
internal_unit
)
const
wxPoint
&
pos_to_edit
,
int
units
,
wxBoxSizer
*
BoxSizer
,
int
internal_unit
)
{
wxString
text
;
...
...
@@ -225,10 +232,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
else
text
=
title
;
text
+=
_
(
"X"
)
+
ReturnUnitSymbol
(
m_Units
);
m_TextX
=
new
wxStaticText
(
parent
,
-
1
,
text
);
m_TextX
=
new
wxStaticText
(
parent
,
-
1
,
text
);
BoxSizer
->
Add
(
m_TextX
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
m_FramePosX
=
new
wxTextCtrl
(
parent
,
-
1
,
wxEmptyString
,
wxDefaultPosition
);
BoxSizer
->
Add
(
m_TextX
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
m_FramePosX
=
new
wxTextCtrl
(
parent
,
-
1
,
wxEmptyString
,
wxDefaultPosition
);
BoxSizer
->
Add
(
m_FramePosX
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
...
...
@@ -238,11 +247,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
else
text
=
title
;
text
+=
_
(
"Y"
)
+
ReturnUnitSymbol
(
m_Units
);
m_TextY
=
new
wxStaticText
(
parent
,
-
1
,
text
);
m_TextY
=
new
wxStaticText
(
parent
,
-
1
,
text
);
BoxSizer
->
Add
(
m_TextY
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
BoxSizer
->
Add
(
m_TextY
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
m_FramePosY
=
new
wxTextCtrl
(
parent
,
-
1
,
wxEmptyString
);
m_FramePosY
=
new
wxTextCtrl
(
parent
,
-
1
,
wxEmptyString
);
BoxSizer
->
Add
(
m_FramePosY
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
...
...
@@ -259,12 +269,9 @@ WinEDA_PositionCtrl::~WinEDA_PositionCtrl()
}
/******************************************/
wxPoint
WinEDA_PositionCtrl
::
GetValue
()
/******************************************/
/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur)
/* Returns (in internal units) to coordinate between (in user units)
*/
wxPoint
WinEDA_PositionCtrl
::
GetValue
()
{
wxPoint
coord
;
double
value
=
0
;
...
...
@@ -278,18 +285,14 @@ wxPoint WinEDA_PositionCtrl::GetValue()
}
/************************************************************/
void
WinEDA_PositionCtrl
::
Enable
(
bool
x_win_on
,
bool
y_win_on
)
/************************************************************/
{
m_FramePosX
->
Enable
(
x_win_on
);
m_FramePosY
->
Enable
(
y_win_on
);
}
/***********************************************************/
void
WinEDA_PositionCtrl
::
SetValue
(
int
x_value
,
int
y_value
)
/***********************************************************/
{
wxString
msg
;
...
...
@@ -320,9 +323,7 @@ WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
}
/*************************************/
wxSize
WinEDA_SizeCtrl
::
GetValue
()
/*************************************/
{
wxPoint
pos
=
WinEDA_PositionCtrl
::
GetValue
();
wxSize
size
;
...
...
@@ -333,15 +334,9 @@ wxSize WinEDA_SizeCtrl::GetValue()
}
/***********************************************************************/
/* Classe pour afficher et editer une dimension en INCHES MM ou autres*/
/***********************************************************************/
/* Unites:
* si units = 0 : unite = inch
* si units = 1 : unite = mm
* si units >1 : affichage direct
*/
/**************************************************************/
/* Class to display and edit a dimension INCHES, MM, or other */
/**************************************************************/
WinEDA_ValueCtrl
::
WinEDA_ValueCtrl
(
wxWindow
*
parent
,
const
wxString
&
title
,
int
value
,
int
units
,
wxBoxSizer
*
BoxSizer
,
int
internal_unit
)
...
...
@@ -353,17 +348,19 @@ WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title,
m_Value
=
value
;
label
+=
ReturnUnitSymbol
(
m_Units
);
m_Text
=
new
wxStaticText
(
parent
,
-
1
,
label
);
m_Text
=
new
wxStaticText
(
parent
,
-
1
,
label
);
BoxSizer
->
Add
(
m_Text
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
BoxSizer
->
Add
(
m_Text
,
0
,
wxGROW
|
wxLEFT
|
wxRIGHT
|
wxTOP
|
wxADJUST_MINSIZE
,
5
);
wxString
stringvalue
=
ReturnStringFromValue
(
m_Units
,
m_Value
,
m_Internal_Unit
);
wxString
stringvalue
=
ReturnStringFromValue
(
m_Units
,
m_Value
,
m_Internal_Unit
);
m_ValueCtrl
=
new
wxTextCtrl
(
parent
,
-
1
,
stringvalue
);
BoxSizer
->
Add
(
m_ValueCtrl
,
0
,
wxGROW
|
wxALIGN_CENTER_VERTICAL
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
0
,
wxGROW
|
wxALIGN_CENTER_VERTICAL
|
wxLEFT
|
wxRIGHT
|
wxBOTTOM
,
5
);
}
...
...
@@ -374,9 +371,7 @@ WinEDA_ValueCtrl::~WinEDA_ValueCtrl()
}
/***********************************/
int
WinEDA_ValueCtrl
::
GetValue
()
/***********************************/
{
int
coord
;
wxString
txtvalue
=
m_ValueCtrl
->
GetValue
();
...
...
@@ -386,9 +381,7 @@ int WinEDA_ValueCtrl::GetValue()
}
/********************************************/
void
WinEDA_ValueCtrl
::
SetValue
(
int
new_value
)
/********************************************/
{
wxString
buffer
;
...
...
@@ -399,7 +392,6 @@ void WinEDA_ValueCtrl::SetValue( int new_value )
}
/* Active ou desactive la frame: */
void
WinEDA_ValueCtrl
::
Enable
(
bool
enbl
)
{
m_ValueCtrl
->
Enable
(
enbl
);
...
...
@@ -407,9 +399,9 @@ void WinEDA_ValueCtrl::Enable( bool enbl )
}
/***************************************************************/
/* Class
e pour afficher et editer une valeur en double flottant
*/
/***************************************************************/
/***************************************************************
*******
/
/* Class
to display and edit a double precision floating point value.
*/
/***************************************************************
*******
/
WinEDA_DFloatValueCtrl
::
WinEDA_DFloatValueCtrl
(
wxWindow
*
parent
,
const
wxString
&
title
,
double
value
,
...
...
@@ -458,7 +450,6 @@ void WinEDA_DFloatValueCtrl::SetValue( double new_value )
}
/* Active ou desactive la frame: */
void
WinEDA_DFloatValueCtrl
::
Enable
(
bool
enbl
)
{
m_ValueCtrl
->
Enable
(
enbl
);
...
...
common/zoom.cpp
View file @
bc5d9a75
...
...
@@ -3,8 +3,7 @@
/************/
/*
* Fonctions de gestion du zoom, du pas de grille et du
* recadrage automatique
* Manage zoom, grid step, and auto crop.
*/
#include "fctsys.h"
...
...
@@ -16,9 +15,6 @@
#include "class_base_screen.h"
#include "wxstruct.h"
/**************************************************/
void
WinEDA_DrawFrame
::
Recadre_Trace
(
bool
ToMouse
)
/**************************************************/
/** Compute draw offset (scroll bars and draw parameters)
* in order to have the current graphic cursor position at the screen center
...
...
@@ -27,6 +23,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
*
* Note: Mac OS ** does not ** allow moving mouse cursor by program.
*/
void
WinEDA_DrawFrame
::
Recadre_Trace
(
bool
ToMouse
)
{
PutOnGrid
(
&
(
GetBaseScreen
()
->
m_Curseur
)
);
AdjustScrollBars
();
...
...
@@ -40,12 +37,10 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
}
/************************************************/
void
WinEDA_DrawFrame
::
PutOnGrid
(
wxPoint
*
coord
)
/************************************************/
/** Adjust the coordinate to the nearest grid value
* @param coord = coordinate to adjust
*/
void
WinEDA_DrawFrame
::
PutOnGrid
(
wxPoint
*
coord
)
{
wxRealPoint
grid_size
=
GetBaseScreen
()
->
GetGridSize
();
...
...
@@ -60,26 +55,20 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
}
/**************************************************************/
void
WinEDA_DrawFrame
::
Zoom_Automatique
(
bool
move_mouse_cursor
)
/**************************************************************/
/** Redraw the screen with the zoom level which shows all the page or the board
*/
void
WinEDA_DrawFrame
::
Zoom_Automatique
(
bool
move_mouse_cursor
)
{
if
(
GetBaseScreen
()
->
SetZoom
(
BestZoom
()
)
)
Recadre_Trace
(
move_mouse_cursor
);
}
/*************************************************/
void
WinEDA_DrawFrame
::
Window_Zoom
(
EDA_Rect
&
Rect
)
/*************************************************/
/** Compute the zoom factor and the new draw offset to draw the
* selected area (Rect) in full window screen
* @param Rect = selected area to show after zooming
*/
void
WinEDA_DrawFrame
::
Window_Zoom
(
EDA_Rect
&
Rect
)
{
double
scalex
,
bestscale
;
wxSize
size
;
...
...
@@ -98,12 +87,10 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
}
/******************************************************/
void
WinEDA_DrawFrame
::
OnZoom
(
wxCommandEvent
&
event
)
/******************************************************/
/** Function OnZoom(
/** Function OnZoom
* Called from any zoom event (toolbar , hotkey or popup )
*/
void
WinEDA_DrawFrame
::
OnZoom
(
wxCommandEvent
&
event
)
{
if
(
DrawPanel
==
NULL
)
{
...
...
@@ -184,13 +171,10 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
}
/*************************************************************/
void
WinEDA_DrawPanel
::
AddMenuZoom
(
wxMenu
*
MasterMenu
)
/*************************************************************/
/* add the zoom list menu the the MasterMenu.
* used in OnRightClick(wxMouseEvent& event)
*/
void
WinEDA_DrawPanel
::
AddMenuZoom
(
wxMenu
*
MasterMenu
)
{
size_t
i
;
int
maxZoomIds
;
...
...
@@ -228,7 +212,8 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
GetScreen
()
->
m_ZoomList
[
i
]
/
GetScreen
()
->
m_ZoomScalar
);
else
msg
.
Printf
(
wxT
(
"%.1f"
),
(
float
)
GetScreen
()
->
m_ZoomList
[
i
]
/
GetScreen
()
->
m_ZoomScalar
);
(
float
)
GetScreen
()
->
m_ZoomList
[
i
]
/
GetScreen
()
->
m_ZoomScalar
);
zoom_choice
->
Append
(
ID_POPUP_ZOOM_LEVEL_START
+
i
,
_
(
"Zoom: "
)
+
msg
,
wxEmptyString
,
wxITEM_CHECK
);
...
...
@@ -258,7 +243,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
}
else
{
if
(
g_UnitMetric
==
0
)
// inches
if
(
g_UnitMetric
==
0
)
// inches
msg
.
Printf
(
wxT
(
"%.1f mils"
),
gridValue
*
1000
);
else
msg
.
Printf
(
wxT
(
"%.3f mm"
),
gridValue
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment