diff --git a/change_log.txt b/change_log.txt index 3c2388c9a0..b76e87858b 100644 --- a/change_log.txt +++ b/change_log.txt @@ -13,6 +13,9 @@ email address. added EDA_BaseStruct::DeleteStructList() deleted gerbview/struct.cpp, pcbnew/struct.cpp, BOARD::~BOARD() now deletes objects that it owns. + Collectors now finds MARQUEURs also + added MARQUEURS::Display_Infos() + added MARQUEURS::HitTest() 2007-Oct-2 UPDATE Dick Hollenbeck <dick@softplc.com> diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 2fcd18ec51..62fadfa0ff 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -190,6 +190,7 @@ void BASE_SCREEN::SetZoomList( int* zoomlist ) // Init liste if( m_ZoomList ) free( m_ZoomList ); + m_ZoomList = (int*) MyZMalloc( nbitems * sizeof( int) ); for( ii = 0, zoom = zoomlist; ii < nbitems; zoom++, ii++ ) diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index 7a186a22e4..a639248015 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -1,6 +1,6 @@ - /******************************************************************/ - /* msgpanel.cpp - fonctions des classes du type WinEDA_MsgPanel */ - /******************************************************************/ +/******************************************************************/ +/* msgpanel.cpp - fonctions des classes du type WinEDA_MsgPanel */ +/******************************************************************/ #ifdef __GNUG__ #pragma implementation @@ -14,131 +14,132 @@ #include "common.h" /* table des evenements captes par un WinEDA_MsgPanel */ -BEGIN_EVENT_TABLE(WinEDA_MsgPanel, wxPanel) - EVT_PAINT(WinEDA_MsgPanel::OnPaint) +BEGIN_EVENT_TABLE( WinEDA_MsgPanel, wxPanel ) +EVT_PAINT( WinEDA_MsgPanel::OnPaint ) END_EVENT_TABLE() +/***********************************************************/ +/* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */ +/***********************************************************/ - /***********************************************************/ - /* Fonctions de base de WinEDA_MsgPanel: l'ecran de messages */ - /***********************************************************/ - -WinEDA_MsgPanel::WinEDA_MsgPanel(WinEDA_DrawFrame *parent, int id, - const wxPoint& pos, const wxSize& size): - wxPanel(parent, id, pos, size ) +WinEDA_MsgPanel::WinEDA_MsgPanel( WinEDA_DrawFrame* parent, int id, + const wxPoint& pos, const wxSize& size ) : + wxPanel( parent, id, pos, size ) { - m_Parent = parent; - SetFont( *g_MsgFont ); + m_Parent = parent; + SetFont( *g_MsgFont ); } - WinEDA_MsgPanel::~WinEDA_MsgPanel() { } - /*************************************************/ -void WinEDA_MsgPanel::OnPaint(wxPaintEvent & event) +void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) /*************************************************/ { -wxPaintDC dc(this); + wxPaintDC dc( this ); - EraseMsgBox(&dc); event.Skip(); + EraseMsgBox( &dc ); event.Skip(); } - - /*****************************************************************************/ -void WinEDA_MsgPanel::Affiche_1_Parametre(int pos_X,const wxString & texte_H, - const wxString & texte_L,int color) +void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, + const wxString& texte_L, int color ) /*****************************************************************************/ + /* - Routine d'affichage d'un parametre. - pos_X = cadrage horizontal - si pos_X < 0 : la position horizontale est la derniere - valeur demandee >= 0 - texte_H = texte a afficher en ligne superieure. - si "", par d'affichage sur cette ligne - texte_L = texte a afficher en ligne inferieure. - si "", par d'affichage sur cette ligne - color = couleur d'affichage -*/ + * Routine d'affichage d'un parametre. + * pos_X = cadrage horizontal + * si pos_X < 0 : la position horizontale est la derniere + * valeur demandee >= 0 + * texte_H = texte a afficher en ligne superieure. + * si "", par d'affichage sur cette ligne + * texte_L = texte a afficher en ligne inferieure. + * si "", par d'affichage sur cette ligne + * color = couleur d'affichage + */ { -static int old_pos_X; -wxPoint pos; -wxSize FontSizeInPixels, DrawSize; -wxClientDC dc(this); + static int old_pos_X; + wxPoint pos; + wxSize FontSizeInPixels, DrawSize; - DrawSize = GetClientSize(); + wxClientDC dc( this ); + + DrawSize = GetClientSize(); + + dc.SetBackground( *wxBLACK_BRUSH ); + dc.SetBackgroundMode( wxSOLID ); - dc.SetBackground(* wxBLACK_BRUSH ); - dc.SetBackgroundMode(wxSOLID); // dc.SetBackgroundMode(wxTRANSPARENT); - dc.SetTextBackground(GetBackgroundColour()); - dc.SetFont(*g_MsgFont); - dc.GetTextExtent( wxT("W"), &FontSizeInPixels.x, &FontSizeInPixels.y ); + dc.SetTextBackground( GetBackgroundColour() ); + dc.SetFont( *g_MsgFont ); + dc.GetTextExtent( wxT( "W" ), &FontSizeInPixels.x, &FontSizeInPixels.y ); - if ( color >= 0 ) - { - color &= MASKCOLOR; - dc.SetTextForeground(wxColour( - ColorRefs[color].m_Red, ColorRefs[color].m_Green, - ColorRefs[color].m_Blue) ); - } + if( color >= 0 ) + { + color &= MASKCOLOR; + dc.SetTextForeground( wxColour( + ColorRefs[color].m_Red, ColorRefs[color].m_Green, + ColorRefs[color].m_Blue ) ); + } - if ( pos_X >= 0 ) - { - old_pos_X = pos.x = pos_X * (FontSizeInPixels.x + 2); - } - else pos.x = old_pos_X; + if( pos_X >= 0 ) + { + old_pos_X = pos.x = pos_X * (FontSizeInPixels.x + 2); + } + else + pos.x = old_pos_X; - - if( !texte_H.IsEmpty()) - { - pos.y = (DrawSize.y/2) - FontSizeInPixels.y;; - dc.DrawText(texte_H.GetData(), pos.x, pos.y); - } - if( !texte_L.IsEmpty()) - { - pos.y = DrawSize.y - FontSizeInPixels.y; - dc.DrawText(texte_L.GetData(), pos.x, pos.y); - } + if( !texte_H.IsEmpty() ) + { + pos.y = (DrawSize.y / 2) - FontSizeInPixels.y;; + dc.DrawText( texte_H.GetData(), pos.x, pos.y ); + } + + if( !texte_L.IsEmpty() ) + { + pos.y = DrawSize.y - FontSizeInPixels.y; + dc.DrawText( texte_L.GetData(), pos.x, pos.y ); + } } + /****************************************/ void WinEDA_MsgPanel::EraseMsgBox() /****************************************/ + /* Effacement de la fenetre d'affichage des messages de bas d'ecran -*/ + */ { -wxClientDC dc(this); - EraseMsgBox(&dc); -} + wxClientDC dc( this ); -/*******************************************/ -void WinEDA_MsgPanel::EraseMsgBox(wxDC * DC) -/*******************************************/ -{ -wxSize size; -wxColor color; -wxPen pen; -wxBrush brush; - - size = GetClientSize(); - color = GetBackgroundColour(); - pen.SetColour(color); - brush.SetColour(color); - brush.SetStyle(wxSOLID); - DC->SetPen(pen); - DC->SetBrush(brush); - - DC->DrawRectangle(0,0,size.x,size.y); - DC->SetBrush(wxNullBrush); - DC->SetPen(wxNullPen); + EraseMsgBox( &dc ); } +/*******************************************/ +void WinEDA_MsgPanel::EraseMsgBox( wxDC* DC ) +/*******************************************/ +{ + wxSize size; + wxColor color; + wxPen pen; + wxBrush brush; + + size = GetClientSize(); + color = GetBackgroundColour(); + pen.SetColour( color ); + brush.SetColour( color ); + brush.SetStyle( wxSOLID ); + DC->SetPen( pen ); + DC->SetBrush( brush ); + + DC->DrawRectangle( 0, 0, size.x, size.y ); + DC->SetBrush( wxNullBrush ); + DC->SetPen( wxNullPen ); +} diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 1b060be147..d0fbb59a42 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -225,7 +225,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, case HK_NEXT_SEARCH: if( ItemInEdit ) break; - if( g_LastSearchIsMarker ) + if( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker( 1 ); else FindSchematicItem( wxEmptyString, 2 ); diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 0267a4c477..822b878544 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -448,6 +448,23 @@ public: ~MARQUEUR(); void UnLink(); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ); + + /** + * Function Display_Infos + * has knowledge about the frame and how and where to put status information + * about this object into the frame's message panel. + * @param frame A WinEDA_DrawFrame in which to print status information. + */ + void Display_Infos( WinEDA_DrawFrame* frame ); + + + /** + * Function HitTest + * tests if the given wxPoint is within the bounds of this object. + * @param ref_pos A wxPoint to test + * @return bool - true if a hit, else false + */ + bool HitTest( const wxPoint& ref_pos ); }; diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index 21d9bd8958..c8a23c1b40 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -179,7 +179,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const break; case TYPEMARQUEUR: - text << _( "Marker" ); + text << _( "Marker" ) << wxT( " @(" ) << ((MARQUEUR*)item)->m_Pos.x << wxT(",") << ((MARQUEUR*)item)->m_Pos.y << wxT(")"); break; case TYPECOTATION: diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 6733fc7f34..93834a4068 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -681,7 +681,7 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) switch( Type() ) { case TYPEVIA: - msg = g_ViaType_Name[m_Shape & 255]; + msg = g_ViaType_Name[Shape()]; break; case TYPETRACK: @@ -764,6 +764,7 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) int drill_value = m_Drill >= 0 ? m_Drill : g_DesignSettings.m_ViaDrill; + valeur_param( (unsigned) drill_value, msg ); text_pos += 8; diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 775c070596..8c6006340a 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -303,6 +303,36 @@ void MARQUEUR::UnLink() } +void MARQUEUR::Display_Infos( WinEDA_DrawFrame* frame ) +{ + int text_pos; + + frame->MsgPanel->EraseMsgBox(); + + text_pos = 1; + Affiche_1_Parametre( frame, text_pos, _( "Type" ), _("Marker"), DARKCYAN ); + + text_pos = 12; + Affiche_1_Parametre( frame, text_pos, _( "Marker Error Text" ), m_Diag, RED ); +} + + +bool MARQUEUR::HitTest( const wxPoint& refPos ) +{ + // currently the MARKER is about 14 pixels by 14 pixels + int xCenter = m_Pos.x + 7; + int yCenter = m_Pos.y + 7; + + int dx = refPos.x - xCenter; + int dy = refPos.y - yCenter; + + if( ABS(dx) <= 7 && ABS(dy) <= 7 ) + return true; + else + return false; +} + + /**************************************************/ /* Class SCREEN: classe de gestion d'un affichage */ /***************************************************/ diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 00c1900f90..45006d42e2 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -33,8 +33,12 @@ // see collectors.h const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { + + // there are some restrictions on the order of items in the general case. + // all items in m_Drawings for instance should be contiguous. TYPETEXTE, TYPEDRAWSEGMENT, + TYPEMARQUEUR, TYPECOTATION, TYPEVIA, TYPETRACK, @@ -49,6 +53,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = { TYPETEXTE, TYPEDRAWSEGMENT, + TYPEMARQUEUR, TYPECOTATION, TYPEVIA, TYPETRACK, @@ -60,6 +65,7 @@ const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = { const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { TYPETEXTE, TYPEDRAWSEGMENT, + TYPEMARQUEUR, TYPECOTATION, TYPEVIA, TYPETRACK, diff --git a/pcbnew/cursors.cpp b/pcbnew/cursors.cpp index 1990441349..4f2e14ee36 100644 --- a/pcbnew/cursors.cpp +++ b/pcbnew/cursors.cpp @@ -1,8 +1,8 @@ - /****************************************************************/ - /* Routines generales d'affichage des curseurs et des marqueurs */ - /****************************************************************/ +/****************************************************************/ +/* Routines generales d'affichage des curseurs et des marqueurs */ +/****************************************************************/ - /* fichier curseurs.cpp */ +/* fichier curseurs.cpp */ #include "fctsys.h" #include "gr_basic.h" @@ -14,57 +14,61 @@ /* Routines Locales : */ - /* Forme (bit_map) du marqueur */ -static char Default_MarkerBitmap[]= - { - 12, 12, /* Dimensions x et y du dessin de marqueurs*/ - 1,1,1,1,1,1,1,1,0,0,0,0, /* bitmap: 1 = color, 0 = notrace */ - 1,1,1,0,1,0,1,1,0,0,0,0, - 1,1,1,1,0,0,0,1,0,0,0,0, - 1,0,1,1,1,0,0,0,0,0,0,0, - 1,1,0,1,1,1,0,0,0,0,0,0, - 1,1,0,0,1,1,1,0,0,0,0,0, - 1,1,1,0,0,1,1,1,0,0,0,0, - 0,0,0,0,0,0,1,1,1,0,0,0, - 0,0,0,0,0,0,0,1,1,1,0,0, - 0,0,0,0,0,0,0,0,1,1,1,0, - 0,0,0,0,0,0,0,0,0,1,1,1, - 0,0,0,0,0,0,0,0,0,0,1,0 - }; - - -/**********************************************************************/ -void MARQUEUR::Draw( WinEDA_DrawPanel * panel, wxDC * DC, int DrawMode) -/**********************************************************************/ -/* - Trace un repere sur l'ecran au point de coordonnees PCB pos - Le marqueur est defini par un tableau de 2 + (lig*col) elements: - 1er element: dim nbre ligne - 2er element: dim nbre col - suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel -*/ +/* Forme (bit_map) du marqueur */ +static char Default_MarkerBitmap[] = { -int px, py; -int ii, ii_max, jj, jj_max; -char * pt_bitmap = m_Bitmap; - - if ( pt_bitmap == NULL ) pt_bitmap = Default_MarkerBitmap; + 12, 12, /* Dimensions x et y du dessin de marqueurs*/ + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, /* bitmap: 1 = color, 0 = notrace */ + 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 +}; - GRSetDrawMode(DC, DrawMode); - px = GRMapX(m_Pos.x); py = GRMapY(m_Pos.y); +/**********************************************************************/ +void MARQUEUR::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ) +/**********************************************************************/ - /* Lecture des dimensions */ - ii_max = *(pt_bitmap++); jj_max = *(pt_bitmap++); +/* + * Trace un repere sur l'ecran au point de coordonnees PCB pos + * Le marqueur est defini par un tableau de 2 + (lig*col) elements: + * 1er element: dim nbre ligne + * 2er element: dim nbre col + * suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel + */ +{ + int px, py; + int ii, ii_max, jj, jj_max; + char* pt_bitmap = m_Bitmap; - /* Trace du bitmap */ - for( ii = 0; ii < ii_max; ii++) - { - for( jj = 0; jj < jj_max; jj++, pt_bitmap++) - { - if(*pt_bitmap) GRSPutPixel(&panel->m_ClipBox, DC, - px+ii , py+jj , m_Color); - } - } + if( pt_bitmap == NULL ) + pt_bitmap = Default_MarkerBitmap; + + GRSetDrawMode( DC, DrawMode ); + + px = GRMapX( m_Pos.x ); + py = GRMapY( m_Pos.y ); + + /* Lecture des dimensions */ + ii_max = *(pt_bitmap++); + jj_max = *(pt_bitmap++); + + /* Trace du bitmap */ + for( ii = 0; ii < ii_max; ii++ ) + { + for( jj = 0; jj < jj_max; jj++, pt_bitmap++ ) + { + if( *pt_bitmap ) + GRSPutPixel( &panel->m_ClipBox, DC, + px + ii, py + jj, m_Color ); + } + } } - diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 09b9ec2966..fcbcd76781 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -46,10 +46,12 @@ static bool Test_Pad_to_Pads_Drc( WinEDA_BasePcbFrame* frame, static int TestClearanceSegmToPad( const D_PAD* pad_to_test, int seg_width, int isol ); static int TestMarginToCircle( int cx, int cy, int rayon, int longueur ); static int Tst_Ligne( int x1, int y1, int x2, int y2 ); + static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, TRACK* pt_ref, BOARD_ITEM* pt_item, int errnumber ); -static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, - BOARD* Pcb, D_PAD* pad1, D_PAD* pad2 ); + +static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, + D_PAD* pad1, D_PAD* pad2 ); /*******************************************/ @@ -923,6 +925,7 @@ static bool Test_Pad_to_Pads_Drc( WinEDA_BasePcbFrame* frame, MaskLayer = pad_ref->m_Masque_Layer & ALL_CU_LAYERS; int x_limite = max_size + g_DesignSettings.m_TrackClearence + pad_ref->m_Rayon + pad_ref->m_Pos.x; + for( ; pad_list < end_buffer; pad_list++ ) { pad = *pad_list; @@ -939,11 +942,11 @@ static bool Test_Pad_to_Pads_Drc( WinEDA_BasePcbFrame* frame, continue; /* The pad must be in a net (i.e pt_pad->m_NetCode != 0 ), - * But noe probleme if pads have the same netcode (same net)*/ + * But no problem if pads have the same netcode (same net)*/ if( pad->m_NetCode && (pad_ref->m_NetCode == pad->m_NetCode) ) continue; - /* No proble if pads are from the same footprint + /* No problem if pads are from the same footprint * and have the same pad number ( equivalent pads ) */ if( (pad->m_Parent == pad_ref->m_Parent) && (pad->m_NumPadName == pad_ref->m_NumPadName) ) continue; @@ -1151,6 +1154,7 @@ static int TestClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int dis if( bflag == OK_DRC ) return OK_DRC; + /* Erreur DRC : analyse fine de la forme de la pastille */ switch( pad_to_test->m_PadShape ) @@ -1360,7 +1364,7 @@ static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, wxString module_name = ( (MODULE*) (pad->m_Parent) )->m_Reference->m_Text; - msg.Printf( _( "%d Drc Err %d %s (net %s)and PAD %s (%s) net %s @ %d,%d\n" ), + msg.Printf( _( "%d Drc Err %d %s (net %s) and PAD %s (%s) net %s @ %d,%d\n" ), ErrorsDRC_Count, errnumber, tracktype.GetData(), netname1.GetData(), pad_name.GetData(), module_name.GetData(), @@ -1437,12 +1441,14 @@ static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, wxString pad_name2 = pad2->ReturnStringPadName(); wxString module_name2 = ( (MODULE*) (pad2->m_Parent) )->m_Reference->m_Text; wxString netname1, netname2; + EQUIPOT* equipot = Pcb->FindNet( pad1->m_NetCode ); if( equipot ) netname1 = equipot->m_Netname; else netname1 = wxT( "<noname>" ); + equipot = Pcb->FindNet( pad2->m_NetCode ); if( equipot ) netname2 = equipot->m_Netname; @@ -1450,19 +1456,21 @@ static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, netname2 = wxT( "<noname>" ); msg.Printf( _( "%d Drc Err: PAD %s (%s) net %s @ %d,%d and PAD %s (%s) net %s @ %d,%d\n" ), - ErrorsDRC_Count, pad_name1.GetData(), module_name1.GetData(), - netname1.GetData(), pad1->m_Pos.x, pad1->m_Pos.y, - pad_name2.GetData(), module_name2.GetData(), - netname2.GetData(), pad2->m_Pos.x, pad2->m_Pos.y ); + ErrorsDRC_Count, + pad_name1.GetData(), module_name1.GetData(), netname1.GetData(), pad1->m_Pos.x, pad1->m_Pos.y, + pad_name2.GetData(), module_name2.GetData(), netname2.GetData(), pad2->m_Pos.x, pad2->m_Pos.y ); + if( DrcFrame ) DrcFrame->m_logWindow->AppendText( msg ); else panel->m_Parent->Affiche_Message( msg ); + if( s_RptFile ) fprintf( s_RptFile, "%s", CONV_TO_UTF8( msg ) ); if( current_marqueur == NULL ) current_marqueur = new MARQUEUR( Pcb ); + current_marqueur->m_Pos = pad1->m_Pos; current_marqueur->m_Color = WHITE; current_marqueur->m_Diag = msg; diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index 8e5c7447b1..0d35fbb1b6 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -47,10 +47,9 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) PCB_SCREEN* screen = m_Parent->GetScreen(); wxPoint locate_pos; wxString msg; - bool succes = FALSE; bool FindMarker = FALSE; - MODULE* Module; int StartCount; + BOARD_ITEM* foundItem = 0; switch( event.GetId() ) { @@ -60,6 +59,7 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) case ID_FIND_MARKER: s_MarkerCount = 0; + // fall thru case ID_FIND_NEXT_MARKER: FindMarker = TRUE; @@ -73,16 +73,17 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) if( FindMarker ) { - MARQUEUR* Marker = (MARQUEUR*) m_Parent->m_Pcb->m_Drawings; - for( ; Marker != NULL; Marker = (MARQUEUR*) Marker->Pnext ) + MARQUEUR* marker = (MARQUEUR*) m_Parent->m_Pcb->m_Drawings; + for( ; marker; marker = (MARQUEUR*) marker->Next() ) { - if( Marker->Type() != TYPEMARQUEUR ) + if( marker->Type() != TYPEMARQUEUR ) continue; + StartCount++; if( StartCount > s_MarkerCount ) { - succes = TRUE; - locate_pos = Marker->m_Pos; + foundItem = marker; + locate_pos = marker->m_Pos; s_MarkerCount++; break; } @@ -90,27 +91,27 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) } else { - for( Module = m_Parent->m_Pcb->m_Modules; Module != NULL; Module = (MODULE*) Module->Pnext ) + for( MODULE* module = m_Parent->m_Pcb->m_Modules; module; module = (MODULE*) module->Next() ) { - if( WildCompareString( s_OldStringFound, Module->m_Reference->m_Text.GetData(), + if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), FALSE ) ) { StartCount++; if( StartCount > s_ItemCount ) { - succes = TRUE; - locate_pos = Module->m_Pos; + foundItem = module; + locate_pos = module->m_Pos; s_ItemCount++; break; } } - if( WildCompareString( s_OldStringFound, Module->m_Value->m_Text.GetData(), FALSE ) ) + if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), FALSE ) ) { StartCount++; if( StartCount > s_ItemCount ) { - succes = TRUE; - locate_pos = Module->m_Pos; + foundItem = module; + locate_pos = module->m_Pos; s_ItemCount++; break; } @@ -118,8 +119,17 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) } } - if( succes ) - { + if( foundItem ) + { + m_Parent->SetCurItem( foundItem ); + + if( FindMarker ) + msg = _( "Marker found" ); + else + msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() ); + + m_Parent->Affiche_Message( msg ); + /* Il y a peut-etre necessite de recadrer le dessin: */ if( !m_Parent->DrawPanel->IsPointOnDisplay( locate_pos ) ) { @@ -135,21 +145,18 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) m_Parent->DrawPanel->MouseToCursorSchema(); m_Parent->DrawPanel->CursorOn( m_DC ); } - - if( FindMarker ) - msg = _( "Marker found" ); - else - msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() ); - m_Parent->Affiche_Message( msg ); + EndModal( 1 ); } else { m_Parent->Affiche_Message( wxEmptyString ); + if( FindMarker ) msg = _( "Marker not found" ); else msg.Printf( _( "<%s> Not Found" ), s_OldStringFound.GetData() ); + DisplayError( this, msg, 10 ); EndModal( 0 ); } diff --git a/share/drawframe.cpp b/share/drawframe.cpp index 8ed10f4842..f90b1458c7 100644 --- a/share/drawframe.cpp +++ b/share/drawframe.cpp @@ -565,6 +565,7 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type ) case ID_POPUP_ZOOM_PLUS: case ID_ZOOM_PLUS_KEY: move_mouse_cursor = TRUE; + // fall thru case ID_ZOOM_PLUS_BUTT: if( zoom_type == ID_ZOOM_PLUS_BUTT ) @@ -576,6 +577,7 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type ) case ID_POPUP_ZOOM_MOINS: case ID_ZOOM_MOINS_KEY: move_mouse_cursor = TRUE; + // fall thru case ID_ZOOM_MOINS_BUTT: if( zoom_type == ID_ZOOM_MOINS_BUTT ) diff --git a/todo.txt b/todo.txt index 7107c309c1..51581f6286 100644 --- a/todo.txt +++ b/todo.txt @@ -51,3 +51,8 @@ understanding by new developers. *** Implement the graying in/out of "Edit/Undo", "Edit/Redo" menu items, when Undo/Redo stack is empty/filled. + +*** Implement action for ID_POPUP_PCB_DELETE_MARKER, since onrightclick.cpp +can now identify a marker. To see where the user gets a menu to delete a marker: +void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) +