Commit bc5d9a75 authored by stambaughw's avatar stambaughw

Complete comment translation of common source.

parent d21bf859
/***************************************************************/ /********************************************************/
/* base_screen.cpp - fonctions des classes du type BASE_SCREEN */ /* base_screen.cpp - BASE_SCREEN object implementation. */
/***************************************************************/ /********************************************************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -19,16 +19,14 @@ WX_DEFINE_OBJARRAY( GridArray ); ...@@ -19,16 +19,14 @@ WX_DEFINE_OBJARRAY( GridArray );
BASE_SCREEN* ActiveScreen = NULL; BASE_SCREEN* ActiveScreen = NULL;
/* defines locaux */ #define CURSOR_SIZE 12 /* size of the cross cursor. */
#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */
/*******************************************************/
/* Class BASE_SCREEN: classe de gestion d'un affichage */
/*******************************************************/
BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
{ {
EEDrawList = NULL; /* Schematic items list */ 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_FirstRedraw = TRUE;
m_ScreenNumber = 1; m_ScreenNumber = 1;
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
...@@ -45,16 +43,12 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) ...@@ -45,16 +43,12 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
} }
/******************************/
BASE_SCREEN::~BASE_SCREEN() BASE_SCREEN::~BASE_SCREEN()
/******************************/
{ {
} }
/*******************************/
void BASE_SCREEN::InitDatas() void BASE_SCREEN::InitDatas()
/*******************************/
{ {
if( m_Center ) if( m_Center )
{ {
...@@ -73,16 +67,15 @@ void BASE_SCREEN::InitDatas() ...@@ -73,16 +67,15 @@ void BASE_SCREEN::InitDatas()
SetCurItem( NULL ); SetCurItem( NULL );
/* indicateurs divers */ m_FlagRefreshReq = 0; /* Redraw screen request flag */
m_FlagRefreshReq = 0; /* Redraw screen requste flag */ m_FlagModified = 0; // Set when any change is made on broad
m_FlagModified = 0; // Set when any change is made on borad
m_FlagSave = 1; // Used in auto save: set when an auto save is made m_FlagSave = 1; // Used in auto save: set when an auto save is made
} }
/** /**
* Get screen units scalar. * Get screen units scalar.
* *
* Default implimentation returns scalar used for schematic screen. The * Default implementation returns scalar used for schematic screen. The
* internal units used by the schematic screen is 1 mil (0.001"). Override * 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. * this in derived classes that require internal units other than 1 mil.
*/ */
...@@ -91,9 +84,8 @@ int BASE_SCREEN::GetInternalUnits( void ) ...@@ -91,9 +84,8 @@ int BASE_SCREEN::GetInternalUnits( void )
return EESCHEMA_INTERNAL_UNIT; return EESCHEMA_INTERNAL_UNIT;
} }
/************************************/
wxSize BASE_SCREEN::ReturnPageSize( void ) wxSize BASE_SCREEN::ReturnPageSize( void )
/************************************/
{ {
int internal_units = GetInternalUnits(); int internal_units = GetInternalUnits();
...@@ -107,9 +99,7 @@ wxSize BASE_SCREEN::ReturnPageSize( void ) ...@@ -107,9 +99,7 @@ wxSize BASE_SCREEN::ReturnPageSize( void )
* @return the position in user units of location ScreenPos * @return the position in user units of location ScreenPos
* @param ScreenPos = the screen (in pixel) position co convert * @param ScreenPos = the screen (in pixel) position co convert
*/ */
/******************************************************************/
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
/******************************************************************/
{ {
wxPoint curpos = ScreenPos; wxPoint curpos = ScreenPos;
Unscale( curpos ); Unscale( curpos );
...@@ -122,7 +112,7 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) ...@@ -122,7 +112,7 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
} }
/** Function SetScalingFactor /** Function SetScalingFactor
* calculates the .m_Zoom member to have a given scaling facort * calculates the .m_Zoom member to have a given scaling factor
* @param the the current scale used to draw items on screen * @param the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( ) * draw coordinates are user coordinates * GetScalingFactor( )
*/ */
...@@ -163,6 +153,7 @@ int BASE_SCREEN::Scale( int coord ) ...@@ -163,6 +153,7 @@ int BASE_SCREEN::Scale( int coord )
#endif #endif
} }
double BASE_SCREEN::Scale( double coord ) double BASE_SCREEN::Scale( double coord )
{ {
#ifdef WX_ZOOM #ifdef WX_ZOOM
...@@ -178,12 +169,14 @@ double BASE_SCREEN::Scale( double coord ) ...@@ -178,12 +169,14 @@ double BASE_SCREEN::Scale( double coord )
#endif #endif
} }
void BASE_SCREEN::Scale( wxPoint& pt ) void BASE_SCREEN::Scale( wxPoint& pt )
{ {
pt.x = Scale( pt.x ); pt.x = Scale( pt.x );
pt.y = Scale( pt.y ); pt.y = Scale( pt.y );
} }
void BASE_SCREEN::Scale( wxRealPoint& pt ) void BASE_SCREEN::Scale( wxRealPoint& pt )
{ {
#ifdef WX_ZOOM #ifdef WX_ZOOM
...@@ -336,12 +329,7 @@ bool BASE_SCREEN::SetLastZoom() ...@@ -336,12 +329,7 @@ bool BASE_SCREEN::SetLastZoom()
} }
/********************************************/
void BASE_SCREEN::SetGridList( GridArray& gridlist ) void BASE_SCREEN::SetGridList( GridArray& gridlist )
/********************************************/
/* init liste des zoom (NULL terminated)
*/
{ {
if( !m_GridList.IsEmpty() ) if( !m_GridList.IsEmpty() )
m_GridList.Clear(); m_GridList.Clear();
...@@ -350,9 +338,7 @@ void BASE_SCREEN::SetGridList( GridArray& gridlist ) ...@@ -350,9 +338,7 @@ void BASE_SCREEN::SetGridList( GridArray& gridlist )
} }
/**********************************************/
void BASE_SCREEN::SetGrid( const wxRealPoint& size ) void BASE_SCREEN::SetGrid( const wxRealPoint& size )
/**********************************************/
{ {
wxASSERT( !m_GridList.IsEmpty() ); wxASSERT( !m_GridList.IsEmpty() );
...@@ -380,6 +366,7 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size ) ...@@ -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 ); size.x, size.y, m_Grid.m_Size.x, m_Grid.m_Size.y );
} }
/* Set grid size from command ID. */ /* Set grid size from command ID. */
void BASE_SCREEN::SetGrid( int id ) void BASE_SCREEN::SetGrid( int id )
{ {
...@@ -403,6 +390,7 @@ void BASE_SCREEN::SetGrid( int id ) ...@@ -403,6 +390,7 @@ void BASE_SCREEN::SetGrid( int id )
m_Grid.m_Size.y ); m_Grid.m_Size.y );
} }
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
{ {
size_t i; size_t i;
...@@ -432,6 +420,7 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid ) ...@@ -432,6 +420,7 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
m_GridList.Add( grid ); m_GridList.Add( grid );
} }
void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id ) void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
{ {
GRID_TYPE grid; GRID_TYPE grid;
...@@ -441,6 +430,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id ) ...@@ -441,6 +430,7 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
AddGrid( grid ); AddGrid( grid );
} }
void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id ) void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
{ {
double x, y; double x, y;
...@@ -490,25 +480,19 @@ int BASE_SCREEN::GetGridId() ...@@ -490,25 +480,19 @@ int BASE_SCREEN::GetGridId()
} }
/*****************************************/
void BASE_SCREEN::ClearUndoRedoList()
/*****************************************/
/* free the undo and the redo lists /* free the undo and the redo lists
*/ */
void BASE_SCREEN::ClearUndoRedoList()
{ {
ClearUndoORRedoList( m_UndoList ); ClearUndoORRedoList( m_UndoList );
ClearUndoORRedoList( m_RedoList ); ClearUndoORRedoList( m_RedoList );
} }
/***********************************************************/
void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
/************************************************************/
/* Put aNewitem in top of undo list /* Put aNewitem in top of undo list
* Deletes olds items if > count max. * Deletes old items if > count max.
*/ */
void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
{ {
m_UndoList.PushCommand( aNewitem ); m_UndoList.PushCommand( aNewitem );
...@@ -519,9 +503,7 @@ void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem ) ...@@ -519,9 +503,7 @@ void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
} }
/***********************************************************/
void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem ) void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
/***********************************************************/
{ {
m_RedoList.PushCommand( aNewitem ); m_RedoList.PushCommand( aNewitem );
...@@ -532,17 +514,13 @@ void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem ) ...@@ -532,17 +514,13 @@ void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
} }
/*****************************************************/
PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromUndoList( ) PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromUndoList( )
/*****************************************************/
{ {
return m_UndoList.PopCommand( ); return m_UndoList.PopCommand( );
} }
/******************************************************/
PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( ) PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( )
/******************************************************/
{ {
return m_RedoList.PopCommand( ); return m_RedoList.PopCommand( );
} }
...@@ -572,4 +550,3 @@ void BASE_SCREEN::Show( int nestLevel, std::ostream& os ) ...@@ -572,4 +550,3 @@ void BASE_SCREEN::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
/* EDA_TextStruct */ /* EDA_TextStruct */
/****************************************/ /****************************************/
/* Fichier base_struct.cpp */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "trigo.h" #include "trigo.h"
...@@ -28,7 +26,7 @@ EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType ) ...@@ -28,7 +26,7 @@ EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
{ {
InitVars(); InitVars();
m_StructType = idType; m_StructType = idType;
m_Parent = parent; /* Chainage hierarchique sur struct racine */ m_Parent = parent;
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
/* /*
* Class constructor for WinEDA_BasicFrame general options * Class constructor for WinEDA_BasicFrame general options
*/ */
/**********************************************************/
WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
int idtype, int idtype,
const wxString& title, const wxString& title,
...@@ -45,32 +44,27 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, ...@@ -45,32 +44,27 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 ); 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 ); SetSize( 0, 0, minsize.x, minsize.y );
// Create child subwindows. // Create child subwindows.
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimx, dimy = dimensions utiles de la GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimensions of the user
* zone utilisateur de la fenetre principale */ * area of the main
* window */
m_FramePos.x = m_FramePos.y = 0; m_FramePos.x = m_FramePos.y = 0;
m_FrameSize.y -= m_MsgFrameHeight; m_FrameSize.y -= m_MsgFrameHeight;
} }
/*
*
*/
/******************************************/
WinEDA_BasicFrame::~WinEDA_BasicFrame() WinEDA_BasicFrame::~WinEDA_BasicFrame()
/******************************************/
{ {
if( wxGetApp().m_HtmlCtrl ) if( wxGetApp().m_HtmlCtrl )
delete wxGetApp().m_HtmlCtrl; delete wxGetApp().m_HtmlCtrl;
wxGetApp().m_HtmlCtrl = NULL; wxGetApp().m_HtmlCtrl = NULL;
/* This needed for OSX: avoids furter OnDraw processing after this destructor /* This needed for OSX: avoids furter OnDraw processing after this
* and before the native window is destroyed * destructor and before the native window is destroyed
*/ */
this->Freeze( ); this->Freeze( );
} }
...@@ -79,9 +73,7 @@ WinEDA_BasicFrame::~WinEDA_BasicFrame() ...@@ -79,9 +73,7 @@ WinEDA_BasicFrame::~WinEDA_BasicFrame()
/* /*
* Virtual function * Virtual function
*/ */
/***********************************/
void WinEDA_BasicFrame::ReCreateMenuBar() void WinEDA_BasicFrame::ReCreateMenuBar()
/***********************************/
{ {
} }
...@@ -158,9 +150,7 @@ void WinEDA_BasicFrame::SaveSettings() ...@@ -158,9 +150,7 @@ void WinEDA_BasicFrame::SaveSettings()
} }
/******************************************************/
void WinEDA_BasicFrame::PrintMsg( const wxString& text ) void WinEDA_BasicFrame::PrintMsg( const wxString& text )
/******************************************************/
{ {
SetStatusText( text ); SetStatusText( text );
} }
...@@ -169,9 +159,7 @@ void WinEDA_BasicFrame::PrintMsg( const wxString& 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 * 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 ) void WinEDA_BasicFrame::DisplayActivity( int PerCent, const wxString& Text )
/*************************************************************************/
{ {
wxString Line; wxString Line;
...@@ -188,11 +176,9 @@ void WinEDA_BasicFrame::DisplayActivity( int PerCent, const wxString& Text ) ...@@ -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 ) void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
/*******************************************************************/
{ {
wxGetApp().m_fileHistory.AddFileToHistory( FullFileName ); wxGetApp().m_fileHistory.AddFileToHistory( FullFileName );
ReCreateMenuBar(); ReCreateMenuBar();
...@@ -202,10 +188,8 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName ) ...@@ -202,10 +188,8 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
/* /*
* Fetch the file name from the file history list. * Fetch the file name from the file history list.
*/ */
/*********************************************************************/
wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId, wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId,
const wxString& type ) const wxString& type )
/*********************************************************************/
{ {
wxString fn, msg; wxString fn, msg;
size_t i; size_t i;
...@@ -236,9 +220,7 @@ wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId, ...@@ -236,9 +220,7 @@ wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId,
/* /*
* *
*/ */
/**************************************************************/
void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/**************************************************************/
{ {
wxString msg; wxString msg;
...@@ -257,7 +239,8 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) ...@@ -257,7 +239,8 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
} }
else 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 ); DisplayError( this, msg );
} }
...@@ -273,7 +256,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) ...@@ -273,7 +256,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument( this, helpFile ); GetAssociatedDocument( this, helpFile );
#else #else
# error Help files format not defined # error Help files format not defined
#endif #endif
} }
...@@ -281,9 +264,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) ...@@ -281,9 +264,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/* /*
* *
*/ */
/***********************************************************************/
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) )
/***********************************************************************/
{ {
wxAboutDialogInfo info; wxAboutDialogInfo info;
InitKiCadAbout(info); InitKiCadAbout(info);
......
/****************************************************/ /********************************************/
/* Routines de gestion des commandes sur blocks */ /* Routines for managing on block commands. */
/* (section commune eeschema/pcbnew... */ /* (Common section Eeschema / pcbnew ... */
/****************************************************/ /********************************************/
/* Fichier common.cpp */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -17,36 +15,25 @@ ...@@ -17,36 +15,25 @@
#include "block_commande.h" #include "block_commande.h"
/*******************/
/* BLOCK_SELECTOR */
/*******************/
/****************************************************************************/
BLOCK_SELECTOR::BLOCK_SELECTOR() : BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE ), EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE ),
EDA_Rect() EDA_Rect()
/****************************************************************************/
{ {
m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */ m_State = STATE_NO_BLOCK; /* State (enum BlockState) of block. */
m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */ m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) of operation. */
m_Color = BROWN; m_Color = BROWN;
} }
/****************************************/
BLOCK_SELECTOR::~BLOCK_SELECTOR() BLOCK_SELECTOR::~BLOCK_SELECTOR()
/****************************************/
{ {
} }
/***************************************************************/
void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame )
/***************************************************************/
/* /*
* Print block command message (Block move, Block copy ...) in status bar * Print block command message (Block move, Block copy ...) in status bar
*/ */
void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame )
{ {
wxString msg; wxString msg;
...@@ -109,12 +96,10 @@ void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame ) ...@@ -109,12 +96,10 @@ void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame )
} }
/**************************************************************/
void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, const wxPoint& aOffset,
int aDrawMode, int aDrawMode,
int aColor ) int aColor )
/**************************************************************/
{ {
int w = aPanel->GetScreen()->Scale( GetWidth() ); int w = aPanel->GetScreen()->Scale( GetWidth() );
int h = aPanel->GetScreen()->Scale( GetHeight() ); int h = aPanel->GetScreen()->Scale( GetHeight() );
...@@ -129,13 +114,11 @@ void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -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 /** function InitData
* Init the initial values of a BLOCK_SELECTOR, before starting a block command * 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; m_State = STATE_BLOCK_INIT;
SetOrigin( startpos ); SetOrigin( startpos );
...@@ -147,7 +130,8 @@ void BLOCK_SELECTOR::InitData( WinEDA_DrawPanel* aPanel, const wxPoint& startpos ...@@ -147,7 +130,8 @@ void BLOCK_SELECTOR::InitData( WinEDA_DrawPanel* aPanel, const wxPoint& startpos
/** Function ClearItemsList /** 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() void BLOCK_SELECTOR::ClearItemsList()
{ {
...@@ -155,7 +139,8 @@ void BLOCK_SELECTOR::ClearItemsList() ...@@ -155,7 +139,8 @@ void BLOCK_SELECTOR::ClearItemsList()
} }
/** Function ClearListAndDeleteItems /** 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() void BLOCK_SELECTOR::ClearListAndDeleteItems()
{ {
...@@ -173,14 +158,11 @@ void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem ) ...@@ -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: /* First command block function:
* Init the Block infos: command type, initial position, and other variables.. * 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; BLOCK_SELECTOR* Block = &GetBaseScreen()->m_BlockLocate;
...@@ -204,7 +186,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, ...@@ -204,7 +186,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
case BLOCK_ROTATE: /* Rotate 90 deg */ case BLOCK_ROTATE: /* Rotate 90 deg */
case BLOCK_FLIP: /* Flip */ case BLOCK_FLIP: /* Flip */
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */ case BLOCK_MIRROR_Y: /* mirror */
...@@ -228,7 +210,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, ...@@ -228,7 +210,7 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
{ {
Block->m_ItemsSelection.ClearItemsList(); Block->m_ItemsSelection.ClearItemsList();
DisplayError( this, DisplayError( this,
wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) ); wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) );
return TRUE; return TRUE;
} }
Block->m_State = STATE_BLOCK_MOVE; Block->m_State = STATE_BLOCK_MOVE;
...@@ -249,15 +231,14 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, ...@@ -249,15 +231,14 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
return TRUE; 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 * The first point of the rectangle showing the area is initialised
* by Initm_BlockLocateDatas(). * by Initm_BlockLocateDatas().
* The other point of the rectangle is the mouse cursor * The other point of the rectangle is the mouse cursor
*/ */
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
BLOCK_SELECTOR* PtBlock; BLOCK_SELECTOR* PtBlock;
...@@ -265,7 +246,6 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -265,7 +246,6 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
PtBlock->m_MoveVector = wxPoint( 0, 0 ); PtBlock->m_MoveVector = wxPoint( 0, 0 );
/* Effacement ancien cadre */
if( erase ) if( erase )
PtBlock->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, PtBlock->m_Color ); 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 ) ...@@ -277,25 +257,23 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( PtBlock->m_State == STATE_BLOCK_INIT ) if( PtBlock->m_State == STATE_BLOCK_INIT )
{ {
if( PtBlock->GetWidth() || PtBlock->GetHeight() ) if( PtBlock->GetWidth() || PtBlock->GetHeight() )
/* 2ieme point existant: le rectangle n'est pas de surface nulle */ /* 2nd point exists: the rectangle is not surface anywhere */
PtBlock->m_State = STATE_BLOCK_END; PtBlock->m_State = STATE_BLOCK_END;
} }
} }
/******************************************************************/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/* /*
* Cancel Current block operation. * Cancel Current block operation.
*/ */
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
BASE_SCREEN* screen = Panel->GetScreen(); 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->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
...@@ -314,4 +292,3 @@ void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -314,4 +292,3 @@ void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
screen->m_BlockLocate.m_Command = BLOCK_IDLE; screen->m_BlockLocate.m_Command = BLOCK_IDLE;
Panel->m_Parent->DisplayToolMsg( wxEmptyString ); Panel->m_Parent->DisplayToolMsg( wxEmptyString );
} }
...@@ -88,7 +88,6 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, ...@@ -88,7 +88,6 @@ MARKER_BASE::MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
} }
/* Effacement memoire de la structure */
MARKER_BASE::~MARKER_BASE() MARKER_BASE::~MARKER_BASE()
{ {
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "fctsys.h" #include "fctsys.h"
//#include "gr_basic.h"
#include "trigo.h" #include "trigo.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "base_struct.h" #include "base_struct.h"
...@@ -37,27 +36,24 @@ PLOTTER::PLOTTER( PlotFormat aPlotType ) ...@@ -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 ) 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 ); pos.x = (int) ( (pos.x - plot_offset.x) * plot_scale * device_scale );
if( plot_orient_options == PLOT_MIROIR ) 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 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 */ /* 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; wxPoint start, end;
const int delta = 50; /* increment (in 0.1 degrees) to draw circles */ 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, ...@@ -69,54 +65,48 @@ void PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
set_current_line_width( width ); set_current_line_width( width );
/* Please NOTE the different sign due to Y-axis flip */ /* Please NOTE the different sign due to Y-axis flip */
alpha = StAngle / 1800.0 * M_PI; alpha = StAngle / 1800.0 * M_PI;
start.x = centre.x + (int) ( rayon * cos( -alpha ) ); start.x = centre.x + (int) ( radius * cos( -alpha ) );
start.y = centre.y + (int) ( rayon * sin( -alpha ) ); start.y = centre.y + (int) ( radius * sin( -alpha ) );
move_to( start ); move_to( start );
for( int ii = StAngle + delta; ii < EndAngle; ii += delta ) for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
{ {
alpha = ii / 1800.0 * M_PI; alpha = ii / 1800.0 * M_PI;
end.x = centre.x + (int) ( rayon * cos( -alpha ) ); end.x = centre.x + (int) ( radius * cos( -alpha ) );
end.y = centre.y + (int) ( rayon * sin( -alpha ) ); end.y = centre.y + (int) ( radius * sin( -alpha ) );
line_to( end ); line_to( end );
} }
alpha = EndAngle / 1800.0 * M_PI; alpha = EndAngle / 1800.0 * M_PI;
end.x = centre.x + (int) ( rayon * cos( -alpha ) ); end.x = centre.x + (int) ( radius * cos( -alpha ) );
end.y = centre.y + (int) ( rayon * sin( -alpha ) ); end.y = centre.y + (int) ( radius * sin( -alpha ) );
finish_to( end ); finish_to( end );
} }
/************************************/ /* Modifies size size.x and size.y trace according to the scale factor. */
void PLOTTER::user_to_device_size( wxSize& size ) 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.x = (int) ( size.x * plot_scale * device_scale );
size.y = (int) ( size.y * plot_scale * device_scale ); size.y = (int) ( size.y * plot_scale * device_scale );
} }
/************************************/
double PLOTTER::user_to_device_size( double size ) double PLOTTER::user_to_device_size( double size )
/************************************/
{ {
return size * plot_scale * device_scale; return size * plot_scale * device_scale;
} }
/************************************************************************************/
void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill ) void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T fill )
/************************************************************************************/
{ {
int rayon = wxRound( diametre / 2.8284 ); int radius = wxRound( diametre / 2.8284 );
int coord[10] = int coord[10] =
{ {
position.x + rayon, position.y + rayon, position.x + radius, position.y + radius,
position.x + rayon, position.y - rayon, position.x + radius, position.y - radius,
position.x - rayon, position.y - rayon, position.x - radius, position.y - radius,
position.x - rayon, position.y + rayon, position.x - radius, position.y + radius,
position.x + rayon, position.y + rayon position.x + radius, position.y + radius
}; };
if( fill ) if( fill )
...@@ -130,18 +120,17 @@ void PLOTTER::center_square( const wxPoint& position, int diametre, FILL_T 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,
void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill ) FILL_T fill )
/************************************************************************************/
{ {
int rayon = diametre / 2; int radius = diametre / 2;
int coord[10] = int coord[10] =
{ {
position.x, position.y + rayon, position.x, position.y + radius,
position.x + rayon, position.y, position.x + radius, position.y,
position.x, position.y - rayon, position.x, position.y - radius,
position.x - rayon, position.y, position.x - radius, position.y,
position.x, position.y + rayon, position.x, position.y + radius,
}; };
if( fill ) if( fill )
...@@ -155,17 +144,14 @@ void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill ...@@ -155,17 +144,14 @@ void PLOTTER::center_lozenge( const wxPoint& position, int diametre, FILL_T fill
} }
/************************************************************************************/ /* Draw a pattern shape number aShapeId, to coord x0, y0.
void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId ) * x0, y0 = coordinates tables
/************************************************************************************/ * Diameter diameter = (coord table) hole
* AShapeId = index (used to generate forms characters)
/* 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 )
*/ */
void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
{ {
int rayon = diametre / 2; int radius = diametre / 2;
int x0, y0; int x0, y0;
...@@ -173,84 +159,84 @@ void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId ) ...@@ -173,84 +159,84 @@ void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId )
switch( aShapeId ) switch( aShapeId )
{ {
case 0: /* vias : forme en X */ case 0: /* vias : X shape */
move_to( wxPoint( x0 - rayon, y0 - rayon ) ); move_to( wxPoint( x0 - radius, y0 - radius ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) ); line_to( wxPoint( x0 + radius, y0 + radius ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) ); move_to( wxPoint( x0 + radius, y0 - radius ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) ); finish_to( wxPoint( x0 - radius, y0 + radius ) );
break; break;
case 1: /* Cercle */ case 1: /* Circle */
circle( position, diametre, NO_FILL ); circle( position, diametre, NO_FILL );
break; break;
case 2: /* forme en + */ case 2: /* + shape */
move_to( wxPoint( x0, y0 - rayon ) ); move_to( wxPoint( x0, y0 - radius ) );
line_to( wxPoint( x0, y0 + rayon ) ); line_to( wxPoint( x0, y0 + radius ) );
move_to( wxPoint( x0 + rayon, y0 ) ); move_to( wxPoint( x0 + radius, y0 ) );
finish_to( wxPoint( x0 - rayon, y0 ) ); finish_to( wxPoint( x0 - radius, y0 ) );
break; break;
case 3: /* forme en X cercle */ case 3: /* X shape in circle */
circle( position, diametre, NO_FILL ); circle( position, diametre, NO_FILL );
move_to( wxPoint( x0 - rayon, y0 - rayon ) ); move_to( wxPoint( x0 - radius, y0 - radius ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) ); line_to( wxPoint( x0 + radius, y0 + radius ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) ); move_to( wxPoint( x0 + radius, y0 - radius ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) ); finish_to( wxPoint( x0 - radius, y0 + radius ) );
break; break;
case 4: /* forme en cercle barre de - */ case 4: /* circle with bar - shape */
circle( position, diametre, NO_FILL ); circle( position, diametre, NO_FILL );
move_to( wxPoint( x0 - rayon, y0 ) ); move_to( wxPoint( x0 - radius, y0 ) );
finish_to( wxPoint( x0 + rayon, y0 ) ); finish_to( wxPoint( x0 + radius, y0 ) );
break; break;
case 5: /* forme en cercle barre de | */ case 5: /* circle with bar | shape */
circle( position, diametre, NO_FILL ); circle( position, diametre, NO_FILL );
move_to( wxPoint( x0, y0 - rayon ) ); move_to( wxPoint( x0, y0 - radius ) );
finish_to( wxPoint( x0, y0 + rayon ) ); finish_to( wxPoint( x0, y0 + radius ) );
break; break;
case 6: /* forme en carre */ case 6: /* square */
center_square( position, diametre, NO_FILL ); center_square( position, diametre, NO_FILL );
break; break;
case 7: /* forme en losange */ case 7: /* diamond */
center_lozenge( position, diametre, NO_FILL ); center_lozenge( position, diametre, NO_FILL );
break; break;
case 8: /* forme en carre barre par un X*/ case 8: /* square with an X*/
center_square( position, diametre, NO_FILL ); center_square( position, diametre, NO_FILL );
move_to( wxPoint( x0 - rayon, y0 - rayon ) ); move_to( wxPoint( x0 - radius, y0 - radius ) );
line_to( wxPoint( x0 + rayon, y0 + rayon ) ); line_to( wxPoint( x0 + radius, y0 + radius ) );
move_to( wxPoint( x0 + rayon, y0 - rayon ) ); move_to( wxPoint( x0 + radius, y0 - radius ) );
finish_to( wxPoint( x0 - rayon, y0 + rayon ) ); finish_to( wxPoint( x0 - radius, y0 + radius ) );
break; break;
case 9: /* forme en losange barre par un +*/ case 9: /* diamond with a +*/
center_lozenge( position, diametre, NO_FILL ); center_lozenge( position, diametre, NO_FILL );
move_to( wxPoint( x0, y0 - rayon ) ); move_to( wxPoint( x0, y0 - radius ) );
line_to( wxPoint( x0, y0 + rayon ) ); line_to( wxPoint( x0, y0 + radius ) );
move_to( wxPoint( x0 + rayon, y0 ) ); move_to( wxPoint( x0 + radius, y0 ) );
finish_to( wxPoint( x0 - rayon, y0 ) ); finish_to( wxPoint( x0 - radius, y0 ) );
break; break;
case 10: /* forme en carre barre par un '/' */ case 10: /* square with a '/' */
center_square( position, diametre, NO_FILL ); center_square( position, diametre, NO_FILL );
move_to( wxPoint( x0 - rayon, y0 - rayon ) ); move_to( wxPoint( x0 - radius, y0 - radius ) );
finish_to( wxPoint( x0 + rayon, y0 + rayon ) ); finish_to( wxPoint( x0 + radius, y0 + radius ) );
break; break;
case 11: /* forme en losange barre par un |*/ case 11: /* square with a |*/
center_lozenge( position, diametre, NO_FILL ); center_lozenge( position, diametre, NO_FILL );
move_to( wxPoint( x0, y0 - rayon ) ); move_to( wxPoint( x0, y0 - radius ) );
finish_to( wxPoint( x0, y0 + rayon ) ); finish_to( wxPoint( x0, y0 + radius ) );
break; break;
case 12: /* forme en losange barre par un -*/ case 12: /* square with a -*/
center_lozenge( position, diametre, NO_FILL ); center_lozenge( position, diametre, NO_FILL );
move_to( wxPoint( x0 - rayon, y0 ) ); move_to( wxPoint( x0 - radius, y0 ) );
finish_to( wxPoint( x0 + rayon, y0 ) ); finish_to( wxPoint( x0 + radius, y0 ) );
break; break;
default: default:
...@@ -260,12 +246,10 @@ void PLOTTER::marker( const wxPoint& position, int diametre, int aShapeId ) ...@@ -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, void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode ) GRTraceMode tracemode )
/***************************************************************/
{ {
/* Convert a thick segment and plot it as an oval */
wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 ); wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
wxSize size( end.x - start.x, end.y - start.y ); wxSize size( end.x - start.x, end.y - start.y );
int orient; int orient;
...@@ -275,64 +259,70 @@ void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width, ...@@ -275,64 +259,70 @@ void PLOTTER::segment_as_oval( wxPoint start, wxPoint end, int width,
else if( size.x == 0 ) else if( size.x == 0 )
orient = 900; orient = 900;
else else
orient = -(int) ( atan2( (double) size.y, (double) size.x ) * 1800.0 / M_PI ); orient = -(int) ( atan2( (double) size.y,
size.x = (int) sqrt( ( (double) size.x * size.x ) + ( (double) size.y * size.y ) ) + width; (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; size.y = width;
flash_pad_oval( center, size, orient, tracemode ); flash_pad_oval( center, size, orient, tracemode );
} }
/***************************************************************/
void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient, void PLOTTER::sketch_oval( wxPoint pos, wxSize size, int orient,
int width ) int width )
/***************************************************************/
{ {
set_current_line_width( width ); set_current_line_width( width );
width = current_pen_width; width = current_pen_width;
int rayon, deltaxy, cx, cy; int radius, deltaxy, cx, cy;
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); orient += 900; EXCHG( size.x, size.y );
orient += 900;
if( orient >= 3600 ) if( orient >= 3600 )
orient -= 3600; orient -= 3600;
} }
deltaxy = size.y - size.x; /* = distance entre centres de l'ovale */
rayon = (size.x - width) / 2; deltaxy = size.y - size.x; /* distance between centers of the oval */
cx = -rayon; cy = -deltaxy / 2; radius = ( size.x - width ) / 2;
cx = -radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
move_to( wxPoint( cx + pos.x, cy + pos.y ) ); move_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = -rayon; cy = deltaxy / 2; cx = -radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
finish_to( wxPoint( cx + pos.x, cy + pos.y ) ); finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = rayon; cy = -deltaxy / 2; cx = radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
move_to( wxPoint( cx + pos.x, cy + pos.y ) ); move_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = rayon; cy = deltaxy / 2; cx = radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
finish_to( wxPoint( cx + pos.x, cy + pos.y ) ); finish_to( wxPoint( cx + pos.x, cy + pos.y ) );
cx = 0; cy = deltaxy / 2; cx = 0;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
arc( wxPoint( cx + pos.x, cy + pos.y ), arc( wxPoint( cx + pos.x, cy + pos.y ),
orient + 1800, orient + 3600, orient + 1800, orient + 3600,
rayon, NO_FILL ); radius, NO_FILL );
cx = 0; cy = -deltaxy / 2; cx = 0;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient ); RotatePoint( &cx, &cy, orient );
arc( wxPoint( cx + pos.x, cy + pos.y ), arc( wxPoint( cx + pos.x, cy + pos.y ),
orient, orient + 1800, orient, orient + 1800,
rayon, NO_FILL ); radius, NO_FILL );
} }
/***************************************************************/
void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
/***************************************************************/
/* Plot 1 segment like a track segment /* Plot 1 segment like a track segment
*/ */
void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
{ {
switch( tracemode ) switch( tracemode )
{ {
...@@ -351,24 +341,26 @@ void PLOTTER::thick_segment( wxPoint start, wxPoint end, int width, ...@@ -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 rayon, void PLOTTER::thick_arc( wxPoint centre, int StAngle, int EndAngle, int radius,
int width, GRTraceMode tracemode ) int width, GRTraceMode tracemode )
{ {
switch( tracemode ) switch( tracemode )
{ {
case FILAIRE: case FILAIRE:
set_current_line_width( -1 ); set_current_line_width( -1 );
arc( centre, StAngle, EndAngle, rayon, NO_FILL, -1 ); arc( centre, StAngle, EndAngle, radius, NO_FILL, -1 );
break; break;
case FILLED: case FILLED:
arc( centre, StAngle, EndAngle, rayon, NO_FILL, width ); arc( centre, StAngle, EndAngle, radius, NO_FILL, width );
break; break;
case SKETCH: case SKETCH:
set_current_line_width( -1 ); set_current_line_width( -1 );
arc( centre, StAngle, EndAngle, rayon - (width - current_pen_width) / 2, NO_FILL, -1 ); arc( centre, StAngle, EndAngle,
arc( centre, StAngle, EndAngle, rayon + (width - current_pen_width) / 2, NO_FILL, -1 ); radius - ( width - current_pen_width ) / 2, NO_FILL, -1 );
arc( centre, StAngle, EndAngle,
radius + ( width - current_pen_width ) / 2, NO_FILL, -1 );
break; break;
} }
} }
...@@ -426,14 +418,12 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width, ...@@ -426,14 +418,12 @@ void PLOTTER::thick_circle( wxPoint pos, int diametre, int width,
} }
/*************************************************************************************/
void PLOTTER::set_paper_size( Ki_PageDescr* asheet ) void PLOTTER::set_paper_size( Ki_PageDescr* asheet )
/*************************************************************************************/
{ {
wxASSERT( !output_file ); wxASSERT( !output_file );
sheet = asheet; sheet = asheet;
// Sheets are in mils, plotter works with decimils // Sheets are in mils, plotter works with decimals
paper_size.x = sheet->m_Size.x * 10; paper_size.x = sheet->m_Size.x * 10;
paper_size.y = sheet->m_Size.y * 10; paper_size.y = sheet->m_Size.y * 10;
} }
/**********************************************************/ /**************/
/* Routines d'affichage de parametres et caracteristiques */ /* common.cpp */
/**********************************************************/ /**************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "trigo.h" #include "trigo.h"
...@@ -31,8 +32,10 @@ Ki_PageDescr g_Sheet_B( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "B" ) ); ...@@ -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_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_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_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_GERBER( wxSize( 32000, 32000 ), wxPoint( 0, 0 ),
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ), wxT( "User" ) ); wxT( "GERBER" ) );
Ki_PageDescr g_Sheet_user( wxSize( 17000, 11000 ), wxPoint( 0, 0 ),
wxT( "User" ) );
Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] = Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
{ {
...@@ -44,7 +47,7 @@ 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 definitions. Please do not changes these. If a different
* file extension is needed, create a new definition in the application. * file extension is needed, create a new definition in the application.
* Please note, just because they are defined as const dosen't guarentee * Please note, just because they are defined as const doesn't guarantee
* that they cannot be changed. */ * that they cannot be changed. */
const wxString ProjectFileExtension( wxT( "pro" ) ); const wxString ProjectFileExtension( wxT( "pro" ) );
const wxString SchematicFileExtension( wxT( "sch" ) ); const wxString SchematicFileExtension( wxT( "sch" ) );
...@@ -74,7 +77,7 @@ int g_KeyPressed; ...@@ -74,7 +77,7 @@ int g_KeyPressed;
wxString g_Prj_Default_Config_FullFilename; wxString g_Prj_Default_Config_FullFilename;
wxString g_Prj_Config_LocalFilename; wxString g_Prj_Config_LocalFilename;
// Handle the preferd editor for browsing report files: // Handle the preferred editor for browsing report files:
int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
/* Draw color for moving objects: */ /* Draw color for moving objects: */
...@@ -134,16 +137,16 @@ wxString GetAboutBuildVersion() ...@@ -134,16 +137,16 @@ wxString GetAboutBuildVersion()
/** function SetLocaleTo_C_standard /** function SetLocaleTo_C_standard
* because kicad is internationalized, switch internatization to "C" standard * because kicad is internationalized, switch internalization to "C" standard
* i.e. uses the . (dot) as separator in print/read float numbers * i.e. uses the . (dot) as separator in print/read float numbers
* (some contries (France, Germany ..) use , (comma) as separator) * (some countries (France, Germany ..) use , (comma) as separator)
* This function must be called before read or write ascii files using float numbers in data * This function must be called before read or write ascii files using float
* the SetLocaleTo_C_standard function must be called after reading or writing the file * 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, * This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
* but could make more easier an optional use of locale in kicad * but could make more easier an optional use of locale in kicad
*/ */
/********************************/
void SetLocaleTo_C_standard( void ) void SetLocaleTo_C_standard( void )
{ {
setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C
...@@ -151,26 +154,22 @@ void SetLocaleTo_C_standard( void ) ...@@ -151,26 +154,22 @@ void SetLocaleTo_C_standard( void )
/** function SetLocaleTo_Default /** function SetLocaleTo_Default
* because kicad is internationalized, switch internatization to default * because kicad is internationalized, switch internalization to default
* to use the default separator in print/read float numbers * to use the default separator in print/read float numbers
* (. (dot) but some contries (France, Germany ..) use , (comma) as separator) * (. (dot) but some countries (France, Germany ..) use , (comma) as separator)
* This function must be called after a call to SetLocaleTo_C_standard * This function must be called after a call to SetLocaleTo_C_standard
* *
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function, * This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
* but could make more easier an optional use of locale in kicad * but could make more easier an optional use of locale in kicad
*/ */
/********************************/
void SetLocaleTo_Default( void ) void SetLocaleTo_Default( void )
/********************************/
{ {
setlocale( LC_NUMERIC, "" ); // revert to the current locale setlocale( LC_NUMERIC, "" ); // revert to the current locale
} }
/********************************************************************/
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
const wxString* aString ) const wxString* aString )
/********************************************************************/
{ {
wxWindow* window = aCtrl->GetParent(); wxWindow* window = aCtrl->GetParent();
...@@ -205,11 +204,9 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, ...@@ -205,11 +204,9 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl,
} }
/*********************************************************************************************/
Ki_PageDescr::Ki_PageDescr( const wxSize& size, Ki_PageDescr::Ki_PageDescr( const wxSize& size,
const wxPoint& offset, const wxPoint& offset,
const wxString& name ) const wxString& name )
/*********************************************************************************************/
{ {
// All sizes are in 1/1000 inch // All sizes are in 1/1000 inch
m_Size = size; m_Size = size;
...@@ -228,9 +225,7 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, ...@@ -228,9 +225,7 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size,
} }
/************************************/
wxString ReturnUnitSymbol( int Units ) wxString ReturnUnitSymbol( int Units )
/************************************/
{ {
wxString label; wxString label;
...@@ -281,9 +276,7 @@ wxString GetUnitsLabel( int units ) ...@@ -281,9 +276,7 @@ wxString GetUnitsLabel( int units )
* Add string " (mm):" or " ("):" to the static text Stext. * Add string " (mm):" or " ("):" to the static text Stext.
* Used in dialog boxes for entering values depending on selected units * Used in dialog boxes for entering values depending on selected units
*/ */
/**************************************************/
void AddUnitSymbol( wxStaticText& Stext, int Units ) void AddUnitSymbol( wxStaticText& Stext, int Units )
/**************************************************/
{ {
wxString msg = Stext.GetLabel(); wxString msg = Stext.GetLabel();
msg += ReturnUnitSymbol( Units ); msg += ReturnUnitSymbol( Units );
...@@ -296,9 +289,7 @@ void AddUnitSymbol( wxStaticText& Stext, int Units ) ...@@ -296,9 +289,7 @@ void AddUnitSymbol( wxStaticText& Stext, int Units )
* Convert the number Value in a string according to the internal 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 * and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl
*/ */
/******************************************/
void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit ) void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
/*****************************************/
{ {
wxString msg = ReturnStringFromValue( g_UnitMetric, Value, Internal_Unit ); wxString msg = ReturnStringFromValue( g_UnitMetric, Value, Internal_Unit );
...@@ -310,9 +301,7 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int 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, * Convert the Value in the wxTextCtrl TextCtrl in an integer,
* according to the internal units and the selected unit (g_UnitMetric) * according to the internal units and the selected unit (g_UnitMetric)
*/ */
/***************************************************/
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
/***************************************************/
{ {
int value; int value;
wxString msg = TextCtr.GetValue(); wxString msg = TextCtr.GetValue();
...@@ -330,12 +319,11 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) ...@@ -330,12 +319,11 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
* @param aValue = value in Internal_Unit * @param aValue = value in Internal_Unit
* @param aInternal_Unit = units per inch for Value * @param aInternal_Unit = units per inch for Value
* @param aAdd_unit_symbol = true to add symbol unit to the string 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, wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
bool aAdd_unit_symbol ) bool aAdd_unit_symbol )
/*******************************************/
{ {
wxString StringValue; wxString StringValue;
double value_to_print; double value_to_print;
...@@ -344,9 +332,11 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, ...@@ -344,9 +332,11 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
StringValue << aValue; StringValue << aValue;
else else
{ {
value_to_print = To_User_Unit( (bool) aUnits, (double) aValue, aInternal_Unit ); value_to_print = To_User_Unit( (bool) aUnits, (double) aValue,
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), aInternal_Unit );
value_to_print ); StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) :
wxT( "%.3f" ),
value_to_print );
} }
if( aAdd_unit_symbol ) if( aAdd_unit_symbol )
...@@ -375,10 +365,8 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit, ...@@ -375,10 +365,8 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
* Value = text * Value = text
* Internal_Unit = units per inch for computed value * Internal_Unit = units per inch for computed value
*/ */
/****************************************************************************/
int ReturnValueFromString( int Units, const wxString& TextValue, int ReturnValueFromString( int Units, const wxString& TextValue,
int Internal_Unit ) int Internal_Unit )
/****************************************************************************/
{ {
int Value; int Value;
double dtmp = 0; double dtmp = 0;
...@@ -400,9 +388,7 @@ int ReturnValueFromString( int Units, const wxString& TextValue, ...@@ -400,9 +388,7 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
* @param txt : wxString : a String text * @param txt : wxString : a String text
* @param splitter : wxChar : the 'split' character * @param splitter : wxChar : the 'split' character
*/ */
/**********************************************************/
wxArrayString* wxStringSplit( wxString txt, wxChar splitter ) wxArrayString* wxStringSplit( wxString txt, wxChar splitter )
/**********************************************************/
{ {
wxArrayString* list = new wxArrayString(); wxArrayString* list = new wxArrayString();
...@@ -427,10 +413,6 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter ) ...@@ -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 * Function To_User_Unit
* Convert in inch or mm the variable "val" (double)given in internal units * 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 ) ...@@ -439,6 +421,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_value )
* @param val : double : the given value * @param val : double : the given value
* @param internal_unit_value = internal units per inch * @param internal_unit_value = internal units per inch
*/ */
double To_User_Unit( bool is_metric, double val, int internal_unit_value )
{ {
double value; double value;
...@@ -454,9 +437,7 @@ double To_User_Unit( bool is_metric, double val, int internal_unit_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 * 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 ) int From_User_Unit( bool is_metric, double val, int internal_unit_value )
/*****************************************/
{ {
double value; double value;
...@@ -472,9 +453,7 @@ int From_User_Unit( bool is_metric, double val, int internal_unit_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" * Return the string date "day month year" like "23 jun 2005"
*/ */
/********/
wxString GenDate() wxString GenDate()
/********/
{ {
static const wxString mois[12] = static const wxString mois[12] =
{ {
...@@ -498,9 +477,7 @@ wxString GenDate() ...@@ -498,9 +477,7 @@ wxString GenDate()
/* /*
* My memory allocation * My memory allocation
*/ */
/***********************************/
void* MyMalloc( size_t nb_octets ) void* MyMalloc( size_t nb_octets )
/***********************************/
{ {
void* pt_mem; void* pt_mem;
...@@ -527,9 +504,7 @@ void* MyMalloc( size_t nb_octets ) ...@@ -527,9 +504,7 @@ void* MyMalloc( size_t nb_octets )
* @param aFlags The same args as allowed for wxExecute() * @param aFlags The same args as allowed for wxExecute()
* @return bool - true if success, else false * @return bool - true if success, else false
*/ */
/********************************************/
bool ProcessExecute( const wxString& aCommandLine, int aFlags ) bool ProcessExecute( const wxString& aCommandLine, int aFlags )
/********************************************/
{ {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
int pid = wxExecute( aCommandLine ); int pid = wxExecute( aCommandLine );
...@@ -544,9 +519,7 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags ) ...@@ -544,9 +519,7 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags )
/* /*
* My memory allocation, memory space is cleared * My memory allocation, memory space is cleared
*/ */
/*****************************/
void* MyZMalloc( size_t nb_octets ) void* MyZMalloc( size_t nb_octets )
/*****************************/
{ {
void* pt_mem = MyMalloc( nb_octets ); void* pt_mem = MyMalloc( nb_octets );
...@@ -556,9 +529,7 @@ void* MyZMalloc( size_t nb_octets ) ...@@ -556,9 +529,7 @@ void* MyZMalloc( size_t nb_octets )
} }
/*******************************/
void MyFree( void* pt_mem ) void MyFree( void* pt_mem )
/*******************************/
{ {
if( pt_mem ) if( pt_mem )
free( pt_mem ); free( pt_mem );
...@@ -570,9 +541,7 @@ void MyFree( void* pt_mem ) ...@@ -570,9 +541,7 @@ void MyFree( void* pt_mem )
* if omitSpacePadding == TRUE, the name can be used for a file name * if omitSpacePadding == TRUE, the name can be used for a file name
* (no spaces, replaced by _) * (no spaces, replaced by _)
*/ */
/**************************************************************/
wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
/**************************************************************/
{ {
const unsigned LAYER_LIMIT = 29; const unsigned LAYER_LIMIT = 29;
...@@ -615,13 +584,14 @@ enum textbox { ...@@ -615,13 +584,14 @@ enum textbox {
ID_TEXTBOX_LIST = 8010 ID_TEXTBOX_LIST = 8010
}; };
BEGIN_EVENT_TABLE( WinEDA_TextFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_TextFrame, wxDialog )
EVT_LISTBOX_DCLICK( ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList ) EVT_LISTBOX_DCLICK( ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList )
EVT_LISTBOX( ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList ) EVT_LISTBOX( ID_TEXTBOX_LIST, WinEDA_TextFrame::D_ClickOnList )
EVT_CLOSE( WinEDA_TextFrame::OnClose ) EVT_CLOSE( WinEDA_TextFrame::OnClose )
END_EVENT_TABLE() END_EVENT_TABLE()
/***************************************************************************/
WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
const wxString& title ) : const wxString& title ) :
wxDialog( parent, wxDialog( parent,
...@@ -631,14 +601,7 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, ...@@ -631,14 +601,7 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
wxDEFAULT_DIALOG_STYLE | wxDEFAULT_DIALOG_STYLE |
wxFRAME_FLOAT_ON_PARENT | wxFRAME_FLOAT_ON_PARENT |
MAYBE_RESIZE_BORDER ) 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; wxSize size;
m_Parent = parent; m_Parent = parent;
...@@ -653,27 +616,17 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent, ...@@ -653,27 +616,17 @@ WinEDA_TextFrame::WinEDA_TextFrame( wxWindow* parent,
0, NULL, 0, NULL,
wxLB_ALWAYS_SB | wxLB_SINGLE ); 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 ); SetReturnCode( -1 );
} }
/***************************************************/
void WinEDA_TextFrame::Append( const wxString& text ) void WinEDA_TextFrame::Append( const wxString& text )
/***************************************************/
{ {
m_List->Append( text ); m_List->Append( text );
} }
/**********************************************************/
void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event ) void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event )
/**********************************************************/
{ {
int ii = m_List->GetSelection(); int ii = m_List->GetSelection();
...@@ -681,27 +634,21 @@ void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event ) ...@@ -681,27 +634,21 @@ void WinEDA_TextFrame::D_ClickOnList( wxCommandEvent& event )
} }
/*************************************************/
void WinEDA_TextFrame::OnClose( wxCloseEvent& event ) void WinEDA_TextFrame::OnClose( wxCloseEvent& event )
/*************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*****************************************************************************/
void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X, void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X,
const wxString& texte_H, const wxString& texte_L, const wxString& texte_H, const wxString& texte_L,
int color ) int color )
/*****************************************************************************/
{ {
frame->MsgPanel->Affiche_1_Parametre( pos_X, texte_H, texte_L, color ); frame->MsgPanel->Affiche_1_Parametre( pos_X, texte_H, texte_L, color );
} }
/***********************/
int GetTimeStamp() int GetTimeStamp()
/***********************/
{ {
static int OldTimeStamp, NewTimeStamp; static int OldTimeStamp, NewTimeStamp;
...@@ -736,9 +683,7 @@ const wxString& valeur_param( int valeur, wxString& buf_texte ) ...@@ -736,9 +683,7 @@ const wxString& valeur_param( int valeur, wxString& buf_texte )
/* /*
* *
*/ */
/**********************************/
wxString& operator <<( wxString& aString, const wxPoint& aPos ) wxString& operator <<( wxString& aString, const wxPoint& aPos )
/*********************************/
{ {
wxString temp; wxString temp;
......
/******************************************/ /***********************************/
/* Kicad: Common plot DXF Routines */ /* Kicad: Common plot DXF Routines */
/******************************************/ /***********************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -11,13 +11,11 @@ ...@@ -11,13 +11,11 @@
#include "macros.h" #include "macros.h"
#include "kicad_string.h" #include "kicad_string.h"
/***********************************************************************************/
void DXF_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
/***********************************************************************************/
/* Set the plot offset for the current plotting /* Set the plot offset for the current plotting
*/ */
void DXF_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
{ {
wxASSERT( !output_file ); wxASSERT( !output_file );
plot_offset = offset; plot_offset = offset;
...@@ -29,16 +27,13 @@ void DXF_PLOTTER::set_viewport( wxPoint offset, ...@@ -29,16 +27,13 @@ void DXF_PLOTTER::set_viewport( wxPoint offset,
} }
/*****************************************************************/
void DXF_PLOTTER::start_plot( FILE* fout ) void DXF_PLOTTER::start_plot( FILE* fout )
/*****************************************************************/
{ {
wxASSERT( !output_file ); wxASSERT( !output_file );
output_file = fout; output_file = fout;
/* DXF HEADER - Boilerplate */ /* DXF HEADER - Boilerplate */
fputs( fputs( "0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n",
"0\nSECTION\n2\nHEADER\n9\n$ANGBASE\n50\n0.0\n9\n$ANGDIR\n70\n0\n0\nENDSEC\n0\nSECTION\n2\nTABLES\n0\nTABLE\n2\nLTYPE\n70\n1\n0\nLTYPE\n2\nCONTINUOUS\n70\n0\n3\nSolid line\n72\n65\n73\n0\n40\n0.0\n0\nENDTAB\n", output_file );
output_file );
/* Layer table - one layer per color */ /* Layer table - one layer per color */
fprintf( output_file, "0\nTABLE\n2\nLAYER\n70\n%d\n", NBCOLOR ); fprintf( output_file, "0\nTABLE\n2\nLAYER\n70\n%d\n", NBCOLOR );
for( int i = 0; i<NBCOLOR; i++ ) for( int i = 0; i<NBCOLOR; i++ )
...@@ -53,9 +48,7 @@ void DXF_PLOTTER::start_plot( FILE* fout ) ...@@ -53,9 +48,7 @@ void DXF_PLOTTER::start_plot( FILE* fout )
} }
/**********************************/
void DXF_PLOTTER::end_plot() void DXF_PLOTTER::end_plot()
/**********************************/
{ {
wxASSERT( output_file ); wxASSERT( output_file );
/* DXF FOOTER */ /* DXF FOOTER */
...@@ -65,27 +58,22 @@ void DXF_PLOTTER::end_plot() ...@@ -65,27 +58,22 @@ void DXF_PLOTTER::end_plot()
} }
/******************************/
void DXF_PLOTTER::set_color( int color )
/******************************/
/* /*
* color = color index in ColorRefs[] * color = color index in ColorRefs[]
*/ */
void DXF_PLOTTER::set_color( int color )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
if( (color >= 0 && color_mode) if( ( color >= 0 && color_mode )
|| (color == BLACK) || ( color == BLACK )
|| (color == WHITE) ) || ( color == WHITE ) )
{ {
current_color = color; current_color = color;
} }
} }
/************************************************************/
void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width ) void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/************************************************************/
{ {
wxASSERT( output_file ); wxASSERT( output_file );
move_to( p1 ); move_to( p1 );
...@@ -96,32 +84,27 @@ void DXF_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width ) ...@@ -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 ) void DXF_PLOTTER::circle( wxPoint centre, int diameter, FILL_T fill, int width )
/************************************************************/
{ {
wxASSERT( output_file ); wxASSERT( output_file );
double rayon = user_to_device_size( diameter / 2 ); double radius = user_to_device_size( diameter / 2 );
user_to_device_coordinates( centre ); user_to_device_coordinates( centre );
if( rayon > 0 ) if( radius > 0 )
{ {
wxString cname = ColorRefs[current_color].m_Name; wxString cname = ColorRefs[current_color].m_Name;
fprintf( output_file, "0\nCIRCLE\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%g\n", fprintf( output_file, "0\nCIRCLE\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%g\n",
CONV_TO_UTF8( cname ), CONV_TO_UTF8( cname ),
centre.x, centre.y, rayon ); centre.x, centre.y, radius );
} }
} }
/*****************************************************/ /* Draw a polygon (closed if completed) in DXF format
void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width ) * coord = coord table tops
/*****************************************************/ * nb = number of coord (coord 1 = 2 elements: X and Y table)
* fill: if != 0 filled polygon
/* 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
*/ */
void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
if( nb <= 1 ) if( nb <= 1 )
...@@ -131,27 +114,23 @@ void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width ) ...@@ -131,27 +114,23 @@ void DXF_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
for( int ii = 1; ii < nb; ii++ ) for( int ii = 1; ii < nb; ii++ )
line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) ); line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) );
/* Fermeture eventuelle du polygone */ /* Close polygon. */
if( fill ) if( fill )
{ {
int ii = (nb - 1) * 2; 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] ) ); line_to( wxPoint( coord[0], coord[1] ) );
} }
pen_finish(); pen_finish();
} }
/**********************************************/
void DXF_PLOTTER::pen_to( wxPoint pos, char plume )
/**********************************************/
/* /*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') * Move the pen up (pen = 'U') or down (feather = 'D') at position x, y
* en position x,y * Unit to unit DRAWING
* Unites en Unites DESSIN * If pen = 'Z' without lifting pen displacement
* Si plume = 'Z' lever de plume sans deplacement
*/ */
void DXF_PLOTTER::pen_to( wxPoint pos, char plume )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
if( plume == 'Z' ) if( plume == 'Z' )
...@@ -179,15 +158,14 @@ void DXF_PLOTTER::set_dash( bool dashed ) ...@@ -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) /** Function Plot a filled segment (track)
* @param start = starting point * @param start = starting point
* @param end = ending point * @param end = ending point
* @param aWidth = segment width (thickness) * @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH .. * @param aPlotMode = FILLED, SKETCH ..
*/ */
void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
...@@ -201,47 +179,44 @@ void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width, ...@@ -201,47 +179,44 @@ void DXF_PLOTTER::thick_segment( wxPoint start, wxPoint end, int width,
} }
/********************************************************************/ /* Plot an arc in DXF format.
void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon, * center = center coord
FILL_T fill, int width ) * StAngle, EndAngle = angle of beginning and end
/********************************************************************/ * Radius = radius of the arc
/* trace d'un arc de cercle:
* centre = coord du centre
* StAngle, EndAngle = angle de debut et fin
* rayon = rayon de l'arc
*/ */
void DXF_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int radius,
FILL_T fill, int width )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
if( rayon <= 0 ) if( radius <= 0 )
return; return;
user_to_device_coordinates( centre ); user_to_device_coordinates( centre );
rayon = user_to_device_size( rayon ); radius = user_to_device_size( radius );
/* DXF ARC */ /* DXF ARC */
wxString cname = ColorRefs[current_color].m_Name; wxString cname = ColorRefs[current_color].m_Name;
fprintf( output_file, "0\nARC\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%d.0\n50\n%d.0\n51\n%d.0\n", fprintf( output_file,
"0\nARC\n8\n%s\n10\n%d.0\n20\n%d.0\n40\n%d.0\n50\n%d.0\n51\n%d.0\n",
CONV_TO_UTF8( cname ), CONV_TO_UTF8( cname ),
centre.x, centre.y, rayon, centre.x, centre.y, radius,
StAngle / 10, EndAngle / 10 ); StAngle / 10, EndAngle / 10 );
} }
/***********************************************************************************/ /* Plot oval pad at position. */
void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{ {
wxASSERT( output_file ); wxASSERT( output_file );
/* la pastille est ramenee a une pastille ovale avec size.y > size.x /* The chip is reduced to an oval tablet with size.y > size.x
* ( ovale vertical en orientation 0 ) */ * (Oval vertical orientation 0) */
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); orient += 900; EXCHG( size.x, size.y );
orient += 900;
if( orient >= 3600 ) if( orient >= 3600 )
orient -= 3600; orient -= 3600;
} }
...@@ -249,27 +224,20 @@ void DXF_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, ...@@ -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, void DXF_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos */
{ {
wxASSERT( output_file ); wxASSERT( output_file );
circle( pos, diametre, NO_FILL ); 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 ) * Plot rectangular pad vertical or horizontal (rectangular Pad)
* donne par son centre et ses dimensions X et Y
* Units are user units
*/ */
void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
int orient, GRTraceMode trace_mode )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
wxSize size; wxSize size;
...@@ -282,12 +250,14 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize, ...@@ -282,12 +250,14 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
if( size.y < 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 ) 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 ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) ); move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) ); finish_to( wxPoint( fx, fy ) );
...@@ -295,28 +265,34 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize, ...@@ -295,28 +265,34 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize,
} }
if( size.y == 0 ) 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 ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) ); move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) ); finish_to( wxPoint( fx, fy ) );
return; 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 ); RotatePoint( &ox, &oy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); line_to( wxPoint( fx, fy ) );
...@@ -324,43 +300,47 @@ void DXF_PLOTTER::flash_pad_rect( wxPoint pos, wxSize padsize, ...@@ -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 : * Plot trapezoidal pad.
* son centre pos.x,pos.y * pos its center, pos.y
* ses dimensions dimX et dimY * Dimensions dim X and dimy
* les variations deltaX et deltaY * DeltaX and variations deltaY
* son orientation orient et 0.1 degres * Orientation and 0.1 degrees east
* le mode de trace (FILLED, SKETCH, FILAIRE) * Plot mode (FILLED, SKETCH, WIRED)
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY * The evidence is that a trapezoid, ie that deltaX or deltaY
* = 0. * = 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 * 0 ------------- 3
* . . * . .
* . . * . .
* . . * . .
* 1 --- 2 * 1 --- 2
*/ */
void DXF_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
wxPoint polygone[4]; /* coord des sommets / centre du pad */ wxPoint polygone[4]; /* coord of vertex or center of the pad */
wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ wxPoint coord[4]; /* coord actual corners of a trapezoidal trace */
int moveX, moveY; /* variation de position plume selon axe X et Y , lors int moveX, moveY; /* change pen position by X and Y axis to
* du remplissage du trapeze */ * fill the trapezoid */
moveX = moveY = 0; moveX = moveY = 0;
size.x /= 2; size.y /= 2; size.x /= 2;
delta.x /= 2; delta.y /= 2; size.y /= 2;
delta.x /= 2;
polygone[0].x = -size.x - delta.y; polygone[0].y = +size.y + delta.x; delta.y /= 2;
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[0].x = -size.x - delta.y;
polygone[3].x = +size.x + delta.y; polygone[3].y = +size.y - delta.x; 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++ ) for( int ii = 0; ii < 4; ii++ )
{ {
......
...@@ -13,16 +13,13 @@ ...@@ -13,16 +13,13 @@
#include "kicad_string.h" #include "kicad_string.h"
/***************************************************************************/
void GERBER_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
/***************************************************************************/
/** function set_viewport /** function set_viewport
* Set the plot offset for the current plotting * Set the plot offset for the current plotting
* @param aOffset = plot offset * @param aOffset = plot offset
* @param aScale = coordinate scale (scale coefficient for coordinates) * @param aScale = coordinate scale (scale coefficient for coordinates)
*/ */
void GERBER_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
{ {
wxASSERT( !output_file ); wxASSERT( !output_file );
wxASSERT( orient == 0 ); wxASSERT( orient == 0 );
...@@ -31,19 +28,16 @@ void GERBER_PLOTTER::set_viewport( wxPoint offset, ...@@ -31,19 +28,16 @@ void GERBER_PLOTTER::set_viewport( wxPoint offset,
wxASSERT( aScale == 1 ); wxASSERT( aScale == 1 );
plot_scale = 1; plot_scale = 1;
device_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 /** Function start_plot
* Write GERBER header to file * Write GERBER header to file
* initialize global variable g_Plot_PlotOutputFile * initialize global variable g_Plot_PlotOutputFile
* @param aFile: an opened file to write to * @param aFile: an opened file to write to
*/ */
void GERBER_PLOTTER::start_plot( FILE* aFile )
{ {
char Line[1024]; char Line[1024];
...@@ -53,7 +47,8 @@ void GERBER_PLOTTER::start_plot( FILE* aFile ) ...@@ -53,7 +47,8 @@ void GERBER_PLOTTER::start_plot( FILE* aFile )
output_file = work_file; output_file = work_file;
DateAndTime( Line ); DateAndTime( Line );
wxString Title = creator + wxT( " " ) + GetBuildVersion(); 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): // Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs( "G01*\nG70*\nG90*\n", output_file ); fputs( "G01*\nG70*\nG90*\n", output_file );
...@@ -69,9 +64,7 @@ void GERBER_PLOTTER::start_plot( FILE* aFile ) ...@@ -69,9 +64,7 @@ void GERBER_PLOTTER::start_plot( FILE* aFile )
} }
/******************************************************************/
void GERBER_PLOTTER::end_plot() void GERBER_PLOTTER::end_plot()
/*****************************************************************/
{ {
char line[1024]; char line[1024];
wxString msg; wxString msg;
...@@ -84,7 +77,7 @@ void GERBER_PLOTTER::end_plot() ...@@ -84,7 +77,7 @@ void GERBER_PLOTTER::end_plot()
output_file = final_file; output_file = final_file;
// Placement des Apertures en RS274X // Placement of apertures in RS274X
while( fgets( line, 1024, work_file ) ) while( fgets( line, 1024, work_file ) )
{ {
fputs( line, output_file ); fputs( line, output_file );
...@@ -101,24 +94,18 @@ void GERBER_PLOTTER::end_plot() ...@@ -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 /* 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(); 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 /* 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; int pen_width;
...@@ -132,10 +119,8 @@ void GERBER_PLOTTER::set_current_line_width( int 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, std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize& size,
APERTURE::Aperture_Type type ) APERTURE::Aperture_Type type )
/******************************************************/
{ {
int last_D_code = 9; int last_D_code = 9;
...@@ -160,14 +145,14 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize& ...@@ -160,14 +145,14 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::get_aperture( const wxSize&
} }
/******************************************************/ void GERBER_PLOTTER::select_aperture( const wxSize& size,
void GERBER_PLOTTER::select_aperture( const wxSize& size, APERTURE::Aperture_Type type ) APERTURE::Aperture_Type type )
/******************************************************/
{ {
wxASSERT( output_file ); wxASSERT( output_file );
if( ( current_aperture == apertures.end() ) if( ( current_aperture == apertures.end() )
|| (current_aperture->type != type) || ( current_aperture->type != type )
|| (current_aperture->size != size) ) || ( current_aperture->size != size ) )
{ {
/* Pick an existing aperture or create a new one */ /* Pick an existing aperture or create a new one */
current_aperture = get_aperture( size, type ); current_aperture = get_aperture( size, type );
...@@ -176,14 +161,10 @@ void GERBER_PLOTTER::select_aperture( const wxSize& size, APERTURE::Aperture_Typ ...@@ -176,14 +161,10 @@ void GERBER_PLOTTER::select_aperture( const wxSize& size, APERTURE::Aperture_Typ
} }
/******************************************************/ /*Generate list of D_CODES.
void GERBER_PLOTTER::write_aperture_list() * Returns the number of D_Codes generated in RS274X format.
/******************************************************/
/* Genere la liste courante des D_CODES
* Retourne le nombre de D_Codes utilises
* Genere une sequence RS274X
*/ */
void GERBER_PLOTTER::write_aperture_list()
{ {
wxASSERT( output_file ); wxASSERT( output_file );
char cbuf[1024]; char cbuf[1024];
...@@ -223,7 +204,6 @@ void GERBER_PLOTTER::write_aperture_list() ...@@ -223,7 +204,6 @@ void GERBER_PLOTTER::write_aperture_list()
} }
/**********************************************/
void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume ) void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
...@@ -246,9 +226,7 @@ void GERBER_PLOTTER::pen_to( wxPoint aPos, char plume ) ...@@ -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 ) void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/**************************************************************************/
{ {
wxASSERT( output_file ); wxASSERT( output_file );
int coord[10] = int coord[10] =
...@@ -263,22 +241,21 @@ void GERBER_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width ) ...@@ -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 /** Function circle
* writes a non filled circle to output file * writes a non filled circle to output file
* Plot one circle as segments (6 to 16 depending on its radius * Plot one circle as segments (6 to 16 depending on its radius
* @param aCentre = centre coordintes * @param aCentre = center coordinates
* @param aDiameter = diameter of the circle * @param aDiameter = diameter of the circle
* @param aWidth = line width * @param aWidth = line width
*/ */
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T fill,
int aWidth )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
wxPoint start, end; wxPoint start, end;
double radius = aDiameter / 2; 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.x = aCentre.x + wxRound( radius );
start.y = aCentre.y; start.y = aCentre.y;
...@@ -295,17 +272,15 @@ void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T fill, int aW ...@@ -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 /** Function PlotFilledPolygon_GERBER
* writes a filled polyline to output file * writes a filled polyline to output file
* @param aCornersCount = numer of corners * @param aCornersCount = number of corners
* @param aCoord = buffer of corners coordinates * @param aCoord = buffer of corners coordinates
* @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR) * @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
* @param aCoord = buffer of corners coordinates * @param aCoord = buffer of corners coordinates
*/ */
void GERBER_PLOTTER::poly( int aCornersCount, int* aCoord, FILL_T aFill,
int aWidth )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
wxPoint pos, startpos; wxPoint pos, startpos;
...@@ -361,30 +336,29 @@ void GERBER_PLOTTER::flash_pad_circle( wxPoint pos, int diametre, ...@@ -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, void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode ) 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 ); wxASSERT( output_file );
int x0, y0, x1, y1, delta; int x0, y0, x1, y1, delta;
/* Trace de la forme flashee */ /* Plot a flashed shape. */
if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 ) if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
&& trace_mode == FILLED ) && trace_mode == FILLED )
{ {
if( orient == 900 || orient == 2700 ) /* orient tournee de 90 deg */ if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
EXCHG( size.x, size.y ); EXCHG( size.x, size.y );
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
select_aperture( size, APERTURE::Oval ); select_aperture( size, APERTURE::Oval );
fprintf( output_file, "X%5.5dY%5.5dD03*\n", pos.x, pos.y ); 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 ) if( size.x > size.y )
{ {
...@@ -396,7 +370,7 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, ...@@ -396,7 +370,7 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
} }
if( trace_mode == FILLED ) 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; delta = size.y - size.x;
x0 = 0; x0 = 0;
y0 = -delta / 2; y0 = -delta / 2;
...@@ -414,25 +388,26 @@ void GERBER_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, ...@@ -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, void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size,
int orient, GRTraceMode trace_mode ) 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 ); wxASSERT( output_file );
/* Trace de la forme flashee */
/* Plot as flashed. */
switch( orient ) switch( orient )
{ {
case 900: case 900:
case 2700: /* la rotation de 90 ou 270 degres revient a permutter des dimensions */ case 2700: /* rotation of 90 degrees or 270 returns dimensions */
EXCHG( size.x, size.y ); EXCHG( size.x, size.y );
// Pass through // Pass through
case 0: case 0:
case 1800: case 1800:
switch( trace_mode ) switch( trace_mode )
...@@ -463,20 +438,16 @@ void GERBER_PLOTTER::flash_pad_rect( wxPoint pos, wxSize size, ...@@ -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, /* Plot trapezoidal pad.
int orient, GRTraceMode trace_mode ) * Pos is pad center
* Dimensions size.x and size.y
/* Trace 1 pad trapezoidal donne par : * Changes delta.x and delta.y (1 of at least two must be zero)
* son centre pos.x,pos.y * Orientation east to 0.1 degrees
* ses dimensions size.x et size.y * Plot mode (FILLED, SKETCH, WIRED)
* 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)
* *
* Le trace n'est fait que pour un trapeze, c.a.d que delta.x ou delta.y * The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
* = 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 " * " 0 ------------- 3 "
* " . . " * " . . "
...@@ -485,7 +456,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -485,7 +456,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " 1 ---- 2 " * " 1 ---- 2 "
* *
* *
* exemple de Disposition pour delta.y > 0, delta.x = 0 * Example delta.y > 0, delta.x = 0
* " 1 ---- 2 " * " 1 ---- 2 "
* " . . " * " . . "
* " . O . " * " . O . "
...@@ -493,7 +464,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -493,7 +464,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " 0 ------------- 3 " * " 0 ------------- 3 "
* *
* *
* exemple de Disposition pour delta.y = 0, delta.x > 0 * Example delta.y = 0, delta.x > 0
* " 0 " * " 0 "
* " . . " * " . . "
* " . . " * " . . "
...@@ -506,6 +477,9 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -506,6 +477,9 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
* " . . " * " . . "
* " 1 " * " 1 "
*/ */
void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int orient, GRTraceMode trace_mode )
{ {
wxASSERT( output_file ); wxASSERT( output_file );
int ii, jj; int ii, jj;
...@@ -514,7 +488,8 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -514,7 +488,8 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
int coord[10]; int coord[10];
int ddx, ddy; 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 ); dx = size.x - abs( delta.y );
dy = size.y - abs( delta.x ); dy = size.y - abs( delta.x );
...@@ -532,8 +507,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -532,8 +507,7 @@ void GERBER_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
polygon[3].x = +dx + ddy; polygon[3].x = +dx + ddy;
polygon[3].y = +dy - ddx; 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++ ) for( ii = 0, jj = 0; ii < 4; ii++ )
{ {
RotatePoint( &polygon[ii].x, &polygon[ii].y, orient ); RotatePoint( &polygon[ii].x, &polygon[ii].y, orient );
......
/******************************************/ /************************************/
/* Kicad: Common plot HPGL Routines */ /* Kicad: Common plot HPGL Routines */
/******************************************/ /************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -11,88 +11,83 @@ ...@@ -11,88 +11,83 @@
#include "macros.h" #include "macros.h"
#include "kicad_string.h" #include "kicad_string.h"
/* From decimils to plu */ /* HPGL scale factor. */
const double SCALE_HPGL = 0.102041; 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 /* Set the plot offset for the current plotting
*/ */
void HPGL_PLOTTER::set_viewport( wxPoint offset, double aScale, int orient )
{ {
wxASSERT(!output_file); wxASSERT( !output_file );
plot_offset = offset; plot_offset = offset;
plot_scale = aScale; plot_scale = aScale;
device_scale = SCALE_HPGL; 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; 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; output_file = fout;
fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number ); fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
} }
/**********************************/
void HPGL_PLOTTER::end_plot() void HPGL_PLOTTER::end_plot()
/**********************************/
{ {
wxASSERT(output_file); wxASSERT( output_file );
fputs( "PU;PA;SP0;\n", output_file ); fputs( "PU;PA;SP0;\n", output_file );
fclose( output_file ); fclose( output_file );
output_file = 0; output_file = 0;
} }
/************************************************************/
void HPGL_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width ) void HPGL_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/************************************************************/
{ {
wxASSERT(output_file); wxASSERT( output_file );
user_to_device_coordinates( p2 ); user_to_device_coordinates( p2 );
move_to(p1); move_to( p1 );
fprintf( output_file, "EA %d,%d;\n", p2.x, p2.y ); fprintf( output_file, "EA %d,%d;\n", p2.x, p2.y );
pen_finish(); 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); wxASSERT( output_file );
double rayon = user_to_device_size(diameter / 2); double rayon = user_to_device_size( diameter / 2 );
if( rayon > 0 ) if( rayon > 0 )
{ {
move_to(centre); move_to( centre );
fprintf( output_file, "CI %g;\n", rayon); fprintf( output_file, "CI %g;\n", rayon );
pen_finish(); pen_finish();
} }
} }
/*****************************************************/
void HPGL_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
/*****************************************************/
/* Trace un polygone (ferme si rempli) en format HPGL /* Plot a polygon (closed if completed) in HPGL
* coord = tableau des coord des sommets * Coord = coord table tops
* nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau ) * Nb = number of coord (coord 1 = 2 elements: X and Y table)
* fill : si != 0 polygone rempli * 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 ) if( nb <= 1 )
return; return;
move_to( wxPoint( coord[0], coord[1] ) ); 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] ) ); line_to( wxPoint( coord[ii * 2], coord[(ii * 2) + 1] ) );
/* Fermeture eventuelle du polygone */ /* Close polygon if filled. */
if( fill ) if( fill )
{ {
int ii = (nb - 1) * 2; int ii = (nb - 1) * 2;
...@@ -102,50 +97,49 @@ void HPGL_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width ) ...@@ -102,50 +97,49 @@ void HPGL_PLOTTER::poly( int nb, int* coord, FILL_T fill, int width )
pen_finish(); 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); wxASSERT( output_file );
switch (plume) { switch( plume )
{
case 'U': case 'U':
if( pen_state != 'U' ) if( pen_state != 'U' )
{ {
fputs( "PU;", output_file ); fputs( "PU;", output_file );
pen_state = 'U'; pen_state = 'U';
} }
break; break;
case 'D': case 'D':
if( pen_state != 'D' ) if( pen_state != 'D' )
{ {
fputs( "PD;", output_file ); fputs( "PD;", output_file );
pen_state = 'D'; pen_state = 'D';
} }
break; break;
case 'Z': case 'Z':
fputs( "PU;", output_file ); fputs( "PU;", output_file );
pen_state = 'U'; pen_state = 'U';
pen_lastpos.x = -1; pen_lastpos.x = -1;
pen_lastpos.y = -1; pen_lastpos.y = -1;
break; break;
} }
} }
/**********************************************/
void HPGL_PLOTTER::pen_to( wxPoint pos, char plume )
/**********************************************/
/* /*
* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') * Move the pen to position with pen up or down.
* en position x,y * At position x, y
* Unites en Unites DESSIN * Unit to unit DRAWING
* Si plume = 'Z' lever de plume sans deplacement * 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' ) if( plume == 'Z' )
{ {
pen_control( 'Z' ); pen_control( 'Z' );
...@@ -154,60 +148,61 @@ void HPGL_PLOTTER::pen_to( wxPoint pos, char plume ) ...@@ -154,60 +148,61 @@ void HPGL_PLOTTER::pen_to( wxPoint pos, char plume )
pen_control( plume ); pen_control( plume );
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
if (pen_lastpos != pos) if( pen_lastpos != pos )
fprintf( output_file, "PA %d,%d;\n", pos.x, pos.y ); fprintf( output_file, "PA %d,%d;\n", pos.x, pos.y );
pen_lastpos = pos; pen_lastpos = pos;
} }
void HPGL_PLOTTER::set_dash( bool dashed ) void HPGL_PLOTTER::set_dash( bool dashed )
{ {
wxASSERT(output_file); wxASSERT( output_file );
if (dashed) if( dashed )
fputs("LI 2;\n", stderr); fputs( "LI 2;\n", stderr );
else 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) /** Function Plot a filled segment (track)
* @param start = starting point * @param start = starting point
* @param end = ending point * @param end = ending point
* @param aWidth = segment width (thickness) * @param aWidth = segment width (thickness)
* @param aPlotMode = FILLED, SKETCH .. * @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; wxPoint center;
wxSize size; 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 ); move_to( start );
finish_to( end ); finish_to( end );
} }
else 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, /* Plot an arc:
FILL_T fill, int width ) * Center = center coord
/********************************************************************/ * Stangl, endAngle = angle of beginning and end
* Radius = radius of the arc
/* trace d'un arc de cercle: * Command
* centre = coord du centre * PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, NbSegm; PU;
* StAngle, EndAngle = angle de debut et fin * Or PU PY x, y; PD start_arc_X AA, start_arc_Y, angle, PU;
* 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;
*/ */
void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width )
{ {
wxASSERT(output_file); wxASSERT( output_file );
wxPoint cmap; /* point de depart */ wxPoint cmap;
wxPoint cpos; /* centre */ wxPoint cpos;
float angle; /* angle de l'arc*/ float angle;
if( rayon <= 0 ) if( rayon <= 0 )
return; return;
...@@ -216,72 +211,81 @@ void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon, ...@@ -216,72 +211,81 @@ void HPGL_PLOTTER::arc( wxPoint centre, int StAngle, int EndAngle, int rayon,
user_to_device_coordinates( cpos ); user_to_device_coordinates( cpos );
if( plot_orient_options == PLOT_MIROIR ) if( plot_orient_options == PLOT_MIROIR )
angle = (StAngle - EndAngle) / 10.0; angle = (StAngle - EndAngle) / 10.0;
else else
angle = (EndAngle - StAngle) / 10.0; angle = (EndAngle - StAngle) / 10.0;
/* Calcul des coord du point de depart : */ /* Calculate start point, */
cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) ); cmap.x = (int) ( centre.x + ( rayon * cos( StAngle * M_PI / 1800 ) ) );
cmap.y = (int) ( centre.y - ( rayon * sin( StAngle * M_PI / 1800 ) ) ); cmap.y = (int) ( centre.y - ( rayon * sin( StAngle * M_PI / 1800 ) ) );
user_to_device_coordinates( cmap ); 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, "%f", angle );
fprintf( output_file, ";PU;\n" ); fprintf( output_file, ";PU;\n" );
pen_finish(); pen_finish();
} }
/***********************************************************************************/
/* Plot oval pad.
*/
void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, void HPGL_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode ) GRTraceMode trace_mode )
/************************************************************************************/
/* Trace 1 pastille PAD_OVAL en position pos_X,Y , de dim size.x, size.y */
{ {
wxASSERT(output_file); wxASSERT( output_file );
int rayon, deltaxy, cx, cy; int rayon, deltaxy, cx, cy;
/* la pastille est ramenee a une pastille ovale avec size.y > size.x /* The pad is reduced to an oval with size.y > size.x
* ( ovale vertical en orientation 0 ) */ * (Oval vertical orientation 0)
*/
if( size.x > size.y ) if( size.x > size.y )
{ {
EXCHG( size.x, size.y ); orient += 900; EXCHG( size.x, size.y ); orient += 900;
if( orient >= 3600 ) if( orient >= 3600 )
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; rayon = size.x / 2;
if( trace_mode == FILLED ) if( trace_mode == FILLED )
{ {
flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ), flash_pad_rect( pos, wxSize( size.x, deltaxy + wxRound( pen_diameter ) ),
orient, trace_mode ); orient, trace_mode );
cx = 0; cy = deltaxy / 2; cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient ); 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; cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient ); 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, /* Plot round pad or via.
GRTraceMode trace_mode) */
/*******************************************************************************/ void HPGL_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
/* Trace 1 pastille RONDE (via,pad rond) en position pos */ GRTraceMode trace_mode )
{ {
wxASSERT(output_file); wxASSERT( output_file );
int rayon, delta; int rayon, delta;
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
delta = wxRound( pen_diameter - pen_overlap ) ; delta = wxRound( pen_diameter - pen_overlap );
rayon = diametre / 2; rayon = diametre / 2;
if( trace_mode != FILAIRE ) if( trace_mode != FILAIRE )
{ {
rayon = (diametre - wxRound( pen_diameter) ) / 2; rayon = ( diametre - wxRound( pen_diameter ) ) / 2;
} }
if( rayon < 0 ) if( rayon < 0 )
...@@ -293,7 +297,8 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre, ...@@ -293,7 +297,8 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
user_to_device_size( rsize ); 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 );
if( trace_mode == FILLED ) /* Trace en mode Remplissage */
if( trace_mode == FILLED ) /* Plot in filled mode. */
{ {
if( delta > 0 ) if( delta > 0 )
{ {
...@@ -301,7 +306,11 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre, ...@@ -301,7 +306,11 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
{ {
rsize.x = rsize.y = rayon; rsize.x = rsize.y = rayon;
user_to_device_size( rsize ); 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, ...@@ -309,68 +318,77 @@ void HPGL_PLOTTER::flash_pad_circle(wxPoint pos, int diametre,
return; 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 ) * Plot rectangular pad vertical or horizontal.
* donne par son centre et ses dimensions X et Y * Gives its center and its dimensions X and Y
* Units are user units * 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; wxSize size;
int delta; int delta;
int ox, oy, fx, fy; 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 ) if( trace_mode != FILAIRE )
{ {
size.x = (padsize.x - (int) pen_diameter) / 2; size.x = (padsize.x - (int) pen_diameter) / 2;
size.y = (padsize.y - (int) pen_diameter) / 2; size.y = (padsize.y - (int) pen_diameter) / 2;
} }
if( size.x < 0 ) if( size.x < 0 )
size.x = 0; size.x = 0;
if( size.y < 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 ) if( size.x == 0 )
{ {
ox = pos.x; oy = pos.y - size.y; ox = pos.x;
RotatePoint( &ox, &oy, pos.x, pos.y, orient ); oy = pos.y - size.y;
fx = pos.x; fy = pos.y + size.y; RotatePoint( &ox, &oy, pos.x, pos.y, orient );
RotatePoint( &fx, &fy, pos.x, pos.y, orient ); fx = pos.x;
move_to( wxPoint( ox, oy ) ); fy = pos.y + size.y;
finish_to( wxPoint( fx, fy ) ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
return; move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) );
return;
} }
if( size.y == 0 ) if( size.y == 0 )
{ {
ox = pos.x - size.x; oy = pos.y; ox = pos.x - size.x;
RotatePoint( &ox, &oy, pos.x, pos.y, orient ); oy = pos.y;
fx = pos.x + size.x; fy = pos.y; RotatePoint( &ox, &oy, pos.x, pos.y, orient );
RotatePoint( &fx, &fy, pos.x, pos.y, orient ); fx = pos.x + size.x;
move_to( wxPoint( ox, oy ) ); fy = pos.y;
finish_to( wxPoint( fx, fy ) ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) );
finish_to( wxPoint( fx, fy ) );
return; 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 ); RotatePoint( &ox, &oy, pos.x, pos.y, orient );
move_to( wxPoint( ox, oy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); 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 ); RotatePoint( &fx, &fy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); line_to( wxPoint( fx, fy ) );
...@@ -378,82 +396,121 @@ void HPGL_PLOTTER::flash_pad_rect(wxPoint pos, wxSize padsize, ...@@ -378,82 +396,121 @@ void HPGL_PLOTTER::flash_pad_rect(wxPoint pos, wxSize padsize,
if( trace_mode == FILLED ) if( trace_mode == FILLED )
{ {
/* Trace en mode Remplissage */ /* Plot in filled mode. */
delta = (int) (pen_diameter - pen_overlap); delta = (int) (pen_diameter - pen_overlap);
if( delta > 0 )
while( (size.x > 0) && (size.y > 0) ) if( delta > 0 )
{ while( (size.x > 0) && (size.y > 0) )
size.x -= delta; size.y -= delta; {
if( size.x < 0 ) size.x -= delta;
size.x = 0; size.y -= delta;
if( size.y < 0 )
size.y = 0; if( size.x < 0 )
size.x = 0;
ox = pos.x - size.x; oy = pos.y - size.y; if( size.y < 0 )
RotatePoint( &ox, &oy, pos.x, pos.y, orient ); size.y = 0;
move_to( wxPoint( ox, oy ) );
ox = pos.x - size.x;
fx = pos.x - size.x; fy = pos.y + size.y; oy = pos.y - size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient ); RotatePoint( &ox, &oy, pos.x, pos.y, orient );
line_to( wxPoint( fx, fy ) ); move_to( wxPoint( ox, oy ) );
fx = pos.x + size.x; fy = pos.y + size.y; fx = pos.x - size.x;
RotatePoint( &fx, &fy, pos.x, pos.y, orient ); fy = pos.y + size.y;
line_to( wxPoint( fx, fy ) ); 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 ); fx = pos.x + size.x;
line_to( wxPoint( fx, fy ) ); fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
finish_to( wxPoint( ox, oy ) ); 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, /* Plot trapezoidal pad.
int orient, GRTraceMode trace_mode ) * Pos is pad center
/*******************************************************************/ * Dimensions size.x and size.y
/* * Changes delta.x and delta.y (1 of at least two must be zero)
* Trace 1 pad trapezoidal donne par : * Orientation east to 0.1 degrees
* son centre pos.x,pos.y * Plot mode (FILLED, SKETCH, WIRED)
* ses dimensions dimX et dimY *
* les variations deltaX et deltaY * The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
* son orientation orient et 0.1 degres *
* le mode de trace (FILLED, SKETCH, FILAIRE) * The rating of the vertexes are (vis a vis the plotter)
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY
* = 0.
* *
* les notation des sommets sont ( vis a vis de la table tracante ) * " 0 ------------- 3 "
* 0 ------------- 3 * " . . "
* . . * " . O . "
* . . * " . . "
* . . * " 1 ---- 2 "
* 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); wxASSERT( output_file );
wxPoint polygone[4]; /* coord des sommets / centre du pad */ wxPoint polygone[4];
wxPoint coord[4]; /* coord reelles des sommets du trapeze a tracer */ wxPoint coord[4];
int moveX, moveY; /* variation de position plume selon axe X et Y , lors int moveX, moveY;
* 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;
/* Trace du contour */ moveX = moveY = wxRound( pen_diameter );
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++ ) 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].x = polygone[ii].x + pos.x;
coord[ii].y = polygone[ii].y + pos.y; coord[ii].y = polygone[ii].y + pos.y;
...@@ -469,63 +526,69 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta, ...@@ -469,63 +526,69 @@ void HPGL_PLOTTER::flash_pad_trapez( wxPoint pos, wxSize size, wxSize delta,
if( trace_mode == FILLED ) if( trace_mode == FILLED )
{ {
int jj; int jj;
/* Fill the shape */ /* Fill the shape */
moveX = moveY = wxRound( pen_diameter - pen_overlap ); moveX = moveY = wxRound( pen_diameter - pen_overlap );
/* calcul de jj = hauteur du remplissage */ /* Calculate fill height. */
if( delta.y ) /* Trapeze horizontal */
{ if( delta.y ) /* Horizontal */
jj = size.y - (int) ( pen_diameter + (2 * pen_overlap) ); {
} jj = size.y - (int) ( pen_diameter + ( 2 * pen_overlap ) );
else }
{ else
jj = size.x - (int) ( pen_diameter + (2 * pen_overlap) ); {
} 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); /* Calculation of dd = number of segments was traced to fill. */
jj = jj / (int) ( pen_diameter - pen_overlap );
/* Trace du contour */
for( ; jj > 0; jj-- ) /* Trace the outline. */
{ for( ; jj > 0; jj-- )
polygone[0].x += moveX; polygone[0].y -= moveY; {
polygone[1].x += moveX; polygone[1].y += moveY; polygone[0].x += moveX;
polygone[2].x -= moveX; polygone[2].y += moveY; polygone[0].y -= moveY;
polygone[3].x -= moveX; polygone[3].y -= moveY; polygone[1].x += moveX;
polygone[1].y += moveY;
/* Test de limitation de variation des dimensions : polygone[2].x -= moveX;
* si les sommets se "croisent", il ne faut plus modifier les polygone[2].y += moveY;
* coordonnees correspondantes */ polygone[3].x -= moveX;
if( polygone[0].x > polygone[3].x ) polygone[3].y -= moveY;
{ /* croisement sur axe X des 2 sommets 0 et 3 */
polygone[0].x = polygone[3].x = 0; /* Test for crossed vertexes. */
} if( polygone[0].x > polygone[3].x ) /* X axis intersection on
if( polygone[1].x > polygone[2].x ) *vertexes 0 and 3 */
{ /* croisement sur axe X des 2 sommets 1 et 2 */ {
polygone[1].x = polygone[2].x = 0; polygone[0].x = polygone[3].x = 0;
} }
if( polygone[1].y > polygone[0].y ) if( polygone[1].x > polygone[2].x ) /* X axis intersection on
{ /* croisement sur axe Y des 2 sommets 0 et 1 */ *vertexes 1 and 2 */
polygone[0].y = polygone[1].y = 0; {
} polygone[1].x = polygone[2].x = 0;
if( polygone[2].y > polygone[3].y ) }
{ /* croisement sur axe Y des 2 sommets 2 et 3 */ if( polygone[1].y > polygone[0].y ) /* Y axis intersection on
polygone[2].y = polygone[3].y = 0; *vertexes 0 and 1 */
} {
polygone[0].y = polygone[1].y = 0;
for(int ii = 0; ii < 4; ii++ ) }
{ if( polygone[2].y > polygone[3].y ) /* Y axis intersection on
coord[ii].x = polygone[ii].x + pos.x; *vertexes 2 and 3 */
coord[ii].y = polygone[ii].y + pos.y; {
RotatePoint( &coord[ii], pos, orient ); polygone[2].y = polygone[3].y = 0;
} }
move_to( coord[0] ); for( int ii = 0; ii < 4; ii++ )
line_to( coord[1] ); {
line_to( coord[2] ); coord[ii].x = polygone[ii].x + pos.x;
line_to( coord[3] ); coord[ii].y = polygone[ii].y + pos.y;
finish_to( coord[0] ); 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] );
}
} }
} }
...@@ -11,40 +11,33 @@ ...@@ -11,40 +11,33 @@
#include "macros.h" #include "macros.h"
#include "kicad_string.h" #include "kicad_string.h"
/*************************************************************************************/
void PS_PLOTTER::set_viewport( wxPoint offset,
double aScale, int orient )
/*************************************************************************************/
/* Set the plot offset for the current plotting */ /* 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_orient_options = orient;
plot_offset = offset; plot_offset = offset;
plot_scale = aScale; plot_scale = aScale;
device_scale = 1; /* PS references in decimils */ device_scale = 1; /* PS references in decimals */
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 */
} }
/*************************************************************************************/
void PS_PLOTTER::set_default_line_width( int width )
/*************************************************************************************/
/* Set the default line width (in 1/1000 inch) for the current plotting /* 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; current_pen_width = -1;
} }
/***************************************/
void PS_PLOTTER::set_current_line_width( int width )
/***************************************/
/* Set the Current line width (in 1/1000 inch) for the next plot /* Set the current 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; int pen_width;
if( width >= 0 ) if( width >= 0 )
...@@ -54,145 +47,138 @@ void PS_PLOTTER::set_current_line_width( int width ) ...@@ -54,145 +47,138 @@ void PS_PLOTTER::set_current_line_width( int width )
if( pen_width != current_pen_width ) if( pen_width != current_pen_width )
fprintf( output_file, "%g setlinewidth\n", fprintf( output_file, "%g setlinewidth\n",
user_to_device_size(pen_width)); user_to_device_size( pen_width ) );
current_pen_width = pen_width; current_pen_width = pen_width;
} }
/******************************/
void PS_PLOTTER::set_color( int color )
/******************************/
/* Print the postscript set color command: /* Print the postscript set color command:
* r g b setrgbcolor, * r g b setrgbcolor,
* r, g, b = color values (= 0 .. 1.0 ) * r, g, b = color values (= 0 .. 1.0 )
* *
* color = color index in ColorRefs[] * color = color index in ColorRefs[]
*/ */
void PS_PLOTTER::set_color( int color )
{ {
wxASSERT(output_file); wxASSERT( output_file );
/* Return at invalid color index */ /* Return at invalid color index */
if(color < 0) if( color < 0 )
return; return;
if(color_mode) if( color_mode )
{ {
if (negative_mode) if( negative_mode )
{ {
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n", fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) 1.0-ColorRefs[color].m_Red / 255, (double) 1.0 - ColorRefs[color].m_Red / 255,
(double) 1.0-ColorRefs[color].m_Green / 255, (double) 1.0 - ColorRefs[color].m_Green / 255,
(double) 1.0-ColorRefs[color].m_Blue / 255 ); (double) 1.0 - ColorRefs[color].m_Blue / 255 );
} else }
{ else
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n", {
(double) ColorRefs[color].m_Red / 255, fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) ColorRefs[color].m_Green / 255, (double) ColorRefs[color].m_Red / 255,
(double) ColorRefs[color].m_Blue / 255 ); (double) ColorRefs[color].m_Green / 255,
} (double) ColorRefs[color].m_Blue / 255 );
}
} }
else 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 ) if( color != WHITE )
bwcolor = BLACK; bwcolor = BLACK;
if (negative_mode) if( negative_mode )
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n", fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) 1.0-ColorRefs[bwcolor].m_Red / 255, (double) 1.0 - ColorRefs[bwcolor].m_Red / 255,
(double) 1.0-ColorRefs[bwcolor].m_Green / 255, (double) 1.0 - ColorRefs[bwcolor].m_Green / 255,
(double) 1.0-ColorRefs[bwcolor].m_Blue / 255 ); (double) 1.0 - ColorRefs[bwcolor].m_Blue / 255 );
else else
fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n", fprintf( output_file, "%.3g %.3g %.3g setrgbcolor\n",
(double) ColorRefs[bwcolor].m_Red / 255, (double) ColorRefs[bwcolor].m_Red / 255,
(double) ColorRefs[bwcolor].m_Green / 255, (double) ColorRefs[bwcolor].m_Green / 255,
(double) ColorRefs[bwcolor].m_Blue / 255 ); (double) ColorRefs[bwcolor].m_Blue / 255 );
} }
} }
void PS_PLOTTER::set_dash( bool dashed ) void PS_PLOTTER::set_dash( bool dashed )
{ {
wxASSERT(output_file); wxASSERT( output_file );
if (dashed) if( dashed )
fputs("dashedline\n", stderr); fputs( "dashedline\n", stderr );
else else
fputs("solidline\n", stderr); fputs( "solidline\n", stderr );
} }
/***************************************************************/
void PS_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width ) void PS_PLOTTER::rect( wxPoint p1, wxPoint p2, FILL_T fill, int width )
/***************************************************************/
{ {
user_to_device_coordinates( p1 ); user_to_device_coordinates( p1 );
user_to_device_coordinates( p2 ); user_to_device_coordinates( p2 );
set_current_line_width( width ); set_current_line_width( width );
fprintf( output_file, "%d %d %d %d rect%d\n", p1.x, p1.y, 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 ) void PS_PLOTTER::circle( wxPoint pos, int diametre, FILL_T fill, int width )
/******************************************************/
{ {
wxASSERT(output_file); wxASSERT( output_file );
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
double rayon = user_to_device_size(diametre / 2.0); double radius = user_to_device_size( diametre / 2.0 );
if( rayon < 1 ) if( radius < 1 )
rayon = 1; radius = 1;
set_current_line_width( width ); 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: /* Plot an arc:
* StAngle, EndAngle = start and end arc in 0.1 degree * 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); wxASSERT( output_file );
if( rayon <= 0 ) if( radius <= 0 )
return; return;
set_current_line_width( width ); set_current_line_width( width );
// Calcul des coord du point de depart : // Calculate start point.
user_to_device_coordinates( centre ); user_to_device_coordinates( centre );
rayon = wxRound( user_to_device_size(rayon) ); radius = wxRound( user_to_device_size( radius ) );
if( plot_orient_options == PLOT_MIROIR ) if( plot_orient_options == PLOT_MIROIR )
fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y, fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
rayon, (double) -EndAngle / 10, (double) -StAngle / 10, radius, (double) -EndAngle / 10, (double) -StAngle / 10,
fill); fill );
else else
fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y, fprintf( output_file, "%d %d %d %g %g arc%d\n", centre.x, centre.y,
rayon, (double) StAngle / 10, (double) EndAngle / 10, radius, (double) StAngle / 10, (double) EndAngle / 10,
fill); fill );
} }
/*****************************************************************/
void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width )
/*****************************************************************/
/** Function poly /** Function poly
* @brief Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format * @brief Draw a polygon ( a filled polygon if fill == 1 ) in POSTSCRIPT format
* @param nb_segm = corner count * @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 fill :if true : filled polygon
* @param width = line width * @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; wxPoint pos;
if( nb_segm <= 1 ) if( nb_segm <= 1 )
...@@ -205,7 +191,7 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width ) ...@@ -205,7 +191,7 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width )
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
fprintf( output_file, "newpath\n%d %d moveto\n", pos.x, pos.y ); 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.x = coord[2 * ii];
pos.y = coord[2 * ii + 1]; pos.y = coord[2 * ii + 1];
...@@ -214,43 +200,43 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width ) ...@@ -214,43 +200,43 @@ void PS_PLOTTER::poly( int nb_segm, int* coord, FILL_T fill, int width )
} }
// Close path // 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 /* Routine to draw to a new position
*/ */
void PS_PLOTTER::pen_to( wxPoint pos, char plume )
{ {
wxASSERT(output_file); wxASSERT( output_file );
if( plume == 'Z' ) { if( plume == 'Z' )
if (pen_state != 'Z') { {
fputs( "stroke\n", output_file ); if( pen_state != 'Z' )
pen_state = 'Z'; {
pen_lastpos.x = -1; fputs( "stroke\n", output_file );
pen_lastpos.y = -1; pen_state = 'Z';
} pen_lastpos.x = -1;
pen_lastpos.y = -1;
}
return; return;
} }
user_to_device_coordinates( pos ); user_to_device_coordinates( pos );
if (pen_state == 'Z') { if( pen_state == 'Z' )
fputs( "newpath\n", output_file ); {
fputs( "newpath\n", output_file );
} }
if (pen_state != plume || pos != pen_lastpos) if( pen_state != plume || pos != pen_lastpos )
fprintf( output_file, "%d %d %sto\n", pos.x, pos.y, (plume=='D')?"line":"move" ); fprintf( output_file,
pen_state = plume; "%d %d %sto\n",
pos.x,
pos.y,
( plume=='D' ) ? "line" : "move" );
pen_state = plume;
pen_lastpos = pos; pen_lastpos = pos;
} }
/***********************************************************/
void PS_PLOTTER::start_plot( FILE *fout)
/***********************************************************/
/* The code within this function (and the CloseFilePS function) /* The code within this function (and the CloseFilePS function)
* creates postscript files whose contents comply with Adobe's * creates postscript files whose contents comply with Adobe's
* Document Structuring Convention, as documented by assorted * Document Structuring Convention, as documented by assorted
...@@ -263,12 +249,14 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -263,12 +249,14 @@ void PS_PLOTTER::start_plot( FILE *fout)
* BBox is the boundary box (position and size of the "client rectangle" * BBox is the boundary box (position and size of the "client rectangle"
* for drawings (page - margins) in mils (0.001 inch) * for drawings (page - margins) in mils (0.001 inch)
*/ */
void PS_PLOTTER::start_plot( FILE* fout )
{ {
wxASSERT(!output_file); wxASSERT( !output_file );
wxString msg; wxString msg;
output_file = fout; output_file = fout;
static const char* PSMacro[] = { static const char* PSMacro[] =
{
"/line {\n", "/line {\n",
" newpath\n", " newpath\n",
" moveto\n", " moveto\n",
...@@ -279,26 +267,28 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -279,26 +267,28 @@ void PS_PLOTTER::start_plot( FILE *fout)
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n", "/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { 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", "/arc0 { newpath arc stroke } bind def\n",
"/arc1 { 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 ",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill grestore stroke } bind def\n", "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", "/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n", "/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n", "/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n", "/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n", "/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n", "/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n", "/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n", "/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [50 50] 0 setdash } bind def\n", "/dashedline { [50 50] 0 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n", "/solidline { [] 0 setdash } bind def\n",
"gsave\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", "linemode1\n",
NULL NULL
}; };
const double DECIMIL_TO_INCH = 0.0001; const double DECIMIL_TO_INCH = 0.0001;
time_t time1970 = time( NULL ); time_t time1970 = time( NULL );
fputs( "%!PS-Adobe-3.0\n", output_file ); // Print header fputs( "%!PS-Adobe-3.0\n", output_file ); // Print header
...@@ -308,18 +298,18 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -308,18 +298,18 @@ void PS_PLOTTER::start_plot( FILE *fout)
// because it is provided by the ctime() function. // because it is provided by the ctime() function.
fprintf( output_file, "%%%%CreationDate: %s", ctime( &time1970 ) ); fprintf( output_file, "%%%%CreationDate: %s", ctime( &time1970 ) );
fprintf( output_file, "%%%%Title: %s\n", CONV_TO_UTF8( filename ) ); 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" ); fprintf( output_file, "%%%%PageOrder: Ascend\n" );
// Print boundary box en 1/72 pouce, box is in decimils // Print boundary box in 1/72 pixels per inch, box is in decimals
const double CONV_SCALE = DECIMIL_TO_INCH * 72; const double CONV_SCALE = DECIMIL_TO_INCH * 72;
// The coordinates of the lower left corner of the boundary // The coordinates of the lower left corner of the boundary
// box need to be "rounded down", but the coordinates of its // box need to be "rounded down", but the coordinates of its
// upper right corner need to be "rounded up" instead. // upper right corner need to be "rounded up" instead.
fprintf( output_file, "%%%%BoundingBox: 0 0 %d %d\n", fprintf( output_file, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceil( paper_size.y * CONV_SCALE), (int) ceil( paper_size.y * CONV_SCALE ),
(int) ceil( paper_size.x * CONV_SCALE)); (int) ceil( paper_size.x * CONV_SCALE ) );
// Specify the size of the sheet and the name associated with that size. // 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, // (If the "User size" option has been selected for the sheet size,
...@@ -327,14 +317,14 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -327,14 +317,14 @@ void PS_PLOTTER::start_plot( FILE *fout)
// otherwise use the name assigned by KiCad for each sheet size.) // otherwise use the name assigned by KiCad for each sheet size.)
// //
// (The Document Structuring Convention also supports sheet weight, // (The Document Structuring Convention also supports sheet weight,
// sheet colour, 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; // %%DocumentMedia comment, but they are not being specified here;
// a zero and two null strings are subsequently provided instead.) // a zero and two null strings are subsequently provided instead.)
// //
// (NOTE: m_Size.y is *supposed* to be listed before m_Size.x; // (NOTE: m_Size.y is *supposed* to be listed before m_Size.x;
// the order in which they are specified is not wrong!) // the order in which they are specified is not wrong!)
// Also note sheet->m_Size is given in mils, not in decimils and must be // Also note sheet->m_Size is given in mils, not in decimals and must be
// sheet->m_Size * 10 in decimils // sheet->m_Size * 10 in decimals
if( sheet->m_Name.Cmp( wxT( "User" ) ) == 0 ) if( sheet->m_Name.Cmp( wxT( "User" ) ) == 0 )
fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n",
wxRound( sheet->m_Size.y * CONV_SCALE ), wxRound( sheet->m_Size.y * CONV_SCALE ),
...@@ -358,7 +348,7 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -358,7 +348,7 @@ void PS_PLOTTER::start_plot( FILE *fout)
// within the Document Structuring Convention. // within the Document Structuring Convention.
fprintf( output_file, "%%%%Page: 1 1\n" ); 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 ); fputs( PSMacro[ii], output_file );
} }
...@@ -366,43 +356,41 @@ void PS_PLOTTER::start_plot( FILE *fout) ...@@ -366,43 +356,41 @@ void PS_PLOTTER::start_plot( FILE *fout)
// (If support for creating postscript files with a portrait orientation // (If support for creating postscript files with a portrait orientation
// is ever provided, determine whether it would be necessary to provide // is ever provided, determine whether it would be necessary to provide
// an "else" command and then an appropriate "sprintf" command here.) // 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 // Apply the scale adjustments
if (plot_scale_adjX != 1.0 || plot_scale_adjY != 1.0) if( plot_scale_adjX != 1.0 || plot_scale_adjY != 1.0 )
fprintf( output_file, "%g %g scale\n", fprintf( output_file, "%g %g scale\n",
plot_scale_adjX, plot_scale_adjY); plot_scale_adjX, plot_scale_adjY );
// Set default line width ( g_Plot_DefaultPenWidth is in user units ) // Set default line width ( g_Plot_DefaultPenWidth is in user units )
fprintf( output_file, "%g setlinewidth\n", 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() void PS_PLOTTER::end_plot()
/******************************************/
{ {
wxASSERT(output_file); wxASSERT( output_file );
fputs( "showpage\ngrestore\n%%EOF\n", output_file ); fputs( "showpage\ngrestore\n%%EOF\n", output_file );
fclose( output_file ); fclose( output_file );
output_file = 0; 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: /* Plot oval pad:
* dimensions dx,dy, * pos - Position of pad.
* orientation orient * Dimensions dx, dy,
* La forme est tracee comme un segment * 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; 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 ) if( size.x > size.y )
{ {
EXCHG( 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, ...@@ -411,7 +399,7 @@ void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
orient -= 3600; orient -= 3600;
} }
delta = size.y - size.x ; delta = size.y - size.x;
x0 = 0; x0 = 0;
y0 = -delta / 2; y0 = -delta / 2;
x1 = 0; x1 = 0;
...@@ -421,89 +409,81 @@ void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient, ...@@ -421,89 +409,81 @@ void PS_PLOTTER::flash_pad_oval( wxPoint pos, wxSize size, int orient,
if( modetrace == FILLED ) if( modetrace == FILLED )
thick_segment( wxPoint( pos.x + x0, pos.y + y0 ), 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 else
sketch_oval(pos, size, orient, -1); sketch_oval( pos, size, orient, -1 );
} }
/*******************************************************************************/
void PS_PLOTTER::flash_pad_circle(wxPoint pos, int diametre, /* Plot round pad or via.
GRTraceMode modetrace)
/*******************************************************************************/
/* Trace 1 pastille RONDE (via,pad rond) en position pos_X,Y
*/ */
void PS_PLOTTER::flash_pad_circle( wxPoint pos, int diametre,
GRTraceMode modetrace )
{ {
wxASSERT(output_file); wxASSERT( output_file );
if( modetrace == FILLED ) if( modetrace == FILLED )
{ {
set_current_line_width( 0 ); set_current_line_width( 0 );
circle(pos, diametre, FILLED_SHAPE); circle( pos, diametre, FILLED_SHAPE );
} }
else else
{ {
set_current_line_width(-1); set_current_line_width( -1 );
int w = current_pen_width; int w = current_pen_width;
circle(pos, diametre-2*w, NO_FILL); circle( pos, diametre - 2 * w, NO_FILL );
} }
} }
/**************************************************************************/
void PS_PLOTTER::flash_pad_rect(wxPoint pos, wxSize size, /* Plot rectangular pad in any orientation.
int orient, GRTraceMode trace_mode)
/**************************************************************************/
/*
* Trace 1 pad rectangulaire d'orientation quelconque
* donne par son centre, ses dimensions,
* et son orientation orient
*/ */
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; int w = current_pen_width;
size.x -= w; size.x -= w;
if( size.x < 1 ) if( size.x < 1 )
size.x = 1; size.x = 1;
size.y -= w; size.y -= w;
if( size.y < 1 ) if( size.y < 1 )
size.y = 1; size.y = 1;
int dx = size.x / 2; int dx = size.x / 2;
int dy = size.y / 2; int dy = size.y / 2;
int coord[10] = { 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, pos.x - dx, pos.y - dy,
pos.x + dx, pos.y + dy, pos.x + dx, pos.y - dy,
0, 0 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[8] = coord[0];
coord[9] = coord[1]; 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, /* Plot trapezoidal pad.
int orient, GRTraceMode modetrace ) * Pos is pad center
/*******************************************************************/ * Dimensions size.x and size.y
/* * Changes delta.x and delta.y (1 of at least two must be zero)
* Trace 1 pad trapezoidal donne par : * Orientation east to 0.1 degrees
* son centre centre * Plot mode (FILLED, SKETCH, WIRED)
* 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)
* *
* Le trace n'est fait que pour un trapeze, c.a.d que deltaX ou deltaY * The evidence is that a trapezoid, ie that delta.x or delta.y = 0.
* = 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 " * " 0 ------------- 3 "
* " . . " * " . . "
...@@ -512,7 +492,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta, ...@@ -512,7 +492,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " 1 ---- 2 " * " 1 ---- 2 "
* *
* *
* exemple de Disposition pour deltaY > 0, deltaX = 0 * Example delta.y > 0, delta.x = 0
* " 1 ---- 2 " * " 1 ---- 2 "
* " . . " * " . . "
* " . O . " * " . O . "
...@@ -520,7 +500,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta, ...@@ -520,7 +500,7 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " 0 ------------- 3 " * " 0 ------------- 3 "
* *
* *
* exemple de Disposition pour deltaY = 0, deltaX > 0 * Example delta.y = 0, delta.x > 0
* " 0 " * " 0 "
* " . . " * " . . "
* " . . " * " . . "
...@@ -533,33 +513,37 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta, ...@@ -533,33 +513,37 @@ void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
* " . . " * " . . "
* " 1 " * " 1 "
*/ */
void PS_PLOTTER::flash_pad_trapez( wxPoint centre, wxSize size, wxSize delta,
int orient, GRTraceMode modetrace )
{ {
wxASSERT(output_file); wxASSERT( output_file );
set_current_line_width(-1); set_current_line_width( -1 );
int w = current_pen_width; int w = current_pen_width;
int dx, dy; int dx, dy;
int ddx, ddy; int ddx, ddy;
dx = (size.x-w) / 2; dx = ( size.x - w ) / 2;
dy = (size.y-w) / 2; dy = ( size.y - w ) / 2;
ddx = delta.x / 2; ddx = delta.x / 2;
ddy = delta.y / 2; ddy = delta.y / 2;
int coord[10] = { int coord[10] =
-dx - ddy, +dy + ddx, {
-dx + ddy, -dy - ddx, -dx - ddy, +dy + ddx,
+dx - ddy, -dy + ddx, -dx + ddy, -dy - ddx,
+dx + ddy, +dy - ddx, +dx - ddy, -dy + ddx,
0, 0 +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 ); RotatePoint( &coord[ii * 2], &coord[ii * 2 + 1], orient );
coord[ii*2] += centre.x; coord[ii * 2] += centre.x;
coord[ii*2+1] += centre.y; coord[ii * 2 + 1] += centre.y;
} }
coord[8] = coord[0]; coord[8] = coord[0];
coord[9] = coord[1]; coord[9] = coord[1];
poly(5, coord, modetrace==FILLED?FILLED_SHAPE:NO_FILL); poly( 5, coord, ( modetrace == FILLED ) ? FILLED_SHAPE : NO_FILL );
} }
...@@ -14,13 +14,11 @@ ...@@ -14,13 +14,11 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "drawtxt.h" #include "drawtxt.h"
/**************************************************************************/
void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
/**************************************************************************/
/* Plot sheet references /* Plot sheet references
* margin is in mils (1/1000 inch) * margin is in mils (1/1000 inch)
*/ */
void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
{ {
#define WSTEXTSIZE 50 // Text size in mils #define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc; Ki_PageDescr* Sheet = screen->m_CurrentSheetDesc;
...@@ -28,14 +26,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -28,14 +26,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
wxSize PageSize; wxSize PageSize;
wxPoint pos, ref; wxPoint pos, ref;
EDA_Colors color; 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 */ /* Scale to convert dimension in 1/1000 in into internal units
wxString msg; * (1/1000 inc for EESchema, 1/10000 for pcbnew. */
wxSize text_size; int conv_unit = screen->GetInternalUnits() / 1000;
int UpperLimit = VARIABLE_BLOCK_START_POSITION; wxString msg;
bool italic = false; wxSize text_size;
bool bold = false; int UpperLimit = VARIABLE_BLOCK_START_POSITION;
bool thickness = 0; //@todo : use current pen bool italic = false;
bool bold = false;
bool thickness = 0; //@todo : use current pen
color = BLACK; color = BLACK;
plotter->set_color( color ); plotter->set_color( color );
...@@ -43,30 +43,36 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -43,30 +43,36 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
PageSize.x = Sheet->m_Size.x; PageSize.x = Sheet->m_Size.x;
PageSize.y = Sheet->m_Size.y; PageSize.y = Sheet->m_Size.y;
/* trace de la bordure */ /* Plot edge. */
ref.x = Sheet->m_LeftMargin * conv_unit; ref.x = Sheet->m_LeftMargin * conv_unit;
ref.y = Sheet->m_TopMargin * conv_unit; /* Upper left corner */ ref.y = Sheet->m_TopMargin * conv_unit;
xg = (PageSize.x - Sheet->m_RightMargin) * conv_unit; xg = ( PageSize.x - Sheet->m_RightMargin ) * conv_unit;
yg = (PageSize.y - Sheet->m_BottomMargin) * conv_unit; /* lower right corner */ yg = ( PageSize.y - Sheet->m_BottomMargin ) * conv_unit;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
plotter->move_to( ref ); plotter->move_to( ref );
pos.x = xg; pos.y = ref.y; pos.x = xg;
pos.y = ref.y;
plotter->line_to( pos ); plotter->line_to( pos );
pos.x = xg; pos.y = yg; pos.x = xg;
pos.y = yg;
plotter->line_to( pos ); plotter->line_to( pos );
pos.x = ref.x; pos.y = yg; pos.x = ref.x;
pos.y = yg;
plotter->line_to( pos ); plotter->line_to( pos );
plotter->finish_to( ref ); plotter->finish_to( ref );
#else #else
for( unsigned ii = 0; ii < 2; ii++ ) for( unsigned ii = 0; ii < 2; ii++ )
{ {
plotter->move_to( ref ); plotter->move_to( ref );
pos.x = xg; pos.y = ref.y; pos.x = xg;
pos.y = ref.y;
plotter->line_to( pos ); plotter->line_to( pos );
pos.x = xg; pos.y = yg; pos.x = xg;
pos.y = yg;
plotter->line_to( pos ); plotter->line_to( pos );
pos.x = ref.x; pos.y = yg; pos.x = ref.x;
pos.y = yg;
plotter->line_to( pos ); plotter->line_to( pos );
plotter->finish_to( ref ); plotter->finish_to( ref );
ref.x += GRID_REF_W * conv_unit; ref.x += GRID_REF_W * conv_unit;
...@@ -77,22 +83,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -77,22 +83,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif #endif
/* trace des reperes */
text_size.x = WSTEXTSIZE * conv_unit; text_size.x = WSTEXTSIZE * conv_unit;
text_size.y = WSTEXTSIZE * conv_unit; text_size.y = WSTEXTSIZE * conv_unit;
ref.x = Sheet->m_LeftMargin; ref.x = Sheet->m_LeftMargin;
ref.y = Sheet->m_TopMargin; /* Upper left corner in 1/1000 inch */ ref.y = Sheet->m_TopMargin; /* Upper left corner in
xg = (PageSize.x - Sheet->m_RightMargin); * 1/1000 inch */
yg = (PageSize.y - Sheet->m_BottomMargin); /* lower right 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) #if defined(KICAD_GOST)
for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU; for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU;
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = (ref.x - WsItem->m_Posx) * conv_unit; pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
pos.y = (yg - WsItem->m_Posy) * conv_unit; pos.y = ( yg - WsItem->m_Posy ) * conv_unit;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
...@@ -110,8 +117,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -110,8 +117,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case WS_SEGMENT_LU: case WS_SEGMENT_LU:
plotter->move_to( pos ); plotter->move_to( pos );
pos.x = (ref.x - WsItem->m_Endx) * conv_unit; pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
pos.y = (yg - WsItem->m_Endy) * conv_unit; pos.y = ( yg - WsItem->m_Endy ) * conv_unit;
plotter->finish_to( pos ); plotter->finish_to( pos );
break; break;
} }
...@@ -121,15 +128,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -121,15 +128,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = (ref.x + WsItem->m_Posx) * conv_unit; pos.x = ( ref.x + WsItem->m_Posx ) * conv_unit;
pos.y = (ref.y + WsItem->m_Posy) * conv_unit; pos.y = ( ref.y + WsItem->m_Posy ) * conv_unit;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_SEGMENT_LT: case WS_SEGMENT_LT:
plotter->move_to( pos ); plotter->move_to( pos );
pos.x = (ref.x + WsItem->m_Endx) * conv_unit; pos.x = ( ref.x + WsItem->m_Endx ) * conv_unit;
pos.y = (ref.y + WsItem->m_Endy) * conv_unit; pos.y = ( ref.y + WsItem->m_Endy ) * conv_unit;
plotter->finish_to( pos ); plotter->finish_to( pos );
break; break;
} }
...@@ -137,21 +144,26 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -137,21 +144,26 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#else #else
/* Trace des reperes selon l'axe X */ /* Plot legend along the X axis. */
ipas = (xg - ref.x) / PAS_REF; ipas = ( xg - ref.x ) / PAS_REF;
gxpas = ( xg - ref.x) / ipas; gxpas = ( xg - ref.x ) / ipas;
for( int ii = ref.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, 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 ) 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 ); 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 ); 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, plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
...@@ -159,37 +171,41 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -159,37 +171,41 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
if( ii < xg - PAS_REF / 2 ) 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 ); 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 ); plotter->finish_to( pos );
} }
pos.x = (ii - gxpas / 2) * conv_unit; pos.x = ( ii - gxpas / 2 ) * conv_unit;
pos.y = (yg - GRID_REF_W / 2) * conv_unit; pos.y = ( yg - GRID_REF_W / 2 ) * conv_unit;
plotter->text( pos, color, plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); thickness, italic, false );
} }
/* Trace des reperes selon l'axe Y */ /* Plot legend along the Y axis. */
ipas = (yg - ref.y) / PAS_REF; ipas = ( yg - ref.y ) / PAS_REF;
gypas = ( yg - ref.y) / ipas; gypas = ( yg - ref.y ) / ipas;
for( int ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) for( int ii = ref.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{ {
if( jj < 26 ) if( jj < 26 )
msg.Printf( wxT( "%c" ), jj + 'A' ); msg.Printf( wxT( "%c" ), jj + 'A' );
else // I hope 52 identifiers are enought... else // I hope 52 identifiers are enough...
msg.Printf( wxT( "%c" ), 'a' + jj - 26 ); msg.Printf( wxT( "%c" ), 'a' + jj - 26 );
if( ii < yg - PAS_REF / 2 ) 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 ); 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 ); plotter->finish_to( pos );
} }
pos.x = (ref.x + GRID_REF_W / 2) * conv_unit; pos.x = ( ref.x + GRID_REF_W / 2 ) * conv_unit;
pos.y = (ii - gypas / 2) * conv_unit; pos.y = ( ii - gypas / 2 ) * conv_unit;
plotter->text( pos, color, plotter->text( pos, color,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
...@@ -197,13 +213,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -197,13 +213,16 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
if( ii < yg - PAS_REF / 2 ) 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 ); 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 ); 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, plotter->text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); thickness, italic, false );
...@@ -211,21 +230,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -211,21 +230,23 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif #endif
/* Trace du cartouche */ /* Plot the worksheet. */
text_size.x = SIZETEXT * conv_unit; text_size.x = SIZETEXT * conv_unit;
text_size.y = SIZETEXT * conv_unit; text_size.y = SIZETEXT * conv_unit;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
ref.x = PageSize.x - Sheet->m_RightMargin; ref.x = PageSize.x - Sheet->m_RightMargin;
ref.y = PageSize.y - Sheet->m_BottomMargin; ref.y = PageSize.y - Sheet->m_BottomMargin;
if( screen->m_ScreenNumber == 1 ) if( screen->m_ScreenNumber == 1 )
{ {
for( Ki_WorkSheetData* WsItem = &WS_Date; for( Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = (ref.x - WsItem->m_Posx) * conv_unit; pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_DATE: case WS_DATE:
...@@ -288,8 +309,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -288,8 +309,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case WS_LEFT_SEGMENT: case WS_LEFT_SEGMENT:
case WS_SEGMENT: case WS_SEGMENT:
plotter->move_to( pos ); plotter->move_to( pos );
pos.x = (ref.x - WsItem->m_Endx) * conv_unit; pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
pos.y = (ref.y - WsItem->m_Endy) * conv_unit; pos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;
plotter->finish_to( pos ); plotter->finish_to( pos );
break; break;
} }
...@@ -301,9 +322,10 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -301,9 +322,10 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = (ref.x - WsItem->m_Posx) * conv_unit; pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_CADRE: case WS_CADRE:
...@@ -328,8 +350,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -328,8 +350,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case WS_LEFT_SEGMENT_D: case WS_LEFT_SEGMENT_D:
case WS_SEGMENT_D: case WS_SEGMENT_D:
plotter->move_to( pos ); plotter->move_to( pos );
pos.x = (ref.x - WsItem->m_Endx) * conv_unit; pos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;
pos.y = (ref.y - WsItem->m_Endy) * conv_unit; pos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;
plotter->finish_to( pos ); plotter->finish_to( pos );
break; break;
} }
...@@ -343,8 +365,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -343,8 +365,8 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = (ref.x - WsItem->m_Posx) * conv_unit; pos.x = ( ref.x - WsItem->m_Posx ) * conv_unit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = ( ref.y - WsItem->m_Posy ) * conv_unit;
bold = false; bold = false;
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
...@@ -372,13 +394,17 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -372,13 +394,17 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
break; break;
case WS_IDENTSHEET: case WS_IDENTSHEET:
msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen; msg << screen->m_ScreenNumber << wxT( "/" ) <<
screen->m_NumberOfScreen;
break; break;
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; 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; msg << fname << wxT( "." ) << fext;
} }
break; break;
...@@ -428,16 +454,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -428,16 +454,15 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
break; break;
case WS_LEFT_SEGMENT: case WS_LEFT_SEGMENT:
WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy
WS_MostUpperLine.m_Endy = = WS_MostLeftLine.m_Posy = UpperLimit;
WS_MostLeftLine.m_Posy = UpperLimit;
pos.y = (ref.y - WsItem->m_Posy) * conv_unit; pos.y = (ref.y - WsItem->m_Posy) * conv_unit;
case WS_SEGMENT: case WS_SEGMENT:
{ {
wxPoint auxpos; wxPoint auxpos;
auxpos.x = (ref.x - WsItem->m_Endx) * conv_unit;; auxpos.x = ( ref.x - WsItem->m_Endx ) * conv_unit;;
auxpos.y = (ref.y - WsItem->m_Endy) * conv_unit;; auxpos.y = ( ref.y - WsItem->m_Endy ) * conv_unit;;
plotter->move_to( pos ); plotter->move_to( pos );
plotter->finish_to( auxpos ); plotter->finish_to( auxpos );
} }
...@@ -455,4 +480,3 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen ) ...@@ -455,4 +480,3 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
#endif #endif
} }
/*************************/ /************************/
/* Menu " CONFIRMATION " */ /* Menu "CONFIRMATION" */
/* fonction Get_Message */ /* Function get_Message */
/* test demande ESC */ /* Test requires ESC */
/*************************/ /************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -11,8 +11,17 @@ enum id_dialog { ...@@ -11,8 +11,17 @@ enum id_dialog {
ID_TIMOUT = 1500 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 class WinEDA_MessageDialog : public wxMessageDialog
{ {
...@@ -34,35 +43,35 @@ BEGIN_EVENT_TABLE( WinEDA_MessageDialog, wxMessageDialog ) ...@@ -34,35 +43,35 @@ BEGIN_EVENT_TABLE( WinEDA_MessageDialog, wxMessageDialog )
EVT_TIMER( ID_TIMOUT, WinEDA_MessageDialog::OnTimeOut ) EVT_TIMER( ID_TIMOUT, WinEDA_MessageDialog::OnTimeOut )
END_EVENT_TABLE() END_EVENT_TABLE()
/**********************************************************************************/
WinEDA_MessageDialog::WinEDA_MessageDialog( wxWindow* parent, const wxString& msg, WinEDA_MessageDialog::WinEDA_MessageDialog( wxWindow* parent,
const wxString& title, int style, int lifetime ) : const wxString& msg,
const wxString& title,
int style,
int lifetime ) :
wxMessageDialog( parent, msg, title, style ) wxMessageDialog( parent, msg, title, style )
/**********************************************************************************/
{ {
m_LifeTime = lifetime; m_LifeTime = lifetime;
m_Timer.SetOwner( this, ID_TIMOUT ); m_Timer.SetOwner( this, ID_TIMOUT );
if( m_LifeTime > 0 ) 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 ) void WinEDA_MessageDialog::OnTimeOut( wxTimerEvent& event )
/********************************************************/
{ {
m_Timer.Stop(); 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. */
} }
/*****************************************************************************/ /* Display an error or warning message.
void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) * If display time > 0 the dialog disappears after displayTime 0.1 seconds
/*****************************************************************************/ *
/* Affiche un Message d'Erreur ou d'avertissement.
* si warn > 0 le dialogue disparait apres displaytime * 0.1 secondes
*/ */
void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
{ {
wxMessageDialog* dialog; wxMessageDialog* dialog;
...@@ -79,13 +88,10 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) ...@@ -79,13 +88,10 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
} }
/**************************************************************************/ /* Display an informational message.
void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime )
/**************************************************************************/
/* Affiche un Message d'information.
*/ */
void DisplayInfoMessage( wxWindow* parent, const wxString& text,
int displaytime )
{ {
wxMessageDialog* dialog; wxMessageDialog* dialog;
...@@ -97,9 +103,7 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime ...@@ -97,9 +103,7 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime
} }
/**************************************************/
bool IsOK( wxWindow* parent, const wxString& text ) bool IsOK( wxWindow* parent, const wxString& text )
/**************************************************/
{ {
int ii; int ii;
...@@ -111,22 +115,19 @@ bool IsOK( wxWindow* parent, const wxString& text ) ...@@ -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 int Get_Message( const wxString& title, // The question
const wxString& frame_caption, // The frame caption const wxString& frame_caption, // The frame caption
wxString& buffer, // String input/return buffer wxString& buffer, // String input/return buffer
wxWindow* frame ) 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; wxString message;
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: copy_to_clipboard.cpp // Name: copy_to_clipboard.cpp
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Created: 18 aug 2006 // Created: 18 aug 2006
// Licence: License GNU // Licence: License GNU
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/metafile.h" #include "wx/metafile.h"
...@@ -24,12 +23,11 @@ static const bool Print_Sheet_Ref = TRUE; ...@@ -24,12 +23,11 @@ static const bool Print_Sheet_Ref = TRUE;
static bool DrawPage( WinEDA_DrawPanel* panel ); 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 ); DrawPage( DrawPanel );
...@@ -50,14 +48,11 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event ) ...@@ -50,14 +48,11 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )
} }
/*****************************************************************/
bool DrawPage( WinEDA_DrawPanel* panel )
/*****************************************************************/
/* copy the current page or block to the clipboard , /* copy the current page or block to the clipboard ,
* to export drawings to other applications (word processing ...) * to export drawings to other applications (word processing ...)
* Thi is not suitable for copy command within eeschema or pcbnew * This is not suitable for copy command within eeschema or pcbnew
*/ */
bool DrawPage( WinEDA_DrawPanel* panel )
{ {
bool success = TRUE; bool success = TRUE;
...@@ -65,7 +60,7 @@ bool DrawPage( WinEDA_DrawPanel* panel ) ...@@ -65,7 +60,7 @@ bool DrawPage( WinEDA_DrawPanel* panel )
int tmpzoom; int tmpzoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
wxPoint old_org; wxPoint old_org;
wxPoint DrawOffset; // Offset de trace wxPoint DrawOffset;
int ClipboardSizeX, ClipboardSizeY; int ClipboardSizeX, ClipboardSizeY;
bool DrawBlock = FALSE; bool DrawBlock = FALSE;
wxRect DrawArea; wxRect DrawArea;
...@@ -83,7 +78,7 @@ bool DrawPage( WinEDA_DrawPanel* panel ) ...@@ -83,7 +78,7 @@ bool DrawPage( WinEDA_DrawPanel* panel )
DrawArea.SetHeight( ActiveScreen->m_BlockLocate.GetHeight() ); DrawArea.SetHeight( ActiveScreen->m_BlockLocate.GetHeight() );
} }
/* modification des cadrages et reglages locaux */ /* Change frames and local settings. */
tmp_startvisu = ActiveScreen->m_StartVisu; tmp_startvisu = ActiveScreen->m_StartVisu;
tmpzoom = ActiveScreen->GetZoom(); tmpzoom = ActiveScreen->GetZoom();
old_org = ActiveScreen->m_DrawOrg; old_org = ActiveScreen->m_DrawOrg;
...@@ -102,16 +97,19 @@ bool DrawPage( WinEDA_DrawPanel* panel ) ...@@ -102,16 +97,19 @@ bool DrawPage( WinEDA_DrawPanel* panel )
ClipboardSizeX = dc.MaxX() + 10; ClipboardSizeX = dc.MaxX() + 10;
ClipboardSizeY = dc.MaxY() + 10; ClipboardSizeY = dc.MaxY() + 10;
panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 ); 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 ) if( DrawBlock )
{ {
dc.SetClippingRegion( DrawArea ); dc.SetClippingRegion( DrawArea );
} }
panel->PrintPage( &dc, Print_Sheet_Ref, -1, false ); panel->PrintPage( &dc, Print_Sheet_Ref, -1, false );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
panel->m_ClipBox = tmp; panel->m_ClipBox = tmp;
wxMetafile* mf = dc.Close(); wxMetafile* mf = dc.Close();
if( mf ) if( mf )
{ {
success = mf->SetClipboard( ClipboardSizeX, ClipboardSizeY ); success = mf->SetClipboard( ClipboardSizeX, ClipboardSizeY );
......
/********************************/ /****************/
/* MODULE displlst.cpp */ /* displlst.cpp */
/********************************/ /****************/
#include "fctsys.h" #include "fctsys.h"
#include "wxstruct.h" #include "wxstruct.h"
...@@ -10,14 +10,11 @@ ...@@ -10,14 +10,11 @@
#include "kicad_string.h" #include "kicad_string.h"
/***********************/
/* class WinEDAListBox */
/***********************/
enum listbox { enum listbox {
ID_LISTBOX_LIST = 8000 ID_LISTBOX_LIST = 8000
}; };
BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog ) BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog )
EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDAListBox::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDAListBox::OnCancelClick )
...@@ -29,16 +26,11 @@ BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog ) ...@@ -29,16 +26,11 @@ BEGIN_EVENT_TABLE( WinEDAListBox, wxDialog )
END_EVENT_TABLE() END_EVENT_TABLE()
/*******************************/ /* Used to display a list of elements for selection.
/* Constructeur et destructeur */ * ITEMLIST* = pointer to the list of names
/*******************************/ * = Reftext preselection
* = Movefct callback function to display comments
/* 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
*/ */
WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title, WinEDAListBox::WinEDAListBox( WinEDA_DrawFrame* parent, const wxString& title,
const wxChar** itemlist, const wxString& reftext, const wxChar** itemlist, const wxString& reftext,
void(* movefct)(wxString& Text) , void(* movefct)(wxString& Text) ,
...@@ -126,9 +118,7 @@ WinEDAListBox::~WinEDAListBox() ...@@ -126,9 +118,7 @@ WinEDAListBox::~WinEDAListBox()
} }
/******************************************/
void WinEDAListBox::MoveMouseToOrigin() void WinEDAListBox::MoveMouseToOrigin()
/******************************************/
{ {
int x, y, w, h; int x, y, w, h;
wxSize list_size = m_List->GetSize(); wxSize list_size = m_List->GetSize();
...@@ -141,9 +131,7 @@ void WinEDAListBox::MoveMouseToOrigin() ...@@ -141,9 +131,7 @@ void WinEDAListBox::MoveMouseToOrigin()
} }
/*********************************************/
wxString WinEDAListBox::GetTextSelection() wxString WinEDAListBox::GetTextSelection()
/*********************************************/
{ {
wxString text = m_List->GetStringSelection(); wxString text = m_List->GetStringSelection();
...@@ -151,33 +139,25 @@ wxString WinEDAListBox::GetTextSelection() ...@@ -151,33 +139,25 @@ wxString WinEDAListBox::GetTextSelection()
} }
/***************************************************************/
void WinEDAListBox::Append( const wxString& item ) void WinEDAListBox::Append( const wxString& item )
/***************************************************************/
{ {
m_List->Append( item ); m_List->Append( item );
} }
/******************************************************************************/
void WinEDAListBox::InsertItems( const wxArrayString& itemlist, int position ) void WinEDAListBox::InsertItems( const wxArrayString& itemlist, int position )
/******************************************************************************/
{ {
m_List->InsertItems( itemlist, position ); m_List->InsertItems( itemlist, position );
} }
/************************************************/
void WinEDAListBox::OnCancelClick( wxCommandEvent& event ) void WinEDAListBox::OnCancelClick( wxCommandEvent& event )
/************************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/*****************************************************/
void WinEDAListBox::ClickOnList( wxCommandEvent& event ) void WinEDAListBox::ClickOnList( wxCommandEvent& event )
/*****************************************************/
{ {
wxString text; wxString text;
...@@ -191,9 +171,7 @@ void WinEDAListBox::ClickOnList( wxCommandEvent& event ) ...@@ -191,9 +171,7 @@ void WinEDAListBox::ClickOnList( wxCommandEvent& event )
} }
/*******************************************************/
void WinEDAListBox::D_ClickOnList( wxCommandEvent& event ) void WinEDAListBox::D_ClickOnList( wxCommandEvent& event )
/*******************************************************/
{ {
int ii = m_List->GetSelection(); int ii = m_List->GetSelection();
...@@ -201,9 +179,7 @@ void WinEDAListBox::D_ClickOnList( wxCommandEvent& event ) ...@@ -201,9 +179,7 @@ void WinEDAListBox::D_ClickOnList( wxCommandEvent& event )
} }
/***********************************************/
void WinEDAListBox::OnOkClick( wxCommandEvent& event ) void WinEDAListBox::OnOkClick( wxCommandEvent& event )
/***********************************************/
{ {
int ii = m_List->GetSelection(); int ii = m_List->GetSelection();
...@@ -211,29 +187,21 @@ void WinEDAListBox::OnOkClick( wxCommandEvent& event ) ...@@ -211,29 +187,21 @@ void WinEDAListBox::OnOkClick( wxCommandEvent& event )
} }
/***********************************************/
void WinEDAListBox::OnClose( wxCloseEvent& event ) void WinEDAListBox::OnClose( wxCloseEvent& event )
/***********************************************/
{ {
EndModal( -1 ); EndModal( -1 );
} }
/********************************************************************/ /* Sort alphabetically, case insensitive.
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
*/ */
static int SortItems( const wxString** ptr1, const wxString** ptr2 )
{ {
return StrNumICmp( (*ptr1)->GetData(), (*ptr2)->GetData() ); return StrNumICmp( (*ptr1)->GetData(), (*ptr2)->GetData() );
} }
/************************************/
void WinEDAListBox:: SortList() void WinEDAListBox:: SortList()
/************************************/
{ {
int ii, NbItems = m_List->GetCount(); int ii, NbItems = m_List->GetCount();
const wxString** BufList; const wxString** BufList;
...@@ -261,9 +229,7 @@ void WinEDAListBox:: SortList() ...@@ -261,9 +229,7 @@ void WinEDAListBox:: SortList()
} }
/****************************************************/
void WinEDAListBox::OnKeyEvent( wxKeyEvent& event ) void WinEDAListBox::OnKeyEvent( wxKeyEvent& event )
/****************************************************/
{ {
event.Skip(); event.Skip();
} }
/******************************************************************/ /*****************/
/* drawframe.cpp - fonctions des classes du type WinEDA_DrawFrame */ /* drawframe.cpp */
/******************************************************************/ /*****************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -38,10 +38,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame ) ...@@ -38,10 +38,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
END_EVENT_TABLE() END_EVENT_TABLE()
/*******************************************************/
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/*******************************************************/
WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
...@@ -63,11 +59,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, ...@@ -63,11 +59,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_ID_current_state = 0; m_ID_current_state = 0;
m_ID_last_state = 0; m_ID_last_state = 0;
m_HTOOL_current_state = 0; m_HTOOL_current_state = 0;
m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines m_Draw_Axis = FALSE; // TRUE to draw axis.
m_Draw_Grid = FALSE; // TRUE pour avoir la axes dessinee m_Draw_Grid = FALSE; // TRUE to show grid.
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin� m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet.
m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprim� m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet.
m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxilary axis.
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
m_CursorShape = 0; m_CursorShape = 0;
m_LastGridSizeId = 0; m_LastGridSizeId = 0;
...@@ -79,11 +75,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, ...@@ -79,11 +75,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 ); 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 ) ) if( ( size.x < minsize.x ) || ( size.y < minsize.y ) )
SetSize( 0, 0, minsize.x, 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 ZOOM_DISPLAY_SIZE 60
#define COORD_DISPLAY_SIZE 156 #define COORD_DISPLAY_SIZE 156
#define UNITS_DISPLAY_SIZE 50 #define UNITS_DISPLAY_SIZE 50
...@@ -97,8 +93,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, ...@@ -97,8 +93,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
SetStatusWidths( 6, dims ); SetStatusWidths( 6, dims );
// Create child subwindows. // Create child subwindows.
GetClientSize( &m_FrameSize.x, &m_FrameSize.y );/* dimx, dimy = dimensions utiles de la GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
* zone utilisateur de la fenetre principale */
m_FramePos.x = m_FramePos.y = 0; m_FramePos.x = m_FramePos.y = 0;
m_FrameSize.y -= m_MsgFrameHeight; m_FrameSize.y -= m_MsgFrameHeight;
...@@ -123,30 +118,23 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame() ...@@ -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 ); SetStatusText( message, 0 );
} }
/****************************************/
void WinEDA_DrawFrame::EraseMsgBox() void WinEDA_DrawFrame::EraseMsgBox()
/****************************************/
{ {
if( MsgPanel ) if( MsgPanel )
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
} }
/*******************************************************/
void WinEDA_DrawFrame::OnActivate( wxActivateEvent& event ) void WinEDA_DrawFrame::OnActivate( wxActivateEvent& event )
/*******************************************************/
{ {
m_FrameIsActive = event.GetActive(); m_FrameIsActive = event.GetActive();
if( DrawPanel ) if( DrawPanel )
...@@ -156,9 +144,7 @@ void WinEDA_DrawFrame::OnActivate( wxActivateEvent& event ) ...@@ -156,9 +144,7 @@ void WinEDA_DrawFrame::OnActivate( wxActivateEvent& event )
} }
/****************************************************/
void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event ) void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event )
/****************************************************/
{ {
if( DrawPanel ) if( DrawPanel )
DrawPanel->m_CanStartBlock = -1; DrawPanel->m_CanStartBlock = -1;
...@@ -166,35 +152,27 @@ void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event ) ...@@ -166,35 +152,27 @@ void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event )
} }
/*******************************************************/
void WinEDA_DrawFrame::ReCreateAuxiliaryToolbar()
/*******************************************************/
// Virtual function // Virtual function
void WinEDA_DrawFrame::ReCreateAuxiliaryToolbar()
{ {
} }
/********************************************/
void WinEDA_DrawFrame::ReCreateMenuBar()
/********************************************/
// Virtual function // Virtual function
void WinEDA_DrawFrame::ReCreateMenuBar()
{ {
} }
/****************************************************/ // Virtual function
void WinEDA_DrawFrame::OnHotKey( wxDC* DC, int hotkey, void WinEDA_DrawFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct ) EDA_BaseStruct* DrawStruct )
/****************************************************/
// Virtual function
{ {
} }
/**************************************************************/
void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event )
/**************************************************************/
// Virtual function // Virtual function
void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event )
{ {
} }
...@@ -272,14 +250,14 @@ void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event ) ...@@ -272,14 +250,14 @@ void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event ) void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event )
{ {
if( m_SelZoomBox == NULL ) if( m_SelZoomBox == NULL )
return; //Ne devrait pas se produire! return; // Should not happen!
int id = m_SelZoomBox->GetChoice(); int id = m_SelZoomBox->GetChoice();
if( id < 0 || !( id < (int)m_SelZoomBox->GetCount() ) ) if( id < 0 || !( id < (int)m_SelZoomBox->GetCount() ) )
return; return;
if( id == 0 ) // Auto zoom (Fit in Page) if( id == 0 ) // Auto zoom (Fit in Page)
{ {
Zoom_Automatique( true ); Zoom_Automatique( true );
} }
...@@ -295,35 +273,27 @@ void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event ) ...@@ -295,35 +273,27 @@ void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event )
} }
} }
/***********************************/
int WinEDA_DrawFrame::GetZoom(void)
/***********************************/
/* Return the current zoom level */ /* Return the current zoom level */
int WinEDA_DrawFrame::GetZoom(void)
{ {
return GetBaseScreen()->GetZoom(); return GetBaseScreen()->GetZoom();
} }
/********************************************************/
void WinEDA_DrawFrame::OnMouseEvent( wxMouseEvent& event ) void WinEDA_DrawFrame::OnMouseEvent( wxMouseEvent& event )
/********************************************************/
{ {
event.Skip(); event.Skip();
} }
/***********************************************************************/ // Virtual
// Virtuelle
void WinEDA_DrawFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_DrawFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/***********************************************************************/
{ {
} }
/***************************************/
void WinEDA_DrawFrame::SetToolbars() void WinEDA_DrawFrame::SetToolbars()
/***************************************/
{ {
DisplayUnitsMsg(); DisplayUnitsMsg();
...@@ -334,20 +304,15 @@ void WinEDA_DrawFrame::SetToolbars() ...@@ -334,20 +304,15 @@ void WinEDA_DrawFrame::SetToolbars()
} }
/********************************************************/
void WinEDA_DrawFrame::DisplayToolMsg( const wxString& msg ) void WinEDA_DrawFrame::DisplayToolMsg( const wxString& msg )
/********************************************************/
{ {
SetStatusText( msg, 5 ); SetStatusText( msg, 5 );
} }
/*******************************************/
void WinEDA_DrawFrame::DisplayUnitsMsg()
/********************************************/
/* Display current unit Selection on Statusbar /* Display current unit Selection on Statusbar
*/ */
void WinEDA_DrawFrame::DisplayUnitsMsg()
{ {
wxString msg; wxString msg;
...@@ -370,9 +335,7 @@ void WinEDA_DrawFrame::DisplayUnitsMsg() ...@@ -370,9 +335,7 @@ void WinEDA_DrawFrame::DisplayUnitsMsg()
} }
/***************************************/
void WinEDA_DrawFrame::ReDrawPanel() void WinEDA_DrawFrame::ReDrawPanel()
/***************************************/
{ {
if( DrawPanel == NULL ) if( DrawPanel == NULL )
return; return;
...@@ -384,12 +347,9 @@ void WinEDA_DrawFrame::ReDrawPanel() ...@@ -384,12 +347,9 @@ void WinEDA_DrawFrame::ReDrawPanel()
} }
/**************************************************/ /* Recalculate the size of toolbars and display panel.
void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
/**************************************************/
/* recalcule les dimensions des toolbars et du panel d'affichage
*/ */
void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
{ {
wxSize size; wxSize size;
wxSize opt_size; wxSize opt_size;
...@@ -401,21 +361,22 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -401,21 +361,22 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
#if !defined(KICAD_AUIMANAGER) #if !defined(KICAD_AUIMANAGER)
size.y -= m_MsgFrameHeight; 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 ); 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; Auxtoolbar_size.y = m_AuxiliaryToolBar->GetSize().y;
m_AuxiliaryToolBar->SetSize( Auxtoolbar_size ); m_AuxiliaryToolBar->SetSize( Auxtoolbar_size );
m_AuxiliaryToolBar->Move( 0, 0 ); m_AuxiliaryToolBar->Move( 0, 0 );
size.y -= Auxtoolbar_size.y; 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.x = m_VToolBar->GetSize().x;
Vtoolbar_size.y = size.y; Vtoolbar_size.y = size.y;
...@@ -424,7 +385,8 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -424,7 +385,8 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
m_VToolBar->Refresh(); 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.x += m_AuxVToolBar->GetSize().x;
Vtoolbar_size.y = size.y; Vtoolbar_size.y = size.y;
...@@ -461,20 +423,17 @@ void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv ) ...@@ -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 * Enables the icon of the selected tool in the vertical toolbar.
* ( ou l'outil par defaut ID_NO_SELECT_BUTT si pas de nouvelle selection ) * (Or tool ID_NO_SELECT_BUTT default if no new selection)
* if ( id >= 0 ) * if (id >= 0)
* Met a jour toutes les variables associees: * Updates all variables related:
* message, m_ID_current_state, curseur * Message m_ID_current_state, cursor
* si ( id < 0 ) * If (id < 0)
* Met a jour seulement les variables message et curseur * Only updates the variables message and cursor
*/ */
void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
const wxString& title )
{ {
// Change Cursor // Change Cursor
if( DrawPanel ) if( DrawPanel )
...@@ -488,7 +447,7 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id, ...@@ -488,7 +447,7 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
if( id < 0 ) if( id < 0 )
return; return;
// Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool // Old Tool ID_NO_SELECT_BUTT active or inactive if no new tool.
if( m_ID_current_state ) if( m_ID_current_state )
{ {
if( m_VToolBar ) if( m_VToolBar )
...@@ -511,7 +470,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id, ...@@ -511,7 +470,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE ); m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
} }
// New Tool Actif
if( id ) if( id )
{ {
if( m_VToolBar ) if( m_VToolBar )
...@@ -560,9 +518,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) ...@@ -560,9 +518,7 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
} }
/*********************************************/
void WinEDA_DrawFrame::AdjustScrollBars() void WinEDA_DrawFrame::AdjustScrollBars()
/*********************************************/
{ {
int xUnit, yUnit; int xUnit, yUnit;
wxSize draw_size, panel_size; wxSize draw_size, panel_size;
...@@ -617,7 +573,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -617,7 +573,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
xUnit = screen->Unscale( xUnit ); xUnit = screen->Unscale( xUnit );
yUnit = screen->Unscale( yUnit ); yUnit = screen->Unscale( yUnit );
// Calcul de la position, curseur place au centre d'ecran // Calculate the position, place the cursor at the center of screen.
scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg; scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg;
scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.x -= panel_size.x / 2;
...@@ -663,14 +619,11 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -663,14 +619,11 @@ void WinEDA_DrawFrame::AdjustScrollBars()
} }
/****************************************************/ /* Updates the background color for drawing panel. The only valid colors
void WinEDA_DrawFrame::SetDrawBgColor( int color_num ) * are BLACK and WHITE.
/****************************************************/ * XorMode the parameter is updated according to the background color
/* 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
*/ */
void WinEDA_DrawFrame::SetDrawBgColor( int color_num )
{ {
if( ( color_num != WHITE ) && ( color_num != BLACK ) ) if( ( color_num != WHITE ) && ( color_num != BLACK ) )
color_num = BLACK; color_num = BLACK;
...@@ -687,15 +640,14 @@ void WinEDA_DrawFrame::SetDrawBgColor( int color_num ) ...@@ -687,15 +640,14 @@ void WinEDA_DrawFrame::SetDrawBgColor( int color_num )
} }
if( DrawPanel ) if( DrawPanel )
DrawPanel->SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red, DrawPanel->SetBackgroundColour(
ColorRefs[g_DrawBgColor].m_Green, wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Blue ) ); ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ) );
} }
/********************************************************/
void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
/********************************************************/
{ {
int id = event.GetId(); int id = event.GetId();
......
/******************************************/ /*****************/
/* drawpanel.cpp - WinEDA_DrawPanel class */ /* drawpanel.cpp */
/******************************************/ /*****************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -13,15 +13,13 @@ ...@@ -13,15 +13,13 @@
#include "wxstruct.h" #include "wxstruct.h"
// Local defines
#define CURSOR_SIZE 12 // Cursor size in pixels #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 /* Used to inhibit a response to a mouse left button release, after a
* (when releasing the left button at the end of the second click * double click (when releasing the left button at the end of the second
* Used in eeschema to inhibit a mouse left release command when switching between * click. Used in eeschema to inhibit a mouse left release command when
* hierarchical sheets on a double click * switching between hierarchical sheets on a double click.
*/ */
static bool s_IgnoreNextLeftButtonRelease = false; static bool s_IgnoreNextLeftButtonRelease = false;
...@@ -41,9 +39,9 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow ) ...@@ -41,9 +39,9 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan ) EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
END_EVENT_TABLE() END_EVENT_TABLE()
/************************************************************************/ /***********************************************************************/
/* WinEDA_DrawPanel basic functions (WinEDA_DrawPanel is the main panel)*/ /* WinEDA_DrawPanel base functions (WinEDA_DrawPanel is the main panel)*/
/************************************************************************/ /***********************************************************************/
WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
const wxPoint& pos, const wxSize& size ) : const wxPoint& pos, const wxSize& size ) :
...@@ -99,11 +97,9 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen() ...@@ -99,11 +97,9 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
} }
/***************************************************************************** /*
*
* Draw the schematic cursor which is usually on grid * Draw the schematic cursor which is usually on grid
* */
*****************************************************************************/
void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
{ {
if( m_CursorLevel != 0 || DC == NULL ) if( m_CursorLevel != 0 || DC == NULL )
...@@ -112,15 +108,15 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) ...@@ -112,15 +108,15 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
wxPoint Cursor = GetScreen()->m_Curseur; wxPoint Cursor = GetScreen()->m_Curseur;
GRSetDrawMode( DC, GR_XOR ); 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 dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() ); int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
GRLine( &m_ClipBox, DC, Cursor.x - dx, Cursor.y, 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, 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 else
{ {
...@@ -134,26 +130,21 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) ...@@ -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 ); Trace_Curseur( DC );
--m_CursorLevel; --m_CursorLevel;
} }
/*******************************************************************/
void WinEDA_DrawPanel::CursorOn( wxDC* DC )
/*******************************************************************/
/* /*
* Display the grid cursor * Display the grid cursor
*/ */
void WinEDA_DrawPanel::CursorOn( wxDC* DC )
{ {
++m_CursorLevel; ++m_CursorLevel;
Trace_Curseur( DC ); Trace_Curseur( DC );
...@@ -163,33 +154,25 @@ void WinEDA_DrawPanel::CursorOn( wxDC* DC ) ...@@ -163,33 +154,25 @@ void WinEDA_DrawPanel::CursorOn( wxDC* DC )
} }
/***********************************/
int WinEDA_DrawPanel::GetZoom() int WinEDA_DrawPanel::GetZoom()
/***********************************/
{ {
return GetScreen()->GetZoom(); return GetScreen()->GetZoom();
} }
/***************************************/
void WinEDA_DrawPanel::SetZoom( int zoom ) void WinEDA_DrawPanel::SetZoom( int zoom )
/***************************************/
{ {
GetScreen()->SetZoom( zoom ); GetScreen()->SetZoom( zoom );
} }
/************************************/
wxRealPoint WinEDA_DrawPanel::GetGrid() wxRealPoint WinEDA_DrawPanel::GetGrid()
/************************************/
{ {
return GetScreen()->GetGridSize(); return GetScreen()->GetGridSize();
} }
/******************************************************/
void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
/******************************************************/
{ {
GRResetPenAndBrush( DC ); GRResetPenAndBrush( DC );
DC->SetBackgroundMode( wxTRANSPARENT ); DC->SetBackgroundMode( wxTRANSPARENT );
...@@ -203,14 +186,11 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) ...@@ -203,14 +186,11 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
} }
/**********************************************************************/ /** Calculate the cursor position in internal units.
wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
/**********************************************************************/
/** CursorRealPosition (used to calculate the cursor position in internal units)
* @return position (in internal units) * @return position (in internal units)
* @param ScreenPos = absolute position in pixels * @param ScreenPos = absolute position in pixels
*/ */
wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
{ {
#ifdef WX_ZOOM #ifdef WX_ZOOM
wxCoord x, y; wxCoord x, y;
...@@ -225,15 +205,12 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) ...@@ -225,15 +205,12 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
} }
/********************************************************/
bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
/********************************************************/
/** Function IsPointOnDisplay /** Function IsPointOnDisplay
* @param ref_pos is the position to test in pixels, relative to the panel. * @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 * @return TRUE if ref_pos is a point currently visible on screen
* FALSE if ref_pos is out of screen * FALSE if ref_pos is out of screen
*/ */
bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
{ {
wxPoint pos; wxPoint pos;
EDA_Rect display_rect; EDA_Rect display_rect;
...@@ -241,12 +218,12 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -241,12 +218,12 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
SetBoundaryBox(); SetBoundaryBox();
display_rect = m_ClipBox; display_rect = m_ClipBox;
// Reduction legere des dimension de l'ecran utile pour eviter cadrage // Slightly decreased the size of the useful screen area to avoid drawing
// en limite d'ecran // limits.
#define PIXEL_MARGIN 8 #define PIXEL_MARGIN 8
display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN ); display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN );
// Conversion en coord physiques // Convert physical coordinates.
pos = CalcUnscrolledPosition( display_rect.GetPosition() ); pos = CalcUnscrolledPosition( display_rect.GetPosition() );
GetScreen()->Unscale( pos ); GetScreen()->Unscale( pos );
...@@ -279,9 +256,7 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect ) ...@@ -279,9 +256,7 @@ void WinEDA_DrawPanel::PostDirtyRect( EDA_Rect aRect )
} }
/************************************************************************/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect ) void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
/************************************************************************/
{ {
// Calculate the draw area origin in internal units: // Calculate the draw area origin in internal units:
wxPoint pos = aRect->GetPosition(); wxPoint pos = aRect->GetPosition();
...@@ -342,13 +317,11 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition() ...@@ -342,13 +317,11 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
} }
/*********************************************************/
wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
/*********************************************************/
/** Function GetScreenCenterRealPosition() /** 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; wxSize size;
wxPoint realpos; wxPoint realpos;
...@@ -370,12 +343,9 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) ...@@ -370,12 +343,9 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
} }
/**********************************************/
void WinEDA_DrawPanel::MouseToCursorSchema()
/**********************************************/
/* Move the mouse cursor to the current schematic cursor /* Move the mouse cursor to the current schematic cursor
*/ */
void WinEDA_DrawPanel::MouseToCursorSchema()
{ {
wxPoint Mouse = CursorScreenPosition(); wxPoint Mouse = CursorScreenPosition();
...@@ -383,13 +353,10 @@ void WinEDA_DrawPanel::MouseToCursorSchema() ...@@ -383,13 +353,10 @@ void WinEDA_DrawPanel::MouseToCursorSchema()
} }
/****************************************************/
void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
/****************************************************/
/** Move the mouse cursor to the position "Mouse" /** Move the mouse cursor to the position "Mouse"
* @param Mouse = mouse cursor position, in pixels units * @param Mouse = mouse cursor position, in pixels units
*/ */
void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
{ {
int x, y, xPpu, yPpu; int x, y, xPpu, yPpu;
wxPoint screenPos, drawingPos; wxPoint screenPos, drawingPos;
...@@ -436,33 +403,27 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse ) ...@@ -436,33 +403,27 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
} }
/********************************************************/
void WinEDA_DrawPanel::OnActivate( wxActivateEvent& event )
/********************************************************/
/** /**
* Called on window activation. * Called on window activation.
* init the member m_CanStartBlock to avoid a block start command * 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 * on activation (because a left mouse button can be pressed and no block
* This happens when enter on a hierarchycat sheet on double click * 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 m_CanStartBlock = -1; // Block Command can't start
event.Skip(); event.Skip();
} }
/***********************************************************/
void WinEDA_DrawPanel::OnEraseBackground( wxEraseEvent& event ) void WinEDA_DrawPanel::OnEraseBackground( wxEraseEvent& event )
/***********************************************************/
{ {
event.Skip(); event.Skip();
} }
/*********************************************************/
void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event ) void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
/*********************************************************/
{ {
int id = event.GetEventType(); int id = event.GetEventType();
int dir, value = 0; int dir, value = 0;
...@@ -504,22 +465,17 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event ) ...@@ -504,22 +465,17 @@ void WinEDA_DrawPanel::OnScroll( wxScrollWinEvent& event )
} }
/*************************************************/
void WinEDA_DrawPanel::OnSize( wxSizeEvent& event ) void WinEDA_DrawPanel::OnSize( wxSizeEvent& event )
/*************************************************/
{ {
SetBoundaryBox(); SetBoundaryBox();
event.Skip(); event.Skip();
} }
/******************************************/
void WinEDA_DrawPanel::SetBoundaryBox()
/******************************************/
/** Function SetBoundaryBox() /** Function SetBoundaryBox()
* set the m_ClipBox member to the current displayed rectangle dimensions * set the m_ClipBox member to the current displayed rectangle dimensions
*/ */
void WinEDA_DrawPanel::SetBoundaryBox()
{ {
BASE_SCREEN* Screen = GetScreen();; BASE_SCREEN* Screen = GetScreen();;
...@@ -554,9 +510,7 @@ void WinEDA_DrawPanel::SetBoundaryBox() ...@@ -554,9 +510,7 @@ void WinEDA_DrawPanel::SetBoundaryBox()
} }
/*********************************************/
void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
/*********************************************/
{ {
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
...@@ -569,8 +523,10 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) ...@@ -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.x = DC->DeviceToLogicalX( m_ClipBox.m_Pos.x );
m_ClipBox.m_Pos.y = DC->DeviceToLogicalY( m_ClipBox.m_Pos.y ); 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.SetWidth(
m_ClipBox.m_Size.SetHeight( DC->DeviceToLogicalYRel( m_ClipBox.m_Size.GetHeight() ) ); 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(), GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(), m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
...@@ -589,9 +545,8 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC ) ...@@ -589,9 +545,8 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
//#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC //#define USE_GCDC_IN_KICAD // uncomment it to use wxGCDC
#endif #endif
/***************************************************/
void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
/***************************************************/
{ {
if( GetScreen() == NULL ) if( GetScreen() == NULL )
{ {
...@@ -601,8 +556,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -601,8 +556,10 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#ifdef USE_GCDC_IN_KICAD #ifdef USE_GCDC_IN_KICAD
wxPaintDC pDC( this ); wxPaintDC pDC( this );
wxGCDC paintDC(pDC); // Following line should be disabled on MSW and OS X // 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 wxGCDC paintDC( pDC );
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC.GetGraphicsContext()->Translate(0.5, 0.5);
#else #else
wxPaintDC paintDC( this ); wxPaintDC paintDC( this );
#endif #endif
...@@ -693,9 +650,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -693,9 +650,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
} }
/****************************************************/
void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg ) void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
/****************************************************/
{ {
BASE_SCREEN* Screen = GetScreen(); BASE_SCREEN* Screen = GetScreen();
...@@ -731,17 +686,14 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg ) ...@@ -731,17 +686,14 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
} }
/***********************************************/
void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
/***********************************************/
/** Function DrawBackGround /** Function DrawBackGround
* @param DC = current Device Context * @param DC = current Device Context
* Draws X , Y axis * Draws X , Y axis
* draws the grid * draws the grid
* - the grid is drawn only if the zoom level allows a good visibility * - the grid is drawn only if the zoom level allows a good visibility
* - the grid is always centered on the screen centre * - the grid is always centered on the screen center
*/ */
void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
{ {
int Color = BLUE; int Color = BLUE;
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
...@@ -846,14 +798,11 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ...@@ -846,14 +798,11 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
} }
/********************************************************************/
void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode )
/********************************************************************/
/** m_Draw_Auxiliary_Axis /** m_Draw_Auxiliary_Axis
* Draw the Auxiliary Axis, used in pcbnew which as origin coordinates * Draw the Auxiliary Axis, used in pcbnew which as origin coordinates
* for gerber and excellon files * for gerber and excellon files
*/ */
void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode )
{ {
if( !m_Parent->m_Draw_Auxiliary_Axis if( !m_Parent->m_Draw_Auxiliary_Axis
|| ( m_Parent->m_Auxiliary_Axis_Position.x == 0 || ( m_Parent->m_Auxiliary_Axis_Position.x == 0
...@@ -883,13 +832,10 @@ void WinEDA_DrawPanel::DrawAuxiliaryAxis( wxDC* DC, int drawmode ) ...@@ -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 /** Build and display a Popup menu on a right mouse button click
* @return true if a popup menu is shown, or false * @return true if a popup menu is shown, or false
*/ */
bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event )
{ {
wxPoint pos; wxPoint pos;
wxMenu MasterMenu; wxMenu MasterMenu;
...@@ -910,13 +856,10 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event ) ...@@ -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 ) 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; m_AutoPAN_Request = FALSE;
if( !m_AutoPAN_Enable || !m_AutoPAN_Request || m_IgnoreMouseEvents ) if( !m_AutoPAN_Enable || !m_AutoPAN_Request || m_IgnoreMouseEvents )
...@@ -988,11 +931,9 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) ...@@ -988,11 +931,9 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
GetEventHandler()->ProcessEvent( cmd ); 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; int localrealbutt = 0, localbutt = 0, localkey = 0;
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
...@@ -1000,14 +941,17 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1000,14 +941,17 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( !screen ) if( !screen )
return; 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 /* 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 #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
* a block command can be started only if MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* in order to avoid spurious block commands /* 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() ) if( event.Leaving() || event.Entering() )
{ {
m_CanStartBlock = -1; m_CanStartBlock = -1;
...@@ -1059,10 +1003,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1059,10 +1003,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
localrealbutt |= localbutt; /* compensation default wxGTK */ localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute absolute m_MousePosition in pixel units: */ /* 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: */ /* Compute absolute m_MousePosition in user units: */
screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); screen->m_MousePosition =
CursorRealPosition( screen->m_MousePositionInPixels );
wxClientDC DC( this ); wxClientDC DC( this );
int kbstat = 0; int kbstat = 0;
...@@ -1087,13 +1033,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1087,13 +1033,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels ); m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );
// inhibit a response to the mouse left button release, // 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; s_IgnoreNextLeftButtonRelease = true;
} }
else if( event.LeftUp() ) 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 // 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 // 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 ); m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
s_IgnoreNextLeftButtonRelease = false; s_IgnoreNextLeftButtonRelease = false;
...@@ -1102,13 +1051,15 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1102,13 +1051,15 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( !event.LeftIsDown() ) if( !event.LeftIsDown() )
{ {
/* be sure there is a response to a left button release command /* be sure there is a response to a left button release command
* even when a LeftUp event is not seen * even when a LeftUp event is not seen. This happens when a
* happens when a double click opens a dialog box, and the release mouse button is made when the dialog box is open * double click opens a dialog box, and the release mouse button
* is made when the dialog box is open.
*/ */
s_IgnoreNextLeftButtonRelease = false; 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: // The middle button has been released, with no block command:
// We use it for a zoom center at cursor position command // We use it for a zoom center at cursor position command
...@@ -1136,7 +1087,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1136,7 +1087,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
/* A new command block can start after a release buttons /* A new command block can start after a release buttons
* and if the drag is enough * and if the drag is enough
* This is to avoid a false start block when a dialog box is demiss, * This is to avoid a false start block when a dialog box is dismissed,
* or when changing panels in hierarchy navigation * or when changing panels in hierarchy navigation
* or when clicking while and moving mouse * or when clicking while and moving mouse
*/ */
...@@ -1145,18 +1096,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1145,18 +1096,20 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
MinDragEventCount = 0; MinDragEventCount = 0;
m_CanStartBlock = 0; m_CanStartBlock = 0;
/* remember the last cursor position when a drag mouse starts /* Remember the last cursor position when a drag mouse starts
* this is the last position ** before ** clicking a button * 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 * this is useful to start a block command from the point where the
* (a filter creates a delay for the real block command start, and we must remember this point) * 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; m_CursorStartPos = screen->m_Curseur;
} }
if( m_Block_Enable && !(localbutt & GR_M_DCLICK) ) if( m_Block_Enable && !(localbutt & GR_M_DCLICK) )
{ {
if( (screen->m_BlockLocate.m_Command == BLOCK_IDLE) if( ( screen->m_BlockLocate.m_Command == BLOCK_IDLE )
|| (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) ) || ( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) )
{ {
screen->m_BlockLocate.SetOrigin( m_CursorStartPos ); screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
} }
...@@ -1169,11 +1122,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1169,11 +1122,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
s_IgnoreNextLeftButtonRelease = true; s_IgnoreNextLeftButtonRelease = true;
} }
} }
else if( (m_CanStartBlock >= 0 ) else if( ( m_CanStartBlock >= 0 )
&& ( event.LeftIsDown() || event.MiddleIsDown() ) && ( event.LeftIsDown() || event.MiddleIsDown() )
&& ManageCurseur == NULL && ManageCurseur == NULL
&& ForceCloseManageCurseur == 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 ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ // Start a block command { // Start a block command
int cmd_type = kbstat; int cmd_type = kbstat;
...@@ -1181,15 +1136,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1181,15 +1136,16 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleIsDown() ) if( event.MiddleIsDown() )
cmd_type |= MOUSE_MIDDLE; cmd_type |= MOUSE_MIDDLE;
/* A block command is started if the drag is enough. /* A block command is started if the drag is enough. A small
* A small drag is ignored (it is certainly a little mouse move when clicking) * drag is ignored (it is certainly a little mouse move when
* not really a drag mouse * clicking) not really a drag mouse
*/ */
if( MinDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND ) if( MinDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
MinDragEventCount++; MinDragEventCount++;
else else
{ {
if( !m_Parent->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) ) if( !m_Parent->HandleBlockBegin( &DC, cmd_type,
m_CursorStartPos ) )
{ {
// should not occurs: error // should not occurs: error
m_Parent->DisplayToolMsg( m_Parent->DisplayToolMsg(
...@@ -1207,17 +1163,21 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1207,17 +1163,21 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( event.ButtonUp( 1 ) || event.ButtonUp( 2 ) ) if( event.ButtonUp( 1 ) || event.ButtonUp( 2 ) )
{ {
/* Release the mouse button: end of block. /* Release the mouse button: end of block.
* The command can finish (DELETE) or have a next command (MOVE, COPY). * The command can finish (DELETE) or have a next command (MOVE,
* However the block command is canceled if the block size is small * COPY). However the block command is canceled if the block
* Because a block command filtering is already made, this case happens, * size is small because a block command filtering is already
* but only when the on grid cursor has not moved. * made, this case happens, but only when the on grid cursor has
* not moved.
*/ */
#define BLOCK_MINSIZE_LIMIT 1 #define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall = bool BlockIsSmall =
( ABS( screen->Scale( screen->m_BlockLocate.GetWidth() ) ) < BLOCK_MINSIZE_LIMIT) ( ABS( screen->Scale( screen->m_BlockLocate.GetWidth() ) )
&& ( ABS( screen->Scale( screen->m_BlockLocate.GetHeight() ) ) < BLOCK_MINSIZE_LIMIT); < 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 ) if( ForceCloseManageCurseur )
{ {
...@@ -1241,8 +1201,9 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1241,8 +1201,9 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
} }
// End of block command on a double click // End of block command on a double click
// To avoid an unwanted block move command if the mouse is moved while double clicking // To avoid an unwanted block move command if the mouse is moved while
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) ) // double clicking
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{ {
if( screen->m_BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
...@@ -1258,7 +1219,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1258,7 +1219,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#if 0 #if 0
wxString msg_debug; wxString msg_debug;
msg_debug.Printf( " block state %d, cmd %d", 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 ); m_Parent->PrintMsg( msg_debug );
#endif #endif
...@@ -1266,9 +1228,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1266,9 +1228,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
} }
/****************************************************/
void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
/****************************************************/
{ {
long key, localkey; long key, localkey;
bool escape = FALSE; bool escape = FALSE;
...@@ -1342,6 +1302,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) ...@@ -1342,6 +1302,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
#endif #endif
} }
void WinEDA_DrawPanel::OnPan( wxCommandEvent& event ) void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
{ {
int x, y; int x, y;
......
/////////////////////// ///////////////////////
// Name: eda_dde.cpp // // Name: eda_dde.cpp //
/////////////////////// ///////////////////////
...@@ -13,27 +12,28 @@ ...@@ -13,27 +12,28 @@
wxString HOSTNAME( wxT( "localhost" ) ); wxString HOSTNAME( wxT( "localhost" ) );
/* variables locales */
// buffer for read and write data in socket connections // buffer for read and write data in socket connections
#define IPC_BUF_SIZE 4096 #define IPC_BUF_SIZE 4096
static char client_ipc_buffer[IPC_BUF_SIZE]; static char client_ipc_buffer[IPC_BUF_SIZE];
static wxServer* server; static wxServer* server;
void (*RemoteFct)(const char* cmd); void (*RemoteFct)(const char* cmd);
void SetupServerFunction( void (*remotefct)(const char* remotecmd) ) void SetupServerFunction( void (*remotefct)(const char* remotecmd) )
{ {
RemoteFct = remotefct; RemoteFct = remotefct;
} }
/*****************************/ /**********************************/
/* Routines liees au SERVEUR */ /* Routines related to the server */
/*****************************/ /**********************************/
/* Fonction d'initialisation d'un serveur socket /* Function to initialize a server socket
*/ */
WinEDA_Server* CreateServer( wxWindow* window, int service ) WinEDA_Server* CreateServer( wxWindow* window, int service )
{ {
...@@ -54,12 +54,9 @@ WinEDA_Server* CreateServer( wxWindow* window, int service ) ...@@ -54,12 +54,9 @@ WinEDA_Server* CreateServer( wxWindow* window, int service )
} }
/********************************************************/ /* Function called on every client request.
void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
/********************************************************/
/* Fonction appelee a chaque demande d'un client
*/ */
void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
{ {
size_t len; size_t len;
wxSocketBase* sock = evt.GetSocket(); wxSocketBase* sock = evt.GetSocket();
...@@ -69,8 +66,8 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt ) ...@@ -69,8 +66,8 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
case wxSOCKET_INPUT: case wxSOCKET_INPUT:
sock->Read( client_ipc_buffer, 1 ); sock->Read( client_ipc_buffer, 1 );
if( sock->LastCount() == 0 ) if( sock->LastCount() == 0 )
break; // No data: Occurs on opening connection break; // No data, occurs on opening connection
sock->Read( client_ipc_buffer + 1, IPC_BUF_SIZE - 2 ); sock->Read( client_ipc_buffer + 1, IPC_BUF_SIZE - 2 );
len = 1 + sock->LastCount(); len = 1 + sock->LastCount();
client_ipc_buffer[len] = 0; client_ipc_buffer[len] = 0;
...@@ -89,12 +86,9 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt ) ...@@ -89,12 +86,9 @@ void WinEDA_DrawFrame::OnSockRequest( wxSocketEvent& evt )
} }
/**************************************************************/ /* Function called when a connection is requested by a client.
void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
/**************************************************************/
/* fonction appele lors d'une demande de connexion d'un client
*/ */
void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
{ {
wxSocketBase* sock2; wxSocketBase* sock2;
wxSocketServer* server = (wxSocketServer*) evt.GetSocket(); wxSocketServer* server = (wxSocketServer*) evt.GetSocket();
...@@ -109,21 +103,18 @@ void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt ) ...@@ -109,21 +103,18 @@ void WinEDA_DrawFrame::OnSockRequestServer( wxSocketEvent& evt )
} }
/****************************/ /**********************************/
/* Routines liees au CLIENT */ /* Routines related to the CLIENT */
/*****************************/ /**********************************/
/**************************************************/
bool SendCommand( int service, const char* cmdline )
/**************************************************/
/* Used by a client to sent (by a socket connection) a data to a server. /* Used by a client to sent (by a socket connection) a data to a server.
* - Open a Socket Client connection * - Open a Socket Client connection
* - Send the buffer cmdline * - Send the buffer cmdline
* - Close the socket connection * - Close the socket connection
* *
* service is the service number for the TC/IP connection * service is the service number for the TC/IP connection
*/ */
bool SendCommand( int service, const char* cmdline )
{ {
wxSocketClient* sock_client; wxSocketClient* sock_client;
bool success = FALSE; bool success = FALSE;
...@@ -133,7 +124,8 @@ bool SendCommand( int service, const char* cmdline ) ...@@ -133,7 +124,8 @@ bool SendCommand( int service, const char* cmdline )
addr.Hostname( HOSTNAME ); addr.Hostname( HOSTNAME );
addr.Service( service ); 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, // There are two ways to use Connect(): blocking and non-blocking,
...@@ -141,7 +133,7 @@ bool SendCommand( int service, const char* cmdline ) ...@@ -141,7 +133,7 @@ bool SendCommand( int service, const char* cmdline )
// //
// Connect(addr, true) will wait until the connection completes, // Connect(addr, true) will wait until the connection completes,
// returning true on success and false on failure. This call blocks // returning true on success and false on failure. This call blocks
// the GUI (this might be changed in future releases to honour the // the GUI (this might be changed in future releases to honor the
// wxSOCKET_BLOCK flag). // wxSOCKET_BLOCK flag).
// //
// Connect(addr, false) will issue a nonblocking connection request // Connect(addr, false) will issue a nonblocking connection request
...@@ -152,7 +144,7 @@ bool SendCommand( int service, const char* cmdline ) ...@@ -152,7 +144,7 @@ bool SendCommand( int service, const char* cmdline )
// events (please read the documentation). // events (please read the documentation).
// //
// WaitOnConnect() itself never blocks the GUI (this might change // WaitOnConnect() itself never blocks the GUI (this might change
// in the future to honour 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 // return false on timeout, or true if the connection request
// completes, which in turn might mean: // completes, which in turn might mean:
// //
...@@ -181,7 +173,7 @@ bool SendCommand( int service, const char* cmdline ) ...@@ -181,7 +173,7 @@ bool SendCommand( int service, const char* cmdline )
// bool success = client->IsConnected(); // bool success = client->IsConnected();
// //
// And that's all :-) // And that's all :-)
sock_client = new wxSocketClient(); sock_client = new wxSocketClient();
sock_client->SetTimeout( 2 ); // Time out in Seconds sock_client->SetTimeout( 2 ); // Time out in Seconds
sock_client->Connect( addr, FALSE ); sock_client->Connect( addr, FALSE );
......
...@@ -14,31 +14,25 @@ ...@@ -14,31 +14,25 @@
#include "macros.h" #include "macros.h"
/*****************************************/
void WinEDA_App::ReadPdfBrowserInfos()
/*****************************************/
/* Read from Common config the Pdf browser choice /* Read from Common config the Pdf browser choice
*/ */
void WinEDA_App::ReadPdfBrowserInfos()
{ {
wxASSERT( m_EDA_CommonConfig != NULL ); wxASSERT( m_EDA_CommonConfig != NULL );
m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault =
true ); m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), true );
m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ),
wxEmptyString ); wxEmptyString );
if( m_PdfBrowser.IsEmpty() ) if( m_PdfBrowser.IsEmpty() )
m_PdfBrowserIsDefault = true; m_PdfBrowserIsDefault = true;
} }
/*****************************************/
void WinEDA_App::WritePdfBrowserInfos()
/*****************************************/
/* Write into Common config the Pdf browser choice /* Write into Common config the Pdf browser choice
*/ */
void WinEDA_App::WritePdfBrowserInfos()
{ {
wxASSERT( m_EDA_CommonConfig != NULL ); wxASSERT( m_EDA_CommonConfig != NULL );
...@@ -46,7 +40,7 @@ void WinEDA_App::WritePdfBrowserInfos() ...@@ -46,7 +40,7 @@ void WinEDA_App::WritePdfBrowserInfos()
m_PdfBrowserIsDefault = true; m_PdfBrowserIsDefault = true;
m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ),
m_PdfBrowserIsDefault ); m_PdfBrowserIsDefault );
m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser ); m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
} }
...@@ -56,16 +50,18 @@ static wxMimeTypesManager* mimeDatabase; ...@@ -56,16 +50,18 @@ static wxMimeTypesManager* mimeDatabase;
static const wxFileTypeInfo EDAfallbacks[] = static const wxFileTypeInfo EDAfallbacks[] =
{ {
wxFileTypeInfo( wxT( "text/html" ), wxFileTypeInfo( wxT( "text/html" ),
wxT( "wxhtml %s" ), wxT( "wxhtml %s" ),
wxT( "wxhtml %s" ), wxT( "wxhtml %s" ),
wxT( "html document (from Kicad)" ), wxT( "html document (from Kicad)" ),
wxT( "htm" ), wxT( "html" ),NULL ), wxT( "htm" ),
wxT( "html" ),NULL ),
wxFileTypeInfo( wxT( "application/sch" ), wxFileTypeInfo( wxT( "application/sch" ),
wxT( "eeschema %s" ), wxT( "eeschema %s" ),
wxT( "eeschema -p %s" ), wxT( "eeschema -p %s" ),
wxT( "sch document (from Kicad)" ), wxT( "sch document (from Kicad)" ),
wxT( "sch" ), wxT( "SCH" ), NULL ), wxT( "sch" ),
wxT( "SCH" ), NULL ),
// must terminate the table with this! // must terminate the table with this!
wxFileTypeInfo() wxFileTypeInfo()
...@@ -75,14 +71,15 @@ static const wxFileTypeInfo EDAfallbacks[] = ...@@ -75,14 +71,15 @@ static const wxFileTypeInfo EDAfallbacks[] =
/** Function GetAssociatedDocument /** Function GetAssociatedDocument
* open a document (file) with the suitable browser * open a document (file) with the suitable browser
* @param aFrame = main frame * @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 aDocName = filename of file to open (Full filename or short filename)
* @param aPaths = a wxPathList to explore. * @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, bool GetAssociatedDocument( wxFrame* aFrame,
const wxString& aDocName, const wxString& aDocName,
const wxPathList* aPaths) const wxPathList* aPaths)
{ {
wxString docname, fullfilename, file_ext; wxString docname, fullfilename, file_ext;
...@@ -91,7 +88,8 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -91,7 +88,8 @@ bool GetAssociatedDocument( wxFrame* aFrame,
bool success = FALSE; bool success = FALSE;
// Is an internet url // 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++ ) for( int ii = 0; ii < 3; ii++ )
{ {
...@@ -113,9 +111,10 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -113,9 +111,10 @@ bool GetAssociatedDocument( wxFrame* aFrame,
/* Compute the full file name */ /* Compute the full file name */
if( wxIsAbsolutePath( aDocName ) || aPaths == NULL) if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
fullfilename = aDocName; fullfilename = aDocName;
/* If the file exists, this is a trivial case: return the filename "as this" /* If the file exists, this is a trivial case: return the filename
* the name can be an absolute path, or a relative path like ./filename or ../<filename> * "as this". the name can be an absolute path, or a relative path
*/ * like ./filename or ../<filename>
*/
else if( wxFileName::FileExists( aDocName ) ) else if( wxFileName::FileExists( aDocName ) )
fullfilename = aDocName; fullfilename = aDocName;
else else
...@@ -132,17 +131,15 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -132,17 +131,15 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( wxIsWild( fullfilename ) ) if( wxIsWild( fullfilename ) )
{ {
fullfilename = fullfilename = EDA_FileSelector( _( "Doc Files" ),
EDA_FileSelector( _( "Doc Files" ), /* Titre de la fenetre */ wxPathOnly( fullfilename ),
wxPathOnly( fullfilename ), /* Chemin par defaut */ fullfilename,
fullfilename, /* nom fichier par defaut */ extension,
extension, /* extension par defaut */ mask,
mask, /* Masque d'affichage */ aFrame,
aFrame, /* parent frame */ wxFD_OPEN,
wxFD_OPEN, /* wxSAVE, wxFD_OPEN ..*/ TRUE,
TRUE, /* true = ne change pas le repertoire courant */ wxPoint( -1, -1 ) );
wxPoint( -1, -1 )
);
if( fullfilename.IsEmpty() ) if( fullfilename.IsEmpty() )
return FALSE; return FALSE;
} }
...@@ -163,13 +160,13 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -163,13 +160,13 @@ bool GetAssociatedDocument( wxFrame* aFrame,
return success; return success;
} }
/* Try to launch some browser (usefull under linux) */ /* Try to launch some browser (useful under linux) */
wxFileType* filetype; wxFileType* filetype;
wxString type; wxString type;
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext ); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
if( !filetype ) // 2ieme tentative if( !filetype ) // 2nd attempt.
{ {
mimeDatabase = new wxMimeTypesManager; mimeDatabase = new wxMimeTypesManager;
mimeDatabase->AddFallbacks( EDAfallbacks ); mimeDatabase->AddFallbacks( EDAfallbacks );
...@@ -199,17 +196,14 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -199,17 +196,14 @@ bool GetAssociatedDocument( wxFrame* aFrame,
} }
/******************************************************************/ /* Search if the text Database found all the words in the KeyList.
int KeyWordOk( const wxString& KeyList, const wxString& Database ) * Give articles in keylist (keylist = Following Keywords
/******************************************************************/ * Separated by spaces
* Returns:
/* Recherche si dans le texte Database on retrouve tous les mots * 0 if no keyword found
* cles donnes dans KeyList ( KeyList = suite de mots cles * 1 if keyword found
* separes par des espaces
* Retourne:
* 0 si aucun mot cle trouv
* 1 si mot cle trouv
*/ */
int KeyWordOk( const wxString& KeyList, const wxString& Database )
{ {
wxString KeysCopy, DataList; wxString KeysCopy, DataList;
......
/************************************************/ /******************************************/
/* MODULE: gestfich.cpp */ /* File: gestfich.cpp */
/* ROLE: fonctions de gestion de fichiers */ /* Purpose: Functions for file management */
/************************************************/ /******************************************/
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "confirm.h" #include "confirm.h"
#ifdef __WINDOWS__
#ifndef _MSC_VER
//#include <dir.h>
#endif
#endif
#include "common.h" #include "common.h"
#include "macros.h" #include "macros.h"
#include "gestfich.h" #include "gestfich.h"
...@@ -24,30 +18,35 @@ ...@@ -24,30 +18,35 @@
/* List of default paths used to locate help files and kicad library files. /* 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") * Under windows, kicad search its files from the binary path file (first
* So for a standard install, default paths are not mandatory, but they exist, just in case. * argument when running "main") So for a standard install, default paths
* kicad is often installed in c:/Program Files/kicad or c:/kicad (or d: or e: ... ) * are not mandatory, but they exist, just in case.
* and the directory "share" has no meaning under windows. * 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. * Under linux, the problem is more complex.
* In fact there are 3 cases: * In fact there are 3 cases:
* 1 - When released in a distribution: * 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: * 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: * 3 - When in an "universal tarball" or build for a server:
* all files are in /usr/local/kicad * 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 * This is mandatory when kicad is installed on a server (in a school for
* and obviously the others paths cannot be used * instance) because one can export /usr/local/kicad and obviously the others
* (cannot be mounted by the client, because they are already used). * 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 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. * in case 3 kicad files can be found from the binary path only if this is
* But if an user creates a symbolic link to the actual binary file to run kicad, the binary path is not good * a kicad binary file which is launched.
* and the defaults paths must be used * 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: * Note:
* kicad uses first the bin path lo locace kicad tree. * kicad uses first the bin path lo locate kicad tree.
* if not found kicad uses the environment variable KICAD to find its files * if not found kicad uses the environment variable KICAD to find its files
* and at last kicad uses the default paths. * and at last kicad uses the default paths.
* So we can export (linux and windows) the variable KICAD: * So we can export (linux and windows) the variable KICAD:
...@@ -64,12 +63,17 @@ static wxString s_HelpPathList[] = { ...@@ -64,12 +63,17 @@ static wxString s_HelpPathList[] = {
#else #else
wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/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/doc/help/" ), // default install for "universal
wxT( "/usr/local/kicad/help/" ), // default install for "universal tarballs" and build for a server (old) // tarballs" and build for a server
// (new)
wxT( "/usr/local/kicad/help/" ), // default install for "universal
// tarballs" and build for a server
// (old)
#endif #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 // Path list for kicad data files
static wxString s_KicadDataPathList[] = { static wxString s_KicadDataPathList[] = {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
...@@ -84,10 +88,14 @@ static wxString s_KicadDataPathList[] = { ...@@ -84,10 +88,14 @@ static wxString s_KicadDataPathList[] = {
#else #else
wxT( "/usr/share/kicad/" ), wxT( "/usr/share/kicad/" ),
wxT( "/usr/local/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/share/" ), // default data path for "universal
wxT( "/usr/local/kicad/" ), // default data path for "universal tarballs" and build for a server (old) // tarballs" and build for a server
// (new)
wxT( "/usr/local/kicad/" ), // default data path for "universal
// tarballs" and build for a server
// (old)
#endif #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 // Path list for kicad binary files
...@@ -102,16 +110,10 @@ static wxString s_KicadBinaryPathList[] = { ...@@ -102,16 +110,10 @@ static wxString s_KicadBinaryPathList[] = {
wxT( "/usr/local/bin/" ), wxT( "/usr/local/bin/" ),
wxT( "/usr/local/kicad/bin/" ), wxT( "/usr/local/kicad/bin/" ),
#endif #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 /** Function MakeReducedFileName
* Calculate the "reduced" filename from * Calculate the "reduced" filename from
* @param fullfilename = full filename * @param fullfilename = full filename
...@@ -120,11 +122,14 @@ wxString MakeReducedFileName( const wxString& fullfilename, ...@@ -120,11 +122,14 @@ wxString MakeReducedFileName( const wxString& fullfilename,
* *
* @return the "reduced" filename, i.e.: * @return the "reduced" filename, i.e.:
* without path if it is default_path * without path if it is default_path
* wiht ./ if the path is the current path * with ./ if the path is the current path
* without extension if extension is default_ext * without extension if extension is default_ext
* *
* the new flename is in unix like notation ('/' as path separator) * 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 reduced_filename = fullfilename;
wxString Cwd, ext, path; wxString Cwd, ext, path;
...@@ -175,14 +180,11 @@ wxString MakeReducedFileName( const wxString& fullfilename, ...@@ -175,14 +180,11 @@ wxString MakeReducedFileName( const wxString& fullfilename,
} }
/*******************************************/
void AddDelimiterString( wxString& string )
/*******************************************/
/** Function AddDelimiterString /** Function AddDelimiterString
* Add un " to the start and the end of string (if not already done). * Add un " to the start and the end of string (if not already done).
* @param string = string to modify * @param string = string to modify
*/ */
void AddDelimiterString( wxString& string )
{ {
wxString text; wxString text;
...@@ -199,21 +201,20 @@ void AddDelimiterString( wxString& string ) ...@@ -199,21 +201,20 @@ void AddDelimiterString( wxString& string )
/* Selection Directory dialog box: */ /* Selection Directory dialog box: */
/***********************************/ /***********************************/
bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre */ bool EDA_DirectorySelector( const wxString& Title,
wxString& Path, /* Chemin par defaut */ wxString& Path,
int flag, /* reserve */ int flag,
wxWindow* Frame, /* parent frame */ wxWindow* Frame,
const wxPoint& Pos ) const wxPoint& Pos )
{ {
int ii; int ii;
bool selected = FALSE; bool selected = FALSE;
wxDirDialog* DirFrame = new wxDirDialog( wxDirDialog* DirFrame = new wxDirDialog( Frame,
Frame, wxString( Title ),
wxString( Title ), Path,
Path, /* Chemin par defaut */ flag,
flag, Pos );
Pos );
ii = DirFrame->ShowModal(); ii = DirFrame->ShowModal();
if( ii == wxID_OK ) if( ii == wxID_OK )
...@@ -227,18 +228,24 @@ bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre * ...@@ -227,18 +228,24 @@ bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre *
} }
/******************************/ /* Selection file dialog box:
/* Selection file dialog box: */ * Dialog title
/******************************/ * Default path
* default filename
wxString EDA_FileSelector( const wxString& Title, /* Dialog title */ * default filename extension
const wxString& Path, /* Default path */ * filter for filename list
const wxString& FileName, /* default filename */ * parent frame
const wxString& Ext, /* default filename extension */ * wxFD_SAVE, wxFD_OPEN ..
const wxString& Mask, /* filter for filename list */ * true = keep the current path
wxWindow* Frame, /* parent frame */ */
int flag, /* wxFD_SAVE, wxFD_OPEN ..*/ wxString EDA_FileSelector( const wxString& Title,
const bool keep_working_directory, /* true = keep the current path */ const wxString& Path,
const wxString& FileName,
const wxString& Ext,
const wxString& Mask,
wxWindow* Frame,
int flag,
const bool keep_working_directory,
const wxPoint& Pos ) const wxPoint& Pos )
{ {
wxString fullfilename; wxString fullfilename;
...@@ -255,15 +262,13 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -255,15 +262,13 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
wxSetWorkingDirectory( defaultpath ); wxSetWorkingDirectory( defaultpath );
#if 0 && defined (DEBUG) #if 0 && defined (DEBUG)
printf( printf( "defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
"defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n", CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8( defaultpath ), CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8( defaultname ), CONV_TO_UTF8( Ext ),
CONV_TO_UTF8( Ext ), CONV_TO_UTF8( Mask ),
CONV_TO_UTF8( Mask ), flag,
flag, keep_working_directory );
keep_working_directory
);
#endif #endif
fullfilename = wxFileSelector( wxString( Title ), fullfilename = wxFileSelector( wxString( Title ),
...@@ -282,10 +287,6 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -282,10 +287,6 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
} }
/********************************************************/
wxString FindKicadHelpPath()
/********************************************************/
/** Function FindKicadHelpPath /** Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/<language>") * Find an absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/: * Find path kicad/doc/help/xx/ or kicad/doc/help/:
...@@ -306,6 +307,7 @@ wxString FindKicadHelpPath() ...@@ -306,6 +307,7 @@ wxString FindKicadHelpPath()
* default = en (if not found = fr) * default = en (if not found = fr)
* *
*/ */
wxString FindKicadHelpPath()
{ {
wxString FullPath, LangFullPath, tmp; wxString FullPath, LangFullPath, tmp;
wxString LocaleString; wxString LocaleString;
...@@ -373,10 +375,6 @@ wxString FindKicadHelpPath() ...@@ -373,10 +375,6 @@ wxString FindKicadHelpPath()
} }
/********************************************************/
wxString FindKicadFile( const wxString& shortname )
/********************************************************/
/* Search the executable file shortname in kicad binary path /* Search the executable file shortname in kicad binary path
* and return full file name if found or shortname * and return full file name if found or shortname
* kicad binary path is * kicad binary path is
...@@ -385,20 +383,23 @@ wxString FindKicadFile( const wxString& shortname ) ...@@ -385,20 +383,23 @@ wxString FindKicadFile( const wxString& shortname )
* kicad binary path is found from: * kicad binary path is found from:
* BinDir * BinDir
* or environment variable KICAD * or environment variable KICAD
* or (default) c:\kicad ou /usr/local/kicad * or (default) c:\kicad or /usr/local/kicad
* or default binary path * or default binary path
*/ */
wxString FindKicadFile( const wxString& shortname )
{ {
wxString FullFileName; wxString FullFileName;
/* test de la presence du fichier shortname dans le repertoire de /* Test the presence of the file in the directory shortname of
* des binaires de kicad */ * the kicad binary path.
*/
FullFileName = wxGetApp().m_BinDir + shortname; FullFileName = wxGetApp().m_BinDir + shortname;
if( wxFileExists( FullFileName ) ) if( wxFileExists( FullFileName ) )
return FullFileName; return FullFileName;
/* test de la presence du fichier shortname dans le repertoire /* Test the presence of the file in the directory shortname
* defini par la variable d'environnement KICAD */ * defined by the environment variable KiCAD.
*/
if( wxGetApp().m_Env_Defined ) if( wxGetApp().m_Env_Defined )
{ {
FullFileName = wxGetApp().m_KicadEnv + shortname; FullFileName = wxGetApp().m_KicadEnv + shortname;
...@@ -448,31 +449,29 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, ...@@ -448,31 +449,29 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
} }
/***********************************/ /* Return data path common kicad.
wxString ReturnKicadDatasPath() * If environment variable defined KiCAD (KiCAD = path to kicad)
/***********************************/ * Returns <KICAD> /;
* Otherwise returns <path of binaries> / (if "kicad" is in the path name)
/* Retourne le chemin des donnees communes de kicad. * Otherwise returns / usr / share / 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/
* *
* Remarque: * Note:
* Les \ sont remplac�s par / (a la mode Unix) * The \ are replaced by / (a la Unix)
*/ */
wxString ReturnKicadDatasPath()
{ {
bool PathFound = FALSE; bool PathFound = FALSE;
wxString data_path; 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; data_path = wxGetApp().m_KicadEnv;
PathFound = TRUE; PathFound = TRUE;
} }
else // Chemin cherche par le chemin des executables else // Path of executables.
{ {
// le chemin est bindir../
wxString tmp = wxGetApp().m_BinDir; wxString tmp = wxGetApp().m_BinDir;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
tmp.MakeLower(); tmp.MakeLower();
...@@ -529,26 +528,27 @@ wxString ReturnKicadDatasPath() ...@@ -529,26 +528,27 @@ wxString ReturnKicadDatasPath()
/* /*
* Return the prefered editor name * Return the preferred editor name
*/ */
wxString& WinEDA_App::GetEditorName() wxString& WinEDA_App::GetEditorName()
{ {
wxString editorname = m_EditorName; wxString editorname = m_EditorName;
// We get the prefered editor name from environment variable first. // We get the preferred editor name from environment variable first.
if( editorname.IsEmpty() ) if( editorname.IsEmpty() )
{ {
wxGetEnv( wxT( "EDITOR" ), &editorname ); wxGetEnv( wxT( "EDITOR" ), &editorname );
} }
if( editorname.IsEmpty() ) // We must get a prefered editor name if( editorname.IsEmpty() ) // We must get a preferred 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( "*" ) ); wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
mask += wxT( ".exe" ); mask += wxT( ".exe" );
#endif #endif
editorname = EDA_FileSelector( _( "Prefered Editor:" ), wxEmptyString, editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString,
wxEmptyString, wxEmptyString, mask, wxEmptyString, wxEmptyString, mask,
NULL, wxFD_OPEN, true ); NULL, wxFD_OPEN, true );
} }
...@@ -563,15 +563,12 @@ wxString& WinEDA_App::GetEditorName() ...@@ -563,15 +563,12 @@ wxString& WinEDA_App::GetEditorName()
} }
/***********************************/
bool OpenPDF( const wxString& file )
/***********************************/
/** Function OpenPDF /** Function OpenPDF
* run the PDF viewer and display a PDF file * run the PDF viewer and display a PDF file
* @param file = PDF file to open * @param file = PDF file to open
* @return true is success, false if no PDF viewer found * @return true is success, false if no PDF viewer found
*/ */
bool OpenPDF( const wxString& file )
{ {
wxString command; wxString command;
wxString filename = file; wxString filename = file;
...@@ -579,7 +576,7 @@ bool OpenPDF( const wxString& file ) ...@@ -579,7 +576,7 @@ bool OpenPDF( const wxString& file )
bool success = false; bool success = false;
wxGetApp().ReadPdfBrowserInfos(); wxGetApp().ReadPdfBrowserInfos();
if( !wxGetApp().m_PdfBrowserIsDefault ) // Run the prefered PDF Browser if( !wxGetApp().m_PdfBrowserIsDefault ) // Run the preferred PDF Browser
{ {
AddDelimiterString( filename ); AddDelimiterString( filename );
command = wxGetApp().m_PdfBrowser + wxT( " " ) + filename; command = wxGetApp().m_PdfBrowser + wxT( " " ) + filename;
...@@ -594,7 +591,8 @@ bool OpenPDF( const wxString& file ) ...@@ -594,7 +591,8 @@ bool OpenPDF( const wxString& file )
delete filetype; delete filetype;
#ifndef __WINDOWS__ #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 if( command.StartsWith( wxT( "acroread" ) ) ) // Workaround
success = false; success = false;
#endif #endif
...@@ -661,9 +659,7 @@ bool OpenPDF( const wxString& file ) ...@@ -661,9 +659,7 @@ bool OpenPDF( const wxString& file )
} }
/*************************************/
void OpenFile( const wxString& file ) void OpenFile( const wxString& file )
/*************************************/
{ {
wxString command; wxString command;
wxString filename = file; wxString filename = file;
...@@ -672,7 +668,8 @@ void OpenFile( const wxString& file ) ...@@ -672,7 +668,8 @@ void OpenFile( const wxString& file )
wxString ext, type; wxString ext, type;
ext = CurrentFileName.GetExt(); ext = CurrentFileName.GetExt();
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); wxFileType* filetype =
wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
bool success = false; bool success = false;
......
...@@ -18,59 +18,63 @@ ...@@ -18,59 +18,63 @@
#endif #endif
/* Important Note: /* Important Note:
* These drawing functions clip draw item before send these items to wxDC draw functions. * These drawing functions clip draw item before send these items to wxDC draw
* For guy who aks why i did it, see a sample of problems encounted when pixels * functions. For guy who asks why i did it, see a sample of problems encountered
* when pixels
* coordinates overflow 16 bits values: * coordinates overflow 16 bits values:
* http://trac.wxwidgets.org/ticket/10446 * http://trac.wxwidgets.org/ticket/10446
* Problems can be found under Windows **and** Linux (mainly when drawing arcs) * Problems can be found under Windows **and** Linux (mainly when drawing arcs)
* (mainly at low zoom values (2, 1 or 0.5), in pcbnew) * (mainly at low zoom values (2, 1 or 0.5), in pcbnew)
* some of these problems could be now fixed in recent distributions. * 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) * So before removing clipping functions, be aware these bug (they are not in
* are fixed by testing how are drawn complex lines arcs and solid polygons under Windows and Linux * kicad or wxWidgets) are fixed by testing how are drawn complex lines arcs
* and remember users can have old versions with bugs * 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; int g_XorMode = GR_NXOR;
// couleur de fond de la frame de dessin
// Background color of the design frame
int g_DrawBgColor = WHITE; int g_DrawBgColor = WHITE;
#define USE_CLIP_FILLED_POLYGONS #define USE_CLIP_FILLED_POLYGONS
#ifdef 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 #endif
/* global variables */
extern BASE_SCREEN* ActiveScreen; extern BASE_SCREEN* ActiveScreen;
/* Variables locales */
static int GRLastMoveToX, GRLastMoveToY; static int GRLastMoveToX, GRLastMoveToY;
static int PenMinWidth = 1; /* largeur minimum de la plume (DOIT etre > 0) static int PenMinWidth = 1; /* minimum pen width (must be> 0)
* (utile pour trace sur imprimante) */ * (Useful for printing) */
static bool ForceBlackPen; /* si != 0 : traces en noir (utilise pour trace static bool ForceBlackPen; /* if true: draws in black instead of
* sur imprimante */ * color for printing. */
static int xcliplo = 0, static int xcliplo = 0,
ycliplo = 0, ycliplo = 0,
xcliphi = 2000, xcliphi = 2000,
ycliphi = 2000; /* coord de la surface de trace */ ycliphi = 2000;
static int lastcolor = -1; static int lastcolor = -1;
static int lastwidth = -1; static int lastwidth = -1;
static int s_Last_Pen_Style = -1; static int s_Last_Pen_Style = -1;
static wxDC* lastDC = NULL; static wxDC* lastDC = NULL;
/* /*
* Macro de clipping du trace d'une ligne: * Macro clipping the trace of a line:
* la ligne (x1,y1 x2,y2) est clippee pour rester dans le cadre * Line (x1, y1 x2, y2) is clipped to remain within
* (xcliplo,ycliplo xcliphi,ycliphi) (variables globales,locales a ce fichier) * (Xcliplo, ycliplo xcliphi, ycliphi) (global variables, local to this file)
* Ceci est necessaire sous WIN95 car les coord de trace * This is necessary because under WIN95 coord trace
* (bien que en int 32bits) sont tronquees en 16 bits (stupide BG) * (Though an int 32 bits) are truncated to 16 bits (stupid BG)
*/ */
#ifndef us #ifndef us
#define us unsigned int #define us unsigned int
...@@ -260,9 +264,8 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC, ...@@ -260,9 +264,8 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
} }
/* Routine de forcage de la reinit de la plume courante. /* Forcing a reset of the current pen.
* Doit etre appelee par securite apres changement de contexte graphique * Must be called after changing the graphical device before any trace.
* avant tout trace
*/ */
void GRResetPenAndBrush( wxDC* DC ) void GRResetPenAndBrush( wxDC* DC )
{ {
...@@ -272,7 +275,6 @@ 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 ) void SetPenMinWidth( int minwidth )
{ {
PenMinWidth = minwidth; PenMinWidth = minwidth;
...@@ -319,9 +321,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -319,9 +321,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
} }
/***********************************************/
void GRSetBrush( wxDC* DC, int Color, int fill ) void GRSetBrush( wxDC* DC, int Color, int fill )
/***********************************************/
{ {
if( ForceBlackPen ) if( ForceBlackPen )
Color = BLACK; Color = BLACK;
...@@ -336,65 +336,59 @@ void GRSetBrush( wxDC* DC, int Color, int fill ) ...@@ -336,65 +336,59 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
} }
/*************************************/
void GRForceBlackPen( bool flagforce )
/*************************************/
/** function GRForceBlackPen /** function GRForceBlackPen
* @param flagforce True to force a black pen whenever the asked color * @param flagforce True to force a black pen whenever the asked color
*/ */
void GRForceBlackPen( bool flagforce )
{ {
ForceBlackPen = flagforce; ForceBlackPen = flagforce;
} }
/***********************************/
bool GetGRForceBlackPenState( void )
/***********************************/
/** function GetGRForceBlackPenState /** function GetGRForceBlackPenState
* @return ForceBlackPen (True if a black pen was forced) * @return ForceBlackPen (True if a black pen was forced)
*/ */
bool GetGRForceBlackPenState( void )
{ {
return ForceBlackPen; return ForceBlackPen;
} }
/**********************************************/ /*************************************/
/* Routine pour selectionner le mode de trace */ /* Set the device context draw mode. */
/**********************************************/ /*************************************/
void GRSetDrawMode( wxDC* DC, int draw_mode ) void GRSetDrawMode( wxDC* DC, int draw_mode )
{ {
if( draw_mode & GR_OR ) 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 ); DC->SetLogicalFunction( wxCOPY );
#else #else
DC->SetLogicalFunction( wxOR ); DC->SetLogicalFunction( wxOR );
#endif #endif
else if( draw_mode & GR_XOR ) else if( draw_mode & GR_XOR )
DC->SetLogicalFunction( wxXOR ); DC->SetLogicalFunction( wxXOR );
else if( draw_mode & GR_NXOR ) else if( draw_mode & GR_NXOR )
#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( wxXOR );
DC->SetLogicalFunction( wxXOR );
#else #else
DC->SetLogicalFunction( wxEQUIV );
DC->SetLogicalFunction( wxEQUIV );
#endif #endif
else else
DC->SetLogicalFunction( wxCOPY ); DC->SetLogicalFunction( wxCOPY );
} }
/*********************************************************************/
void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
/*********************************************************************/
{ {
GRSPutPixel( ClipBox, DC, GRMapX( x ), GRMapY( y ), Color ); GRSPutPixel( ClipBox, DC, GRMapX( x ), GRMapY( y ), Color );
} }
/********************************************************************/
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
/********************************************************************/
{ {
if( ClipBox && !ClipBox->Inside( x, y ) ) if( ClipBox && !ClipBox->Inside( x, y ) )
return; return;
...@@ -404,10 +398,6 @@ void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) ...@@ -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 ) int GRGetPixel( wxDC* DC, int x, int y )
{ {
wxColour colour; wxColour colour;
...@@ -430,24 +420,39 @@ int GRGetPixel( wxDC* DC, int x, int y ) ...@@ -430,24 +420,39 @@ int GRGetPixel( wxDC* DC, int x, int y )
} }
/**************************************************************************** /*
* Routine to draw a line, in Object spaces. * * 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 ) 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( GRSLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
width ), Color ); 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 ), GRSLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
ZoomValue( aWidth ), aColor ); 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, void GRSDashedLine( EDA_Rect* ClipBox,
wxDC* DC, wxDC* DC,
int x1, int x1,
...@@ -467,7 +472,12 @@ void GRSDashedLine( EDA_Rect* ClipBox, ...@@ -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; lastcolor = -1;
GRSetColorPen( DC, Color, width, wxSHORT_DASH ); GRSetColorPen( DC, Color, width, wxSHORT_DASH );
...@@ -479,12 +489,18 @@ void GRSDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, in ...@@ -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. * * Draw a dashed line, in object space.
****************************************************************************/ */
void GRDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, int Color ) 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, ...@@ -497,14 +513,14 @@ void GRDashedLine( EDA_Rect* ClipBox,
int width, int width,
int Color ) int Color )
{ {
GRSDashedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRSDashedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
ZoomValue( width ), Color ); 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 ) void GRMoveTo( int x, int y )
{ {
GRLastMoveToX = GRMapX( x ); GRLastMoveToX = GRMapX( x );
...@@ -512,22 +528,28 @@ void GRMoveTo( int x, int y ) ...@@ -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 ) void GRLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color )
{ {
int GRLineToX, GRLineToY; int GRLineToX, GRLineToY;
GRLineToX = GRMapX( x ); GRLineToY = GRMapY( y ); GRLineToX = GRMapX( x ); GRLineToY = GRMapY( y );
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, ZoomValue( GRSLine( ClipBox,
width ), Color ); 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, void GRMixedLine( EDA_Rect* ClipBox,
wxDC* DC, wxDC* DC,
int x1, int x1,
...@@ -537,14 +559,14 @@ void GRMixedLine( EDA_Rect* ClipBox, ...@@ -537,14 +559,14 @@ void GRMixedLine( EDA_Rect* ClipBox,
int width, int width,
int Color ) int Color )
{ {
GRSMixedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRSMixedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
ZoomValue( width ), Color ); 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, void GRSMixedLine( EDA_Rect* ClipBox,
wxDC* DC, wxDC* DC,
int x1, int x1,
...@@ -560,9 +582,9 @@ void GRSMixedLine( EDA_Rect* ClipBox, ...@@ -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 ) void GRSMoveTo( int x, int y )
{ {
GRLastMoveToX = x; GRLastMoveToX = x;
...@@ -570,30 +592,43 @@ void GRSMoveTo( int x, int y ) ...@@ -570,30 +592,43 @@ void GRSMoveTo( int x, int y )
} }
/**************************************************************************** /*
* Routine to draw to a new position, in Screen (pixels) space. * * 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 ) void GRSLineTo( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int width,
int Color )
{ {
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, 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. * * 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 ) 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 ); 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 */ * Move to a new position relative to current one, in object space.
/* space. */ */
/****************************************************************************/
void GRMoveRel( int x, int y ) void GRMoveRel( int x, int y )
{ {
GRLastMoveToX += ZoomValue( x ); GRLastMoveToX += ZoomValue( x );
...@@ -601,11 +636,15 @@ void GRMoveRel( int x, int y ) ...@@ -601,11 +636,15 @@ void GRMoveRel( int x, int y )
} }
/**************************************************************************** /*
* Routine to line to a new position relative to current one, as in Object * * Draw a line to a new position relative to current one, in object space.
* space. * */
****************************************************************************/ void GRLineRel( EDA_Rect* ClipBox,
void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color ) wxDC* DC,
int x,
int y,
int width,
int Color )
{ {
int GRLineToX = GRLastMoveToX, int GRLineToX = GRLastMoveToX,
GRLineToY = GRLastMoveToY; GRLineToY = GRLastMoveToY;
...@@ -613,15 +652,21 @@ void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color ...@@ -613,15 +652,21 @@ void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color
GRLineToX += ZoomValue( x ); GRLineToX += ZoomValue( x );
GRLineToY += ZoomValue( y ); GRLineToY += ZoomValue( y );
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, ZoomValue( GRSLine( ClipBox,
width ), Color ); DC,
GRLastMoveToX,
GRLastMoveToY,
GRLineToX,
GRLineToY,
ZoomValue( width ),
Color );
} }
/**************************************************************************** /*
* Routine to move to a new position relative to current one, as in Screen * * Move to a new position relative to current one, in screen space
* space (pixel coords.). * * (pixel coords.).
****************************************************************************/ */
void GRSMoveRel( int x, int y ) void GRSMoveRel( int x, int y )
{ {
GRLastMoveToX += x; GRLastMoveToX += x;
...@@ -629,50 +674,58 @@ void GRSMoveRel( int x, int y ) ...@@ -629,50 +674,58 @@ void GRSMoveRel( int x, int y )
} }
/**************************************************************************** /*
* Routine to line to a new position relative to current one, as in Screen * * Draw line to a new position relative to current one, in screen space
* space (pixel coords.). * * (pixel coords.).
****************************************************************************/ */
void GRSLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color ) void GRSLineRel( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int width,
int Color )
{ {
long GRLineToX = GRLastMoveToX + x, long GRLineToX = GRLastMoveToX + x,
GRLineToY = GRLastMoveToY + y; GRLineToY = GRLastMoveToY + y;
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, width, Color ); GRSLine( ClipBox,
DC,
GRLastMoveToX,
GRLastMoveToY,
GRLineToX,
GRLineToY,
width,
Color );
GRLastMoveToX = GRLineToX; GRLastMoveToX = GRLineToX;
GRLastMoveToY = GRLineToY; GRLastMoveToY = GRLineToY;
} }
/**************************************************/ /*
/* Routine de trace d'un segment a bouts arrondis */ * Draw segment with rounded ends in object space.
/* Object space = real coords.). */ */
/**************************************************/
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ) int width, int Color )
{ {
GRSCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRSCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
ZoomValue( width ), Color ); GRMapY( y2 ), ZoomValue( width ), Color );
} }
/******************************************************************* /*
* Routine de trace d'un segment (plein) a bouts arrondis in Object * * Draw segment (full) with rounded ends in object space (real coords.).
* space (real coords.). * */
********************************************************************/
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ) int width, int Color )
{ {
GRSFillCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRSFillCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
ZoomValue( width ), Color ); GRMapY( y2 ), ZoomValue( width ), Color );
} }
/**********************************************************/ /*
/* Routine de trace d'un segment (plein) a bouts arrondis */ * Draw segment with rounded ends in screen space.
/* ( Screen space = pixel coords.). */ */
/**********************************************************/
void GRSFillCSegm( EDA_Rect* ClipBox, void GRSFillCSegm( EDA_Rect* ClipBox,
wxDC* DC, wxDC* DC,
int x1, int x1,
...@@ -686,17 +739,23 @@ void GRSFillCSegm( EDA_Rect* ClipBox, ...@@ -686,17 +739,23 @@ void GRSFillCSegm( EDA_Rect* ClipBox,
} }
/****************************************************************/ /*
/* Routine de trace d'un segment a bouts arrondis (Mode SKETCH) */ * Draw segment with rounded ends (SKETCH mode) in screen space
/* Screen space (pixel coords.). */ */
/****************************************************************/ void GRSCSegm( EDA_Rect* ClipBox,
void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ) wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color )
{ {
long rayon; long radius;
int dwx, dwy; int dwx, dwy;
long dx, dy, dwx2, dwy2; long dx, dy, dwx2, dwy2;
long sx1, sy1, ex1, ey1; /* coord du 1er bord */ long sx1, sy1, ex1, ey1;
long sx2, sy2, ex2, ey2; /* coord du 1eme bord */ long sx2, sy2, ex2, ey2;
bool swap_ends = FALSE; bool swap_ends = FALSE;
...@@ -721,7 +780,7 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int ...@@ -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 ); GRSetColorPen( DC, Color, width );
DC->DrawLine( x1, y1, x2, y2 ); 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 ...@@ -731,14 +790,14 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
GRSetColorPen( DC, Color ); GRSetColorPen( DC, Color );
GRSetBrush( DC, Color, FALSE ); GRSetBrush( DC, Color, FALSE );
rayon = (width + 1) >> 1; radius = (width + 1) >> 1;
dx = x2 - x1; dx = x2 - x1;
dy = y2 - y1; dy = y2 - y1;
if( dx == 0 ) /* segment vertical */ if( dx == 0 ) /* segment vertical */
{ {
dwx = rayon; dwx = radius;
if( dy >= 0 ) if( dy >= 0 )
dwx = -dwx; dwx = -dwx;
...@@ -760,7 +819,7 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int ...@@ -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 */ else if( dy == 0 ) /* segment horizontal */
{ {
dwy = rayon; dwy = radius;
if( dx < 0 ) if( dx < 0 )
dwy = -dwy; dwy = -dwy;
...@@ -782,9 +841,9 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int ...@@ -782,9 +841,9 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
} }
else 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( dy < 0 )
{ {
if( dx <= 0 ) if( dx <= 0 )
...@@ -847,7 +906,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] ) ...@@ -847,7 +906,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
Xmin = Xmax = Points[0].x; Xmin = Xmax = Points[0].x;
Ymin = Ymax = Points[0].y; Ymin = Ymax = Points[0].y;
for( int ii = 1; ii < n; ii++ ) // calcul du rectangle d'encadrement for( int ii = 1; ii < n; ii++ ) // calculate rectangle
{ {
Xmin = MIN( Xmin, Points[ii].x ); Xmin = MIN( Xmin, Points[ii].x );
Xmax = MAX( Xmax, Points[ii].x ); Xmax = MAX( Xmax, Points[ii].x );
...@@ -873,11 +932,17 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] ) ...@@ -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. */ * 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, static void GRSPoly( EDA_Rect* ClipBox,
int width, int Color, int BgColor ) wxDC* DC,
int n,
wxPoint Points[],
bool Fill,
int width,
int Color,
int BgColor )
{ {
if( !IsGRSPolyDrawable( ClipBox, n, Points ) ) if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
return; return;
...@@ -889,13 +954,13 @@ static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool ...@@ -889,13 +954,13 @@ static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool
GRSetBrush( DC, BgColor, FILLED ); GRSetBrush( DC, BgColor, FILLED );
/* clip before send the filled polygon to wxDC, because under linux (GTK?) /* clip before send the filled polygon to wxDC, because under linux
* polygonsl having large coordinates are incorrectly drawn * (GTK?) polygons having large coordinates are incorrectly drawn
*/ */
#ifdef USE_CLIP_FILLED_POLYGONS #ifdef USE_CLIP_FILLED_POLYGONS
ClipAndDrawFilledPoly( ClipBox, DC, Points, n ); ClipAndDrawFilledPoly( ClipBox, DC, Points, n );
#else #else
DC->DrawPolygon( n, Points ); //does not work very well under linux DC->DrawPolygon( n, Points ); // does not work very well under linux
#endif #endif
} }
else else
...@@ -913,11 +978,17 @@ static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool ...@@ -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 */ * 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[], static void GRSClosedPoly( EDA_Rect* ClipBox,
bool Fill, int width, int Color, int BgColor ) wxDC* DC,
int aPointCount,
wxPoint aPoints[],
bool Fill,
int width,
int Color,
int BgColor )
{ {
if( !IsGRSPolyDrawable( ClipBox, aPointCount, aPoints ) ) if( !IsGRSPolyDrawable( ClipBox, aPointCount, aPoints ) )
return; return;
...@@ -935,18 +1006,25 @@ static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int aPointCount, wxPoint ...@@ -935,18 +1006,25 @@ static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int aPointCount, wxPoint
GRSetBrush( DC, BgColor ); GRSetBrush( DC, BgColor );
DC->DrawLines( aPointCount, aPoints ); DC->DrawLines( aPointCount, aPoints );
/* Fermeture du polygone */ /* Close the polygon. */
if( aPoints[aPointCount - 1] != aPoints[0] ) if( aPoints[aPointCount - 1] != aPoints[0] )
{ {
GRSLine( ClipBox, DC, aPoints[0].x, aPoints[0].y, GRSLine( ClipBox,
aPoints[aPointCount - 1].x, aPoints[aPointCount - 1].y, width, Color ); DC,
aPoints[0].x,
aPoints[0].y,
aPoints[aPointCount - 1].x,
aPoints[aPointCount - 1].y,
width,
Color );
} }
} }
} }
/* not used /* 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 ) * bool Fill, int Color, int BgColor )
* { * {
* GRSClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, 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 ...@@ -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[], void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, int Color, int BgColor ) bool Fill, int width, int Color, int BgColor )
{ {
...@@ -971,9 +1049,9 @@ void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], ...@@ -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[], void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int Color, int BgColor ) bool Fill, int Color, int BgColor )
{ {
...@@ -995,38 +1073,39 @@ void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], ...@@ -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 ) void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color )
{ {
int cx = GRMapX( x ); int cx = GRMapX( x );
int cy = GRMapY( y ); int cy = GRMapY( y );
int rayon = ZoomValue( r ); int radius = ZoomValue( r );
GRSCircle( ClipBox, DC, cx, cy, rayon, 0, Color ); GRSCircle( ClipBox, DC, cx, cy, radius, 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, void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor ) int width, int Color, int BgColor )
{ {
r = ZoomValue( r ); r = ZoomValue( r );
width = ZoomValue( width ); 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, void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor ) int width, int Color, int BgColor )
{ {
/* suppression des cercles hors ecran */ /* Clip circles off screen. */
if( ClipBox ) if( ClipBox )
{ {
int x0, y0, xm, ym; int x0, y0, xm, ym;
...@@ -1050,10 +1129,16 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, ...@@ -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. */ * Draw a circle in object space.
/***********************************************************/ */
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ) void GRCircle( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int r,
int width,
int Color )
{ {
r = ZoomValue( r ); r = ZoomValue( r );
width = ZoomValue( width ); width = ZoomValue( width );
...@@ -1061,12 +1146,18 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int ...@@ -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. */ * Draw a circle in drawing space.
/***********************************************/ */
void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, int Color ) void GRSCircle( EDA_Rect* ClipBox,
{ wxDC* DC,
/* suppression des cercles hors ecran */ int xc,
int yc,
int r,
int width,
int Color )
{
/* Clip circles off screen. */
if( ClipBox ) if( ClipBox )
{ {
int x0, y0, xm, ym; 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 ...@@ -1074,13 +1165,13 @@ void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, i
y0 = ClipBox->GetY(); y0 = ClipBox->GetY();
xm = ClipBox->GetRight(); xm = ClipBox->GetRight();
ym = ClipBox->GetBottom(); ym = ClipBox->GetBottom();
if( xc < (x0 - r - width) ) if( xc < ( x0 - r - width ) )
return; return;
if( yc < (y0 - r - width) ) if( yc < ( y0 - r - width ) )
return; return;
if( xc > (r + xm + width) ) if( xc > ( r + xm + width ) )
return; return;
if( yc > (r + ym + width) ) if( yc > ( r + ym + width ) )
return; return;
} }
...@@ -1090,40 +1181,36 @@ void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, i ...@@ -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. */ * Draw an arc in user space.
/* Debut et fin de l'arc donnes par leur coord. */ */
/************************************************/
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int Color ) int xc, int yc, int Color )
{ {
GRSArc1( ClipBox, DC, GRSArc1( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRMapY( y2 ), GRMapX( xc ), GRMapY( yc ), 0, Color );
GRMapX( xc ), GRMapY( yc ), 0, Color );
} }
/************************************************/ /*
/* Routine to draw an arc, width = width in USER space. */ * Draw an arc, width = width in user space.
/* Debut et fin de l'arc donnes par leur coord. */ */
/************************************************/
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color ) int xc, int yc, int width, int Color )
{ {
GRSArc1( ClipBox, DC, GRSArc1( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), GRMapY( y2 ), GRMapY( y2 ), GRMapX( xc ), GRMapY( yc ), ZoomValue( width ),
GRMapX( xc ), GRMapY( yc ), ZoomValue( width ), Color ); Color );
} }
/************************************************/ /*
/* Routine to draw an arc, width = width, in screen space. */ * Draw an arc, width = width, in screen space.
/* Debut et fin de l'arc donnes par leur coord. */ */
/************************************************/
void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color ) int xc, int yc, int width, int Color )
{ {
/* suppression des cercles hors ecran */ /* Clip arcs off screen. */
if( ClipBox ) if( ClipBox )
{ {
int x0, y0, xm, ym, r; 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, ...@@ -1132,13 +1219,13 @@ void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
xm = ClipBox->GetRight(); xm = ClipBox->GetRight();
ym = ClipBox->GetBottom(); ym = ClipBox->GetBottom();
r = (int) hypot( x1 - xc, y1 - yc ); r = (int) hypot( x1 - xc, y1 - yc );
if( xc < (x0 - r) ) if( xc < ( x0 - r ) )
return; return;
if( yc < (y0 - r) ) if( yc < ( y0 - r ) )
return; return;
if( xc > (r + xm) ) if( xc > ( r + xm ) )
return; return;
if( yc > (r + ym) ) if( yc > ( r + ym ) )
return; return;
} }
...@@ -1148,16 +1235,22 @@ void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -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. */ * Draw an arc in screen space.
/* As the Y axe is inverted the Angles should be inverted as well. */ */
/********************************************************************/ void GRSArc( EDA_Rect* ClipBox,
void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAngle, wxDC* DC,
int r, int width, int Color ) int xc,
int yc,
int StAngle,
int EndAngle,
int r,
int width,
int Color )
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
/* suppression des cercles hors ecran */ /* Clip arcs off screen. */
if( ClipBox ) if( ClipBox )
{ {
int x0, y0, xm, ym; int x0, y0, xm, ym;
...@@ -1165,20 +1258,22 @@ void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAn ...@@ -1165,20 +1258,22 @@ void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAn
y0 = ClipBox->GetY(); y0 = ClipBox->GetY();
xm = ClipBox->GetRight(); xm = ClipBox->GetRight();
ym = ClipBox->GetBottom(); ym = ClipBox->GetBottom();
if( xc < (x0 - r - width) ) if( xc < ( x0 - r - width ) )
return; return;
if( yc < (y0 - r - width) ) if( yc < ( y0 - r - width ) )
return; return;
if( xc > (r + xm + width) ) if( xc > ( r + xm + width ) )
return; return;
if( yc > (r + ym + width) ) if( yc > ( r + ym + width ) )
return; return;
} }
x1 = r; y1 = 0; x1 = r;
y1 = 0;
RotatePoint( &x1, &y1, EndAngle ); RotatePoint( &x1, &y1, EndAngle );
x2 = r; y2 = 0; x2 = r;
y2 = 0;
RotatePoint( &x2, &y2, StAngle ); RotatePoint( &x2, &y2, StAngle );
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
...@@ -1187,16 +1282,23 @@ void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, int EndAn ...@@ -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. */ * 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,
void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, wxDC* DC,
int StAngle, int EndAngle, int r, int width, int Color, int BgColor ) int xc,
int yc,
int StAngle,
int EndAngle,
int r,
int width,
int Color,
int BgColor )
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
/* suppression des cercles hors ecran */ /* Clip arcs off screen */
if( ClipBox ) if( ClipBox )
{ {
int x0, y0, xm, ym; int x0, y0, xm, ym;
...@@ -1204,20 +1306,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, ...@@ -1204,20 +1306,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc,
y0 = ClipBox->GetY(); y0 = ClipBox->GetY();
xm = ClipBox->GetRight(); xm = ClipBox->GetRight();
ym = ClipBox->GetBottom(); ym = ClipBox->GetBottom();
if( xc < (x0 - r - 1) ) if( xc < ( x0 - r - 1 ) )
return; return;
if( yc < (y0 - r - 1) ) if( yc < ( y0 - r - 1 ) )
return; return;
if( xc > (r + xm + 1) ) if( xc > ( r + xm + 1 ) )
return; return;
if( yc > (r + ym + 1) ) if( yc > ( r + ym + 1 ) )
return; return;
} }
x1 = r; y1 = 0; x1 = r;
y1 = 0;
RotatePoint( &x1, &y1, EndAngle ); RotatePoint( &x1, &y1, EndAngle );
x2 = r; y2 = 0; x2 = r;
y2 = 0;
RotatePoint( &x2, &y2, StAngle ); RotatePoint( &x2, &y2, StAngle );
GRSetBrush( DC, BgColor, FILLED ); GRSetBrush( DC, BgColor, FILLED );
...@@ -1226,16 +1330,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, ...@@ -1226,16 +1330,22 @@ void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc,
} }
/********************************************************************/ /*
/* Routine to draw a Filled arc, in drawing space. */ * 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,
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, wxDC* DC,
int StAngle, int EndAngle, int r, int width, int Color, int BgColor ) int x,
int y,
int StAngle,
int EndAngle,
int r,
int width,
int Color,
int BgColor )
{ {
width = ZoomValue( width ); width = ZoomValue( width );
GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
StAngle, EndAngle,
ZoomValue( r ), width, Color, BgColor ); ZoomValue( r ), width, Color, BgColor );
} }
...@@ -1243,126 +1353,155 @@ void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, ...@@ -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, void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y,
int StAngle, int EndAngle, int r, int Color, int BgColor ) int StAngle, int EndAngle, int r, int Color, int BgColor )
{ {
GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
StAngle, EndAngle,
ZoomValue( r ), 0, Color, BgColor ); ZoomValue( r ), 0, Color, BgColor );
} }
/********************************************************************/ /*
/* Routine to draw an arc, in drawing space. */ * Draw an arc in drawing space.
/* As the Y axes is inverted the Angles should be inverted as well. */ */
/********************************************************************/
void GRArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle, void GRArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle,
int EndAngle, int r, int Color ) int EndAngle, int r, int Color )
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
/* suppression des cercles hors ecran */ /* Clip arcs off screen */
if( ClipBox ) if( ClipBox )
{ {
int rayon = ZoomValue( r ) + 1; int radius = ZoomValue( r ) + 1;
int x0, y0, xm, ym, x, y; int x0, y0, xm, ym, x, y;
x0 = ClipBox->GetX(); x0 = ClipBox->GetX();
y0 = ClipBox->GetY(); y0 = ClipBox->GetY();
xm = ClipBox->GetRight(); xm = ClipBox->GetRight();
ym = ClipBox->GetBottom(); ym = ClipBox->GetBottom();
x = GRMapX( xc ); y = GRMapY( yc ); x = GRMapX( xc ); y = GRMapY( yc );
if( x < (x0 - rayon) ) if( x < ( x0 - radius ) )
return; return;
if( y < (y0 - rayon) ) if( y < ( y0 - radius ) )
return; return;
if( x > (xm + rayon) ) if( x > ( xm + radius ) )
return; return;
if( y > (ym + rayon) ) if( y > ( ym + radius ) )
return; return;
} }
x1 = r; y1 = 0; x1 = r;
y1 = 0;
RotatePoint( &x1, &y1, EndAngle ); RotatePoint( &x1, &y1, EndAngle );
x2 = r; y2 = 0; x2 = r;
y2 = 0;
RotatePoint( &x2, &y2, StAngle ); RotatePoint( &x2, &y2, StAngle );
GRSetColorPen( DC, Color ); GRSetColorPen( DC, Color );
GRSetBrush( DC, Color, FALSE ); GRSetBrush( DC, Color, FALSE );
DC->DrawArc( GRMapX( xc + x1 ), GRMapY( yc - y1 ), DC->DrawArc( GRMapX( xc + x1 ), GRMapY( yc - y1 ), GRMapX( xc + x2 ),
GRMapX( xc + x2 ), GRMapY( yc - y2 ), GRMapY( yc - y2 ), GRMapX( xc ), GRMapY( yc ) );
GRMapX( xc ), GRMapY( yc ) );
} }
/********************************************************************/ /*
/* Routine to draw an arc, width = width, in drawing space. */ * Draw an arc with width = width in drawing space.
/* As the Y axes is inverted the Angles should be inverted as well. */ */
/********************************************************************/ void GRArc( EDA_Rect* ClipBox,
void GRArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle, int EndAngle, wxDC* DC,
int r, int width, int Color ) int x,
int y,
int StAngle,
int EndAngle,
int r,
int width,
int Color )
{ {
GRSArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), GRSArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
StAngle, EndAngle, ZoomValue( r ), ZoomValue( width ), Color );
ZoomValue( r ),
ZoomValue( width ),
Color );
} }
/**************************************************/ /*
/* Routine to draw a Rectangle, in drawing space. */ * Draw a rectangle in drawing space.
/**************************************************/ */
void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int Color ) void GRRect( EDA_Rect* ClipBox,
{ wxDC* DC,
x1 = GRMapX( x1 ); y1 = GRMapY( y1 ); int x1,
x2 = GRMapX( x2 ); y2 = GRMapY( y2 ); 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 ); GRSRect( ClipBox, DC, x1, y1, x2, y2, Color );
} }
/**************************************************/ /*
/* Routine to draw a Rectangle, in drawing space. */ * 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 ) void GRRect( EDA_Rect* ClipBox,
{ wxDC* DC,
x1 = GRMapX( x1 ); y1 = GRMapY( y1 ); int x1,
x2 = GRMapX( x2 ); y2 = GRMapY( y2 ); 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 ); width = ZoomValue( width );
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color ); 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, void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int Color, int BgColor ) int Color, int BgColor )
/************************************************************************************/
/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */
{ {
x1 = GRMapX( x1 ); y1 = GRMapY( y1 ); x1 = GRMapX( x1 );
x2 = GRMapX( x2 ); y2 = GRMapY( y2 ); y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor ); 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, void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color, int BgColor ) int width, int Color, int BgColor )
/************************************************************************************/
/* Routine to draw a Rectangle (filled with AreaColor), in drawing space. */
{ {
x1 = GRMapX( x1 ); y1 = GRMapY( y1 ); x1 = GRMapX( x1 );
x2 = GRMapX( x2 ); y2 = GRMapY( y2 ); y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
width = ZoomValue( width ); width = ZoomValue( width );
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor ); GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
} }
/*************************************************/ /*
/* Routine to draw a Rectangle, in screen space. */ * Draw a rectangle in screen space.
/*************************************************/ */
void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int Color ) 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 ); 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, ...@@ -1376,7 +1515,6 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
if( y1 > y2 ) if( y1 > y2 )
EXCHG( y1, y2 ); EXCHG( y1, y2 );
/* Clipping des coordonnees */
if( ClipBox ) if( ClipBox )
{ {
int xmin = ClipBox->GetX(); int xmin = ClipBox->GetX();
...@@ -1395,7 +1533,7 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -1395,7 +1533,7 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
} }
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
if( (x1 == x2) || (y1 == y2) ) if( ( x1 == x2 ) || ( y1 == y2 ) )
DC->DrawLine( x1, y1, x2, y2 ); DC->DrawLine( x1, y1, x2, y2 );
else else
{ {
...@@ -1405,20 +1543,31 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -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. */ /*
/***************************************************************************************/ * 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 ) 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 ); GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
} }
/***************************************************************************************/ void GRSFilledRect( EDA_Rect* ClipBox,
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, wxDC* DC,
int width, int Color, int BgColor ) int x1,
/***************************************************************************************/ int y1,
int x2,
int y2,
int width,
int Color,
int BgColor )
{ {
if( x1 > x2 ) if( x1 > x2 )
EXCHG( x1, x2 ); EXCHG( x1, x2 );
...@@ -1452,7 +1601,7 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -1452,7 +1601,7 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
} }
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
if( (x1 == x2) || (y1 == y2) ) if( ( x1 == x2 ) || ( y1 == y2 ) )
DC->DrawLine( x1, y1, x2, y2 ); DC->DrawLine( x1, y1, x2, y2 );
else else
{ {
...@@ -1466,14 +1615,17 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -1466,14 +1615,17 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
/** Function ClipAndDrawFilledPoly /** Function ClipAndDrawFilledPoly
* Used to clip a polygon and draw it as Filled Polygon * 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. * uses the Sutherland and Hodgman algo to clip the given poly against a
* This rectangle is the drawing area * rectangle. This rectangle is the drawing area this is useful under
* this is useful under Linux (2009) because filled polygons are incorrectly drawn * Linux (2009) because filled polygons are incorrectly drawn if they have
* if they have too large coordinates (seems due to integer overflows in calculations) * too large coordinates (seems due to integer overflows in calculations)
* Could be removed in some years, if become unnecesary. * Could be removed in some years, if become unnecessary.
*/ */
#include "SutherlandHodgmanClipPoly.h" #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 vector<wxPoint> clippedPolygon;
static pointVector inputPolygon, outputPolygon; static pointVector inputPolygon, outputPolygon;
...@@ -1482,24 +1634,31 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPoints[], in ...@@ -1482,24 +1634,31 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPoints[], in
outputPolygon.clear(); outputPolygon.clear();
clippedPolygon.clear(); clippedPolygon.clear();
for( int ii = 0; ii < n; ii++ ) 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(), RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
(REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() ); (REAL) aClipBox->GetWidth(),
(REAL) aClipBox->GetHeight() );
SutherlandHodgman sh( window ); SutherlandHodgman sh( window );
sh.Clip( inputPolygon, outputPolygon ); 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] ); aDC->DrawPolygon( clippedPolygon.size(), &clippedPolygon[0] );
} }
#endif #endif
void GRBezier( EDA_Rect* ClipBox, void GRBezier( EDA_Rect* ClipBox,
wxDC* DC, wxDC* DC,
int x1, int x1,
......
...@@ -27,6 +27,7 @@ wxString g_LibEditSectionTag( wxT( "[libedit]" ) ); ...@@ -27,6 +27,7 @@ wxString g_LibEditSectionTag( wxT( "[libedit]" ) );
wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) ); wxString g_BoardEditorSectionTag( wxT( "[pcbnew]" ) );
wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) ); wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) );
/* 0 = files are in Home directory (usefull under unix) /* 0 = files are in Home directory (usefull under unix)
* 1 = kicad/template ( usefull only under windows ) * 1 = kicad/template ( usefull only under windows )
* 2 ... = unused * 2 ... = unused
...@@ -35,15 +36,20 @@ int g_ConfigFileLocationChoice; ...@@ -35,15 +36,20 @@ int g_ConfigFileLocationChoice;
/* Class to handle hotkey commnands. hotkeys have a default value /* 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_InfoMsg = infomsg; // info message.
m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) m_Idcommand = idcommand; // internal id for the corresponding
m_IdMenuEvent = idmenuevent; // id to call the corresponding event (if any) (see id.h) // 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[] = ...@@ -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 * 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) * @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name in a wxString * @return the key name in a wxString
*/ */
wxString ReturnKeyNameFromKeyCode( int keycode )
{ {
wxString keyname, modifier, fullkeyname; wxString keyname, modifier, fullkeyname;
int ii; int ii;
...@@ -177,7 +181,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) ...@@ -177,7 +181,7 @@ wxString ReturnKeyNameFromKeyCode( int keycode )
if( (keycode & GR_KB_SHIFT) != 0 ) if( (keycode & GR_KB_SHIFT) != 0 )
modifier << wxT( "Shift " ); 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++ ) for( ii = 0; ; ii++ )
{ {
if( s_Hotkey_Name_List[ii].m_KeyCode == 0 ) if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
...@@ -197,16 +201,14 @@ wxString ReturnKeyNameFromKeyCode( int keycode ) ...@@ -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) * Add the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands * @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value * @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification * @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 msg = text;
wxString keyname = ReturnKeyNameFromCommandId( List, CommandId ); wxString keyname = ReturnKeyNameFromCommandId( List, CommandId );
...@@ -217,18 +219,16 @@ wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandI ...@@ -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) * 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 * @param CommandId = Command Id value
* @return text (key name) in a wxString if found or text without modification * @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 msg = text;
wxString keyname; wxString keyname;
...@@ -249,16 +249,13 @@ wxString AddHotkeyName( const wxString& text, ...@@ -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) * return the key name from the Command id value ( m_Idcommand member value)
* @param List = pointer to a Ki_HotkeyInfo list of commands * @param List = pointer to a Ki_HotkeyInfo list of commands
* @param CommandId = Command Id value * @param CommandId = Command Id value
* @return the key name in a wxString * @return the key name in a wxString
*/ */
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId )
{ {
wxString keyname; wxString keyname;
...@@ -276,16 +273,14 @@ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId ) ...@@ -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 * return the key code from its key name
* Only some wxWidgets key values are handled for function key * 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 * @return the key code
*/ */
static int ReturnKeyCodeFromKeyName( const wxString& keyname )
{ {
int ii, keycode = 0; int ii, keycode = 0;
...@@ -305,16 +300,15 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname ) ...@@ -305,16 +300,15 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
} }
/********************************************************************************************/
void DisplayHotkeyList( WinEDA_DrawFrame* frame, struct Ki_HotkeyInfoSectionDescriptor* DescList )
/***************************************************************************************/
/* /*
* Displays the current hotkey list * Displays the current hotkey list
* @param frame = current active frame * @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 * @return none
*/ */
void DisplayHotkeyList( WinEDA_DrawFrame* frame,
struct Ki_HotkeyInfoSectionDescriptor* DescList )
{ {
wxString keyname; wxString keyname;
Ki_HotkeyInfo** List; Ki_HotkeyInfo** List;
...@@ -337,16 +331,13 @@ void DisplayHotkeyList( WinEDA_DrawFrame* frame, struct Ki_HotkeyInfoSectionDesc ...@@ -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 * 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 key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands * @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++ ) for( ; *List != NULL; List++ )
{ {
...@@ -359,20 +350,19 @@ Ki_HotkeyInfo* GetDescriptorFromHotkey( int key, Ki_HotkeyInfo** 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 * 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. * @param List = pointer to the current hotkey list.
* the ouput format is: shortcut "key" "function" * the ouput format is: shortcut "key" "function"
* lines starting with # are comments * lines starting with # are comments
* *
*/ */
int WinEDA_BasicFrame::WriteHotkeyConfigFile(
const wxString& Filename,
struct Ki_HotkeyInfoSectionDescriptor* DescList,
bool verbose )
{ {
wxString FullFilename = Filename; wxString FullFilename = Filename;
FILE* cfgfile; FILE* cfgfile;
...@@ -385,15 +375,15 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& ...@@ -385,15 +375,15 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString&
Mask = wxT( "*." ) + Ext; Mask = wxT( "*." ) + Ext;
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFilename = EDA_FileSelector( _( "Save Hotkey Configuration File:" ), FullFilename = EDA_FileSelector( _( "Save Hotkey Configuration File:" ),
Path, /* Chemin par defaut */ Path,
FullFilename, /* nom fichier par defaut */ FullFilename,
Ext, /* extension par defaut */ Ext,
Mask, /* Masque d'affichage */ Mask,
this, this,
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE );
);
} }
if( FullFilename.IsEmpty() ) if( FullFilename.IsEmpty() )
return 0; return 0;
...@@ -474,21 +464,22 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& ...@@ -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 * Read a configuration file (<file>.key) and fill the current hotkey list
* @param Filename = default full file name to create. If void, A filename will be asked * 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. * @param DescList = current hotkey list descr. to initialise.
* the input format is: shortcut "key" "function" * the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments) * 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; wxString FullFilename = Filename;
FILE* cfgfile; FILE* cfgfile;
...@@ -501,14 +492,13 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& ...@@ -501,14 +492,13 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
Mask = wxT( "*." ) + Ext; Mask = wxT( "*." ) + Ext;
Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFilename = EDA_FileSelector( _( "Open Hotkey Configuration File:" ), FullFilename = EDA_FileSelector( _( "Open Hotkey Configuration File:" ),
Path, /* Chemin par defaut */ Path,
FullFilename, /* nom fichier par defaut */ FullFilename,
Ext, /* extension par defaut */ Ext,
Mask, /* Masque d'affichage */ Mask,
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE TRUE );
);
if( FullFilename.IsEmpty() ) if( FullFilename.IsEmpty() )
return 0; return 0;
} }
...@@ -590,13 +580,10 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& ...@@ -590,13 +580,10 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
} }
/****************************************************/
wxString ReturnHotkeyConfigFilePath( int choice )
/****************************************************/
/* return the hotkey config file path /* return the hotkey config file path
* @param choice : 0 = home, 1 = kicad/share/template * @param choice : 0 = home, 1 = kicad/share/template
*/ */
wxString ReturnHotkeyConfigFilePath( int choice )
{ {
wxString path; wxString path;
wxAppTraits* traits = wxGetApp().GetTraits(); wxAppTraits* traits = wxGetApp().GetTraits();
...@@ -625,13 +612,10 @@ wxString ReturnHotkeyConfigFilePath( int choice ) ...@@ -625,13 +612,10 @@ wxString ReturnHotkeyConfigFilePath( int choice )
} }
/***************************************/
void AddHotkeyConfigMenu( wxMenu* menu )
/***************************************/
/** add hotkey config options submenu to a menu /** add hotkey config options submenu to a menu
* @param menu : initial menu * @param menu : initial menu
*/ */
void AddHotkeyConfigMenu( wxMenu* menu )
{ {
wxMenuItem* item; wxMenuItem* item;
wxMenu* HotkeySubmenu = new wxMenu(); wxMenu* HotkeySubmenu = new wxMenu();
...@@ -640,7 +624,8 @@ void AddHotkeyConfigMenu( wxMenu* menu ) ...@@ -640,7 +624,8 @@ void AddHotkeyConfigMenu( wxMenu* menu )
return; return;
/* Show hotkey configuration */ /* 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" ),
_( "Show the current hotkey configuration" ) ); _( "Show the current hotkey configuration" ) );
item->SetBitmap( info_xpm ); item->SetBitmap( info_xpm );
...@@ -678,41 +663,39 @@ void AddHotkeyConfigMenu( wxMenu* menu ) ...@@ -678,41 +663,39 @@ void AddHotkeyConfigMenu( wxMenu* menu )
wxMenu* HotkeyLocationSubmenu = new wxMenu(); wxMenu* HotkeyLocationSubmenu = new wxMenu();
/* Home directory */ /* Home directory */
item = new wxMenuItem( HotkeyLocationSubmenu, ID_PREFERENCES_HOTKEY_PATH_IS_HOME, item = new wxMenuItem( HotkeyLocationSubmenu,
ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
_( "Home directory" ), _( "Home directory" ),
_( "Use home directory to load or store Hotkey config files" ), _( "Use home directory to load or store Hotkey config files" ),
wxITEM_CHECK ); wxITEM_CHECK );
HotkeyLocationSubmenu->Append( item ); HotkeyLocationSubmenu->Append( item );
/* KiCad template directory */ /* KiCad template directory */
item = new wxMenuItem( HotkeyLocationSubmenu, ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, item = new wxMenuItem( HotkeyLocationSubmenu,
ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
_( "KiCad template directory" ), _( "KiCad template directory" ),
_( "Use kicad/template directory to load or store Hotkey config files" ), _( "Use kicad/template directory to load or store Hotkey config files" ),
wxITEM_CHECK ); wxITEM_CHECK );
HotkeyLocationSubmenu->Append( item ); HotkeyLocationSubmenu->Append( item );
/* Append location submenu to HotkeySubmenu */ /* Append location submenu to HotkeySubmenu */
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( ADD_MENUITEM_WITH_HELP_AND_SUBMENU( HotkeySubmenu, HotkeyLocationSubmenu,
HotkeySubmenu, HotkeyLocationSubmenu, -1, -1, _( "Location" ),
_( "Location" ), _( "Select hotkey configuration file location" ),
_( "Select hotkey configuration file location" ), right_xpm );
right_xpm );
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
g_ConfigFileLocationChoice == 0 ); g_ConfigFileLocationChoice == 0 );
HotkeyLocationSubmenu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, 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 /* called on hotkey file location selecton menu
* @param frame = current WinEDA_DrawFrame * @param frame = current WinEDA_DrawFrame
* @param id = selected menu id * @param id = selected menu id
* @return g_ConfigFileLocationChoice (global) = new selection * @return g_ConfigFileLocationChoice (global) = new selection
*/ */
void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
{ {
wxMenuBar* menu = frame->GetMenuBar(); wxMenuBar* menu = frame->GetMenuBar();
......
/******************************************************************/ /****************/
/* msgpanel.cpp - fonctions des classes du type WinEDA_MsgPanel */ /* msgpanel.cpp */
/******************************************************************/ /****************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -12,16 +12,11 @@ ...@@ -12,16 +12,11 @@
#include "colors.h" #include "colors.h"
/* table des evenements captes par un WinEDA_MsgPanel */
BEGIN_EVENT_TABLE( WinEDA_MsgPanel, wxPanel ) BEGIN_EVENT_TABLE( WinEDA_MsgPanel, wxPanel )
EVT_PAINT( WinEDA_MsgPanel::OnPaint ) EVT_PAINT( WinEDA_MsgPanel::OnPaint )
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************************/
/* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */
/***********************************************************/
WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id, WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id,
const wxPoint& pos, const wxSize& size ) : const wxPoint& pos, const wxSize& size ) :
wxPanel( parent, id, pos, size ) wxPanel( parent, id, pos, size )
...@@ -75,9 +70,7 @@ wxSize WinEDA_MsgPanel::computeTextSize( const wxString& text ) ...@@ -75,9 +70,7 @@ wxSize WinEDA_MsgPanel::computeTextSize( const wxString& text )
} }
/*************************************************/
void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
/*************************************************/
{ {
wxPaintDC dc( this ); wxPaintDC dc( this );
...@@ -128,22 +121,18 @@ void WinEDA_MsgPanel::AppendMessage( const wxString& textUpper, ...@@ -128,22 +121,18 @@ void WinEDA_MsgPanel::AppendMessage( const wxString& textUpper,
Refresh(); 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. * Display a parameter in message panel.
* pos_X = cadrage horizontal * pos_X = horizontal position
* si pos_X < 0 : la position horizontale est la derniere * If pos_X < 0: horizontal position is the last
* valeur demandee >= 0 * Required value >= 0
* texte_H = texte a afficher en ligne superieure. * Texte_H = text to be displayed in top line.
* si "", par d'affichage sur cette ligne * Texte_L = text to be displayed in bottom line.
* texte_L = texte a afficher en ligne inferieure. * Color = color display
* si "", par d'affichage sur cette ligne
* color = couleur d'affichage
*/ */
void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
const wxString& texte_L, int color )
{ {
wxPoint pos; wxPoint pos;
wxSize drawSize = GetClientSize(); wxSize drawSize = GetClientSize();
...@@ -181,12 +170,12 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, ...@@ -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 ) 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; 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 ); m_Items.push_back( item );
} }
...@@ -219,18 +208,14 @@ void WinEDA_MsgPanel::showItem( wxDC& dc, const MsgItem& aItem ) ...@@ -219,18 +208,14 @@ void WinEDA_MsgPanel::showItem( wxDC& dc, const MsgItem& aItem )
} }
/****************************************/
void WinEDA_MsgPanel::EraseMsgBox() void WinEDA_MsgPanel::EraseMsgBox()
/****************************************/
{ {
m_Items.clear(); m_Items.clear();
m_last_x = 0; m_last_x = 0;
Refresh(); Refresh();
} }
/*******************************************/
void WinEDA_MsgPanel::erase( wxDC* DC ) void WinEDA_MsgPanel::erase( wxDC* DC )
/*******************************************/
{ {
wxPen pen; wxPen pen;
wxBrush brush; wxBrush brush;
......
...@@ -59,8 +59,10 @@ int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { ...@@ -59,8 +59,10 @@ int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
wxString g_ViaType_Name[4] = { wxString g_ViaType_Name[4] = {
_( "??? Via" ), // Not used yet _( "??? Via" ), // Not used yet
_( "Micro Via" ), // from external layer (TOP or BOTTOM) from the near neightbour inner layer only _( "Micro Via" ), // from external layer (TOP or BOTTOM) from
_( "Blind/Buried Via" ), // from inner or external to inner or external layer (no restriction) // 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 ) _( "Through Via" ) // Usual via (from TOP to BOTTOM layer only )
}; };
...@@ -86,7 +88,7 @@ const wxString PcbFileWildcard( ...@@ -86,7 +88,7 @@ const wxString PcbFileWildcard(
int g_CurrentVersionPCB = 1; int g_CurrentVersionPCB = 1;
/* variables generales */
int g_TimeOut; // Timer for automatic saving int g_TimeOut; // Timer for automatic saving
int g_SaveTime; // Time for next saving int g_SaveTime; // Time for next saving
...@@ -97,7 +99,8 @@ int g_ModuleTextNOVColor = DARKGRAY; ...@@ -97,7 +99,8 @@ int g_ModuleTextNOVColor = DARKGRAY;
int g_PadCUColor = GREEN; int g_PadCUColor = GREEN;
int g_PadCMPColor = RED; int g_PadCMPColor = RED;
// Current designe settings:
// Current design settings:
class EDA_BoardDesignSettings g_DesignSettings; class EDA_BoardDesignSettings g_DesignSettings;
/** /**
...@@ -116,13 +119,13 @@ int g_GridRoutingSize = 250; ...@@ -116,13 +119,13 @@ int g_GridRoutingSize = 250;
bool g_Zone_45_Only = FALSE; bool g_Zone_45_Only = FALSE;
/* HPGL plot settings. */ /* HPGL plot settings. */
int g_HPGL_Pen_Num = 1; /* num de plume a charger */ int g_HPGL_Pen_Num = 1; /* pen number */
int g_HPGL_Pen_Speed = 40; /* vitesse en cm/s */ int g_HPGL_Pen_Speed = 40; /* speed in cm/s */
int g_HPGL_Pen_Diam; /* diametre en mils */ int g_HPGL_Pen_Diam; /* diameter in mils */
int g_HPGL_Pen_Recouvrement; /* recouvrement en mils ( pour remplissages */ int g_HPGL_Pen_Recouvrement; /* recovery in mils ( for filling ) */
float Scale_X; float Scale_X;
float Scale_Y; /* coeff d'agrandissement en X et Y demandes */ float Scale_Y; /* scale factor in X and Y axis */
int PlotMarge; int PlotMarge;
int g_PlotLine_Width; int g_PlotLine_Width;
......
/**************************************************/ /*********************/
/* projet_config : routines de trace du cartouche */ /* projet_config.cpp */
/**************************************************/ /*********************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
/** /**
* Cree ou recree la configuration locale de kicad (filename.pro) * Creates or recreates the kicad project file. (filename.pro)
* initialise: * Initialize:
* g_Prj_Config * G_Prj_Config
* g_Prj_Config_LocalFilename * G_Prj_Config_LocalFilename
* g_Prj_Default_Config_FullFilename * G_Prj_Default_Config_FullFilename
* return: * Return:
* true si config locale * True if local config
* false si default config * False if default config
*/ */
bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
...@@ -49,7 +49,7 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, ...@@ -49,7 +49,7 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
/* Check the file name does not a kicad project extension. /* Check the file name does not a kicad project extension.
* This allows the user to enter a filename without extension * This allows the user to enter a filename without extension
* or use an existing name to create te project file * or use an existing name to create te project file
*/ */
if( fn.GetExt() != ProjectFileExtension ) if( fn.GetExt() != ProjectFileExtension )
{ {
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
...@@ -133,9 +133,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, ...@@ -133,9 +133,9 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG ); ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write date ( surtout pour eviter bug de wxFileConfig /* Write time (especially to avoid bug wxFileConfig that writes the
* qui se trompe de rubrique si declaration [xx] en premiere ligne * wrong item if declaration [xx] in first line (If empty group)
* (en fait si groupe vide) */ */
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
msg = DateAndTime(); msg = DateAndTime();
...@@ -145,7 +145,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, ...@@ -145,7 +145,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig->Write( wxT( "last_client" ), msg ); m_ProjectConfig->Write( wxT( "last_client" ), msg );
/* Save parameters */ /* Save parameters */
m_ProjectConfig->DeleteGroup( GroupName ); // Erase all datas m_ProjectConfig->DeleteGroup( GroupName ); // Erase all data
m_ProjectConfig->Flush(); m_ProjectConfig->Flush();
m_ProjectConfig->SetPath( GroupName ); m_ProjectConfig->SetPath( GroupName );
...@@ -193,7 +193,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, ...@@ -193,7 +193,7 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig->Write( wxT( "last_client" ), GetAppName() ); m_ProjectConfig->Write( wxT( "last_client" ), GetAppName() );
/* Save parameters */ /* Save parameters */
m_ProjectConfig->DeleteGroup( GroupName ); // Erase all datas m_ProjectConfig->DeleteGroup( GroupName ); // Erase all data
m_ProjectConfig->Flush(); m_ProjectConfig->Flush();
m_ProjectConfig->SetPath( GroupName ); m_ProjectConfig->SetPath( GroupName );
...@@ -225,15 +225,12 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, ...@@ -225,15 +225,12 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
} }
/*****************************************************************/
void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
/*****************************************************************/
/** Function SaveCurrentSetupValues() /** Function SaveCurrentSetupValues()
* Save the current setup values in m_EDA_Config * Save the current setup values in m_EDA_Config
* saved parameters are parameters that have the .m_Setup member set to true * saved parameters are parameters that have the .m_Setup member set to true
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
{ {
PARAM_CFG_BASE* pt_cfg; PARAM_CFG_BASE* pt_cfg;
...@@ -393,15 +390,12 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, ...@@ -393,15 +390,12 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
} }
/***************************************************************/
void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
/***************************************************************/
/** Function ReadCurrentSetupValues() /** Function ReadCurrentSetupValues()
* Raed the current setup values previously saved, from m_EDA_Config * Raed the current setup values previously saved, from m_EDA_Config
* saved parameters are parameters that have the .m_Setup member set to true * saved parameters are parameters that have the .m_Setup member set to true
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
{ {
PARAM_CFG_BASE* pt_cfg; PARAM_CFG_BASE* pt_cfg;
...@@ -428,10 +422,6 @@ void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ) ...@@ -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, PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
const wxChar* group ) const wxChar* group )
{ {
...@@ -496,8 +486,6 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) ...@@ -496,8 +486,6 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig )
} }
/**************************************************************************/
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
int default_val, int default_val,
const wxChar* group ) : const wxChar* group ) :
...@@ -614,8 +602,6 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) ...@@ -614,8 +602,6 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig )
} }
/***********************************************************************/
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
int default_val, const wxChar* group ) : int default_val, const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_BOOL, group ) PARAM_CFG_BASE( ident, PARAM_BOOL, group )
...@@ -664,7 +650,6 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) ...@@ -664,7 +650,6 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig )
} }
/*********************************************************************/
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident, PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
wxString* ptparam, wxString* ptparam,
const wxChar* group ) : const wxChar* group ) :
...@@ -708,7 +693,6 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) ...@@ -708,7 +693,6 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig )
} }
/***************************************************************************/
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
wxArrayString* ptparam, wxArrayString* ptparam,
const wxChar* group ) : const wxChar* group ) :
...@@ -726,7 +710,8 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) ...@@ -726,7 +710,8 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; 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; wxString libname, id_lib;
wxArrayString* libname_list = m_Pt_param; wxArrayString* libname_list = m_Pt_param;
while( 1 ) while( 1 )
......
...@@ -23,25 +23,39 @@ static object ChooseFile( str objTitle, str objMask, object objOpen ) ...@@ -23,25 +23,39 @@ static object ChooseFile( str objTitle, str objMask, object objOpen )
int open = extract<int>( objOpen ); int open = extract<int>( objOpen );
wxString script = EDA_FileSelector( PyHandler::MakeStr( objTitle ), wxString script = EDA_FileSelector( PyHandler::MakeStr( objTitle ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString,
wxEmptyString, /* nom fichier par defaut */ wxEmptyString,
mask, /* extension par defaut */ mask,
mask, /* Masque d'affichage */ mask,
NULL, NULL,
open ? wxFD_OPEN : wxFD_SAVE, open ? wxFD_OPEN : wxFD_SAVE,
TRUE TRUE );
);
return PyHandler::Convert( script ); 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 Clear() {}
static void RegisterCb( str objKey, object callback ) 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 ) 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() static void init_base_utils()
{ {
...@@ -54,7 +68,13 @@ static void init_base_utils() ...@@ -54,7 +68,13 @@ static void init_base_utils()
def ( "Clear", &Clear); def ( "Clear", &Clear);
} }
static void InitPyModules() { PyHandler::GetInstance()->InitNextModule(); } // Dummy boost callback
// Dummy boost callback
static void InitPyModules()
{
PyHandler::GetInstance()->InitNextModule();
}
/*****************************************************************************/ /*****************************************************************************/
/* PyHandler */ /* PyHandler */
...@@ -63,9 +83,21 @@ static void InitPyModules() { PyHandler::GetInstance()->InitNextModule(); } // D ...@@ -63,9 +83,21 @@ static void InitPyModules() { PyHandler::GetInstance()->InitNextModule(); } // D
// std::vector< T > -> python object implicit conversion // std::vector< T > -> python object implicit conversion
template <typename T> struct std_vector_to_tuple 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 wxString & str )
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 ) ); } 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 ) static PyObject * convert( const T& vect )
{ {
...@@ -80,24 +112,26 @@ template <typename T> struct std_vector_to_tuple ...@@ -80,24 +112,26 @@ template <typename T> struct std_vector_to_tuple
PyHandler* PyHandler::m_instance = NULL; PyHandler* PyHandler::m_instance = NULL;
PyHandler * PyHandler::GetInstance()
/* Singleton implementation */ /* Singleton implementation */
PyHandler * PyHandler::GetInstance()
{ {
if ( !PyHandler::m_instance ) if( !PyHandler::m_instance )
{ {
PyHandler::m_instance = new PyHandler(); PyHandler::m_instance = new PyHandler();
} }
return PyHandler::m_instance; return PyHandler::m_instance;
} }
PyHandler::PyHandler()
/* Init the Python env */ /* Init the Python env */
PyHandler::PyHandler()
{ {
Py_Initialize(); Py_Initialize();
PyEval_InitThreads(); PyEval_InitThreads();
m_ModulesLoaded = false; m_ModulesLoaded = false;
m_current = 0; m_current = 0;
if ( !wxPyCoreAPI_IMPORT() ) if( !wxPyCoreAPI_IMPORT() )
{ {
std::cerr << "Can't get wx Python binding\n" ; std::cerr << "Can't get wx Python binding\n" ;
PyErr_Print(); PyErr_Print();
...@@ -117,23 +151,30 @@ PyHandler::PyHandler() ...@@ -117,23 +151,30 @@ PyHandler::PyHandler()
// Register converters // Register converters
to_python_converter < std::vector< std::string >, std_vector_to_tuple< const std::vector < std::string > > > (); to_python_converter < std::vector< std::string >,
to_python_converter < std::vector< wxString >, std_vector_to_tuple< const std::vector < wxString > > > (); 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() void PyHandler::DoInitModules()
{ {
if ( m_ModulesLoaded ) return; if ( m_ModulesLoaded )
return;
m_ModulesLoaded = true; m_ModulesLoaded = true;
for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ ) 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*/ /* 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 ++ ) for ( unsigned int i = 0; i < m_ModuleRegistry.size(); i ++ )
{ {
...@@ -142,10 +183,14 @@ int PyHandler::GetModuleIndex( const wxString & name ) const ...@@ -142,10 +183,14 @@ int PyHandler::GetModuleIndex( const wxString & name ) const
return -1; return -1;
} }
void PyHandler::AddToModule( const wxString & name, PyHandler::initfunc_t initfunc )
/* Adds an init function to a python module */ /* 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 ); int i = GetModuleIndex( name );
if ( -1 == i ) if ( -1 == i )
...@@ -158,38 +203,48 @@ void PyHandler::AddToModule( const wxString & name, PyHandler::initfunc_t initfu ...@@ -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' */ /* 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_ModuleRegistry[m_current].registry[j]();
} }
m_current++; m_current++;
} }
PyHandler::~PyHandler()
/* Closes the Python env */ /* Closes the Python env */
PyHandler::~PyHandler()
{ {
wxPyEndAllowThreads(m_mainTState); wxPyEndAllowThreads(m_mainTState);
Py_Finalize(); Py_Finalize();
} }
void PyHandler::RunBaseScripts( const wxString & base )
/* Run scripts looking in 'base' directory */ /* Run scripts looking in 'base' directory */
void PyHandler::RunBaseScripts( const wxString & base )
{ {
const wxString sep = wxFileName().GetPathSeparator(); const wxString sep = wxFileName().GetPathSeparator();
// check if we can have a kicad_startup.py around ? // check if we can have a kicad_startup.py around ?
wxString script = base + wxT( "scripts" ) + sep + wxT( "kicad_startup.py" ); 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 : // First find scripts/<name>.py and run it if found :
script = base + wxString::FromAscii( "scripts" ) + sep + m_appName + wxString::FromAscii(".py"); script = base + wxString::FromAscii( "scripts" ) + sep + m_appName
if ( wxFileExists( script ) ) RunScript( script ); + 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; wxString pluginDir = base + wxT( "plugins" ) + sep + m_appName;
if ( wxDirExists( pluginDir ) ) if ( wxDirExists( pluginDir ) )
...@@ -205,8 +260,9 @@ void PyHandler::RunBaseScripts( const wxString & base ) ...@@ -205,8 +260,9 @@ void PyHandler::RunBaseScripts( const wxString & base )
} }
} }
void PyHandler::RunScripts()
/* Run application startup scripts */ /* Run application startup scripts */
void PyHandler::RunScripts()
{ {
// SYSTEMWIDE: // SYSTEMWIDE:
...@@ -216,15 +272,19 @@ void PyHandler::RunScripts() ...@@ -216,15 +272,19 @@ void PyHandler::RunScripts()
if ( wxDirExists( dataPath ) ) RunBaseScripts( dataPath ); if ( wxDirExists( dataPath ) ) RunBaseScripts( dataPath );
// USER Scripts: // USER Scripts:
wxString userDir = wxGetUserHome() + sep + wxString::FromAscii(".kicad.d") + sep; wxString userDir = wxGetUserHome() + sep
if ( wxDirExists( userDir ) ) RunBaseScripts( userDir ); + wxString::FromAscii(".kicad.d") + sep;
if ( wxDirExists( userDir ) )
RunBaseScripts( userDir );
userDir = wxGetUserHome() + sep + wxString::FromAscii("_kicad_d") + sep; 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' */ /* Run the script specified by 'name' */
bool PyHandler::RunScript( const wxString & name )
{ {
DoInitModules(); DoInitModules();
...@@ -253,7 +313,8 @@ bool PyHandler::RunScript( const wxString & name ) ...@@ -253,7 +313,8 @@ bool PyHandler::RunScript( const wxString & name )
try try
{ {
ns["currentScript"] = Convert( name ); 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 ) catch ( error_already_set )
{ {
...@@ -268,6 +329,7 @@ bool PyHandler::RunScript( const wxString & name ) ...@@ -268,6 +329,7 @@ bool PyHandler::RunScript( const wxString & name )
return ret; return ret;
} }
bool PyHandler::RunSimpleString( const wxString & code ) bool PyHandler::RunSimpleString( const wxString & code )
/* Run the code in 'code' */ /* Run the code in 'code' */
{ {
...@@ -292,80 +354,114 @@ void PyHandler::SetAppName( const wxString & name ) ...@@ -292,80 +354,114 @@ void PyHandler::SetAppName( const wxString & name )
/* Set the application name in the python scope */ /* Set the application name in the python scope */
{ {
m_appName = name; m_appName = name;
object module(( handle<>(borrowed(PyImport_AddModule("__main__"))))); object module( ( handle<>( borrowed( PyImport_AddModule( "__main__") ) ) ) );
object ns = module.attr( "__dict__" ); object ns = module.attr( "__dict__" );
try { try
{
ns["kicadApp"] = std::string( name.ToAscii() ); ns["kicadApp"] = std::string( name.ToAscii() );
} }
catch (error_already_set) catch( error_already_set )
{ {
PyErr_Print(); PyErr_Print();
} }
} }
const char * PyHandler::GetVersion() { return Py_GetVersion(); } const char * PyHandler::GetVersion() { return Py_GetVersion(); }
// Event handling : // 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 ) int PyHandler::GetEventIndex( const wxString & key )
{ {
for ( unsigned int i = 0; i < m_EventRegistry.size(); i ++ ) 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; 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 ) void PyHandler::TriggerEvent( const wxString & key, const object & param )
{ {
int i = GetEventIndex( key ); int i = GetEventIndex( key );
if ( -1 == i ) return; if ( -1 == i )
return;
wxPyBlock_t blocked = wxPyBeginBlockThreads(); 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 try
{ {
m_EventRegistry[i].functors[j]( param ); 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(); 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 ); int i = GetEventIndex( key );
if ( -1 == i ) return;
if( -1 == i )
return;
m_EventRegistry[i].functors.push_back( callback ); 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 ); int i = GetEventIndex( key );
if ( -1 == i ) return; if( -1 == i )
for ( unsigned int j = 0; j < m_EventRegistry[i].functors.size() ; j++ ) return;
for( unsigned int j = 0; j < m_EventRegistry[i].functors.size() ; j++ )
{ {
if ( callback == m_EventRegistry[i].functors[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; break;
} }
} }
} }
// Object conversion: // 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() );
}
/****************/ /****************/
/* SELCOLOR.CPP */ /* SELCOLOR.CPP */
/****************/ /****************/
/* Affichage et selection de la palette des couleurs disponibles /* Dialog for selecting color from the palette of available colors.
* dans une frame
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -22,17 +20,10 @@ enum colors_id { ...@@ -22,17 +20,10 @@ enum colors_id {
}; };
/*******************************************/
class WinEDA_SelColorFrame : public wxDialog class WinEDA_SelColorFrame : public wxDialog
/*******************************************/
/* Frame d'affichage de la palette des couleurs disponibles
*/
{ {
private: private:
public: public:
// Constructor and destructor
WinEDA_SelColorFrame( wxWindow* parent, WinEDA_SelColorFrame( wxWindow* parent,
const wxPoint& framepos, int OldColor ); const wxPoint& framepos, int OldColor );
~WinEDA_SelColorFrame() {}; ~WinEDA_SelColorFrame() {};
...@@ -45,7 +36,6 @@ private: ...@@ -45,7 +36,6 @@ private:
}; };
/* Construction de la table des evenements pour FrameClassMain */
BEGIN_EVENT_TABLE( WinEDA_SelColorFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SelColorFrame, wxDialog )
EVT_BUTTON( wxID_CANCEL, WinEDA_SelColorFrame::OnCancel ) EVT_BUTTON( wxID_CANCEL, WinEDA_SelColorFrame::OnCancel )
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31, EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + 31,
......
/*********************************************/ /*********************************************/
/* string.cpp */ /* string.cpp */
/* some useful functions to handle strings */ /* some useful functions to handle strings */
/*********************************************/ /*********************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -8,14 +8,11 @@ ...@@ -8,14 +8,11 @@
#include "kicad_string.h" #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 a double-quote delimited text from source and put it in in dest,
* read NbMaxChar bytes max * read NbMaxChar bytes max
* return the char count read from source * return the char count read from source
*/ */
int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
{ {
int ii, jj, flag = 0; int ii, jj, flag = 0;
...@@ -23,11 +20,11 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) ...@@ -23,11 +20,11 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
{ {
if( *source == 0 ) if( *source == 0 )
break; /* E.O.L. */ break; /* E.O.L. */
if( *source == '"' ) /* delimiteur trouve */ if( *source == '"' ) /* delimiter is " */
{ {
if( flag ) if( flag )
break; /* Fin de texte delimite */ break; /* End of delimited text */
flag = 1; /* Marque 1er delimiteur trouve */ flag = 1; /* First delimiter found. */
} }
else if( flag ) else if( flag )
{ {
...@@ -35,29 +32,26 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) ...@@ -35,29 +32,26 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
} }
} }
*dest = 0; /* Null termined */ *dest = 0; /* Null terminated */
return jj; return jj;
} }
/********************************/
char* StrPurge( char* text )
/********************************/
/* Remove training spaces in text /* Remove training spaces in text
* return a pointer on the first non space char in text * return a pointer on the first non space char in text
*/ */
char* StrPurge( char* text )
{ {
char* ptspace; char* ptspace;
if( text == NULL ) if( text == NULL )
return NULL; return NULL;
while( (*text <= ' ') && *text ) while( ( *text <= ' ' ) && *text )
text++; text++;
ptspace = text + strlen( text ) - 1; ptspace = text + strlen( text ) - 1;
while( (*ptspace <= ' ') && *ptspace && (ptspace >= text) ) while( ( *ptspace <= ' ' ) && *ptspace && ( ptspace >= text ) )
{ {
*ptspace = 0; ptspace--; *ptspace = 0; ptspace--;
} }
...@@ -66,15 +60,12 @@ char* StrPurge( char* text ) ...@@ -66,15 +60,12 @@ char* StrPurge( char* text )
} }
/*****************************************************************/
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
/*****************************************************************/
/* Read lines from File /* Read lines from File
* Skip void lines and comments (starting by #) * Skip void lines and comments (starting by #)
* return the first non void line. * return the first non void line.
* increments *LineNum for ecah line * increments *LineNum for each line
*/ */
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
{ {
do { do {
if( fgets( Line, SizeLine, File ) == NULL ) if( fgets( Line, SizeLine, File ) == NULL )
...@@ -89,13 +80,10 @@ char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ) ...@@ -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 /* return in aBuffer the date and time
* time is the local time. * time is the local time.
*/ */
char* DateAndTime( char* aBuffer )
{ {
wxString datetime; wxString datetime;
...@@ -106,14 +94,12 @@ char* DateAndTime( char* aBuffer ) ...@@ -106,14 +94,12 @@ char* DateAndTime( char* aBuffer )
} }
/*******************************/
wxString DateAndTime()
/*******************************/
/* return the date and time in a wxString /* return the date and time in a wxString
* note: does the same thing than strftime() * note: does the same thing than strftime()
* time is the local time. * time is the local time.
*/ */
wxString DateAndTime()
{ {
wxString Line; wxString Line;
...@@ -126,20 +112,17 @@ wxString DateAndTime() ...@@ -126,20 +112,17 @@ wxString DateAndTime()
} }
/************************************************************/
int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
/************************************************************/
/* /*
* sort() function * sort() function
* Same as strncmp() but numbers in strings * Same as strncmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit * 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 i;
int nb1 = 0, nb2 = 0; int nb1 = 0, nb2 = 0;
if( (str1 == NULL) || (str2 == NULL) ) if( ( str1 == NULL ) || ( str2 == NULL ) )
return 0; return 0;
for( i = 0; i < NbMax; i++ ) for( i = 0; i < NbMax; i++ )
...@@ -167,7 +150,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -167,7 +150,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
return -1; return -1;
if( *str1 > *str2 ) if( *str1 > *str2 )
return 1; return 1;
if( (*str1 == 0 ) && ( *str2 == 0 ) ) if( ( *str1 == 0 ) && ( *str2 == 0 ) )
return 0; return 0;
str1++; str2++; str1++; str2++;
} }
...@@ -176,34 +159,28 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -176,34 +159,28 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
} }
/***********************************************/
int StrNumICmp( const wxChar* str1, const wxChar* str2 )
/***********************************************/
/* /*
* sort() function * sort() function
* Same as stricmp() but numbers in strings * Same as stricmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit * 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 ); return StrLenNumICmp( str1, str2, 32735 );
} }
/**************************************************************/
int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
/**************************************************************/
/* /*
* sort() function * sort() function
* Same as strnicmp() but numbers in strings * Same as strnicmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit * 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 i;
int nb1 = 0, nb2 = 0; int nb1 = 0, nb2 = 0;
if( (str1 == NULL) || (str2 == NULL) ) if( ( str1 == NULL ) || ( str2 == NULL ) )
return 0; return 0;
for( i = 0; i < NbMax; i++ ) for( i = 0; i < NbMax; i++ )
...@@ -240,16 +217,13 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -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 /* compare a string to a pattern
* ( usual chars * and ? allowed). * ( usual chars * and ? allowed).
* if case_sensitive == true, comparison is case sensitive * if case_sensitive == true, comparison is case sensitive
* return true if match else false * 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* cp = NULL, * mp = NULL;
const wxChar* wild, * string; const wxChar* wild, * string;
...@@ -270,9 +244,9 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -270,9 +244,9 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
string = _string_to_tst.GetData(); string = _string_to_tst.GetData();
} }
while( (*string) && (*wild != '*') ) while( ( *string ) && ( *wild != '*' ) )
{ {
if( (*wild != *string) && (*wild != '?') ) if( ( *wild != *string ) && ( *wild != '?' ) )
return FALSE; return FALSE;
wild++; string++; wild++; string++;
} }
...@@ -286,7 +260,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -286,7 +260,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
mp = wild; mp = wild;
cp = string + 1; cp = string + 1;
} }
else if( (*wild == *string) || (*wild == '?') ) else if( ( *wild == *string ) || ( *wild == '?' ) )
{ {
wild++; wild++;
string++; string++;
...@@ -307,15 +281,11 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -307,15 +281,11 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
} }
/***************************/ /* Converts a string used to compensate for internalization of printf().
char* to_point( char* Text ) * Generated floats with a comma instead of point.
/**************************/ * Obsolete: use SetLocaleTo_C_standard instead
/* 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
*/ */
char* to_point( char* Text )
{ {
char* line = Text; char* line = Text;
...@@ -331,13 +301,10 @@ char* to_point( char* Text ) ...@@ -331,13 +301,10 @@ char* to_point( char* Text )
} }
/********************************/ /* Convert string to upper case.
char* strupper( char* Text ) * Returns pointer to the converted string.
/********************************/
/* Change les caracteres 'a' ... 'z' en 'A' ... 'Z'. dans la chaine Text.
* Retourne Text
*/ */
char* strupper( char* Text )
{ {
char* code = Text; char* code = Text;
...@@ -345,7 +312,7 @@ char* strupper( char* Text ) ...@@ -345,7 +312,7 @@ char* strupper( char* Text )
{ {
while( *code ) while( *code )
{ {
if( (*code >= 'a') && (*code <= 'z') ) if( ( *code >= 'a' ) && ( *code <= 'z' ) )
*code += 'A' - 'a'; *code += 'A' - 'a';
code++; code++;
} }
......
/******************************************************************/ /****************/
/* toolbars.cpp - fonctions des classes du type WinEDA_ttolbar */ /* toolbars.cpp */
/******************************************************************/ /****************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -9,15 +9,14 @@ ...@@ -9,15 +9,14 @@
#include "fctsys.h" #include "fctsys.h"
#include "wxstruct.h" #include "wxstruct.h"
/*************************/
/* class WinEDA_HToolbar */
/*************************/
WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent, WinEDA_Toolbar::WinEDA_Toolbar( id_toolbar type, wxWindow * parent,
wxWindowID id, bool horizontal ): wxWindowID id, bool horizontal ):
#if defined(KICAD_AUITOOLBAR) #if defined(KICAD_AUITOOLBAR)
wxAuiToolBar( parent, id, wxDefaultPosition, wxDefaultSize, 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 #else
wxToolBar( parent, id, wxPoint( -1,-1 ), wxSize( -1,-1 ), wxToolBar( parent, id, wxPoint( -1,-1 ), wxSize( -1,-1 ),
horizontal ? wxTB_HORIZONTAL : wxTB_VERTICAL ) horizontal ? wxTB_HORIZONTAL : wxTB_VERTICAL )
......
/************************/ /****************************/
/* Routines de rotation */ /* Trigonometric functions. */
/************************/ /****************************/
/* Fichier TRIGO.CPP */
#include "fctsys.h" #include "fctsys.h"
#include "trigo.h" #include "trigo.h"
...@@ -24,16 +22,13 @@ bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist ...@@ -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 /** Function DistanceTest
* Calcul de la distance du curseur souris a un segment de droite : * Calculate the distance from mouse cursor to a line segment.
* retourne: * Returns:
* false si distance > seuil * False if distance > threshold
* true si distance <= seuil * True if distance <= threshold
*/ */
bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
{ {
/* We can have 4 cases:: /* We can have 4 cases::
* horizontal segment * horizontal segment
...@@ -41,156 +36,162 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) ...@@ -41,156 +36,162 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY )
* 45 degrees segment * 45 degrees segment
* other slopes * other slopes
*/ */
int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ int cXrot, cYrot, segX, segY;
segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY;
int pointX, pointY; /* coord point a tester dans repere modifie dans lequel
* segX et segY sont >=0 */
segX = dx; segX = dx;
segY = dy; segY = dy;
pointX = spot_cX; pointX = spot_cX;
pointY = spot_cY; pointY = spot_cY;
/*Recalcul coord pour que le segment soit dans 1er quadrant (coord >= 0)*/ /*Recalculating coord for the segment is in 1st quadrant (coord >= 0)*/
if( segX < 0 ) /* mise en >0 par symetrie par rapport a l'axe Y */ if( segX < 0 ) /* set > 0 by symmetry about the Y axis */
{ {
segX = -segX; segX = -segX;
pointX = -pointX; 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; segY = -segY;
pointY = -pointY; pointY = -pointY;
} }
if( segY == 0 ) /* piste Horizontale */ if( segY == 0 ) /* horizontal */
{ {
if( abs( pointY ) <= seuil ) if( abs( pointY ) <= seuil )
{ {
if( (pointX >= 0) && (pointX <= segX) ) if( ( pointX >= 0 ) && ( pointX <= segX ) )
return 1; 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; return true;
} }
if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) if( ( pointX > segX ) && ( pointX <= ( segX + seuil ) ) )
{ {
if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= if( ( ( ( pointX - segX ) * ( pointX - segX ) )
(seuil * seuil) ) + ( pointY * pointY ) ) <= ( seuil * seuil ) )
return true; return true;
} }
} }
} }
else if( segX == 0 ) /* piste verticale */ else if( segX == 0 ) /* vertical */
{ {
if( abs( pointX ) <= seuil ) if( abs( pointX ) <= seuil )
{ {
if( (pointY >= 0 ) && (pointY <= segY) ) if( ( pointY >= 0 ) && ( pointY <= segY ) )
return true; 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; return true;
} }
if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) if( ( pointY > segY ) && ( pointY <= ( segY + seuil ) ) )
{ {
if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= if( ( ( ( pointY - segY ) * ( pointY - segY ) )
(seuil * seuil) ) + ( pointX * pointX ) ) <= ( seuil * seuil ) )
return true; 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 /* Rotate axes of 45 degrees. mouse was then
* coord : x1 = x*cos45 + y*sin45 * Coord: x1 = x * y * cos45 + sin45
* y1 = y*cos45 - x*sin45 * y1 = y * cos45 - sin45 x *
* et le segment de piste est alors horizontal. * And the segment of track is horizontal.
* recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * Coord recalculation of the mouse (sin45 = cos45 = .707 = 7 / 10
* remarque : sin ou cos45 = .707, et lors du recalcul des coord * Note: sin or cos45 = .707, and when recalculating coord
* dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait 0.707 fois * dx45 and dy45, lect coeff .707 is neglected, dx and dy are
* trop grands. (c.a.d trop petits) * actually 0707 times
* spot_cX,Y doit etre * par .707 * .707 = 0.5 */ * Too big. (security hole too small)
* Spot_cX, Y * must be by .707 * .707 = 0.5
*/
cXrot = (pointX + pointY) >> 1; cXrot = (pointX + pointY) >> 1;
cYrot = (pointY - pointX) >> 1; cYrot = (pointY - pointX) >> 1;
/* recalcul des coord de l'extremite du segment , qui sera vertical /* Recalculating coord of segment extremity, which will be vertical
* suite a l'orientation des axes sur l'ecran : dx45 = pointX (ou pointY) * following the orientation of axes on the screen: dx45 = pointx
* et est en fait 1,414 plus grand , et dy45 = 0 */ * (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 *= 7;
seuil /= 10; 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; return true;
/* Etude des extremites : cercle de rayon seuil */ /* Check extremes using the radius of a circle. */
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; 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 true;
} }
} }
} }
else /* orientation quelconque */ else /* any orientation */
{ {
/* On fait un changement d'axe (rotation) de facon a ce que le segment /* There is a change of axis (rotation), so that the segment
* de piste soit horizontal dans le nouveau repere */ * track is horizontal in the new reference
*/
int angle; 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; cXrot = pointX;
cYrot = pointY; cYrot = pointY;
RotatePoint( &cXrot, &cYrot, angle ); /* Rotation du point a tester */ RotatePoint( &cXrot, &cYrot, angle ); /* Rotate the point to be tested */
RotatePoint( &segX, &segY, angle ); /* Rotation du segment */ RotatePoint( &segX, &segY, angle ); /* Rotate the segment */
/* la piste est Horizontale , par suite des modifs de coordonnes
* et d'axe, donc segX = longueur du 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; 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; 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 true;
} }
} }
} }
return false; return false;
} }
/***********************************/ /* Return the arc tangent of 0.1 degrees coord vector dx, dy
int ArcTangente( int dy, int dx ) * between -1800 and 1800
/***********************************/ * Equivalent to atan2 (but faster for calculations if
* the angle is 0 to -1800, or + - 900
/* 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
*/ */
int ArcTangente( int dy, int dx )
{ {
double fangle; double fangle;
...@@ -231,15 +232,11 @@ int ArcTangente( int dy, int dx ) ...@@ -231,15 +232,11 @@ int ArcTangente( int dy, int dx )
} }
/*********************************************/
void RotatePoint( int* pX, int* pY, int angle )
/*********************************************/
/* /*
* Fonction surchargee! * Calculate the new point of coord coord pX, pY,
* calcule les nouvelles coord du point de coord pX, pY, * for a rotation center 0, 0, and angle in (1 / 10 degree)
* pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre)
*/ */
void RotatePoint( int* pX, int* pY, int angle )
{ {
double fpx, fpy; double fpx, fpy;
int tmp; int tmp;
...@@ -253,8 +250,7 @@ void RotatePoint( int* pX, int* pY, int angle ) ...@@ -253,8 +250,7 @@ void RotatePoint( int* pX, int* pY, int angle )
if( angle == 0 ) if( angle == 0 )
return; return;
/* Calcul des coord : /* coord: xrot = y*sin + x*cos
* coord: xrot = y*sin + x*cos
* yrot = y*cos - x*sin * yrot = y*cos - x*sin
*/ */
if( angle == 900 ) /* sin = 1, cos = 0 */ if( angle == 900 ) /* sin = 1, cos = 0 */
...@@ -276,8 +272,8 @@ void RotatePoint( int* pX, int* pY, int angle ) ...@@ -276,8 +272,8 @@ void RotatePoint( int* pX, int* pY, int angle )
} }
else else
{ {
fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); fpx = ( *pY * fsinus[angle] ) + ( *pX * fcosinus[angle] );
fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); fpy = ( *pY * fcosinus[angle] ) - ( *pX * fsinus[angle] );
*pX = wxRound( fpx ); *pX = wxRound( fpx );
*pY = wxRound( fpy ); *pY = wxRound( fpy );
...@@ -285,15 +281,11 @@ void RotatePoint( int* pX, int* pY, int angle ) ...@@ -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! * Calculate the new point of coord coord pX, pY,
* calcule les nouvelles coord du point de coord pX, pY, * for a rotation center cx, cy, and angle in (1 / 10 degree)
* pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre)
*/ */
void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
{ {
int ox, oy; int ox, oy;
...@@ -307,15 +299,11 @@ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle ) ...@@ -307,15 +299,11 @@ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
} }
/********************************************/
void RotatePoint( wxPoint* point, int angle )
/********************************************/
/* /*
* Fonction surchargee! * Calculates the new coord point point
* calcule les nouvelles coord du point point, * for a rotation angle in (1 / 10 degree)
* pour une rotation d'angle angle ( en 1/10 degre)
*/ */
void RotatePoint( wxPoint* point, int angle )
{ {
int ox, oy; int ox, oy;
...@@ -328,15 +316,11 @@ void RotatePoint( wxPoint* point, int angle ) ...@@ -328,15 +316,11 @@ void RotatePoint( wxPoint* point, int angle )
} }
/*****************************************************************/
void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
/*****************************************************************/
/* /*
* Fonction surchargee! * Calculates the new coord point point
* calcule les nouvelles coord du point point, * for a center rotation center and angle in (1 / 10 degree)
* pour une rotation de centre centre, et d'angle angle ( en 1/10 degre)
*/ */
void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
{ {
int ox, oy; int ox, oy;
...@@ -349,9 +333,7 @@ void RotatePoint( wxPoint* point, const wxPoint& centre, int angle ) ...@@ -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 ) void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
/*************************************************************************/
{ {
double ox, oy; double ox, oy;
...@@ -365,14 +347,7 @@ void RotatePoint( double* pX, double* pY, double cx, double cy, int angle ) ...@@ -365,14 +347,7 @@ void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
} }
/*************************************************/
void RotatePoint( double* pX, double* pY, 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; double tmp;
......
/**************************************************/ /*****************/
/* WORKSHEET.CPP : routines de trace du cartouche */ /* WORKSHEET.CPP */
/**************************************************/ /*****************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -178,7 +178,7 @@ Ki_WorkSheetData WS_Comment4 = ...@@ -178,7 +178,7 @@ Ki_WorkSheetData WS_Comment4 =
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */ Ki_WorkSheetData WS_MostLeftLine = /* Left vertical segment */
{ {
WS_LEFT_SEGMENT, WS_LEFT_SEGMENT,
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
...@@ -192,7 +192,8 @@ Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */ ...@@ -192,7 +192,8 @@ Ki_WorkSheetData WS_MostLeftLine = /* segment vertical gauche */
NULL, NULL 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_SEGMENT,
&WS_MostUpperLine, &WS_MostUpperLine,
...@@ -202,7 +203,7 @@ Ki_WorkSheetData WS_SeparatorLine = /* horizontal segment between filename and c ...@@ -202,7 +203,7 @@ Ki_WorkSheetData WS_SeparatorLine = /* horizontal segment between filename and c
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */ Ki_WorkSheetData WS_MostUpperLine = /* superior horizontal segment */
{ {
WS_UPPER_SEGMENT, WS_UPPER_SEGMENT,
&WS_Segm3, &WS_Segm3,
...@@ -216,7 +217,7 @@ Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */ ...@@ -216,7 +217,7 @@ Ki_WorkSheetData WS_MostUpperLine = /* segment horizontal superieur */
NULL, NULL 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_SEGMENT,
&WS_Segm4, &WS_Segm4,
...@@ -230,7 +231,7 @@ Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY ...@@ -230,7 +231,7 @@ Ki_WorkSheetData WS_Segm3 = /* segment horizontal au dessus de NAME COMPANY
NULL, NULL 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_SEGMENT,
&WS_Segm5, &WS_Segm5,
...@@ -244,7 +245,7 @@ Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */ ...@@ -244,7 +245,7 @@ Ki_WorkSheetData WS_Segm4 = /* segment vertical a gauche de SHEET et REV */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */ Ki_WorkSheetData WS_Segm5 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm6, &WS_Segm6,
...@@ -258,7 +259,7 @@ Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */ ...@@ -258,7 +259,7 @@ Ki_WorkSheetData WS_Segm5 = /* 1er segment horizontal */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */ Ki_WorkSheetData WS_Segm6 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm7, &WS_Segm7,
...@@ -272,7 +273,7 @@ Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */ ...@@ -272,7 +273,7 @@ Ki_WorkSheetData WS_Segm6 = /* 2eme segment horizontal */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm7 =
{ {
WS_SEGMENT, WS_SEGMENT,
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
...@@ -282,7 +283,7 @@ Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */ ...@@ -282,7 +283,7 @@ Ki_WorkSheetData WS_Segm7 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm8 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm9, &WS_Segm9,
...@@ -291,7 +292,7 @@ Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */ ...@@ -291,7 +292,7 @@ Ki_WorkSheetData WS_Segm8 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm9 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm10, &WS_Segm10,
...@@ -300,7 +301,7 @@ Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */ ...@@ -300,7 +301,7 @@ Ki_WorkSheetData WS_Segm9 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm10 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm11, &WS_Segm11,
...@@ -309,7 +310,7 @@ Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */ ...@@ -309,7 +310,7 @@ Ki_WorkSheetData WS_Segm10 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm11 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm12, &WS_Segm12,
...@@ -318,7 +319,7 @@ Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */ ...@@ -318,7 +319,7 @@ Ki_WorkSheetData WS_Segm11 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm12 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm13, &WS_Segm13,
...@@ -327,7 +328,7 @@ Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */ ...@@ -327,7 +328,7 @@ Ki_WorkSheetData WS_Segm12 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm13 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm14, &WS_Segm14,
...@@ -336,7 +337,7 @@ Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */ ...@@ -336,7 +337,7 @@ Ki_WorkSheetData WS_Segm13 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm14 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm15, &WS_Segm15,
...@@ -345,7 +346,7 @@ Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */ ...@@ -345,7 +346,7 @@ Ki_WorkSheetData WS_Segm14 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm15 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm16, &WS_Segm16,
...@@ -354,7 +355,7 @@ Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */ ...@@ -354,7 +355,7 @@ Ki_WorkSheetData WS_Segm15 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm16 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm17, &WS_Segm17,
...@@ -363,7 +364,7 @@ Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */ ...@@ -363,7 +364,7 @@ Ki_WorkSheetData WS_Segm16 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm17 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm18, &WS_Segm18,
...@@ -372,7 +373,7 @@ Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */ ...@@ -372,7 +373,7 @@ Ki_WorkSheetData WS_Segm17 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm18 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm19, &WS_Segm19,
...@@ -381,7 +382,7 @@ Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */ ...@@ -381,7 +382,7 @@ Ki_WorkSheetData WS_Segm18 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm19 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm20, &WS_Segm20,
...@@ -390,7 +391,7 @@ Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */ ...@@ -390,7 +391,7 @@ Ki_WorkSheetData WS_Segm19 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm20 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm21, &WS_Segm21,
...@@ -399,7 +400,7 @@ Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */ ...@@ -399,7 +400,7 @@ Ki_WorkSheetData WS_Segm20 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm21 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm22, &WS_Segm22,
...@@ -408,7 +409,7 @@ Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */ ...@@ -408,7 +409,7 @@ Ki_WorkSheetData WS_Segm21 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm22 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm23, &WS_Segm23,
...@@ -417,7 +418,7 @@ Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */ ...@@ -417,7 +418,7 @@ Ki_WorkSheetData WS_Segm22 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm23 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm24, &WS_Segm24,
...@@ -426,7 +427,7 @@ Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */ ...@@ -426,7 +427,7 @@ Ki_WorkSheetData WS_Segm23 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm24 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Segm25, &WS_Segm25,
...@@ -435,7 +436,7 @@ Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */ ...@@ -435,7 +436,7 @@ Ki_WorkSheetData WS_Segm24 = /* segment vertical apres SIZE */
NULL, NULL NULL, NULL
}; };
Ki_WorkSheetData WS_Segm25 = /* segment vertical apres SIZE */ Ki_WorkSheetData WS_Segm25 =
{ {
WS_SEGMENT, WS_SEGMENT,
&WS_Izm, &WS_Izm,
...@@ -826,8 +827,8 @@ Ki_WorkSheetData WS_Podp1_LU = ...@@ -826,8 +827,8 @@ Ki_WorkSheetData WS_Podp1_LU =
{ {
WS_PODPIS_LU, WS_PODPIS_LU,
&WS_Podp2_LU, &WS_Podp2_LU,
STAMP_7 + 90, 0 + 492, STAMP_7 + 90, 0 + 492,
0, 0, 0, 0,
wxT( "Инв.N подл." ),NULL wxT( "Инв.N подл." ),NULL
}; };
...@@ -835,8 +836,8 @@ Ki_WorkSheetData WS_Podp2_LU = ...@@ -835,8 +836,8 @@ Ki_WorkSheetData WS_Podp2_LU =
{ {
WS_PODPIS_LU, WS_PODPIS_LU,
&WS_Podp3_LU, &WS_Podp3_LU,
STAMP_7 + 90, STAMP_25 + 688, STAMP_7 + 90, STAMP_25 + 688,
0, 0, 0, 0,
wxT( "Подп. и дата" ),NULL wxT( "Подп. и дата" ),NULL
}; };
...@@ -844,8 +845,8 @@ Ki_WorkSheetData WS_Podp3_LU = ...@@ -844,8 +845,8 @@ Ki_WorkSheetData WS_Podp3_LU =
{ {
WS_PODPIS_LU, WS_PODPIS_LU,
&WS_Podp4_LU, &WS_Podp4_LU,
STAMP_7 + 90, STAMP_60 + 492, STAMP_7 + 90, STAMP_60 + 492,
0, 0, 0, 0,
wxT( "Взам.инв.N" ),NULL wxT( "Взам.инв.N" ),NULL
}; };
...@@ -853,8 +854,8 @@ Ki_WorkSheetData WS_Podp4_LU = ...@@ -853,8 +854,8 @@ Ki_WorkSheetData WS_Podp4_LU =
{ {
WS_PODPIS_LU, WS_PODPIS_LU,
&WS_Podp5_LU, &WS_Podp5_LU,
STAMP_7 + 90, STAMP_85 + 492, STAMP_7 + 90, STAMP_85 + 492,
0, 0, 0, 0,
wxT( "Инв.N дубл." ),NULL wxT( "Инв.N дубл." ),NULL
}; };
...@@ -862,8 +863,8 @@ Ki_WorkSheetData WS_Podp5_LU = ...@@ -862,8 +863,8 @@ Ki_WorkSheetData WS_Podp5_LU =
{ {
WS_PODPIS_LU, WS_PODPIS_LU,
NULL, NULL,
STAMP_7 + 90, STAMP_110 + 688, STAMP_7 + 90, STAMP_110 + 688,
0, 0, 0, 0,
wxT( "Подп. и дата" ),NULL wxT( "Подп. и дата" ),NULL
}; };
...@@ -906,8 +907,8 @@ Ki_WorkSheetData WS_Segm5_LT = ...@@ -906,8 +907,8 @@ Ki_WorkSheetData WS_Segm5_LT =
{ {
WS_SEGMENT_LT, WS_SEGMENT_LT,
NULL, NULL,
STAMP_X_70, STAMP_Y_14, STAMP_X_70, STAMP_Y_14,
STAMP_X_70, 0, STAMP_X_70, 0,
#else #else
NULL, NULL,
BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 4, BLOCK_OX - (SIZETEXT * 11),SIZETEXT * 4,
...@@ -916,12 +917,11 @@ Ki_WorkSheetData WS_Segm5_LT = ...@@ -916,12 +917,11 @@ Ki_WorkSheetData WS_Segm5_LT =
NULL, NULL 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 ) if( !m_Draw_Sheet_Ref )
return; return;
...@@ -945,7 +945,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -945,7 +945,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
if( Sheet == NULL ) if( Sheet == NULL )
{ {
DisplayError( this, DisplayError( this,
wxT( "WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet" ) ); wxT( "WinEDA_DrawFrame::TraceWorkSheet() error: NULL Sheet" ) );
return; return;
} }
...@@ -959,7 +959,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -959,7 +959,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
} }
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
/* trace de la bordure */ /* Draw the border. */
refx = Sheet->m_LeftMargin; refx = Sheet->m_LeftMargin;
refy = Sheet->m_TopMargin; /* Upper left corner */ refy = Sheet->m_TopMargin; /* Upper left corner */
xg = Sheet->m_Size.x - Sheet->m_RightMargin; xg = Sheet->m_Size.x - Sheet->m_RightMargin;
...@@ -981,14 +981,14 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -981,14 +981,14 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
#endif #endif
/* trace des reperes */ /* Draw the reference legends. */
refx = Sheet->m_LeftMargin; refx = Sheet->m_LeftMargin;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
refy = Sheet->m_Size.y - Sheet->m_BottomMargin; /* Lower left corner */ refy = Sheet->m_Size.y - Sheet->m_BottomMargin; /* Lower left corner */
for( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext ) for( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext )
{ {
pos.x = (refx - WsItem->m_Posx) * scale; pos.x = ( refx - WsItem->m_Posx ) * scale;
pos.y = (refy - WsItem->m_Posy) * scale; pos.y = ( refy - WsItem->m_Posy ) * scale;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
...@@ -1000,8 +1000,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1000,8 +1000,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_VERT, size, msg, TEXT_ORIENT_VERT, size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
false, false ); width, false, false );
break; break;
case WS_SEGMENT_LU: case WS_SEGMENT_LU:
...@@ -1016,8 +1016,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1016,8 +1016,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
refy = Sheet->m_BottomMargin; /* Left Top corner */ refy = Sheet->m_BottomMargin; /* Left Top corner */
for( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext ) for( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext )
{ {
pos.x = (refx + WsItem->m_Posx) * scale; pos.x = ( refx + WsItem->m_Posx ) * scale;
pos.y = (refy + WsItem->m_Posy) * scale; pos.y = ( refy + WsItem->m_Posy ) * scale;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
...@@ -1035,39 +1035,37 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1035,39 +1035,37 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
xg = Sheet->m_Size.x - Sheet->m_RightMargin; xg = Sheet->m_Size.x - Sheet->m_RightMargin;
yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ yg = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */
/* Trace des reperes selon l'axe X */ ipas = ( xg - refx ) / PAS_REF;
ipas = (xg - refx) / PAS_REF; gxpas = ( xg - refx ) / ipas;
gxpas = ( xg - refx) / ipas;
for( ii = refx + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- ) for( ii = refx + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- )
{ {
Line.Printf( wxT( "%d" ), jj ); Line.Printf( wxT( "%d" ), jj );
if( ii < xg - PAS_REF / 2 ) if( ii < xg - PAS_REF / 2 )
{ {
GRLine( &DrawPanel->m_ClipBox, DC, ii * scale, refy * scale, 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, DrawGraphicText( DrawPanel, DC,
wxPoint( (ii - gxpas / 2) * scale, (refy + GRID_REF_W / 2) * scale ), wxPoint( ( ii - gxpas / 2 ) * scale,
Color, ( refy + GRID_REF_W / 2 ) * scale ),
Line, TEXT_ORIENT_HORIZ, size_ref, Color, Line, TEXT_ORIENT_HORIZ, size_ref,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
width, false, false ); width, false, false );
if( ii < xg - PAS_REF / 2 ) if( ii < xg - PAS_REF / 2 )
{ {
GRLine( &DrawPanel->m_ClipBox, DC, ii * scale, yg * scale, 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, DrawGraphicText( DrawPanel, DC,
wxPoint( (ii - gxpas / 2) * scale, wxPoint( ( ii - gxpas / 2 ) * scale,
(yg - GRID_REF_W / 2) * scale ), ( yg - GRID_REF_W / 2) * scale ),
Color, Line, TEXT_ORIENT_HORIZ, size_ref, Color, Line, TEXT_ORIENT_HORIZ, size_ref,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
width, false, false ); width, false, false );
} }
/* Trace des reperes selon l'axe Y */ ipas = ( yg - refy ) / PAS_REF;
ipas = (yg - refy) / PAS_REF; gypas = ( yg - refy ) / ipas;
gypas = ( yg - refy) / ipas;
for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- )
{ {
if( jj < 26 ) if( jj < 26 )
...@@ -1077,23 +1075,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1077,23 +1075,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
if( ii < yg - PAS_REF / 2 ) if( ii < yg - PAS_REF / 2 )
{ {
GRLine( &DrawPanel->m_ClipBox, DC, refx * scale, ii * scale, 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, DrawGraphicText( DrawPanel, DC,
wxPoint( (refx + GRID_REF_W / 2) * scale, wxPoint( ( refx + GRID_REF_W / 2 ) * scale,
(ii - gypas / 2) * scale ), ( ii - gypas / 2 ) * scale ),
Color, Color, Line, TEXT_ORIENT_HORIZ, size_ref,
Line, TEXT_ORIENT_HORIZ, size_ref,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
width, false, false ); width, false, false );
if( ii < yg - PAS_REF / 2 ) if( ii < yg - PAS_REF / 2 )
{ {
GRLine( &DrawPanel->m_ClipBox, DC, xg * scale, ii * scale, 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, DrawGraphicText( DrawPanel, DC,
wxPoint( (xg - GRID_REF_W / 2) * scale, wxPoint( ( xg - GRID_REF_W / 2 ) * scale,
(ii - gxpas / 2) * scale ), ( ii - gxpas / 2 ) * scale ),
Color, Line, TEXT_ORIENT_HORIZ, size_ref, Color, Line, TEXT_ORIENT_HORIZ, size_ref,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
width, false, false ); width, false, false );
...@@ -1101,7 +1098,6 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1101,7 +1098,6 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
#endif #endif
/* Trace du cartouche */
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
refx = Sheet->m_Size.x - Sheet->m_RightMargin; refx = Sheet->m_Size.x - Sheet->m_RightMargin;
refy = Sheet->m_Size.y - Sheet->m_BottomMargin; /* lower right corner */ 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 ...@@ -1141,7 +1137,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg << screen->m_ScreenNumber; msg << screen->m_ScreenNumber;
DrawGraphicText( DrawPanel, DC, pos, Color, msg, DrawGraphicText( DrawPanel, DC, pos, Color, msg,
TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, 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; break;
case WS_SHEETS: case WS_SHEETS:
...@@ -1150,7 +1147,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1150,7 +1147,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg << screen->m_NumberOfScreen; msg << screen->m_NumberOfScreen;
DrawGraphicText( DrawPanel, DC, pos, Color, msg, DrawGraphicText( DrawPanel, DC, pos, Color, msg,
TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, 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; break;
case WS_COMPANY_NAME: case WS_COMPANY_NAME:
...@@ -1173,10 +1171,9 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1173,10 +1171,9 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
case WS_UPPER_SEGMENT: case WS_UPPER_SEGMENT:
case WS_LEFT_SEGMENT: case WS_LEFT_SEGMENT:
WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy =
WS_MostUpperLine.m_Endy = WS_MostLeftLine.m_Posy = STAMP_OY;
WS_MostLeftLine.m_Posy = STAMP_OY; pos.y = ( refy - WsItem->m_Posy ) * scale;
pos.y = (refy - WsItem->m_Posy) * scale;
case WS_SEGMENT: case WS_SEGMENT:
xg = Sheet->m_Size.x - xg = Sheet->m_Size.x -
...@@ -1193,8 +1190,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -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 ) for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext )
{ {
pos.x = (refx - WsItem->m_Posx) * scale; pos.x = ( refx - WsItem->m_Posx ) * scale;
pos.y = (refy - WsItem->m_Posy) * scale; pos.y = ( refy - WsItem->m_Posy ) * scale;
msg.Empty(); msg.Empty();
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
...@@ -1238,7 +1235,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1238,7 +1235,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
break; break;
case WS_LEFT_SEGMENT_D: case WS_LEFT_SEGMENT_D:
pos.y = (refy - WsItem->m_Posy) * scale; pos.y = ( refy - WsItem->m_Posy ) * scale;
case WS_SEGMENT_D: case WS_SEGMENT_D:
xg = Sheet->m_Size.x - xg = Sheet->m_Size.x -
...@@ -1253,7 +1250,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1253,7 +1250,7 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
} }
#else #else
refx = Sheet->m_Size.x - Sheet->m_RightMargin - GRID_REF_W; 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 ) 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 ...@@ -1269,8 +1266,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg += screen->m_Date; msg += screen->m_Date;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, true ); width, false, true );
break; break;
case WS_REV: case WS_REV:
...@@ -1291,8 +1288,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1291,8 +1288,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg += wxT( " " ) + GetBuildVersion(); msg += wxT( " " ) + GetBuildVersion();
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
break; break;
case WS_SIZESHEET: case WS_SIZESHEET:
...@@ -1301,8 +1298,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1301,8 +1298,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg += Sheet->m_Name; msg += Sheet->m_Name;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
break; break;
...@@ -1312,21 +1309,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1312,21 +1309,22 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen; msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
break; break;
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; 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 ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
msg << fname << wxT( "." ) << fext; msg << fname << wxT( "." ) << fext;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
} }
break; break;
...@@ -1336,8 +1334,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1336,8 +1334,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
msg += GetScreenDesc(); msg += GetScreenDesc();
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
break; break;
...@@ -1375,8 +1373,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1375,8 +1373,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{ {
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
} }
break; break;
...@@ -1389,8 +1387,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1389,8 +1387,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{ {
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
} }
break; break;
...@@ -1403,8 +1401,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1403,8 +1401,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{ {
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
} }
break; break;
...@@ -1417,8 +1415,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -1417,8 +1415,8 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w
{ {
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
false, false ); width, false, false );
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
} }
break; break;
...@@ -1448,16 +1446,14 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_w ...@@ -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 /** Function GetXYSheetReferences
* Return the X,Y sheet references where the point position is located * Return the X,Y sheet references where the point position is located
* @param aScreen = screen to use * @param aScreen = screen to use
* @param aPosition = position to identify by YX ref * @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) * @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; Ki_PageDescr* Sheet = aScreen->m_CurrentSheetDesc;
int ii, xg, yg, ipas, gxpas, gypas; int ii, xg, yg, ipas, gxpas, gypas;
...@@ -1467,7 +1463,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP ...@@ -1467,7 +1463,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
if( Sheet == NULL ) if( Sheet == NULL )
{ {
DisplayError( this, DisplayError( this,
wxT( "WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet" ) ); wxT( "WinEDA_DrawFrame::GetXYSheetReferences() error: NULL Sheet" ) );
return msg; return msg;
} }
...@@ -1481,9 +1477,9 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP ...@@ -1481,9 +1477,9 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
msg << wxT( "?" ); msg << wxT( "?" );
else else
{ {
ipas = (yg - refy) / PAS_REF; // ipas = Y count sections ipas = ( yg - refy ) / PAS_REF; // ipas = Y count sections
gypas = ( yg - refy) / ipas; // gypas = Y section size gypas = ( yg - refy ) / ipas; // gypas = Y section size
ii = (aPosition.y - refy) / gypas; ii = ( aPosition.y - refy ) / gypas;
msg.Printf( wxT( "%c" ), 'A' + ii ); msg.Printf( wxT( "%c" ), 'A' + ii );
} }
...@@ -1492,10 +1488,10 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP ...@@ -1492,10 +1488,10 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
msg << wxT( "?" ); msg << wxT( "?" );
else else
{ {
ipas = (xg - refx) / PAS_REF; // ipas = X count sections ipas = ( xg - refx ) / PAS_REF; // ipas = X count sections
gxpas = ( xg - refx) / ipas; // gxpas = X section size gxpas = ( xg - refx ) / ipas; // gxpas = X section size
ii = (aPosition.x - refx) / gxpas; ii = ( aPosition.x - refx ) / gxpas;
msg << ii + 1; msg << ii + 1;
} }
...@@ -1503,9 +1499,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP ...@@ -1503,9 +1499,7 @@ wxString WinEDA_DrawFrame::GetXYSheetReferences( BASE_SCREEN* aScreen, const wxP
} }
/*********************************************************************/
wxString WinEDA_DrawFrame::GetScreenDesc() wxString WinEDA_DrawFrame::GetScreenDesc()
/*********************************************************************/
{ {
wxString msg; wxString msg;
......
/**********************************************************/ /***************/
/* wxwineda.cpp - fonctions des classes du type WinEDAxxxx */ /* wxwineda.cpp */
/**********************************************************/ /****************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include "wxstruct.h" #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, WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
const wxString& Title, const wxString& Title,
const wxString& TextToEdit, const wxString& TextToEdit,
...@@ -26,26 +26,26 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, ...@@ -26,26 +26,26 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
m_Title = new wxStaticText( parent, -1, Title ); 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; long style = 0;
if (Multiline) if (Multiline)
style = wxTE_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 ); m_FrameText->SetInsertionPoint( 1 );
BoxSizer->Add( m_FrameText, BoxSizer->Add( m_FrameText,
0, 0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 ); 5 );
} }
/****************************************/
wxString WinEDA_EnterText::GetValue() wxString WinEDA_EnterText::GetValue()
/****************************************/
{ {
m_Modify = m_FrameText->IsModified(); m_Modify = m_FrameText->IsModified();
m_NewText = m_FrameText->GetValue(); m_NewText = m_FrameText->GetValue();
...@@ -82,14 +82,17 @@ void WinEDA_EnterText::Enable( bool enbl ) ...@@ -82,14 +82,17 @@ void WinEDA_EnterText::Enable( bool enbl )
} }
/*********************************************************************/ /*******************************************************/
/* Classe pour editer un texte graphique + dimension en INCHES ou MM */ /* Class to edit a graphic + text size in INCHES or MM */
/*********************************************************************/ /*******************************************************/
WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent, WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
const wxString& Title, const wxString& Title,
const wxString& TextToEdit, int textsize, const wxString& TextToEdit,
int units, wxBoxSizer* BoxSizer, int framelen, int textsize,
int internal_unit ) int units,
wxBoxSizer* BoxSizer,
int framelen,
int internal_unit )
{ {
m_Units = units; m_Units = units;
m_Internal_Unit = internal_unit; m_Internal_Unit = internal_unit;
...@@ -97,7 +100,8 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent, ...@@ -97,7 +100,8 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
m_Title = new wxStaticText( parent, -1, Title ); 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 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
...@@ -108,12 +112,14 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent, ...@@ -108,12 +112,14 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_Units ); wxString msg = _( "Size" ) + ReturnUnitSymbol( m_Units );
wxStaticText* text = new wxStaticText( parent, -1, msg ); 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 ); 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 ); BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
} }
...@@ -128,11 +134,12 @@ WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl() ...@@ -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; wxString value;
// Limitation de la taille du texte a de valeurs raisonnables // Limiting the size of the text of reasonable values.
if( textSize < 10 ) if( textSize < 10 )
textSize = 10; textSize = 10;
...@@ -172,7 +179,8 @@ wxString WinEDA_GraphicTextCtrl::GetText() ...@@ -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; int textsize;
...@@ -205,16 +213,15 @@ void WinEDA_GraphicTextCtrl::Enable( bool state ) ...@@ -205,16 +213,15 @@ void WinEDA_GraphicTextCtrl::Enable( bool state )
} }
/*****************************************************************/ /********************************************************/
/* Classe pour afficher et editer une coordonne en INCHES ou MM */ /* Class to display and edit a coordinated INCHES or MM */
/*****************************************************************/ /********************************************************/
WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
const wxString& title, const wxString& title,
const wxPoint& pos_to_edit, const wxPoint& pos_to_edit,
int units, int units,
wxBoxSizer* BoxSizer, wxBoxSizer* BoxSizer,
int internal_unit ) int internal_unit )
{ {
wxString text; wxString text;
...@@ -225,10 +232,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent, ...@@ -225,10 +232,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
else else
text = title; text = title;
text += _( "X" ) + ReturnUnitSymbol( m_Units ); 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 ); BoxSizer->Add( m_TextX, 0,
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition ); 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 ); BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
...@@ -238,11 +247,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent, ...@@ -238,11 +247,12 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
else else
text = title; text = title;
text += _( "Y" ) + ReturnUnitSymbol( m_Units ); 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 ); BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
...@@ -259,12 +269,9 @@ WinEDA_PositionCtrl::~WinEDA_PositionCtrl() ...@@ -259,12 +269,9 @@ WinEDA_PositionCtrl::~WinEDA_PositionCtrl()
} }
/******************************************/ /* Returns (in internal units) to coordinate between (in user units)
wxPoint WinEDA_PositionCtrl::GetValue()
/******************************************/
/* Retourne (en unites internes) les coordonnes entrees (en unites utilisateur)
*/ */
wxPoint WinEDA_PositionCtrl::GetValue()
{ {
wxPoint coord; wxPoint coord;
double value = 0; double value = 0;
...@@ -278,18 +285,14 @@ wxPoint WinEDA_PositionCtrl::GetValue() ...@@ -278,18 +285,14 @@ wxPoint WinEDA_PositionCtrl::GetValue()
} }
/************************************************************/
void WinEDA_PositionCtrl::Enable( bool x_win_on, bool y_win_on ) void WinEDA_PositionCtrl::Enable( bool x_win_on, bool y_win_on )
/************************************************************/
{ {
m_FramePosX->Enable( x_win_on ); m_FramePosX->Enable( x_win_on );
m_FramePosY->Enable( y_win_on ); m_FramePosY->Enable( y_win_on );
} }
/***********************************************************/
void WinEDA_PositionCtrl::SetValue( int x_value, int y_value ) void WinEDA_PositionCtrl::SetValue( int x_value, int y_value )
/***********************************************************/
{ {
wxString msg; wxString msg;
...@@ -320,9 +323,7 @@ WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title, ...@@ -320,9 +323,7 @@ WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
} }
/*************************************/
wxSize WinEDA_SizeCtrl::GetValue() wxSize WinEDA_SizeCtrl::GetValue()
/*************************************/
{ {
wxPoint pos = WinEDA_PositionCtrl::GetValue(); wxPoint pos = WinEDA_PositionCtrl::GetValue();
wxSize size; wxSize size;
...@@ -333,15 +334,9 @@ wxSize WinEDA_SizeCtrl::GetValue() ...@@ -333,15 +334,9 @@ wxSize WinEDA_SizeCtrl::GetValue()
} }
/***********************************************************************/ /**************************************************************/
/* Classe pour afficher et editer une dimension en INCHES MM ou autres*/ /* Class to display and edit a dimension INCHES, MM, or other */
/***********************************************************************/ /**************************************************************/
/* Unites:
* si units = 0 : unite = inch
* si units = 1 : unite = mm
* si units >1 : affichage direct
*/
WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title,
int value, int units, wxBoxSizer* BoxSizer, int value, int units, wxBoxSizer* BoxSizer,
int internal_unit ) int internal_unit )
...@@ -353,17 +348,19 @@ WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, ...@@ -353,17 +348,19 @@ WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title,
m_Value = value; m_Value = value;
label += ReturnUnitSymbol( m_Units ); 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 ); m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl, BoxSizer->Add( m_ValueCtrl,
0, 0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 ); 5 );
} }
...@@ -374,9 +371,7 @@ WinEDA_ValueCtrl::~WinEDA_ValueCtrl() ...@@ -374,9 +371,7 @@ WinEDA_ValueCtrl::~WinEDA_ValueCtrl()
} }
/***********************************/
int WinEDA_ValueCtrl::GetValue() int WinEDA_ValueCtrl::GetValue()
/***********************************/
{ {
int coord; int coord;
wxString txtvalue = m_ValueCtrl->GetValue(); wxString txtvalue = m_ValueCtrl->GetValue();
...@@ -386,9 +381,7 @@ int WinEDA_ValueCtrl::GetValue() ...@@ -386,9 +381,7 @@ int WinEDA_ValueCtrl::GetValue()
} }
/********************************************/
void WinEDA_ValueCtrl::SetValue( int new_value ) void WinEDA_ValueCtrl::SetValue( int new_value )
/********************************************/
{ {
wxString buffer; wxString buffer;
...@@ -399,7 +392,6 @@ void WinEDA_ValueCtrl::SetValue( int new_value ) ...@@ -399,7 +392,6 @@ void WinEDA_ValueCtrl::SetValue( int new_value )
} }
/* Active ou desactive la frame: */
void WinEDA_ValueCtrl::Enable( bool enbl ) void WinEDA_ValueCtrl::Enable( bool enbl )
{ {
m_ValueCtrl->Enable( enbl ); m_ValueCtrl->Enable( enbl );
...@@ -407,9 +399,9 @@ void WinEDA_ValueCtrl::Enable( bool enbl ) ...@@ -407,9 +399,9 @@ void WinEDA_ValueCtrl::Enable( bool enbl )
} }
/***************************************************************/ /**********************************************************************/
/* Classe 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, WinEDA_DFloatValueCtrl::WinEDA_DFloatValueCtrl( wxWindow* parent,
const wxString& title, const wxString& title,
double value, double value,
...@@ -458,7 +450,6 @@ void WinEDA_DFloatValueCtrl::SetValue( double new_value ) ...@@ -458,7 +450,6 @@ void WinEDA_DFloatValueCtrl::SetValue( double new_value )
} }
/* Active ou desactive la frame: */
void WinEDA_DFloatValueCtrl::Enable( bool enbl ) void WinEDA_DFloatValueCtrl::Enable( bool enbl )
{ {
m_ValueCtrl->Enable( enbl ); m_ValueCtrl->Enable( enbl );
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
/************/ /************/
/* /*
* Fonctions de gestion du zoom, du pas de grille et du * Manage zoom, grid step, and auto crop.
* recadrage automatique
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -16,9 +15,6 @@ ...@@ -16,9 +15,6 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "wxstruct.h" #include "wxstruct.h"
/**************************************************/
void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
/**************************************************/
/** Compute draw offset (scroll bars and draw parameters) /** Compute draw offset (scroll bars and draw parameters)
* in order to have the current graphic cursor position at the screen center * in order to have the current graphic cursor position at the screen center
...@@ -27,6 +23,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) ...@@ -27,6 +23,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
* *
* Note: Mac OS ** does not ** allow moving mouse cursor by program. * Note: Mac OS ** does not ** allow moving mouse cursor by program.
*/ */
void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
{ {
PutOnGrid( &(GetBaseScreen()->m_Curseur) ); PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars(); AdjustScrollBars();
...@@ -40,12 +37,10 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) ...@@ -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 /** Adjust the coordinate to the nearest grid value
* @param coord = coordinate to adjust * @param coord = coordinate to adjust
*/ */
void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
{ {
wxRealPoint grid_size = GetBaseScreen()->GetGridSize(); wxRealPoint grid_size = GetBaseScreen()->GetGridSize();
...@@ -60,26 +55,20 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) ...@@ -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 /** 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() ) ) if( GetBaseScreen()->SetZoom( BestZoom() ) )
Recadre_Trace( move_mouse_cursor ); 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 /** Compute the zoom factor and the new draw offset to draw the
* selected area (Rect) in full window screen * selected area (Rect) in full window screen
* @param Rect = selected area to show after zooming * @param Rect = selected area to show after zooming
*/ */
void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
{ {
double scalex, bestscale; double scalex, bestscale;
wxSize size; wxSize size;
...@@ -98,12 +87,10 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect ) ...@@ -98,12 +87,10 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
} }
/******************************************************/ /** Function OnZoom
void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
/******************************************************/
/** Function OnZoom(
* Called from any zoom event (toolbar , hotkey or popup ) * Called from any zoom event (toolbar , hotkey or popup )
*/ */
void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
{ {
if( DrawPanel == NULL ) if( DrawPanel == NULL )
{ {
...@@ -184,13 +171,10 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) ...@@ -184,13 +171,10 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
} }
/*************************************************************/
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
/*************************************************************/
/* add the zoom list menu the the MasterMenu. /* add the zoom list menu the the MasterMenu.
* used in OnRightClick(wxMouseEvent& event) * used in OnRightClick(wxMouseEvent& event)
*/ */
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
{ {
size_t i; size_t i;
int maxZoomIds; int maxZoomIds;
...@@ -228,7 +212,8 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -228,7 +212,8 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar ); GetScreen()->m_ZoomList[i] / GetScreen()->m_ZoomScalar );
else else
msg.Printf( wxT( "%.1f" ), 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, zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
wxEmptyString, wxITEM_CHECK ); wxEmptyString, wxITEM_CHECK );
...@@ -258,7 +243,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu ) ...@@ -258,7 +243,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
} }
else else
{ {
if ( g_UnitMetric == 0 ) // inches if ( g_UnitMetric == 0 ) // inches
msg.Printf( wxT( "%.1f mils" ), gridValue * 1000 ); msg.Printf( wxT( "%.1f mils" ), gridValue * 1000 );
else else
msg.Printf( wxT( "%.3f mm" ), gridValue ); msg.Printf( wxT( "%.3f mm" ), gridValue );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment