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 ...@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. 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> 2008-Mar-06 UPDATE Igor Plyatov <plyatov@mail.ru>
================================================================================ ================================================================================
+help +help
......
...@@ -373,21 +373,3 @@ char* strupper( char* Text ) ...@@ -373,21 +373,3 @@ char* strupper( char* Text )
return 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: ...@@ -95,7 +95,23 @@ public:
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
wxPoint CursorRealPosition( const wxPoint& ScreenPos ); wxPoint CursorRealPosition( const wxPoint& ScreenPos );
wxPoint CursorScreenPosition(); 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 MouseToCursorSchema();
void MouseTo( const wxPoint& Mouse ); void MouseTo( const wxPoint& Mouse );
......
...@@ -78,6 +78,7 @@ SET(PCBNEW_SRCS ...@@ -78,6 +78,7 @@ SET(PCBNEW_SRCS
gen_modules_placefile.cpp gen_modules_placefile.cpp
gendrill.cpp gendrill.cpp
globaleditpad.cpp globaleditpad.cpp
gpcb_exchange.cpp
graphpcb.cpp graphpcb.cpp
hotkeys.cpp hotkeys.cpp
initpcb.cpp initpcb.cpp
......
...@@ -765,15 +765,15 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -765,15 +765,15 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
} }
} }
/* Recalcul de l'encadrement */ /* Recalculate the bounding box */
Set_Rectangle_Encadrement(); Set_Rectangle_Encadrement();
return 0; return 0;
} }
/****************************************************/ /*************************************************/
void MODULE::SetPosition( const wxPoint& newpos ) void MODULE::SetPosition( const wxPoint& newpos )
/****************************************************/ /*************************************************/
// replace le module en position newpos // replace le module en position newpos
{ {
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
unsigned long m_Link; // variable temporaire ( pour editions, ...) unsigned long m_Link; // variable temporaire ( pour editions, ...)
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies) 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_Doc; // Texte de description du module
wxString m_KeyWord; // Liste des mots cles relatifs au module wxString m_KeyWord; // Liste des mots cles relatifs au module
...@@ -142,6 +142,14 @@ public: ...@@ -142,6 +142,14 @@ public:
int Write_3D_Descr( FILE* File ) const; int Write_3D_Descr( FILE* File ) const;
int ReadDescr( FILE* File, int* LineNum = NULL ); 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 ); int Read_3D_Descr( FILE* File, int* LineNum = NULL );
/* drawing functions */ /* drawing functions */
......
...@@ -32,9 +32,9 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) ...@@ -32,9 +32,9 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
if( Track == NULL ) if( Track == NULL )
return 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; return NULL;
} }
...@@ -42,7 +42,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) ...@@ -42,7 +42,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{ {
if( g_TrackSegmentCount > 0 ) 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 // effacement de la piste en cours
ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE ); ShowNewTrackWhenMovingCursor( DrawPanel, DC, FALSE );
...@@ -83,7 +83,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) ...@@ -83,7 +83,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
// Rectification couche active qui a pu changer si une via // Rectification couche active qui a pu changer si une via
// a ete effacee // a ete effacee
((PCB_SCREEN*)GetScreen())->m_Active_Layer = previous_layer; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = previous_layer;
Affiche_Status_Box(); Affiche_Status_Box();
if( g_TwoSegmentTrackBuild ) // We must have 2 segments or more, or 0 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 ) ...@@ -126,41 +126,19 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
#else #else
// redraw the area where the track was // redraw the area where the track was
// this rectangle is correct
EDA_Rect dirty = Track->GetBoundingBox();
// this rectangle is corrrect // Convert the rect coordinates and size in pixels (make a draw clip box):
EDA_Rect dirty = Track->GetBoundingBox(); DrawPanel->ConvertPcbUnitsToPixelsUnits( dirty );
D(printf( "dirty m_Pos=(%d, %d) m_Size=(%d, %d)\n", // Ensure the last line and column are in the dirty rectangle after truncatures
dirty.m_Pos.x, dirty.m_Pos.y, dirty.m_Size.x, dirty.m_Size.y );) dirty.m_Size.x += 1; dirty.m_Size.y += 1;
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 );)
// pass wxRect() via EDA_Rect::operator wxRect() overload // pass wxRect() via EDA_Rect::operator wxRect() overload
wxRect dirtyR = dirty; 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->RefreshRect( dirtyR, TRUE );
*/
DrawPanel->Refresh( TRUE );
#endif #endif
...@@ -241,7 +219,7 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm ) ...@@ -241,7 +219,7 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm )
return; return;
pt_track = Marque_Une_Piste( this, DC, pt_segm, 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 */ 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 ) ...@@ -249,7 +227,7 @@ void WinEDA_PcbFrame::Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm )
/* Effacement flag BUSY */ /* Effacement flag BUSY */
Struct = pt_track;; 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 ); Struct->SetState( BUSY, OFF );
} }
......
This diff is collapsed.
...@@ -43,13 +43,15 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -43,13 +43,15 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
wxString CmpFullFileName; wxString CmpFullFileName;
FILE* dest; FILE* dest;
MODULE* module = NULL; MODULE* module = NULL;
bool Footprint_Is_GPCB_Format = false;
wxString mask = wxT("*.*;"); mask += EXT_CMP_MASK;
/* Lecture Fichier module */ /* Lecture Fichier module */
CmpFullFileName = EDA_FileSelector( _( "Import Module:" ), CmpFullFileName = EDA_FileSelector( _( "Import Module:" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */ wxEmptyString, /* nom fichier par defaut */
EXT_CMP, /* extension par defaut */ wxEmptyString, /* extension par defaut */
EXT_CMP_MASK, /* Masque d'affichage */ mask, /* Masque d'affichage */
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE TRUE
...@@ -70,21 +72,38 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) ...@@ -70,21 +72,38 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
GetLine( dest, Line, &NbLine ); GetLine( dest, Line, &NbLine );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{ {
DisplayError( this, _( "Not a module file" ) ); if( strnicmp( Line, "Element", 7 ) == 0 )
return NULL; 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 */ /* Lecture du fichier: recherche du debut de la descr module */
while( GetLine( dest, Line, &NbLine ) != NULL ) if ( ! Footprint_Is_GPCB_Format )
{ {
if( strnicmp( Line, "$MODULE", 7 ) == 0 ) while( GetLine( dest, Line, &NbLine ) != NULL )
break; {
} if( strnicmp( Line, "$MODULE", 7 ) == 0 )
break;
}
}
module = new MODULE( m_Pcb ); module = new MODULE( m_Pcb );
module->ReadDescr( dest, &NbLine ); if ( Footprint_Is_GPCB_Format )
fclose( dest ); {
fclose( dest );
module->Read_GPCB_Descr(CmpFullFileName);
}
else
{
module->ReadDescr( dest, &NbLine );
fclose( dest );
}
/* Mise a jour du chainage */ /* Mise a jour du chainage */
if( m_Pcb->m_Modules ) if( m_Pcb->m_Modules )
......
...@@ -116,7 +116,8 @@ OBJECTS= $(TARGET).o classpcb.o\ ...@@ -116,7 +116,8 @@ OBJECTS= $(TARGET).o classpcb.o\
modedit.o\ modedit.o\
export_gencad.o\ export_gencad.o\
hotkeys.o \ hotkeys.o \
collectors.o collectors.o\
gpcb_exchange.o
PolyLine.o: ../polygon/PolyLine.cpp ../polygon/PolyLine.h $(COMMON) 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