예제 #1
0
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);
}
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)));
  }
}
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");
    }
}
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
0
  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
0
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
0
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;
}
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
0
 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
0
파일: main.cpp 프로젝트: nimgould/mantid
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
0
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 ) );
    }
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
0
//--------------------------------------------------------------------------------------------
void MGyrohorizon::paintEvent(QPaintEvent * event)
{
//setStyleSheet(QLatin1String("background: transparent;"));

//  QPixmap pixmap(400,300);  pixmap.fill(Qt::white);
//  QPainter paint(&pixmap);
  QPainter painter(this);
  painter.setRenderHint(QPainter::Antialiasing, true);

qreal Width = 320.0;
qreal Height = 320.0;
qreal rRoll = 125.0;

qreal WidthHalf = Width/2.0;
qreal HeightHalf = Height/2.0;  qreal AngleHeightHalf = 40.0;   qreal AngleHeightHalfVisible = 25.0;
qreal HOneDegreeAngle = HeightHalf/AngleHeightHalf;

qreal MaxDim = qMax(Width,Height)*qSqrt(2.0);  qreal MaxDimHalf = MaxDim/2.0;

qreal HeightHalfVisible = HeightHalf/AngleHeightHalf*AngleHeightHalfVisible;

qreal h1 = HOneDegreeAngle*AngleHeightHalf;
qreal h2 = HOneDegreeAngle*(90.0-AngleHeightHalf);

  QLinearGradient linearGrad;
  QPointF mpointsF[5];
  qreal yh;


/*===========  First Variant  ===========

  qreal hPitchAngle = HeightHalf/AngleHeightHalf*PitchAngle;


//qreal cs = qCos(RollAngle/180.0*M_PI);   qreal acs = qAbs(cs);
//qreal hPitchAngleCos = hPitchAngle*cs;

//qreal HeightHemiSphere = Height/AngleHeight*90.0;


  painter.translate(WidthHalf,HeightHalf);

//painter.translate(0.0,-hPitchAngle);

  painter.rotate(-RollAngle);

//painter.translate(0.0,hPitchAngle);

//=====  Pitch:  =====


  painter.setPen(Qt::NoPen);

//  bool isUpDawn = false;

//-Sky:

// 0:
  yh = hPitchAngle;
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, QColor(80,180,255, 255));
  linearGrad.setColorAt(1, QColor(0,0,100, 255));
  QBrush brushSky1(linearGrad);   painter.setBrush(brushSky1);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);

  yh = hPitchAngle-h1;
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, QColor(0,0,100, 255));
  linearGrad.setColorAt(1, QColor(0,0,80, 255));
  QBrush brushSky2(linearGrad);   painter.setBrush(brushSky2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

//90
  yh = hPitchAngle-h1-h2;
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, QColor(0,0,80, 255));
  linearGrad.setColorAt(1, QColor(0,0,100, 255));
  QBrush brushSky3(linearGrad);   painter.setBrush(brushSky3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

  yh = hPitchAngle-h1-h2-h2;
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, QColor(0,0,100, 255));
  linearGrad.setColorAt(1, QColor(80,180,255, 255));
  QBrush brushSky4(linearGrad);   painter.setBrush(brushSky4);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);
//180

//-Ground:

// 0:
  yh = hPitchAngle;
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, QColor(90,170,110, 255));
  linearGrad.setColorAt(1, QColor(90,17,11, 255));
  QBrush brushGround1(linearGrad);   painter.setBrush(brushGround1);
  painter.drawRect(-MaxDimHalf,yh-0.5, MaxDim,h1+1.0);

  yh = hPitchAngle+h1;
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, QColor(90,17,11, 255));
  linearGrad.setColorAt(1, QColor(0,17,11, 255));
  QBrush brushGround2(linearGrad);   painter.setBrush(brushGround2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

//90:
  yh = hPitchAngle+h1+h2;
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, QColor(0,17,11, 255));
  linearGrad.setColorAt(1, QColor(90,17,11, 255));
  QBrush brushGround3(linearGrad);   painter.setBrush(brushGround3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

  yh = hPitchAngle+h1+h2+h2;
  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, QColor(90,17,11, 255));
  linearGrad.setColorAt(1, QColor(90,170,110, 255));
  QBrush brushGround4(linearGrad);   painter.setBrush(brushGround4);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h1);
//180


//  if(isUpDawn) { PSliderRoll->setValue(RollAngle+180); }


//painter.translate(0.0,-hPitchAngle);

//painter.rotate(RollAngle);

//painter.translate(0.0,hPitchAngle);


//= Pitch Scale:


  QPen pen(QColor(255,255,255, 255));
  pen.setWidthF(1.0);
//  pen.setCapStyle(Qt::RoundCap);
//  pen.setJoinStyle(Qt::SvgMiterJoin); //Qt::RoundJoin); //Qt::BevelJoin); //Qt::MiterJoin);
  painter.setPen(pen);

//  qreal x,y;
  QVector<QLineF> lines;

//- (2)-degrees:
  qreal y;  bool isHas = false;
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    for(int i = 1; i <= 4; i++) {
      y += -2.0*HOneDegreeAngle*k;
      if(qAbs(y) <= HeightHalfVisible) {  isHas = true;
        lines << QLineF(-8.0,y, 8.0,y);
      }
    }
  }
  if(isHas)  painter.drawLines(lines);
  lines.clear();

  pen.setWidthF(1.5);   painter.setPen(pen);

  qreal xoff, yoff;
  qreal angle;

//- 10-degrees:
  mpointsF[0].setX(-24.0);
  mpointsF[1].setX(-24.0);
  mpointsF[2].setX(24.0);
  mpointsF[3].setX(24.0);
  for(int k = -1; k <= 1; k += 2) {
    for(int i = 0; i <= 9; i++) {
      angle = 10.0*i;
      y = hPitchAngle - angle*HOneDegreeAngle*k;
      while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
      while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
      if(qAbs(y) <= HeightHalfVisible) {
        if(i == 0) {
          painter.drawLine(QLineF(-48.0,y, 48.0,y));
        }
        else if(i < 9) {
          mpointsF[0].setY(y + 5.0*k);
          mpointsF[1].setY(y);
          mpointsF[2].setY(y);
          mpointsF[3].setY(y + 5.0*k);
          painter.drawPolyline(mpointsF, 4); //int pointCount)
          DrawText(painter, -24.0-12.0+0.5, y+5.0/2.0*k, angle);
          DrawText(painter,  24.0+12.0+1.0, y+5.0/2.0*k, angle);
        }
        else {
          lines << QLineF(-36.0,y-7.0, -36.0,y+7.0);
          lines << QLineF(-36.0,y,      36.0,y);
          lines << QLineF( 36.0,y-7.0,  36.0,y+7.0);
          painter.drawLines(lines);  lines.clear();
          DrawText(painter, -36.0-12.0+1.0, y, angle);
          DrawText(painter,  36.0+12.0+1.0, y, angle);
        }
      }
    }

  }
//- (15)-degrees:
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle - 10.0*HOneDegreeAngle*(1.0+0.5)*k;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    if(qAbs(y) <= HeightHalfVisible)
      painter.drawLine(QLineF(-16.0,y, 16.0,y));
  }


//  QFont font(font());   // font.setStyleStrategy(QFont::NoAntialias);
//  painter.setFont(font);



//=====  Roll:  =====

//painter.rotate(-RollAngle);

  painter.setBrush(QBrush(QColor(255,255,255, 255)));

//- Triangle:
  painter.setPen(Qt::NoPen);
  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);

//- Arc:
  pen.setWidthF(1.5);   painter.setPen(pen);
  painter.drawArc(QRectF(-rRoll, -rRoll, 2.0*rRoll, 2.0*rRoll), 30*16, 120*16);


  qreal hs1 = 5.0;
  qreal hs2 = 12.0;  qreal ws2 = 5.0;
  qreal hs3 = 10.0;
  yoff = -rRoll - hs2 - 10.0; //  - 5.0
  angle = 0.0;

  qreal dopangle;  // QString text;

  for(int k = -1; k <= 1; k += 2) {
    xoff = ws2/2.0*k;
//- (5), (10):
    dopangle = 10.0*k;  painter.rotate(dopangle);
    for(int i = 1; i <= 2; i++) {
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs1));
      painter.rotate(dopangle);
    }

//- 30, (45), 60, (75):
    dopangle = 15.0*k;  angle = 15.0;
    for(int i = 1; i <= 2; i++) {
// 30, 60:
      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);
// (45), (75):
      painter.rotate(dopangle);
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs3));

      painter.rotate(dopangle);
      angle += dopangle*k;
    }

//- 90:
    xoff = 1.0;
    angle += dopangle*k;  //  text.sprintf(("%.0f"),angle);
    DrawText(painter, xoff, yoff, angle); //text);
//    painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0, -rRoll-hs2));
//    painter.drawLine(QPointF(-4.0, -rRoll-hs2), QPointF(4.0, -rRoll-hs2));
    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);
//  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);
*/

//=============================

PitchAngle = PitchAngle0;
  bool isUpDawn = false;
  while(PitchAngle < -90.0) { PitchAngle += 180.0;
//  while(PitchAngle < -90.0) { PitchAngle = -180.0 - PitchAngle;
//    PSliderPitch->setValue(PitchAngle);
    isUpDawn = !isUpDawn; //true;
//    IsUpDawn = isUpDawn;
  } //PitchAngle += 180.0; } // hPitchAngle += 2.0*(h1+h2); }
  while(PitchAngle > 90.0)  { PitchAngle -= 180.0;
//  while(PitchAngle > 90.0)  { PitchAngle = 180.0 - PitchAngle;
//    PSliderPitch->setValue(PitchAngle); // PSliderPitch->setTracking(true);
    isUpDawn = !isUpDawn; //true;
//    IsUpDawn = isUpDawn;
  } //PitchAngle -= 180.0; } // hPitchAngle -= 2.0*(h1+h2); }

RollAngle = RollAngle0;
  if(isUpDawn) {  RollAngle += 180.0;
//    PSliderRoll->setValue(RollAngle);
  }
  while(RollAngle < -180.0) {
    RollAngle += 360.0;
//    PSliderRoll->setValue(RollAngle);
  } //PitchAngle += 180.0; } // hPitchAngle += 2.0*(h1+h2); }
  while(RollAngle > 180.0)  { RollAngle -= 360.0;
//    PSliderRoll->setValue(RollAngle);
  } //PitchAngle -= 180.0; } // hPitchAngle -= 2.0*(h1+h2); }


  qreal hPitchAngle = HeightHalf/AngleHeightHalf*PitchAngle;
  if(isUpDawn) {
//    painter.translate(0.0,-2.0*hPitchAngle);
    hPitchAngle = -hPitchAngle;
  }


//qreal cs = qCos(RollAngle/180.0*M_PI);   qreal acs = qAbs(cs);
//qreal hPitchAngleCos = hPitchAngle*cs;

//qreal HeightHemiSphere = Height/AngleHeight*90.0;


  painter.translate(WidthHalf,HeightHalf);

//  painter.translate(0.0,hPitchAngle);


  painter.rotate(-RollAngle);

//painter.translate(0.0,hPitchAngle);

//=====  Pitch:  =====


  painter.setPen(Qt::NoPen);


//-Sky:

// 0:
  yh = hPitchAngle;
//  yh = 0.0;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h1)) { yh += 2.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h1)  { yh -= 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, ColorSky0);
  linearGrad.setColorAt(1, ColorSky1);
  QBrush brushSky1(linearGrad);   painter.setBrush(brushSky1);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);

  yh = hPitchAngle-h1;
//  yh = -h1;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h2)) { yh += 2.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h2)  { yh -= 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, ColorSky1);
  linearGrad.setColorAt(1, ColorSky2);
  QBrush brushSky2(linearGrad);   painter.setBrush(brushSky2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

//90
  yh = hPitchAngle-h1-h2;
//  yh = -h1-h2;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h2)) { yh += 2.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h2)  { yh -= 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, ColorSky2);
  linearGrad.setColorAt(1, ColorSky1);
  QBrush brushSky3(linearGrad);   painter.setBrush(brushSky3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

  yh = hPitchAngle-h1-h2-h2;
//  yh = -h1-h2-h2;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h1)) { yh += 2.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h1)  { yh -= 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, ColorSky1);
  linearGrad.setColorAt(1, ColorSky0);
  QBrush brushSky4(linearGrad);   painter.setBrush(brushSky4);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);
//180


//-Ground:

// 0:
  yh = hPitchAngle;
//  yh = 0.0;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h1)  { yh -= 2.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h1)) { yh += 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, ColorGround0);
  linearGrad.setColorAt(1, ColorGround1);
  QBrush brushGround1(linearGrad);   painter.setBrush(brushGround1);
  painter.drawRect(-MaxDimHalf,yh-0.5, MaxDim,h1+1.0);

  yh = hPitchAngle+h1;
//  yh = h1;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h2)  { yh -= 2.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h2)) { yh += 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, ColorGround1);
  linearGrad.setColorAt(1, ColorGround2);
  QBrush brushGround2(linearGrad);   painter.setBrush(brushGround2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

//90:
  yh = hPitchAngle+h1+h2;
//  yh = h1+h2;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h2)  { yh -= 2.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h2)) { yh += 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, ColorGround2);
  linearGrad.setColorAt(1, ColorGround1);
  QBrush brushGround3(linearGrad);   painter.setBrush(brushGround3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

  yh = hPitchAngle+h1+h2+h2;
//  yh = h1+h2+h2;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   2.0*(h1+h2)-qSqrt(2.0)*h1)  { yh -= 2.0*(h1+h2); }
//  while(yh <= -(2.0*(h1+h2)-qSqrt(2.0)*h1)) { yh += 2.0*(h1+h2); }
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, ColorGround1);
  linearGrad.setColorAt(1, ColorGround0);
  QBrush brushGround4(linearGrad);   painter.setBrush(brushGround4);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h1);
//180


//  painter.translate(0.0,hPitchAngle);
//
//  if(isUpDawn) {
//    painter.translate(0.0,2.0*hPitchAngle);
//    hPitchAngle = -hPitchAngle;
//  }


//  if(isUpDawn) { PSliderRoll->setValue(RollAngle+180); }


//painter.translate(0.0,-hPitchAngle);

//painter.rotate(RollAngle);

//painter.translate(0.0,hPitchAngle);


//== Pitch Scale:

  QPen pen(ColorPitch);  pen.setWidthF(1.0);
//  pen.setCapStyle(Qt::RoundCap);
//  pen.setJoinStyle(Qt::SvgMiterJoin); //Qt::RoundJoin); //Qt::BevelJoin); //Qt::MiterJoin);
  painter.setPen(pen);

//  qreal x,y;
  QVector<QLineF> lines;

//- (2)-degrees:
  qreal y;  bool isHas = false;
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    for(int i = 1; i <= 4; i++) {
      y += -2.0*HOneDegreeAngle*k;
      if(qAbs(y) <= HeightHalfVisible) {  isHas = true;
        lines << QLineF(-8.0,y, 8.0,y);
      }
    }
  }
  if(isHas)  painter.drawLines(lines);
  lines.clear();

  pen.setWidthF(1.5);   painter.setPen(pen);

  qreal xoff, yoff;
  qreal angle;

//- 10-degrees:
  mpointsF[0].setX(-24.0);
  mpointsF[1].setX(-24.0);
  mpointsF[2].setX(24.0);
  mpointsF[3].setX(24.0);
  for(int k = -1; k <= 1; k += 2) {
    for(int i = 0; i <= 9; i++) {
      angle = 10.0*i;
      y = hPitchAngle - angle*HOneDegreeAngle*k;
      while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
      while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
      if(qAbs(y) <= HeightHalfVisible) {
        if(i == 0) {
          painter.drawLine(QLineF(-48.0,y, 48.0,y));
        }
        else if(i < 9) {
          mpointsF[0].setY(y + 5.0*k);
          mpointsF[1].setY(y);
          mpointsF[2].setY(y);
          mpointsF[3].setY(y + 5.0*k);
          painter.drawPolyline(mpointsF, 4); //int pointCount)
          DrawText(painter, -24.0-12.0+0.5, y+5.0/2.0*k, angle);
          DrawText(painter,  24.0+12.0+1.0, y+5.0/2.0*k, angle);
        }
        else {
          lines << QLineF(-36.0,y-7.0, -36.0,y+7.0);
          lines << QLineF(-36.0,y,      36.0,y);
          lines << QLineF( 36.0,y-7.0,  36.0,y+7.0);
          painter.drawLines(lines);  lines.clear();
          DrawText(painter, -36.0-12.0+1.0, y, angle);
          DrawText(painter,  36.0+12.0+1.0, y, angle);
        }
      }
    }

  }
//- (15)-degrees:
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle - 10.0*HOneDegreeAngle*(1.0+0.5)*k;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    if(qAbs(y) <= HeightHalfVisible)
      painter.drawLine(QLineF(-16.0,y, 16.0,y));
  }


//  QFont font(font());   // font.setStyleStrategy(QFont::NoAntialias);
//  painter.setFont(font);



//=====  Roll:  =====

//painter.rotate(-RollAngle);

  painter.setBrush(QBrush(ColorRoll));

//- Triangle:
  painter.setPen(Qt::NoPen);
  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);

//- Arc:
  pen.setColor(ColorRoll);  pen.setWidthF(1.5);   painter.setPen(pen);
  painter.drawArc(QRectF(-rRoll, -rRoll, 2.0*rRoll, 2.0*rRoll), 30*16, 120*16);


  qreal hs1 = 5.0;
  qreal hs2 = 12.0;  qreal ws2 = 5.0;
  qreal hs3 = 10.0;
  yoff = -rRoll - hs2 - 10.0; //  - 5.0
  angle = 0.0;

  qreal dopangle;  // QString text;

  for(int k = -1; k <= 1; k += 2) {
    xoff = ws2/2.0*k;
//- (5), (10):
    dopangle = 10.0*k;  painter.rotate(dopangle);
    for(int i = 1; i <= 2; i++) {
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs1));
      painter.rotate(dopangle);
    }

//- 30, (45), 60, (75):
    dopangle = 15.0*k;  angle = 15.0;
    for(int i = 1; i <= 2; i++) {
// 30, 60:
      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);
// (45), (75):
      painter.rotate(dopangle);
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs3));

      painter.rotate(dopangle);
      angle += dopangle*k;
    }

//- 90:
    xoff = 1.0;
    angle += dopangle*k;  //  text.sprintf(("%.0f"),angle);
    DrawText(painter, xoff, yoff, angle); //text);
//    painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0, -rRoll-hs2));
//    painter.drawLine(QPointF(-4.0, -rRoll-hs2), QPointF(4.0, -rRoll-hs2));
    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);
//  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(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[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, 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);


//=============================


/*
qreal cs = qCos(RollAngle/180.0*M_PI);   qreal acs = qAbs(cs);
qreal hPitchAngleCos = hPitchAngle*cs;

//qreal HeightHemiSphere = Height/AngleHeight*90.0;


  painter.translate(WidthHalf,HeightHalf);

while(hPitchAngle <= -(2.0*(h1+h2)-h2)) { hPitchAngle += 4.0*(h1+h2); }
while(hPitchAngle >=  (2.0*(h1+h2)-h2)) { hPitchAngle -= 4.0*(h1+h2); }

//if(hPitchAngle <= -(2.0*(h1+h2))) { hPitchAngle += 2.0*(h1+h2); }
//if(hPitchAngle >=  (2.0*(h1+h2))) { hPitchAngle -= 2.0*(h1+h2); }


painter.translate(0.0,hPitchAngle);

//while(hPitchAngle <= -(4.0*(h1+h2))) { hPitchAngle += 4.0*(h1+h2); }
//while(hPitchAngle >=  (4.0*(h1+h2))) { hPitchAngle -= 4.0*(h1+h2); }


  painter.rotate(-RollAngle);

//painter.translate(0.0,hPitchAngle);

//=====  Pitch:  =====


  painter.setPen(Qt::NoPen);

//-Sky:

// 0:
//  yh = hPitchAngle;
//yh = hPitchAngleCos; //*cs;
yh = 0.0;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h1))  { yh -= 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, QColor(80,180,255, 255));
  linearGrad.setColorAt(1, QColor(0,0,100, 255));
  QBrush brushSky1(linearGrad);   painter.setBrush(brushSky1);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);

//  yh = hPitchAngle-h1;
//yh = hPitchAngleCos-h1; //)*cs;
yh = -h1; //)*cs;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h2))  { yh -= 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, QColor(0,0,100, 255));
  linearGrad.setColorAt(1, QColor(0,0,80, 255));
  QBrush brushSky2(linearGrad);   painter.setBrush(brushSky2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

//90
//  yh = hPitchAngle-h1-h2;
//yh = hPitchAngleCos-h1-h2; //)*cs;
yh = -h1-h2; //)*cs;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h2))  { yh -= 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h2);
  linearGrad.setColorAt(0, QColor(0,0,80, 255));
  linearGrad.setColorAt(1, QColor(0,0,100, 255));
  QBrush brushSky3(linearGrad);   painter.setBrush(brushSky3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,-h2-1.0);

//  yh = hPitchAngle-h1-h2-h2;
//yh = hPitchAngleCos-h1-h2-h2; //)*cs;
yh = -h1-h2-h2; //)*cs;
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h1))  { yh -= 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-h1);
  linearGrad.setColorAt(0, QColor(0,0,100, 255));
  linearGrad.setColorAt(1, QColor(80,180,255, 255));
  QBrush brushSky4(linearGrad);   painter.setBrush(brushSky4);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-h1-1.0);
//180

//-Ground:

// 0:
//  yh = hPitchAngle;
//yh = hPitchAngleCos; //*cs;
yh = 0.0;//hPitchAngleCos; //*cs;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h1))  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, QColor(90,170,110, 255));
  linearGrad.setColorAt(1, QColor(90,17,11, 255));
  QBrush brushGround1(linearGrad);   painter.setBrush(brushGround1);
  painter.drawRect(-MaxDimHalf,yh-0.5, MaxDim,h1+1.0);

//  yh = hPitchAngle+h1;
//yh = hPitchAngleCos+h1; //)*cs;
yh = h1; //)*cs;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h2))  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, QColor(90,17,11, 255));
  linearGrad.setColorAt(1, QColor(0,17,11, 255));
  QBrush brushGround2(linearGrad);   painter.setBrush(brushGround2);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

//90:
//  yh = hPitchAngle+h1+h2;
//yh = hPitchAngleCos+h1+h2; //)*cs;
yh = h1+h2; //)*cs;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h2))  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h2)) { yh += 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h2);
  linearGrad.setColorAt(0, QColor(0,17,11, 255));
  linearGrad.setColorAt(1, QColor(90,17,11, 255));
  QBrush brushGround3(linearGrad);   painter.setBrush(brushGround3);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h2+1.0);

//  yh = hPitchAngle+h1+h2+h2;
//yh = hPitchAngleCos+h1+h2+h2; //)*cs;
yh = h1+h2+h2; //)*cs;
//  while(yh >=   4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)  { yh -= 4.0*(h1+h2); }
//  while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//while(yh >=  (4.0*(h1+h2)-2.0*qSqrt(2.0)*h1))  { yh -= 4.0*(h1+h2); }
//while(yh <= -(4.0*(h1+h2)-2.0*qSqrt(2.0)*h1)) { yh += 4.0*(h1+h2); }
//yh += -hPitchAngle + hPitchAngleCos; //*cs;
//yh *= cs;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+h1);
  linearGrad.setColorAt(0, QColor(90,17,11, 255));
  linearGrad.setColorAt(1, QColor(90,170,110, 255));
  QBrush brushGround4(linearGrad);   painter.setBrush(brushGround4);
  painter.drawRect(-MaxDimHalf,yh, MaxDim,h1);
//180



//painter.translate(0.0,-hPitchAngle);

painter.rotate(RollAngle);

painter.translate(0.0,-hPitchAngle);


//= Pitch Scale:


  QPen pen(QColor(255,255,255, 255));
  pen.setWidthF(1.0);
//  pen.setCapStyle(Qt::RoundCap);
//  pen.setJoinStyle(Qt::SvgMiterJoin); //Qt::RoundJoin); //Qt::BevelJoin); //Qt::MiterJoin);
  painter.setPen(pen);

//  qreal x,y;
  QVector<QLineF> lines;

//- (2)-degrees:
  qreal y;  bool isHas = false;
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    for(int i = 1; i <= 4; i++) {
      y += -2.0*HOneDegreeAngle*k;
      if(qAbs(y) <= HeightHalfVisible) {  isHas = true;
        lines << QLineF(-8.0,y, 8.0,y);
      }
    }
  }
  if(isHas)  painter.drawLines(lines);
  lines.clear();

  pen.setWidthF(1.5);   painter.setPen(pen);

  qreal xoff, yoff;
  qreal angle;

//- 10-degrees:
  mpointsF[0].setX(-24.0);
  mpointsF[1].setX(-24.0);
  mpointsF[2].setX(24.0);
  mpointsF[3].setX(24.0);
  for(int k = -1; k <= 1; k += 2) {
    for(int i = 0; i <= 9; i++) {
      angle = 10.0*i;
      y = hPitchAngle - angle*HOneDegreeAngle*k;
      while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
      while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
      if(qAbs(y) <= HeightHalfVisible) {
        if(i == 0) {
          painter.drawLine(QLineF(-48.0,y, 48.0,y));
        }
        else if(i < 9) {
          mpointsF[0].setY(y + 5.0*k);
          mpointsF[1].setY(y);
          mpointsF[2].setY(y);
          mpointsF[3].setY(y + 5.0*k);
          painter.drawPolyline(mpointsF, 4); //int pointCount)
          DrawText(painter, -24.0-12.0+0.5, y+5.0/2.0*k, angle);
          DrawText(painter,  24.0+12.0+1.0, y+5.0/2.0*k, angle);
        }
        else {
          lines << QLineF(-36.0,y-7.0, -36.0,y+7.0);
          lines << QLineF(-36.0,y,      36.0,y);
          lines << QLineF( 36.0,y-7.0,  36.0,y+7.0);
          painter.drawLines(lines);  lines.clear();
          DrawText(painter, -36.0-12.0+1.0, y, angle);
          DrawText(painter,  36.0+12.0+1.0, y, angle);
        }
      }
    }

  }
//- (15)-degrees:
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle - 10.0*HOneDegreeAngle*(1.0+0.5)*k;
    while(y >=   2.0*(h1+h2)-2.0*HeightHalfVisible)  { y -= 2.0*(h1+h2); }
    while(y <= -(2.0*(h1+h2)-2.0*HeightHalfVisible)) { y += 2.0*(h1+h2); }
    if(qAbs(y) <= HeightHalfVisible)
      painter.drawLine(QLineF(-16.0,y, 16.0,y));
  }


//  QFont font(font());   // font.setStyleStrategy(QFont::NoAntialias);
//  painter.setFont(font);



//=====  Roll:  =====

painter.rotate(-RollAngle);

  painter.setBrush(QBrush(QColor(255,255,255, 255)));

//- Triangle:
  painter.setPen(Qt::NoPen);
  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);

//- Arc:
  pen.setWidthF(1.5);   painter.setPen(pen);
  painter.drawArc(QRectF(-rRoll, -rRoll, 2.0*rRoll, 2.0*rRoll), 30*16, 120*16);


  qreal hs1 = 5.0;
  qreal hs2 = 12.0;  qreal ws2 = 5.0;
  qreal hs3 = 10.0;
  yoff = -rRoll - hs2 - 10.0; //  - 5.0
  angle = 0.0;

  qreal dopangle;  // QString text;

  for(int k = -1; k <= 1; k += 2) {
    xoff = ws2/2.0*k;
//- (5), (10):
    dopangle = 10.0*k;  painter.rotate(dopangle);
    for(int i = 1; i <= 2; i++) {
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs1));
      painter.rotate(dopangle);
    }

//- 30, (45), 60, (75):
    dopangle = 15.0*k;  angle = 15.0;
    for(int i = 1; i <= 2; i++) {
// 30, 60:
      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);
// (45), (75):
      painter.rotate(dopangle);
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs3));

      painter.rotate(dopangle);
      angle += dopangle*k;
    }

//- 90:
    xoff = 1.0;
    angle += dopangle*k;  //  text.sprintf(("%.0f"),angle);
    DrawText(painter, xoff, yoff, angle); //text);
//    painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0, -rRoll-hs2));
//    painter.drawLine(QPointF(-4.0, -rRoll-hs2), QPointF(4.0, -rRoll-hs2));
    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);
//  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
0
//--------------------------------------------------------------------------------------------
void MGyrohorizon::paintEvent(QPaintEvent * event)
{
//--
  QImage imgagePaint(size(), QImage::Format_ARGB32_Premultiplied);
  QPainter painter;
  painter.begin(&imgagePaint);
//--

  painter.setRenderHint(QPainter::Antialiasing, true);

  QLinearGradient linearGrad;
  QPointF mpointsF[5];
  qreal yh;

//=============================

  bool isUpDawn = false;
  while(PitchAngle < -90.0)
  {
    PitchAngle += 180.0;
    isUpDawn = !isUpDawn; //true;
  }
  while(PitchAngle > 90.0)
  {
    PitchAngle -= 180.0;
    isUpDawn = !isUpDawn; //true;
  }


  if(isUpDawn)
  {
      RollAngle += 180.0;

  }
  while(RollAngle < -180.0)
  {
    RollAngle += 360.0;
  }
  while(RollAngle > 180.0)
  {
     RollAngle -= 360.0;
  }


  qreal hPitchAngle = HeightHalf/AngleHeightHalf*PitchAngle;//здвиг по пикселям в соответсвии с градусами
  if(isUpDawn) {
    hPitchAngle = -hPitchAngle;
  }


  painter.translate(WidthHalf,HeightHalf);//переместили цент с 0,0 на центр
  painter.rotate(-RollAngle);

//=====  Pitch:  =====
  painter.setPen(Qt::NoPen);


//-Sky:

// 0:
  yh = hPitchAngle;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-H1);
  linearGrad.setColorAt(0, ColorSky0);
  linearGrad.setColorAt(1, ColorSky1);
  QBrush brushSky1(linearGrad);   painter.setBrush(brushSky1);
  painter.drawRect(-MaxDimHalf,yh+0.5, MaxDim,-H1-2.0);//первый верхний четерехугольник

  yh -= H1;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-H2);
  linearGrad.setColorAt(0, ColorSky1);
  linearGrad.setColorAt(1, ColorSky2);
  QBrush brushSky2(linearGrad);   painter.setBrush(brushSky2);
  painter.drawRect(QRectF(-MaxDimHalf,yh, MaxDim,-H2-2.0));

//90
  yh -= H2;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-H2);
  linearGrad.setColorAt(0, ColorSky2);
  linearGrad.setColorAt(1, ColorSky1);
  QBrush brushSky3(linearGrad);   painter.setBrush(brushSky3);
  painter.drawRect(QRectF(-MaxDimHalf,yh, MaxDim,-H2-2.0));

  yh -= H2;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh-H1);
  linearGrad.setColorAt(0, ColorSky1);
  linearGrad.setColorAt(1, ColorSky0);
  QBrush brushSky4(linearGrad);   painter.setBrush(brushSky4);
  painter.drawRect(QRectF(-MaxDimHalf,yh+0.5, MaxDim,-H1-2.0));

//180

//-Ground:

// 0:
  yh = hPitchAngle;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+H1);
  linearGrad.setColorAt(0, ColorGround0);
  linearGrad.setColorAt(1, ColorGround1);
  QBrush brushGround1(linearGrad);   painter.setBrush(brushGround1);
  painter.drawRect(QRectF(-MaxDimHalf,yh-0.5, MaxDim,H1+2.0));

  yh += H1;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+H2);
  linearGrad.setColorAt(0, ColorGround1);
  linearGrad.setColorAt(1, ColorGround2);
  QBrush brushGround2(linearGrad);   painter.setBrush(brushGround2);
  painter.drawRect(QRectF(-MaxDimHalf,yh, MaxDim,H2+2.0));

//90:
  yh += H2;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+H2);
  linearGrad.setColorAt(0, ColorGround2);
  linearGrad.setColorAt(1, ColorGround1);
  QBrush brushGround3(linearGrad);   painter.setBrush(brushGround3);
  painter.drawRect(QRectF(-MaxDimHalf,yh, MaxDim,H2+2.0));

  yh += H2;
  linearGrad.setStart(0.0,     yh);
  linearGrad.setFinalStop(0.0, yh+H1);
  linearGrad.setColorAt(0, ColorGround1);
  linearGrad.setColorAt(1, ColorGround0);
  QBrush brushGround4(linearGrad);   painter.setBrush(brushGround4);
  painter.drawRect(QRectF(-MaxDimHalf,yh, MaxDim,H1+2));
//180

//== Pitch Scale:

  QPen pen(ColorPitch);  pen.setWidthF(1.0);
  painter.setPen(pen);

  QVector<QLineF> lines;

//- (2)-degrees:
  qreal y;  bool isHas = false;
  for(int k = -1; k <= 1; k += 2)
  {
    y = hPitchAngle;
    while(y >=   2.0*(H1+H2)-2.0*HeightHalfVisible)  { y -= 2.0*(H1+H2); }
    while(y <= -(2.0*(H1+H2)-2.0*HeightHalfVisible)) { y += 2.0*(H1+H2); }
    for(int i = 1; i <= 4; i++)
    {
      y += -2.0*HOneDegreeAngle*k;
      if(qAbs(y) <= HeightHalfVisible)
      {
        isHas = true;
        lines << QLineF(-8.0,y, 8.0,y);
      }
    }
  }
  if(isHas)  painter.drawLines(lines);
  lines.clear();

  pen.setWidthF(1.5);   painter.setPen(pen);

  qreal xoff, yoff;
  qreal angle;

//- 10-degrees:
  mpointsF[0].setX(-24.0);
  mpointsF[1].setX(-24.0);
  mpointsF[2].setX(24.0);
  mpointsF[3].setX(24.0);
  for(int k = -1; k <= 1; k += 2)
  {
    for(int i = 0; i <= 9; i++)
    {
      angle = 10.0*i;
      y = hPitchAngle - angle*HOneDegreeAngle*k;
      while(y >=   2.0*(H1+H2)-2.0*HeightHalfVisible)  { y -= 2.0*(H1+H2); }
      while(y <= -(2.0*(H1+H2)-2.0*HeightHalfVisible)) { y += 2.0*(H1+H2); }
      if(qAbs(y) <= HeightHalfVisible)
      {
        if(i == 0)
        {
          painter.drawLine(QLineF(-48.0,y, 48.0,y));
        }
        else if(i < 9)
        {
          mpointsF[0].setY(y + 5.0*k);
          mpointsF[1].setY(y);
          mpointsF[2].setY(y);
          mpointsF[3].setY(y + 5.0*k);
          painter.drawPolyline(mpointsF, 4); //int pointCount)
          DrawText(painter, -24.0-12.0+0.5, y+5.0/2.0*k, angle);
          DrawText(painter,  24.0+12.0+1.0, y+5.0/2.0*k, angle);
        }
        else
        {
          lines << QLineF(-36.0,y-7.0, -36.0,y+7.0);
          lines << QLineF(-36.0,y,      36.0,y);
          lines << QLineF( 36.0,y-7.0,  36.0,y+7.0);
          painter.drawLines(lines);  lines.clear();
          DrawText(painter, -36.0-12.0+1.0, y, angle);
          DrawText(painter,  36.0+12.0+1.0, y, angle);
        }
      }
    }

  }
//- (15)-degrees:
  for(int k = -1; k <= 1; k += 2) {
    y = hPitchAngle - 10.0*HOneDegreeAngle*(1.0+0.5)*k;
    while(y >=   2.0*(H1+H2)-2.0*HeightHalfVisible)  { y -= 2.0*(H1+H2); }
    while(y <= -(2.0*(H1+H2)-2.0*HeightHalfVisible)) { y += 2.0*(H1+H2); }
    if(qAbs(y) <= HeightHalfVisible)
      painter.drawLine(QLineF(-16.0,y, 16.0,y));
  }

//=====  Roll:  =====
  painter.setBrush(QBrush(ColorRoll));

//- Triangle:
  painter.setPen(Qt::NoPen);
  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);

//- Arc:
  pen.setColor(ColorRoll);  pen.setWidthF(1.5);   painter.setPen(pen);
  painter.drawArc(QRectF(-rRoll, -rRoll, 2.0*rRoll, 2.0*rRoll), 30*16, 120*16);

//для крючочков
  qreal hs1 = 5.0;
  qreal hs2 = 12.0;  qreal ws2 = 5.0;
  qreal hs3 = 10.0;
  yoff = -rRoll - hs2 - 10.0; //  - 5.0
  angle = 0.0;

  qreal dopangle;  // QString text;

  for(int k = -1; k <= 1; k += 2)
  {
    xoff = ws2/2.0*k;
//- (5), (10):
    dopangle = 10.0*k;  painter.rotate(dopangle);
    for(int i = 1; i <= 2; i++)
    {
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs1));
      painter.rotate(dopangle);
    }

//- 30, (45), 60, (75):
    dopangle = 15.0*k;  angle = 15.0;
    for(int i = 1; i <= 2; i++)
    {
// 30, 60:
      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);
// (45), (75):
      painter.rotate(dopangle);
      painter.drawLine(QPointF(0.0,-rRoll), QPointF(0.0,-rRoll-hs3));

      painter.rotate(dopangle);
      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
0
void LayerWidget::setMask(const QImage &mask)
{
    QPixmap masked = QPixmap::fromImage(mask);
    masked.setMask(masked.createMaskFromColor(QColor(Qt::white)));
    _maskItem->setPixmap(masked);
}
예제 #16
0
void TransferTabController::replayFrame()
{
    static unsigned int i;
    double euler_x, euler_y, euler_z;
    Mat_<double> rmatrix;
    Mat_<double> rot;
    Mat_<double> tran;
    vector<Point2f> points;

    Point2 *textureData;
    vector<Point2f> imagePoints;
    vector<Point3f> objectPoints;
    int img_width;
    int img_height;

    src_videoProcessor->getFaceForFrame(i,src_face_ptr);
    target_videoProcessor->getFaceAndPoseForFrame(i,target_face_ptr,rot,tran);

    double tx = tran(0,0);
    double ty = tran(0,1);
    double tz = tran(0,2);
    //compute and set the pose parameters
    Rodrigues(rot,rmatrix);
    Utility::computeEulerAnglesFromRmatrix(rmatrix,euler_x,euler_y,euler_z);
    //only y needs to be negative so that it agrees with the transposes   

    if(projModel)
    {
        vector<Point2f> points;
        src_videoProcessor->getGeneratedPointsForFrame(i,points);
        sourceLabel->setMarked(points);
    }

    if(textured3D && i == 10)
    {
        //transfer texture
        for(int j=0;j<target_face_ptr->getPointNum();j++)
            objectPoints.push_back(target_face_ptr->vertexes[j]);

        cv::projectPoints(Mat(objectPoints),rot,tran,cameraSrc,lensDist,imagePoints);
        textureData = new Point2[imagePoints.size()];
        //    img_width = srcFrames[i].size().width;
        //    img_height = srcFrames[i].size().height;
        img_width = Utility::closestLargetPowerOf2(t_frameData[i].size().width);
        img_height = Utility::closestLargetPowerOf2(t_frameData[i].size().height);

        for(unsigned int j=0;j<imagePoints.size();j++)
        {
            textureData[j].x = imagePoints[j].x / img_width;
            //our texture coordinate sysem is 0,0 top left corner ..
            //bingTexture doesnt do this
            textureData[j].y = imagePoints[j].y / img_height;
        }


        cout << "in text " << i << " " << textured3D << endl;
        convertFrameIntoTexture(t_frameData[i]);
        face_widget->setFace(target_face_ptr,textureData);

        delete[] textureData;
    }
    else if(!textured3D)
    {
        face_widget->disableTexture();
    }

    //create the 4x4 proj matrix for the face widget
    Mat_<double> projM = Mat_<double>::zeros(Size(4,4));
    for(int j=0;j<3;j++)
        for(int k=0;k<3;k++)
            projM(j,k) = cameraSrc.at<double>(j,k);
    face_widget->setProjectionMatrix(projM);

    //creat the 4x4 (homogen) trans matrix for face widget
    Mat_<double> tranM = Mat_<double>::zeros(Size(4,4));
    for(int j=0;j<3;j++)
        for(int k=0;k<3;k++)
            tranM(j,k) = rmatrix(j,k);
    tranM(0,3) = tx;
    tranM(1,3) = ty;
    tranM(2,3) = tz;
    tranM(3,3) = 1.0;
//
//    //face_widget->setTransformationMatrix(tranM);   

    //set the parameters in face widget
    face_widget->setTransParams(euler_x,-euler_y,euler_z,tx,ty,tz);
    target_face_ptr->transferExpressionFromFace(src_face_ptr);
    //face_widget->bindTexture(Utility::mat2QImage(frameData[i]));
    srcFrames.push_back(t_frameData[i]);

    sourceLabel->clearMarked();
    targetLabel->clearMarked();

    if(!show3D)
    {
         face_widget->setFace(target_face_ptr);
    }    

    if(textureInterpolate && !show3D)
    {
        QImage qimg = face_widget->grabFrameBuffer(false);
        QPixmap pimg = QPixmap::fromImage(qimg);
        pimg.setMask(pimg.createMaskFromColor(Qt::white,Qt::MaskInColor));
        QPixmap result = Utility::composePixmaps(Utility::mat2QPixmap(t_frameData[i]),pimg);
        targetLabel->setPixmap(result);
    }
    else if(!textureInterpolate && !show3D)
    {
        getClonedMouth(s_frameData[i],i,t_frameData[i]);        
        targetLabel->setPixmap(Utility::mat2QPixmap(t_frameData[i]));
    }

    sourceLabel->setPixmap(Utility::mat2QPixmap(s_frameData[i]));
    i++;
    view->incrementTransferProgress();

    if(i == src_videoProcessor->getFrameNum())
    {
        timerReplay->stop();
        i = 0;
        s_frameData.clear();
        t_frameData.clear();
        featurePoints.clear();

        view->setAllTransferTabButtonsDisabled(false);

        delete src_videoProcessor;
        delete target_videoProcessor;
    }

}