Commit ea6eeca1 authored by dickelbeck's avatar dickelbeck

beautification

parent 0f406d3f
/*****************************************/ /*****************************************/
/* Routines generales d'affichage du PCB */ /* Routines generales d'affichage du PCB */
/*****************************************/ /*****************************************/
/* fichier TRACEPCB.CPP */
/* fichier TRACEPCB.CPP */
/* /*
Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ... * Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ...
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -22,122 +23,126 @@ ...@@ -22,122 +23,126 @@
/**********************************************************************************/ /**********************************************************************************/
void WinEDA_DrawPanel::PrintPage(wxDC *DC, bool Print_Sheet_Ref, int printmasklayer) void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmasklayer )
/**********************************************************************************/ /**********************************************************************************/
/* routine de trace du pcb, avec selection des couches */ /* routine de trace du pcb, avec selection des couches */
{ {
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
save_opt = DisplayOpt; save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS ) DisplayOpt.DisplayPadFill = FILLED; if( printmasklayer & ALL_CU_LAYERS )
else DisplayOpt.DisplayPadFill = SKETCH; DisplayOpt.DisplayPadFill = FILLED;
DisplayOpt.DisplayPadNum = 0; else
DisplayOpt.DisplayPadNoConn = 0; DisplayOpt.DisplayPadFill = SKETCH;
DisplayOpt.DisplayPadIsol = 0; DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayModEdge = FILLED; DisplayOpt.DisplayPadNoConn = 0;
DisplayOpt.DisplayModText = FILLED; DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayPcbTrackFill = FILLED; DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayTrackIsol = 0; DisplayOpt.DisplayModText = FILLED;
DisplayOpt.DisplayDrawItems = FILLED; DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.DisplayZones = 1; DisplayOpt.DisplayTrackIsol = 0;
DisplayOpt.DisplayDrawItems = FILLED;
((WinEDA_GerberFrame*)m_Parent)->Trace_Gerber(DC, GR_COPY); DisplayOpt.DisplayZones = 1;
if ( Print_Sheet_Ref ) ( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC, GR_COPY );
m_Parent->TraceWorkSheet(DC, GetScreen(), 0);
if( Print_Sheet_Ref )
DisplayOpt = save_opt; m_Parent->TraceWorkSheet( DC, GetScreen(), 0 );
DisplayOpt = save_opt;
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_GerberFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg) void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/ /*******************************************************************/
/* Trace le PCB, et les elements complementaires ( axes, grille .. ) /* Trace le PCB, et les elements complementaires ( axes, grille .. )
*/ */
{ {
PCB_SCREEN * screen = GetScreen(); PCB_SCREEN* screen = GetScreen();
if ( ! m_Pcb ) return;
ActiveScreen = screen;
GRSetDrawMode(DC, GR_COPY);
if ( EraseBg ) DrawPanel->EraseScreen(DC); if( !m_Pcb )
return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
DrawPanel->DrawBackGround(DC); if( EraseBg )
DrawPanel->EraseScreen( DC );
Trace_Gerber(DC, GR_OR); DrawPanel->DrawBackGround( DC );
TraceWorkSheet(DC, screen, 0);
Affiche_Status_Box();
if( DrawPanel->ManageCurseur ) Trace_Gerber( DC, GR_OR );
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); TraceWorkSheet( DC, screen, 0 );
Affiche_Status_Box();
DrawPanel->Trace_Curseur(DC); if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->Trace_Curseur( DC );
} }
/********************************************************/ /********************************************************/
void WinEDA_GerberFrame::Trace_Gerber(wxDC * DC, int mode) void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int mode )
/********************************************************/ /********************************************************/
/* Trace l'ensemble des elements du PCB sur l'ecran actif*/ /* Trace l'ensemble des elements du PCB sur l'ecran actif*/
{ {
if( !m_Pcb )
if ( ! m_Pcb ) return; return;
// Draw tracks and flashes // Draw tracks and flashes
Trace_Pistes(DrawPanel, DC, m_Pcb, mode); Trace_Pistes( DrawPanel, DC, m_Pcb, mode );
// Draw filled polygons // Draw filled polygons
#define NBMAX 2000 #define NBMAX 2000
TRACK * track; TRACK* track;
int nbpoints = 0; int nbpoints = 0;
int nbpointsmax = NBMAX; int nbpointsmax = NBMAX;
int * coord = (int*) malloc(nbpointsmax * sizeof (int) * 2); int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 );
int * ptcoord = coord; int* ptcoord = coord;
track = m_Pcb->m_Zone; track = m_Pcb->m_Zone;
for ( ; track != NULL ; track = track->Next() ) for( ; track != NULL; track = track->Next() )
{ {
if ( track->m_NetCode == 0 ) // StartPoint if( track->m_NetCode == 0 ) // StartPoint
{ {
if ( nbpoints ) if( nbpoints )
{ {
int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; int Color = g_DesignSettings.m_LayerColor[track->m_Layer];
GRClosedPoly(&DrawPanel->m_ClipBox, DC, nbpoints, coord, GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
1, Color, Color); 1, Color, Color );
} }
nbpoints = 2; nbpoints = 2;
ptcoord = coord; ptcoord = coord;
* ptcoord = track->m_Start.x; ptcoord++; *ptcoord = track->m_Start.x; ptcoord++;
* ptcoord = track->m_Start.y; ptcoord++; *ptcoord = track->m_Start.y; ptcoord++;
* ptcoord = track->m_End.x; ptcoord++; *ptcoord = track->m_End.x; ptcoord++;
* ptcoord = track->m_End.y; ptcoord++; *ptcoord = track->m_End.y; ptcoord++;
} }
else else
{ {
if ( nbpoints >= nbpointsmax ) if( nbpoints >= nbpointsmax )
{ {
nbpointsmax *= 2; nbpointsmax *= 2;
coord = (int*) realloc(coord, nbpointsmax * sizeof (int) * 2); coord = (int*) realloc( coord, nbpointsmax * sizeof(int) * 2 );
ptcoord = coord + nbpointsmax; ptcoord = coord + nbpointsmax;
} }
nbpoints++; nbpoints++;
* ptcoord = track->m_End.x; ptcoord++; *ptcoord = track->m_End.x; ptcoord++;
* ptcoord = track->m_End.y; ptcoord++; *ptcoord = track->m_End.y; ptcoord++;
} }
if ( track->Next() == NULL ) // Last point if( track->Next() == NULL ) // Last point
{ {
int Color = g_DesignSettings.m_LayerColor[track->m_Layer]; int Color = g_DesignSettings.m_LayerColor[track->m_Layer];
GRClosedPoly(&DrawPanel->m_ClipBox, DC, nbpoints, coord, GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
1, Color, Color); 1, Color, Color );
} }
} }
free(coord); free( coord );
if ( DisplayOpt.DisplayPadNum ) if( DisplayOpt.DisplayPadNum )
Affiche_DCodes_Pistes(DrawPanel, DC, m_Pcb, GR_COPY); Affiche_DCodes_Pistes( DrawPanel, DC, m_Pcb, GR_COPY );
GetScreen()->ClrRefreshReq(); GetScreen()->ClrRefreshReq();
} }
/******************************************************************/ /******************************************************************/
/* drawframe.cpp - fonctions des classes du type WinEDA_DrawFrame */ /* drawframe.cpp - fonctions des classes du type WinEDA_DrawFrame */
/******************************************************************/ /******************************************************************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -34,792 +34,854 @@ ...@@ -34,792 +34,854 @@
#include "id.h" #include "id.h"
/*******************************************************/ /*******************************************************/
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */ /* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/*******************************************************/ /*******************************************************/
WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow * father, int idtype,
WinEDA_App *parent, const wxString & title,
const wxPoint& pos, const wxSize& size):
WinEDA_BasicFrame(father, idtype, parent, title, pos, size)
{
wxSize minsize;
m_VToolBar = NULL;
m_AuxVToolBar = NULL;
m_OptionsToolBar = NULL;
m_AuxiliaryToolBar = NULL;
m_SelGridBox = NULL;
m_SelZoomBox = NULL;
m_ZoomMaxValue = 128;
DrawPanel = NULL;
MsgPanel = NULL;
m_CurrentScreen = NULL;
m_MenuBar = NULL; // menu du haut d'ecran
m_ID_current_state = 0;
m_HTOOL_current_state = 0;
m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines
m_Draw_Grid = FALSE; // TRUE pour avoir la axes dessinee
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin
m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprim
m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
// nombre d'unites internes pour 1 pouce
// = 1000 pour schema, = 10000 pour PCB
m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
if( (m_Ident == PCB_FRAME) || (m_Ident == GERBER_FRAME) ||
(m_Ident == CVPCB_DISPLAY_FRAME) ||
(m_Ident == MODULE_EDITOR_FRAME)
)
m_InternalUnits = PCB_INTERNAL_UNIT ;
minsize.x = 470;
minsize.y = 350 + m_MsgFrameHeight;
SetSizeHints( minsize.x, minsize.y, -1,-1, -1,-1);
/* Verification des parametres de creation */
if ( (size.x < minsize.x) || (size.y < minsize.y) )
SetSize(0,0, minsize.x, minsize.y);
// Creation de la ligne de status
int dims[6] = { -1, 60, 130, 130, 40, 100};
CreateStatusBar(6);
SetStatusWidths(6,dims);
// Create child subwindows.
GetClientSize(&m_FrameSize.x, &m_FrameSize.y); /* dimx, dimy = dimensions utiles de la
zone utilisateur de la fenetre principale */
m_FramePos.x = m_FramePos.y = 0;
m_FrameSize.y -= m_MsgFrameHeight;
if ( m_Ident != DISPLAY3D_FRAME)
{
DrawPanel = new WinEDA_DrawPanel(this, -1, wxPoint(0, 0), m_FrameSize);
MsgPanel = new WinEDA_MsgPanel(this, -1, wxPoint(0, m_FrameSize.y),
wxSize(m_FrameSize.x, m_MsgFrameHeight));
MsgPanel->SetBackgroundColour(wxColour(ColorRefs[LIGHTGRAY].m_Red,
ColorRefs[LIGHTGRAY].m_Green,
ColorRefs[LIGHTGRAY].m_Blue ));
}
WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
WinEDA_App* parent, const wxString& title,
const wxPoint& pos, const wxSize& size ) :
WinEDA_BasicFrame( father, idtype, parent, title, pos, size )
{
wxSize minsize;
m_VToolBar = NULL;
m_AuxVToolBar = NULL;
m_OptionsToolBar = NULL;
m_AuxiliaryToolBar = NULL;
m_SelGridBox = NULL;
m_SelZoomBox = NULL;
m_ZoomMaxValue = 128;
DrawPanel = NULL;
MsgPanel = NULL;
m_CurrentScreen = NULL;
m_MenuBar = NULL; // menu du haut d'ecran
m_ID_current_state = 0;
m_HTOOL_current_state = 0;
m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines
m_Draw_Grid = FALSE; // TRUE pour avoir la axes dessinee
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin
m_Print_Sheet_Ref = TRUE; // TRUE pour avoir le cartouche imprim
m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
// nombre d'unites internes pour 1 pouce
// = 1000 pour schema, = 10000 pour PCB
m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
if( (m_Ident == PCB_FRAME) || (m_Ident == GERBER_FRAME)
|| (m_Ident == CVPCB_DISPLAY_FRAME)
|| (m_Ident == MODULE_EDITOR_FRAME)
)
m_InternalUnits = PCB_INTERNAL_UNIT;
minsize.x = 470;
minsize.y = 350 + m_MsgFrameHeight;
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
/* Verification des parametres de creation */
if( (size.x < minsize.x) || (size.y < minsize.y) )
SetSize( 0, 0, minsize.x, minsize.y );
// Creation de la ligne de status
static const int dims[6] = { -1, 60, 130, 130, 40, 100 };
CreateStatusBar( 6 );
SetStatusWidths( 6, dims );
// Create child subwindows.
GetClientSize( &m_FrameSize.x, &m_FrameSize.y );/* dimx, dimy = dimensions utiles de la
* zone utilisateur de la fenetre principale */
m_FramePos.x = m_FramePos.y = 0;
m_FrameSize.y -= m_MsgFrameHeight;
if( m_Ident != DISPLAY3D_FRAME )
{
DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize );
MsgPanel = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ),
wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
ColorRefs[LIGHTGRAY].m_Green,
ColorRefs[LIGHTGRAY].m_Blue ) );
}
} }
/****************************************/ /****************************************/
WinEDA_DrawFrame::~WinEDA_DrawFrame(void) WinEDA_DrawFrame::~WinEDA_DrawFrame( void )
/****************************************/ /****************************************/
{ {
if ( DrawPanel ) // for WinEDA3D_DrawFrame DrawPanel == NULL ! if( DrawPanel ) // for WinEDA3D_DrawFrame DrawPanel == NULL !
m_Parent->m_EDA_Config->Write( wxT("AutoPAN"), DrawPanel->m_AutoPAN_Enable); m_Parent->m_EDA_Config->Write( wxT( "AutoPAN" ), DrawPanel->m_AutoPAN_Enable );
} }
/****************************************************************/ /****************************************************************/
void WinEDA_DrawFrame::AddFontSelectionMenu(wxMenu * main_menu) void WinEDA_DrawFrame::AddFontSelectionMenu( wxMenu* main_menu )
/*****************************************************************/ /*****************************************************************/
/* create the submenu for fonte selection and setup fonte size
*/ /* create the submenu for fonte selection and setup font size
*/
{ {
wxMenu * fontmenu = new wxMenu(); wxMenu* fontmenu = new wxMenu();
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_DIALOG, _("font for dialog boxes"),
fonts_xpm ); ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_DIALOG, _( "font for dialog boxes" ),
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _("font for info display"), fonts_xpm );
fonts_xpm ); ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _( "font for info display" ),
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_STATUS, _("font for Status Line"), fonts_xpm );
fonts_xpm ); ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_STATUS, _( "font for Status Line" ),
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(main_menu, fontmenu, fonts_xpm );
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( main_menu, fontmenu,
ID_PREFERENCES_FONT, _("&Font selection"), ID_PREFERENCES_FONT, _("&Font selection"),
_("Choose font type and size for dialogs, infos and status box"), _("Choose font type and size for dialogs, infos and status box"),
fonts_xpm); fonts_xpm );
} }
/********************************************************************/ /********************************************************************/
void WinEDA_DrawFrame::ProcessFontPreferences(wxCommandEvent& event) void WinEDA_DrawFrame::ProcessFontPreferences( wxCommandEvent& event )
/********************************************************************/ /********************************************************************/
{ {
int id = event.GetId(); int id = event.GetId();
wxFont font; wxFont font;
switch (id) switch( id )
{ {
case ID_PREFERENCES_FONT:
case ID_PREFERENCES_FONT_DIALOG:
case ID_PREFERENCES_FONT_STATUS:
WinEDA_BasicFrame::ProcessFontPreferences( id );
break;
case ID_PREFERENCES_FONT: case ID_PREFERENCES_FONT_INFOSCREEN:
case ID_PREFERENCES_FONT_DIALOG: {
case ID_PREFERENCES_FONT_STATUS: font = wxGetFontFromUser( this, *g_MsgFont );
WinEDA_BasicFrame::ProcessFontPreferences(id); if( font.Ok() )
break; {
int pointsize = font.GetPointSize();
*g_MsgFont = font;
g_MsgFontPointSize = pointsize;
}
break;
}
default:
case ID_PREFERENCES_FONT_INFOSCREEN: DisplayError( this, wxT( "WinEDA_DrawFrame::ProcessFontPreferences Internal Error" ) );
{ break;
font = wxGetFontFromUser(this, *g_MsgFont); }
if ( font.Ok() )
{
int pointsize = font.GetPointSize();
*g_MsgFont = font;
g_MsgFontPointSize = pointsize;
}
break;
}
default: DisplayError(this, wxT("WinEDA_DrawFrame::ProcessFontPreferences Internal Error") );
break;
}
} }
/**************************************************************/ /**************************************************************/
void WinEDA_DrawFrame::Affiche_Message(const wxString & message) void WinEDA_DrawFrame::Affiche_Message( const wxString& message )
/**************************************************************/ /**************************************************************/
/* /*
Affiche un message en bas de l'ecran * Affiche un message en bas de l'ecran
*/ */
{ {
SetStatusText(message); SetStatusText( message );
} }
/****************************************/ /****************************************/
void WinEDA_DrawFrame::EraseMsgBox(void) void WinEDA_DrawFrame::EraseMsgBox( void )
/****************************************/ /****************************************/
{ {
if ( MsgPanel ) MsgPanel->EraseMsgBox(); if( MsgPanel )
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 )
DrawPanel->m_CanStartBlock = -1; DrawPanel->m_CanStartBlock = -1;
event.Skip(); // required under wxMAC event.Skip(); // required under wxMAC
} }
/****************************************************/ /****************************************************/
void WinEDA_DrawFrame::OnMenuOpen(wxMenuEvent& event) void WinEDA_DrawFrame::OnMenuOpen( wxMenuEvent& event )
/****************************************************/ /****************************************************/
{ {
if ( DrawPanel ) DrawPanel->m_CanStartBlock = -1; if( DrawPanel )
event.Skip(); DrawPanel->m_CanStartBlock = -1;
event.Skip();
} }
/*******************************************************/ /*******************************************************/
void WinEDA_DrawFrame::ReCreateAuxiliaryToolbar(void) // fonction virtuelle void WinEDA_DrawFrame::ReCreateAuxiliaryToolbar( void ) // fonction virtuelle
/*******************************************************/ /*******************************************************/
{ {
} }
/********************************************/ /********************************************/
void WinEDA_DrawFrame::ReCreateMenuBar(void) // fonction virtuelle void WinEDA_DrawFrame::ReCreateMenuBar( void ) // fonction virtuelle
/********************************************/ /********************************************/
{ {
} }
/****************************************************/ /****************************************************/
void WinEDA_DrawFrame::OnHotKey(wxDC * DC, int hotkey, void WinEDA_DrawFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct * DrawStruct) // fonction virtuelle EDA_BaseStruct* DrawStruct ) // fonction virtuelle
/****************************************************/ /****************************************************/
{ {
} }
/**************************************************************/ /**************************************************************/
void WinEDA_DrawFrame::ToolOnRightClick(wxCommandEvent & event) // fonction virtuelle void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event ) // fonction virtuelle
/**************************************************************/ /**************************************************************/
{ {
} }
/********************************************************/ /********************************************************/
void WinEDA_DrawFrame::OnSelectGrid(wxCommandEvent& event) // fonction virtuelle void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event ) // fonction virtuelle
/********************************************************/ /********************************************************/
{ {
if ( m_SelGridBox == NULL ) return; //Ne devrait pas se produire! if( m_SelGridBox == NULL )
return; //Ne devrait pas se produire!
int id = m_SelGridBox->GetChoice(); int id = m_SelGridBox->GetChoice();
if ( id < 0 ) return; if( id < 0 )
return;
m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
wxSize grid = m_CurrentScreen->GetGrid(); wxSize grid = m_CurrentScreen->GetGrid();
m_CurrentScreen->SetGrid(g_GridList[id]); m_CurrentScreen->SetGrid( g_GridList[id] );
wxSize newgrid = m_CurrentScreen->GetGrid(); wxSize newgrid = m_CurrentScreen->GetGrid();
if ( newgrid.x != grid.x || newgrid.y != grid.y ) if( newgrid.x != grid.x || newgrid.y != grid.y )
Recadre_Trace(FALSE); Recadre_Trace( FALSE );
} }
#ifndef EESCHEMA #ifndef EESCHEMA
/**************************************************************/ /**************************************************************/
void WinEDA_DrawFrame::GeneralControle(wxDC *DC, wxPoint Mouse) void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/**************************************************************/ /**************************************************************/
/* Fonction virtuelle /* Fonction virtuelle
traitement des touches de fonctions utilisees ds tous les menus * traitement des touches de fonctions utilisees ds tous les menus
Zoom * Zoom
Redessin d'ecran * Redessin d'ecran
Cht Unites * Cht Unites
Cht couches * Cht couches
Remise a 0 de l'origine des coordonnees relatives * Remise a 0 de l'origine des coordonnees relatives
*/ */
{ {
} }
#endif #endif
/********************************************************/ /********************************************************/
void WinEDA_DrawFrame::OnSelectZoom(wxCommandEvent& event) // fonction virtuelle void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event ) // fonction virtuelle
/********************************************************/ /********************************************************/
/* Set the zoom when selected by the Zoom List Box /* Set the zoom when selected by the Zoom List Box
Note: * Note:
position 0 = Fit in Page * position 0 = Fit in Page
position >= 1 = zoom (1 to zoom max) * position >= 1 = zoom (1 to zoom max)
last position : special zoom * last position : special zoom
*/ */
{ {
if ( m_SelZoomBox == NULL ) return; //Ne devrait pas se produire! if( m_SelZoomBox == NULL )
return; //Ne devrait pas se produire!
int id = m_SelZoomBox->GetChoice();
int id = m_SelZoomBox->GetChoice();
if ( id < 0 ) return; // No selection
if( id < 0 )
if ( id == 0 ) // Auto zoom (Fit in Page) return; // No selection
{
Zoom_Automatique(TRUE); if( id == 0 ) // Auto zoom (Fit in Page)
} {
else if ( id == (int)(m_SelZoomBox->GetCount()-1) ) // Dummy position: unlisted zoom Zoom_Automatique( TRUE );
return ; }
else // zooml 1 to zoom max else if( id == (int) (m_SelZoomBox->GetCount() - 1) ) // Dummy position: unlisted zoom
{ return;
id --; else // zooml 1 to zoom max
int zoom = 1 << id; {
if ( zoom > m_ZoomMaxValue ) zoom = m_ZoomMaxValue; id--;
if ( m_CurrentScreen->GetZoom() == zoom) return; int zoom = 1 << id;
m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); if( zoom > m_ZoomMaxValue )
m_CurrentScreen->SetZoom(zoom); zoom = m_ZoomMaxValue;
Recadre_Trace(FALSE); if( m_CurrentScreen->GetZoom() == zoom )
} return;
m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
m_CurrentScreen->SetZoom( zoom );
Recadre_Trace( FALSE );
}
} }
/********************************************************/ /********************************************************/
void WinEDA_DrawFrame::OnMouseEvent(wxMouseEvent& event) void WinEDA_DrawFrame::OnMouseEvent( wxMouseEvent& event )
/********************************************************/ /********************************************************/
{ {
event.Skip(); event.Skip();
} }
/***********************************************************************/ /***********************************************************************/
// Virtuelle // Virtuelle
void WinEDA_DrawFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos) void WinEDA_DrawFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/***********************************************************************/ /***********************************************************************/
{ {
} }
/***************************************/ /***************************************/
void WinEDA_DrawFrame::SetToolbars(void) void WinEDA_DrawFrame::SetToolbars( void )
/***************************************/ /***************************************/
{ {
DisplayUnitsMsg(); DisplayUnitsMsg();
} }
/********************************************************/ /********************************************************/
void WinEDA_DrawFrame::DisplayToolMsg(const wxString msg) void WinEDA_DrawFrame::DisplayToolMsg( const wxString msg )
/********************************************************/ /********************************************************/
{ {
SetStatusText(msg, 5); SetStatusText( msg, 5 );
} }
/*******************************************/ /*******************************************/
void WinEDA_DrawFrame::DisplayUnitsMsg(void) void WinEDA_DrawFrame::DisplayUnitsMsg( void )
/********************************************/ /********************************************/
/* Display current unit Selection on Statusbar /* Display current unit Selection on Statusbar
*/ */
{ {
wxString msg; wxString msg;
switch( g_UnitMetric )
{
case INCHES:
msg = _( "Inch" );
break;
switch ( g_UnitMetric ) case MILLIMETRE:
{ msg += _( "mm" );
case INCHES: break;
msg = _("Inch");
break;
case MILLIMETRE:
msg += _("mm");
break;
default:
msg += _("??");
break;
}
SetStatusText(msg, 4); default:
msg += _( "??" );
break;
}
SetStatusText( msg, 4 );
} }
/***************************************/ /***************************************/
void WinEDA_DrawFrame::ReDrawPanel(void) void WinEDA_DrawFrame::ReDrawPanel( void )
/***************************************/ /***************************************/
{ {
if ( DrawPanel == NULL ) return; if( DrawPanel == NULL )
wxClientDC dc(DrawPanel); return;
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext(&dc); DrawPanel->PrepareGraphicContext( &dc );
DrawPanel->ReDraw(&dc); DrawPanel->ReDraw( &dc );
} }
/**************************************************/ /**************************************************/
void WinEDA_DrawFrame::OnSize(wxSizeEvent & SizeEv) void WinEDA_DrawFrame::OnSize( wxSizeEvent& SizeEv )
/**************************************************/ /**************************************************/
/* recalcule les dimensions des toolbars et du panel d'affichage /* recalcule les dimensions des toolbars et du panel d'affichage
*/ */
{ {
wxSize size; wxSize size;
wxSize opt_size; wxSize opt_size;
wxSize Vtoolbar_size; wxSize Vtoolbar_size;
wxSize Auxtoolbar_size; wxSize Auxtoolbar_size;
GetClientSize(&size.x, &size.y); GetClientSize( &size.x, &size.y );
m_FrameSize = size; m_FrameSize = size;
size.y -= m_MsgFrameHeight; size.y -= m_MsgFrameHeight;
if ( MsgPanel ) // Positionnement en bas d'ecran if( MsgPanel ) // Positionnement en bas d'ecran
{ {
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 ) // est sous le m_HToolBar
{ {
Auxtoolbar_size.x = size.x; // = Largeur de la frame Auxtoolbar_size.x = size.x; // = Largeur de la frame
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 ) // Toolbar de droite: hauteur = hauteur utile de la frame-Auxtoolbar
{ {
Vtoolbar_size.x = m_VToolBar->GetSize().x; Vtoolbar_size.x = m_VToolBar->GetSize().x;
Vtoolbar_size.y = size.y; Vtoolbar_size.y = size.y;
m_VToolBar->SetSize( Vtoolbar_size); m_VToolBar->SetSize( Vtoolbar_size );
m_VToolBar->Move(size.x - Vtoolbar_size.x, Auxtoolbar_size.y); m_VToolBar->Move( size.x - Vtoolbar_size.x, Auxtoolbar_size.y );
m_VToolBar->Refresh(); m_VToolBar->Refresh();
} }
if( m_AuxVToolBar ) // auxiliary vertical right toolbar, showing tools fo microwave applications if( m_AuxVToolBar ) // auxiliary vertical right toolbar, showing tools fo microwave applications
{ {
Vtoolbar_size.x += m_AuxVToolBar->GetSize().x; Vtoolbar_size.x += m_AuxVToolBar->GetSize().x;
Vtoolbar_size.y = size.y; Vtoolbar_size.y = size.y;
m_AuxVToolBar->SetSize( m_AuxVToolBar->GetSize().x, Vtoolbar_size.y); m_AuxVToolBar->SetSize( m_AuxVToolBar->GetSize().x, Vtoolbar_size.y );
m_AuxVToolBar->Move(size.x - Vtoolbar_size.x, Auxtoolbar_size.y); m_AuxVToolBar->Move( size.x - Vtoolbar_size.x, Auxtoolbar_size.y );
m_AuxVToolBar->Refresh(); m_AuxVToolBar->Refresh();
} }
if( m_OptionsToolBar ) if( m_OptionsToolBar )
{ {
if ( m_OptionsToolBar->m_Horizontal) if( m_OptionsToolBar->m_Horizontal )
{ {
opt_size.x = 0; opt_size.x = 0;
opt_size.y = m_OptionsToolBar->GetSize().y; opt_size.y = m_OptionsToolBar->GetSize().y;
m_OptionsToolBar->SetSize(Auxtoolbar_size.x, 0, size.x, opt_size.y); m_OptionsToolBar->SetSize( Auxtoolbar_size.x, 0, size.x, opt_size.y );
} }
else else
{ {
opt_size.x = m_OptionsToolBar->GetSize().x; opt_size.x = m_OptionsToolBar->GetSize().x;
opt_size.y = 0; opt_size.y = 0;
m_OptionsToolBar->SetSize(0, Auxtoolbar_size.y, opt_size.x, size.y); m_OptionsToolBar->SetSize( 0, Auxtoolbar_size.y, opt_size.x, size.y );
} }
} }
if ( DrawPanel ) if( DrawPanel )
{ {
DrawPanel->SetSize( size.x - Vtoolbar_size.x - opt_size.x, size.y - opt_size.y - 1); DrawPanel->SetSize( size.x - Vtoolbar_size.x - opt_size.x, size.y - opt_size.y - 1 );
DrawPanel->Move(opt_size.x, opt_size.y + Auxtoolbar_size.y + 1); DrawPanel->Move( opt_size.x, opt_size.y + Auxtoolbar_size.y + 1 );
} }
SizeEv.Skip(); SizeEv.Skip();
} }
/*************************************************************************/ /*************************************************************************/
void WinEDA_DrawFrame::SetToolID(int id, int new_cursor_id, void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
const wxString & title) const wxString& title )
/*************************************************************************/ /*************************************************************************/
/* /*
Active l'icone de l'outil selectionne dans le toolbar Vertical * Active l'icone de l'outil selectionne dans le toolbar Vertical
( ou l'outil par defaut ID_NO_SELECT_BUTT si pas de nouvelle selection ) * ( ou l'outil par defaut ID_NO_SELECT_BUTT si pas de nouvelle selection )
if ( id >= 0 ) * if ( id >= 0 )
Met a jour toutes les variables associees: * Met a jour toutes les variables associees:
message, m_ID_current_state, curseur * message, m_ID_current_state, curseur
si ( id < 0 ) * si ( id < 0 )
Met a jour seulement les variables message et curseur * Met a jour seulement les variables message et curseur
*/ */
{ {
// Change Cursor // Change Cursor
if (DrawPanel ) if( DrawPanel )
{ {
DrawPanel->m_PanelDefaultCursor = new_cursor_id; DrawPanel->m_PanelDefaultCursor = new_cursor_id;
DrawPanel->SetCursor( new_cursor_id ); DrawPanel->SetCursor( new_cursor_id );
} }
SetCursor( wxCURSOR_ARROW ); SetCursor( wxCURSOR_ARROW );
DisplayToolMsg(title); DisplayToolMsg( title );
if ( id < 0 ) return; if( id < 0 )
return;
// Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool
if ( m_ID_current_state ) // Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool
{ if( m_ID_current_state )
if ( m_VToolBar ) m_VToolBar->ToggleTool(m_ID_current_state, FALSE); {
if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(m_ID_current_state, FALSE); if( m_VToolBar )
} m_VToolBar->ToggleTool( m_ID_current_state, FALSE );
else if( m_AuxVToolBar )
{ m_AuxVToolBar->ToggleTool( m_ID_current_state, FALSE );
if ( id ) }
{ else
if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, FALSE); {
if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(m_ID_current_state, FALSE); if( id )
} {
else if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); if( m_VToolBar )
} m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, FALSE );
if( m_AuxVToolBar )
// New Tool Actif m_AuxVToolBar->ToggleTool( m_ID_current_state, FALSE );
if ( id ) }
{ else if( m_VToolBar )
if ( m_VToolBar ) m_VToolBar->ToggleTool(id, TRUE); m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
if ( m_AuxVToolBar ) m_AuxVToolBar->ToggleTool(id, TRUE); }
}
else if ( m_VToolBar ) m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); // New Tool Actif
if( id )
m_ID_current_state = id; {
if( m_VToolBar )
m_VToolBar->ToggleTool( id, TRUE );
if( m_AuxVToolBar )
m_AuxVToolBar->ToggleTool( id, TRUE );
}
else if( m_VToolBar )
m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
m_ID_current_state = id;
} }
/********************************************/ /********************************************/
void WinEDA_DrawFrame::OnZoom(int zoom_type) void WinEDA_DrawFrame::OnZoom( int zoom_type )
/********************************************/ /********************************************/
/* Fonction de traitement du zoom /* Fonction de traitement du zoom
Modifie le facteur de zoom et reaffiche l'ecran * Modifie le facteur de zoom et reaffiche l'ecran
Pour les commandes par menu Popup ou par le clavier, le curseur est * Pour les commandes par menu Popup ou par le clavier, le curseur est
replac au centre de l'ecran * replac au centre de l'ecran
*/ */
{ {
if ( DrawPanel == NULL ) return; if( DrawPanel == NULL )
return;
bool move_mouse_cursor = FALSE;
int x,y; bool move_mouse_cursor = FALSE;
wxPoint old_pos; int x, y;
wxPoint old_pos;
DrawPanel->GetViewStart( &x, &y );
old_pos = m_CurrentScreen->m_Curseur; DrawPanel->GetViewStart( &x, &y );
old_pos = m_CurrentScreen->m_Curseur;
switch (zoom_type)
{ switch( zoom_type )
case ID_POPUP_ZOOM_PLUS: {
case ID_ZOOM_PLUS_KEY: case ID_POPUP_ZOOM_PLUS:
move_mouse_cursor = TRUE; case ID_ZOOM_PLUS_KEY:
case ID_ZOOM_PLUS_BUTT: move_mouse_cursor = TRUE;
if ( zoom_type == ID_ZOOM_PLUS_BUTT)
m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); case ID_ZOOM_PLUS_BUTT:
m_CurrentScreen->SetPreviousZoom(); if( zoom_type == ID_ZOOM_PLUS_BUTT )
Recadre_Trace(move_mouse_cursor); m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
break; m_CurrentScreen->SetPreviousZoom();
Recadre_Trace( move_mouse_cursor );
case ID_POPUP_ZOOM_MOINS: break;
case ID_ZOOM_MOINS_KEY:
move_mouse_cursor = TRUE; case ID_POPUP_ZOOM_MOINS:
case ID_ZOOM_MOINS_BUTT: case ID_ZOOM_MOINS_KEY:
if ( zoom_type == ID_ZOOM_MOINS_BUTT) move_mouse_cursor = TRUE;
m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
m_CurrentScreen->SetNextZoom(); case ID_ZOOM_MOINS_BUTT:
Recadre_Trace(move_mouse_cursor); if( zoom_type == ID_ZOOM_MOINS_BUTT )
break; m_CurrentScreen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
m_CurrentScreen->SetNextZoom();
case ID_POPUP_ZOOM_REDRAW: Recadre_Trace( move_mouse_cursor );
case ID_ZOOM_REDRAW_KEY: break;
case ID_ZOOM_REDRAW_BUTT:
ReDrawPanel(); case ID_POPUP_ZOOM_REDRAW:
break; case ID_ZOOM_REDRAW_KEY:
case ID_ZOOM_REDRAW_BUTT:
case ID_POPUP_ZOOM_CENTER: ReDrawPanel();
case ID_ZOOM_CENTER_KEY: break;
Recadre_Trace(TRUE);
break; case ID_POPUP_ZOOM_CENTER:
case ID_ZOOM_CENTER_KEY:
case ID_ZOOM_PAGE_BUTT: Recadre_Trace( TRUE );
case ID_ZOOM_AUTO: break;
case ID_POPUP_ZOOM_AUTO:
Zoom_Automatique(FALSE); case ID_ZOOM_PAGE_BUTT:
break; case ID_ZOOM_AUTO:
case ID_POPUP_ZOOM_AUTO:
case ID_ZOOM_PANNING_UP: Zoom_Automatique( FALSE );
OnPanning(ID_ZOOM_PANNING_UP); break;
break;
case ID_ZOOM_PANNING_UP:
case ID_ZOOM_PANNING_DOWN: OnPanning( ID_ZOOM_PANNING_UP );
OnPanning(ID_ZOOM_PANNING_DOWN); break;
break;
case ID_ZOOM_PANNING_DOWN:
case ID_ZOOM_PANNING_LEFT: OnPanning( ID_ZOOM_PANNING_DOWN );
OnPanning(ID_ZOOM_PANNING_LEFT); break;
DrawPanel->CursorOn(NULL);
break; case ID_ZOOM_PANNING_LEFT:
OnPanning( ID_ZOOM_PANNING_LEFT );
case ID_ZOOM_PANNING_RIGHT: DrawPanel->CursorOn( NULL );
OnPanning(ID_ZOOM_PANNING_RIGHT); break;
break;
case ID_ZOOM_PANNING_RIGHT:
OnPanning( ID_ZOOM_PANNING_RIGHT );
default: wxMessageBox( wxT("WinEDA_DrawFrame::OnZoom switch Error") ); break;
break;
}
Affiche_Status_Box(); default:
wxMessageBox( wxT( "WinEDA_DrawFrame::OnZoom switch Error" ) );
break;
}
Affiche_Status_Box();
} }
/**********************************************/ /**********************************************/
void WinEDA_DrawFrame::OnPanning(int direction) void WinEDA_DrawFrame::OnPanning( int direction )
/**********************************************/ /**********************************************/
/* Fonction de traitement du zoom /* Fonction de traitement du zoom
Modifie le facteur de zoom et reaffiche l'ecran * Modifie le facteur de zoom et reaffiche l'ecran
Pour les commandes par menu Popup ou par le clavier, le curseur est * Pour les commandes par menu Popup ou par le clavier, le curseur est
replac au centre de l'ecran * replac au centre de l'ecran
*/ */
{ {
if ( DrawPanel == NULL ) return; if( DrawPanel == NULL )
return;
int delta; int delta;
wxClientDC dc(DrawPanel); wxClientDC dc( DrawPanel );
int x,y;
int x, y;
DrawPanel->PrepareGraphicContext(&dc);
DrawPanel->GetViewStart( &x, &y ); // x and y are in scroll unit, not in pixels
delta = DrawPanel->m_ScrollButt_unit;
switch (direction)
{
case ID_ZOOM_PANNING_UP:
y -= delta;
break;
case ID_ZOOM_PANNING_DOWN: DrawPanel->PrepareGraphicContext( &dc );
y += delta; DrawPanel->GetViewStart( &x, &y ); // x and y are in scroll unit, not in pixels
break; delta = DrawPanel->m_ScrollButt_unit;
case ID_ZOOM_PANNING_LEFT: switch( direction )
x -= delta; {
break; case ID_ZOOM_PANNING_UP:
y -= delta;
break;
case ID_ZOOM_PANNING_RIGHT: case ID_ZOOM_PANNING_DOWN:
x += delta; y += delta;
break; break;
default: wxMessageBox( wxT("WinEDA_DrawFrame::OnPanning Error") ); case ID_ZOOM_PANNING_LEFT:
break; x -= delta;
} break;
DrawPanel->Scroll(x, y); case ID_ZOOM_PANNING_RIGHT:
x += delta;
break;
/* Place le curseur souris sur le curseur SCHEMA*/ default:
DrawPanel->MouseToCursorSchema(); wxMessageBox( wxT( "WinEDA_DrawFrame::OnPanning Error" ) );
break;
}
DrawPanel->Scroll( x, y );
/* Place le curseur souris sur le curseur SCHEMA*/
DrawPanel->MouseToCursorSchema();
} }
/*****************************/ /*****************************/
/* default virtual fonctions */ /* default virtual fonctions */
/*****************************/ /*****************************/
void WinEDA_DrawFrame::OnGrid(int grid_type) void WinEDA_DrawFrame::OnGrid( int grid_type )
{ {
} }
int WinEDA_DrawFrame::ReturnBlockCommand(int key)
int WinEDA_DrawFrame::ReturnBlockCommand( int key )
{ {
return 0; return 0;
} }
void WinEDA_DrawFrame::InitBlockPasteInfos() void WinEDA_DrawFrame::InitBlockPasteInfos()
{ {
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
} }
void WinEDA_DrawFrame::HandleBlockPlace(wxDC * DC)
{
}
int WinEDA_DrawFrame::HandleBlockEnd(wxDC * DC) void WinEDA_DrawFrame::HandleBlockPlace( wxDC* DC )
{ {
return 0;
} }
int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
{
return 0;
}
/*********************************************/ /*********************************************/
void WinEDA_DrawFrame::AdjustScrollBars(void) void WinEDA_DrawFrame::AdjustScrollBars( void )
/*********************************************/ /*********************************************/
{ {
wxSize draw_size, panel_size; wxSize draw_size, panel_size;
wxSize scrollbar_number; wxSize scrollbar_number;
wxPoint scrollbar_pos; wxPoint scrollbar_pos;
int zoom = m_CurrentScreen->GetZoom(); int zoom = m_CurrentScreen->GetZoom();
int xUnit, yUnit; int xUnit, yUnit;
if ( m_CurrentScreen == NULL) return;
if ( DrawPanel == NULL ) return;
draw_size = m_CurrentScreen->ReturnPageSize(); if( m_CurrentScreen == NULL )
return;
if( DrawPanel == NULL )
return;
// La zone d'affichage est reglee a une taille double de la feuille de travail: draw_size = m_CurrentScreen->ReturnPageSize();
draw_size.x *= 2; draw_size.y *= 2;
// On utilise le centre de l'ecran comme position de reference, donc // La zone d'affichage est reglee a une taille double de la feuille de travail:
// la surface de trace doit etre augmentee draw_size.x *= 2; draw_size.y *= 2;
panel_size = DrawPanel->GetClientSize();
panel_size.x *= zoom; panel_size.y *= zoom;
draw_size.x += panel_size.x/2;
draw_size.y += panel_size.y/2;
// On utilise le centre de l'ecran comme position de reference, donc
// la surface de trace doit etre augmentee
panel_size = DrawPanel->GetClientSize();
panel_size.x *= zoom; panel_size.y *= zoom;
draw_size.x += panel_size.x / 2;
draw_size.y += panel_size.y / 2;
if ( m_CurrentScreen->m_Center )
{
m_CurrentScreen->m_DrawOrg.x = - draw_size.x/2;
m_CurrentScreen->m_DrawOrg.y = - draw_size.y/2;
}
else
{
m_CurrentScreen->m_DrawOrg.x = - panel_size.x/2;
m_CurrentScreen->m_DrawOrg.y = - panel_size.y/2;
}
// DrawOrg est rendu multiple du zoom min : if( m_CurrentScreen->m_Center )
m_CurrentScreen->m_DrawOrg.x -= m_CurrentScreen->m_DrawOrg.x % 256; {
m_CurrentScreen->m_DrawOrg.y -= m_CurrentScreen->m_DrawOrg.y % 256; m_CurrentScreen->m_DrawOrg.x = -draw_size.x / 2;
m_CurrentScreen->m_DrawOrg.y = -draw_size.y / 2;
}
else
{
m_CurrentScreen->m_DrawOrg.x = -panel_size.x / 2;
m_CurrentScreen->m_DrawOrg.y = -panel_size.y / 2;
}
// Calcul du nombre de scrolls (en unites de scrool ) // DrawOrg est rendu multiple du zoom min :
scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit*zoom); m_CurrentScreen->m_DrawOrg.x -= m_CurrentScreen->m_DrawOrg.x % 256;
scrollbar_number.y = draw_size.y / (DrawPanel->m_Scroll_unit*zoom); m_CurrentScreen->m_DrawOrg.y -= m_CurrentScreen->m_DrawOrg.y % 256;
xUnit = yUnit = DrawPanel->m_Scroll_unit; // Calcul du nombre de scrolls (en unites de scrool )
scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit * zoom);
scrollbar_number.y = draw_size.y / (DrawPanel->m_Scroll_unit * zoom);
if (xUnit <= 1 ) xUnit = 1; xUnit = yUnit = DrawPanel->m_Scroll_unit;
if (yUnit <= 1 ) yUnit = 1;
xUnit *= zoom; yUnit *= zoom;
// Calcul de la position, curseur place au centre d'ecran if( xUnit <= 1 )
scrollbar_pos = m_CurrentScreen->m_Curseur; xUnit = 1;
if( yUnit <= 1 )
yUnit = 1;
xUnit *= zoom; yUnit *= zoom;
scrollbar_pos.x -= m_CurrentScreen->m_DrawOrg.x; // Calcul de la position, curseur place au centre d'ecran
scrollbar_pos.y -= m_CurrentScreen->m_DrawOrg.y; scrollbar_pos = m_CurrentScreen->m_Curseur;
scrollbar_pos.x -= panel_size.x /2; scrollbar_pos.x -= m_CurrentScreen->m_DrawOrg.x;
scrollbar_pos.y -= panel_size.y /2; scrollbar_pos.y -= m_CurrentScreen->m_DrawOrg.y;
if ( scrollbar_pos.x < 0 ) scrollbar_pos.x = 0; scrollbar_pos.x -= panel_size.x / 2;
if ( scrollbar_pos.y < 0 ) scrollbar_pos.y = 0; scrollbar_pos.y -= panel_size.y / 2;
scrollbar_pos.x /= xUnit; if( scrollbar_pos.x < 0 )
scrollbar_pos.y /= yUnit; scrollbar_pos.x = 0;
m_CurrentScreen->m_ScrollbarPos = scrollbar_pos; if( scrollbar_pos.y < 0 )
m_CurrentScreen->m_ScrollbarNumber = scrollbar_number; scrollbar_pos.y = 0;
DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit, scrollbar_pos.x /= xUnit;
DrawPanel->m_Scroll_unit, scrollbar_pos.y /= yUnit;
m_CurrentScreen->m_ScrollbarNumber.x, m_CurrentScreen->m_ScrollbarPos = scrollbar_pos;
m_CurrentScreen->m_ScrollbarNumber.y, m_CurrentScreen->m_ScrollbarNumber = scrollbar_number;
m_CurrentScreen->m_ScrollbarPos.x,
m_CurrentScreen->m_ScrollbarPos.y, TRUE);
DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit,
DrawPanel->m_Scroll_unit,
m_CurrentScreen->m_ScrollbarNumber.x,
m_CurrentScreen->m_ScrollbarNumber.y,
m_CurrentScreen->m_ScrollbarPos.x,
m_CurrentScreen->m_ScrollbarPos.y, TRUE );
} }
/****************************************************/ /****************************************************/
void WinEDA_DrawFrame::SetDrawBgColor(int color_num) void WinEDA_DrawFrame::SetDrawBgColor( int color_num )
/****************************************************/ /****************************************************/
/* met a jour la couleur de fond pour les tracs
seules les couleurs BLACK ou WHITE sont autorises
le parametre XorMode est mis a jour selon la couleur du fond
*/
{
if ( (color_num != WHITE) && (color_num != BLACK) ) color_num = BLACK;
g_DrawBgColor = color_num;
if(color_num == WHITE)
{
g_XorMode = GR_NXOR;
g_GhostColor = BLACK;
}
else
{
g_XorMode = GR_XOR;
g_GhostColor = WHITE;
}
if ( DrawPanel )
DrawPanel-> SetBackgroundColour(wxColour(ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ));
/* met a jour la couleur de fond pour les tracs
* seules les couleurs BLACK ou WHITE sont autorises
* le parametre XorMode est mis a jour selon la couleur du fond
*/
{
if( (color_num != WHITE) && (color_num != BLACK) )
color_num = BLACK;
g_DrawBgColor = color_num;
if( color_num == WHITE )
{
g_XorMode = GR_NXOR;
g_GhostColor = BLACK;
}
else
{
g_XorMode = GR_XOR;
g_GhostColor = WHITE;
}
if( DrawPanel )
DrawPanel->SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
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();
m_Parent->SetLanguageIdentifier(id ); m_Parent->SetLanguageIdentifier( id );
m_Parent->SetLanguage(); m_Parent->SetLanguage();
} }
/***********************************************/ /***********************************************/
void WinEDA_DrawFrame::Affiche_Status_Box(void) void WinEDA_DrawFrame::Affiche_Status_Box( void )
/***********************************************/ /***********************************************/
/* Routine d'affichage du zoom et des coord curseur. /* Routine d'affichage du zoom et des coord curseur.
*/ */
{ {
wxString Line; wxString Line;
int dx, dy; int dx, dy;
if (GetScreen() == NULL ) return; if( GetScreen() == NULL )
return;
/* affichage Zoom et coordonnees absolues */ /* affichage Zoom et coordonnees absolues */
Line.Printf(wxT("Z %d"), GetScreen()->GetZoom()); Line.Printf( wxT( "Z %d" ), GetScreen()->GetZoom() );
SetStatusText(Line, 1); SetStatusText( Line, 1 );
Line.Printf( g_UnitMetric ? wxT("X %.3f Y %.3f") : wxT("X %.4f Y %.4f"), Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) : wxT( "X %.4f Y %.4f" ),
To_User_Unit(g_UnitMetric, GetScreen()->m_Curseur.x, To_User_Unit( g_UnitMetric, GetScreen()->m_Curseur.x,
m_InternalUnits), m_InternalUnits ),
To_User_Unit(g_UnitMetric, GetScreen()->m_Curseur.y, To_User_Unit( g_UnitMetric, GetScreen()->m_Curseur.y,
m_InternalUnits)); m_InternalUnits ) );
SetStatusText(Line, 2); SetStatusText( Line, 2 );
/* affichage des coordonnees relatives */ /* affichage des coordonnees relatives */
dx = GetScreen()->m_Curseur.x - GetScreen()->m_O_Curseur.x; dx = GetScreen()->m_Curseur.x - GetScreen()->m_O_Curseur.x;
dy = GetScreen()->m_Curseur.y - GetScreen()->m_O_Curseur.y; dy = GetScreen()->m_Curseur.y - GetScreen()->m_O_Curseur.y;
Line.Printf( g_UnitMetric ? wxT("x %.3f y %.3f") : wxT("x %.4f y %.4f"), Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) : wxT( "x %.4f y %.4f" ),
To_User_Unit(g_UnitMetric, dx, m_InternalUnits), To_User_Unit( g_UnitMetric, dx, m_InternalUnits ),
To_User_Unit(g_UnitMetric, dy, m_InternalUnits) ); To_User_Unit( g_UnitMetric, dy, m_InternalUnits ) );
SetStatusText(Line, 3); SetStatusText( Line, 3 );
#ifdef PCBNEW #ifdef PCBNEW
if ( DisplayOpt.DisplayPolarCood ) /* Display coordonnee polaire */ if( DisplayOpt.DisplayPolarCood ) /* Display coordonnee polaire */
{ {
double theta, ro; double theta, ro;
if ( (dx == 0) && (dy == 0) ) theta = 0.0; if( (dx == 0) && (dy == 0) )
else theta = atan2( (double) - dy , (double) dx ); theta = 0.0;
theta = theta *180 / M_PI; else
theta = atan2( (double) -dy, (double) dx );
ro = sqrt( ((double) dx * dx) + ((double)dy * dy) ); theta = theta * 180 / M_PI;
Line.Printf( g_UnitMetric ? wxT("Ro %.3f Th %.1f") : wxT("Ro %.4f Th %.1f"),
To_User_Unit(g_UnitMetric, (int) round(ro), m_InternalUnits), ro = sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
theta) ; Line.Printf( g_UnitMetric ? wxT( "Ro %.3f Th %.1f" ) : wxT( "Ro %.4f Th %.1f" ),
SetStatusText(Line, 0); To_User_Unit( g_UnitMetric, (int) round( ro ), m_InternalUnits ),
} theta );
SetStatusText( Line, 0 );
}
#endif #endif
} }
/******************************************************************/ /******************************************************************/
/* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */ /* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */
/******************************************************************/ /******************************************************************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -12,13 +13,13 @@ ...@@ -12,13 +13,13 @@
#include "macros.h" #include "macros.h"
#include "id.h" #include "id.h"
/* defines locaux */ // defines locaux
#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */ #define CURSOR_SIZE 12 // taille de la croix du curseur PCB
/* Variables locales */ // Variables locales
/* table des evenements captes par un WinEDA_DrawPanel */ // table des evenements captes par un WinEDA_DrawPanel
BEGIN_EVENT_TABLE(WinEDA_DrawPanel, EDA_DRAW_PANEL) BEGIN_EVENT_TABLE( WinEDA_DrawPanel, EDA_DRAW_PANEL )
EVT_LEAVE_WINDOW(WinEDA_DrawPanel::OnMouseLeaving) EVT_LEAVE_WINDOW(WinEDA_DrawPanel::OnMouseLeaving)
EVT_MOUSE_EVENTS(WinEDA_DrawPanel::OnMouseEvent) EVT_MOUSE_EVENTS(WinEDA_DrawPanel::OnMouseEvent)
EVT_CHAR(WinEDA_DrawPanel::OnKeyEvent) EVT_CHAR(WinEDA_DrawPanel::OnKeyEvent)
...@@ -31,12 +32,8 @@ BEGIN_EVENT_TABLE(WinEDA_DrawPanel, EDA_DRAW_PANEL) ...@@ -31,12 +32,8 @@ BEGIN_EVENT_TABLE(WinEDA_DrawPanel, EDA_DRAW_PANEL)
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
WinEDA_DrawPanel::Process_Popup_Zoom) WinEDA_DrawPanel::Process_Popup_Zoom)
END_EVENT_TABLE() END_EVENT_TABLE()
/***********************************************************/ /***********************************************************/
/* Fonctions de base de WinEDA_DrawPanel: l'ecran de trace */ /* Fonctions de base de WinEDA_DrawPanel: l'ecran de trace */
/***********************************************************/ /***********************************************************/
...@@ -73,6 +70,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id, ...@@ -73,6 +70,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id,
m_CursorLevel = 0; m_CursorLevel = 0;
} }
/*********************************************************************************/ /*********************************************************************************/
void WinEDA_DrawPanel::Trace_Curseur(wxDC * DC, int color) void WinEDA_DrawPanel::Trace_Curseur(wxDC * DC, int color)
/*********************************************************************************/ /*********************************************************************************/
...@@ -109,6 +107,7 @@ wxPoint Cursor = GetScreen()->m_Curseur; ...@@ -109,6 +107,7 @@ wxPoint Cursor = GetScreen()->m_Curseur;
} }
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_DrawPanel::CursorOff(wxDC * DC) void WinEDA_DrawPanel::CursorOff(wxDC * DC)
/*******************************************************************/ /*******************************************************************/
...@@ -120,6 +119,7 @@ void WinEDA_DrawPanel::CursorOff(wxDC * DC) ...@@ -120,6 +119,7 @@ void WinEDA_DrawPanel::CursorOff(wxDC * DC)
--m_CursorLevel; --m_CursorLevel;
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_DrawPanel::CursorOn(wxDC * DC) void WinEDA_DrawPanel::CursorOn(wxDC * DC)
/*******************************************************************/ /*******************************************************************/
...@@ -142,6 +142,7 @@ int WinEDA_DrawPanel::GetZoom(void) ...@@ -142,6 +142,7 @@ int WinEDA_DrawPanel::GetZoom(void)
return GetScreen()->GetZoom(); return GetScreen()->GetZoom();
} }
/***************************************/ /***************************************/
void WinEDA_DrawPanel::SetZoom(int zoom) void WinEDA_DrawPanel::SetZoom(int zoom)
/***************************************/ /***************************************/
...@@ -149,6 +150,7 @@ void WinEDA_DrawPanel::SetZoom(int zoom) ...@@ -149,6 +150,7 @@ void WinEDA_DrawPanel::SetZoom(int zoom)
GetScreen()->SetZoom(zoom); GetScreen()->SetZoom(zoom);
} }
/************************************/ /************************************/
wxSize WinEDA_DrawPanel::GetGrid(void) wxSize WinEDA_DrawPanel::GetGrid(void)
/************************************/ /************************************/
...@@ -211,6 +213,7 @@ wxPoint curpos; ...@@ -211,6 +213,7 @@ wxPoint curpos;
return curpos; return curpos;
} }
/********************************************************/ /********************************************************/
bool WinEDA_DrawPanel::IsPointOnDisplay(wxPoint ref_pos) bool WinEDA_DrawPanel::IsPointOnDisplay(wxPoint ref_pos)
/********************************************************/ /********************************************************/
...@@ -262,6 +265,7 @@ wxPoint curpos = GetScreen()->m_Curseur; ...@@ -262,6 +265,7 @@ wxPoint curpos = GetScreen()->m_Curseur;
return curpos; return curpos;
} }
/*********************************************************/ /*********************************************************/
wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition(void) wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition(void)
/*********************************************************/ /*********************************************************/
...@@ -292,6 +296,7 @@ wxPoint Mouse = CursorScreenPosition(); ...@@ -292,6 +296,7 @@ wxPoint Mouse = CursorScreenPosition();
MouseTo(Mouse); MouseTo(Mouse);
} }
/****************************************************/ /****************************************************/
void WinEDA_DrawPanel::MouseTo(const wxPoint & Mouse) void WinEDA_DrawPanel::MouseTo(const wxPoint & Mouse)
/****************************************************/ /****************************************************/
...@@ -467,15 +472,18 @@ wxPoint org; ...@@ -467,15 +472,18 @@ wxPoint org;
} }
/****************************************************/ /****************************************************/
void WinEDA_DrawPanel::ReDraw(wxDC * DC, bool erasebg) void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
/****************************************************/ /****************************************************/
{ {
BASE_SCREEN * Screen = GetScreen(); BASE_SCREEN * Screen = GetScreen();
if ( Screen == NULL ) return; if( Screen == NULL )
return;
if ( (g_DrawBgColor != WHITE) && (g_DrawBgColor != BLACK) ) g_DrawBgColor = BLACK; if( (g_DrawBgColor != WHITE) && (g_DrawBgColor != BLACK) )
if(g_DrawBgColor == WHITE) g_DrawBgColor = BLACK;
if( g_DrawBgColor == WHITE )
{ {
g_XorMode = GR_NXOR; g_XorMode = GR_NXOR;
g_GhostColor = BLACK; g_GhostColor = BLACK;
...@@ -487,26 +495,28 @@ BASE_SCREEN * Screen = GetScreen(); ...@@ -487,26 +495,28 @@ BASE_SCREEN * Screen = GetScreen();
} }
#ifdef WX_ZOOM #ifdef WX_ZOOM
int zoom = GetZoom(); int zoom = GetZoom();
double f_scale = 1.0/(double)zoom; double f_scale = 1.0/(double)zoom;
DC->SetUserScale(f_scale, f_scale); DC->SetUserScale(f_scale, f_scale);
#endif #endif
if(erasebg)
if(erasebg) PrepareGraphicContext(DC); PrepareGraphicContext(DC);
DC->SetFont(* g_StdFont);
DC->SetFont( *g_StdFont );
SetBackgroundColour(wxColour(ColorRefs[g_DrawBgColor].m_Red, SetBackgroundColour( wxColour(ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green, ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue )); ColorRefs[g_DrawBgColor].m_Blue ) );
GRResetPenAndBrush(DC); GRResetPenAndBrush( DC );
DC->SetBackground(*wxBLACK_BRUSH ); DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode(wxTRANSPARENT); DC->SetBackgroundMode( wxTRANSPARENT );
m_Parent->RedrawActiveWindow(DC, erasebg); m_Parent->RedrawActiveWindow( DC, erasebg );
} }
/***********************************************/ /***********************************************/
void WinEDA_DrawPanel::DrawBackGround(wxDC * DC) void WinEDA_DrawPanel::DrawBackGround(wxDC * DC)
/***********************************************/ /***********************************************/
...@@ -622,6 +632,7 @@ BASE_SCREEN * screen = GetScreen(); ...@@ -622,6 +632,7 @@ BASE_SCREEN * screen = GetScreen();
0, Color ); 0, Color );
} }
/*******************************************************/ /*******************************************************/
void WinEDA_DrawPanel::OnRightClick(wxMouseEvent& event) void WinEDA_DrawPanel::OnRightClick(wxMouseEvent& event)
/*******************************************************/ /*******************************************************/
...@@ -721,7 +732,6 @@ static WinEDA_DrawPanel * LastPanel; ...@@ -721,7 +732,6 @@ static WinEDA_DrawPanel * LastPanel;
if( event.MiddleDown()) localbutt = GR_M_MIDDLE_DOWN; if( event.MiddleDown()) localbutt = GR_M_MIDDLE_DOWN;
if( event.ButtonDClick(2)) {}; // Unused if( event.ButtonDClick(2)) {}; // Unused
localrealbutt |= localbutt; /* compensation defaut wxGTK */ localrealbutt |= localbutt; /* compensation defaut wxGTK */
/* Compute absolute m_MousePosition in pixel units: */ /* Compute absolute m_MousePosition in pixel units: */
...@@ -919,7 +929,11 @@ BASE_SCREEN * Screen = GetScreen(); ...@@ -919,7 +929,11 @@ BASE_SCREEN * Screen = GetScreen();
ForceCloseManageCurseur(this, &DC); ForceCloseManageCurseur(this, &DC);
SetCursor(m_PanelCursor = m_PanelDefaultCursor); SetCursor(m_PanelCursor = m_PanelDefaultCursor);
} }
else m_Parent->SetToolID(0, m_PanelCursor = m_PanelDefaultCursor = wxCURSOR_ARROW, wxEmptyString); else
{
m_PanelCursor = m_PanelDefaultCursor = wxCURSOR_ARROW;
m_Parent->SetToolID(0, m_PanelCursor, wxEmptyString);
}
} }
m_Parent->GeneralControle(&DC, Screen->m_MousePositionInPixels); m_Parent->GeneralControle(&DC, Screen->m_MousePositionInPixels);
...@@ -928,6 +942,3 @@ BASE_SCREEN * Screen = GetScreen(); ...@@ -928,6 +942,3 @@ BASE_SCREEN * Screen = GetScreen();
event.Skip(); // Allow menu shortcut processing event.Skip(); // Allow menu shortcut processing
#endif #endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment