InstallScreen::InstallScreen() { m_mainLayout = new QVBoxLayout; m_mainLayout->setSpacing( 0 ); m_currentPackage = 0; // log file m_logFile.setFileName( "/tmp/oci_log.txt" ); if( !m_logFile.open( QIODevice::Truncate | QIODevice::WriteOnly ) ) { qDebug() << "Could not open Data File"; } m_outData = new QTextStream( &m_logFile ); // status widget and its layout m_statusWidget = new QTextBrowser; m_statusWidget->setObjectName( "statusWidget" ); m_statusWidget->setStyleSheet( "QTextBrowser#statusWidget{ background-color : white; border-bottom: 1px solid rgb(196, 181, 147); border-left : 1px solid rgb(196,181,147); border-top : 1px solid rgb(196,181,147); border-right : 1px solid rgb(196,181,147); }" ); m_statusWidget->setMinimumSize( 500, 180 ); // Cancel button m_cancelButton = new QPushButton( i18n( "Cancel" ) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacing( 400 ); buttonLayout->addWidget( m_cancelButton ); // Current message label, Progress Bar m_currentPackageStatusLabel = new QLabel( i18n( "Please Wait..." ) ); m_progressBar = new QProgressBar; m_progressBar->setMinimum( 0 ); m_progressBar->setMaximum( 100 ); m_progressBar->setRange( 0, 100 ); m_progressBar->setTextVisible( true ); // total progress message label, Total Progress Bar m_totProgBarStatusLabel = new QLabel( i18n( "Total Progress:" ) ); m_totalProgressBar = new QProgressBar; m_totalProgressBar->setMinimum( 0 ); m_totalProgressBar->setRange( 0, 100 ); m_totalProgressBar->setTextVisible( true ); // All set! Now add widgets to the m_mainLayout m_mainLayout->addWidget( m_statusWidget ); m_mainLayout->addWidget( horizontalLine() ); m_mainLayout->addWidget( m_currentPackageStatusLabel ); m_mainLayout->addWidget( m_progressBar ); m_mainLayout->addWidget( m_totProgBarStatusLabel ); m_mainLayout->addWidget( m_totalProgressBar ); m_mainLayout->addWidget( horizontalLine() ); m_mainLayout->addLayout( buttonLayout ); // Signals and slots QObject::connect( m_cancelButton, SIGNAL( clicked() ), this, SLOT( cancelInstallation() ) ); setLayout( m_mainLayout ); }
//Prints the contents of the board onto the display void printChessBoard(char grid[8][8][33], char pieceTranslator[33]) { int x, y; //Clear screen for better formating // system("cls"); //Creats the alphabetical coordinates printf("\n A B C D E F G H"); //Makes the top of the window space putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\n'); //New line after each segment //Prints out the new table after shifting for(y = 0; y < 8; y++) { printf("%d |",8 - y);//Creates the numerical coordinates //Lays down the grid, complete with pieces for(x = 0; x < 8; x++) if(grid[x][y][0] == 0) if(((x + y) % 2) == 0) printf(":|");//Blank Black square else printf(" |");//Blank white square else printf("%c|", pieceTranslator[(int)grid[x][y][0]]); printf(" %d",8 - y);//Creates the numerical coordinates putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\n'); //New line after each segment } printf(" A B C D E F G H");//Creats the alphabetical coordinates //For formating putchar('\n'); putchar('\n'); return; }
void legalDisplay(char grid[8][8][33], int piece) { int x, y; //Creats the alphabetical coordinates printf("\n A B C D E F G H"); //Makes the top of the window space putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\n'); //New line after each segment //Prints out the new table after shifting for(y = 0; y < 8; y++) { printf("%d |",8 - y);//Creates the numerical coordinates //Lays down the grid, complete with pieces for(x = 0; x < 8; x++) if(grid[x][y][piece] == 'L') printf("%c|", grid[x][y][piece]); else if(((x + y) % 2) == 0) printf(":|");//Blank Black square else printf(" |");//Blank white square printf(" %d",8 - y);//Creates the numerical coordinates putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\n'); //New line after each segment } //Creats the alphabetical coordinates printf(" A B C D E F G H"); //For formating putchar('\n'); putchar('\n'); return; }
void Location::CutsceneView::CameraManipulatable::UpdateCore() { if (pOutsideCameraPathItem != NULL) { QRectF gameWindowPosition = windowRect.ToQRectF(); QPainterPath outsidePath; outsidePath.addRect( 0, 0, backgroundSize.GetX(), gameWindowPosition.top()); outsidePath.addRect( 0, gameWindowPosition.top(), gameWindowPosition.left(), gameWindowPosition.height()); outsidePath.addRect( gameWindowPosition.right(), gameWindowPosition.top(), backgroundSize.GetX() - gameWindowPosition.right(), gameWindowPosition.height()); outsidePath.addRect( 0, gameWindowPosition.bottom(), backgroundSize.GetX(), backgroundSize.GetY() - gameWindowPosition.bottom()); pOutsideCameraPathItem->setPath(outsidePath); pOutsideCameraPathItem->setZValue(99 * 1000000); QLine horizontalLine( gameWindowPosition.center().x() - 10, gameWindowPosition.center().y(), gameWindowPosition.center().x() + 10, gameWindowPosition.center().y()); QLine verticalLine( gameWindowPosition.center().x(), gameWindowPosition.center().y() - 10, gameWindowPosition.center().x(), gameWindowPosition.center().y() + 10); pCameraCenterHorizontalOuterLineItem->setLine(horizontalLine); pCameraCenterVerticalOuterLineItem->setLine(verticalLine); pCameraCenterHorizontalInnerLineItem->setLine(horizontalLine); pCameraCenterVerticalInnerLineItem->setLine(verticalLine); pCameraCenterHorizontalOuterLineItem->setZValue(1); pCameraCenterVerticalOuterLineItem->setZValue(1); pCameraCenterHorizontalInnerLineItem->setZValue(2); pCameraCenterVerticalInnerLineItem->setZValue(2); pCameraCenterGraphicsItemGroup->setZValue(99 * 1000000); pCameraCenterOpacityEffect->setOpacity(IsEnabled() ? 1.0 : 0.0); } }
void QgsTextDiagram::renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, QPointF position ) { QPainter* p = c.painter(); if ( !p ) { return; } //convert from mm / map units to painter units QSizeF spu = sizePainterUnits( s.size, s, c ); double w = spu.width(); double h = spu.height(); double baseX = position.x(); double baseY = position.y() - h; QVector<QPointF> textPositions; //midpoints for text placement int nCategories = s.categoryAttributes.size(); for ( int i = 0; i < nCategories; ++i ) { if ( mOrientation == Horizontal ) { textPositions.push_back( QPointF( baseX + ( w / nCategories ) * i + w / nCategories / 2.0, baseY + h / 2.0 ) ); } else //vertical { textPositions.push_back( QPointF( baseX + w / 2.0, baseY + h / nCategories * i + w / nCategories / 2.0 ) ); } } mPen.setColor( s.penColor ); setPenWidth( mPen, s, c ); p->setPen( mPen ); mBrush.setColor( s.backgroundColor ); p->setBrush( mBrush ); //draw shapes and separator lines first if ( mShape == Circle ) { p->drawEllipse( baseX, baseY, w, h ); //draw separator lines QList<QPointF> intersect; //intersections between shape and separation lines QPointF center( baseX + w / 2.0, baseY + h / 2.0 ); double r1 = w / 2.0; double r2 = h / 2.0; for ( int i = 1; i < nCategories; ++i ) { if ( mOrientation == Horizontal ) { lineEllipseIntersection( QPointF( baseX + w / nCategories * i, baseY ), QPointF( baseX + w / nCategories * i, baseY + h ), center, r1, r2, intersect ); } else //vertical { lineEllipseIntersection( QPointF( baseX, baseY + h / nCategories * i ), QPointF( baseX + w, baseY + h / nCategories * i ), center, r1, r2, intersect ); } if ( intersect.size() > 1 ) { p->drawLine( intersect.at( 0 ), intersect.at( 1 ) ); } } } else if ( mShape == Rectangle ) { p->drawRect( QRectF( baseX, baseY, w, h ) ); for ( int i = 1; i < nCategories; ++i ) { if ( mOrientation == Horizontal ) { p->drawLine( QPointF( baseX + w / nCategories * i, baseY ), QPointF( baseX + w / nCategories * i, baseY + h ) ); } else { p->drawLine( QPointF( baseX, baseY + h / nCategories * i ), QPointF( baseX + w, baseY + h / nCategories * i ) ); } } } else //triangle { QPolygonF triangle; triangle << QPointF( baseX, baseY + h ) << QPointF( baseX + w, baseY + h ) << QPointF( baseX + w / 2.0, baseY ); p->drawPolygon( triangle ); QLineF triangleEdgeLeft( baseX + w / 2.0, baseY, baseX, baseY + h ); QLineF triangleEdgeRight( baseX + w, baseY + h, baseX + w / 2.0, baseY ); QPointF intersectionPoint1, intersectionPoint2; for ( int i = 1; i < nCategories; ++i ) { if ( mOrientation == Horizontal ) { QLineF verticalLine( baseX + w / nCategories * i, baseY + h, baseX + w / nCategories * i, baseY ); if ( baseX + w / nCategories * i < baseX + w / 2.0 ) { verticalLine.intersect( triangleEdgeLeft, &intersectionPoint1 ); } else { verticalLine.intersect( triangleEdgeRight, &intersectionPoint1 ); } p->drawLine( QPointF( baseX + w / nCategories * i, baseY + h ), intersectionPoint1 ); } else //vertical { QLineF horizontalLine( baseX, baseY + h / nCategories * i, baseX + w, baseY + h / nCategories * i ); horizontalLine.intersect( triangleEdgeLeft, &intersectionPoint1 ); horizontalLine.intersect( triangleEdgeRight, &intersectionPoint2 ); p->drawLine( intersectionPoint1, intersectionPoint2 ); } } } //draw text QFont sFont = scaledFont( s, c ); QFontMetricsF fontMetrics( sFont ); p->setFont( sFont ); QgsExpressionContext expressionContext = c.expressionContext(); expressionContext.setFeature( feature ); if ( feature.fields() ) expressionContext.setFields( *feature.fields() ); for ( int i = 0; i < textPositions.size(); ++i ) { QgsExpression* expression = getExpression( s.categoryAttributes.at( i ), expressionContext ); QString val = expression->evaluate( &expressionContext ).toString(); //find out dimesions double textWidth = fontMetrics.width( val ); double textHeight = fontMetrics.height(); mPen.setColor( s.categoryColors.at( i ) ); p->setPen( mPen ); QPointF position = textPositions.at( i ); // Calculate vertical placement double xOffset = 0; switch ( s.labelPlacementMethod ) { case QgsDiagramSettings::Height: xOffset = textHeight / 2.0; break; case QgsDiagramSettings::XHeight: xOffset = fontMetrics.xHeight(); break; } p->drawText( QPointF( position.x() - textWidth / 2.0, position.y() + xOffset ), val ); } }
void draw() { // update the mouse position and add it to the broadphase auto mousePosition = static_cast<sf::Vector2f>(sf::Mouse::getPosition(window)); const auto mouseSize = mouseObject.getSize(); mouseObject.setPosition(mousePosition); mousePosition -= mouseObject.getOrigin(); broadphase.addRectangle( mousePosition.x, mousePosition.y, mouseSize.x, mouseSize.y, &mouseObject); // move the rectangles around and add them to the broadphase for (const auto& object : objects) { object->setPosition(randb(0, window.getSize().x), randb(0, window.getSize().y)); const auto objectPosition = object->getPosition() - object->getOrigin(); const auto objectSize = object->getSize(); broadphase.addRectangle( objectPosition.x, objectPosition.y, objectSize.x, objectSize.y, object); object->setFillColor(sf::Color(0x00, 0x8B, 0x8B)); object->setOutlineColor(sf::Color::White); } // now query the collision pairs and change the color of objects that hit the mouse object to red const auto &collisionPairs = broadphase.getCollisionPairs(); for (const auto &pair : collisionPairs) { sf::RectangleShape *other = nullptr; if (pair.first == &mouseObject) other = (sf::RectangleShape*)pair.second; else if (pair.second == &mouseObject) other = (sf::RectangleShape*)pair.first; else { ((sf::RectangleShape*)pair.first)->setOutlineColor(sf::Color::Cyan); ((sf::RectangleShape*)pair.second)->setOutlineColor(sf::Color::Cyan); } if (other != nullptr) other->setFillColor(sf::Color(200, 0, 0)); } // clear out the broadphase for the next run broadphase.clear(); // clear the window with black color window.clear(sf::Color::Black); for (const auto& object : objects) window.draw(*object); window.draw(mouseObject); // draw a grid to outline the buckets const float lineThickness = 5; const sf::Color lineColor(150, 150, 150); sf::RectangleShape verticalLine(sf::Vector2f(lineThickness, window.getSize().y)); verticalLine.setFillColor(lineColor); for (size_t i = 1; i < (window.getSize().x / broadphase.getCellWidth()); ++i) { verticalLine.setPosition(i * broadphase.getCellWidth(), 0); window.draw(verticalLine); } sf::RectangleShape horizontalLine(sf::Vector2f(window.getSize().x, lineThickness)); horizontalLine.setFillColor(lineColor); for (size_t i = 1; i < (window.getSize().y / broadphase.getCellHeight()); ++i) { horizontalLine.setPosition(0, i * broadphase.getCellHeight()); window.draw(horizontalLine); } }
void Print_Chess_Board_with_Legal(char grid[8][8][33], char pieceTranslator[33], int piece) { int x, y; //Clear the screen // system("cls"); //Board display //Creats the alphabetical coordinates printf("\n A B C D E F G H\t A B C D E F G H"); //Makes the top of the window space putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\t'); //tab between boards horizontalLine(WIDTH); putchar('\n'); //New line after each segment //Prints out the new table after shifting for(y = 0; y < 8; y++) { //Board layout printf("%d |",8 - y);//Creates the numerical coordinates //Lays down the grid, complete with pieces for(x = 0; x < 8; x++) if(grid[x][y][0] == 0) if(((x + y) % 2) == 0) printf(":|");//Blank Black square else printf(" |");//Blank white square else printf("%c|", pieceTranslator[(int)grid[x][y][0]]); printf(" %d",8 - y);//Creates the numerical coordinates //Legal printf("\t%d |",8 - y);//Creates the numerical coordinates //Lays down the grid, complete with pieces for(x = 0; x < 8; x++) if(grid[x][y][piece] != 'I') printf("L|"); else if(((x + y) % 2) == 0) printf(":|");//Blank Black square else printf(" |");//Blank white square printf(" %d",8 - y);//Creates the numerical coordinates //Make the bottom of the window putchar('\n'); //New line after each segment horizontalLine(WIDTH); putchar('\t'); //tab between boards horizontalLine(WIDTH); putchar('\n'); //New line after each segment } //Creats the alphabetical coordinates printf(" A B C D E F G H\t A B C D E F G H"); //For formating putchar('\n'); putchar('\n'); return; }