diff --git a/3d-viewer/3d_canvas.h b/3d-viewer/3d_canvas.h index d4ad84cebf..b68541dfdf 100644 --- a/3d-viewer/3d_canvas.h +++ b/3d-viewer/3d_canvas.h @@ -80,7 +80,7 @@ public: EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList = 0 ); ~EDA_3D_CANVAS(); - EDA_3D_FRAME* Parent() { return (EDA_3D_FRAME*)GetParent(); } + EDA_3D_FRAME* Parent() const { return static_cast( GetParent() ); } BOARD* GetBoard() { return Parent()->GetBoard(); } diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 46c92053b7..c0f950a67a 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -81,7 +81,7 @@ public: m_auimgr.UnInit(); }; - PCB_BASE_FRAME* Parent() { return (PCB_BASE_FRAME*)GetParent(); } + PCB_BASE_FRAME* Parent() const { return (PCB_BASE_FRAME*)GetParent(); } BOARD* GetBoard(); diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 1e3adb750b..9ac1875616 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -165,7 +165,7 @@ EDA_DRAW_PANEL::~EDA_DRAW_PANEL() } -EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() +EDA_DRAW_FRAME* EDA_DRAW_PANEL::GetParent() const { wxWindow* mom = wxScrolledWindow::GetParent(); return (EDA_DRAW_FRAME*) mom; diff --git a/common/page_layout/page_layout_graphic_items.cpp b/common/page_layout/page_layout_graphic_items.cpp index aeb4b53696..c927e935df 100644 --- a/common/page_layout/page_layout_graphic_items.cpp +++ b/common/page_layout/page_layout_graphic_items.cpp @@ -192,7 +192,7 @@ void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) } // return true if the point aPosition is on the text -bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) +bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) const { return EDA_TEXT::TextHitTest( aPosition, 0 ); } @@ -221,7 +221,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) // return true if the point aPosition is inside one of polygons #include -bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) +bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) const { return TestPointInsidePolygon( &m_Corners[0], m_Corners.size(), aPosition ); @@ -249,7 +249,7 @@ void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) } // return true if the point aPosition is on the rect outline -bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition) +bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition) const { int dist = GetPenWidth()/2; wxPoint start = GetStart(); @@ -316,7 +316,7 @@ void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) } // return true if the point aPosition is on the text -bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) +bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) const { return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 ); } @@ -394,9 +394,9 @@ void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC ) * Virtual function * return true if the point aPosition is on bitmap */ -bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) +bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) const { - WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent(); + const WORKSHEET_DATAITEM_BITMAP* parent = static_cast( GetParent() ); if( parent->m_ImageBitmap == NULL ) return false; diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index 579aa44dc6..7078a8d8a8 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -52,7 +52,7 @@ public: int GetSelection(); void OnSize( wxSizeEvent& event ); - virtual CVPCB_MAINFRAME* GetParent(); + virtual CVPCB_MAINFRAME* GetParent() const; }; diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index d36d921625..bc7f364658 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -79,7 +79,7 @@ int ITEMS_LISTBOX_BASE::GetSelection() } -CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() +CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() const { return (CVPCB_MAINFRAME*) wxListView::GetParent(); } diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index a8c84ade03..a730d9d19b 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -654,14 +654,14 @@ public: */ void SetPartCount( int count ); - int GetPartCount() { return m_unitCount; } + int GetPartCount() const { return m_unitCount; } /** * Function IsMulti * @return true if the component has multiple parts per package. * When happens, the reference has a sub reference ti identify part */ - bool IsMulti() { return m_unitCount > 1; } + bool IsMulti() const { return m_unitCount > 1; } /** * Function SubReference diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index df4fb03f0d..686adbf8c0 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -171,7 +171,7 @@ bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) } -bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) +bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) const { int mindist = GetPenSize() / 2; @@ -183,7 +183,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) } -bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_ARC::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 2c017b9c20..74fc633071 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -100,9 +100,9 @@ public: bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint& aPosition, int aThreshold, const TRANSFORM& aTransform ) const; const EDA_RECT GetBoundingBox() const; // Virtual diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index b58e11cb6b..3378bb1603 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -345,7 +345,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& } -bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) +bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) const { int mindist = GetPenSize() / 2; @@ -357,7 +357,7 @@ bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) } -bool LIB_BEZIER::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_BEZIER::HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const { wxPoint ref, start, end; diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 00a320b43f..0a1be188f1 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -72,9 +72,9 @@ public: */ unsigned GetCornerCount() const { return m_PolyPoints.size(); } - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const; const EDA_RECT GetBoundingBox() const; // Virtual diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 204db95d5f..6a249ec740 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -87,7 +87,7 @@ bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) } -bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) +bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) const { int mindist = GetPenSize() / 2; @@ -99,7 +99,7 @@ bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) } -bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_CIRCLE::HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index 49f0f605ac..cbd0b31778 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -61,9 +61,9 @@ public: bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const; int GetPenSize( ) const; diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 8efffd827e..10e972eb4a 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -237,12 +237,12 @@ public: virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0; - LIB_COMPONENT* GetParent() + LIB_COMPONENT* GetParent() const { return (LIB_COMPONENT *)m_Parent; } - virtual bool HitTest( const wxPoint& aPosition ) + virtual bool HitTest( const wxPoint& aPosition ) const { return EDA_ITEM::HitTest( aPosition ); } @@ -255,7 +255,7 @@ public: * @param aTransform The transform matrix. * @return True if the point \a aPosition is near this object */ - virtual bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) = 0; + virtual bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const = 0; /** * @return the boundary box for this, in library coordinates diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 392daecc8c..36f43f8c0d 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -320,7 +320,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a } -bool LIB_FIELD::HitTest( const wxPoint& aPosition ) +bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const { // Because HitTest is mainly used to select the field // return always false if this field is void @@ -331,49 +331,37 @@ bool LIB_FIELD::HitTest( const wxPoint& aPosition ) } -bool LIB_FIELD::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = 0; - int extraCharCount = 0; + // Build a temporary copy of the text for hit testing + EDA_TEXT tmp_text( *this ); // Reference designator text has one or 2 additional character (displays // U? or U?A) if( m_id == REFERENCE ) { - extraCharCount++; - m_Text.Append('?'); - LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent; + wxString extended_text = tmp_text.GetText(); + extended_text.Append('?'); + const LIB_COMPONENT* parent = static_cast( m_Parent ); if ( parent && ( parent->GetPartCount() > 1 ) ) - { - m_Text.Append('A'); - extraCharCount++; - } + extended_text.Append('A'); + tmp_text.SetText( extended_text ); } - wxPoint physicalpos = aTransform.TransformCoordinate( m_Pos ); - wxPoint tmp = m_Pos; - m_Pos = physicalpos; + tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); - int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; - EXCHG( m_Orient, orient ); + tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT ); - bool hit = TextHitTest( aPosition ); - - EXCHG( m_Orient, orient ); - m_Pos = tmp; - - while( extraCharCount-- ) - m_Text.RemoveLast( ); - - return hit; + return tmp_text.TextHitTest( aPosition ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 1e475fa913..49e36d8be5 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -151,7 +151,7 @@ public: * Function IsVoid * @return true if the field value is void (no text in this field) */ - bool IsVoid() + bool IsVoid() const { return m_Text.IsEmpty(); } @@ -169,9 +169,9 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const; void operator=( const LIB_FIELD& field ) { diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index e4f16b3a8f..29c4aee929 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -525,13 +525,13 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) } -bool LIB_PIN::HitTest( const wxPoint& aPosition ) +bool LIB_PIN::HitTest( const wxPoint& aPosition ) const { return HitTest( aPosition, 0, DefaultTransform ); } -bool LIB_PIN::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_PIN::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = 0; diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index bf4c504776..dd85740de6 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -131,9 +131,9 @@ public: bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const; void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 5b4b1ba49c..75eae61c71 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -321,7 +321,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint } -bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) +bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) const { int mindist = GetPenSize() / 2; @@ -333,7 +333,7 @@ bool LIB_POLYLINE::HitTest( const wxPoint& aPosition ) } -bool LIB_POLYLINE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_POLYLINE::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { wxPoint ref, start, end; diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 81a4d8a08e..78a3891613 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -74,9 +74,9 @@ public: */ unsigned GetCornerCount() const { return m_PolyPoints.size(); } - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const; const EDA_RECT GetBoundingBox() const; // Virtual diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 7efdb3dbf1..057b049eb1 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -267,7 +267,7 @@ const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const } -bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) +bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) const { int mindist = ( GetPenSize() / 2 ) + 1; @@ -279,7 +279,7 @@ bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition ) } -bool LIB_RECTANGLE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_RECTANGLE::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 739f20b60e..63e182691d 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -65,9 +65,9 @@ public: bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const; int GetPenSize( ) const; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index d52acdda97..1b51b0f4e9 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -185,32 +185,27 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg ) } -bool LIB_TEXT::HitTest( const wxPoint& aPosition ) +bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const { return HitTest( aPosition, 0, DefaultTransform ); } -bool LIB_TEXT::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) +bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { if( aThreshold < 0 ) aThreshold = 0; - wxPoint physicalpos = aTransform.TransformCoordinate( m_Pos ); - wxPoint tmp = m_Pos; - m_Pos = physicalpos; + EDA_TEXT tmp_text( *this ); + tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) ); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 ); - int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; - EXCHG( m_Orient, orient ); - bool hit = TextHitTest( aPosition ); - EXCHG( m_Orient, orient ); - m_Pos = tmp; - return hit; + tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT ); + return tmp_text.TextHitTest( aPosition ); } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 3db14c11a8..8353869226 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -82,11 +82,11 @@ public: bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; - bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ); + bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const; - bool HitTest( EDA_RECT& aRect ) + bool HitTest( const EDA_RECT& aRect ) const { return TextHitTest( aRect ); } diff --git a/eeschema/sch_collectors.h b/eeschema/sch_collectors.h index 299ea9ec62..4813253919 100644 --- a/eeschema/sch_collectors.h +++ b/eeschema/sch_collectors.h @@ -210,7 +210,7 @@ public: wxString GetSheetPath() const { return m_sheetPath; } - SCH_ITEM* GetParent() { return m_parent; } + SCH_ITEM* GetParent() const { return m_parent; } }; diff --git a/gerbview/class_GERBER.h b/gerbview/class_GERBER.h index 632ac6487c..c975bf0233 100644 --- a/gerbview/class_GERBER.h +++ b/gerbview/class_GERBER.h @@ -148,7 +148,7 @@ public: * Function GetParent * @return the GERBVIEW_FRAME parent of this GERBER_IMAGE */ - GERBVIEW_FRAME* GetParent() + GERBVIEW_FRAME* GetParent() const { return m_Parent; } diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index c73d8972da..f01f3d5d55 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -131,7 +131,7 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition ) const } -wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) +wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition ) const { // do the inverse transform made by GetABPosition wxPoint xyPos = aABPosition; @@ -577,7 +577,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) } -bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) +bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const { // calculate aRefPos in XY gerber axis: wxPoint ref_pos = GetXYPosition( aRefPos ); @@ -592,7 +592,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) } -bool GERBER_DRAW_ITEM::HitTest( EDA_RECT& aRefArea ) +bool GERBER_DRAW_ITEM::HitTest( const EDA_RECT& aRefArea ) const { wxPoint pos = GetABPosition( m_Start ); diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index 70ad0a1164..c7a0b695cc 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -209,7 +209,7 @@ public: * @param aABPosition = position in A,B plotter axis * @return const wxPoint - The given position in X,Y axis. */ - wxPoint GetXYPosition( const wxPoint& aABPosition ); + wxPoint GetXYPosition( const wxPoint& aABPosition ) const; /** * Function GetDcodeDescr @@ -255,7 +255,7 @@ public: * @param aRefPos a wxPoint to test * @return bool - true if a hit, else false */ - bool HitTest( const wxPoint& aRefPos ); + bool HitTest( const wxPoint& aRefPos ) const; /** * Function HitTest (overloaded) @@ -264,7 +264,7 @@ public: * @param aRefArea a wxPoint to test * @return bool - true if a hit, else false */ - bool HitTest( EDA_RECT& aRefArea ); + bool HitTest( const EDA_RECT& aRefArea ) const; /** * Function GetClass diff --git a/include/base_struct.h b/include/base_struct.h index 9ec7af03c8..38e320ef38 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -456,14 +456,10 @@ public: * Function HitTest * tests if \a aPosition is contained within or on the bounding area of an item. * - * @note This function cannot be const because some of the derive objects perform - * intermediate calculations which change object members. Make sure derived - * objects do not declare this as const. - * * @param aPosition A reference to a wxPoint object containing the coordinates to test. * @return True if \a aPosition is within or on the item bounding area. */ - virtual bool HitTest( const wxPoint& aPosition ) + virtual bool HitTest( const wxPoint& aPosition ) const { return false; // derived classes should override this function } diff --git a/include/class_board_item.h b/include/class_board_item.h index 26a30af896..91fd3ead0c 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -254,7 +254,7 @@ public: */ wxString GetLayerName() const; - virtual bool HitTest( const wxPoint& aPosition ) + virtual bool HitTest( const wxPoint& aPosition ) const { return EDA_ITEM::HitTest( aPosition ); } diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 3a9c3735b7..d3e69371b3 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -123,7 +123,7 @@ public: BASE_SCREEN* GetScreen(); - EDA_DRAW_FRAME* GetParent(); + EDA_DRAW_FRAME* GetParent() const; void OnPaint( wxPaintEvent& event ); diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 5fe90cd69f..6a3d4913ba 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -291,7 +291,10 @@ public: bool IsConnected( const wxPoint& aPoint ) const; /** @copydoc EDA_ITEM::HitTest(const wxPoint&) */ - virtual bool HitTest( const wxPoint& aPosition ) { return HitTest( aPosition, 0 ); } + virtual bool HitTest( const wxPoint& aPosition ) const + { + return HitTest( aPosition, 0 ); + } /** * Function HitTest diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index de0bb5aa57..718213c9b7 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -59,7 +59,7 @@ public: EDA_COLOR_T GetColor() const { return m_color; } WS_DRAW_TYPE GetType() const { return m_type; }; - WORKSHEET_DATAITEM* GetParent() { return m_parent; } + WORKSHEET_DATAITEM* GetParent() const { return m_parent; } /** The function to draw a WS_DRAW_ITEM */ @@ -69,7 +69,7 @@ public: * Abstract function: should exist for derived items * return true if the point aPosition is on the item */ - virtual bool HitTest( const wxPoint& aPosition) = 0; + virtual bool HitTest( const wxPoint& aPosition) const = 0; /** * Abstract function: should exist for derived items @@ -124,7 +124,7 @@ public: * Virtual function * return true if the point aPosition is on the line */ - virtual bool HitTest( const wxPoint& aPosition); + virtual bool HitTest( const wxPoint& aPosition) const; /** * return true if the point aPosition is on the starting point of this item. @@ -174,7 +174,7 @@ public: * Virtual function * return true if the point aPosition is inside one polygon */ - virtual bool HitTest( const wxPoint& aPosition); + virtual bool HitTest( const wxPoint& aPosition) const; /** * return true if the point aPosition is on the starting point of this item. @@ -202,7 +202,7 @@ public: * Virtual function * return true if the point aPosition is on one edge of the rectangle */ - virtual bool HitTest( const wxPoint& aPosition); + virtual bool HitTest( const wxPoint& aPosition) const; /** * return true if the point aPosition is on the starting point of this item. @@ -239,7 +239,7 @@ public: * Virtual function * return true if the point aPosition is on the text */ - virtual bool HitTest( const wxPoint& aPosition); + virtual bool HitTest( const wxPoint& aPosition) const; /** * return true if the point aPosition is on the starting point of this item. @@ -274,7 +274,7 @@ public: * Virtual function * return true if the point aPosition is on bitmap */ - virtual bool HitTest( const wxPoint& aPosition); + virtual bool HitTest( const wxPoint& aPosition) const; /** * return true if the point aPosition is on the reference point of this item. diff --git a/kicad/class_treeprojectfiles.h b/kicad/class_treeprojectfiles.h index b671a02e0f..6d592d4696 100644 --- a/kicad/class_treeprojectfiles.h +++ b/kicad/class_treeprojectfiles.h @@ -17,7 +17,7 @@ private: public: - TREE_PROJECT_FRAME* GetParent() + TREE_PROJECT_FRAME* GetParent() const { return m_Parent; } diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index e49ca7e5dd..59ff184ddc 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -396,7 +396,7 @@ void DIMENSION::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) } -bool DIMENSION::HitTest( const wxPoint& aPosition ) +bool DIMENSION::HitTest( const wxPoint& aPosition ) const { if( m_Text.TextHitTest( aPosition ) ) return true; diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 1ea29bd8dc..d68fc7770d 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -127,7 +127,7 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, * bool aContained = true, int aAccuracy ) const diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index d1e9799258..2c976e90ee 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -475,7 +475,7 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const } -bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) +bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const { switch( m_Shape ) { diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 64ce5dcb8c..3cae1d9dcf 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -178,7 +178,7 @@ public: virtual const EDA_RECT GetBoundingBox() const; - virtual bool HitTest( const wxPoint& aPosition ); + virtual bool HitTest( const wxPoint& aPosition ) const; /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, * bool aContained = true, int aAccuracy ) const diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 7728b152c0..5e794a743c 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -64,7 +64,7 @@ public: const wxPoint& GetPosition() const { return m_Pos; } void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } - bool HitTest( const wxPoint& aPosition ) + bool HitTest( const wxPoint& aPosition ) const { return HitTestMarker( aPosition ); } diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index d2fb096755..3abeaf95d0 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -158,7 +158,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, } -bool PCB_TARGET::HitTest( const wxPoint& aPosition ) +bool PCB_TARGET::HitTest( const wxPoint& aPosition ) const { int dX = aPosition.x - m_Pos.x; int dY = aPosition.y - m_Pos.y; diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index 0a7186b6b1..9f12ac7d73 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -82,7 +82,7 @@ public: void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, * bool aContained = true, int aAccuracy ) const diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index ca343a6333..257f34bd6e 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -549,7 +549,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) } -bool MODULE::HitTest( const wxPoint& aPosition ) +bool MODULE::HitTest( const wxPoint& aPosition ) const { if( m_BoundaryBox.Contains( aPosition ) ) return true; diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 189abfe6be..3b378c30a6 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -324,7 +324,7 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, * bool aContained = true, int aAccuracy ) const diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 43b2b17f04..f4a1282ed7 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -637,7 +637,7 @@ bool D_PAD::IsOnLayer( LAYER_NUM aLayer ) const } -bool D_PAD::HitTest( const wxPoint& aPosition ) +bool D_PAD::HitTest( const wxPoint& aPosition ) const { int dx, dy; diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 3cbdcbe82a..41ac5c3913 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -341,7 +341,7 @@ public: * Function GetBoundingRadius * returns the radius of a minimum sized circle which fully encloses this pad. */ - int GetBoundingRadius() + int GetBoundingRadius() const { // Any member function which would affect this calculation should set // m_boundingRadius to -1 to re-trigger the calculation from here. @@ -368,7 +368,7 @@ public: bool IsOnLayer( LAYER_NUM aLayer ) const; - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; wxString GetClass() const { @@ -450,7 +450,8 @@ private: */ int boundingRadius() const; - int m_boundingRadius; ///< radius of the circle containing the pad shape + // Actually computed and cached on demand by the accessor + mutable int m_boundingRadius; ///< radius of the circle containing the pad shape /// Pad name (4 char) or a long identifier (used in pad name /// comparisons because this is faster than string comparison) diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 0ebd4119bf..7a6d853704 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -76,7 +76,7 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); - bool HitTest( const wxPoint& aPosition ) + bool HitTest( const wxPoint& aPosition ) const { return TextHitTest( aPosition ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index e5e7a2d2be..b103869775 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -163,7 +163,7 @@ void TEXTE_MODULE::SetLocalCoord() RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle ); } -bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) +bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const { wxPoint rel_pos; EDA_RECT area = GetTextBox( -1, -1 ); @@ -455,6 +455,9 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const case LAYER_N_FRONT: aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about SILKSCREEN_N_FRONT? break; + + default: + wxFAIL_MSG( wxT( "Can't tell text layer" ) ); } break; } diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index bc207e7254..7ab96e516b 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -148,7 +148,7 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); - bool HitTest( const wxPoint& aPosition ); + bool HitTest( const wxPoint& aPosition ) const; wxString GetClass() const { diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 2dd626a5c8..7a40e066fb 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1236,7 +1236,7 @@ bool TRACK::HitTest( const wxPoint& aPosition ) return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 ); } -bool VIA::HitTest( const wxPoint& aPosition ) +bool VIA::HitTest( const wxPoint& aPosition ) const { int max_dist = m_Width / 2; diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 9afc346788..4340c33e6d 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -401,7 +401,7 @@ public: const wxPoint& GetPosition() const { return m_Start; } // was overload void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } // was overload - virtual bool HitTest( const wxPoint& aPosition ); + virtual bool HitTest( const wxPoint& aPosition ) const; virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const; diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 6679fee49a..a6b360f98a 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -440,37 +440,42 @@ int ZONE_CONTAINER::GetThermalReliefCopperBridge( D_PAD* aPad ) const } -bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) +bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) const { - if( HitTestForCorner( aPosition ) ) + if( HitTestForCorner( aPosition ) >= 0 ) return true; - if( HitTestForEdge( aPosition ) ) + if( HitTestForEdge( aPosition ) >= 0 ) return true; return false; } +void ZONE_CONTAINER::SetSelectedCorner( const wxPoint& aPosition ) +{ + m_CornerSelection = HitTestForCorner( aPosition ); + + if( m_CornerSelection < 0 ) + m_CornerSelection = HitTestForEdge( aPosition ); +} + + // Zones outlines have no thickness, so it Hit Test functions // we must have a default distance between the test point // and a corner or a zone edge: #define MAX_DIST_IN_MM 0.25 -bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) +int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) const { int distmax = Millimeter2iu( MAX_DIST_IN_MM ); - m_CornerSelection = m_Poly->HitTestForCorner( refPos, distmax ); - - return m_CornerSelection >= 0; + return m_Poly->HitTestForCorner( refPos, distmax ); } -bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) +int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) const { int distmax = Millimeter2iu( MAX_DIST_IN_MM ); - m_CornerSelection = m_Poly->HitTestForEdge( refPos, distmax ); - - return m_CornerSelection >= 0; + return m_Poly->HitTestForEdge( refPos, distmax ); } @@ -700,25 +705,23 @@ void ZONE_CONTAINER::Move( const wxPoint& offset ) } -void ZONE_CONTAINER::MoveEdge( const wxPoint& offset ) +void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge ) { - int ii = m_CornerSelection; - // Move the start point of the selected edge: - SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); + SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset ); // Move the end point of the selected edge: - if( m_Poly->m_CornersList.IsEndContour( ii ) || ii == GetNumCorners() - 1 ) + if( m_Poly->m_CornersList.IsEndContour( aEdge ) || aEdge == GetNumCorners() - 1 ) { - int icont = m_Poly->GetContour( ii ); - ii = m_Poly->GetContourStart( icont ); + int icont = m_Poly->GetContour( aEdge ); + aEdge = m_Poly->GetContourStart( icont ); } else { - ii++; + aEdge++; } - SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); + SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset ); m_Poly->Hatch(); } diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 6423d85396..2642937d06 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -217,6 +217,10 @@ public: int GetSelectedCorner() const { return m_CornerSelection; } void SetSelectedCorner( int aCorner ) { m_CornerSelection = aCorner; } + /// + // Like HitTest but selects the current corner to be operated on + void SetSelectedCorner( const wxPoint& aPosition ); + int GetLocalFlags() const { return m_localFlgs; } void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; } @@ -234,7 +238,7 @@ public: * @param aRefPos A wxPoint to test * @return bool - true if a hit, else false */ - virtual bool HitTest( const wxPoint& aPosition ); + virtual bool HitTest( const wxPoint& aPosition ) const; /** * Function HitTest @@ -342,7 +346,7 @@ public: * @return true if found * @param refPos : A wxPoint to test */ - bool HitTestForCorner( const wxPoint& refPos ); + int HitTestForCorner( const wxPoint& refPos ) const; /** * Function HitTestForEdge @@ -351,7 +355,7 @@ public: * @return true if found * @param refPos : A wxPoint to test */ - bool HitTestForEdge( const wxPoint& refPos ); + int HitTestForEdge( const wxPoint& refPos ) const; /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect, * bool aContained = true, int aAccuracy ) const @@ -400,10 +404,11 @@ public: /** * Function MoveEdge - * Move the outline Edge. m_CornerSelection is the start point of the outline edge + * Move the outline Edge * @param offset = moving vector + * @param aEdge = start point of the outline edge */ - void MoveEdge( const wxPoint& offset ); + void MoveEdge( const wxPoint& offset, int aEdge ); /** * Function Rotate diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index d6f8a79583..06f07af712 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -160,8 +161,9 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) (*m_Collector)[i]->Show( 0, std::cout ); #endif - /* Remove redundancies: sometime, zones are found twice, + /* Remove redundancies: sometime, legacy zones are found twice, * because zones can be filled by overlapping segments (this is a fill option) + * Trigger the selection of the current edge for new-style zones */ time_t timestampzone = 0; @@ -169,18 +171,32 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) { item = (*m_Collector)[ii]; - if( item->Type() != PCB_ZONE_T ) - continue; + switch( item->Type() ) + { + case PCB_ZONE_T: + // Found a TYPE ZONE + if( item->GetTimeStamp() == timestampzone ) // Remove it, redundant, zone already found + { + m_Collector->Remove( ii ); + ii--; + } + else + { + timestampzone = item->GetTimeStamp(); + } + break; - // Found a TYPE ZONE - if( item->GetTimeStamp() == timestampzone ) // Remove it, redundant, zone already found - { - m_Collector->Remove( ii ); - ii--; - } - else - { - timestampzone = item->GetTimeStamp(); + case PCB_ZONE_AREA_T: + { + /* We need to do the selection now because the menu text + * depends on it */ + ZONE_CONTAINER *zone = static_cast( item ); + zone->SetSelectedCorner( RefPos( true ) ); + } + break; + + default: + break; } } diff --git a/pcbnew/dialogs/dialog_general_options.h b/pcbnew/dialogs/dialog_general_options.h index 7cdefdbe2e..89abaa7b1b 100644 --- a/pcbnew/dialogs/dialog_general_options.h +++ b/pcbnew/dialogs/dialog_general_options.h @@ -16,7 +16,7 @@ public: void OnOkClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); - PCB_EDIT_FRAME* GetParent() { return (PCB_EDIT_FRAME*) wxDialog::GetParent(); } + PCB_EDIT_FRAME* GetParent() const { return (PCB_EDIT_FRAME*) wxDialog::GetParent(); } private: void OnMiddleBtnPanEnbl( wxCommandEvent& event ) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index a78007761b..4f93574ab2 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -2234,6 +2234,8 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, CPTREE& aTree ) const case ECO1_N: layer = SILKSCREEN_N_FRONT; break; case ECO2_N: layer = SILKSCREEN_N_BACK; break; */ + default: + break; } gr->SetLayer( layer ); diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index c66adc4c64..372538c1b1 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -661,14 +661,14 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* edge_zone->GetIsKeepout() ? _("Keepout Area") : _( "Zones" ), KiBitmap( add_zone_xpm ) ); - if( edge_zone->HitTestForCorner( RefPos( true ) ) ) + if( edge_zone->HitTestForCorner( RefPos( true ) ) >= 0 ) { AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER, _( "Move Corner" ), KiBitmap( move_xpm ) ); AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER, _( "Delete Corner" ), KiBitmap( delete_xpm ) ); } - else if( edge_zone->HitTestForEdge( RefPos( true ) ) ) + else if( edge_zone->HitTestForEdge( RefPos( true ) ) >= 0 ) { AddMenuItem( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER, _( "Create Corner" ), KiBitmap( add_corner_xpm ) ); diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index e2349c4800..825be77e57 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -401,9 +401,9 @@ struct hitVisitor { PNS_ITEMSET& m_items; const VECTOR2I& m_point; - PNS_NODE* m_world; + const PNS_NODE* m_world; - hitVisitor( PNS_ITEMSET& aTab, const VECTOR2I& aPoint, PNS_NODE* aWorld ) : + hitVisitor( PNS_ITEMSET& aTab, const VECTOR2I& aPoint, const PNS_NODE* aWorld ) : m_items( aTab ), m_point( aPoint ), m_world( aWorld ) {}; bool operator()( PNS_ITEM* aItem ) @@ -423,7 +423,7 @@ struct hitVisitor }; -const PNS_ITEMSET PNS_NODE::HitTest( const VECTOR2I& aPoint ) +const PNS_ITEMSET PNS_NODE::HitTest( const VECTOR2I& aPoint ) const { PNS_ITEMSET items; // fixme: we treat a point as an infinitely small circle - this is inefficient. diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index f88b74bd4f..de3e886dc2 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -140,7 +140,7 @@ public: int aKindMask = PNS_ITEM::ANY ); ///> Hit detection - const PNS_ITEMSET HitTest( const VECTOR2I& aPoint ); + const PNS_ITEMSET HitTest( const VECTOR2I& aPoint ) const; void Add( PNS_ITEM* aItem ); void Remove( PNS_ITEM* aItem ); diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 44f669fce8..7b40a598e8 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -433,9 +433,9 @@ void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) } else if( zone->IsDragging() ) { - wxPoint offset; - offset = s_CornerInitialPosition - s_CursorLastPosition; - zone->MoveEdge( offset ); + wxPoint offset = s_CornerInitialPosition - s_CursorLastPosition; + int selection = zone->GetSelectedCorner(); + zone->MoveEdge( offset, selection ); } else { @@ -485,9 +485,9 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* } else if( zone->IsDragging() ) { - wxPoint offset; - offset = pos - s_CursorLastPosition; - zone->MoveEdge( offset ); + wxPoint offset = pos - s_CursorLastPosition; + int selection = zone->GetSelectedCorner(); + zone->MoveEdge( offset, selection ); s_CursorLastPosition = pos; } else diff --git a/polygon/polygon_test_point_inside.cpp b/polygon/polygon_test_point_inside.cpp index aafade407c..f63d9ba9d7 100644 --- a/polygon/polygon_test_point_inside.cpp +++ b/polygon/polygon_test_point_inside.cpp @@ -96,7 +96,7 @@ bool TestPointInsidePolygon( const CPOLYGONS_LIST& aPolysList, /* Function TestPointInsidePolygon (overlaid) * same as previous, but use wxPoint and aCount corners */ -bool TestPointInsidePolygon( wxPoint *aPolysList, int aCount,wxPoint aRefPoint ) +bool TestPointInsidePolygon( const wxPoint *aPolysList, int aCount, const wxPoint &aRefPoint ) { // count intersection points to right of (refx,refy). If odd number, point (refx,refy) is inside polyline int ics, ice; diff --git a/polygon/polygon_test_point_inside.h b/polygon/polygon_test_point_inside.h index b817380d1c..ff43798159 100644 --- a/polygon/polygon_test_point_inside.h +++ b/polygon/polygon_test_point_inside.h @@ -34,6 +34,6 @@ bool TestPointInsidePolygon( const CPOLYGONS_LIST& aPolysList, * @param aRefPoint: the point coordinate to test * @return true if the point is inside, false for outside */ -bool TestPointInsidePolygon( wxPoint* aPolysList, +bool TestPointInsidePolygon( const wxPoint* aPolysList, int aCount, - wxPoint aRefPoint ); + const wxPoint &aRefPoint );