Commit 80e03c8c authored by stambaughw's avatar stambaughw

Build optimizations and cursor movement key bug fix.

parent 9f555dbd
......@@ -5,6 +5,20 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2009-Feb-05 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++All
* Change CMakeList.txt so that all PCB object classes that do not need built
separately for pcbnew, gerbview, and cvpcb only get built once and added
to the common library.
* Override all classes derived from WinEDA_BasePcbFrame so that the source
code file basepcbframe.cpp only gets compiled once and added to the common
library.
* Prevent cursor movement keys from moving outside of client area by
automatically scrolling the drawing.
2009-Feb-4 UPDATE Vesa Solonen <vesa.solonen@hut.fi>
================================================================================
++pcbnew:
......@@ -19,6 +33,7 @@ email address.
* Move sine and cosine look up tables from trigo.h to trigo.cpp to avoid
multiple recompiles.
2009-feb-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++All:
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
../pcbnew
../polygon
)
set(COMMON_SRCS
about_kicad.cpp
base_screen.cpp
......@@ -37,6 +40,24 @@ set(COMMON_SRCS
trigo.cpp
worksheet.cpp
wxwineda.cpp
zoom.cpp)
zoom.cpp
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_board_connected_item.cpp
../pcbnew/class_cotation.cpp
../pcbnew/class_drc_item.cpp
../pcbnew/class_marker.cpp
../pcbnew/class_mire.cpp
../pcbnew/class_pad.cpp
../pcbnew/class_pad_draw_functions.cpp
../pcbnew/class_pcb_text.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp
../pcbnew/dialog_print_using_printer_base.cpp
)
add_library(common ${COMMON_SRCS})
......@@ -364,13 +364,48 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
* @param Mouse = new mouse cursor position
*/
{
wxPoint mouse;
int x, y, xPpu, yPpu;
wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
#ifdef WX_ZOOM
CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y );
CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y );
#else
mouse = Mouse - GetScreen()->m_StartVisu;
screenPos = Mouse - GetScreen()->m_StartVisu;
#endif
WarpPointer( mouse.x, mouse.y );
/* Scroll if the requested mouse position cursor is outside the drawing
* area. */
if( !clientRect.Contains( screenPos ) )
{
GetViewStart( &x, &y );
GetScrollPixelsPerUnit( &xPpu, &yPpu );
CalcUnscrolledPosition( screenPos.x, screenPos.y,
&drawingPos.x, &drawingPos.y );
wxLogDebug( wxT( "MouseTo() initial screen position(%d, %d) " \
"rectangle(%d, %d, %d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, clientRect.x, clientRect.y,
clientRect.width, clientRect.height, x, y );
if( screenPos.y < clientRect.GetTop() )
y -= m_ScrollButt_unit * yPpu;
else if( screenPos.y > clientRect.GetBottom() )
y += m_ScrollButt_unit * yPpu;
else if( clientRect.GetRight() < screenPos.x )
x += m_ScrollButt_unit * xPpu;
else
x -= m_ScrollButt_unit * xPpu;
Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y,
&screenPos.x, &screenPos.y );
wxLogDebug( wxT( "MouseTo() scrolled screen position(%d, %d) " \
"view(%d, %d)" ), screenPos.x, screenPos.y, x, y );
}
WarpPointer( screenPos.x, screenPos.y );
}
......@@ -1242,9 +1277,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
{
int x, y;
wxClientDC dc( this );
PrepareGraphicContext( &dc );
GetViewStart( &x, &y ); // x and y are in scroll units, not in pixels
switch( event.GetId() )
......
......@@ -29,25 +29,13 @@ set(CVPCB_SRCS
writenetlistpcbnew.cpp)
set(CVPCB_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_board_item.cpp
../pcbnew/class_board_connected_item.cpp
../pcbnew/class_cotation.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_edge_mod.cpp
../pcbnew/class_equipot.cpp
../pcbnew/class_mire.cpp
../pcbnew/class_module.cpp
../pcbnew/class_pad.cpp
../pcbnew/class_pad_draw_functions.cpp
../pcbnew/class_pcb_text.cpp
../pcbnew/class_text_mod.cpp
../pcbnew/class_track.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/ioascii.cpp
../pcbnew/tracemod.cpp)
......
......@@ -11,6 +11,8 @@
#include <wx/fontdlg.h>
#include "3d_viewer.h"
#include "cvpcb.h"
#include "pcbnew.h"
#include "bitmaps.h"
......
......@@ -7,6 +7,9 @@
#include "common.h"
#include "class_drawpanel.h"
#include "id.h"
#include "confirm.h"
#include "3d_viewer.h"
#include "cvpcb.h"
#include "bitmaps.h"
......@@ -23,7 +26,7 @@ BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_DrawFrame )
EVT_SIZE( WinEDA_DrawFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_DisplayFrame::OnZoom )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_DisplayFrame::InstallOptionsDisplay )
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, WinEDA_BasePcbFrame::Show3D_Frame )
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, WinEDA_DisplayFrame::Show3D_Frame )
END_EVENT_TABLE()
......@@ -196,69 +199,62 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( delta.y <= 0 )
delta.y = 1;
if( g_KeyPressed )
switch( g_KeyPressed )
{
switch( g_KeyPressed )
{
case WXK_F1:
cmd.SetId( ID_POPUP_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case WXK_F1:
cmd.SetId( ID_POPUP_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case WXK_F2:
cmd.SetId( ID_POPUP_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case WXK_F3:
cmd.SetId( ID_ZOOM_REDRAW );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
break;
case WXK_F4:
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case ' ':
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case WXK_NUMPAD8: /* cursor moved up */
case WXK_UP:
DrawPanel->CalcScrolledPosition( Mouse.x, Mouse.y - delta.y,
&Mouse.x, &Mouse.y );
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD2: /* cursor moved down */
case WXK_DOWN:
DrawPanel->CalcScrolledPosition( Mouse.x, Mouse.y + delta.y,
&Mouse.x, &Mouse.y );
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD4: /* cursor moved left */
case WXK_LEFT:
DrawPanel->CalcScrolledPosition( Mouse.x - delta.x, Mouse.y,
&Mouse.x, &Mouse.y );
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD6: /* cursor moved right */
case WXK_RIGHT:
DrawPanel->CalcScrolledPosition( Mouse.x + delta.x, Mouse.y,
&Mouse.x, &Mouse.y );
DrawPanel->MouseTo( Mouse );
break;
}
case WXK_F2:
cmd.SetId( ID_POPUP_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case WXK_F3:
cmd.SetId( ID_ZOOM_REDRAW );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
break;
case WXK_F4:
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
break;
case ' ':
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case WXK_NUMPAD8: /* cursor moved up */
case WXK_UP:
Mouse.y -= delta.y;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD2: /* cursor moved down */
case WXK_DOWN:
Mouse.y += delta.y;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD4: /* cursor moved left */
case WXK_LEFT:
Mouse.x -= delta.x;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD6: /* cursor moved right */
case WXK_RIGHT:
Mouse.x += delta.x;
DrawPanel->MouseTo( Mouse );
break;
}
GetScreen()->m_Curseur = curpos;
......@@ -316,3 +312,20 @@ void WinEDA_DisplayFrame::Process_Special_Functions( wxCommandEvent& event )
SetToolbars();
}
/**
* Display 3D frame of current footprint selection.
*/
void WinEDA_DisplayFrame::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfo( this, _( "3D Frame already opened" ) );
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ),
KICAD_DEFAULT_3D_DRAWFRAME_STYLE |
wxFRAME_FLOAT_ON_PARENT );
m_Draw3DFrame->Show( TRUE );
}
......@@ -36,25 +36,14 @@ set(GERBVIEW_SRCS
trpiste.cpp )
set(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_board_item.cpp
../pcbnew/class_board_connected_item.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_drc_item.cpp
../pcbnew/class_marker.cpp
../pcbnew/class_pcb_text.cpp
../pcbnew/class_track.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp
../pcbnew/undelete.cpp
../share/setpage.cpp
../pcbnew/dialog_print_using_printer_base.cpp
../pcbnew/dialog_print_using_printer.cpp)
../pcbnew/dialog_print_using_printer.cpp
)
if(WIN32)
if(MINGW)
......
......@@ -30,7 +30,7 @@ BOARD_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
/****************************************************************/
void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/****************************************************************/
/* traitement des touches de fonctions utilisees ds tous les menus
......@@ -107,8 +107,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/* Placement sur la grille generale */
PutOnGrid( &GetScreen()->m_Curseur );
if( (oldpos.x != GetScreen()->m_Curseur.x)
|| (oldpos.y != GetScreen()->m_Curseur.y) )
if( oldpos != GetScreen()->m_Curseur )
{
curpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
......
......@@ -49,8 +49,6 @@ class GENERAL_COLLECTORS_GUIDE;
class WinEDA_BasePcbFrame : public WinEDA_DrawFrame
{
BOARD* m_Pcb;
public:
bool m_DisplayPadFill; // How show pads
......@@ -63,9 +61,9 @@ public:
WinEDA_ModuleEditFrame* m_ModuleEditFrame;
protected:
BOARD* m_Pcb;
GENERAL_COLLECTOR* m_Collector;
public:
WinEDA_BasePcbFrame( wxWindow* father, int idtype,
const wxString& title,
......@@ -109,9 +107,7 @@ public:
int BestZoom();
void Show3D_Frame( wxCommandEvent& event );
virtual void GeneralControle( wxDC* DC, wxPoint Mouse );
virtual void Show3D_Frame( wxCommandEvent& event );
// Undo and redo functions
public:
......@@ -378,6 +374,9 @@ public:
void ReCreateMenuBar();
WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent );
void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse );
/**
* Function UpdateToolbarLayerInfo
* updates the currently selected layer in the layer listbox and
......@@ -821,6 +820,8 @@ public:
const wxString& D_Code_FullFileName );
bool SaveGerberFile( const wxString& FileName, wxDC* DC );
void GeneralControle( wxDC* DC, wxPoint Mouse );
/**
* Function Read_D_Code_File
......@@ -913,6 +914,8 @@ public:
void ToolOnRightClick( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event );
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse );
/* handlers for block commands */
int ReturnBlockCommand( int key );
......
......@@ -12,32 +12,18 @@ set(PCBNEW_SRCS
automove.cpp
autoplac.cpp
autorout.cpp
basepcbframe.cpp
block.cpp
block_module_editor.cpp
board.cpp
class_board.cpp
class_board_item.cpp
class_board_connected_item.cpp
class_cotation.cpp
class_drawsegment.cpp
class_drc_item.cpp
class_edge_mod.cpp
class_equipot.cpp
class_marker.cpp
class_mire.cpp
class_module.cpp
class_pad.cpp
class_pad_draw_functions.cpp
classpcb.cpp
class_pcb_text.cpp
class_text_mod.cpp
class_track.cpp
class_zone.cpp
class_zone_setting.cpp
clean.cpp
# cleaningoptions_dialog.cpp
collectors.cpp
connect.cpp
controle.cpp
# copy_track.cpp <-- not used
......@@ -66,7 +52,6 @@ set(PCBNEW_SRCS
dialog_pad_properties.cpp
dialog_pad_properties_base.cpp
dialog_print_using_printer.cpp
dialog_print_using_printer_base.cpp
dialog_setup_libs.cpp
dialog_orient_footprints.cpp
# dialog_track_options.cpp
......@@ -131,7 +116,6 @@ set(PCBNEW_SRCS
queue.cpp
ratsnest.cpp
router.cpp
sel_layer.cpp
set_color.cpp
set_grid.cpp
solve.cpp
......
......@@ -144,65 +144,25 @@ void WinEDA_BasePcbFrame::ReCreateMenuBar( void )
{
}
#ifdef CVPCB
/********************************************************************/
void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/********************************************************************/
// Virtual function
{
}
#endif
#include "3d_viewer.h"
/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */
/***********************************************************/
void WinEDA_BasePcbFrame::Show3D_Frame( wxCommandEvent& event )
/***********************************************************/
/* Creates and shows the 3D frame display
*/
{
#ifndef GERBVIEW
// Create the main frame window
if( m_Draw3DFrame )
{
DisplayInfo( this, _( "3D Frame already opened" ) );
return;
}
#ifdef CVPCB
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ),
KICAD_DEFAULT_3D_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
#else
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
#endif
// Show the frame
m_Draw3DFrame->Show( TRUE );
#endif
}
/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */
/***********************************************************************************/
void WinEDA_BasePcbFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, int flag )
/***********************************************************************************/
void WinEDA_BasePcbFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
int flag )
{
}
/********************************************************/
void WinEDA_BasePcbFrame::GetComponentFromUndoList( void )
/********************************************************/
{
}
/********************************************************/
void WinEDA_BasePcbFrame::GetComponentFromRedoList( void )
/********************************************************/
{
}
......
......@@ -3,14 +3,8 @@
/*************************************************************************/
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "pcbnew.h"
#ifdef CVPCB
#include "cvpcb.h"
#endif
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_ITEM( aParent, idtype )
......
......@@ -479,7 +479,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
/****************************************************************/
void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/
{
wxSize delta;
......
......@@ -16,6 +16,9 @@
#include "protos.h"
#include "id.h"
#include "3d_viewer.h"
/********************************/
/* class WinEDA_ModuleEditFrame */
/********************************/
......@@ -378,3 +381,115 @@ void WinEDA_ModuleEditFrame::SetToolbars()
DisplayUnitsMsg();
}
/**
* Display 3D frame of footprint (module) being edited.
*/
void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfo( this, _( "3D Frame already opened" ) );
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( TRUE );
}
void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
{
wxSize delta;
wxPoint curpos, oldpos;
int hotkey = 0;
if( GetScreen()->IsRefreshReq() )
{
RedrawActiveWindow( DC, TRUE );
// We must return here, instead of proceeding.
// If we let the cursor move during a refresh request,
// the cursor be displayed in the wrong place
// during delayed repaint events that occur when
// you move the mouse when a message dialog is on
// the screen, and then you dismiss the dialog by
// typing the Enter key.
return;
}
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid();
GetScreen()->Scale( delta );
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
delta.y = 1;
switch( g_KeyPressed )
{
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_UP:
Mouse.y -= delta.y;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_DOWN:
Mouse.y += delta.y;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_LEFT:
Mouse.x -= delta.x;
DrawPanel->MouseTo( Mouse );
break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_RIGHT:
Mouse.x += delta.x;
DrawPanel->MouseTo( Mouse );
break;
default:
hotkey = g_KeyPressed;
break;
}
/* Recalcul de la position du curseur schema */
GetScreen()->m_Curseur = curpos;
/* Placement sur la grille generale */
PutOnGrid( &GetScreen()->m_Curseur );
if( oldpos != GetScreen()->m_Curseur )
{
curpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
}
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )
{
RedrawActiveWindow( DC, TRUE );
}
SetToolbars();
Affiche_Status_Box(); /* Affichage des coord curseur */
}
......@@ -6,12 +6,14 @@
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "collectors.h"
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
#include "drc_stuff.h"
#include "3d_viewer.h"
#include "kbool/include/kbool/booleng.h"
/*******************************/
......@@ -572,3 +574,18 @@ void WinEDA_PcbFrame::SetToolbars()
PrepareLayerIndicator();
DisplayUnitsMsg();
}
/**
* Display 3D frame of current printed circuit board.
*/
void WinEDA_PcbFrame::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfo( this, _( "3D Frame already opened" ) );
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( TRUE );
}
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