本文整理汇总了C++中QPixmap::createMaskFromColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::createMaskFromColor方法的具体用法?C++ QPixmap::createMaskFromColor怎么用?C++ QPixmap::createMaskFromColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::createMaskFromColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QIcon
void MainWindow::W7ToolbarSetImages() {
QPixmap img;
QBitmap mask;
HIMAGELIST himl = ImageList_Create(20, 20, ILC_COLOR32, 4, 0);
img = QIcon(":/back.png").pixmap(20);
mask = img.createMaskFromColor(Qt::transparent);
ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());
img = QIcon(":/play.png").pixmap(20);
mask = img.createMaskFromColor(Qt::transparent);
ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());
img = QIcon(":/forward.png").pixmap(20);
mask = img.createMaskFromColor(Qt::transparent);
ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());
img = QIcon(":/pause.png").pixmap(20);
mask = img.createMaskFromColor(Qt::transparent);
ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha), mask.toWinHBITMAP());
if (m_w7toolbar) m_w7toolbar->ThumbBarSetImageList(this->winId(), himl);
ImageList_Destroy(himl);
}
示例2: generate
QCursor CursorFactory::generate (const DocumentModelDigitizeCurve &modelDigitizeCurve) const
{
// To prevent hideous drawing errors when the line is thicker, we
// leave a padding region around the outside equal in size to the line width
int innerRadius = modelDigitizeCurve.cursorInnerRadius();
int size = CursorSizeToPixels (modelDigitizeCurve.cursorSize());
int halfSize = size / 2;
int lineWidth = modelDigitizeCurve.cursorLineWidth();
int halfLineWidth = lineWidth / 2;
if (modelDigitizeCurve.cursorStandardCross()) {
// Standard cursor
return QCursor (Qt::CrossCursor);
} else {
// Custom cursor
const int BACKGROUND_COLOR = Qt::white, FOREGROUND_COLOR = Qt::black;
// Cursor is created with pic image (which has nontrivial pen) masked by picMask image
// (which has single color pen)
QPixmap picMask (size,
size);
QPainter picMaskPaint (&picMask);
picMask.fill (QColor (BACKGROUND_COLOR));
QPen pen (QBrush (FOREGROUND_COLOR),
modelDigitizeCurve.cursorLineWidth());
picMaskPaint.setPen (pen);
picMaskPaint.drawLine (QPointF (halfSize,
halfSize - innerRadius - halfLineWidth),
QPointF (halfSize,
lineWidth)); // Up
picMaskPaint.drawLine (QPointF (halfSize - innerRadius - halfLineWidth,
halfSize),
QPointF (lineWidth,
halfSize)); // Left
picMaskPaint.drawLine (QPointF (halfSize,
halfSize + innerRadius + halfLineWidth),
QPointF (halfSize,
size - 1 - lineWidth)); // Down
picMaskPaint.drawLine (QPointF (halfSize + innerRadius + halfLineWidth,
halfSize),
QPointF (size - 1 - lineWidth,
halfSize)); // Right
QPixmap pic (size,
size);
pic.fill (QColor (FOREGROUND_COLOR));
return QCursor (pic.createMaskFromColor(QColor (BACKGROUND_COLOR)),
picMask.createMaskFromColor(QColor (BACKGROUND_COLOR)));
}
}
示例3: addWidgetToViewer
void mainWindow::addWidgetToViewer( QPixmap p, bool isNewPic)
{
if( isNewPic)
for( int i = viewer->count()-1; i >= 0; i--)
viewer->removeTab( i);
if( viewer->count() > 0)
{
QPixmap output( p.width(), p.height());
output.fill(Qt::transparent);
QPainter painter( &output);
//Setting the mask for the output Image
QBitmap mask = p.createMaskFromColor(Qt::MaskInColor);
QPixmap tempImage = monitorWidget->image->copy( monitorWidget->image->rect());
tempImage.setMask(mask);
painter.drawPixmap(0, 0, tempImage);
painter.drawPixmap(p.width(), 0 , p);
QPixmap *image = new QPixmap(output);
QWidget *w = new QWidget(0);
QLabel *l = new QLabel( w);
l->setPixmap( *image);
viewer->addTab( w, QString("ForeGround %1").arg(viewer->count()));
}
else
{
monitorWidget->setFixedSize( p.size());
viewer->addTab( monitorWidget, "Original");
}
}
示例4: itemExtraImage
bool CWizAttachmentListView::itemExtraImage(const QModelIndex& index, const QRect& itemBound, QRect& rcImage, QPixmap& extraPix) const
{
if (const CWizAttachmentListViewItem* item = attachmentItemFromIndex(index))
{
QString strIcoPath;
CWizDatabase& db = m_dbMgr.db(item->attachment().strKbGUID);
MainWindow* mainWindow = qobject_cast<MainWindow *>(Core::ICore::mainWindow());
if (!db.IsAttachmentDownloaded(item->attachment().strGUID))
{
strIcoPath = ::WizGetSkinResourcePath(mainWindow->userSettings().skin()) + "downloading.bmp";
}
else if (db.IsAttachmentModified(item->attachment().strGUID))
{
strIcoPath = ::WizGetSkinResourcePath(mainWindow->userSettings().skin()) + "uploading.bmp";
}
else
return false;
QPixmap fullPix(strIcoPath);
extraPix = fullPix.copy(0, 0, fullPix.height(), fullPix.height());
extraPix.setMask(extraPix.createMaskFromColor(Qt::black, Qt::MaskInColor));
int nMargin = -1;
rcImage.setLeft(itemBound.right() - extraPix.width() - nMargin);
rcImage.setTop(itemBound.bottom() - extraPix.height() - nMargin);
rcImage.setSize(extraPix.size());
return true;
}
return false;
}
示例5: i
TransparentSprite(
const int width, const int height,
const int r = 255,
const int g = 255,
const int b = 255)
: angle(GetRandomUniform() * 2.0 * boost::math::constants::pi<double>()), //Random direction
speed(2.0),
maxx(0),
maxy(0)
{
QImage i(width,height,QImage::Format_ARGB32);
const QColor transparency_color = QColor(0,0,0,255);
const double r_real = static_cast<double>(r);
const double g_real = static_cast<double>(g);
const double b_real = static_cast<double>(b);
const double midx = static_cast<double>(width ) / 2.0;
const double midy = static_cast<double>(height) / 2.0;
const double ray = std::min(midx,midy);
for (int y=0;y!=height;++y)
{
const double y_real = static_cast<double>(y);
const double dy = midy - y_real;
const double dy2 = dy * dy;
for (int x=0;x!=width;++x)
{
const double x_real = static_cast<double>(x);
const double dx = midx - x_real;
const double dx2 = dx * dx;
const double dist = std::sqrt(dx2 + dy2);
if (dist < ray)
{
const QColor c(
(1.0 - (dist / ray)) * r_real,
(1.0 - (dist / ray)) * g_real,
(1.0 - (dist / ray)) * b_real
);
i.setPixel(x,y,c.rgb());
}
else
{
i.setPixel(x,y,transparency_color.rgb());
}
}
}
this->setPixmap(this->pixmap().fromImage(i));
//Add transparancy
QPixmap pixmap = this->pixmap();
const QBitmap mask = pixmap.createMaskFromColor(transparency_color);
pixmap.setMask(mask);
this->setPixmap(pixmap);
}
示例6: QString
QPixmap * QTHelpers::createPixmap(const QString &filename)
{
QString id = QString("T") + filename;
if( m_Pixmaps.find( id ) != m_Pixmaps.end() )
return m_Pixmaps[id];
QPixmap * pixmap = new QPixmap( filename );
QImage image = pixmap->toImage();
QColor transpColor = image.pixel(0,0);
pixmap->setMask( pixmap->createMaskFromColor( transpColor ) );
m_Pixmaps[id]=pixmap;
return pixmap;
}
示例7: on_bSetFG_clicked
void Database_Terrain::on_bSetFG_clicked()
{
ImageBrowser *imageBrowser = new ImageBrowser();
imageBrowser->setupBrowser("/backgrounds", ImageBrowser::BlockGIF|ImageBrowser::BlockJPEG|ImageBrowser::BlockPBM|ImageBrowser::BlockPCX|ImageBrowser::BlockPGM|ImageBrowser::BlockPNM|ImageBrowser::BlockTGA|ImageBrowser::BlockTIFF, QList<QSize>() << QSize(640, 480));
if (imageBrowser->exec())
{
QString fileLocation = imageBrowser->getFileLocation();
QPixmap pixmap = QPixmap(fileLocation).scaled(400, 300);
pixmap.setMask(pixmap.createMaskFromColor(QColor(255, 0, 255), Qt::MaskInColor));
bgPreview_FGImageItem->setPixmap(pixmap);
gvBGPreview->setEnabled(true);
(*terrainRef)->setFGImageLocation(fileLocation);
}
delete imageBrowser;
}
示例8: symbolPixmap
QPixmap IqAmeSymbolGraphicsItem::symbolPixmap(int number, bool selected)
{
if (!selected) {
if (m_symbolPixmaps.contains(number))
return m_symbolPixmaps[number];
m_symbolPixmaps[number] = QPixmap(QString("://symbols/%0.png").arg(number));
return m_symbolPixmaps[number];
}
if (m_selectedSymbolPixmaps.contains(number))
return m_selectedSymbolPixmaps[number];
QPixmap oldPixmap = symbolPixmap(number);
QPixmap newPixmap (oldPixmap.size());
newPixmap.fill(Qt::blue);
newPixmap.setMask(oldPixmap.createMaskFromColor(Qt::transparent));
m_selectedSymbolPixmaps[number] = newPixmap;
return m_selectedSymbolPixmaps[number];
}
示例9: setStateColor
void setStateColor()
{
const int width = this->pixmap().width();
const int height = this->pixmap().height();
QImage i(width,height,QImage::Format_ARGB32);
const QColor transparency_color = QColor(0,0,0,255);
const QColor state_color = getStateColor();
const double midx = static_cast<double>(width ) / 2.0;
const double midy = static_cast<double>(height) / 2.0;
const double ray = std::min(midx,midy);
for (int y=0;y!=height;++y)
{
const double y_real = static_cast<double>(y);
const double dy = midy - y_real;
const double dy2 = dy * dy;
for (int x=0;x!=width;++x)
{
const double x_real = static_cast<double>(x);
const double dx = midx - x_real;
const double dx2 = dx * dx;
const double dist = std::sqrt(dx2 + dy2);
if (dist < ray)
{
i.setPixel(x,y,state_color.rgb());
}
else
{
i.setPixel(x,y,transparency_color.rgb());
}
}
}
this->setPixmap(this->pixmap().fromImage(i));
//Add transparancy
QPixmap pixmap = this->pixmap();
const QBitmap mask = pixmap.createMaskFromColor(transparency_color);
pixmap.setMask(mask);
this->setPixmap(pixmap);
}
示例10: main
int main( int argc, char ** argv )
{
// First, look for command-line arguments that we want to deal with before launching anything
if ( argc == 2 )
{
QString str(argv[1]);
if ( str == "-v" || str == "--version" )
{
std::cout << Mantid::Kernel::MantidVersion::version() << " (" <<
Mantid::Kernel::MantidVersion::releaseDate() << ")" << std::endl;
exit(0);
}
else if ( str == "-r" || str == "--revision") // Print abbreviated git SHA-1
{
QString revision(Mantid::Kernel::MantidVersion::revision());
std::cout << revision.toStdString() << std::endl;
exit(0);
}
else if ( str == "-a" || str == "--about" )
{
MantidApplication app( argc, argv ); // Needed to avoid an error
ApplicationWindow::about();
exit(0);
}
else if ( str == "-h" || str == "--help")
{
QString s = "\nUsage: ";
s += "MantidPlot [options] [filename]\n\n";
s += "Valid options are:\n";
s += "-a or --about: show about dialog and exit\n";
s += "-d or --default-settings: start MantidPlot with the default settings\n";
s += "-h or --help: show command line options\n";
s += "-v or --version: print MantidPlot version and release date\n";
s += "-r or --revision: print MantidPlot version and release date\n";
s += "-s or --silent: start mantidplot without any setup dialogs\n";
s += "-x or --execute: execute the script file given as argument\n";
s += "-xq or --executeandquit: execute the script file given as argument and then exit MantidPlot\n\n";
s += "'filename' can be any of .qti, qti.gz, .opj, .ogm, .ogw, .ogg, .py or ASCII file\n\n";
std::wcout << s.toStdWString();
exit(0);
}
//else if ( str == "-m" || str == "--manual" ) // Not for the time being at least
// ApplicationWindow::showStandAloneHelp();
}
MantidApplication app( argc, argv );
QStringList args = app.arguments();
args.removeFirst(); // remove application name
try
{
// Splash
QPixmap pixmap;
if (!pixmap.load(":/MantidSplashScreen.png")) std::cerr << "Couldn't load splashscreen\n";
QSplashScreen splash(pixmap);
const QString releaseDateTime(Mantid::Kernel::MantidVersion::releaseDate());
const QString versionInfo(Mantid::Kernel::MantidVersion::version());
splash.showMessage("Release: " + releaseDateTime + " (Version " + versionInfo + ")", Qt::AlignLeft | Qt::AlignBottom);
splash.setMask(pixmap.createMaskFromColor(QColor(Qt::transparent)));
splash.show();
// If we take too long to get to the event loop then box starts out gray so ensure
// it is painted before doing any heavy lifting like the ApplicationWindow init
splash.repaint();
app.processEvents();
const bool factorySettings = (args.contains("-d") || args.contains("--default-settings"));
ApplicationWindow *mw = new ApplicationWindow(factorySettings, args);
mw->restoreApplicationGeometry();
mw->parseCommandLineArguments(args);
app.processEvents();
//register a couple of fonts
QFontDatabase::addApplicationFont(":/fonts/MontserratAlternates-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/OpenSans-Regular.ttf");
splash.finish(mw);
app.connect( &app, SIGNAL(lastWindowClosed()), mw, SLOT(exitWithPresetCode()) );
QTimer::singleShot(0, mw, SLOT(about2Start()));
return app.exec();
}
catch(std::exception& e)
{
QMessageBox::critical(0,"Mantid - Error",
QString("An unhandled exception has been caught. MantidPlot will have to close. Details:\n\n")+e.what());
}
catch(...)
{
QMessageBox::critical(0,"Mantid - Error",
"An unhandled exception has been caught. MantidPlot will have to close.");
}
}
示例11: createTaskBarButtons
void MainInterface::createTaskBarButtons()
{
taskbar_wmsg = WM_NULL;
/*Here is the code for the taskbar thumb buttons
FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
FIXME:the play button's picture doesn't changed to pause when clicked
*/
CoInitialize( 0 );
if( S_OK == CoCreateInstance( CLSID_TaskbarList,
NULL, CLSCTX_INPROC_SERVER,
IID_ITaskbarList3,
(void **)&p_taskbl) )
{
p_taskbl->HrInit();
if( (himl = ImageList_Create( 20, //cx
20, //cy
ILC_COLOR32,//flags
4,//initial nb of images
0//nb of images that can be added
) ) != NULL )
{
QPixmap img = QPixmap(":/win7/prev");
QPixmap img2 = QPixmap(":/win7/pause");
QPixmap img3 = QPixmap(":/win7/play");
QPixmap img4 = QPixmap(":/win7/next");
QBitmap mask = img.createMaskFromColor(Qt::transparent);
QBitmap mask2 = img2.createMaskFromColor(Qt::transparent);
QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
msg_Err( p_intf, "First ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
msg_Err( p_intf, "Second ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
msg_Err( p_intf, "Third ImageList_Add failed" );
if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
msg_Err( p_intf, "Fourth ImageList_Add failed" );
}
// Define an array of two buttons. These buttons provide images through an
// image list and also provide tooltips.
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_BITMAP | THB_FLAGS);
THUMBBUTTON thbButtons[3];
thbButtons[0].dwMask = dwMask;
thbButtons[0].iId = 0;
thbButtons[0].iBitmap = 0;
thbButtons[0].dwFlags = THBF_HIDDEN;
thbButtons[1].dwMask = dwMask;
thbButtons[1].iId = 1;
thbButtons[1].iBitmap = 2;
thbButtons[1].dwFlags = THBF_HIDDEN;
thbButtons[2].dwMask = dwMask;
thbButtons[2].iId = 2;
thbButtons[2].iBitmap = 3;
thbButtons[2].dwFlags = THBF_HIDDEN;
HRESULT hr = p_taskbl->ThumbBarSetImageList(winId(), himl );
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr );
else
{
hr = p_taskbl->ThumbBarAddButtons(winId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr );
}
CONNECT( THEMIM->getIM(), playingStatusChanged( int ), this, changeThumbbarButtons( int ) );
}
示例12: buttonIcon
QBitmap QWaylandMaterialDecoration::buttonIcon(const QString &name) const
{
QIcon icon(":/icons/" + name + ".svg");
QPixmap pixmap = icon.pixmap(QSize(BUTTON_WIDTH, BUTTON_WIDTH));
return pixmap.createMaskFromColor(QColor("black"), Qt::MaskOutColor);
}
示例13: paintEvent
//.........这里部分代码省略.........
dopangle = 30.0*k; painter.rotate(dopangle);
for(int i = 1; i <= 2; i++) {
angle += dopangle*k; // text.sprintf(("%.0f"),angle);
DrawText(painter, xoff, yoff, angle); //text);
mpointsF[0].setX(0.0); mpointsF[0].setY(-rRoll);
mpointsF[1].setX(0.0); mpointsF[1].setY(-rRoll-hs2);
mpointsF[2].setX(-ws2*k); mpointsF[2].setY(-rRoll-hs2);
painter.drawPolyline(mpointsF, 3);
painter.rotate(dopangle);
}
if(k == -1) painter.rotate(180.0);
}
//- 180:
xoff = -1.0;
angle += dopangle; // text.sprintf(("%.0f"),angle);
DrawText(painter, xoff, yoff, angle); //text);
// painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs2));
// painter.drawLine(QPointF(-3.0, -rRoll-hs2+4.0), QPointF(3.0, -rRoll-hs2+4.0));
// painter.drawLine(QPointF(-6.0, -rRoll-hs2), QPointF(6.0, -rRoll-hs2));
lines << QLineF(0.0,-rRoll, 0.0,-rRoll-hs2);
lines << QLineF(-3.0,-rRoll-hs2+4.0, 3.0,-rRoll-hs2+4.0);
lines << QLineF(-6.0,-rRoll-hs2, 6.0,-rRoll-hs2);
painter.drawLines(lines); lines.clear();
painter.rotate(-180.0);
//===== Static: =====
painter.rotate(RollAngle);
painter.setPen(Qt::NoPen);
//-Balance:
pen.setColor(Qt::black);
pen.setWidthF(0.5); painter.setPen(pen);
linearGrad.setStart(0.0, -3.5+1.5);
linearGrad.setFinalStop(0.0, 3.5);
linearGrad.setColorAt(0, QColor(255,255,0, 255));
linearGrad.setColorAt(1, QColor(88,88,0, 255));
QBrush brushBalance(linearGrad); painter.setBrush(brushBalance);
//-Left:
mpointsF[0].setX(-48.0-1.0); mpointsF[0].setY(0.0);
mpointsF[1].setX(-48.0-1.0-8.0); mpointsF[1].setY(-3.5);
mpointsF[2].setX(-48.0-1.0-8.0-24.0); mpointsF[2].setY(-3.5);
mpointsF[3].setX(-48.0-1.0-8.0-24.0); mpointsF[3].setY(3.5);
mpointsF[4].setX(-48.0-1.0-8.0); mpointsF[4].setY(3.5);
painter.drawPolygon(mpointsF,5);
//-Right:
mpointsF[0].setX(48.0+1.0); // mpointsF[0].setY(0.0);
mpointsF[1].setX(48.0+1.0+8.0); // mpointsF[1].setY(-3.5);
mpointsF[2].setX(48.0+1.0+8.0+24.0); // mpointsF[2].setY(-3.5);
mpointsF[3].setX(48.0+1.0+8.0+24.0); // mpointsF[3].setY(3.5);
mpointsF[4].setX(48.0+1.0+8.0); // mpointsF[4].setY(3.5);
painter.drawPolygon(mpointsF,5);
//-Center:
linearGrad.setStart(0.0, 0.0);
linearGrad.setFinalStop(0.0, 12.0+6.0);
linearGrad.setColorAt(0, QColor(255,255,0, 255));
linearGrad.setColorAt(1, QColor(88,88,0, 255));
QBrush brushBalanceCenter(linearGrad); painter.setBrush(brushBalanceCenter);
mpointsF[0].setX(0.0); mpointsF[0].setY(0.0);
mpointsF[1].setX(-30.0); mpointsF[1].setY(12.0);
mpointsF[2].setX(0.0); mpointsF[2].setY(6.0);
mpointsF[3].setX(30.0); mpointsF[3].setY(12.0);
painter.drawPolygon(mpointsF,4);
//- Triangle:
painter.setBrush(QBrush(QColor(255,255,0, 255)));
mpointsF[0].setX(0.0); mpointsF[0].setY(-rRoll);
mpointsF[1].setX(6.5); mpointsF[1].setY(-rRoll + 11.258); // 11.258 = sqrt(3.0)/2.0 * 13.0
mpointsF[2].setX(-6.5); mpointsF[2].setY(-rRoll + 11.258);
painter.drawPolygon(mpointsF,3);
*/
//==========================
painter.setOpacity(0.6);
// QPixmap pixmap = PEkranoplanGLWidget->renderPixmap(); //80,80);//,false);
// bool b = pixmap.save("d:\\Progs\\WIGTS\\__TT.png", "PNG");
// painter.drawPixmap(-40,-40, pixmap);
// bool b2 = pixmap2.save("d:\\Progs\\WIGTS\\__TT2.png", "PNG");
// QImage image = PEkranoplanGLWidget->grabFrameBuffer();
QPixmap pixmap = QPixmap::fromImage(PEkranoplanGL->grabFrameBuffer());
pixmap.setMask(pixmap.createMaskFromColor(QColor(0,0,0, 255)));
painter.drawPixmap(-WidthHalf+1,HeightHalf-pixmap.rect().height()-1, pixmap);
/*
//GetPMainWnd()->statusBar()->hide();
//GetPMainWnd()->statusBar()->repaint();
QString s; s.sprintf("PitchAngle0 = %.1f, RollAngle0 = %.1f; PitchAngle = %.1f, RollAngle = %.1f;", PitchAngle0,RollAngle0, PitchAngle,RollAngle);
GetPMainWnd()->statusBar()->showMessage(s);
GetPMainWnd()->statusBar()->repaint();
*/
}
示例14: paintEvent
//.........这里部分代码省略.........
angle += dopangle*k;
}
//- 90:
xoff = 1.0;
angle += dopangle*k; // text.sprintf(("%.0f"),angle);
DrawText(painter, xoff, yoff, angle); //text);
lines << QLineF(0.0,-rRoll, 0.0,-rRoll-hs2);
lines << QLineF(-4.0,-rRoll-hs2, 4.0,-rRoll-hs2);
painter.drawLines(lines); lines.clear();
//- 120, 150:
xoff = -ws2/2.0*k;
dopangle = 30.0*k; painter.rotate(dopangle);
for(int i = 1; i <= 2; i++)
{
angle += dopangle*k; // text.sprintf(("%.0f"),angle);
DrawText(painter, xoff, yoff, angle); //text);
mpointsF[0].setX(0.0); mpointsF[0].setY(-rRoll);
mpointsF[1].setX(0.0); mpointsF[1].setY(-rRoll-hs2);
mpointsF[2].setX(-ws2*k); mpointsF[2].setY(-rRoll-hs2);
painter.drawPolyline(mpointsF, 3);
painter.rotate(dopangle);
}
if(k == -1) painter.rotate(180.0);
}
//- 180:
xoff = -1.0;
angle += dopangle; // text.sprintf(("%.0f"),angle);
DrawText(painter, xoff, yoff, angle); //text);
lines << QLineF(0.0,-rRoll, 0.0,-rRoll-hs2);
lines << QLineF(-3.0,-rRoll-hs2+4.0, 3.0,-rRoll-hs2+4.0);
lines << QLineF(-6.0,-rRoll-hs2, 6.0,-rRoll-hs2);
painter.drawLines(lines); lines.clear();
painter.rotate(-180.0);
//===== Static: =====
painter.rotate(RollAngle);
//==Balance:
pen.setColor(ColorStaticBalanceOutline); pen.setWidthF(0.5); painter.setPen(pen);
linearGrad.setStart(0.0, -3.5+1.5);
linearGrad.setFinalStop(0.0, 3.5);
linearGrad.setColorAt(0, ColorStaticBalance0);
linearGrad.setColorAt(1, ColorStaticBalance1);
QBrush brushBalance(linearGrad); painter.setBrush(brushBalance);
//-Left:
mpointsF[0].setX(-48.0-1.0); mpointsF[0].setY(0.0);
mpointsF[1].setX(-48.0-1.0-8.0); mpointsF[1].setY(-3.5);
mpointsF[2].setX(-48.0-1.0-8.0-24.0); mpointsF[2].setY(-3.5);
mpointsF[3].setX(-48.0-1.0-8.0-24.0); mpointsF[3].setY(3.5);
mpointsF[4].setX(-48.0-1.0-8.0); mpointsF[4].setY(3.5);
painter.drawPolygon(mpointsF,5);
//-Right:
mpointsF[0].setX(48.0+1.0);
mpointsF[1].setX(48.0+1.0+8.0);
mpointsF[2].setX(48.0+1.0+8.0+24.0);
mpointsF[3].setX(48.0+1.0+8.0+24.0);
mpointsF[4].setX(48.0+1.0+8.0);
painter.drawPolygon(mpointsF,5);
//-Center:
linearGrad.setStart(0.0, 0.0);
linearGrad.setFinalStop(0.0, 12.0+6.0);
linearGrad.setColorAt(0, ColorStaticBalance0);
linearGrad.setColorAt(1, ColorStaticBalance1);
QBrush brushBalanceCenter(linearGrad); painter.setBrush(brushBalanceCenter);
mpointsF[0].setX(0.0); mpointsF[0].setY(0.0);
mpointsF[1].setX(-30.0); mpointsF[1].setY(12.0);
mpointsF[2].setX(0.0); mpointsF[2].setY(6.0);
mpointsF[3].setX(30.0); mpointsF[3].setY(12.0);
painter.drawPolygon(mpointsF,4);
//- Triangle:
painter.setBrush(QBrush(ColorStaticTriangle));
mpointsF[0].setX(0.0); mpointsF[0].setY(-rRoll);
mpointsF[1].setX(6.5); mpointsF[1].setY(-rRoll + 11.258); // 11.258 = sqrt(3.0)/2.0 * 13.0
mpointsF[2].setX(-6.5); mpointsF[2].setY(-rRoll + 11.258);
painter.drawPolygon(mpointsF,3);
//=============================
painter.setOpacity(0.6);
QPixmap pixmap = PEkranoplanGL->renderPixmap(); //80,80);//,false);
pixmap.setMask(pixmap.createMaskFromColor(QColor(0,0,0, 255)));
painter.drawPixmap(-WidthHalf+1,HeightHalf-pixmap.rect().height()-1, pixmap);
//--
painter.end();
QPainter paint(this);
paint.drawImage(0,0, imgagePaint);
}
示例15: setMask
void LayerWidget::setMask(const QImage &mask)
{
QPixmap masked = QPixmap::fromImage(mask);
masked.setMask(masked.createMaskFromColor(QColor(Qt::white)));
_maskItem->setPixmap(masked);
}