Commit 8111fe49 authored by charras's avatar charras

Dirty rect Ok. Code must be cleaned. Import footprints from gpcb ok. See changelog for details

parent 92390f6c
......@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew
Pcbnew can import footprints in gpcb format in Nelib format only
Pcbnew automatically recognizes pcbnew or gpcb format when importing a footprint.
Due to differences between pcbnew and gpcb,
only gpcb newlib files containing only one footprint (one element) are useables.
Dirty rectangle calculation debugged.
WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect& aRect ) can be used to convert a bouding box to a clip box
(see example in deltrack.cpp)
2008-Mar-06 UPDATE Igor Plyatov <plyatov@mail.ru>
================================================================================
+help
......
......@@ -373,21 +373,3 @@ char* strupper( char* Text )
return Text;
}
#if 0
/********************************/
char* strlower( char* text )
/********************************/
{
char* start = text;
while( *text )
{
if( *text >= 'A' && *text <= 'Z' )
*text -= 'A' - 'a';
text++;
}
return start;
}
#endif
......@@ -95,7 +95,23 @@ public:
void Process_Special_Functions( wxCommandEvent& event );
wxPoint CursorRealPosition( const wxPoint& ScreenPos );
wxPoint CursorScreenPosition();
wxPoint GetScreenCenterRealPosition();
/** Function ConvertPcbUnitsToPixelsUnits
* Convert pos and size of the given EDA_Rect to pos and size in pixels,
* relative to the current draw area (origin 0,0 is the left top visible corner draw area)
* according to the current scrool and zoom
* @param aRect = the given rect
*/
void ConvertPcbUnitsToPixelsUnits( EDA_Rect & aRect);
/** Function ConvertPcbUnitsToPixelsUnits
* Convert a given wxPoint position (in internal units) to the pos in pixels,
* relative to the current draw area (origin 0,0 is the left top visible corner draw area)
* according to the current scrool and zoom
* @param aPosition = the given position
*/
void ConvertPcbUnitsToPixelsUnits( wxPoint & aPosition);
wxPoint GetScreenCenterRealPosition( void );
void MouseToCursorSchema();
void MouseTo( const wxPoint& Mouse );
......
......@@ -78,6 +78,7 @@ SET(PCBNEW_SRCS
gen_modules_placefile.cpp
gendrill.cpp
globaleditpad.cpp
gpcb_exchange.cpp
graphpcb.cpp
hotkeys.cpp
initpcb.cpp
......
......@@ -765,15 +765,15 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
}
}
/* Recalcul de l'encadrement */
/* Recalculate the bounding box */
Set_Rectangle_Encadrement();
return 0;
}
/****************************************************/
/*************************************************/
void MODULE::SetPosition( const wxPoint& newpos )
/****************************************************/
/*************************************************/
// replace le module en position newpos
{
......
......@@ -65,7 +65,7 @@ public:
unsigned long m_Link; // variable temporaire ( pour editions, ...)
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
wxString m_Path;
wxString m_Path;
wxString m_Doc; // Texte de description du module
wxString m_KeyWord; // Liste des mots cles relatifs au module
......@@ -142,6 +142,14 @@ public:
int Write_3D_Descr( FILE* File ) const;
int ReadDescr( FILE* File, int* LineNum = NULL );
/**
* Function Read_GPCB_Descr
* Read a footprint description in GPCB format
* @param CmpFullFileName = Full file name (there is one footprint per file.
* this is also the footprint name
* @return bool - true if success reading else false.
*/
bool Read_GPCB_Descr(const wxString & CmpFullFileName);
int Read_3D_Descr( FILE* File, int* LineNum = NULL );
/* drawing functions */
......
......@@ -32,9 +32,9 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
if( Track == NULL )
return NULL;
if( Track->GetState(DELETED) )
if( Track->GetState( DELETED ) )
{
D(printf("WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n");)
D( printf( "WinEDA_PcbFrame::Delete_Segment(): bug deleted already deleted TRACK\n" ); )
return NULL;
}
......@@ -42,7 +42,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{
if( g_TrackSegmentCount > 0 )
{
int previous_layer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
int previous_layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
// effacement de la piste en cours
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
......@@ -83,7 +83,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
// Rectification couche active qui a pu changer si une via
// a ete effacee
((PCB_SCREEN*)GetScreen())->m_Active_Layer = previous_layer;
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
Affiche_Status_Box();
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0
......@@ -126,41 +126,19 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
#else
// redraw the area where the track was
// this rectangle is correct
EDA_Rect dirty = Track->GetBoundingBox();
// this rectangle is corrrect
EDA_Rect dirty = Track->GetBoundingBox();
// Convert the rect coordinates and size in pixels (make a draw clip box):
DrawPanel->ConvertPcbUnitsToPixelsUnits( dirty );
D(printf( "dirty m_Pos=(%d, %d) m_Size=(%d, %d)\n",
dirty.m_Pos.x, dirty.m_Pos.y, dirty.m_Size.x, dirty.m_Size.y );)
int zoom = GetZoom();
wxPoint drwOrig = GetScreen()->m_DrawOrg;
dirty.m_Pos.x = (dirty.m_Pos.x - drwOrig.x) / zoom;
dirty.m_Pos.y = (dirty.m_Pos.y - drwOrig.y) / zoom;
dirty.m_Size.x = (dirty.m_Size.x - drwOrig.x) / zoom;
dirty.m_Size.y = (dirty.m_Size.y - drwOrig.y) / zoom;
D(printf( "dirty scaled zoom=%d m_Pos=(%d, %d) m_Size=(%d, %d) drwOrig=(%d, %d)\n",
zoom,
dirty.m_Pos.x, dirty.m_Pos.y, dirty.m_Size.x, dirty.m_Size.y,
drwOrig.x, drwOrig.y );)
// Ensure the last line and column are in the dirty rectangle after truncatures
dirty.m_Size.x += 1; dirty.m_Size.y += 1;
// pass wxRect() via EDA_Rect::operator wxRect() overload
wxRect dirtyR = dirty;
D(printf( "dirtyR m_Pos=(%d, %d) m_Size=(%d, %d)\n",
dirtyR.x, dirtyR.y, dirtyR.width, dirtyR.height );)
/* The calculation for dirtyR is either wrong or the handling of the clipping
rect in OnPaint() is wrong. Enable this line instead of the Refresh() below,
then try deleting a track segment.
DrawPanel->RefreshRect( dirtyR, TRUE );
*/
DrawPanel->Refresh( TRUE );
#endif
......@@ -241,7 +219,7 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm )
return;
pt_track = Marque_Une_Piste( this, DC, pt_segm,
&nb_segm, GR_OR | GR_SURBRILL );
&nb_segm, GR_OR | GR_SURBRILL );
if( nb_segm ) /* Il y a nb_segm segments de piste a effacer */
{
......@@ -249,7 +227,7 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm )
/* Effacement flag BUSY */
Struct = pt_track;;
for( ii=0; ii<nb_segm; ii++, Struct = (TRACK*) Struct->Pnext )
for( ii = 0; ii<nb_segm; ii++, Struct = (TRACK*) Struct->Pnext )
{
Struct->SetState( BUSY, OFF );
}
......
This diff is collapsed.
......@@ -43,13 +43,15 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
wxString CmpFullFileName;
FILE* dest;
MODULE* module = NULL;
bool Footprint_Is_GPCB_Format = false;
wxString mask = wxT("*.*;"); mask += EXT_CMP_MASK;
/* Lecture Fichier module */
CmpFullFileName = EDA_FileSelector( _( "Import Module:" ),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
EXT_CMP, /* extension par defaut */
EXT_CMP_MASK, /* Masque d'affichage */
wxEmptyString, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
......@@ -70,21 +72,38 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
GetLine( dest, Line, &NbLine );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
DisplayError( this, _( "Not a module file" ) );
return NULL;
if( strnicmp( Line, "Element", 7 ) == 0 )
Footprint_Is_GPCB_Format = true;
else
{
fclose( dest );
DisplayError( this, _( "Not a module file" ) );
return NULL;
}
}
/* Lecture du fichier: recherche du debut de la descr module */
while( GetLine( dest, Line, &NbLine ) != NULL )
{
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
break;
}
if ( ! Footprint_Is_GPCB_Format )
{
while( GetLine( dest, Line, &NbLine ) != NULL )
{
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
break;
}
}
module = new MODULE( m_Pcb );
module->ReadDescr( dest, &NbLine );
fclose( dest );
if ( Footprint_Is_GPCB_Format )
{
fclose( dest );
module->Read_GPCB_Descr(CmpFullFileName);
}
else
{
module->ReadDescr( dest, &NbLine );
fclose( dest );
}
/* Mise a jour du chainage */
if( m_Pcb->m_Modules )
......
......@@ -116,7 +116,8 @@ OBJECTS= $(TARGET).o classpcb.o\
modedit.o\
export_gencad.o\
hotkeys.o \
collectors.o
collectors.o\
gpcb_exchange.o
PolyLine.o: ../polygon/PolyLine.cpp ../polygon/PolyLine.h $(COMMON)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment