本文整理汇总了C++中KoSelection::size方法的典型用法代码示例。如果您正苦于以下问题:C++ KoSelection::size方法的具体用法?C++ KoSelection::size怎么用?C++ KoSelection::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoSelection
的用法示例。
在下文中一共展示了KoSelection::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSize
void TestSelection::testSize()
{
KoSelection selection;
MockShape shape1;
shape1.setSize( QSizeF( 100, 100 ) );
shape1.setPosition( QPointF( 0, 0 ) );
selection.select( &shape1 );
QCOMPARE(selection.size(), QSizeF( 100, 100 ));
MockShape shape2;
shape2.setSize( QSizeF( 100, 100 ) );
shape2.setPosition( QPointF( 100, 100 ) );
selection.select( &shape2 );
QCOMPARE(selection.size(), QSizeF( 200, 200 ));
MockShape shape3;
shape3.setSize( QSizeF( 100, 100 ) );
shape3.setPosition( QPointF( 200, 200 ) );
selection.select( &shape3 );
QCOMPARE(selection.size(), QSizeF( 300, 300 ));
selection.deselect( &shape3 );
QCOMPARE(selection.size(), QSizeF( 200, 200 ));
selection.deselect( &shape2 );
QCOMPARE(selection.size(), QSizeF( 100, 100 ));
}
示例2: if
ShapeShearStrategy::ShapeShearStrategy( KoToolBase *tool, const QPointF &clicked, KoFlake::SelectionHandle direction )
: KoInteractionStrategy(tool)
, m_start(clicked)
{
KoSelection *sel = tool->canvas()->shapeManager()->selection();
QList<KoShape*> selectedShapes = sel->selectedShapes(KoFlake::StrippedSelection);
foreach(KoShape *shape, selectedShapes) {
if( ! shape->isEditable() )
continue;
m_selectedShapes << shape;
m_oldTransforms << shape->transformation();
}
m_initialSelectionMatrix = sel->transformation();
// Eventhoug we aren't currently activated by the corner handles we might as well code like it
switch(direction) {
case KoFlake::TopMiddleHandle:
m_top = true; m_bottom = false; m_left = false; m_right = false; break;
case KoFlake::TopRightHandle:
m_top = true; m_bottom = false; m_left = false; m_right = true; break;
case KoFlake::RightMiddleHandle:
m_top = false; m_bottom = false; m_left = false; m_right = true; break;
case KoFlake::BottomRightHandle:
m_top = false; m_bottom = true; m_left = false; m_right = true; break;
case KoFlake::BottomMiddleHandle:
m_top = false; m_bottom = true; m_left = false; m_right = false; break;
case KoFlake::BottomLeftHandle:
m_top = false; m_bottom = true; m_left = true; m_right = false; break;
case KoFlake::LeftMiddleHandle:
m_top = false; m_bottom = false; m_left = true; m_right = false; break;
case KoFlake::TopLeftHandle:
m_top = true; m_bottom = false; m_left = true; m_right = false; break;
default:
;// throw exception ? TODO
}
m_initialSize = sel->size();
m_solidPoint = QPointF( m_initialSize.width() / 2, m_initialSize.height() / 2);
if(m_top)
m_solidPoint += QPointF(0, m_initialSize.height() / 2);
else if(m_bottom)
m_solidPoint -= QPointF(0, m_initialSize.height() / 2);
if(m_left)
m_solidPoint += QPointF(m_initialSize.width() / 2, 0);
else if(m_right)
m_solidPoint -= QPointF(m_initialSize.width() / 2, 0);
QPointF edge;
qreal angle = 0.0;
if( m_top )
{
edge = sel->absolutePosition( KoFlake::BottomLeftCorner ) - sel->absolutePosition( KoFlake::BottomRightCorner );
angle = 180.0;
}
else if( m_bottom )
{
edge = sel->absolutePosition( KoFlake::TopRightCorner ) - sel->absolutePosition( KoFlake::TopLeftCorner );
angle = 0.0;
}
else if( m_left )
{
edge = sel->absolutePosition( KoFlake::BottomLeftCorner ) - sel->absolutePosition( KoFlake::TopLeftCorner );
angle = 90.0;
}
else if( m_right )
{
edge = sel->absolutePosition( KoFlake::TopRightCorner ) - sel->absolutePosition( KoFlake::BottomRightCorner );
angle = 270.0;
}
qreal currentAngle = atan2( edge.y(), edge.x() ) / M_PI * 180;
m_initialSelectionAngle = currentAngle - angle;
kDebug(30006) <<" PREsol.x=" << m_solidPoint.x() <<" sol.y=" << m_solidPoint.y();
m_solidPoint = tool->canvas()->shapeManager()->selection()->absoluteTransformation(0).map( m_solidPoint );
// use crossproduct of top edge and left edge of selection bounding rect
// to determine if the selection is mirrored
QPointF top = sel->absolutePosition( KoFlake::TopRightCorner ) - sel->absolutePosition( KoFlake::TopLeftCorner );
QPointF left = sel->absolutePosition( KoFlake::BottomLeftCorner ) - sel->absolutePosition( KoFlake::TopLeftCorner );
m_isMirrored = (top.x()*left.y() - top.y()*left.x() ) < 0.0;
}