2007-09-05 04:48:47 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* basepcbframe.cpp - fonctions des classes du type WinEDA_BasePcbFrame */
|
|
|
|
/************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "protos.h"
|
|
|
|
#include "id.h"
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
#include "collectors.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
/*******************************/
|
|
|
|
/* class WinEDA_BasePcbFrame */
|
|
|
|
/*******************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_BasePcbFrame, WinEDA_DrawFrame )
|
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
COMMON_EVENTS_DRAWFRAME EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
|
|
|
|
ID_POPUP_PCB_ITEM_SELECTION_END,
|
|
|
|
WinEDA_BasePcbFrame::ProcessItemSelection )
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-09-12 02:14:07 +00:00
|
|
|
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
/****************/
|
|
|
|
/* Constructeur */
|
|
|
|
/****************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
|
|
|
|
WinEDA_App* parent,
|
|
|
|
int idtype,
|
2007-09-05 04:48:47 +00:00
|
|
|
const wxString& title,
|
2007-10-07 18:24:15 +00:00
|
|
|
const wxPoint& pos,
|
2007-10-27 12:24:09 +00:00
|
|
|
const wxSize& size,
|
|
|
|
long style) :
|
|
|
|
WinEDA_DrawFrame( father, idtype, parent, title, pos, size, style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
m_InternalUnits = 10000; // Internal unit = 1/10000 inch
|
|
|
|
m_CurrentScreen = NULL;
|
|
|
|
m_Pcb = NULL;
|
|
|
|
|
|
|
|
m_DisplayPadFill = TRUE; // How to draw pads
|
|
|
|
m_DisplayPadNum = TRUE; // show pads number
|
|
|
|
|
|
|
|
m_DisplayModEdge = FILLED; // How to show module drawings
|
|
|
|
m_DisplayModText = FILLED; // How to show module texts
|
|
|
|
m_DisplayPcbTrackFill = TRUE; /* FALSE = sketch , TRUE = filled */
|
|
|
|
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
|
2007-10-07 18:24:15 +00:00
|
|
|
|
|
|
|
m_Collector = new GENERAL_COLLECTOR();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
WinEDA_BasePcbFrame::~WinEDA_BasePcbFrame( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
delete m_Collector;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
int WinEDA_BasePcbFrame::BestZoom( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************/
|
2007-10-27 18:05:50 +00:00
|
|
|
/**
|
2007-12-06 07:35:26 +00:00
|
|
|
* Return the "best" zoom, i.e. the zoom which shows the entire board on screen
|
2007-10-27 18:05:50 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
int dx, dy, ii, jj;
|
|
|
|
int bestzoom;
|
|
|
|
wxSize size;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
if( m_Pcb == NULL )
|
|
|
|
return 32;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
m_Pcb->ComputeBoundaryBox();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
dx = m_Pcb->m_BoundaryBox.GetWidth();
|
|
|
|
dy = m_Pcb->m_BoundaryBox.GetHeight();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
size = DrawPanel->GetClientSize();
|
|
|
|
ii = ( dx + (size.x / 2) ) / size.x;
|
|
|
|
jj = ( dy + (size.y / 2) ) / size.y;
|
|
|
|
bestzoom = MAX( ii, jj ) + 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
m_CurrentScreen->m_Curseur = m_Pcb->m_BoundaryBox.Centre();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
return bestzoom;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-06 07:35:26 +00:00
|
|
|
/***********************************************************/
|
2007-12-04 07:04:53 +00:00
|
|
|
void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
|
2007-12-06 07:35:26 +00:00
|
|
|
/***********************************************************/
|
2007-12-04 07:04:53 +00:00
|
|
|
{
|
|
|
|
// factored out of pcbnew/find.cpp
|
|
|
|
|
|
|
|
PCB_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
|
|
|
/* Il y a peut-etre necessite de recadrer le dessin: */
|
|
|
|
if( !DrawPanel->IsPointOnDisplay( aPos ) )
|
|
|
|
{
|
|
|
|
screen->m_Curseur = aPos;
|
|
|
|
Recadre_Trace( TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-06 07:35:26 +00:00
|
|
|
// Put cursor on item position
|
2007-12-04 07:04:53 +00:00
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
screen->m_Curseur = aPos;
|
|
|
|
GRMouseWarp( DrawPanel, screen->m_Curseur );
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
}
|
2007-12-05 17:56:57 +00:00
|
|
|
|
|
|
|
D(printf("CursorGoto end x=%d, y=%d\n",
|
|
|
|
m_CurrentScreen->m_Curseur.x, m_CurrentScreen->m_Curseur.y );)
|
2007-12-04 07:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 16:16:48 +00:00
|
|
|
/*************************************************/
|
|
|
|
void WinEDA_BasePcbFrame::ReCreateMenuBar( void )
|
|
|
|
/*************************************************/
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2007-10-06 16:16:48 +00:00
|
|
|
// Virtual function
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
#ifdef CVPCB
|
|
|
|
/********************************************************************/
|
|
|
|
void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
|
|
|
/********************************************************************/
|
|
|
|
|
|
|
|
// Virtual function
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "3d_viewer.h"
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
void WinEDA_BasePcbFrame::Show3D_Frame( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-12-06 07:35:26 +00:00
|
|
|
/* Creates and shows the 3D frame display
|
2007-09-05 04:48:47 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
#ifndef GERBVIEW
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
// Create the main frame window
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
{
|
|
|
|
DisplayInfo( this, _( "3D Frame already opened" ) );
|
|
|
|
return;
|
|
|
|
}
|
2007-10-27 12:24:09 +00:00
|
|
|
|
|
|
|
#ifdef CVPCB
|
|
|
|
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, m_Parent, _( "3D Viewer" ),
|
|
|
|
KICAD_DEFAULT_3D_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
|
|
|
|
#else
|
2007-09-05 04:48:47 +00:00
|
|
|
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, m_Parent, _( "3D Viewer" ) );
|
2007-10-27 12:24:09 +00:00
|
|
|
#endif
|
2007-09-05 04:48:47 +00:00
|
|
|
// Show the frame
|
|
|
|
m_Draw3DFrame->Show( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
void WinEDA_BasePcbFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, int flag )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
void WinEDA_BasePcbFrame::GetComponentFromUndoList( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
void WinEDA_BasePcbFrame::GetComponentFromRedoList( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-15 12:04:24 +00:00
|
|
|
|
|
|
|
/****************************************************************/
|
2007-09-05 04:48:47 +00:00
|
|
|
void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
|
2007-06-15 12:04:24 +00:00
|
|
|
/*****************************************************************/
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Note: virtual, overridden in WinEDA_PcbFrame;
|
2007-06-15 12:04:24 +00:00
|
|
|
{
|
2007-09-05 04:48:47 +00:00
|
|
|
int preslayer = GetScreen()->m_Active_Layer;
|
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Check if the specified layer matches the present layer
|
|
|
|
if( layer == preslayer )
|
2007-09-05 04:48:47 +00:00
|
|
|
return;
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Copper layers cannot be selected unconditionally; how many
|
|
|
|
// of those layers are currently enabled needs to be checked.
|
2007-11-01 05:27:31 +00:00
|
|
|
if( (layer >= FIRST_COPPER_LAYER) && (layer <= LAST_COPPER_LAYER) )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
|
|
|
// If only one copper layer is enabled, the only such layer
|
|
|
|
// that can be selected to is the "Copper" layer (so the
|
|
|
|
// selection of any other copper layer is disregarded).
|
|
|
|
if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 )
|
|
|
|
{
|
|
|
|
if( layer != COPPER_LAYER_N )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If more than one copper layer is enabled, the "Copper"
|
|
|
|
// and "Component" layers can be selected, but the total
|
|
|
|
// number of copper layers determines which internal
|
|
|
|
// layers are also capable of being selected.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N)
|
|
|
|
&& (layer >= m_Pcb->m_BoardSettings->m_CopperLayerCount - 1) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is yet more checking required? E.g. when the layer to be selected
|
|
|
|
// is a non-copper layer, or when switching between a copper layer
|
|
|
|
// and a non-copper layer, or vice-versa?
|
|
|
|
// ...
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
GetScreen()->m_Active_Layer = layer;
|
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
GetScreen()->SetRefreshReq();
|
2007-06-15 12:04:24 +00:00
|
|
|
}
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-10-06 16:16:48 +00:00
|
|
|
/**********************************************************************/
|
2007-09-12 02:14:07 +00:00
|
|
|
void WinEDA_BasePcbFrame::ProcessItemSelection( wxCommandEvent& event )
|
2007-10-06 16:16:48 +00:00
|
|
|
/**********************************************************************/
|
2007-09-12 02:14:07 +00:00
|
|
|
{
|
2007-10-07 18:24:15 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
// index into the collector list:
|
2007-10-07 18:24:15 +00:00
|
|
|
int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
|
|
|
|
|
2007-10-10 04:53:23 +00:00
|
|
|
if( id >= ID_POPUP_PCB_ITEM_SELECTION_START
|
|
|
|
&& id <= ID_POPUP_PCB_ITEM_SELECTION_END )
|
2007-10-07 18:24:15 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (*m_Collector)[itemNdx];
|
|
|
|
DrawPanel->m_AbortRequest = false;
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2007-10-10 04:53:23 +00:00
|
|
|
#if defined (DEBUG) && 0
|
2007-10-07 18:24:15 +00:00
|
|
|
item->Show( 0, std::cout );
|
2007-09-12 02:14:07 +00:00
|
|
|
#endif
|
2007-10-07 18:24:15 +00:00
|
|
|
|
|
|
|
SetCurItem( item );
|
|
|
|
}
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
|
|
|
void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem )
|
|
|
|
/*****************************************************************/
|
|
|
|
{
|
|
|
|
m_CurrentScreen->SetCurItem( aItem );
|
2007-10-10 12:43:30 +00:00
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
if( aItem )
|
2007-10-10 12:43:30 +00:00
|
|
|
{
|
2007-10-07 18:24:15 +00:00
|
|
|
aItem->Display_Infos( this );
|
2007-10-10 12:43:30 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
aItem->Show( 0, std::cout );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2007-09-12 02:14:07 +00:00
|
|
|
else
|
|
|
|
{
|
2007-10-10 12:43:30 +00:00
|
|
|
// we can use either of these two:
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
//MsgPanel->EraseMsgBox();
|
2007-10-10 12:43:30 +00:00
|
|
|
m_Pcb->Display_Infos( this ); // show the BOARD stuff
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
std::cout << "SetCurItem(NULL)\n";
|
|
|
|
#endif
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
|
|
|
BOARD_ITEM* WinEDA_BasePcbFrame::GetCurItem()
|
|
|
|
/*****************************************************************/
|
2007-10-07 18:24:15 +00:00
|
|
|
{
|
|
|
|
return (BOARD_ITEM*) m_CurrentScreen->GetCurItem();
|
2007-09-12 02:14:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
/****************************************************************/
|
|
|
|
GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide()
|
|
|
|
/****************************************************************/
|
|
|
|
{
|
2007-10-07 18:24:15 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE guide( m_Pcb->m_BoardSettings->GetVisibleLayers(),
|
|
|
|
GetScreen()->m_Active_Layer );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
// account for the globals
|
|
|
|
guide.SetIgnoreMTextsMarkedNoShow( g_ModuleTextNOVColor & ITEM_NOT_SHOW );
|
|
|
|
guide.SetIgnoreMTextsOnCopper( g_ModuleTextCUColor & ITEM_NOT_SHOW );
|
|
|
|
guide.SetIgnoreMTextsOnCmp( g_ModuleTextCMPColor & ITEM_NOT_SHOW );
|
|
|
|
guide.SetIgnoreModulesOnCu( !DisplayOpt.Show_Modules_Cu );
|
|
|
|
guide.SetIgnoreModulesOnCmp( !DisplayOpt.Show_Modules_Cmp );
|
|
|
|
|
|
|
|
return guide;
|
|
|
|
}
|