24#include <boost/test/unit_test.hpp>
46 if( aRawScale < 1.25 )
48 else if( aRawScale < 1.75 )
61 return wxPoint(
static_cast<int>( aX * aScaleFactor ),
static_cast<int>( aY * aScaleFactor ) );
69wxSize
ScaleSize(
int aWidth,
int aHeight,
double aScaleFactor )
71 return wxSize(
static_cast<int>( aWidth * aScaleFactor ),
static_cast<int>( aHeight * aScaleFactor ) );
79bool IsOutOfBounds(
const wxPoint& aScaledPos,
const wxSize& aScaledSize,
const wxSize& aBitmapSize )
81 return ( aScaledPos.x + aScaledSize.GetWidth() > aBitmapSize.GetWidth() ||
82 aScaledPos.y + aScaledSize.GetHeight() > aBitmapSize.GetHeight() );
92 std::sort( aPositions.begin(), aPositions.end(),
95 return a.tabOrder < b.tabOrder;
195 wxSize size1x =
ScaleSize( width, height, 1.0 );
199 wxSize size1_5x =
ScaleSize( width, height, 1.5 );
203 wxSize size2x =
ScaleSize( width, height, 2.0 );
275 std::vector<DRC_RE_FIELD_POSITION> fields = {
293 std::vector<DRC_RE_FIELD_POSITION> fields = {
316 std::vector<DRC_RE_FIELD_POSITION> fields = {
339 std::vector<DRC_RE_FIELD_POSITION> fields = {
360 std::vector<DRC_RE_FIELD_POSITION> fields = { { 10, 50, 20, 1 } };
373 std::vector<DRC_RE_FIELD_POSITION> fields;
377 BOOST_CHECK( fields.empty() );
389 wxSize bitmapSize( 300, 200 );
392 wxPoint pos1( 10, 10 );
393 wxSize size1( 80, 24 );
397 wxPoint pos2( 220, 176 );
398 wxSize size2( 80, 24 );
402 wxPoint pos3( 0, 0 );
403 wxSize size3( 100, 50 );
412 wxSize bitmapSize( 300, 200 );
415 wxPoint pos( 250, 10 );
416 wxSize size( 80, 24 );
426 wxSize bitmapSize( 300, 200 );
429 wxPoint pos( 10, 180 );
430 wxSize size( 80, 30 );
440 wxSize bitmapSize( 300, 200 );
443 wxPoint pos( 250, 180 );
444 wxSize size( 80, 30 );
454 wxSize bitmapSize( 300, 200 );
458 wxSize size( 400, 300 );
475 wxSize bitmap1x( 300, 200 );
477 wxSize size1x =
ScaleSize( baseWidth, baseHeight, 1.0 );
481 wxSize bitmap1_5x( 450, 300 );
483 wxSize size1_5x =
ScaleSize( baseWidth, baseHeight, 1.5 );
484 BOOST_CHECK( !
IsOutOfBounds( pos1_5x, size1_5x, bitmap1_5x ) );
487 wxSize bitmap2x( 600, 400 );
489 wxSize size2x =
ScaleSize( baseWidth, baseHeight, 2.0 );
498 wxSize bitmapSize( 300, 200 );
501 wxPoint posExact( 220, 176 );
502 wxSize sizeExact( 80, 24 );
503 BOOST_CHECK( !
IsOutOfBounds( posExact, sizeExact, bitmapSize ) );
506 wxPoint posOverWidth( 221, 176 );
507 BOOST_CHECK(
IsOutOfBounds( posOverWidth, sizeExact, bitmapSize ) );
510 wxPoint posOverHeight( 220, 177 );
511 BOOST_CHECK(
IsOutOfBounds( posOverHeight, sizeExact, bitmapSize ) );
519 wxSize bitmapSize( 300, 200 );
523 wxSize zeroSize( 0, 0 );
527 wxPoint posEdge( 300, 200 );
528 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")