Add handle-based editing for eeschema bitmaps.

Also cleans out a bunch of duplicated functionality from the image
editor dialog.

Fixes: lp:1828722
* https://bugs.launchpad.net/kicad/+bug/1828722
This commit is contained in:
Jeff Young 2019-06-19 11:31:21 +01:00
parent 6a9eb4576d
commit 3a0256aade
21 changed files with 238 additions and 915 deletions

View File

@ -1,12 +1,8 @@
/**
* @file dialog_image_editor.cpp
*/
/* /*
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2018 jean-pierre.charras * Copyright (C) 2018 jean-pierre.charras
* Copyright (C) 2011-2018 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2011-2019 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -38,9 +34,7 @@
DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem ) DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem )
: DIALOG_IMAGE_EDITOR_BASE( aParent ) : DIALOG_IMAGE_EDITOR_BASE( aParent )
{ {
m_workingImage = new BITMAP_BASE( * aItem ); m_workingImage = new BITMAP_BASE( *aItem );
m_lastImage = NULL;
m_buttonUndoLast->Enable( false );
wxString msg; wxString msg;
msg.Printf( wxT( "%f" ), m_workingImage->GetScale() ); msg.Printf( wxT( "%f" ), m_workingImage->GetScale() );
m_textCtrlScale->SetValue( msg ); m_textCtrlScale->SetValue( msg );
@ -50,53 +44,8 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem
} }
void DIALOG_IMAGE_EDITOR::OnUndoLastChange( wxCommandEvent& event )
{
BITMAP_BASE * tmp = m_workingImage;
m_workingImage = m_lastImage;
delete tmp;
m_buttonUndoLast->Enable( false );
m_lastImage = NULL;
m_panelDraw->Refresh();
}
void DIALOG_IMAGE_EDITOR::OnMirrorX_click( wxCommandEvent& event )
{
delete m_lastImage;
m_lastImage = new BITMAP_BASE( * m_workingImage );
m_buttonUndoLast->Enable( true );
m_buttonUndoLast->Enable( true );
m_workingImage->Mirror( true );
m_panelDraw->Refresh();
}
void DIALOG_IMAGE_EDITOR::OnMirrorY_click( wxCommandEvent& event )
{
delete m_lastImage;
m_lastImage = new BITMAP_BASE( * m_workingImage );
m_buttonUndoLast->Enable( true );
m_workingImage->Mirror( false );
m_panelDraw->Refresh();
}
void DIALOG_IMAGE_EDITOR::OnRotateClick( wxCommandEvent& event )
{
delete m_lastImage;
m_lastImage = new BITMAP_BASE( * m_workingImage );
m_buttonUndoLast->Enable( true );
m_workingImage->Rotate( false );
m_panelDraw->Refresh();
}
void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event ) void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event )
{ {
delete m_lastImage;
m_lastImage = new BITMAP_BASE( * m_workingImage );
m_buttonUndoLast->Enable( true );
wxImage& image = *m_workingImage->GetImageData(); wxImage& image = *m_workingImage->GetImageData();
image = image.ConvertToGreyscale(); image = image.ConvertToGreyscale();
m_workingImage->RebuildBitmap(); m_workingImage->RebuildBitmap();
@ -104,37 +53,23 @@ void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event )
} }
void DIALOG_IMAGE_EDITOR::OnHalfSize( wxCommandEvent& event ) /*
{ * Test params values correctness
delete m_lastImage; * Currently scale value must give an actual image > MIN_SIZE pixels (mandatory to be able to
m_lastImage = new BITMAP_BASE( * m_workingImage ); * see the image) and < MAX_SIZE pixels (if bigger, a confirmation will be asked)
m_buttonUndoLast->Enable( true );
wxSize psize = m_workingImage->GetSizePixels();
wxImage& image = *m_workingImage->GetImageData();
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 (mandatory to be able to see the image)
* and < MAX_SIZE pixels (if bigger, a confirmation will be asked)
* Note: The image definition is 300ppi in drawing routines. * Note: The image definition is 300ppi in drawing routines.
*/ */
bool DIALOG_IMAGE_EDITOR::CheckValues() bool DIALOG_IMAGE_EDITOR::CheckValues()
{ {
#define MIN_SIZE 32 // Min size in pixels after scaling #define MIN_SIZE 15 // Min size in pixels after scaling (50 mils)
#define MAX_SIZE 6000 // Max size in pixels after scaling #define MAX_SIZE 6000 // Max size in pixels after scaling (20 inches)
double tmp; double tmp;
wxString msg = m_textCtrlScale->GetValue(); wxString msg = m_textCtrlScale->GetValue();
// Test number correctness // Test number correctness
if( !msg.ToDouble( &tmp ) || tmp < 0.0 ) if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
{ {
wxMessageBox( _("Incorrect scale number" ) ); wxMessageBox( _( "Incorrect scale number" ) );
return false; return false;
} }
@ -144,9 +79,9 @@ bool DIALOG_IMAGE_EDITOR::CheckValues()
if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate
{ {
wxMessageBox( wxString::Format( wxMessageBox( wxString::Format( _( "This scale results in an image which is too small "
_("This scale gives a too small image size (%.2f mm or %.1f mil)" ), "(%.2f mm or %.1f mil)." ),
25.4 / 300 * size_min, 1000.0/300.0 * size_min ) ); 25.4 / 300 * size_min, 1000.0/300.0 * size_min ) );
return false; return false;
} }
@ -155,9 +90,9 @@ bool DIALOG_IMAGE_EDITOR::CheckValues()
if( size_max > MAX_SIZE ) if( size_max > MAX_SIZE )
{ {
// the actual size is 25.4/300 * size_max in mm // the actual size is 25.4/300 * size_max in mm
if( !IsOK( this, wxString::Format( if( !IsOK( this, wxString::Format( _( "This scale results in an image which is very large "
_("This scale gives a very large image size (%.1f mm or %.2f in). Are you sure?" ), "(%.1f mm or %.2f in). Are you sure?" ),
25.4 / 300 * size_max, size_max /300.0 ) ) ) 25.4 / 300 * size_max, size_max /300.0 ) ) )
return false; return false;
} }
@ -183,7 +118,7 @@ void DIALOG_IMAGE_EDITOR::OnRedrawPanel( wxPaintEvent& event )
} }
void DIALOG_IMAGE_EDITOR::TransfertToImage( BITMAP_BASE* aItem ) void DIALOG_IMAGE_EDITOR::TransferToImage( BITMAP_BASE* aItem )
{ {
wxString msg = m_textCtrlScale->GetValue(); wxString msg = m_textCtrlScale->GetValue();
double scale = 1.0; double scale = 1.0;

View File

@ -36,8 +36,6 @@ class DIALOG_IMAGE_EDITOR : public DIALOG_IMAGE_EDITOR_BASE
{ {
private: private:
BITMAP_BASE* m_workingImage; // The copy of BITMAP_BASE to be edited BITMAP_BASE* m_workingImage; // The copy of BITMAP_BASE to be edited
BITMAP_BASE* m_lastImage; // the saved BITMAP_BASE before a new change.
// Used to undo the last change
public: public:
DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem ); DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem );
@ -46,19 +44,13 @@ public:
public: public:
/** /**
* Function TransfertToImage * Function TransferToImage
* copy edited image to aItem * copy edited image to aItem
* @param aItem = the target
*/ */
void TransfertToImage( BITMAP_BASE* aItem ); void TransferToImage( BITMAP_BASE* aItem );
private: private:
void OnUndoLastChange( wxCommandEvent& event ) override;
void OnGreyScaleConvert( wxCommandEvent& event ) override; void OnGreyScaleConvert( wxCommandEvent& event ) override;
void OnHalfSize( wxCommandEvent& event ) override;
void OnMirrorX_click( wxCommandEvent& event ) override;
void OnMirrorY_click( wxCommandEvent& event ) override;
void OnRotateClick( wxCommandEvent& event ) override;
void OnRedrawPanel( wxPaintEvent& event ) override; void OnRedrawPanel( wxPaintEvent& event ) override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2018) // C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -30,23 +30,11 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID
wxBoxSizer* bSizerRight; wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL ); bSizerRight = new wxBoxSizer( wxVERTICAL );
m_buttonMirrorX = new wxButton( this, wxID_ANY, _("Mirror X"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonMirrorX, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonMirrorY = new wxButton( this, wxID_ANY, _("Mirror Y"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonMirrorY, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonRotate = new wxButton( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonRotate, 0, wxEXPAND|wxALL, 5 );
m_buttonGrey = new wxButton( this, wxID_ANY, _("Grey"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonGrey = new wxButton( this, wxID_ANY, _("Grey"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonGrey, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); bSizerRight->Add( m_buttonGrey, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonHalfSize = new wxButton( this, wxID_ANY, _("Half Size"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonHalfSize, 0, wxALL|wxEXPAND, 5 );
m_buttonUndoLast = new wxButton( this, wxID_ANY, _("Undo Last"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerRight->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 );
bSizerRight->Add( m_buttonUndoLast, 0, wxALL|wxEXPAND, 5 );
m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Image Scale:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Image Scale:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextScale->Wrap( -1 ); m_staticTextScale->Wrap( -1 );
@ -56,7 +44,7 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID
bSizerRight->Add( m_textCtrlScale, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bSizerRight->Add( m_textCtrlScale, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerLeft->Add( bSizerRight, 0, wxEXPAND, 5 ); bSizerLeft->Add( bSizerRight, 0, wxEXPAND|wxALL, 5 );
bUpperSizer->Add( bSizerLeft, 1, wxEXPAND, 5 ); bUpperSizer->Add( bSizerLeft, 1, wxEXPAND, 5 );
@ -82,23 +70,13 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID
// Connect Events // Connect Events
m_panelDraw->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRedrawPanel ), NULL, this ); m_panelDraw->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRedrawPanel ), NULL, this );
m_buttonMirrorX->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorX_click ), NULL, this );
m_buttonMirrorY->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorY_click ), NULL, this );
m_buttonRotate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRotateClick ), NULL, this );
m_buttonGrey->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this ); m_buttonGrey->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this );
m_buttonHalfSize->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnHalfSize ), NULL, this );
m_buttonUndoLast->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnUndoLastChange ), NULL, this );
} }
DIALOG_IMAGE_EDITOR_BASE::~DIALOG_IMAGE_EDITOR_BASE() DIALOG_IMAGE_EDITOR_BASE::~DIALOG_IMAGE_EDITOR_BASE()
{ {
// Disconnect Events // Disconnect Events
m_panelDraw->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRedrawPanel ), NULL, this ); m_panelDraw->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRedrawPanel ), NULL, this );
m_buttonMirrorX->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorX_click ), NULL, this );
m_buttonMirrorY->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnMirrorY_click ), NULL, this );
m_buttonRotate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnRotateClick ), NULL, this );
m_buttonGrey->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this ); m_buttonGrey->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnGreyScaleConvert ), NULL, this );
m_buttonHalfSize->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnHalfSize ), NULL, this );
m_buttonUndoLast->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMAGE_EDITOR_BASE::OnUndoLastChange ), NULL, this );
} }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2018) // C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -36,12 +36,7 @@ class DIALOG_IMAGE_EDITOR_BASE : public DIALOG_SHIM
protected: protected:
wxPanel* m_panelDraw; wxPanel* m_panelDraw;
wxButton* m_buttonMirrorX;
wxButton* m_buttonMirrorY;
wxButton* m_buttonRotate;
wxButton* m_buttonGrey; wxButton* m_buttonGrey;
wxButton* m_buttonHalfSize;
wxButton* m_buttonUndoLast;
wxStaticText* m_staticTextScale; wxStaticText* m_staticTextScale;
wxTextCtrl* m_textCtrlScale; wxTextCtrl* m_textCtrlScale;
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
@ -50,12 +45,7 @@ class DIALOG_IMAGE_EDITOR_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnRedrawPanel( wxPaintEvent& event ) { event.Skip(); } virtual void OnRedrawPanel( wxPaintEvent& event ) { event.Skip(); }
virtual void OnMirrorX_click( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMirrorY_click( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRotateClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnGreyScaleConvert( wxCommandEvent& event ) { event.Skip(); } virtual void OnGreyScaleConvert( wxCommandEvent& event ) { event.Skip(); }
virtual void OnHalfSize( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUndoLastChange( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -14,7 +14,6 @@
<property name="file">dialog_image_editor_base</property> <property name="file">dialog_image_editor_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">dialog_image_editor</property> <property name="name">dialog_image_editor</property>
<property name="namespace"></property> <property name="namespace"></property>
@ -194,277 +193,13 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerRight</property> <property name="name">bSizerRight</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" 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">0</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">Mirror X</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_buttonMirrorX</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnMirrorX_click</event>
<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">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" 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">0</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">Mirror Y</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_buttonMirrorY</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnMirrorY_click</event>
<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">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" 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">0</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">Rotate</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_buttonRotate</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRotateClick</event>
<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"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
@ -554,179 +289,13 @@
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">10</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxButton" expanded="1"> <object class="spacer" expanded="1">
<property name="BottomDockable">1</property> <property name="height">0</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">0</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">Half Size</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_buttonHalfSize</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property> <property name="permission">protected</property>
<property name="pin_button">1</property> <property name="width">0</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnHalfSize</event>
<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">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" 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">0</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">Undo Last</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_buttonUndoLast</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnUndoLastChange</event>
<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> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">

View File

@ -140,8 +140,6 @@ set( EESCHEMA_SRCS
connection_graph.cpp connection_graph.cpp
cross-probing.cpp cross-probing.cpp
drc_erc_item.cpp drc_erc_item.cpp
edit_bitmap.cpp
edit_component_in_schematic.cpp
edit_label.cpp edit_label.cpp
eeschema_config.cpp eeschema_config.cpp
erc.cpp erc.cpp

View File

@ -23,16 +23,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file sch_text.h
* @brief Implementation of the label properties dialog.
*/
#include <fctsys.h> #include <fctsys.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <base_units.h> #include <base_units.h>
#include <sch_validators.h> #include <sch_validators.h>
#include <tool/tool_manager.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
#include <general.h> #include <general.h>
#include <gr_text.h> #include <gr_text.h>
@ -40,9 +35,9 @@
#include <sch_text.h> #include <sch_text.h>
#include <typeinfo> #include <typeinfo>
#include <widgets/unit_binder.h> #include <widgets/unit_binder.h>
#include <dialog_edit_label_base.h> #include <dialog_edit_label_base.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <tool/actions.h>
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
class SCH_TEXT; class SCH_TEXT;
@ -91,14 +86,11 @@ private:
}; };
void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem ) int InvokeDialogLabelEditor( SCH_EDIT_FRAME* aCaller, SCH_TEXT* aTextItem )
{ {
if( aTextItem == NULL ) DIALOG_LABEL_EDITOR dialog( aCaller, aTextItem );
return;
DIALOG_LABEL_EDITOR dialog( this, aTextItem ); return dialog.ShowModal();
dialog.ShowModal();
} }

View File

@ -1,52 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 jean-pierre.charras
* Copyright (C) 2012-2019 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <sch_draw_panel.h>
#include <sch_view.h>
#include <sch_edit_frame.h>
#include <sch_bitmap.h>
#include <dialog_image_editor.h>
#include <view/view_group.h>
bool SCH_EDIT_FRAME::EditImage( SCH_BITMAP* aItem )
{
// TODO: change image scale or more
DIALOG_IMAGE_EDITOR dlg( this, aItem->GetImage() );
if( dlg.ShowModal() != wxID_OK )
return false;
// save old image in undo list if not already in edit
if( aItem->GetEditFlags() == 0 )
SaveCopyInUndoList( aItem, UR_CHANGED );
dlg.TransfertToImage( aItem->GetImage() );
RefreshItem( aItem );
OnModify();
return true;
}

View File

@ -1,105 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file edit_component_in_schematic.cpp
* @brief Schematic component editing code.
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_edit_frame.h>
#include <msgpanel.h>
#include <general.h>
#include <class_library.h>
#include <sch_component.h>
#include <symbol_lib_table.h>
#include <dialogs/dialog_edit_component_in_schematic.h>
#include <dialogs/dialog_edit_one_field.h>
void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
{
wxCHECK_RET( aField != NULL && aField->Type() == SCH_FIELD_T,
wxT( "Cannot edit invalid schematic field." ) );
SCH_COMPONENT* component = (SCH_COMPONENT*) aField->GetParent();
wxCHECK_RET( component != NULL && component->Type() == SCH_COMPONENT_T,
wxT( "Invalid schematic field parent item." ) );
// Save old component in undo list if not already in edit, or moving.
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
SaveCopyInUndoList( component, UR_CHANGED );
wxString title;
title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
DIALOG_SCH_EDIT_ONE_FIELD dlg( this, title, aField );
// The dialog may invoke a kiway player for footprint fields
// so we must use a quasimodal
if( dlg.ShowQuasiModal() != wxID_OK )
return;
dlg.UpdateField( aField, g_CurrentSheet );
if( m_autoplaceFields )
component->AutoAutoplaceFields( GetScreen() );
RefreshItem( aField );
OnModify();
MSG_PANEL_ITEMS items;
component->GetMsgPanelInfo( m_userUnits, items );
SetMsgPanel( items );
}
void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
{
wxCHECK_RET( aComponent != nullptr && aComponent->Type() == SCH_COMPONENT_T,
wxT( "Invalid component object pointer. Bad Programmer!" ) );
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( this, aComponent );
// This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
// frame. Therefore this dialog as a modal frame parent, MUST be run under
// quasimodal mode for the quasimodal frame support to work. So don't use
// the QUASIMODAL macros here.
int ret = dlg.ShowQuasiModal();
if( ret == wxID_OK )
{
if( m_autoplaceFields )
aComponent->AutoAutoplaceFields( GetScreen() );
GetCanvas()->Refresh();
}
}

View File

@ -35,7 +35,7 @@
#include <sch_text.h> #include <sch_text.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <sch_view.h> #include <sch_view.h>
#include "invoke_sch_dialog.h"
static PINSHEETLABEL_SHAPE lastGlobalLabelShape = NET_INPUT; static PINSHEETLABEL_SHAPE lastGlobalLabelShape = NET_INPUT;
static int lastTextOrientation = 0; static int lastTextOrientation = 0;
@ -79,9 +79,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) );
textItem->SetFlags( IS_NEW | IS_MOVED ); textItem->SetFlags( IS_NEW | IS_MOVED );
EditSchematicText( textItem ); if( InvokeDialogLabelEditor( this, textItem ) != wxID_OK || textItem->GetText().IsEmpty() )
if( textItem->GetText().IsEmpty() )
{ {
delete textItem; delete textItem;
return nullptr; return nullptr;

View File

@ -49,6 +49,7 @@ class wxDialog;
class LIB_PART; class LIB_PART;
class PART_LIBS; class PART_LIBS;
class SCH_COMPONENT; class SCH_COMPONENT;
class SCH_TEXT;
class SCH_SHEET_PATH; class SCH_SHEET_PATH;
class RESCUER; class RESCUER;
@ -105,4 +106,11 @@ int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller );
*/ */
bool InvokeDialogEditComponentsLibId( SCH_EDIT_FRAME* aCaller ); bool InvokeDialogEditComponentsLibId( SCH_EDIT_FRAME* aCaller );
/**
* Launches the "Edit Text/Label" dialog
* @return the ShowModal() result (wxID_OK, wxID_CANCEL, etc.)
*/
int InvokeDialogLabelEditor( SCH_EDIT_FRAME* aCaller, SCH_TEXT* aText );
#endif // INVOKE_SCH_DIALOG_H_ #endif // INVOKE_SCH_DIALOG_H_

View File

@ -56,52 +56,33 @@ public:
SCH_ITEM& operator=( const SCH_ITEM& aItem ); SCH_ITEM& operator=( const SCH_ITEM& aItem );
/*
* Accessors:
*/
double GetPixelScaleFactor() const { return m_image->GetPixelScaleFactor(); }
void SetPixelScaleFactor( double aSF ) { m_image->SetPixelScaleFactor( aSF ); }
BITMAP_BASE* GetImage() BITMAP_BASE* GetImage()
{ {
wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP initialization, m_image is NULL." ); wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP init, m_image is NULL." );
return m_image; return m_image;
} }
/** /**
* @return the scaling factor from pixel size to actual draw size * @return the image "zoom" value
* this scaling factor depend on m_pixelScaleFactor and m_Scale * scale = 1.0 = original size of bitmap.
* m_pixelScaleFactor gives the scaling factor between a pixel size and * scale < 1.0 = the bitmap is drawn smaller than its original size.
* the internal schematic units * 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_image->GetScalingFactor();
}
/**
* @return the m_Scale image "zoom" value
* m_Scale is an user dependant value, and is similar to a "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 GetImageScale() const double GetImageScale() const
{ {
return m_image->GetScale(); return m_image->GetScale();
} }
void SetImageScale( double aScale )
{
m_image->SetScale( aScale );
}
wxString GetClass() const override wxString GetClass() const override
{ {
return wxT( "SCH_BITMAP" ); return wxT( "SCH_BITMAP" );
} }
/** /**
* @return the actual size (in user units, not in pixels) of the image * @return the actual size (in user units, not in pixels) of the image
*/ */

View File

@ -760,27 +760,6 @@ public:
*/ */
void ConvertTextType( SCH_TEXT* aText, KICAD_T aNewType ); void ConvertTextType( SCH_TEXT* aText, KICAD_T aNewType );
/**
* Launches the "Edit Text/Label" dialog
*/
void EditSchematicText( SCH_TEXT* aText );
/**
* Launches the "Edit Image" dialog to modify an image
* @param aItem Pointer to the image item to modify
* @return true if the image was modified, false if the user canceled
*/
bool EditImage( SCH_BITMAP* aItem );
/**
* Function EditLine
* displays the dialog for editing the parameters of \a aLine.
* @param aLine The Line/Wire/Bus to edit.
* @param aRedraw = true to refresh the screen
* @return The user response from the edit dialog.
*/
int EditLine( SCH_LINE* aLine, bool aRedraw );
/** /**
* Edit an existing sheet or add a new sheet to the schematic. * Edit an existing sheet or add a new sheet to the schematic.
* *
@ -836,15 +815,6 @@ public:
*/ */
SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel ); SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel );
/**
* Display the dialog for editing the parameters of \a aSheetPin.
*
* @param aSheetPin The sheet pin item to edit.
* @param aRedraw = true to refresh the screen
* @return The user response from the edit dialog.
*/
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw );
/** /**
* Import a hierarchical label with no attached sheet pin. * Import a hierarchical label with no attached sheet pin.
* *
@ -862,22 +832,7 @@ public:
int GetLabelIncrement() const { return m_repeatLabelDelta; } int GetLabelIncrement() const { return m_repeatLabelDelta; }
/**
* Display the edit component dialog to edit the parameters of \a aComponent.
*
* @param aComponent is a pointer to the SCH_COMPONENT object to be edited.
*/
void EditComponent( SCH_COMPONENT* aComponent );
public: public:
/**
* Display the edit field dialog to edit the parameters of \a aField.
*
* @param aField is a pointer to the SCH_FIELD object to be edited.
*/
void EditComponentFieldText( SCH_FIELD* aField );
void ConvertPart( SCH_COMPONENT* aComponent ); void ConvertPart( SCH_COMPONENT* aComponent );
void SelectUnit( SCH_COMPONENT* aComponent, int aUnit ); void SelectUnit( SCH_COMPONENT* aComponent, int aUnit );

View File

@ -40,8 +40,6 @@
#include <netlist_object.h> #include <netlist_object.h>
#include <sch_view.h> #include <sch_view.h>
#include <dialogs/dialog_edit_line_style.h>
static wxPenStyle getwxPenStyle( PlotDashType aType ) static wxPenStyle getwxPenStyle( PlotDashType aType )
{ {
@ -383,8 +381,7 @@ bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition )
else else
return false; return false;
return ( sign( first.x ) == sign( second.x ) && return ( sign( first.x ) == sign( second.x ) && sign( first.y ) == sign( second.y ) );
sign( first.y ) == sign( second.y ) );
} }
@ -622,20 +619,10 @@ wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
switch( m_Layer ) switch( m_Layer )
{ {
case LAYER_NOTES: case LAYER_NOTES: txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); break;
txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); case LAYER_WIRE: txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" ); break;
break; case LAYER_BUS: txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" ); break;
default: txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" ); break;
case LAYER_WIRE:
txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" );
break;
case LAYER_BUS:
txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" );
break;
default:
txtfmt = _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" );
} }
return wxString::Format( txtfmt, return wxString::Format( txtfmt,
@ -782,29 +769,15 @@ void SCH_LINE::SetPosition( const wxPoint& aPosition )
} }
wxPoint SCH_LINE::MidPoint()
{
return wxPoint( ( m_start.x + m_end.x ) / 2, ( m_start.y + m_end.y ) / 2 );
}
void SCH_LINE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) void SCH_LINE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{ {
wxString msg; wxString msg;
switch( GetLayer() ) switch( GetLayer() )
{ {
case LAYER_WIRE: case LAYER_WIRE: msg = _( "Net Wire" ); break;
msg = _( "Net Wire" ); case LAYER_BUS: msg = _( "Bus Wire" ); break;
break; default: msg = _( "Graphical" ); return;
case LAYER_BUS:
msg = _( "Bus Wire" );
break;
default:
msg = _( "Graphical" );
return;
} }
aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Line Type" ), msg, DARKCYAN ) );
@ -822,23 +795,3 @@ void SCH_LINE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
} }
} }
int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
{
if( aLine == NULL )
return wxID_CANCEL;
// We purposely disallow editing everything except graphic lines
if( aLine->GetLayer() != LAYER_NOTES )
return wxID_CANCEL;
DIALOG_EDIT_LINE_STYLE dlg( this, aLine );
if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL;
if( aRedraw )
RefreshItem( aLine );
return wxID_OK;
}

View File

@ -198,8 +198,6 @@ public:
void Plot( PLOTTER* aPlotter ) override; void Plot( PLOTTER* aPlotter ) override;
wxPoint MidPoint();
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
void SwapData( SCH_ITEM* aItem ) override; void SwapData( SCH_ITEM* aItem ) override;

View File

@ -28,6 +28,7 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <project.h> #include <project.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <tool/tool_manager.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_legacy_plugin.h> #include <sch_legacy_plugin.h>
@ -36,7 +37,7 @@
#include <sch_view.h> #include <sch_view.h>
#include <dialogs/dialog_sch_sheet_props.h> #include <dialogs/dialog_sch_sheet_props.h>
#include <dialogs/dialog_sch_edit_sheet_pin.h> #include <dialogs/dialog_sch_edit_sheet_pin.h>
#include <tool/actions.h>
void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename ) void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
{ {
@ -347,23 +348,6 @@ const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize()
} }
int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw )
{
if( aSheetPin == NULL )
return wxID_CANCEL;
DIALOG_SCH_EDIT_SHEET_PIN dlg( this, aSheetPin );
if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL;
if( aRedraw )
RefreshItem( aSheetPin );
return wxID_OK;
}
SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel ) SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel )
{ {
wxString text; wxString text;
@ -382,9 +366,9 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL*
if( !aLabel ) if( !aLabel )
{ {
int response = EditSheetPin( sheetPin, false ); DIALOG_SCH_EDIT_SHEET_PIN dlg( this, sheetPin );
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) ) if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
{ {
delete sheetPin; delete sheetPin;
return nullptr; return nullptr;

View File

@ -37,6 +37,7 @@ using namespace std::placeholders;
#include <status_popup.h> #include <status_popup.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_bitmap.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <lib_arc.h> #include <lib_arc.h>
@ -132,6 +133,18 @@ public:
points->AddPoint( (wxPoint) botRight ); points->AddPoint( (wxPoint) botRight );
break; break;
} }
case SCH_BITMAP_T:
{
SCH_BITMAP* bitmap = (SCH_BITMAP*) aItem;
wxPoint topLeft = bitmap->GetPosition() - bitmap->GetSize() / 2;
wxPoint botRight = bitmap->GetPosition() + bitmap->GetSize() / 2;
points->AddPoint( (wxPoint) topLeft );
points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
points->AddPoint( (wxPoint) botRight );
break;
}
case SCH_LINE_T: case SCH_LINE_T:
{ {
SCH_LINE* line = (SCH_LINE*) aItem; SCH_LINE* line = (SCH_LINE*) aItem;
@ -237,15 +250,23 @@ void EE_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
{ {
static KICAD_T pointTypes[] = { LIB_ARC_T, LIB_CIRCLE_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, static KICAD_T supportedTypes[] = {
SCH_SHEET_T, SCH_LINE_LOCATE_GRAPHIC_LINE_T, EOT }; LIB_ARC_T,
LIB_CIRCLE_T,
LIB_POLYLINE_T,
LIB_RECTANGLE_T,
SCH_SHEET_T,
SCH_LINE_LOCATE_GRAPHIC_LINE_T,
SCH_BITMAP_T,
EOT
};
if( !m_selectionTool ) if( !m_selectionTool )
return 0; return 0;
const EE_SELECTION& selection = m_selectionTool->GetSelection(); const EE_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) ) if( selection.Size() != 1 || !selection.Front()->IsType( supportedTypes ) )
return 0; return 0;
// Wait till drawing tool is done // Wait till drawing tool is done
@ -450,6 +471,29 @@ void EE_POINT_EDITOR::updateItem() const
break; break;
} }
case SCH_BITMAP_T:
{
SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition();
VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition();
VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition();
VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition();
pinEditedCorner( getEditedPointIndex(), Mils2iu( 50 ), Mils2iu( 50 ),
topLeft, topRight, botLeft, botRight );
double oldWidth = bitmap->GetSize().x;
double newWidth = topRight.x - topLeft.x;
double widthRatio = newWidth / oldWidth;
double oldHeight = bitmap->GetSize().y;
double newHeight = botLeft.y - topLeft.y;
double heightRatio = newHeight / oldHeight;
bitmap->SetImageScale( bitmap->GetImageScale() * std::min( widthRatio, heightRatio ) );
break;
}
case SCH_SHEET_T: case SCH_SHEET_T:
{ {
SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) item;
@ -592,6 +636,19 @@ void EE_POINT_EDITOR::updatePoints()
break; break;
} }
case SCH_BITMAP_T:
{
SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
wxPoint topLeft = bitmap->GetPosition() - bitmap->GetSize() / 2;
wxPoint botRight = bitmap->GetPosition() + bitmap->GetSize() / 2;
m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft );
m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( botRight.x, topLeft.y );
m_editPoints->Point( RECT_BOTLEFT ).SetPosition( topLeft.x, botRight.y );
m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight );
break;
}
case SCH_SHEET_T: case SCH_SHEET_T:
{ {
SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) item;

View File

@ -327,6 +327,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
{ {
m_frame->AddItemToScreenAndUndoList( image ); m_frame->AddItemToScreenAndUndoList( image );
image = nullptr; image = nullptr;
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
m_view->ClearPreview(); m_view->ClearPreview();

View File

@ -46,6 +46,11 @@
#include <status_popup.h> #include <status_popup.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <dialogs/dialog_image_editor.h>
#include <dialogs/dialog_edit_line_style.h>
#include <dialogs/dialog_edit_component_in_schematic.h>
#include <dialogs/dialog_sch_edit_sheet_pin.h>
#include <dialogs/dialog_edit_one_field.h>
#include "sch_drawing_tools.h" #include "sch_drawing_tools.h"
@ -1002,6 +1007,35 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
} }
void SCH_EDIT_TOOL::editComponentFieldText( SCH_FIELD* aField )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) aField->GetParent();
// Save old component in undo list if not already in edit, or moving.
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
m_frame->SaveCopyInUndoList( component, UR_CHANGED );
wxString title;
title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
// The dialog may invoke a kiway player for footprint fields
// so we must use a quasimodal
if( dlg.ShowQuasiModal() != wxID_OK )
return;
dlg.UpdateField( aField, g_CurrentSheet );
if( m_frame->GetAutoplaceFields() )
component->AutoAutoplaceFields( m_frame->GetScreen() );
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->RefreshItem( aField );
m_frame->OnModify();
}
int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
{ {
static KICAD_T Nothing[] = { EOT }; static KICAD_T Nothing[] = { EOT };
@ -1030,15 +1064,15 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
SCH_COMPONENT* component = (SCH_COMPONENT*) item; SCH_COMPONENT* component = (SCH_COMPONENT*) item;
if( aEvent.IsAction( &EE_ACTIONS::editReference ) ) if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
m_frame->EditComponentFieldText( component->GetField( REFERENCE ) ); editComponentFieldText( component->GetField( REFERENCE ) );
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) ) else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
m_frame->EditComponentFieldText( component->GetField( VALUE ) ); editComponentFieldText( component->GetField( VALUE ) );
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) ) else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
m_frame->EditComponentFieldText( component->GetField( FOOTPRINT ) ); editComponentFieldText( component->GetField( FOOTPRINT ) );
} }
else if( item->Type() == SCH_FIELD_T ) else if( item->Type() == SCH_FIELD_T )
{ {
m_frame->EditComponentFieldText( (SCH_FIELD*) item ); editComponentFieldText( (SCH_FIELD*) item );
} }
return 0; return 0;
@ -1124,7 +1158,23 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
switch( item->Type() ) switch( item->Type() )
{ {
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
m_frame->EditComponent( (SCH_COMPONENT*) item ); {
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( m_frame, component );
// This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
// frame. Therefore this dialog as a modal frame parent, MUST be run under
// quasimodal mode for the quasimodal frame support to work. So don't use
// the QUASIMODAL macros here.
if( dlg.ShowQuasiModal() == wxID_OK )
{
if( m_frame->GetAutoplaceFields() )
component->AutoAutoplaceFields( m_frame->GetScreen() );
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->OnModify();
}
}
break; break;
case SCH_SHEET_T: case SCH_SHEET_T:
@ -1157,31 +1207,72 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
} }
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
m_frame->EditSheetPin( (SCH_SHEET_PIN*) item, true ); {
SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
DIALOG_SCH_EDIT_SHEET_PIN dlg( m_frame, pin );
if( dlg.ShowModal() == wxID_OK )
{
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->OnModify();
}
}
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
m_frame->EditSchematicText( (SCH_TEXT*) item ); if( InvokeDialogLabelEditor( m_frame, (SCH_TEXT*) item ) == wxID_OK )
break;
case SCH_FIELD_T:
m_frame->EditComponentFieldText( (SCH_FIELD*) item );
break;
case SCH_BITMAP_T:
if( m_frame->EditImage( (SCH_BITMAP*) item ) )
{ {
// The bitmap is cached in Opengl: clear the cache in case it has become invalid m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
getView()->RecacheAllItems(); m_frame->OnModify();
} }
break; break;
case SCH_FIELD_T:
editComponentFieldText( (SCH_FIELD*) item );
break;
case SCH_BITMAP_T:
{
// JEY TODO: selected image doesn't have any highlighting....
SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
if( dlg.ShowModal() == wxID_OK )
{
// save old image in undo list if not already in edit
if( bitmap->GetEditFlags() == 0 )
m_frame->SaveCopyInUndoList( bitmap, UR_CHANGED );
dlg.TransferToImage( bitmap->GetImage() );
// The bitmap is cached in Opengl: clear the cache in case it has become invalid
getView()->RecacheAllItems();
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->OnModify();
}
}
break;
case SCH_LINE_T: case SCH_LINE_T:
m_frame->EditLine( (SCH_LINE*) item, true ); {
SCH_LINE* line = (SCH_LINE*) item;
// We purposely disallow editing everything except graphic lines
if( line->GetLayer() != LAYER_NOTES )
break;
DIALOG_EDIT_LINE_STYLE dlg( m_frame, line );
if( dlg.ShowModal() == wxID_OK )
{
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
m_frame->OnModify();
}
}
break; break;
case SCH_MARKER_T: // These items have no properties to edit case SCH_MARKER_T: // These items have no properties to edit

View File

@ -67,6 +67,8 @@ public:
int DeleteItemCursor( const TOOL_EVENT& aEvent ); int DeleteItemCursor( const TOOL_EVENT& aEvent );
private: private:
void editComponentFieldText( SCH_FIELD* aField );
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -248,14 +248,12 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{ {
item->ClearEditFlags(); item->ClearEditFlags();
item = nullptr; item = nullptr;
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
m_frame->OnModify(); m_frame->OnModify();
if( immediateMode ) if( immediateMode )
{
m_toolMgr->RunAction( ACTIONS::activatePointEditor );
break; break;
}
} }
} }