本文整理汇总了C++中QVector2D::y方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector2D::y方法的具体用法?C++ QVector2D::y怎么用?C++ QVector2D::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector2D
的用法示例。
在下文中一共展示了QVector2D::y方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPlayerAtChild
bool EnvPortal::GetPlayerAtChild(const QVector3D & player_pos) const
{
QVector2D local = GetChildLocal(player_pos);
return (local.x() >= -1.0f && local.x() <= 1.0f && local.y() >= -1.0f && local.y() <= 1.0f);
}
示例2: addElectrodeItem
void TMSIImpedanceWidget::addElectrodeItem(QString electrodeName, QVector2D position)
{
TMSIElectrodeItem *item = new TMSIElectrodeItem(electrodeName, QPointF(position.x(), position.y()), QColor(m_cbColorMap->valueToJet(1)), m_qmElectrodeNameIndex[electrodeName]);
item->setPos(QPointF(position.x(), position.y()));
m_qGScene->addItem(item);
}
示例3:
QDebug operator<<(QDebug dbg, const QVector2D &vector)
{
dbg.nospace() << "QVector2D(" << vector.x() << ", " << vector.y() << ')';
return dbg.space();
}
示例4: GetPlayerNearParent
bool EnvPortal::GetPlayerNearParent(const QVector3D & player_pos) const
{
QVector2D local = GetParentLocal(player_pos);
return (local.x() >= -1.0f && local.x() <= 1.0f && local.y() >= -1.0f && local.y() <= 3.0f);
}
示例5: contains
bool BBox::contains(const QVector2D &pt) const {
if (pt.x() < minPt.x() || pt.y() < minPt.y()) return false;
if (pt.x() > maxPt.x() || pt.y() > maxPt.y()) return false;
return true;
}
示例6:
BBox::BBox(const QVector2D& pt) {
minPt.setX(pt.x());
minPt.setY(pt.y());
maxPt.setX(pt.x());
maxPt.setY(pt.y());
}
示例7: qAcos
void //TODO: second plane
SliceAdjustmentTool::toolMouseMoveEvent(QMouseEvent *ev)
{
voxie::data::SliceImage& currentImg = (currentSlice == 0) ? this->sv->sliceImageFirst() : this->sv->sliceImageSecond();
voxie::data::SliceImage& otherImg = (currentSlice == 1) ? this->sv->sliceImageFirst() : this->sv->sliceImageSecond();
voxie::data::Slice* otherSlice = (currentSlice == 0) ? this->sv->slices().at(0) : this->sv->slices().at(1);
if(this->dragUpdates){
if(this->ctrlDown){
if(this->rotatingInProgress){
QVector2D cursorOnPlane = QVector2D(currentImg.pixelToPlanePoint(ev->pos(), true)).normalized();
float angle = (float) qAcos(QVector3D::dotProduct(this->rotationHypotenuse, cursorOnPlane));
// check clockwise or counterclockwise rotation
float sign = 1;
{
/* to know if cursor is left of hypotenuse rotate their coordinatesystem so that
* hypotenuse points in xAxis direction and check if cursor.y is positive.
* Rotation matrix for this can be obtained from hypotenuse since its normalized
* counterclockwise clockwise
* cos(a) -sin(a) cos(a)/det sin(a)/det
* sin(a) cos(a) -sin(a)/det cos(a)/det
*
* with cos(a) = hypotenuse.x , sin(a) = hypotenuse.y , det = determinant(clockwise rotMat)
*/
qreal cos = this->rotationHypotenuse.x();
qreal sin = this->rotationHypotenuse.y();
qreal det = cos*cos + sin*sin;
// y-part of matrix multiplication (clockwise*cursor)
qreal rotCursorY = -sin/det * cursorOnPlane.x() + cos/det * cursorOnPlane.y();
sign = rotCursorY > 0 ? 1:-1;
}
if(this->selectedBoth)
{
QVector2D cursorOnPlane = QVector2D(otherImg.pixelToPlanePoint(ev->pos(), true)).normalized();
float angle = (float) qAcos(QVector3D::dotProduct(this->rotationHypotenuse2, cursorOnPlane));
// check clockwise or counterclockwise rotation
float sign = 1;
{
/* to know if cursor is left of hypotenuse rotate their coordinatesystem so that
* hypotenuse points in xAxis direction and check if cursor.y is positive.
* Rotation matrix for this can be obtained from hypotenuse since its normalized
* counterclockwise clockwise
* cos(a) -sin(a) cos(a)/det sin(a)/det
* sin(a) cos(a) -sin(a)/det cos(a)/det
*
* with cos(a) = hypotenuse.x , sin(a) = hypotenuse.y , det = determinant(clockwise rotMat)
*/
qreal cos = this->rotationHypotenuse2.x();
qreal sin = this->rotationHypotenuse2.y();
qreal det = cos*cos + sin*sin;
// y-part of matrix multiplication (clockwise*cursor)
qreal rotCursorY = -sin/det * cursorOnPlane.x() + cos/det * cursorOnPlane.y();
sign = rotCursorY > 0 ? 1:-1;
}
rotateSlice(otherSlice, otherSlice->normal(), ((angle)/3.1415f) * 180 * sign);
this->rotationHypotenuse2 = cursorOnPlane;
}
rotateSlice(this->slice, this->slice->normal(), ((angle)/3.1415f) * 180 * sign);
this->rotationHypotenuse = cursorOnPlane;
}
}
}
}
示例8: hitTestResizingPoint
bool BBox::hitTestResizingPoint(const QVector2D& pt) const {
if (fabs(pt.x() - maxPt.x()) < dx() * 0.1f && fabs(pt.y() - minPt.y()) < dy() * 0.1f) return true;
else return false;
}
示例9: qDebug
SketchJoint::SketchJoint(QObject* rawPoint, QList<QObject*> lines) {
/**
* Precondition : note that this is only possible to compute
* if the angle between each line is greater than
* 2*Arctan(SketchLine::radius/SketchLine::edgeShortcut) otherwise
* we would need to cut more than SketchLine::edgeShortcut
*
* 1) Sort the line with respect to angle from the rawPoint center
* 2) Compute two point on the line equation at distance parametrized
* via SketchLine::radius and compute two point on the line
* 3) compute the intersection
* from following equation : http://stackoverflow.com/a/385355
*
* float x12 = x1 - x2;
* float x34 = x3 - x4;
* float y12 = y1 - y2;
* float y34 = y3 - y4;
*
* float c = x12 * y34 - y12 * x34;
*
* if (fabs(c) < 0.01)
* {
* // No intersection
* return false;
* }
* else
* {
* // Intersection
* float a = x1 * y2 - y1 * x2;
* float b = x3 * y4 - y3 * x4;
*
* float x = (a * x34 - b * x12) / c;
* float y = (a * y34 - b * y12) / c;
*
* return true;
* }
*
* 4) We build the list of vertices in this way :
* foreach Lines
* I. take the first point on the line drawn by third and fourth point on line 1
* II. take the intersection between the current and next line
* III. take the first point on the line drawn by first and sercond point on line 2
* 5) Compute the 3D vertex
*/
#ifdef CARPENTER_DEBUG
qDebug() << "SketchJoint: new SketchJoint";
qDebug() << "SketchJoint: " << lines;
qDebug() << "SketchJoint: " << rawPoint;
qDebug() << "SketchJoint: edgeShortcut" << SketchLine::edgeShortcut;
qDebug() << "SketchJoint: radius" << SketchLine::radius;
#endif
QVariant startProperty = rawPoint->property("start");
if(!startProperty.isValid() || !startProperty.canConvert<QVector2D>()) {
this->setErrorMessage("Cannot find origin in Point");
return;
}
QVector2D point = startProperty.value<QVector2D>();
// Nothing to do if no more than one line
if(lines.size() <= 1) {
this->setValid(true);
return;
}
foreach(QObject* line, lines) {
// ----------------------------------------------------------------------------------
// Cast and properties check
QVariant pointerProperty = line->property("pointer");
if(!pointerProperty.isValid() || !pointerProperty.canConvert<QVector2D>()) {
this->setErrorMessage("Cannot find or convert pointer in Line");
return;
}
QVariant endPointProperty = line->property("endPoint");
if(!endPointProperty.isValid() || !endPointProperty.canConvert<QObject*>()) {
this->setErrorMessage("Cannot find or convert endPoint in Line");
return;
}
QVariant identifierProperty = line->property("identifier");
if(!identifierProperty.isValid() || !identifierProperty.canConvert<int>()) {
this->setErrorMessage("Cannot find or convert identifier in Line");
return;
}
int identifier = identifierProperty.toInt();
// ----------------------------------------------------------------------------------
QVector2D pointer = pointerProperty.value<QVector2D>().normalized();
if(endPointProperty.value<QObject*>() == rawPoint) {
//qDebug() << "invert the pointer";
pointer *= -1.0f;
}
//.........这里部分代码省略.........
示例10: draw_data
void draw_data(void)
{
#if 0
// !!! タイムスタンプのローテーションに対応できていないので、
// !!! 1つ残して全てのデータを削除するようにする
// 一定時間以上経過したデータを削除
size_t data_size = draw_data_.size();
for (size_t i = 0; i < data_size; ++i) {
long diff = last_timestamp_ - draw_data_[0]->timestamp;
if (diff < draw_period_) {
break;
}
remove_front_data();
}
#else
// 一定時間以上経過したデータを削除
// 強度と距離の2つのみ残す
int remove_size = draw_data_.size() - 2;
for (int i = 0; i < remove_size; ++i) {
remove_front_data();
}
#endif
// !!! 時間が経過するほど、薄い色で表示するようにする
double ratio = zoom_ratio();
QVector2D offset = point_offset(ratio);
// 注視するステップ位置に線を描画
if (is_step_line_active_) {
double radian = step_line_radian_ + (M_PI / 2.0);
double x = 100000 * cos(radian);
double y = 100000 * sin(radian);
glColor4d(0.0, 1.0, 0.0, 0.9);
glBegin(GL_LINES);
glVertex2d(-offset.x(), -offset.y());
glVertex2d(x - offset.x(), y - offset.y());
glEnd();
}
// 中心から測定点への直線を描画
glBegin(GL_LINES);
for (deque<Draw_data*>::const_iterator scan_it = draw_data_.begin();
scan_it != draw_data_.end(); ++scan_it) {
QColor& color = (*scan_it)->color;
#if 0
double diff = last_timestamp_ - (*scan_it)->timestamp;
double alpha = (1.0 - (diff / draw_period_)) * 0.6;
#else
double alpha = color.alpha() / 255.0;
#endif
glColor4d(color.red() / 255.0,
color.green() / 255.0,
color.blue() / 255.0, alpha);
vector<QPoint>& scan_data = (*scan_it)->points;
vector<QPoint>::const_iterator end_it = scan_data.end();
for (vector<QPoint>::const_iterator it = scan_data.begin();
it != end_it; ++it) {
double x = it->x() * ratio;
double y = it->y() * ratio;
glVertex2d(-offset.x(), -offset.y());
glVertex2d(x - offset.x(), y - offset.y());
}
}
glEnd();
#if 0
// 測定点の描画
double base_size = 1.4;
double mm_pixel = max(base_size / pixel_per_mm_, base_size);
glPointSize(mm_pixel);
glBegin(GL_POINTS);
for (DataArray::iterator line_it = draw_data_.begin();
line_it != draw_data_.end(); ++line_it) {
// !!! 関数にする
double diff = last_timestamp_ - line_it->timestamp;
double alpha = 1.0 - (diff / draw_period_);
glColor4d(1.0, 0.0, 0.0, alpha);
vector<QPoint>::iterator end_it = line_it->point_data.end();
for (vector<QPoint>::iterator it =
line_it->point_data.begin();
it != end_it; ++it) {
double x = it->x * ratio;
double y = it->y * ratio;
glVertex2d(x - offset.x, y - offset.y);
}
}
glEnd();
#endif
//.........这里部分代码省略.........
示例11: switch
void tvalue2json(rapidjson::Value & output, const QVariant & input, rapidjson::Value::AllocatorType & allocator)
{
switch(input.type())
{
case QVariant::Invalid:
{
output.SetNull();
break;
}
case QVariant::Bool:
{
output.SetBool(input.toBool());
break;
}
case QVariant::Int:
{
output.SetInt64(input.toInt());
break;
}
case QVariant::LongLong:
{
output.SetInt64(input.toLongLong());
break;
}
case QVariant::Double:
{
output.SetDouble(input.toDouble());
break;
}
case QVariant::String:
{
QByteArray str = input.toString().toUtf8();
output.SetString(str.data(), str.size(), allocator);
break;
}
case QVariant::StringList:
{
QStringList list = input.toStringList();
output.SetArray();
output.Reserve(list.size(), allocator);
rapidjson::Value temp;
for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
{
QByteArray str = it->toUtf8();
temp.SetString(str.data(), str.size(), allocator);
output.PushBack(temp, allocator);
}
break;
}
case QVariant::List:
{
QList<QVariant> list = input.toList();
output.SetArray();
output.Reserve(list.size(), allocator);
rapidjson::Value temp;
for(QList<QVariant>::const_iterator it = list.begin(); it != list.end(); ++it)
{
tvalue2json(temp, *it, allocator);
output.PushBack(temp, allocator);
}
break;
}
case QVariant::Map:
{
output.SetObject();
rapidjson::Value tempK, tempV;
QMap<QString, QVariant> qmap = input.toMap();
for(QMap<QString, QVariant>::const_iterator it = qmap.begin(); it != qmap.end(); ++it)
{
tvalue2json(tempK, it.key(), allocator);
tvalue2json(tempV, it.value(), allocator);
output.AddMember(tempK, tempV, allocator);
}
break;
}
case QVariant::Point:
{
QPoint pt = input.toPoint();
output.SetArray();
output.Reserve(2, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
break;
}
case QVariant::PointF:
{
QPointF pt = input.toPointF();
output.SetArray();
output.Reserve(2, allocator);
output.PushBack(pt.x(), allocator);
output.PushBack(pt.y(), allocator);
//.........这里部分代码省略.........
示例12: Set
void SettingsManager::Set(QString Key, QVector2D Val)
{
Map.insert(Key, QString::number(Val.x()) + ";" + QString::number(Val.y()));
}
示例13: foreach
foreach (ViewWidget *view, _linkedViews) {
GeographicalViewWidget *gw = (GeographicalViewWidget*)view->mapWidget();
gw->getColorBar()->setRealMinMax(range.x(), range.y());
gw->repaintContents();
}