Esempio n. 1
0
//! change the copyright font
void QgsCopyrightLabelPlugin::setFont( QFont theQFont )
{
  mQFont = theQFont;
  //save state to the project file.....
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/FontName", theQFont.family() );
  //save state to the project file.....
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/FontSize", theQFont.pointSize() );
  refreshCanvas();
}
Esempio n. 2
0
// Unload the plugin by cleaning up the GUI
void QgsNorthArrowPlugin::unload()
{
  // remove the GUI
  qGisInterface->removePluginMenu( tr( "&Decorations" ), myQActionPointer );
  qGisInterface->removeToolBarIcon( myQActionPointer );
  // remove the northarrow from the canvas
  disconnect( qGisInterface->mapCanvas(), SIGNAL( renderComplete( QPainter * ) ),
              this, SLOT( renderNorthArrow( QPainter * ) ) );
  refreshCanvas();

  delete myQActionPointer;
}
Esempio n. 3
0
void QgsScaleBarPluginGui::on_buttonBox_accepted()
{
  hide();
  emit changePlacement( cboPlacement->currentIndex() );
  emit changePreferredSize( spnSize->value() );
  emit changeSnapping( chkSnapping->isChecked() );
  emit changeEnabled( chkEnable->isChecked() );
  emit changeStyle( cboStyle->currentIndex() );
  emit changeColor( pbnChangeColor->color() );
  emit refreshCanvas();
  accept();
}
Esempio n. 4
0
// Slot called when the  menu item is activated
void QgsScaleBarPlugin::run()
{
  QgsScaleBarPluginGui *myPluginGui = new QgsScaleBarPluginGui( qGisInterface->mainWindow(), QgisGui::ModalDialogFlags );
  myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
  myPluginGui->setPreferredSize( mPreferredSize );
  myPluginGui->setSnapping( mSnapping );
  myPluginGui->setPlacementLabels( mPlacementLabels );
  myPluginGui->setPlacement( mPlacementIndex );
  myPluginGui->setEnabled( mEnabled );
  myPluginGui->setStyleLabels( mStyleLabels );
  myPluginGui->setStyle( mStyleIndex );
  myPluginGui->setColor( mColor );

  connect( myPluginGui, SIGNAL( changePreferredSize( int ) ), this, SLOT( setPreferredSize( int ) ) );
  connect( myPluginGui, SIGNAL( changeSnapping( bool ) ), this, SLOT( setSnapping( bool ) ) );
  connect( myPluginGui, SIGNAL( changePlacement( int ) ), this, SLOT( setPlacement( int ) ) );
  connect( myPluginGui, SIGNAL( changeEnabled( bool ) ), this, SLOT( setEnabled( bool ) ) );
  connect( myPluginGui, SIGNAL( changeStyle( int ) ), this, SLOT( setStyle( int ) ) );
  connect( myPluginGui, SIGNAL( changeColor( QColor ) ), this, SLOT( setColor( QColor ) ) );
  connect( myPluginGui, SIGNAL( refreshCanvas() ), this, SLOT( refreshCanvas() ) );
  myPluginGui->show();
  //set the map units in the spin box
  int myUnits = qGisInterface->mapCanvas()->mapUnits();
  switch ( myUnits )
  {
    case 0:
      myPluginGui->getSpinSize()->setSuffix( tr( " metres/km" ) );
      break;
    case 1:
      myPluginGui->getSpinSize()->setSuffix( tr( " feet/miles" ) );
      break;
    case 2:
      myPluginGui->getSpinSize()->setSuffix( tr( " degrees" ) );
      break;
    default:
      QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( myUnits ) );
  };
}
Esempio n. 5
0
void
EraserTool::paint(PaintCanvas *canvas) {
  mRefreshRect = QRectF(mStartPoint, mEndPoint).normalized().toRect()
    .adjusted(-mPen.width(), -mPen.width(), mPen.width(), mPen.width());
  mPainter.begin(canvas->editImage());

  mPainter.setRenderHint(QPainter::Antialiasing, false);
  mPainter.setPen(mPen);
  if(mStartPoint == mEndPoint)
    mPainter.drawPoint(mStartPoint);
  else
    mPainter.drawLine(mStartPoint, mEndPoint);

  mPainter.end();
  refreshCanvas(canvas);
}
Esempio n. 6
0
// Slot called when the buffer menu item is activated
void QgsNorthArrowPlugin::run()
{
  QgsNorthArrowPluginGui *myPluginGui = new QgsNorthArrowPluginGui( qGisInterface->mainWindow(), QgisGui::ModalDialogFlags );
  myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
  //overides function by the same name created in .ui
  myPluginGui->setRotation( mRotationInt );
  myPluginGui->setPlacementLabels( mPlacementLabels );
  myPluginGui->setPlacement( mPlacementIndex );
  myPluginGui->setEnabled( mEnable );
  myPluginGui->setAutomatic( mAutomatic );

  //listen for when the layer has been made so we can draw it
  connect( myPluginGui, SIGNAL( rotationChanged( int ) ), this, SLOT( rotationChanged( int ) ) );
  connect( myPluginGui, SIGNAL( changePlacement( int ) ), this, SLOT( setPlacement( int ) ) );
  connect( myPluginGui, SIGNAL( enableAutomatic( bool ) ), this, SLOT( setAutomatic( bool ) ) );
  connect( myPluginGui, SIGNAL( enableNorthArrow( bool ) ), this, SLOT( setEnabled( bool ) ) );
  connect( myPluginGui, SIGNAL( needToRefresh() ), this, SLOT( refreshCanvas() ) );
  myPluginGui->show();
}
Esempio n. 7
0
/*
* Initialize the GUI interface for the plugin
*/
void QgsNorthArrowPlugin::initGui()
{
  // Create the action for tool
  myQActionPointer = new QAction( QIcon( ":/north_arrow.png" ), tr( "&North Arrow" ), this );
  myQActionPointer->setWhatsThis( tr( "Creates a north arrow that is displayed on the map canvas" ) );
  // Connect the action to the run
  connect( myQActionPointer, SIGNAL( activated() ), this, SLOT( run() ) );
  //render the arrow each time the map is rendered
  connect( qGisInterface->mapCanvas(), SIGNAL( renderComplete( QPainter * ) ), this, SLOT( renderNorthArrow( QPainter * ) ) );
  //this resets this plugin up if a project is loaded
  connect( qGisInterface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
  // Add the icon to the toolbar & appropriate menu
  qGisInterface->addToolBarIcon( myQActionPointer );
  qGisInterface->addPluginToMenu( tr( "&Decorations" ), myQActionPointer );

  projectRead();
  refreshCanvas();

}
Esempio n. 8
0
QImage
StrokeTool::paintStroke(PaintCanvas *canvas) {
    QPainterPath path;
    path = strokePathCubic(m_pStrokePoints);
    mRefreshRect = path.controlPointRect().toRect()
                   .adjusted(-mPen.width(), -mPen.width(), mPen.width(), mPen.width());

    QImage strokeImage(mRefreshRect.size(), QImage::Format_ARGB32_Premultiplied);
    strokeImage.setOffset(mRefreshRect.topLeft());
    strokeImage.fill(0);

    mPainter.begin(&strokeImage);
    mPainter.setRenderHint(QPainter::Antialiasing, true);
    mPainter.setPen(mPen);
    mPainter.drawPath(path.translated(-mRefreshRect.topLeft()));
    mPainter.end();

    mPainter.begin(canvas->editImage());
    mPainter.drawImage(mRefreshRect, strokeImage);
    mPainter.end();

    refreshCanvas(canvas);
    return strokeImage;
}
Esempio n. 9
0
//! set whether copyright label is enabled
void QgsCopyrightLabelPlugin::setEnable( bool theBool )
{
  mEnable = theBool;
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/Enabled", mEnable );
  refreshCanvas();
}
Esempio n. 10
0
//! set placement of copyright label
void QgsCopyrightLabelPlugin::setPlacement( int placementIndex )
{
  mPlacementIndex = placementIndex;
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/Placement", mPlacementIndex );
  refreshCanvas();
}
Esempio n. 11
0
//! change the copyright text color
void QgsCopyrightLabelPlugin::setColor( QColor theQColor )
{
  mLabelQColor = theQColor;
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/Color", mLabelQColor.name() );
  refreshCanvas();
}
Esempio n. 12
0
//! change the copyright text
void QgsCopyrightLabelPlugin::setLabel( QString theLabelQString )
{
  mLabelQString = theLabelQString;
  QgsProject::instance()->writeEntry( "CopyrightLabel", "/Label", mLabelQString );
  refreshCanvas();
}