2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: annotate_dialog.cpp
|
2009-10-27 19:30:32 +00:00
|
|
|
// Licence: License GNU
|
2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
#include "fctsys.h"
|
2009-10-27 19:30:32 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2008-04-21 14:03:20 +00:00
|
|
|
#include "bitmaps.h"
|
2008-04-14 19:22:48 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "annotate_dialog.h"
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
#define KEY_ANNOTATE_SORT_OPTION wxT("AnnotateSortOption")
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
extern void AnnotateComponents( WinEDA_SchematicFrame* parent,
|
|
|
|
bool annotateSchematic,
|
2008-04-21 14:03:20 +00:00
|
|
|
int sortOption,
|
2009-04-25 10:12:30 +00:00
|
|
|
bool resetAnnotation,
|
|
|
|
bool repairsTimestamps );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
DIALOG_ANNOTATE::DIALOG_ANNOTATE( WinEDA_SchematicFrame* parent )
|
|
|
|
: DIALOG_ANNOTATE_BASE( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
m_Parent = parent;
|
2009-10-27 19:30:32 +00:00
|
|
|
InitValues();
|
|
|
|
Layout();
|
|
|
|
GetSizer()->SetSizeHints(this);
|
2007-06-05 12:10:51 +00:00
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/*********************************/
|
|
|
|
void DIALOG_ANNOTATE::InitValues()
|
|
|
|
/*********************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-10-27 19:30:32 +00:00
|
|
|
m_Config = wxGetApp().m_EDA_Config;
|
|
|
|
SetFocus(); // needed to close dialog by escape key
|
|
|
|
if( m_Config )
|
|
|
|
{
|
|
|
|
long option;
|
|
|
|
m_Config->Read(KEY_ANNOTATE_SORT_OPTION, &option, 0l);
|
|
|
|
switch( option )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_rbSortBy_X_Position->SetValue(1);
|
|
|
|
break;
|
2008-04-16 17:21:01 +00:00
|
|
|
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
case 1:
|
|
|
|
m_rbSortBy_Y_Position->SetValue(1);
|
|
|
|
break;
|
2008-04-16 17:21:01 +00:00
|
|
|
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
case 2:
|
|
|
|
rbSortByValue->SetValue(1);
|
|
|
|
break;
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-30 11:52:34 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
wxBitmap bitmap0(annotate_down_right_xpm);
|
|
|
|
annotate_down_right_bitmap->SetBitmap(bitmap0);
|
|
|
|
wxBitmap bitmap1(annotate_right_down_xpm);
|
|
|
|
annotate_right_down_bitmap->SetBitmap(bitmap1);
|
|
|
|
wxBitmap bitmap2(add_text_xpm);
|
|
|
|
annotate_by_value_bitmap->SetBitmap(bitmap2);
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/*********************************************************/
|
|
|
|
void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
|
|
|
|
/*********************************************************/
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
int response;
|
|
|
|
wxString message;
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
if( m_Config )
|
|
|
|
m_Config->Write(KEY_ANNOTATE_SORT_OPTION, GetSortOrder());
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetResetItems() )
|
|
|
|
message = _( "Clear and annotate all of the components " );
|
|
|
|
else
|
|
|
|
message = _( "Annotate only the unannotated components " );
|
|
|
|
if( GetLevel() )
|
|
|
|
message += _( "on the entire schematic?" );
|
|
|
|
else
|
|
|
|
message += _( "on the current sheet?" );
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
message += _( "\n\nThis operation will change the current annotation and cannot be undone." );
|
2008-02-26 19:19:54 +00:00
|
|
|
response = wxMessageBox( message, wxT( "" ),
|
2008-02-26 01:07:38 +00:00
|
|
|
wxICON_EXCLAMATION | wxOK | wxCANCEL );
|
|
|
|
if (response == wxCANCEL)
|
|
|
|
return;
|
|
|
|
AnnotateComponents( m_Parent, GetLevel(), GetSortOrder(),
|
2009-04-25 10:12:30 +00:00
|
|
|
GetResetItems() , true );
|
2008-02-26 01:07:38 +00:00
|
|
|
m_btnClear->Enable();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/************************************************************************/
|
|
|
|
void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
|
|
|
|
/************************************************************************/
|
2008-04-16 17:21:01 +00:00
|
|
|
{
|
|
|
|
int response;
|
|
|
|
|
|
|
|
wxString message = _( "Clear the existing annotation for " );
|
|
|
|
if( GetLevel() )
|
|
|
|
message += _( "the entire schematic?" );
|
|
|
|
else
|
|
|
|
message += _( "the current sheet?" );
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." );
|
2008-04-16 17:21:01 +00:00
|
|
|
response = wxMessageBox( message, wxT( "" ),
|
|
|
|
wxICON_EXCLAMATION | wxOK | wxCANCEL );
|
|
|
|
if (response == wxCANCEL)
|
|
|
|
return;
|
2008-04-21 06:34:56 +00:00
|
|
|
m_Parent->DeleteAnnotation( GetLevel() ? false : true, true );
|
2008-04-16 17:21:01 +00:00
|
|
|
m_btnClear->Enable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/************************************************************/
|
|
|
|
void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
|
|
|
|
/************************************************************/
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
|
|
|
if( IsModal() )
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetReturnCode( wxID_CANCEL );
|
|
|
|
this->Show( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/**************************************/
|
|
|
|
bool DIALOG_ANNOTATE::GetLevel( void )
|
|
|
|
/**************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
return m_rbEntireSchematic->GetValue();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/******************************************/
|
|
|
|
bool DIALOG_ANNOTATE::GetResetItems( void )
|
|
|
|
/******************************************/
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2008-04-21 14:03:20 +00:00
|
|
|
return m_rbResetAnnotation->GetValue();
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
/****************************************/
|
|
|
|
int DIALOG_ANNOTATE::GetSortOrder( void )
|
|
|
|
/****************************************/
|
2008-04-12 18:39:20 +00:00
|
|
|
/**
|
2008-04-21 14:03:20 +00:00
|
|
|
* @return 0 if annotation by X position,
|
|
|
|
* 1 if annotation by Y position
|
|
|
|
* 2 if annotation by value
|
2008-04-12 18:39:20 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-21 14:03:20 +00:00
|
|
|
if ( m_rbSortBy_X_Position->GetValue() )
|
|
|
|
return 0;
|
|
|
|
if ( m_rbSortBy_Y_Position->GetValue() )
|
|
|
|
return 1;
|
|
|
|
return 2;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-04-16 17:21:01 +00:00
|
|
|
|