Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,39 @@
#ifndef QGSNORTHARROWPLUGIN
#define QGSNORTHARROWPLUGIN

#include "../qgisplugin.h"

#include <QObject>
#include <QStringList>
class QgisInterface;

class QAction;
class QToolBar;
class QPainter;
/**
* \class Plugin
* \brief North Arrow plugin for QGIS
*
*/
class QgsNorthArrowPlugin: public QObject, public QgisPlugin

class QgsDecorationNorthArrow: public QObject
{
Q_OBJECT public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param qI Pointer to the QgisInterface object.
*/
QgsNorthArrowPlugin( QgisInterface * );
Q_OBJECT

public:
//! Constructor
QgsDecorationNorthArrow( QObject* parent = NULL );
//! Destructor
virtual ~QgsNorthArrowPlugin();
virtual ~QgsDecorationNorthArrow();

public slots:
//! init the gui
virtual void initGui();
//!set values on the gui when a project is read or the gui first loaded
//! set values on the gui when a project is read or the gui first loaded
void projectRead();
//! save values to the project
void saveToProject();

//! Show the dialog box
void run();
// draw some arbitary text to the screen
//! draw some arbitary text to the screen
void renderNorthArrow( QPainter * );
//! Run when the user has set a new rotation
void rotationChanged( int );
//! Refresh the map display using the mapcanvas exported via the plugin interface
void refreshCanvas();
//! unload the plugin
void unload();
//! show the help document
void help();
//! set north arrow placement
void setPlacement( int );
//! enable or disable north arrow
void setEnabled( bool );
//! enable or disable the automatic setting of the arrow direction
void setAutomatic( bool );

//! try to calculate the direction for the north arrow. Sets the
// private class rotation variable. If unable to calculate the
// direction, the function returns false and leaves the rotation
// variable as is.
//! private class rotation variable. If unable to calculate the
//! direction, the function returns false and leaves the rotation
//! variable as is.
bool calculateNorthDirection();
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme( QString theThemeName );

private:

Expand All @@ -90,10 +69,8 @@ class QgsNorthArrowPlugin: public QObject, public QgisPlugin
// The placement index and translated text
int mPlacementIndex;
QStringList mPlacementLabels;
//! Pointer to the QGIS interface object
QgisInterface *qGisInterface;
//! Pointer to the QAction object used in the menu and toolbar
QAction *myQActionPointer;

friend class QgsDecorationNorthArrowDialog;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,92 +9,77 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "plugingui.h"
#include "qgsapplication.h"

#include "qgsdecorationnortharrowdialog.h"

#include "qgsdecorationnortharrow.h"

#include "qgslogger.h"
#include "qgscontexthelp.h"

#include <QPainter>
#include <cmath>
#include "qgslogger.h"


QgsNorthArrowPluginGui::QgsNorthArrowPluginGui( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );
}

QgsNorthArrowPluginGui::~QgsNorthArrowPluginGui()
{
}

void QgsNorthArrowPluginGui::on_buttonBox_accepted()
{
// Hide the dialog
hide();
//close the dialog
emit rotationChanged( sliderRotation->value() );
emit enableAutomatic( cboxAutomatic->isChecked() );
emit changePlacement( cboPlacement->currentIndex() );
emit enableNorthArrow( cboxShow->isChecked() );
emit needToRefresh();

accept();
}

void QgsNorthArrowPluginGui::on_buttonBox_rejected()
{
reject();
}

void QgsNorthArrowPluginGui::setRotation( int theInt )
{
rotatePixmap( theInt );
//sliderRotation->setValue(theInt);
// 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( theInt );
}
spinAngle->setValue( mDeco.mRotationInt );

void QgsNorthArrowPluginGui::setPlacementLabels( QStringList& labels )
{
// placement
cboPlacement->clear();
cboPlacement->addItems( labels );
cboPlacement->addItems( mDeco.mPlacementLabels );
cboPlacement->setCurrentIndex( mDeco.mPlacementIndex );

// enabled
cboxShow->setChecked( mDeco.mEnable );

// automatic
cboxAutomatic->setChecked( mDeco.mAutomatic );
}

void QgsNorthArrowPluginGui::setPlacement( int placementIndex )
QgsDecorationNorthArrowDialog::~QgsDecorationNorthArrowDialog()
{
cboPlacement->setCurrentIndex( placementIndex );
}

void QgsNorthArrowPluginGui::setEnabled( bool theBool )
void QgsDecorationNorthArrowDialog::on_buttonBox_helpRequested()
{
cboxShow->setChecked( theBool );
QgsContextHelp::run( metaObject()->className() );
}

void QgsNorthArrowPluginGui::setAutomatic( bool theBool )
void QgsDecorationNorthArrowDialog::on_buttonBox_accepted()
{
cboxAutomatic->setChecked( theBool );
mDeco.mRotationInt = sliderRotation->value();
mDeco.mPlacementIndex = cboPlacement->currentIndex();
mDeco.mEnable = cboxShow->isChecked();
mDeco.mAutomatic = cboxAutomatic->isChecked();

accept();
}

void QgsNorthArrowPluginGui::setAutomaticDisabled()
void QgsDecorationNorthArrowDialog::on_buttonBox_rejected()
{
cboxAutomatic->setEnabled( false );
reject();
}


//overides function by the same name created in .ui
void QgsNorthArrowPluginGui::on_spinAngle_valueChanged( int theInt )
void QgsDecorationNorthArrowDialog::on_spinAngle_valueChanged( int theInt )
{
Q_UNUSED( theInt );
}

void QgsNorthArrowPluginGui::on_sliderRotation_valueChanged( int theInt )
void QgsDecorationNorthArrowDialog::on_sliderRotation_valueChanged( int theInt )
{
rotatePixmap( theInt );
}

void QgsNorthArrowPluginGui::rotatePixmap( int theRotationInt )
void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
{
QPixmap myQPixmap;
QString myFileNameQString = ":/images/north_arrows/default.png";
Expand Down Expand Up @@ -157,7 +142,7 @@ void QgsNorthArrowPluginGui::rotatePixmap( int theRotationInt )
// Called when the widget has been resized.
//

void QgsNorthArrowPluginGui::resizeEvent( QResizeEvent *theResizeEvent )
void QgsDecorationNorthArrowDialog::resizeEvent( QResizeEvent *theResizeEvent )
{
Q_UNUSED( theResizeEvent );
rotatePixmap( sliderRotation->value() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,31 @@
#ifndef QGSNORTHARROWPLUGINGUI_H
#define QGSNORTHARROWPLUGINGUI_H

#include "ui_pluginguibase.h"
#include "qgscontexthelp.h"
#include "ui_qgsdecorationnortharrowdialog.h"

/**
@author Tim Sutton
*/
class QgsNorthArrowPluginGui : public QDialog, private Ui::QgsNorthArrowPluginGuiBase
class QgsDecorationNorthArrow;

class QgsDecorationNorthArrowDialog : public QDialog, private Ui::QgsDecorationNorthArrowDialog
{
Q_OBJECT

public:
QgsNorthArrowPluginGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsNorthArrowPluginGui();
QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent = 0 );
~QgsDecorationNorthArrowDialog();

private:
void rotatePixmap( int theRotationInt );
// void paintEvent( QPaintEvent * );//overloads qwidget
void resizeEvent( QResizeEvent * ); //overloads qwidget

signals:
//void drawRasterLayer(QString);
//void drawVectorrLayer(QString,QString,QString);
void rotationChanged( int );
void changePlacement( int );
// enable NorthArrow
void enableNorthArrow( bool );
void enableAutomatic( bool );
void needToRefresh();

public slots:
void setRotation( int );
void setPlacementLabels( QStringList& );
void setPlacement( int );
void setEnabled( bool );
void setAutomatic( bool );
void setAutomaticDisabled();

private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void on_buttonBox_helpRequested();
void on_spinAngle_valueChanged( int theInt );
void on_sliderRotation_valueChanged( int theInt );

protected:
QgsDecorationNorthArrow& mDeco;
};

#endif
1 change: 0 additions & 1 deletion src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDI
ADD_SUBDIRECTORY(delimited_text)
ADD_SUBDIRECTORY(diagram_overlay)
ADD_SUBDIRECTORY(interpolation)
ADD_SUBDIRECTORY(north_arrow)
ADD_SUBDIRECTORY(scale_bar)
ADD_SUBDIRECTORY(oracle_raster)
ADD_SUBDIRECTORY(raster_terrain_analysis)
Expand Down
48 changes: 0 additions & 48 deletions src/plugins/north_arrow/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions src/plugins/north_arrow/README

This file was deleted.

Binary file removed src/plugins/north_arrow/images/logo.jpg
Binary file not shown.
Binary file removed src/plugins/north_arrow/images/logo.xcf
Binary file not shown.
197 changes: 0 additions & 197 deletions src/plugins/north_arrow/north_arrow.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/plugins/north_arrow/northarrow_plugin.qrc

This file was deleted.

13 changes: 13 additions & 0 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string>&amp;Decorations</string>
</property>
<addaction name="mActionDecorationCopyright"/>
<addaction name="mActionDecorationNorthArrow"/>
</widget>
<addaction name="mActionPan"/>
<addaction name="mActionZoomIn"/>
Expand Down Expand Up @@ -1502,6 +1503,18 @@
<string>Creates a copyright label that is displayed on the map canvas.</string>
</property>
</action>
<action name="mActionDecorationNorthArrow">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/plugins/north_arrow.png</normaloff>:/images/themes/default/plugins/north_arrow.png</iconset>
</property>
<property name="text">
<string>&amp;North Arrow</string>
</property>
<property name="whatsThis">
<string>&quot;Creates a north arrow that is displayed on the map canvas&quot;</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsNorthArrowPluginGuiBase</class>
<widget class="QDialog" name="QgsNorthArrowPluginGuiBase">
<class>QgsDecorationNorthArrowDialog</class>
<widget class="QDialog" name="QgsDecorationNorthArrowDialog">
<property name="geometry">
<rect>
<x>0</x>
Expand All @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>North Arrow Plugin</string>
<string>North Arrow Decoration</string>
</property>
<property name="windowIcon">
<iconset>
Expand All @@ -35,7 +35,7 @@
<string>Preview of north arrow</string>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
<enum>QFrame::StyledPanel</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
Expand All @@ -44,7 +44,7 @@
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textLabel6">
Expand Down Expand Up @@ -189,9 +189,7 @@
<tabstop>cboxAutomatic</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="northarrow_plugin.qrc"/>
</resources>
<resources/>
<connections>
<connection>
<sender>sliderRotation</sender>
Expand Down