mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
map frame
git-svn-id: http://svn.osgeo.org/qgis/trunk@3010 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1632e85672
commit
997398d5ef
@ -29,6 +29,7 @@
|
||||
#include <qlineedit.h>
|
||||
#include <qpointarray.h>
|
||||
#include <qlabel.h>
|
||||
#include <qcheckbox.h>
|
||||
|
||||
#include "qgsproject.h"
|
||||
#include "qgsrect.h"
|
||||
@ -102,6 +103,8 @@ void QgsComposerMap::init ()
|
||||
mSymbolScale = 1.0;
|
||||
mFontScale = 1.0;
|
||||
|
||||
mFrame = true;
|
||||
|
||||
QCanvasRectangle::setZ(20);
|
||||
setActive(true);
|
||||
}
|
||||
@ -241,15 +244,14 @@ void QgsComposerMap::draw ( QPainter & painter )
|
||||
}
|
||||
|
||||
// Draw frame around
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( Qt::NoBrush );
|
||||
|
||||
painter.save();
|
||||
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
//painter.drawRect ( 0, 0, (int) mWidth+1, (int) mHeight+1 ); // is it right?
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.restore();
|
||||
if ( mFrame ) {
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( Qt::NoBrush );
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
// Show selected / Highlight
|
||||
std::cout << "mSelected = " << mSelected << std::endl;
|
||||
@ -338,6 +340,17 @@ void QgsComposerMap::recalculate ( void )
|
||||
cache();
|
||||
}
|
||||
|
||||
void QgsComposerMap::frameChanged ( )
|
||||
{
|
||||
mFrame = mFrameCheckBox->isChecked();
|
||||
|
||||
QCanvasRectangle::update();
|
||||
QCanvasRectangle::canvas()->update();
|
||||
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
|
||||
void QgsComposerMap::setOptions ( void )
|
||||
{
|
||||
mNameLabel->setText ( mName );
|
||||
@ -365,6 +378,8 @@ void QgsComposerMap::setOptions ( void )
|
||||
mWidthScaleLineEdit->setText ( QString("%1").arg(mWidthScale,0,'g',2) );
|
||||
mSymbolScaleLineEdit->setText ( QString("%1").arg(mSymbolScale,0,'g',2) );
|
||||
mFontScaleLineEdit->setText ( QString("%1").arg(mFontScale,0,'g',2) );
|
||||
|
||||
mFrameCheckBox->setChecked ( mFrame );
|
||||
}
|
||||
|
||||
void QgsComposerMap::setCurrentExtent ( void )
|
||||
@ -419,6 +434,8 @@ bool QgsComposerMap::writeSettings ( void )
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"symbolscale", mSymbolScale );
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"fontscale", mFontScale );
|
||||
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"frame", mFrame );
|
||||
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"previewmode", mPreviewMode );
|
||||
|
||||
return true;
|
||||
@ -446,6 +463,8 @@ bool QgsComposerMap::readSettings ( void )
|
||||
mSymbolScale = QgsProject::instance()->readDoubleEntry("Compositions", path+"symbolscale", 1., &ok);
|
||||
mFontScale = QgsProject::instance()->readDoubleEntry("Compositions", path+"fontscale", 1., &ok);
|
||||
|
||||
mFrame = QgsProject::instance()->readBoolEntry("Compositions", path+"frame", true, &ok);
|
||||
|
||||
mPreviewMode = (PreviewMode) QgsProject::instance()->readNumEntry("Compositions", path+"previewmode", Cache, &ok);
|
||||
|
||||
recalculate();
|
||||
|
@ -123,6 +123,9 @@ public slots:
|
||||
// Called by GUI if with scale was changed
|
||||
void scaleChanged ( void );
|
||||
|
||||
// Frame settings changed
|
||||
void frameChanged ( void );
|
||||
|
||||
// Called by GUI if preview style was changed
|
||||
void previewModeChanged ( int i );
|
||||
|
||||
@ -177,6 +180,9 @@ private:
|
||||
|
||||
/** \brief Number of layers when cache was created */
|
||||
int mNumCachedLayers;
|
||||
|
||||
/** \brief Draw frame */
|
||||
bool mFrame;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -8,8 +8,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>265</width>
|
||||
<height>607</height>
|
||||
<width>271</width>
|
||||
<height>650</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -217,6 +217,14 @@
|
||||
<cstring>mFontScaleLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox">
|
||||
<property name="name">
|
||||
<cstring>mFrameCheckBox</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_5</cstring>
|
||||
@ -300,12 +308,19 @@
|
||||
<receiver>QgsComposerMapBase</receiver>
|
||||
<slot>scaleChanged()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>mFrameCheckBox</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QgsComposerMapBase</receiver>
|
||||
<slot>frameChanged()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>sizeChanged()</slot>
|
||||
<slot>setCurrentExtent()</slot>
|
||||
<slot>scaleChanged()</slot>
|
||||
<slot>previewModeChanged(int)</slot>
|
||||
<slot>frameChanged()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
|
@ -498,6 +498,16 @@ void QgsComposition::setPlotStyle ( PlotStyle p )
|
||||
for (std::list < QgsComposerItem * >::iterator it = mItems.begin(); it != mItems.end(); ++it) {
|
||||
(*it)->setPlotStyle( p ) ;
|
||||
}
|
||||
|
||||
// Remove paper if Print, reset if Preview
|
||||
if ( mPlotStyle == Print ) {
|
||||
mPaperItem->setCanvas(0);
|
||||
mCanvas->setBackgroundColor( Qt::white );
|
||||
} else {
|
||||
mPaperItem->setCanvas(mCanvas);
|
||||
mCanvas->setBackgroundColor( QColor(180,180,180) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
double QgsComposition::viewScale ( void )
|
||||
|
Loading…
x
Reference in New Issue
Block a user