Remove duplicate files.
Page layout editor: Add bitmap items to the page layout existing items. Now a bitmap image can be added to a page layout description. Currently the bitmap is expected having a 300 ppi definition. Note: not all plotters can plot a bitmap, and in this case the bounding box is plotted instead of the bitmap
This commit is contained in:
commit
6bb62a7196
|
@ -492,7 +492,7 @@ void EDA_3D_CANVAS::InitGL()
|
||||||
glEnable( GL_DEPTH_TEST ); // Enable z-buferring
|
glEnable( GL_DEPTH_TEST ); // Enable z-buferring
|
||||||
glEnable( GL_ALPHA_TEST );
|
glEnable( GL_ALPHA_TEST );
|
||||||
glEnable( GL_LINE_SMOOTH );
|
glEnable( GL_LINE_SMOOTH );
|
||||||
glEnable(GL_POLYGON_SMOOTH);
|
// glEnable(GL_POLYGON_SMOOTH); // creates issues with some graphic cards
|
||||||
glShadeModel( GL_SMOOTH );
|
glShadeModel( GL_SMOOTH );
|
||||||
glEnable( GL_COLOR_MATERIAL );
|
glEnable( GL_COLOR_MATERIAL );
|
||||||
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
||||||
|
|
|
@ -121,6 +121,35 @@ bool BITMAP_BASE::SaveData( FILE* aFile ) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BITMAP_BASE::SaveData( wxArrayString& aPngStrings ) const
|
||||||
|
{
|
||||||
|
if( m_image )
|
||||||
|
{
|
||||||
|
wxMemoryOutputStream stream;
|
||||||
|
m_image->SaveFile( stream, wxBITMAP_TYPE_PNG );
|
||||||
|
|
||||||
|
// Write binary data in hexadecimal form (ASCII)
|
||||||
|
wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
|
||||||
|
char* begin = (char*) buffer->GetBufferStart();
|
||||||
|
wxString line;
|
||||||
|
for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
|
||||||
|
{
|
||||||
|
if( ii >= 32 )
|
||||||
|
{
|
||||||
|
ii = 0;
|
||||||
|
aPngStrings.Add( line );
|
||||||
|
line.Empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
line << wxString::Format( wxT("%2.2X "), *begin & 0xFF );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add last line:
|
||||||
|
if( !line.IsEmpty() )
|
||||||
|
aPngStrings.Add( line );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
|
bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
|
||||||
{
|
{
|
||||||
|
@ -130,9 +159,13 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
|
||||||
while( true )
|
while( true )
|
||||||
{
|
{
|
||||||
if( !aLine.ReadLine() )
|
if( !aLine.ReadLine() )
|
||||||
|
{
|
||||||
|
aErrorMsg = wxT("Unexpected end of data");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
line = aLine.Line();
|
line = aLine.Line();
|
||||||
|
|
||||||
if( strnicmp( line, "EndData", 4 ) == 0 )
|
if( strnicmp( line, "EndData", 4 ) == 0 )
|
||||||
{
|
{
|
||||||
// all the PNG date is read.
|
// all the PNG date is read.
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <drawtxt.h>
|
#include <drawtxt.h>
|
||||||
#include <class_title_block.h>
|
#include <class_title_block.h>
|
||||||
#include "worksheet_shape_builder.h"
|
#include "worksheet_shape_builder.h"
|
||||||
|
#include "class_worksheet_dataitem.h"
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,6 +138,20 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
||||||
poly->IsFilled() ? FILLED_SHAPE : NO_FILL );
|
poly->IsFilled() ? FILLED_SHAPE : NO_FILL );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WS_DRAW_ITEM_BASE::wsg_bitmap:
|
||||||
|
{
|
||||||
|
WS_DRAW_ITEM_BITMAP* bm = (WS_DRAW_ITEM_BITMAP*) item;
|
||||||
|
|
||||||
|
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)bm->GetParent();
|
||||||
|
|
||||||
|
if( parent->m_ImageBitmap == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
|
||||||
|
plotColor, PLOTTER::DEFAULT_LINE_WIDTH );
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,6 +316,7 @@ const wxString WORKSHEET_DATAITEM::GetClassName() const
|
||||||
case WS_SEGMENT: name = wxT("Line"); break;
|
case WS_SEGMENT: name = wxT("Line"); break;
|
||||||
case WS_RECT: name = wxT("Rect"); break;
|
case WS_RECT: name = wxT("Rect"); break;
|
||||||
case WS_POLYPOLYGON: name = wxT("Poly"); break;
|
case WS_POLYPOLYGON: name = wxT("Poly"); break;
|
||||||
|
case WS_BITMAP: name = wxT("Bitmap"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -539,3 +540,4 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,18 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WS_DRAW_ITEM_BASE::wsg_bitmap:
|
||||||
|
{
|
||||||
|
WS_DRAW_ITEM_BITMAP* bitmap = (WS_DRAW_ITEM_BITMAP*) item;
|
||||||
|
|
||||||
|
if( markerSize )
|
||||||
|
{
|
||||||
|
drawMarker( aClipBox, aDC, bitmap->GetPosition(),
|
||||||
|
markerSize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,10 +286,10 @@ bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition)
|
||||||
*/
|
*/
|
||||||
bool WS_DRAW_ITEM_RECT::HitTestStartPoint( const wxPoint& aPosition)
|
bool WS_DRAW_ITEM_RECT::HitTestStartPoint( const wxPoint& aPosition)
|
||||||
{
|
{
|
||||||
wxPoint pos = GetStart();
|
wxPoint dist = GetStart() - aPosition;
|
||||||
|
|
||||||
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
||||||
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -313,10 +325,10 @@ bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition)
|
||||||
*/
|
*/
|
||||||
bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
|
bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
|
||||||
{
|
{
|
||||||
wxPoint pos = GetStart();
|
wxPoint dist = GetStart() - aPosition;
|
||||||
|
|
||||||
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
||||||
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -326,10 +338,10 @@ bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
|
||||||
*/
|
*/
|
||||||
bool WS_DRAW_ITEM_LINE::HitTestEndPoint( const wxPoint& aPosition)
|
bool WS_DRAW_ITEM_LINE::HitTestEndPoint( const wxPoint& aPosition)
|
||||||
{
|
{
|
||||||
wxPoint pos = GetEnd();
|
wxPoint dist = GetEnd() - aPosition;
|
||||||
|
|
||||||
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
||||||
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -365,3 +377,47 @@ void WS_DRAW_ITEM_LIST::Locate( std::vector <WS_DRAW_ITEM_BASE*>& aList,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The function to draw a WS_DRAW_ITEM_BITMAP
|
||||||
|
*/
|
||||||
|
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
|
||||||
|
{
|
||||||
|
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
|
||||||
|
|
||||||
|
if( parent->m_ImageBitmap )
|
||||||
|
{
|
||||||
|
parent->m_ImageBitmap->DrawBitmap( NULL, aDC, m_pos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual function
|
||||||
|
* return true if the point aPosition is on bitmap
|
||||||
|
*/
|
||||||
|
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition)
|
||||||
|
{
|
||||||
|
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
|
||||||
|
|
||||||
|
if( parent->m_ImageBitmap == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
|
||||||
|
rect.Move( m_pos );
|
||||||
|
return rect.Contains( aPosition );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true if the point aPosition is on the reference point of this item.
|
||||||
|
*/
|
||||||
|
bool WS_DRAW_ITEM_BITMAP::HitTestStartPoint( const wxPoint& aPosition)
|
||||||
|
{
|
||||||
|
wxPoint dist = m_pos - aPosition;
|
||||||
|
|
||||||
|
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
|
||||||
|
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,11 @@ private:
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
|
void parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
|
||||||
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR );
|
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR );
|
||||||
void readOption( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR );
|
void readOption( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR );
|
||||||
|
void readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem ) throw( IO_ERROR, PARSE_ERROR );
|
||||||
};
|
};
|
||||||
|
|
||||||
// PCB_PLOT_PARAMS_PARSER
|
// PCB_PLOT_PARAMS_PARSER
|
||||||
|
@ -131,6 +134,12 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
|
||||||
aLayout->Append( item );
|
aLayout->Append( item );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_bitmap:
|
||||||
|
item = new WORKSHEET_DATAITEM_BITMAP( NULL );
|
||||||
|
parseBitmap( (WORKSHEET_DATAITEM_BITMAP*) item );
|
||||||
|
aLayout->Append( item );
|
||||||
|
break;
|
||||||
|
|
||||||
case T_tbtext:
|
case T_tbtext:
|
||||||
NeedSYMBOLorNUMBER();
|
NeedSYMBOLorNUMBER();
|
||||||
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
|
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
|
||||||
|
@ -306,6 +315,110 @@ void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <wx/mstream.h>
|
||||||
|
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
|
||||||
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
{
|
||||||
|
T token;
|
||||||
|
BITMAP_BASE* image = new BITMAP_BASE;
|
||||||
|
aItem->m_ImageBitmap = image;
|
||||||
|
|
||||||
|
while( ( token = NextTok() ) != T_RIGHT )
|
||||||
|
{
|
||||||
|
if( token == T_EOF)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( token == T_LEFT )
|
||||||
|
token = NextTok();
|
||||||
|
|
||||||
|
switch( token )
|
||||||
|
{
|
||||||
|
case T_name:
|
||||||
|
NeedSYMBOLorNUMBER();
|
||||||
|
aItem->m_Name = FromUTF8();
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_pos:
|
||||||
|
parseCoordinate( aItem->m_Pos );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_repeat:
|
||||||
|
aItem->m_RepeatCount = parseInt( -1, 100 );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_incrx:
|
||||||
|
aItem->m_IncrementVector.x = parseDouble();
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_incry:
|
||||||
|
aItem->m_IncrementVector.y = parseDouble();
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_linewidth:
|
||||||
|
aItem->m_LineWidth = parseDouble();
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_scale:
|
||||||
|
aItem->m_ImageBitmap->m_Scale = parseDouble();
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_pngdata:
|
||||||
|
readPngdata( aItem );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Unexpected( CurText() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
|
||||||
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
|
{
|
||||||
|
std::string tmp;
|
||||||
|
T token;
|
||||||
|
|
||||||
|
while( ( token = NextTok() ) != T_RIGHT )
|
||||||
|
{
|
||||||
|
if( token == T_EOF)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( token == T_LEFT )
|
||||||
|
token = NextTok();
|
||||||
|
|
||||||
|
switch( token )
|
||||||
|
{
|
||||||
|
case T_data:
|
||||||
|
NeedSYMBOLorNUMBER();
|
||||||
|
tmp += CurStr();
|
||||||
|
tmp += "\n";
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Unexpected( CurText() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp += "EndData";
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
STRING_LINE_READER reader( tmp, wxT("Png kicad_wks data") );
|
||||||
|
if( ! aItem->m_ImageBitmap->LoadData( reader, msg ) )
|
||||||
|
{
|
||||||
|
wxLogMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
|
void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@ notonpage1
|
||||||
line
|
line
|
||||||
rect
|
rect
|
||||||
polygon
|
polygon
|
||||||
|
bitmap
|
||||||
tbtext
|
tbtext
|
||||||
ltcorner
|
ltcorner
|
||||||
lbcorner
|
lbcorner
|
||||||
|
@ -23,6 +24,9 @@ name
|
||||||
pos
|
pos
|
||||||
start
|
start
|
||||||
end
|
end
|
||||||
|
scale
|
||||||
|
pngdata
|
||||||
|
data
|
||||||
pts
|
pts
|
||||||
xy
|
xy
|
||||||
maxlen
|
maxlen
|
||||||
|
|
|
@ -236,6 +236,21 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
||||||
|
|
||||||
|
((WORKSHEET_DATAITEM_BITMAP*)wsItem)->SetPixelScaleFactor();
|
||||||
|
|
||||||
|
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
|
||||||
|
{
|
||||||
|
if( jj && ! wsItem->IsInsidePage( jj ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Append( new WS_DRAW_ITEM_BITMAP( wsItem,
|
||||||
|
wsItem->GetStartPosUi( jj ) ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,198 +0,0 @@
|
||||||
/**
|
|
||||||
* @file common/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 change_log.txt for contributors.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* keyword used in page layout description are (see page_layout_reader.keywords)
|
|
||||||
* page_layout
|
|
||||||
* setup
|
|
||||||
* linewidth
|
|
||||||
* textlinewidth
|
|
||||||
* textsize
|
|
||||||
* comment
|
|
||||||
* line
|
|
||||||
* rect
|
|
||||||
* polygon
|
|
||||||
* tbtext
|
|
||||||
* ltcorner
|
|
||||||
* lbcorner
|
|
||||||
* rbcorner
|
|
||||||
* rtcorner
|
|
||||||
* name
|
|
||||||
* pos
|
|
||||||
* start
|
|
||||||
* end
|
|
||||||
* pts
|
|
||||||
* xy
|
|
||||||
* maxlen
|
|
||||||
* maxheight
|
|
||||||
* font
|
|
||||||
* bold
|
|
||||||
* italic
|
|
||||||
* size
|
|
||||||
* justify
|
|
||||||
* left
|
|
||||||
* center
|
|
||||||
* right
|
|
||||||
* top
|
|
||||||
* bottom
|
|
||||||
* rotate
|
|
||||||
* repeat
|
|
||||||
* incrx
|
|
||||||
* incry
|
|
||||||
* incrlabel
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Items use coordinates.
|
|
||||||
* A coordinate is defined relative to a page corner
|
|
||||||
* A coordinate is the X pos, the Y pos, and the corner which is the coordinate origin
|
|
||||||
* the default is the bottom right corner
|
|
||||||
* example: (start 10 0 ltcorner) or (start 20 10)
|
|
||||||
* The direction depends on the corner: a positive coordinate define a point
|
|
||||||
* from the corner origin, to the opposite corner.
|
|
||||||
*
|
|
||||||
* Items are defined by a name, coordinates in mm and some attributes,
|
|
||||||
* and can be repeated.
|
|
||||||
* for instance (repeat 2) (incrx 2) (incry 2) repeat the item 2 times,
|
|
||||||
* and coordinates are incremented by 2 on X direction, and 2 on Y direction
|
|
||||||
* Comments are allowed. they are inside (), and start by the keyword comment
|
|
||||||
* example:
|
|
||||||
* (comment rect around the title block)
|
|
||||||
*
|
|
||||||
* Lines and rect are defined by 2 coordinates start and end, and attributes.
|
|
||||||
* Attributes are linewidth and repeat parameters.
|
|
||||||
* example:
|
|
||||||
* (line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )
|
|
||||||
* (rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )
|
|
||||||
*
|
|
||||||
* Texts are defined by the text (between quotes), the position, and attributes
|
|
||||||
* example
|
|
||||||
* "(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )"
|
|
||||||
* the text can be rotated by (rotation <value>) with value = rot angle in degrees
|
|
||||||
* (font (size 1.3 1.3) bold italic) defines a specific size,
|
|
||||||
* with bold and italic options
|
|
||||||
* (justify <justif keyword>) controls the text justification (the default is left)
|
|
||||||
* justif keyword is center, left, right, top and bottom
|
|
||||||
* (justify center top) is a text centered on X axis and top aligned on vertical axis
|
|
||||||
* The text size can be constrained:
|
|
||||||
* (maxlen <value>) and (maxheight <value>) force the actual text x and/or y size to be
|
|
||||||
* reduced to limit the text height to the maxheight value,
|
|
||||||
* and the full text x size to the maxlen value.
|
|
||||||
* If the actual text size is smaller than limits, its size is not modified.
|
|
||||||
*
|
|
||||||
* Texts can include a format symbol, a la printf.
|
|
||||||
* At run time these format symbols will be replaced by their actual value.
|
|
||||||
*
|
|
||||||
* format symbols are:
|
|
||||||
*
|
|
||||||
* %% = replaced by %
|
|
||||||
* %K = Kicad version
|
|
||||||
* %Z = paper format name (A4, USLetter ...)
|
|
||||||
* %Y = company name
|
|
||||||
* %D = date
|
|
||||||
* %R = revision
|
|
||||||
* %S = sheet number
|
|
||||||
* %N = number of sheets
|
|
||||||
* %Cx = comment (x = 0 to 9 to identify the comment)
|
|
||||||
* %F = filename
|
|
||||||
* %P = sheet path (sheet full name)
|
|
||||||
* %T = title
|
|
||||||
*
|
|
||||||
* example:
|
|
||||||
* (tbtext \"Size: %Z\" ...) displays "Size A4" or Size USLetter"
|
|
||||||
*
|
|
||||||
* Poly Polygons
|
|
||||||
* Set of filled polygons are supported.
|
|
||||||
*
|
|
||||||
* The main purpose is to allow logos, or complex shapes
|
|
||||||
* They support the repeat and rotation options
|
|
||||||
* They are defined by
|
|
||||||
* (polygon (position ..) <rotation> <linewidth>
|
|
||||||
* the parameter linewidth defines the pen size used to draw/plot
|
|
||||||
* the polygon outlines (default = 0)
|
|
||||||
* example:
|
|
||||||
* (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254)
|
|
||||||
*
|
|
||||||
* and a list of corners like
|
|
||||||
* (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932)
|
|
||||||
* .... )
|
|
||||||
*
|
|
||||||
* each sequence like
|
|
||||||
* (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932)
|
|
||||||
* .... )
|
|
||||||
* defines a polygon.
|
|
||||||
* Each coordinate is relative to the polygon position.
|
|
||||||
* Therefore a "polygon" is in fact a set of polygons, of a poly polygon
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <worksheet.h> // defaultPageLayout
|
|
||||||
|
|
||||||
|
|
||||||
// height of the band reference grid 2.0 mm
|
|
||||||
// worksheet frame reference text size 1.3 mm
|
|
||||||
// default text size 1.5 mm
|
|
||||||
// default line width 0.15 mm
|
|
||||||
// frame ref pitch 50 mm
|
|
||||||
|
|
||||||
// export defaultPageLayout:
|
|
||||||
extern const char defaultPageLayout[];
|
|
||||||
|
|
||||||
// Default page layout (sizes are in mm)
|
|
||||||
const char defaultPageLayout[] = "( page_layout\n"
|
|
||||||
"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )"
|
|
||||||
"(rect (comment \"rect around the title block\") (linewidth 0.15) (start 110 34) (end 2 2) )\n"
|
|
||||||
"(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n"
|
|
||||||
"(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n"
|
|
||||||
"(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n"
|
|
||||||
"(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n"
|
|
||||||
"(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n"
|
|
||||||
"(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n"
|
|
||||||
"(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n"
|
|
||||||
"(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n"
|
|
||||||
"(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n"
|
|
||||||
"(tbtext \"Date: %D\" (pos 87 6.9) )\n"
|
|
||||||
"(line (start 110 5.5) end 2 5.5) )\n"
|
|
||||||
"(tbtext \"%K\" (pos 109 4.1) (comment \"Kicad version\" ) )\n"
|
|
||||||
"(line (start 110 8.5) end 2 8.5) )\n"
|
|
||||||
"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n"
|
|
||||||
"(tbtext \"Size: %Z\" (comment \"Paper format name\")(pos 109 6.9) )\n"
|
|
||||||
"(tbtext \"Id: %S/%N\" (comment \"Sheet id\")(pos 24 4.1) )\n"
|
|
||||||
"(line (start 110 12.5) end 2 12.5) )\n"
|
|
||||||
"(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n"
|
|
||||||
"(tbtext \"File: %F\" (pos 109 14.3) )\n"
|
|
||||||
"(line (start 110 18.5) end 2 18.5) )\n"
|
|
||||||
"(tbtext \"Sheet: %P\" (pos 109 17) )\n"
|
|
||||||
"(tbtext \"%Y\" (comment \"Company name\") (pos 109 20)(font bold) )\n"
|
|
||||||
"(tbtext \"%C0\" (comment \"Comment 0\") (pos 109 23) )\n"
|
|
||||||
"(tbtext \"%C1\" (comment \"Comment 1\") (pos 109 26) )\n"
|
|
||||||
"(tbtext \"%C2\" (comment \"Comment 2\") (pos 109 29) )\n"
|
|
||||||
"(tbtext \"%C3\" (comment \"Comment 3\") (pos 109 32) )\n"
|
|
||||||
"(line (start 90 8.5) end 90 5.5) )\n"
|
|
||||||
"(line (start 26 8.5) end 26 2) )\n"
|
|
||||||
")\n"
|
|
||||||
;
|
|
|
@ -1,623 +0,0 @@
|
||||||
/**
|
|
||||||
* @file common/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-2013 KiCad Developers, see change_log.txt for contributors.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
|
||||||
#include <base_struct.h>
|
|
||||||
#include <worksheet.h>
|
|
||||||
#include <worksheet_shape_builder.h>
|
|
||||||
#include <vector2d.h>
|
|
||||||
#include <page_layout_reader_lexer.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace TB_READER_T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class PAGE_LAYOUT_READER_PARSER
|
|
||||||
* holds data and functions pertinent to parsing a S-expression file
|
|
||||||
* for a WORKSHEET_LAYOUT.
|
|
||||||
*/
|
|
||||||
class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER
|
|
||||||
{
|
|
||||||
DSIZE m_defaultTextSize; // Default text size, when not defined inside a tbtext
|
|
||||||
double m_defaultLineWidth;
|
|
||||||
double m_defaulTextLineWidth;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource );
|
|
||||||
void Parse( WORKSHEET_LAYOUT* aLayout )
|
|
||||||
throw( PARSE_ERROR, IO_ERROR );
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function parseInt
|
|
||||||
* parses an integer and constrains it between two values.
|
|
||||||
* @param aMin is the smallest return value.
|
|
||||||
* @param aMax is the largest return value.
|
|
||||||
* @return int - the parsed integer.
|
|
||||||
*/
|
|
||||||
int parseInt( int aMin, int aMax );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function parseDouble
|
|
||||||
* parses a double
|
|
||||||
* @return double - the parsed double.
|
|
||||||
*/
|
|
||||||
double parseDouble();
|
|
||||||
|
|
||||||
void parseSetup() throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
void parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
void parseText( WORKSHEET_DATAITEM_TEXT * aItem ) throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
void parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
};
|
|
||||||
|
|
||||||
// PCB_PLOT_PARAMS_PARSER
|
|
||||||
|
|
||||||
PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ) :
|
|
||||||
PAGE_LAYOUT_READER_LEXER( aLine, aSource )
|
|
||||||
{
|
|
||||||
m_defaultTextSize.x = m_defaultTextSize.y = TB_DEFAULT_TEXTSIZE;
|
|
||||||
m_defaultLineWidth = 0.0;
|
|
||||||
m_defaulTextLineWidth = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
|
|
||||||
throw( PARSE_ERROR, IO_ERROR )
|
|
||||||
{
|
|
||||||
T token;
|
|
||||||
WORKSHEET_DATAITEM * item;
|
|
||||||
|
|
||||||
LOCALE_IO toggle;
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( token == T_LEFT )
|
|
||||||
token = NextTok();
|
|
||||||
|
|
||||||
if( token == T_page_layout )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_setup: // Defines default values for graphic items
|
|
||||||
parseSetup();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_line:
|
|
||||||
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT );
|
|
||||||
parseGraphic( item );
|
|
||||||
aLayout->Append( item );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_rect:
|
|
||||||
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT );
|
|
||||||
parseGraphic( item );
|
|
||||||
aLayout->Append( item );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_polygon:
|
|
||||||
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
|
|
||||||
parsePolygon( (WORKSHEET_DATAITEM_POLYPOLYGON*) item );
|
|
||||||
aLayout->Append( item );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_tbtext:
|
|
||||||
NeedSYMBOLorNUMBER();
|
|
||||||
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
|
|
||||||
parseText( (WORKSHEET_DATAITEM_TEXT*) item );
|
|
||||||
aLayout->Append( item );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
T token;
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_LEFT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_linewidth:
|
|
||||||
m_defaultLineWidth = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_textsize:
|
|
||||||
m_defaultTextSize.x = parseDouble();
|
|
||||||
m_defaultTextSize.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_textlinewidth:
|
|
||||||
m_defaulTextLineWidth = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
aItem->m_LineWidth = 0;
|
|
||||||
|
|
||||||
T token;
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( token == T_LEFT )
|
|
||||||
token = NextTok();
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_comment: // Comment, search the closing ')'
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_pos:
|
|
||||||
parseCoordinate( aItem->m_Pos );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_pts:
|
|
||||||
parsePolyOutline( aItem );
|
|
||||||
aItem->CloseContour();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_rotate:
|
|
||||||
aItem->m_Orient = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_repeat:
|
|
||||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incrx:
|
|
||||||
aItem->m_IncrementVector.x = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incry:
|
|
||||||
aItem->m_IncrementVector.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_linewidth:
|
|
||||||
aItem->m_LineWidth = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aItem->SetBoundingBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
DPOINT corner;
|
|
||||||
T token;
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( token == T_LEFT )
|
|
||||||
token = NextTok();
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_xy:
|
|
||||||
corner.x = parseDouble();
|
|
||||||
corner.y = parseDouble();
|
|
||||||
aItem->AppendCorner( corner );
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
T token;
|
|
||||||
|
|
||||||
aItem->m_LineWidth = m_defaultLineWidth;
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( token == T_LEFT )
|
|
||||||
token = NextTok();
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_comment: // Comment, search the closing ')'
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_start:
|
|
||||||
parseCoordinate( aItem->m_Pos );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_end:
|
|
||||||
parseCoordinate( aItem->m_End );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_repeat:
|
|
||||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incrx:
|
|
||||||
aItem->m_IncrementVector.x = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incry:
|
|
||||||
aItem->m_IncrementVector.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_linewidth:
|
|
||||||
aItem->m_LineWidth = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
T token;
|
|
||||||
|
|
||||||
aItem->m_TextSize = m_defaultTextSize;
|
|
||||||
aItem->m_LineWidth = m_defaulTextLineWidth;
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if( token == T_LEFT )
|
|
||||||
token = NextTok();
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_comment: // Comment, search the closing ')'
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_pos:
|
|
||||||
parseCoordinate( aItem->m_Pos );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_repeat:
|
|
||||||
aItem->m_RepeatCount = parseInt( -1, 100 );
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incrx:
|
|
||||||
aItem->m_IncrementVector.x = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incry:
|
|
||||||
aItem->m_IncrementVector.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_incrlabel:
|
|
||||||
aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_maxlen:
|
|
||||||
aItem->m_BoundingBoxSize.x = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_maxheight:
|
|
||||||
aItem->m_BoundingBoxSize.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_font:
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_LEFT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_bold:
|
|
||||||
aItem->m_Flags |= USE_BOLD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_italic:
|
|
||||||
aItem->m_Flags |= USE_ITALIC;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_size:
|
|
||||||
aItem->m_TextSize.x = parseDouble();
|
|
||||||
aItem->m_TextSize.y = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_linewidth:
|
|
||||||
aItem->m_LineWidth = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_justify:
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
if( token == T_EOF)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_center:
|
|
||||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER;
|
|
||||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_left:
|
|
||||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_right:
|
|
||||||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_top:
|
|
||||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_bottom:
|
|
||||||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_rotate:
|
|
||||||
aItem->m_Orient = parseDouble();
|
|
||||||
NeedRIGHT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse an expression like " 25 1 ltcorner)"
|
|
||||||
void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
|
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
|
||||||
{
|
|
||||||
T token;
|
|
||||||
|
|
||||||
aCoord.m_Pos.x = parseDouble();
|
|
||||||
aCoord.m_Pos.y = parseDouble();
|
|
||||||
|
|
||||||
while( ( token = NextTok() ) != T_RIGHT )
|
|
||||||
{
|
|
||||||
switch( token )
|
|
||||||
{
|
|
||||||
case T_ltcorner:
|
|
||||||
aCoord.m_Anchor = LT_CORNER; // left top corner
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_lbcorner:
|
|
||||||
aCoord.m_Anchor = LB_CORNER; // left bottom corner
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_rbcorner:
|
|
||||||
aCoord.m_Anchor = RB_CORNER; // right bottom corner
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_rtcorner:
|
|
||||||
aCoord.m_Anchor = RT_CORNER; // right top corner
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Unexpected( CurText() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax )
|
|
||||||
{
|
|
||||||
T token = NextTok();
|
|
||||||
|
|
||||||
if( token != T_NUMBER )
|
|
||||||
Expecting( T_NUMBER );
|
|
||||||
|
|
||||||
int val = atoi( CurText() );
|
|
||||||
|
|
||||||
if( val < aMin )
|
|
||||||
val = aMin;
|
|
||||||
else if( val > aMax )
|
|
||||||
val = aMax;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double PAGE_LAYOUT_READER_PARSER::parseDouble()
|
|
||||||
{
|
|
||||||
T token = NextTok();
|
|
||||||
|
|
||||||
if( token != T_NUMBER )
|
|
||||||
Expecting( T_NUMBER );
|
|
||||||
|
|
||||||
double val = strtod( CurText(), NULL );
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
// defaultPageLayout is the default page layout description
|
|
||||||
// using the S expr.
|
|
||||||
// see page_layout_default_shape.cpp
|
|
||||||
extern const char defaultPageLayout[];
|
|
||||||
|
|
||||||
void WORKSHEET_LAYOUT::SetDefaultLayout()
|
|
||||||
{
|
|
||||||
ClearList();
|
|
||||||
PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, wxT( "default page" ) );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lp_parser.Parse( this );
|
|
||||||
}
|
|
||||||
catch( IO_ERROR ioe )
|
|
||||||
{
|
|
||||||
wxLogMessage( ioe.errorText );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <wx/file.h>
|
|
||||||
|
|
||||||
// SetLayout() try to load a custom layout file,
|
|
||||||
// currently defined by the environment variable KICAD_WKSFILE
|
|
||||||
// (a *.kicad_wks file).
|
|
||||||
// if does not exists, loads the default page layout.
|
|
||||||
void WORKSHEET_LAYOUT::SetLayout()
|
|
||||||
{
|
|
||||||
wxString fullFileName;
|
|
||||||
wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName );
|
|
||||||
|
|
||||||
if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) )
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if( !fullFileName.IsEmpty() )
|
|
||||||
{
|
|
||||||
wxLogMessage( wxT("Page layout file <%s> not found"),
|
|
||||||
fullFileName.GetData() );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
SetDefaultLayout();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFile wksFile( fullFileName );
|
|
||||||
|
|
||||||
if( ! wksFile.IsOpened() )
|
|
||||||
{
|
|
||||||
SetDefaultLayout();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int filelen = wksFile.Length();
|
|
||||||
char * buffer = new char[filelen+10];
|
|
||||||
|
|
||||||
if( wksFile.Read( buffer, filelen ) != filelen )
|
|
||||||
wxLogMessage( _("The file <%s> was not fully read"),
|
|
||||||
fullFileName.GetData() );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buffer[filelen]=0;
|
|
||||||
ClearList();
|
|
||||||
PAGE_LAYOUT_READER_PARSER lp_parser( buffer, fullFileName );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lp_parser.Parse( this );
|
|
||||||
}
|
|
||||||
catch( IO_ERROR ioe )
|
|
||||||
{
|
|
||||||
wxLogMessage( ioe.errorText );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
page_layout
|
|
||||||
setup
|
|
||||||
linewidth
|
|
||||||
textlinewidth
|
|
||||||
textsize
|
|
||||||
comment
|
|
||||||
line
|
|
||||||
rect
|
|
||||||
polygon
|
|
||||||
tbtext
|
|
||||||
ltcorner
|
|
||||||
lbcorner
|
|
||||||
rbcorner
|
|
||||||
rtcorner
|
|
||||||
name
|
|
||||||
pos
|
|
||||||
start
|
|
||||||
end
|
|
||||||
pts
|
|
||||||
xy
|
|
||||||
maxlen
|
|
||||||
maxheight
|
|
||||||
font
|
|
||||||
bold
|
|
||||||
italic
|
|
||||||
size
|
|
||||||
justify
|
|
||||||
left
|
|
||||||
center
|
|
||||||
right
|
|
||||||
top
|
|
||||||
bottom
|
|
||||||
rotate
|
|
||||||
repeat
|
|
||||||
incrx
|
|
||||||
incry
|
|
||||||
incrlabel
|
|
|
@ -122,6 +122,15 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||||
return wxSize(0,0);
|
return wxSize(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bitmap definition in ppi
|
||||||
|
* the default is 300 ppi
|
||||||
|
*/
|
||||||
|
int GetPPI() const
|
||||||
|
{
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetBoundingBox
|
* Function GetBoundingBox
|
||||||
* returns the orthogonal, bounding box of this object for display
|
* returns the orthogonal, bounding box of this object for display
|
||||||
|
@ -147,7 +156,6 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||||
bool ReadImageFile( const wxString& aFullFilename );
|
bool ReadImageFile( const wxString& aFullFilename );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function
|
|
||||||
* writes the bitmap data to aFile
|
* writes the bitmap data to aFile
|
||||||
* The format is png, in Hexadecimal form:
|
* The format is png, in Hexadecimal form:
|
||||||
* If the hexadecimal data is converted to binary it gives exactly a .png image data
|
* If the hexadecimal data is converted to binary it gives exactly a .png image data
|
||||||
|
@ -156,9 +164,17 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||||
*/
|
*/
|
||||||
bool SaveData( FILE* aFile ) const;
|
bool SaveData( FILE* aFile ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writes the bitmap data to an array string
|
||||||
|
* The format is png, in Hexadecimal form:
|
||||||
|
* If the hexadecimal data is converted to binary it gives exactly a .png image data
|
||||||
|
* @param aPngStrings The wxArrayString to write to.
|
||||||
|
*/
|
||||||
|
void SaveData( wxArrayString& aPngStrings ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load an image data saved by SaveData (png, in Hexadecimal form)
|
* Load an image data saved by SaveData (png, in Hexadecimal form)
|
||||||
* @param aLine - Essentially this is file to read schematic junction from.
|
* @param aLine - the LINE_READER used to read the data file.
|
||||||
* @param aErrorMsg - Description of the error if an error occurs while loading the
|
* @param aErrorMsg - Description of the error if an error occurs while loading the
|
||||||
* png bimap data.
|
* png bimap data.
|
||||||
* @return true if the bitmap loaded successfully.
|
* @return true if the bitmap loaded successfully.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <vector2d.h>
|
#include <vector2d.h>
|
||||||
#include <eda_text.h>
|
#include <eda_text.h>
|
||||||
|
#include <class_bitmap_base.h>
|
||||||
|
|
||||||
class WS_DRAW_ITEM_TEXT; // Forward declaration
|
class WS_DRAW_ITEM_TEXT; // Forward declaration
|
||||||
|
|
||||||
|
@ -75,7 +76,8 @@ public:
|
||||||
WS_TEXT,
|
WS_TEXT,
|
||||||
WS_SEGMENT,
|
WS_SEGMENT,
|
||||||
WS_RECT,
|
WS_RECT,
|
||||||
WS_POLYPOLYGON
|
WS_POLYPOLYGON,
|
||||||
|
WS_BITMAP
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -465,4 +467,43 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BITMAP_BASE;
|
||||||
|
class WORKSHEET_DATAITEM_BITMAP : public WORKSHEET_DATAITEM
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BITMAP_BASE* m_ImageBitmap;
|
||||||
|
|
||||||
|
public:
|
||||||
|
WORKSHEET_DATAITEM_BITMAP(BITMAP_BASE* aImage)
|
||||||
|
: WORKSHEET_DATAITEM( WS_BITMAP )
|
||||||
|
{
|
||||||
|
m_ImageBitmap = aImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return false (no end point)
|
||||||
|
*/
|
||||||
|
virtual bool HasEndPoint() { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the pixel scale factor of the bitmap
|
||||||
|
* this factor depend on the application internal unit
|
||||||
|
* and the pixel per inch bitmap factor
|
||||||
|
* the pixel scale factor is the pixel size to application internal unit
|
||||||
|
* and should be initialized before printing or drawing the bitmap
|
||||||
|
*/
|
||||||
|
void SetPixelScaleFactor()
|
||||||
|
{
|
||||||
|
if( m_ImageBitmap )
|
||||||
|
{
|
||||||
|
// m_WSunits2Iu is the page layout unit to application internal unit
|
||||||
|
// i.e. the mm to to application internal unit
|
||||||
|
// however the bitmap definition is always known in pixels per inches
|
||||||
|
double scale = m_WSunits2Iu * 25.4 / m_ImageBitmap->GetPPI();
|
||||||
|
m_ImageBitmap->SetPixelScaleFactor( scale );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // CLASS_WORKSHEET_DATA_ITEM_H
|
#endif // CLASS_WORKSHEET_DATA_ITEM_H
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include <vector2d.h>
|
#include <vector2d.h>
|
||||||
#include <eda_text.h>
|
#include <eda_text.h>
|
||||||
|
#include <eda_text.h>
|
||||||
|
#include <class_bitmap_base.h>
|
||||||
|
|
||||||
class WORKSHEET_DATAITEM; // Forward declaration
|
class WORKSHEET_DATAITEM; // Forward declaration
|
||||||
class TITLE_BLOCK;
|
class TITLE_BLOCK;
|
||||||
|
@ -22,12 +24,14 @@ class TITLE_BLOCK;
|
||||||
* rect
|
* rect
|
||||||
* polygons (for logos)
|
* polygons (for logos)
|
||||||
* graphic texts
|
* graphic texts
|
||||||
|
* bitmaps, also for logos, but they cannot be plot by SVG, GERBER
|
||||||
|
* and HPGL plotters (In this case, only the bounding box is plotted)
|
||||||
*/
|
*/
|
||||||
class WS_DRAW_ITEM_BASE // This basic class, not directly usable.
|
class WS_DRAW_ITEM_BASE // This basic class, not directly usable.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum WS_DRAW_TYPE {
|
enum WS_DRAW_TYPE {
|
||||||
wsg_line, wsg_rect, wsg_poly, wsg_text
|
wsg_line, wsg_rect, wsg_poly, wsg_text, wsg_bitmap
|
||||||
};
|
};
|
||||||
int m_Flags; // temporary flgs used in page layout editor
|
int m_Flags; // temporary flgs used in page layout editor
|
||||||
// to locate the item;
|
// to locate the item;
|
||||||
|
@ -244,6 +248,43 @@ public:
|
||||||
virtual bool HitTestStartPoint( const wxPoint& aPosition);
|
virtual bool HitTestStartPoint( const wxPoint& aPosition);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This class draws a bitmap.
|
||||||
|
class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE
|
||||||
|
{
|
||||||
|
wxPoint m_pos; // position of reference point
|
||||||
|
|
||||||
|
public:
|
||||||
|
WS_DRAW_ITEM_BITMAP( WORKSHEET_DATAITEM* aParent, wxPoint aPos )
|
||||||
|
:WS_DRAW_ITEM_BASE( aParent, wsg_bitmap, UNSPECIFIED_COLOR )
|
||||||
|
{
|
||||||
|
m_pos = aPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
WS_DRAW_ITEM_BITMAP()
|
||||||
|
:WS_DRAW_ITEM_BASE( NULL, wsg_bitmap, UNSPECIFIED_COLOR )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~WS_DRAW_ITEM_BITMAP() {}
|
||||||
|
|
||||||
|
/** The function to draw a WS_DRAW_ITEM_BITMAP
|
||||||
|
*/
|
||||||
|
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual function
|
||||||
|
* return true if the point aPosition is on bitmap
|
||||||
|
*/
|
||||||
|
virtual bool HitTest( const wxPoint& aPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true if the point aPosition is on the reference point of this item.
|
||||||
|
*/
|
||||||
|
virtual bool HitTestStartPoint( const wxPoint& aPosition);
|
||||||
|
|
||||||
|
const wxPoint& GetPosition() { return m_pos; }
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this class stores the list of graphic items:
|
* this class stores the list of graphic items:
|
||||||
* rect, lines, polygons and texts to draw/plot
|
* rect, lines, polygons and texts to draw/plot
|
||||||
|
|
|
@ -132,6 +132,25 @@ static const char* poly_xpm[] =
|
||||||
" xx "
|
" xx "
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* img_xpm[] =
|
||||||
|
{
|
||||||
|
"12 12 2 1",
|
||||||
|
" c None",
|
||||||
|
"x c #800000",
|
||||||
|
" xx ",
|
||||||
|
" xxxxxx ",
|
||||||
|
" xx xx ",
|
||||||
|
"xx xx",
|
||||||
|
"xx xx",
|
||||||
|
" xx xx ",
|
||||||
|
" xxxxxx ",
|
||||||
|
" xx ",
|
||||||
|
" xx ",
|
||||||
|
" xx ",
|
||||||
|
" xx ",
|
||||||
|
" xx "
|
||||||
|
};
|
||||||
|
|
||||||
// Event table:
|
// Event table:
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,13 +166,14 @@ DESIGN_TREE_FRAME::DESIGN_TREE_FRAME( PL_EDITOR_FRAME* aParent ) :
|
||||||
iconsize.y = root_bm.GetHeight();
|
iconsize.y = root_bm.GetHeight();
|
||||||
|
|
||||||
// Make an image list containing small icons
|
// Make an image list containing small icons
|
||||||
m_imageList = new wxImageList( iconsize.x, iconsize.y, true, 4 );
|
m_imageList = new wxImageList( iconsize.x, iconsize.y, true, 6 );
|
||||||
|
|
||||||
m_imageList->Add( root_bm ); // root symbol
|
m_imageList->Add( root_bm ); // root symbol
|
||||||
m_imageList->Add( wxBitmap( line_xpm ) ); // line item
|
m_imageList->Add( wxBitmap( line_xpm ) ); // line item
|
||||||
m_imageList->Add( wxBitmap( rect_xpm ) ); // rect item
|
m_imageList->Add( wxBitmap( rect_xpm ) ); // rect item
|
||||||
m_imageList->Add( wxBitmap( text_xpm ) ); // text item
|
m_imageList->Add( wxBitmap( text_xpm ) ); // text item
|
||||||
m_imageList->Add( wxBitmap( poly_xpm ) ); // poly item
|
m_imageList->Add( wxBitmap( poly_xpm ) ); // poly item
|
||||||
|
m_imageList->Add( wxBitmap( img_xpm ) ); // bitmap item
|
||||||
|
|
||||||
SetImageList( m_imageList );
|
SetImageList( m_imageList );
|
||||||
}
|
}
|
||||||
|
@ -201,6 +221,7 @@ void DESIGN_TREE_FRAME::ReCreateDesignTree()
|
||||||
case WORKSHEET_DATAITEM::WS_RECT: img = 2; break;
|
case WORKSHEET_DATAITEM::WS_RECT: img = 2; break;
|
||||||
case WORKSHEET_DATAITEM::WS_TEXT: img = 3; break;
|
case WORKSHEET_DATAITEM::WS_TEXT: img = 3; break;
|
||||||
case WORKSHEET_DATAITEM::WS_POLYPOLYGON: img = 4; break;
|
case WORKSHEET_DATAITEM::WS_POLYPOLYGON: img = 4; break;
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP: img = 5; break;
|
||||||
}
|
}
|
||||||
wxTreeItemId cell= AppendItem( rootitem, item->m_Name, img, img );
|
wxTreeItemId cell= AppendItem( rootitem, item->m_Name, img, img );
|
||||||
DESIGN_TREE_ITEM_DATA* data = new DESIGN_TREE_ITEM_DATA( item );
|
DESIGN_TREE_ITEM_DATA* data = new DESIGN_TREE_ITEM_DATA( item );
|
||||||
|
|
|
@ -133,12 +133,14 @@ void DIALOG_NEW_DATAITEM::initDlg()
|
||||||
m_textCtrlText->Enable( false );
|
m_textCtrlText->Enable( false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
||||||
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
||||||
m_textCtrlText->Enable( false );
|
m_textCtrlText->Enable( false );
|
||||||
// fall through
|
// fall through
|
||||||
case WORKSHEET_DATAITEM::WS_TEXT:
|
case WORKSHEET_DATAITEM::WS_TEXT:
|
||||||
m_textCtrlEndX->Enable( false );
|
m_textCtrlEndX->Enable( false );
|
||||||
m_textCtrlEndY->Enable( false );
|
m_textCtrlEndY->Enable( false );
|
||||||
|
m_choiceCornerEnd->Enable( false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
|
||||||
// menu Preferences
|
// menu Preferences
|
||||||
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
||||||
PL_EDITOR_FRAME::Process_Config )
|
PL_EDITOR_FRAME::Process_Config )
|
||||||
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EDA_DRAW_FRAME::SetLanguage )
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
||||||
|
EDA_DRAW_FRAME::SetLanguage )
|
||||||
EVT_MENU( ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
|
EVT_MENU( ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
|
||||||
EDA_BASE_FRAME::OnSelectPreferredEditor )
|
EDA_BASE_FRAME::OnSelectPreferredEditor )
|
||||||
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
|
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
|
||||||
|
@ -246,6 +247,25 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ID_POPUP_ITEM_ADD_BITMAP:
|
||||||
|
SaveCopyInUndoList();
|
||||||
|
idx = m_treePagelayout->GetSelectedItemIndex();
|
||||||
|
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
|
||||||
|
if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
|
||||||
|
{
|
||||||
|
RemoveLastCommandInUndoList();
|
||||||
|
pglayout.Remove( item );
|
||||||
|
RebuildDesignTree();
|
||||||
|
item = NULL;
|
||||||
|
}
|
||||||
|
if( item )
|
||||||
|
{
|
||||||
|
// Put the new text in move mode:
|
||||||
|
item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
|
||||||
|
MoveItem( item );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT:
|
case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT:
|
||||||
cmd.SetId( ID_APPEND_DESCR_FILE );
|
cmd.SetId( ID_APPEND_DESCR_FILE );
|
||||||
wxPostEvent( this, cmd );
|
wxPostEvent( this, cmd );
|
||||||
|
|
|
@ -51,6 +51,9 @@ void AddNewItemsCommand( wxMenu* aMainMenu )
|
||||||
AddMenuItem( aMainMenu, ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
|
AddMenuItem( aMainMenu, ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
|
||||||
_( "Append Page Layout Descr File" ),
|
_( "Append Page Layout Descr File" ),
|
||||||
KiBitmap( import_xpm ) );
|
KiBitmap( import_xpm ) );
|
||||||
|
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_BITMAP,
|
||||||
|
_( "Add Bitmap" ),
|
||||||
|
KiBitmap( image_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the right-click pullup menu.
|
/* Prepare the right-click pullup menu.
|
||||||
|
@ -85,19 +88,19 @@ bool PL_EDITOR_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
|
||||||
|
|
||||||
if( (item->GetFlags() & LOCATE_ENDPOINT ) )
|
if( (item->GetFlags() & LOCATE_ENDPOINT ) )
|
||||||
{
|
{
|
||||||
msg = AddHotkeyName( _( "Move End Point" ), s_PlEditor_Hokeys_Descr,
|
msg = AddHotkeyName( _( "Move End Point" ), s_PlEditor_Hokeys_Descr,
|
||||||
HK_MOVE_END_POINT );
|
HK_MOVE_END_POINT );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_END_POINT, msg,
|
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_END_POINT, msg,
|
||||||
KiBitmap( move_xpm ) );
|
KiBitmap( move_xpm ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Move Item" ), s_PlEditor_Hokeys_Descr,
|
msg = AddHotkeyName( _( "Move Item" ), s_PlEditor_Hokeys_Descr,
|
||||||
HK_MOVE_ITEM );
|
HK_MOVE_ITEM );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE, msg,
|
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE, msg,
|
||||||
KiBitmap( move_xpm ) );
|
KiBitmap( move_xpm ) );
|
||||||
aPopMenu->AppendSeparator();
|
aPopMenu->AppendSeparator();
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Delete" ), s_PlEditor_Hokeys_Descr,
|
msg = AddHotkeyName( _( "Delete" ), s_PlEditor_Hokeys_Descr,
|
||||||
HK_DELETE_ITEM );
|
HK_DELETE_ITEM );
|
||||||
AddMenuItem( aPopMenu, ID_POPUP_ITEM_DELETE, msg, KiBitmap( delete_xpm ) );
|
AddMenuItem( aPopMenu, ID_POPUP_ITEM_DELETE, msg, KiBitmap( delete_xpm ) );
|
||||||
aPopMenu->AppendSeparator();
|
aPopMenu->AppendSeparator();
|
||||||
|
|
|
@ -76,6 +76,8 @@ private:
|
||||||
void format( WORKSHEET_DATAITEM* aItem, int aNestLevel ) const throw( IO_ERROR );
|
void format( WORKSHEET_DATAITEM* aItem, int aNestLevel ) const throw( IO_ERROR );
|
||||||
void format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNestLevel )
|
void format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNestLevel )
|
||||||
const throw( IO_ERROR );
|
const throw( IO_ERROR );
|
||||||
|
void format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLevel ) const
|
||||||
|
throw( IO_ERROR );
|
||||||
void formatCoordinate( const char * aToken, POINT_COORD & aCoord ) const
|
void formatCoordinate( const char * aToken, POINT_COORD & aCoord ) const
|
||||||
throw( IO_ERROR );
|
throw( IO_ERROR );
|
||||||
void formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) const throw( IO_ERROR );
|
void formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) const throw( IO_ERROR );
|
||||||
|
@ -172,6 +174,10 @@ void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_DATAITEM* aItem, int aNestLevel ) co
|
||||||
format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
|
format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
||||||
|
format( (WORKSHEET_DATAITEM_BITMAP*) aItem, aNestLevel );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxT( "Cannot format item" ) );
|
wxFAIL_MSG( wxT( "Cannot format item" ) );
|
||||||
}
|
}
|
||||||
|
@ -360,6 +366,34 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNe
|
||||||
m_out->Print( aNestLevel, ")\n" );
|
m_out->Print( aNestLevel, ")\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLevel ) const
|
||||||
|
throw( IO_ERROR )
|
||||||
|
{
|
||||||
|
m_out->Print( aNestLevel, "( %s", getTokenName( T_bitmap ) );
|
||||||
|
m_out->Print( 0, " (%s %s)", getTokenName( T_name ),
|
||||||
|
m_out->Quotew( aItem->m_Name ).c_str() );
|
||||||
|
formatCoordinate( getTokenName( T_pos ), aItem->m_Pos );
|
||||||
|
formatOptions( aItem );
|
||||||
|
|
||||||
|
m_out->Print( 0, " (%s %s)", getTokenName( T_scale ),
|
||||||
|
double2Str(aItem->m_ImageBitmap->m_Scale ).c_str() );
|
||||||
|
|
||||||
|
formatRepeatParameters( aItem );
|
||||||
|
m_out->Print( 0,"\n");
|
||||||
|
|
||||||
|
// Write image in png readable format
|
||||||
|
m_out->Print( aNestLevel, "( %s\n", getTokenName( T_pngdata ) );
|
||||||
|
wxArrayString pngStrings;
|
||||||
|
aItem->m_ImageBitmap->SaveData( pngStrings );
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < pngStrings.GetCount(); ii++ )
|
||||||
|
m_out->Print( aNestLevel+1, "(data \"%s\")\n", TO_UTF8(pngStrings[ii]) );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel+1, ")\n" );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel, ")\n" );
|
||||||
|
}
|
||||||
|
|
||||||
void WORKSHEET_LAYOUT_IO::formatCoordinate( const char * aToken,
|
void WORKSHEET_LAYOUT_IO::formatCoordinate( const char * aToken,
|
||||||
POINT_COORD & aCoord ) const
|
POINT_COORD & aCoord ) const
|
||||||
throw( IO_ERROR )
|
throw( IO_ERROR )
|
||||||
|
|
|
@ -521,6 +521,7 @@ void PL_EDITOR_FRAME::RebuildDesignTree()
|
||||||
int lineId = 0;
|
int lineId = 0;
|
||||||
int textId = 0;
|
int textId = 0;
|
||||||
int polyId = 0;
|
int polyId = 0;
|
||||||
|
int bitmapId = 0;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
|
@ -546,6 +547,11 @@ void PL_EDITOR_FRAME::RebuildDesignTree()
|
||||||
item->m_Name = wxString::Format( wxT("poly%d:%s"), ++polyId,
|
item->m_Name = wxString::Format( wxT("poly%d:%s"), ++polyId,
|
||||||
GetChars(item->GetClassName()) );
|
GetChars(item->GetClassName()) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
||||||
|
item->m_Name = wxString::Format( wxT("bm%d:%s"), ++bitmapId,
|
||||||
|
GetChars(item->GetClassName()) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,6 +582,35 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
|
||||||
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
|
||||||
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
|
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WORKSHEET_DATAITEM::WS_BITMAP:
|
||||||
|
{
|
||||||
|
wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
|
||||||
|
_( "Image Files " ) + wxImage::GetImageExtWildcard(),
|
||||||
|
wxFD_OPEN );
|
||||||
|
|
||||||
|
if( fileDlg.ShowModal() != wxID_OK )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
wxString fullFilename = fileDlg.GetPath();
|
||||||
|
|
||||||
|
if( !wxFileExists( fullFilename ) )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BITMAP_BASE* image = new BITMAP_BASE();
|
||||||
|
|
||||||
|
if( !image->ReadImageFile( fullFilename ) )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Couldn't load image from <%s>" ),
|
||||||
|
GetChars( fullFilename ) );
|
||||||
|
delete image;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
item = new WORKSHEET_DATAITEM_BITMAP( image );
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( item == NULL )
|
if( item == NULL )
|
||||||
|
|
|
@ -63,12 +63,14 @@ enum pl_editor_ids
|
||||||
ID_POPUP_ITEM_ADD_LINE,
|
ID_POPUP_ITEM_ADD_LINE,
|
||||||
ID_POPUP_ITEM_ADD_RECT,
|
ID_POPUP_ITEM_ADD_RECT,
|
||||||
ID_POPUP_ITEM_ADD_TEXT,
|
ID_POPUP_ITEM_ADD_TEXT,
|
||||||
|
ID_POPUP_ITEM_ADD_BITMAP,
|
||||||
ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
|
ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
|
||||||
ID_POPUP_ITEM_MOVE,
|
ID_POPUP_ITEM_MOVE,
|
||||||
ID_POPUP_ITEM_PLACE,
|
ID_POPUP_ITEM_PLACE,
|
||||||
ID_POPUP_ITEM_MOVE_START_POINT,
|
ID_POPUP_ITEM_MOVE_START_POINT,
|
||||||
ID_POPUP_ITEM_MOVE_END_POINT,
|
ID_POPUP_ITEM_MOVE_END_POINT,
|
||||||
ID_POPUP_ITEM_PLACE_CANCEL,
|
ID_POPUP_ITEM_PLACE_CANCEL,
|
||||||
|
ID_POPUP_ITEM_EDIT_BITMAP,
|
||||||
ID_POPUP_END_RANGE,
|
ID_POPUP_END_RANGE,
|
||||||
|
|
||||||
ID_PLEDITOR_END_LIST
|
ID_PLEDITOR_END_LIST
|
||||||
|
|
|
@ -249,13 +249,18 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WORKSHEET_DATAITEM* aItem )
|
||||||
msg.Printf( wxT("%.3f"), item->m_Orient );
|
msg.Printf( wxT("%.3f"), item->m_Orient );
|
||||||
m_textCtrlRotation->SetValue( msg );
|
m_textCtrlRotation->SetValue( msg );
|
||||||
}
|
}
|
||||||
|
else if(aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
|
||||||
|
{
|
||||||
|
m_staticTextInfoThickness->Show( false );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_staticTextInfoThickness->Show( true );
|
m_staticTextInfoThickness->Show( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_SEGMENT ||
|
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_SEGMENT ||
|
||||||
aItem->GetType() == WORKSHEET_DATAITEM::WS_RECT )
|
aItem->GetType() == WORKSHEET_DATAITEM::WS_RECT ||
|
||||||
|
aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
|
||||||
{
|
{
|
||||||
m_SizerRotation->Show( false );
|
m_SizerRotation->Show( false );
|
||||||
m_SizerEndPosition->Show(true);
|
m_SizerEndPosition->Show(true);
|
||||||
|
|
Loading…
Reference in New Issue