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"
|
|
|
|
|
#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 */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp
|
|
|
|
|
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 */
|
|
|
|
|
Text->Pnext = Module->m_Drawings;
|
|
|
|
|
Text->Pback = Module;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( Module->m_Drawings )
|
|
|
|
|
Module->m_Drawings->Pback = Text;
|
|
|
|
|
Module->m_Drawings = Text;
|
|
|
|
|
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;
|
|
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
Text->Display_Infos( 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
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
MODULE* module = (MODULE*) Text->m_Parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
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 */
|
|
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
Text->Display_Infos( 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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Module = (MODULE*) Text->m_Parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( Text->m_Type == TEXT_is_DIVERS )
|
|
|
|
|
{
|
|
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* liberation de la memoire : */
|
|
|
|
|
DeleteStructure( Text );
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Module = (MODULE*) Text->m_Parent;
|
|
|
|
|
Text->Draw( Panel, DC, MoveVector, GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* Redessin du Texte */
|
|
|
|
|
Text->Draw( Panel, DC, wxPoint( 0, 0 ), GR_OR );
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Module = (MODULE*) Text->m_Parent;
|
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;
|
|
|
|
|
CursorInitialPosition = Text->m_Pos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
|
Text->Display_Infos( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->SetCurItem( Text );
|
|
|
|
|
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 )
|
|
|
|
|
{
|
|
|
|
|
Text->m_Pos = GetScreen()->m_Curseur;
|
|
|
|
|
/* mise a jour des coordonn<6E>es relatives a l'ancre */
|
|
|
|
|
MODULE* Module = (MODULE*) Text->m_Parent;
|
|
|
|
|
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 */
|
|
|
|
|
Text->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
Module = (MODULE*) Text->m_Parent;
|
|
|
|
|
/* effacement du texte : */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( erase )
|
|
|
|
|
Text->Draw( panel, DC, MoveVector, GR_XOR );
|
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 */
|
|
|
|
|
Text->Draw( panel, DC, MoveVector, GR_XOR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|