diff --git a/common/dialogs/panel_image_editor.cpp b/common/dialogs/panel_image_editor.cpp index 38fa0e8c16..89a57289d8 100644 --- a/common/dialogs/panel_image_editor.cpp +++ b/common/dialogs/panel_image_editor.cpp @@ -39,9 +39,13 @@ PANEL_IMAGE_EDITOR::PANEL_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem ) PANEL_IMAGE_EDITOR_BASE( aParent ) { m_workingImage = new BITMAP_BASE( *aItem ); + wxString msg; msg.Printf( wxT( "%f" ), m_workingImage->GetScale() ); m_textCtrlScale->SetValue( msg ); + + msg.Printf( wxT( "%d" ), m_workingImage->GetPPI() ); + m_stPPI_Value->SetLabel( msg ); } diff --git a/common/dialogs/panel_image_editor_base.cpp b/common/dialogs/panel_image_editor_base.cpp index 812a2eb763..5f23aa1162 100644 --- a/common/dialogs/panel_image_editor_base.cpp +++ b/common/dialogs/panel_image_editor_base.cpp @@ -41,6 +41,20 @@ PANEL_IMAGE_EDITOR_BASE::PANEL_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID i m_textCtrlScale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerRight->Add( m_textCtrlScale, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + wxBoxSizer* bSizerPPI; + bSizerPPI = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextPPI = new wxStaticText( this, wxID_ANY, _("PPI:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPPI->Wrap( -1 ); + bSizerPPI->Add( m_staticTextPPI, 0, wxALL, 5 ); + + m_stPPI_Value = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stPPI_Value->Wrap( -1 ); + bSizerPPI->Add( m_stPPI_Value, 1, wxALL|wxEXPAND, 5 ); + + + bSizerRight->Add( bSizerPPI, 0, wxEXPAND, 5 ); + bSizerLeft->Add( bSizerRight, 0, wxEXPAND|wxALL, 5 ); diff --git a/common/dialogs/panel_image_editor_base.fbp b/common/dialogs/panel_image_editor_base.fbp index 223d4aec90..0ab8997cad 100644 --- a/common/dialogs/panel_image_editor_base.fbp +++ b/common/dialogs/panel_image_editor_base.fbp @@ -356,6 +356,141 @@ + + 5 + wxEXPAND + 0 + + + bSizerPPI + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + PPI: + 0 + + 0 + + + 0 + + 1 + m_staticTextPPI + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + dummy + 0 + + 0 + + + 0 + + 1 + m_stPPI_Value + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + diff --git a/common/dialogs/panel_image_editor_base.h b/common/dialogs/panel_image_editor_base.h index 827e4c935d..e6bc11294f 100644 --- a/common/dialogs/panel_image_editor_base.h +++ b/common/dialogs/panel_image_editor_base.h @@ -39,6 +39,8 @@ class PANEL_IMAGE_EDITOR_BASE : public wxPanel wxButton* m_buttonGrey; wxStaticText* m_staticTextScale; wxTextCtrl* m_textCtrlScale; + wxStaticText* m_staticTextPPI; + wxStaticText* m_stPPI_Value; // Virtual event handlers, override them in your derived class virtual void OnRedrawPanel( wxPaintEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_image_properties_base.fbp b/eeschema/dialogs/dialog_image_properties_base.fbp index ea64d374bc..e8fb8c0c1c 100644 --- a/eeschema/dialogs/dialog_image_properties_base.fbp +++ b/eeschema/dialogs/dialog_image_properties_base.fbp @@ -51,7 +51,7 @@ 363,281 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h; forward_declare - + Image Properties 0 diff --git a/eeschema/dialogs/dialog_image_properties_base.h b/eeschema/dialogs/dialog_image_properties_base.h index 96c1a0b12a..b57229c398 100644 --- a/eeschema/dialogs/dialog_image_properties_base.h +++ b/eeschema/dialogs/dialog_image_properties_base.h @@ -52,7 +52,7 @@ class DIALOG_IMAGE_PROPERTIES_BASE : public DIALOG_SHIM public: - DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 363,281 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Image Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 363,281 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_IMAGE_PROPERTIES_BASE(); diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index d1b8f09ed9..588e9ba509 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -46,7 +46,7 @@ SCH_BITMAP::SCH_BITMAP( const VECTOR2I& 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_bitmapBase = new BITMAP_BASE(); } @@ -55,7 +55,7 @@ SCH_BITMAP::SCH_BITMAP( const SCH_BITMAP& aSchBitmap ) : { m_pos = aSchBitmap.m_pos; m_layer = aSchBitmap.m_layer; - m_image = new BITMAP_BASE( *aSchBitmap.m_image ); + m_bitmapBase = new BITMAP_BASE( *aSchBitmap.m_bitmapBase ); } @@ -71,8 +71,8 @@ SCH_BITMAP& SCH_BITMAP::operator=( const SCH_ITEM& aItem ) SCH_BITMAP* bitmap = (SCH_BITMAP*) &aItem; - delete m_image; - m_image = new BITMAP_BASE( *bitmap->m_image ); + delete m_bitmapBase; + m_bitmapBase = new BITMAP_BASE( *bitmap->m_bitmapBase ); m_pos = bitmap->m_pos; } @@ -82,9 +82,9 @@ SCH_BITMAP& SCH_BITMAP::operator=( const SCH_ITEM& aItem ) bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename ) { - if( m_image->ReadImageFile( aFullFilename ) ) + if( m_bitmapBase->ReadImageFile( aFullFilename ) ) { - m_image->SetPixelSizeIu( 254000.0 / m_image->GetPPI() ); + m_bitmapBase->SetPixelSizeIu( 254000.0 / m_bitmapBase->GetPPI() ); return true; } @@ -94,8 +94,8 @@ bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename ) void SCH_BITMAP::SetImage( wxImage* aImage ) { - m_image->SetImage( aImage ); - m_image->SetPixelSizeIu( 254000.0 / m_image->GetPPI() ); + m_bitmapBase->SetImage( aImage ); + m_bitmapBase->SetPixelSizeIu( 254000.0 / m_bitmapBase->GetPPI() ); } @@ -113,13 +113,13 @@ void SCH_BITMAP::SwapData( SCH_ITEM* aItem ) SCH_BITMAP* item = (SCH_BITMAP*) aItem; std::swap( m_pos, item->m_pos ); - std::swap( m_image, item->m_image ); + std::swap( m_bitmapBase, item->m_bitmapBase ); } const BOX2I SCH_BITMAP::GetBoundingBox() const { - BOX2I bbox = m_image->GetBoundingBox(); + BOX2I bbox = m_bitmapBase->GetBoundingBox(); bbox.Move( m_pos ); @@ -131,34 +131,34 @@ void SCH_BITMAP::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse { VECTOR2I pos = m_pos + aOffset; - m_image->DrawBitmap( aSettings->GetPrintDC(), pos ); + m_bitmapBase->DrawBitmap( aSettings->GetPrintDC(), pos ); } VECTOR2I SCH_BITMAP::GetSize() const { - return m_image->GetSize(); + return m_bitmapBase->GetSize(); } void SCH_BITMAP::MirrorVertically( int aCenter ) { MIRROR( m_pos.y, aCenter ); - m_image->Mirror( true ); + m_bitmapBase->Mirror( true ); } void SCH_BITMAP::MirrorHorizontally( int aCenter ) { MIRROR( m_pos.x, aCenter ); - m_image->Mirror( false ); + m_bitmapBase->Mirror( false ); } void SCH_BITMAP::Rotate( const VECTOR2I& aCenter ) { RotatePoint( m_pos, aCenter, ANGLE_90 ); - m_image->Rotate( false ); + m_bitmapBase->Rotate( false ); } @@ -200,7 +200,7 @@ void SCH_BITMAP::Plot( PLOTTER* aPlotter, bool aBackground ) const { if( aBackground ) { - m_image->PlotImage( aPlotter, m_pos, + m_bitmapBase->PlotImage( aPlotter, m_pos, aPlotter->RenderSettings()->GetLayerColor( GetLayer() ), aPlotter->RenderSettings()->GetDefaultPenWidth() ); } @@ -217,6 +217,9 @@ void SCH_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetPPI() ) ); + aList.emplace_back( _( "Scale" ), wxString::Format( wxT( "%f "), GetImageScale() ) ); + aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetSize().x ) ); aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetSize().y ) ); } diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 7285b78d0d..2ccf6655fa 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -46,15 +46,16 @@ public: ~SCH_BITMAP() { - delete m_image; + delete m_bitmapBase; } SCH_BITMAP& operator=( const SCH_ITEM& aItem ); BITMAP_BASE* GetImage() const { - wxCHECK_MSG( m_image != nullptr, nullptr, "Invalid SCH_BITMAP init, m_image is NULL." ); - return m_image; + wxCHECK_MSG( m_bitmapBase != nullptr, nullptr, + "Invalid SCH_BITMAP init, m_bitmapBase is NULL." ); + return m_bitmapBase; } void SetImage( wxImage* aImage ); @@ -67,12 +68,12 @@ public: */ double GetImageScale() const { - return m_image->GetScale(); + return m_bitmapBase->GetScale(); } void SetImageScale( double aScale ) { - m_image->SetScale( aScale ); + m_bitmapBase->SetScale( aScale ); } static inline bool ClassOf( const EDA_ITEM* aItem ) @@ -151,7 +152,7 @@ public: private: VECTOR2I m_pos; // XY coordinates of center of the bitmap - BITMAP_BASE* m_image; // the BITMAP_BASE item + BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item }; diff --git a/pcbnew/dialogs/dialog_image_properties_base.cpp b/pcbnew/dialogs/dialog_image_properties_base.cpp index 5540792324..e04da7c018 100644 --- a/pcbnew/dialogs/dialog_image_properties_base.cpp +++ b/pcbnew/dialogs/dialog_image_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -94,7 +94,6 @@ DIALOG_IMAGE_PROPERTIES_BASE::DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wx this->SetSizer( m_GeneralBoxSizer ); this->Layout(); - m_GeneralBoxSizer->Fit( this ); this->Centre( wxBOTH ); } diff --git a/pcbnew/dialogs/dialog_image_properties_base.fbp b/pcbnew/dialogs/dialog_image_properties_base.fbp index 1ce01c7be5..672a33e258 100644 --- a/pcbnew/dialogs/dialog_image_properties_base.fbp +++ b/pcbnew/dialogs/dialog_image_properties_base.fbp @@ -36,6 +36,7 @@ wxBOTH 1 + 0 1 impl_virtual @@ -47,10 +48,10 @@ DIALOG_IMAGE_PROPERTIES_BASE - + 353,260 wxDEFAULT_DIALOG_STYLE DIALOG_SHIM; dialog_shim.h; forward_declare - + Image Properties 0 @@ -87,6 +88,7 @@ Dock 0 Left + 0 1 1 @@ -143,6 +145,7 @@ Dock 0 Left + 0 1 1 @@ -231,6 +234,7 @@ Dock 0 Left + 0 1 1 @@ -292,6 +296,7 @@ Dock 0 Left + 0 1 1 @@ -356,6 +361,7 @@ Dock 0 Left + 0 1 1 @@ -417,6 +423,7 @@ Dock 0 Left + 0 1 1 @@ -478,6 +485,7 @@ Dock 0 Left + 0 1 1 @@ -542,6 +550,7 @@ Dock 0 Left + 0 1 1 @@ -603,6 +612,7 @@ Dock 0 Left + 0 1 1 @@ -665,6 +675,7 @@ Dock 0 Left + 0 1 1 @@ -742,6 +753,7 @@ Dock 0 Left + 0 1 1 diff --git a/pcbnew/dialogs/dialog_image_properties_base.h b/pcbnew/dialogs/dialog_image_properties_base.h index 8d09857769..6b8ce668db 100644 --- a/pcbnew/dialogs/dialog_image_properties_base.h +++ b/pcbnew/dialogs/dialog_image_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -59,7 +59,7 @@ class DIALOG_IMAGE_PROPERTIES_BASE : public DIALOG_SHIM public: - DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + DIALOG_IMAGE_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Image Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 353,260 ), long style = wxDEFAULT_DIALOG_STYLE ); ~DIALOG_IMAGE_PROPERTIES_BASE(); diff --git a/pcbnew/pcb_bitmap.cpp b/pcbnew/pcb_bitmap.cpp index de8aab8f1d..facc1d0aa3 100644 --- a/pcbnew/pcb_bitmap.cpp +++ b/pcbnew/pcb_bitmap.cpp @@ -47,16 +47,16 @@ PCB_BITMAP::PCB_BITMAP( BOARD_ITEM* aParent, const VECTOR2I& pos, PCB_LAYER_ID a BOARD_ITEM( aParent, PCB_BITMAP_T, aLayer ) { m_pos = pos; - m_image = new BITMAP_BASE(); - m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() ); + m_bitmapBase = new BITMAP_BASE(); + m_bitmapBase->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_bitmapBase->GetPPI() ); } PCB_BITMAP::PCB_BITMAP( const PCB_BITMAP& aPCBBitmap ) : BOARD_ITEM( aPCBBitmap ) { m_pos = aPCBBitmap.m_pos; - m_image = new BITMAP_BASE( *aPCBBitmap.m_image ); - m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() ); + m_bitmapBase = new BITMAP_BASE( *aPCBBitmap.m_bitmapBase ); + m_bitmapBase->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_bitmapBase->GetPPI() ); } @@ -72,10 +72,10 @@ PCB_BITMAP& PCB_BITMAP::operator=( const BOARD_ITEM& aItem ) PCB_BITMAP* bitmap = (PCB_BITMAP*) &aItem; - delete m_image; - m_image = new BITMAP_BASE( *bitmap->m_image ); + delete m_bitmapBase; + m_bitmapBase = new BITMAP_BASE( *bitmap->m_bitmapBase ); m_pos = bitmap->m_pos; - m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() ); + m_bitmapBase->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_bitmapBase->GetPPI() ); } return *this; @@ -84,16 +84,16 @@ PCB_BITMAP& PCB_BITMAP::operator=( const BOARD_ITEM& aItem ) void PCB_BITMAP::SetImage( wxImage* aImage ) { - m_image->SetImage( aImage ); - m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() ); + m_bitmapBase->SetImage( aImage ); + m_bitmapBase->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_bitmapBase->GetPPI() ); } bool PCB_BITMAP::ReadImageFile( const wxString& aFullFilename ) { - if( m_image->ReadImageFile( aFullFilename ) ) + if( m_bitmapBase->ReadImageFile( aFullFilename ) ) { - m_image->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_image->GetPPI() ); + m_bitmapBase->SetPixelSizeIu( (float) pcbIUScale.MilsToIU( 1000 ) / m_bitmapBase->GetPPI() ); return true; } @@ -121,7 +121,7 @@ void PCB_BITMAP::swapData( BOARD_ITEM* aItem ) std::swap( m_parent, item->m_parent ); std::swap( m_forceVisible, item->m_forceVisible ); std::swap( m_pos, item->m_pos ); - std::swap( m_image, item->m_image ); + std::swap( m_bitmapBase, item->m_bitmapBase ); } @@ -141,7 +141,7 @@ double PCB_BITMAP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const const BOX2I PCB_BITMAP::GetBoundingBox() const { // Bitmaps are center origin, BOX2Is need top-left origin - VECTOR2I size = m_image->GetSize(); + VECTOR2I size = m_bitmapBase->GetSize(); VECTOR2I topLeft = { m_pos.x - size.x / 2, m_pos.y - size.y / 2 }; return BOX2I( topLeft, size ); @@ -158,7 +158,7 @@ std::shared_ptr PCB_BITMAP::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASH const VECTOR2I PCB_BITMAP::GetSize() const { - return m_image->GetSize(); + return m_bitmapBase->GetSize(); } @@ -167,12 +167,12 @@ void PCB_BITMAP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) if( aFlipLeftRight ) { MIRROR( m_pos.x, aCentre.x ); - m_image->Mirror( false ); + m_bitmapBase->Mirror( false ); } else { MIRROR( m_pos.y, aCentre.y ); - m_image->Mirror( true ); + m_bitmapBase->Mirror( true ); } } @@ -184,9 +184,9 @@ void PCB_BITMAP::Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) norm.Normalize(); - // each call to m_image->Rotate() rotates 90 degrees CCW + // each call to m_bitmapBase->Rotate() rotates 90 degrees CCW for( double ang = 45.0; ang < norm.AsDegrees(); ang += 90.0 ) - m_image->Rotate( false ); + m_bitmapBase->Rotate( false ); } @@ -234,6 +234,9 @@ void PCB_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetPPI() ) ); + aList.emplace_back( _( "Scale" ), wxString::Format( wxT( "%f "), GetImageScale() ) ); + aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetSize().x ) ); aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetSize().y ) ); aList.emplace_back( _( "Layer" ), LayerName( m_layer ) ); diff --git a/pcbnew/pcb_bitmap.h b/pcbnew/pcb_bitmap.h index 4f09603b6a..45fad04cf3 100644 --- a/pcbnew/pcb_bitmap.h +++ b/pcbnew/pcb_bitmap.h @@ -46,14 +46,15 @@ public: PCB_BITMAP( const PCB_BITMAP& aPcbBitmap ); - ~PCB_BITMAP() { delete m_image; } + ~PCB_BITMAP() { delete m_bitmapBase; } PCB_BITMAP& operator=( const BOARD_ITEM& aItem ); const BITMAP_BASE* GetImage() const { - wxCHECK_MSG( m_image != nullptr, nullptr, "Invalid PCB_BITMAP init, m_image is NULL." ); - return m_image; + wxCHECK_MSG( m_bitmapBase != nullptr, nullptr, + "Invalid PCB_BITMAP init, m_bitmapBase is NULL." ); + return m_bitmapBase; } /** @@ -61,7 +62,7 @@ public: */ BITMAP_BASE* MutableImage() const { - return m_image; + return m_bitmapBase; } void SetImage( wxImage* aImage ); @@ -72,9 +73,9 @@ public: * scale < 1.0 = the bitmap is drawn smaller than its original size. * scale > 1.0 = the bitmap is drawn bigger than its original size. */ - double GetImageScale() const { return m_image->GetScale(); } + double GetImageScale() const { return m_bitmapBase->GetScale(); } - void SetImageScale( double aScale ) { m_image->SetScale( aScale ); } + void SetImageScale( double aScale ) { m_bitmapBase->SetScale( aScale ); } static inline bool ClassOf( const EDA_ITEM* aItem ) { @@ -141,7 +142,7 @@ protected: private: VECTOR2I m_pos; // XY coordinates of center of the bitmap - BITMAP_BASE* m_image; // the BITMAP_BASE item + BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item }; #endif // _PCB_BITMAP_H_