2011-01-04 20:27:52 +00:00
|
|
|
/*
|
|
|
|
* annotate_dialog.cpp
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* annotate_dialog.cpp
|
|
|
|
* Annotation dialog functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2011 jean-pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
|
|
|
* Copyright (C) 1992-2011 Kicad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
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"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2011-01-01 17:28:21 +00:00
|
|
|
#include "class_drawpanel.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")
|
2011-01-04 20:27:52 +00:00
|
|
|
#define KEY_ANNOTATE_ALGO_OPTION wxT("AnnotateAlgoOption")
|
2009-10-27 19:30:32 +00:00
|
|
|
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
|
2009-10-27 19:30:32 +00:00
|
|
|
: 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 )
|
|
|
|
{
|
2011-01-01 17:28:21 +00:00
|
|
|
default:
|
2009-10-27 19:30:32 +00:00
|
|
|
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:
|
2011-01-04 20:27:52 +00:00
|
|
|
m_rbSortBy_Y_Position->SetValue(1);
|
2009-10-27 19:30:32 +00:00
|
|
|
break;
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2009-10-27 19:30:32 +00:00
|
|
|
case 2:
|
2011-01-04 20:27:52 +00:00
|
|
|
m_rbUseIncremental->SetValue(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Config->Read(KEY_ANNOTATE_ALGO_OPTION, &option, 0l);
|
|
|
|
switch( option )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
m_rbUseIncremental->SetValue(1);
|
2009-10-27 19:30:32 +00:00
|
|
|
break;
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2011-01-04 20:27:52 +00:00
|
|
|
case 1:
|
|
|
|
m_rbUseSheetNum->SetValue(1);
|
2011-01-01 17:28:21 +00:00
|
|
|
break;
|
|
|
|
|
2011-01-04 20:27:52 +00:00
|
|
|
case 2:
|
|
|
|
m_rbStartSheetNumLarge->SetValue(1);
|
2009-10-27 19:30:32 +00:00
|
|
|
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);
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
m_btnApply->SetDefault();
|
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 )
|
2011-01-04 20:27:52 +00:00
|
|
|
{
|
2009-10-27 19:30:32 +00:00
|
|
|
m_Config->Write(KEY_ANNOTATE_SORT_OPTION, GetSortOrder());
|
2011-01-04 20:27:52 +00:00
|
|
|
m_Config->Write(KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo());
|
|
|
|
}
|
2009-10-27 19:30:32 +00:00
|
|
|
|
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." );
|
2010-11-11 21:10:27 +00:00
|
|
|
response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL );
|
2008-02-26 01:07:38 +00:00
|
|
|
if (response == wxCANCEL)
|
|
|
|
return;
|
2011-01-04 20:27:52 +00:00
|
|
|
|
2011-05-20 19:21:09 +00:00
|
|
|
m_Parent->AnnotateComponents( GetLevel(), (ANNOTATE_ORDER_T) GetSortOrder(),
|
|
|
|
(ANNOTATE_OPTION_T) GetAnnotateAlgo(),
|
2011-01-04 20:27:52 +00:00
|
|
|
GetResetItems() , true );
|
2011-01-01 17:28:21 +00:00
|
|
|
m_Parent->DrawPanel->Refresh();
|
|
|
|
|
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;
|
2011-01-01 17:28:21 +00:00
|
|
|
m_Parent->DeleteAnnotation( GetLevel() ? false : true );
|
|
|
|
m_Parent->DrawPanel->Refresh();
|
|
|
|
|
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,
|
2011-01-04 20:27:52 +00:00
|
|
|
* 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;
|
2011-01-01 17:28:21 +00:00
|
|
|
if ( m_rbSortBy_Y_Position->GetValue() )
|
2011-01-04 20:27:52 +00:00
|
|
|
return 1;
|
|
|
|
return 2;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-04-16 17:21:01 +00:00
|
|
|
|
2011-01-04 20:27:52 +00:00
|
|
|
int DIALOG_ANNOTATE::GetAnnotateAlgo( void )
|
|
|
|
/**
|
|
|
|
* @return 0 if annotation using first not used Id value
|
|
|
|
* 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99
|
|
|
|
* 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if ( m_rbUseIncremental->GetValue() )
|
|
|
|
return 0;
|
|
|
|
if ( m_rbUseSheetNum->GetValue() )
|
|
|
|
return 1;
|
|
|
|
return 2;
|
|
|
|
}
|