Commit 1047e60e authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Encapsulate SCH_POLYLINE, SCH_SHEET, and SCH_TEXT classes.

parent eb52f4ba
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
// Name:     build_BOM.cpp
// Author:   jean-pierre Charras
// License:  GPL license
/////////////////////////////////////////////////////////////////////////////
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * 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 build_BOM.cpp
 * @brief Code used to generate bill of materials.
 */

#include <algorithm> // to use sort vector
#include <vector>
@@ -159,7 +183,7 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )
        case SCH_SHEET_PIN_T:
        {
            pinsheet = (SCH_SHEET_PIN*) aList[ii].m_Label;
            int jj = pinsheet->m_Shape;
            int jj = pinsheet->GetShape();

            if( jj < 0 )
                jj = NET_TMAX;
+5 −5
Original line number Diff line number Diff line
@@ -424,18 +424,18 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
        endpos = screen->GetCrossHairPosition();

        int idx = polyLine->GetCornerCount() - 1;
        wxPoint pt = (*polyLine)[idx];

        if( g_HVLines )
        {
            /* Coerce the line to vertical or horizontal one: */
            if( ABS( endpos.x - polyLine->m_PolyPoints[idx].x ) <
                ABS( endpos.y - polyLine->m_PolyPoints[idx].y ) )
                endpos.x = polyLine->m_PolyPoints[idx].x;
            if( ABS( endpos.x - pt.x ) < ABS( endpos.y - pt.y ) )
                endpos.x = pt.x;
            else
                endpos.y = polyLine->m_PolyPoints[idx].y;
                endpos.y = pt.y;
        }

        polyLine->m_PolyPoints[idx] = endpos;
        polyLine->SetPoint( idx, endpos );
        polyLine->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
    }
    else
+40 −9
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_edit_label.cpp
// Author:      jean-pierre Charras
// Modified by:
// Created:     18/12/2008 15:46:26
// 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) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * 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 sch_text.h
 * @brief Implementation of the label properties dialog.
 */

#include "fctsys.h"
#include "wx/valgen.h"
@@ -98,6 +120,7 @@ void DialogLabelEditor::InitDialog()
    int MINTEXTWIDTH = 40;    // M's are big characters, a few establish a lot of width

    int max_len = 0;

    if ( !multiLine )
    {
        max_len =m_CurrentText->m_Text.Length();
@@ -108,6 +131,7 @@ void DialogLabelEditor::InitDialog()
        // we cannot use the length of the entire text that has no meaning
        int curr_len = MINTEXTWIDTH;
        int imax = m_CurrentText->m_Text.Len();

        for( int count = 0; count < imax; count++ )
        {
            if( m_CurrentText->m_Text[count] == '\n' ||
@@ -118,11 +142,13 @@ void DialogLabelEditor::InitDialog()
            else
            {
                curr_len++;

                if ( max_len < curr_len )
                    max_len = curr_len;
            }
        }
    }

    if( max_len < MINTEXTWIDTH )
        max_len = MINTEXTWIDTH;

@@ -132,11 +158,13 @@ void DialogLabelEditor::InitDialog()

    // Set validators
    m_TextOrient->SetSelection( m_CurrentText->GetOrientation() );
    m_TextShape->SetSelection( m_CurrentText->m_Shape );
    m_TextShape->SetSelection( m_CurrentText->GetShape() );

    int style = 0;

    if( m_CurrentText->m_Italic )
        style = 1;

    if( m_CurrentText->m_Bold )
        style += 2;

@@ -203,6 +231,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
    m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );

    text = m_textLabel->GetValue();

    if( !text.IsEmpty() )
        m_CurrentText->m_Text = text;
    else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
@@ -212,10 +241,12 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
    text  = m_TextSize->GetValue();
    value = ReturnValueFromString( g_UserUnit, text, m_Parent->m_InternalUnits );
    m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;

    if( m_TextShape )
        m_CurrentText->m_Shape = m_TextShape->GetSelection();
        m_CurrentText->SetShape( m_TextShape->GetSelection() );

    int style = m_TextStyle->GetSelection();

    if( ( style & 1 ) )
        m_CurrentText->m_Italic = 1;
    else
+4 −4
Original line number Diff line number Diff line
@@ -87,12 +87,12 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )

    case LAYER_HIERLABEL:
        textItem = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() );
        textItem->m_Shape = lastGlobalLabelShape;
        textItem->SetShape( lastGlobalLabelShape );
        break;

    case LAYER_GLOBLABEL:
        textItem = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() );
        textItem->m_Shape = lastGlobalLabelShape;
        textItem->SetShape( lastGlobalLabelShape );
        break;

    default:
@@ -121,7 +121,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )

    if( (aType == SCH_GLOBAL_LABEL_T) || (aType == SCH_HIERARCHICAL_LABEL_T) )
    {
        lastGlobalLabelShape = textItem->m_Shape;
        lastGlobalLabelShape = textItem->GetShape();
    }

    textItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
@@ -207,7 +207,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
     * text item type.
     */
    newtext->SetFlags( text->GetFlags() );
    newtext->m_Shape = text->m_Shape;
    newtext->SetShape( text->GetShape() );
    newtext->SetOrientation( text->GetOrientation() );
    newtext->m_Size = text->m_Size;
    newtext->m_Thickness = text->m_Thickness;
+4 −4
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ int TestDuplicateSheetNames( bool aCreateMarker )
                    continue;

                // We have found a second sheet: compare names
                if( ( (SCH_SHEET*) item )->m_SheetName.CmpNoCase(
                        ( ( SCH_SHEET* ) test_item )-> m_SheetName ) == 0 )
                if( ( (SCH_SHEET*) item )->GetName().CmpNoCase(
                        ( ( SCH_SHEET* ) test_item )->GetName() ) == 0 )
                {
                    if( aCreateMarker )
                    {
@@ -206,9 +206,9 @@ int TestDuplicateSheetNames( bool aCreateMarker )
                        SCH_MARKER* marker = new SCH_MARKER();
                        marker->m_TimeStamp = GetNewTimeStamp();
                        marker->SetData( ERCE_DUPLICATE_SHEET_NAME,
                                         ( (SCH_SHEET*) test_item )->m_Pos,
                                         ( (SCH_SHEET*) test_item )->GetPosition(),
                                         _( "Duplicate sheet name" ),
                                         ( (SCH_SHEET*) test_item )->m_Pos );
                                         ( (SCH_SHEET*) test_item )->GetPosition() );
                        marker->SetMarkerType( MARK_ERC );
                        marker->SetErrorLevel( ERR );
                        marker->SetNext( screen->GetDrawItems() );
Loading