diff --git a/common/dialogs/dialog_image_editor.cpp b/common/dialogs/dialog_image_editor.cpp index 8323104d19..eae18db586 100644 --- a/common/dialogs/dialog_image_editor.cpp +++ b/common/dialogs/dialog_image_editor.cpp @@ -1,12 +1,8 @@ -/** - * @file dialog_image_editor.cpp - */ - /* * This program source code file is part of KICAD, a free EDA CAD application. * * 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 * 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_BASE( aParent ) { - m_workingImage = new BITMAP_BASE( * aItem ); - m_lastImage = NULL; - m_buttonUndoLast->Enable( false ); + m_workingImage = new BITMAP_BASE( *aItem ); wxString msg; msg.Printf( wxT( "%f" ), m_workingImage->GetScale() ); 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 ) { - delete m_lastImage; - m_lastImage = new BITMAP_BASE( * m_workingImage ); - m_buttonUndoLast->Enable( true ); wxImage& image = *m_workingImage->GetImageData(); image = image.ConvertToGreyscale(); m_workingImage->RebuildBitmap(); @@ -104,37 +53,23 @@ void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event ) } -void DIALOG_IMAGE_EDITOR::OnHalfSize( wxCommandEvent& event ) -{ - delete m_lastImage; - m_lastImage = new BITMAP_BASE( * m_workingImage ); - 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) +/* + * 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. */ bool DIALOG_IMAGE_EDITOR::CheckValues() { - #define MIN_SIZE 32 // Min size in pixels after scaling - #define MAX_SIZE 6000 // Max 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 (20 inches) double tmp; wxString msg = m_textCtrlScale->GetValue(); // Test number correctness if( !msg.ToDouble( &tmp ) || tmp < 0.0 ) { - wxMessageBox( _("Incorrect scale number" ) ); + wxMessageBox( _( "Incorrect scale number" ) ); 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 { - wxMessageBox( wxString::Format( - _("This scale gives a too small image size (%.2f mm or %.1f mil)" ), - 25.4 / 300 * size_min, 1000.0/300.0 * size_min ) ); + wxMessageBox( wxString::Format( _( "This scale results in an image which is too small " + "(%.2f mm or %.1f mil)." ), + 25.4 / 300 * size_min, 1000.0/300.0 * size_min ) ); return false; } @@ -155,9 +90,9 @@ bool DIALOG_IMAGE_EDITOR::CheckValues() if( size_max > MAX_SIZE ) { // the actual size is 25.4/300 * size_max in mm - if( !IsOK( this, wxString::Format( - _("This scale gives a very large image size (%.1f mm or %.2f in). Are you sure?" ), - 25.4 / 300 * size_max, size_max /300.0 ) ) ) + if( !IsOK( this, wxString::Format( _( "This scale results in an image which is very large " + "(%.1f mm or %.2f in). Are you sure?" ), + 25.4 / 300 * size_max, size_max /300.0 ) ) ) 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(); double scale = 1.0; diff --git a/common/dialogs/dialog_image_editor.h b/common/dialogs/dialog_image_editor.h index efb5e7449a..0e9c1bd854 100644 --- a/common/dialogs/dialog_image_editor.h +++ b/common/dialogs/dialog_image_editor.h @@ -36,8 +36,6 @@ class DIALOG_IMAGE_EDITOR : public DIALOG_IMAGE_EDITOR_BASE { private: 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: DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem ); @@ -46,19 +44,13 @@ public: public: /** - * Function TransfertToImage + * Function TransferToImage * copy edited image to aItem - * @param aItem = the target */ - void TransfertToImage( BITMAP_BASE* aItem ); + void TransferToImage( BITMAP_BASE* aItem ); private: - void OnUndoLastChange( 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; bool TransferDataFromWindow() override; diff --git a/common/dialogs/dialog_image_editor_base.cpp b/common/dialogs/dialog_image_editor_base.cpp index b8fe700b2a..12fda5dd3d 100644 --- a/common/dialogs/dialog_image_editor_base.cpp +++ b/common/dialogs/dialog_image_editor_base.cpp @@ -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/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -30,23 +30,11 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bSizerRight; 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 ); 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( m_buttonUndoLast, 0, wxALL|wxEXPAND, 5 ); + bSizerRight->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Image Scale:"), wxDefaultPosition, wxDefaultSize, 0 ); 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 ); - bSizerLeft->Add( bSizerRight, 0, wxEXPAND, 5 ); + bSizerLeft->Add( bSizerRight, 0, wxEXPAND|wxALL, 5 ); bUpperSizer->Add( bSizerLeft, 1, wxEXPAND, 5 ); @@ -82,23 +70,13 @@ DIALOG_IMAGE_EDITOR_BASE::DIALOG_IMAGE_EDITOR_BASE( wxWindow* parent, wxWindowID // Connect Events 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_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() { // Disconnect Events 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_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 ); } diff --git a/common/dialogs/dialog_image_editor_base.h b/common/dialogs/dialog_image_editor_base.h index abbdc9051d..087e99ff31 100644 --- a/common/dialogs/dialog_image_editor_base.h +++ b/common/dialogs/dialog_image_editor_base.h @@ -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/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -36,12 +36,7 @@ class DIALOG_IMAGE_EDITOR_BASE : public DIALOG_SHIM protected: wxPanel* m_panelDraw; - wxButton* m_buttonMirrorX; - wxButton* m_buttonMirrorY; - wxButton* m_buttonRotate; wxButton* m_buttonGrey; - wxButton* m_buttonHalfSize; - wxButton* m_buttonUndoLast; wxStaticText* m_staticTextScale; wxTextCtrl* m_textCtrlScale; 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 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 OnHalfSize( wxCommandEvent& event ) { event.Skip(); } - virtual void OnUndoLastChange( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/common/dialogs/dialog_image_editor_fbp.fbp b/common/dialogs/dialog_image_editor_fbp.fbp index c18e7d766e..6a2eda3005 100644 --- a/common/dialogs/dialog_image_editor_fbp.fbp +++ b/common/dialogs/dialog_image_editor_fbp.fbp @@ -14,7 +14,6 @@ dialog_image_editor_base 1000 none - 1 dialog_image_editor @@ -194,277 +193,13 @@ 5 - wxEXPAND + wxEXPAND|wxALL 0 bSizerRight wxVERTICAL none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Mirror X - - 0 - - - 0 - - 1 - m_buttonMirrorX - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnMirrorX_click - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Mirror Y - - 0 - - - 0 - - 1 - m_buttonMirrorY - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnMirrorY_click - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Rotate - - 0 - - - 0 - - 1 - m_buttonRotate - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnRotateClick - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT @@ -554,179 +289,13 @@ - 5 - wxALL|wxEXPAND + 10 + wxEXPAND|wxTOP|wxBOTTOM 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Half Size - - 0 - - - 0 - - 1 - m_buttonHalfSize - 1 - - + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnHalfSize - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Undo Last - - 0 - - - 0 - - 1 - m_buttonUndoLast - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnUndoLastChange - - - - - - - - - - - - - - - - - - - - - - - + 0 diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index f9671f3b74..5fe56e9cec 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -140,8 +140,6 @@ set( EESCHEMA_SRCS connection_graph.cpp cross-probing.cpp drc_erc_item.cpp - edit_bitmap.cpp - edit_component_in_schematic.cpp edit_label.cpp eeschema_config.cpp erc.cpp diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 594f7007dc..26257f5a9a 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -23,16 +23,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_text.h - * @brief Implementation of the label properties dialog. - */ - #include #include #include #include - +#include #include #include #include @@ -40,9 +35,9 @@ #include #include #include - #include #include +#include class SCH_EDIT_FRAME; 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 ) - return; + DIALOG_LABEL_EDITOR dialog( aCaller, aTextItem ); - DIALOG_LABEL_EDITOR dialog( this, aTextItem ); - - dialog.ShowModal(); + return dialog.ShowModal(); } diff --git a/eeschema/edit_bitmap.cpp b/eeschema/edit_bitmap.cpp deleted file mode 100644 index b3dd21125c..0000000000 --- a/eeschema/edit_bitmap.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -#include - - -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; -} diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp deleted file mode 100644 index 3d1f8285dc..0000000000 --- a/eeschema/edit_component_in_schematic.cpp +++ /dev/null @@ -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 - * 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - - -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(); - } -} \ No newline at end of file diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 30199732a8..9bcee5e75d 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -35,7 +35,7 @@ #include #include #include - +#include "invoke_sch_dialog.h" static PINSHEETLABEL_SHAPE lastGlobalLabelShape = NET_INPUT; static int lastTextOrientation = 0; @@ -79,9 +79,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) textItem->SetTextSize( wxSize( GetDefaultTextSize(), GetDefaultTextSize() ) ); textItem->SetFlags( IS_NEW | IS_MOVED ); - EditSchematicText( textItem ); - - if( textItem->GetText().IsEmpty() ) + if( InvokeDialogLabelEditor( this, textItem ) != wxID_OK || textItem->GetText().IsEmpty() ) { delete textItem; return nullptr; diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index 9376a87abf..5b34c4d82c 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -49,6 +49,7 @@ class wxDialog; class LIB_PART; class PART_LIBS; class SCH_COMPONENT; +class SCH_TEXT; class SCH_SHEET_PATH; class RESCUER; @@ -105,4 +106,11 @@ int InvokeDialogNetList( 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_ diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 23359725b5..54ef61cf2f 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -56,52 +56,33 @@ public: 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() { - 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 the scaling factor from pixel size to actual draw size - * this scaling factor depend on m_pixelScaleFactor and m_Scale - * m_pixelScaleFactor gives the scaling factor between a pixel size and - * the internal schematic units - * m_Scale is an user dependant value, and gives the "zoom" value - * m_Scale = 1.0 = original size of bitmap. - * m_Scale < 1.0 = the bitmap is drawn smaller than its original size. - * m_Scale > 1.0 = the bitmap is drawn bigger than its original size. - */ - 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. + * @return the image "zoom" value + * scale = 1.0 = original size of bitmap. + * 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(); } + void SetImageScale( double aScale ) + { + m_image->SetScale( aScale ); + } + wxString GetClass() const override { return wxT( "SCH_BITMAP" ); } - /** * @return the actual size (in user units, not in pixels) of the image */ diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 6201876f52..b217b13afd 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -760,27 +760,6 @@ public: */ 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. * @@ -836,15 +815,6 @@ public: */ 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. * @@ -862,22 +832,7 @@ public: 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: - - /** - * 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 SelectUnit( SCH_COMPONENT* aComponent, int aUnit ); diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 3ce8e8bb24..8e52878096 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -40,8 +40,6 @@ #include #include -#include - static wxPenStyle getwxPenStyle( PlotDashType aType ) { @@ -383,8 +381,7 @@ bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition ) else return false; - return ( sign( first.x ) == sign( second.x ) && - sign( first.y ) == sign( second.y ) ); + return ( sign( first.x ) == sign( second.x ) && sign( first.y ) == sign( second.y ) ); } @@ -622,20 +619,10 @@ wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const switch( m_Layer ) { - case LAYER_NOTES: - txtfmt = _( "%s Graphic Line 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)" ); + case LAYER_NOTES: txtfmt = _( "%s Graphic Line 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)" ); break; } 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 ) { wxString msg; switch( GetLayer() ) { - case LAYER_WIRE: - msg = _( "Net Wire" ); - break; - - case LAYER_BUS: - msg = _( "Bus Wire" ); - break; - - default: - msg = _( "Graphical" ); - return; + case LAYER_WIRE: msg = _( "Net Wire" ); break; + case LAYER_BUS: msg = _( "Bus Wire" ); break; + default: msg = _( "Graphical" ); return; } 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; -} diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 3584025b41..1970e765ae 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -198,8 +198,6 @@ public: void Plot( PLOTTER* aPlotter ) override; - wxPoint MidPoint(); - EDA_ITEM* Clone() const override; void SwapData( SCH_ITEM* aItem ) override; diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 3a17162dfb..a2d8c49246 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ #include #include #include - +#include 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 ) { wxString text; @@ -382,9 +366,9 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* 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; return nullptr; diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 7d8ae6da8b..467fbadd36 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -37,6 +37,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include @@ -132,6 +133,18 @@ public: points->AddPoint( (wxPoint) botRight ); 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: { 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 ) { - static KICAD_T pointTypes[] = { LIB_ARC_T, LIB_CIRCLE_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, - SCH_SHEET_T, SCH_LINE_LOCATE_GRAPHIC_LINE_T, EOT }; + static KICAD_T supportedTypes[] = { + 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 ) return 0; 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; // Wait till drawing tool is done @@ -450,6 +471,29 @@ void EE_POINT_EDITOR::updateItem() const 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: { SCH_SHEET* sheet = (SCH_SHEET*) item; @@ -592,6 +636,19 @@ void EE_POINT_EDITOR::updatePoints() 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: { SCH_SHEET* sheet = (SCH_SHEET*) item; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 9348f45792..2090622a27 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -327,6 +327,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) { m_frame->AddItemToScreenAndUndoList( image ); image = nullptr; + m_toolMgr->RunAction( ACTIONS::activatePointEditor ); m_view->ClearPreview(); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 4d9130f113..262e88d0c0 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -46,6 +46,11 @@ #include #include #include +#include +#include +#include +#include +#include #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 ) { static KICAD_T Nothing[] = { EOT }; @@ -1030,15 +1064,15 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent ) SCH_COMPONENT* component = (SCH_COMPONENT*) item; if( aEvent.IsAction( &EE_ACTIONS::editReference ) ) - m_frame->EditComponentFieldText( component->GetField( REFERENCE ) ); + editComponentFieldText( component->GetField( REFERENCE ) ); else if( aEvent.IsAction( &EE_ACTIONS::editValue ) ) - m_frame->EditComponentFieldText( component->GetField( VALUE ) ); + editComponentFieldText( component->GetField( VALUE ) ); else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) ) - m_frame->EditComponentFieldText( component->GetField( FOOTPRINT ) ); + editComponentFieldText( component->GetField( FOOTPRINT ) ); } else if( item->Type() == SCH_FIELD_T ) { - m_frame->EditComponentFieldText( (SCH_FIELD*) item ); + editComponentFieldText( (SCH_FIELD*) item ); } return 0; @@ -1124,7 +1158,23 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) switch( item->Type() ) { 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; case SCH_SHEET_T: @@ -1157,31 +1207,72 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) } 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; case SCH_TEXT_T: case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: - m_frame->EditSchematicText( (SCH_TEXT*) item ); - break; - - case SCH_FIELD_T: - m_frame->EditComponentFieldText( (SCH_FIELD*) item ); - break; - - case SCH_BITMAP_T: - if( m_frame->EditImage( (SCH_BITMAP*) item ) ) + if( InvokeDialogLabelEditor( m_frame, (SCH_TEXT*) item ) == wxID_OK ) { - // 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_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: - 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; case SCH_MARKER_T: // These items have no properties to edit diff --git a/eeschema/tools/sch_edit_tool.h b/eeschema/tools/sch_edit_tool.h index 235287e289..70480a98f1 100644 --- a/eeschema/tools/sch_edit_tool.h +++ b/eeschema/tools/sch_edit_tool.h @@ -67,6 +67,8 @@ public: int DeleteItemCursor( const TOOL_EVENT& aEvent ); private: + void editComponentFieldText( SCH_FIELD* aField ); + ///> Sets up handlers for various events. void setTransitions() override; diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index 0976c02625..3dd749d6e3 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -248,14 +248,12 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) { item->ClearEditFlags(); item = nullptr; + m_toolMgr->RunAction( ACTIONS::activatePointEditor ); m_frame->OnModify(); if( immediateMode ) - { - m_toolMgr->RunAction( ACTIONS::activatePointEditor ); break; - } } }