2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file edtxtmod.cpp
|
|
|
|
* @brief Edit module text.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2009-05-30 16:06:01 +00:00
|
|
|
#include "drawtxt.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "wxBasePcbFrame.h"
|
|
|
|
#include "macros.h"
|
|
|
|
|
|
|
|
#include "pcbnew.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_module.h"
|
|
|
|
#include "class_text_mod.h"
|
|
|
|
#include "class_pcb_text.h"
|
|
|
|
|
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.
|
|
|
|
* New texts have the member TEXTE_MODULE.m_Type set to TEXT_is_DIVERS
|
|
|
|
*/
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Flags = 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
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
g_ModuleTextWidth = Clamp_Text_PenSize( g_ModuleTextWidth,
|
2011-09-07 19:41:04 +00:00
|
|
|
MIN( g_ModuleTextSize.x, g_ModuleTextSize.y ), true );
|
2010-07-20 18:11:34 +00:00
|
|
|
Text->m_Size = g_ModuleTextSize;
|
2010-11-27 13:09:18 +00:00
|
|
|
Text->m_Thickness = g_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-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Flags = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( DC )
|
|
|
|
Text->Draw( DrawPanel, 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-09-07 19:41:04 +00:00
|
|
|
if( module && module->m_Flags == 0 && Text->m_Flags == 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
|
|
|
|
Text->Draw( DrawPanel, 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
|
|
|
|
2008-04-29 03:18:02 +00:00
|
|
|
Text->Draw( DrawPanel, 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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Text->m_Type == TEXT_is_DIVERS )
|
|
|
|
{
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->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
|
2009-11-14 22:15:22 +00:00
|
|
|
if( (Text->m_Flags & IS_MOVED) )
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Flags = 0;
|
|
|
|
Module->m_Flags = 0;
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Flags |= IS_MOVED;
|
|
|
|
Module->m_Flags |= 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 );
|
|
|
|
DrawPanel->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-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Show_MoveTexte_Module, AbortMoveTextModule );
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, 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-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
|
2010-11-18 13:38:08 +00:00
|
|
|
Text->DrawUmbilical( DrawPanel, 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 );
|
2009-11-14 22:15:22 +00:00
|
|
|
Text->m_Pos0 = textRelPos;
|
2007-08-20 01:20:48 +00:00
|
|
|
Text->m_Flags = 0;
|
|
|
|
Module->m_Flags = 0;
|
|
|
|
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-01-30 22:22:38 +00:00
|
|
|
DrawPanel->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-02-11 20:48:13 +00:00
|
|
|
DrawPanel->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() )
|
|
|
|
{
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
newSize = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize;
|
|
|
|
newThickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth;
|
|
|
|
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-01-09 11:17:28 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
|
|
|
newSize = g_ModuleTextSize;
|
|
|
|
newThickness = g_ModuleTextWidth;
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
SaveCopyInUndoList( pcbText, UR_CHANGED );
|
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
|
|
|
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 )
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
itemWrapper.m_PickedItemType = TYPE_MODULE;
|
|
|
|
|
|
|
|
module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
// Prepare undo list
|
|
|
|
while( module )
|
|
|
|
{
|
|
|
|
itemWrapper.m_PickedItem = 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
|
|
|
|
|
|
|
if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_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
|
|
|
|
|
|
|
if( item->GetSize() != g_ModuleTextSize || item->GetThickness() != g_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
|
|
|
{
|
|
|
|
if( boardItem->Type() == TYPE_TEXTE_MODULE )
|
|
|
|
{
|
|
|
|
item = (TEXTE_MODULE*) boardItem;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
if( item->GetSize() != g_ModuleTextSize
|
|
|
|
|| item->GetThickness() != g_ModuleTextWidth )
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
module->m_Reference->SetThickness( g_ModuleTextWidth );
|
|
|
|
module->m_Reference->SetSize( g_ModuleTextSize );
|
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
case TEXT_is_VALUE:
|
|
|
|
module->m_Value->SetThickness( g_ModuleTextWidth );
|
|
|
|
module->m_Value->SetSize( g_ModuleTextSize );
|
|
|
|
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
|
|
|
{
|
|
|
|
if( boardItem->Type() == TYPE_TEXTE_MODULE )
|
|
|
|
{
|
|
|
|
item = (TEXTE_MODULE*) boardItem;
|
|
|
|
item->SetThickness( g_ModuleTextWidth );
|
|
|
|
item->SetSize( g_ModuleTextSize );
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-09 11:17:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aDC )
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
|
|
|
OnModify();
|
|
|
|
}
|