Skip to content
Permalink
Browse files
Initial commit of new quick print plugin:
The plugin seeks to cater for users who want to print a map with no
hassle, and does not seek to replace the mapcomposer plugin which is
aimed at advanced users. Since I hate wasting paper / cutting down
trees, I have made the quick print plugin output to pdf for digital
redistribution or optionally printing from pdf.

Features;
- fill in 3 fields, choose a pdf output file and get a pdf ready for printing
- field values are remembered between uses so in most cases you
  simply click the plugin icon then press OK
- automatically scales label text and symbol sizes suitable for
  printing and then scales them down again afterwards
- at the moment all options (page size Letter, output pdf, layout)
  are fixed as I prefer to keep it extremely simple in this iteration.
- 300dpi output

Future options:

- In the future it will be possible to refactor the plugin to support
  simpled predefined layouts at different page sizes.
- autoincrementing filenames for when you want to produce a sequence of maps


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7877 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jan 9, 2008
1 parent 8f4169f commit 42893560cdb7f9f9101fe9aa89af66c899b8221d
@@ -0,0 +1,52 @@

########################################################
# Files

SET (quickprint_SRCS
quickprint.cpp
quickprintgui.cpp
)

SET (quickprint_UIS quickprintguibase.ui)

SET (quickprint_MOC_HDRS
quickprint.h
quickprintgui.h
)

SET (quickprint_RCCS quickprint.qrc)

########################################################
# Build

QT4_WRAP_UI (quickprint_UIS_H ${quickprint_UIS})

QT4_WRAP_CPP (quickprint_MOC_SRCS ${quickprint_MOC_HDRS})

QT4_ADD_RESOURCES(quickprint_RCC_SRCS ${quickprint_RCCS})

ADD_LIBRARY (quickprintplugin MODULE ${quickprint_SRCS} ${quickprint_MOC_SRCS} ${quickprint_RCC_SRCS} ${quickprint_UIS_H})

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
../../core
../../core/raster
../../core/renderer
../../core/symbology
../../gui
..
)

TARGET_LINK_LIBRARIES(quickprintplugin
qgis_core
qgis_gui
)


########################################################
# Install

INSTALL(TARGETS quickprintplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

@@ -0,0 +1,163 @@
/***************************************************************************
quickprint.cpp
Quick Print is a plugin to quickly print a map with minimal effort.
-------------------
begin : Jan 2008
copyright : (c) Tim Sutton, 2008
email : tim@linfiniti.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: plugin.cpp 7796 2007-12-16 22:11:38Z homann $ */

//
// QGIS Specific includes
//

#include <qgisinterface.h>
#include <qgisgui.h>

#include "quickprint.h"
#include "quickprintgui.h"

//
// Qt4 Related Includes
//

#include <QAction>
#include <QToolBar>


static const char * const sIdent = "$Id: plugin.cpp 7796 2007-12-16 22:11:38Z homann $";
static const QString sName = QObject::tr("Quick Print");
static const QString sDescription =
QObject::tr("Quick Print is a plugin to quickly print a map with minimal effort.");
static const QString sPluginVersion = QObject::tr("Version 0.1");
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;

//////////////////////////////////////////////////////////////////////
//
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
//
//////////////////////////////////////////////////////////////////////

/**
* Constructor for the plugin. The plugin is passed a pointer
* an interface object that provides access to exposed functions in QGIS.
* @param theQGisInterface - Pointer to the QGIS interface object
*/
QuickPrint::QuickPrint(QgisInterface * theQgisInterface):
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
mQGisIface(theQgisInterface)
{
}

QuickPrint::~QuickPrint()
{

}

/*
* Initialize the GUI interface for the plugin - this is only called once when the plugin is
* added to the plugin registry in the QGIS application.
*/
void QuickPrint::initGui()
{

// Create the action for tool
mQActionPointer = new QAction(QIcon(":/quickprint/quickprint.png"),tr("Quick Print"), this);
// Set the what's this text
mQActionPointer->setWhatsThis(tr("Replace this with a short description of the what the plugin does"));
// Connect the action to the run
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
// Add the icon to the toolbar
mQGisIface->addToolBarIcon(mQActionPointer);
mQGisIface->addPluginMenu(tr("&Quick Print"), mQActionPointer);

}
//method defined in interface
void QuickPrint::help()
{
//implement me!
}

// Slot called when the menu item is activated
// If you created more menu items / toolbar buttons in initiGui, you should
// create a separate handler for each action - this single run() method will
// not be enough
void QuickPrint::run()
{
QuickPrintGui *myPluginGui=new QuickPrintGui(mQGisIface->getMainWindow(), QgisGui::ModalDialogFlags);
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);

myPluginGui->setMapCanvas(mQGisIface->getMapCanvas());
myPluginGui->show();
}

// Unload the plugin by cleaning up the GUI
void QuickPrint::unload()
{
// remove the GUI
mQGisIface->removePluginMenu("&Quick Print",mQActionPointer);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
}


//////////////////////////////////////////////////////////////////////////
//
//
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
//
//
//////////////////////////////////////////////////////////////////////////


/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
* of the plugin class
*/
// Class factory to return a new instance of the plugin class
QGISEXTERN QgisPlugin * classFactory(QgisInterface * theQgisInterfacePointer)
{
return new QuickPrint(theQgisInterfacePointer);
}
// Return the name of the plugin - note that we do not user class members as
// the class may not yet be insantiated when this method is called.
QGISEXTERN QString name()
{
return sName;
}

// Return the description
QGISEXTERN QString description()
{
return sDescription;
}

// Return the type (either UI or MapLayer plugin)
QGISEXTERN int type()
{
return sPluginType;
}

// Return the version number for the plugin
QGISEXTERN QString version()
{
return sPluginVersion;
}

// Delete ourself
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
{
delete thePluginPointer;
}
@@ -0,0 +1,106 @@
/***************************************************************************
quickprint.h
-------------------
begin : Jan 21, 2004
copyright : (C) 2004 by Tim Sutton
email : tim@linfiniti.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: plugin.h 7796 2007-12-16 22:11:38Z homann $ */
/***************************************************************************
* QGIS Programming conventions:
*
* mVariableName - a class level member variable
* sVariableName - a static class level member variable
* variableName() - accessor for a class member (no 'get' in front of name)
* setVariableName() - mutator for a class member (prefix with 'set')
*
* Additional useful conventions:
*
* theVariableName - a method parameter (prefix with 'the')
* myVariableName - a locally declared variable within a method ('my' prefix)
*
* DO: Use mixed case variable names - myVariableName
* DON'T: separate variable names using underscores: my_variable_name (NO!)
*
* **************************************************************************/
#ifndef QuickPrint_H
#define QuickPrint_H

//QT4 includes
#include <QObject>

//QGIS includes
#include "../qgisplugin.h"

//forward declarations
class QAction;
class QToolBar;

class QgisInterface;

/**
* \class Plugin
* \brief [name] plugin for QGIS
* [description]
*/
class QuickPrint:public QObject, public QgisPlugin
{
Q_OBJECT;
public:

//////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN METHODS FOLLOW
//
//////////////////////////////////////////////////////////////////////

/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param theInterface Pointer to the QgisInterface object.
*/
QuickPrint(QgisInterface * theInterface);
//! Destructor
virtual ~QuickPrint();

public slots:
//! init the gui
virtual void initGui();
//! Show the dialog box
void run();
//! unload the plugin
void unload();
//! show the help document
void help();

private:

////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
//
////////////////////////////////////////////////////////////////////

int mPluginType;
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
//!pointer to the qaction for this plugin
QAction * mQActionPointer;
////////////////////////////////////////////////////////////////////
//
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
//
////////////////////////////////////////////////////////////////////
};

#endif //QuickPrint_H
Binary file not shown.
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/quickprint/" >
<file>quickprint.png</file>
</qresource>
</RCC>
Loading

0 comments on commit 4289356

Please sign in to comment.