Commit 2a603275 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Build default change and minor schematic screen object improvements.

* Change default build to enable wxDC zooming.
* Move sheet label find function into SCH_SCREEN object.
* Move draw screen items function into SCH_SCREEN object.
* Remove redundant page print method from SCH_EDIT_FRAME.
* Add method to hit test for all items in SCH_SCREEN.
* Add method for testing if junction is required in SCH_SCREEN.
* Fix Doxygen waring in help_common_strings.h
parent 20efe4f6
......@@ -22,7 +22,7 @@ option(KICAD_GOST "enable/disable building using GOST notation for multiple gate
#for those who bored with uppercase
option(KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected")
option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is experimental" )
option(USE_WX_ZOOM "Use wxDC to perform zooming (default ON)." ON)
option(USE_WX_GRAPHICS_CONTEXT
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
......
......@@ -667,7 +667,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
if( item )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->GetDrawItems() );
pinsheet = screen->GetSheetLabel( pos );
if( pinsheet && IsBusLabel( pinsheet->m_Text ) )
{
......@@ -715,7 +715,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->GetDrawItems() );
pinsheet = screen->GetSheetLabel( pos );
if( pinsheet && !IsBusLabel( pinsheet->m_Text ) )
{
......
......@@ -14,9 +14,7 @@
#include "gestfich.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "dcsvg.h"
#include "general.h"
#include "libeditframe.h"
#include "sch_sheet_path.h"
......@@ -136,7 +134,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
fn = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), schscreen,
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) schscreen,
m_ModeColorOption->GetSelection() == 0 ? false : true,
aPrint_Sheet_Ref );
msg = _( "Create file " ) + fn.GetFullPath();
......@@ -160,7 +158,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
fn.SetExt( wxT( "svg" ) );
fn.MakeAbsolute();
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), screen,
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) screen,
m_ModeColorOption->GetSelection() == 0 ? false : true,
aPrint_Sheet_Ref );
msg = _( "Create file " ) + fn.GetFullPath();
......@@ -176,11 +174,11 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
}
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame* frame,
const wxString& FullFileName,
BASE_SCREEN* screen,
bool aPrintBlackAndWhite,
bool aPrint_Sheet_Ref )
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame* frame,
const wxString& FullFileName,
SCH_SCREEN* screen,
bool aPrintBlackAndWhite,
bool aPrint_Sheet_Ref )
{
int tmpzoom;
wxPoint tmp_startvisu;
......@@ -216,7 +214,11 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame* frame,
panel->m_ClipBox.SetHeight( 0x7FFFFF0 );
screen->m_IsPrinting = true;
frame->PrintPage( &dc, aPrint_Sheet_Ref, 1, false );
screen->Draw( panel, &dc, GR_COPY );
if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness );
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
......
......@@ -32,7 +32,7 @@ private:
public:
static bool DrawSVGPage( WinEDA_DrawFrame* frame,
const wxString& FullFileName, BASE_SCREEN* screen,
const wxString& FullFileName, SCH_SCREEN* screen,
bool aPrintBlackAndWhite = false,
bool aPrint_Sheet_Ref = false );
};
......
......@@ -343,7 +343,8 @@ void SCH_PRINTOUT::DrawPage()
wxBitmap psuedoBitmap( 1, 1 );
wxMemoryDC memDC;
memDC.SelectObject( psuedoBitmap );
parent->PrintPage( &memDC, true, 0xFFFFFFFF, false );
( (SCH_SCREEN*) ActiveScreen )->Draw( panel, &memDC, GR_DEFAULT_DRAWMODE );
parent->TraceWorkSheet( &memDC, ActiveScreen, g_DrawDefaultLineThickness );
wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
......@@ -371,7 +372,10 @@ void SCH_PRINTOUT::DrawPage()
ActiveScreen->m_IsPrinting = true;
int bg_color = g_DrawBgColor;
parent->PrintPage( dc, printReference, 0xFFFFFFFF, false );
( ( SCH_SCREEN* ) ActiveScreen )->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference )
parent->TraceWorkSheet( dc, ActiveScreen, g_DrawDefaultLineThickness );
g_DrawBgColor = bg_color;
ActiveScreen->m_IsPrinting = false;
......
......@@ -54,7 +54,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC );
RedrawStructList( DrawPanel, DC, GetScreen()->GetDrawItems(), GR_DEFAULT_DRAWMODE );
GetScreen()->Draw( DrawPanel, DC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
......@@ -98,50 +98,3 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
SetTitle( title );
}
}
/**
* PrintPage
* used to print a page.
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not used here)
*/
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMask,
bool aPrintMirrorMode, void* aData)
{
wxBeginBusyCursor();
RedrawStructList( DrawPanel, aDC, (SCH_ITEM*) ActiveScreen->GetDrawItems(), GR_COPY );
if( aPrint_Sheet_Ref )
TraceWorkSheet( aDC, ActiveScreen, g_DrawDefaultLineThickness );
wxEndBusyCursor();
}
/*****************************************************************************
* Routine to redraw list of structs. *
* If the list is of DrawPickStruct types then the picked item are drawn. *
*****************************************************************************/
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* Structlist, int DrawMode, int Color )
{
while( Structlist )
{
if( !(Structlist->m_Flags & IS_MOVED) )
{
// uncomment line below when there is a virtual
// EDA_ITEM::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox()
// ) )
Structlist->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
}
Structlist = Structlist->Next();
}
}
......@@ -5,11 +5,11 @@
/**
* These strings are used in menus and tools, that do the same command
* But they are internatinalized, and therefore must be created
* But they are internationalized, and therefore must be created
* at run time, on the fly.
* So they cannot be static.
*
* Therefore they are defined by #define, used inside menu constructors
* Therefore they are defined by \#define, used inside menu constructors
*/
// Common to schematic editor and component editor
......@@ -57,5 +57,3 @@
#define HELP_ADD_BODYCIRCLE _( "Add circles to the component body" )
#define HELP_ADD_BODYARC _( "Add arcs to the component body" )
#define HELP_ADD_BODYPOLYGON _( "Add lines and polygons to the component body" )
......@@ -322,24 +322,3 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList )
return FALSE;
}
SCH_SHEET_PIN* LocateAnyPinSheet( const wxPoint& RefPos, SCH_ITEM* DrawList )
{
SCH_ITEM* DrawStruct;
SCH_SHEET_PIN* PinSheet = NULL;
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != SCH_SHEET_T )
continue;
SCH_SHEET* sheet = (SCH_SHEET*) DrawStruct;
PinSheet = sheet->GetLabel( RefPos );
if( PinSheet )
break;
}
return PinSheet;
}
......@@ -114,9 +114,7 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen );
* Pointer to the structure if only 1 item is selected.
* NULL if no items are selects.
*/
SCH_ITEM* PickStruct( const wxPoint& refpos, SCH_SCREEN* screen, int SearchMask );
SCH_SHEET_PIN* LocateAnyPinSheet( const wxPoint& RefPos, SCH_ITEM* DrawList );
SCH_ITEM* PickStruct( const wxPoint& refpos, SCH_SCREEN* screen, int SearchMask );
/***************/
......@@ -124,11 +122,7 @@ SCH_SHEET_PIN* LocateAnyPinSheet( const wxPoint& RefPos, SCH_ITEM* DrawList );
/***************/
void DrawDanglingSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pos, int Color );
void RedrawActiveWindow( WinEDA_DrawPanel* panel, wxDC* DC );
void RedrawStructList( WinEDA_DrawPanel* panel,
wxDC* DC,
SCH_ITEM* Structs,
int DrawMode,
int Color = -1 );
/**************/
/* EELAYER.CPP */
......
......@@ -179,17 +179,18 @@ void SCH_SCREEN::AddToDrawList( SCH_ITEM* st )
}
/* Extract the old wires, junctions and buses, an if CreateCopy replace them
* by a copy. Old ones must be put in undo list, and the new ones can be
* modified by clean up safely.
* If an abort command is made, old wires must be put in GetDrawItems(), and
* copies must be deleted. This is because previously stored undo commands
* can handle pointers on wires or bus, and we do not delete wires or bus,
* we must put they in undo list.
*
* Because cleanup delete and/or modify bus and wires, the more easy is to put
* all wires in undo list and use a new copy of wires for cleanup.
*/
int SCH_SCREEN::GetItems( const wxPoint& aPosition, SCH_ITEMS& aItemList ) const
{
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
if( item->HitTest( aPosition ) )
aItemList.push_back( item );
}
return aItemList.size();
}
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{
SCH_ITEM* item, * next_item, * new_item, * List = NULL;
......@@ -335,6 +336,22 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
}
void SCH_SCREEN::Draw( WinEDA_DrawPanel* aCanvas, wxDC* aDC, int aDrawMode, int aColor )
{
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
if( item->IsMoving() )
continue;
// uncomment line below when there is a virtual
// EDA_ITEM::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox()
// ) )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
}
}
/**
* Function ClearUndoORRedoList
* free the undo or redo list from List element
......@@ -408,6 +425,79 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
}
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
{
SCH_SHEET_PIN* sheetLabel = NULL;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
if( item->Type() != SCH_SHEET_T )
continue;
SCH_SHEET* sheet = (SCH_SHEET*) item;
sheetLabel = sheet->GetLabel( aPosition );
if( sheetLabel )
break;
}
return sheetLabel;
}
bool SCH_SCREEN::IsJunctionNeeded( const wxPoint& aPosition ) const
{
SCH_ITEMS items;
int wireEndPoints = 0;
if( GetItems( aPosition, items ) == 0 )
return false;
bool isJunctionNeeded = false;
bool isWireMidpoint = false;
for( size_t i = 0; i < items.size(); i++ )
{
KICAD_T itemType = items[i].Type();
if( itemType == SCH_JUNCTION_T )
{
isJunctionNeeded = false;
break;
}
else if( itemType == SCH_LINE_T )
{
SCH_LINE* line = ( SCH_LINE* ) &items[i];
if( !line->IsConnectable() )
continue;
if( !line->IsEndPoint( aPosition ) )
isWireMidpoint = true;
else
wireEndPoints += 1;
if( ( isWireMidpoint && ( wireEndPoints != 0 ) ) || ( wireEndPoints > 2 ) )
isJunctionNeeded = true;
}
else if( itemType == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = ( SCH_COMPONENT* ) &items[i];
if( !component->IsConnected( aPosition ) )
continue;
if( isWireMidpoint || wireEndPoints > 2 )
isJunctionNeeded = true;
}
}
items.release();
return isJunctionNeeded;
}
int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const
{
SCH_ITEM* item;
......
......@@ -13,6 +13,8 @@
class LIB_PIN;
class SCH_COMPONENT;
class SCH_SHEET_PATH;
class SCH_SHEET_PIN;
/* Max number of sheets in a hierarchy project: */
#define NB_MAX_SHEET 500
......@@ -39,6 +41,11 @@ public:
SCH_SCREEN( KICAD_T aType = SCH_SCREEN_T );
~SCH_SCREEN();
virtual wxString GetClass() const
{
return wxT( "SCH_SCREEN" );
}
/**
* Function GetDrawItems().
*
......@@ -65,35 +72,63 @@ public:
BASE_SCREEN::SetCurItem( (BASE_SCREEN*) aItem );
}
virtual wxString GetClass() const
{
return wxT( "SCH_SCREEN" );
}
/**
* Free all the items from the schematic associated with the screen.
*
* This does not delete any sub hierarchies.
*/
void FreeDrawList();
void FreeDrawList();
/**
* Function GetItems
* adds all items found at \a aPosition to \a aItemList. Please note that \a aItemList
* will own the item pointers added to it. Do not allow it to go out of scope without
* first calling the release() method. Otherwise, the pointer will be deleted and
* EESchema will crash.
* @param aPosition The position to test.
* @param aItemList The list to place items into.
* @return The number of items found at \a aPosition.
*/
int GetItems( const wxPoint& aPosition, SCH_ITEMS& aItemList ) const;
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
/**
* Function Draw
* draws all the items in the screen to \a aCanvas.
* @param aCanvas The canvas item to draw on.
* @param aDC The device context to draw on.
* @param aDrawMode The drawing mode.
* @param aColor The drawing color.
*/
void Draw( WinEDA_DrawPanel* aCanvas, wxDC* aDC, int aDrawMode, int aColor = -1 );
/**
* Remove \a aItem from the schematic associated with this screen.
*
* @param aItem - Item to be removed from schematic.
*/
void RemoveFromDrawList( SCH_ITEM* aItem );
void RemoveFromDrawList( SCH_ITEM* aItem );
bool CheckIfOnDrawList( SCH_ITEM* st );
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st );
bool SchematicCleanUp( wxDC* DC = NULL );
bool SchematicCleanUp( wxDC* DC = NULL );
SCH_ITEM* ExtractWires( bool CreateCopy );
/**
* Function ExtractWires
* extracts the old wires, junctions and buses. If \a aCreateCopy is true, replace
* them with a copy. Old item must be put in undo list, and the new ones can be
* modified by clean up safely. If an abort command is made, old wires must be put
* in GetDrawItems(), and copies must be deleted. This is because previously stored
* undo commands can handle pointers on wires or busses, and we do not delete wires or
* busses, we must put they in undo list.
*
* Because cleanup delete and/or modify bus and wires, the it is easier is to put
* all wires in undo list and use a new copy of wires for cleanup.
*/
SCH_ITEM* ExtractWires( bool aCreateCopy );
/* full undo redo management : */
// use BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aItem )
......@@ -128,6 +163,24 @@ public:
int CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const;
/**
* Function IsJunctionNeeded
* tests if a junction is required for the items at \a aPosition on the screen.
* <p>
* A junction is required at \a aPosition if the following criteria are satisfied:
* <ul>
* <li>one wire midpoint, one or more wire endpoints and no junction.</li>
* <li>three or more wire endpoints and no junction.</li>
* <li>two wire midpoints and no junction</li>
* <li>one wire midpoint, a component pin, and no junction.</li>
* <li>three wire endpoints, a component pin, and no junction.</li>
* </ul>
* </p>
* @param aPosition The position to test.
* @return True if a junction is required at \a aPosition.
*/
bool IsJunctionNeeded( const wxPoint& aPosition ) const;
/**
* Function GetPin
* test the screen for a component pin item at \a aPosition.
......@@ -140,17 +193,25 @@ public:
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
bool aEndPointOnly = false );
/**
* Function GetSheetLabel
* test the screen if \a aPosition is a sheet label object.
* @param aPosition The position to test.
* @return The sheet label object if found otherwise NULL.
*/
SCH_SHEET_PIN* GetSheetLabel( const wxPoint& aPosition );
/**
* Function ClearAnnotation
* clears the annotation for the components in \a aSheetPath on the screen.
* @param aSheetPath The sheet path of the component annotation to clear. If NULL then
* the entire heirarchy is cleared.
* the entire hierarchy is cleared.
*/
void ClearAnnotation( SCH_SHEET_PATH* aSheetPath );
/**
* Function GetHierarchicalItems
* adds all schematica sheet and component object in the screen to \a aItems.
* adds all schematic sheet and component object in the screen to \a aItems.
* @param aItems Hierarchical item list.
*/
void GetHierarchicalItems( std::vector <SCH_ITEM*> aItems );
......@@ -158,7 +219,7 @@ public:
/**
* Function SelectBlockItems
* creates a list of items found when a block command is initiated. The items selected
* depend on the block commad. If the drag block command is issued, than any items
* depend on the block command. If the drag block command is issued, than any items
* connected to items in the block are also selected.
*/
void SelectBlockItems();
......@@ -212,8 +273,8 @@ public:
/**
* Function ReplaceDuplicateTimeStamps
* test all sheet and component objects in the schematic for duplicate time stamps
* an replaces them as neccessary. Time stamps must be unique in order for complex
* hierarcies know which components go to which sheets.
* an replaces them as necessary. Time stamps must be unique in order for complex
* hierarchies know which components go to which sheets.
* @return The number of duplicate time stamps replaced.
*/
int ReplaceDuplicateTimeStamps();
......
......@@ -17,6 +17,9 @@ class SCH_EDIT_FRAME;
class wxFindReplaceData;
typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS;
// Schematic item filter mask for hit test objects in schematic editor.
enum SCH_FILTER_T {
COMPONENT_T = 0x0001,
......
......@@ -332,20 +332,6 @@ public:
*/
void SetSheetNumberAndCount();
/**
* Function PrintPage
* is used to print a schematic page.
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
int aPrintMask, bool aPrintMirrorMode,
void* aData = NULL );
/**
* Show the print dialog
*/
......
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