Commit b0e2908c authored by jean-pierre charras's avatar jean-pierre charras

pl_editor: add a PPI (pixel per inch) setup option for bitmaps.

parent 6bb62a71
......@@ -46,11 +46,12 @@
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_pixelScaleFactor = 3.33; // a value OK for bitmaps using 300 PPI
// (Eeschema uses currently 1000PPI
m_ppi = 300; // the bitmap definition. the default is 300PPI
m_pixelScaleFactor = 1000.0 / m_ppi; // a value OK for bitmaps using 300 PPI
// for Eeschema which uses currently 1000PPI
}
......@@ -72,6 +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_ppi = aItem->m_ppi;
m_pixelScaleFactor = aItem->m_pixelScaleFactor;
}
......
......@@ -540,4 +540,38 @@ 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
* the pixel scale factor should be initialized before drawing the bitmap
*/
void WORKSHEET_DATAITEM_BITMAP::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 );
}
}
/* return the PPI of the bitmap
*/
int WORKSHEET_DATAITEM_BITMAP::GetPPI() const
{
if( m_ImageBitmap )
return m_ImageBitmap->GetPPI() / m_ImageBitmap->m_Scale;
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;
}
......@@ -54,6 +54,7 @@ private:
// to convert the bitmap size (in pixels)
// to internal KiCad units
// Usually does not change
int m_ppi; // the bitmap definition. the default is 300PPI
public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
......@@ -128,7 +129,7 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
*/
int GetPPI() const
{
return 300;
return m_ppi;
}
/**
......
......@@ -485,6 +485,17 @@ public:
*/
virtual bool HasEndPoint() { return false; }
/**
* @return the PPI of the bitmap
*/
int GetPPI() const;
/**
* adjust the PPI of the bitmap
* @param aBitmapPPI = the ned PPI for the bitmap
*/
void SetPPI( int aBitmapPPI );
/**
* set the pixel scale factor of the bitmap
* this factor depend on the application internal unit
......@@ -492,17 +503,7 @@ public:
* 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 );
}
}
void SetPixelScaleFactor();
};
......
......@@ -317,28 +317,27 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerMain->Add( m_SizerEndPosition, 0, 0, 5 );
wxBoxSizer* bSizerLineThickness;
bSizerLineThickness = new wxBoxSizer( wxHORIZONTAL );
m_SizerLineThickness = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerthickness;
bSizerthickness = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerThickness;
bSizerThickness = new wxBoxSizer( wxVERTICAL );
m_staticTextThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Thickness"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextThickness->Wrap( -1 );
bSizerthickness->Add( m_staticTextThickness, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizerThickness->Add( m_staticTextThickness, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_textCtrlThickness = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerthickness->Add( m_textCtrlThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerThickness->Add( m_textCtrlThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerLineThickness->Add( bSizerthickness, 0, wxEXPAND, 5 );
m_SizerLineThickness->Add( bSizerThickness, 0, wxEXPAND, 5 );
m_staticTextInfoThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Set to 0 to use default"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInfoThickness->Wrap( -1 );
bSizerLineThickness->Add( m_staticTextInfoThickness, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_SizerLineThickness->Add( m_staticTextInfoThickness, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( bSizerLineThickness, 0, 0, 5 );
bSizerMain->Add( m_SizerLineThickness, 0, 0, 5 );
m_SizerRotation = new wxBoxSizer( wxVERTICAL );
......@@ -361,6 +360,18 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerMain->Add( m_SizerRotation, 0, wxEXPAND, 5 );
m_SizerBitmapPPI = new wxBoxSizer( wxHORIZONTAL );
m_staticTextBitmapPPI = new wxStaticText( m_swItemProperties, wxID_ANY, _("Bitmap PPI"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextBitmapPPI->Wrap( -1 );
m_SizerBitmapPPI->Add( m_staticTextBitmapPPI, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlBitmapPPI = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SizerBitmapPPI->Add( m_textCtrlBitmapPPI, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( m_SizerBitmapPPI, 0, wxEXPAND, 5 );
m_staticline4 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline4, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
......
......@@ -3953,16 +3953,16 @@
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerLineThickness</property>
<property name="name">m_SizerLineThickness</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerthickness</property>
<property name="name">bSizerThickness</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
......@@ -4503,6 +4503,191 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">m_SizerBitmapPPI</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Bitmap PPI</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextBitmapPPI</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_textCtrlBitmapPPI</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
......
......@@ -85,6 +85,7 @@ class PANEL_PROPERTIES_BASE : public wxPanel
wxTextCtrl* m_textCtrlEndY;
wxStaticText* m_staticTextOrgEnd;
wxComboBox* m_comboBoxCornerEnd;
wxBoxSizer* m_SizerLineThickness;
wxStaticText* m_staticTextThickness;
wxTextCtrl* m_textCtrlThickness;
wxStaticText* m_staticTextInfoThickness;
......@@ -92,6 +93,9 @@ class PANEL_PROPERTIES_BASE : public wxPanel
wxStaticLine* m_staticline1;
wxStaticText* m_staticTextRot;
wxTextCtrl* m_textCtrlRotation;
wxBoxSizer* m_SizerBitmapPPI;
wxStaticText* m_staticTextBitmapPPI;
wxTextCtrl* m_textCtrlBitmapPPI;
wxStaticLine* m_staticline4;
wxStaticText* m_staticTextRepeatPrms;
wxStaticText* m_staticTextRepeatCnt;
......
......@@ -153,6 +153,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WORKSHEET_DATAITEM* aItem )
m_textCtrlPosX->SetValue( msg );
msg.Printf( wxT("%.3f"), aItem->m_Pos.m_Pos.y );
m_textCtrlPosY->SetValue( msg );
switch( aItem->m_Pos.m_Anchor )
{
case RB_CORNER: // right bottom corner
......@@ -170,6 +171,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WORKSHEET_DATAITEM* aItem )
m_textCtrlEndX->SetValue( msg );
msg.Printf( wxT("%.3f"), aItem->m_End.m_Pos.y );
m_textCtrlEndY->SetValue( msg );
switch( aItem->m_End.m_Anchor )
{
case RB_CORNER: // right bottom corner
......@@ -242,33 +244,53 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WORKSHEET_DATAITEM* aItem )
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_POLYPOLYGON )
{
m_staticTextInfoThickness->Show( false );
WORKSHEET_DATAITEM_POLYPOLYGON* item = (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem;
// Rotation (poly and text)
msg.Printf( wxT("%.3f"), item->m_Orient );
m_textCtrlRotation->SetValue( msg );
}
else if(aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
{
m_staticTextInfoThickness->Show( false );
}
else
{
m_staticTextInfoThickness->Show( true );
}
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_SEGMENT ||
aItem->GetType() == WORKSHEET_DATAITEM::WS_RECT ||
aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
{
m_SizerRotation->Show( false );
m_SizerEndPosition->Show(true);
WORKSHEET_DATAITEM_BITMAP* item = (WORKSHEET_DATAITEM_BITMAP*) aItem;
// select definition in PPI
msg.Printf( wxT("%d"), item->GetPPI() );
m_textCtrlBitmapPPI->SetValue( msg );
}
else
switch( aItem->GetType() )
{
m_SizerRotation->Show( true );
m_SizerEndPosition->Show(false);
case WORKSHEET_DATAITEM::WS_SEGMENT:
case WORKSHEET_DATAITEM::WS_RECT:
m_SizerBitmapPPI->Show( false );
m_SizerLineThickness->Show( true );
m_staticTextInfoThickness->Show( true );
m_SizerRotation->Show( false );
m_SizerEndPosition->Show(true);
break;
case WORKSHEET_DATAITEM::WS_TEXT:
m_SizerBitmapPPI->Show( false );
m_SizerLineThickness->Show( true );
m_staticTextInfoThickness->Show( true );
m_SizerRotation->Show( true );
m_SizerEndPosition->Show(false);
break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
m_SizerBitmapPPI->Show( false );
m_SizerLineThickness->Show( true );
m_staticTextInfoThickness->Show( false ); // No defaut value for thickness
m_SizerRotation->Show( true );
m_SizerEndPosition->Show(false);
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
m_SizerBitmapPPI->Show( true );
m_SizerLineThickness->Show( false );
m_SizerRotation->Show( false );
m_SizerEndPosition->Show(false);
break;
}
// Repeat parameters
......@@ -456,6 +478,16 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( WORKSHEET_DATAITEM* aItem )
item->m_Orient = dtmp;
}
if( aItem->GetType() == WORKSHEET_DATAITEM::WS_BITMAP )
{
WORKSHEET_DATAITEM_BITMAP* item = (WORKSHEET_DATAITEM_BITMAP*) aItem;
// Set definition in PPI
long value;
msg = m_textCtrlBitmapPPI->GetValue();
if( msg.ToLong( &value ) )
item->SetPPI( (int)value );
}
return true;
}
......@@ -101,7 +101,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Seave Error" ), wxOK | wxICON_ERROR );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
......@@ -120,7 +120,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
wxString msg;
msg.Printf( _( "Error occurred saving project specific footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "File Seave Error" ), wxOK | wxICON_ERROR );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment