Commit e3b4eeb1 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

More EESchema dialog file housekeeping

parent fdb18547
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -4,6 +4,18 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.

2010-nov-17 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
  * Move library text edit, library draw item edit, SVG print, and BOM dialogs
    to dialogs folder.
  * Rename library text edit dialog file and object names to comply with
    coding policy.
  * Set default button in library text edit, library draw item edit, SVG print,
    and BOM dialogs.
  * Move BOM dialog code into BOM dialog object source file.


2010-nov-11 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
+8 −8
Original line number Diff line number Diff line
@@ -35,9 +35,10 @@ set(EESCHEMA_SRCS
    dialogs/dialog_plot_schematic_PS_base.cpp
    dialogs/annotate_dialog.cpp
    dialogs/dialog_annotate_base.cpp
    dialog_bodygraphictext_properties_base.cpp
    dialog_build_BOM.cpp
    dialog_build_BOM_base.cpp
    dialogs/dialog_lib_edit_text.cpp
    dialogs/dialog_lib_edit_text_base.cpp
    dialogs/dialog_build_BOM.cpp
    dialogs/dialog_build_BOM_base.cpp
    dialog_edit_component_in_lib.cpp
    dialog_edit_component_in_lib_base.cpp
    dialog_edit_component_in_schematic_fbp.cpp
@@ -54,8 +55,8 @@ set(EESCHEMA_SRCS
    dialogs/dialog_erc_base.cpp
    dialog_libedit_dimensions.cpp
    dialog_libedit_dimensions_base.cpp
    dialog_lib_edit_draw_item.cpp
    dialog_lib_edit_draw_item_base.cpp
    dialogs/dialog_lib_edit_draw_item.cpp
    dialogs/dialog_lib_edit_draw_item_base.cpp
    dialogs/dialog_lib_edit_pin.cpp
    dialogs/dialog_lib_edit_pin_base.cpp
    dialog_lib_new_component.cpp
@@ -66,8 +67,8 @@ set(EESCHEMA_SRCS
    dialog_sch_sheet_props_base.cpp
    dialogs/dialog_schematic_find.cpp
    dialogs/dialog_schematic_find_base.cpp
    dialog_SVG_print.cpp
    dialog_SVG_print_base.cpp
    dialogs/dialog_SVG_print.cpp
    dialogs/dialog_SVG_print_base.cpp
    edit_component_in_lib.cpp
    edit_component_in_schematic.cpp
    edit_label.cpp
@@ -130,7 +131,6 @@ set(EESCHEMA_SRCS
    sheetlab.cpp
    symbdraw.cpp
    symbedit.cpp
    edit_graphic_bodyitem_text.cpp
    template_fieldnames_keywords.cpp
    template_fieldnames.cpp
    tool_lib.cpp
+6 −725

File changed.

Preview size limit exceeded, changes collapsed.

eeschema/dialog_build_BOM.cpp

deleted100644 → 0
+0 −248
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////

// Name:        dialog_build_BOM.cpp
// Author:      jean-pierre Charras
// Modified by:
// Licence:     GPL
/////////////////////////////////////////////////////////////////////////////


#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "wxstruct.h"

#include "general.h"
#include "netlist.h"

#include "wx/valgen.h"

#include "dialog_build_BOM.h"


#include "protos.h"


/* Local variables */
static bool  s_ListByRef   = TRUE;
static bool  s_ListByValue = TRUE;
static bool  s_ListWithSubCmponents;
static bool  s_ListHierarchicalPinByName;
static bool  s_ListBySheet;
static bool  s_BrowseCreatedList;
static int   s_OutputFormOpt;
static int   s_OutputSeparatorOpt;
static bool  s_Add_FpField_state;
static bool  s_Add_F1_state;
static bool  s_Add_F2_state;
static bool  s_Add_F3_state;
static bool  s_Add_F4_state;
static bool  s_Add_F5_state;
static bool  s_Add_F6_state;
static bool  s_Add_F7_state;
static bool  s_Add_F8_state;
static bool  s_Add_Alls_state;

static bool* s_AddFieldList[] = {
    &s_Add_FpField_state,
    &s_Add_F1_state,
    &s_Add_F2_state,
    &s_Add_F3_state,
    &s_Add_F4_state,
    &s_Add_F5_state,
    &s_Add_F6_state,
    &s_Add_F7_state,
    &s_Add_F8_state,
    &s_Add_Alls_state,
    NULL
};


#define OPTION_BOM_FORMAT    wxT( "BomFormat" )
#define OPTION_BOM_LAUNCH_BROWSER    wxT( "BomLaunchBrowser" )
#define OPTION_BOM_SEPARATOR wxT( "BomExportSeparator" )
#define OPTION_BOM_ADD_FIELD wxT( "BomAddField" )

/* list of separators used in bom export to spreadsheet
 * (selected by s_OutputSeparatorOpt, and s_OutputSeparatorOpt radiobox)
 */
static char s_ExportSeparator[] = ("\t;,.");

/*!
 * DIALOG_BUILD_BOM dialog type definition
 */


DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( WinEDA_DrawFrame* parent ):
    DIALOG_BUILD_BOM_BASE(parent)
{
    m_Config = wxGetApp().m_EDA_Config;
    wxASSERT( m_Config != NULL );

    m_Parent = parent;

    Init( );

    if (GetSizer())
    {
        GetSizer()->SetSizeHints(this);
    }
    Centre();
}


/*!
 * Init Controls for DIALOG_BUILD_BOM
 */

void DIALOG_BUILD_BOM::Init()
{
    SetFocus();

    /* Get options */
    s_OutputFormOpt      = m_Config->Read( OPTION_BOM_FORMAT, (long) 0 );
    s_BrowseCreatedList      = m_Config->Read( OPTION_BOM_LAUNCH_BROWSER, (long) 0 );
    s_OutputSeparatorOpt = m_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
    long addfields = m_Config->Read( OPTION_BOM_ADD_FIELD, (long) 0 );
    for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
    {
        if( (addfields & bitmask) )
            *s_AddFieldList[ii] = true;
        else
            *s_AddFieldList[ii] = false;

        bitmask <<= 1;
    }

    // Set validators
    m_ListCmpbyRefItems->SetValidator( wxGenericValidator(& s_ListByRef) );
    m_ListSubCmpItems->SetValidator( wxGenericValidator(& s_ListWithSubCmponents) );
    m_ListCmpbyValItems->SetValidator( wxGenericValidator(& s_ListByValue) );
    m_GenListLabelsbyVal->SetValidator( wxGenericValidator(& s_ListHierarchicalPinByName) );
    m_GenListLabelsbySheet->SetValidator( wxGenericValidator(& s_ListBySheet) );
    m_OutputFormCtrl->SetValidator( wxGenericValidator(& s_OutputFormOpt) );
    m_OutputSeparatorCtrl->SetValidator( wxGenericValidator(& s_OutputSeparatorOpt) );
    m_GetListBrowser->SetValidator( wxGenericValidator(& s_BrowseCreatedList) );
    m_AddFootprintField->SetValidator( wxGenericValidator(& s_Add_FpField_state) );
    m_AddField1->SetValidator( wxGenericValidator(& s_Add_F1_state) );
    m_AddField2->SetValidator( wxGenericValidator(& s_Add_F2_state) );
    m_AddField3->SetValidator( wxGenericValidator(& s_Add_F3_state) );
    m_AddField4->SetValidator( wxGenericValidator(& s_Add_F4_state) );
    m_AddField5->SetValidator( wxGenericValidator(& s_Add_F5_state) );
    m_AddField6->SetValidator( wxGenericValidator(& s_Add_F6_state) );
    m_AddField7->SetValidator( wxGenericValidator(& s_Add_F7_state) );
    m_AddField8->SetValidator( wxGenericValidator(& s_Add_F8_state) );
    m_AddAllFields->SetValidator( wxGenericValidator(& s_Add_Alls_state) );

    m_OutputFormCtrl->SetSelection( s_OutputFormOpt );
    m_OutputSeparatorCtrl->SetSelection( s_OutputSeparatorOpt );

    // Enable/disable options:
    wxCommandEvent dummy;
    OnRadioboxSelectFormatSelected( dummy );
}


/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SELECT_FORMAT
 */

void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event )
{
    if( m_OutputFormCtrl->GetSelection() == 0 )
    {
        m_OutputSeparatorCtrl->Enable( false );
        m_ListCmpbyValItems->Enable( true );
        m_GenListLabelsbyVal->Enable( true );
        m_GenListLabelsbySheet->Enable( true );
    } else {
        m_OutputSeparatorCtrl->Enable( true );
        m_ListCmpbyValItems->Enable( false );
        m_GenListLabelsbyVal->Enable( false );
        m_GenListLabelsbySheet->Enable( false );
    }
}


/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void DIALOG_BUILD_BOM::OnOkClick( wxCommandEvent& event )
{
    char ExportSeparatorSymbol = s_ExportSeparator[0];
    if( m_OutputSeparatorCtrl->GetSelection() > 0 )
        ExportSeparatorSymbol = s_ExportSeparator[m_OutputSeparatorCtrl->GetSelection()];

    int ExportFileType = m_OutputFormCtrl->GetSelection(); 

    SavePreferences();

    Create_BOM_Lists( ExportFileType, m_ListSubCmpItems->GetValue(),
                      ExportSeparatorSymbol, m_GetListBrowser->GetValue());
}



/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
 */

void DIALOG_BUILD_BOM::OnCancelClick( wxCommandEvent& event )
{
    EndModal( -1 );
}


/**************************************************/
void DIALOG_BUILD_BOM::SavePreferences()
/**************************************************/
{
    wxASSERT( m_Config != NULL );

    // Determine current settings of "List items" and "Options" checkboxes
    // (NOTE: These 6 settings are restored when the dialog box is next
    // invoked, but are *not* still saved after EESchema is next shut down.)
    s_ListByRef = m_ListCmpbyRefItems->GetValue();
    s_ListWithSubCmponents = m_ListSubCmpItems->GetValue();
    s_ListByValue = m_ListCmpbyValItems->GetValue();
    s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue();
    s_ListBySheet = m_GenListLabelsbySheet->GetValue();
    s_BrowseCreatedList   = m_GetListBrowser->GetValue();

    // (aved in config ):

    // Determine current settings of both radiobutton groups
    s_OutputFormOpt      = m_OutputFormCtrl->GetSelection();
    s_OutputSeparatorOpt = m_OutputSeparatorCtrl->GetSelection();
    if( s_OutputSeparatorOpt < 0 )
        s_OutputSeparatorOpt = 0;

    // Determine current settings of all "Fields to add" checkboxes
    s_Add_FpField_state = m_AddFootprintField->GetValue();
    s_Add_F1_state = m_AddField1->GetValue();
    s_Add_F2_state = m_AddField2->GetValue();
    s_Add_F3_state = m_AddField3->GetValue();
    s_Add_F4_state = m_AddField4->GetValue();
    s_Add_F5_state = m_AddField5->GetValue();
    s_Add_F6_state = m_AddField6->GetValue();
    s_Add_F7_state = m_AddField7->GetValue();
    s_Add_F8_state = m_AddField8->GetValue();
    s_Add_Alls_state = m_AddAllFields->GetValue();

    // Now save current settings of both radiobutton groups
    m_Config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt );
    m_Config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt );
    m_Config->Write( OPTION_BOM_LAUNCH_BROWSER, (long) s_BrowseCreatedList );

    // Now save current settings of all "Fields to add" checkboxes
    long addfields = 0;
    for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
    {
        if( *s_AddFieldList[ii] )
            addfields |= bitmask;
        bitmask <<= 1;
    }

    m_Config->Write( OPTION_BOM_ADD_FIELD, addfields );
}
+11 −49
Original line number Diff line number Diff line
@@ -15,13 +15,14 @@
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"

#include "dialog_SVG_print_base.h"
#include "dcsvg.h"

#include "general.h"
#include "libeditframe.h"
#include "sch_sheet_path.h"

#include "dialog_SVG_print.h"


// Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
@@ -34,58 +35,12 @@ extern BASE_SCREEN* ActiveScreen;
static bool s_Print_Frame_Ref      = true;
static int  s_PlotBlackAndWhite    = 0;

class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
{
private:
    WinEDA_DrawFrame * m_Parent;
    wxConfig* m_Config;

public:
    DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent );
    ~DIALOG_SVG_PRINT( ) {}

private:
	void OnCloseWindow( wxCloseEvent& event );
	void OnInitDialog( wxInitDialogEvent& event );
	void OnButtonPlotCurrentClick( wxCommandEvent& event );
	void OnButtonPlotAllClick( wxCommandEvent& event );
	void OnButtonCancelClick( wxCommandEvent& event );
    void OnSetColorModeSelected( wxCommandEvent& event );
    void SetPenWidth();
    void PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref );
public:
    static bool DrawSVGPage( WinEDA_DrawFrame * frame,
                   const wxString& FullFileName, BASE_SCREEN* screen,
                   bool aPrintBlackAndWhite = false,
                   bool aPrint_Sheet_Ref = false);
};


/* Prepare the data structures of print management and display the dialog
 * window for printing sheets.
 */
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
{
    DIALOG_SVG_PRINT frame( this );

    frame.ShowModal();
}

/* Creates the SVG print file for the current edited component.
 */
void WinEDA_LibeditFrame::SVG_Print_Component( const wxString& FullFileName )
{
    DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() );
}




/*!
 * DIALOG_SVG_PRINT functions
 */
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent )
    : DIALOG_SVG_PRINT_base( parent )
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) :
    DIALOG_SVG_PRINT_base( parent )
{
    m_Parent   = parent;
    m_Config   = wxGetApp().m_EDA_Config;
@@ -108,6 +63,7 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
        ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness,
                               m_Parent->m_InternalUnits ) );
    m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref );

    if( GetSizer() )
    {
        GetSizer()->SetSizeHints( this );
@@ -164,6 +120,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
            if( sheetpath == NULL )
                break;
            list.Clear();

            if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
            {
                schframe->m_CurrentSheet = &list;
@@ -174,6 +131,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
            }
            else  // Should not happen
                return;

            sheetpath = SheetList.GetNext();

            fn = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
@@ -187,6 +145,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
            msg += wxT( "\n" );
            m_MessagesBox->AppendText( msg );
        }

        schframe->m_CurrentSheet = oldsheetpath;
        schframe->m_CurrentSheet->UpdateAllScreenReferences();
        schframe->SetSheetNumberAndCount();
@@ -216,6 +175,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
    ActiveScreen = oldscreen;
}


bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame*   frame,
                                    const wxString&     FullFileName,
                                    BASE_SCREEN*        screen,
@@ -233,6 +193,7 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame,
    old_org    = screen->m_DrawOrg;
    screen->m_DrawOrg.x    = screen->m_DrawOrg.y = 0;
    screen->m_StartVisu.x  = screen->m_StartVisu.y = 0;

    SheetSize = screen->ReturnPageSize();      // page size in 1/1000 inch, ie in internal units

    screen->SetScalingFactor( 1.0 );
@@ -276,6 +237,7 @@ void DIALOG_SVG_PRINT::OnButtonPlotAllClick( wxCommandEvent& event )
    PrintSVGDoc( true, m_Print_Sheet_Ref->GetValue() );
}


void DIALOG_SVG_PRINT::OnButtonPlotCurrentClick( wxCommandEvent& event )
{
    PrintSVGDoc( false, m_Print_Sheet_Ref->GetValue() );
Loading