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.
...@@ -17,156 +17,164 @@ ...@@ -17,156 +17,164 @@
/* Routines Locales */ /* Routines Locales */
/* Variables locales */ /* Variables locales */
static int s_LastShape = '\\'; 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;
} }
} }
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
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 */
if( erase ) /* effacement apres deplacement curseur */
RedrawOneStruct(panel, DC, BusEntry, g_XorMode); if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur; /* Reaffichage au bon endroit */
RedrawOneStruct(panel, DC, BusEntry, g_XorMode); BusEntry->m_Pos = screen->m_Curseur;
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;
DrawPanel->CursorOff(DC); // Erase schematic cursor BusEntry->m_Flags = IS_NEW;
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
DrawPanel->CursorOn(DC); // Display schematic cursor
GetScreen()->SetModify(); DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
DrawPanel->CursorOn( DC ); // Display schematic cursor
StartMoveBusEntry(BusEntry, DC); GetScreen()->SetModify();
return BusEntry;
StartMoveBusEntry( BusEntry, DC );
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; {
g_ItemToUndoCopy = BusEntry->GenCopy(); delete g_ItemToUndoCopy;
} g_ItemToUndoCopy = BusEntry->GenCopy();
}
BusEntry->m_Flags |= IS_MOVED;
BusEntry->m_Flags |= IS_MOVED;
ItemInitialPosition = BusEntry->m_Pos;
ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff(DC);
GetScreen()->m_Curseur = BusEntry->m_Pos; DrawPanel->CursorOff( DC );
DrawPanel->MouseToCursorSchema(); GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->m_CurrentItem = BusEntry;
DrawPanel->ManageCurseur = ShowWhileMoving; GetScreen()->SetCurItem( BusEntry );
DrawPanel->ForceCloseManageCurseur = ExitBusEntry; DrawPanel->ManageCurseur = ShowWhileMoving;
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") ); {
return; DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
} return;
}
/* Put old item in undo list if it is not currently in edit */
if ( BusEntry->m_Flags == 0 ) SaveCopyInUndoList(BusEntry, IS_CHANGED); /* Put old item in undo list if it is not currently in edit */
if( BusEntry->m_Flags == 0 )
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode); SaveCopyInUndoList( BusEntry, IS_CHANGED );
switch( entry_shape ) RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
{
case '\\' : switch( entry_shape )
s_LastShape = '\\'; {
BusEntry->m_Size.y = 100; case '\\':
break; s_LastShape = '\\';
BusEntry->m_Size.y = 100;
case '/' : break;
s_LastShape = '/';
BusEntry->m_Size.y = -100; case '/':
break; s_LastShape = '/';
} BusEntry->m_Size.y = -100;
break;
TestDanglingEnds(GetScreen()->EEDrawList, NULL); }
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
GetScreen()->SetModify(); TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
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 )
return entry_shape; 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,9 +97,54 @@ class EDA_BaseStruct; ...@@ -95,9 +97,54 @@ 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
* is the examining function within the INSPECTOR which is passed to the * is the examining function within the INSPECTOR which is passed to the
...@@ -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.
}; };
......
...@@ -141,8 +141,8 @@ typedef enum { ...@@ -141,8 +141,8 @@ typedef enum {
} CmdBlockType; } CmdBlockType;
class DrawBlockStruct : public EDA_BaseStruct
, public EDA_Rect class DrawBlockStruct : public EDA_BaseStruct, public EDA_Rect
{ {
public: public:
BlockState m_State; /* Etat (enum BlockState) du block */ BlockState m_State; /* Etat (enum BlockState) du block */
...@@ -192,7 +192,6 @@ public: ...@@ -192,7 +192,6 @@ public:
EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */ EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */
EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */ EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */
int m_UndoRedoCountMax; /* undo/Redo command Max depth */ int m_UndoRedoCountMax; /* undo/Redo command Max depth */
EDA_BaseStruct* m_CurrentItem; /* Current selected object */
/* block control */ /* block control */
DrawBlockStruct BlockLocate; /* Bock description for block commands */ DrawBlockStruct BlockLocate; /* Bock description for block commands */
...@@ -213,9 +212,10 @@ public: ...@@ -213,9 +212,10 @@ public:
private: private:
/* indicateurs divers */ /* indicateurs divers */
char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ 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_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
char m_FlagSave; // indique sauvegarde auto faite char m_FlagSave; // indique sauvegarde auto faite
EDA_BaseStruct* m_CurrentItem; /* Current selected object */
/* Valeurs du pas de grille et du zoom */ /* Valeurs du pas de grille et du zoom */
public: public:
...@@ -246,16 +246,28 @@ public: ...@@ -246,16 +246,28 @@ public:
virtual EDA_BaseStruct* GetItemFromRedoList( void ); virtual EDA_BaseStruct* GetItemFromRedoList( void );
/* Manipulation des flags */ /* Manipulation des flags */
void SetRefreshReq( void ) { m_FlagRefreshReq = 1; } void SetRefreshReq( void ) { m_FlagRefreshReq = 1; }
void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; } void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; }
void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; } void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; }
void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; } void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; }
void SetSave( void ) { m_FlagSave = 1; } void SetSave( void ) { m_FlagSave = 1; }
void ClrSave( void ) { m_FlagSave = 0; } void ClrSave( void ) { m_FlagSave = 0; }
int IsModify( void ) { return m_FlagModified & 1; } int IsModify( void ) { return m_FlagModified & 1; }
int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; } int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; }
int IsSave( void ) { return m_FlagSave & 1; } int IsSave( void ) { return m_FlagSave & 1; }
/**
* Function SetCurItem
* sets the currently selected object, m_CurrentItem.
* This intentionally not inlined so we can set breakpoints on the
* activity easier in base_screen.cpp.
* @param current Any object derived from EDA_BaseStruct
*/
void SetCurItem( EDA_BaseStruct* current );
EDA_BaseStruct* GetCurItem();
/* fonctions relatives au zoom */ /* fonctions relatives au zoom */
int GetZoom( void ); /* retourne le coeff de zoom */ int GetZoom( void ); /* retourne le coeff de zoom */
void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */ void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */
......
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.
...@@ -351,7 +351,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -351,7 +351,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK ) if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE; keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem; EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
keep_on_grid = TRUE; keep_on_grid = TRUE;
......
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