7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 11:50:10 +00:00

Use consistent PageLayout data structure names.

This commit is contained in:
Jeff Young 2019-05-25 12:05:39 +01:00
parent 0e5cc54ec9
commit bdd44ce88c
49 changed files with 657 additions and 696 deletions

View File

@ -36,7 +36,7 @@ set( GAL_SRCS
newstroke_font.cpp
painter.cpp
text_utils.cpp
page_layout/worksheet_viewitem.cpp
page_layout/ws_view_item.cpp
gal/color4d.cpp
gal/gal_display_options.cpp
gal/graphics_abstraction_layer.cpp
@ -236,8 +236,8 @@ set( COMMON_WIDGET_SRCS
)
set( COMMON_PAGE_LAYOUT_SRCS
page_layout/worksheet_dataitem.cpp
page_layout/worksheet_layout.cpp
page_layout/ws_data_item.cpp
page_layout/ws_data_model.cpp
page_layout/page_layout_default_description.cpp
page_layout/ws_draw_item.cpp
page_layout/page_layout_reader_keywords.cpp
@ -358,7 +358,7 @@ set( COMMON_SRCS
utf8.cpp
validators.cpp
wildcards_and_files_ext.cpp
page_layout/worksheet_painter.cpp
page_layout/ws_painter.cpp
wxdataviewctrl_helpers.cpp
xnode.cpp
)

View File

@ -21,10 +21,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_page_settings.cpp
*/
#include <fctsys.h>
#include <macros.h> // arrayDim()
#include <common.h>
@ -35,7 +31,7 @@
#include <class_drawpanel.h>
#include <title_block.h>
#include <draw_frame.h>
#include <ws_draw_item.h>
#include <ws_data_model.h>
#include <base_screen.h>
#include <wildcards_and_files_ext.h>
@ -47,7 +43,7 @@
#include <general.h>
#endif
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <dialog_page_settings.h>
#define MAX_PAGE_EXAMPLE_SIZE 200
@ -433,7 +429,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName )
{
wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName, m_projectPath );
wxString fullFileName = WS_DATA_MODEL::MakeFullFileName( fileName, m_projectPath );
if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
{
@ -445,7 +441,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
}
BASE_SCREEN::m_PageLayoutDescrFileName = fileName;
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
pglayout.SetPageLayout( fullFileName );
m_localPrjConfigChanged = true;
}
@ -660,7 +656,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
wxString emptyString;
GRResetPenAndBrush( &memDC );
WORKSHEET_LAYOUT::SetAltInstance( m_pagelayout );
WS_DATA_MODEL::SetAltInstance( m_pagelayout );
GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE );
DrawPageLayout( &memDC, NULL, pageDUMMY,
emptyString, emptyString,
@ -669,7 +665,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
memDC.SelectObject( wxNullBitmap );
m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap );
WORKSHEET_LAYOUT::SetAltInstance( NULL );
WS_DATA_MODEL::SetAltInstance( NULL );
// Refresh the dialog.
Layout();
@ -784,7 +780,7 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
// Try to remove the path, if the path is the current working dir,
// or the dir of kicad.pro (template), and use a relative path
wxString shortFileName = WORKSHEET_LAYOUT::MakeShortFileName( fileName, m_projectPath );
wxString shortFileName = WS_DATA_MODEL::MakeShortFileName( fileName, m_projectPath );
// For Win/Linux/macOS compatibility, a relative path is a good idea
if( shortFileName != GetWksFileName() && shortFileName != fileName )
@ -803,7 +799,7 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
SetWksFileName( shortFileName );
if( m_pagelayout == NULL )
m_pagelayout = new WORKSHEET_LAYOUT;
m_pagelayout = new WS_DATA_MODEL;
m_pagelayout->SetPageLayout( fileName );

View File

@ -27,6 +27,8 @@
#include <widgets/unit_binder.h>
#include <dialog_page_settings_base.h>
class WS_DATA_MODEL;
/*!
* DIALOG_PAGES_SETTINGS class declaration
*/
@ -46,7 +48,7 @@ private:
PAGE_INFO m_pageInfo; /// Temporary page info.
bool m_customFmt; /// true if the page selection is custom
TITLE_BLOCK m_tb; /// Temporary title block (basic inscriptions).
WORKSHEET_LAYOUT *m_pagelayout; // the alternate and temporary page layout shown by the dialog
WS_DATA_MODEL* m_pagelayout; // the alternate and temporary page layout shown by the dialog
// when the initial one is replaced by a new one
UNIT_BINDER m_customSizeX;
UNIT_BINDER m_customSizeY;

View File

@ -115,7 +115,7 @@
*
*/
#include <worksheet_painter.h>
#include <ws_painter.h>
// height of the band reference grid 2.0 mm
// worksheet frame reference text size 1.3 mm

View File

@ -31,9 +31,9 @@
#include <fctsys.h>
#include <base_struct.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <ws_data_model.h>
#include <page_layout_reader_lexer.h>
#include <wx/file.h>
@ -45,13 +45,13 @@ using namespace TB_READER_T;
/**
* Class PAGE_LAYOUT_READER_PARSER
* holds data and functions pertinent to parsing a S-expression file
* for a WORKSHEET_LAYOUT.
* for a WS_DATA_MODEL.
*/
class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER
{
public:
PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource );
void Parse( WORKSHEET_LAYOUT* aLayout );
void Parse( WS_DATA_MODEL* aLayout );
private:
@ -71,38 +71,38 @@ private:
*/
double parseDouble();
void parseSetup( WORKSHEET_LAYOUT* aLayout );
void parseSetup( WS_DATA_MODEL* aLayout );
/**
* parse a graphic item starting by "(line" or "(rect" and read parameters.
*/
void parseGraphic( WORKSHEET_DATAITEM * aItem );
void parseGraphic( WS_DATA_ITEM * aItem );
/**
* parse a text item starting by "(tbtext" and read parameters.
*/
void parseText( WORKSHEET_DATAITEM_TEXT * aItem );
void parseText( WS_DATA_ITEM_TEXT * aItem );
/**
* parse a polygon item starting by "( polygon" and read parameters.
* the list of corners included in this description is read by parsePolyOutline
*/
void parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem );
void parsePolygon( WS_DATA_ITEM_POLYGONS * aItem );
/**
* parse a list of corners starting by "( pts" and read coordinates.
*/
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem );
void parsePolyOutline( WS_DATA_ITEM_POLYGONS * aItem );
/**
* parse a bitmap item starting by "( bitmap" and read parameters.
*/
void parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem );
void parseBitmap( WS_DATA_ITEM_BITMAP * aItem );
void parseCoordinate( POINT_COORD& aCoord);
void readOption( WORKSHEET_DATAITEM * aItem );
void readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem );
void readOption( WS_DATA_ITEM * aItem );
void readPngdata( WS_DATA_ITEM_BITMAP * aItem );
};
// PCB_PLOT_PARAMS_PARSER
@ -113,9 +113,9 @@ PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const w
}
void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
void PAGE_LAYOUT_READER_PARSER::Parse( WS_DATA_MODEL* aLayout )
{
WORKSHEET_DATAITEM* item;
WS_DATA_ITEM* item;
LOCALE_IO toggle;
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
@ -133,33 +133,33 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
break;
case T_line:
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT );
item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_SEGMENT );
parseGraphic( item );
aLayout->Append( item );
break;
case T_rect:
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT );
item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_RECT );
parseGraphic( item );
aLayout->Append( item );
break;
case T_polygon:
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
parsePolygon( (WORKSHEET_DATAITEM_POLYPOLYGON*) item );
item = new WS_DATA_ITEM_POLYGONS();
parsePolygon( (WS_DATA_ITEM_POLYGONS*) item );
aLayout->Append( item );
break;
case T_bitmap:
item = new WORKSHEET_DATAITEM_BITMAP( NULL );
parseBitmap( (WORKSHEET_DATAITEM_BITMAP*) item );
item = new WS_DATA_ITEM_BITMAP( NULL );
parseBitmap( (WS_DATA_ITEM_BITMAP*) item );
aLayout->Append( item );
break;
case T_tbtext:
NeedSYMBOLorNUMBER();
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
parseText( (WORKSHEET_DATAITEM_TEXT*) item );
item = new WS_DATA_ITEM_TEXT( FromUTF8() );
parseText( (WS_DATA_ITEM_TEXT*) item );
aLayout->Append( item );
break;
@ -170,7 +170,7 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
}
}
void PAGE_LAYOUT_READER_PARSER::parseSetup( WORKSHEET_LAYOUT* aLayout )
void PAGE_LAYOUT_READER_PARSER::parseSetup( WS_DATA_MODEL* aLayout )
{
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
@ -180,18 +180,18 @@ void PAGE_LAYOUT_READER_PARSER::parseSetup( WORKSHEET_LAYOUT* aLayout )
break;
case T_linewidth:
WORKSHEET_DATAITEM::m_DefaultLineWidth = parseDouble();
WS_DATA_ITEM::m_DefaultLineWidth = parseDouble();
NeedRIGHT();
break;
case T_textsize:
WORKSHEET_DATAITEM::m_DefaultTextSize.x = parseDouble();
WORKSHEET_DATAITEM::m_DefaultTextSize.y = parseDouble();
WS_DATA_ITEM::m_DefaultTextSize.x = parseDouble();
WS_DATA_ITEM::m_DefaultTextSize.y = parseDouble();
NeedRIGHT();
break;
case T_textlinewidth:
WORKSHEET_DATAITEM::m_DefaultTextThickness = parseDouble();
WS_DATA_ITEM::m_DefaultTextThickness = parseDouble();
NeedRIGHT();
break;
@ -222,7 +222,7 @@ void PAGE_LAYOUT_READER_PARSER::parseSetup( WORKSHEET_LAYOUT* aLayout )
}
}
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WS_DATA_ITEM_POLYGONS * aItem )
{
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
@ -290,7 +290,7 @@ void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * a
aItem->SetBoundingBox();
}
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WS_DATA_ITEM_POLYGONS * aItem )
{
DPOINT corner;
@ -316,7 +316,7 @@ void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON
}
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WS_DATA_ITEM_BITMAP * aItem )
{
BITMAP_BASE* image = new BITMAP_BASE;
aItem->m_ImageBitmap = image;
@ -378,7 +378,7 @@ void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
}
}
void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
void PAGE_LAYOUT_READER_PARSER::readPngdata( WS_DATA_ITEM_BITMAP * aItem )
{
std::string tmp;
@ -412,7 +412,7 @@ void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
}
void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
void PAGE_LAYOUT_READER_PARSER::readOption( WS_DATA_ITEM * aItem )
{
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
@ -426,7 +426,7 @@ void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
}
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WS_DATA_ITEM * aItem )
{
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
@ -496,7 +496,7 @@ void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
}
void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
void PAGE_LAYOUT_READER_PARSER::parseText( WS_DATA_ITEM_TEXT* aItem )
{
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
@ -688,13 +688,13 @@ double PAGE_LAYOUT_READER_PARSER::parseDouble()
// see page_layout_default_shape.cpp
extern const char defaultPageLayout[];
void WORKSHEET_LAYOUT::SetDefaultLayout()
void WS_DATA_MODEL::SetDefaultLayout()
{
SetPageLayout( defaultPageLayout, false, wxT( "default page" ) );
}
// Returns defaultPageLayout as a string;
wxString WORKSHEET_LAYOUT::DefaultLayout()
wxString WS_DATA_MODEL::DefaultLayout()
{
return wxString( defaultPageLayout );
}
@ -705,19 +705,19 @@ wxString WORKSHEET_LAYOUT::DefaultLayout()
// see page_layout_empty_description.cpp
extern const char emptyPageLayout[];
void WORKSHEET_LAYOUT::SetEmptyLayout()
void WS_DATA_MODEL::SetEmptyLayout()
{
SetPageLayout( emptyPageLayout, false, wxT( "empty page" ) );
}
wxString WORKSHEET_LAYOUT::EmptyLayout()
wxString WS_DATA_MODEL::EmptyLayout()
{
return wxString( emptyPageLayout );
}
void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append, const wxString& aSource )
void WS_DATA_MODEL::SetPageLayout( const char* aPageLayout, bool Append, const wxString& aSource )
{
if( ! Append )
ClearList();
@ -735,7 +735,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append, cons
}
void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append )
void WS_DATA_MODEL::SetPageLayout( const wxString& aFullFileName, bool Append )
{
wxString fullFileName = aFullFileName;

View File

@ -25,54 +25,54 @@
/*
* the class WORKSHEET_DATAITEM (and derived) defines
* the class WS_DATA_ITEM (and derived) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* the WS_DATA_ITEM coordinates units is the mm, and are relative to
* one of 4 page corners.
*
* These items cannot be drawn or plot "as this". they should be converted
* to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
* The list of these items is stored in a WS_DATA_MODEL instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
* coordinates are converted to draw/plot coordinates.
* texts are expanded if they contain format symbols.
* Items with m_RepeatCount > 1 are created m_RepeatCount times
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DATA_MODEL is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* the WS_DATA_MODEL instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <draw_graphic_text.h>
#include <eda_rect.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <title_block.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <ws_data_item.h>
#include <view/view.h>
using KIGFX::COLOR4D;
// Static members of class WORKSHEET_DATAITEM:
double WORKSHEET_DATAITEM::m_WSunits2Iu = 1000.0;
DPOINT WORKSHEET_DATAITEM::m_RB_Corner;
DPOINT WORKSHEET_DATAITEM::m_LT_Corner;
double WORKSHEET_DATAITEM::m_DefaultLineWidth = 0.0;
DSIZE WORKSHEET_DATAITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
double WORKSHEET_DATAITEM::m_DefaultTextThickness = 0.0;
bool WORKSHEET_DATAITEM::m_SpecialMode = false;
// Static members of class WS_DATA_ITEM:
double WS_DATA_ITEM::m_WSunits2Iu = 1000.0;
DPOINT WS_DATA_ITEM::m_RB_Corner;
DPOINT WS_DATA_ITEM::m_LT_Corner;
double WS_DATA_ITEM::m_DefaultLineWidth = 0.0;
DSIZE WS_DATA_ITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
double WS_DATA_ITEM::m_DefaultTextThickness = 0.0;
bool WS_DATA_ITEM::m_SpecialMode = false;
// The constructor:
WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ITEM_TYPE aType )
WS_DATA_ITEM::WS_DATA_ITEM( WS_ITEM_TYPE aType )
{
m_pageOption = ALL_PAGES;
m_type = aType;
@ -82,7 +82,7 @@ WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ITEM_TYPE aType )
}
void WORKSHEET_DATAITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
int pensize = GetPenSizeUi();
@ -136,7 +136,7 @@ void WORKSHEET_DATAITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VI
// (if both coordinates have the same corner reference)
// MoveToUi and MoveTo takes the graphic position (i.e relative to the left top
// paper corner
void WORKSHEET_DATAITEM::MoveToUi( wxPoint aPosition )
void WS_DATA_ITEM::MoveToUi( wxPoint aPosition )
{
DPOINT pos_mm;
pos_mm.x = aPosition.x / m_WSunits2Iu;
@ -146,7 +146,7 @@ void WORKSHEET_DATAITEM::MoveToUi( wxPoint aPosition )
}
void WORKSHEET_DATAITEM::MoveTo( DPOINT aPosition )
void WS_DATA_ITEM::MoveTo( DPOINT aPosition )
{
DPOINT vector = aPosition - GetStartPos();
DPOINT endpos = vector + GetEndPos();
@ -169,7 +169,7 @@ void WORKSHEET_DATAITEM::MoveTo( DPOINT aPosition )
/* move the starting point of the item to a new position
* aPosition = the new position of the starting point, in mm
*/
void WORKSHEET_DATAITEM::MoveStartPointTo( DPOINT aPosition )
void WS_DATA_ITEM::MoveStartPointTo( DPOINT aPosition )
{
DPOINT position;
@ -204,7 +204,7 @@ void WORKSHEET_DATAITEM::MoveStartPointTo( DPOINT aPosition )
/* move the starting point of the item to a new position
* aPosition = the new position of the starting point in graphic units
*/
void WORKSHEET_DATAITEM::MoveStartPointToUi( wxPoint aPosition )
void WS_DATA_ITEM::MoveStartPointToUi( wxPoint aPosition )
{
DPOINT pos_mm;
pos_mm.x = aPosition.x / m_WSunits2Iu;
@ -220,7 +220,7 @@ void WORKSHEET_DATAITEM::MoveStartPointToUi( wxPoint aPosition )
* (segments and rectangles)
* aPosition = the new position of the ending point, in mm
*/
void WORKSHEET_DATAITEM::MoveEndPointTo( DPOINT aPosition )
void WS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
{
DPOINT position;
@ -267,7 +267,7 @@ void WORKSHEET_DATAITEM::MoveEndPointTo( DPOINT aPosition )
* (segments and rectangles)
* aPosition = the new position of the ending point in graphic units
*/
void WORKSHEET_DATAITEM::MoveEndPointToUi( wxPoint aPosition )
void WS_DATA_ITEM::MoveEndPointToUi( wxPoint aPosition )
{
DPOINT pos_mm;
pos_mm.x = aPosition.x / m_WSunits2Iu;
@ -277,7 +277,7 @@ void WORKSHEET_DATAITEM::MoveEndPointToUi( wxPoint aPosition )
}
const DPOINT WORKSHEET_DATAITEM::GetStartPos( int ii ) const
const DPOINT WS_DATA_ITEM::GetStartPos( int ii ) const
{
DPOINT pos;
pos.x = m_Pos.m_Pos.x + ( m_IncrementVector.x * ii );
@ -308,7 +308,7 @@ const DPOINT WORKSHEET_DATAITEM::GetStartPos( int ii ) const
}
const wxPoint WORKSHEET_DATAITEM::GetStartPosUi( int ii ) const
const wxPoint WS_DATA_ITEM::GetStartPosUi( int ii ) const
{
DPOINT pos = GetStartPos( ii );
pos = pos * m_WSunits2Iu;
@ -316,7 +316,7 @@ const wxPoint WORKSHEET_DATAITEM::GetStartPosUi( int ii ) const
}
const DPOINT WORKSHEET_DATAITEM::GetEndPos( int ii ) const
const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
{
DPOINT pos;
pos.x = m_End.m_Pos.x + ( m_IncrementVector.x * ii );
@ -347,7 +347,7 @@ const DPOINT WORKSHEET_DATAITEM::GetEndPos( int ii ) const
}
const wxPoint WORKSHEET_DATAITEM::GetEndPosUi( int ii ) const
const wxPoint WS_DATA_ITEM::GetEndPosUi( int ii ) const
{
DPOINT pos = GetEndPos( ii );
pos = pos * m_WSunits2Iu;
@ -355,7 +355,7 @@ const wxPoint WORKSHEET_DATAITEM::GetEndPosUi( int ii ) const
}
bool WORKSHEET_DATAITEM::IsInsidePage( int ii ) const
bool WS_DATA_ITEM::IsInsidePage( int ii ) const
{
DPOINT pos = GetStartPos( ii );
@ -374,31 +374,31 @@ bool WORKSHEET_DATAITEM::IsInsidePage( int ii ) const
}
const wxString WORKSHEET_DATAITEM::GetClassName() const
const wxString WS_DATA_ITEM::GetClassName() const
{
wxString name;
switch( GetType() )
{
case WS_TEXT: name = wxT( "Text" ); break;
case WS_SEGMENT: name = wxT( "Line" ); break;
case WS_RECT: name = wxT( "Rectangle" ); break;
case WS_TEXT: name = wxT( "Text" ); break;
case WS_SEGMENT: name = wxT( "Line" ); break;
case WS_RECT: name = wxT( "Rectangle" ); break;
case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
case WS_BITMAP: name = wxT( "Image" ); break;
case WS_BITMAP: name = wxT( "Image" ); break;
}
return name;
}
WORKSHEET_DATAITEM_POLYPOLYGON::WORKSHEET_DATAITEM_POLYPOLYGON() :
WORKSHEET_DATAITEM( WS_POLYPOLYGON )
WS_DATA_ITEM_POLYGONS::WS_DATA_ITEM_POLYGONS() :
WS_DATA_ITEM( WS_POLYPOLYGON )
{
m_Orient = 0.0;
}
void WORKSHEET_DATAITEM_POLYPOLYGON::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector,
void WS_DATA_ITEM_POLYGONS::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector,
KIGFX::VIEW* aView )
{
std::map<int, STATUS_FLAGS> itemFlags;
@ -445,13 +445,12 @@ void WORKSHEET_DATAITEM_POLYPOLYGON::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollecto
while( ist <= iend )
poly->m_Corners.push_back( GetCornerPositionUi( ist++, jj ) );
}
}
}
const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx, int aRepeat ) const
const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepeat ) const
{
DPOINT pos = m_Corners[aIdx];
@ -462,7 +461,7 @@ const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx, i
}
void WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox()
void WS_DATA_ITEM_POLYGONS::SetBoundingBox()
{
if( m_Corners.size() == 0 )
{
@ -496,7 +495,7 @@ void WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox()
}
bool WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage( int ii ) const
bool WS_DATA_ITEM_POLYGONS::IsInsidePage( int ii ) const
{
DPOINT pos = GetStartPos( ii );
pos += m_minCoord; // left top pos of bounding box
@ -514,8 +513,7 @@ bool WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage( int ii ) const
}
const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx,
int aRepeat ) const
const wxPoint WS_DATA_ITEM_POLYGONS::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const
{
DPOINT pos = GetCornerPosition( aIdx, aRepeat );
pos = pos * m_WSunits2Iu;
@ -523,8 +521,8 @@ const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx
}
WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) :
WORKSHEET_DATAITEM( WS_TEXT )
WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
WS_DATA_ITEM( WS_TEXT )
{
m_TextBase = aTextBase;
m_IncrementLabel = 1;
@ -537,7 +535,7 @@ WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) :
}
void WORKSHEET_DATAITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
int pensize = GetPenSizeUi();
bool multilines = false;
@ -556,8 +554,8 @@ void WORKSHEET_DATAITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGF
SetConstrainedTextSize();
wxSize textsize;
textsize.x = KiROUND( m_ConstrainedTextSize.x * WORKSHEET_DATAITEM::m_WSunits2Iu );
textsize.y = KiROUND( m_ConstrainedTextSize.y * WORKSHEET_DATAITEM::m_WSunits2Iu );
textsize.x = KiROUND( m_ConstrainedTextSize.x * WS_DATA_ITEM::m_WSunits2Iu );
textsize.y = KiROUND( m_ConstrainedTextSize.y * WS_DATA_ITEM::m_WSunits2Iu );
if( m_Bold )
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
@ -609,7 +607,7 @@ void WORKSHEET_DATAITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGF
}
void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr )
void WS_DATA_ITEM_TEXT::IncrementLabel( int aIncr )
{
int last = m_TextBase.Len() -1;
@ -628,7 +626,7 @@ void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr )
// Replace the '\''n' sequence by EOL
// and the sequence '\''\' by only one '\' in m_FullText
// if m_FullText is a multiline text (i.e.contains '\n') return true
bool WORKSHEET_DATAITEM_TEXT::ReplaceAntiSlashSequence()
bool WS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence()
{
bool multiline = false;
@ -663,7 +661,7 @@ bool WORKSHEET_DATAITEM_TEXT::ReplaceAntiSlashSequence()
}
void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
{
m_ConstrainedTextSize = m_TextSize;
@ -705,7 +703,7 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
}
void WORKSHEET_DATAITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
std::map<int, STATUS_FLAGS> itemFlags;
WS_DRAW_ITEM_BASE* item = nullptr;
@ -749,7 +747,7 @@ void WORKSHEET_DATAITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KI
* and the PPI bitmap factor
* the pixel scale factor should be initialized before drawing the bitmap
*/
void WORKSHEET_DATAITEM_BITMAP::SetPixelScaleFactor()
void WS_DATA_ITEM_BITMAP::SetPixelScaleFactor()
{
if( m_ImageBitmap )
{
@ -764,7 +762,7 @@ void WORKSHEET_DATAITEM_BITMAP::SetPixelScaleFactor()
/* return the PPI of the bitmap
*/
int WORKSHEET_DATAITEM_BITMAP::GetPPI() const
int WS_DATA_ITEM_BITMAP::GetPPI() const
{
if( m_ImageBitmap )
return m_ImageBitmap->GetPPI() / m_ImageBitmap->GetScale();
@ -775,7 +773,7 @@ int WORKSHEET_DATAITEM_BITMAP::GetPPI() const
/*adjust the PPI of the bitmap
*/
void WORKSHEET_DATAITEM_BITMAP::SetPPI( int aBitmapPPI )
void WS_DATA_ITEM_BITMAP::SetPPI( int aBitmapPPI )
{
if( m_ImageBitmap )
m_ImageBitmap->SetScale( (double) m_ImageBitmap->GetPPI() / aBitmapPPI );

View File

@ -1,13 +1,8 @@
/**
* @file worksheet_layout.cpp
* @brief description of graphic items and texts to build a title block
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
@ -30,40 +25,40 @@
/*
* the class WORKSHEET_DATAITEM (and derived ) defines
* the class WS_DATA_ITEM (and derived ) defines
* a basic shape of a page layout ( frame references and title block )
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
* The list of these items is stored in a WS_DATA_MODEL instance.
*
*
* These items cannot be drawn or plot "as this". they should be converted
* to a "draw list". When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
* coordinates are converted to draw/plot coordinates.
* texts are expanded if they contain format symbols.
* Items with m_RepeatCount > 1 are created m_RepeatCount times
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DATA_MODEL is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* the WS_DATA_MODEL instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <kiface_i.h>
#include <draw_graphic_text.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <title_block.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <ws_data_model.h>
// The layout shape used in the application
// It is accessible by WORKSHEET_LAYOUT::GetTheInstance()
static WORKSHEET_LAYOUT wksTheInstance;
static WORKSHEET_LAYOUT* wksAltInstance;
// It is accessible by WS_DATA_MODEL::GetTheInstance()
static WS_DATA_MODEL wksTheInstance;
static WS_DATA_MODEL* wksAltInstance;
WORKSHEET_LAYOUT::WORKSHEET_LAYOUT()
WS_DATA_MODEL::WS_DATA_MODEL()
{
m_allowVoidList = false;
m_leftMargin = 10.0; // the left page margin in mm
@ -72,10 +67,10 @@ WORKSHEET_LAYOUT::WORKSHEET_LAYOUT()
m_bottomMargin = 10.0; // the bottom page margin in mm
}
/* static function: returns the instance of WORKSHEET_LAYOUT
/* static function: returns the instance of WS_DATA_MODEL
* used in the application
*/
WORKSHEET_LAYOUT& WORKSHEET_LAYOUT::GetTheInstance()
WS_DATA_MODEL& WS_DATA_MODEL::GetTheInstance()
{
if( wksAltInstance )
return *wksAltInstance;
@ -84,64 +79,64 @@ WORKSHEET_LAYOUT& WORKSHEET_LAYOUT::GetTheInstance()
}
/**
* static function: Set an alternate instance of WORKSHEET_LAYOUT
* static function: Set an alternate instance of WS_DATA_MODEL
* mainly used in page setting dialog
* @param aLayout = the alternate page layout.
* if null, restore the basic page layout
*/
void WORKSHEET_LAYOUT::SetAltInstance( WORKSHEET_LAYOUT* aLayout )
void WS_DATA_MODEL::SetAltInstance( WS_DATA_MODEL* aLayout )
{
wksAltInstance = aLayout;
}
void WORKSHEET_LAYOUT::SetLeftMargin( double aMargin )
void WS_DATA_MODEL::SetLeftMargin( double aMargin )
{
m_leftMargin = aMargin; // the left page margin in mm
}
void WORKSHEET_LAYOUT::SetRightMargin( double aMargin )
void WS_DATA_MODEL::SetRightMargin( double aMargin )
{
m_rightMargin = aMargin; // the right page margin in mm
}
void WORKSHEET_LAYOUT::SetTopMargin( double aMargin )
void WS_DATA_MODEL::SetTopMargin( double aMargin )
{
m_topMargin = aMargin; // the top page margin in mm
}
void WORKSHEET_LAYOUT::SetBottomMargin( double aMargin )
void WS_DATA_MODEL::SetBottomMargin( double aMargin )
{
m_bottomMargin = aMargin; // the bottom page margin in mm
}
void WORKSHEET_LAYOUT::ClearList()
void WS_DATA_MODEL::ClearList()
{
for( WORKSHEET_DATAITEM* item : m_list )
for( WS_DATA_ITEM* item : m_list )
delete item;
m_list.clear();
}
void WORKSHEET_LAYOUT::Append( WORKSHEET_DATAITEM* aItem )
void WS_DATA_MODEL::Append( WS_DATA_ITEM* aItem )
{
m_list.push_back( aItem );
}
void WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
void WS_DATA_MODEL::Remove( WS_DATA_ITEM* aItem )
{
auto newEnd = std::remove( m_list.begin(), m_list.end(), aItem );
m_list.erase( newEnd, m_list.end() );
}
int WORKSHEET_LAYOUT::GetItemIndex( WORKSHEET_DATAITEM* aItem ) const
int WS_DATA_MODEL::GetItemIndex( WS_DATA_ITEM* aItem ) const
{
unsigned idx = 0;
while( idx < m_list.size() )
@ -157,7 +152,7 @@ int WORKSHEET_LAYOUT::GetItemIndex( WORKSHEET_DATAITEM* aItem ) const
/* return the item from its index aIdx, or NULL if does not exist
*/
WORKSHEET_DATAITEM* WORKSHEET_LAYOUT::GetItem( unsigned aIdx ) const
WS_DATA_ITEM* WS_DATA_MODEL::GetItem( unsigned aIdx ) const
{
if( aIdx < m_list.size() )
return m_list[aIdx];
@ -166,8 +161,8 @@ WORKSHEET_DATAITEM* WORKSHEET_LAYOUT::GetItem( unsigned aIdx ) const
}
const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileName,
const wxString& aProjectPath )
const wxString WS_DATA_MODEL::MakeShortFileName( const wxString& aFullFileName,
const wxString& aProjectPath )
{
wxString shortFileName = aFullFileName;
wxFileName fn = aFullFileName;
@ -195,8 +190,8 @@ const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileNam
}
const wxString WORKSHEET_LAYOUT::MakeFullFileName( const wxString& aShortFileName,
const wxString& aProjectPath )
const wxString WS_DATA_MODEL::MakeFullFileName( const wxString& aShortFileName,
const wxString& aProjectPath )
{
wxString fullFileName = ExpandEnvVarSubstitutions( aShortFileName );

View File

@ -24,27 +24,27 @@
*/
/*
* the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
* the class WS_DATA_ITEM (and WS_DATA_ITEM_TEXT) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* the WS_DATA_ITEM coordinates units is the mm, and are relative to
* one of 4 page corners.
*
* These items cannot be drawn or plot "as this". they should be converted
* to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
* The list of these items is stored in a WS_DATA_MODEL instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
* coordinates are converted to draw/plot coordinates.
* texts are expanded if they contain format symbols.
* Items with m_RepeatCount > 1 are created m_RepeatCount times
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DATA_MODEL is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* the WS_DATA_MODEL instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
@ -52,7 +52,7 @@
#include <eda_rect.h>
#include <draw_graphic_text.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <ws_data_model.h>
#include <base_units.h>
#include <page_info.h>
#include <layers_id_colors_and_visibility.h>
@ -63,7 +63,7 @@ void WS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
WORKSHEET_DATAITEM* dataItem = GetPeer();
WS_DATA_ITEM* dataItem = GetPeer();
if( dataItem->GetPage1Option() == FIRST_PAGE_ONLY )
aLayers[0] = LAYER_WORKSHEET_PAGE1;
@ -92,28 +92,28 @@ bool WS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAc
void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{
wxString msg;
WORKSHEET_DATAITEM* dataItem = GetPeer();
WS_DATA_ITEM* dataItem = GetPeer();
switch( dataItem->GetType() )
{
case WORKSHEET_DATAITEM::WS_SEGMENT:
case WS_DATA_ITEM::WS_SEGMENT:
aList.push_back( MSG_PANEL_ITEM( _( "Line" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_RECT:
case WS_DATA_ITEM::WS_RECT:
aList.push_back( MSG_PANEL_ITEM( _( "Rectangle" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_TEXT:
case WS_DATA_ITEM::WS_TEXT:
msg = static_cast<WS_DRAW_ITEM_TEXT*>( this )->GetShownText();
aList.push_back( MSG_PANEL_ITEM( _( "Text" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
case WS_DATA_ITEM::WS_POLYPOLYGON:
aList.push_back( MSG_PANEL_ITEM( _( "Imported Shape" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
case WS_DATA_ITEM::WS_BITMAP:
aList.push_back( MSG_PANEL_ITEM( _( "Image" ), msg, DARKCYAN ) );
break;
}
@ -365,7 +365,7 @@ wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
WORKSHEET_DATAITEM_BITMAP* bitmap = (WORKSHEET_DATAITEM_BITMAP*) GetPeer();
WS_DATA_ITEM_BITMAP* bitmap = (WS_DATA_ITEM_BITMAP*) GetPeer();
if( bitmap->m_ImageBitmap )
{
@ -378,7 +378,7 @@ void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoi
const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
{
auto* bitmap = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( m_peer );
auto* bitmap = static_cast<const WS_DATA_ITEM_BITMAP*>( m_peer );
EDA_RECT rect = bitmap->m_ImageBitmap->GetBoundingBox();
rect.Move( m_pos );
@ -401,26 +401,26 @@ wxString WS_DRAW_ITEM_BITMAP::GetSelectMenuText( EDA_UNITS_T aUnits ) const
void WS_DRAW_ITEM_LIST::SetupDrawEnvironment( const PAGE_INFO& aPageInfo )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
// Left top corner position
DPOINT lt_corner;
lt_corner.x = pglayout.GetLeftMargin();
lt_corner.y = pglayout.GetTopMargin();
WORKSHEET_DATAITEM::m_LT_Corner = lt_corner;
WS_DATA_ITEM::m_LT_Corner = lt_corner;
// Right bottom corner position
DPOINT rb_corner;
rb_corner.x = ( aPageInfo.GetSizeMils().x * MILS_TO_MM ) - pglayout.GetRightMargin();
rb_corner.y = ( aPageInfo.GetSizeMils().y * MILS_TO_MM ) - pglayout.GetBottomMargin();
WORKSHEET_DATAITEM::m_RB_Corner = rb_corner;
WS_DATA_ITEM::m_RB_Corner = rb_corner;
}
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
m_titleBlock = &aTitleBlock;
m_paperFormat = &aPageInfo.GetType();
@ -432,11 +432,11 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
if( pglayout.GetCount() == 0 && !pglayout.VoidListAllowed() )
pglayout.SetPageLayout();
WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / MILS_TO_MM;
WS_DATA_ITEM::m_WSunits2Iu = m_milsToIu / MILS_TO_MM;
SetupDrawEnvironment( aPageInfo );
for( WORKSHEET_DATAITEM* wsItem : pglayout.GetItems() )
for( WS_DATA_ITEM* wsItem : pglayout.GetItems() )
{
// Generate it only if the page option allows this
if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && m_sheetNumber != 1 )

View File

@ -34,8 +34,8 @@
#include <ws_draw_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <worksheet_painter.h>
#include <worksheet_dataitem.h>
#include <ws_painter.h>
#include <ws_data_item.h>
using namespace KIGFX;
@ -236,7 +236,7 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
}
bool KIGFX::WORKSHEET_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
bool KIGFX::WS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
{
auto item = static_cast<const EDA_ITEM*>( aItem );
@ -254,7 +254,7 @@ bool KIGFX::WORKSHEET_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
{
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
@ -264,7 +264,7 @@ void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
{
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
@ -274,7 +274,7 @@ void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_POLYGON* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_POLYGON* aItem, int aLayer ) const
{
std::deque<VECTOR2D> corners;
for( wxPoint point : aItem->m_Corners )
@ -300,7 +300,7 @@ void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_POLYGON* aItem, int aLay
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
{
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
@ -315,12 +315,12 @@ void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
{
m_gal->Save();
VECTOR2D position = aItem->GetPosition();
m_gal->Translate( position );
auto* bitmap = static_cast<WORKSHEET_DATAITEM_BITMAP*>( aItem->GetPeer() );
auto* bitmap = static_cast<WS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
// When the image scale factor is not 1.0, we need to modify the actual scale
// as the image scale factor is similar to a local zoom
@ -334,7 +334,7 @@ void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLaye
}
void KIGFX::WORKSHEET_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
void KIGFX::WS_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
{
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
VECTOR2D end = VECTOR2D( aPageInfo->GetWidthMils() * aScaleFactor,

View File

@ -27,38 +27,38 @@
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <ws_data_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#include <layers_id_colors_and_visibility.h>
#include <page_info.h>
#include <view/view.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( int aMils2IUscalefactor,
WS_VIEW_ITEM::WS_VIEW_ITEM( int aMils2IUscalefactor,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_mils2IUscalefactor( aMils2IUscalefactor ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
void WORKSHEET_VIEWITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
void WS_VIEW_ITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
{
m_pageInfo = aPageInfo;
}
void WORKSHEET_VIEWITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
void WS_VIEW_ITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
{
m_titleBlock = aTitleBlock;
}
const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
const BOX2I WS_VIEW_ITEM::ViewBBox() const
{
BOX2I bbox;
@ -77,7 +77,7 @@ const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
}
void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
void WS_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
{
auto gal = aView->GetGAL();
auto settings = aView->GetPainter()->GetSettings();
@ -107,7 +107,7 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
gal->Scale( VECTOR2D( -1.0, 1.0 ) );
}
WORKSHEET_PAINTER ws_painter( gal );
WS_PAINTER ws_painter( gal );
WS_RENDER_SETTINGS* ws_settings =static_cast<WS_RENDER_SETTINGS*>( ws_painter.GetSettings() );
ws_settings->SetNormalColor( settings->GetLayerColor( LAYER_WORKSHEET ) );
@ -127,7 +127,7 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
}
void WORKSHEET_VIEWITEM::ViewGetLayers( int aLayers[], int& aCount ) const
void WS_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = LAYER_WORKSHEET;

View File

@ -25,12 +25,12 @@
#include <fctsys.h>
#include <base_struct.h>
#include <plotter.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <base_screen.h>
#include <draw_graphic_text.h>
#include <title_block.h>
#include "ws_draw_item.h"
#include "worksheet_dataitem.h"
#include "ws_data_item.h"
#include <wx/filename.h>
@ -126,7 +126,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
case WSG_BITMAP_T:
{
WS_DRAW_ITEM_BITMAP* drawItem = (WS_DRAW_ITEM_BITMAP*) item;
auto* bitmap = (WORKSHEET_DATAITEM_BITMAP*) drawItem->GetPeer();
auto* bitmap = (WS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
if( bitmap->m_ImageBitmap == NULL )
break;

View File

@ -31,7 +31,7 @@
#include <pgm_base.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <worksheet_painter.h>
#include <ws_painter.h>
#include <sch_sheet.h>
#include <dialog_plot_schematic.h>

View File

@ -38,6 +38,7 @@
#include <eeschema_config.h>
#include <ee_hotkeys.h>
#include <ws_draw_item.h>
#include <ws_data_model.h>
#include <class_library.h>
#include <symbol_lib_table.h>
#include <dialog_erc.h>
@ -285,19 +286,17 @@ bool SCH_EDIT_FRAME::LoadProjectFile()
// Verify some values, because the config file can be edited by hand,
// and have bad values:
LIB_PART::SetSubpartIdNotation(
LIB_PART::GetSubpartIdSeparator(),
LIB_PART::GetSubpartFirstId() );
LIB_PART::SetSubpartIdNotation( LIB_PART::GetSubpartIdSeparator(),
LIB_PART::GetSubpartFirstId() );
// Load the page layout decr file, from the filename stored in
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
// If empty, or not existing, the default descr is loaded
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
wxString pg_fullfilename = WORKSHEET_LAYOUT::MakeFullFileName(
BASE_SCREEN::m_PageLayoutDescrFileName,
Prj().GetProjectPath() );
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
wxString filename = WS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
Prj().GetProjectPath() );
pglayout.SetPageLayout( pg_fullfilename );
pglayout.SetPageLayout( filename );
return ret;
}

View File

@ -24,10 +24,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/files-io.cpp
*/
#include <fctsys.h>
#include <sch_draw_panel.h>
#include <confirm.h>
@ -52,7 +48,7 @@
#include <symbol_lib_table.h>
#include <dialog_symbol_remap.h>
#include <dialog_migrate_buses.h>
#include <ws_draw_item.h>
#include <ws_data_model.h>
#include <connection_graph.h>
@ -804,7 +800,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
g_RootSheet = pi->Load( aFileName, &Kiway() );
// Eagle sheets do not use a worksheet frame by default, so set it to an empty one
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
pglayout.SetEmptyLayout();
BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks";
@ -814,7 +810,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
if( layoutfile.Create( layoutfn.GetFullPath() ) )
{
layoutfile.Write( WORKSHEET_LAYOUT::EmptyLayout() );
layoutfile.Write( WS_DATA_MODEL::EmptyLayout() );
layoutfile.Close();
}

View File

@ -25,7 +25,7 @@
#include <view/wx_view_controls.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <sch_draw_panel.h>

View File

@ -23,7 +23,7 @@
#include <view/wx_view_controls.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <gal/graphics_abstraction_layer.h>

View File

@ -28,7 +28,7 @@
#include <view/view_group.h>
#include <view/view_rtree.h>
#include <view/wx_view_controls.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <layers_id_colors_and_visibility.h>
#include <class_libentry.h>
#include <sch_sheet.h>
@ -85,7 +85,7 @@ void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen )
for( auto item = aScreen->GetDrawItems(); item; item = item->Next() )
Add( item );
m_worksheet.reset( new KIGFX::WORKSHEET_VIEWITEM( 1, &aScreen->GetPageSettings(),
m_worksheet.reset( new KIGFX::WS_VIEW_ITEM( 1, &aScreen->GetPageSettings(),
&aScreen->GetTitleBlock() ) );
m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber );
m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens );

View File

@ -29,7 +29,7 @@
#include <math/box2.h>
#include <view/wx_view_controls.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <layers_id_colors_and_visibility.h>
class SCH_SHEET;
@ -61,7 +61,7 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
namespace KIGFX
{
class VIEW_GROUP;
class WORKSHEET_VIEWITEM;
class WS_VIEW_ITEM;
namespace PREVIEW
{
@ -105,7 +105,7 @@ public:
private:
SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
// to know the sheet path name when drawing the page layout
std::unique_ptr<WORKSHEET_VIEWITEM> m_worksheet;
std::unique_ptr<WS_VIEW_ITEM> m_worksheet;
std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
std::vector<EDA_ITEM *> m_ownedItems;

View File

@ -21,7 +21,7 @@
#include <view/view.h>
#include <view/wx_view_controls.h>
#include <gerbview_painter.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
#include <colors_design_settings.h>
#include <gerbview_frame.h>
@ -179,7 +179,7 @@ void GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps()
}
void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet )
void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet )
{
m_worksheet.reset( aWorksheet );
m_view->Add( m_worksheet.get() );

View File

@ -21,11 +21,11 @@
#define GERBVIEW_DRAW_PANEL_GAL_H_
#include <class_draw_panel_gal.h>
#include <worksheet_viewitem.h>
#include <ws_view_item.h>
namespace KIGFX
{
class WORKSHEET_VIEWITEM;
class WS_VIEW_ITEM;
}
class COLORS_DESIGN_SETTINGS;
@ -69,14 +69,14 @@ public:
* @param aWorksheet is the worksheet to be used.
* The object is then owned by GERBVIEW_DRAW_PANEL_GAL.
*/
void SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet );
void SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet );
protected:
///> Sets rendering targets & dependencies for layers.
void setDefaultLayerDeps();
///> Currently used worksheet
std::unique_ptr<KIGFX::WORKSHEET_VIEWITEM> m_worksheet;
std::unique_ptr<KIGFX::WS_VIEW_ITEM> m_worksheet;
};

View File

@ -960,7 +960,7 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
// Prepare worksheet template
auto worksheet =
new KIGFX::WORKSHEET_VIEWITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
new KIGFX::WS_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
if( screen != NULL )
{

View File

@ -85,7 +85,7 @@ public:
// * poly polygon defined by a coordinate, and a set of list of corners
// ( because we use it for logos, there are more than one polygon
// in this description
class WORKSHEET_DATAITEM
class WS_DATA_ITEM
{
public:
enum WS_ITEM_TYPE {
@ -116,8 +116,12 @@ public:
int m_IncrementLabel;
// These variables are static, because these values are common to all
// instances of WORKSHEET_DATAITEM.
// instances of WS_DATA_ITEM.
// They are default or common values.
//==============================================================================
// JEY TODO: these globals are death when we try to generate the page setttings preview...
// move them to member variables of WS_DATA_MODEL
//==============================================================================
static double m_WSunits2Iu; // conversion factor between
// ws units (mils) and draw/plot units
static DPOINT m_RB_Corner; // cordinates of the right bottom corner
@ -135,9 +139,9 @@ public:
// When set to true, base texts
// instead of full texts are displayed
public:
WORKSHEET_DATAITEM( WS_ITEM_TYPE aType );
WS_DATA_ITEM( WS_ITEM_TYPE aType );
virtual ~WORKSHEET_DATAITEM() {}
virtual ~WS_DATA_ITEM() {}
const std::vector<WS_DRAW_ITEM_BASE*>& GetDrawItems() const { return m_drawItems; }
@ -233,7 +237,7 @@ public:
};
class WORKSHEET_DATAITEM_POLYPOLYGON : public WORKSHEET_DATAITEM
class WS_DATA_ITEM_POLYGONS : public WS_DATA_ITEM
{
public:
double m_Orient; // Orientation in degrees
@ -245,7 +249,7 @@ private:
DPOINT m_maxCoord; // max coord of corners, relative to m_Pos
public:
WORKSHEET_DATAITEM_POLYPOLYGON( );
WS_DATA_ITEM_POLYGONS( );
void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
@ -324,7 +328,7 @@ public:
};
class WORKSHEET_DATAITEM_TEXT : public WORKSHEET_DATAITEM
class WS_DATA_ITEM_TEXT : public WS_DATA_ITEM
{
public:
wxString m_TextBase; // The basic text, with format symbols
@ -345,7 +349,7 @@ public:
public:
WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase );
WS_DATA_ITEM_TEXT( const wxString& aTextBase );
void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
@ -400,14 +404,14 @@ public:
class BITMAP_BASE;
class WORKSHEET_DATAITEM_BITMAP : public WORKSHEET_DATAITEM
class WS_DATA_ITEM_BITMAP : public WS_DATA_ITEM
{
public:
BITMAP_BASE* m_ImageBitmap;
public:
WORKSHEET_DATAITEM_BITMAP(BITMAP_BASE* aImage)
: WORKSHEET_DATAITEM( WS_BITMAP )
WS_DATA_ITEM_BITMAP(BITMAP_BASE* aImage)
: WS_DATA_ITEM( WS_BITMAP )
{
m_ImageBitmap = aImage;
}

193
include/ws_data_model.h Normal file
View File

@ -0,0 +1,193 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef WS_DATA_MODEL_H
#define WS_DATA_MODEL_H
#include <math/vector2d.h>
#include <eda_text.h>
#include <eda_text.h>
#include <bitmap_base.h>
#include <ws_data_item.h>
/**
* WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block
*/
class WS_DATA_MODEL
{
std::vector <WS_DATA_ITEM*> m_list;
bool m_allowVoidList; // If false, the default page layout
// will be loaded the first time
// WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList
// is run (useful mainly for page layout editor)
double m_leftMargin; // the left page margin in mm
double m_rightMargin; // the right page margin in mm
double m_topMargin; // the top page margin in mm
double m_bottomMargin; // the bottom page margin in mm
public:
WS_DATA_MODEL();
~WS_DATA_MODEL() {ClearList(); }
/**
* static function: returns the instance of WS_DATA_MODEL used in the application
*/
static WS_DATA_MODEL& GetTheInstance();
/**
* static function: Set an alternate instance of WS_DATA_MODEL
* mainly used in page setting dialog
* @param aLayout = the alternate page layout; if null restore the basic page layout
*/
static void SetAltInstance( WS_DATA_MODEL* aLayout = NULL );
// Accessors:
double GetLeftMargin() { return m_leftMargin; }
double GetRightMargin() { return m_rightMargin; }
double GetTopMargin() { return m_topMargin; }
double GetBottomMargin() { return m_bottomMargin; }
void SetLeftMargin( double aMargin );
void SetRightMargin( double aMargin );
void SetTopMargin( double aMargin );
void SetBottomMargin( double aMargin );
/**
* In Kicad applications, a page layout description is needed
* So if the list is empty, a default description is loaded,
* the first time a page layout is drawn.
* However, in page layout editor, an empty list is acceptable.
* AllowVoidList allows or not the empty list
*/
void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
/**
* @return true if an empty list is allowed
* (mainly allowed for page layout editor).
*/
bool VoidListAllowed() { return m_allowVoidList; }
/**
* erase the list of items
*/
void ClearList();
/**
* Save the description in a file
* @param aFullFileName the filename of the file to created
*/
void Save( const wxString& aFullFileName );
/**
* Save the description in a buffer
* @param aOutputString = a wxString to store the S expr string
*/
void SaveInString( wxString& aOutputString );
void Append( WS_DATA_ITEM* aItem );
void Remove( WS_DATA_ITEM* aItem );
/**
* @return the index of aItem, or -1 if does not exist
*/
int GetItemIndex( WS_DATA_ITEM* aItem ) const;
/**
* @return the item from its index aIdx, or NULL if does not exist
*/
WS_DATA_ITEM* GetItem( unsigned aIdx ) const;
/**
* @return a reference to the items.
*/
std::vector<WS_DATA_ITEM*>& GetItems() { return m_list; }
/**
* @return the item count
*/
unsigned GetCount() const { return m_list.size(); }
void SetDefaultLayout();
void SetEmptyLayout();
/**
* Returns a string containing the empty layout shape
*/
static wxString EmptyLayout();
/**
* Returns a string containing the empty layout shape
*/
static wxString DefaultLayout();
/**
* Populates the list with a custom layout, or
* the default layout, if no custom layout available
* @param aFullFileName = the custom page layout description file.
* if empty, loads the file defined by KICAD_WKSFILE
* and if its is not defined, uses the default internal description
* @param Append = if true: do not delete old layout, and load only
aFullFileName.
*/
void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false );
/**
* Populates the list from a S expr description stored in a string
* @param aPageLayout = the S expr string
* @param aAppend Do not delete old layout if true and append \a aPageLayout
* the existing one.
@param aSource is the layout source description.
*/
void SetPageLayout( const char* aPageLayout, bool aAppend = false,
const wxString& aSource = wxT( "Sexpr_string" ) );
/**
* @return a short filename from a full filename:
* if the path is the current project path, or if the path
* is the same as kicad.pro (in template), returns the shortname
* else do nothing and returns a full filename
* @param aFullFileName = the full filename, which can be a relative
* @param aProjectPath = the curr project absolute path (can be empty)
*/
static const wxString MakeShortFileName( const wxString& aFullFileName,
const wxString& aProjectPath );
/**
* Static function
* @return a full filename from a short filename.
* @param aShortFileName = the short filename, which can be a relative
* @param aProjectPath = the curr project absolute path (can be empty)
* or absolute path, and can include env variable reference ( ${envvar} expression )
* if the short filename path is relative, it is expected relative to the project path
* or (if aProjectPath is empty or if the file does not exist)
* relative to kicad.pro (in template)
* If aShortFileName is absolute return aShortFileName
*/
static const wxString MakeFullFileName( const wxString& aShortFileName,
const wxString& aProjectPath );
};
#endif // WS_DATA_MODEL_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -31,30 +31,26 @@
#include <bitmap_base.h>
#include "msgpanel.h"
class WORKSHEET_DATAITEM;
class WS_DATA_ITEM;
class TITLE_BLOCK;
class PAGE_INFO;
#define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm
/*
* Helper classes to handle basic graphic items used to draw/plot
* title blocks and frame references
* segments
* rect
* polygons (for logos)
* graphic texts
* bitmaps, also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters (in
* which case only the bounding box is plotted)
* title blocks and frame references
* segments
* rect
* polygons (for logos)
* graphic texts
* bitmaps (also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters
* where we just plot the bounding box)
*/
class WS_DRAW_ITEM_BASE : public EDA_ITEM // This basic class, not directly usable.
{
protected:
WORKSHEET_DATAITEM* m_peer; // an unique identifier, used as link
// to the parent WORKSHEET_DATAITEM item,
// in page layout editor
WS_DATA_ITEM* m_peer; // the parent WS_DATA_ITEM item in the WS_DATA_MODEL
WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aPeer, KICAD_T aType ) :
WS_DRAW_ITEM_BASE( WS_DATA_ITEM* aPeer, KICAD_T aType ) :
EDA_ITEM( aType )
{
m_peer = aPeer;
@ -64,7 +60,7 @@ protected:
public:
virtual ~WS_DRAW_ITEM_BASE() {}
WORKSHEET_DATAITEM* GetPeer() const { return m_peer; }
WS_DATA_ITEM* GetPeer() const { return m_peer; }
void ViewGetLayers( int aLayers[], int& aCount ) const override;
@ -72,19 +68,21 @@ public:
virtual void SetPosition( wxPoint aPos ) = 0;
virtual void SetEnd( wxPoint aPos ) { /* not all types will need this */ }
/** The function to draw a WS_DRAW_ITEM
*/
// The function to draw a WS_DRAW_ITEM
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor )
{
wxPoint offset( 0, 0 );
DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, aColor );
}
/// More advanced version of DrawWsItem. This is what must be
/// defined in the derived type.
// More advanced version of DrawWsItem. This is what must be defined in the derived type.
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor ) = 0;
// Derived types must define GetBoundingBox() as a minimum, and can then override the
// two HitTest() functions if they need something more specific.
const EDA_RECT GetBoundingBox() const override = 0;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
{
// This is just here to prevent annoying compiler warnings about hidden overloaded
@ -92,10 +90,6 @@ public:
return EDA_ITEM::HitTest( aPosition, aAccuracy );
}
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
void GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) override;
@ -110,7 +104,7 @@ class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE
int m_penWidth;
public:
WS_DRAW_ITEM_LINE( WORKSHEET_DATAITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_LINE( WS_DATA_ITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_LINE_T )
{
m_start = aStart;
@ -131,15 +125,8 @@ public:
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
const EDA_RECT GetBoundingBox() const override;
/**
* Virtual function
* return true if the point aPosition is on the line
*/
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/** The function to draw a WS_DRAW_ITEM_LINE
*/
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
@ -154,7 +141,7 @@ public:
class WS_DRAW_ITEM_POLYGON : public WS_DRAW_ITEM_BASE
{
wxPoint m_pos; // position of reference point, from the
// WORKSHEET_DATAITEM_POLYPOLYGON parent
// WS_DATA_ITEM_POLYGONS parent
// (used only in page layout editor to draw anchors)
int m_penWidth;
bool m_fill;
@ -163,8 +150,8 @@ public:
std::vector <wxPoint> m_Corners;
public:
WS_DRAW_ITEM_POLYGON( WORKSHEET_DATAITEM* aPeer, wxPoint aPos, bool aFill, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_POLY_T )
WS_DRAW_ITEM_POLYGON( WS_DATA_ITEM* aPeer, wxPoint aPos, bool aFill, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_POLY_T )
{
m_penWidth = aPenWidth;
m_fill = aFill;
@ -180,21 +167,9 @@ public:
void SetPosition( wxPoint aPos ) override { m_pos = aPos; }
const EDA_RECT GetBoundingBox() const override;
/**
* Virtual function
* return true if the point aPosition is inside one polygon
*/
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
/** The function to draw a WS_DRAW_ITEM_POLYGON
*/
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
@ -213,7 +188,7 @@ class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_BASE
int m_penWidth;
public:
WS_DRAW_ITEM_RECT( WORKSHEET_DATAITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_RECT( WS_DATA_ITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_RECT_T )
{
m_start = aStart;
@ -233,17 +208,10 @@ public:
const wxPoint GetPosition() const override { return GetStart(); }
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
/** The function to draw a WS_DRAW_ITEM_RECT
*/
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
const EDA_RECT GetBoundingBox() const override;
/**
* Virtual function
* return true if the point aPosition is on one edge of the rectangle
*/
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
@ -259,7 +227,7 @@ public:
class WS_DRAW_ITEM_TEXT : public WS_DRAW_ITEM_BASE, public EDA_TEXT
{
public:
WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aPeer, wxString& aText, wxPoint aPos, wxSize aSize,
WS_DRAW_ITEM_TEXT( WS_DATA_ITEM* aPeer, wxString& aText, wxPoint aPos, wxSize aSize,
int aPenWidth, bool aItalic = false, bool aBold = false ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_TEXT_T),
EDA_TEXT( aText )
@ -290,17 +258,7 @@ public:
void SetPosition( wxPoint aPos ) override { SetTextPos( aPos ); }
const EDA_RECT GetBoundingBox() const override;
/**
* Virtual function
* return true if the point aPosition is inside one polygon
*/
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
@ -316,7 +274,7 @@ class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE
wxPoint m_pos; // position of reference point
public:
WS_DRAW_ITEM_BITMAP( WORKSHEET_DATAITEM* aPeer, wxPoint aPos ) :
WS_DRAW_ITEM_BITMAP( WS_DATA_ITEM* aPeer, wxPoint aPos ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_BITMAP_T )
{
m_pos = aPos;
@ -334,8 +292,6 @@ public:
const wxPoint GetPosition() const override { return m_pos; }
void SetPosition( wxPoint aPos ) override { m_pos = aPos; }
/** The function to draw a WS_DRAW_ITEM_BITMAP
*/
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
@ -546,162 +502,4 @@ public:
};
/**
* WORKSHEET_LAYOUT handles the graphic items list to draw/plot
* the title block and other items (page references ...
*/
class WORKSHEET_LAYOUT
{
std::vector <WORKSHEET_DATAITEM*> m_list;
bool m_allowVoidList; // If false, the default page layout
// will be loaded the first time
// WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList
// is run (useful mainly for page layout editor)
double m_leftMargin; // the left page margin in mm
double m_rightMargin; // the right page margin in mm
double m_topMargin; // the top page margin in mm
double m_bottomMargin; // the bottom page margin in mm
public:
WORKSHEET_LAYOUT();
~WORKSHEET_LAYOUT() {ClearList(); }
/**
* static function: returns the instance of WORKSHEET_LAYOUT used in the application
*/
static WORKSHEET_LAYOUT& GetTheInstance();
/**
* static function: Set an alternate instance of WORKSHEET_LAYOUT
* mainly used in page setting dialog
* @param aLayout = the alternate page layout; if null restore the basic page layout
*/
static void SetAltInstance( WORKSHEET_LAYOUT* aLayout = NULL );
// Accessors:
double GetLeftMargin() { return m_leftMargin; }
double GetRightMargin() { return m_rightMargin; }
double GetTopMargin() { return m_topMargin; }
double GetBottomMargin() { return m_bottomMargin; }
void SetLeftMargin( double aMargin );
void SetRightMargin( double aMargin );
void SetTopMargin( double aMargin );
void SetBottomMargin( double aMargin );
/**
* In Kicad applications, a page layout description is needed
* So if the list is empty, a default description is loaded,
* the first time a page layout is drawn.
* However, in page layout editor, an empty list is acceptable.
* AllowVoidList allows or not the empty list
*/
void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
/**
* @return true if an empty list is allowed
* (mainly allowed for page layout editor).
*/
bool VoidListAllowed() { return m_allowVoidList; }
/**
* erase the list of items
*/
void ClearList();
/**
* Save the description in a file
* @param aFullFileName the filename of the file to created
*/
void Save( const wxString& aFullFileName );
/**
* Save the description in a buffer
* @param aOutputString = a wxString to store the S expr string
*/
void SaveInString( wxString& aOutputString );
void Append( WORKSHEET_DATAITEM* aItem );
void Remove( WORKSHEET_DATAITEM* aItem );
/**
* @return the index of aItem, or -1 if does not exist
*/
int GetItemIndex( WORKSHEET_DATAITEM* aItem ) const;
/**
* @return the item from its index aIdx, or NULL if does not exist
*/
WORKSHEET_DATAITEM* GetItem( unsigned aIdx ) const;
/**
* @return a reference to the items.
*/
std::vector<WORKSHEET_DATAITEM*>& GetItems() { return m_list; }
/**
* @return the item count
*/
unsigned GetCount() const { return m_list.size(); }
void SetDefaultLayout();
void SetEmptyLayout();
/**
* Returns a string containing the empty layout shape
*/
static wxString EmptyLayout();
/**
* Returns a string containing the empty layout shape
*/
static wxString DefaultLayout();
/**
* Populates the list with a custom layout, or
* the default layout, if no custom layout available
* @param aFullFileName = the custom page layout description file.
* if empty, loads the file defined by KICAD_WKSFILE
* and if its is not defined, uses the default internal description
* @param Append = if true: do not delete old layout, and load only
aFullFileName.
*/
void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false );
/**
* Populates the list from a S expr description stored in a string
* @param aPageLayout = the S expr string
* @param aAppend Do not delete old layout if true and append \a aPageLayout
* the existing one.
@param aSource is the layout source description.
*/
void SetPageLayout( const char* aPageLayout, bool aAppend = false,
const wxString& aSource = wxT( "Sexpr_string" ) );
/**
* @return a short filename from a full filename:
* if the path is the current project path, or if the path
* is the same as kicad.pro (in template), returns the shortname
* else do nothing and returns a full filename
* @param aFullFileName = the full filename, which can be a relative
* @param aProjectPath = the curr project absolute path (can be empty)
*/
static const wxString MakeShortFileName( const wxString& aFullFileName,
const wxString& aProjectPath );
/**
* Static function
* @return a full filename from a short filename.
* @param aShortFileName = the short filename, which can be a relative
* @param aProjectPath = the curr project absolute path (can be empty)
* or absolute path, and can include env variable reference ( ${envvar} expression )
* if the short filename path is relative, it is expected relative to the project path
* or (if aProjectPath is empty or if the file does not exist)
* relative to kicad.pro (in template)
* If aShortFileName is absolute return aShortFileName
*/
static const wxString MakeFullFileName( const wxString& aShortFileName,
const wxString& aProjectPath );
};
#endif // WS_DRAW_ITEM_H

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,8 +23,8 @@
// For page and paper size, values are in 1/1000 inch
#ifndef WORKSHEET_PAINTER_H
#define WORKSHEET_PAINTER_H
#ifndef WS_PAINTER_H
#define WS_PAINTER_H
#include <gal/color4d.h>
#include <painter.h>
@ -47,7 +47,7 @@ namespace KIGFX
class WS_RENDER_SETTINGS : public RENDER_SETTINGS
{
public:
friend class WORKSHEET_PAINTER;
friend class WS_PAINTER;
WS_RENDER_SETTINGS();
@ -90,13 +90,13 @@ private:
/**
* Class WORKSHEET_PAINTER
* Class WS_PAINTER
* Contains methods for drawing worksheet items.
*/
class WORKSHEET_PAINTER : public PAINTER
class WS_PAINTER : public PAINTER
{
public:
WORKSHEET_PAINTER( GAL* aGal ) :
WS_PAINTER( GAL* aGal ) :
PAINTER( aGal )
{ }
@ -164,4 +164,4 @@ void DrawPageLayout( wxDC* aDC,
const wxString& aSheetLayer = wxEmptyString );
#endif // WORKSHEET_PAINTER_H
#endif // WS_PAINTER_H

Some files were not shown because too many files have changed in this diff Show More