mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-07 18:45:32 +00:00
Round 2 of Worksheet -> Drawing Sheet.
This commit is contained in:
parent
507ca9bc73
commit
a3b9e8ddb4
.gitignore
common
CMakeLists.txt
dialogs
drawing_sheet
drawing_sheet_default_description.cppdrawing_sheet_reader.cppdrawing_sheet_reader.keywordsds_data_item.cppds_data_model.cppds_data_model_io.cppds_draw_item.cppds_painter.cppds_proxy_undo_item.cppds_proxy_view_item.cpp
eda_draw_frame.cppplotters
eeschema
dialogs
dialog_eeschema_page_settings.hdialog_plot_schematic.cppdialog_print_using_printer.cpppanel_eeschema_color_settings.cpppanel_eeschema_color_settings.h
eeschema_config.cpperc.cpperc.hfiles-io.cpphierarch.cppsch_edit_frame.cppsch_plugins/eagle
sch_preview_panel.cppsch_view.cppsch_view.hschematic_undo_redo.cpptools
gerbview
clear_gbr_drawlayers.cppgerbview_draw_panel_gal.cppgerbview_draw_panel_gal.hgerbview_frame.cppgerbview_printout.cpp
include
pagelayout_editor
CMakeLists.txt
dialogs
design_inspector.cppdesign_inspector.hdialog_new_dataitem.cppdialogs_for_printing.cppproperties_frame.cppproperties_frame.h
files.cppinvoke_pl_editor_dialog.hpl_draw_panel_gal.cpppl_draw_panel_gal.hpl_editor_frame.cpppl_editor_frame.hpl_editor_layout.hpl_editor_undo_redo.cpptools
pcbnew
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,7 +9,7 @@ common/drc_rules_lexer.h
|
||||
common/netlist_keywords.*
|
||||
common/netlist_lexer.h
|
||||
common/pcb_plot_params_lexer.h
|
||||
common/page_layout/page_layout_reader_keywords.cpp
|
||||
common/drawing_sheet/drawing_sheet_reader_keywords.cpp
|
||||
common/lib_table_keywords.*
|
||||
common/gal/opengl/shader_src.h
|
||||
include/fp_lib_table_lexer.h
|
||||
|
@ -246,15 +246,15 @@ set( COMMON_WIDGET_SRCS
|
||||
widgets/wx_aui_dock_art.cpp
|
||||
)
|
||||
|
||||
set( COMMON_PAGE_LAYOUT_SRCS
|
||||
page_layout/ws_data_item.cpp
|
||||
page_layout/ws_data_model.cpp
|
||||
page_layout/ws_data_model_io.cpp
|
||||
page_layout/page_layout_default_description.cpp
|
||||
page_layout/ws_draw_item.cpp
|
||||
page_layout/ws_proxy_undo_item.cpp
|
||||
page_layout/ws_proxy_view_item.cpp
|
||||
page_layout/page_layout_reader.cpp
|
||||
set( COMMON_DRAWING_SHEET_SRCS
|
||||
drawing_sheet/ds_data_item.cpp
|
||||
drawing_sheet/ds_data_model.cpp
|
||||
drawing_sheet/ds_data_model_io.cpp
|
||||
drawing_sheet/drawing_sheet_default_description.cpp
|
||||
drawing_sheet/ds_draw_item.cpp
|
||||
drawing_sheet/ds_proxy_undo_item.cpp
|
||||
drawing_sheet/ds_proxy_view_item.cpp
|
||||
drawing_sheet/drawing_sheet_reader.cpp
|
||||
)
|
||||
|
||||
set( COMMON_PREVIEW_ITEMS_SRCS
|
||||
@ -300,7 +300,7 @@ set( COMMON_SRCS
|
||||
${COMMON_ABOUT_DLG_SRCS}
|
||||
${COMMON_DLG_SRCS}
|
||||
${COMMON_WIDGET_SRCS}
|
||||
${COMMON_PAGE_LAYOUT_SRCS}
|
||||
${COMMON_DRAWING_SHEET_SRCS}
|
||||
${COMMON_PREVIEW_ITEMS_SRCS}
|
||||
${PLOTTERS_CONTROL_SRCS}
|
||||
${PLUGINS_ALTIUM_SRCS}
|
||||
@ -392,7 +392,7 @@ set( COMMON_SRCS
|
||||
utf8.cpp
|
||||
validators.cpp
|
||||
wildcards_and_files_ext.cpp
|
||||
page_layout/ws_painter.cpp
|
||||
drawing_sheet/ds_painter.cpp
|
||||
wxdataviewctrl_helpers.cpp
|
||||
wx_filename.cpp
|
||||
xnode.cpp
|
||||
@ -559,7 +559,7 @@ set( PCB_COMMON_SRCS
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcbnew_settings.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/plugin.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest/ratsnest_data.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest/ratsnest_viewitem.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest/ratsnest_view_item.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/sel_layer.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/zone_settings.cpp
|
||||
|
||||
@ -667,9 +667,9 @@ make_lexer(
|
||||
# and title_block_reader_keywords.cpp.
|
||||
make_lexer(
|
||||
common
|
||||
page_layout/page_layout_reader.keywords
|
||||
page_layout/page_layout_reader_lexer.h
|
||||
page_layout/page_layout_reader_keywords.cpp
|
||||
drawing_sheet/drawing_sheet_reader.keywords
|
||||
drawing_sheet/drawing_sheet_reader_lexer.h
|
||||
drawing_sheet/drawing_sheet_reader_keywords.cpp
|
||||
TB_READER_T
|
||||
)
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <wx/valgen.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
@ -83,10 +83,10 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, double aI
|
||||
m_customFmt = false;
|
||||
m_localPrjConfigChanged = false;
|
||||
|
||||
m_pagelayout = new WS_DATA_MODEL;
|
||||
m_drawingSheet = new DS_DATA_MODEL;
|
||||
wxString serialization;
|
||||
WS_DATA_MODEL::GetTheInstance().SaveInString( serialization );
|
||||
m_pagelayout->SetPageLayout( TO_UTF8( serialization ) );
|
||||
DS_DATA_MODEL::GetTheInstance().SaveInString( serialization );
|
||||
m_drawingSheet->SetPageLayout(TO_UTF8( serialization ) );
|
||||
|
||||
m_PickDate->SetValue( wxDateTime::Now() );
|
||||
|
||||
@ -110,7 +110,7 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, double aI
|
||||
DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS()
|
||||
{
|
||||
delete m_pageBitmap;
|
||||
delete m_pagelayout;
|
||||
delete m_drawingSheet;
|
||||
}
|
||||
|
||||
|
||||
@ -455,7 +455,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
|
||||
|
||||
if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName )
|
||||
{
|
||||
wxString fullFileName = WS_DATA_MODEL::MakeFullFileName( fileName, m_projectPath );
|
||||
wxString fullFileName = DS_DATA_MODEL::MakeFullFileName( fileName, m_projectPath );
|
||||
|
||||
if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
|
||||
{
|
||||
@ -466,8 +466,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
|
||||
}
|
||||
|
||||
BASE_SCREEN::m_PageLayoutDescrFileName = fileName;
|
||||
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
|
||||
pglayout.SetPageLayout( fullFileName );
|
||||
DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( fullFileName );
|
||||
m_localPrjConfigChanged = true;
|
||||
}
|
||||
|
||||
@ -641,12 +640,12 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
|
||||
}
|
||||
|
||||
// Draw layout preview.
|
||||
KIGFX::WS_RENDER_SETTINGS renderSettings;
|
||||
KIGFX::DS_RENDER_SETTINGS renderSettings;
|
||||
COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings();
|
||||
COLOR4D bgColor = m_parent->GetDrawBgColor();
|
||||
wxString emptyString;
|
||||
|
||||
WS_DATA_MODEL::SetAltInstance( m_pagelayout );
|
||||
DS_DATA_MODEL::SetAltInstance( m_drawingSheet );
|
||||
{
|
||||
GRResetPenAndBrush( &memDC );
|
||||
renderSettings.SetDefaultPenWidth( 1 );
|
||||
@ -664,14 +663,14 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
|
||||
|
||||
GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor, bgColor );
|
||||
|
||||
PrintPageLayout( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
|
||||
m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(),
|
||||
wxEmptyString, m_screen->GetVirtualPageNumber() == 1 );
|
||||
PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
|
||||
m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(),
|
||||
wxEmptyString, m_screen->GetVirtualPageNumber() == 1 );
|
||||
|
||||
memDC.SelectObject( wxNullBitmap );
|
||||
m_PageLayoutExampleBitmap->SetBitmap( *m_pageBitmap );
|
||||
}
|
||||
WS_DATA_MODEL::SetAltInstance( NULL );
|
||||
DS_DATA_MODEL::SetAltInstance( NULL );
|
||||
|
||||
// Refresh the dialog.
|
||||
Layout();
|
||||
@ -787,7 +786,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 = WS_DATA_MODEL::MakeShortFileName( fileName, m_projectPath );
|
||||
wxString shortFileName = DS_DATA_MODEL::MakeShortFileName( fileName, m_projectPath );
|
||||
|
||||
// For Win/Linux/macOS compatibility, a relative path is a good idea
|
||||
if( shortFileName != GetWksFileName() && shortFileName != fileName )
|
||||
@ -806,10 +805,10 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
|
||||
|
||||
SetWksFileName( shortFileName );
|
||||
|
||||
if( m_pagelayout == NULL )
|
||||
m_pagelayout = new WS_DATA_MODEL;
|
||||
if( m_drawingSheet == NULL )
|
||||
m_drawingSheet = new DS_DATA_MODEL;
|
||||
|
||||
m_pagelayout->SetPageLayout( fileName );
|
||||
m_drawingSheet->LoadDrawingSheet( fileName );
|
||||
|
||||
GetPageLayoutInfoFromDialog();
|
||||
UpdatePageLayoutExample();
|
||||
|
@ -1,12 +1,8 @@
|
||||
/**
|
||||
* @file common/page_layout/page_layout_default_description.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -28,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/* keyword used in page layout description are listed
|
||||
* in page_layout_reader.keywords file
|
||||
* in drawing_sheet_reader.keywords file
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -116,15 +112,15 @@
|
||||
*/
|
||||
|
||||
|
||||
// height of the band reference grid 2.0 mm
|
||||
// drawing sheet frame reference text size 1.3 mm
|
||||
// height of the coordinates band 2.0 mm
|
||||
// coordinates text size 1.3 mm
|
||||
// default text size 1.5 mm
|
||||
// default line width 0.15 mm
|
||||
// frame ref pitch 50 mm
|
||||
|
||||
// Default page layout (sizes are in mm)
|
||||
extern const char defaultPageLayout[] =
|
||||
"(page_layout\n"
|
||||
extern const char defaultDrawingSheet[] =
|
||||
"(drawing_sheet\n"
|
||||
"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15)\n"
|
||||
"(left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10))\n"
|
||||
"(rect (comment \"rect around the title block\") (linewidth 0.15) (start 110 34) (end 2 2) )\n"
|
||||
@ -158,8 +154,8 @@ extern const char defaultPageLayout[] =
|
||||
"(line (start 26 8.5) (end 26 2) )\n"
|
||||
")\n";
|
||||
|
||||
extern const char emptyPageLayout[] =
|
||||
"(page_layout\n"
|
||||
extern const char emptyDrawingSheet[] =
|
||||
"(drawing_sheet\n"
|
||||
"(setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15)\n"
|
||||
"(left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10))\n"
|
||||
"(line (name segm1:Line) (start 0 0) (end 0 0))\n"
|
@ -1,14 +1,8 @@
|
||||
/**
|
||||
* @file common/page_layout/page_layout_reader.cpp
|
||||
* @brief read an S expression of description of graphic items and texts
|
||||
* to build a title block and page layout
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -31,11 +25,11 @@
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <locale_io.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <page_layout/page_layout_reader_lexer.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <drawing_sheet/drawing_sheet_reader_lexer.h>
|
||||
#include <wx/ffile.h>
|
||||
|
||||
#include <wx/file.h>
|
||||
@ -45,15 +39,15 @@
|
||||
using namespace TB_READER_T;
|
||||
|
||||
/**
|
||||
* PAGE_LAYOUT_READER_PARSER
|
||||
* DRAWING_SHEET_READER_PARSER
|
||||
* holds data and functions pertinent to parsing a S-expression file
|
||||
* for a WS_DATA_MODEL.
|
||||
* for a DS_DATA_MODEL.
|
||||
*/
|
||||
class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER
|
||||
class DRAWING_SHEET_READER_PARSER : public DRAWING_SHEET_READER_LEXER
|
||||
{
|
||||
public:
|
||||
PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource );
|
||||
void Parse( WS_DATA_MODEL* aLayout );
|
||||
DRAWING_SHEET_READER_PARSER( const char* aLine, const wxString& aSource );
|
||||
void Parse( DS_DATA_MODEL* aLayout );
|
||||
|
||||
private:
|
||||
|
||||
@ -73,44 +67,45 @@ private:
|
||||
*/
|
||||
double parseDouble();
|
||||
|
||||
void parseSetup( WS_DATA_MODEL* aLayout );
|
||||
void parseSetup( DS_DATA_MODEL* aLayout );
|
||||
|
||||
/**
|
||||
* parse a graphic item starting by "(line" or "(rect" and read parameters.
|
||||
*/
|
||||
void parseGraphic( WS_DATA_ITEM * aItem );
|
||||
void parseGraphic( DS_DATA_ITEM * aItem );
|
||||
|
||||
/**
|
||||
* parse a text item starting by "(tbtext" and read parameters.
|
||||
*/
|
||||
void parseText( WS_DATA_ITEM_TEXT * aItem );
|
||||
void parseText( DS_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( WS_DATA_ITEM_POLYGONS * aItem );
|
||||
void parsePolygon( DS_DATA_ITEM_POLYGONS * aItem );
|
||||
|
||||
/**
|
||||
* parse a list of corners starting by "( pts" and read coordinates.
|
||||
*/
|
||||
void parsePolyOutline( WS_DATA_ITEM_POLYGONS * aItem );
|
||||
void parsePolyOutline( DS_DATA_ITEM_POLYGONS * aItem );
|
||||
|
||||
|
||||
/**
|
||||
* parse a bitmap item starting by "( bitmap" and read parameters.
|
||||
*/
|
||||
void parseBitmap( WS_DATA_ITEM_BITMAP * aItem );
|
||||
void parseBitmap( DS_DATA_ITEM_BITMAP * aItem );
|
||||
|
||||
void parseCoordinate( POINT_COORD& aCoord);
|
||||
void readOption( WS_DATA_ITEM * aItem );
|
||||
void readPngdata( WS_DATA_ITEM_BITMAP * aItem );
|
||||
void readOption( DS_DATA_ITEM * aItem );
|
||||
void readPngdata( DS_DATA_ITEM_BITMAP * aItem );
|
||||
};
|
||||
|
||||
// PCB_PLOT_PARAMS_PARSER
|
||||
|
||||
PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ) :
|
||||
PAGE_LAYOUT_READER_LEXER( aLine, aSource )
|
||||
DRAWING_SHEET_READER_PARSER::DRAWING_SHEET_READER_PARSER( const char* aLine,
|
||||
const wxString& aSource ) :
|
||||
DRAWING_SHEET_READER_LEXER( aLine, aSource )
|
||||
{
|
||||
}
|
||||
|
||||
@ -189,9 +184,9 @@ wxString convertLegacyVariableRefs( const wxString& aTextbase )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::Parse( WS_DATA_MODEL* aLayout )
|
||||
void DRAWING_SHEET_READER_PARSER::Parse( DS_DATA_MODEL* aLayout )
|
||||
{
|
||||
WS_DATA_ITEM* item;
|
||||
DS_DATA_ITEM* item;
|
||||
LOCALE_IO toggle;
|
||||
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
@ -199,7 +194,7 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WS_DATA_MODEL* aLayout )
|
||||
if( token == T_LEFT )
|
||||
token = NextTok();
|
||||
|
||||
if( token == T_page_layout )
|
||||
if( token == T_page_layout || token == T_drawing_sheet )
|
||||
continue;
|
||||
|
||||
switch( token )
|
||||
@ -209,33 +204,33 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WS_DATA_MODEL* aLayout )
|
||||
break;
|
||||
|
||||
case T_line:
|
||||
item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_SEGMENT );
|
||||
item = new DS_DATA_ITEM( DS_DATA_ITEM::DS_SEGMENT );
|
||||
parseGraphic( item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
case T_rect:
|
||||
item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_RECT );
|
||||
item = new DS_DATA_ITEM( DS_DATA_ITEM::DS_RECT );
|
||||
parseGraphic( item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
case T_polygon:
|
||||
item = new WS_DATA_ITEM_POLYGONS();
|
||||
parsePolygon( (WS_DATA_ITEM_POLYGONS*) item );
|
||||
item = new DS_DATA_ITEM_POLYGONS();
|
||||
parsePolygon( (DS_DATA_ITEM_POLYGONS*) item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
case T_bitmap:
|
||||
item = new WS_DATA_ITEM_BITMAP( NULL );
|
||||
parseBitmap( (WS_DATA_ITEM_BITMAP*) item );
|
||||
item = new DS_DATA_ITEM_BITMAP( NULL );
|
||||
parseBitmap( (DS_DATA_ITEM_BITMAP*) item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
case T_tbtext:
|
||||
NeedSYMBOLorNUMBER();
|
||||
item = new WS_DATA_ITEM_TEXT( convertLegacyVariableRefs( FromUTF8() ) );
|
||||
parseText( (WS_DATA_ITEM_TEXT*) item );
|
||||
item = new DS_DATA_ITEM_TEXT( convertLegacyVariableRefs( FromUTF8() ) );
|
||||
parseText( (DS_DATA_ITEM_TEXT*) item );
|
||||
aLayout->Append( item );
|
||||
break;
|
||||
|
||||
@ -247,7 +242,7 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WS_DATA_MODEL* aLayout )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parseSetup( WS_DATA_MODEL* aLayout )
|
||||
void DRAWING_SHEET_READER_PARSER::parseSetup( DS_DATA_MODEL* aLayout )
|
||||
{
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
{
|
||||
@ -304,7 +299,7 @@ void PAGE_LAYOUT_READER_PARSER::parseSetup( WS_DATA_MODEL* aLayout )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WS_DATA_ITEM_POLYGONS * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::parsePolygon( DS_DATA_ITEM_POLYGONS * aItem )
|
||||
{
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
{
|
||||
@ -372,7 +367,7 @@ void PAGE_LAYOUT_READER_PARSER::parsePolygon( WS_DATA_ITEM_POLYGONS * aItem )
|
||||
aItem->SetBoundingBox();
|
||||
}
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WS_DATA_ITEM_POLYGONS * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::parsePolyOutline( DS_DATA_ITEM_POLYGONS * aItem )
|
||||
{
|
||||
DPOINT corner;
|
||||
|
||||
@ -398,7 +393,7 @@ void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WS_DATA_ITEM_POLYGONS * aItem
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WS_DATA_ITEM_BITMAP * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::parseBitmap( DS_DATA_ITEM_BITMAP * aItem )
|
||||
{
|
||||
BITMAP_BASE* image = new BITMAP_BASE;
|
||||
aItem->m_ImageBitmap = image;
|
||||
@ -460,7 +455,7 @@ void PAGE_LAYOUT_READER_PARSER::parseBitmap( WS_DATA_ITEM_BITMAP * aItem )
|
||||
}
|
||||
}
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::readPngdata( WS_DATA_ITEM_BITMAP * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::readPngdata( DS_DATA_ITEM_BITMAP * aItem )
|
||||
{
|
||||
std::string tmp;
|
||||
|
||||
@ -494,7 +489,7 @@ void PAGE_LAYOUT_READER_PARSER::readPngdata( WS_DATA_ITEM_BITMAP * aItem )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::readOption( WS_DATA_ITEM * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::readOption( DS_DATA_ITEM * aItem )
|
||||
{
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
{
|
||||
@ -508,7 +503,7 @@ void PAGE_LAYOUT_READER_PARSER::readOption( WS_DATA_ITEM * aItem )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WS_DATA_ITEM * aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::parseGraphic( DS_DATA_ITEM * aItem )
|
||||
{
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
{
|
||||
@ -578,7 +573,7 @@ void PAGE_LAYOUT_READER_PARSER::parseGraphic( WS_DATA_ITEM * aItem )
|
||||
}
|
||||
|
||||
|
||||
void PAGE_LAYOUT_READER_PARSER::parseText( WS_DATA_ITEM_TEXT* aItem )
|
||||
void DRAWING_SHEET_READER_PARSER::parseText( DS_DATA_ITEM_TEXT* aItem )
|
||||
{
|
||||
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
|
||||
{
|
||||
@ -717,7 +712,7 @@ void PAGE_LAYOUT_READER_PARSER::parseText( WS_DATA_ITEM_TEXT* aItem )
|
||||
}
|
||||
|
||||
// parse an expression like " 25 1 ltcorner)"
|
||||
void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
|
||||
void DRAWING_SHEET_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
|
||||
{
|
||||
aCoord.m_Pos.x = parseDouble();
|
||||
aCoord.m_Pos.y = parseDouble();
|
||||
@ -735,7 +730,7 @@ void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
|
||||
}
|
||||
}
|
||||
|
||||
int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax )
|
||||
int DRAWING_SHEET_READER_PARSER::parseInt( int aMin, int aMax )
|
||||
{
|
||||
T token = NextTok();
|
||||
|
||||
@ -753,7 +748,7 @@ int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax )
|
||||
}
|
||||
|
||||
|
||||
double PAGE_LAYOUT_READER_PARSER::parseDouble()
|
||||
double DRAWING_SHEET_READER_PARSER::parseDouble()
|
||||
{
|
||||
T token = NextTok();
|
||||
|
||||
@ -765,46 +760,42 @@ double PAGE_LAYOUT_READER_PARSER::parseDouble()
|
||||
return val;
|
||||
}
|
||||
|
||||
// defaultPageLayout is the default page layout description
|
||||
// using the S expr.
|
||||
// see page_layout_default_shape.cpp
|
||||
extern const char defaultPageLayout[];
|
||||
// defaultDrawingSheet is the default page layout description using the S expr.
|
||||
extern const char defaultDrawingSheet[];
|
||||
|
||||
void WS_DATA_MODEL::SetDefaultLayout()
|
||||
void DS_DATA_MODEL::SetDefaultLayout()
|
||||
{
|
||||
SetPageLayout( defaultPageLayout, false, wxT( "default page" ) );
|
||||
SetPageLayout( defaultDrawingSheet, false, wxT( "default page" ) );
|
||||
}
|
||||
|
||||
// Returns defaultPageLayout as a string;
|
||||
wxString WS_DATA_MODEL::DefaultLayout()
|
||||
// Returns defaultDrawingSheet as a string;
|
||||
wxString DS_DATA_MODEL::DefaultLayout()
|
||||
{
|
||||
return wxString( defaultPageLayout );
|
||||
return wxString( defaultDrawingSheet );
|
||||
}
|
||||
|
||||
// emptyPageLayout is a "empty" page layout description
|
||||
// emptyDrawingSheet is a "empty" page layout description using the S expr.
|
||||
// there is a 0 length line to fool something somewhere.
|
||||
// using the S expr.
|
||||
// see page_layout_empty_description.cpp
|
||||
extern const char emptyPageLayout[];
|
||||
extern const char emptyDrawingSheet[];
|
||||
|
||||
void WS_DATA_MODEL::SetEmptyLayout()
|
||||
void DS_DATA_MODEL::SetEmptyLayout()
|
||||
{
|
||||
SetPageLayout( emptyPageLayout, false, wxT( "empty page" ) );
|
||||
SetPageLayout( emptyDrawingSheet, false, wxT( "empty page" ) );
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DATA_MODEL::EmptyLayout()
|
||||
wxString DS_DATA_MODEL::EmptyLayout()
|
||||
{
|
||||
return wxString( emptyPageLayout );
|
||||
return wxString( emptyDrawingSheet );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::SetPageLayout( const char* aPageLayout, bool Append, const wxString& aSource )
|
||||
void DS_DATA_MODEL::SetPageLayout( const char* aPageLayout, bool Append, const wxString& aSource )
|
||||
{
|
||||
if( ! Append )
|
||||
ClearList();
|
||||
|
||||
PAGE_LAYOUT_READER_PARSER lp_parser( aPageLayout, wxT( "Sexpr_string" ) );
|
||||
DRAWING_SHEET_READER_PARSER lp_parser( aPageLayout, wxT( "Sexpr_string" ) );
|
||||
|
||||
try
|
||||
{
|
||||
@ -817,7 +808,7 @@ void WS_DATA_MODEL::SetPageLayout( const char* aPageLayout, bool Append, const w
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::SetPageLayout( const wxString& aFullFileName, bool Append )
|
||||
void DS_DATA_MODEL::LoadDrawingSheet( const wxString& aFullFileName, bool Append )
|
||||
{
|
||||
wxString fullFileName = aFullFileName;
|
||||
|
||||
@ -830,7 +821,7 @@ void WS_DATA_MODEL::SetPageLayout( const wxString& aFullFileName, bool Append )
|
||||
{
|
||||
#if 0
|
||||
if( !fullFileName.IsEmpty() )
|
||||
wxLogMessage( wxT( "Page layout file <%s> not found" ), fullFileName.GetData() );
|
||||
wxLogMessage( wxT( "Drawing sheet file <%s> not found" ), fullFileName.GetData() );
|
||||
#endif
|
||||
SetDefaultLayout();
|
||||
return;
|
||||
@ -858,7 +849,7 @@ void WS_DATA_MODEL::SetPageLayout( const wxString& aFullFileName, bool Append )
|
||||
if( ! Append )
|
||||
ClearList();
|
||||
|
||||
PAGE_LAYOUT_READER_PARSER pl_parser( buffer, fullFileName );
|
||||
DRAWING_SHEET_READER_PARSER pl_parser( buffer, fullFileName );
|
||||
|
||||
try
|
||||
{
|
@ -1,4 +1,5 @@
|
||||
page_layout
|
||||
drawing_sheet
|
||||
setup
|
||||
left_margin
|
||||
right_margin
|
@ -24,27 +24,27 @@
|
||||
|
||||
|
||||
/*
|
||||
* the class WS_DATA_ITEM (and derived) defines
|
||||
* the class DS_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 WS_DATA_ITEM coordinates units is the mm, and are relative to
|
||||
* the DS_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)
|
||||
* to a "draw list" (DS_DRAW_ITEM_BASE and derived items)
|
||||
|
||||
* The list of these items is stored in a WS_DATA_MODEL instance.
|
||||
* The list of these items is stored in a DS_DATA_MODEL instance.
|
||||
*
|
||||
* When building the draw list:
|
||||
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
|
||||
* the DS_DATA_MODEL is used to create a DS_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 WS_DATA_MODEL is created only once.
|
||||
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
|
||||
* the DS_DATA_MODEL is created only once.
|
||||
* the DS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
|
||||
*
|
||||
* the WS_DATA_MODEL instance is created from a S expression which
|
||||
* the DS_DATA_MODEL instance is created from a S expression which
|
||||
* describes the page layout (can be the default page layout or a custom file).
|
||||
*/
|
||||
|
||||
@ -53,17 +53,17 @@
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <view/view.h>
|
||||
#include <title_block.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <trigo.h>
|
||||
|
||||
using KIGFX::COLOR4D;
|
||||
|
||||
|
||||
// The constructor:
|
||||
WS_DATA_ITEM::WS_DATA_ITEM( WS_ITEM_TYPE aType )
|
||||
DS_DATA_ITEM::DS_DATA_ITEM( DS_ITEM_TYPE aType )
|
||||
{
|
||||
m_pageOption = ALL_PAGES;
|
||||
m_type = aType;
|
||||
@ -73,14 +73,14 @@ WS_DATA_ITEM::WS_DATA_ITEM( WS_ITEM_TYPE aType )
|
||||
}
|
||||
|
||||
|
||||
WS_DATA_ITEM::~WS_DATA_ITEM()
|
||||
DS_DATA_ITEM::~DS_DATA_ITEM()
|
||||
{
|
||||
for( WS_DRAW_ITEM_BASE* item : m_drawItems )
|
||||
for( DS_DRAW_ITEM_BASE* item : m_drawItems )
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
void DS_DATA_ITEM::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
{
|
||||
int pensize = GetPenSizeUi();
|
||||
|
||||
@ -88,7 +88,7 @@ void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aV
|
||||
pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
|
||||
|
||||
std::map<int, STATUS_FLAGS> itemFlags;
|
||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||
DS_DRAW_ITEM_BASE* item = nullptr;
|
||||
|
||||
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
||||
{
|
||||
@ -111,10 +111,10 @@ void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aV
|
||||
if( j && ! IsInsidePage( j ) )
|
||||
continue;
|
||||
|
||||
if( m_type == WS_SEGMENT )
|
||||
item = new WS_DRAW_ITEM_LINE( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
||||
else if( m_type == WS_RECT )
|
||||
item = new WS_DRAW_ITEM_RECT( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
||||
if( m_type == DS_SEGMENT )
|
||||
item = new DS_DRAW_ITEM_LINE( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
||||
else if( m_type == DS_RECT )
|
||||
item = new DS_DRAW_ITEM_RECT( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( "Unknown drawing sheet item type" );
|
||||
@ -133,9 +133,9 @@ void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aV
|
||||
}
|
||||
|
||||
|
||||
int WS_DATA_ITEM::GetPenSizeUi()
|
||||
int DS_DATA_ITEM::GetPenSizeUi()
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
if( m_LineWidth != 0 )
|
||||
return KiROUND( m_LineWidth * model.m_WSunits2Iu );
|
||||
@ -150,17 +150,17 @@ int WS_DATA_ITEM::GetPenSizeUi()
|
||||
// (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 WS_DATA_ITEM::MoveToUi( wxPoint aPosition )
|
||||
void DS_DATA_ITEM::MoveToUi( wxPoint aPosition )
|
||||
{
|
||||
DPOINT pos_mm;
|
||||
pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
|
||||
MoveTo( pos_mm );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM::MoveTo( DPOINT aPosition )
|
||||
void DS_DATA_ITEM::MoveTo( DPOINT aPosition )
|
||||
{
|
||||
DPOINT vector = aPosition - GetStartPos();
|
||||
DPOINT endpos = vector + GetEndPos();
|
||||
@ -168,7 +168,7 @@ void WS_DATA_ITEM::MoveTo( DPOINT aPosition )
|
||||
MoveStartPointTo( aPosition );
|
||||
MoveEndPointTo( endpos );
|
||||
|
||||
for( WS_DRAW_ITEM_BASE* drawItem : m_drawItems )
|
||||
for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
|
||||
{
|
||||
drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
|
||||
drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
|
||||
@ -179,9 +179,9 @@ void WS_DATA_ITEM::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 WS_DATA_ITEM::MoveStartPointTo( DPOINT aPosition )
|
||||
void DS_DATA_ITEM::MoveStartPointTo( DPOINT aPosition )
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
DPOINT position;
|
||||
|
||||
// Calculate the position of the starting point
|
||||
@ -215,10 +215,10 @@ void WS_DATA_ITEM::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 WS_DATA_ITEM::MoveStartPointToUi( wxPoint aPosition )
|
||||
void DS_DATA_ITEM::MoveStartPointToUi( wxPoint aPosition )
|
||||
{
|
||||
DPOINT pos_mm( aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
|
||||
aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
DPOINT pos_mm( aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
|
||||
aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
|
||||
MoveStartPointTo( pos_mm );
|
||||
}
|
||||
@ -230,9 +230,9 @@ void WS_DATA_ITEM::MoveStartPointToUi( wxPoint aPosition )
|
||||
* (segments and rectangles)
|
||||
* aPosition = the new position of the ending point, in mm
|
||||
*/
|
||||
void WS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
|
||||
void DS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
DPOINT position;
|
||||
|
||||
// Calculate the position of the starting point
|
||||
@ -262,8 +262,8 @@ void WS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
|
||||
// Modify m_End only for items having 2 coordinates
|
||||
switch( GetType() )
|
||||
{
|
||||
case WS_SEGMENT:
|
||||
case WS_RECT:
|
||||
case DS_SEGMENT:
|
||||
case DS_RECT:
|
||||
m_End.m_Pos = position;
|
||||
break;
|
||||
|
||||
@ -278,19 +278,19 @@ void WS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
|
||||
* (segments and rectangles)
|
||||
* aPosition = the new position of the ending point in graphic units
|
||||
*/
|
||||
void WS_DATA_ITEM::MoveEndPointToUi( wxPoint aPosition )
|
||||
void DS_DATA_ITEM::MoveEndPointToUi( wxPoint aPosition )
|
||||
{
|
||||
DPOINT pos_mm;
|
||||
pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
|
||||
MoveEndPointTo( pos_mm );
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WS_DATA_ITEM::GetStartPos( int ii ) const
|
||||
const DPOINT DS_DATA_ITEM::GetStartPos( int ii ) const
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
|
||||
m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
|
||||
|
||||
@ -319,14 +319,14 @@ const DPOINT WS_DATA_ITEM::GetStartPos( int ii ) const
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WS_DATA_ITEM::GetStartPosUi( int ii ) const
|
||||
const wxPoint DS_DATA_ITEM::GetStartPosUi( int ii ) const
|
||||
{
|
||||
DPOINT pos = GetStartPos( ii ) * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
DPOINT pos = GetStartPos( ii ) * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
|
||||
const DPOINT DS_DATA_ITEM::GetEndPos( int ii ) const
|
||||
{
|
||||
DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
|
||||
m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
|
||||
@ -334,21 +334,21 @@ const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
|
||||
switch( m_End.m_Anchor )
|
||||
{
|
||||
case RB_CORNER: // right bottom corner
|
||||
pos = WS_DATA_MODEL::GetTheInstance().m_RB_Corner - pos;
|
||||
pos = DS_DATA_MODEL::GetTheInstance().m_RB_Corner - pos;
|
||||
break;
|
||||
|
||||
case RT_CORNER: // right top corner
|
||||
pos.x = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
|
||||
pos.y = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
|
||||
pos.x = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
|
||||
pos.y = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
|
||||
break;
|
||||
|
||||
case LB_CORNER: // left bottom corner
|
||||
pos.x = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
|
||||
pos.y = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
|
||||
pos.x = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
|
||||
pos.y = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
|
||||
break;
|
||||
|
||||
case LT_CORNER: // left top corner
|
||||
pos = WS_DATA_MODEL::GetTheInstance().m_LT_Corner + pos;
|
||||
pos = DS_DATA_MODEL::GetTheInstance().m_LT_Corner + pos;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -356,17 +356,17 @@ const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WS_DATA_ITEM::GetEndPosUi( int ii ) const
|
||||
const wxPoint DS_DATA_ITEM::GetEndPosUi( int ii ) const
|
||||
{
|
||||
DPOINT pos = GetEndPos( ii );
|
||||
pos = pos * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos = pos * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
|
||||
}
|
||||
|
||||
|
||||
bool WS_DATA_ITEM::IsInsidePage( int ii ) const
|
||||
bool DS_DATA_ITEM::IsInsidePage( int ii ) const
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
DPOINT pos = GetStartPos( ii );
|
||||
|
||||
@ -385,34 +385,34 @@ bool WS_DATA_ITEM::IsInsidePage( int ii ) const
|
||||
}
|
||||
|
||||
|
||||
const wxString WS_DATA_ITEM::GetClassName() const
|
||||
const wxString DS_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_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
|
||||
case WS_BITMAP: name = wxT( "Image" ); break;
|
||||
case DS_TEXT: name = wxT( "Text" ); break;
|
||||
case DS_SEGMENT: name = wxT( "Line" ); break;
|
||||
case DS_RECT: name = wxT( "Rectangle" ); break;
|
||||
case DS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
|
||||
case DS_BITMAP: name = wxT( "Image" ); break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
WS_DATA_ITEM_POLYGONS::WS_DATA_ITEM_POLYGONS() :
|
||||
WS_DATA_ITEM( WS_POLYPOLYGON )
|
||||
DS_DATA_ITEM_POLYGONS::DS_DATA_ITEM_POLYGONS() :
|
||||
DS_DATA_ITEM( DS_POLYPOLYGON )
|
||||
{
|
||||
m_Orient = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_POLYGONS::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
void DS_DATA_ITEM_POLYGONS::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
{
|
||||
std::map<int, STATUS_FLAGS> itemFlags;
|
||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||
DS_DRAW_ITEM_BASE* item = nullptr;
|
||||
|
||||
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
||||
{
|
||||
@ -436,7 +436,7 @@ void WS_DATA_ITEM_POLYGONS::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX:
|
||||
continue;
|
||||
|
||||
int pensize = GetPenSizeUi();
|
||||
auto poly_shape = new WS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
|
||||
auto poly_shape = new DS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
|
||||
poly_shape->SetFlags( itemFlags[ j ] );
|
||||
m_drawItems.push_back( poly_shape );
|
||||
|
||||
@ -463,13 +463,13 @@ void WS_DATA_ITEM_POLYGONS::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX:
|
||||
}
|
||||
|
||||
|
||||
int WS_DATA_ITEM_POLYGONS::GetPenSizeUi()
|
||||
int DS_DATA_ITEM_POLYGONS::GetPenSizeUi()
|
||||
{
|
||||
return KiROUND( m_LineWidth * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
return KiROUND( m_LineWidth * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepeat ) const
|
||||
const DPOINT DS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepeat ) const
|
||||
{
|
||||
DPOINT pos = m_Corners[aIdx];
|
||||
|
||||
@ -480,7 +480,7 @@ const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepea
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_POLYGONS::SetBoundingBox()
|
||||
void DS_DATA_ITEM_POLYGONS::SetBoundingBox()
|
||||
{
|
||||
if( m_Corners.size() == 0 )
|
||||
{
|
||||
@ -514,9 +514,9 @@ void WS_DATA_ITEM_POLYGONS::SetBoundingBox()
|
||||
}
|
||||
|
||||
|
||||
bool WS_DATA_ITEM_POLYGONS::IsInsidePage( int ii ) const
|
||||
bool DS_DATA_ITEM_POLYGONS::IsInsidePage( int ii ) const
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
DPOINT pos = GetStartPos( ii );
|
||||
pos += m_minCoord; // left top pos of bounding box
|
||||
@ -534,16 +534,16 @@ bool WS_DATA_ITEM_POLYGONS::IsInsidePage( int ii ) const
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WS_DATA_ITEM_POLYGONS::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const
|
||||
const wxPoint DS_DATA_ITEM_POLYGONS::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const
|
||||
{
|
||||
DPOINT pos = GetCornerPosition( aIdx, aRepeat );
|
||||
pos = pos * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
pos = pos * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
||||
return wxPoint( int(pos.x), int(pos.y) );
|
||||
}
|
||||
|
||||
|
||||
WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
|
||||
WS_DATA_ITEM( WS_TEXT )
|
||||
DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
|
||||
DS_DATA_ITEM( DS_TEXT )
|
||||
{
|
||||
m_TextBase = aTextBase;
|
||||
m_IncrementLabel = 1;
|
||||
@ -556,13 +556,15 @@ WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
void DS_DATA_ITEM_TEXT::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
{
|
||||
int pensize = GetPenSizeUi();
|
||||
bool multilines = false;
|
||||
|
||||
if( WS_DATA_MODEL::GetTheInstance().m_EditMode )
|
||||
if( DS_DATA_MODEL::GetTheInstance().m_EditMode )
|
||||
{
|
||||
m_FullText = m_TextBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
|
||||
@ -575,18 +577,18 @@ void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
|
||||
SetConstrainedTextSize();
|
||||
wxSize textsize;
|
||||
|
||||
textsize.x = KiROUND( m_ConstrainedTextSize.x * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
textsize.y = KiROUND( m_ConstrainedTextSize.y * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
textsize.x = KiROUND( m_ConstrainedTextSize.x * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
textsize.y = KiROUND( m_ConstrainedTextSize.y * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
||||
|
||||
if( m_Bold )
|
||||
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
|
||||
|
||||
std::map<int, STATUS_FLAGS> itemFlags;
|
||||
WS_DRAW_ITEM_TEXT* text = nullptr;
|
||||
DS_DRAW_ITEM_TEXT* text = nullptr;
|
||||
|
||||
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
||||
{
|
||||
text = (WS_DRAW_ITEM_TEXT*) m_drawItems[ i ];
|
||||
text = (DS_DRAW_ITEM_TEXT*) m_drawItems[ i ];
|
||||
itemFlags[ i ] = text->GetFlags();
|
||||
|
||||
if( aCollector )
|
||||
@ -605,7 +607,7 @@ void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
|
||||
if( j > 0 && !IsInsidePage( j ) )
|
||||
continue;
|
||||
|
||||
text = new WS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
|
||||
text = new DS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
|
||||
m_Italic, m_Bold );
|
||||
text->SetFlags( itemFlags[ j ] );
|
||||
m_drawItems.push_back( text );
|
||||
@ -628,9 +630,9 @@ void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
|
||||
}
|
||||
|
||||
|
||||
int WS_DATA_ITEM_TEXT::GetPenSizeUi()
|
||||
int DS_DATA_ITEM_TEXT::GetPenSizeUi()
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
if( m_LineWidth != 0 )
|
||||
return KiROUND( m_LineWidth * model.m_WSunits2Iu );
|
||||
@ -639,7 +641,7 @@ int WS_DATA_ITEM_TEXT::GetPenSizeUi()
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_TEXT::IncrementLabel( int aIncr )
|
||||
void DS_DATA_ITEM_TEXT::IncrementLabel( int aIncr )
|
||||
{
|
||||
int last = m_TextBase.Len() -1;
|
||||
|
||||
@ -658,7 +660,7 @@ void WS_DATA_ITEM_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 WS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence()
|
||||
bool DS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence()
|
||||
{
|
||||
bool multiline = false;
|
||||
|
||||
@ -693,15 +695,15 @@ bool WS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence()
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
void DS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
{
|
||||
m_ConstrainedTextSize = m_TextSize;
|
||||
|
||||
if( m_ConstrainedTextSize.x == 0 )
|
||||
m_ConstrainedTextSize.x = WS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.x;
|
||||
m_ConstrainedTextSize.x = DS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.x;
|
||||
|
||||
if( m_ConstrainedTextSize.y == 0 )
|
||||
m_ConstrainedTextSize.y = WS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.y;
|
||||
m_ConstrainedTextSize.y = DS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.y;
|
||||
|
||||
if( m_BoundingBoxSize.x || m_BoundingBoxSize.y )
|
||||
{
|
||||
@ -714,8 +716,8 @@ void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
int linewidth = 0;
|
||||
size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
|
||||
size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
|
||||
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, 0, m_FullText, wxPoint( 0, 0 ),
|
||||
size_micron, linewidth, m_Italic, m_Bold ) );
|
||||
DS_DRAW_ITEM_TEXT dummy( DS_DRAW_ITEM_TEXT( this, 0, m_FullText, wxPoint( 0, 0 ),
|
||||
size_micron, linewidth, m_Italic, m_Bold ) );
|
||||
dummy.SetMultilineAllowed( true );
|
||||
dummy.SetHorizJustify( m_Hjustify ) ;
|
||||
dummy.SetVertJustify( m_Vjustify );
|
||||
@ -735,10 +737,10 @@ void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
void DS_DATA_ITEM_BITMAP::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
||||
{
|
||||
std::map<int, STATUS_FLAGS> itemFlags;
|
||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||
DS_DRAW_ITEM_BASE* item = nullptr;
|
||||
|
||||
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
||||
{
|
||||
@ -767,7 +769,7 @@ void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::V
|
||||
if( j && !IsInsidePage( j ) )
|
||||
continue;
|
||||
|
||||
WS_DRAW_ITEM_BITMAP* bitmap = new WS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) );
|
||||
DS_DRAW_ITEM_BITMAP* bitmap = new DS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) );
|
||||
|
||||
bitmap->SetFlags( itemFlags[ j ] );
|
||||
m_drawItems.push_back( bitmap );
|
||||
@ -781,7 +783,7 @@ void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::V
|
||||
}
|
||||
|
||||
|
||||
int WS_DATA_ITEM_BITMAP::GetPPI() const
|
||||
int DS_DATA_ITEM_BITMAP::GetPPI() const
|
||||
{
|
||||
if( m_ImageBitmap )
|
||||
return m_ImageBitmap->GetPPI() / m_ImageBitmap->GetScale();
|
||||
@ -790,7 +792,7 @@ int WS_DATA_ITEM_BITMAP::GetPPI() const
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_ITEM_BITMAP::SetPPI( int aBitmapPPI )
|
||||
void DS_DATA_ITEM_BITMAP::SetPPI( int aBitmapPPI )
|
||||
{
|
||||
if( m_ImageBitmap )
|
||||
m_ImageBitmap->SetScale( (double) m_ImageBitmap->GetPPI() / aBitmapPPI );
|
@ -26,40 +26,39 @@
|
||||
|
||||
/*
|
||||
* The WS_DATA_ITEM_* classes define the basic shapes of a drawing sheet (frame references
|
||||
* and title block). The list of these items is stored in a WS_DATA_MODEL instance.
|
||||
* and title block). The list of these items is stored in a DS_DATA_MODEL instance.
|
||||
*
|
||||
* These items cannot be drawn or plotetd "as is". They must be converted to WS_DRAW_*
|
||||
* types. When building the draw list:
|
||||
* - the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
|
||||
* - the DS_DATA_MODEL is used to create a DS_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 WS_DATA_MODEL is created only once.
|
||||
* The DS_DATA_MODEL is created only once.
|
||||
* The WS_DRAW_ITEM_*s are created and maintained by the PlEditor, but are created each time
|
||||
* they're needed for drawing by the clients (Eeschema, Pcbnew, etc.)
|
||||
*
|
||||
* The WS_DATA_MODEL instance is created from a S expression which describes the page
|
||||
* The DS_DATA_MODEL instance is created from a S expression which describes the page
|
||||
* layout (can be the default page layout or a custom file). This format is also used
|
||||
* for undo/redo storage (wrapped in a WS_PROXY_UNDO_ITEM).
|
||||
* for undo/redo storage (wrapped in a DS_PROXY_UNDO_ITEM).
|
||||
*/
|
||||
|
||||
#include <kiface_i.h>
|
||||
#include <title_block.h>
|
||||
#include <common.h>
|
||||
#include <eda_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
|
||||
|
||||
// The layout shape used in the application
|
||||
// It is accessible by WS_DATA_MODEL::GetTheInstance()
|
||||
static WS_DATA_MODEL wksTheInstance;
|
||||
static WS_DATA_MODEL* wksAltInstance;
|
||||
// It is accessible by DS_DATA_MODEL::GetTheInstance()
|
||||
static DS_DATA_MODEL wksTheInstance;
|
||||
static DS_DATA_MODEL* wksAltInstance;
|
||||
|
||||
WS_DATA_MODEL::WS_DATA_MODEL() :
|
||||
DS_DATA_MODEL::DS_DATA_MODEL() :
|
||||
m_WSunits2Iu( 1000.0 ),
|
||||
m_DefaultLineWidth( 0.0 ),
|
||||
m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE ),
|
||||
@ -73,10 +72,10 @@ WS_DATA_MODEL::WS_DATA_MODEL() :
|
||||
m_bottomMargin = 10.0; // the bottom page margin in mm
|
||||
}
|
||||
|
||||
/* static function: returns the instance of WS_DATA_MODEL
|
||||
* used in the application
|
||||
/*
|
||||
* static function: returns the instance of DS_DATA_MODEL used in the application
|
||||
*/
|
||||
WS_DATA_MODEL& WS_DATA_MODEL::GetTheInstance()
|
||||
DS_DATA_MODEL& DS_DATA_MODEL::GetTheInstance()
|
||||
{
|
||||
if( wksAltInstance )
|
||||
return *wksAltInstance;
|
||||
@ -85,18 +84,18 @@ WS_DATA_MODEL& WS_DATA_MODEL::GetTheInstance()
|
||||
}
|
||||
|
||||
/**
|
||||
* static function: Set an alternate instance of WS_DATA_MODEL
|
||||
* static function: Set an alternate instance of DS_DATA_MODEL
|
||||
* mainly used in page setting dialog
|
||||
* @param aLayout = the alternate page layout.
|
||||
* if null, restore the basic page layout
|
||||
*/
|
||||
void WS_DATA_MODEL::SetAltInstance( WS_DATA_MODEL* aLayout )
|
||||
void DS_DATA_MODEL::SetAltInstance( DS_DATA_MODEL* aLayout )
|
||||
{
|
||||
wksAltInstance = aLayout;
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU )
|
||||
void DS_DATA_MODEL::SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU )
|
||||
{
|
||||
#define MILS_TO_MM (25.4/1000)
|
||||
|
||||
@ -116,29 +115,29 @@ void WS_DATA_MODEL::SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMi
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::ClearList()
|
||||
void DS_DATA_MODEL::ClearList()
|
||||
{
|
||||
for( WS_DATA_ITEM* item : m_list )
|
||||
for( DS_DATA_ITEM* item : m_list )
|
||||
delete item;
|
||||
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::Append( WS_DATA_ITEM* aItem )
|
||||
void DS_DATA_MODEL::Append( DS_DATA_ITEM* aItem )
|
||||
{
|
||||
m_list.push_back( aItem );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::Remove( WS_DATA_ITEM* aItem )
|
||||
void DS_DATA_MODEL::Remove( DS_DATA_ITEM* aItem )
|
||||
{
|
||||
auto newEnd = std::remove( m_list.begin(), m_list.end(), aItem );
|
||||
m_list.erase( newEnd, m_list.end() );
|
||||
}
|
||||
|
||||
|
||||
int WS_DATA_MODEL::GetItemIndex( WS_DATA_ITEM* aItem ) const
|
||||
int DS_DATA_MODEL::GetItemIndex( DS_DATA_ITEM* aItem ) const
|
||||
{
|
||||
unsigned idx = 0;
|
||||
while( idx < m_list.size() )
|
||||
@ -154,7 +153,7 @@ int WS_DATA_MODEL::GetItemIndex( WS_DATA_ITEM* aItem ) const
|
||||
|
||||
/* return the item from its index aIdx, or NULL if does not exist
|
||||
*/
|
||||
WS_DATA_ITEM* WS_DATA_MODEL::GetItem( unsigned aIdx ) const
|
||||
DS_DATA_ITEM* DS_DATA_MODEL::GetItem( unsigned aIdx ) const
|
||||
{
|
||||
if( aIdx < m_list.size() )
|
||||
return m_list[aIdx];
|
||||
@ -163,7 +162,7 @@ WS_DATA_ITEM* WS_DATA_MODEL::GetItem( unsigned aIdx ) const
|
||||
}
|
||||
|
||||
|
||||
const wxString WS_DATA_MODEL::MakeShortFileName( const wxString& aFullFileName,
|
||||
const wxString DS_DATA_MODEL::MakeShortFileName( const wxString& aFullFileName,
|
||||
const wxString& aProjectPath )
|
||||
{
|
||||
wxString shortFileName = aFullFileName;
|
||||
@ -192,7 +191,7 @@ const wxString WS_DATA_MODEL::MakeShortFileName( const wxString& aFullFileName,
|
||||
}
|
||||
|
||||
|
||||
const wxString WS_DATA_MODEL::MakeFullFileName( const wxString& aShortFileName,
|
||||
const wxString DS_DATA_MODEL::MakeFullFileName( const wxString& aShortFileName,
|
||||
const wxString& aProjectPath )
|
||||
{
|
||||
wxString fullFileName = ExpandEnvVarSubstitutions( aShortFileName, nullptr );
|
@ -1,9 +1,3 @@
|
||||
/**
|
||||
* @file page_layout_writer.cpp
|
||||
* @brief write an S expression of description of graphic items and texts
|
||||
* to build a title block and page layout
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
@ -33,12 +27,12 @@
|
||||
#include <eda_item.h>
|
||||
#include <locale_io.h>
|
||||
#include <macros.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <math/vector2d.h>
|
||||
#include <page_layout/page_layout_reader_lexer.h>
|
||||
#include <drawing_sheet/drawing_sheet_reader_lexer.h>
|
||||
#include <convert_to_biu.h>
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
@ -50,46 +44,45 @@ using namespace TB_READER_T;
|
||||
// A helper function to write tokens:
|
||||
static const char* getTokenName( T aTok )
|
||||
{
|
||||
return PAGE_LAYOUT_READER_LEXER::TokenName( aTok );
|
||||
return DRAWING_SHEET_READER_LEXER::TokenName( aTok );
|
||||
}
|
||||
|
||||
// A basic helper class to write a page layout description
|
||||
// Not used alone, a file writer or a string writer should be
|
||||
// derived to use it
|
||||
// Therefore the constructor is protected
|
||||
class WS_DATA_MODEL_IO
|
||||
// Not used alone, a file writer or a string writer should be derived to use it.
|
||||
// Therefore the constructor is protected.
|
||||
class DS_DATA_MODEL_IO
|
||||
{
|
||||
protected:
|
||||
OUTPUTFORMATTER* m_out;
|
||||
|
||||
WS_DATA_MODEL_IO() { m_out = NULL; }
|
||||
virtual ~WS_DATA_MODEL_IO() {}
|
||||
DS_DATA_MODEL_IO() { m_out = NULL; }
|
||||
virtual ~DS_DATA_MODEL_IO() {}
|
||||
|
||||
public:
|
||||
void Format( WS_DATA_MODEL* aModel ) const;
|
||||
void Format( DS_DATA_MODEL* aModel ) const;
|
||||
|
||||
void Format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int aNestLevel ) const;
|
||||
void Format( DS_DATA_MODEL* aModel, DS_DATA_ITEM* aItem, int aNestLevel ) const;
|
||||
|
||||
private:
|
||||
void format( WS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const;
|
||||
void format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int aNestLevel ) const;
|
||||
void format( WS_DATA_ITEM_POLYGONS* aItem, int aNestLevel )
|
||||
void format( DS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const;
|
||||
void format( DS_DATA_MODEL* aModel, DS_DATA_ITEM* aItem, int aNestLevel ) const;
|
||||
void format( DS_DATA_ITEM_POLYGONS* aItem, int aNestLevel )
|
||||
const;
|
||||
void format( WS_DATA_ITEM_BITMAP* aItem, int aNestLevel ) const;
|
||||
void format( DS_DATA_ITEM_BITMAP* aItem, int aNestLevel ) const;
|
||||
void formatCoordinate( const char * aToken, POINT_COORD & aCoord ) const;
|
||||
void formatRepeatParameters( WS_DATA_ITEM* aItem ) const;
|
||||
void formatOptions( WS_DATA_ITEM* aItem ) const;
|
||||
void formatRepeatParameters( DS_DATA_ITEM* aItem ) const;
|
||||
void formatOptions( DS_DATA_ITEM* aItem ) const;
|
||||
};
|
||||
|
||||
|
||||
// A helper class to write a page layout description to a file
|
||||
class WS_DATA_MODEL_FILEIO: public WS_DATA_MODEL_IO
|
||||
class DS_DATA_MODEL_FILEIO : public DS_DATA_MODEL_IO
|
||||
{
|
||||
FILE_OUTPUTFORMATTER * m_fileout;
|
||||
|
||||
public:
|
||||
WS_DATA_MODEL_FILEIO( const wxString& aFilename ):
|
||||
WS_DATA_MODEL_IO()
|
||||
DS_DATA_MODEL_FILEIO( const wxString& aFilename ) :
|
||||
DS_DATA_MODEL_IO()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -102,7 +95,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~WS_DATA_MODEL_FILEIO()
|
||||
~DS_DATA_MODEL_FILEIO()
|
||||
{
|
||||
delete m_fileout;
|
||||
}
|
||||
@ -110,14 +103,14 @@ public:
|
||||
|
||||
|
||||
// A helper class to write a page layout description to a string
|
||||
class WS_DATA_MODEL_STRINGIO: public WS_DATA_MODEL_IO
|
||||
class DS_DATA_MODEL_STRINGIO : public DS_DATA_MODEL_IO
|
||||
{
|
||||
STRING_FORMATTER * m_writer;
|
||||
wxString & m_output;
|
||||
|
||||
public:
|
||||
WS_DATA_MODEL_STRINGIO( wxString& aOutputString ):
|
||||
WS_DATA_MODEL_IO(), m_output( aOutputString )
|
||||
DS_DATA_MODEL_STRINGIO( wxString& aOutputString ) :
|
||||
DS_DATA_MODEL_IO(), m_output( aOutputString )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -130,7 +123,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~WS_DATA_MODEL_STRINGIO()
|
||||
~DS_DATA_MODEL_STRINGIO()
|
||||
{
|
||||
m_output = FROM_UTF8( m_writer->GetString().c_str() );
|
||||
delete m_writer;
|
||||
@ -141,52 +134,52 @@ public:
|
||||
/*
|
||||
* Save the description in a file
|
||||
*/
|
||||
void WS_DATA_MODEL::Save( const wxString& aFullFileName )
|
||||
void DS_DATA_MODEL::Save( const wxString& aFullFileName )
|
||||
{
|
||||
WS_DATA_MODEL_FILEIO writer( aFullFileName );
|
||||
DS_DATA_MODEL_FILEIO writer( aFullFileName );
|
||||
writer.Format( this );
|
||||
}
|
||||
|
||||
|
||||
/* Save the description in a buffer
|
||||
*/
|
||||
void WS_DATA_MODEL::SaveInString( wxString& aOutputString )
|
||||
void DS_DATA_MODEL::SaveInString( wxString& aOutputString )
|
||||
{
|
||||
WS_DATA_MODEL_STRINGIO writer( aOutputString );
|
||||
DS_DATA_MODEL_STRINGIO writer( aOutputString );
|
||||
writer.Format( this );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL::SaveInString( std::vector<WS_DATA_ITEM*> aItemsList, wxString& aOutputString )
|
||||
void DS_DATA_MODEL::SaveInString( std::vector<DS_DATA_ITEM*> aItemsList, wxString& aOutputString )
|
||||
{
|
||||
WS_DATA_MODEL_STRINGIO writer( aOutputString );
|
||||
DS_DATA_MODEL_STRINGIO writer( aOutputString );
|
||||
|
||||
LOCALE_IO toggle; // switch on/off the locale "C" notation
|
||||
|
||||
for( WS_DATA_ITEM* item : aItemsList )
|
||||
for( DS_DATA_ITEM* item : aItemsList )
|
||||
writer.Format( this, item, 0 );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::Format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int aNestLevel ) const
|
||||
void DS_DATA_MODEL_IO::Format( DS_DATA_MODEL* aModel, DS_DATA_ITEM* aItem, int aNestLevel ) const
|
||||
{
|
||||
switch( aItem->GetType() )
|
||||
{
|
||||
case WS_DATA_ITEM::WS_TEXT:
|
||||
format( (WS_DATA_ITEM_TEXT*) aItem, aNestLevel );
|
||||
case DS_DATA_ITEM::DS_TEXT:
|
||||
format( (DS_DATA_ITEM_TEXT*) aItem, aNestLevel );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_SEGMENT:
|
||||
case WS_DATA_ITEM::WS_RECT:
|
||||
case DS_DATA_ITEM::DS_SEGMENT:
|
||||
case DS_DATA_ITEM::DS_RECT:
|
||||
format( aModel, aItem, aNestLevel );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_POLYPOLYGON:
|
||||
format( (WS_DATA_ITEM_POLYGONS*) aItem, aNestLevel );
|
||||
case DS_DATA_ITEM::DS_POLYPOLYGON:
|
||||
format( (DS_DATA_ITEM_POLYGONS*) aItem, aNestLevel );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_BITMAP:
|
||||
format( (WS_DATA_ITEM_BITMAP*) aItem, aNestLevel );
|
||||
case DS_DATA_ITEM::DS_BITMAP:
|
||||
format( (DS_DATA_ITEM_BITMAP*) aItem, aNestLevel );
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -195,11 +188,11 @@ void WS_DATA_MODEL_IO::Format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int a
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::Format( WS_DATA_MODEL* aPageLayout ) const
|
||||
void DS_DATA_MODEL_IO::Format( DS_DATA_MODEL* aPageLayout ) const
|
||||
{
|
||||
LOCALE_IO toggle; // switch on/off the locale "C" notation
|
||||
|
||||
m_out->Print( 0, "(page_layout\n" );
|
||||
m_out->Print( 0, "(drawing_sheet\n" );
|
||||
|
||||
// Setup
|
||||
int nestLevel = 1;
|
||||
@ -228,7 +221,7 @@ void WS_DATA_MODEL_IO::Format( WS_DATA_MODEL* aPageLayout ) const
|
||||
// Save the graphical items on the page layout
|
||||
for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ )
|
||||
{
|
||||
WS_DATA_ITEM* item = aPageLayout->GetItem( ii );
|
||||
DS_DATA_ITEM* item = aPageLayout->GetItem( ii );
|
||||
Format( aPageLayout, item, nestLevel );
|
||||
}
|
||||
|
||||
@ -236,7 +229,7 @@ void WS_DATA_MODEL_IO::Format( WS_DATA_MODEL* aPageLayout ) const
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
|
||||
void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
|
||||
{
|
||||
m_out->Print( aNestLevel, "(%s", getTokenName( T_tbtext ) );
|
||||
m_out->Print( 0, " %s", m_out->Quotew( aItem->m_TextBase ).c_str() );
|
||||
@ -316,9 +309,9 @@ void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
void WS_DATA_MODEL_IO::format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int aNestLevel ) const
|
||||
void DS_DATA_MODEL_IO::format( DS_DATA_MODEL* aModel, DS_DATA_ITEM* aItem, int aNestLevel ) const
|
||||
{
|
||||
if( aItem->GetType() == WS_DATA_ITEM::WS_RECT )
|
||||
if( aItem->GetType() == DS_DATA_ITEM::DS_RECT )
|
||||
m_out->Print( aNestLevel, "(%s", getTokenName( T_rect ) );
|
||||
else
|
||||
m_out->Print( aNestLevel, "(%s", getTokenName( T_line ) );
|
||||
@ -339,7 +332,7 @@ void WS_DATA_MODEL_IO::format( WS_DATA_MODEL* aModel, WS_DATA_ITEM* aItem, int a
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_POLYGONS* aItem, int aNestLevel ) const
|
||||
void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_POLYGONS* aItem, int aNestLevel ) const
|
||||
{
|
||||
m_out->Print( aNestLevel, "(%s", getTokenName( T_polygon ) );
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_name ),
|
||||
@ -389,7 +382,7 @@ void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_POLYGONS* aItem, int aNestLevel ) co
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_BITMAP* aItem, int aNestLevel ) const
|
||||
void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_BITMAP* aItem, int aNestLevel ) const
|
||||
{
|
||||
m_out->Print( aNestLevel, "(%s", getTokenName( T_bitmap ) );
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_name ),
|
||||
@ -417,8 +410,8 @@ void WS_DATA_MODEL_IO::format( WS_DATA_ITEM_BITMAP* aItem, int aNestLevel ) cons
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::formatCoordinate( const char * aToken,
|
||||
POINT_COORD & aCoord ) const
|
||||
void DS_DATA_MODEL_IO::formatCoordinate( const char * aToken,
|
||||
POINT_COORD & aCoord ) const
|
||||
{
|
||||
m_out->Print( 0, " (%s %s %s", aToken,
|
||||
double2Str( aCoord.m_Pos.x ).c_str(),
|
||||
@ -436,7 +429,7 @@ void WS_DATA_MODEL_IO::formatCoordinate( const char * aToken,
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::formatRepeatParameters( WS_DATA_ITEM* aItem ) const
|
||||
void DS_DATA_MODEL_IO::formatRepeatParameters( DS_DATA_ITEM* aItem ) const
|
||||
{
|
||||
if( aItem->m_RepeatCount <= 1 )
|
||||
return;
|
||||
@ -449,12 +442,12 @@ void WS_DATA_MODEL_IO::formatRepeatParameters( WS_DATA_ITEM* aItem ) const
|
||||
if( aItem->m_IncrementVector.y )
|
||||
m_out->Print( 0, " (incry %s)", double2Str( aItem->m_IncrementVector.y ).c_str() );
|
||||
|
||||
if( aItem->m_IncrementLabel != 1 && aItem->GetType() == WS_DATA_ITEM::WS_TEXT )
|
||||
if( aItem->m_IncrementLabel != 1 && aItem->GetType() == DS_DATA_ITEM::DS_TEXT )
|
||||
m_out->Print( 0, " (incrlabel %d)", aItem->m_IncrementLabel );
|
||||
}
|
||||
|
||||
|
||||
void WS_DATA_MODEL_IO::formatOptions( WS_DATA_ITEM* aItem ) const
|
||||
void DS_DATA_MODEL_IO::formatOptions( DS_DATA_ITEM* aItem ) const
|
||||
{
|
||||
if( aItem->GetPage1Option() == FIRST_PAGE_ONLY )
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_option ), getTokenName(T_page1only ) );
|
@ -24,36 +24,35 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* the class WS_DATA_ITEM (and WS_DATA_ITEM_TEXT) defines
|
||||
* the class DS_DATA_ITEM (and DS_DATA_ITEM_TEXT) defines
|
||||
* a basic shape of a page layout ( frame references and title block )
|
||||
* Basic shapes are line, rect and texts
|
||||
* the WS_DATA_ITEM coordinates units is the mm, and are relative to
|
||||
* the DS_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)
|
||||
* to a "draw list" (DS_DRAW_ITEM_BASE and derived items)
|
||||
|
||||
* The list of these items is stored in a WS_DATA_MODEL instance.
|
||||
* The list of these items is stored in a DS_DATA_MODEL instance.
|
||||
*
|
||||
* When building the draw list:
|
||||
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
|
||||
* the DS_DATA_MODEL is used to create a DS_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 WS_DATA_MODEL is created only once.
|
||||
* the WS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
|
||||
* the DS_DATA_MODEL is created only once.
|
||||
* the DS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
|
||||
*
|
||||
* the WS_DATA_MODEL instance is created from a S expression which
|
||||
* the DS_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 <eda_rect.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <fill_type.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <base_units.h>
|
||||
#include <page_info.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
@ -63,13 +62,13 @@
|
||||
|
||||
// ============================ BASE CLASS ==============================
|
||||
|
||||
void WS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
void DS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
|
||||
WS_DATA_ITEM* dataItem = GetPeer();
|
||||
DS_DATA_ITEM* dataItem = GetPeer();
|
||||
|
||||
if( !dataItem ) // No peer: this item is like a WS_DRAW_ITEM_PAGE
|
||||
if( !dataItem ) // No peer: this item is like a DS_DRAW_ITEM_PAGE
|
||||
{
|
||||
aLayers[0] = LAYER_DRAWINGSHEET;
|
||||
return;
|
||||
@ -85,7 +84,7 @@ void WS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
|
||||
|
||||
// A generic HitTest that can be used by some, but not all, sub-classes.
|
||||
bool WS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT sel = aRect;
|
||||
|
||||
@ -99,10 +98,10 @@ bool WS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAc
|
||||
}
|
||||
|
||||
|
||||
void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
|
||||
void DS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
|
||||
{
|
||||
wxString msg;
|
||||
WS_DATA_ITEM* dataItem = GetPeer();
|
||||
DS_DATA_ITEM* dataItem = GetPeer();
|
||||
|
||||
if( dataItem == nullptr ) // Is only a pure graphic item used in drawing sheet editor to
|
||||
// handle the page limits
|
||||
@ -110,24 +109,24 @@ void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS
|
||||
|
||||
switch( dataItem->GetType() )
|
||||
{
|
||||
case WS_DATA_ITEM::WS_SEGMENT:
|
||||
case DS_DATA_ITEM::DS_SEGMENT:
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Line" ), msg ) );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_RECT:
|
||||
case DS_DATA_ITEM::DS_RECT:
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Rectangle" ), msg ) );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_TEXT:
|
||||
msg = static_cast<WS_DRAW_ITEM_TEXT*>( this )->GetShownText();
|
||||
case DS_DATA_ITEM::DS_TEXT:
|
||||
msg = static_cast<DS_DRAW_ITEM_TEXT*>( this )->GetShownText();
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Text" ), msg ) );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_POLYPOLYGON:
|
||||
case DS_DATA_ITEM::DS_POLYPOLYGON:
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Imported Shape" ), msg ) );
|
||||
break;
|
||||
|
||||
case WS_DATA_ITEM::WS_BITMAP:
|
||||
case DS_DATA_ITEM::DS_BITMAP:
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Image" ), msg ) );
|
||||
break;
|
||||
}
|
||||
@ -159,45 +158,46 @@ void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS
|
||||
|
||||
// ============================ TEXT ==============================
|
||||
|
||||
void WS_DRAW_ITEM_TEXT::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
void DS_DRAW_ITEM_TEXT::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
Print( aSettings, aOffset, aSettings->GetLayerColor( LAYER_DRAWINGSHEET ), FILLED );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_TEXT::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_TEXT::GetBoundingBox() const
|
||||
{
|
||||
return EDA_TEXT::GetTextBox();
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
return EDA_TEXT::TextHitTest( aPosition, aAccuracy );
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
|
||||
{
|
||||
return EDA_TEXT::TextHitTest( aRect, aContains, aAccuracy );
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return wxString::Format( _( "Text '%s'" ),
|
||||
GetShownText() );
|
||||
}
|
||||
|
||||
|
||||
void WS_DRAW_ITEM_TEXT::SetTextAngle( double aAngle )
|
||||
void DS_DRAW_ITEM_TEXT::SetTextAngle( double aAngle )
|
||||
{
|
||||
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
|
||||
}
|
||||
|
||||
// ============================ POLYGON =================================
|
||||
|
||||
void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
void DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( const RENDER_SETTINGS* aSettings,
|
||||
const wxPoint& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
|
||||
@ -222,7 +222,7 @@ void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( const RENDER_SETTINGS* aSettings, c
|
||||
}
|
||||
|
||||
|
||||
void WS_DRAW_ITEM_POLYPOLYGONS::SetPosition( const wxPoint& aPos )
|
||||
void DS_DRAW_ITEM_POLYPOLYGONS::SetPosition( const wxPoint& aPos )
|
||||
{
|
||||
// Note: m_pos is the anchor point of the shape.
|
||||
wxPoint move_vect = aPos - m_pos;
|
||||
@ -233,7 +233,7 @@ void WS_DRAW_ITEM_POLYPOLYGONS::SetPosition( const wxPoint& aPos )
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT rect;
|
||||
BOX2I box = m_Polygons.BBox();
|
||||
@ -247,13 +247,13 @@ const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_POLYPOLYGONS::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
return m_Polygons.Collide( aPosition, aAccuracy );
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_POLYPOLYGONS::HitTest( const EDA_RECT& aRect, bool aContained,
|
||||
bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const EDA_RECT& aRect, bool aContained,
|
||||
int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT sel = aRect;
|
||||
@ -293,7 +293,7 @@ bool WS_DRAW_ITEM_POLYPOLYGONS::HitTest( const EDA_RECT& aRect, bool aContained,
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return wxString::Format( _( "Imported Shape" ) );
|
||||
}
|
||||
@ -301,7 +301,7 @@ wxString WS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============================ RECT ==============================
|
||||
|
||||
void WS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
void DS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
|
||||
@ -312,13 +312,13 @@ void WS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxP
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_RECT::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_RECT::GetBoundingBox() const
|
||||
{
|
||||
return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) );
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
int dist = aAccuracy + ( GetPenWidth() / 2 );
|
||||
wxPoint start = GetStart();
|
||||
@ -352,7 +352,7 @@ bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT sel = aRect;
|
||||
|
||||
@ -363,7 +363,7 @@ bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAc
|
||||
return sel.Contains( GetBoundingBox() );
|
||||
|
||||
// For greedy we need to check each side of the rect as we're pretty much always inside the
|
||||
// rect which defines the drawing sheet frame.
|
||||
// rect which defines the drawing-sheet frame.
|
||||
EDA_RECT side = GetBoundingBox();
|
||||
side.SetHeight( 0 );
|
||||
|
||||
@ -390,7 +390,7 @@ bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAc
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return wxString::Format( _( "Rectangle, width %s height %s" ),
|
||||
MessageTextFromValue( aUnits, std::abs( GetStart().x - GetEnd().x ) ),
|
||||
@ -400,7 +400,7 @@ wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============================ LINE ==============================
|
||||
|
||||
void WS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
void DS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
|
||||
@ -410,20 +410,20 @@ void WS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxP
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_LINE::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_LINE::GetBoundingBox() const
|
||||
{
|
||||
return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) );
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
int mindist = aAccuracy + ( GetPenWidth() / 2 ) + 1;
|
||||
return TestSegmentHit( aPosition, GetStart(), GetEnd(), mindist );
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return wxString::Format( _( "Line, length %s" ),
|
||||
MessageTextFromValue( aUnits, EuclideanNorm( GetStart() - GetEnd() ) ) );
|
||||
@ -432,9 +432,9 @@ wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
|
||||
// ============== BITMAP ================
|
||||
|
||||
void WS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
void DS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
|
||||
{
|
||||
WS_DATA_ITEM_BITMAP* bitmap = (WS_DATA_ITEM_BITMAP*) GetPeer();
|
||||
DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) GetPeer();
|
||||
|
||||
if( !bitmap->m_ImageBitmap )
|
||||
return;
|
||||
@ -443,9 +443,9 @@ void WS_DRAW_ITEM_BITMAP::PrintWsItem( const RENDER_SETTINGS* aSettings, const w
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_BITMAP::GetBoundingBox() const
|
||||
{
|
||||
auto* bitmap = static_cast<const WS_DATA_ITEM_BITMAP*>( m_peer );
|
||||
auto* bitmap = static_cast<const DS_DATA_ITEM_BITMAP*>( m_peer );
|
||||
wxSize bm_size = bitmap->m_ImageBitmap->GetSize();
|
||||
|
||||
EDA_RECT bbox;
|
||||
@ -456,7 +456,7 @@ const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT bbox = GetBoundingBox();
|
||||
bbox.Inflate( aAccuracy );
|
||||
@ -465,25 +465,25 @@ bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition, int aAccuracy ) con
|
||||
}
|
||||
|
||||
|
||||
bool WS_DRAW_ITEM_BITMAP::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
|
||||
bool DS_DRAW_ITEM_BITMAP::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
|
||||
{
|
||||
return WS_DRAW_ITEM_BASE::HitTest( aRect, aContains, aAccuracy );
|
||||
return DS_DRAW_ITEM_BASE::HitTest( aRect, aContains, aAccuracy );
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_BITMAP::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_BITMAP::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return _( "Image" );
|
||||
}
|
||||
|
||||
|
||||
wxString WS_DRAW_ITEM_PAGE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
wxString DS_DRAW_ITEM_PAGE::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
{
|
||||
return _( "Page Limits" );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT WS_DRAW_ITEM_PAGE::GetBoundingBox() const
|
||||
const EDA_RECT DS_DRAW_ITEM_PAGE::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT dummy;
|
||||
|
||||
@ -494,23 +494,23 @@ const EDA_RECT WS_DRAW_ITEM_PAGE::GetBoundingBox() const
|
||||
}
|
||||
|
||||
|
||||
// ====================== WS_DRAW_ITEM_LIST ==============================
|
||||
// ====================== DS_DRAW_ITEM_LIST ==============================
|
||||
|
||||
void WS_DRAW_ITEM_LIST::BuildDrawItemsList( const PAGE_INFO& aPageInfo,
|
||||
void DS_DRAW_ITEM_LIST::BuildDrawItemsList( const PAGE_INFO& aPageInfo,
|
||||
const TITLE_BLOCK& aTitleBlock )
|
||||
{
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
|
||||
m_titleBlock = &aTitleBlock;
|
||||
m_paperFormat = &aPageInfo.GetType();
|
||||
|
||||
// Build the basic layout shape, if the layout list is empty
|
||||
if( model.GetCount() == 0 && !model.VoidListAllowed() )
|
||||
model.SetPageLayout();
|
||||
model.LoadDrawingSheet();
|
||||
|
||||
model.SetupDrawEnvironment( aPageInfo, m_milsToIu );
|
||||
|
||||
for( WS_DATA_ITEM* wsItem : model.GetItems() )
|
||||
for( DS_DATA_ITEM* wsItem : model.GetItems() )
|
||||
{
|
||||
// Generate it only if the page option allows this
|
||||
if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && !m_isFirstPage )
|
||||
@ -529,11 +529,11 @@ void WS_DRAW_ITEM_LIST::BuildDrawItemsList( const PAGE_INFO& aPageInfo,
|
||||
* The selected items are drawn after (usually 0 or 1)
|
||||
* to be sure they are seen, even for overlapping items
|
||||
*/
|
||||
void WS_DRAW_ITEM_LIST::Print( const RENDER_SETTINGS* aSettings )
|
||||
void DS_DRAW_ITEM_LIST::Print( const RENDER_SETTINGS* aSettings )
|
||||
{
|
||||
std::vector<WS_DRAW_ITEM_BASE*> second_items;
|
||||
std::vector<DS_DRAW_ITEM_BASE*> second_items;
|
||||
|
||||
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
|
||||
for( DS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
|
||||
{
|
||||
if( item->Type() == WSG_BITMAP_T )
|
||||
item->PrintWsItem( aSettings );
|
@ -29,11 +29,11 @@
|
||||
#include <title_block.h>
|
||||
#include <build_version.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
|
||||
#include <wx/app.h>
|
||||
|
||||
@ -41,7 +41,7 @@ using namespace KIGFX;
|
||||
|
||||
static const wxString productName = wxT( "KiCad E.D.A. " );
|
||||
|
||||
WS_RENDER_SETTINGS::WS_RENDER_SETTINGS()
|
||||
DS_RENDER_SETTINGS::DS_RENDER_SETTINGS()
|
||||
{
|
||||
m_backgroundColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 );
|
||||
m_normalColor = RED;
|
||||
@ -53,7 +53,7 @@ WS_RENDER_SETTINGS::WS_RENDER_SETTINGS()
|
||||
}
|
||||
|
||||
|
||||
void WS_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
||||
void DS_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
||||
{
|
||||
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
|
||||
m_layerColors[ layer ] = aSettings->GetColor( layer );
|
||||
@ -67,7 +67,7 @@ void WS_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
||||
}
|
||||
|
||||
|
||||
COLOR4D WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
||||
COLOR4D DS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
||||
{
|
||||
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
|
||||
@ -85,7 +85,7 @@ COLOR4D WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void WS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
|
||||
void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
|
||||
{
|
||||
aVars->push_back( wxT( "KICAD_VERSION" ) );
|
||||
aVars->push_back( wxT( "#" ) );
|
||||
@ -100,7 +100,7 @@ void WS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
|
||||
|
||||
// returns the full text corresponding to the aTextbase,
|
||||
// after replacing format symbols by the corresponding value
|
||||
wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||
wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||
{
|
||||
std::function<bool( wxString* )> wsResolver =
|
||||
[ this ]( wxString* token ) -> bool
|
||||
@ -169,7 +169,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||
}
|
||||
|
||||
|
||||
bool KIGFX::WS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
bool KIGFX::DS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
{
|
||||
auto item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
|
||||
@ -178,12 +178,12 @@ bool KIGFX::WS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case WSG_LINE_T: draw( (WS_DRAW_ITEM_LINE*) item, aLayer ); break;
|
||||
case WSG_POLY_T: draw( (WS_DRAW_ITEM_POLYPOLYGONS*) item, aLayer ); break;
|
||||
case WSG_RECT_T: draw( (WS_DRAW_ITEM_RECT*) item, aLayer ); break;
|
||||
case WSG_TEXT_T: draw( (WS_DRAW_ITEM_TEXT*) item, aLayer ); break;
|
||||
case WSG_BITMAP_T: draw( (WS_DRAW_ITEM_BITMAP*) item, aLayer ); break;
|
||||
case WSG_PAGE_T: draw( (WS_DRAW_ITEM_PAGE*) item, aLayer ); break;
|
||||
case WSG_LINE_T: draw( (DS_DRAW_ITEM_LINE*) item, aLayer ); break;
|
||||
case WSG_POLY_T: draw( (DS_DRAW_ITEM_POLYPOLYGONS*) item, aLayer ); break;
|
||||
case WSG_RECT_T: draw( (DS_DRAW_ITEM_RECT*) item, aLayer ); break;
|
||||
case WSG_TEXT_T: draw( (DS_DRAW_ITEM_TEXT*) item, aLayer ); break;
|
||||
case WSG_BITMAP_T: draw( (DS_DRAW_ITEM_BITMAP*) item, aLayer ); break;
|
||||
case WSG_PAGE_T: draw( (DS_DRAW_ITEM_PAGE*) item, aLayer ); break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ bool KIGFX::WS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const
|
||||
{
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetIsFill( false );
|
||||
@ -201,7 +201,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const
|
||||
{
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetIsFill( false );
|
||||
@ -211,13 +211,13 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const
|
||||
{
|
||||
m_gal->SetFillColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
||||
m_gal->SetIsFill( true );
|
||||
m_gal->SetIsStroke( false );
|
||||
|
||||
WS_DRAW_ITEM_POLYPOLYGONS* item = (WS_DRAW_ITEM_POLYPOLYGONS*)aItem;
|
||||
DS_DRAW_ITEM_POLYPOLYGONS* item = (DS_DRAW_ITEM_POLYPOLYGONS*)aItem;
|
||||
|
||||
for( int idx = 0; idx < item->GetPolygons().OutlineCount(); ++idx )
|
||||
{
|
||||
@ -227,7 +227,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
||||
{
|
||||
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
|
||||
int penWidth = std::max( aItem->GetEffectiveTextPenWidth(),
|
||||
@ -246,10 +246,10 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
|
||||
{
|
||||
m_gal->Save();
|
||||
auto* bitmap = static_cast<WS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
|
||||
auto* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
|
||||
|
||||
VECTOR2D position = aItem->GetPosition();
|
||||
m_gal->Translate( position );
|
||||
@ -281,7 +281,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) con
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_PAGE* aItem, int aLayer ) const
|
||||
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const
|
||||
{
|
||||
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
|
||||
VECTOR2D end = VECTOR2D( aItem->GetPageSize().x,
|
||||
@ -309,7 +309,7 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_PAGE* aItem, int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void KIGFX::WS_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
|
||||
void KIGFX::DS_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
|
||||
{
|
||||
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
|
||||
VECTOR2D end = VECTOR2D( aPageInfo->GetWidthMils() * aScaleFactor,
|
@ -21,16 +21,16 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <page_layout/ws_proxy_undo_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <drawing_sheet/ds_proxy_undo_item.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <view/view.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <macros.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame ) :
|
||||
DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame ) :
|
||||
EDA_ITEM( aFrame ? WS_PROXY_UNDO_ITEM_PLUS_T : WS_PROXY_UNDO_ITEM_T ),
|
||||
m_selectedDataItem( INT_MAX ),
|
||||
m_selectedDrawItem( INT_MAX )
|
||||
@ -41,16 +41,16 @@ WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame ) :
|
||||
m_titleBlock = aFrame->GetTitleBlock();
|
||||
}
|
||||
|
||||
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
||||
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
||||
model.SaveInString( m_layoutSerialization );
|
||||
|
||||
for( size_t ii = 0; ii < model.GetItems().size(); ++ii )
|
||||
{
|
||||
WS_DATA_ITEM* dataItem = model.GetItem( ii );
|
||||
DS_DATA_ITEM* dataItem = model.GetItem( ii );
|
||||
|
||||
for( size_t jj = 0; jj < dataItem->GetDrawItems().size(); ++jj )
|
||||
{
|
||||
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ jj ];
|
||||
DS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ jj ];
|
||||
|
||||
if( drawItem->IsSelected() )
|
||||
{
|
||||
@ -63,7 +63,7 @@ WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame ) :
|
||||
}
|
||||
|
||||
|
||||
void WS_PROXY_UNDO_ITEM::Restore( EDA_DRAW_FRAME* aFrame, KIGFX::VIEW* aView )
|
||||
void DS_PROXY_UNDO_ITEM::Restore( EDA_DRAW_FRAME* aFrame, KIGFX::VIEW* aView )
|
||||
{
|
||||
if( Type() == WS_PROXY_UNDO_ITEM_PLUS_T )
|
||||
{
|
||||
@ -71,21 +71,21 @@ void WS_PROXY_UNDO_ITEM::Restore( EDA_DRAW_FRAME* aFrame, KIGFX::VIEW* aView )
|
||||
aFrame->SetTitleBlock( m_titleBlock );
|
||||
}
|
||||
|
||||
WS_DATA_MODEL::GetTheInstance().SetPageLayout( TO_UTF8( m_layoutSerialization ) );
|
||||
DS_DATA_MODEL::GetTheInstance().SetPageLayout(TO_UTF8( m_layoutSerialization ) );
|
||||
|
||||
if( aView )
|
||||
{
|
||||
aView->Clear();
|
||||
|
||||
for( int ii = 0; ii < (int)WS_DATA_MODEL::GetTheInstance().GetItems().size(); ++ii )
|
||||
for( int ii = 0; ii < (int)DS_DATA_MODEL::GetTheInstance().GetItems().size(); ++ii )
|
||||
{
|
||||
WS_DATA_ITEM* dataItem = WS_DATA_MODEL::GetTheInstance().GetItem( ii );
|
||||
DS_DATA_ITEM* dataItem = DS_DATA_MODEL::GetTheInstance().GetItem( ii );
|
||||
|
||||
dataItem->SyncDrawItems( nullptr, aView );
|
||||
|
||||
if( ii == m_selectedDataItem && m_selectedDrawItem < (int)dataItem->GetDrawItems().size() )
|
||||
{
|
||||
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ m_selectedDrawItem ];
|
||||
DS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ m_selectedDrawItem ];
|
||||
drawItem->SetSelected();
|
||||
}
|
||||
}
|
@ -24,16 +24,16 @@
|
||||
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <page_info.h>
|
||||
#include <page_layout/ws_proxy_view_item.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <project.h>
|
||||
#include <view/view.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
WS_PROXY_VIEW_ITEM::WS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO* aPageInfo,
|
||||
DS_PROXY_VIEW_ITEM::DS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO* aPageInfo,
|
||||
const PROJECT* aProject, const TITLE_BLOCK* aTitleBlock ) :
|
||||
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
|
||||
m_mils2IUscalefactor( aMils2IUscalefactor ),
|
||||
@ -49,7 +49,7 @@ WS_PROXY_VIEW_ITEM::WS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO
|
||||
}
|
||||
|
||||
|
||||
const BOX2I WS_PROXY_VIEW_ITEM::ViewBBox() const
|
||||
const BOX2I DS_PROXY_VIEW_ITEM::ViewBBox() const
|
||||
{
|
||||
BOX2I bbox;
|
||||
|
||||
@ -68,7 +68,7 @@ const BOX2I WS_PROXY_VIEW_ITEM::ViewBBox() const
|
||||
}
|
||||
|
||||
|
||||
void WS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, WS_DRAW_ITEM_LIST* aDrawList ) const
|
||||
void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, DS_DRAW_ITEM_LIST* aDrawList ) const
|
||||
{
|
||||
RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings();
|
||||
wxString fileName( m_fileName.c_str(), wxConvUTF8 );
|
||||
@ -89,11 +89,11 @@ void WS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, WS_DRAW_ITEM_LIST* aDrawLis
|
||||
}
|
||||
|
||||
|
||||
void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
void DS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
{
|
||||
GAL* gal = aView->GetGAL();
|
||||
RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings();
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
DS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
buildDrawList( aView, &drawList );
|
||||
|
||||
@ -107,8 +107,8 @@ void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
gal->Scale( VECTOR2D( -1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
WS_PAINTER ws_painter( gal );
|
||||
auto ws_settings = static_cast<WS_RENDER_SETTINGS*>( ws_painter.GetSettings() );
|
||||
DS_PAINTER ws_painter( gal );
|
||||
auto ws_settings = static_cast<DS_RENDER_SETTINGS*>( ws_painter.GetSettings() );
|
||||
|
||||
ws_settings->SetNormalColor( settings->GetLayerColor( m_colorLayer ) );
|
||||
ws_settings->SetSelectedColor( settings->GetLayerColor( LAYER_SELECT_OVERLAY ) );
|
||||
@ -116,7 +116,7 @@ void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
ws_settings->SetPageBorderColor( settings->GetLayerColor( m_pageBorderColorLayer ) );
|
||||
|
||||
// Draw all the components that make the page layout
|
||||
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
ws_painter.Draw( item, LAYER_DRAWINGSHEET );
|
||||
|
||||
// Draw gray line that outlines the sheet size
|
||||
@ -128,21 +128,21 @@ void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
}
|
||||
|
||||
|
||||
void WS_PROXY_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
void DS_PROXY_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
aLayers[0] = LAYER_DRAWINGSHEET;
|
||||
}
|
||||
|
||||
|
||||
bool WS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems( VIEW* aView, const wxPoint& aPosition )
|
||||
bool DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems( VIEW* aView, const wxPoint& aPosition )
|
||||
{
|
||||
int accuracy = (int) aView->ToWorld( 5.0 ); // five pixels at current zoom
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
DS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
buildDrawList( aView, &drawList );
|
||||
|
||||
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
{
|
||||
if( item->HitTest( aPosition, accuracy ) )
|
||||
return true;
|
@ -53,12 +53,11 @@
|
||||
#include <tool/zoom_menu.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <view/view.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <widgets/msgpanel.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <dialogs/dialog_grid_settings.h>
|
||||
#include <widgets/ui_common.h>
|
||||
#include <zoom_defines.h>
|
||||
|
||||
#define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks.
|
||||
|
||||
@ -831,13 +830,13 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos )
|
||||
|
||||
static const wxString productName = wxT( "KiCad E.D.A. " );
|
||||
|
||||
void PrintPageLayout( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
|
||||
const wxString& aFullSheetName, const wxString& aFileName,
|
||||
const TITLE_BLOCK& aTitleBlock, int aSheetCount, const wxString& aPageNumber,
|
||||
double aMils2Iu, const PROJECT* aProject, const wxString& aSheetLayer,
|
||||
bool aIsFirstPage )
|
||||
void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
|
||||
const wxString& aFullSheetName, const wxString& aFileName,
|
||||
const TITLE_BLOCK& aTitleBlock, int aSheetCount,
|
||||
const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject,
|
||||
const wxString& aSheetLayer, bool aIsFirstPage )
|
||||
{
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
DS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() );
|
||||
drawList.SetMilsToIUfactor( aMils2Iu );
|
||||
@ -872,9 +871,9 @@ void EDA_DRAW_FRAME::PrintDrawingSheet( const RENDER_SETTINGS* aSettings, BASE_S
|
||||
DC->SetAxisOrientation( true, false );
|
||||
}
|
||||
|
||||
PrintPageLayout( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
|
||||
aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
|
||||
aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
|
||||
::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(),
|
||||
aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(),
|
||||
aSheetLayer, aScreen->GetVirtualPageNumber() == 1 );
|
||||
|
||||
if( origin.y > 0 )
|
||||
{
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <plotters_specific.h>
|
||||
#include <page_layout/ws_data_item.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_data_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <title_block.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
@ -69,7 +69,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
plotColor = COLOR4D( RED );
|
||||
|
||||
plotter->SetColor( plotColor );
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
DS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
// Print only a short filename, if aFilename is the full filename
|
||||
wxFileName fn( aFilename );
|
||||
@ -87,7 +87,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
drawList.BuildDrawItemsList( aPageInfo, aTitleBlock );
|
||||
|
||||
// Draw item list
|
||||
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
|
||||
{
|
||||
plotter->SetCurrentLineWidth( PLOTTER::USE_DEFAULT_LINE_WIDTH );
|
||||
|
||||
@ -95,7 +95,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
{
|
||||
case WSG_LINE_T:
|
||||
{
|
||||
WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
|
||||
DS_DRAW_ITEM_LINE* line = (DS_DRAW_ITEM_LINE*) item;
|
||||
plotter->SetCurrentLineWidth( std::max( line->GetPenWidth(), defaultPenWidth ) );
|
||||
plotter->MoveTo( line->GetStart() );
|
||||
plotter->FinishTo( line->GetEnd() );
|
||||
@ -104,7 +104,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
|
||||
case WSG_RECT_T:
|
||||
{
|
||||
WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
|
||||
DS_DRAW_ITEM_RECT* rect = (DS_DRAW_ITEM_RECT*) item;
|
||||
int penWidth = std::max( rect->GetPenWidth(), defaultPenWidth );
|
||||
plotter->Rect( rect->GetStart(), rect->GetEnd(), FILL_TYPE::NO_FILL, penWidth );
|
||||
}
|
||||
@ -112,7 +112,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
|
||||
case WSG_TEXT_T:
|
||||
{
|
||||
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
|
||||
DS_DRAW_ITEM_TEXT* text = (DS_DRAW_ITEM_TEXT*) item;
|
||||
int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
|
||||
plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
|
||||
text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
|
||||
@ -123,7 +123,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
|
||||
case WSG_POLY_T:
|
||||
{
|
||||
WS_DRAW_ITEM_POLYPOLYGONS* poly = (WS_DRAW_ITEM_POLYPOLYGONS*) item;
|
||||
DS_DRAW_ITEM_POLYPOLYGONS* poly = (DS_DRAW_ITEM_POLYPOLYGONS*) item;
|
||||
int penWidth = std::max( poly->GetPenWidth(), defaultPenWidth );
|
||||
std::vector<wxPoint> points;
|
||||
|
||||
@ -142,8 +142,8 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
|
||||
|
||||
case WSG_BITMAP_T:
|
||||
{
|
||||
WS_DRAW_ITEM_BITMAP* drawItem = (WS_DRAW_ITEM_BITMAP*) item;
|
||||
auto* bitmap = (WS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
|
||||
DS_DRAW_ITEM_BITMAP* drawItem = (DS_DRAW_ITEM_BITMAP*) item;
|
||||
DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
|
||||
|
||||
if( bitmap->m_ImageBitmap == NULL )
|
||||
break;
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <dialogs/dialog_page_settings.h>
|
||||
|
||||
class WS_DATA_MODEL;
|
||||
|
||||
class DIALOG_EESCHEMA_PAGE_SETTINGS : public DIALOG_PAGES_SETTINGS
|
||||
{
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <page_layout/ws_painter.h>
|
||||
#include <drawing_sheet/ds_painter.h>
|
||||
#include <sch_painter.h>
|
||||
#include <schematic.h>
|
||||
|
||||
|
@ -486,7 +486,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
|
||||
if( cfg->m_Printing.use_theme && theme )
|
||||
renderSettings.LoadColors( theme );
|
||||
|
||||
// The drawing sheet item print code is shared between PCBNew and EESchema, so it's easier
|
||||
// The drawing-sheet-item print code is shared between PCBNew and EESchema, so it's easier
|
||||
// if they just use the PCB layer.
|
||||
renderSettings.SetLayerColor( LAYER_DRAWINGSHEET,
|
||||
renderSettings.GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ) );
|
||||
|
@ -40,20 +40,20 @@
|
||||
#include <settings/settings_manager.h>
|
||||
#include <title_block.h>
|
||||
#include <view/view.h>
|
||||
#include <page_layout/ws_proxy_view_item.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <widgets/color_swatch.h>
|
||||
|
||||
|
||||
PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aFrame,
|
||||
wxWindow* aParent ) :
|
||||
PANEL_COLOR_SETTINGS( aParent ),
|
||||
m_frame( aFrame ),
|
||||
m_preview( nullptr ),
|
||||
m_page( nullptr ),
|
||||
m_titleBlock( nullptr ),
|
||||
m_ws( nullptr ),
|
||||
m_previewItems()
|
||||
PANEL_COLOR_SETTINGS( aParent ),
|
||||
m_frame( aFrame ),
|
||||
m_preview( nullptr ),
|
||||
m_page( nullptr ),
|
||||
m_titleBlock( nullptr ),
|
||||
m_drawingSheet( nullptr ),
|
||||
m_previewItems()
|
||||
{
|
||||
m_colorNamespace = "schematic";
|
||||
|
||||
@ -107,7 +107,7 @@ PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS()
|
||||
{
|
||||
delete m_page;
|
||||
delete m_titleBlock;
|
||||
delete m_ws;
|
||||
delete m_drawingSheet;
|
||||
delete m_currentSettings;
|
||||
|
||||
for( EDA_ITEM* item : m_previewItems )
|
||||
@ -244,9 +244,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||
m_page->SetHeightMils( 5000 );
|
||||
m_page->SetWidthMils( 6000 );
|
||||
|
||||
m_ws = new KIGFX::WS_PROXY_VIEW_ITEM( (int) IU_PER_MILS, m_page, nullptr, m_titleBlock );
|
||||
m_ws->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET );
|
||||
view->Add( m_ws );
|
||||
m_drawingSheet = new DS_PROXY_VIEW_ITEM((int) IU_PER_MILS, m_page, nullptr, m_titleBlock );
|
||||
m_drawingSheet->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET );
|
||||
view->Add( m_drawingSheet );
|
||||
|
||||
// NOTE: It would be nice to parse a schematic file here.
|
||||
// This is created from the color_settings.sch file in demos folder
|
||||
@ -453,7 +453,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview()
|
||||
fabs( psize.y / screenSize.y ) );
|
||||
|
||||
view->SetScale( scale * 1.1 );
|
||||
view->SetCenter( m_ws->ViewBBox().Centre() );
|
||||
view->SetCenter( m_drawingSheet->ViewBBox().Centre() );
|
||||
m_preview->ForceRefresh();
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,8 @@ class PAGE_INFO;
|
||||
class SCH_ITEM;
|
||||
class SCH_PREVIEW_PANEL;
|
||||
class TITLE_BLOCK;
|
||||
class DS_PROXY_VIEW_ITEM;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class WS_PROXY_VIEW_ITEM;
|
||||
}
|
||||
|
||||
class PANEL_EESCHEMA_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS
|
||||
{
|
||||
@ -68,7 +65,7 @@ private:
|
||||
SCH_PREVIEW_PANEL* m_preview;
|
||||
PAGE_INFO* m_page;
|
||||
TITLE_BLOCK* m_titleBlock;
|
||||
KIGFX::WS_PROXY_VIEW_ITEM* m_ws;
|
||||
DS_PROXY_VIEW_ITEM* m_drawingSheet;
|
||||
std::vector<EDA_ITEM*> m_previewItems;
|
||||
|
||||
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions;
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include <symbol_lib_table.h>
|
||||
#include <widgets/paged_dialog.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <zoom_defines.h>
|
||||
|
||||
|
||||
@ -86,14 +86,13 @@ bool SCH_EDIT_FRAME::LoadProjectSettings()
|
||||
LIB_PART::SetSubpartIdNotation( LIB_PART::GetSubpartIdSeparator(),
|
||||
LIB_PART::GetSubpartFirstId() );
|
||||
|
||||
// Load the page layout decr file, from the filename stored in
|
||||
// Load the drawing sheet description 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
|
||||
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
|
||||
wxString filename = WS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
|
||||
wxString filename = DS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
|
||||
Prj().GetProjectPath() );
|
||||
|
||||
pglayout.SetPageLayout( filename );
|
||||
DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include <sch_reference_list.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <schematic.h>
|
||||
#include <page_layout/ws_draw_item.h>
|
||||
#include <page_layout/ws_proxy_view_item.h>
|
||||
#include <drawing_sheet/ds_draw_item.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
#include <wx/ffile.h>
|
||||
|
||||
|
||||
@ -159,9 +159,9 @@ int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
|
||||
}
|
||||
|
||||
|
||||
void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aDrawingSheet )
|
||||
void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
||||
{
|
||||
WS_DRAW_ITEM_LIST wsItems;
|
||||
DS_DRAW_ITEM_LIST wsItems;
|
||||
|
||||
auto unresolved = [this]( wxString str )
|
||||
{
|
||||
@ -252,9 +252,9 @@ void ERC_TESTER::TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aDrawingSheet )
|
||||
}
|
||||
}
|
||||
|
||||
for( WS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
|
||||
for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() )
|
||||
{
|
||||
if( WS_DRAW_ITEM_TEXT* text = dynamic_cast<WS_DRAW_ITEM_TEXT*>( item ) )
|
||||
if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
|
||||
{
|
||||
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) )
|
||||
{
|
||||
|
@ -37,11 +37,7 @@ class NETLIST_OBJECT;
|
||||
class NETLIST_OBJECT_LIST;
|
||||
class SCH_SHEET_LIST;
|
||||
class SCHEMATIC;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class WS_PROXY_VIEW_ITEM;
|
||||
}
|
||||
class DS_PROXY_VIEW_ITEM;
|
||||
|
||||
|
||||
extern const wxString CommentERC_H[];
|
||||
@ -83,7 +79,7 @@ public:
|
||||
/**
|
||||
* Check for any unresolved text variable references.
|
||||
*/
|
||||
void TestTextVars( KIGFX::WS_PROXY_VIEW_ITEM* aDrawingSheet );
|
||||
void TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet );
|
||||
|
||||
/**
|
||||
* Check that there are no conflicting bus alias definitions in the schematic.
|
||||
|
@ -41,25 +41,21 @@
|
||||
#include <project_rescue.h>
|
||||
#include <reporter.h>
|
||||
#include <richio.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_plugins/legacy/sch_legacy_plugin.h>
|
||||
#include <sch_file_versions.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tool/actions.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_editor_control.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <page_layout/ws_data_model.h>
|
||||
#include <drawing_sheet/ds_data_model.h>
|
||||
#include <wx/ffile.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <tools/ee_inspection_tool.h>
|
||||
#include <paths.h>
|
||||
|
||||
@ -920,9 +916,9 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||
SCH_IO_MGR::FindPlugin( (SCH_IO_MGR::SCH_FILE_T) aFileType ) );
|
||||
Schematic().SetRoot( pi->Load( aFileName, &Schematic() ) );
|
||||
|
||||
// Eagle sheets do not use a drawing sheet frame by default, so set it to an empty one
|
||||
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
|
||||
pglayout.SetEmptyLayout();
|
||||
// Eagle sheets do not use a drawing-sheet frame by default, so set it to an empty one
|
||||
DS_DATA_MODEL& drawingSheet = DS_DATA_MODEL::GetTheInstance();
|
||||
drawingSheet.SetEmptyLayout();
|
||||
|
||||
BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks";
|
||||
wxFileName layoutfn( Prj().GetProjectPath(), BASE_SCREEN::m_PageLayoutDescrFileName );
|
||||
@ -930,7 +926,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||
|
||||
if( layoutfile.Open( layoutfn.GetFullPath(), "wb" ) )
|
||||
{
|
||||
layoutfile.Write( WS_DATA_MODEL::EmptyLayout() );
|
||||
layoutfile.Write( DS_DATA_MODEL::EmptyLayout() );
|
||||
layoutfile.Close();
|
||||
}
|
||||
|
||||
|
@ -317,5 +317,5 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||
TOOL_EVENT dummy;
|
||||
editTool->UpdateNetHighlighting( dummy );
|
||||
|
||||
HardRedraw(); // Ensure any item has its view updated, especially the worksheet items
|
||||
HardRedraw(); // Ensure all items are redrawn (especially the drawing-sheet items)
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user