Browse Source

Make sure marker zoom is correctly set before fetching scale.

master
Jeff Young 3 weeks ago
parent
commit
33f1ada4cd
  1. 11
      include/marker_base.h
  2. 1
      pcbnew/drc/drc_test_provider_clearance_base.cpp
  3. 2
      pcbnew/pcb_marker.cpp
  4. 11
      pcbnew/pcb_marker.h
  5. 14
      pcbnew/pcb_painter.cpp

11
include/marker_base.h

@ -67,7 +67,7 @@ public:
* The scaling factor to convert polygonal shape coordinates to internal units.
*/
int MarkerScale() const { return m_scalingFactor; }
void SetMarkerScale( int aScale ) { m_scalingFactor = aScale; }
void SetMarkerScale( int aScale ) const { m_scalingFactor = aScale; }
/**
* Return the shape polygon in internal units in a #SHAPE_LINE_CHAIN the coordinates
@ -145,11 +145,10 @@ protected:
wxString m_comment; ///< User supplied comment.
std::shared_ptr<RC_ITEM> m_rcItem;
int m_scalingFactor; ///< Scaling factor to convert corners coordinates
///< to internal units coordinates.
BOX2I m_shapeBoundingBox; ///< Bounding box of the graphic symbol relative
///< to the position of the shape in marker shape
///< units.
mutable int m_scalingFactor; ///< Scaling factor to convert corners coordinates to internal
///< units. Dependant on current zoom.
BOX2I m_shapeBoundingBox; ///< Bounding box of the graphic symbol relative to the position
///< of the shape in marker shape units.
};

1
pcbnew/drc/drc_test_provider_clearance_base.cpp

@ -59,6 +59,7 @@ DRC_TEST_PROVIDER_CLEARANCE_BASE::GetGraphicsHandler( const std::vector<PCB_SHAP
shortestPathShapes2.push_back( sh );
}
// Draw perpendicular end stops
if( shortestPathShapes1.size() > 0 )
{
PCB_SHAPE s1, s2;

2
pcbnew/pcb_marker.cpp

@ -363,7 +363,7 @@ KIGFX::COLOR4D PCB_MARKER::getColor() const
}
void PCB_MARKER::SetZoom( double aZoomFactor )
void PCB_MARKER::SetZoom( double aZoomFactor ) const
{
SetMarkerScale( SCALING_FACTOR * aZoomFactor );
}

11
pcbnew/pcb_marker.h

@ -22,8 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PCB_MARKER_H
#define PCB_MARKER_H
#pragma once
#include <board_item.h>
@ -32,10 +31,6 @@
#include <marker_base.h>
class DRC_ITEM;
// Coordinates count for the basic shape marker
#define MARKER_SHAPE_POINT_COUNT 9
class MSG_PANEL_ITEM;
@ -123,7 +118,7 @@ public:
BITMAPS GetMenuImage() const override;
void SetZoom( double aZoomFactor );
void SetZoom( double aZoomFactor ) const;
const BOX2I ViewBBox() const override;
@ -167,5 +162,3 @@ protected:
std::vector<PCB_SHAPE> m_shapes1; // Shown on LAYER_DRC_SHAPE1
std::vector<PCB_SHAPE> m_shapes2; // Shown on LAYER_DRC_SHAPE2
};
#endif // PCB_MARKER_H

14
pcbnew/pcb_painter.cpp

@ -3050,6 +3050,13 @@ void PCB_PAINTER::draw( const PCB_POINT* aPoint, int aLayer )
void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
{
// Don't paint invisible markers.
// It would be nice to do this through layer dependencies but we can't do an "or" there today
if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
return;
aMarker->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
switch( aLayer )
{
case LAYER_MARKER_SHADOWS:
@ -3058,13 +3065,6 @@ void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
{
bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
// Don't paint invisible markers.
// It would be nice to do this through layer dependencies but we can't do an "or" there today
if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
return;
const_cast<PCB_MARKER*>( aMarker )->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
SHAPE_LINE_CHAIN polygon;
aMarker->ShapeToPolygon( polygon );

Loading…
Cancel
Save