Quantum GIS API Documentation  1.8
src/gui/qgsgenericprojectionselector.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsgenericprojectionselector.cpp
00003                     Set user defined CRS using projection selector widget
00004                              -------------------
00005     begin                : May 28, 2004
00006     copyright            : (C) 2004 by Gary E.Sherman
00007     email                : sherman at mrcc.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 #include "qgsapplication.h"
00019 
00020 #include <qgsgenericprojectionselector.h>
00021 #include <QApplication>
00022 #include <QSettings>
00023 
00028 QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
00029     Qt::WFlags fl )
00030     : QDialog( parent, fl )
00031 {
00032   setupUi( this );
00033 
00034   QSettings settings;
00035   restoreGeometry( settings.value( "/Windows/ProjectionSelector/geometry" ).toByteArray() );
00036 
00037   //we will show this only when a message is set
00038   textEdit->hide();
00039 }
00040 
00041 void QgsGenericProjectionSelector::setMessage( QString theMessage )
00042 {
00043   //short term kludge to make the layer selector default to showing
00044   //a layer projection selection message. If you want the selector
00045   if ( theMessage.isEmpty() )
00046   {
00047     // Set up text edit pane
00048     QString format( "<h1>%1</h1>%2 %3" );
00049     QString header = tr( "Define this layer's coordinate reference system:" );
00050     QString sentence1 = tr( "This layer appears to have no projection specification." );
00051     QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
00052                             "but you may override this by selecting a different projection below." );
00053     theMessage = format.arg( header ).arg( sentence1 ).arg( sentence2 );
00054   }
00055 
00056   QString myStyle = QgsApplication::reportStyleSheet();
00057   theMessage = "<head><style>" + myStyle + "</style></head><body>" + theMessage + "</body>";
00058   textEdit->setHtml( theMessage );
00059   textEdit->show();
00060 }
00062 QgsGenericProjectionSelector::~QgsGenericProjectionSelector()
00063 {
00064   QSettings settings;
00065   settings.setValue( "/Windows/ProjectionSelector/geometry", saveGeometry() );
00066 }
00067 
00068 void QgsGenericProjectionSelector::setSelectedEpsg( long theId )
00069 {
00070   projectionSelector->setSelectedAuthId( QString( "EPSG:%1" ).arg( theId ) );
00071 }
00072 
00073 void QgsGenericProjectionSelector::setSelectedCrsName( QString theName )
00074 {
00075   projectionSelector->setSelectedCrsName( theName );
00076 }
00077 
00078 void QgsGenericProjectionSelector::setSelectedCrsId( long theID )
00079 {
00080   projectionSelector->setSelectedCrsId( theID );
00081 }
00082 
00083 void QgsGenericProjectionSelector::setSelectedAuthId( QString theID )
00084 {
00085   projectionSelector->setSelectedAuthId( theID );
00086 }
00087 
00088 QString QgsGenericProjectionSelector::selectedProj4String()
00089 {
00090   [email protected] don't use getSelectedWkt as that just returns the name part!
00091   return projectionSelector->selectedProj4String();
00092 }
00093 
00094 long QgsGenericProjectionSelector::selectedCrsId()
00095 {
00096   [email protected] don't use getSelectedWkt as that just returns the name part!
00097   return projectionSelector->selectedCrsId();
00098 }
00099 
00100 long QgsGenericProjectionSelector::selectedEpsg()
00101 {
00102   QString authid = projectionSelector->selectedAuthId();
00103   if ( authid.startsWith( "EPSG:", Qt::CaseInsensitive ) )
00104     return authid.mid( 5 ).toLong();
00105   else
00106     return 0;
00107 }
00108 
00109 QString QgsGenericProjectionSelector::selectedAuthId()
00110 {
00111   return projectionSelector->selectedAuthId();
00112 }
00113 
00114 void QgsGenericProjectionSelector::setOgcWmsCrsFilter( QSet<QString> crsFilter )
00115 {
00116   projectionSelector->setOgcWmsCrsFilter( crsFilter );
00117 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines