POV...persistance of vision for North Arrow (ie north arrow settings are saved with your project now...)

git-svn-id: http://svn.osgeo.org/qgis/trunk@2334 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-11-25 23:33:05 +00:00
parent 5e95b68935
commit 9876b25a08
2 changed files with 23 additions and 0 deletions

View File

@ -25,6 +25,7 @@ email : tim@linfiniti.com
#include <qgisapp.h>
#include <qgsmaplayer.h>
#include "plugin.h"
#include "qgsproject.h"
#include <qtoolbar.h>
@ -105,11 +106,28 @@ void Plugin::initGui()
connect(myQActionPointer, SIGNAL(activated()), this, SLOT(run()));
//render the arrow each time the map is rendered
connect(qGisInterface->getMapCanvas(), SIGNAL(renderComplete(QPainter *)), this, SLOT(renderNorthArrow(QPainter *)));
//this resets this plugin up if a project is loaded
connect(qgisMainWindowPointer, SIGNAL(projectRead()), this, SLOT(projectRead()));
// Add the icon to the toolbar
qGisInterface->addToolBarIcon(myQActionPointer);
projectRead();
refreshCanvas();
}
void Plugin::projectRead()
{
#ifdef QGISDEBUG
std::cout << "+++++++++ north arrow plugin - project read slot called...." << std::endl;
#endif
//default text to start with - try to fetch it from qgsproject
mRotationInt = QgsProject::instance()->readNumEntry("NorthArrow","/Rotation",0);
mPlacement = QgsProject::instance()->readEntry("NorthArrow","/Placement","Top Left");
mEnable = QgsProject::instance()->readBoolEntry("NorthArrow","/Enabled",true);
refreshCanvas();
}
//method defined in interface
void Plugin::help()
{
@ -237,6 +255,7 @@ void Plugin::unload()
void Plugin::rotationChanged(int theInt)
{
mRotationInt = theInt;
QgsProject::instance()->writeEntry("NorthArrow","/Rotation", mRotationInt );
refreshCanvas();
}
@ -244,12 +263,14 @@ void Plugin::rotationChanged(int theInt)
void Plugin::setPlacement(QString theQString)
{
mPlacement = theQString;
QgsProject::instance()->writeEntry("NorthArrow","/Placement", mPlacement);
refreshCanvas();
}
void Plugin::setEnabled(bool theBool)
{
mEnable = theBool;
QgsProject::instance()->writeEntry("NorthArrow","/Enabled", mEnable );
refreshCanvas();
}

View File

@ -46,6 +46,8 @@ class Plugin:public QObject, public QgisPlugin
public slots:
//! init the gui
virtual void initGui();
//!set values on the gui when a project is read or the gui first loaded
void projectRead();
//! Show the dialog box
void run();
// draw some arbitary text to the screen