QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent ) : QDialog( parent ), mDeco( deco ) { setupUi( this ); QSettings settings; restoreGeometry( settings.value( "/Windows/DecorationNorthArrow/geometry" ).toByteArray() ); // rotation rotatePixmap( mDeco.mRotationInt ); // signal/slot connection defined in 'designer' causes the slider to // be moved to reflect the change in the spinbox. spinAngle->setValue( mDeco.mRotationInt ); // placement cboPlacement->clear(); cboPlacement->addItems( mDeco.mPlacementLabels ); cboPlacement->setCurrentIndex( mDeco.mPlacementIndex ); // enabled cboxShow->setChecked( mDeco.enabled() ); // automatic cboxAutomatic->setChecked( mDeco.mAutomatic ); }
QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent ) : QDialog( parent ) , mDeco( deco ) { setupUi( this ); QSettings settings; restoreGeometry( settings.value( "/Windows/DecorationNorthArrow/geometry" ).toByteArray() ); QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply ); connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) ); // rotation rotatePixmap( mDeco.mRotationInt ); // signal/slot connection defined in 'designer' causes the slider to // be moved to reflect the change in the spinbox. spinAngle->setValue( mDeco.mRotationInt ); // placement cboPlacement->addItem( tr( "Top left" ), QgsDecorationItem::TopLeft ); cboPlacement->addItem( tr( "Top right" ), QgsDecorationItem::TopRight ); cboPlacement->addItem( tr( "Bottom left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom right" ), QgsDecorationItem::BottomRight ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); spinHorizontal->setValue( mDeco.mMarginHorizontal ); spinVertical->setValue( mDeco.mMarginVertical ); wgtUnitSelection->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderPercentage << QgsUnitTypes::RenderPixels ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); // enabled grpEnable->setChecked( mDeco.enabled() ); // automatic cboxAutomatic->setChecked( mDeco.mAutomatic ); }
void girarder::rotarplayer(tam grados) { QPixmap sourceImage(*player->pixmap()); QPixmap rotatePixmap(sourceImage.size()); rotatePixmap.fill(Qt::transparent); QTransform transform; transform.translate(sourceImage.size().width() / 2, sourceImage.size().height() / 2); transform.rotate(grados); transform.translate(-sourceImage.size().width() / 2, -sourceImage.size().height() / 2); QPainter p; p.begin(&rotatePixmap); p.setTransform(transform); p.drawPixmap(0, 0, sourceImage); p.end(); rotatePixmap.save(":/temp.png"); player->setPixmap(rotatePixmap); player->giro = player->giro + grados; }
QRectF UBGraphicsRuler::rotateButtonRect() const { QPixmap rotatePixmap(":/images/closeTool.svg"); QSizeF rotateRectSize( rotatePixmap.width() * mAntiScaleRatio, rotatePixmap.height() * mAntiScaleRatio); int centimeters = (int)(rect().width() - sLeftEdgeMargin - resizeButtonRect().width()) / (int)(10 * sPixelsPerMillimeter); QPointF rotateRectCenter( rect().left() + sLeftEdgeMargin + (centimeters - 0.5) * 10 * sPixelsPerMillimeter, rect().center().y()); QPointF rotateRectTopLeft( rotateRectCenter.x() - rotateRectSize.width() / 2, rotateRectCenter.y() - rotateRectSize.height() / 2); return QRectF(rotateRectTopLeft, rotateRectSize); }
void GPS::update(){ double dx,dy; int pix_por_km=500; if(velocidad>0){ x=ui->mapa->pos().x(); y=ui->mapa->pos().y(); if(lastYaw!=yaw){ ui->avion->setPixmap(rotatePixmap(360-yaw)); lastYaw=yaw; } dy = (double) cos((yaw)*Pi/180)*cos((pitch)*Pi/180)*(velocidad/3600)*0.2*pix_por_km; dx = (double)sin((yaw)*Pi/180)*cos((pitch)*Pi/180)*(velocidad/3600)*0.2*pix_por_km; y+=dy; x+=dx; if((y<33 && x<33) && (y>-5502 && x>-10165) ){ ui->mapa->move(x,y); }else{ if(y>=33){ y=-5500; } if(x>=33){ x=-10160; } if(y<=-5502){ y=30; } if(x<=-10165){ x=30; } ui->mapa->move(x,y); } } }
void QgsCompassPluginGui::handleAzimuth( const QVariant &azimuth, const QVariant &calLevel ) { this->mAzimutDisplay->setText( QString( "%1" ).arg( azimuth.toInt() ) + QString::fromUtf8( "°" ) ); //TODO check when https://sourceforge.net/p/necessitas/tickets/153/ is fixed qreal calibrationLevel = calLevel.toReal() / 3; if ( calibrationLevel == 1 ) { this->mCalibrationLabel->setStyleSheet( "Background-color:green" ); } else if ( calibrationLevel <= 1 / 3 ) { this->mCalibrationLabel->setStyleSheet( "Background-color:red" ); this->mWarningLabel->setText( "<font color='red'><a href='http://www.youtube.com/watch?v=oNJJPeoG8lQ'>Compass calibration</a> needed</font>" ); } else { this->mCalibrationLabel->setStyleSheet( "Background-color:yellow" ); } rotatePixmap( this->mArrowPixmapLabel, QString( ":/images/north_arrows/default.png" ), -azimuth.toInt() ); }
void Tank::hrotate() // поворот башни { if (alive == true) { QPixmap shipPixels(headImage); QPixmap rotatePixmap(shipPixels.size()); rotatePixmap.fill(Qt::transparent); QPainter p(&rotatePixmap); p.setRenderHint(QPainter::Antialiasing); // сглаживание p.setRenderHint(QPainter::SmoothPixmapTransform); p.setRenderHint(QPainter::HighQualityAntialiasing); p.translate(rotatePixmap.size().width() / 2, rotatePixmap.size().height() / 2); p.rotate(hdegree); // градус p.translate(-rotatePixmap.size().width() / 2, -rotatePixmap.size().height() / 2); p.drawPixmap(0, 0, shipPixels); p.end(); shipPixels = rotatePixmap; head->setPixmap(shipPixels.scaled(pixsize,pixsize)); } }
void QgsDecorationNorthArrowDialog::on_sliderRotation_valueChanged( int theInt ) { rotatePixmap( theInt ); }
void QgsDecorationNorthArrowDialog::resizeEvent( QResizeEvent *theResizeEvent ) { Q_UNUSED( theResizeEvent ); rotatePixmap( sliderRotation->value() ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), sentBytes(NULL) { ui->setupUi(this); //---- Menu Configuration ---- machineGroup = new QActionGroup(this); machineGroup->addAction(ui->actionScorpio); machineGroup->addAction(ui->actionQuadcopter); ui->actionScorpio->setChecked(true); viewGroup = new QActionGroup(this); viewGroup->addAction(ui->actionTracking); viewGroup->addAction(ui->actionTracking); viewGroup->addAction(ui->actionManual_Control); viewGroup->addAction(ui->actionCommand_Center); ui->actionCommand_Center->setChecked(true); //---- ---- //---- Statusbar ---- serialConnected=false; gpsFix=false; joystickConnected=false; gpsFooterStat = new QLabel(this); connectedFooterStat = new QLabel(this); joystickFooterStat = new QLabel(this); aliveFooterState = new QLabel(this); connectedGPSFooterStat = new QLabel(this); ui->statusBar->addPermanentWidget(gpsFooterStat); ui->statusBar->addPermanentWidget(connectedFooterStat); ui->statusBar->addPermanentWidget(aliveFooterState); ui->statusBar->addPermanentWidget(joystickFooterStat); ui->statusBar->addPermanentWidget(connectedGPSFooterStat); //---- ---- //---- Compass Graphics View ---- compassPixmap = new QPixmap(":/img/CompassSquare150.png"); ui->compassViewLabel->setPixmap(rotatePixmap(compassPixmap,0)); //---- ---- //---- Speedometer Graphics View ---- ui->speedometerViewLabel->setPixmap(updateSpeedIndicator(0)); //---- ---- //---- Steer Graphics View ---- ui->steerGraphicsView->setStyleSheet("background: transparent"); steerGraphicsScene = new QGraphicsScene(this); QBrush brush(QColor::fromRgb(59,174,227)); steerRailIndicator = steerGraphicsScene->addRect(0,22.5,148,15,Qt::NoPen,brush); brush.setColor(Qt::red); QPen pen(Qt::black); pen.setWidth(2); steerIndicator = steerGraphicsScene->addRect(67.5,5,15,50,Qt::NoPen,brush); updateSteerIndicator(-100); ui->steerGraphicsView->setScene(steerGraphicsScene); //---- ---- //---- Tracker View ---- ui->trackerGraphicsView-> setBackgroundBrush(QBrush(QColor::fromRgb(237,200,90),Qt::Dense4Pattern)); trackerScene = new QGraphicsScene(this); ui->trackerGraphicsView->setScene(trackerScene); QPolygonF NorthArrow; NorthArrow.append(QPointF(-5.,0)); NorthArrow.append(QPointF(0.,-20)); NorthArrow.append(QPointF(5.,0)); NorthArrow.append(QPointF(0.,-5.)); NorthArrow.append(QPointF(-5.,0)); brush.setColor(Qt::black); northArrowGraphicsItem = trackerScene->addPolygon(NorthArrow,Qt::NoPen,brush); northArrowGraphicsItem->setPos(800,10); northArrowGraphicsItem->setFlag(QGraphicsItem::ItemIgnoresTransformations); //Scorpio Graphics Item scorpio2DGraphicsItem = new GraphicsItemScorpio; trackerScene->addItem(scorpio2DGraphicsItem); scorpio2DGraphicsItem->setPos(500,150); wgs2utm(BASE_LATITUDE, BASE_LONGITUDE,&baseEasting,&baseNorthing, &baseUTMZone); lastPoKnown=false; //---- ---- brush.setColor(QColor(255, 0, 0, 180)); targetMarker = trackerScene->addEllipse(400,100,10,10,pen,brush); brush.setColor(QColor(255, 255, 0, 180)); baseMarker = trackerScene->addRect(0,0,10,10,pen,brush); //---- ---- connect(&timerTracker,SIGNAL(timeout()),this,SLOT(updateTrackerGraphics())); //TODO: another sig-slot for updating scene to zoom to fit timerTracker.start(100); //---- ---- ---- ---- //---- Joystick Initialization ---- myJoystick = new RR_SDLJoystick; myJoystickData = new RR_SDLJoystickData_t; QString *joystickInitError; if(!myJoystick->initJoystick(myJoystickData, joystickInitError)){ ui->plainTextEdit->insertPlainText("Error Connecting Joystick"); //TODO: Fix so that the insertPlainText takes the error code from Joystick Object. } else{ ui->plainTextEdit->insertPlainText("Joystick Connected!"); joystickConnected=true; connect(&timerJoystick,SIGNAL(timeout()),myJoystick ,SLOT(pollJoystick())); timerJoystick.start(150); } connect(myJoystick,SIGNAL(gotJoystick()),this,SLOT(updateGaugeIndicators())); connect(myJoystick,SIGNAL(gotJoystick()),this,SLOT(updateJoystickTelemetry())); //---- ---- //---- Serial ---- serialPort = new RR_QtSerial(57600,"COM26"); connect(&timerSerial,SIGNAL(timeout()), serialPort,SLOT(receiveBytes())); connect(ui->actionConnect,SIGNAL(triggered(bool)),serialPort,SLOT(switchSerial(bool))); connect(serialPort,SIGNAL(gotConnected(bool)),this,SLOT(updateSerialStatusBar(bool))); connect(serialPort,SIGNAL(gotConnected(bool)),ui->actionConnect,SLOT(setChecked(bool))); timerSerial.start(150); //----- GPS ------ serialGPSPort = new RR_QtSerial(57600,"COM19"); connect(&timerGPSSerial, SIGNAL(timeout()),serialGPSPort, SLOT(receiveBytes())); connect(ui->actionConnect_GPS, SIGNAL(triggered(bool)), serialGPSPort, SLOT(switchSerial(bool))); connect(serialGPSPort,SIGNAL(gotConnected(bool)),this,SLOT(updateGPSSerialStatusBar(bool))); connect(serialGPSPort,SIGNAL(gotConnected(bool)),ui->actionConnect_GPS,SLOT(setChecked(bool))); timerGPSSerial.start(150); //------- //---- GPS Data Serialization ---- receivedGPSData = new RR_QtTelemetryReceivedData_t; sentGPSData = new RR_QtTelemetrySentData_t; gps = new RR_QtTelemetry(receivedGPSData,sentGPSData); receivedGPSData->fix=false; connect(serialGPSPort,SIGNAL(gotBytes(QByteArray*)),gps,SLOT(decodeBytes(QByteArray*))); connect(gps,SIGNAL(gotDecodedMessage()),this,SLOT(updateGPSData())); //---- ---- //---- Telemetry ---- receivedTelemetryData = new RR_QtTelemetryReceivedData_t; sentTelemetryData = new RR_QtTelemetrySentData_t; telemetry = new RR_QtTelemetry(receivedTelemetryData,sentTelemetryData); receivedTelemetryData->fix=false; connect(this,SIGNAL(gotJoystickMessage()),telemetry,SLOT(sendMessage())); connect(telemetry,SIGNAL(gotEncodedBytes(QByteArray*)),serialPort,SLOT(sendBytes(QByteArray*))); connect(serialPort,SIGNAL(gotBytes(QByteArray*)),telemetry,SLOT(decodeBytes(QByteArray*))); connect(telemetry,SIGNAL(gotDecodedMessage()),this,SLOT(updateTelemetryGraphics())); //---- ---- //---- Text Display ---- connect(&timerSerialPrint,SIGNAL(timeout()),this, SLOT(printStuff())); timerSerialPrint.start(ui->printfreSlider->value()); connect(ui->printfreSlider, SIGNAL(sliderMoved(int)),&timerSerialPrint,SLOT(start(int))); connect(ui->clearPushButton,SIGNAL(clicked()),ui->plainTextEdit,SLOT(clear())); connect(ui->printfreSlider,SIGNAL(sliderMoved(int)),this,SLOT(setPrintFrequencyText())); setPrintFrequencyText(); //---- ---- //---- Test and Debug ---- connect(&timerTestDebug,SIGNAL(timeout()),this,SLOT(testdebug())); timerTestDebug.start(1000); //---- ---- connect(&timerStatusBarUpdate, SIGNAL(timeout()), this, SLOT(updateGPSStatbar())); timerStatusBarUpdate.start(500); //Pulse Check connect(&timerPulseCheck,SIGNAL(timeout()), this, SLOT(checkPulse())); pulseSamplingTime = 5000; timerPulseCheck.start(pulseSamplingTime); }
void MainWindow::updateTelemetryGraphics() { newPulse=true; ui->labelElapsedTime->setText( QString("%1:%2").arg(int(receivedTelemetryData->ellapsedm/60)).arg( int(receivedTelemetryData->ellapsedm%60))); if(receivedTelemetryData->fix){ wgs2utm(receivedTelemetryData->Latitude, receivedTelemetryData->Longitude, &robotEasting, &robotNorthing, &robotUTMZone); } wgs2utm(receivedTelemetryData->targetLatidude, receivedTelemetryData->targetLongitude, &targetEasting, &targetNorthing, &targetUTMZone); //Offset UTM to fit graphics view using min easting and max northing //Since grid starts top left and UTM starts bottom left offset_easting = qMin(baseEasting,targetEasting); if(receivedTelemetryData->fix){offset_easting = qMin((float)offset_easting,robotEasting);} offset_easting-=10; offset_northing=qMax(baseNorthing,targetNorthing); if(receivedTelemetryData->fix){offset_northing=qMax((float)offset_northing,robotNorthing);} offset_northing+=10; qint16 h = receivedTelemetryData->Heading; ui->compassViewLabel->setPixmap(rotatePixmap(compassPixmap,(-h))); ui->headingLcdNumber->display(h); ui->plainTextEdit->moveCursor(QTextCursor::End); int scale=1; int scaleR=1; QPointF poTarget= QPointF(targetEasting/scaleR-offset_easting, offset_northing-targetNorthing/scale); targetMarker->setPos(poTarget); QPointF poBase= QPointF(baseEasting/scaleR-offset_easting, offset_northing-baseNorthing/scale); qDebug()<<"Target Easting/Northing: "<<targetEasting<<" "<<targetNorthing; qDebug()<<"Target Mapping: "<<targetEasting/scaleR-offset_easting<<" "<<offset_northing-targetNorthing/scale; qDebug()<<"Base Easting/Northing: "<<baseEasting<<" "<<baseNorthing; qDebug()<<"Target Mapping: "<<baseEasting/scaleR-offset_easting<<" "<<offset_northing-baseNorthing/scale; if(!lastPoKnown) { poRobotLastKnown = poBase; } if(receivedTelemetryData->fix){ poRobotLastKnown = QPointF(robotEasting/scaleR-offset_easting, offset_northing-robotNorthing/scale); lastPoKnown=true; ui->distanceTravelledLcdNumber->display(receivedTelemetryData->DistanceTravelled); ui->distanceToTargetLcdNumber->display(receivedTelemetryData->DistanceToTarget); ui->bearingLcdNumber->display(receivedTelemetryData->Bearing); qDebug()<<"Robot Easting/Northing: "<<robotEasting<<" "<<robotNorthing; qDebug()<<"Robot Mapping: "<<robotEasting/scale-offset_easting<<" "<<offset_northing-robotNorthing/scale; ui->labelRobotLocation->setText(QString("%1 %2, %3 %4").arg(float(int(receivedTelemetryData->Latitude/100))).arg( QString::number(fmod(fabs(receivedTelemetryData->Latitude), 100.0),'f',4)).arg( float(int(receivedTelemetryData->Longitude/100))).arg( QString::number(fmod(fabs(receivedTelemetryData->Longitude), 100.0),'f',4))); if(receivedTelemetryData->isMoving == 1){ ui->labelMovingStatus->setText("Moving"); } else{ ui->labelMovingStatus->setText("Not Moving"); } } baseMarker->setPos(poBase); scorpio2DGraphicsItem->updatePose(poRobotLastKnown,-h); updateLaunchStatus(); ui->labelBaseAlt->setText( QString("%1").arg(receivedTelemetryData->baseAltitude)); ui->labelMaxAlt->setText( QString("%1").arg(receivedTelemetryData->maxAltitude)); ui->labelAltitude->setText( QString("%1").arg(receivedTelemetryData->Altitude)); ui->labelleftcurrent->setText( QString("%1").arg(receivedTelemetryData->Motors.leftCurrent)); ui->labelrightcurrent->setText( QString("%1").arg(receivedTelemetryData->Motors.rightCurrent)); ui->labelleftspeed->setText( QString("%1").arg(receivedTelemetryData->Motors.leftSpeed)); ui->labelrightspeed->setText( QString("%1").arg(receivedTelemetryData->Motors.rightSpeed)); }