Commit c52e99e9 authored by charras's avatar charras

Annotation enhancements

parent af7b6691
/* XPM */
#ifndef XPMMAIN
extern const char *annotate_down_right_xpm[];
#else
const char *annotate_down_right_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 16 1",
"@ c #89B09C",
"O c #DB8F8F",
". c #D4B7B7",
"# c #85A794",
"& c #72CAA2",
"% c #9EB5A9",
"- c #59CD99",
"o c #E48080",
"+ c #DC9897",
" c none",
"X c #D6A1A0",
": c #E46264",
"= c #64F6B4",
"$ c #B4BEBC",
"; c #69E5A9",
"* c #81B79F",
/* pixels */
" ",
" ",
" .X o. ",
" .O +o. ",
" .X O.X. ",
" .O X. O. ",
" @# $%%+. #% ",
" && *=* $&&$",
"@&-# %;*@ #;-@",
" @@ .O% $ #@ ",
" .X O. X. ",
" .O O O. ",
" .+O. X. ",
" .: O. ",
" $ ",
" "
};
#endif
/* XPM */
#ifndef XPMMAIN
extern const char *annotate_right_down_xpm[];
#else
const char *annotate_right_down_xpm[] = {
/* columns rows colors const chars-per-pixel */
"16 16 16 1",
"@ c #59CE99",
"% c #D79E9C",
"$ c #DC9393",
"o c #FFB4B4",
"* c #74CAA2",
"X c #FFBDBD",
". c #89AF9A",
" c none",
"- c #E46264",
"# c #FFAAAC",
"; c #64F6B4",
"& c #84A794",
"= c #69E5A9",
": c #E08280",
"O c #9BB5A5",
"+ c #81B79F",
/* pixels */
" . ",
" XoooO+@Ooooo ",
" #$%$&*=&%$%-X ",
" X& X$ ",
" X$o ",
" $ ",
" X O$o ",
" O+=+ ",
" O;@X ",
" %.OX ",
" %X ",
" $o ",
" $X X& ",
" ::%$&*=.%$%$ ",
" oooo.@@.oooo ",
" . "
};
#endif
......@@ -135,7 +135,7 @@ CmpListStruct* AllocateCmpListStrct( int numcomponents )
* if same X pos, by Y pos
* if same Y pos, by time stamp
*/
int AnnotateByPosition( const void* o1, const void* o2 )
int AnnotateBy_X_Position( const void* o1, const void* o2 )
{
CmpListStruct* item1 = (CmpListStruct*) o1;
CmpListStruct* item2 = (CmpListStruct*) o2;
......@@ -155,6 +155,34 @@ int AnnotateByPosition( const void* o1, const void* o2 )
}
/* qsort function to annotate items by their position.
* Components are sorted
* by reference
* if same reference: by sheet
* if same sheet, by Y pos
* if same Y pos, by X pos
* if same X pos, by time stamp
*/
int AnnotateBy_Y_Position( const void* o1, const void* o2 )
{
CmpListStruct* item1 = (CmpListStruct*) o1;
CmpListStruct* item2 = (CmpListStruct*) o2;
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 );
if( ii == 0 )
ii = item1->m_SheetList.Cmp( item2->m_SheetList );
if( ii == 0 )
ii = item1->m_Pos.y - item2->m_Pos.y;
if( ii == 0 )
ii = item1->m_Pos.x - item2->m_Pos.x;
if( ii == 0 )
ii = item1->m_TimeStamp - item2->m_TimeStamp;
return ii;
}
/*****************************************************************************
* qsort function to annotate items by value
* Components are sorted
......@@ -246,12 +274,14 @@ void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly, bool aRedr
* annotated.
* @param parent = Schematic frame
* @param annotateSchematic : true = entire schematic annotation, false = current scheet only
* @param sortByPosition : true = annotate by sorting X position, false = annotate by sorting value
* @param sortOption : 0 = annotate by sorting X position,
* 1 = annotate by sorting Y position,
* 2 = annotate by sorting value
* @param resetAnnotation : true = remove previous annotation false = anotate new components only
*****************************************************************************/
void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
bool sortByPosition,
int sortOption,
bool resetAnnotation )
{
int ii, NbOfCmp;
......@@ -308,13 +338,26 @@ void AnnotateComponents( WinEDA_SchematicFrame* parent,
/* Break full components reference in name (prefix) and number:
* example: IC1 become IC, and 1 */
BreakReference( BaseListeCmp, NbOfCmp );
wxString msg1;
msg1 << sortOption;
wxMessageBox(msg1);
switch( sortOption )
{
case 0:
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotateBy_X_Position );
break;
if( sortByPosition )
case 1:
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotateByPosition );
else
( int( * ) ( const void*, const void* ) )AnnotateBy_Y_Position );
break;
case 2:
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotateByValue );
break;
}
/* Recalculate reference numbers */
ComputeReferenceNumber( BaseListeCmp, NbOfCmp );
......
......@@ -30,13 +30,14 @@
////@end includes
#include "fctsys.h"
#include "bitmaps.h"
#include "common.h"
#include "program.h"
#include "annotate_dialog.h"
extern void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
bool sortByPosition,
int sortOption,
bool resetAnnotation );
////@begin XPM images
......@@ -125,8 +126,10 @@ void WinEDA_AnnotateFrame::Init()
{
////@begin WinEDA_AnnotateFrame member initialisation
m_rbEntireSchematic = NULL;
m_cbResetAnnotation = NULL;
m_rbSortByPosition = NULL;
m_rbKeepAnnotation = NULL;
m_rbResetAnnotation = NULL;
m_rbSortBy_X_Position = NULL;
m_rbSortBy_Y_Position = NULL;
rbSortByValue = NULL;
sizerDialogButtons = NULL;
m_btnClose = NULL;
......@@ -143,7 +146,7 @@ void WinEDA_AnnotateFrame::Init()
void WinEDA_AnnotateFrame::CreateControls()
{
////@begin WinEDA_AnnotateFrame content construction
// Generated by DialogBlocks, 16/04/2008 20:16:13 (unregistered)
// Generated by DialogBlocks, 21/04/2008 16:47:55 (unregistered)
WinEDA_AnnotateFrame* itemDialog1 = this;
......@@ -161,34 +164,65 @@ void WinEDA_AnnotateFrame::CreateControls()
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxLEFT, 25);
m_rbEntireSchematic = new wxRadioButton( itemDialog1, ID_ENTIRE_SCHEMATIC, _("Annotate the &entire schematic"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbEntireSchematic = new wxRadioButton( itemDialog1, ID_ENTIRE_SCHEMATIC, _("Use the &entire schematic"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbEntireSchematic->SetValue(true);
itemBoxSizer5->Add(m_rbEntireSchematic, 0, wxGROW|wxALL, 5);
wxRadioButton* itemRadioButton7 = new wxRadioButton( itemDialog1, ID_CURRENT_PAGE, _("Annotate the current &page only"), wxDefaultPosition, wxDefaultSize, 0 );
wxRadioButton* itemRadioButton7 = new wxRadioButton( itemDialog1, ID_CURRENT_PAGE, _("Use the current &page only"), wxDefaultPosition, wxDefaultSize, 0 );
itemRadioButton7->SetValue(false);
itemBoxSizer5->Add(itemRadioButton7, 0, wxGROW|wxALL, 5);
m_cbResetAnnotation = new wxCheckBox( itemDialog1, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbResetAnnotation->SetValue(false);
m_cbResetAnnotation->SetForegroundColour(wxColour(217, 38, 52));
itemBoxSizer5->Add(m_cbResetAnnotation, 0, wxGROW|wxALL, 5);
wxStaticLine* itemStaticLine8 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
itemBoxSizer5->Add(itemStaticLine8, 0, wxGROW|wxALL, 5);
wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("Order"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticText9->SetForegroundColour(wxColour(125, 2, 12));
itemStaticText9->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma")));
itemBoxSizer3->Add(itemStaticText9, 0, wxALIGN_LEFT|wxALL, 5);
m_rbKeepAnnotation = new wxRadioButton( itemDialog1, ID_KEEP_ANNOTATION, _("&Keep existing annotation"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbKeepAnnotation->SetValue(true);
itemBoxSizer5->Add(m_rbKeepAnnotation, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer10, 0, wxGROW|wxLEFT, 25);
m_rbResetAnnotation = new wxRadioButton( itemDialog1, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 );
m_rbResetAnnotation->SetValue(false);
itemBoxSizer5->Add(m_rbResetAnnotation, 0, wxGROW|wxALL, 5);
m_rbSortByPosition = new wxRadioButton( itemDialog1, ID_SORT_BY_POSITION, _("Sort Components by &Y Position"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbSortByPosition->SetValue(true);
itemBoxSizer10->Add(m_rbSortByPosition, 0, wxGROW|wxALL, 5);
wxStaticLine* itemStaticLine11 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
itemBoxSizer3->Add(itemStaticLine11, 0, wxGROW|wxALL, 5);
wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Order"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticText12->SetForegroundColour(wxColour(125, 2, 12));
itemStaticText12->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma")));
itemBoxSizer3->Add(itemStaticText12, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW|wxLEFT, 25);
wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer13->Add(itemBoxSizer14, 0, wxGROW, 5);
wxStaticBitmap* itemStaticBitmap15 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemDialog1->GetBitmapResource(wxT("annotate_down_right_xpm")), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer14->Add(itemStaticBitmap15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_rbSortBy_X_Position = new wxRadioButton( itemDialog1, ID_SORT_BY_X_POSITION, _("Sort Components by &X Position"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_rbSortBy_X_Position->SetValue(true);
itemBoxSizer14->Add(m_rbSortBy_X_Position, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer13->Add(itemBoxSizer17, 0, wxGROW, 5);
wxStaticBitmap* itemStaticBitmap18 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemDialog1->GetBitmapResource(wxT("annotate_right_down_xpm")), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer17->Add(itemStaticBitmap18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_rbSortBy_Y_Position = new wxRadioButton( itemDialog1, ID_SORT_BY_Y_POSITION, _("Sort Components by &Y Position"), wxDefaultPosition, wxDefaultSize, 0 );
m_rbSortBy_Y_Position->SetValue(false);
itemBoxSizer17->Add(m_rbSortBy_Y_Position, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer13->Add(itemBoxSizer20, 0, wxGROW, 5);
wxStaticBitmap* itemStaticBitmap21 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemDialog1->GetBitmapResource(wxT("add_text_xpm")), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer20->Add(itemStaticBitmap21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
rbSortByValue = new wxRadioButton( itemDialog1, ID_SORT_BY_VALUE, _("Sort Components by &Value"), wxDefaultPosition, wxDefaultSize, 0 );
rbSortByValue->SetValue(false);
itemBoxSizer10->Add(rbSortByValue, 0, wxGROW|wxALL, 5);
itemBoxSizer20->Add(rbSortByValue, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
sizerDialogButtons = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(sizerDialogButtons, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
......@@ -296,19 +330,25 @@ bool WinEDA_AnnotateFrame::GetResetItems( void )
m_cbResetAnnotation->IsKindOf( CLASSINFO( wxCheckBox ) ),
wxT( "m_cbResetAnnotation pointer was NULL." ) );
return m_cbResetAnnotation->IsChecked();
return m_rbResetAnnotation->GetValue();
}
bool WinEDA_AnnotateFrame::GetSortOrder( void )
int WinEDA_AnnotateFrame::GetSortOrder( void )
/**
* @return true if annotation by position, false if annotation by value
* @return 0 if annotation by X position,
* 1 if annotation by Y position
* 2 if annotation by value
*/
{
wxASSERT_MSG( (m_rbSortByPosition != NULL) &&
m_rbSortByPosition->IsKindOf( CLASSINFO( wxRadioButton ) ),
wxT( "m_rbSortByPosition pointer was NULL." ) );
return m_rbSortByPosition->GetValue();
if ( m_rbSortBy_X_Position->GetValue() )
return 0;
if ( m_rbSortBy_Y_Position->GetValue() )
return 1;
return 2;
}
......@@ -329,10 +369,23 @@ bool WinEDA_AnnotateFrame::ShowToolTips()
wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_AnnotateFrame bitmap retrieval
wxUnusedVar(name);
if (name == wxT("annotate_down_right_xpm"))
{
wxBitmap bitmap(annotate_down_right_xpm);
return bitmap;
}
else if (name == wxT("annotate_right_down_xpm"))
{
wxBitmap bitmap(annotate_right_down_xpm);
return bitmap;
}
else if (name == wxT("add_text_xpm"))
{
wxBitmap bitmap(add_text_xpm);
return bitmap;
}
return wxNullBitmap;
////@end WinEDA_AnnotateFrame bitmap retrieval
}
/*!
......
......@@ -23,6 +23,7 @@
*/
////@begin includes
#include "wx/statline.h"
////@end includes
/*!
......@@ -41,8 +42,10 @@ class wxBoxSizer;
#define ID_DIALOG 10000
#define ID_ENTIRE_SCHEMATIC 10002
#define ID_CURRENT_PAGE 10003
#define ID_KEEP_ANNOTATION 10009
#define ID_RESET_ANNOTATION 10009
#define ID_SORT_BY_POSITION 10010
#define ID_SORT_BY_X_POSITION 10001
#define ID_SORT_BY_Y_POSITION 10001
#define ID_SORT_BY_VALUE 10011
#define ID_CLEAR_ANNOTATION_CMP 10004
#define SYMBOL_WINEDA_ANNOTATEFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
......@@ -107,12 +110,14 @@ public:
// User functions:
bool GetLevel( void );
bool GetResetItems( void );
bool GetSortOrder( void );
int GetSortOrder( void );
////@begin WinEDA_AnnotateFrame member variables
wxRadioButton* m_rbEntireSchematic;
wxCheckBox* m_cbResetAnnotation;
wxRadioButton* m_rbSortByPosition;
wxRadioButton* m_rbKeepAnnotation;
wxRadioButton* m_rbResetAnnotation;
wxRadioButton* m_rbSortBy_X_Position;
wxRadioButton* m_rbSortBy_Y_Position;
wxRadioButton* rbSortByValue;
wxBoxSizer* sizerDialogButtons;
wxButton* m_btnClose;
......
This diff is collapsed.
......@@ -200,6 +200,9 @@
#include "../bitmaps/Auto_track_width.xpm"
#include "../bitmaps/fill_zone.xpm"
#include "../bitmaps/Width_Segment.xpm"
#include "../bitmaps/annotate_right_down.xpm"
#include "../bitmaps/annotate_down_right.xpm"
// Largeur du toolbar vertical
#define VTOOLBAR_WIDTH 26
......
No preview for this file type
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