20#include <boost/test/unit_test.hpp>
42 if( aRawScale < 1.25 )
44 else if( aRawScale < 1.75 )
57 return wxPoint(
static_cast<int>( aX * aScaleFactor ),
static_cast<int>( aY * aScaleFactor ) );
65wxSize
ScaleSize(
int aWidth,
int aHeight,
double aScaleFactor )
67 return wxSize(
static_cast<int>( aWidth * aScaleFactor ),
static_cast<int>( aHeight * aScaleFactor ) );
75bool IsOutOfBounds(
const wxPoint& aScaledPos,
const wxSize& aScaledSize,
const wxSize& aBitmapSize )
77 return ( aScaledPos.x + aScaledSize.GetWidth() > aBitmapSize.GetWidth() ||
78 aScaledPos.y + aScaledSize.GetHeight() > aBitmapSize.GetHeight() );
88 std::sort( aPositions.begin(), aPositions.end(),
91 return a.tabOrder < b.tabOrder;
191 wxSize size1x =
ScaleSize( width, height, 1.0 );
195 wxSize size1_5x =
ScaleSize( width, height, 1.5 );
199 wxSize size2x =
ScaleSize( width, height, 2.0 );
271 std::vector<DRC_RE_FIELD_POSITION> fields = {
289 std::vector<DRC_RE_FIELD_POSITION> fields = {
312 std::vector<DRC_RE_FIELD_POSITION> fields = {
335 std::vector<DRC_RE_FIELD_POSITION> fields = {
356 std::vector<DRC_RE_FIELD_POSITION> fields = { { 10, 50, 20, 1 } };
369 std::vector<DRC_RE_FIELD_POSITION> fields;
373 BOOST_CHECK( fields.empty() );
385 wxSize bitmapSize( 300, 200 );
388 wxPoint pos1( 10, 10 );
389 wxSize size1( 80, 24 );
393 wxPoint pos2( 220, 176 );
394 wxSize size2( 80, 24 );
398 wxPoint pos3( 0, 0 );
399 wxSize size3( 100, 50 );
408 wxSize bitmapSize( 300, 200 );
411 wxPoint pos( 250, 10 );
412 wxSize size( 80, 24 );
422 wxSize bitmapSize( 300, 200 );
425 wxPoint pos( 10, 180 );
426 wxSize size( 80, 30 );
436 wxSize bitmapSize( 300, 200 );
439 wxPoint pos( 250, 180 );
440 wxSize size( 80, 30 );
450 wxSize bitmapSize( 300, 200 );
454 wxSize size( 400, 300 );
471 wxSize bitmap1x( 300, 200 );
473 wxSize size1x =
ScaleSize( baseWidth, baseHeight, 1.0 );
477 wxSize bitmap1_5x( 450, 300 );
479 wxSize size1_5x =
ScaleSize( baseWidth, baseHeight, 1.5 );
480 BOOST_CHECK( !
IsOutOfBounds( pos1_5x, size1_5x, bitmap1_5x ) );
483 wxSize bitmap2x( 600, 400 );
485 wxSize size2x =
ScaleSize( baseWidth, baseHeight, 2.0 );
494 wxSize bitmapSize( 300, 200 );
497 wxPoint posExact( 220, 176 );
498 wxSize sizeExact( 80, 24 );
499 BOOST_CHECK( !
IsOutOfBounds( posExact, sizeExact, bitmapSize ) );
502 wxPoint posOverWidth( 221, 176 );
503 BOOST_CHECK(
IsOutOfBounds( posOverWidth, sizeExact, bitmapSize ) );
506 wxPoint posOverHeight( 220, 177 );
507 BOOST_CHECK(
IsOutOfBounds( posOverHeight, sizeExact, bitmapSize ) );
515 wxSize bitmapSize( 300, 200 );
519 wxSize zeroSize( 0, 0 );
523 wxPoint posEdge( 300, 200 );
524 BOOST_CHECK( !
IsOutOfBounds( posEdge, zeroSize, bitmapSize ) );
Helper functions that mirror the logic from DRC_RE_BITMAP_OVERLAY_PANEL.
void SortByTabOrder(std::vector< DRC_RE_FIELD_POSITION > &aPositions)
Sort field positions by tab order.
wxSize ScaleSize(int aWidth, int aHeight, double aScaleFactor)
Scale a size from 1x bitmap coordinates to display coordinates.
wxPoint ScalePosition(int aX, int aY, double aScaleFactor)
Scale a position from 1x bitmap coordinates to display coordinates.
double ComputeScaleFactor(double aRawScale)
Compute the scale factor from a raw content scale factor.
bool IsOutOfBounds(const wxPoint &aScaledPos, const wxSize &aScaledSize, const wxSize &aBitmapSize)
Check if a field position exceeds bitmap bounds.
Specifies the position and size of a field overlaid on a constraint bitmap.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(ScalePosition_1x)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")