Commit 768ec258 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Encapsulate LABEL_OBJECT class and message panel window member of EDA_DRAW_FRAME.

parent 0498f265
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
    m_HotkeysZoomAndGridList = NULL;

    DrawPanel             = NULL;
    MsgPanel              = NULL;
    m_messagePanel        = NULL;
    m_currentScreen       = NULL;
    m_toolId              = ID_NO_TOOL_SELECTED;
    m_ID_last_state       = ID_NO_TOOL_SELECTED;
@@ -148,10 +148,10 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
    m_FrameSize.y -= m_MsgFrameHeight;

    DrawPanel = new EDA_DRAW_PANEL( this, -1, wxPoint( 0, 0 ), m_FrameSize );
    MsgPanel  = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
    m_messagePanel  = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
                                         wxSize( m_FrameSize.x, m_MsgFrameHeight ) );

    MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
    m_messagePanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
                                                   ColorRefs[LIGHTGRAY].m_Green,
                                                   ColorRefs[LIGHTGRAY].m_Blue ) );
}
@@ -178,8 +178,8 @@ void EDA_DRAW_FRAME::unitsChangeRefresh()

void EDA_DRAW_FRAME::EraseMsgBox()
{
    if( MsgPanel )
        MsgPanel->EraseMsgBox();
    if( m_messagePanel )
        m_messagePanel->EraseMsgBox();
}


@@ -872,19 +872,19 @@ void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
                                     const wxString& textLower,
                                     int color, int pad )
{
    if( MsgPanel == NULL )
    if( m_messagePanel == NULL )
        return;

    MsgPanel->AppendMessage( textUpper, textLower, color, pad );
    m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
}


void EDA_DRAW_FRAME::ClearMsgPanel( void )
{
    if( MsgPanel == NULL )
    if( m_messagePanel == NULL )
        return;

    MsgPanel->EraseMsgBox();
    m_messagePanel->EraseMsgBox();
}


+32 −5
Original line number Diff line number Diff line
/**********************/
/** displayframe.cpp **/
/**********************/
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2007-2011 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
 */

/**
 * @file class_DisplayFootprintsFrame.cpp
 */

#include "fctsys.h"
#include "appl_wxstruct.h"
@@ -106,7 +131,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
    m_auimgr.AddPane( DrawPanel,
                      wxAuiPaneInfo().Name( wxT( "DisplayFrame" ) ).CentrePane() );

    m_auimgr.AddPane( MsgPanel,
    m_auimgr.AddPane( m_messagePanel,
                      wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );

    m_auimgr.AddPane( m_OptionsToolBar,
@@ -134,6 +159,7 @@ void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
{
    if( m_Draw3DFrame )
        m_Draw3DFrame->Close( true );

    SaveSettings();
    Destroy();
}
@@ -406,6 +432,7 @@ void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
        // This should work on any platform.
        if( m_Draw3DFrame->IsIconized() )
             m_Draw3DFrame->Iconize( false );

        m_Draw3DFrame->Raise();

        // Raising the window does not set the focus on Linux.  This should work on any platform.
+23 −48
Original line number Diff line number Diff line
@@ -41,13 +41,14 @@
#include "template_fieldnames.h"
#include "netlist.h"


/* Fill aList  with labels
 */
void GenListeGLabels( LABEL_OBJECT_LIST& aList )
void GenListeGLabels( BOM_LABEL_LIST& aList )
{
    // Build the sheet list
    SCH_SHEET_LIST sheetList;
    LABEL_OBJECT    label;
    BOM_LABEL      label;

    for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() )
    {
@@ -59,10 +60,7 @@ void GenListeGLabels( LABEL_OBJECT_LIST& aList )
            {
            case SCH_HIERARCHICAL_LABEL_T:
            case SCH_GLOBAL_LABEL_T:
                label.m_LabelType = schItem->Type();
                label.m_SheetPath = *path;
                label.m_Label     = schItem;
                aList.push_back( label );
                aList.push_back( BOM_LABEL( schItem->Type(), schItem, *path ) );
                break;

            case SCH_SHEET_T:
@@ -71,10 +69,7 @@ void GenListeGLabels( LABEL_OBJECT_LIST& aList )

                BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, sheet->GetPins() )
                {
                    label.m_LabelType = SCH_SHEET_PIN_T;
                    label.m_SheetPath = *path;
                    label.m_Label     = &sheetPin;
                    aList.push_back( label );
                    aList.push_back( BOM_LABEL( SCH_SHEET_PIN_T, &sheetPin, *path ) );
                }
            }
            break;
@@ -88,31 +83,21 @@ void GenListeGLabels( LABEL_OBJECT_LIST& aList )
    }
}


/* compare function for sorting labels
 * sort by
 *     value
 *     if same value: by sheet
 */
bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 )
{
    int       ii;
    wxString* Text1, * Text2;

    if( obj1.m_LabelType == SCH_SHEET_PIN_T )
        Text1 = &( (SCH_SHEET_PIN*)(obj1.m_Label) )->m_Text;
    else
        Text1 = &( (SCH_TEXT*)(obj1.m_Label) )->m_Text;

    if( obj2.m_LabelType == SCH_SHEET_PIN_T )
        Text2 = &( (SCH_SHEET_PIN*)(obj2.m_Label) )->m_Text;
    else
        Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text;

    ii = Text1->CmpNoCase( *Text2 );
    ii = obj1.GetText().CmpNoCase( obj2.GetText() );

    if( ii == 0 )
    {
        ii = obj1.m_SheetPath.Cmp( obj2.m_SheetPath );
        ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() );
    }

    return ii < 0;
@@ -123,33 +108,22 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
 *     by sheet
 *     in a sheet, by alphabetic order
 */
bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 )
{
    int      ii;
    wxString Text1, Text2;

    ii = obj1.m_SheetPath.Cmp( obj2.m_SheetPath );
    ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() );

    if( ii == 0 )
    {
        if( obj1.m_LabelType == SCH_SHEET_PIN_T )
            Text1 = ( (SCH_SHEET_PIN*) obj1.m_Label )->m_Text;
        else
            Text1 = ( (SCH_TEXT*) obj1.m_Label )->m_Text;

        if( obj2.m_LabelType == SCH_SHEET_PIN_T )
            Text2 = ( (SCH_SHEET_PIN*) obj2.m_Label )->m_Text;
        else
            Text2 = ( (SCH_TEXT*) obj2.m_Label )->m_Text;

        ii = Text1.CmpNoCase( Text2 );
        ii = obj1.GetText().CmpNoCase( obj2.GetText() );
    }

    return ii < 0;
}


int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )
int PrintListeGLabel( FILE* f, BOM_LABEL_LIST& aList )
{
    SCH_LABEL* label;
    SCH_SHEET_PIN* pinsheet;
@@ -158,20 +132,20 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )

    for( unsigned ii = 0; ii < aList.size(); ii++ )
    {
        switch( aList[ii].m_LabelType )
        switch( aList[ii].GetType() )
        {
        case SCH_HIERARCHICAL_LABEL_T:
        case SCH_GLOBAL_LABEL_T:
            label = (SCH_LABEL*)(aList[ii].m_Label);
            label = (SCH_LABEL*)(aList[ii].GetLabel());

            if( aList[ii].m_LabelType == SCH_HIERARCHICAL_LABEL_T )
            if( aList[ii].GetType() == SCH_HIERARCHICAL_LABEL_T )
                labeltype = wxT( "Hierarchical" );
            else
                labeltype = wxT( "Global      " );

            sheetpath = aList[ii].m_SheetPath.PathHumanReadable();
            sheetpath = aList[ii].GetSheetPath().PathHumanReadable();
            msg.Printf( _( "> %-28.28s %s        (Sheet %s) pos: %3.3f, %3.3f\n" ),
                        GetChars( label->m_Text ),
                        GetChars( label->GetText() ),
                        GetChars( labeltype ),
                        GetChars( sheetpath ),
                        (float) label->m_Pos.x / 1000,
@@ -182,7 +156,7 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )

        case SCH_SHEET_PIN_T:
        {
            pinsheet = (SCH_SHEET_PIN*) aList[ii].m_Label;
            pinsheet = (SCH_SHEET_PIN*) aList[ii].GetLabel();
            int jj = pinsheet->GetShape();

            if( jj < 0 )
@@ -194,14 +168,15 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )
            wxString labtype = FROM_UTF8( SheetLabelType[jj] );

            msg.Printf( _( "> %-28.28s PinSheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f\n" ),
                        GetChars( pinsheet->m_Text ),
                        GetChars( pinsheet->GetText() ),
                        GetChars( labtype ),
                        GetChars( aList[ii].m_SheetPath.PathHumanReadable() ),
                        GetChars( aList[ii].GetSheetPath().PathHumanReadable() ),
                        (float) pinsheet->m_Pos.x / 1000,
                        (float) pinsheet->m_Pos.y / 1000 );

            fputs( TO_UTF8( msg ), f );
        }

        break;

        default:
+85 −39
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_build_BOM.cpp
// Author:      jean-pierre Charras
// Modified by:
// Licence:     GPL
/////////////////////////////////////////////////////////////////////////////
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2008 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 1992-2011 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
 */

/**
 * @file dialog_build_BOM.cpp
 */

#include "fctsys.h"
#include "appl_wxstruct.h"
@@ -29,10 +49,10 @@
#include "protos.h"


extern void GenListeGLabels( std::vector <LABEL_OBJECT>& aList );
extern bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
extern bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
extern int  PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
extern void GenListeGLabels( std::vector <BOM_LABEL>& aList );
extern bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 );
extern bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 );
extern int  PrintListeGLabel( FILE* f, std::vector <BOM_LABEL>& aList );


/* Local variables */
@@ -503,9 +523,10 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
    /*************************************************/
    /* Create list of global labels and pins sheets */
    /*************************************************/
    std::vector <LABEL_OBJECT> listOfLabels;
    std::vector <BOM_LABEL> listOfLabels;

    GenListeGLabels( listOfLabels );

    if( ( itemCount = listOfLabels.size() ) > 0 )
    {
        if( m_GenListLabelsbySheet->GetValue() )
@@ -659,6 +680,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,

    std::string     CmpName;
    wxString        subRef;

#if defined(KICAD_GOST)
    wxString        strCur;
    wxString        strPred;
@@ -683,6 +705,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
        bool isMulti = false;

        LIB_COMPONENT*  entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );

        if( entry )
            isMulti = entry->IsMulti();

@@ -748,21 +771,32 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
#if defined(KICAD_GOST)
        wxString tmpStr = PrintFieldData( comp, CompactForm );
        strCur += tmpStr;

        if ( CompactForm )
        {
            if ( strPred.Len() == 0 )
            {
                CmpNameFirst = CmpName;
            }
            else
            {
                if ( !strCur.IsSameAs(strPred) )
                {
                    switch (amount)
                    {
                case 1: fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );
                    case 1:
                        fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8( strPred ),
                                 s_ExportSeparatorSymbol, amount );
                        break;
                case 2: fprintf( f, "%s,%s%s%c%d\n",CmpNameFirst.c_str(), CmpNameLast.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );

                    case 2:
                        fprintf( f, "%s,%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(),
                                 TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );
                        break;
                default:fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );

                    default:
                        fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(),
                                 TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount );
                        break;
                    }
                    CmpNameFirst = CmpName;
@@ -796,11 +830,19 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
    {
    	switch (amount)
      	{
        	case 1: fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );
        case 1:
            fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8( strPred ),
                     s_ExportSeparatorSymbol, amount );
            break;
	        case 2: fprintf( f, "%s,%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );

        case 2:
            fprintf( f, "%s,%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(),
                     TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount );
            break;
			default:fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), TO_UTF8(strPred), s_ExportSeparatorSymbol, amount );

        default:
            fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(),
                     TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount );
            break;
      	}
	}
@@ -862,6 +904,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL

        refName = aList[ii].GetRef();
        valName = currCmp->GetField( VALUE )->m_Text;

#if defined(KICAD_GOST)
        footName = currCmp->GetField( FOOTPRINT )->m_Text;
        datsName = currCmp->GetField( DATASHEET )->m_Text;
@@ -931,8 +974,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL
        int last_nonempty_field_idx = 0;

        for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
        {
            if ( !dummyCmp.GetField( jj )->m_Text.IsEmpty() )
                last_nonempty_field_idx = jj;
        }

        for( int jj = FIELD1; jj <= last_nonempty_field_idx ; jj++ )
        {
@@ -1010,6 +1055,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
        if( aIncludeSubComponents )
        {
            BASE_SCREEN * screen = (BASE_SCREEN*) DrawLibItem->GetParent();

            if( screen )
            {
                msg = aList[ii].GetSheetPath().PathHumanReadable();
+1 −1
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
    m_auimgr.AddPane( DrawPanel,
                      wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );

    m_auimgr.AddPane( MsgPanel,
    m_auimgr.AddPane( m_messagePanel,
                      wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );

    m_auimgr.Update();
Loading