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
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>
================================================================================
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,156 +17,164 @@
/* Routines Locales */
/* Variables locales */
static int s_LastShape = '\\';
static int s_LastShape = '\\';
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 */
{
DrawBusEntryStruct *BusEntry =
(DrawBusEntryStruct *)Panel->GetScreen()->m_CurrentItem;
if( BusEntry) /* trace en cours */
{
RedrawOneStruct(Panel, DC, BusEntry, g_XorMode);
if( BusEntry->m_Flags & IS_NEW )
{
delete BusEntry;
Panel->GetScreen()->m_CurrentItem = NULL;
}
else
{
BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct(Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE);
BusEntry->m_Flags = 0;
}
}
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry ) /* trace en cours */
{
RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW )
{
delete BusEntry;
Panel->GetScreen()->SetCurItem( NULL );
}
else
{
BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct( Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE );
BusEntry->m_Flags = 0;
}
}
g_ItemToRepeat = NULL;
Panel->ManageCurseur = 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
*/
*/
{
BASE_SCREEN * screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct *BusEntry = (DrawBusEntryStruct *) screen->m_CurrentItem;
if( BusEntry == NULL ) return;
/* effacement apres deplacement curseur */
if( erase )
RedrawOneStruct(panel, DC, BusEntry, g_XorMode);
/* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct(panel, DC, BusEntry, g_XorMode);
BASE_SCREEN* screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
if( BusEntry == NULL )
return;
/* effacement apres deplacement curseur */
if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */
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)
*/
*/
{
DrawBusEntryStruct * BusEntry = new DrawBusEntryStruct(GetScreen()->m_Curseur,
s_LastShape , entry_type);
BusEntry->m_Flags = IS_NEW;
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
s_LastShape, entry_type );
DrawPanel->CursorOff(DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
DrawPanel->CursorOn(DC); // Display schematic cursor
BusEntry->m_Flags = IS_NEW;
GetScreen()->SetModify();
DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
DrawPanel->CursorOn( DC ); // Display schematic cursor
StartMoveBusEntry(BusEntry, DC);
return BusEntry;
GetScreen()->SetModify();
StartMoveBusEntry( BusEntry, DC );
return BusEntry;
}
/**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry,
wxDC * DC)
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC* DC )
/**************************************************************************/
{
if ( BusEntry == NULL ) return;
if ( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
}
BusEntry->m_Flags |= IS_MOVED;
ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff(DC);
GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->m_CurrentItem = BusEntry;
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn(DC);
if( BusEntry == NULL )
return;
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
}
BusEntry->m_Flags |= IS_MOVED;
ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetCurItem( BusEntry );
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn( DC );
}
/************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape(wxDC * DC,
DrawBusEntryStruct *BusEntry, int entry_shape)
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry, int entry_shape )
/************************************************************/
/* set the shape of BusEntry (shape = / or \ )
*/
*/
{
if ( BusEntry == NULL ) return;
if ( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE )
{
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);
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
switch( entry_shape )
{
case '\\' :
s_LastShape = '\\';
BusEntry->m_Size.y = 100;
break;
case '/' :
s_LastShape = '/';
BusEntry->m_Size.y = -100;
break;
}
TestDanglingEnds(GetScreen()->EEDrawList, NULL);
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
GetScreen()->SetModify();
if( BusEntry == NULL )
return;
if( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE )
{
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 );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
switch( entry_shape )
{
case '\\':
s_LastShape = '\\';
BusEntry->m_Size.y = 100;
break;
case '/':
s_LastShape = '/';
BusEntry->m_Size.y = -100;
break;
}
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 = '/';
return entry_shape;
if( BusEntry->m_Size.y < 0 )
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
if( hotkey )
{
if( m_CurrentScreen->m_CurrentItem
&& m_CurrentScreen->m_CurrentItem->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem );
if( m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() );
else
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 @@
#ifndef BASE_STRUCT_H
#define BASE_STRUCT_H
#include <vector>
#if defined(DEBUG)
#include <iostream> // needed for Show()
......@@ -95,9 +97,54 @@ class EDA_BaseStruct;
*/
class INSPECTOR
{
private:
/// A place to hold collected objects without taking ownership of their memory.
std::vector<EDA_BaseStruct*> list;
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
* is the examining function within the INSPECTOR which is passed to the
......@@ -112,9 +159,6 @@ public:
*/
SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem,
const void* testData ) = 0;
// derived classes add more functions for collecting and subsequent
// retrieval here.
};
......
......@@ -141,8 +141,8 @@ typedef enum {
} CmdBlockType;
class DrawBlockStruct : public EDA_BaseStruct
, public EDA_Rect
class DrawBlockStruct : public EDA_BaseStruct, public EDA_Rect
{
public:
BlockState m_State; /* Etat (enum BlockState) du block */
......@@ -192,7 +192,6 @@ public:
EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */
EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */
int m_UndoRedoCountMax; /* undo/Redo command Max depth */
EDA_BaseStruct* m_CurrentItem; /* Current selected object */
/* block control */
DrawBlockStruct BlockLocate; /* Bock description for block commands */
......@@ -213,9 +212,10 @@ public:
private:
/* indicateurs divers */
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
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 */
/* Valeurs du pas de grille et du zoom */
public:
......@@ -246,16 +246,28 @@ public:
virtual EDA_BaseStruct* GetItemFromRedoList( void );
/* Manipulation des flags */
void SetRefreshReq( void ) { m_FlagRefreshReq = 1; }
void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; }
void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; }
void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; }
void SetSave( void ) { m_FlagSave = 1; }
void ClrSave( void ) { m_FlagSave = 0; }
int IsModify( void ) { return m_FlagModified & 1; }
int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; }
int IsSave( void ) { return m_FlagSave & 1; }
void SetRefreshReq( void ) { m_FlagRefreshReq = 1; }
void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; }
void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; }
void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; }
void SetSave( void ) { m_FlagSave = 1; }
void ClrSave( void ) { m_FlagSave = 0; }
int IsModify( void ) { return m_FlagModified & 1; }
int IsRefreshReq( void ) { return m_FlagRefreshReq & 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 */
int GetZoom( void ); /* retourne le coeff de zoom */
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 )
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->m_CurrentItem;
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
if( DrawStruct && DrawStruct->m_Flags )
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