本文整理汇总了C++中QLine::setP2方法的典型用法代码示例。如果您正苦于以下问题:C++ QLine::setP2方法的具体用法?C++ QLine::setP2怎么用?C++ QLine::setP2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLine
的用法示例。
在下文中一共展示了QLine::setP2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cos
QHash<QString, QLine> Controller::coordinateAxes(Length length){
QLine x;
QLine y;
QLine z;
int size = length;
//z
z.setP1(QPoint(0, size));
z.setP2(QPoint(0, -size));
//x
x.setP1(QPoint( -size, 0));
x.setP2(QPoint(size, 0));
//z
y.setP1(QPoint(size * cos(_alpha * M_PI/180), -size * sin(_alpha * M_PI/180)));
y.setP2(QPoint(-size * cos(_alpha * M_PI/180), size * sin(_alpha * M_PI/180)));
QHash<QString, QLine> axes = {
{"X", x},
{"Y", y},
{"Z", z}
};
return axes;
}
示例2: extractBlackGuide
QLine extractBlackGuide(QImage input,QPoint start,bool hor) {
QLine line;
QPoint step(1,0);
if (!hor) {
// vertical movement
step = QPoint(0,1);
}
QPoint pt = start;
while (pt.x() < input.width() && pt.y() < input.height()) {
if (input.pixel(pt) == 0xFF000000) {
line.setP1(pt);
break;
}
pt += step;
}
while (pt.x() < input.width() && pt.y() < input.height()) {
if (input.pixel(pt) != 0xFF000000) {
line.setP2(pt);
break;
}
pt += step;
}
return line;
}
示例3: drawRobotPose
void map_widget::drawRobotPose(QPainter *painter , QPaintEvent *event)
{
QPoint Robot_Pose = this->convertToActFrame( sensor_connection->act_pose.x_pos,
sensor_connection->act_pose.y_pos,
event );
painter->setPen( QPen( Qt::red, 5, Qt::SolidLine, Qt::RoundCap) );
painter->drawPoint( Robot_Pose );
// Draw the orientatian;
// Berechne Steigung
const double lenght_of_orientation_line = 2.0;
double theta = sensor_connection->act_pose.theta;
while( theta >= (2* M_PI) )
{
theta -= (2* M_PI);
}
double skew_y = tan( theta );
double skew_x = 1.0;
if( theta == 0.5 * M_PI )
{
skew_y = 1.0;
skew_x = 0.0;
}
else if( theta == (3.0*M_PI)/2.0 )
{
skew_y = -1.0;
skew_x = 0.0;
}
else if( theta >= 0.5 * M_PI && theta < (3.0*M_PI)/2.0)
{
skew_y *= -1.0;
skew_x *= -1.0;
}
double distance = sqrt( (skew_x*skew_x) + (skew_y*skew_y) );
skew_x = (skew_x * lenght_of_orientation_line) / distance;
skew_y = (skew_y * lenght_of_orientation_line) / distance;
skew_x *= ((double) event->rect().width() / (double) this->visible_rect.width() );
skew_y *= ((double) event->rect().height() / (double) this->visible_rect.height() );
QLine line;
line.setP1( Robot_Pose );
line.setP2( QPoint(Robot_Pose.x() + skew_x, Robot_Pose.y() - skew_y) );
painter->setPen( QPen( Qt::red, 3, Qt::SolidLine, Qt::RoundCap) );
painter->drawLine( line );
}
示例4: testSet
void tst_QLine::testSet()
{
{
QLine l;
l.setP1(QPoint(1, 2));
l.setP2(QPoint(3, 4));
QCOMPARE(l.x1(), 1);
QCOMPARE(l.y1(), 2);
QCOMPARE(l.x2(), 3);
QCOMPARE(l.y2(), 4);
l.setPoints(QPoint(5, 6), QPoint(7, 8));
QCOMPARE(l.x1(), 5);
QCOMPARE(l.y1(), 6);
QCOMPARE(l.x2(), 7);
QCOMPARE(l.y2(), 8);
l.setLine(9, 10, 11, 12);
QCOMPARE(l.x1(), 9);
QCOMPARE(l.y1(), 10);
QCOMPARE(l.x2(), 11);
QCOMPARE(l.y2(), 12);
}
{
QLineF l;
l.setP1(QPointF(1, 2));
l.setP2(QPointF(3, 4));
QCOMPARE(l.x1(), 1.0);
QCOMPARE(l.y1(), 2.0);
QCOMPARE(l.x2(), 3.0);
QCOMPARE(l.y2(), 4.0);
l.setPoints(QPointF(5, 6), QPointF(7, 8));
QCOMPARE(l.x1(), 5.0);
QCOMPARE(l.y1(), 6.0);
QCOMPARE(l.x2(), 7.0);
QCOMPARE(l.y2(), 8.0);
l.setLine(9.0, 10.0, 11.0, 12.0);
QCOMPARE(l.x1(), 9.0);
QCOMPARE(l.y1(), 10.0);
QCOMPARE(l.x2(), 11.0);
QCOMPARE(l.y2(), 12.0);
}
}