QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent ) : QWidget( parent ) , mDizzyTimer( nullptr ) , mMapCanvas( nullptr ) , mMousePrecisionDecimalPlaces( 0 ) { // add a label to show current position mLabel = new QLabel( QString(), this ); mLabel->setObjectName( "mCoordsLabel" ); mLabel->setMinimumWidth( 10 ); //mCoordsLabel->setMaximumHeight( 20 ); mLabel->setMargin( 3 ); mLabel->setAlignment( Qt::AlignCenter ); mLabel->setFrameStyle( QFrame::NoFrame ); mLabel->setText( tr( "Coordinate" ) ); mLabel->setToolTip( tr( "Current map coordinate" ) ); mLineEdit = new QLineEdit( this ); mLineEdit->setMinimumWidth( 10 ); mLineEdit->setMaximumWidth( 300 ); //mLineEdit->setMaximumHeight( 20 ); mLineEdit->setContentsMargins( 0, 0, 0, 0 ); mLineEdit->setAlignment( Qt::AlignCenter ); connect( mLineEdit, SIGNAL( returnPressed() ), this, SLOT( validateCoordinates() ) ); QRegExp coordValidator( "[+-]?\\d+\\.?\\d*\\s*,\\s*[+-]?\\d+\\.?\\d*" ); mCoordsEditValidator = new QRegExpValidator( coordValidator, this ); mLineEdit->setWhatsThis( tr( "Shows the map coordinates at the " "current cursor position. The display is continuously updated " "as the mouse is moved. It also allows editing to set the canvas " "center to a given position. The format is lat,lon or east,north" ) ); mLineEdit->setToolTip( tr( "Current map coordinate (lat,lon or east,north)" ) ); //toggle to switch between mouse pos and extents display in status bar widget mToggleExtentsViewButton = new QToolButton( this ); mToggleExtentsViewButton->setMaximumWidth( 20 ); //mToggleExtentsViewButton->setMaximumHeight( 20 ); mToggleExtentsViewButton->setIcon( uavCore::getThemeIcon( "tracking.png" ) ); mToggleExtentsViewButton->setToolTip( tr( "Toggle extents and mouse position display" ) ); mToggleExtentsViewButton->setCheckable( true ); connect( mToggleExtentsViewButton, SIGNAL( toggled( bool ) ), this, SLOT( extentsViewToggled( bool ) ) ); QHBoxLayout* layout = new QHBoxLayout( this ); setLayout( layout ); layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) ); layout->addWidget( mLabel ); layout->addWidget( mLineEdit ); layout->addWidget( mToggleExtentsViewButton ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->setAlignment( Qt::AlignRight ); layout->setSpacing( 0 ); // When you feel dizzy mDizzyTimer = new QTimer( this ); connect( mDizzyTimer, SIGNAL( timeout() ), this, SLOT( dizzy() ) ); }
void NMEAGPS::setCoordinates() { if (validateCoordinates()){ boat.latitude = Boat::latDecimal(ui->latLineEdit->text()); if (ui->southButton->isChecked()) boat.latitude = boat.latitude * -1; boat.longnitude = Boat::longDecimal(ui->longLineEdit->text()); if (ui->westButton->isChecked()) boat.longnitude = boat.longnitude * -1; coordinatesChanged(); setBoatMapLocation(boat.latitude, boat.longnitude); ui->latLineEdit->setCursorPosition(latCursorPos); ui->longLineEdit->setCursorPosition(longCursorPos); } }
bool isEmpty(Index x, Index y) const { validateCoordinates(x, y); return grid[x][y] == Cell::EMPTY; }
inline Cell getCell(Index x, Index y) const { validateCoordinates(x, y); return grid[x][y]; }
inline void setCell(Index x, Index y, Cell value) { validateCoordinates(x, y); grid[x][y] = value; }
inline char &operator()(Index x, Index y) { validateCoordinates(x, y); return grid[x][y]; }