Commit 515f5fbe authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

*) Introduce "invoke_a_dialog.h" to information hide between top frame

   and various DIALOG classes called from top frames.  See comments in
   {eeschema,pcbnew}/invoke_a_dialog.h.
*) Move some dialog classes into *.cpp files from *.h files.
*) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) was opening the modeless
   ERC dialog more than once if icon was clicked more than once.
*) Remove BOM stuff.
parent 0c5d9fa2
Loading
Loading
Loading
Loading

eeschema/BOM_lister.h.notused

deleted100644 → 0
+0 −188
Original line number Diff line number Diff line
/**
 * @file BOM_lister.h
 */

/* This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2012 Jean-Pierre Charras  jp.charras at wanadoo.fr
 * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.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
 */

#ifndef _BOM_LISTER_H_
#define _BOM_LISTER_H_

#include <netlist.h>


// A helper class to build item lists for BOM,
// and write lists on files
class BOM_LISTER
{
private:
    BOM_LABEL_LIST      m_labelList;            // a list of global and hierarchical labels
    SCH_REFERENCE_LIST  m_cmplist;              // a flat list of components in the full hierarchy
    FILE*               m_outFile;              // the output file for BOM generation
    char                m_separatorSymbol;      // the separator used for csv files ( usually \t ; or , )
    bool                m_outputFmtCsv;         // true to create Csv files, false to create text lists
    bool                m_includeSubComponents; // true to list each part
                                                // of a multiple part per package component
                                                // false to list only once this kind of component
    bool                m_csvForm;              // true to print less verbose component list
                                                // false to print more verbose component list
    bool                m_groupReferences;      // true to group  in list by reference (when possible,
                                                // i.e. when other fields have the same value
                                                // false to list one reference per line
    bool                m_printLocation;        // true to print component location in list by reference
    std::vector <int>   m_fieldIDactive;        // list of field IDs to print

public:
    BOM_LISTER()
    {
        m_outFile = NULL;
        m_separatorSymbol   = '\t';
        m_outputFmtCsv      = false;
        m_includeSubComponents = false;
        m_csvForm = true;
        m_printLocation     = false;
        m_groupReferences   = false;
    }

    // Accessors:
    void SetGroupReferences( bool aGroupRef )
    {
        m_groupReferences = aGroupRef;
    }

    void SetPrintLocation( bool aPrintLoc )
    {
        m_printLocation = aPrintLoc;
    }

    void SetIncludeSubCmp( bool aIncludeSubCmp )
    {
        m_includeSubComponents = aIncludeSubCmp;
    }

    /**
     * Function SetCvsFormOn
     * prepare parameters to create a BOM list in comma separated value (cvs)
     * @param aSeparator = the character used as "csv" separator
     */
    void SetCvsFormOn( char aSeparator )
    {
        m_csvForm = true;
        m_separatorSymbol = aSeparator;
    }

    /**
     * Function SetCvsFormOff
     * prepare parameters to create a BOM list in full text readable mode
     * (not csv format)
     */
    void SetCvsFormOff()
    {
        m_csvForm = false;
    }

    void            AddFieldIdToPrintList( int aFieldId );

    void ClearFieldIdPrintList() { m_fieldIDactive.clear(); }

    /**
     * Function CreateCsvBOMListByValues
     * print the list of components, grouped by values:
     * One line by value. The format is something like:
     *   value;quantity;references;other fields
     *   18pF;2;"C404 C405";SM0402
     *   22nF/25V;4;"C128 C168 C228 C268";SM0402
     * @param aFile = the file to write to (will be closed)
     */
    void            CreateCsvBOMListByValues( FILE* aFile );

    /**
     * Function PrintGlobalAndHierarchicalLabelsList
     * print the list of global and hierarchical labels by sheet or by name
     * @param aSortBySheet = true to print by sheet name order
     *          false to print by label name order
     * @param aFile = the file to write to (will be NOT closed)
     */
    void            PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet );

    /**
     * Function PrintComponentsListByReferenceHumanReadable
     * print a BOM list in human readable form
     * @param aFile = the file to write to (will be NOT closed)
     */
    bool            PrintComponentsListByReferenceHumanReadable( FILE* aFile );

    /**
     * Function PrintComponentsListByReferenceCsvForm
     * print the list of components ordered by references. Generate 2 formats:
     * - full component list in csv form
     * - "short" component list in csv form, grouped by common fields values
     *          (mainly component value)
     * @param aFile = the file to write to (will be NOT closed)
     */
    bool            PrintComponentsListByReferenceCsvForm( FILE* aFile );

    /**
     * Function PrintComponentsListByValue
     * print the list of components, sorted by value, one line per component
     * not useable for csv format (use CreateCsvBOMListByValues instead)
     * @param aFile = the file to write to (will be NOT closed)
     */
    int             PrintComponentsListByValue( FILE* aFile );

private:

    /**
     * Helper function isFieldPrintable
     * @return true if the field aFieldId should be printed.
     * @param aFieldId = the field Id (FOOTPRIN, FIELD4 ...)
     */
    bool            isFieldPrintable( int aFieldId );

    /**
     * Helper function buildGlobalAndHierarchicalLabelsList
     * Populate m_labelList with global and hierarchical labels
     * and sheet pins labels
     */
    void            buildGlobalAndHierarchicalLabelsList();

    /**
     * Helper function returnFieldsString
     * @return a string containing all selected fields texts,
     * @param aComponent = the schematic component
     * separated by the csv separator symbol
     */
    const wxString  returnFieldsString( SCH_COMPONENT* aComponent );

    /**
     * Helper function returnURLItemLocation
     * @param aPathName = the full sheet name of item
     * @param aPosition = a position (in internal units) to print
     * @return a formated string to print the full location:
     * /sheet name/( X Y position)
     */
    const wxString  returnURLItemLocation( const wxString&  aPathName,
                                           wxPoint          aPosition );
};

#endif    // _BOM_LISTER_H_
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ include_directories(

set(EESCHEMA_DLGS
    dialogs/dialog_color_config.cpp
    dialogs/annotate_dialog.cpp
    dialogs/dialog_annotate.cpp
    dialogs/dialog_annotate_base.cpp
    dialogs/dialog_lib_edit_text.cpp
    dialogs/dialog_lib_edit_text_base.cpp

eeschema/build_BOM.cpp.notused

deleted100644 → 0
+0 −736

File deleted.

Preview size limit exceeded, changes collapsed.

+82 −29
Original line number Diff line number Diff line
@@ -33,7 +33,9 @@
#include <wxEeschemaStruct.h>
#include <class_drawpanel.h>

#include <annotate_dialog.h>
#include <invoke_a_dialog.h>
#include <dialog_annotate_base.h>


#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
@@ -41,10 +43,66 @@
#define KEY_ANNOTATE_USE_SILENTMODE wxT( "AnnotateSilentMode" )


class wxConfig;


/**
 * Class DIALOG_ANNOTATE
 */
class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE
{
public:
    DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent );


private:
    SCH_EDIT_FRAME* m_Parent;
    wxConfig*       m_Config;

    /// Initialises member variables
    void InitValues();
    void OnCancelClick( wxCommandEvent& event );
    void OnClearAnnotationCmpClick( wxCommandEvent& event );
    void OnApplyClick( wxCommandEvent& event );

    // User functions:
    bool GetLevel();
    bool GetResetItems();

    /**
     * Function GetSortOrder
     * @return 0 if annotation by X position,
     *         1 if annotation by Y position,
     *         2 if annotation by value
     */
    int GetSortOrder();

    /**
     * Function GetAnnotateAlgo
     * @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
     */
    int GetAnnotateAlgo();

    bool GetAnnotateAutoCloseOpt()
    {
        return m_cbAutoCloseDlg->GetValue();
    }

    bool GetAnnotateSilentMode()
    {
        return m_cbUseSilentMode->GetValue();
    }
};



DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
    : DIALOG_ANNOTATE_BASE( parent )
{
    m_Parent = parent;

    InitValues();
    Layout();
    GetSizer()->SetSizeHints( this );
@@ -52,15 +110,14 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
}


/*********************************/
void DIALOG_ANNOTATE::InitValues()
/*********************************/
{
    m_Config = wxGetApp().GetSettings();
    SetFocus();	// needed to close dialog by escape key

    if( m_Config )
    {
        long option;

        m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0l );
        switch( option )
        {
@@ -111,9 +168,7 @@ void DIALOG_ANNOTATE::InitValues()
}


/*********************************************************/
void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
/*********************************************************/
{
    int         response;
    wxString    message;
@@ -176,13 +231,11 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
}


/************************************************************************/
void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
/************************************************************************/
{
    int         response;

    wxString    message;

    if( GetLevel() )
        message = _( "Clear the existing annotation for the entire schematic?" );
    else
@@ -201,9 +254,7 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
}


/************************************************************/
void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
/************************************************************/
{
    if( IsModal() )
        EndModal( wxID_CANCEL );
@@ -215,44 +266,46 @@ void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event )
}


/**************************************/
bool DIALOG_ANNOTATE::GetLevel( void )
/**************************************/
bool DIALOG_ANNOTATE::GetLevel()
{
    return m_rbEntireSchematic->GetValue();
}

/******************************************/
bool DIALOG_ANNOTATE::GetResetItems( void )
/******************************************/

bool DIALOG_ANNOTATE::GetResetItems()
{
    return m_rbResetAnnotation->GetValue();
}

int DIALOG_ANNOTATE::GetSortOrder( void )
/**
 * @return 0 if annotation by X position,
 *         1 if annotation by Y position,
 *         2 if annotation by value
 */

int DIALOG_ANNOTATE::GetSortOrder()
{
    if( m_rbSortBy_X_Position->GetValue() )
        return 0;

    if( m_rbSortBy_Y_Position->GetValue() )
        return 1;

    return 2;
}

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
 */

int DIALOG_ANNOTATE::GetAnnotateAlgo()
{
    if( m_rbUseIncremental->GetValue() )
        return 0;

    if( m_rbUseSheetNum->GetValue() )
        return 1;

    return 2;
}


int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller )
{
    DIALOG_ANNOTATE dlg( aCaller );

    return dlg.ShowModal();
}
+0 −591

File deleted.

Preview size limit exceeded, changes collapsed.

Loading