2007-08-20 01:20:48 +00:00
|
|
|
|
/*************************************************************/
|
|
|
|
|
/* Edition des Modules: Routines de modification des textes */
|
|
|
|
|
/* sur les MODULES */
|
|
|
|
|
/*************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Fichier EDTXTMOD.CPP */
|
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"
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "pcbnew.h"
|
2009-05-30 16:06:01 +00:00
|
|
|
|
#include "drawtxt.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "trigo.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2009-08-11 14:10:34 +00:00
|
|
|
|
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/* local variables */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp
|
2009-08-11 10:27:21 +00:00
|
|
|
|
static wxPoint TextInitialPosition; // Mouse cursor inital position for undo/abort move command
|
|
|
|
|
static int TextInitialOrientation; // module text inital orientation for undo/abort move+rot command+rot
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
|
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
|
|
|
|
|
*/
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Chainage de la nouvelle structure en tete de liste drawings */
|
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
|
|
|
|
|
2009-05-30 16:06:01 +00:00
|
|
|
|
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth,
|
|
|
|
|
MIN(ModuleTextSize.x, ModuleTextSize.y), true );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Text->m_Size = ModuleTextSize;
|
|
|
|
|
Text->m_Width = ModuleTextWidth;
|
|
|
|
|
Text->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
|
Text->SetLocalCoord();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
InstallTextModOptionsFrame( Text, NULL );
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Text->m_Flags = 0;
|
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
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
|
|
|
|
/* Rotation de 90 du texte d'un module */
|
|
|
|
|
{
|
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
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // simple rot command
|
|
|
|
|
{ // prepare undo command
|
|
|
|
|
if( this->m_Ident == PCB_FRAME )
|
|
|
|
|
SaveCopyInUndoList( module,UR_CHANGED );
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
while( Text->m_Orient >= 1800 )
|
|
|
|
|
Text->m_Orient -= 1800;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Redessin du Texte */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
Text->Draw( DrawPanel, DC, GR_XOR, MoveVector );
|
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
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
if( module )
|
|
|
|
|
module->m_LastEdit_Time = time( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->SetModify();
|
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-05-23 07:16:05 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Supprime 1 texte sur module (si ce n'est pas la r<EFBFBD>f<EFBFBD>rence ou la valeur)
|
|
|
|
|
*/
|
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 )
|
|
|
|
|
{
|
2008-04-29 03:18:02 +00:00
|
|
|
|
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* liberation de la memoire : */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
Text->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2009-08-11 14:10:34 +00:00
|
|
|
|
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************/
|
|
|
|
|
/*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Routine de sortie du menu edit texte module
|
|
|
|
|
* Si un texte est selectionne, ses coord initiales sont regenerees
|
|
|
|
|
*/
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
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();
|
2008-04-29 03:18:02 +00:00
|
|
|
|
|
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
|
|
|
|
|
if ( (Text->m_Flags & IS_MOVED) )
|
|
|
|
|
Text->m_Orient = TextInitialOrientation;
|
|
|
|
|
|
|
|
|
|
/* Redraw the text */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
Panel->PostDirtyRect( Text->GetBoundingBox() );
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine d'initialisation du deplacement d'un texte sur module
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
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-08-11 10:27:21 +00:00
|
|
|
|
TextInitialPosition = Text->m_Pos;
|
|
|
|
|
TextInitialOrientation = Text->m_Orient;
|
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-09-12 02:14:07 +00:00
|
|
|
|
SetCurItem( Text );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->ManageCurseur = Show_MoveTexte_Module;
|
2009-08-11 14:10:34 +00:00
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortMoveTextModule;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine complementaire a StartMoveTexteModule().
|
2009-08-11 10:27:21 +00:00
|
|
|
|
* Place le texte en cours de deplacement
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( Text != NULL )
|
|
|
|
|
{
|
2008-04-29 03:18:02 +00:00
|
|
|
|
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* mise a jour des coordonn<6E>es relatives a l'ancre */
|
2008-11-24 06:53:43 +00:00
|
|
|
|
MODULE* Module = (MODULE*) Text->GetParent();
|
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)
|
|
|
|
|
EXCHG(Text->m_Orient, TextInitialOrientation);
|
2009-08-11 10:27:21 +00:00
|
|
|
|
if( m_Ident == PCB_FRAME )
|
|
|
|
|
SaveCopyInUndoList(Module, UR_CHANGED);
|
2009-08-11 14:10:34 +00:00
|
|
|
|
else
|
|
|
|
|
SaveCopyInUndoList(Module, UR_MODEDIT);
|
|
|
|
|
EXCHG(Text->m_Orient, TextInitialOrientation);
|
|
|
|
|
|
|
|
|
|
Text->m_Pos = GetScreen()->m_Curseur; // Set the new position for text
|
2009-08-11 10:27:21 +00:00
|
|
|
|
wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
|
|
|
|
|
RotatePoint( &textRelPos, -Module->m_Orient );
|
|
|
|
|
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 );
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
/* Redessin du Texte */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2009-08-11 14:10:34 +00:00
|
|
|
|
else
|
|
|
|
|
Text->m_Pos = GetScreen()->m_Curseur;
|
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;
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
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();
|
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
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
/* Undraw the text : */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( erase )
|
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 10:27:21 +00:00
|
|
|
|
MoveVector = TextInitialPosition - screen->m_Curseur;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
|
/* Redraw the text */
|
2008-04-01 05:21:50 +00:00
|
|
|
|
Text->Draw( panel, DC, GR_XOR, MoveVector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|