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"
|
|
|
|
|
#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 );
|
|
|
|
|
static void ExitTextModule( 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
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command
|
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 */
|
2008-12-04 04:28:11 +00:00
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
InstallTextModOptionsFrame( Text, NULL, wxPoint( -1, -1 ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Text->m_Flags = 0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
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
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::DeleteTextModule( 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
|
|
|
|
/*
|
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
|
|
|
|
// Text->Draw( DrawPanel, DC, GR_XOR );
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void ExitTextModule( WinEDA_DrawPanel* Panel, 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
|
|
|
|
/*
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Redessin du Texte */
|
2008-04-29 03:18:02 +00:00
|
|
|
|
// Text->Draw( Panel, DC, GR_OR );
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
CursorInitialPosition = Text->m_Pos;
|
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;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitTextModule;
|
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().
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Place le texte en cours de deplacement ou nouvellement cree
|
|
|
|
|
*/
|
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
|
|
|
|
Text->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
|
/* 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 )
|
|
|
|
|
{
|
|
|
|
|
int px = Text->m_Pos.x - Module->m_Pos.x;
|
|
|
|
|
int py = Text->m_Pos.y - Module->m_Pos.y;
|
|
|
|
|
RotatePoint( &px, &py, -Module->m_Orient );
|
|
|
|
|
Text->m_Pos0.x = px;
|
|
|
|
|
Text->m_Pos0.y = py;
|
|
|
|
|
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
|
|
|
|
//Text->Draw( DrawPanel, DC, GR_OR );
|
|
|
|
|
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
|
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();
|
|
|
|
|
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-08-20 01:20:48 +00:00
|
|
|
|
/* effacement du texte : */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x);
|
|
|
|
|
MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y);
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Redessin du Texte */
|
2008-04-01 05:21:50 +00:00
|
|
|
|
Text->Draw( panel, DC, GR_XOR, MoveVector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|