From 36c316e7e0b9a5fb2af554194d5754cd840244ac Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Tue, 4 Dec 2007 07:04:53 +0000 Subject: [PATCH] DRC dialog work --- change_log.txt | 16 +++++++-- include/wxstruct.h | 10 ++++++ pcbnew/basepcbframe.cpp | 26 ++++++++++++++ pcbnew/dialog_drc.cpp | 75 ++++++++++++++++++++++++++++++----------- pcbnew/drc_stuff.h | 3 ++ pcbnew/find.cpp | 22 +++--------- 6 files changed, 112 insertions(+), 40 deletions(-) diff --git a/change_log.txt b/change_log.txt index 9ffd722997..10a8e25d7f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,19 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-Dec-4 UPDATE Dick Hollenbeck +================================================================================ ++pcbnew + * drc.cpp and dialog_drc.cpp intermediate update. + Added double click support on a MARKER in the listbox. On Linux, it pops up the + menu from PcbGeneralLocateAndDisplay() for some reason after repositioning the + cursor. That is not intended, but after several attempts to work around + it, I realized it is not so bad to have this happen. + A few more hours to go for the unconnected tab. + * Added WinEDA_BasePcbFrame::CursorGoto( const wxPoint& ) by factoring it + out of pcbnew/find.cpp + + 2007-Dec-02 UPDATE Jean-Pierre Charras ================================================================================ +eeschema: @@ -14,8 +27,7 @@ email address. 2007-Dec-2 UPDATE Dick Hollenbeck ================================================================================ +pcbnew - drc.cpp and dialog_drc.cpp intermediate update. More hours to go - before completion. + drc.cpp and dialog_drc.cpp intermediate update. 2007-Nov-30 UPDATE Dick Hollenbeck diff --git a/include/wxstruct.h b/include/wxstruct.h index bc70388f02..4b68fe7a22 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -440,6 +440,16 @@ public: */ GENERAL_COLLECTORS_GUIDE GetCollectorsGuide(); + + /** + * Function CursorGoto + * positions the cursor at a given coordinate and reframes the drawing if the + * requested point is out of view. + * @param aPos The point to go to. + */ + void CursorGoto( const wxPoint& aPos ); + + /* Place un repere sur l'ecran au point de coordonnees PCB pos */ void place_marqueur( wxDC* DC, const wxPoint& pos, char* pt_bitmap, int DrawMode, int color, int type ); diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index e313ef5e16..8978a68c64 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -96,6 +96,32 @@ int WinEDA_BasePcbFrame::BestZoom( void ) } +void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos ) +{ + // factored out of pcbnew/find.cpp + + PCB_SCREEN* screen = GetScreen(); + + wxClientDC dc( DrawPanel ); + + /* Il y a peut-etre necessite de recadrer le dessin: */ + if( !DrawPanel->IsPointOnDisplay( aPos ) ) + { + screen->m_Curseur = aPos; + Recadre_Trace( TRUE ); + } + else + { + // Positionnement du curseur sur l'item + DrawPanel->CursorOff( &dc ); + screen->m_Curseur = aPos; + GRMouseWarp( DrawPanel, screen->m_Curseur ); + DrawPanel->MouseToCursorSchema(); + DrawPanel->CursorOn( &dc ); + } +} + + /*************************************************/ void WinEDA_BasePcbFrame::ReCreateMenuBar( void ) /*************************************************/ diff --git a/pcbnew/dialog_drc.cpp b/pcbnew/dialog_drc.cpp index a31c919ce8..427c6173a7 100644 --- a/pcbnew/dialog_drc.cpp +++ b/pcbnew/dialog_drc.cpp @@ -138,6 +138,20 @@ public: Refresh(); } + + /** + * Function GetItem + * returns a requested DRC_ITEM* or NULL. + */ + const DRC_ITEM* GetItem( int aIndex ) + { + if( m_list ) + { + return m_list->GetItem( aIndex ); + } + return NULL; + } + /** * Function OnGetItem @@ -677,7 +691,7 @@ void DrcDialog::OnOkClick( wxCommandEvent& event ) SetReturnCode( wxID_OK ); m_tester->DestroyDialog(); - event.Skip(); +// event.Skip(); } @@ -693,7 +707,7 @@ void DrcDialog::OnCancelClick( wxCommandEvent& event ) SetReturnCode( wxID_CANCEL ); m_tester->DestroyDialog(); - event.Skip(); +// event.Skip(); } @@ -713,7 +727,7 @@ void DrcDialog::OnReportCheckBoxClicked( wxCommandEvent& event ) m_RptFilenameCtrl->Enable(false); m_BrowseButton->Enable(false); } - event.Skip(); +// event.Skip(); } @@ -749,13 +763,24 @@ void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event ) if( selection != wxNOT_FOUND ) { - //printf("get item number %d\n", selection ); - // Find the selected MARKER in the PCB, position cursor there. - // Do not close this dialog for users with dual screens. + // Then close the dialog. + const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection ); + if( item ) + { + // after the goto, process a button OK command later. + wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ); + ::wxPostEvent( GetEventHandler(), cmd ); + + m_Parent->CursorGoto( item->GetPosition() ); + } } + + // On linux, the double click is being propagated to the parent. The + // call to StopPropagation was an attempt to prevent this. - event.Skip(); + event.StopPropagation(); // we handled the double click event here. + // well that didn't work, we still get a popup menu } @@ -765,6 +790,7 @@ void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event ) void DrcDialog::OnRightUpUnconnected( wxMouseEvent& event ) { + // @todo: add popup menu support to go to either of the items listed in the DRC_ITEM. event.Skip(); } @@ -775,10 +801,8 @@ void DrcDialog::OnRightUpUnconnected( wxMouseEvent& event ) void DrcDialog::OnRightUpClearance( wxMouseEvent& event ) { -////@begin wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST in WinEDA_DrcFrame. - // Before editing this code, remove the block markers. + // @todo: add popup menu support to go to either of the items listed in the DRC_ITEM. event.Skip(); -////@end wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST in WinEDA_DrcFrame. } @@ -792,10 +816,24 @@ void DrcDialog::OnLeftDClickUnconnected( wxMouseEvent& event ) if( selection != wxNOT_FOUND ) { - //printf("get item number %d\n", selection ); + // Find the selected DRC_ITEM in the DRC, position cursor there. + // Then close the dialog. + const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection ); + if( item ) + { + // after the goto, process a button OK command later. + wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ); + ::wxPostEvent( GetEventHandler(), cmd ); + + m_Parent->CursorGoto( item->GetPosition() ); + } } + + // On linux, the double click is being propagated to the parent. The + // call to StopPropagation was an attempt to prevent this. - event.Skip(); + event.StopPropagation(); // we handled the double click event here. + // well that didn't work, we still get a popup menu } @@ -807,7 +845,6 @@ void DrcDialog::OnMarkerSelectionEvent( wxCommandEvent& event ) { // until a MARKER is selected, this button is not enabled. m_DeleteCurrentMarkerButton->Enable(true); - //printf("get Marker number %d\n", selection ); } event.Skip(); @@ -819,7 +856,8 @@ void DrcDialog::OnUnconnectedSelectionEvent( wxCommandEvent& event ) if( selection != wxNOT_FOUND ) { - printf("get Unconnected item number %d\n", selection ); + // until a MARKER is selected, this button is not enabled. + m_DeleteCurrentMarkerButton->Enable(true); } event.Skip(); @@ -857,7 +895,7 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event ) if( selectedIndex != wxNOT_FOUND ) { m_ClearanceListBox->DeleteItem( selectedIndex ); - m_Parent->ReDrawPanel(); + RedrawDrawPanel(); } } @@ -867,13 +905,10 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event ) if( selectedIndex != wxNOT_FOUND ) { m_UnconnectedListBox->DeleteItem( selectedIndex ); - m_Parent->ReDrawPanel(); + RedrawDrawPanel(); } } -////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE in DrcDialog. - // Before editing this code, remove the block markers. - event.Skip(); -////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE in DrcDialog. +// event.Skip(); } diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index f8b814f4d0..28586536a7 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -299,6 +299,9 @@ private: BOARD* m_pcb; DrcDialog* m_ui; + std::vector m_unconnected; + + /** * Function updatePointers * is a private helper function used to update needed pointers from the diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index b886cbadfb..efc69e3e97 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -115,25 +115,11 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) if( FindMarker ) msg = _( "Marker found" ); else - msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() ); - - m_Parent->Affiche_Message( msg ); + msg.Printf( _( "<%s> Found" ), s_OldStringFound.GetData() ); - /* Il y a peut-etre necessite de recadrer le dessin: */ - if( !m_Parent->DrawPanel->IsPointOnDisplay( locate_pos ) ) - { - screen->m_Curseur = locate_pos; - m_Parent->Recadre_Trace( TRUE ); - } - else - { - // Positionnement du curseur sur l'item - m_Parent->DrawPanel->CursorOff( m_DC ); - screen->m_Curseur = locate_pos; - GRMouseWarp( m_Parent->DrawPanel, screen->m_Curseur ); - m_Parent->DrawPanel->MouseToCursorSchema(); - m_Parent->DrawPanel->CursorOn( m_DC ); - } + m_Parent->Affiche_Message( msg ); + + m_Parent->CursorGoto( locate_pos ); EndModal( 1 ); }