mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Added input so that user can set specific scale. Set focus in the linedit showing scale, enter your scale and hit return!
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6747 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
9f5cefc0c1
commit
325a312a56
@ -1021,9 +1021,20 @@ void QgisApp::createStatusBar()
|
|||||||
mScaleLabel->setMinimumWidth(10);
|
mScaleLabel->setMinimumWidth(10);
|
||||||
mScaleLabel->setMargin(3);
|
mScaleLabel->setMargin(3);
|
||||||
mScaleLabel->setAlignment(Qt::AlignCenter);
|
mScaleLabel->setAlignment(Qt::AlignCenter);
|
||||||
QWhatsThis::add(mScaleLabel, tr("Displays the current map scale"));
|
// QWhatsThis::add(mScaleLabel, tr("Displays the current map scale"));
|
||||||
QToolTip::add (mScaleLabel, tr("Current map scale"));
|
// QToolTip::add (mScaleLabel, tr("Current map scale"));
|
||||||
statusBar()->addWidget(mScaleLabel, 0,true);
|
statusBar()->addWidget(mScaleLabel, 0,true);
|
||||||
|
mScaleEdit = new QLineEdit(QString(),statusBar());
|
||||||
|
mScaleEdit->setFont(myFont);
|
||||||
|
mScaleEdit->setMinimumWidth(10);
|
||||||
|
mScaleEdit->setMaximumWidth(100);
|
||||||
|
mScaleEdit->setMargin(0);
|
||||||
|
mScaleEdit->setAlignment(Qt::AlignLeft);
|
||||||
|
QWhatsThis::add(mScaleEdit, tr("Displays the current map scale"));
|
||||||
|
QToolTip::add (mScaleEdit, tr("Current map scale"));
|
||||||
|
statusBar()->addWidget(mScaleEdit, 0,true);
|
||||||
|
connect(mScaleEdit, SIGNAL(editingFinished()), this, SLOT(userScale()));
|
||||||
|
|
||||||
//coords status bar widget
|
//coords status bar widget
|
||||||
mCoordsLabel = new QLabel(QString(), statusBar());
|
mCoordsLabel = new QLabel(QString(), statusBar());
|
||||||
mCoordsLabel->setMinimumWidth(10);
|
mCoordsLabel->setMinimumWidth(10);
|
||||||
@ -1161,8 +1172,8 @@ void QgisApp::setupConnections()
|
|||||||
connect(mMapCanvas->mapRender(), SIGNAL(projectionsEnabled(bool)), this, SLOT(projectionsEnabled(bool)));
|
connect(mMapCanvas->mapRender(), SIGNAL(projectionsEnabled(bool)), this, SLOT(projectionsEnabled(bool)));
|
||||||
connect(mMapCanvas->mapRender(), SIGNAL(destinationSrsChanged()), this, SLOT(destinationSrsChanged()));
|
connect(mMapCanvas->mapRender(), SIGNAL(destinationSrsChanged()), this, SLOT(destinationSrsChanged()));
|
||||||
connect(mMapCanvas, SIGNAL(extentsChanged()),this,SLOT(showExtents()));
|
connect(mMapCanvas, SIGNAL(extentsChanged()),this,SLOT(showExtents()));
|
||||||
connect(mMapCanvas, SIGNAL(scaleChanged(QString)), this, SLOT(showScale(QString)));
|
connect(mMapCanvas, SIGNAL(scaleChanged(long)), this, SLOT(showScale(long)));
|
||||||
connect(mMapCanvas, SIGNAL(scaleChanged(QString)), this, SLOT(updateMouseCoordinatePrecision()));
|
connect(mMapCanvas, SIGNAL(scaleChanged(long)), this, SLOT(updateMouseCoordinatePrecision()));
|
||||||
|
|
||||||
connect(mRenderSuppressionCBox, SIGNAL(toggled(bool )), mMapCanvas, SLOT(setRenderFlag(bool)));
|
connect(mRenderSuppressionCBox, SIGNAL(toggled(bool )), mMapCanvas, SLOT(setRenderFlag(bool)));
|
||||||
}
|
}
|
||||||
@ -3524,16 +3535,27 @@ void QgisApp::showMouseCoordinate(QgsPoint & p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::showScale(QString theScale)
|
void QgisApp::showScale(long theScale)
|
||||||
{
|
{
|
||||||
mScaleLabel->setText(theScale);
|
mScaleLabel->setText(tr("Scale 1: "));
|
||||||
|
mScaleEdit->setText(QString::number(theScale));
|
||||||
// Set minimum necessary width
|
// Set minimum necessary width
|
||||||
if ( mScaleLabel->width() > mScaleLabel->minimumWidth() )
|
if ( mScaleEdit->width() > mScaleEdit->minimumWidth() )
|
||||||
{
|
{
|
||||||
mScaleLabel->setMinimumWidth(mScaleLabel->width());
|
mScaleEdit->setMinimumWidth(mScaleEdit->width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgisApp::userScale()
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
double currentScale = mMapCanvas->getScale();
|
||||||
|
double wantedScale = mScaleEdit->text().toDouble(&ok);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
mMapCanvas->zoom(wantedScale/currentScale);
|
||||||
|
|
||||||
|
}
|
||||||
void QgisApp::testButton()
|
void QgisApp::testButton()
|
||||||
{
|
{
|
||||||
/* QgsShapeFileLayer *sfl = new QgsShapeFileLayer("foo");
|
/* QgsShapeFileLayer *sfl = new QgsShapeFileLayer("foo");
|
||||||
|
@ -23,6 +23,7 @@ class QRect;
|
|||||||
class QStringList;
|
class QStringList;
|
||||||
class QCursor;
|
class QCursor;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
class QFileInfo;
|
class QFileInfo;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@ -174,7 +175,9 @@ public slots:
|
|||||||
//copy the click coord to clipboard and let the user know its there
|
//copy the click coord to clipboard and let the user know its there
|
||||||
void showCapturePointCoordinate(QgsPoint &);
|
void showCapturePointCoordinate(QgsPoint &);
|
||||||
//! Slot to show current map scale;
|
//! Slot to show current map scale;
|
||||||
void showScale(QString theScale);
|
void showScale(long theScale);
|
||||||
|
//! Slot to handle user scale input;
|
||||||
|
void userScale();
|
||||||
//! Remove a layer from the map and legend
|
//! Remove a layer from the map and legend
|
||||||
void removeLayer();
|
void removeLayer();
|
||||||
//! zoom to extent of layer
|
//! zoom to extent of layer
|
||||||
@ -540,8 +543,10 @@ private:
|
|||||||
//!The name of the active theme
|
//!The name of the active theme
|
||||||
QString mThemeName;
|
QString mThemeName;
|
||||||
|
|
||||||
//! Widget that will live on the statusbar to display scale
|
//! Widget that will live on the statusbar to display "scale 1:"
|
||||||
QLabel * mScaleLabel;
|
QLabel * mScaleLabel;
|
||||||
|
//! Widget that will live on the statusbar to display scale value
|
||||||
|
QLineEdit * mScaleEdit;
|
||||||
//! Widget that will live in the statusbar to display coords
|
//! Widget that will live in the statusbar to display coords
|
||||||
QLabel * mCoordsLabel;
|
QLabel * mCoordsLabel;
|
||||||
//! Widget that will live in the statusbar to show progress of operations
|
//! Widget that will live in the statusbar to show progress of operations
|
||||||
|
@ -431,15 +431,11 @@ void QgsMapCanvas::setExtent(QgsRect const & r)
|
|||||||
void QgsMapCanvas::updateScale()
|
void QgsMapCanvas::updateScale()
|
||||||
{
|
{
|
||||||
double scale = mMapRender->scale();
|
double scale = mMapRender->scale();
|
||||||
QString myScaleString = tr("Scale ");
|
|
||||||
int thePrecision = 0;
|
if (scale < 1)
|
||||||
if (scale == 0)
|
emit scaleChanged(lround(-1.0/scale));
|
||||||
myScaleString = "";
|
else
|
||||||
else if (scale >= 1)
|
emit scaleChanged(lround(scale));
|
||||||
myScaleString += QString("1: ") + QString::number(scale,'f',thePrecision);
|
|
||||||
else
|
|
||||||
myScaleString += QString::number(1.0/scale, 'f', thePrecision) + QString(": 1");
|
|
||||||
emit scaleChanged(myScaleString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ signals:
|
|||||||
void xyCoordinates(QgsPoint & p);
|
void xyCoordinates(QgsPoint & p);
|
||||||
|
|
||||||
//! Emitted when the scale of the map changes
|
//! Emitted when the scale of the map changes
|
||||||
void scaleChanged(QString);
|
void scaleChanged(long);
|
||||||
|
|
||||||
//! Emitted when the extents of the map change
|
//! Emitted when the extents of the map change
|
||||||
void extentsChanged();
|
void extentsChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user