Commit 6acce67a authored by dickelbeck's avatar dickelbeck

made m_CurrentItem private, beautification

parent 4ca51f75
This diff is collapsed.
...@@ -5,6 +5,22 @@ Please add newer entries at the top, list the date and your name with ...@@ -5,6 +5,22 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Aug-19 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ all
* Made BASE_SCREEN::m_CurrentItem private so we can force usage of the new
SetCurItem() function, and use it to put a breakpoint on the only place
that m_CurrentItem is changed, namely in the new SetCurItem() function.
( Added new function GetCurItem() as well to class BASE_SCREEN in
drawpanel_wxstruct.h.) Using a stack trace at the breakpoint we can tell
who called it. There were in excess of 450 edits to get this done so I
had to commit it asap so other folks could get on with edits without a
merge conflict.
* Started work on the COLLECTOR class which will assist in giving a choice
in PCBNEW when there is more than one click candidate at the same mouse
or cursor coordinates. COLLECTOR not committed yet.
* More beautification.
2007-Aug-14 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Aug-14 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -21,25 +21,25 @@ static int s_LastShape = '\\'; ...@@ -21,25 +21,25 @@ static int s_LastShape = '\\';
static wxPoint ItemInitialPosition; static wxPoint ItemInitialPosition;
/**************************************************************/ /**************************************************************/
static void ExitBusEntry( WinEDA_DrawPanel * Panel, wxDC * DC ) static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/ /**************************************************************/
/* Routine de sortie des menus de trace */ /* Routine de sortie des menus de trace */
{ {
DrawBusEntryStruct *BusEntry = DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct *)Panel->GetScreen()->m_CurrentItem; (DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry) /* trace en cours */ if( BusEntry ) /* trace en cours */
{ {
RedrawOneStruct(Panel, DC, BusEntry, g_XorMode); RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW ) if( BusEntry->m_Flags & IS_NEW )
{ {
delete BusEntry; delete BusEntry;
Panel->GetScreen()->m_CurrentItem = NULL; Panel->GetScreen()->SetCurItem( NULL );
} }
else else
{ {
BusEntry->m_Pos = ItemInitialPosition; BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct(Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE); RedrawOneStruct( Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE );
BusEntry->m_Flags = 0; BusEntry->m_Flags = 0;
} }
} }
...@@ -49,55 +49,62 @@ DrawBusEntryStruct *BusEntry = ...@@ -49,55 +49,62 @@ DrawBusEntryStruct *BusEntry =
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
} }
/************************************************************************/ /************************************************************************/
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase) static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/ /************************************************************************/
/* Dessin du Segment "BusEntry" lors des deplacements du curseur /* Dessin du Segment "BusEntry" lors des deplacements du curseur
*/ */
{ {
BASE_SCREEN * screen = panel->m_Parent->GetScreen(); BASE_SCREEN* screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct *BusEntry = (DrawBusEntryStruct *) screen->m_CurrentItem; DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
if( BusEntry == NULL ) return; if( BusEntry == NULL )
return;
/* effacement apres deplacement curseur */ /* effacement apres deplacement curseur */
if( erase ) if( erase )
RedrawOneStruct(panel, DC, BusEntry, g_XorMode); RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */ /* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur; BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct(panel, DC, BusEntry, g_XorMode); RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
} }
/**********************************************************************************/ /**********************************************************************************/
DrawBusEntryStruct * WinEDA_SchematicFrame::CreateBusEntry(wxDC * DC, int entry_type) DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type )
/**********************************************************************************/ /**********************************************************************************/
/* Create a new bus entry, and prepare moving function (for later place it) /* Create a new bus entry, and prepare moving function (for later place it)
*/ */
{ {
DrawBusEntryStruct * BusEntry = new DrawBusEntryStruct(GetScreen()->m_Curseur, DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
s_LastShape , entry_type); s_LastShape, entry_type );
BusEntry->m_Flags = IS_NEW; BusEntry->m_Flags = IS_NEW;
DrawPanel->CursorOff(DC); // Erase schematic cursor DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
DrawPanel->CursorOn(DC); // Display schematic cursor DrawPanel->CursorOn( DC ); // Display schematic cursor
GetScreen()->SetModify(); GetScreen()->SetModify();
StartMoveBusEntry(BusEntry, DC); StartMoveBusEntry( BusEntry, DC );
return BusEntry; return BusEntry;
} }
/**************************************************************************/ /**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry, void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC * DC) wxDC* DC )
/**************************************************************************/ /**************************************************************************/
{ {
if ( BusEntry == NULL ) return; if( BusEntry == NULL )
return;
if ( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */ if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{ {
delete g_ItemToUndoCopy; delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy(); g_ItemToUndoCopy = BusEntry->GenCopy();
...@@ -107,66 +114,67 @@ void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry, ...@@ -107,66 +114,67 @@ void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry,
ItemInitialPosition = BusEntry->m_Pos; ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff(DC); DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = BusEntry->m_Pos; GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->m_CurrentItem = BusEntry; GetScreen()->SetCurItem( BusEntry );
DrawPanel->ManageCurseur = ShowWhileMoving; DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry; DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn(DC); DrawPanel->CursorOn( DC );
} }
/************************************************************/ /************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape(wxDC * DC, void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct *BusEntry, int entry_shape) DrawBusEntryStruct* BusEntry, int entry_shape )
/************************************************************/ /************************************************************/
/* set the shape of BusEntry (shape = / or \ ) /* set the shape of BusEntry (shape = / or \ )
*/ */
{ {
if ( BusEntry == NULL ) return; if( BusEntry == NULL )
return;
if ( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE ) if( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE )
{ {
DisplayError(this, wxT("SetBusEntryType: Bad StructType") ); DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return; return;
} }
/* Put old item in undo list if it is not currently in edit */ /* Put old item in undo list if it is not currently in edit */
if ( BusEntry->m_Flags == 0 ) SaveCopyInUndoList(BusEntry, IS_CHANGED); if( BusEntry->m_Flags == 0 )
SaveCopyInUndoList( BusEntry, IS_CHANGED );
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
switch( entry_shape ) switch( entry_shape )
{ {
case '\\' : case '\\':
s_LastShape = '\\'; s_LastShape = '\\';
BusEntry->m_Size.y = 100; BusEntry->m_Size.y = 100;
break; break;
case '/' : case '/':
s_LastShape = '/'; s_LastShape = '/';
BusEntry->m_Size.y = -100; BusEntry->m_Size.y = -100;
break; break;
} }
TestDanglingEnds(GetScreen()->EEDrawList, NULL); TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
/************************************************************************/ /************************************************************************/
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct *BusEntry) int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
/************************************************************************/ /************************************************************************/
{ {
int entry_shape = '\\'; int entry_shape = '\\';
if ( BusEntry->m_Size.y < 0 ) entry_shape = '/'; if( BusEntry->m_Size.y < 0 )
entry_shape = '/';
return entry_shape; return entry_shape;
} }
This diff is collapsed.
This diff is collapsed.
...@@ -395,9 +395,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ...@@ -395,9 +395,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
if( hotkey ) if( hotkey )
{ {
if( m_CurrentScreen->m_CurrentItem if( m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->m_CurrentItem->m_Flags ) && m_CurrentScreen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem ); OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() );
else else
OnHotKey( DC, hotkey, NULL ); OnHotKey( DC, hotkey, NULL );
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef BASE_STRUCT_H #ifndef BASE_STRUCT_H
#define BASE_STRUCT_H #define BASE_STRUCT_H
#include <vector>
#if defined(DEBUG) #if defined(DEBUG)
#include <iostream> // needed for Show() #include <iostream> // needed for Show()
...@@ -95,8 +97,53 @@ class EDA_BaseStruct; ...@@ -95,8 +97,53 @@ class EDA_BaseStruct;
*/ */
class INSPECTOR class INSPECTOR
{ {
private:
/// A place to hold collected objects without taking ownership of their memory.
std::vector<EDA_BaseStruct*> list;
public: public:
virtual ~INSPECTOR() {} virtual ~INSPECTOR()
{
// empty the list so that ~list() does not try and delete all
// the objects that it holds. list is not the owner of such objects.
Empty();
}
/**
* Function GetCount
* returns the number of objects in the list
*/
int GetCount() const
{
return list.size();
}
/**
* Function Empty
* sets the list to empty
*/
void Empty()
{
list.clear();
}
/**
* Function operator[]
* is used for read only access and returns the object at index ndx.
* @param ndx The index into the list.
* @return EDA_BaseStruct* - or something derived from it, or NULL.
*/
EDA_BaseStruct* operator[]( int ndx ) const
{
if( (unsigned)ndx < (unsigned)GetCount() )
return list[ndx];
return NULL;
}
/** /**
* Function Inspect * Function Inspect
...@@ -112,9 +159,6 @@ public: ...@@ -112,9 +159,6 @@ public:
*/ */
SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem, SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem,
const void* testData ) = 0; const void* testData ) = 0;
// derived classes add more functions for collecting and subsequent
// retrieval here.
}; };
......
This diff is collapsed.
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#define eda_global extern #define eda_global extern
#endif #endif
#include <vector>
#include <wx/socket.h> #include <wx/socket.h>
#include "wx/log.h" #include "wx/log.h"
#include "wx/config.h" #include "wx/config.h"
...@@ -502,6 +504,7 @@ public: ...@@ -502,6 +504,7 @@ public:
/*****************************************************/ /*****************************************************/
class WinEDA_PcbFrame : public WinEDA_BasePcbFrame class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
{ {
public: public:
WinEDAChoiceBox* m_SelLayerBox; WinEDAChoiceBox* m_SelLayerBox;
WinEDAChoiceBox* m_SelTrackWidthBox; WinEDAChoiceBox* m_SelTrackWidthBox;
...@@ -512,6 +515,13 @@ private: ...@@ -512,6 +515,13 @@ private:
bool m_SelViaSizeBox_Changed; bool m_SelViaSizeBox_Changed;
wxMenu* m_FilesMenu; wxMenu* m_FilesMenu;
#if defined(DEBUG)
class COLLECTOR;
COLLECTOR* m_GeneralCollector; ///< while arrow icon tool
COLLECTOR* m_RatsModuleCollector; ///< while find1rats icon tool
#endif
public: public:
WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, const wxString& title, WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, const wxString& title,
const wxPoint& pos, const wxSize& size ); const wxPoint& pos, const wxSize& size );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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