本文整理汇总了C++中FPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ FPoint::x方法的具体用法?C++ FPoint::x怎么用?C++ FPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPoint
的用法示例。
在下文中一共展示了FPoint::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseHitsGuide
bool RulerGesture::mouseHitsGuide(FPoint mousePointDoc)
{
const int page = m_doc->OnPage(mousePointDoc.x(), mousePointDoc.y());
if ((m_doc->guidesSettings.guidesShown) && (!m_doc->GuideLock) && page >= 0)
{
double grabRadScale = m_doc->guidesSettings.grabRad / m_canvas->scale();
int index = m_doc->Pages->at(page)->guides.isMouseOnVertical(mousePointDoc.x() + grabRadScale, mousePointDoc.x() - grabRadScale, GuideManagerCore::Standard);
if (index >= 0)
{
m_mode = VERTICAL;
m_haveGuide = true;
m_guide = m_doc->Pages->at(page)->guides.vertical(index, GuideManagerCore::Standard);
m_currentGuide = m_guide;
m_page = page;
return true;
}
index = m_doc->Pages->at(page)->guides.isMouseOnHorizontal(mousePointDoc.y() + grabRadScale, mousePointDoc.y() - grabRadScale, GuideManagerCore::Standard);
if (index >= 0)
{
m_mode = HORIZONTAL;
m_haveGuide = true;
m_guide = m_doc->Pages->at(page)->guides.horizontal(index, GuideManagerCore::Standard);
m_currentGuide = m_guide;
m_page = page;
return true;
}
}
m_haveGuide = false;
return false;
}
示例2: mouseReleaseEvent
void CanvasMode_Magnifier::mouseReleaseEvent(QMouseEvent *m)
{
#ifdef GESTURE_FRAME_PREVIEW
clearPixmapCache();
#endif // GESTURE_FRAME_PREVIEW
const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
m->accept();
// m_view->stopDragTimer();
if (m_doc->appMode == modeMagnifier)
{
double sc = m_canvas->scale();
if (m_view->HaveSelRect)
{
QRect geom = m_view->redrawMarker->geometry().normalized();
geom = QRect(m_view->mapToGlobal(geom.topLeft()), m_view->mapToGlobal(geom.bottomRight()));
FPoint nx = m_canvas->globalToCanvas(QPoint(geom.x() + geom.width() / 2, geom.y() + geom.height() / 2));
double scaleH = m_view->visibleWidth() / static_cast<double>(qMax(geom.width(), 1));
double scaleV = m_view->visibleHeight() / static_cast<double>(qMax(geom.height(), 1));
double scaleAdjust = qMax(0.5, qMin(scaleH, scaleV));
m_view->zoom(nx.x(), nx.y(), m_canvas->scale() * scaleAdjust, false);
if (sc == m_canvas->scale())
{
m_view->HaveSelRect = false;
m_view->setRedrawMarkerShown(false);
m_view->requestMode(submodePaintingDone);
}
m_view->setRedrawMarkerShown(false);
}
else
{
FPoint nx = mousePointDoc;
int mx = qRound(nx.x());
int my = qRound(nx.y());
m_view->Magnify ? m_view->slotZoomIn(mx,my) : m_view->slotZoomOut(mx,my);
if (sc == m_canvas->scale())
{
m_view->HaveSelRect = false;
m_view->requestMode(submodePaintingDone);
}
else
{
if (m->modifiers() & Qt::ShiftModifier)
m_view->setCursor(IconManager::instance()->loadCursor("LupeZm.xpm"));
else
m_view->setCursor(IconManager::instance()->loadCursor("LupeZ.xpm"));
}
}
}
m_canvas->setRenderModeUseBuffer(false);
m_doc->DragP = false;
m_doc->leaveDrag = false;
m_canvas->m_viewMode.operItemMoving = false;
m_canvas->m_viewMode.operItemResizing = false;
m_view->MidButt = false;
//Make sure the Zoom spinbox and page selector dont have focus if we click on the canvas
m_view->m_ScMW->zoomSpinBox->clearFocus();
m_view->m_ScMW->pageSelector->clearFocus();
}
示例3: drawLine
void ScPainterEx_GDI::drawLine(FPoint start, FPoint end)
{
newPath();
moveTo(start.x(), start.y());
lineTo(end.x(), end.y());
strokePath();
}
示例4: keyPressEvent
void KCurve::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
{
if (m_points.size() > 2)
{
FPoint closest_point = m_points.point(0);
FPoint p = m_points.point(0);
int pos = 0;
int cc = 0;
double distance = 1000; // just a big number
while(cc < m_points.size())
{
p = m_points.point(cc);
if (fabs (m_grab_point.x() - p.x()) < distance)
{
distance = fabs(m_grab_point.x() - p.x());
closest_point = p;
m_pos = pos;
}
cc++;
pos++;
}
FPointArray cli;
cli.putPoints(0, m_pos, m_points);
cli.putPoints(cli.size(), m_points.size()-m_pos-1, m_points, m_pos+1);
m_points.resize(0);
m_points = cli.copy();
m_grab_point = closest_point;
repaint();
emit modified();
QWidget::keyPressEvent(e);
}
}
}
示例5: mousePressEvent
void ResizeGesture::mousePressEvent(QMouseEvent *m)
{
FPoint point = m_canvas->globalToCanvas(m->globalPos());
m_mousePressPoint = m->globalPos();
if (m_doc->m_Selection->count() == 0)
{
m_handle = Canvas::OUTSIDE;
}
else if (m_doc->m_Selection->isMultipleSelection())
{
double gx, gy, gh, gw;
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
m_handle = m_canvas->frameHitTest(QPointF(point.x(), point.y()), QRectF(gx,gy,gw,gh));
}
else
{
m_handle = m_canvas->frameHitTest(QPointF(point.x(), point.y()), m_doc->m_Selection->itemAt(0));
}
if (m_handle > 0)
{
prepare(m_handle);
m->accept();
m_mousePressBounds = m_bounds;
}
}
示例6: rebuildList
void ArrowChooser::rebuildList(QList<ArrowDesc> *arrowStyles)
{
clear();
FPointArray Path;
Path.resize(0);
addItem(CommonStrings::tr_None);
for (int a = 0; a < arrowStyles->count(); ++a)
{
QImage image(22, 22, QImage::Format_ARGB32);
ScPainter *painter = new ScPainter(&image, 22, 22);
painter->clear();
painter->setBrush(qRgb(0, 0, 0));
painter->setPen(qRgb(0, 0, 0));
painter->setFillMode(1);
painter->translate(3.0, 3.0);
Path.resize(0);
Path = arrowStyles->at(a).points.copy();
FPoint min = getMinClipF(&Path);
Path.translate(-min.x(), -min.y());
FPoint max = Path.WidthHeight();
QMatrix mm;
QMatrix mm2;
if (arrowDirection)
{
mm2.scale(-1, 1);
mm2.translate(-max.x(), 0);
}
mm.scale(16.0 / qMax(max.x(), max.y()), 16.0 / qMax(max.x(), max.y()));
Path.map(mm2 * mm);
painter->setupPolygon(&Path);
painter->setLineWidth(1.0);
painter->drawPolygon();
painter->drawPolyLine();
painter->end();
delete painter;
int wi = image.width();
int hi = image.height();
for( int yi=0; yi < hi; ++yi )
{
QRgb *s = (QRgb*)(image.scanLine( yi ));
for(int xi=0; xi < wi; ++xi )
{
if((*s) == 0xffffffff)
(*s) &= 0x00ffffff;
s++;
}
}
QPixmap Ico;
Ico=QPixmap::fromImage(image);
addItem(Ico, arrowStyles->at(a).name);
}
}
示例7: paintEvent
void KCurve::paintEvent(QPaintEvent *)
{
int x = 0;
int wWidth = width() - 1;
int wHeight = height() - 1;
// Drawing selection or all histogram values.
QPainter p1;
p1.begin(this);
// draw background
p1.fillRect(QRect(0, 0, wWidth, wHeight), QColor(255, 255, 255));
// Draw grid separators.
p1.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
p1.drawLine(wWidth/4, 0, wWidth/4, wHeight);
p1.drawLine(wWidth/2, 0, wWidth/2, wHeight);
p1.drawLine(3*wWidth/4, 0, 3*wWidth/4, wHeight);
p1.drawLine(0, wHeight/4, wWidth, wHeight/4);
p1.drawLine(0, wHeight/2, wWidth, wHeight/2);
p1.drawLine(0, 3*wHeight/4, wWidth, 3*wHeight/4);
// Draw curve.
double curvePrevVal = getCurveValue(0.0);
p1.setPen(QPen(Qt::black, 1, Qt::SolidLine));
for (x = 0 ; x < wWidth ; x++)
{
double curveX;
double curveVal;
// curveX = (x + 0.5) / wWidth;
curveX = x / static_cast<double>(wWidth);
curveVal = getCurveValue(curveX);
p1.drawLine(x - 1, wHeight - int(curvePrevVal * wHeight), x, wHeight - int(curveVal * wHeight));
curvePrevVal = curveVal;
}
p1.drawLine(x - 1, wHeight - int(curvePrevVal * wHeight), x, wHeight - int(getCurveValue(1.0) * wHeight));
for (int dh = 0; dh < m_points.size(); dh++)
{
FPoint p = m_points.point(dh);
if(p == m_grab_point)
{
p1.setPen(QPen(Qt::red, 3, Qt::SolidLine));
p1.drawEllipse( int(p.x() * wWidth) - 2, wHeight - 2 - int(p.y() * wHeight), 4, 4 );
}
else
{
p1.setPen(QPen(Qt::red, 1, Qt::SolidLine));
p1.drawEllipse( int(p.x() * wWidth) - 3, wHeight - 3 - int(p.y() * wHeight), 6, 6 );
}
}
p1.end();
}
示例8: curveTo
void ScPainterEx_GDI::curveTo( FPoint p1, FPoint p2, FPoint p3 )
{
FPoint fpoints[3];
fpoints[0].setXY( p1.x(), p1.y() );
fpoints[1].setXY( p2.x(), p2.y() );
fpoints[2].setXY( p3.x(), p3.y() );
transformPoints( fpoints, fpoints, 3 );
POINT points[3];
points[0].x = fpoints[0].x();
points[0].y = fpoints[0].y();
points[1].x = fpoints[1].x();
points[1].y = fpoints[1].y();
points[2].x = fpoints[2].x();
points[2].y = fpoints[2].y();
PolyBezierTo(m_dc, points, 3);
}
示例9: selectPage
void CanvasMode_FrameLinks::selectPage(QMouseEvent *m)
{
m_canvas->m_viewMode.m_MouseButtonPressed = true;
FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
Mxp = mousePointDoc.x(); //static_cast<int>(m->x()/m_canvas->scale());
Myp = mousePointDoc.y(); //static_cast<int>(m->y()/m_canvas->scale());
m_doc->nodeEdit.deselect();
m_view->Deselect(false);
if (!m_doc->masterPageMode())
{
int i = m_doc->OnPage(Mxp, Myp);
if (i!=-1)
{
uint docCurrPageNo=m_doc->currentPageNumber();
uint j=static_cast<uint>(i);
if (docCurrPageNo != j)
{
m_doc->setCurrentPage(m_doc->Pages->at(j));
m_view->setMenTxt(j);
m_view->DrawNew();
}
}
m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
}
}
示例10: drawItemOutlines
void CanvasMode_Rotate::drawItemOutlines(QPainter* p)
{
FPoint itemPos;
double itemRotation;
p->save();
QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight);
p->setRenderHint(QPainter::Antialiasing);
p->setBrush(Qt::NoBrush);
p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
uint docSelectionCount = m_doc->m_Selection->count();
for (uint i = 0; i < docSelectionCount; ++i)
{
PageItem * currItem = m_doc->m_Selection->itemAt(i);
getNewItemPosition(currItem, itemPos, itemRotation);
p->save();
p->translate(itemPos.x(), itemPos.y());
p->rotate(itemRotation);
currItem->DrawPolyL(p, currItem->Clip);
p->restore();
}
p->restore();
}
示例11: mouseMoveEvent
void CanvasMode_EditArc::mouseMoveEvent(QMouseEvent *m)
{
const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
m->accept();
double newX = mousePointDoc.x();
double newY = mousePointDoc.y();
if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
{
PageItem *currItem = m_doc->m_Selection->itemAt(0);
QTransform itemMatrix = currItem->getTransform();
QPointF sPoint = currItem->PoLine.pointQF(0);
QPointF smPoint = itemMatrix.map(sPoint);
QLineF stLinA = QLineF(smPoint, QPointF(m_Mxp, m_Myp));
QLineF stLinM = QLineF(smPoint, QPointF(newX, newY));
double deltaAngle = stLinM.angle() - stLinA.angle();
QPainterPath pp;
if (m_arcPoint == useControlStart)
m_startAngle += deltaAngle;
else if (m_arcPoint == useControlSweep)
m_endAngle += deltaAngle;
else if (m_arcPoint == useControlHeight)
m_heightPoint = QPointF(m_heightPoint.x(), m_heightPoint.y() + (newY - m_Myp));
else if (m_arcPoint == useControlWidth)
m_widthPoint = QPointF(m_widthPoint.x() + (newX - m_Mxp), m_widthPoint.y());
double nSweep = m_endAngle - m_startAngle;
if (nSweep < 0)
nSweep += 360;
double nWidth = sPoint.x() - m_widthPoint.x();
double nHeight = sPoint.y() - m_heightPoint.y();
if ((nWidth > 0) && (nHeight > 0))
{
pp.moveTo(sPoint);
pp.arcTo(QRectF(sPoint.x() - nWidth, sPoint.y() - nHeight, nWidth * 2, nHeight * 2), m_startAngle, nSweep);
pp.closeSubpath();
FPointArray ar;
ar.fromQPainterPath(pp);
if (m_arcPoint == useControlStart)
{
m_startPoint = ar.pointQF(2);
QLineF stLinA = QLineF(smPoint, itemMatrix.map(m_startPoint));
m_canvas->displayRotHUD(m->globalPos(), 360.0 - stLinA.angle());
}
else if (m_arcPoint == useControlSweep)
{
m_endPoint = ar.pointQF(ar.size() - 4);
QLineF stLinA = QLineF(smPoint, itemMatrix.map(m_endPoint));
m_canvas->displayRotHUD(m->globalPos(), 360.0 - stLinA.angle());
}
QLineF res = QLineF(m_centerPoint, m_startPoint);
QLineF swe = QLineF(m_centerPoint, m_endPoint);
vectorDialog->setValues(res.angle(), swe.angle(), nHeight * 2, nWidth * 2);
blockUpdateFromItem(true);
currItem->update();
blockUpdateFromItem(false);
m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-nWidth, -nHeight, nWidth, nHeight));
}
}
m_Mxp = newX;
m_Myp = newY;
}
示例12: adjustBounds
void LineMove::adjustBounds(QMouseEvent *m)
{
FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
bool constrainRatio = ((m->modifiers() & Qt::ControlModifier) != Qt::NoModifier);
double newX = mousePointDoc.x();
double newY = mousePointDoc.y();
if (m_doc->useRaster)
{
newX = qRound(newX / m_doc->guidesSettings.minorGridSpacing) * m_doc->guidesSettings.minorGridSpacing;
newY = qRound(newY / m_doc->guidesSettings.minorGridSpacing) * m_doc->guidesSettings.minorGridSpacing;
}
//<<#8099
FPoint np2 = m_doc->ApplyGridF(FPoint(newX, newY));
double nx = np2.x();
double ny = np2.y();
m_doc->ApplyGuides(&nx, &ny);
newX = qRound(nx);
newY = qRound(ny);
//>>#8099
m_bounds.setBottomRight(QPointF(newX, newY));
//Constrain rotation angle, when the mouse is being dragged around for a new line
if (constrainRatio)
{
double newRot = rotation();
newRot = constrainAngle(newRot, m_doc->opToolPrefs.constrain);
setRotation(newRot);
}
// qDebug() << "LineMove::adjustBounds" << m_bounds << rotation() << length() << m_bounds.bottomRight();
m_view->updateCanvas(m_bounds.normalized().adjusted(-10, -10, 20, 20));
}
示例13: startDrag
void ShapeView::startDrag(Qt::DropActions supportedActions)
{
QString key = currentItem()->data(Qt::UserRole).toString();
if (m_Shapes.contains(key))
{
int w = m_Shapes[key].width;
int h = m_Shapes[key].height;
ScribusDoc *m_Doc = new ScribusDoc();
m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
m_Doc->setPage(w, h, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
m_Doc->setGUI(false, m_scMW, 0);
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset(), w, h, m_Doc->itemToolPrefs().shapeLineWidth, m_Doc->itemToolPrefs().shapeFillColor, m_Doc->itemToolPrefs().shapeLineColor, true);
PageItem* ite = m_Doc->Items->at(z);
ite->PoLine = m_Shapes[key].path.copy();
FPoint wh = getMaxClipF(&ite->PoLine);
ite->setWidthHeight(wh.x(),wh.y());
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Doc->AdjustItemSize(ite);
ite->OldB2 = ite->width();
ite->OldH2 = ite->height();
ite->updateClip();
ite->ClipEdited = true;
ite->FrameType = 3;
m_Doc->m_Selection->addItem(ite, true);
ScElemMimeData* md = ScriXmlDoc::WriteToMimeData(m_Doc, m_Doc->m_Selection);
QDrag* dr = new QDrag(this);
dr->setMimeData(md);
dr->setPixmap(currentItem()->icon().pixmap(QSize(48, 48)));
dr->exec();
delete m_Doc;
}
}
示例14: mouseMoveEvent
void CanvasMode_Magnifier::mouseMoveEvent(QMouseEvent *m)
{
// const double mouseX = m->globalX();
// const double mouseY = m->globalY();
const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
m_lastPosWasOverGuide = false;
double newX, newY;
m->accept();
if (commonMouseMove(m))
return;
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
newY = qRound(Myp + ((SeRx - Mxp) * m_view->visibleHeight()) / m_view->visibleWidth());
SeRx = newX;
SeRy = newY;
/*
m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
*/
QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
if (!m_view->redrawMarker->isVisible())
m_view->redrawMarker->show();
m_view->HaveSelRect = true;
}
}
示例15: mousePressEvent
void CanvasMode_ObjImport::mousePressEvent(QMouseEvent *m)
{
// const double mouseX = m->globalX();
// const double mouseY = m->globalY();
const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
double Rxp = 0, Ryp = 0;
m_canvas->PaintSizeRect(QRect());
m_canvas->m_viewMode.m_MouseButtonPressed = true;
m_canvas->m_viewMode.operItemMoving = false;
m_view->HaveSelRect = false;
m_doc->DragP = false;
m_doc->leaveDrag = false;
// oldClip = 0;
m->accept();
m_view->registerMousePress(m->globalPos());
Mxp = mousePointDoc.x();
Myp = mousePointDoc.y();
Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
Mxp = qRound(Rxp);
Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
Myp = qRound(Ryp);
if (m->button() == Qt::MidButton)
{
m_view->MidButt = true;
if (m->modifiers() & Qt::ControlModifier)
m_view->DrawNew();
return;
}
}