本文整理汇总了C++中QPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ QPoint函数的具体用法?C++ QPoint怎么用?C++ QPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QPoint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QLatin1String
bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMessage)
{
QStringList closedAreas;
QStringList toggleAreas;
QStringList toggleActiveAreas;
int nareas = 0;
screenDepth = 0;
QString mark;
ts >> mark;
hasMouseHover = true; // historical default
if ( mark == QLatin1String("[SkinFile]") ) {
const QString UpKey = QLatin1String("Up");
const QString DownKey = QLatin1String("Down");
const QString ClosedKey = QLatin1String("Closed");
const QString ClosedAreasKey = QLatin1String("ClosedAreas");
const QString ScreenKey = QLatin1String("Screen");
const QString ScreenDepthKey = QLatin1String("ScreenDepth");
const QString BackScreenKey = QLatin1String("BackScreen");
const QString ClosedScreenKey = QLatin1String("ClosedScreen");
const QString CursorKey = QLatin1String("Cursor");
const QString AreasKey = QLatin1String("Areas");
const QString ToggleAreasKey = QLatin1String("ToggleAreas");
const QString ToggleActiveAreasKey = QLatin1String("ToggleActiveAreas");
const QString HasMouseHoverKey = QLatin1String("HasMouseHover");
// New
while (!nareas) {
QString line = ts.readLine();
if ( line.isNull() )
break;
if ( line[0] != QLatin1Char('#') && !line.isEmpty() ) {
int eq = line.indexOf(QLatin1Char('='));
if ( eq >= 0 ) {
const QString key = line.left(eq);
eq++;
while (eq<line.length()-1 && line[eq].isSpace())
eq++;
const QString value = line.mid(eq);
if ( key == UpKey ) {
skinImageUpFileName = value;
} else if ( key == DownKey ) {
skinImageDownFileName = value;
} else if ( key == ClosedKey ) {
skinImageClosedFileName = value;
} else if ( key == ClosedAreasKey ) {
closedAreas = value.split(QLatin1Char(' '));
} else if ( key == ScreenKey ) {
parseRect( value, &screenRect);
} else if ( key == ScreenDepthKey ) {
screenDepth = value.toInt();
} else if ( key == BackScreenKey ) {
parseRect(value, &backScreenRect);
} else if ( key == ClosedScreenKey ) {
parseRect( value, &closedScreenRect );
} else if ( key == CursorKey ) {
QStringList l = value.split(QLatin1Char(' '));
skinCursorFileName = l[0];
cursorHot = QPoint(l[1].toInt(),l[2].toInt());
} else if ( key == AreasKey ) {
nareas = value.toInt();
} else if ( key == ToggleAreasKey ) {
toggleAreas = value.split(QLatin1Char(' '));
} else if ( key == ToggleActiveAreasKey ) {
toggleActiveAreas = value.split(QLatin1Char(' '));
} else if ( key == HasMouseHoverKey ) {
hasMouseHover = value == QLatin1String("true") || value == QLatin1String("1");
}
} else {
*errorMessage = DeviceSkin::tr("Syntax error: %1").arg(line);
return false;
}
}
}
} else {
// Old
skinImageUpFileName = mark;
QString s;
int x,y,w,h,na;
ts >> s >> x >> y >> w >> h >> na;
skinImageDownFileName = s;
screenRect.setRect(x, y, w, h);
nareas = na;
}
// Done for short mode
if (rm == ReadSizeOnly)
return true;
// verify skin files exist
skinImageUpFileName.insert(0, prefix);
if (!QFile(skinImageUpFileName).exists()) {
*errorMessage = DeviceSkin::tr("The skin \"up\" image file '%1' does not exist.").arg(skinImageUpFileName);
return false;
}
if (!skinImageUp.load(skinImageUpFileName)) {
*errorMessage = msgImageNotLoaded(skinImageUpFileName);
return false;
}
skinImageDownFileName.insert(0, prefix);
if (!QFile(skinImageDownFileName).exists()) {
*errorMessage = DeviceSkin::tr("The skin \"down\" image file '%1' does not exist.").arg(skinImageDownFileName);
return false;
//.........这里部分代码省略.........
开发者ID:kileven,项目名称:qt5,代码行数:101,代码来源:deviceskin.cpp
示例2: Q_ASSERT
void RToolMatrixItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
const QAbstractItemModel* model = index.model();
Q_ASSERT(model);
if (!model->parent(index).isValid()) {
// bool hidden = model->data(index, Qt::UserRole+2).toBool();
// qDebug() << "hidden: " << hidden;
// if (hidden) {
// return;
// }
// this is a top-level item.
QStyleOptionButton buttonOption;
buttonOption.state = option.state;
#ifdef Q_OS_MAC
buttonOption.state |= QStyle::State_Raised;
#endif
buttonOption.state &= ~QStyle::State_HasFocus;
buttonOption.rect = option.rect;
buttonOption.palette = option.palette;
buttonOption.features = QStyleOptionButton::None;
painter->save();
QColor buttonColor(230, 230, 230);
QBrush buttonBrush = option.palette.button();
if (!buttonBrush.gradient() && buttonBrush.texture().isNull()) {
buttonColor = buttonBrush.color();
}
QColor outlineColor = buttonColor.darker(150);
QColor highlightColor = buttonColor.lighter(130);
// Only draw topline if the previous item is expanded
QModelIndex previousIndex = model->index(index.row() - 1, index.column());
bool drawTopline = (index.row() > 0 && treeView->isExpanded(previousIndex));
int highlightOffset = drawTopline ? 1 : 0;
QLinearGradient gradient(option.rect.topLeft(), option.rect.bottomLeft());
gradient.setColorAt(0, buttonColor.lighter(102));
gradient.setColorAt(1, buttonColor.darker(106));
painter->setPen(Qt::NoPen);
painter->setBrush(gradient);
painter->drawRect(option.rect);
painter->setPen(highlightColor);
painter->drawLine(option.rect.topLeft() + QPoint(0, highlightOffset),
option.rect.topRight() + QPoint(0, highlightOffset));
painter->setPen(outlineColor);
if (drawTopline) {
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
}
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
painter->restore();
QStyleOption branchOption;
static const int i = 9;
QRect r = option.rect;
branchOption.rect = QRect(r.left() + i/2, r.top() + (r.height() - i)/2, i, i);
branchOption.palette = option.palette;
branchOption.state = QStyle::State_Children;
if (treeView->isExpanded(index)) {
branchOption.state |= QStyle::State_Open;
}
treeView->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, painter, treeView);
// draw text
QRect textrect = QRect(r.left() + i*2, r.top(), r.width() - ((5*i)/2), r.height());
QString text = elidedText(option.fontMetrics, textrect.width(), Qt::ElideMiddle,
model->data(index, Qt::DisplayRole).toString());
treeView->style()->drawItemText(painter, textrect, Qt::AlignCenter,
option.palette, treeView->isEnabled(), text);
} else {
QItemDelegate::paint(painter, option, index);
}
}
开发者ID:fallenwind,项目名称:qcad,代码行数:80,代码来源:RToolMatrixItemDelegate.cpp
示例3: buttonClicked
void KviMircTextColorSelector::buttonClicked()
{
QPoint p = m_pButton->mapToGlobal(QPoint(0,m_pButton->height()));
m_pContextPopup->popup(p);
}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:5,代码来源:KviSelectors.cpp
示例4: colorGroup
void QLCDNumber::drawSegment( const QPoint &pos, char segmentNo, QPainter &p,
int segLen, bool erase )
{
QPoint pt = pos;
int width = segLen/5;
const QColorGroup & g = colorGroup();
QColor lightColor,darkColor,fgColor;
if ( erase ){
lightColor = backgroundColor();
darkColor = lightColor;
fgColor = lightColor;
} else {
lightColor = g.light();
darkColor = g.dark();
fgColor = g.foreground();
}
#define LINETO(X,Y) addPoint( a, QPoint(pt.x() + (X),pt.y() + (Y)))
#define LIGHT
#define DARK
if ( fill ) {
QPointArray a(0);
//The following is an exact copy of the switch below.
//don't make any changes here
switch ( segmentNo ) {
case 0 :
p.moveTo(pt);
LIGHT;
LINETO(segLen - 1,0);
DARK;
LINETO(segLen - width - 1,width);
LINETO(width,width);
LINETO(0,0);
break;
case 1 :
pt += QPoint(0 , 1);
p.moveTo(pt);
LIGHT;
LINETO(width,width);
DARK;
LINETO(width,segLen - width/2 - 2);
LINETO(0,segLen - 2);
LIGHT;
LINETO(0,0);
break;
case 2 :
pt += QPoint(segLen - 1 , 1);
p.moveTo(pt);
DARK;
LINETO(0,segLen - 2);
LINETO(-width,segLen - width/2 - 2);
LIGHT;
LINETO(-width,width);
LINETO(0,0);
break;
case 3 :
pt += QPoint(0 , segLen);
p.moveTo(pt);
LIGHT;
LINETO(width,-width/2);
LINETO(segLen - width - 1,-width/2);
LINETO(segLen - 1,0);
DARK;
if (width & 1) { // adjust for integer division error
LINETO(segLen - width - 3,width/2 + 1);
LINETO(width + 2,width/2 + 1);
} else {
LINETO(segLen - width - 1,width/2);
LINETO(width,width/2);
}
LINETO(0,0);
break;
case 4 :
pt += QPoint(0 , segLen + 1);
p.moveTo(pt);
LIGHT;
LINETO(width,width/2);
DARK;
LINETO(width,segLen - width - 2);
LINETO(0,segLen - 2);
LIGHT;
LINETO(0,0);
break;
case 5 :
pt += QPoint(segLen - 1 , segLen + 1);
p.moveTo(pt);
DARK;
LINETO(0,segLen - 2);
LINETO(-width,segLen - width - 2);
LIGHT;
LINETO(-width,width/2);
LINETO(0,0);
break;
case 6 :
pt += QPoint(0 , segLen*2);
p.moveTo(pt);
LIGHT;
//.........这里部分代码省略.........
开发者ID:aroraujjwal,项目名称:qt3,代码行数:101,代码来源:qlcdnumber.cpp
示例5: resetRegionTrack
// UpdatePosition updates the position of the buttons arround the
// selection area. Ignores the sides blocked by the end of the screen.
// When the selection is too small it works on a virtual selection with
// the original in the center.
void ButtonHandler::updatePosition(const QRect &selection) {
resetRegionTrack();
const int vecLength = m_vectorButtons.size();
if (vecLength == 0) {
return;
}
// Copy of the selection area for internal modifications
m_selection = selection;
updateBlockedSides();
ensureSelectionMinimunSize();
// Indicates the actual button to be moved
int elemIndicator = 0;
while (elemIndicator < vecLength) {
// Add them inside the area when there is no more space
if (m_allSidesBlocked) {
positionButtonsInside(elemIndicator);
break; // the while
}
// Number of buttons per row column
int buttonsPerRow = (m_selection.width() + SEPARATION) / (m_buttonExtendedSize);
int buttonsPerCol = (m_selection.height() + SEPARATION) / (m_buttonExtendedSize);
// Buttons to be placed in the corners
int extraButtons = (vecLength - elemIndicator) -
(buttonsPerRow + buttonsPerCol) * 2;
int elemsAtCorners = extraButtons > 4 ? 4 : extraButtons;
int maxExtra = 2;
if (m_oneHorizontalBlocked) {
maxExtra = 1;
} else if (m_horizontalyBlocked) {
maxExtra = 0;
}
int elemCornersTop = qBound(0, elemsAtCorners, maxExtra);
elemsAtCorners -= elemCornersTop;
int elemCornersBotton = qBound(0, elemsAtCorners, maxExtra);
// Add buttons at the botton of the seletion
if (!m_blockedBotton) {
int addCounter = buttonsPerRow + elemCornersBotton;
// Don't add more than we have
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
QPoint center = QPoint(m_selection.center().x(),
m_selection.bottom() + SEPARATION);
if (addCounter > buttonsPerRow) {
adjustHorizontalCenter(center);
}
// ElemIndicator, elemsAtCorners
QVector<QPoint> positions = horizontalPoints(center, addCounter, true);
moveButtonsToPoints(positions, elemIndicator);
}
// Add buttons at the right side of the seletion
if (!m_blockedRight && elemIndicator < vecLength) {
int addCounter = buttonsPerCol;
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
QPoint center = QPoint(m_selection.right() + SEPARATION,
m_selection.center().y());
QVector<QPoint> positions = verticalPoints(center, addCounter, false);
moveButtonsToPoints(positions, elemIndicator);
}
// Add buttons at the top of the seletion
if (!m_blockedTop && elemIndicator < vecLength) {
int addCounter = buttonsPerRow + elemCornersTop;
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
QPoint center = QPoint(m_selection.center().x(),
m_selection.top() - m_buttonExtendedSize);
if (addCounter == 1 + buttonsPerRow) {
adjustHorizontalCenter(center);
}
QVector<QPoint> positions = horizontalPoints(center, addCounter, false);
moveButtonsToPoints(positions, elemIndicator);
}
// Add buttons at the left side of the seletion
if (!m_blockedLeft && elemIndicator < vecLength) {
int addCounter = buttonsPerCol;
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
QPoint center = QPoint(m_selection.left() - m_buttonExtendedSize,
m_selection.center().y());
QVector<QPoint> positions = verticalPoints(center, addCounter, true);
moveButtonsToPoints(positions, elemIndicator);
}
// If there are elements for the next cycle, increase the size of the
// base area
if (elemIndicator < vecLength && !(m_allSidesBlocked)) {
expandSelection();
}
updateBlockedSides();
}
}
开发者ID:ManuelLR,项目名称:flameshot,代码行数:95,代码来源:buttonhandler.cpp
示例6: QPoint
QPointF ObjectNodeInstance::transformOriginPoint() const
{
return QPoint();
}
开发者ID:55171514,项目名称:qtcreator,代码行数:4,代码来源:objectnodeinstance.cpp
示例7: internalEditor
void KexiComboBoxBase::createPopup(bool show)
{
//kDebug() << show << field() << popup() << m_updatePopupSelectionOnShow;
if (!field())
return;
m_insideCreatePopup = true;
QWidget* thisWidget = dynamic_cast<QWidget*>(this);
QWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget;
if (m_reinstantiatePopupOnShow) {
QWidget *oldPopup = popup();
setPopup(0);
delete oldPopup;
}
if (!popup()) {
setPopup(column() ? new KexiComboBoxPopup(thisWidget, *column())
: new KexiComboBoxPopup(thisWidget, *field()));
QObject::connect(popup(), SIGNAL(rowAccepted(KexiDB::RecordData*,int)),
thisWidget, SLOT(slotRowAccepted(KexiDB::RecordData*,int)));
QObject::connect(popup()->tableView(), SIGNAL(itemSelected(KexiDB::RecordData*)),
thisWidget, SLOT(slotItemSelected(KexiDB::RecordData*)));
popup()->setFocusProxy(widgetToFocus);
popup()->tableView()->setFocusProxy(widgetToFocus);
popup()->installEventFilter(thisWidget);
if (origValue().isNull())
popup()->tableView()->clearSelection();
else {
popup()->tableView()->selectRow(0);
popup()->tableView()->setHighlightedRecord(0);
}
}
if (show && internalEditor() && !internalEditor()->isVisible())
/*emit*/editRequested();
QPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos());
if (posMappedToGlobal != QPoint(-1, -1)) {
//! todo alter the position to fit the popup within screen boundaries
popup()->hide();
popup()->move(posMappedToGlobal + QPoint(0, thisWidget->height()));
//kDebug() << "pos:" << posMappedToGlobal + QPoint(0, thisWidget->height());
//to avoid flickering: first resize to 0-height, then show and resize back to prev. height
const int w = popupWidthHint();
popup()->resize(w, 0);
if (show) {
popup()->show();
//kDebug(44010) << "SHOW!!!";
}
popup()->updateSize(w);
if (m_updatePopupSelectionOnShow) {
int rowToHighlight = -1;
KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
KexiTableViewData *relData = column() ? column()->relatedData() : 0;
if (lookupFieldSchema) {
rowToHighlight = rowToHighlightForLookupTable();
} else if (relData) {
(void)valueForString(origValue().toString(), &rowToHighlight, 0, 1);
} else //enum hint
rowToHighlight = origValue().toInt();
/*-->*/ m_moveCursorToEndInInternalEditor_enabled = show;
m_selectAllInInternalEditor_enabled = show;
m_setValueInInternalEditor_enabled = show;
if (rowToHighlight == -1) {
rowToHighlight = qMax(popup()->tableView()->highlightedRecord(), 0);
setValueInInternalEditor(QVariant());
}
popup()->tableView()->selectRow(rowToHighlight);
popup()->tableView()->setHighlightedRecord(rowToHighlight);
if (rowToHighlight < popup()->tableView()->rowsPerPage())
popup()->tableView()->ensureCellVisible(0, -1);
/*-->*/ m_moveCursorToEndInInternalEditor_enabled = true;
m_selectAllInInternalEditor_enabled = true;
m_setValueInInternalEditor_enabled = true;
}
}
if (show) {
moveCursorToEndInInternalEditor();
selectAllInInternalEditor();
widgetToFocus->setFocus();
popup()->show();
popup()->raise();
popup()->repaint();
}
m_insideCreatePopup = false;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:90,代码来源:kexicomboboxbase.cpp
示例8: gsl_stats_sd
void BoxCurve::drawBox(QPainter *painter, const QwtScaleMap &xMap,
const QwtScaleMap &yMap, double *dat, int size) const {
const int px = xMap.transform(x(0));
const int px_min = xMap.transform(x(0) - 0.5);
const int px_max = xMap.transform(x(0) + 0.5);
const int box_width = 1 + (px_max - px_min) * b_width / 100;
const int hbw = box_width / 2;
const int median =
yMap.transform(gsl_stats_median_from_sorted_data(dat, 1, size));
int b_lowerq, b_upperq;
double sd, se, mean;
if (w_range == SD || w_range == SE || b_range == SD || b_range == SE) {
sd = gsl_stats_sd(dat, 1, size);
se = sd / sqrt((double)size);
mean = gsl_stats_mean(dat, 1, size);
}
if (b_range == SD) {
b_lowerq = yMap.transform(mean - sd * b_coeff);
b_upperq = yMap.transform(mean + sd * b_coeff);
} else if (b_range == SE) {
b_lowerq = yMap.transform(mean - se * b_coeff);
b_upperq = yMap.transform(mean + se * b_coeff);
} else {
b_lowerq = yMap.transform(
gsl_stats_quantile_from_sorted_data(dat, 1, size, 1 - 0.01 * b_coeff));
b_upperq = yMap.transform(
gsl_stats_quantile_from_sorted_data(dat, 1, size, 0.01 * b_coeff));
}
// draw box
if (b_style == Rect) {
const QRect r =
QRect(px - hbw, b_upperq, box_width, b_lowerq - b_upperq + 1);
painter->fillRect(r, QwtPlotCurve::brush());
painter->drawRect(r);
} else if (b_style == Diamond) {
QPolygon pa(4);
pa[0] = QPoint(px, b_upperq);
pa[1] = QPoint(px + hbw, median);
pa[2] = QPoint(px, b_lowerq);
pa[3] = QPoint(px - hbw, median);
painter->setBrush(QwtPlotCurve::brush());
painter->drawPolygon(pa);
} else if (b_style == WindBox) {
const int lowerq =
yMap.transform(gsl_stats_quantile_from_sorted_data(dat, 1, size, 0.25));
const int upperq =
yMap.transform(gsl_stats_quantile_from_sorted_data(dat, 1, size, 0.75));
QPolygon pa(8);
pa[0] = QPoint(px + hbw, b_upperq);
pa[1] = QPoint(int(px + 0.4 * box_width), upperq);
pa[2] = QPoint(int(px + 0.4 * box_width), lowerq);
pa[3] = QPoint(px + hbw, b_lowerq);
pa[4] = QPoint(px - hbw, b_lowerq);
pa[5] = QPoint(int(px - 0.4 * box_width), lowerq);
pa[6] = QPoint(int(px - 0.4 * box_width), upperq);
pa[7] = QPoint(px - hbw, b_upperq);
painter->setBrush(QwtPlotCurve::brush());
painter->drawPolygon(pa);
} else if (b_style == Notch) {
int j = (int)ceil(0.5 * (size - 1.96 * sqrt((double)size)));
int k = (int)ceil(0.5 * (size + 1.96 * sqrt((double)size)));
const int lowerCI = yMap.transform(dat[j]);
const int upperCI = yMap.transform(dat[k]);
QPolygon pa(10);
pa[0] = QPoint(px + hbw, b_upperq);
pa[1] = QPoint(px + hbw, upperCI);
pa[2] = QPoint(int(px + 0.25 * hbw), median);
pa[3] = QPoint(px + hbw, lowerCI);
pa[4] = QPoint(px + hbw, b_lowerq);
pa[5] = QPoint(px - hbw, b_lowerq);
pa[6] = QPoint(px - hbw, lowerCI);
pa[7] = QPoint(int(px - 0.25 * hbw), median);
pa[8] = QPoint(px - hbw, upperCI);
pa[9] = QPoint(px - hbw, b_upperq);
painter->setBrush(QwtPlotCurve::brush());
painter->drawPolygon(pa);
}
if (w_range) { // draw whiskers
const int l = int(0.1 * box_width);
int w_upperq, w_lowerq;
if (w_range == SD) {
w_lowerq = yMap.transform(mean - sd * w_coeff);
w_upperq = yMap.transform(mean + sd * w_coeff);
} else if (w_range == SE) {
w_lowerq = yMap.transform(mean - se * w_coeff);
w_upperq = yMap.transform(mean + se * w_coeff);
} else {
w_lowerq = yMap.transform(gsl_stats_quantile_from_sorted_data(
dat, 1, size, 1 - 0.01 * w_coeff));
w_upperq = yMap.transform(
gsl_stats_quantile_from_sorted_data(dat, 1, size, 0.01 * w_coeff));
}
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:AlphaPlot,代码行数:101,代码来源:BoxCurve.cpp
示例9: qInfo
//! [1]
bool RotoCanvas::openImage(const QString &fileName)
//! [1] //! [2]
{
qInfo()<<"RotoCanvas::openImage...";
QImage loadedImage;
if (!loadedImage.load(fileName))
return false;
this->outputSize = loadedImage.size();
if (this->loadedFI!=nullptr) {
delete this->loadedFI;
this->loadedFI=nullptr;
}
this->loadedFI = new QFileInfo(fileName);
//this->formatString = loadedFI.suffix();
QSize newSize = loadedImage.size().expandedTo(size());
//resizeImage(&loadedImage, this->outputSize);
resizeImage(&panelImage, newSize); // resizeImage(&)
fillCheckered(&panelImage);
/// Load the source frame as originalImage (converting to 32-bit):
originalImage = QImage(loadedImage.size(), QImage::Format_ARGB32);
originalImage.fill(qRgba(0,0,0,0));
QPainter bgPainter(&originalImage);
bgPainter.drawImage(QPoint(0,0), loadedImage); // originalImage = loadedImage;
QPainter displayPainter(&panelImage);
displayPainter.drawImage(QPoint(0,0), originalImage);
//isModified = false;
while (layerPtrs.length()>0) {
RotoCanvasLayer* thisLayer=layerPtrs.takeLast();
if (thisLayer!=nullptr) delete thisLayer;
}
int frameNumber=getSeqFrameNumber();
qInfo()<<"frameNumber: "<<frameNumber;
QString layersPath=getLayersFolderPath(frameNumber,false);
qInfo()<<"layersPath: "<<layersPath;
QDir layersDir=QDir(layersPath);
for (int thisLayerNumber=0; thisLayerNumber<layerCount; thisLayerNumber++) {
//QString thisLayerPath=layersDir.filePath(QString::number(thisLayerNumber)+"."+RotoCanvas::getSeqFormatString(fileName));
int thisLayerFrameNumber=-1;
QString thisLayerPath=getLayerImagePathMostRecent(frameNumber,thisLayerNumber,&thisLayerFrameNumber);
QFileInfo thisLayerFI=QFileInfo(thisLayerPath);
if (thisLayerPath!="" && thisLayerFI.exists()) {
//while (thisLayerFI.exists()) {
qInfo()<<"Found layer file: "<<thisLayerPath;
//QImage newImage(loadedImage.size(), QImage::Format_ARGB32);
//QImage* thisLayerImagePtr=new QImage();
//thisLayerImagePtr->load(thisLayerPath);
RotoCanvasLayer* thisLayerPtr=new RotoCanvasLayer();
thisLayerPtr->frameNumber=thisLayerFrameNumber;
thisLayerPtr->isModified=false;
thisLayerPtr->image.load(thisLayerPath);
//TODO: seek backward to get image from previous keyframe
layerPtrs.append(thisLayerPtr);
displayPainter.drawImage(QPoint(0, 0), thisLayerPtr->image);
//thisLayerNumber++;
//thisLayerPath=layersDir.filePath(QString::number(thisLayerNumber));
//thisLayerFI=QFileInfo(thisLayerPath);
//}
}
else {
layerPtrs.append((RotoCanvasLayer*)nullptr);
qInfo()<<"No layer file: "<<thisLayerPath;
}
}
//bgPainter.drawImage(QPoint(0,0), displayImage);
this->selectedLayerIndex=0;
update();
return true;
}
开发者ID:expertmm,项目名称:RotoCanvasPaint,代码行数:72,代码来源:rotocanvas.cpp
示例10: setFocus
void RoutingDrawWidget::mousePressEvent(QMouseEvent *e)
{
QScrollView::mousePressEvent(e);
setFocus();
RoutingWidget *parent = (RoutingWidget *)parentWidget();
StrGlobal *structure = parent->getStructure();
if (!structure)
return;
//treba prepocet na zoom a ofset qscrollview - a niekde to pada
int xp = e->x();
int yp = e->y();
viewportToContents(xp, yp, xp, yp);
xp = parent->deZoomVal(xp);
yp = parent->deZoomVal(yp);
RSItemBaseWithType *item;
QPtrList <RSItemBaseWithType> toClear;
if (e->button() == MidButton)
return;
if (mode == DragLink)
{
QPoint tmpp = mapToGlobal(QPoint(e->x(), e->y()));
connectLinkDrag(xp, yp, tmpp.x(), tmpp.y());
return;
}
// get mode
if (parent->getWidgetMode() != RoutingWidget::Normal &&
e->button() == LeftButton)
{
parent->putNewObjectAt(xp, yp);
return;
}
// find item under this point
bool oneSelected = false;
bool clearOthers = false;
RSItemBase::RSItemHandle resHandle = RSItemBase::None;
RSItemBaseWithType *itemToResize = NULL;
RSItemBaseWithType *itemOn = NULL;
linkHandle = -1;
for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next())
{
bool redraw = false;
if (!oneSelected && item->containsPoint(xp, yp))
{
if (!item->flagSelected())
{
item->setFlagSelected(true);
redraw = true;
clearOthers = true;
}
else if (e->state() & Qt::ControlButton)
{
item->setFlagSelected(false);
redraw = true;
}
oneSelected = true;
itemOn = item;
// check resize point
resHandle = item->getHandlePoint(xp, yp);
if (resHandle == RSItemBase::Other)
{
itemToResize = item;
linkHandle = item->getHandlePointNum(xp, yp);
}
else
{
linkHandle = -1;
if (resHandle != RSItemBase::None)
itemToResize = item;
}
}
else
{
if (item->flagSelected())
toClear.append(item);
}
if (redraw)
{
this->updateContents(parent->zoomVal(item->x()),
parent->zoomVal(item->y()),
parent->zoomVal(item->width()),
parent->zoomVal(item->height()));
}
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:alsa-tools,代码行数:101,代码来源:routingwidget.cpp
示例11: selArea
void RoutingDrawWidget::mouseReleaseEvent(QMouseEvent *e)
{
RoutingWidget *parent = (RoutingWidget *)parentWidget();
StrGlobal *structure = parent->getStructure();
if (!structure)
return;
if (mode == Select)
{
selectEndPoint.setX(e->x());
selectEndPoint.setY(e->y());
QRect selArea(selectStartPoint, selectEndPoint);
selArea = selArea.normalize();
// transform
int xt1;
int yt1;
int xt2;
int yt2;
viewportToContents(selArea.x(), selArea.y(), xt1, yt1);
xt1 = parent->deZoomVal(xt1);
yt1 = parent->deZoomVal(yt1);
viewportToContents(selArea.right(), selArea.bottom(), xt2, yt2);
xt2 = parent->deZoomVal(xt2);
yt2 = parent->deZoomVal(yt2);
// set flag for selected
QRect selAreaTrans(QPoint(xt1, yt1), QPoint(xt2, yt2));
RSItemBaseWithType *item;
for(item = structure->UsedItems.first(); item; item = structure->UsedItems.next() )
{
if (selAreaTrans.contains(item->x(), item->y()) &&
selAreaTrans.contains(item->x() + item->width(), item->y() + item->height()))
{
if (!item->flagSelected())
item->setFlagSelected(true);
}
else
{
if (!(e->state() & Qt::ControlButton) && item->flagSelected())
{
item->setFlagSelected(false);
this->updateContents(parent->zoomVal(item->x()),
parent->zoomVal(item->y()),
parent->zoomVal(item->width()),
parent->zoomVal(item->height()));
}
}
}
//this->updateContents(selArea);
this->viewport()->update(selArea);
}
if (mode != DragLink)
mode = None;
}
开发者ID:Distrotech,项目名称:alsa-tools,代码行数:66,代码来源:routingwidget.cpp
示例12: Q_Q
void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter &p,
int segLen, bool erase)
{
Q_Q(QLCDNumber);
QPoint ppt;
QPoint pt = pos;
int width = segLen/5;
const QPalette &pal = q->palette();
QColor lightColor,darkColor,fgColor;
if (erase){
lightColor = pal.color(q->backgroundRole());
darkColor = lightColor;
fgColor = lightColor;
} else {
lightColor = pal.light().color();
darkColor = pal.dark().color();
fgColor = pal.color(q->foregroundRole());
}
#define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y)))
#define LIGHT
#define DARK
if (fill) {
QPolygon a(0);
//The following is an exact copy of the switch below.
//don't make any changes here
switch (segmentNo) {
case 0 :
ppt = pt;
LIGHT;
LINETO(segLen - 1,0);
DARK;
LINETO(segLen - width - 1,width);
LINETO(width,width);
LINETO(0,0);
break;
case 1 :
pt += QPoint(0 , 1);
ppt = pt;
LIGHT;
LINETO(width,width);
DARK;
LINETO(width,segLen - width/2 - 2);
LINETO(0,segLen - 2);
LIGHT;
LINETO(0,0);
break;
case 2 :
pt += QPoint(segLen - 1 , 1);
ppt = pt;
DARK;
LINETO(0,segLen - 2);
LINETO(-width,segLen - width/2 - 2);
LIGHT;
LINETO(-width,width);
LINETO(0,0);
break;
case 3 :
pt += QPoint(0 , segLen);
ppt = pt;
LIGHT;
LINETO(width,-width/2);
LINETO(segLen - width - 1,-width/2);
LINETO(segLen - 1,0);
DARK;
if (width & 1) { // adjust for integer division error
LINETO(segLen - width - 3,width/2 + 1);
LINETO(width + 2,width/2 + 1);
} else {
LINETO(segLen - width - 1,width/2);
LINETO(width,width/2);
}
LINETO(0,0);
break;
case 4 :
pt += QPoint(0 , segLen + 1);
ppt = pt;
LIGHT;
LINETO(width,width/2);
DARK;
LINETO(width,segLen - width - 2);
LINETO(0,segLen - 2);
LIGHT;
LINETO(0,0);
break;
case 5 :
pt += QPoint(segLen - 1 , segLen + 1);
ppt = pt;
DARK;
LINETO(0,segLen - 2);
LINETO(-width,segLen - width - 2);
LIGHT;
LINETO(-width,width/2);
LINETO(0,0);
break;
case 6 :
pt += QPoint(0 , segLen*2);
//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:101,代码来源:qlcdnumber.cpp
示例13: QScrollBar
void Window::init()
{
m_data = new PrivateData;
m_data->bar = new QScrollBar(Qt::Vertical, this);
connect(m_data->bar,
SIGNAL(valueChanged(int)),
this,
SLOT(update()));
m_data->bar->setEnabled(true);
m_data->bar->setRange(0, 32678 - 600);
m_data->bar->setValue(0);
m_data->bar->move(width() - 30, 0);
m_data->bar->resize(30, height());
m_data->renderer = new GraphLib::GraphAggRenderer();
m_data->interactiveRenderer = new GraphLib::GraphAggInteractiveRenderer((GraphLib::GraphRenderer *)m_data->renderer);
//
//m_data->interactiveRenderer->setSize(NULL, 500, 500);
//
//
QImage *image = new QImage(10.00, 32.678, QImage::Format_ARGB32);
image->fill(Qt::darkYellow);
m_data->interactiveRenderer->setSize((void *)image,
image->width(), image->height());
//m_data->renderer->beginRender();
m_data->interactiveRenderer->fillPixelRect(200, 50, 30, 30, new QColor(Qt::red));
GraphLib::Rectangle rect1(0, 0, 300, 300);
m_data->interactiveRenderer->clipRegionAddRect(&rect1);
resize(800, 600);
m_data->renderer->beginRender();
m_data->interactiveRenderer->fillPixelRect(200, 50, 30, 30, new QColor(Qt::red));
m_data->renderer->setLineWidth(0.3);
m_data->renderer->drawLine(new GraphLib::Point(10, 10),
new GraphLib::Point(30, 50),
new QColor(Qt::red));
m_data->renderer->drawRect(new GraphLib::Point(50, 100),
new GraphLib::Point(150, 40201), new QColor(Qt::blue));
m_data->renderer->fillRect(new GraphLib::Point(80, 50),
new GraphLib::Point(100, 70), new QColor(Qt::cyan));
m_data->renderer->drawEllipse(new GraphLib::Point(50, 100),
20, 20, new QColor(0, 1, 0));
m_data->renderer->fillEllipse(new GraphLib::Point(100, 100),
20, 20, new QColor(1, 1, 0));
GraphLib::Point polyline[] = {QPoint(110, 210), QPoint(120,210), QPoint(130,220)};
m_data->renderer->drawPolyline(polyline,
3, new QColor(1, 1, 0));
GraphLib::Point polygon[] = {QPoint(110, 310), QPoint(120,310), QPoint(130,320)};
m_data->renderer->drawPolygon(polygon,
3, new QColor(1, 1, 0));
GraphLib::Point polygon1[] = {QPoint(110, 410), QPoint(120,410), QPoint(130,420)};
m_data->renderer->fillPolygon(polygon1,
3, new QColor(1, 1, 0));
//for (int i = 100; i < 99900; i+= 20) {
for (int i = 100; i < 1000; i+= 20) {
QString str = QString("line %1").arg(i);
m_data->renderer->drawString(str,
new GraphLib::Point(20, i), 0, new QColor(1, 1, 0));
}
GraphLib::GraphAggRenderer *r = m_data->renderer;
r->beginPath();
r->moveTo(30, 30);
r->lineTo(500, 500);
r->moveTo(200, 200.2);
r->lineTo(400, 200.2);
r->moveTo(200, 100);
r->lineTo(400, 100);
r->moveTo(50.5, 50);
r->lineTo(50.5, 200);
r->setLineWidth(0.5);
r->endPath();
//.........这里部分代码省略.........
开发者ID:ongbe,项目名称:xchart,代码行数:101,代码来源:window.cpp
示例14: ereg
bool CertWizard::validateCurrentPage() {
if (currentPage() == qwpNew) {
QRegExp ereg(QLatin1String("(^$)|((.+)@(.+))"), Qt::CaseInsensitive, QRegExp::RegExp2);
if (!ereg.exactMatch(qleEmail->text())) {
qlError->setText(tr("Unable to validate email.<br />Enter a valid (or blank) email to continue."));
qwpNew->setComplete(false);
return false;
} else {
kpNew = generateNewCert(qleName->text(), qleEmail->text());
if (! validateCert(kpNew)) {
qlError->setText(tr("There was an error generating your certificate.<br />Please try again."));
return false;
}
}
}
if (currentPage() == qwpExport) {
QByteArray qba = exportCert(kpNew);
if (qba.isEmpty()) {
QToolTip::showText(qleExportFile->mapToGlobal(QPoint(0,0)), tr("Your certificate and key could not be exported to PKCS#12 format. There might be an error in your certificate."), qleExportFile);
return false;
}
QFile f(qleExportFile->text());
if (! f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered)) {
QToolTip::showText(qleExportFile->mapToGlobal(QPoint(0,0)), tr("The file could not be opened for writing. Please use another file."), qleExportFile);
return false;
}
if (! f.setPermissions(QFile::ReadOwner | QFile::WriteOwner)) {
QToolTip::showText(qleExportFile->mapToGlobal(QPoint(0,0)), tr("The file's permissions could not be set. No certificate and key has been written. Please use another file."), qleExportFile);
return false;
}
qint64 written = f.write(qba);
f.close();
if (written != qba.length()) {
QToolTip::showText(qleExportFile->mapToGlobal(QPoint(0,0)), tr("The file could not be written successfully. Please use another file."), qleExportFile);
return false;
}
}
if (currentPage() == qwpImport) {
QFile f(qleImportFile->text());
if (! f.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) {
QToolTip::showText(qleImportFile->mapToGlobal(QPoint(0,0)), tr("The file could not be opened for reading. Please use another file."), qleImportFile);
return false;
}
QByteArray qba = f.readAll();
f.close();
if (qba.isEmpty()) {
QToolTip::showText(qleImportFile->mapToGlobal(QPoint(0,0)), tr("The file is empty or could not be read. Please use another file."), qleImportFile);
return false;
}
QPair<QList<QSslCertificate>, QSslKey> imp = importCert(qba, qlePassword->text());
if (! validateCert(imp)) {
QToolTip::showText(qleImportFile->mapToGlobal(QPoint(0,0)), tr("The file did not contain a valid certificate and key. Please use another file."), qleImportFile);
return false;
}
kpNew = imp;
}
if (currentPage() == qwpFinish) {
g.s.kpCertificate = kpNew;
}
return QWizard::validateCurrentPage();
}
开发者ID:MumbleTransifexBot,项目名称:mumble,代码行数:62,代码来源:Cert.cpp
示例15: resizeEvent
void resizeEvent(QResizeEvent *event) {
if (scene())
scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
QGraphicsView::resizeEvent(event);
}
开发者ID:Andreas665,项目名称:qt,代码行数:5,代码来源:main.cpp
示例16: p
void ShaderEffect::updateRenderTargets()
{
if (!m_changed)
return;
m_changed = false;
int count = m_renderTargets.count();
for (int i = 0; i < count; i++) {
if (m_renderTargets[i]->isLive() || m_renderTargets[i]->isDirtyTexture()) {
m_renderTargets[i]->updateBackbuffer();
ShaderEffectBuffer* target = m_renderTargets[i]->fbo();
if (target && target->isValid() && target->width() > 0 && target->height() > 0) {
QPainter p(target);
p.setCompositionMode(QPainter::CompositionMode_Clear);
p.fillRect(QRect(QPoint(0, 0), target->size()), Qt::transparent);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
QRectF sourceRect = m_renderTargets[i]->sourceRect();
QSize textureSize = m_renderTargets[i]->textureSize();
qreal yflip = m_renderTargets[i]->isMirrored() ? -1.0 : 1.0; // flip y to match scenegraph, it also flips texturecoordinates
qreal xscale = 1.0;
qreal yscale = 1.0 * yflip;
qreal leftMargin = 0.0;
qreal rightMargin = 0.0;
qreal topMargin = 0.0;
qreal bottomMargin = 0.0;
qreal width = m_renderTargets[i]->sourceItem()->width();
qreal height = m_renderTargets[i]->sourceItem()->height();
if (!sourceRect.isEmpty()) {
leftMargin = -sourceRect.left();
rightMargin = sourceRect.right() - width;
topMargin = -sourceRect.top();
bottomMargin = sourceRect.bottom() - height;
}
if ((width + leftMargin + rightMargin) > 0 && (height + topMargin + bottomMargin) > 0) {
if (!textureSize.isEmpty()) {
qreal textureWidth = textureSize.wid
|
请发表评论