2019-07-16 19:34:07 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Alexander Shuklin, jasuramme@gmail.com
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-07-16 19:34:07 +00:00
|
|
|
*
|
|
|
|
* 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 _DIALOG_BOARD_STATISTICS_H
|
|
|
|
#define _DIALOG_BOARD_STATISTICS_H
|
|
|
|
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2019-07-16 19:34:07 +00:00
|
|
|
#include <dialog_board_statistics_base.h>
|
|
|
|
#include <pad_shapes.h>
|
|
|
|
#include <pcb_base_frame.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
2019-07-22 19:04:09 +00:00
|
|
|
#include <project.h>
|
|
|
|
#include <wx/datetime.h>
|
2019-07-16 19:34:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dialog to show common board info.
|
|
|
|
*/
|
|
|
|
class DIALOG_BOARD_STATISTICS : public DIALOG_BOARD_STATISTICS_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Type information, which will be shown in dialog.
|
2019-07-16 19:34:07 +00:00
|
|
|
*/
|
2019-07-22 19:04:09 +00:00
|
|
|
template <typename T>
|
2022-09-27 11:23:38 +00:00
|
|
|
struct LINE_ITEM
|
2019-07-16 19:34:07 +00:00
|
|
|
{
|
2022-09-27 11:23:38 +00:00
|
|
|
LINE_ITEM<T>( T aAttribute, const wxString& aTitle ) :
|
2022-09-27 10:50:14 +00:00
|
|
|
attribute( aAttribute ),
|
|
|
|
title( aTitle ),
|
|
|
|
qty( 0 )
|
2019-07-16 19:34:07 +00:00
|
|
|
{
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2019-07-22 19:04:09 +00:00
|
|
|
T attribute;
|
2019-07-16 19:34:07 +00:00
|
|
|
wxString title;
|
|
|
|
int qty;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Footprint attributes (such as SMD, THT, Virtual and so on), which will be shown in the
|
2022-09-27 10:50:14 +00:00
|
|
|
* dialog. Holds both front and back footprint quantities.
|
2019-07-16 19:34:07 +00:00
|
|
|
*/
|
2022-09-27 11:23:38 +00:00
|
|
|
struct FP_LINE_ITEM
|
2019-07-16 19:34:07 +00:00
|
|
|
{
|
2022-09-27 11:23:38 +00:00
|
|
|
FP_LINE_ITEM( int aAttributeMask, int aAttributeValue, wxString aTitle ) :
|
2022-09-27 10:50:14 +00:00
|
|
|
attribute_mask( aAttributeMask ),
|
|
|
|
attribute_value( aAttributeValue ),
|
|
|
|
title( aTitle ),
|
|
|
|
frontSideQty( 0 ),
|
|
|
|
backSideQty( 0 )
|
2019-07-16 19:34:07 +00:00
|
|
|
{
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2022-09-27 10:50:14 +00:00
|
|
|
int attribute_mask;
|
|
|
|
int attribute_value;
|
|
|
|
wxString title;
|
|
|
|
int frontSideQty;
|
|
|
|
int backSideQty;
|
2019-07-16 19:34:07 +00:00
|
|
|
};
|
|
|
|
|
2022-09-27 11:23:38 +00:00
|
|
|
struct DRILL_LINE_ITEM
|
2019-11-10 20:30:58 +00:00
|
|
|
{
|
|
|
|
enum COL_ID
|
|
|
|
{
|
|
|
|
COL_COUNT,
|
|
|
|
COL_SHAPE,
|
|
|
|
COL_X_SIZE,
|
|
|
|
COL_Y_SIZE,
|
|
|
|
COL_PLATED,
|
|
|
|
COL_VIA_PAD,
|
|
|
|
COL_START_LAYER,
|
|
|
|
COL_STOP_LAYER
|
|
|
|
};
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2022-09-27 11:23:38 +00:00
|
|
|
DRILL_LINE_ITEM( int aXSize, int aYSize, PAD_DRILL_SHAPE_T aShape, bool aIsPlated,
|
|
|
|
bool aIsPad, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aStopLayer ) :
|
2022-09-27 10:50:14 +00:00
|
|
|
xSize( aXSize ),
|
|
|
|
ySize( aYSize ),
|
|
|
|
shape( aShape ),
|
|
|
|
isPlated( aIsPlated ),
|
|
|
|
isPad( aIsPad ),
|
|
|
|
startLayer( aStartLayer ),
|
|
|
|
stopLayer( aStopLayer ),
|
2022-09-27 11:23:38 +00:00
|
|
|
qty( 0 )
|
2019-11-10 20:30:58 +00:00
|
|
|
{
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-06-20 20:35:03 +00:00
|
|
|
bool operator==( const DRILL_LINE_ITEM& other ) const
|
2019-11-10 20:30:58 +00:00
|
|
|
{
|
|
|
|
return xSize == other.xSize && ySize == other.ySize && shape == other.shape
|
|
|
|
&& isPlated == other.isPlated && isPad == other.isPad
|
|
|
|
&& startLayer == other.startLayer && stopLayer == other.stopLayer;
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2019-11-10 20:30:58 +00:00
|
|
|
struct COMPARE
|
|
|
|
{
|
|
|
|
COMPARE( COL_ID aColId, bool aAscending ) : colId( aColId ), ascending( aAscending )
|
|
|
|
{
|
|
|
|
}
|
2022-09-27 11:23:38 +00:00
|
|
|
bool operator()( const DRILL_LINE_ITEM& aLeft, const DRILL_LINE_ITEM& aRight )
|
2019-11-10 20:30:58 +00:00
|
|
|
{
|
|
|
|
switch( colId )
|
|
|
|
{
|
|
|
|
case COL_COUNT:
|
|
|
|
return compareDrillParameters( aLeft.qty, aRight.qty );
|
|
|
|
case COL_SHAPE:
|
|
|
|
return compareDrillParameters( aLeft.shape, aRight.shape );
|
|
|
|
case COL_X_SIZE:
|
|
|
|
return compareDrillParameters( aLeft.xSize, aRight.xSize );
|
|
|
|
case COL_Y_SIZE:
|
|
|
|
return compareDrillParameters( aLeft.ySize, aRight.ySize );
|
|
|
|
case COL_PLATED:
|
|
|
|
return ascending ? aLeft.isPlated : aRight.isPlated;
|
|
|
|
case COL_VIA_PAD:
|
|
|
|
return ascending ? aLeft.isPad : aRight.isPad;
|
|
|
|
case COL_START_LAYER:
|
|
|
|
return compareDrillParameters( aLeft.startLayer, aRight.startLayer );
|
|
|
|
case COL_STOP_LAYER:
|
|
|
|
return compareDrillParameters( aLeft.stopLayer, aRight.stopLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2019-11-10 20:30:58 +00:00
|
|
|
bool compareDrillParameters( int aLeft, int aRight )
|
|
|
|
{
|
|
|
|
return ascending ? aLeft < aRight : aLeft > aRight;
|
|
|
|
}
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2019-11-10 20:30:58 +00:00
|
|
|
COL_ID colId;
|
|
|
|
bool ascending;
|
|
|
|
};
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2019-11-10 20:30:58 +00:00
|
|
|
int xSize;
|
|
|
|
int ySize;
|
|
|
|
PAD_DRILL_SHAPE_T shape;
|
|
|
|
bool isPlated;
|
|
|
|
bool isPad;
|
|
|
|
PCB_LAYER_ID startLayer;
|
|
|
|
PCB_LAYER_ID stopLayer;
|
|
|
|
int qty;
|
|
|
|
};
|
|
|
|
|
2019-07-16 19:34:07 +00:00
|
|
|
DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame );
|
|
|
|
~DIALOG_BOARD_STATISTICS();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Get data from the PCB board and print it to dialog
|
2019-07-16 19:34:07 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
|
|
|
|
private:
|
2019-07-22 19:04:09 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Function to fill up all items types to be shown in the dialog.
|
2019-11-10 20:30:58 +00:00
|
|
|
void refreshItemsTypes();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Get data from board.
|
2019-11-10 20:30:58 +00:00
|
|
|
void getDataFromPCB();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Apply data to dialog widgets.
|
2019-11-10 20:30:58 +00:00
|
|
|
void updateWidets();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Update drills grid.
|
2019-11-10 20:30:58 +00:00
|
|
|
void updateDrillGrid();
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Print grid to string in tabular format.
|
2022-09-27 10:50:14 +00:00
|
|
|
void printGridToStringAsTable( wxGrid* aGrid, wxString& aStr, bool aUseColLabels,
|
|
|
|
bool aUseFirstColAsLabel );
|
2019-11-10 20:30:58 +00:00
|
|
|
|
|
|
|
void adjustDrillGridColumns();
|
|
|
|
|
|
|
|
void checkboxClicked( wxCommandEvent& aEvent ) override;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Save board statistics to a file
|
2019-11-10 20:30:58 +00:00
|
|
|
void saveReportClicked( wxCommandEvent& aEvent ) override;
|
|
|
|
|
|
|
|
void drillGridSize( wxSizeEvent& aEvent ) override;
|
|
|
|
|
|
|
|
void drillGridSort( wxGridEvent& aEvent );
|
2021-01-27 22:15:38 +00:00
|
|
|
|
|
|
|
PCB_EDIT_FRAME* m_parentFrame;
|
|
|
|
|
|
|
|
int m_boardWidth;
|
|
|
|
int m_boardHeight;
|
|
|
|
double m_boardArea;
|
|
|
|
|
2022-09-27 10:50:14 +00:00
|
|
|
bool m_hasOutline; ///< Show if board outline properly defined.
|
2022-02-15 16:17:37 +00:00
|
|
|
|
2022-09-27 11:23:38 +00:00
|
|
|
std::deque<FP_LINE_ITEM> m_fpTypes;
|
|
|
|
std::deque<LINE_ITEM<PAD_ATTRIB>> m_padTypes;
|
|
|
|
std::deque<LINE_ITEM<VIATYPE>> m_viaTypes;
|
|
|
|
std::deque<DRILL_LINE_ITEM> m_drillTypes;
|
2022-02-15 16:17:37 +00:00
|
|
|
|
2022-09-27 10:50:14 +00:00
|
|
|
int m_startLayerColInitialSize; ///< Width of the start layer column as calculated by
|
|
|
|
///< the wxWidgets autosizing algorithm.
|
|
|
|
int m_stopLayerColInitialSize; ///< Width of the stop layer column.
|
2019-07-16 19:34:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __DIALOG_BOARD_STATISTICS_H
|