本文整理汇总了C++中QPoint类的典型用法代码示例。如果您正苦于以下问题:C++ QPoint类的具体用法?C++ QPoint怎么用?C++ QPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPoint类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locationEvent
int FreehandSelection::locationEvent(const SoLocation2Event* const e, const QPoint& pos)
{
// do all the drawing stuff for us
QPoint clPoint = pos;
if (polyline.isWorking()) {
// check the position
QRect r = _pcView3D->getGLWidget()->rect();
if (!r.contains(clPoint)) {
if (clPoint.x() < r.left())
clPoint.setX(r.left());
if (clPoint.x() > r.right())
clPoint.setX(r.right());
if (clPoint.y() < r.top())
clPoint.setY(r.top());
if (clPoint.y() > r.bottom())
clPoint.setY(r.bottom());
}
SbVec2s last = _clPoly.back();
SbVec2s curr = e->getPosition();
if (abs(last[0]-curr[0]) > 20 || abs(last[1]-curr[1]) > 20)
_clPoly.push_back(curr);
polyline.addNode(clPoint);
polyline.setCoords(clPoint.x(), clPoint.y());
}
m_iXnew = clPoint.x();
m_iYnew = clPoint.y();
draw();
m_iXold = clPoint.x();
m_iYold = clPoint.y();
return Continue;
}
示例2: initialiseInstance
void FFGLNode::initialiseInstance( QPoint pPoint, QSize pSize )
{
InterfaceOpenGL *GL = qobject_cast<InterfaceOpenGL *>( FreeframePlugin::instance()->app()->findInterface( IID_OPENGL ) );
if( GL )
{
GL->checkErrors( __FILE__, __LINE__ );
}
FFMixed PMU;
if( mPoint != pPoint || mSize != pSize )
{
#if defined( __FFGL_H__ )
FF_Main_FuncPtr MainFunc = mLibrary->func();
if( mInstanceId )
{
PMU.UIntValue = 0;
PMU = MainFunc( FF_DEINSTANTIATEGL, PMU, mInstanceId );
if( GL )
{
GL->checkErrors( __FILE__, __LINE__ );
}
mInstanceId = 0;
}
FFGLViewportStruct VPS;
VPS.x = pPoint.x();
VPS.y = pPoint.y();
VPS.width = pSize.width();
VPS.height = pSize.height();
PMU.PointerValue = &VPS;
PMU = MainFunc( FF_INSTANTIATEGL, PMU, 0 );
if( GL )
{
GL->checkErrors( __FILE__, __LINE__ );
}
if( PMU.UIntValue == FF_FAIL )
{
return;
}
mSize = pSize;
if( PMU.UIntValue != FF_FAIL )
{
mInstanceId = PMU.PointerValue;
}
#endif
}
}
示例3: mouseButtonEvent
int FreehandSelection::mouseButtonEvent(const SoMouseButtonEvent* const e, const QPoint& pos)
{
const int button = e->getButton();
const SbBool press = e->getState() == SoButtonEvent::DOWN ? true : false;
if (press) {
switch(button)
{
case SoMouseButtonEvent::BUTTON1:
{
if (!polyline.isWorking()) {
polyline.setWorking(true);
polyline.clear();
};
polyline.addNode(pos);
polyline.setCoords(pos.x(), pos.y());
m_iXnew = pos.x(); m_iYnew = pos.y();
m_iXold = pos.x(); m_iYold = pos.y();
}
break;
case SoMouseButtonEvent::BUTTON2:
{
polyline.addNode(pos);
m_iXnew = pos.x(); m_iYnew = pos.y();
m_iXold = pos.x(); m_iYold = pos.y();
}
break;
default:
{
} break;
}
}
// release
else {
switch(button)
{
case SoMouseButtonEvent::BUTTON1:
if (polyline.isWorking()) {
releaseMouseModel();
return Finish;
}
case SoMouseButtonEvent::BUTTON2:
{
QCursor cur = _pcView3D->getWidget()->cursor();
_pcView3D->getWidget()->setCursor(m_cPrevCursor);
// The pop-up menu should be shown when releasing mouse button because
// otherwise the navigation style doesn't get the UP event and gets into
// an inconsistent state.
int id = popupMenu();
if (id == Finish || id == Cancel) {
releaseMouseModel();
}
else if (id == Restart) {
_pcView3D->getWidget()->setCursor(cur);
}
polyline.setWorking(false);
return id;
}
break;
default:
{
} break;
}
}
return Continue;
}
示例4: max
/**
* \fn VideoOutWindow::GetVisibleOSDBounds(float&,float&,float) const
* \brief Returns visible portions of total OSD bounds
* \param visible_aspect physical aspect ratio of bounds returned
* \param font_scaling scaling to apply to fonts
*/
QRect VideoOutWindow::GetVisibleOSDBounds(
float &visible_aspect, float &font_scaling, float themeaspect) const
{
float dv_w = (((float)video_disp_dim.width()) /
display_video_rect.width());
float dv_h = (((float)video_disp_dim.height()) /
display_video_rect.height());
uint right_overflow = max(
(display_video_rect.width() + display_video_rect.left()) -
display_visible_rect.width(), 0);
uint lower_overflow = max(
(display_video_rect.height() + display_video_rect.top()) -
display_visible_rect.height(), 0);
bool isPBP = (kPBPLeft == pip_state || kPBPRight == pip_state);
if (isPBP)
{
right_overflow = 0;
lower_overflow = 0;
}
// top left and bottom right corners respecting letterboxing
QPoint tl = QPoint((uint) ceil(max(-display_video_rect.left(),0)*dv_w),
(uint) ceil(max(-display_video_rect.top(),0)*dv_h));
QPoint br = QPoint(
(uint) floor(video_disp_dim.width() - (right_overflow * dv_w)),
(uint) floor(video_disp_dim.height() - (lower_overflow * dv_h)));
// adjust for overscan
if ((db_scale_vert > 0.0f) || (db_scale_horiz > 0.0f))
{
QRect v(tl, br);
float xs = (db_scale_horiz > 0.0f) ? db_scale_horiz : 0.0f;
float ys = (db_scale_vert > 0.0f) ? db_scale_vert : 0.0f;
QPoint s((int)(v.width() * xs), (int)(v.height() * ys));
tl += s;
br -= s;
}
// Work around Qt bug, QRect(QPoint(0,0), QPoint(0,0)) has area 1.
QRect vb(tl.x(), tl.y(), br.x() - tl.x(), br.y() - tl.y());
// The calculation is completely bogus if the video is not centered
// which happens in the EPG, where we don't actually care about the OSD.
// So we just make sure the width and height are positive numbers
vb = QRect(vb.x(), vb.y(), abs(vb.width()), abs(vb.height()));
// set the physical aspect ratio of the displayable area
float dispPixelAdj = 1.0f;
if (display_visible_rect.width())
{
dispPixelAdj = GetDisplayAspect() * display_visible_rect.height();
dispPixelAdj /= display_visible_rect.width();
}
if ((vb.height() >= 0) && overriden_video_aspect >= 0.0f)
{
// now adjust for scaling of the video on the aspect ratio
float vs = ((float)vb.width())/vb.height();
visible_aspect =
themeaspect * (vs/overriden_video_aspect) * dispPixelAdj;
}
if (themeaspect >= 0.0f)
{
// now adjust for scaling of the video on the size
float tmp = sqrtf(2.0f/(sq(visible_aspect / themeaspect) + 1.0f));
if (tmp >= 0.0f)
font_scaling = 1.0f / tmp;
// now adjust for aspect ratio effect on font size
// (should be in osd.cpp?)
font_scaling *= sqrtf(overriden_video_aspect / themeaspect);
}
if (isPBP)
font_scaling *= 0.65f;
return vb;
}
示例5: generateGroundPlaneAux
bool GroundPlaneGenerator::generateGroundPlaneUnit(const QString & boardSvg, QSizeF boardImageSize, const QString & svg, QSizeF copperImageSize,
QStringList & exceptions, QGraphicsItem * board, double res, const QString & color,
QPointF whereToStart)
{
double bWidth, bHeight;
QImage * image = generateGroundPlaneAux(boardSvg, boardImageSize, svg, copperImageSize, exceptions, board, res, bWidth, bHeight);
if (image == NULL) return false;
QRectF bsbr = board->sceneBoundingRect();
QPoint s(qRound(res * (whereToStart.x() - bsbr.topLeft().x()) / FSvgRenderer::printerScale()),
qRound(res * (whereToStart.y() - bsbr.topLeft().y()) / FSvgRenderer::printerScale()));
QBitArray redMarker(image->height() * image->width(), false);
QRgb pixel = image->pixel(s);
DebugDialog::debug(QString("unit %1").arg(pixel, 0, 16));
if (pixel != 0xffffffff) {
// starting off in bad territory
delete image;
return false;
}
// step 1 flood fill white to "red" (keep max locations)
int minY = image->height();
int maxY = 0;
int minX = image->width();
int maxX = 0;
QList<QPoint> stack;
stack << s;
while (stack.count() > 0) {
QPoint p = stack.takeFirst();
if (p.x() < 0) continue;
if (p.y() < 0) continue;
if (p.x() >= image->width()) continue;
if (p.y() >= image->height()) continue;
if (redMarker.testBit(OFFSET(p.x(), p.y(), image))) continue; // already been here
QRgb pixel = image->pixel(p);
if (pixel != 0xffffffff) continue; // black; bail
redMarker.setBit(OFFSET(p.x(), p.y(), image), true);
if (p.x() > maxX) maxX = p.x();
if (p.x() < minX) minX = p.x();
if (p.y() > maxY) maxY = p.y();
if (p.y() < minY) minY = p.y();
stack.append(QPoint(p.x() - 1, p.y()));
stack.append(QPoint(p.x() + 1, p.y()));
stack.append(QPoint(p.x(), p.y() - 1));
stack.append(QPoint(p.x(), p.y() + 1));
}
//image->save("testPoly1.png");
// step 2 replace white with black
image->fill(0);
// step 3 replace "red" with white
for (int y = 0; y < image->height(); y++) {
for (int x = 0; x < image->width(); x++) {
if (redMarker.testBit(OFFSET(x, y, image))) {
image->setPixel(x, y, 1);
}
}
}
#ifndef QT_NO_DEBUG
image->save("testGroundPlaneUnit3.png");
#endif
scanImage(*image, bWidth, bHeight, GraphicsUtils::StandardFritzingDPI / res, res, color, true, true, QSizeF(.05, .05), 1 / FSvgRenderer::printerScale(), QPointF(0,0));
delete image;
return true;
}
示例6: mouseMoveEvent
void ccHistogramWindow::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton)
{
if (m_sfInteractionMode)
{
QPoint mousePos = event->pos();
if (m_histogram)
{
QRect rect = m_histogram->rect();
mousePos.setX(std::min(rect.x()+rect.width(),std::max(rect.x(),mousePos.x())));
}
switch(m_selectedItem)
{
case NONE:
//nothing to do
break;
case LEFT_AREA:
if (m_areaLeft)
{
double newValue = m_areaLeft->pixelToKey(mousePos.x());
if (m_areaRight)
newValue = std::min(newValue,m_areaRight->currentVal());
setMinDispValue(newValue);
}
break;
case RIGHT_AREA:
if (m_areaRight)
{
double newValue = m_areaRight->pixelToKey(mousePos.x());
if (m_areaLeft)
newValue = std::max(newValue,m_areaLeft->currentVal());
setMaxDispValue(newValue);
}
break;
case BOTH_AREAS:
{
int dx = m_lastMouseClick.x() - mousePos.x();
if (dx < -2)
{
//going to the right
m_selectedItem = RIGHT_AREA;
//call the same method again
mouseMoveEvent(event);
return;
}
else if (dx > 2)
{
//going to the left
m_selectedItem = LEFT_AREA;
//call the same method again
mouseMoveEvent(event);
return;
}
//else: nothing we can do right now!
}
break;
case LEFT_ARROW:
if (m_arrowLeft)
{
double newValue = m_arrowLeft->pixelToKey(mousePos.x());
if (m_arrowRight)
newValue = std::min(newValue,m_arrowRight->currentVal());
setMinSatValue(newValue);
}
break;
case RIGHT_ARROW:
if (m_arrowRight)
{
double newValue = m_arrowRight->pixelToKey(mousePos.x());
if (m_arrowLeft)
newValue = std::max(newValue,m_arrowLeft->currentVal());
setMaxSatValue(newValue);
}
break;
case BOTH_ARROWS:
{
int dx = m_lastMouseClick.x() - mousePos.x();
if (dx < -2)
{
//going to the right
m_selectedItem = RIGHT_ARROW;
//call the same method again
mouseMoveEvent(event);
return;
}
else if (dx > 2)
{
//going to the left
m_selectedItem = LEFT_ARROW;
//call the same method again
mouseMoveEvent(event);
return;
}
//else: nothing we can do right now!
}
break;
default:
assert(false);
//.........这里部分代码省略.........