2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 1992-2011 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
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
#include <protos.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
|
|
|
|
static int TextInitialOrientation; // module text initial orientation for
|
|
|
|
// 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)
|
2007-08-20 01:20:48 +00:00
|
|
|
* Note there always are 2 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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
TEXTE_MODULE* Text;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text = new TEXTE_MODULE( Module );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +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 )
|
|
|
|
Module->m_Drawings.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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Text = 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,
|
|
|
|
MIN( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
|
|
|
|
Text->m_Size = GetDesignSettings().m_ModuleTextSize;
|
|
|
|
Text->m_Thickness = GetDesignSettings().m_ModuleTextWidth;
|
2011-02-11 20:48:13 +00:00
|
|
|
Text->m_Pos = GetScreen()->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
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Text->DisplayInfo( this );
|
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
|
|
|
{
|
2009-08-11 10:27:21 +00:00
|
|
|
if( this->m_Ident == PCB_FRAME )
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Orient += 900;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( Text->m_Orient >= 1800 )
|
|
|
|
Text->m_Orient -= 1800;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
|
2009-04-17 08:51:02 +00:00
|
|
|
Text->DisplayInfo( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( module )
|
|
|
|
module->m_LastEdit_Time = time( NULL );
|
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
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Module = (MODULE*) Text->GetParent();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
if( Text->GetType() == 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();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
}
|
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();
|
|
|
|
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
|
|
|
|
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
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Module = (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() )
|
2009-08-11 14:10:34 +00:00
|
|
|
Text->m_Orient = TextInitialOrientation;
|
|
|
|
|
|
|
|
/* 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
|
|
|
MODULE* Module;
|
|
|
|
|
|
|
|
if( Text == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Module = (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
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
TextInitialPosition = Text->m_Pos;
|
2009-08-11 10:27:21 +00:00
|
|
|
TextInitialOrientation = Text->m_Orient;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-18 13:38:08 +00:00
|
|
|
// Center cursor on initial position of text
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( TextInitialPosition );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-11-18 13:38:08 +00:00
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Text->DisplayInfo( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
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
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update the coordinates for anchor. */
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (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)
|
2009-11-14 22:15:22 +00:00
|
|
|
EXCHG( Text->m_Orient, TextInitialOrientation );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( m_Ident == PCB_FRAME )
|
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
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
EXCHG( Text->m_Orient, TextInitialOrientation );
|
2009-08-11 14:10:34 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Set the new position for text.
|
2011-02-11 20:48:13 +00:00
|
|
|
Text->m_Pos = GetScreen()->GetCrossHairPosition();
|
2009-08-11 10:27:21 +00:00
|
|
|
wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
|
|
|
|
RotatePoint( &textRelPos, -Module->m_Orient );
|
2011-12-12 08:37:05 +00:00
|
|
|
Text->SetPos0( textRelPos );
|
2011-12-21 13:42:02 +00:00
|
|
|
Text->ClearFlags();
|
|
|
|
Module->ClearFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +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
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
Text->m_Pos = GetScreen()->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();
|
2007-08-20 01:20:48 +00:00
|
|
|
TEXTE_MODULE* Text = (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
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
MoveVector = TextInitialPosition - screen->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;
|
2011-01-09 11:17:28 +00:00
|
|
|
pcbText = (TEXTE_PCB*) aItem;
|
2011-03-29 19:33:07 +00:00
|
|
|
text = (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;
|
2011-01-09 11:17:28 +00:00
|
|
|
moduleText = (TEXTE_MODULE*) aItem;
|
2011-03-29 19:33:07 +00:00
|
|
|
text = (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;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
|
|
|
MODULE* module;
|
|
|
|
BOARD_ITEM* boardItem;
|
|
|
|
TEXTE_MODULE* item;
|
|
|
|
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
|
|
|
|
PICKED_ITEMS_LIST undoItemList;
|
|
|
|
unsigned int ii;
|
|
|
|
|
|
|
|
module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
// Prepare undo list
|
|
|
|
while( module )
|
|
|
|
{
|
2012-02-05 13:02:46 +00:00
|
|
|
itemWrapper.SetItem( module );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case TEXT_is_REFERENCE:
|
|
|
|
item = module->m_Reference;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
2011-01-09 11:17:28 +00:00
|
|
|
undoItemList.PushItem( itemWrapper );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
case TEXT_is_VALUE:
|
|
|
|
item = module->m_Value;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-05 13:02:46 +00:00
|
|
|
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
|
|
|
|
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
2011-01-09 11:17:28 +00:00
|
|
|
undoItemList.PushItem( itemWrapper );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
case TEXT_is_DIVERS:
|
|
|
|
// Go through all other module text fields
|
2011-09-07 19:41:04 +00:00
|
|
|
for( boardItem = module->m_Drawings; boardItem; boardItem = boardItem->Next() )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( boardItem->Type() == PCB_MODULE_TEXT_T )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
|
|
|
item = (TEXTE_MODULE*) boardItem;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize
|
|
|
|
|| item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
|
|
|
undoItemList.PushItem( itemWrapper );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
module = module->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exit if there's nothing to do
|
|
|
|
if( !undoItemList.GetCount() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SaveCopyInUndoList( undoItemList, UR_CHANGED );
|
|
|
|
|
|
|
|
// Apply changes to modules in the undo list
|
|
|
|
for( ii = 0; ii < undoItemList.GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
module = (MODULE*) undoItemList.GetPickedItem( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case TEXT_is_REFERENCE:
|
2012-02-02 17:45:37 +00:00
|
|
|
module->m_Reference->SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
|
|
|
module->m_Reference->SetSize( GetDesignSettings().m_ModuleTextSize );
|
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
|
|
|
case TEXT_is_VALUE:
|
2012-02-02 17:45:37 +00:00
|
|
|
module->m_Value->SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
|
|
|
module->m_Value->SetSize( GetDesignSettings().m_ModuleTextSize );
|
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
|
|
|
case TEXT_is_DIVERS:
|
2011-09-07 19:41:04 +00:00
|
|
|
for( boardItem = module->m_Drawings; boardItem; boardItem = boardItem->Next() )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( boardItem->Type() == PCB_MODULE_TEXT_T )
|
2011-01-09 11:17:28 +00:00
|
|
|
{
|
|
|
|
item = (TEXTE_MODULE*) boardItem;
|
2012-02-02 17:45:37 +00:00
|
|
|
item->SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
|
|
|
item->SetSize( GetDesignSettings().m_ModuleTextSize );
|
2011-01-09 11:17:28 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aDC )
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-01-09 11:17:28 +00:00
|
|
|
|
|
|
|
OnModify();
|
|
|
|
}
|