Commit cb49ea89 authored by dickelbeck's avatar dickelbeck

see change_log.txt for 2007-Sep-11 UPDATE

parent 07f2dd72
......@@ -5,13 +5,32 @@ Please add newer entries at the top, list the date and your name with
email address.
2007-Sep-11 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
* Changed PcbLocateAndDisplay() to be tool specific in its search and to present
a popup menu when there are multiple items under the mouse. It is also
a framework for future enhancements.
@todo: grep for @todo and finish off those tasks.
* Introduced a formal notion of "selected item". This is done with the addition
of the WinEDA_BasePcbFrame::SetCurItem() function. So now you have to first
select an item with the left mouse button before you attempt to use the
right button popup menu. Right button no longer has an effect on the
currently selected item. The currently selected item is shown in the MsgPanel.
When none is selected, the m_Pcb is shown.
* Tweaked the OnRightClick() popup menus so that the most likely choices are
at the top.
* Added wxString BOARD_ITEM::MenuText() const and BOARD_ITEM::MenuIcon() and
both need more work, work which I will not have time to do.
2007-Sep-10 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
* Searched and did not see any usage of TRACK::Copy(int), where int was other
than '1', so renamed it to TRACK::CopyList(int) and commented it out because
with int==1, this makes Copy(1) equivalent to the new Copy(void).
* Made TRACK::Copy() capable or copying SEGZONE too.
* Made TRACK::Copy() capable of copying SEGZONE too.
2007-sept-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
......
......@@ -555,13 +555,3 @@ EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList()
return item;
}
void BASE_SCREEN::SetCurItem( EDA_BaseStruct* aCurItem )
{
#if 0 && defined(DEBUG)
printf( "SetCurItem(%p)\n", aCurItem );
#endif
m_CurrentItem = aCurItem;
}
......@@ -477,6 +477,21 @@ public:
return false; // only MODULEs can be locked at this time.
}
/**
* Function MenuText
* @return wxString - The text to use in any menu type UI control which
* must identify this item.
* @todo: make this virtual and split into each derived class
*/
wxString MenuText() const;
/**
* Function MenuIcon
* @return const char** - The XPM to use in any UI control which can help
* identify this item.
* @todo: make this virtual and split into each derived class
*/
const char** MenuIcon() const;
};
......
......@@ -215,7 +215,7 @@ private:
char m_FlagRefreshReq; /* indique que l'ecran doit redessine */
char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
char m_FlagSave; // indique sauvegarde auto faite
EDA_BaseStruct* m_CurrentItem; /* Current selected object */
EDA_BaseStruct* m_CurrentItem; ///< Current selected object
/* Valeurs du pas de grille et du zoom */
public:
......@@ -232,7 +232,7 @@ public:
BASE_SCREEN( int idscreen, KICAD_T aType = SCREEN_STRUCT_TYPE );
~BASE_SCREEN();
void InitDatas();/* Inits completes des variables */
void InitDatas(); /* Inits completes des variables */
wxSize ReturnPageSize();
int GetInternalUnits();
......@@ -264,7 +264,11 @@ public:
* activity easier in base_screen.cpp.
* @param current Any object derived from EDA_BaseStruct
*/
void SetCurItem( EDA_BaseStruct* current );
void SetCurItem( EDA_BaseStruct* current )
{
m_CurrentItem = current;
}
EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; }
/* fonctions relatives au zoom */
......@@ -290,7 +294,7 @@ public:
* Function RefPos
* returns the reference position, coming from either the mouse position or the
* the cursor position.
* @param useMouse If true, return mouse posistion, else cursor's.
* @param useMouse If true, return mouse position, else cursor's.
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
......
......@@ -2,6 +2,8 @@
#ifndef ID_H
#define ID_H
#define MAX_ITEMS_IN_PICKER 15 ///< max no. items in the popup menu for item selection
enum main_id {
ID_MAIN_FRAME = 100,
ID_LEFT_FRAME,
......@@ -635,6 +637,10 @@ enum main_id {
ID_POPUP_PCB_END_RANGE,
// reserve a block of MAX_ITEMS_IN_PICKER ids for the item selection popup
ID_POPUP_PCB_ITEM_SELECTION_START,
ID_POPUP_PCB_ITEM_SELECTION_END = MAX_ITEMS_IN_PICKER + ID_POPUP_PCB_ITEM_SELECTION_START,
ID_POPUP_PCB_AUTOPLACE_START_RANGE,
ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE,
......@@ -858,7 +864,6 @@ enum main_id {
ID_PCB_MUWAVE_END_CMD,
ID_END_LIST
};
#endif /* define ID_H */
......@@ -276,9 +276,9 @@ public:
* returned, otherwise any visible Pad or Module on any other layer.
* The provided layer must be visible.
* @param refPos The wxPoint to hit-test.
* @return EDA_BaseStruct* - if a direct hit, else NULL.
* @return BOARD_ITEM* - if a direct hit, else NULL.
*/
EDA_BaseStruct* FindPadOrModule( const wxPoint& refPos, int layer );
// BOARD_ITEM* FindPadOrModule( const wxPoint& refPos, int layer );
/**
......
......@@ -340,9 +340,7 @@ public:
WinEDA3D_DrawFrame* m_Draw3DFrame;
protected:
#if defined(DEBUG)
GENERAL_COLLECTOR* m_Collector;
#endif
public:
......@@ -392,17 +390,39 @@ public:
// Gestion du PCB
bool Clear_Pcb( wxDC* DC, bool query );
/**
* Function PcbGeneralLocateAndDisplay
* searches for an item under the mouse cursor.
* Items are searched first on the current working layer.
* If nothing found, an item will be searched without layer restriction. If
* more than one item is found meeting the current working layer criterion, then
* a popup menu is shown which allows the user to pick which item he/she is
* interested in. Once an item is chosen, then it is make the "current item"
* and the status window is updated to reflect this.
*/
BOARD_ITEM* PcbGeneralLocateAndDisplay();
BOARD_ITEM* Locate( int typeloc, int LayerSearch );
void ProcessItemSelection( wxCommandEvent& event );
/**
* Function SetCurItem
* sets the currently selected item and displays it in the MsgPanel.
* If the given item is NULL then the MsgPanel is erased and there is no
* currently selected item. This function is intended to make the process
* of "selecting" an item more formal, and to indivisibly tie the operation
* of selecting an item to displaying it using BOARD_ITEM::Display_Infos().
* @param aItem The BOARD_ITEM to make the selected item or NULL if none.
*/
void SetCurItem( BOARD_ITEM* aItem );
BOARD_ITEM* GetCurItem();
#if defined(DEBUG)
/**
* Function GetCollectorsGuide
* @return GENERAL_COLLECTORS_GUIDE - that considers the global configuration options.
*/
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
#endif
// Gestion du curseur
void place_marqueur( wxDC* DC, const wxPoint& pos, char* pt_bitmap,
......@@ -456,9 +476,11 @@ public:
// Chargement de modules
MODULE* Get_Librairie_Module( wxWindow* winaff, const wxString& library,
const wxString& ModuleName, bool show_msg_err );
wxString Select_1_Module_From_List(
WinEDA_DrawFrame* active_window, const wxString& Library,
const wxString& Mask, const wxString& KeyWord );
MODULE* Load_Module_From_Library( const wxString& library, wxDC* DC );
// Gestion des chevelus (ratsnest)
......@@ -514,6 +536,8 @@ public:
// divers
void AddHistory( int value, KICAD_T type ); // Add value in data list history
void InstallGridFrame( const wxPoint& pos );
DECLARE_EVENT_TABLE()
};
......@@ -533,7 +557,28 @@ private:
bool m_SelViaSizeBox_Changed;
wxMenu* m_FilesMenu;
#if 0 && defined(DEBUG)
/**
* Function onRightClickBuilder
* is a helper function for private use by OnRightClick(). It helps build
* the hierarchical menu.
* @param collectorNdx The index into the COLLECTOR that \a aItem represents.
* @param aItem The BOARD_ITEM to provide menu support for, or NULL if
* nothing was under the mouse.
* @param pPopMenu What to populate with choices.
*/
void onRightClickBuilder( int collectorNdx, BOARD_ITEM* aItem, wxMenu* aPopMenu );
void popUpMenuForFootprints( int collectorNdx, MODULE* aModule, wxMenu* aPopMenu );
void popUpMenuForFpTexts( int collectorNdx, TEXTE_MODULE* aText, wxMenu* aPopMenu );
void popUpMenuForFpPads( int collectorNdx, D_PAD* aPad, wxMenu* aPopMenu );
void popupMenuForTracks( int collectorNdx, TRACK* aTrack, wxMenu* aPopMenu );
#endif
public:
WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, const wxString& title,
const wxPoint& pos, const wxSize& size );
......@@ -549,6 +594,7 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
void Process_Special_Functions( wxCommandEvent& event );
void ProcessMuWaveFunctions( wxCommandEvent& event );
void MuWaveCommand( wxDC* DC, const wxPoint& MousePos );
......@@ -898,7 +944,7 @@ public:
virtual void HandleBlockPlace( wxDC* DC );
virtual int HandleBlockEnd( wxDC* DC );
EDA_BaseStruct* ModeditLocateAndDisplay();
BOARD_ITEM* ModeditLocateAndDisplay();
public:
void SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, int flag_type_command = 0 );
......
......@@ -15,15 +15,24 @@
#include "protos.h"
#include "id.h"
#if defined(DEBUG)
#include "collectors.h"
#endif
/*******************************/
/* class WinEDA_BasePcbFrame */
/*******************************/
BEGIN_EVENT_TABLE( WinEDA_BasePcbFrame, WinEDA_DrawFrame )
COMMON_EVENTS_DRAWFRAME
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
WinEDA_BasePcbFrame::ProcessItemSelection )
END_EVENT_TABLE()
/****************/
/* Constructeur */
/****************/
......@@ -48,18 +57,13 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
m_DisplayPcbTrackFill = TRUE; /* FALSE = sketch , TRUE = filled */
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
#if defined(DEBUG)
m_Collector = new GENERAL_COLLECTOR();
#endif
}
WinEDA_BasePcbFrame::~WinEDA_BasePcbFrame( void )
{
#if defined(DEBUG)
delete m_Collector;
#endif
}
......@@ -168,7 +172,51 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
GetScreen()->SetRefreshReq();
}
/*****************************************************************/
void WinEDA_BasePcbFrame::ProcessItemSelection( wxCommandEvent& event )
/*****************************************************************/
{
int id = event.GetId();
// index into the collector list:
int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
BOARD_ITEM* item = (*m_Collector)[itemNdx];
#if defined(DEBUG)
item->Show( 0, std::cout );
#endif
SetCurItem( item );
}
/*****************************************************************/
void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem )
/*****************************************************************/
{
m_CurrentScreen->SetCurItem( aItem );
if( aItem )
aItem->Display_Infos(this);
else
{
// we can use either of these:
//MsgPanel->EraseMsgBox();
m_Pcb->Display_Infos(this);
}
}
/*****************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::GetCurItem()
/*****************************************************************/
{
return (BOARD_ITEM*) m_CurrentScreen->GetCurItem();
}
/****************************************************************/
GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide()
/****************************************************************/
......@@ -185,6 +233,3 @@ GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide()
return guide;
}
#endif
/* XPM */
char * footprint_text_xpm[] = {
static char * footprint_text_xpm[] = {
"16 16 4 1",
" c None",
". c #009B9B",
......@@ -21,4 +21,3 @@ char * footprint_text_xpm[] = {
" .....+ ",
" ........ ",
" "};
......@@ -439,7 +439,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize();
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
/* Effacement des modules */
if( Block_Include_Modules )
......
......@@ -192,7 +192,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
DrawPanel->Refresh( TRUE );
}
......@@ -275,7 +275,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
GetScreen()->BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
DrawPanel->Refresh( TRUE );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
......
......@@ -440,8 +440,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
}
/*
// see pcbstruct.h
EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
{
class PadOrModule : public INSPECTOR
{
......@@ -514,6 +515,7 @@ EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
return inspector.found;
}
*/
/**
......
......@@ -1170,6 +1170,7 @@ bool MODULE::HitTest( const wxPoint& refPos )
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
return true;
/* no
// The GENERAL_COLLECTOR needs these two tests in order to find a MODULE
// when the user clicks on its text. Keep these 2, needed in OnRightClick().
if( m_Reference->HitTest( refPos ) )
......@@ -1177,7 +1178,7 @@ bool MODULE::HitTest( const wxPoint& refPos )
if( m_Value->HitTest( refPos ) )
return true;
*/
return false;
}
......
......@@ -22,8 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if defined(DEBUG)
#include "collectors.h"
#include "pcbnew.h" // class BOARD
......@@ -60,6 +58,26 @@ const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
};
const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = {
TYPEMODULE,
EOT
};
const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = {
TYPEPAD,
TYPEMODULE,
EOT
};
const KICAD_T GENERAL_COLLECTOR::Tracks[] = {
TYPETRACK,
TYPEVIA,
EOT
};
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
......@@ -77,7 +95,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
MODULE* module = NULL;
#if 1 // debugging
#if 0 // debugging
static int breakhere = 0;
switch( item->Type() )
{
......@@ -258,6 +276,9 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
m_ScanTypes);
SetTimeNow(); // when snapshot was taken
// record the length of the primary list before concatonating on to it.
m_PrimaryLength = m_List.size();
// append 2nd list onto end of the first list
for( unsigned i=0; i<m_List2nd.size(); ++i )
......@@ -267,6 +288,4 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
}
#endif // DEBUG
//EOF
......@@ -184,6 +184,13 @@ protected:
* Determines which items are to be collected by Inspect()
*/
const COLLECTORS_GUIDE* m_Guide;
/**
* The number of items that were originally in the primary list before the
* m_List2nd was concatonated onto the end of it.
*/
int m_PrimaryLength;
public:
......@@ -199,6 +206,24 @@ public:
* a MODULE, such as D_PAD and TEXTEMODULE.
*/
static const KICAD_T PrimaryItems[];
/**
* A scan list for only MODULEs
*/
static const KICAD_T ModuleItems[];
/**
* A scan list for PADs or MODULEs
*/
static const KICAD_T PadsOrModules[];
/**
* A scan list for only TRACKS
*/
static const KICAD_T Tracks[];
/**
......@@ -243,6 +268,13 @@ public:
}
/**
* Function GetPrimaryCount
* @return int - The number if items which met the primary search criteria
*/
int GetPrimaryCount() { return m_PrimaryLength; }
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
......
......@@ -18,6 +18,13 @@
#include "protos.h"
#include "collectors.h"
#include "bitmaps.h"
#include "Footprint_Text.xpm"
#include "add_cotation.xpm"
#include "Add_Mires.xpm"
#include "Add_Zone.xpm"
/* Routines Locales : */
/* Variables Locales */
......@@ -117,48 +124,282 @@ void RemoteCommand( const char* cmdline )
}
// @todo: move this to proper source file.
wxString BOARD_ITEM::MenuText() const
{
wxString text;
const BOARD_ITEM* item = this;
switch( item->Type() )
{
case PCB_EQUIPOT_STRUCT_TYPE:
text << _("Net") << ((EQUIPOT*)item)->m_Netname << wxT(" ") << ((EQUIPOT*)item)->m_NetCode;
break;
case TYPEMODULE:
text << _("Footprint") << wxT(" ") << ((MODULE*)item)->GetReference();
break;
case TYPEPAD:
text << _("Pad") << wxT(" ") << ((D_PAD*)item)->ReturnStringPadName() << _(" of ") << GetParent()->MenuText();
break;
case TYPEDRAWSEGMENT:
text << _("PGraphic");
break;
case TYPETEXTE:
text << _("Pcb Text") << wxT(" ");;
if( ((TEXTE_PCB*)item)->m_Text.Len() < 12 )
text << ((TEXTE_PCB*)item)->m_Text;
else
text += ((TEXTE_PCB*)item)->m_Text.Left( 10 ) + wxT( ".." );
break;
case TYPETEXTEMODULE:
switch( ((TEXTE_MODULE*)item)->m_Type )
{
case TEXT_is_REFERENCE:
text << _( "Reference" ) << wxT( " " ) << ((TEXTE_MODULE*)item)->m_Text;
break;
case TEXT_is_VALUE:
text << _( "Value" ) << wxT( " " ) << ((TEXTE_MODULE*)item)->m_Text << _(" of ") << GetParent()->MenuText();
break;
default:
text << _( "Text" ) << wxT( " " ) << ((TEXTE_MODULE*)item)->m_Text << _(" of ") << GetParent()->MenuText();
break;
}
break;
case TYPEEDGEMODULE:
text << _("MGraphic"); // @todo: expand on the text
break;
case TYPETRACK:
text << _("Track"); // @todo: expand on the text
break;
case TYPEZONE:
text << _("Zone"); // @todo: expand on the text
break;
case TYPEVIA:
text << _("Via"); // @todo: expand on text
break;
case TYPEMARQUEUR:
text << _("Marker");
break;
case TYPECOTATION:
text << _("Dimension"); // @todo: extend text
break;
case TYPEMIRE:
text << _("Mire"); // @todo: extend text, Mire is not an english word!
break;
case TYPEEDGEZONE:
text << _("Graphic"); // @todo: extend text
break;
default:
text << item->ReturnClassName() << wxT(" BUG!!");
break;
}
return text;
}
// @todo: move this to proper source file.
const char** BOARD_ITEM::MenuIcon() const
{
char** xpm;
const BOARD_ITEM* item = this;
switch( item->Type() )
{
case PCB_EQUIPOT_STRUCT_TYPE:
xpm = module_xpm; // @todo: use net icon
break;
case TYPEMODULE:
xpm = module_xpm;
break;
case TYPEPAD:
xpm = pad_xpm;
break;
case TYPEDRAWSEGMENT:
xpm = module_xpm; // @todo: use draw segment icon & expand on text
break;
case TYPETEXTE:
xpm = add_text_xpm;
break;
case TYPETEXTEMODULE:
xpm = footprint_text_xpm;
break;
case TYPEEDGEMODULE:
xpm = show_mod_edge_xpm;
break;
case TYPETRACK:
xpm = showtrack_xpm;
break;
case TYPEZONE:
xpm = add_zone_xpm;
break;
case TYPEVIA:
xpm = showtrack_xpm; // @todo: use via specific xpm
break;
case TYPEMARQUEUR:
xpm = pad_xpm; // @todo: create and use marker xpm
break;
case TYPECOTATION:
xpm = add_cotation_xpm;
break;
case TYPEMIRE:
xpm = add_mires_xpm;
break;
case TYPEEDGEZONE:
xpm = show_mod_edge_xpm; // @todo: pcb edge xpm
break;
default:
xpm = 0;
break;
}
return (const char**) xpm;
}
/***********************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
/***********************************************************************/
/* Search an item under the mouse cursor.
* items are searched first on the current working layer.
* if nothing found, an item will be searched without layer restriction
*/
{
BOARD_ITEM* item;
BOARD_ITEM* item;
#if defined(DEBUG)
// test scaffolding for Collect():
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
m_Collector->Collect( m_Pcb,
GetScreen()->RefPos(true),
&guide );
// use only the first one collected for now.
item = (*m_Collector)[0]; // grab first one, may be NULL
// Assign to scanList the proper item types desired based on tool type.
// May need to pass a hot key code to this function to support hot keys too.
std::cout << "collected " << m_Collector->GetCount() << '\n'; // debugging only
const KICAD_T* scanList;
if( m_ID_current_state == 0 )
{
switch( m_HTOOL_current_state )
{
case ID_TOOLBARH_PCB_AUTOPLACE:
scanList = GENERAL_COLLECTOR::ModuleItems;
break;
default:
scanList = GENERAL_COLLECTOR::AllBoardItems;
break;
}
}
else
{
switch( m_ID_current_state )
{
case ID_PCB_SHOW_1_RATSNEST_BUTT:
scanList = GENERAL_COLLECTOR::PadsOrModules;
break;
case ID_TRACK_BUTT:
scanList = GENERAL_COLLECTOR::Tracks;
break;
case ID_COMPONENT_BUTT:
scanList = GENERAL_COLLECTOR::ModuleItems;
break;
default:
scanList = GENERAL_COLLECTOR::AllBoardItems;
}
}
m_Collector->Collect( m_Pcb, scanList, GetScreen()->RefPos(true), guide );
/* debugging: print out the collected items, showing their priority order too.
for( unsigned i=0; i<m_Collector->GetCount(); ++i )
(*m_Collector)[i]->Show( 0, std::cout );
*/
if( m_Collector->GetCount() <= 1 )
{
item = (*m_Collector)[0];
SetCurItem( item );
}
if( item )
// If the first item is a pad or moduletext, and the 2nd item is its parent module:
else if( m_Collector->GetCount() == 2 &&
( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == TYPETEXTEMODULE) &&
(*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()==(*m_Collector)[1] )
{
item->Display_Infos( this );
item = (*m_Collector)[0];
SetCurItem( item );
}
else // show a popup menu
{
wxMenu itemMenu;
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
itemMenu.SetTitle( _("Selection Clarification") ); // does this work? not under Linux!
// debugging: print out the collected items, showing their priority order too.
for( unsigned i=0; i<m_Collector->GetCount(); ++i )
(*m_Collector)[i]->Show( 0, std::cout );
for( int i=0; i<limit; ++i )
{
wxString text;
const char** xpm;
item = (*m_Collector)[i];
text = item->MenuText();
xpm = item->MenuIcon();
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START+i, text, xpm );
}
DrawPanel->m_IgnoreMouseEvents = TRUE;
// this menu's handler is void WinEDA_BasePcbFrame::ProcessItemSelection()
// and it calls SetCurItem() which in turn calls Display_Infos() on the item.
PopupMenu( &itemMenu );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
// The function ProcessItemSelection() has set the current item, return it.
item = GetCurItem();
}
return item;
#else
/* old way:
item = Locate( CURSEUR_OFF_GRILLE, GetScreen()->m_Active_Layer );
if( item == NULL )
item = Locate( CURSEUR_OFF_GRILLE, -1 );
return item;
#endif
*/
}
......
......@@ -219,7 +219,7 @@ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC )
status_cotation = 0;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem(NULL);
}
......
......@@ -96,7 +96,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
Hight_Light( DC );
g_CurrentTrackSegment = NULL;
g_FirstTrackSegment = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
return NULL;
}
else
......
......@@ -622,7 +622,7 @@ void WinEDA_ModulePropertiesFrame::ExchangeModule( wxCommandEvent& event )
m_DC, wxPoint( -1, -1 ) );
// Attention: si il y a eu echange, m_CurrentModule a t delete!
m_Parent->GetScreen()->SetCurItem( NULL );
m_Parent->SetCurItem( NULL );
Close( TRUE );
}
......
......@@ -48,7 +48,7 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
CursorInitialPosition = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = Move_Segment;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
GetScreen()->SetCurItem( Edge );
SetCurItem( Edge );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
......@@ -77,7 +77,7 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
Edge->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetScreen()->SetModify();
MODULE* Module = (MODULE*) Edge->m_Parent;
Module->Set_Rectangle_Encadrement();
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
drawitem->Display_Infos( this );
DrawPanel->ManageCurseur = Move_Segment;
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
GetScreen()->SetCurItem( drawitem );
SetCurItem( drawitem );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
......@@ -55,7 +55,7 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
Trace_DrawSegmentPcb( DrawPanel, DC, drawitem, GR_OR );
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetScreen()->SetModify();
drawitem->m_Flags = 0;
}
......@@ -113,14 +113,14 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) )
Segment = (DRAWSEGMENT*) PtStruct;
DisplayOpt.DisplayDrawItems = track_fill_copy;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
}
else
{
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR );
Segment->m_Flags = 0;
DeleteStructure( Segment );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetScreen()->SetModify();
}
}
......@@ -248,7 +248,7 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
}
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem( NULL );
}
......@@ -275,7 +275,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
if( Segment == NULL ) /* debut reel du trace */
{
GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) );
SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) );
Segment->m_Flags = IS_NEW;
Segment->SetLayer( GetScreen()->m_Active_Layer );
Segment->m_Width = s_large;
......@@ -305,7 +305,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
DrawItem = Segment;
GetScreen()->SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) );
SetCurItem( Segment = new DRAWSEGMENT( m_Pcb ) );
Segment->m_Flags = IS_NEW;
Segment->SetLayer( DrawItem->GetLayer() );
......@@ -353,7 +353,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
}
......
......@@ -50,7 +50,7 @@ void WinEDA_BasePcbFrame::InstallModuleOptionsFrame( MODULE* Module,
m_Parent->m_ModuleEditFrame->Load_Module_Module_From_BOARD(
(MODULE*) GetScreen()->GetCurItem() );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GoToEditor = FALSE;
m_Parent->m_ModuleEditFrame->Show( TRUE );
......
......@@ -61,7 +61,7 @@ static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
}
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
frame->GetScreen()->SetCurItem( NULL );
frame->SetCurItem( NULL );
}
......@@ -156,7 +156,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
}
g_CurrentTrackSegment->Display_Infos( this );
GetScreen()->SetCurItem( g_CurrentTrackSegment );
SetCurItem( g_CurrentTrackSegment );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( Drc_On && (Drc( this, DC, g_CurrentTrackSegment, m_Pcb->m_Track, 1 ) == BAD_DRC) )
{
......@@ -221,7 +221,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
g_CurrentTrackSegment->Display_Infos( this );
}
GetScreen()->SetCurItem( g_CurrentTrackSegment );
SetCurItem( g_CurrentTrackSegment );
return g_CurrentTrackSegment;
}
......@@ -472,7 +472,7 @@ void WinEDA_PcbFrame::End_Route( TRACK* track, wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
}
......
......@@ -171,7 +171,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
Text->Display_Infos( this );
GetScreen()->SetCurItem( Text );
SetCurItem( Text );
DrawPanel->ManageCurseur = Show_MoveTexte_Module;
DrawPanel->ForceCloseManageCurseur = ExitTextModule;
......
......@@ -235,7 +235,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo
g_SaveTime = time( NULL );
#if 1 && defined(DEBUG)
#if 0 && defined(DEBUG)
// note this seems to freeze up pcbnew when run under the kicad project
// manager. runs fine from command prompt.
// output the board object tree to stdout:
......
......@@ -165,11 +165,9 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
*/
{
bool PopupOn = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags;
bool PopupOn = (GetCurItem() && GetCurItem()->m_Flags);
bool ItemFree = (GetScreen()->GetCurItem() == 0 )
|| (GetScreen()->GetCurItem()->m_Flags == 0);
bool ItemFree = (GetCurItem()==0 || GetCurItem()->m_Flags==0);
if( hotkey == 0 )
return;
......@@ -296,11 +294,15 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_BACK_SPACE:
if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N )
{
bool ItemFree = (GetScreen()->GetCurItem() == NULL )
|| (GetScreen()->GetCurItem()->m_Flags == 0);
bool ItemFree = GetCurItem()==NULL || GetCurItem()->m_Flags==0;
if( ItemFree )
{
// no track is currently being edited - select a segment and remove it.
// @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() so it can restrict its search to specific item types.
// @todo: use PcbGeneralLocateAndDisplay() everywhere in this source file.
DrawStruct = PcbGeneralLocateAndDisplay();
// don't let backspace delete modules!!
......@@ -309,10 +311,10 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
Delete_Segment( DC, (TRACK*) DrawStruct );
GetScreen()->SetModify();
}
else if( GetScreen()->GetCurItem()->Type() == TYPETRACK )
else if( GetCurItem()->Type() == TYPETRACK )
{
// then an element is being edited - remove the last segment.
GetScreen()->SetCurItem( Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) );
SetCurItem( Delete_Segment( DC, (TRACK*) GetCurItem() ) );
GetScreen()->SetModify();
}
}
......@@ -320,7 +322,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_END_TRACK:
DrawPanel->MouseToCursorSchema();
End_Route( (TRACK*) ( GetScreen()->GetCurItem() ), DC );
End_Route( (TRACK*) ( GetCurItem() ), DC );
break;
case HK_FIND_ITEM:
......@@ -357,11 +359,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
Other_Layer_Route( NULL, DC );
break;
}
if( GetScreen()->GetCurItem()->Type() != TYPETRACK )
if( GetCurItem()->Type() != TYPETRACK )
return;
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 )
if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
return;
Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC );
Other_Layer_Route( (TRACK*) GetCurItem(), DC );
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
break;
......@@ -371,11 +373,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
// get any module, locked or not locked and toggle its locked status
if( ItemFree )
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
else if( GetScreen()->GetCurItem()->Type() == TYPEMODULE )
module = (MODULE*) GetScreen()->GetCurItem();
else if( GetCurItem()->Type() == TYPEMODULE )
module = (MODULE*) GetCurItem();
if( module )
{
GetScreen()->SetCurItem( module );
SetCurItem( module );
module->SetLocked( !module->IsLocked() );
module->Display_Infos( this );
}
......@@ -415,12 +417,12 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
}
}
}
else if( GetScreen()->GetCurItem()->Type() == TYPEMODULE )
else if( GetCurItem()->Type() == TYPEMODULE )
{
module = (MODULE*) GetScreen()->GetCurItem();
module = (MODULE*) GetCurItem();
// @todo: might need to add a layer check in if() below
if( (GetScreen()->GetCurItem()->m_Flags == 0)
if( (GetCurItem()->m_Flags == 0)
&& module->IsLocked() )
module = NULL; // do not move, rotate ... it.
}
......@@ -432,13 +434,13 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
* does not set GetCurItem() at this time, nor does a mouse click
* when the local ratsnest icon is in play set GetCurItem(), and these
* actions also call SendMessageToEESCHEMA().
* if( GetScreen()->GetCurItem() != module )
* if( GetCurItem() != module )
*/
{
// Send the module via socket to EESCHEMA's search facility.
SendMessageToEESCHEMA( module );
GetScreen()->SetCurItem( module );
SetCurItem( module );
}
switch( CommandCode )
......@@ -538,8 +540,8 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
* Delete the module.
*/
{
bool ItemFree = (GetScreen()->GetCurItem() == NULL )
|| (GetScreen()->GetCurItem()->m_Flags == 0);
bool ItemFree = (GetCurItem() == NULL )
|| (GetCurItem()->m_Flags == 0);
switch( m_ID_current_state )
{
......@@ -553,10 +555,10 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
return FALSE;
Delete_Track( DC, (TRACK*) DrawStruct );
}
else if( GetScreen()->GetCurItem()->Type() == TYPETRACK )
else if( GetCurItem()->Type() == TYPETRACK )
{
GetScreen()->SetCurItem(
Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) );
SetCurItem(
Delete_Segment( DC, (TRACK*) GetCurItem() ) );
GetScreen()->SetModify();
return TRUE;
}
......@@ -581,6 +583,6 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
}
GetScreen()->SetModify();
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
return TRUE;
}
......@@ -99,7 +99,7 @@ void WinEDA_PcbGlobalDeleteFrame::AcceptPcbDelete( wxCommandEvent& event )
if( redraw )
{
m_Parent->GetScreen()->SetCurItem( NULL );
m_Parent->SetCurItem( NULL );
m_Parent->ReDrawPanel();
}
......@@ -182,7 +182,7 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( wxDC* DC, bool query )
m_Pcb->m_NbNoconnect = 0;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_NbSegmZone = 0;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
/* Init parametres de gestion */
GetScreen()->Init();
......
......@@ -59,7 +59,7 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module )
if( Module == NULL )
return;
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
Clear_Pcb( NULL, TRUE );
......
......@@ -243,7 +243,7 @@ void WinEDA_PcbFrame::StartMove_Mire( MIREPCB* MirePcb, wxDC* DC )
MirePcb->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur = Montre_Position_Mire;
DrawPanel->ForceCloseManageCurseur = Exit_EditMire;
GetScreen()->SetCurItem( MirePcb );
SetCurItem( MirePcb );
}
......@@ -259,7 +259,7 @@ void WinEDA_PcbFrame::Place_Mire( MIREPCB* MirePcb, wxDC* DC )
MirePcb->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetScreen()->SetModify();
}
......
......@@ -19,10 +19,10 @@
/*********************************************************************/
EDA_BaseStruct* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay()
BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay()
/*********************************************************************/
{
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
BOARD_ITEM* DrawStruct = GetCurItem();
MODULE* Module = m_Pcb->m_Modules;
if( Module == NULL )
......@@ -129,7 +129,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_NEW_MODULE:
Clear_Pcb( &dc, TRUE );
GetScreen()->ClearUndoRedoList();
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Create_1_Module( &dc, wxEmptyString );
if( m_Pcb->m_Modules )
......@@ -224,14 +224,14 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
newmodule->m_Flags = 0;
GetScreen()->ClrModify();
pcbframe->GetScreen()->SetCurItem( NULL );
pcbframe->SetCurItem( NULL );
mainpcb->m_Status_Pcb = 0;
}
break;
case ID_LIBEDIT_IMPORT_PART:
GetScreen()->ClearUndoRedoList();
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
Clear_Pcb( &dc, TRUE );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Import_Module( &dc );
......@@ -259,7 +259,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_LOAD_MODULE:
{
GetScreen()->ClearUndoRedoList();
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
Clear_Pcb( &dc, TRUE );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Load_Module_From_Library( m_CurrentLib, &dc );
......@@ -301,7 +301,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
if( m_Pcb->m_Modules )
{
GetScreen()->SetCurItem( m_Pcb->m_Modules );
SetCurItem( m_Pcb->m_Modules );
InstallModuleOptionsFrame( (MODULE*) GetScreen()->GetCurItem(),
&dc, pos );
GetScreen()->GetCurItem()->m_Flags = 0;
......@@ -375,7 +375,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_PAD:
SaveCopyInUndoList( m_Pcb->m_Modules );
DeletePad( (D_PAD*) GetScreen()->GetCurItem(), &dc );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
DrawPanel->MouseToCursorSchema();
break;
......@@ -418,7 +418,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( m_Pcb->m_Modules );
DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(),
&dc );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
DrawPanel->MouseToCursorSchema();
break;
......@@ -432,7 +432,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) )
{
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
}
break;
......@@ -474,7 +474,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( m_Pcb->m_Modules );
DrawPanel->MouseToCursorSchema();
RemoveStruct( GetScreen()->GetCurItem(), &dc );
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
break;
case ID_MODEDIT_MODULE_ROTATE:
......
......@@ -34,7 +34,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
* quand un outil est deja selectionn
*/
{
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
BOARD_ITEM* DrawStruct = GetCurItem();
DrawPanel->CursorOff( DC );
if( m_ID_current_state == 0 )
......@@ -72,10 +72,11 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
}
DrawStruct = m_CurrentScreen->GetCurItem();
DrawStruct = GetCurItem();
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( DrawStruct = ModeditLocateAndDisplay() );
DrawStruct = (BOARD_ITEM*) ModeditLocateAndDisplay();
SetCurItem( DrawStruct );
}
switch( m_ID_current_state )
......@@ -97,7 +98,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC;
m_CurrentScreen->SetCurItem(
SetCurItem(
Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
}
else if( (DrawStruct->m_Flags & IS_NEW) )
......@@ -105,16 +106,16 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_CIRCLE )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
}
else if( ( (EDGE_MODULE*) DrawStruct )->m_Shape == S_SEGMENT )
{
m_CurrentScreen->SetCurItem(
SetCurItem(
Begin_Edge_Module( (EDGE_MODULE*) DrawStruct, DC, 0 ) );
}
else
......@@ -130,7 +131,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
SaveCopyInUndoList( m_Pcb->m_Modules );
RemoveStruct( DrawStruct, DC );
m_CurrentScreen->SetCurItem( DrawStruct = NULL );
SetCurItem( DrawStruct = NULL );
}
}
break;
......@@ -144,7 +145,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
Place_Module( m_Pcb->m_Modules, DC );
RedrawActiveWindow( DC, TRUE );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
break;
case ID_TEXT_COMMENT_BUTT:
......@@ -181,7 +182,7 @@ void WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
* Ce menu est ensuite complt par la liste des commandes de ZOOM
*/
{
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
BOARD_ITEM* DrawStruct = GetCurItem();
wxString msg;
bool append_set_width = FALSE;
bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE);
......@@ -189,7 +190,7 @@ void WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
// Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( DrawStruct = ModeditLocateAndDisplay() );
SetCurItem( DrawStruct = ModeditLocateAndDisplay() );
}
// Si commande en cours: affichage fin de commande
......@@ -378,7 +379,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
* appel de l'editeur correspondant.
*/
{
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel );
......@@ -396,7 +397,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break;
// Element localis
m_CurrentScreen->SetCurItem( DrawStruct );
SetCurItem( DrawStruct );
switch( DrawStruct->Type() )
{
......@@ -429,7 +430,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
End_Edge_Module( (EDGE_MODULE*) DrawStruct, DC );
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
}
break;
}
......
......@@ -56,7 +56,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList()
(MODULE*) GetScreen()->GetItemFromRedoList();
if( m_Pcb->m_Modules )
m_Pcb->m_Modules->Pnext = NULL;
GetScreen()->SetCurItem( NULL );;
SetCurItem( NULL );;
GetScreen()->SetModify();
ReCreateHToolbar();
SetToolbars();
......@@ -82,7 +82,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromUndoList()
if( m_Pcb->m_Modules )
m_Pcb->m_Modules->Pnext = NULL;
GetScreen()->SetModify();
GetScreen()->SetCurItem( NULL );;
SetCurItem( NULL );;
ReCreateHToolbar();
SetToolbars();
}
......@@ -131,7 +131,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, WinEDA_App* pa
m_Pcb->m_PcbFrame = this;
m_CurrentScreen = ScreenModule;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
GetSettings();
wxSize GridSize( 500, 500 );
......
......@@ -100,7 +100,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
if( module == NULL )
return;
m_CurrentScreen->SetCurItem( module );
SetCurItem( module );
m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK;
module->m_Flags |= IS_MOVED;
ModuleInitOrient = module->m_Orient;
......@@ -199,7 +199,7 @@ void Exit_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
g_Drag_Pistes_On = FALSE;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
pcbframe->m_CurrentScreen->SetCurItem( NULL );
pcbframe->SetCurItem( NULL );
}
......
......@@ -93,8 +93,8 @@ static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
Panel->m_Parent->EraseMsgBox();
Panel->SetCurItem( NULL );
// Panel->m_Parent->EraseMsgBox(); SeCurItem() does this
/* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM* pt_drag = g_DragSegmentList;
......
......@@ -95,8 +95,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
Panel->m_Parent->EraseMsgBox();
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem(NULL);
/* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM* pt_drag = g_DragSegmentList;
......
......@@ -113,7 +113,7 @@ static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->m_CurrentScreen->SetCurItem( NULL );
frame->SetCurItem( NULL );
}
......
......@@ -131,25 +131,23 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE);
wxClientDC dc( DrawPanel );
BOARD_ITEM* item = GetScreen()->GetCurItem();
BOARD_ITEM* item = GetCurItem();
DrawPanel->CursorOff( &dc );
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
// Simple localisation des elements si possible
if( item == NULL || item->m_Flags == 0 )
/* The user must now left click to first make the selection. OnRightClick()
is now only an action mechanism, not a selection mechanism. The selection
mechanism sometimes involves a popup menu, so it is too complex to try
and do that here.
// Only offer user a new selection if there is currently none.
if( item == NULL )
{
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOPLACE )
{
item = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
if( item )
item->Display_Infos( this );
else
item = PcbGeneralLocateAndDisplay();
}
else
item = PcbGeneralLocateAndDisplay();
item = PcbGeneralLocateAndDisplay();
}
*/
// If command in progress: Put the Cancel command (if needed) and End command
if( m_ID_current_state )
......@@ -187,19 +185,11 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
return;
}
m_CurrentScreen->SetCurItem( item );
if( item )
flags = item->m_Flags;
else
flags = 0;
if( !flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST,
_( "Get and Move Footprint" ), Move_Module_xpm );
}
if( item )
{
switch( item->Type() )
......@@ -230,15 +220,6 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
break;
case TYPEPAD:
if( !flags )
{
MODULE* module = (MODULE*) item->m_Parent;
if( module )
{
CreatePopUpMenuForFootprints( module, aPopMenu, TRUE );
aPopMenu->AppendSeparator();
}
}
CreatePopUpMenuForPads( (D_PAD*) item, aPopMenu );
if( m_HTOOL_current_state == ID_TOOLBARH_PCB_AUTOROUTE )
{
......@@ -248,19 +229,28 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
aPopMenu->Append( ID_POPUP_PCB_AUTOROUTE_NET, _( "Autoroute Net" ) );
}
}
if( !flags )
{
MODULE* module = (MODULE*) item->m_Parent;
if( module )
{
aPopMenu->AppendSeparator();
CreatePopUpMenuForFootprints( module, aPopMenu, TRUE );
}
}
break;
case TYPETEXTEMODULE:
CreatePopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu );
if( !flags )
{
MODULE* module = (MODULE*) item->m_Parent;
if( module )
{
CreatePopUpMenuForFootprints( module, aPopMenu, TRUE );
aPopMenu->AppendSeparator();
CreatePopUpMenuForFootprints( module, aPopMenu, TRUE );
}
}
CreatePopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu );
break;
case TYPEDRAWSEGMENT:
......@@ -355,6 +345,12 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
aPopMenu->AppendSeparator();
}
if( !flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST,
_( "Get and Move Footprint" ), Move_Module_xpm );
}
/* Traitement des fonctions specifiques */
switch( m_ID_current_state )
{
......
......@@ -6,6 +6,7 @@
#include "common.h"
#include "pcbnew.h"
#include "collectors.h"
#include "bitmaps.h"
#include "protos.h"
......@@ -16,7 +17,7 @@
/* class WinEDA_PcbFrame */
/*******************************/
BEGIN_EVENT_TABLE( WinEDA_PcbFrame, wxFrame )
BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
COMMON_EVENTS_DRAWFRAME
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, WinEDA_PcbFrame::OnSockRequestServer )
......@@ -159,7 +160,7 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, wxFrame )
// Annulation de commande en cours
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_PcbFrame::Process_Special_Functions )
// PopUp Menus pour Zooms traites dans drawpanel.cpp
END_EVENT_TABLE()
......
......@@ -251,7 +251,7 @@ void Exit_Texte_Pcb( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem( NULL );
}
......@@ -270,7 +270,7 @@ void WinEDA_PcbFrame::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
m_CurrentScreen->SetModify();
TextePcb->m_Flags = 0;
}
......@@ -291,7 +291,7 @@ void WinEDA_PcbFrame::StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Display_Infos( this );
DrawPanel->ManageCurseur = Move_Texte_Pcb;
DrawPanel->ForceCloseManageCurseur = Exit_Texte_Pcb;
m_CurrentScreen->SetCurItem( TextePcb );
SetCurItem( TextePcb );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
......@@ -332,7 +332,7 @@ void WinEDA_PcbFrame::Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
DeleteStructure( TextePcb );
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
m_CurrentScreen->SetCurItem( NULL );
SetCurItem( NULL );
}
......
......@@ -495,7 +495,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone )
Segm = previous_segm;
m_Pcb->m_CurrentLimitZone = Segm;
GetScreen()->SetCurItem( Segm );
SetCurItem( Segm );
if( Segm )
{
......@@ -507,7 +507,7 @@ EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone )
{
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
}
return Segm;
}
......@@ -626,7 +626,7 @@ static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
pcbframe->GetScreen()->SetCurItem( NULL );
pcbframe->SetCurItem( NULL );
}
......@@ -656,7 +656,7 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
segment->Pnext = NULL; delete segment;
}
GetScreen()->SetCurItem( NULL );
SetCurItem( NULL );
m_Pcb->m_CurrentLimitZone = NULL;
}
......
......@@ -7,6 +7,10 @@ folks will see these items and volunteer to do them.
// @todo: bug? memory leak at this point: about line 418
this definitely looks like a memory leak.
*** footprint_text_xpm is included more than once into the link image of pcbnew.
*** @todo: grep for @todo and finish off those tasks.
*** make the ADD_MENUITEM macros in include/macros.h be static inline functions instead
of macros. e.g. w/o argument types:
......@@ -18,10 +22,6 @@ static inline void ADD_MENUITEM(menu, id, text, icon)
}
*** Add hierarchical menu to right mouse click in PCBNEW for the case when
multiple items are under the mouse cursor.
*** Set up a DOXYGEN environment starting with a configuration file that:
- understands the JavaDoc style comments that we have started using
- gives preference to comments in header files over *.cpp files
......
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