diff --git a/common/legacy_gal/other.cpp b/common/legacy_gal/other.cpp index 7fe3938fff..5eb7da2a94 100644 --- a/common/legacy_gal/other.cpp +++ b/common/legacy_gal/other.cpp @@ -9,7 +9,6 @@ -void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { } diff --git a/common/legacy_wx/other.cpp b/common/legacy_wx/other.cpp index fd15a1dae3..a68f128ff9 100644 --- a/common/legacy_wx/other.cpp +++ b/common/legacy_wx/other.cpp @@ -8,8 +8,7 @@ #include "dialog_display_info_HTML_base.h" -void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) +void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { // Build the marker shape polygon in internal units: const int ccount = GetShapePolygonCornerCount(); @@ -17,10 +16,10 @@ void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDr shape.reserve( ccount ); for( int ii = 0; ii < ccount; ii++ ) + { shape.push_back( wxPoint( GetShapePolygonCorner( ii ).x * MarkerScale(), GetShapePolygonCorner( ii ).y * MarkerScale() ) ); - - GRSetDrawMode( aDC, aDrawMode ); + } for( int ii = 0; ii < ccount; ii++ ) { @@ -33,9 +32,4 @@ void MARKER_BASE::DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDr m_Color, // outline color m_Color // fill collor ); - -#if 0 // For testing purpose only: - EDA_RECT bbox = GetBoundingBoxMarker(); - GRRect( aPanel->GetClipBox(), aDC, bbox, 10, m_Color ); -#endif } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 27bef5fede..17e3eba558 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -154,7 +154,6 @@ set( EESCHEMA_SRCS edit_bitmap.cpp edit_component_in_schematic.cpp edit_label.cpp - eeredraw.cpp eeschema.cpp eeschema_config.cpp erc.cpp diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 0a96f849db..9eab960f0c 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -368,32 +368,19 @@ void LIB_PART::SetName( const wxString& aName ) void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, - int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ) + int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ) { - BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL; - GRSetDrawMode( aDc, aOpts.draw_mode ); - /* draw background for filled items using background option * Solid lines will be drawn after the background - * Note also, background is not drawn when: - * printing in black and white - * If the color is not the default color (aColor != -1 ) + * Note also, background is not drawn when printing in black and white */ - if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() ) - && ( aOpts.color == COLOR4D::UNSPECIFIED ) ) + if( ! GetGRForceBlackPenState() ) { for( LIB_ITEM& drawItem : m_drawings ) { if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR ) continue; - if( aOpts.only_selected && !drawItem.IsSelected() ) - continue; - - // Do not draw an item while moving (the cursor handler does that) - if( drawItem.m_Flags & IS_MOVED ) - continue; - // Do not draw items not attached to the current part if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) ) continue; @@ -404,31 +391,14 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, if( drawItem.Type() == LIB_FIELD_T ) continue; - if( drawItem.Type() == LIB_FIELD_T ) // TODO dead code? - { - drawItem.Draw( aPanel, aDc, aOffset, aOpts.color, - aOpts.draw_mode, (void*) NULL, aOpts.transform ); - } - // Now, draw only the background for items with // m_Fill == FILLED_WITH_BG_BODYCOLOR: - drawItem.Draw( aPanel, aDc, aOffset, aOpts.color, - aOpts.draw_mode, (void*) false, aOpts.transform ); + drawItem.Draw( aPanel, aDc, aOffset, (void*) false, aOpts.transform ); } } - // Track the index into the dangling pins list - size_t pin_index = 0; - for( LIB_ITEM& drawItem : m_drawings ) { - if( aOpts.only_selected && !drawItem.IsSelected() ) - continue; - - // Do not draw an item while moving (the cursor handler does that) - if( drawItem.m_Flags & IS_MOVED ) - continue; - // Do not draw items not attached to the current part if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) ) continue; @@ -449,60 +419,18 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, if( drawItem.Type() == LIB_PIN_T ) { - LIB_PIN& pin = static_cast( drawItem ); - - uintptr_t flags = 0; - if( aOpts.show_pin_text ) - flags |= PIN_DRAW_TEXTS; - - if( aOpts.show_elec_type ) - flags |= PIN_DRAW_ELECTRICAL_TYPE_NAME; - - if( aOpts.PinIsDangling( pin_index ) ) - flags |= PIN_DRAW_DANGLING; - - if( pin.IsPowerConnection() && IsPower() ) - flags |= PIN_DANGLING_HIDDEN; - - drawItem.Draw( aPanel, aDc, aOffset, aOpts.color, - aOpts.draw_mode, (void*) flags, aOpts.transform ); - - ++pin_index; + drawItem.Draw( aPanel, aDc, aOffset, (void*) aOpts.show_elec_type, aOpts.transform ); } else if( drawItem.Type() == LIB_FIELD_T ) { - drawItem.Draw( aPanel, aDc, aOffset, aOpts.color, - aOpts.draw_mode, (void*) NULL, aOpts.transform ); + drawItem.Draw( aPanel, aDc, aOffset, (void*) NULL, aOpts.transform ); } else { bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR; - drawItem.Draw( aPanel, aDc, aOffset, aOpts.color, - aOpts.draw_mode, (void*) forceNoFill, - aOpts.transform ); + drawItem.Draw( aPanel, aDc, aOffset, (void*) forceNoFill, aOpts.transform ); } } - - // Enable this to draw the anchor of the component. -#if 0 - int len = aDc->DeviceToLogicalXRel( 3 ); - EDA_RECT* const clipbox = aPanel ? aPanel->GetClipBox() : NULL; - - GRLine( clipbox, aDc, aOffset.x, aOffset.y - len, aOffset.x, - aOffset.y + len, 0, aOpts.color ); - GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len, - aOffset.y, 0, aOpts.color ); -#endif - - /* Enable this to draw the bounding box around the component to validate - * the bounding box calculations. */ -#if 0 - EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert ); - bBox.RevertYAxis(); - bBox = aOpts.transform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox, 0, LIGHTMAGENTA ); -#endif } @@ -612,10 +540,6 @@ void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aD { if( *i == aItem ) { - if( aDc != NULL ) - aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, - g_XorMode, NULL, DefaultTransform ); - items.erase( i ); SetModified(); break; diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index dcca4e029b..370e984bcd 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -203,37 +203,20 @@ extern bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 ); struct PART_DRAW_OPTIONS { - GR_DRAWMODE draw_mode; ///< Device context drawing mode, see wxDC - COLOR4D color; ///< Color to draw part in TRANSFORM transform; ///< Coordinate adjustment settings - bool show_pin_text; ///< Whether to show pin texts bool draw_visible_fields; ///< Whether to draw "visible" fields bool draw_hidden_fields; ///< Whether to draw "hidden" fields - bool only_selected; ///< Draws only the body items that are selected, for block moves - std::vector dangling; ///< which pins should display as dangling, or empty for All bool show_elec_type; ///< Whether to show the pin electrical type static PART_DRAW_OPTIONS Default() { PART_DRAW_OPTIONS def; - def.draw_mode = GR_DEFAULT_DRAWMODE; - def.color = COLOR4D::UNSPECIFIED; def.transform = DefaultTransform; - def.show_pin_text = true; def.draw_visible_fields = true; def.draw_hidden_fields = true; - def.only_selected = false; def.show_elec_type = false; return def; } - - bool PinIsDangling( size_t aPin ) const - { - if( aPin < dangling.size() ) - return dangling[aPin]; - else - return true; - } }; @@ -466,8 +449,7 @@ public: * @param aOpts - Drawing options */ void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, - int aMulti, int aConvert, - const PART_DRAW_OPTIONS& aOpts ); + int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts ); /** * Plot lib part to plotter. diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 13d96f5ae7..fb3374e03a 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -169,11 +169,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) dc.SetUserScale( scale, scale ); GRResetPenAndBrush( &dc ); - // This is a flag for m_dummyPin->Draw - uintptr_t flags = uintptr_t( PIN_DRAW_TEXTS | PIN_DRAW_DANGLING ); - - m_dummyPin->Draw( nullptr, &dc, -bBox.Centre(), COLOR4D::UNSPECIFIED, GR_COPY, (void*)flags, - DefaultTransform ); + m_dummyPin->Draw( nullptr, &dc, -bBox.Centre(), (void*)0, DefaultTransform ); m_dummyPin->SetParent( nullptr ); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index ec126590d8..c3d9c0e1b0 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -428,6 +428,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) #endif OffsetLogicalOrigin( xoffset, yoffset ); + GRSetDrawMode( dc, GR_DEFAULT_DRAWMODE ); GRResetPenAndBrush( dc ); if( m_parent->GetPrintMonochrome() ) @@ -437,7 +438,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) COLOR4D bgColor = m_parent->GetDrawBgColor(); - aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 ); + aScreen->Draw( panel, dc ); if( printReference ) m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(), diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp deleted file mode 100644 index 24b8995254..0000000000 --- a/eeschema/eeredraw.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2009-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.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 eeredraw.cpp - */ - -#include -#include -#include -#include -#include - - -void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, const COLOR4D& Color ) -{ - BASE_SCREEN* screen = panel->GetScreen(); - - if( !screen->m_IsPrinting ) /* Draw but do not print the Dangling Symbol */ - { - GRRect( panel->GetClipBox(), DC, - pos.x - DANGLING_SYMBOL_SIZE, pos.y - DANGLING_SYMBOL_SIZE, - pos.x + DANGLING_SYMBOL_SIZE, pos.y + DANGLING_SYMBOL_SIZE, - 0, Color ); - } -} - - -/* - * Redraws only the active window which is assumed to be whole visible. - */ -void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) -{ - if( GetScreen() == NULL ) - return; - - if( m_canvas->IsMouseCaptured() ) - m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); - - // Display the sheet filename, and the sheet path, for non root sheets - UpdateTitle(); -} diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index b1156d0f07..d6f6083e1e 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -325,28 +325,7 @@ int LIB_ARC::GetPenSize() const } -void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) -{ - // The edit indicators only get drawn when a new arc is being drawn. - if( !IsNew() ) - return; - - // Use the last edit state so when the drawing switches from the end mode to the center - // point mode, the last line between the center points gets erased. - if( m_lastEditState == 1 ) - { - GRLine( aClipBox, aDC, m_ArcStart.x, -m_ArcStart.y, m_ArcEnd.x, -m_ArcEnd.y, 0, aColor ); - } - else - { - GRDashedLine( aClipBox, aDC, m_ArcStart.x, -m_ArcStart.y, m_Pos.x, -m_Pos.y, 0, aColor ); - GRDashedLine( aClipBox, aDC, m_ArcEnd.x, -m_ArcEnd.y, m_Pos.x, -m_Pos.y, 0, aColor ); - } -} - - -void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, +void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { // Don't draw the arc until the end point is selected. Only the edit indicators @@ -355,17 +334,8 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf return; wxPoint pos1, pos2, posc; - COLOR4D color = GetLayerColor( LAYER_DEVICE ); - - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } + COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); pos1 = aTransform.TransformCoordinate( m_ArcEnd ) + aOffset; pos2 = aTransform.TransformCoordinate( m_ArcStart ) + aOffset; @@ -380,21 +350,14 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf std::swap( pos1.y, pos2.y ); } - GRSetDrawMode( aDC, aDrawMode ); - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor != COLOR4D::UNSPECIFIED ) - fill = NO_FILL; - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) { - GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, - m_Radius, GetPenSize( ), - (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), - GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, GetPenSize( ), + bgColor, bgColor ); } else if( fill == FILLED_SHAPE && !aData ) { @@ -404,26 +367,9 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf else { -#ifdef DRAW_ARC_WITH_ANGLE - - GRArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, - GetPenSize(), color ); -#else - - GRArc1( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - posc.x, posc.y, GetPenSize(), color ); -#endif + GRArc1( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, GetPenSize(), + color ); } - - /* Set to one (1) to draw bounding box around arc to validate bounding box - * calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif } diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 99071b9f91..5df62c2498 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -60,15 +60,9 @@ class LIB_ARC : public LIB_ITEM /** * Draws the arc. */ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; - /** - * Draw the graphics when the arc is being edited. - */ - void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) override; - /** * Calculates the center, radius, and angles at \a aPosition when the arc is being edited. * diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index ce6a4213e2..43fe71cac5 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -229,12 +229,12 @@ int LIB_BEZIER::GetPenSize() const void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) + void* aData, const TRANSFORM& aTransform ) { std::vector PolyPointsTraslated; - COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); BEZIER_POLY converter( m_BezierPoints ); converter.GetPoly( m_PolyPoints ); @@ -244,43 +244,25 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& PolyPointsTraslated.push_back( aTransform.TransformCoordinate( m_PolyPoints[i] ) + aOffset ); - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor != COLOR4D::UNSPECIFIED ) - fill = NO_FILL; - - GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), - &PolyPointsTraslated[0], 1, GetPenSize(), - (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), - GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + { + GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 1, GetPenSize(), + bgColor, bgColor ); + } else if( fill == FILLED_SHAPE ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), - &PolyPointsTraslated[0], 1, GetPenSize(), color, color ); + { + GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 1, GetPenSize(), + color, color ); + } else - GRPoly( clipbox, aDC, m_PolyPoints.size(), - &PolyPointsTraslated[0], 0, GetPenSize(), color, color ); - - /* Set to one (1) to draw bounding box around bezier curve to validate - * bounding box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - GRRect( aPanel->GetClipBox(), aDC, bBox.GetOrigin().x, bBox.GetOrigin().y, - bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA ); -#endif + { + GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 0, GetPenSize(), + color, color ); + } } diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index e22004a834..d4d9fba8ab 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -42,8 +42,7 @@ class LIB_BEZIER : public LIB_ITEM std::vector m_BezierPoints; // list of parameter (3|4) std::vector m_PolyPoints; // list of points (>= 2) - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; public: diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index e9bf26c3b9..8993996d04 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -181,49 +181,21 @@ int LIB_CIRCLE::GetPenSize() const void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) + void* aData, const TRANSFORM& aTransform ) { - wxPoint pos1; - - COLOR4D color = GetLayerColor( LAYER_DEVICE ); - - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - - pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; - GRSetDrawMode( aDC, aDrawMode ); - - FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor != COLOR4D::UNSPECIFIED ) - fill = NO_FILL; + wxPoint pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; + COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); + FILL_T fill = aData ? NO_FILL : m_Fill; EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; + if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), - (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), - GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), bgColor, bgColor ); else if( fill == FILLED_SHAPE ) GRFilledCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, 0, color, color ); else GRCircle( clipbox, aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), color ); - - /* Set to one (1) to draw bounding box around circle to validate bounding - * box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif } diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index ff46161461..ace76a0b16 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -38,8 +38,7 @@ class LIB_CIRCLE : public LIB_ITEM wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments). int m_Width; // Line width. - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; void CalcEdit( const wxPoint& aPosition ) override; diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index 381ce9b392..33c2ee71cf 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -37,8 +37,6 @@ const int fill_tab[3] = { 'N', 'F', 'f' }; -//#define DRAW_ARC_WITH_ANGLE // Used to draw arcs - LIB_ITEM::LIB_ITEM( KICAD_T aType, LIB_PART* aComponent, @@ -111,45 +109,10 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const } -void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, - GR_DRAWMODE aDrawMode, void* aData, +void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { - #if 0 - if( InEditMode() ) - { - // Temporarily disable filling while the item is being edited. - FILL_T fillMode = m_Fill; - COLOR4D color = GetDefaultColor(); - - m_Fill = NO_FILL; - -#ifndef USE_WX_OVERLAY - // Erase the old items using the previous attributes. - if( m_eraseLastDrawItem ) - { - GRSetDrawMode( aDC, g_XorMode ); - drawEditGraphics( aPanel->GetClipBox(), aDC, color ); - drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, - aTransform ); - } -#endif - // Calculate the new attributes at the current cursor position. - CalcEdit( aOffset ); - - // Draw the items using the new attributes. - drawEditGraphics( aPanel->GetClipBox(), aDC, color ); - drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, - aTransform ); - - m_Fill = fillMode; - } - else - #endif - { - drawGraphic( aPanel, aDC, aOffset, aColor, aDrawMode, aData, aTransform ); - } + drawGraphic( aPanel, aDC, aOffset, aData, aTransform ); } diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 6b02c705f2..36db15cafa 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -74,27 +74,12 @@ class LIB_ITEM : public EDA_ITEM * @param aDC A pointer to the device context used to draw the object. * @param aOffset A reference to a wxPoint object containing the offset where to draw * from the object's current position. - * @param aColor A COLOR4D to draw the object or COLOR4D::UNSPECIFIED to draw - * the object in it's default color. - * @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.). * @param aData A pointer to any object specific data required to perform the draw. * @param aTransform A reference to a #TRANSFORM object containing drawing transform. */ - virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, - GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) = 0; + virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, + void* aData, const TRANSFORM& aTransform ) = 0; - /** - * Draw any editing specific graphics when the item is being edited. - * - * @param aClipBox Clip box of the current device context. - * @param aDC The device context to draw on. - * @param aColor Draw color - */ - virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) {} - - friend class LIB_PART; protected: @@ -198,16 +183,13 @@ public: * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes. * @param aDC Device Context (can be null) * @param aOffset Offset to draw - * @param aColor Draw color, or COLOR4D::UNSPECIFIED to use the normal body item color - * @param aDrawMode GR_OR, GR_XOR, ... * @param aData Value or pointer used to pass others parameters, depending on body items. * Used for some items to force to force no fill mode ( has meaning only for * items what can be filled ). used in printing or moving objects mode or to * pass reference to the lib component for pins. * @param aTransform Transform Matrix (rotation, mirror ..) */ - virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset, void* aData, const TRANSFORM& aTransform ); /** diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index d26bb84cea..c64c01c1cd 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -134,29 +134,12 @@ int LIB_FIELD::GetPenSize() const void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) + void* aData, const TRANSFORM& aTransform ) { wxPoint text_pos; - COLOR4D color = COLOR4D::UNSPECIFIED; + COLOR4D color = IsVisible() ? GetDefaultColor() : GetInvisibleItemColor(); int linewidth = GetPenSize(); - if( !IsVisible() && ( aColor == COLOR4D::UNSPECIFIED ) ) - { - color = GetInvisibleItemColor(); - } - else if( IsSelected() && ( aColor == COLOR4D::UNSPECIFIED ) ) - { - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - - if( color == COLOR4D::UNSPECIFIED ) - color = GetDefaultColor(); - text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset; wxString text; @@ -166,23 +149,10 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a else text = m_Text; - GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, text_pos, color, text, - GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), - linewidth, IsItalic(), IsBold() ); - - /* Set to one (1) to draw bounding box around field text to validate - * bounding box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif + DrawGraphicText( clipbox, aDC, text_pos, color, text, GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), linewidth, IsItalic(), IsBold() ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 4c097b5228..5fd127cbe1 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -72,8 +72,7 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT * the m_Text *

*/ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; /** diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 20c5d453c4..36ec205bee 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -574,20 +574,11 @@ int LIB_PIN::GetPenSize() const } -void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - const wxPoint& aOffset, - COLOR4D aColor, - GR_DRAWMODE aDrawMode, - void* aData, +void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { - // aData is used here as a bitfield of flags. - uintptr_t flags = (uintptr_t) aData; - bool drawPinText = flags & PIN_DRAW_TEXTS; - bool drawPinDangling = flags & PIN_DRAW_DANGLING; - bool drawDanglingHidden = flags & PIN_DANGLING_HIDDEN; - bool drawElectricalTypeName = flags & PIN_DRAW_ELECTRICAL_TYPE_NAME; + // aData is used here as a boolean. + bool drawElectricalTypeName = (bool) aData; LIB_PART* Entry = GetParent(); @@ -598,8 +589,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset; // Invisible pins are only drawn on request. - // They are drawn in GetInvisibleItemColor(). - if( ! IsVisible() ) + if( !IsVisible() ) { bool drawHidden = true; @@ -612,143 +602,64 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, } if( !drawHidden ) - { - if( drawPinDangling && drawDanglingHidden ) - { - // Draw the target - DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor, drawPinDangling, - /* aOnlyTarget */ true ); - } return; - } - - aColor = GetInvisibleItemColor(); } - /* Drawing from the pin and the special symbol combination */ - DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor, drawPinDangling ); + DrawPinSymbol( aPanel, aDC, pos1, orient ); - if( drawPinText ) - { - DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), - Entry->ShowPinNumbers(), Entry->ShowPinNames(), - aColor, aDrawMode ); - } + DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), Entry->ShowPinNumbers(), + Entry->ShowPinNames() ); if( drawElectricalTypeName ) - DrawPinElectricalTypeName( aPanel, aDC, pos1, orient, aColor, aDrawMode ); - - - /* Set to one (1) to draw bounding box around pin to validate bounding - * box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDC, bBox, 0, LIGHTMAGENTA ); -#endif + DrawPinElectricalTypeName( aPanel, aDC, pos1, orient ); } -void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - const wxPoint& aPinPos, - int aOrient, - GR_DRAWMODE aDrawMode, - COLOR4D aColor, - bool aDrawDangling, - bool aOnlyTarget ) +void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos, int aOrient ) { - int MapX1, MapY1, x1, y1; - int width = GetPenSize(); - int posX = aPinPos.x, posY = aPinPos.y, len = m_length; + int MapX1, MapY1, x1, y1; + int width = GetPenSize(); + int posX = aPos.x, posY = aPos.y, len = m_length; + COLOR4D color = IsVisible() ? GetLayerColor( LAYER_PIN ) : GetInvisibleItemColor(); + EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - COLOR4D color = GetLayerColor( LAYER_PIN ); - - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - color = aColor; - - GRSetDrawMode( aDC, aDrawMode ); - MapX1 = MapY1 = 0; x1 = posX; y1 = posY; switch( aOrient ) { - case PIN_UP: - y1 = posY - len; - MapY1 = 1; - break; - - case PIN_DOWN: - y1 = posY + len; - MapY1 = -1; - break; - - case PIN_LEFT: - x1 = posX - len; - MapX1 = 1; - break; - - case PIN_RIGHT: - x1 = posX + len; - MapX1 = -1; - break; + case PIN_UP: y1 = posY - len; MapY1 = 1; break; + case PIN_DOWN: y1 = posY + len; MapY1 = -1; break; + case PIN_LEFT: x1 = posX - len; MapX1 = 1; break; + case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break; } - // Draw the pin end target (active end of the pin) - BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL; - #define NCSYMB_PIN_DIM TARGET_PIN_RADIUS - - // Draw but do not print the pin end target 1 pixel width - if( m_type != PIN_NC && ( screen == NULL || !screen->m_IsPrinting ) ) - { - if( aDrawDangling ) - GRCircle( clipbox, aDC, posX, posY, TARGET_PIN_RADIUS, 0, color ); - } - - if( aOnlyTarget ) - return; - - if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK ) { const int radius = ExternalPinDecoSize( *this ); - GRCircle( clipbox, aDC, MapX1 * radius + x1, - MapY1 * radius + y1, - radius, width, color ); + GRCircle( clipbox, aDC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color ); - GRMoveTo( MapX1 * radius * 2 + x1, - MapY1 * radius * 2 + y1 ); + GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ); GRLineTo( clipbox, aDC, posX, posY, width, color ); } else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK ) /* an alternative for Inverted Clock */ { - const int clock_size = InternalPinDecoSize( *this ); + const int SIZE = InternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - GRMoveTo( x1, y1 + clock_size ); - GRLineTo( clipbox, aDC, x1 + MapX1 * clock_size * 2, y1, - width, color ); - GRLineTo( clipbox, aDC, x1, y1 - clock_size, width, color ); + GRMoveTo( x1, y1 + SIZE ); + GRLineTo( clipbox, aDC, x1 + MapX1 * SIZE * 2, y1, width, color ); + GRLineTo( clipbox, aDC, x1, y1 - SIZE, width, color ); } else /* MapX1 = 0 */ { - GRMoveTo( x1 + clock_size, y1 ); - GRLineTo( clipbox, aDC, x1, y1 + MapY1 * clock_size * 2, - width, color ); - GRLineTo( clipbox, aDC, x1 - clock_size, y1, - width, color ); + GRMoveTo( x1 + SIZE, y1 ); + GRLineTo( clipbox, aDC, x1, y1 + MapY1 * SIZE * 2, width, color ); + GRLineTo( clipbox, aDC, x1 - SIZE, y1, width, color ); } - GRMoveTo( MapX1 * clock_size * 2 + x1, MapY1 * clock_size * 2 + y1 ); + GRMoveTo( MapX1 * SIZE * 2 + x1, MapY1 * SIZE * 2 + y1 ); GRLineTo( clipbox, aDC, posX, posY, width, color ); } else @@ -763,37 +674,30 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, if( MapY1 == 0 ) /* MapX1 = +- 1 */ { GRMoveTo( x1, y1 + clock_size ); - GRLineTo( clipbox, aDC, x1 - MapX1 * clock_size * 2, y1, - width, color ); - GRLineTo( clipbox, aDC, x1, y1 - clock_size, - width, color ); + GRLineTo( clipbox, aDC, x1 - MapX1 * clock_size * 2, y1, width, color ); + GRLineTo( clipbox, aDC, x1, y1 - clock_size, width, color ); } else /* MapX1 = 0 */ { GRMoveTo( x1 + clock_size, y1 ); - GRLineTo( clipbox, aDC, x1, y1 - MapY1 * clock_size * 2, - width, color ); - GRLineTo( clipbox, aDC, x1 - clock_size, y1, - width, color ); + GRLineTo( clipbox, aDC, x1, y1 - MapY1 * clock_size * 2, width, color ); + GRLineTo( clipbox, aDC, x1 - clock_size, y1, width, color ); } } if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW ) { - const int symbol_size = ExternalPinDecoSize( *this ); + const int SIZE = ExternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - GRMoveTo( x1 + MapX1 * symbol_size * 2, y1 ); - GRLineTo( clipbox, aDC, - x1 + MapX1 * symbol_size * 2, y1 - symbol_size * 2, - width, color ); + GRMoveTo( x1 + MapX1 * SIZE * 2, y1 ); + GRLineTo( clipbox, aDC, x1 + MapX1 * SIZE * 2, y1 - SIZE * 2, width, color ); GRLineTo( clipbox, aDC, x1, y1, width, color ); } else /* MapX1 = 0 */ { - GRMoveTo( x1, y1 + MapY1 * symbol_size * 2 ); - GRLineTo( clipbox, aDC, x1 - symbol_size * 2, - y1 + MapY1 * symbol_size * 2, width, color ); + GRMoveTo( x1, y1 + MapY1 * SIZE * 2 ); + GRLineTo( clipbox, aDC, x1 - SIZE * 2, y1 + MapY1 * SIZE * 2, width, color ); GRLineTo( clipbox, aDC, x1, y1, width, color ); } } @@ -801,116 +705,68 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */ { - const int symbol_size = ExternalPinDecoSize( *this ); + const int SIZE = ExternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - GRMoveTo( x1, y1 - symbol_size * 2 ); - GRLineTo( clipbox, - aDC, - x1 + MapX1 * symbol_size * 2, - y1, - width, - color ); + GRMoveTo( x1, y1 - SIZE * 2 ); + GRLineTo( clipbox, aDC, x1 + MapX1 * SIZE * 2, y1, width, color ); } else /* MapX1 = 0 */ { - GRMoveTo( x1 - symbol_size * 2, y1 ); - GRLineTo( clipbox, aDC, x1, y1 + MapY1 * symbol_size * 2, - width, color ); + GRMoveTo( x1 - SIZE * 2, y1 ); + GRLineTo( clipbox, aDC, x1, y1 + MapY1 * SIZE * 2, width, color ); } } else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */ { - const int symbol_size = ExternalPinDecoSize( *this ); - GRMoveTo( x1 - (MapX1 + MapY1) * symbol_size, - y1 - (MapY1 - MapX1) * symbol_size ); - GRLineTo( clipbox, aDC, - x1 + (MapX1 + MapY1) * symbol_size, - y1 + (MapY1 - MapX1) * symbol_size, - width, color ); - GRMoveTo( x1 - (MapX1 - MapY1) * symbol_size, - y1 - (MapY1 + MapX1) * symbol_size ); - GRLineTo( clipbox, aDC, - x1 + (MapX1 - MapY1) * symbol_size, - y1 + (MapY1 + MapX1) * symbol_size, - width, color ); + const int SIZE = ExternalPinDecoSize( *this ); + GRMoveTo( x1 - (MapX1 + MapY1) * SIZE, y1 - (MapY1 - MapX1) * SIZE ); + GRLineTo( clipbox, aDC, x1 + (MapX1 + MapY1) * SIZE, y1 + (MapY1 - MapX1) * SIZE, width, + color ); + GRMoveTo( x1 - (MapX1 - MapY1) * SIZE, y1 - (MapY1 + MapX1) * SIZE ); + GRLineTo( clipbox, aDC, x1 + (MapX1 - MapY1) * SIZE, y1 + (MapY1 + MapX1) * SIZE, width, + color ); } if( m_type == PIN_NC ) // Draw a N.C. symbol { - GRLine( clipbox, aDC, - posX - NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM, - posX + NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM, - width, color ); - GRLine( clipbox, aDC, - posX + NCSYMB_PIN_DIM, posY - NCSYMB_PIN_DIM, - posX - NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM, - width, color ); + const int SIZE = TARGET_PIN_RADIUS; + GRLine( clipbox, aDC, posX - SIZE, posY - SIZE, posX + SIZE, posY + SIZE, width, color ); + GRLine( clipbox, aDC, posX + SIZE, posY - SIZE, posX - SIZE, posY + SIZE, width, color ); } } -void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, - wxDC* DC, - wxPoint& pin_pos, - int orient, - int TextInside, - bool DrawPinNum, - bool DrawPinName, - COLOR4D Color, - GR_DRAWMODE DrawMode ) +void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, int orient, + int TextInside, bool DrawPinNum, bool DrawPinName ) { if( !DrawPinName && !DrawPinNum ) return; - int x, y; + int x, y; - wxSize PinNameSize( m_nameTextSize, m_nameTextSize ); - wxSize PinNumSize( m_numTextSize, m_numTextSize ); + wxSize PinNameSize( m_nameTextSize, m_nameTextSize ); + wxSize PinNumSize( m_numTextSize, m_numTextSize ); + int nameLineWidth = Clamp_Text_PenSize( GetPenSize(), m_nameTextSize, false ); + int numLineWidth = Clamp_Text_PenSize( GetPenSize(), m_numTextSize, false ); + int name_offset = PIN_TEXT_MARGIN + ( nameLineWidth + GetDefaultLineThickness() ) / 2; + int num_offset = PIN_TEXT_MARGIN + ( numLineWidth + GetDefaultLineThickness() ) / 2; - int nameLineWidth = GetPenSize(); - - nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_nameTextSize, false ); - int numLineWidth = GetPenSize(); - numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false ); - - int name_offset = PIN_TEXT_MARGIN + - ( nameLineWidth + GetDefaultLineThickness() ) / 2; - int num_offset = PIN_TEXT_MARGIN + - ( numLineWidth + GetDefaultLineThickness() ) / 2; - - GRSetDrawMode( DC, DrawMode ); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; /* Get the num and name colors */ - if( ( Color == COLOR4D::UNSPECIFIED ) && IsSelected() ) - Color = GetItemSelectedColor(); - - COLOR4D NameColor = Color == COLOR4D::UNSPECIFIED ? - GetLayerColor( LAYER_PINNAM ) : Color; - COLOR4D NumColor = Color == COLOR4D::UNSPECIFIED ? - GetLayerColor( LAYER_PINNUM ) : Color; + COLOR4D NameColor = IsVisible() ? GetLayerColor( LAYER_PINNAM ) : GetInvisibleItemColor(); + COLOR4D NumColor = IsVisible() ? GetLayerColor( LAYER_PINNUM ) : GetInvisibleItemColor(); int x1 = pin_pos.x; int y1 = pin_pos.y; switch( orient ) { - case PIN_UP: - y1 -= m_length; - break; - - case PIN_DOWN: - y1 += m_length; - break; - - case PIN_LEFT: - x1 -= m_length; - break; - - case PIN_RIGHT: - x1 += m_length; - break; + case PIN_UP: y1 -= m_length; break; + case PIN_DOWN: y1 += m_length; break; + case PIN_LEFT: x1 -= m_length; break; + case PIN_RIGHT: x1 += m_length; break; } if( m_name.IsEmpty() ) @@ -927,35 +783,24 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, { x = x1 + TextInside; DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, - m_name, - TEXT_ANGLE_HORIZ, - PinNameSize, - GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, - false, false ); + m_name, TEXT_ANGLE_HORIZ, PinNameSize, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + nameLineWidth, false, false ); } else // Orient == PIN_LEFT { x = x1 - TextInside; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, - m_name, - TEXT_ANGLE_HORIZ, - PinNameSize, - GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, + GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); } } if( DrawPinNum ) { - DrawGraphicText( clipbox, DC, - wxPoint( (x1 + pin_pos.x) / 2, - y1 - num_offset ), NumColor, - m_number, - TEXT_ANGLE_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, + DrawGraphicText( clipbox, DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), + NumColor, m_number, TEXT_ANGLE_HORIZ, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false ); } } @@ -967,44 +812,30 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, y = y1 + TextInside; if( DrawPinName ) - DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, - m_name, - TEXT_ANGLE_VERT, PinNameSize, - GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, + GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); if( DrawPinNum ) - DrawGraphicText( clipbox, DC, - wxPoint( x1 - num_offset, - (y1 + pin_pos.y) / 2 ), NumColor, - m_number, - TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), + NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + numLineWidth, false, false ); } else /* PIN_UP */ { y = y1 - TextInside; if( DrawPinName ) - DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, - m_name, - TEXT_ANGLE_VERT, PinNameSize, - GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, + GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false ); if( DrawPinNum ) - DrawGraphicText( clipbox, DC, - wxPoint( x1 - num_offset, - (y1 + pin_pos.y) / 2 ), NumColor, - m_number, - TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), + NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + numLineWidth, false, false ); } } } @@ -1016,22 +847,16 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), - NameColor, m_name, - TEXT_ANGLE_HORIZ, PinNameSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, + TEXT_ANGLE_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); } if( DrawPinNum ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), - NumColor, m_number, - TEXT_ANGLE_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, numLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, + TEXT_ANGLE_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false ); } } else /* Its a vertical line. */ @@ -1039,23 +864,16 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) { y = (y1 + pin_pos.y) / 2; - DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), - NameColor, m_name, - TEXT_ANGLE_VERT, PinNameSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, - false, false ); + DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, + TEXT_ANGLE_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false ); } if( DrawPinNum ) { - DrawGraphicText( clipbox, DC, - wxPoint( x1 + num_offset, (y1 + pin_pos.y) - / 2 ), - NumColor, m_number, - TEXT_ANGLE_VERT, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP, numLineWidth, + DrawGraphicText( clipbox, DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), + NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false ); } } @@ -1064,29 +882,23 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, -void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - wxPoint& aPosition, int aOrientation, - COLOR4D aColor, GR_DRAWMODE aDrawMode ) +void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, + int aOrientation ) { - wxString etypeName = GetElectricalTypeName(); + wxString typeName = GetElectricalTypeName(); // Use a reasonable (small) size to draw the text - int etextSize = (m_nameTextSize*3)/4; + int textSize = (m_nameTextSize*3)/4; #define ETXT_MAX_SIZE Millimeter2iu(0.7 ) - if( etextSize > ETXT_MAX_SIZE ) - etextSize = ETXT_MAX_SIZE; + if( textSize > ETXT_MAX_SIZE ) + textSize = ETXT_MAX_SIZE; // Use a reasonable pen size to draw the text - int pensize = etextSize/6; + int pensize = textSize/6; // Get a suitable color - if( ( aColor == COLOR4D::UNSPECIFIED ) && IsSelected() ) - aColor = GetItemSelectedColor(); - else if( !IsVisible() ) - aColor = GetInvisibleItemColor(); - else - aColor = GetLayerColor( LAYER_NOTES ); + COLOR4D color = IsVisible() ? GetLayerColor( LAYER_NOTES ) : GetInvisibleItemColor(); wxPoint txtpos = aPosition; int offset = Millimeter2iu( 0.4 ); @@ -1116,13 +928,10 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, break; } - GRSetDrawMode( aDC, aDrawMode ); - EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; + EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; - DrawGraphicText( clipbox, aDC, txtpos, aColor, etypeName, - orient, wxSize( etextSize, etextSize ), - hjustify, GR_TEXT_VJUSTIFY_CENTER, pensize, - false, false ); + DrawGraphicText( clipbox, aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), + hjustify, GR_TEXT_VJUSTIFY_CENTER, pensize, false, false ); } @@ -1139,58 +948,38 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie switch( aOrientation ) { - case PIN_UP: - y1 = aPosition.y - m_length; - MapY1 = 1; - break; - - case PIN_DOWN: - y1 = aPosition.y + m_length; - MapY1 = -1; - break; - - case PIN_LEFT: - x1 = aPosition.x - m_length; - MapX1 = 1; - break; - - case PIN_RIGHT: - x1 = aPosition.x + m_length; - MapX1 = -1; - break; + case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break; + case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break; + case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break; + case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break; } if( m_shape == PINSHAPE_INVERTED || m_shape == PINSHAPE_INVERTED_CLOCK ) { const int radius = ExternalPinDecoSize( *this ); - aPlotter->Circle( wxPoint( MapX1 * radius + x1, - MapY1 * radius + y1 ), - radius * 2, // diameter - NO_FILL, // fill option - GetPenSize() ); // width + aPlotter->Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ), + radius * 2, NO_FILL, GetPenSize() ); - aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, - MapY1 * radius * 2 + y1 ) ); + aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) ); aPlotter->FinishTo( aPosition ); } else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK ) { - const int clock_size = InternalPinDecoSize( *this ); + const int SIZE = InternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - aPlotter->MoveTo( wxPoint( x1, y1 + clock_size ) ); - aPlotter->LineTo( wxPoint( x1 + MapX1 * clock_size * 2, y1 ) ); - aPlotter->FinishTo( wxPoint( x1, y1 - clock_size ) ); + aPlotter->MoveTo( wxPoint( x1, y1 + SIZE ) ); + aPlotter->LineTo( wxPoint( x1 + MapX1 * SIZE * 2, y1 ) ); + aPlotter->FinishTo( wxPoint( x1, y1 - SIZE ) ); } else /* MapX1 = 0 */ { - aPlotter->MoveTo( wxPoint( x1 + clock_size, y1 ) ); - aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * clock_size * 2 ) ); - aPlotter->FinishTo( wxPoint( x1 - clock_size, y1 ) ); + aPlotter->MoveTo( wxPoint( x1 + SIZE, y1 ) ); + aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * SIZE * 2 ) ); + aPlotter->FinishTo( wxPoint( x1 - SIZE, y1 ) ); } - aPlotter->MoveTo( wxPoint( MapX1 * clock_size * 2 + x1, - MapY1 * clock_size * 2 + y1 ) ); + aPlotter->MoveTo( wxPoint( MapX1 * SIZE * 2 + x1, MapY1 * SIZE * 2 + y1 ) ); aPlotter->FinishTo( aPosition ); } else @@ -1202,37 +991,35 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie if( m_shape == PINSHAPE_CLOCK || m_shape == PINSHAPE_INVERTED_CLOCK || m_shape == PINSHAPE_CLOCK_LOW ) { - const int clock_size = InternalPinDecoSize( *this ); + const int SIZE = InternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - aPlotter->MoveTo( wxPoint( x1, y1 + clock_size ) ); - aPlotter->LineTo( wxPoint( x1 - MapX1 * clock_size * 2, y1 ) ); - aPlotter->FinishTo( wxPoint( x1, y1 - clock_size ) ); + aPlotter->MoveTo( wxPoint( x1, y1 + SIZE ) ); + aPlotter->LineTo( wxPoint( x1 - MapX1 * SIZE * 2, y1 ) ); + aPlotter->FinishTo( wxPoint( x1, y1 - SIZE ) ); } else /* MapX1 = 0 */ { - aPlotter->MoveTo( wxPoint( x1 + clock_size, y1 ) ); - aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * clock_size * 2 ) ); - aPlotter->FinishTo( wxPoint( x1 - clock_size, y1 ) ); + aPlotter->MoveTo( wxPoint( x1 + SIZE, y1 ) ); + aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * SIZE * 2 ) ); + aPlotter->FinishTo( wxPoint( x1 - SIZE, y1 ) ); } } if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW ) /* IEEE symbol "Active Low Input" */ { - const int symbol_size = ExternalPinDecoSize( *this ); + const int SIZE = ExternalPinDecoSize( *this ); if( MapY1 == 0 ) /* MapX1 = +- 1 */ { - aPlotter->MoveTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) ); - aPlotter->LineTo( wxPoint( x1 + MapX1 * symbol_size * 2, - y1 - symbol_size * 2 ) ); + aPlotter->MoveTo( wxPoint( x1 + MapX1 * SIZE * 2, y1 ) ); + aPlotter->LineTo( wxPoint( x1 + MapX1 * SIZE * 2, y1 - SIZE * 2 ) ); aPlotter->FinishTo( wxPoint( x1, y1 ) ); } else /* MapX1 = 0 */ { - aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) ); - aPlotter->LineTo( wxPoint( x1 - symbol_size * 2, - y1 + MapY1 * symbol_size * 2 ) ); + aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * SIZE * 2 ) ); + aPlotter->LineTo( wxPoint( x1 - SIZE * 2, y1 + MapY1 * SIZE * 2 ) ); aPlotter->FinishTo( wxPoint( x1, y1 ) ); } } @@ -1255,24 +1042,21 @@ void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrie } else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */ { - const int symbol_size = ExternalPinDecoSize( *this ); - aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * symbol_size, - y1 - (MapY1 - MapX1) * symbol_size ) ); - aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * symbol_size, - y1 + (MapY1 - MapX1) * symbol_size ) ); - aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * symbol_size, - y1 - (MapY1 + MapX1) * symbol_size ) ); - aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * symbol_size, - y1 + (MapY1 + MapX1) * symbol_size ) ); + const int SIZE = ExternalPinDecoSize( *this ); + aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * SIZE, y1 - (MapY1 - MapX1) * SIZE ) ); + aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * SIZE, y1 + (MapY1 - MapX1) * SIZE ) ); + aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * SIZE, y1 - (MapY1 + MapX1) * SIZE ) ); + aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * SIZE, y1 + (MapY1 + MapX1) * SIZE ) ); } if( m_type == PIN_NC ) // Draw a N.C. symbol { + const int SIZE = TARGET_PIN_RADIUS; const int ex1 = aPosition.x; const int ey1 = aPosition.y; - aPlotter->MoveTo( wxPoint( ex1 - NCSYMB_PIN_DIM, ey1 - NCSYMB_PIN_DIM ) ); - aPlotter->FinishTo( wxPoint( ex1 + NCSYMB_PIN_DIM, ey1 + NCSYMB_PIN_DIM ) ); - aPlotter->MoveTo( wxPoint( ex1 + NCSYMB_PIN_DIM, ey1 - NCSYMB_PIN_DIM ) ); - aPlotter->FinishTo( wxPoint( ex1 - NCSYMB_PIN_DIM, ey1 + NCSYMB_PIN_DIM ) ); + aPlotter->MoveTo( wxPoint( ex1 - SIZE, ey1 - SIZE ) ); + aPlotter->FinishTo( wxPoint( ex1 + SIZE, ey1 + SIZE ) ); + aPlotter->MoveTo( wxPoint( ex1 + SIZE, ey1 - SIZE ) ); + aPlotter->FinishTo( wxPoint( ex1 - SIZE, ey1 + SIZE ) ); } } @@ -1313,21 +1097,10 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, switch( orient ) { - case PIN_UP: - y1 -= m_length; - break; - - case PIN_DOWN: - y1 += m_length; - break; - - case PIN_LEFT: - x1 -= m_length; - break; - - case PIN_RIGHT: - x1 += m_length; - break; + case PIN_UP: y1 -= m_length; break; + case PIN_DOWN: y1 += m_length; break; + case PIN_LEFT: x1 -= m_length; break; + case PIN_RIGHT: x1 += m_length; break; } /* Draw the text inside, but the pin numbers outside. */ @@ -1483,21 +1256,10 @@ wxPoint LIB_PIN::PinEndPoint() const switch( m_orientation ) { - case PIN_UP: - pos.y += m_length; - break; - - case PIN_DOWN: - pos.y -= m_length; - break; - - case PIN_LEFT: - pos.x -= m_length; - break; - - case PIN_RIGHT: - pos.x += m_length; - break; + case PIN_UP: pos.y += m_length; break; + case PIN_DOWN: pos.y -= m_length; break; + case PIN_LEFT: pos.x -= m_length; break; + case PIN_RIGHT: pos.x += m_length; break; } return pos; @@ -1511,21 +1273,10 @@ int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const switch( m_orientation ) { - case PIN_UP: - end.y = 1; - break; - - case PIN_DOWN: - end.y = -1; - break; - - case PIN_LEFT: - end.x = -1; - break; - - case PIN_RIGHT: - end.x = 1; - break; + case PIN_UP: end.y = 1; break; + case PIN_DOWN: end.y = -1; break; + case PIN_LEFT: end.x = -1; break; + case PIN_RIGHT: end.x = 1; break; } // = pos of end point, according to the component orientation @@ -1637,40 +1388,20 @@ void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW ) { switch( m_orientation ) { - case PIN_RIGHT: - m_orientation = PIN_UP; - break; - - case PIN_UP: - m_orientation = PIN_LEFT; - break; - case PIN_LEFT: - m_orientation = PIN_DOWN; - break; - - case PIN_DOWN: - m_orientation = PIN_RIGHT; - break; + case PIN_RIGHT: m_orientation = PIN_UP; break; + case PIN_UP: m_orientation = PIN_LEFT; break; + case PIN_LEFT: m_orientation = PIN_DOWN; break; + case PIN_DOWN: m_orientation = PIN_RIGHT; break; } } else { switch( m_orientation ) { - case PIN_RIGHT: - m_orientation = PIN_DOWN; - break; - - case PIN_UP: - m_orientation = PIN_RIGHT; - break; - case PIN_LEFT: - m_orientation = PIN_UP; - break; - - case PIN_DOWN: - m_orientation = PIN_LEFT; - break; + case PIN_RIGHT: m_orientation = PIN_DOWN; break; + case PIN_UP: m_orientation = PIN_RIGHT; break; + case PIN_LEFT: m_orientation = PIN_UP; break; + case PIN_DOWN: m_orientation = PIN_LEFT; break; } } } @@ -1688,8 +1419,7 @@ void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, PlotSymbol( plotter, pos, orient ); PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(), - GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), - GetPenSize() ); + GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), GetPenSize() ); } @@ -1710,20 +1440,13 @@ void LIB_PIN::getMsgPanelInfoBase( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetText( m_type ), RED ) ); text = GetText( m_shape ); - aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) ); - if( IsVisible() ) - text = _( "Yes" ); - else - text = _( "No" ); - + text = IsVisible() ? _( "Yes" ) : _( "No" ); aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) ); // Display pin length @@ -1769,8 +1492,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( aComponent->GetField( REFERENCE )->GetShownText(), - aComponent->GetField( VALUE )->GetShownText(), - DARKCYAN ) ); + aComponent->GetField( VALUE )->GetShownText(), DARKCYAN ) ); #if defined(DEBUG) @@ -1935,21 +1657,10 @@ void LIB_PIN::Rotate() switch( GetOrientation() ) { - case PIN_UP: - orient = PIN_LEFT; - break; - - case PIN_DOWN: - orient = PIN_RIGHT; - break; - - case PIN_LEFT: - orient = PIN_DOWN; - break; - - case PIN_RIGHT: - orient = PIN_UP; - break; + case PIN_UP: orient = PIN_LEFT; break; + case PIN_DOWN: orient = PIN_RIGHT; break; + case PIN_LEFT: orient = PIN_DOWN; break; + case PIN_RIGHT: orient = PIN_UP; break; } // Set the new orientation @@ -2018,6 +1729,7 @@ void LIB_PIN::Show( int nestLevel, std::ostream& os ) const void LIB_PIN::CalcEdit( const wxPoint& aPosition ) { DBG(printf("m_Flags %x\n", m_Flags );) + if( m_Flags == IS_NEW ) { SetPosition( aPosition ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 931e2f76af..c6488ea193 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -56,14 +56,6 @@ enum DrawPinOrient { PIN_DOWN = 'D' }; -enum LibPinDrawFlags { - PIN_DRAW_TEXTS = 1, - PIN_DRAW_DANGLING = 2, // Draw this pin with a 'dangling' indicator - PIN_DANGLING_HIDDEN = 4, // Draw (only!) the dangling indicator if the pin is hidden - PIN_DRAW_ELECTRICAL_TYPE_NAME = 8 // Draw the pin electrical type name - // used only in component editor and component viewer -}; - class LIB_PIN : public LIB_ITEM { @@ -90,17 +82,11 @@ class LIB_PIN : public LIB_ITEM * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes. * @param aDC Device Context (can be null) * @param aOffset Offset to draw - * @param aColor COLOR4D::UNSPECIFIED to use the normal body item color, or else use this color - * @param aDrawMode GR_OR, GR_XOR, ... - * @param aData = used here as uintptr_t containing bitwise OR'd flags: - * PIN_DRAW_TEXTS, -- false to draw only pin shape, useful for fast mode - * PIN_DRAW_DANGLING, -- true to draw the pin with its target - * PIN_DANGLING_HIDDEN -- draw the target even if the pin is hidden - * PIN_DRAW_ELECTRICAL_TYPE_NAME -- Draw the pin electrical type name + * @param aData = used here as a boolean indicating whether or not to draw the pin + * electrical types * @param aTransform Transform Matrix (rotation, mirror ..) */ - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; public: @@ -379,11 +365,8 @@ public: * Draw the pin symbol without text. * If \a aColor != 0, draw with \a aColor, else with the normal pin color. */ - void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - int aOrientation, GR_DRAWMODE aDrawMode, - COLOR4D aColor = COLOR4D::UNSPECIFIED, - bool aDrawDangling = true, - bool aOnlyTarget = false ); + void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos, + int aOrientation ); /** * Put the pin number and pin text info, given the pin line coordinates. @@ -392,18 +375,15 @@ public: * If DrawPinNum = false the pin number is not printed. * If TextInside then the text is been put inside,otherwise all is drawn outside. * Pin Name: substring between '~' is negated - * DrawMode = GR_OR, XOR ... */ void DrawPinTexts( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, - int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName, - COLOR4D aColor, GR_DRAWMODE aDrawMode ); + int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName ); /** * Draw the electrical type text of the pin (only for the footprint editor) - * aDrawMode = GR_OR, XOR ... */ void DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition, - int aOrientation, COLOR4D aColor, GR_DRAWMODE aDrawMode ); + int aOrientation ); /** * Plot the pin number and pin text info, given the pin line coordinates. @@ -412,13 +392,8 @@ public: * If TextInside then the text is been put inside (moving from x1, y1 in * the opposite direction to x2,y2), otherwise all is drawn outside. */ - void PlotPinTexts( PLOTTER *aPlotter, - wxPoint& aPosition, - int aOrientation, - int aTextInside, - bool aDrawPinNum, - bool aDrawPinName, - int aWidth ); + void PlotPinTexts( PLOTTER *aPlotter, wxPoint& aPosition, int aOrientation, + int aTextInside, bool aDrawPinNum, bool aDrawPinName, int aWidth ); void PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index f263d1c92d..75e3dede24 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -130,14 +130,11 @@ void LIB_POLYLINE::MirrorVertical( const wxPoint& aCenter ) void LIB_POLYLINE::Rotate( const wxPoint& aCenter, bool aRotateCCW ) { - int rot_angle = aRotateCCW ? -900 : 900; - + int rot_angle = aRotateCCW ? -900 : 900; size_t i, imax = m_PolyPoints.size(); for( i = 0; i < imax; i++ ) - { RotatePoint( &m_PolyPoints[i], aCenter, rot_angle ); - } } @@ -169,7 +166,7 @@ void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, { pen_size = std::max( 0, pen_size ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); - aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() ); + aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, pen_size ); } } @@ -193,60 +190,27 @@ int LIB_POLYLINE::GetPenSize() const void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) + void* aData, const TRANSFORM& aTransform ) { - wxPoint pos1; - COLOR4D color = GetLayerColor( LAYER_DEVICE ); - wxPoint* buffer = NULL; + COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - - buffer = new wxPoint[ m_PolyPoints.size() ]; + wxPoint* buffer = new wxPoint[ m_PolyPoints.size() ]; for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) - { buffer[ii] = aTransform.TransformCoordinate( m_PolyPoints[ii] ) + aOffset; - } FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor != COLOR4D::UNSPECIFIED ) - fill = NO_FILL; - - GRSetDrawMode( aDC, aDrawMode ); - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), - (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), - GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), bgColor, bgColor ); else if( fill == FILLED_SHAPE ) - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), - color, color ); + GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(), color, color ); else - GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(), - color, color ); + GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(), color, color ); delete[] buffer; - - /* Set to one (1) to draw bounding box around polyline to validate - * bounding box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif } diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 45e35ee235..d795636301 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -39,8 +39,7 @@ class LIB_POLYLINE : public LIB_ITEM int m_ModifyIndex; // Index of the polyline point to modify - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; void CalcEdit( const wxPoint& aPosition ) override; diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index abb63eec54..8d6a70b96d 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -153,7 +153,7 @@ void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, { pen_size = std::max( 0, pen_size ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) ); - aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, GetPenSize() ); + aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, pen_size ); } } @@ -170,54 +170,26 @@ int LIB_RECTANGLE::GetPenSize() const } -void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, +void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) { - wxPoint pos1, pos2; + wxPoint pt1, pt2; - COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D color = GetLayerColor( LAYER_DEVICE ); + COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND ); - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - - pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; - pos2 = aTransform.TransformCoordinate( m_End ) + aOffset; + pt1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; + pt2 = aTransform.TransformCoordinate( m_End ) + aOffset; FILL_T fill = aData ? NO_FILL : m_Fill; - if( aColor != COLOR4D::UNSPECIFIED ) - fill = NO_FILL; - - GRSetDrawMode( aDC, aDrawMode ); - EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) - GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ), - (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), - GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + GRFilledRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize( ), bgColor, bgColor ); else if( m_Fill == FILLED_SHAPE && !aData ) - GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, - GetPenSize(), color, color ); + GRFilledRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color, color ); else - GRRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color ); - - /* Set to one (1) to draw bounding box around rectangle to validate - * bounding box calculation. */ -#if 0 - EDA_RECT bBox = GetBoundingBox(); - bBox.RevertYAxis(); - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif + GRRect( clipbox, aDC, pt1.x, pt1.y, pt2.x, pt2.y, GetPenSize(), color ); } diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index add1b403d7..abb6b248a3 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -41,8 +41,7 @@ class LIB_RECTANGLE : public LIB_ITEM bool m_isHeightLocked; // Flag: Keep height locked bool m_isStartPointSelected; // Flag: is the upper left edge selected? - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; void CalcEdit( const wxPoint& aPosition ) override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 6c91102e66..55e59b69fd 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -67,9 +67,6 @@ bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { - if( aThreshold < 0 ) - aThreshold = 0; - EDA_TEXT tmp_text( *this ); tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) ); @@ -86,7 +83,7 @@ bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFOR EDA_ITEM* LIB_TEXT::Clone() const { - LIB_TEXT* newitem = new LIB_TEXT(NULL); + LIB_TEXT* newitem = new LIB_TEXT( nullptr ); newitem->m_Unit = m_Unit; newitem->m_Convert = m_Convert; @@ -229,23 +226,10 @@ int LIB_TEXT::GetPenSize() const void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, - const TRANSFORM& aTransform ) + void* aData, const TRANSFORM& aTransform ) { COLOR4D color = GetDefaultColor(); - if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color - { - if( IsSelected() ) - color = GetItemSelectedColor(); - } - else - { - color = aColor; - } - - GRSetDrawMode( aDC, aDrawMode ); - /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ @@ -283,17 +267,6 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); - - - /* Enable this to draw the bounding box around the text field to validate - * the bounding box calculations. - */ -#if 0 - // bBox already uses libedit Y axis. - bBox = aTransform.TransformCoordinate( bBox ); - bBox.Move( aOffset ); - GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); -#endif } @@ -337,13 +310,9 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const void LIB_TEXT::Rotate() { if( InEditMode() ) - { m_rotate = true; - } else - { SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT ); - } } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index a167083857..bbd2df0b0e 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -47,8 +47,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT bool m_rotate; ///< Flag to indicate a rotation occurred while editing. bool m_updateText; ///< Flag to indicate text change occurred while editing. - void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData, + void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform ) override; void CalcEdit( const wxPoint& aPosition ) override; diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 5ce030ee92..40bdb8c605 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -1007,11 +1007,6 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ) if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) ) return; - // Deleting old text - if( DC && !DrawItem->InEditMode() ) - DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL, - DefaultTransform ); - DIALOG_LIB_EDIT_TEXT dlg( this, (LIB_TEXT*) DrawItem ); if( dlg.ShowModal() != wxID_OK ) @@ -1020,11 +1015,6 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ) GetCanvas()->GetView()->Update( DrawItem ); GetCanvas()->Refresh(); OnModify(); - - // Display new text - if( DC && !DrawItem->InEditMode() ) - DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, GR_DEFAULT_DRAWMODE, - NULL, DefaultTransform ); } diff --git a/eeschema/list_operations.h b/eeschema/list_operations.h index 28e68d546c..a62effb7be 100644 --- a/eeschema/list_operations.h +++ b/eeschema/list_operations.h @@ -24,13 +24,9 @@ #ifndef LIST_OPERATIONS_H #define LIST_OPERATIONS_H -namespace KIGFX { -class COLOR4D; -} class wxPoint; class wxDC; -class EDA_DRAW_PANEL; class SCH_ITEM; class SCH_SCREEN; class PICKED_ITEMS_LIST; @@ -40,21 +36,6 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, const wxPoint& rotationPo void MirrorY( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMirrorPoint ); void MirrorX( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMirrorPoint ); -/** - * Function DeleteItemsInList - * delete schematic items in aItemsList - * deleted items are put in undo list - */ -void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList ); - -/** - * Routine to copy a new entity of an object for each object in list and - * reposition it. - * Return the new created object list in aItemsList - */ -void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, - const wxPoint& aMoveVector ); - /** * Routine to create a new copy of given struct. * The new object is not put in draw list (not linked) @@ -67,7 +48,5 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, */ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone = false ); -void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, - const wxPoint& pos, const KIGFX::COLOR4D& Color ); #endif /* LIST_OPERATIONS_H */ diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 6bdc9fe122..b628557fdd 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 jean-pierre.charras - * Copyright (C) 2011-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2011-2019 KiCad Developers, see change_log.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 @@ -111,35 +111,11 @@ const EDA_RECT SCH_BITMAP::GetBoundingBox() const } -void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { wxPoint pos = m_pos + aOffset; - if( aColor == COLOR4D::UNSPECIFIED ) // Use normal drawing function - { - // https://bugs.launchpad.net/kicad/+bug/1529163 - // "Moving images in eeschema on OS X uses - // wrong position and shows image flipped" - // - // Original fix was to only GRSetDrawMode if aColor >= 0, but this made - // moving SCH_BITMAP work poorly on other platforms. -#ifndef __WXMAC__ - GRSetDrawMode( aDC, aDrawMode ); -#endif - - m_image->DrawBitmap( aDC, pos ); - } - else // draws bounding box only (used to move items) - { - GRSetDrawMode( aDC, aDrawMode ); - // To draw the rect, pos is the upper left corner position - wxSize size = m_image->GetSize(); - pos.x -= size.x / 2; - pos.y -= size.y / 2; - GRRect( aPanel->GetClipBox(), aDC, pos.x, pos.y, - pos.x + size.x, pos.y + size.y, 0, aColor ); - } + m_image->DrawBitmap( aDC, pos ); } diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 0ccea01821..1c9505f898 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 jean-pierre.charras - * Copyright (C) 2011-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2011-2019 KiCad Developers, see change_log.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 @@ -111,8 +111,7 @@ public: void SwapData( SCH_ITEM* aItem ) override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; /// @copydoc VIEW_ITEM::ViewGetLayers() virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 4518bf347b..696a4513ee 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -159,33 +159,13 @@ void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLis } -void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D color; + COLOR4D color = GetLayerColor( m_Layer ); EDA_RECT* clipbox = aPanel->GetClipBox(); - if( aColor != COLOR4D::UNSPECIFIED ) - color = aColor; - else - color = GetLayerColor( m_Layer ); - - GRSetDrawMode( aDC, aDrawMode ); - GRLine( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color ); - - if( m_isDanglingStart ) - { - GRCircle( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, - TARGET_BUSENTRY_RADIUS, 0, color ); - } - - if( m_isDanglingEnd ) - { - GRCircle( clipbox, aDC, m_End().x + aOffset.x, m_End().y + aOffset.y, - TARGET_BUSENTRY_RADIUS, 0, color ); - } } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 8d4fafc3f9..0b6b8120fe 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -85,8 +85,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; const EDA_RECT GetBoundingBox() const override; diff --git a/eeschema/sch_collectors.cpp b/eeschema/sch_collectors.cpp index f9c48a2e03..ad16e895e4 100644 --- a/eeschema/sch_collectors.cpp +++ b/eeschema/sch_collectors.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -367,7 +367,7 @@ public: // define pure virtuals: wxPoint GetPosition() const override { return wxPoint(); } void SetPosition( const wxPoint& ) override {} - void Draw( EDA_DRAW_PANEL* , wxDC* , const wxPoint& , GR_DRAWMODE , COLOR4D ) override {} + void Draw( EDA_DRAW_PANEL* , wxDC* , const wxPoint& ) override {} #if defined(DEBUG) void Show( int , std::ostream& ) const override {} diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index a8ed6514df..134a0d8488 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -60,7 +60,6 @@ #include -#define NULL_STRING "_NONAME_" /** * Function toUTFTildaText @@ -514,32 +513,15 @@ int SCH_COMPONENT::GetUnitCount() const } -void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor, bool aDrawPinText ) +void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { auto opts = PART_DRAW_OPTIONS::Default(); - opts.draw_mode = aDrawMode; - opts.color = aColor; opts.transform = m_transform; - opts.show_pin_text = aDrawPinText; opts.draw_visible_fields = false; opts.draw_hidden_fields = false; if( PART_SPTR part = m_part.lock() ) { - LIB_PINS libPins; - part->GetPins( libPins, m_unit, m_convert ); - - for( LIB_PIN *libPin : libPins ) - { - bool isDangling = true; - - if( m_pins.count( libPin ) ) - isDangling = m_pins.at( libPin ).IsDangling(); - - opts.dangling.push_back( isDangling ); - } - part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, opts ); } else // Use dummy() part if the actual cannot be found. @@ -550,14 +532,12 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff SCH_FIELD* field = GetField( REFERENCE ); if( field->IsVisible() ) - { - field->Draw( aPanel, aDC, aOffset, aDrawMode ); - } + field->Draw( aPanel, aDC, aOffset ); for( int ii = VALUE; ii < GetFieldCount(); ii++ ) { field = GetField( ii ); - field->Draw( aPanel, aDC, aOffset, aDrawMode ); + field->Draw( aPanel, aDC, aOffset ); } } @@ -604,7 +584,7 @@ wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet ) { wxString path = GetPath( sheet ); - wxString h_path, h_ref; + wxString h_path; wxStringTokenizer tokenizer; wxString separators( wxT( " " ) ); @@ -614,13 +594,7 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet ) h_path = tokenizer.GetNextToken(); if( h_path.Cmp( path ) == 0 ) - { - h_ref = tokenizer.GetNextToken(); - - /* printf( "GetRef hpath: %s\n", - * TO_UTF8( m_PathsAndReferences[ii] ) ); */ - return h_ref; - } + return tokenizer.GetNextToken(); } // if it was not found in m_Paths array, then see if it is in @@ -693,8 +667,7 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) SCH_FIELD* rf = GetField( REFERENCE ); if( rf->GetText().IsEmpty() - || ( abs( rf->GetTextPos().x - m_Pos.x ) + - abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) ) + || ( abs( rf->GetTextPos().x - m_Pos.x ) + abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) ) { // move it to a reasonable position rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) ); @@ -982,14 +955,10 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem ) // Reparent items after copying data // (after swap(), m_Parent member does not point to the right parent): for( int ii = 0; ii < component->GetFieldCount(); ++ii ) - { component->GetField( ii )->SetParent( component ); - } for( int ii = 0; ii < GetFieldCount(); ++ii ) - { GetField( ii )->SetParent( this ); - } std::swap( m_PathsAndReferences, component->m_PathsAndReferences ); } @@ -1237,12 +1206,6 @@ int SCH_COMPONENT::GetOrientation() } -wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& aPoint ) -{ - return m_transform.TransformCoordinate( aPoint ); -} - - #if defined(DEBUG) void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) const @@ -1325,9 +1288,7 @@ const EDA_RECT SCH_COMPONENT::GetBoundingBox() const EDA_RECT bbox = GetBodyBoundingBox(); for( size_t i = 0; i < m_Fields.size(); i++ ) - { bbox.Merge( m_Fields[i].GetBoundingBox() ); - } return bbox; } @@ -1353,8 +1314,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList return; if( g_CurrentSheet ) - aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), - GetRef( g_CurrentSheet ), + aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( g_CurrentSheet ), DARKCYAN ) ); msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" ); @@ -1362,8 +1322,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) ); // Display component reference in library and library - aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), - BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) ); if( alias->GetName() != part->GetName() ) aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) ); @@ -1404,12 +1363,11 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList if( libNickname.empty() ) { - aList.push_back( MSG_PANEL_ITEM( _( "Library" ), - _( "No library defined!!!" ), RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "No library defined!" ), RED ) ); } else { - msg.Printf( _( "Symbol not found in %s!!!" ), libNickname ); + msg.Printf( _( "Symbol not found in %s!" ), libNickname ); aList.push_back( MSG_PANEL_ITEM( _( "Library" ), msg , RED ) ); } } @@ -1876,9 +1834,7 @@ void SCH_COMPONENT::Plot( PLOTTER* aPlotter ) part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp ); for( size_t i = 0; i < m_Fields.size(); i++ ) - { m_Fields[i].Plot( aPlotter ); - } aPlotter->EndBlock( nullptr ); } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 0ccecfcd3c..34b939fbf4 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -282,17 +282,6 @@ public: */ int GetOrientation(); - /** - * Returns the coordinate points relative to the orientation of the symbol to \a aPoint. - * - * The coordinates are always relative to the anchor position of the component. - * - * @param aPoint The coordinates to transform. - * - * @return The transformed point. - */ - wxPoint GetScreenCoord( const wxPoint& aPoint ); - void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** @@ -476,28 +465,15 @@ public: */ SCH_PINS& GetPinMap(); - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override - { - Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true ); - } - /** - * Draw a component with or without pin text + * Draw a component * * @param aPanel is the panel to use (can be null) mainly used for clipping purposes. * @param aDC is the device context (can be null) * @param aOffset is the drawing offset (usually wxPoint(0,0), * but can be different when moving an object) - * @param aDrawMode is the drawing mode, GR_OR, GR_XOR, ... - * @param aColor use COLOR4D::UNSPECIFIED for the normal body item color or use this - * color if >= 0 - * @param aDrawPinText use true to draw pin texts, false to draw only the pin shape - * usually false to draw a component when moving it and true otherwise. */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor, - bool aDrawPinText ); + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; void SwapData( SCH_ITEM* aItem ) override; diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 9528fedae1..735adbd428 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -156,13 +156,6 @@ void SCH_DRAW_PANEL::DisplayComponent( const LIB_PART* aComponent ) } -void SCH_DRAW_PANEL::DisplaySheet( const SCH_SHEET* aSheet ) -{ - view()->Clear(); - view()->DisplaySheet( const_cast(aSheet) ); -} - - void SCH_DRAW_PANEL::DisplaySheet( const SCH_SCREEN *aScreen ) { view()->Clear(); diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index c52b133f96..0e3c2ed180 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -43,7 +43,6 @@ public: * @param aBoard is the PCB to be loaded. */ void DisplayComponent( const LIB_PART *aComponent ); - void DisplaySheet( const SCH_SHEET *aSheet ); void DisplaySheet( const SCH_SCREEN *aScreen ); /** diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index dfb38fc644..280e562e97 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -615,6 +615,22 @@ void SCH_EDIT_FRAME::HardRedraw() } +/* + * Redraws only the active window which is assumed to be whole visible. + */ +void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) +{ + if( GetScreen() == NULL ) + return; + + if( m_canvas->IsMouseCaptured() ) + m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); + + // Display the sheet filename, and the sheet path, for non root sheets + UpdateTitle(); +} + + void SCH_EDIT_FRAME::SetUndoItem( const SCH_ITEM* aItem ) { // if aItem != NULL, delete a previous m_undoItem, if exists @@ -1304,12 +1320,12 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, - void* aData ) +void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData ) { wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() ); - GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); + GRSetDrawMode( aDC, GR_DEFAULT_DRAWMODE ); + GetScreen()->Draw( m_canvas, aDC ); DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 469b46ef5a..fe59dd4514 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -150,8 +150,7 @@ int SCH_FIELD::GetPenSize() const } -void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { int orient; COLOR4D color; @@ -173,8 +172,6 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, if( ( !IsVisible() && !m_forceVisible) || IsVoid() ) return; - GRSetDrawMode( aDC, aDrawMode ); - // Calculate the text orientation according to the component orientation. orient = GetTextAngle(); @@ -201,23 +198,18 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, textpos = boundaryBox.Centre() + aOffset; if( m_forceVisible ) - { color = COLOR4D( DARKGRAY ); - } + else if( m_id == REFERENCE ) + color = GetLayerColor( LAYER_REFERENCEPART ); + else if( m_id == VALUE ) + color = GetLayerColor( LAYER_VALUEPART ); else - { - if( m_id == REFERENCE ) - color = GetLayerColor( LAYER_REFERENCEPART ); - else if( m_id == VALUE ) - color = GetLayerColor( LAYER_VALUEPART ); - else - color = GetLayerColor( LAYER_FIELDS ); - } + color = GetLayerColor( LAYER_FIELDS ); EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, - lineWidth, IsItalic(), IsBold() ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, lineWidth, IsItalic(), + IsBold() ); } @@ -227,16 +219,6 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) } -void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const -{ - aDest.SetId( GetId() ); - aDest.SetText( m_Text ); // Set field value - aDest.SetName( GetName() ); - - aDest.SetEffects( *this ); -} - - void SCH_FIELD::SwapData( SCH_ITEM* aItem ) { wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T), @@ -320,9 +302,7 @@ bool SCH_FIELD::IsVoid() const // that linked list is not thread-safe. std::lock_guard guard( m_mutex ); - size_t len = m_Text.Len(); - - return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) ); + return m_Text.Len() == 0; } @@ -335,7 +315,6 @@ void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) // save old cmp in undo list frame->SaveUndoItemInUndoList( component ); - Draw( frame->GetCanvas(), DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); ClearFlags(); frame->GetScreen()->SetCurItem( NULL ); frame->OnModify(); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index e91f3ea3dd..f4b4fb684a 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 @@ -131,18 +131,9 @@ public: */ void ImportValues( const LIB_FIELD& aSource ); - /** - * Function ImportValues - * copy parameters into a LIB_FIELD destination. - * Pointers and specific values (position) are not copied - * @param aDest = the LIB_FIELD to write - */ - void ExportValues(LIB_FIELD& aDest ) const; - int GetPenSize() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; // Geometric transforms (used in block operations): diff --git a/eeschema/sch_item_struct.h b/eeschema/sch_item_struct.h index 46b39c36bb..e61d754f6b 100644 --- a/eeschema/sch_item_struct.h +++ b/eeschema/sch_item_struct.h @@ -203,12 +203,8 @@ public: * @param aDC Device Context (can be null) * @param aOffset drawing Offset (usually wxPoint(0,0), * but can be different when moving an object) - * @param aDrawMode GR_OR, GR_XOR, ... - * @param aColor COLOR4D::UNSPECIFIED to use the normal body item color, - * or force this color if it is a valid color */ - virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) = 0; + virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) = 0; /** * Function Move diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index f8afc57774..4e25b1f874 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -91,19 +91,10 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const } -void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D color; - - auto conn = Connection( *g_CurrentSheet ); - - if( aColor != COLOR4D::UNSPECIFIED ) - color = aColor; - else - color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); - - GRSetDrawMode( aDC, aDrawMode ); + auto conn = Connection( *g_CurrentSheet ); + COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); GRFilledCircle( aPanel->GetClipBox(), aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, ( GetEffectiveSymbolSize() / 2 ), 0, color, color ); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 05391fe628..b3dfdfead8 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -2,7 +2,7 @@ * 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) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -63,8 +63,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; void Move( const wxPoint& aMoveVector ) override { diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index e1f2c24d91..c41204be7f 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -305,21 +305,10 @@ int SCH_LINE::GetPenSize() const } -void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE DrawMode, COLOR4D Color ) +void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) { - COLOR4D color; - int width = GetPenSize(); - - if( Color != COLOR4D::UNSPECIFIED ) - color = Color; - else if( m_color != COLOR4D::UNSPECIFIED ) - color = m_color; - else - color = GetLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - + COLOR4D color = ( m_color != COLOR4D::UNSPECIFIED ) ? m_color : GetLayerColor( m_Layer ); + int width = GetPenSize(); wxPoint start = m_start; wxPoint end = m_end; @@ -331,12 +320,6 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, GRLine( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y, width, color, getwxPenStyle( (PlotDashType) GetLineStyle() ) ); - - if( m_startIsDangling ) - DrawDanglingSymbol( panel, DC, start, color ); - - if( m_endIsDangling ) - DrawDanglingSymbol( panel, DC, end, color ); } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 92560d2a11..c1b25e7546 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -2,7 +2,7 @@ * 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) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -117,8 +117,7 @@ public: */ double GetLength() const; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; int GetPenSize() const override; diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index 46041483f5..ac9ae3eda7 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -2,7 +2,7 @@ * 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) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -71,24 +71,17 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const #endif -void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D color = m_Color; - COLOR4D tmp = color; + COLOR4D tmp = m_Color; if( GetMarkerType() == MARKER_BASE::MARKER_ERC ) { - color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ? - GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN ); + m_Color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ? + GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN ); } - if( aColor == COLOR4D::UNSPECIFIED ) - m_Color = color; - else - m_Color = aColor; - - DrawMarker( aPanel, aDC, aDrawMode, aOffset ); + DrawMarker( aPanel, aDC, aOffset ); m_Color = tmp; } diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index dde79949fd..b8c1fdf763 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2019 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 @@ -50,8 +50,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDraw_mode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; void Plot( PLOTTER* aPlotter ) override { diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 36a0c4f0af..0d2480c2ac 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanoadoo.fr - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -99,29 +99,19 @@ int SCH_NO_CONNECT::GetPenSize() const } -void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { int pX, pY; - int delta = GetSize() / 2; + int half = GetSize() / 2; int width = GetDefaultLineThickness(); pX = m_pos.x + aOffset.x; pY = m_pos.y + aOffset.y; - COLOR4D color; + COLOR4D color = GetLayerColor( LAYER_NOCONNECT ); - if( aColor != COLOR4D::UNSPECIFIED ) - color = aColor; - else - color = GetLayerColor( LAYER_NOCONNECT ); - - GRSetDrawMode( aDC, aDrawMode ); - - GRLine( aPanel->GetClipBox(), aDC, pX - delta, pY - delta, pX + delta, pY + delta, - width, color ); - GRLine( aPanel->GetClipBox(), aDC, pX + delta, pY - delta, pX - delta, pY + delta, - width, color ); + GRLine( aPanel->GetClipBox(), aDC, pX - half, pY - half, pX + half, pY + half, width, color ); + GRLine( aPanel->GetClipBox(), aDC, pX + half, pY - half, pX - half, pY + half, width, color ); } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 3a551929a7..04de56c226 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -2,7 +2,7 @@ * 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) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -62,8 +62,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index 0871aa3549..d879444d38 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -58,8 +58,7 @@ public: wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override {} + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override {} void Move( const wxPoint& aMoveVector ) override {} diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 093ef788a9..e3fe6c1eba 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -513,7 +513,7 @@ void SCH_SCREEN::UpdateSymbolLinks( bool aForce ) } -void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) { /* note: SCH_SCREEN::Draw is useful only for schematic. * library editor and library viewer do not use m_drawList, and therefore @@ -534,7 +534,7 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode else // uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox() // if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) ) - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor ); + item->Draw( aCanvas, aDC, wxPoint( 0, 0 ) ); // TODO(JE) Remove debugging code #ifdef DEBUG @@ -549,13 +549,13 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode auto text = SCH_TEXT( pos, label, SCH_TEXT_T ); text.SetTextSize( wxSize( sz, sz ) ); - text.Draw( aCanvas, aDC, wxPoint( 10, 10 ), aDrawMode, COLOR4D( LIGHTRED ) ); + text.Draw( aCanvas, aDC, wxPoint( 10, 10 ) ); } #endif } for( auto item : junctions ) - item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor ); + item->Draw( aCanvas, aDC, wxPoint( 0, 0 ) ); } diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index a248049101..dd999e8586 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -258,11 +258,8 @@ public: * * @param aCanvas The canvas item to draw on. * @param aDC The device context to draw on. - * @param aDrawMode The drawing mode. - * @param aColor The drawing color. */ - void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, - COLOR4D aColor = COLOR4D::UNSPECIFIED ); + void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ); /** * Plot all the schematic objects to \a aPlotter. diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 4adcbd1317..7f0ba0b17b 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -433,12 +433,9 @@ void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const } -void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor ) +void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { - COLOR4D txtcolor; wxString Text; - COLOR4D color; int name_orientation; wxPoint pos_sheetname,pos_filename; wxPoint pos = m_pos + aOffset; @@ -446,16 +443,9 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int textWidth; wxSize textSize; EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; + COLOR4D color = GetLayerColor( m_Layer ); - if( aColor != COLOR4D::UNSPECIFIED ) - color = aColor; - else - color = GetLayerColor( m_Layer ); - - GRSetDrawMode( aDC, aDrawMode ); - - GRRect( clipbox, aDC, pos.x, pos.y, - pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); + GRRect( clipbox, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); pos_sheetname = GetSheetNamePosition() + aOffset; pos_filename = GetFileNamePosition() + aOffset; @@ -466,38 +456,24 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, name_orientation = TEXT_ANGLE_HORIZ; /* Draw text : SheetName */ - if( aColor != COLOR4D::UNSPECIFIED ) - txtcolor = aColor; - else - txtcolor = GetLayerColor( LAYER_SHEETNAME ); - Text = wxT( "Sheet: " ) + m_name; textSize = wxSize( m_sheetNameSize, m_sheetNameSize ); textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - DrawGraphicText( clipbox, aDC, pos_sheetname, - txtcolor, Text, name_orientation, - textSize, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, textWidth, - false, false ); + DrawGraphicText( clipbox, aDC, pos_sheetname, GetLayerColor( LAYER_SHEETNAME ), Text, + name_orientation, textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, + textWidth, false, false ); /* Draw text : FileName */ - if( aColor != COLOR4D::UNSPECIFIED ) - txtcolor = aColor; - else - txtcolor = GetLayerColor( LAYER_SHEETFILENAME ); - Text = wxT( "File: " ) + m_fileName; textSize = wxSize( m_fileNameSize, m_fileNameSize ); textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - DrawGraphicText( clipbox, aDC, pos_filename, - txtcolor, Text, name_orientation, - textSize, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, textWidth, - false, false ); + DrawGraphicText( clipbox, aDC, pos_filename, GetLayerColor( LAYER_SHEETFILENAME ), Text, + name_orientation, textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, + textWidth, false, false ); /* Draw text : SheetLabel */ for( SCH_SHEET_PIN& sheetPin : m_pins ) - sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); + sheetPin.Draw( aPanel, aDC, aOffset ); } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 7d54a18a2c..23dc47fb48 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -111,8 +111,7 @@ public: */ bool IsMovableFromAnchorPoint() override { return true; } - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; /** * Calculate the graphic shape (a polygon) associated to the text. @@ -407,8 +406,7 @@ public: int GetPenSize() const override; - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, - GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override; + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; EDA_RECT const GetBoundingBox() const override; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 43ddb38952..11051ea598 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -69,15 +69,11 @@ EDA_ITEM* SCH_SHEET_PIN::Clone() const } -void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - const wxPoint& aOffset, - GR_DRAWMODE aDraw_mode, - COLOR4D aColor ) +void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) { // The icon selection is handle by the virtual method CreateGraphicShape // called by ::Draw - SCH_HIERLABEL::Draw( aPanel, aDC, aOffset, aDraw_mode, aColor ); + SCH_HIERLABEL::Draw( aPanel, aDC, aOffset ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 73b16076e2..118dfe9c85 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -305,33 +305,22 @@ int SCH_TEXT::GetPenSize() const } -void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, - GR_DRAWMODE DrawMode, COLOR4D Color ) +void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) { - COLOR4D color; + COLOR4D color = GetLayerColor( m_Layer ); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); - if( Color != COLOR4D::UNSPECIFIED ) - color = Color; - else - color = GetLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - wxPoint text_offset = aOffset + GetSchematicTextOffset(); int savedWidth = GetThickness(); SetThickness( linewidth ); // Set the minimum width - EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED ); + EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); SetThickness( savedWidth ); - - if( m_isDangling && panel) - DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color ); } @@ -823,24 +812,11 @@ void SCH_GLOBALLABEL::SetLabelSpinStyle( int aSpinStyle ) } -void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, - wxDC* DC, - const wxPoint& aOffset, - GR_DRAWMODE DrawMode, - COLOR4D Color ) +void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset ) { static std::vector Poly; - COLOR4D color; - wxPoint text_offset = aOffset + GetSchematicTextOffset(); - - if( Color != COLOR4D::UNSPECIFIED ) - color = Color; - else if( panel->GetScreen() && !panel->GetScreen()->m_IsPrinting && GetState( BRIGHTENED ) ) - color = GetLayerColor( LAYER_BRIGHTENED ); - else - color = GetLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); + COLOR4D color = GetLayerColor( m_Layer ); + wxPoint text_offset = aOffset + GetSchematicTextOffset(); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); @@ -850,23 +826,12 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, SetThickness( linewidth ); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; - EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED ); + EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); SetThickness( save_width ); // restore initial value CreateGraphicShape( Poly, GetTextPos() + aOffset ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); - - if( m_isDangling && panel ) - DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color ); - - // Enable these line to draw the bounding box (debug tests purposes only) -#if DRAW_BBOX - { - EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); - } -#endif } @@ -1087,51 +1052,26 @@ void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle ) } -void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, - wxDC* DC, - const wxPoint& offset, - GR_DRAWMODE DrawMode, - COLOR4D Color ) +void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) { static std::vector Poly; - COLOR4D color; + auto conn = Connection( *g_CurrentSheet ); + COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); - auto conn = Connection( *g_CurrentSheet ); - - if( Color != COLOR4D::UNSPECIFIED ) - color = Color; - else if( panel->GetScreen() && !panel->GetScreen()->m_IsPrinting && GetState( BRIGHTENED ) ) - color = GetLayerColor( LAYER_BRIGHTENED ); - else - color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - int save_width = GetThickness(); SetThickness( linewidth ); wxPoint text_offset = offset + GetSchematicTextOffset(); - EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED ); + EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE ); SetThickness( save_width ); // restore initial value CreateGraphicShape( Poly, GetTextPos() + offset ); GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); - - if( m_isDangling && panel ) - DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color ); - - // Enable these line to draw the bounding box (debug tests purposes only) -#if DRAW_BBOX - { - EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); - } -#endif } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 4da3cc5045..d3cfb8429d 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -130,8 +130,7 @@ public: */ virtual wxPoint GetSchematicTextOffset() const; - virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE draw_mode, COLOR4D Color ) override; + virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; /** * Calculate the graphic shape (a polygon) associated to the text. @@ -260,8 +259,7 @@ public: ~SCH_GLOBALLABEL() { } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE draw_mode, COLOR4D Color ) override; + void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; wxString GetClass() const override { @@ -306,8 +304,7 @@ public: ~SCH_HIERLABEL() { } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, - GR_DRAWMODE draw_mode, COLOR4D Color ) override; + void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; wxString GetClass() const override { diff --git a/include/marker_base.h b/include/marker_base.h index eb78050f6c..d54f80a43f 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -144,8 +144,7 @@ public: * Function DrawMarker * draws the shape is the polygon defined in m_Corners (array of wxPoints). */ - void DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ); + void DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ); /** * Function GetPos diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 893d534fba..ef4a7f81d7 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -91,7 +91,7 @@ public: void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override { - DrawMarker( aPanel, aDC, aDrawMode, aOffset ); + DrawMarker( aPanel, aDC, aOffset ); } const wxPoint GetPosition() const override { return m_Pos; }