2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-05-29 12:25:10 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-29 20:11:42 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file edtxtmod.cpp
|
|
|
|
* @brief Edit module text.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <macros.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2012-05-29 12:25:10 +00:00
|
|
|
#include <wxPcbStruct.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_text_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
wxPoint MoveVector; // Move vector for move edge, exported
|
|
|
|
// to dialog_edit mod_text.cpp
|
|
|
|
static wxPoint TextInitialPosition; // Mouse cursor initial position for
|
|
|
|
// undo/abort move command
|
2013-05-05 07:17:48 +00:00
|
|
|
static double TextInitialOrientation; // module text initial orientation for
|
2009-11-14 22:15:22 +00:00
|
|
|
// undo/abort move+rot command+rot
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Add a new graphical text to the active module (footprint)
|
2014-09-10 15:18:42 +00:00
|
|
|
* Note there always are 2 mandatory texts: reference and value.
|
2011-12-12 08:37:05 +00:00
|
|
|
* New texts have the member TEXTE_MODULE.GetType() set to TEXT_is_DIVERS
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-09-10 15:18:42 +00:00
|
|
|
TEXTE_MODULE* Text = new TEXTE_MODULE( Module );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Add the new text object to the beginning of the draw item list.
|
2009-08-11 10:27:21 +00:00
|
|
|
if( Module )
|
2013-03-18 19:36:07 +00:00
|
|
|
Module->GraphicalItems().PushFront( Text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->SetFlags( IS_NEW );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
Text->SetText( wxT( "text" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth,
|
2013-03-13 18:53:58 +00:00
|
|
|
std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetSize( GetDesignSettings().m_ModuleTextSize );
|
|
|
|
Text->SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
2013-08-03 05:15:23 +00:00
|
|
|
Text->SetTextPosition( GetCrossHairPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->SetLocalCoord();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
InstallTextModOptionsFrame( Text, NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->ClearFlags();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( DC )
|
2011-12-22 13:28:11 +00:00
|
|
|
Text->Draw( m_canvas, DC, GR_OR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( Text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Rotate text 90 degrees.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* module = (MODULE*) Text->GetParent();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( module && module->GetFlags() == 0 && Text->GetFlags() == 0 ) // prepare undo command
|
2009-11-14 22:15:22 +00:00
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
if( IsType( FRAME_PCB ) )
|
2009-11-14 22:15:22 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2008-04-29 03:18:02 +00:00
|
|
|
// we expect MoveVector to be (0,0) if there is no move in progress
|
2011-12-22 13:28:11 +00:00
|
|
|
Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetOrientation( Text->GetOrientation() + 900 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( Text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( module )
|
2012-09-05 12:13:33 +00:00
|
|
|
module->SetLastEditTime();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Deletes text in module (if not the reference or value)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::DeleteTextModule( TEXTE_MODULE* Text )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
MODULE* Module;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
Module = static_cast<MODULE*>( Text->GetParent() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
if( Text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->RefreshDrawingRect( Text->GetBoundingBox() );
|
2008-04-29 03:18:02 +00:00
|
|
|
Text->DeleteStructure();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2012-09-05 12:13:33 +00:00
|
|
|
Module->SetLastEditTime();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Abort text move in progress.
|
|
|
|
*
|
|
|
|
* If a text is selected, its initial coordinates are regenerated.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN* screen = Panel->GetScreen();
|
2014-09-10 15:18:42 +00:00
|
|
|
TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
|
2007-08-20 01:20:48 +00:00
|
|
|
MODULE* Module;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-13 09:07:30 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
Module = static_cast<MODULE*>( Text->GetParent() );
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
|
2008-04-01 05:21:50 +00:00
|
|
|
Text->Draw( Panel, DC, GR_XOR, MoveVector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-11 14:10:34 +00:00
|
|
|
// If the text was moved (the move does not change internal data)
|
|
|
|
// it could be rotated while moving. So set old value for orientation
|
2011-12-21 13:42:02 +00:00
|
|
|
if( Text->IsMoving() )
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetOrientation( TextInitialOrientation );
|
2009-08-11 14:10:34 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Redraw the text
|
2011-01-30 22:22:38 +00:00
|
|
|
Panel->RefreshDrawingRect( Text->GetBoundingBox() );
|
2008-04-29 03:18:02 +00:00
|
|
|
|
|
|
|
// leave it at (0,0) so we can use it Rotate when not moving.
|
|
|
|
MoveVector.x = MoveVector.y = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->ClearFlags();
|
|
|
|
Module->ClearFlags();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Start a text move.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-09-10 15:18:42 +00:00
|
|
|
MODULE *Module = static_cast<MODULE*>( Text->GetParent() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->SetFlags( IS_MOVED );
|
|
|
|
Module->SetFlags( IN_EDIT );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
MoveVector.x = MoveVector.y = 0;
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
TextInitialPosition = Text->GetTextPosition();
|
|
|
|
TextInitialOrientation = Text->GetOrientation();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
// Center cursor on initial position of text
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( TextInitialPosition );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-11-18 13:38:08 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( Text );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( Text );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( Show_MoveTexte_Module, AbortMoveTextModule );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Place the text a the cursor position when the left mouse button is clicked.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text != NULL )
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->RefreshDrawingRect( Text->GetBoundingBox() );
|
|
|
|
Text->DrawUmbilical( m_canvas, DC, GR_XOR, -MoveVector );
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Update the coordinates for anchor.
|
2014-09-10 15:18:42 +00:00
|
|
|
MODULE* Module = static_cast<MODULE*>( Text->GetParent() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Module )
|
|
|
|
{
|
2009-08-11 14:10:34 +00:00
|
|
|
// Prepare undo command (a rotation can be made while moving)
|
2013-05-05 07:17:48 +00:00
|
|
|
double tmp = Text->GetOrientation();
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetOrientation( TextInitialOrientation );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
if( IsType( FRAME_PCB ) )
|
2009-11-14 22:15:22 +00:00
|
|
|
SaveCopyInUndoList( Module, UR_CHANGED );
|
2009-08-11 14:10:34 +00:00
|
|
|
else
|
2009-11-14 22:15:22 +00:00
|
|
|
SaveCopyInUndoList( Module, UR_MODEDIT );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetOrientation( tmp );
|
2009-08-11 14:10:34 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Set the new position for text.
|
2013-08-03 05:15:23 +00:00
|
|
|
Text->SetTextPosition( GetCrossHairPosition() );
|
2013-03-18 19:36:07 +00:00
|
|
|
wxPoint textRelPos = Text->GetTextPosition() - Module->GetPosition();
|
2013-03-13 18:53:58 +00:00
|
|
|
RotatePoint( &textRelPos, -Module->GetOrientation() );
|
2011-12-12 08:37:05 +00:00
|
|
|
Text->SetPos0( textRelPos );
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->ClearFlags();
|
|
|
|
Module->ClearFlags();
|
2012-09-05 12:13:33 +00:00
|
|
|
Module->SetLastEditTime();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Redraw text.
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->RefreshDrawingRect( Text->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-11 14:10:34 +00:00
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
Text->SetTextPosition( GetCrossHairPosition() );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-04-29 03:18:02 +00:00
|
|
|
// leave it at (0,0) so we can use it Rotate when not moving.
|
|
|
|
MoveVector.x = MoveVector.y = 0;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2014-09-10 15:18:42 +00:00
|
|
|
TEXTE_MODULE* Text = static_cast<TEXTE_MODULE*>( screen->GetCurItem() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
// Erase umbilical and text if necessary
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2010-11-18 13:38:08 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
|
|
|
|
Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
2010-11-18 13:38:08 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
MoveVector = TextInitialPosition - aPanel->GetParent()->GetCrossHairPosition();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
// Draw umbilical if text moved
|
|
|
|
if( MoveVector.x || MoveVector.y )
|
2011-02-03 19:27:28 +00:00
|
|
|
Text->DrawUmbilical( aPanel, aDC, GR_XOR, -MoveVector );
|
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
// Redraw text
|
2011-02-03 19:27:28 +00:00
|
|
|
Text->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2011-01-09 11:17:28 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
|
|
|
wxSize newSize;
|
|
|
|
int newThickness;
|
2011-01-10 17:47:50 +00:00
|
|
|
TEXTE_PCB* pcbText = NULL;
|
|
|
|
TEXTE_MODULE* moduleText = NULL;
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_TEXT* text;
|
2011-01-09 11:17:28 +00:00
|
|
|
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2012-02-02 17:45:37 +00:00
|
|
|
newSize = GetDesignSettings().m_PcbTextSize;
|
|
|
|
newThickness = GetDesignSettings().m_PcbTextWidth;
|
2014-09-10 15:18:42 +00:00
|
|
|
pcbText = static_cast<TEXTE_PCB*>( aItem );
|
|
|
|
text = static_cast<EDA_TEXT*>( pcbText );
|
2011-01-09 11:17:28 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2012-02-02 17:45:37 +00:00
|
|
|
newSize = GetDesignSettings().m_ModuleTextSize;
|
|
|
|
newThickness = GetDesignSettings().m_ModuleTextWidth;
|
2014-09-10 15:18:42 +00:00
|
|
|
moduleText = static_cast<TEXTE_MODULE*>( aItem );
|
|
|
|
text = static_cast<EDA_TEXT*>( moduleText );
|
2011-01-09 11:17:28 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
default:
|
|
|
|
// Exit if aItem is not a text field
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exit if there's nothing to do
|
2011-09-07 19:41:04 +00:00
|
|
|
if( text->GetSize() == newSize && text->GetThickness() == newThickness )
|
2011-01-09 11:17:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Push item to undo list
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2011-01-09 11:17:28 +00:00
|
|
|
SaveCopyInUndoList( pcbText, UR_CHANGED );
|
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2011-01-09 11:17:28 +00:00
|
|
|
SaveCopyInUndoList( moduleText->GetParent(), UR_CHANGED );
|
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply changes
|
|
|
|
text->SetSize( newSize );
|
|
|
|
text->SetThickness( newThickness );
|
|
|
|
|
|
|
|
if( aDC )
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-01-09 11:17:28 +00:00
|
|
|
|
|
|
|
OnModify();
|
|
|
|
}
|