Eeschema: add saving schematic files to schematic plugin.
* Add SCH_PLUGIN::Save() for current file format and code for saving all SCH_XXX objects. * Add function to SCH_FIELD to get the position of the field in the component not the position added to the component position which is what GetPosition() does. This was required because saving the component field expects position of the field sans the position of the component. * Remove public members from BITMAP_BASE object and fix all associated code. * Fix the never ending coding policy violations found making these changes.
This commit is contained in:
parent
34469c1d9c
commit
98ad5096b0
|
@ -46,7 +46,7 @@
|
|||
|
||||
BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
|
||||
{
|
||||
m_Scale = 1.0; // 1.0 = original bitmap size
|
||||
m_scale = 1.0; // 1.0 = original bitmap size
|
||||
m_bitmap = NULL;
|
||||
m_image = NULL;
|
||||
m_ppi = 300; // the bitmap definition. the default is 300PPI
|
||||
|
@ -57,7 +57,7 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
|
|||
|
||||
BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap )
|
||||
{
|
||||
m_Scale = aSchBitmap.m_Scale;
|
||||
m_scale = aSchBitmap.m_scale;
|
||||
m_ppi = aSchBitmap.m_ppi;
|
||||
m_pixelScaleFactor = aSchBitmap.m_pixelScaleFactor;
|
||||
m_image = new wxImage( *aSchBitmap.m_image );
|
||||
|
@ -73,7 +73,7 @@ void BITMAP_BASE::ImportData( BITMAP_BASE* aItem )
|
|||
{
|
||||
*m_image = *aItem->m_image;
|
||||
*m_bitmap = *aItem->m_bitmap;
|
||||
m_Scale = aItem->m_Scale;
|
||||
m_scale = aItem->m_scale;
|
||||
m_ppi = aItem->m_ppi;
|
||||
m_pixelScaleFactor = aItem->m_pixelScaleFactor;
|
||||
}
|
||||
|
@ -189,9 +189,11 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
// each byte = 2 hexadecimal digits and a space between 2 bytes
|
||||
// and put it in memory stream buffer
|
||||
int len = strlen( line );
|
||||
|
||||
for( ; len > 0; len -= 3, line += 3 )
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
if( sscanf( line, "%X", &value ) == 1 )
|
||||
stream.PutC( (char) value );
|
||||
else
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 jean-pierre.charras
|
||||
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2011-2016 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
|
||||
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <dialog_image_editor.h>
|
||||
|
||||
|
||||
DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem )
|
||||
: DIALOG_IMAGE_EDITOR_BASE( aParent )
|
||||
{
|
||||
|
@ -40,7 +41,7 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem
|
|||
m_lastImage = NULL;
|
||||
m_buttonUndoLast->Enable( false );
|
||||
wxString msg;
|
||||
msg.Printf( wxT("%f"), m_workingImage->m_Scale );
|
||||
msg.Printf( wxT( "%f" ), m_workingImage->GetScale() );
|
||||
m_textCtrlScale->SetValue( msg );
|
||||
|
||||
GetSizer()->SetSizeHints( this );
|
||||
|
@ -52,6 +53,7 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem
|
|||
SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnUndoLastChange( wxCommandEvent& event )
|
||||
{
|
||||
BITMAP_BASE * tmp = m_workingImage;
|
||||
|
@ -62,6 +64,7 @@ void DIALOG_IMAGE_EDITOR::OnUndoLastChange( wxCommandEvent& event )
|
|||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnMirrorX_click( wxCommandEvent& event )
|
||||
{
|
||||
delete m_lastImage;
|
||||
|
@ -72,6 +75,7 @@ void DIALOG_IMAGE_EDITOR::OnMirrorX_click( wxCommandEvent& event )
|
|||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnMirrorY_click( wxCommandEvent& event )
|
||||
{
|
||||
delete m_lastImage;
|
||||
|
@ -81,6 +85,7 @@ void DIALOG_IMAGE_EDITOR::OnMirrorY_click( wxCommandEvent& event )
|
|||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnRotateClick( wxCommandEvent& event )
|
||||
{
|
||||
delete m_lastImage;
|
||||
|
@ -90,6 +95,7 @@ void DIALOG_IMAGE_EDITOR::OnRotateClick( wxCommandEvent& event )
|
|||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event )
|
||||
{
|
||||
delete m_lastImage;
|
||||
|
@ -101,6 +107,7 @@ void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event )
|
|||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnHalfSize( wxCommandEvent& event )
|
||||
{
|
||||
delete m_lastImage;
|
||||
|
@ -109,11 +116,12 @@ void DIALOG_IMAGE_EDITOR::OnHalfSize( wxCommandEvent& event )
|
|||
wxSize psize = m_workingImage->GetSizePixels();
|
||||
wxImage& image = *m_workingImage->GetImageData();
|
||||
|
||||
image = image.Scale(psize.x/2, psize.y/2, wxIMAGE_QUALITY_HIGH);
|
||||
image = image.Scale( psize.x/2, psize.y/2, wxIMAGE_QUALITY_HIGH );
|
||||
m_workingImage->RebuildBitmap();
|
||||
m_panelDraw->Refresh();
|
||||
}
|
||||
|
||||
|
||||
/* Test params values correctness
|
||||
* Currently scale value must give an actual image
|
||||
* > MIN_SIZE pixels and < MAX_SIZE pixels
|
||||
|
@ -124,6 +132,7 @@ bool DIALOG_IMAGE_EDITOR::CheckValues()
|
|||
#define MAX_SIZE 6000
|
||||
double tmp;
|
||||
wxString msg = m_textCtrlScale->GetValue();
|
||||
|
||||
// Test number correctness
|
||||
if( ! msg.ToDouble( &tmp ) )
|
||||
{
|
||||
|
@ -133,12 +142,14 @@ bool DIALOG_IMAGE_EDITOR::CheckValues()
|
|||
|
||||
// Test value correctness
|
||||
wxSize psize = m_workingImage->GetSizePixels();
|
||||
if ( (psize.x * tmp) < MIN_SIZE || (psize.y * tmp) < MIN_SIZE )
|
||||
|
||||
if( (psize.x * tmp) < MIN_SIZE || (psize.y * tmp) < MIN_SIZE )
|
||||
{
|
||||
wxMessageBox( _("Scale is too small for this image" ) );
|
||||
return false;
|
||||
}
|
||||
if ( (psize.x * tmp) > MAX_SIZE || (psize.y * tmp) > MAX_SIZE )
|
||||
|
||||
if( (psize.x * tmp) > MAX_SIZE || (psize.y * tmp) > MAX_SIZE )
|
||||
{
|
||||
wxMessageBox( _("Scale is too large for this image" ) );
|
||||
return false;
|
||||
|
@ -147,18 +158,22 @@ bool DIALOG_IMAGE_EDITOR::CheckValues()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnOK_Button( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( CheckValues() )
|
||||
EndModal( wxID_OK );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnCancel_Button( wxCommandEvent& aEvent )
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::OnRedrawPanel( wxPaintEvent& event )
|
||||
{
|
||||
wxPaintDC dc( m_panelDraw );
|
||||
|
@ -167,13 +182,15 @@ void DIALOG_IMAGE_EDITOR::OnRedrawPanel( wxPaintEvent& event )
|
|||
|
||||
double scale = 1.0 / m_workingImage->GetScalingFactor();
|
||||
dc.SetUserScale( scale, scale );
|
||||
m_workingImage->DrawBitmap( NULL, &dc, wxPoint(0,0) );
|
||||
m_workingImage->DrawBitmap( NULL, &dc, wxPoint( 0, 0 ) );
|
||||
}
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::TransfertToImage(BITMAP_BASE* aItem )
|
||||
|
||||
void DIALOG_IMAGE_EDITOR::TransfertToImage( BITMAP_BASE* aItem )
|
||||
{
|
||||
wxString msg = m_textCtrlScale->GetValue();
|
||||
msg.ToDouble( &m_workingImage->m_Scale );
|
||||
double scale = 1.0;
|
||||
msg.ToDouble( &scale );
|
||||
m_workingImage->SetScale( scale );
|
||||
aItem->ImportData( m_workingImage );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* 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.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -74,6 +74,7 @@ EDA_COLOR_T WORKSHEET_DATAITEM::m_Color = RED; // the default color
|
|||
EDA_COLOR_T WORKSHEET_DATAITEM::m_AltColor = RED; // an alternate color to draw items
|
||||
EDA_COLOR_T WORKSHEET_DATAITEM::m_SelectedColor = BROWN; // the color to draw selected items
|
||||
|
||||
|
||||
// The constructor:
|
||||
WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ItemType aType )
|
||||
{
|
||||
|
@ -84,6 +85,7 @@ WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ItemType aType )
|
|||
m_LineWidth = 0;
|
||||
}
|
||||
|
||||
|
||||
// move item to aPosition
|
||||
// starting point is moved to aPosition
|
||||
// the Ending point is moved to a position which keeps the item size
|
||||
|
@ -99,6 +101,7 @@ void WORKSHEET_DATAITEM::MoveToUi( wxPoint aPosition )
|
|||
MoveTo( pos_mm );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_DATAITEM::MoveTo( DPOINT aPosition )
|
||||
{
|
||||
DPOINT vector = aPosition - GetStartPos();
|
||||
|
@ -108,6 +111,7 @@ void WORKSHEET_DATAITEM::MoveTo( DPOINT aPosition )
|
|||
MoveEndPointTo( endpos );
|
||||
}
|
||||
|
||||
|
||||
/* move the starting point of the item to a new position
|
||||
* aPosition = the new position of the starting point, in mm
|
||||
*/
|
||||
|
@ -120,28 +124,29 @@ void WORKSHEET_DATAITEM::MoveStartPointTo( DPOINT aPosition )
|
|||
// aPosition is the position relative to the right top paper corner
|
||||
switch( m_Pos.m_Anchor )
|
||||
{
|
||||
case RB_CORNER:
|
||||
position = m_RB_Corner - aPosition;
|
||||
break;
|
||||
case RB_CORNER:
|
||||
position = m_RB_Corner - aPosition;
|
||||
break;
|
||||
|
||||
case RT_CORNER:
|
||||
position.x = m_RB_Corner.x - aPosition.x;
|
||||
position.y = aPosition.y - m_LT_Corner.y;
|
||||
break;
|
||||
case RT_CORNER:
|
||||
position.x = m_RB_Corner.x - aPosition.x;
|
||||
position.y = aPosition.y - m_LT_Corner.y;
|
||||
break;
|
||||
|
||||
case LB_CORNER:
|
||||
position.x = aPosition.x - m_LT_Corner.x;
|
||||
position.y = m_RB_Corner.y - aPosition.y;
|
||||
break;
|
||||
case LB_CORNER:
|
||||
position.x = aPosition.x - m_LT_Corner.x;
|
||||
position.y = m_RB_Corner.y - aPosition.y;
|
||||
break;
|
||||
|
||||
case LT_CORNER:
|
||||
position = aPosition - m_LT_Corner;
|
||||
break;
|
||||
case LT_CORNER:
|
||||
position = aPosition - m_LT_Corner;
|
||||
break;
|
||||
}
|
||||
|
||||
m_Pos.m_Pos = position;
|
||||
}
|
||||
|
||||
|
||||
/* move the starting point of the item to a new position
|
||||
* aPosition = the new position of the starting point in graphic units
|
||||
*/
|
||||
|
@ -154,6 +159,7 @@ void WORKSHEET_DATAITEM::MoveStartPointToUi( wxPoint aPosition )
|
|||
MoveStartPointTo( pos_mm );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* move the ending point of the item to a new position
|
||||
* has meaning only for items defined by 2 points
|
||||
|
@ -169,38 +175,39 @@ void WORKSHEET_DATAITEM::MoveEndPointTo( DPOINT aPosition )
|
|||
// aPosition is the position relative to the right top paper corner
|
||||
switch( m_End.m_Anchor )
|
||||
{
|
||||
case RB_CORNER:
|
||||
position = m_RB_Corner - aPosition;
|
||||
break;
|
||||
case RB_CORNER:
|
||||
position = m_RB_Corner - aPosition;
|
||||
break;
|
||||
|
||||
case RT_CORNER:
|
||||
position.x = m_RB_Corner.x - aPosition.x;
|
||||
position.y = aPosition.y - m_LT_Corner.y;
|
||||
break;
|
||||
case RT_CORNER:
|
||||
position.x = m_RB_Corner.x - aPosition.x;
|
||||
position.y = aPosition.y - m_LT_Corner.y;
|
||||
break;
|
||||
|
||||
case LB_CORNER:
|
||||
position.x = aPosition.x - m_LT_Corner.x;
|
||||
position.y = m_RB_Corner.y - aPosition.y;
|
||||
break;
|
||||
case LB_CORNER:
|
||||
position.x = aPosition.x - m_LT_Corner.x;
|
||||
position.y = m_RB_Corner.y - aPosition.y;
|
||||
break;
|
||||
|
||||
case LT_CORNER:
|
||||
position = aPosition - m_LT_Corner;
|
||||
break;
|
||||
case LT_CORNER:
|
||||
position = aPosition - m_LT_Corner;
|
||||
break;
|
||||
}
|
||||
|
||||
// Modify m_End only for items having 2 coordinates
|
||||
switch( GetType() )
|
||||
{
|
||||
case WS_SEGMENT:
|
||||
case WS_RECT:
|
||||
m_End.m_Pos = position;
|
||||
break;
|
||||
case WS_SEGMENT:
|
||||
case WS_RECT:
|
||||
m_End.m_Pos = position;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* move the ending point of the item to a new position
|
||||
* has meaning only for items defined by 2 points
|
||||
* (segments and rectangles)
|
||||
|
@ -215,6 +222,7 @@ void WORKSHEET_DATAITEM::MoveEndPointToUi( wxPoint aPosition )
|
|||
MoveEndPointTo( pos_mm );
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WORKSHEET_DATAITEM::GetStartPos( int ii ) const
|
||||
{
|
||||
DPOINT pos;
|
||||
|
@ -245,18 +253,21 @@ const DPOINT WORKSHEET_DATAITEM::GetStartPos( int ii ) const
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WORKSHEET_DATAITEM::GetStartPosUi( int ii ) const
|
||||
{
|
||||
DPOINT pos = GetStartPos( ii );
|
||||
pos = pos * m_WSunits2Iu;
|
||||
return wxPoint( KiROUND(pos.x), KiROUND(pos.y) );
|
||||
return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WORKSHEET_DATAITEM::GetEndPos( int ii ) const
|
||||
{
|
||||
DPOINT pos;
|
||||
pos.x = m_End.m_Pos.x + ( m_IncrementVector.x * ii );
|
||||
pos.y = m_End.m_Pos.y + ( m_IncrementVector.y * ii );
|
||||
|
||||
switch( m_End.m_Anchor )
|
||||
{
|
||||
case RB_CORNER: // right bottom corner
|
||||
|
@ -281,11 +292,12 @@ const DPOINT WORKSHEET_DATAITEM::GetEndPos( int ii ) const
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WORKSHEET_DATAITEM::GetEndPosUi( int ii ) const
|
||||
{
|
||||
DPOINT pos = GetEndPos( ii );
|
||||
pos = pos * m_WSunits2Iu;
|
||||
return wxPoint( KiROUND(pos.x), KiROUND(pos.y) );
|
||||
return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,21 +319,24 @@ bool WORKSHEET_DATAITEM::IsInsidePage( int ii ) const
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
const wxString WORKSHEET_DATAITEM::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("Rect"); break;
|
||||
case WS_POLYPOLYGON: name = wxT("Poly"); break;
|
||||
case WS_BITMAP: name = wxT("Bitmap"); break;
|
||||
case WS_TEXT: name = wxT( "Text" ); break;
|
||||
case WS_SEGMENT: name = wxT( "Line" ); break;
|
||||
case WS_RECT: name = wxT( "Rect" ); break;
|
||||
case WS_POLYPOLYGON: name = wxT( "Poly" ); break;
|
||||
case WS_BITMAP: name = wxT( "Bitmap" ); break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/* return 0 if the item has no specific option for page 1
|
||||
* 1 if the item is only on page 1
|
||||
* -1 if the item is not on page 1
|
||||
|
@ -337,6 +352,7 @@ int WORKSHEET_DATAITEM::GetPage1Option()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Set the option for page 1
|
||||
* aChoice = 0 if the item has no specific option for page 1
|
||||
* > 0 if the item is only on page 1
|
||||
|
@ -346,10 +362,10 @@ void WORKSHEET_DATAITEM::SetPage1Option( int aChoice )
|
|||
{
|
||||
ClearFlags( PAGE1OPTION );
|
||||
|
||||
if( aChoice > 0)
|
||||
if( aChoice > 0 )
|
||||
SetFlags( PAGE1OPTION_PAGE1ONLY );
|
||||
|
||||
else if( aChoice < 0)
|
||||
else if( aChoice < 0 )
|
||||
SetFlags( PAGE1OPTION_NOTONPAGE1 );
|
||||
|
||||
}
|
||||
|
@ -361,8 +377,9 @@ WORKSHEET_DATAITEM_POLYPOLYGON::WORKSHEET_DATAITEM_POLYPOLYGON() :
|
|||
m_Orient = 0.0;
|
||||
}
|
||||
|
||||
|
||||
const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx,
|
||||
int aRepeat ) const
|
||||
int aRepeat ) const
|
||||
{
|
||||
DPOINT pos = m_Corners[aIdx];
|
||||
|
||||
|
@ -372,6 +389,7 @@ const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx,
|
|||
return pos;
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox()
|
||||
{
|
||||
if( m_Corners.size() == 0 )
|
||||
|
@ -405,6 +423,7 @@ void WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage( int ii ) const
|
||||
{
|
||||
DPOINT pos = GetStartPos( ii );
|
||||
|
@ -422,14 +441,16 @@ bool WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage( int ii ) const
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx,
|
||||
int aRepeat ) const
|
||||
int aRepeat ) const
|
||||
{
|
||||
DPOINT pos = GetCornerPosition( aIdx, aRepeat );
|
||||
pos = pos * m_WSunits2Iu;
|
||||
return wxPoint( int(pos.x), int(pos.y) );
|
||||
}
|
||||
|
||||
|
||||
WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) :
|
||||
WORKSHEET_DATAITEM( WS_TEXT )
|
||||
{
|
||||
|
@ -441,6 +462,7 @@ WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) :
|
|||
m_LineWidth = 0.0; // 0.0 means use default value
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aGText )
|
||||
{
|
||||
aGText->SetHorizJustify( m_Hjustify ) ;
|
||||
|
@ -448,6 +470,7 @@ void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aG
|
|||
aGText->SetOrientation( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr )
|
||||
{
|
||||
int last = m_TextBase.Len() -1;
|
||||
|
@ -463,6 +486,7 @@ void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr )
|
|||
m_FullText << (wxChar) ( aIncr + lbchar );
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
@ -500,6 +524,7 @@ bool WORKSHEET_DATAITEM_TEXT::ReplaceAntiSlashSequence()
|
|||
return multiline;
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
|
||||
{
|
||||
m_ConstrainedTextSize = m_TextSize;
|
||||
|
@ -540,6 +565,7 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* set the pixel scale factor of the bitmap
|
||||
* this factor depend on the application internal unit
|
||||
* and the PPI bitmap factor
|
||||
|
@ -557,21 +583,22 @@ void WORKSHEET_DATAITEM_BITMAP::SetPixelScaleFactor()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* return the PPI of the bitmap
|
||||
*/
|
||||
int WORKSHEET_DATAITEM_BITMAP::GetPPI() const
|
||||
{
|
||||
if( m_ImageBitmap )
|
||||
return m_ImageBitmap->GetPPI() / m_ImageBitmap->m_Scale;
|
||||
return m_ImageBitmap->GetPPI() / m_ImageBitmap->GetScale();
|
||||
|
||||
return 300;
|
||||
}
|
||||
|
||||
|
||||
/*adjust the PPI of the bitmap
|
||||
*/
|
||||
void WORKSHEET_DATAITEM_BITMAP::SetPPI( int aBitmapPPI )
|
||||
{
|
||||
if( m_ImageBitmap )
|
||||
m_ImageBitmap->m_Scale = (double) m_ImageBitmap->GetPPI() / aBitmapPPI;
|
||||
m_ImageBitmap->SetScale( (double) m_ImageBitmap->GetPPI() / aBitmapPPI );
|
||||
}
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
|
|||
break;
|
||||
|
||||
case T_scale:
|
||||
aItem->m_ImageBitmap->m_Scale = parseDouble();
|
||||
aItem->m_ImageBitmap->SetScale( parseDouble() );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 jean-pierre.charras
|
||||
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2012-2016 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
|
||||
|
@ -138,6 +138,7 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC )
|
|||
return image;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC )
|
||||
{
|
||||
aImageItem->SetFlags( IS_MOVED );
|
||||
|
@ -156,6 +157,7 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC )
|
|||
OnModify();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem )
|
||||
{
|
||||
if( aItem->GetFlags( ) == 0 )
|
||||
|
@ -166,6 +168,7 @@ void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem )
|
|||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::MirrorImage( SCH_BITMAP* aItem, bool Is_X_axis )
|
||||
{
|
||||
if( aItem->GetFlags( ) == 0 )
|
||||
|
@ -180,10 +183,12 @@ void SCH_EDIT_FRAME::MirrorImage( SCH_BITMAP* aItem, bool Is_X_axis )
|
|||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::EditImage( SCH_BITMAP* aItem )
|
||||
{
|
||||
// TODO: change image scale or more
|
||||
DIALOG_IMAGE_EDITOR dlg( this, aItem->m_Image );
|
||||
DIALOG_IMAGE_EDITOR dlg( this, aItem->GetImage() );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
|
@ -193,7 +198,7 @@ void SCH_EDIT_FRAME::EditImage( SCH_BITMAP* aItem )
|
|||
GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
SaveCopyInUndoList( aItem, UR_CHANGED );
|
||||
|
||||
dlg.TransfertToImage(aItem->m_Image);
|
||||
dlg.TransfertToImage( aItem->GetImage() );
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
|
|
@ -71,9 +71,9 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
if( aSaveUnderNewName )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Schematic Files" ),
|
||||
wxPathOnly( Prj().GetProjectFullName() ),
|
||||
schematicFileName.GetFullName(), SchematicFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
wxPathOnly( Prj().GetProjectFullName() ),
|
||||
schematicFileName.GetFullName(), SchematicFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
@ -101,7 +101,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
|
||||
{
|
||||
msg.Printf( _( "Could not save backup of file '%s'" ),
|
||||
GetChars( schematicFileName.GetFullPath() ) );
|
||||
GetChars( schematicFileName.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,26 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
wxLogTrace( traceAutoSave,
|
||||
wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) );
|
||||
|
||||
#ifdef USE_SCH_IO_MANAGER
|
||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
|
||||
|
||||
try
|
||||
{
|
||||
pi->Save( schematicFileName.GetFullPath(), aScreen, &Kiway() );
|
||||
success = true;
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
msg.Printf( _( "Error saving schematic file '%s'.\n%s" ),
|
||||
GetChars( schematicFileName.GetFullPath() ), GetChars( ioe.errorText ) );
|
||||
DisplayError( this, msg );
|
||||
|
||||
msg.Printf( _( "Failed to save '%s'" ), GetChars( schematicFileName.GetFullPath() ) );
|
||||
AppendMsgPanel( wxEmptyString, msg, CYAN );
|
||||
|
||||
success = false;
|
||||
}
|
||||
#else
|
||||
FILE* f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) );
|
||||
|
||||
if( !f )
|
||||
|
@ -121,6 +141,8 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
}
|
||||
|
||||
success = aScreen->Save( f );
|
||||
fclose( f );
|
||||
#endif
|
||||
|
||||
if( success )
|
||||
{
|
||||
|
@ -140,6 +162,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
// Update the screen and frame info.
|
||||
if( aSaveUnderNewName )
|
||||
aScreen->SetFileName( schematicFileName.GetFullPath() );
|
||||
|
||||
aScreen->ClrSave();
|
||||
aScreen->ClrModify();
|
||||
|
||||
|
@ -151,8 +174,6 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
|
|||
DisplayError( this, _( "File write operation failed." ) );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -374,7 +395,7 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
|
||||
if( !screen )
|
||||
{
|
||||
wxLogError( wxT("Document not ready, cannot import") );
|
||||
wxLogError( wxT( "Document not ready, cannot import" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -399,6 +420,7 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
}
|
||||
|
||||
wxString cache_name = PART_LIBS::CacheName( fullFileName );
|
||||
|
||||
if( !!cache_name )
|
||||
{
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
@ -414,8 +436,10 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
SCH_ITEM* bs = screen->GetDrawItems();
|
||||
|
||||
if( bs )
|
||||
{
|
||||
while( bs->Next() )
|
||||
bs = bs->Next();
|
||||
}
|
||||
|
||||
// load the project
|
||||
bool success = LoadOneEEFile( screen, fullFileName, true );
|
||||
|
@ -460,7 +484,8 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
else
|
||||
sheet->SetName( tmp );
|
||||
|
||||
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
|
||||
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ),
|
||||
(long) newtimestamp ) );
|
||||
SCH_SCREEN* new_screen = new SCH_SCREEN( &Kiway() );
|
||||
new_screen->SetMaxUndoItems( m_UndoRedoCountMax );
|
||||
sheet->SetScreen( new_screen );
|
||||
|
|
|
@ -43,19 +43,19 @@
|
|||
SCH_BITMAP::SCH_BITMAP( const wxPoint& pos ) :
|
||||
SCH_ITEM( NULL, SCH_BITMAP_T )
|
||||
{
|
||||
m_Pos = pos;
|
||||
m_pos = pos;
|
||||
m_Layer = LAYER_NOTES; // used only to draw/plot a rectangle,
|
||||
// when a bitmap cannot be drawn or plotted
|
||||
m_Image = new BITMAP_BASE();
|
||||
m_image = new BITMAP_BASE();
|
||||
}
|
||||
|
||||
|
||||
SCH_BITMAP::SCH_BITMAP( const SCH_BITMAP& aSchBitmap ) :
|
||||
SCH_ITEM( aSchBitmap )
|
||||
{
|
||||
m_Pos = aSchBitmap.m_Pos;
|
||||
m_pos = aSchBitmap.m_pos;
|
||||
m_Layer = aSchBitmap.m_Layer;
|
||||
m_Image = new BITMAP_BASE( *aSchBitmap.m_Image );
|
||||
m_image = new BITMAP_BASE( *aSchBitmap.m_image );
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,9 +71,9 @@ SCH_ITEM& SCH_BITMAP::operator=( const SCH_ITEM& aItem )
|
|||
|
||||
SCH_BITMAP* bitmap = (SCH_BITMAP*) &aItem;
|
||||
|
||||
delete m_Image;
|
||||
m_Image = new BITMAP_BASE( *bitmap->m_Image );
|
||||
m_Pos = bitmap->m_Pos;
|
||||
delete m_image;
|
||||
m_image = new BITMAP_BASE( *bitmap->m_image );
|
||||
m_pos = bitmap->m_pos;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -82,7 +82,7 @@ SCH_ITEM& SCH_BITMAP::operator=( const SCH_ITEM& aItem )
|
|||
|
||||
bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename )
|
||||
{
|
||||
return m_Image->ReadImageFile( aFullFilename );
|
||||
return m_image->ReadImageFile( aFullFilename );
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,16 +91,16 @@ bool SCH_BITMAP::Save( FILE* aFile ) const
|
|||
if( fprintf( aFile, "$Bitmap\n" ) == EOF )
|
||||
return false;
|
||||
|
||||
if( fprintf( aFile, "Pos %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
|
||||
if( fprintf( aFile, "Pos %-4d %-4d\n", m_pos.x, m_pos.y ) == EOF )
|
||||
return false;
|
||||
|
||||
if( fprintf( aFile, "Scale %f\n", m_Image->m_Scale ) == EOF )
|
||||
if( fprintf( aFile, "Scale %f\n", m_image->GetScale() ) == EOF )
|
||||
return false;
|
||||
|
||||
if( fprintf( aFile, "Data\n" ) == EOF )
|
||||
return false;
|
||||
|
||||
if( !m_Image->SaveData( aFile ) )
|
||||
if( !m_image->SaveData( aFile ) )
|
||||
return false;
|
||||
|
||||
if( fprintf( aFile, "\nEndData\n" ) == EOF )
|
||||
|
@ -127,8 +127,8 @@ void SCH_BITMAP::SwapData( SCH_ITEM* aItem )
|
|||
GetChars( aItem->GetClass() ) ) );
|
||||
|
||||
SCH_BITMAP* item = (SCH_BITMAP*) aItem;
|
||||
std::swap( m_Pos, item->m_Pos );
|
||||
std::swap( m_Image, item->m_Image );
|
||||
std::swap( m_pos, item->m_pos );
|
||||
std::swap( m_image, item->m_image );
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,19 +153,21 @@ bool SCH_BITMAP::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
|
||||
if( strnicmp( line, "Pos", 3 ) == 0 )
|
||||
{
|
||||
sscanf( line + 3, "%d %d", &m_Pos.x, &m_Pos.y );
|
||||
sscanf( line + 3, "%d %d", &m_pos.x, &m_pos.y );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( strnicmp( line, "Scale", 5 ) == 0 )
|
||||
{
|
||||
sscanf( line + 5, "%lf", &m_Image->m_Scale );
|
||||
double scale = 1.0;
|
||||
sscanf( line + 5, "%lf", &scale );
|
||||
m_image->SetScale( scale );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( strnicmp( line, "Data", 4 ) == 0 )
|
||||
{
|
||||
m_Image->LoadData( aLine, aErrorMsg );
|
||||
m_image->LoadData( aLine, aErrorMsg );
|
||||
}
|
||||
|
||||
if( strnicmp( line, "$EndBitmap", 4 ) == 0 )
|
||||
|
@ -178,9 +180,9 @@ bool SCH_BITMAP::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
|
||||
const EDA_RECT SCH_BITMAP::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT rect = m_Image->GetBoundingBox();
|
||||
EDA_RECT rect = m_image->GetBoundingBox();
|
||||
|
||||
rect.Move( m_Pos );
|
||||
rect.Move( m_pos );
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
@ -189,7 +191,7 @@ const EDA_RECT SCH_BITMAP::GetBoundingBox() const
|
|||
void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
||||
{
|
||||
wxPoint pos = m_Pos + aOffset;
|
||||
wxPoint pos = m_pos + aOffset;
|
||||
|
||||
if( aColor < 0 ) // Use normal drawing function
|
||||
{
|
||||
|
@ -203,13 +205,13 @@ void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset
|
|||
GRSetDrawMode( aDC, aDrawMode );
|
||||
#endif
|
||||
|
||||
m_Image->DrawBitmap( aPanel, aDC, pos );
|
||||
m_image->DrawBitmap( aPanel, aDC, pos );
|
||||
}
|
||||
else // draws bounding box only (used to move items)
|
||||
{
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
// To draw the rect, pos is the upper left corner position
|
||||
wxSize size = m_Image->GetSize();
|
||||
wxSize size = m_image->GetSize();
|
||||
pos.x -= size.x / 2;
|
||||
pos.y -= size.y / 2;
|
||||
GRRect( aPanel->GetClipBox(), aDC, pos.x, pos.y,
|
||||
|
@ -223,7 +225,7 @@ void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset
|
|||
*/
|
||||
wxSize SCH_BITMAP::GetSize() const
|
||||
{
|
||||
return m_Image->GetSize();
|
||||
return m_image->GetSize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,8 +234,8 @@ wxSize SCH_BITMAP::GetSize() const
|
|||
*/
|
||||
void SCH_BITMAP::MirrorX( int aXaxis_position )
|
||||
{
|
||||
MIRROR( m_Pos.y, aXaxis_position );
|
||||
m_Image->Mirror( true );
|
||||
MIRROR( m_pos.y, aXaxis_position );
|
||||
m_image->Mirror( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -242,15 +244,15 @@ void SCH_BITMAP::MirrorX( int aXaxis_position )
|
|||
*/
|
||||
void SCH_BITMAP::MirrorY( int aYaxis_position )
|
||||
{
|
||||
MIRROR( m_Pos.x, aYaxis_position );
|
||||
m_Image->Mirror( false );
|
||||
MIRROR( m_pos.x, aYaxis_position );
|
||||
m_image->Mirror( false );
|
||||
}
|
||||
|
||||
|
||||
void SCH_BITMAP::Rotate( wxPoint aPosition )
|
||||
{
|
||||
RotatePoint( &m_Pos, aPosition, 900 );
|
||||
m_Image->Rotate( false );
|
||||
RotatePoint( &m_pos, aPosition, 900 );
|
||||
m_image->Rotate( false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -258,7 +260,7 @@ bool SCH_BITMAP::IsSelectStateChanged( const wxRect& aRect )
|
|||
{
|
||||
bool previousState = IsSelected();
|
||||
|
||||
if( aRect.Contains( m_Pos ) )
|
||||
if( aRect.Contains( m_pos ) )
|
||||
SetFlags( SELECTED );
|
||||
else
|
||||
ClearFlags( SELECTED );
|
||||
|
@ -273,7 +275,7 @@ void SCH_BITMAP::Show( int nestLevel, std::ostream& os ) const
|
|||
// XML output:
|
||||
wxString s = GetClass();
|
||||
|
||||
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_Pos << "/>\n";
|
||||
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << "/>\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,5 +307,5 @@ bool SCH_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
|
|||
|
||||
void SCH_BITMAP::Plot( PLOTTER* aPlotter )
|
||||
{
|
||||
m_Image->PlotImage( aPlotter, m_Pos, GetLayerColor( GetLayer() ), GetPenSize() );
|
||||
m_image->PlotImage( aPlotter, m_pos, GetLayerColor( GetLayer() ), GetPenSize() );
|
||||
}
|
||||
|
|
|
@ -37,11 +37,8 @@
|
|||
|
||||
class SCH_BITMAP : public SCH_ITEM
|
||||
{
|
||||
wxPoint m_Pos; // XY coordinates of center of the bitmap
|
||||
|
||||
public:
|
||||
BITMAP_BASE* m_Image; // the BITMAP_BASE item
|
||||
|
||||
wxPoint m_pos; // XY coordinates of center of the bitmap
|
||||
BITMAP_BASE* m_image; // the BITMAP_BASE item
|
||||
|
||||
public:
|
||||
SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
|
@ -50,7 +47,7 @@ public:
|
|||
|
||||
~SCH_BITMAP()
|
||||
{
|
||||
delete m_Image;
|
||||
delete m_image;
|
||||
}
|
||||
|
||||
SCH_ITEM& operator=( const SCH_ITEM& aItem );
|
||||
|
@ -58,8 +55,15 @@ public:
|
|||
/*
|
||||
* Accessors:
|
||||
*/
|
||||
double GetPixelScaleFactor() { return m_Image->GetPixelScaleFactor(); }
|
||||
void SetPixelScaleFactor( double aSF ) { m_Image->SetPixelScaleFactor( aSF ); }
|
||||
double GetPixelScaleFactor() const { return m_image->GetPixelScaleFactor(); }
|
||||
void SetPixelScaleFactor( double aSF ) { m_image->SetPixelScaleFactor( aSF ); }
|
||||
|
||||
BITMAP_BASE* GetImage()
|
||||
{
|
||||
wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP initialization, m_image is NULL." );
|
||||
|
||||
return m_image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetScalingFactor
|
||||
|
@ -74,7 +78,7 @@ public:
|
|||
*/
|
||||
double GetScalingFactor() const
|
||||
{
|
||||
return m_Image->GetScalingFactor();
|
||||
return m_image->GetScalingFactor();
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,7 +116,7 @@ public:
|
|||
|
||||
void Move( const wxPoint& aMoveVector )
|
||||
{
|
||||
m_Pos += aMoveVector;
|
||||
m_pos += aMoveVector;
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,9 +132,9 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const { return image_xpm; }
|
||||
|
||||
wxPoint GetPosition() const { return m_Pos; }
|
||||
wxPoint GetPosition() const { return m_pos; }
|
||||
|
||||
void SetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; }
|
||||
void SetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
|
||||
|
||||
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
* convert a wxString to UTF8 and replace any control characters with a ~,
|
||||
* where a control character is one of the first ASCII values up to ' ' 32d.
|
||||
*/
|
||||
static std::string toUTFTildaText( const wxString& txt )
|
||||
std::string toUTFTildaText( const wxString& txt )
|
||||
{
|
||||
std::string ret = TO_UTF8( txt );
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ typedef std::vector<SCH_FIELD> SCH_FIELDS;
|
|||
typedef std::weak_ptr<LIB_PART> PART_REF;
|
||||
|
||||
|
||||
extern std::string toUTFTildaText( const wxString& txt );
|
||||
|
||||
|
||||
/**
|
||||
* Class SCH_COMPONENT
|
||||
* describes a real schematic component
|
||||
|
@ -142,6 +145,8 @@ public:
|
|||
return wxT( "SCH_COMPONENT" );
|
||||
}
|
||||
|
||||
const wxArrayString& GetPathsAndReferences() const { return m_PathsAndReferences; }
|
||||
|
||||
/**
|
||||
* Virtual function IsMovableFromAnchorPoint
|
||||
* Return true for items which are moved with the anchor point at mouse cursor
|
||||
|
@ -309,7 +314,7 @@ public:
|
|||
* Function GetFieldCount
|
||||
* returns the number of fields in this component.
|
||||
*/
|
||||
int GetFieldCount() const { return (int) m_Fields.size(); }
|
||||
int GetFieldCount() const { return (int)m_Fields.size(); }
|
||||
|
||||
/**
|
||||
* Function GetFieldsAutoplaced
|
||||
|
|
|
@ -188,6 +188,8 @@ public:
|
|||
|
||||
bool IsReplaceable() const { return true; }
|
||||
|
||||
wxPoint GetLibPosition() const { return m_Pos; }
|
||||
|
||||
wxPoint GetPosition() const;
|
||||
|
||||
void SetPosition( const wxPoint& aPosition );
|
||||
|
|
|
@ -54,6 +54,8 @@ SCH_PLUGIN* SCH_IO_MGR::FindPlugin( SCH_FILE_T aFileType )
|
|||
{
|
||||
case SCH_LEGACY:
|
||||
return new SCH_LEGACY_PLUGIN();
|
||||
case SCH_KICAD:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -147,14 +149,14 @@ SCH_SHEET* SCH_IO_MGR::Load( SCH_FILE_T aFileType, const wxString& aFileName, KI
|
|||
|
||||
|
||||
void SCH_IO_MGR::Save( SCH_FILE_T aFileType, const wxString& aFileName,
|
||||
SCH_SHEET* aSchematic, const PROPERTIES* aProperties )
|
||||
SCH_SCREEN* aSchematic, KIWAY* aKiway, const PROPERTIES* aProperties )
|
||||
{
|
||||
// release the SCH_PLUGIN even if an exception is thrown.
|
||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( FindPlugin( aFileType ) );
|
||||
|
||||
if( (SCH_PLUGIN*) pi ) // test pi->plugin
|
||||
{
|
||||
pi->Save( aFileName, aSchematic, aProperties ); // virtual
|
||||
pi->Save( aFileName, aSchematic, aKiway, aProperties ); // virtual
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
|
||||
class SCH_SHEET;
|
||||
class SCH_SCREEN;
|
||||
class SCH_PLUGIN;
|
||||
class KIWAY;
|
||||
class LIB_PART;
|
||||
|
@ -155,7 +156,7 @@ public:
|
|||
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||
*/
|
||||
static void Save( SCH_FILE_T aFileType, const wxString& aFileName,
|
||||
SCH_SHEET* aSchematic, const PROPERTIES* aProperties = NULL );
|
||||
SCH_SCREEN* aSchematic, KIWAY* aKiway, const PROPERTIES* aProperties = NULL );
|
||||
};
|
||||
|
||||
|
||||
|
@ -248,7 +249,7 @@ public:
|
|||
*
|
||||
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||
*/
|
||||
virtual void Save( const wxString& aFileName, SCH_SHEET* aSchematic,
|
||||
virtual void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,12 +24,16 @@
|
|||
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include <drawtxt.h>
|
||||
#include <kiway.h>
|
||||
#include <kicad_string.h>
|
||||
#include <richio.h>
|
||||
#include <core/typeinfo.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <class_library.h>
|
||||
#include <lib_field.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_marker.h>
|
||||
|
@ -460,7 +464,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
|
|||
if( aAppendToMe == NULL )
|
||||
{
|
||||
// Clean up any allocated memory if an exception occurs loading the schematic.
|
||||
std::auto_ptr< SCH_SHEET > newSheet( new SCH_SHEET );
|
||||
std::unique_ptr< SCH_SHEET > newSheet( new SCH_SHEET );
|
||||
newSheet->SetFileName( aFileName );
|
||||
m_rootSheet = newSheet.get();
|
||||
loadHierarchy( newSheet.get() );
|
||||
|
@ -719,7 +723,7 @@ void SCH_LEGACY_PLUGIN::loadPageSettings( FILE_LINE_READER& aReader, SCH_SCREEN*
|
|||
|
||||
SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( FILE_LINE_READER& aReader )
|
||||
{
|
||||
std::auto_ptr< SCH_SHEET > sheet( new SCH_SHEET() );
|
||||
std::unique_ptr< SCH_SHEET > sheet( new SCH_SHEET() );
|
||||
|
||||
sheet->SetTimeStamp( GetNewTimeStamp() );
|
||||
|
||||
|
@ -771,7 +775,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( FILE_LINE_READER& aReader )
|
|||
}
|
||||
else // Sheet pin.
|
||||
{
|
||||
std::auto_ptr< SCH_SHEET_PIN > sheetPin( new SCH_SHEET_PIN( sheet.get() ) );
|
||||
std::unique_ptr< SCH_SHEET_PIN > sheetPin( new SCH_SHEET_PIN( sheet.get() ) );
|
||||
|
||||
sheetPin->SetNumber( fieldId );
|
||||
|
||||
|
@ -856,7 +860,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( FILE_LINE_READER& aReader )
|
|||
|
||||
SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( FILE_LINE_READER& aReader )
|
||||
{
|
||||
std::auto_ptr< SCH_BITMAP > bitmap( new SCH_BITMAP );
|
||||
std::unique_ptr< SCH_BITMAP > bitmap( new SCH_BITMAP );
|
||||
|
||||
const char* line = aReader.Line();
|
||||
|
||||
|
@ -877,7 +881,7 @@ SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( FILE_LINE_READER& aReader )
|
|||
else if( strCompare( "Scale", line, &line ) )
|
||||
{
|
||||
/// @todo Make m_scale private and add accessors.
|
||||
bitmap->m_Image->m_Scale = parseDouble( aReader, line, &line );
|
||||
bitmap->GetImage()->SetScale( parseDouble( aReader, line, &line ) );
|
||||
}
|
||||
else if( strCompare( "Data", line, &line ) )
|
||||
{
|
||||
|
@ -897,8 +901,8 @@ SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( FILE_LINE_READER& aReader )
|
|||
wxImage* image = new wxImage();
|
||||
wxMemoryInputStream istream( stream );
|
||||
image->LoadFile( istream, wxBITMAP_TYPE_PNG );
|
||||
bitmap->m_Image->SetImage( image );
|
||||
bitmap->m_Image->SetBitmap( new wxBitmap( *image ) );
|
||||
bitmap->GetImage()->SetImage( image );
|
||||
bitmap->GetImage()->SetBitmap( new wxBitmap( *image ) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -933,7 +937,7 @@ SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( FILE_LINE_READER& aReader )
|
|||
|
||||
SCH_JUNCTION* SCH_LEGACY_PLUGIN::loadJunction( FILE_LINE_READER& aReader )
|
||||
{
|
||||
std::auto_ptr< SCH_JUNCTION > junction( new SCH_JUNCTION );
|
||||
std::unique_ptr< SCH_JUNCTION > junction( new SCH_JUNCTION );
|
||||
|
||||
const char* line = aReader.Line();
|
||||
|
||||
|
@ -955,7 +959,7 @@ SCH_JUNCTION* SCH_LEGACY_PLUGIN::loadJunction( FILE_LINE_READER& aReader )
|
|||
|
||||
SCH_NO_CONNECT* SCH_LEGACY_PLUGIN::loadNoConnect( FILE_LINE_READER& aReader )
|
||||
{
|
||||
std::auto_ptr< SCH_NO_CONNECT > no_connect( new SCH_NO_CONNECT );
|
||||
std::unique_ptr< SCH_NO_CONNECT > no_connect( new SCH_NO_CONNECT );
|
||||
|
||||
const char* line = aReader.Line();
|
||||
|
||||
|
@ -977,7 +981,7 @@ SCH_NO_CONNECT* SCH_LEGACY_PLUGIN::loadNoConnect( FILE_LINE_READER& aReader )
|
|||
|
||||
SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( FILE_LINE_READER& aReader )
|
||||
{
|
||||
std::auto_ptr< SCH_LINE > wire( new SCH_LINE );
|
||||
std::unique_ptr< SCH_LINE > wire( new SCH_LINE );
|
||||
|
||||
const char* line = aReader.Line();
|
||||
|
||||
|
@ -1017,7 +1021,7 @@ SCH_BUS_ENTRY_BASE* SCH_LEGACY_PLUGIN::loadBusEntry( FILE_LINE_READER& aReader )
|
|||
|
||||
wxCHECK( strCompare( "Entry", line, &line ), NULL );
|
||||
|
||||
std::auto_ptr< SCH_BUS_ENTRY_BASE > busEntry;
|
||||
std::unique_ptr< SCH_BUS_ENTRY_BASE > busEntry;
|
||||
|
||||
if( strCompare( "Wire", line, &line ) )
|
||||
{
|
||||
|
@ -1062,7 +1066,7 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( FILE_LINE_READER& aReader )
|
|||
|
||||
wxCHECK( strCompare( "Text", line, &line ), NULL );
|
||||
|
||||
std::auto_ptr< SCH_TEXT> text;
|
||||
std::unique_ptr< SCH_TEXT> text;
|
||||
|
||||
if( strCompare( "Notes", line, &line ) )
|
||||
text.reset( new SCH_TEXT );
|
||||
|
@ -1157,7 +1161,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader )
|
|||
|
||||
wxCHECK( strCompare( "$Comp", line, &line ), NULL );
|
||||
|
||||
std::auto_ptr< SCH_COMPONENT > component( new SCH_COMPONENT() );
|
||||
std::unique_ptr< SCH_COMPONENT > component( new SCH_COMPONENT() );
|
||||
|
||||
line = aReader.ReadLine();
|
||||
|
||||
|
@ -1395,3 +1399,463 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader )
|
|||
|
||||
return NULL; // Prevents compiler warning. Should never get here.
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aScreen, KIWAY* aKiway,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
wxCHECK_RET( aScreen != NULL, "NULL SCH_SCREEN object." );
|
||||
wxCHECK_RET( !aFileName.IsEmpty(), "No schematic file name defined." );
|
||||
|
||||
init( aKiway, aProperties );
|
||||
|
||||
wxFileName fn = aFileName;
|
||||
|
||||
// File names should be absolute. Don't assume everything relative to the project path
|
||||
// works properly.
|
||||
wxASSERT( fn.IsAbsolute() );
|
||||
|
||||
FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
|
||||
|
||||
m_out = &formatter; // no ownership
|
||||
|
||||
Format( aScreen );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::Format( SCH_SCREEN* aScreen )
|
||||
{
|
||||
wxCHECK_RET( aScreen != NULL, "NULL SCH_SCREEN* object." );
|
||||
wxCHECK_RET( m_kiway != NULL, "NULL KIWAY* object." );
|
||||
|
||||
// Write the header
|
||||
m_out->Print( 0, "%s %s %d\n", "EESchema", SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION );
|
||||
|
||||
// Write the project libraries.
|
||||
for( const PART_LIB& lib : *m_kiway->Prj().SchLibs() )
|
||||
m_out->Print( 0, "LIBS:%s\n", TO_UTF8( lib.GetName() ) );
|
||||
|
||||
// This section is not used, but written for file compatibility
|
||||
m_out->Print( 0, "EELAYER %d %d\n", LAYERSCH_ID_COUNT, 0 );
|
||||
m_out->Print( 0, "EELAYER END\n" );
|
||||
|
||||
/* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for
|
||||
* SheetNumber and Sheet Count in a complex hierarchy, but useful in
|
||||
* simple hierarchy and flat hierarchy. Used also to search the root
|
||||
* sheet ( ScreenNumber = 1 ) within the files
|
||||
*/
|
||||
const TITLE_BLOCK& tb = aScreen->GetTitleBlock();
|
||||
const PAGE_INFO& page = aScreen->GetPageSettings();
|
||||
|
||||
m_out->Print( 0, "$Descr %s %d %d%s\n", TO_UTF8( page.GetType() ),
|
||||
page.GetWidthMils(),
|
||||
page.GetHeightMils(),
|
||||
!page.IsCustom() && page.IsPortrait() ? " portrait" : "" );
|
||||
m_out->Print( 0, "encoding utf-8\n" );
|
||||
m_out->Print( 0, "Sheet %d %d\n", aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens );
|
||||
m_out->Print( 0, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() );
|
||||
m_out->Print( 0, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() );
|
||||
m_out->Print( 0, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() );
|
||||
m_out->Print( 0, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() );
|
||||
m_out->Print( 0, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() );
|
||||
m_out->Print( 0, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() );
|
||||
m_out->Print( 0, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() );
|
||||
m_out->Print( 0, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() );
|
||||
m_out->Print( 0, "$EndDescr\n" );
|
||||
|
||||
for( SCH_ITEM* item = aScreen->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_COMPONENT_T:
|
||||
saveComponent( dynamic_cast< SCH_COMPONENT* >( item ) );
|
||||
break;
|
||||
case SCH_BITMAP_T:
|
||||
saveBitmap( dynamic_cast< SCH_BITMAP* >( item ) );
|
||||
break;
|
||||
case SCH_SHEET_T:
|
||||
saveSheet( dynamic_cast< SCH_SHEET* >( item ) );
|
||||
break;
|
||||
case SCH_JUNCTION_T:
|
||||
saveJunction( dynamic_cast< SCH_JUNCTION* >( item ) );
|
||||
break;
|
||||
case SCH_NO_CONNECT_T:
|
||||
saveNoConnect( dynamic_cast< SCH_NO_CONNECT* >( item ) );
|
||||
break;
|
||||
case SCH_BUS_WIRE_ENTRY_T:
|
||||
case SCH_BUS_BUS_ENTRY_T:
|
||||
saveBusEntry( dynamic_cast< SCH_BUS_ENTRY_BASE* >( item ) );
|
||||
break;
|
||||
case SCH_LINE_T:
|
||||
saveLine( dynamic_cast< SCH_LINE* >( item ) );
|
||||
break;
|
||||
case SCH_TEXT_T:
|
||||
case SCH_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_HIERARCHICAL_LABEL_T:
|
||||
saveText( dynamic_cast< SCH_TEXT* >( item ) );
|
||||
break;
|
||||
default:
|
||||
wxASSERT( "Unexpected schematic object type in SCH_LEGACY_PLUGIN::Format()" );
|
||||
}
|
||||
}
|
||||
|
||||
m_out->Print( 0, "$EndSCHEMATC\n" );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveComponent( SCH_COMPONENT* aComponent )
|
||||
{
|
||||
std::string name1;
|
||||
std::string name2;
|
||||
wxArrayString reference_fields;
|
||||
|
||||
static wxString delimiters( wxT( " " ) );
|
||||
|
||||
// This is redundant with the AR entries below, but it makes the files backwards-compatible.
|
||||
if( aComponent->GetPathsAndReferences().GetCount() > 0 )
|
||||
{
|
||||
reference_fields = wxStringTokenize( aComponent->GetPathsAndReferences()[0], delimiters );
|
||||
name1 = toUTFTildaText( reference_fields[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aComponent->GetField( REFERENCE )->GetText().IsEmpty() )
|
||||
name1 = toUTFTildaText( aComponent->GetPrefix() );
|
||||
else
|
||||
name1 = toUTFTildaText( aComponent->GetField( REFERENCE )->GetText() );
|
||||
}
|
||||
|
||||
wxString part_name = aComponent->GetPartName();
|
||||
|
||||
if( part_name.size() )
|
||||
{
|
||||
name2 = toUTFTildaText( part_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
name2 = "_NONAME_";
|
||||
}
|
||||
|
||||
m_out->Print( 0, "$Comp\n" );
|
||||
m_out->Print( 0, "L %s %s\n", name2.c_str(), name1.c_str() );
|
||||
|
||||
// Generate unit number, convert and time stamp
|
||||
m_out->Print( 0, "U %d %d %8.8lX\n", aComponent->GetUnit(), aComponent->GetConvert(),
|
||||
(unsigned long)aComponent->GetTimeStamp() );
|
||||
|
||||
// Save the position
|
||||
m_out->Print( 0, "P %d %d\n", aComponent->GetPosition().x, aComponent->GetPosition().y );
|
||||
|
||||
/* If this is a complex hierarchy; save hierarchical references.
|
||||
* but for simple hierarchies it is not necessary.
|
||||
* the reference inf is already saved
|
||||
* this is useful for old Eeschema version compatibility
|
||||
*/
|
||||
if( aComponent->GetPathsAndReferences().GetCount() > 1 )
|
||||
{
|
||||
for( unsigned int ii = 0; ii < aComponent->GetPathsAndReferences().GetCount(); ii++ )
|
||||
{
|
||||
/*format:
|
||||
* AR Path="/140/2" Ref="C99" Part="1"
|
||||
* where 140 is the uid of the containing sheet
|
||||
* and 2 is the timestamp of this component.
|
||||
* (timestamps are actually 8 hex chars)
|
||||
* Ref is the conventional component reference for this 'path'
|
||||
* Part is the conventional component part selection for this 'path'
|
||||
*/
|
||||
reference_fields = wxStringTokenize( aComponent->GetPathsAndReferences()[ii],
|
||||
delimiters );
|
||||
|
||||
m_out->Print( 0, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
|
||||
TO_UTF8( reference_fields[0] ),
|
||||
TO_UTF8( reference_fields[1] ),
|
||||
TO_UTF8( reference_fields[2] ) );
|
||||
}
|
||||
}
|
||||
|
||||
// update the ugly field index, which I would like to see go away someday soon.
|
||||
for( int i = 0; i < aComponent->GetFieldCount(); ++i )
|
||||
aComponent->GetField( i )->SetId( i );
|
||||
|
||||
// Fixed fields:
|
||||
// Save mandatory fields even if they are blank,
|
||||
// because the visibility, size and orientation are set from libary editor.
|
||||
for( unsigned i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
saveField( aComponent->GetField( i ) );
|
||||
|
||||
// User defined fields:
|
||||
// The *policy* about which user defined fields are part of a symbol is now
|
||||
// only in the dialog editors. No policy should be enforced here, simply
|
||||
// save all the user defined fields, they are present because a dialog editor
|
||||
// thought they should be. If you disagree, go fix the dialog editors.
|
||||
for( int i = MANDATORY_FIELDS; i < aComponent->GetFieldCount(); ++i )
|
||||
saveField( aComponent->GetField( i ) );
|
||||
|
||||
// Unit number, position, box ( old standard )
|
||||
m_out->Print( 0, "\t%-4d %-4d %-4d\n", aComponent->GetUnit(), aComponent->GetPosition().x,
|
||||
aComponent->GetPosition().y );
|
||||
|
||||
TRANSFORM transform = aComponent->GetTransform();
|
||||
|
||||
m_out->Print( 0, "\t%-4d %-4d %-4d %-4d\n",
|
||||
transform.x1, transform.y1, transform.x2, transform.y2 );
|
||||
m_out->Print( 0, "$EndComp\n" );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField )
|
||||
{
|
||||
char hjustify = 'C';
|
||||
|
||||
if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
||||
hjustify = 'L';
|
||||
else if( aField->GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
||||
hjustify = 'R';
|
||||
|
||||
char vjustify = 'C';
|
||||
|
||||
if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
||||
vjustify = 'B';
|
||||
else if( aField->GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
|
||||
aField->GetId(),
|
||||
EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too
|
||||
aField->GetOrientation() == TEXT_ORIENT_HORIZ ? 'H' : 'V',
|
||||
aField->GetLibPosition().x, aField->GetLibPosition().y,
|
||||
aField->GetSize().x,
|
||||
aField->GetAttributes(),
|
||||
hjustify, vjustify,
|
||||
aField->IsItalic() ? 'I' : 'N',
|
||||
aField->IsBold() ? 'B' : 'N' );
|
||||
|
||||
// Save field name, if the name is user definable
|
||||
if( aField->GetId() >= FIELD1 )
|
||||
{
|
||||
m_out->Print( 0, " %s", EscapedUTF8( aField->GetName() ).c_str() );
|
||||
}
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap )
|
||||
{
|
||||
wxCHECK_RET( aBitmap != NULL, "SCH_BITMAP* is NULL" );
|
||||
|
||||
wxImage* image = aBitmap->GetImage()->GetImageData();
|
||||
|
||||
wxCHECK_RET( image != NULL, "wxImage* is NULL" );
|
||||
|
||||
m_out->Print( 0, "$Bitmap\n" );
|
||||
m_out->Print( 0, "Pos %-4d %-4d\n", aBitmap->GetPosition().x, aBitmap->GetPosition().y );
|
||||
m_out->Print( 0, "Scale %f\n", aBitmap->GetImage()->GetScale() );
|
||||
m_out->Print( 0, "Data\n" );
|
||||
|
||||
wxMemoryOutputStream stream;
|
||||
|
||||
image->SaveFile( stream, wxBITMAP_TYPE_PNG );
|
||||
|
||||
// Write binary data in hexadecimal form (ASCII)
|
||||
wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
|
||||
char* begin = (char*) buffer->GetBufferStart();
|
||||
|
||||
for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
|
||||
{
|
||||
if( ii >= 32 )
|
||||
{
|
||||
ii = 0;
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
}
|
||||
|
||||
m_out->Print( 0, "%2.2X ", *begin & 0xFF );
|
||||
}
|
||||
|
||||
m_out->Print( 0, "\nEndData\n" );
|
||||
m_out->Print( 0, "$EndBitmap\n" );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet )
|
||||
{
|
||||
wxCHECK_RET( aSheet != NULL, "SCH_SHEET* is NULL" );
|
||||
|
||||
m_out->Print( 0, "$Sheet\n" );
|
||||
m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n", aSheet->GetPosition().x, aSheet->GetPosition().y,
|
||||
aSheet->GetSize().x, aSheet->GetSize().y );
|
||||
|
||||
m_out->Print( 0, "U %8.8lX\n", (unsigned long) aSheet->GetTimeStamp() );
|
||||
|
||||
if( !aSheet->GetName().IsEmpty() )
|
||||
m_out->Print( 0, "F0 %s %d\n", EscapedUTF8( aSheet->GetName() ).c_str(),
|
||||
aSheet->GetSheetNameSize() );
|
||||
|
||||
if( !aSheet->GetFileName().IsEmpty() )
|
||||
m_out->Print( 0, "F1 %s %d\n", EscapedUTF8( aSheet->GetFileName() ).c_str(),
|
||||
aSheet->GetFileNameSize() );
|
||||
|
||||
for( const SCH_SHEET_PIN& pin : aSheet->GetPins() )
|
||||
{
|
||||
int type, side;
|
||||
|
||||
if( pin.GetText().IsEmpty() )
|
||||
break;
|
||||
|
||||
switch( pin.GetEdge() )
|
||||
{
|
||||
default:
|
||||
case SCH_SHEET_PIN::SHEET_LEFT_SIDE:
|
||||
side = 'L';
|
||||
break;
|
||||
|
||||
case SCH_SHEET_PIN::SHEET_RIGHT_SIDE:
|
||||
side = 'R';
|
||||
break;
|
||||
|
||||
case SCH_SHEET_PIN::SHEET_TOP_SIDE:
|
||||
side = 'T';
|
||||
break;
|
||||
|
||||
case SCH_SHEET_PIN::SHEET_BOTTOM_SIDE:
|
||||
side = 'B';
|
||||
break;
|
||||
}
|
||||
|
||||
switch( pin.GetShape() )
|
||||
{
|
||||
case NET_INPUT:
|
||||
type = 'I'; break;
|
||||
|
||||
case NET_OUTPUT:
|
||||
type = 'O'; break;
|
||||
|
||||
case NET_BIDI:
|
||||
type = 'B'; break;
|
||||
|
||||
case NET_TRISTATE:
|
||||
type = 'T'; break;
|
||||
|
||||
default:
|
||||
case NET_UNSPECIFIED:
|
||||
type = 'U'; break;
|
||||
}
|
||||
|
||||
m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(),
|
||||
EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes
|
||||
type, side, pin.GetPosition().x, pin.GetPosition().y,
|
||||
pin.GetSize().x );
|
||||
}
|
||||
|
||||
m_out->Print( 0, "$EndSheet\n" );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveJunction( SCH_JUNCTION* aJunction )
|
||||
{
|
||||
wxCHECK_RET( aJunction != NULL, "SCH_JUNCTION* is NULL" );
|
||||
|
||||
m_out->Print( 0, "Connection ~ %-4d %-4d\n",
|
||||
aJunction->GetPosition().x, aJunction->GetPosition().y );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveNoConnect( SCH_NO_CONNECT* aNoConnect )
|
||||
{
|
||||
wxCHECK_RET( aNoConnect != NULL, "SCH_NOCONNECT* is NULL" );
|
||||
|
||||
m_out->Print( 0, "NoConn ~ %-4d %-4d\n", aNoConnect->GetPosition().x,
|
||||
aNoConnect->GetPosition().y );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry )
|
||||
{
|
||||
wxCHECK_RET( aBusEntry != NULL, "SCH_BUS_ENTRY_BASE* is NULL" );
|
||||
|
||||
if( aBusEntry->GetLayer() == LAYER_WIRE )
|
||||
m_out->Print( 0, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n",
|
||||
aBusEntry->GetPosition().x, aBusEntry->GetPosition().y,
|
||||
aBusEntry->m_End().x, aBusEntry->m_End().y );
|
||||
else
|
||||
m_out->Print( 0, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n",
|
||||
aBusEntry->GetPosition().x, aBusEntry->GetPosition().y,
|
||||
aBusEntry->m_End().x, aBusEntry->m_End().y );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine )
|
||||
{
|
||||
wxCHECK_RET( aLine != NULL, "SCH_LINE* is NULL" );
|
||||
|
||||
const char* layer = "Notes";
|
||||
const char* width = "Line";
|
||||
|
||||
if( aLine->GetLayer() == LAYER_WIRE )
|
||||
layer = "Wire";
|
||||
else if( aLine->GetLayer() == LAYER_BUS )
|
||||
layer = "Bus";
|
||||
|
||||
m_out->Print( 0, "Wire %s %s\n", layer, width );
|
||||
m_out->Print( 0, "\t%-4d %-4d %-4d %-4d\n", aLine->GetStartPoint().x, aLine->GetStartPoint().y,
|
||||
aLine->GetEndPoint().x, aLine->GetEndPoint().y );
|
||||
}
|
||||
|
||||
|
||||
void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
|
||||
{
|
||||
wxCHECK_RET( aText != NULL, "SCH_TEXT* is NULL" );
|
||||
|
||||
const char* italics = "~";
|
||||
const char* textType = "Notes";
|
||||
|
||||
if( aText->IsItalic() )
|
||||
italics = "Italic";
|
||||
|
||||
wxString text = aText->GetText();
|
||||
|
||||
LAYERSCH_ID layer = aText->GetLayer();
|
||||
|
||||
if( layer == LAYER_NOTES || layer == LAYER_LOCLABEL )
|
||||
{
|
||||
if( layer == LAYER_NOTES )
|
||||
{
|
||||
// For compatibility reasons, the text must be saved in only one text line
|
||||
// so replace all EOLs with \\n
|
||||
text.Replace( wxT( "\n" ), wxT( "\\n" ) );
|
||||
|
||||
// Here we should have no CR or LF character in line
|
||||
// This is not always the case if a multiline text was copied (using a copy/paste
|
||||
// function) from a text that uses E.O.L characters that differs from the current
|
||||
// EOL format. This is mainly the case under Linux using LF symbol when copying
|
||||
// a text from Windows (using CRLF symbol) so we must just remove the extra CR left
|
||||
// (or LF left under MacOSX)
|
||||
for( unsigned ii = 0; ii < text.Len(); )
|
||||
{
|
||||
if( text[ii] == 0x0A || text[ii] == 0x0D )
|
||||
text.erase( ii, 1 );
|
||||
else
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textType = "Label";
|
||||
}
|
||||
|
||||
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType,
|
||||
aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(),
|
||||
aText->GetSize().x, italics, aText->GetThickness(), TO_UTF8( text ) );
|
||||
}
|
||||
else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL )
|
||||
{
|
||||
textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel";
|
||||
|
||||
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType,
|
||||
aText->GetPosition().x, aText->GetPosition().y, aText->GetOrientation(),
|
||||
aText->GetSize().x, SheetLabelType[aText->GetShape()], italics,
|
||||
aText->GetThickness(), TO_UTF8( text ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class SCH_LINE;
|
|||
class SCH_BUS_ENTRY_BASE;
|
||||
class SCH_TEXT;
|
||||
class SCH_COMPONENT;
|
||||
class SCH_FIELD;
|
||||
class PROPERTIES;
|
||||
|
||||
|
||||
|
@ -70,8 +71,10 @@ public:
|
|||
SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway,
|
||||
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
void Save( const wxString& aFileName, SCH_SHEET* aSheet,
|
||||
const PROPERTIES* aProperties = NULL ) {}
|
||||
void Save( const wxString& aFileName, SCH_SCREEN* aScreen, KIWAY* aKiway,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
|
||||
void Format( SCH_SCREEN* aScreen );
|
||||
|
||||
//-----</PLUGIN IMPLEMENTATION>---------------------------------------------
|
||||
|
||||
|
@ -92,14 +95,24 @@ private:
|
|||
SCH_TEXT* loadText( FILE_LINE_READER& aReader );
|
||||
SCH_COMPONENT* loadComponent( FILE_LINE_READER& aReader );
|
||||
|
||||
protected:
|
||||
void saveComponent( SCH_COMPONENT* aComponent );
|
||||
void saveField( SCH_FIELD* aField );
|
||||
void saveBitmap( SCH_BITMAP* aBitmap );
|
||||
void saveSheet( SCH_SHEET* aSheet );
|
||||
void saveJunction( SCH_JUNCTION* aJunction );
|
||||
void saveNoConnect( SCH_NO_CONNECT* aNoConnect );
|
||||
void saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry );
|
||||
void saveLine( SCH_LINE* aLine );
|
||||
void saveText( SCH_TEXT* aText );
|
||||
|
||||
protected:
|
||||
int m_version; ///< Version of file being loaded.
|
||||
wxString m_error; ///< For throwing exceptions
|
||||
wxString m_path; ///< Root project path for loading child sheets.
|
||||
const PROPERTIES* m_props; ///< Passed via Save() or Load(), no ownership, may be NULL.
|
||||
KIWAY* m_kiway; ///< Required for path to legacy component libraries.
|
||||
SCH_SHEET* m_rootSheet; ///< The root sheet of the schematic being loaded..
|
||||
FILE_OUTPUTFORMATTER* m_out; ///< The output formatter for saving SCH_SCREEN objects.
|
||||
|
||||
/// initialize PLUGIN like a constructor would.
|
||||
void init( KIWAY* aKiway, const PROPERTIES* aProperties = NULL );
|
||||
|
|
|
@ -50,7 +50,7 @@ SCH_SHEET* SCH_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, SCH_SHEET
|
|||
}
|
||||
|
||||
|
||||
void SCH_PLUGIN::Save( const wxString& aFileName, SCH_SHEET* aSchematic,
|
||||
void SCH_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
|
||||
const PROPERTIES* aProperties )
|
||||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
|
||||
|
|
|
@ -43,10 +43,9 @@ class PLOTTER;
|
|||
*/
|
||||
class BITMAP_BASE
|
||||
{
|
||||
public:
|
||||
double m_Scale; // The scaling factor of the bitmap
|
||||
// With m_pixelScaleFactor, controls the actual draw size
|
||||
private:
|
||||
double m_scale; // The scaling factor of the bitmap
|
||||
// With m_pixelScaleFactor, controls the actual draw size
|
||||
wxImage* m_image; // the raw image data (png format)
|
||||
wxBitmap* m_bitmap; // the bitmap used to draw/plot image
|
||||
double m_pixelScaleFactor; // The scaling factor of the bitmap
|
||||
|
@ -71,7 +70,7 @@ public:
|
|||
/*
|
||||
* Accessors:
|
||||
*/
|
||||
double GetPixelScaleFactor() { return m_pixelScaleFactor; }
|
||||
double GetPixelScaleFactor() const { return m_pixelScaleFactor; }
|
||||
void SetPixelScaleFactor( double aSF ) { m_pixelScaleFactor = aSF; }
|
||||
wxImage* GetImageData() { return m_image; }
|
||||
void SetImage( wxImage* aImage )
|
||||
|
@ -80,6 +79,9 @@ public:
|
|||
m_image = aImage;
|
||||
}
|
||||
|
||||
double GetScale() const { return m_scale; }
|
||||
void SetScale( double aScale ) { m_scale = aScale; }
|
||||
|
||||
/*
|
||||
* Function RebuildBitmap
|
||||
* Rebuild the internal bitmap used to draw/plot image
|
||||
|
@ -102,17 +104,17 @@ public:
|
|||
/**
|
||||
* Function GetScalingFactor
|
||||
* @return the scaling factor from pixel size to actual draw size
|
||||
* this scaling factor depend on m_pixelScaleFactor and m_Scale
|
||||
* this scaling factor depend on m_pixelScaleFactor and m_scale
|
||||
* m_pixelScaleFactor gives the scaling factor between a pixel size and
|
||||
* the internal schematic units
|
||||
* m_Scale is an user dependant value, and gives the "zoom" value
|
||||
* m_Scale = 1.0 = original size of bitmap.
|
||||
* m_Scale < 1.0 = the bitmap is drawn smaller than its original size.
|
||||
* m_Scale > 1.0 = the bitmap is drawn bigger than its original size.
|
||||
* m_scale is an user dependant value, and gives the "zoom" value
|
||||
* m_scale = 1.0 = original size of bitmap.
|
||||
* m_scale < 1.0 = the bitmap is drawn smaller than its original size.
|
||||
* m_scale > 1.0 = the bitmap is drawn bigger than its original size.
|
||||
*/
|
||||
double GetScalingFactor() const
|
||||
{
|
||||
return m_pixelScaleFactor * m_Scale;
|
||||
return m_pixelScaleFactor * m_scale;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,7 +122,7 @@ public:
|
|||
* Function GetSize
|
||||
* @return the actual size (in user units, not in pixels) of the image
|
||||
*/
|
||||
wxSize GetSize() const;
|
||||
wxSize GetSize() const;
|
||||
|
||||
/**
|
||||
* Function GetSizePixels
|
||||
|
@ -131,7 +133,7 @@ public:
|
|||
if( m_image )
|
||||
return wxSize( m_image->GetWidth(), m_image->GetHeight() );
|
||||
else
|
||||
return wxSize(0,0);
|
||||
return wxSize( 0, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +155,7 @@ public:
|
|||
*/
|
||||
const EDA_RECT GetBoundingBox() const;
|
||||
|
||||
void DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos );
|
||||
void DrawBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos );
|
||||
|
||||
/**
|
||||
* Function ReadImageFile
|
||||
|
@ -165,7 +167,7 @@ public:
|
|||
* @param aFullFilename The full filename of the image file to read.
|
||||
* @return bool - true if success reading else false.
|
||||
*/
|
||||
bool ReadImageFile( const wxString& aFullFilename );
|
||||
bool ReadImageFile( const wxString& aFullFilename );
|
||||
|
||||
/**
|
||||
* writes the bitmap data to aFile
|
||||
|
@ -174,7 +176,7 @@ public:
|
|||
* @param aFile The FILE to write to.
|
||||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
bool SaveData( FILE* aFile ) const;
|
||||
bool SaveData( FILE* aFile ) const;
|
||||
|
||||
/**
|
||||
* writes the bitmap data to an array string
|
||||
|
@ -182,7 +184,7 @@ public:
|
|||
* 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;
|
||||
void SaveData( wxArrayString& aPngStrings ) const;
|
||||
|
||||
/**
|
||||
* Load an image data saved by SaveData (png, in Hexadecimal form)
|
||||
|
@ -191,7 +193,7 @@ public:
|
|||
* png bimap data.
|
||||
* @return true if the bitmap loaded successfully.
|
||||
*/
|
||||
bool LoadData( LINE_READER& aLine, wxString& aErrorMsg );
|
||||
bool LoadData( LINE_READER& aLine, wxString& aErrorMsg );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -201,14 +203,14 @@ public:
|
|||
* @param aVertically = false to mirror horizontally
|
||||
* or true to mirror vertically
|
||||
*/
|
||||
void Mirror( bool aVertically );
|
||||
void Mirror( bool aVertically );
|
||||
|
||||
/**
|
||||
* Function Rotate
|
||||
* Rotate image CW or CCW.
|
||||
* @param aRotateCCW = true to rotate CCW
|
||||
*/
|
||||
void Rotate( bool aRotateCCW );
|
||||
void Rotate( bool aRotateCCW );
|
||||
|
||||
/**
|
||||
* Function PlotImage
|
||||
|
@ -219,8 +221,8 @@ public:
|
|||
* @param aDefaultColor = the color used to plot the rectangle when bitmap is not supported
|
||||
* @param aDefaultPensize = the pen size used to plot the rectangle when bitmap is not supported
|
||||
*/
|
||||
void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos,
|
||||
EDA_COLOR_T aDefaultColor, int aDefaultPensize );
|
||||
void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos,
|
||||
EDA_COLOR_T aDefaultColor, int aDefaultPensize );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 CERN
|
||||
* Copyright (C) 2013-2016 CERN
|
||||
*
|
||||
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -84,6 +85,7 @@ private:
|
|||
void formatOptions( WORKSHEET_DATAITEM* aItem ) const throw( IO_ERROR );
|
||||
};
|
||||
|
||||
|
||||
// A helper class to write a page layout description to a file
|
||||
class WORKSHEET_LAYOUT_FILEIO: public WORKSHEET_LAYOUT_IO
|
||||
{
|
||||
|
@ -100,7 +102,7 @@ public:
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
||||
wxMessageBox( ioe.errorText, _( "Error writing page layout descr file" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,6 +112,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// A helper class to write a page layout description to a string
|
||||
class WORKSHEET_LAYOUT_STRINGIO: public WORKSHEET_LAYOUT_IO
|
||||
{
|
||||
|
@ -127,7 +130,7 @@ public:
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
||||
wxMessageBox( ioe.errorText, _( "Error writing page layout descr file" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,6 +141,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Save the description in a file
|
||||
*/
|
||||
|
@ -147,6 +151,7 @@ void WORKSHEET_LAYOUT::Save( const wxString& aFullFileName )
|
|||
writer.Format( this );
|
||||
}
|
||||
|
||||
|
||||
/* Save the description in a buffer
|
||||
*/
|
||||
void WORKSHEET_LAYOUT::SaveInString( wxString& aOutputString )
|
||||
|
@ -183,6 +188,7 @@ void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_DATAITEM* aItem, int aNestLevel ) co
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_LAYOUT* aPageLayout ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
|
@ -222,6 +228,7 @@ void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_LAYOUT* aPageLayout ) const
|
|||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_TEXT* aItem, int aNestLevel ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
|
@ -346,6 +353,7 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNe
|
|||
unsigned ist = aItem->GetPolyIndexStart( kk );
|
||||
unsigned iend = aItem->GetPolyIndexEnd( kk );
|
||||
int ii = 0;
|
||||
|
||||
while( ist <= iend )
|
||||
{
|
||||
DPOINT pos = aItem->m_Corners[ist++];
|
||||
|
@ -357,16 +365,19 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_POLYPOLYGON* aItem, int aNe
|
|||
nestLevel = aNestLevel+2;
|
||||
ii = 0;
|
||||
}
|
||||
|
||||
m_out->Print( nestLevel, " (%s %s %s)", getTokenName( T_xy ),
|
||||
double2Str( pos.x ).c_str(),
|
||||
double2Str( pos.y ).c_str() );
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLevel ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
|
@ -377,7 +388,7 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLev
|
|||
formatOptions( aItem );
|
||||
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_scale ),
|
||||
double2Str(aItem->m_ImageBitmap->m_Scale ).c_str() );
|
||||
double2Str( aItem->m_ImageBitmap->GetScale() ).c_str() );
|
||||
|
||||
formatRepeatParameters( aItem );
|
||||
m_out->Print( 0,"\n");
|
||||
|
@ -395,6 +406,7 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_BITMAP* aItem, int aNestLev
|
|||
m_out->Print( aNestLevel, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::formatCoordinate( const char * aToken,
|
||||
POINT_COORD & aCoord ) const
|
||||
throw( IO_ERROR )
|
||||
|
@ -409,23 +421,24 @@ void WORKSHEET_LAYOUT_IO::formatCoordinate( const char * aToken,
|
|||
break;
|
||||
|
||||
case LT_CORNER:
|
||||
m_out->Print( 0, " %s", getTokenName(T_ltcorner ) );
|
||||
m_out->Print( 0, " %s", getTokenName( T_ltcorner ) );
|
||||
break;
|
||||
|
||||
case LB_CORNER:
|
||||
m_out->Print( 0, " %s", getTokenName(T_lbcorner ) );
|
||||
m_out->Print( 0, " %s", getTokenName( T_lbcorner ) );
|
||||
break;
|
||||
|
||||
case RT_CORNER:
|
||||
m_out->Print( 0, " %s", getTokenName(T_rtcorner ) );
|
||||
m_out->Print( 0, " %s", getTokenName( T_rtcorner ) );
|
||||
break;
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")" );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) const
|
||||
throw( IO_ERROR )
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
if( aItem->m_RepeatCount <= 1 )
|
||||
return;
|
||||
|
@ -443,6 +456,7 @@ void WORKSHEET_LAYOUT_IO::formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) co
|
|||
m_out->Print( 0, " (incrlabel %d)", aItem->m_IncrementLabel );
|
||||
}
|
||||
|
||||
|
||||
void WORKSHEET_LAYOUT_IO::formatOptions( WORKSHEET_DATAITEM* aItem ) const
|
||||
throw( IO_ERROR )
|
||||
{
|
||||
|
@ -453,13 +467,12 @@ void WORKSHEET_LAYOUT_IO::formatOptions( WORKSHEET_DATAITEM* aItem ) const
|
|||
break;
|
||||
|
||||
case 1:
|
||||
m_out->Print( 0, " (%s %s)", getTokenName(T_option ),
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_option ),
|
||||
getTokenName(T_page1only ) );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
m_out->Print( 0, " (%s %s)", getTokenName(T_option ),
|
||||
getTokenName(T_notonpage1 ) );
|
||||
m_out->Print( 0, " (%s %s)", getTokenName( T_option ), getTokenName( T_notonpage1 ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue