30 changes: 30 additions & 0 deletions src/core/composer/qgscomposermap.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,32 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void setGridFrameWidth( double w ) { mGridFrameWidth = w; }
double gridFrameWidth() const { return mGridFrameWidth; }

/**Set grid frame pen thickness
@note: this function was added in version 2.1*/
void setGridFramePenSize( double w ) { mGridFramePenThickness = w; }
double gridFramePenSize() const { return mGridFramePenThickness; }

/**Sets pen color for grid frame
@note: this function was added in version 2.1*/
void setGridFramePenColor( const QColor& c ) { mGridFramePenColor = c;}
/**Get pen color for grid frame
@note: this function was added in version 2.1*/
QColor gridFramePenColor() const {return mGridFramePenColor;}

/**Sets first fill color for grid zebra frame
@note: this function was added in version 2.1*/
void setGridFrameFillColor1( const QColor& c ) { mGridFrameFillColor1 = c;}
/**Get first fill color for grid zebra frame
@note: this function was added in version 2.1*/
QColor gridFrameFillColor1() const {return mGridFrameFillColor1;}

/**Sets second fill color for grid zebra frame
@note: this function was added in version 2.1*/
void setGridFrameFillColor2( const QColor& c ) { mGridFrameFillColor2 = c;}
/**Get second fill color for grid zebra frame
@note: this function was added in version 2.1*/
QColor gridFrameFillColor2() const {return mGridFrameFillColor2;}

/**In case of annotations, the bounding rectangle can be larger than the map item rectangle
@note this function was added in version 1.4*/
QRectF boundingRect() const;
Expand Down Expand Up @@ -470,6 +496,10 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem

GridFrameStyle mGridFrameStyle;
double mGridFrameWidth;
double mGridFramePenThickness;
QColor mGridFramePenColor;
QColor mGridFrameFillColor1;
QColor mGridFrameFillColor2;

/**Current bounding rectangle. This is used to check if notification to the graphics scene is necessary*/
QRectF mCurrentRectangle;
Expand Down
118 changes: 87 additions & 31 deletions src/ui/qgscomposermapwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-376</y>
<y>-420</y>
<width>439</width>
<height>1439</height>
<height>1509</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -393,32 +393,6 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mFrameStyleLabel">
<property name="text">
<string>Frame style</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="mFrameStyleComboBox"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mFrameWidthLabel">
<property name="text">
<string>Frame width</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="mLineStyleLabel">
<property name="text">
<string>Line style</string>
Expand All @@ -428,17 +402,17 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="4" column="1">
<widget class="QPushButton" name="mGridLineStyleButton">
<property name="text">
<string>change...</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="5" column="1">
<widget class="QgsBlendModeComboBox" name="mGridBlendComboBox"/>
</item>
<item row="7" column="0">
<item row="5" column="0">
<widget class="QLabel" name="mGridBlendLabel">
<property name="text">
<string>Blend mode</string>
Expand All @@ -460,6 +434,88 @@
</item>
</layout>
</item>
<item>
<widget class="QgsCollapsibleGroupBoxBasic" name="mGridFrameGroupBox">
<property name="title">
<string>Grid frame</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="collapsed" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="mFrameStyleLabel">
<property name="text">
<string>Frame style</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="mFrameStyleComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mFrameWidthLabel">
<property name="text">
<string>Frame size</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mFramePenLabel">
<property name="text">
<string>Frame line thickness</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mGridFramePenSizeSpinBox"/>
</item>
<item row="2" column="2">
<widget class="QgsColorButton" name="mGridFramePenColorButton">
<property name="text">
<string>Color...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mFrameFillLabel">
<property name="text">
<string>Frame fill colors</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QgsColorButton" name="mGridFrameFill1ColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QgsColorButton" name="mGridFrameFill2ColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBoxBasic" name="mDrawAnnotationCheckableGroupBox">
<property name="enabled">
Expand Down
37 changes: 21 additions & 16 deletions tests/src/core/testqgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void TestQgsComposerMap::initTestCase()
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );
mComposition->addComposerMap( mComposerMap );

mReport = "<h1>Composer Map Tests</h1>\n";
}

Expand All @@ -84,15 +84,15 @@ void TestQgsComposerMap::cleanupTestCase()
delete mComposition;
delete mMapRenderer;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
{
QTextStream myQTextStream( &myFile );
myQTextStream << mReport;
myFile.close();
}
}
}

void TestQgsComposerMap::init()
Expand All @@ -108,7 +108,7 @@ void TestQgsComposerMap::render()
{
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
QgsCompositionChecker checker( "composermap_render", mComposition );

QVERIFY( checker.testComposition( mReport ) );
}

Expand All @@ -132,8 +132,8 @@ void TestQgsComposerMap::grid()
mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay );
qWarning() << "grid annotation font: " << mComposerMap->gridAnnotationFont().toString() << " exactMatch:" << mComposerMap->gridAnnotationFont().exactMatch();
QgsCompositionChecker checker( "composermap_grid", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
mComposerMap->setGridEnabled( false );
mComposerMap->setShowGridAnnotation( false );
QVERIFY( testResult );
Expand All @@ -148,8 +148,8 @@ void TestQgsComposerMap::overviewMap()
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
overviewMap->setOverviewFrameMap( mComposerMap->id() );
QgsCompositionChecker checker( "composermap_overview", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
mComposition->removeComposerItem( overviewMap );
QVERIFY( testResult );
}
Expand All @@ -165,8 +165,8 @@ void TestQgsComposerMap::overviewMapBlending()
overviewMapBlend->setOverviewBlendMode( QPainter::CompositionMode_Multiply );

QgsCompositionChecker checker( "composermap_overview_blending", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
mComposition->removeComposerItem( overviewMapBlend );
QVERIFY( testResult );
}
Expand All @@ -182,8 +182,8 @@ void TestQgsComposerMap::overviewMapInvert()
overviewMapInvert->setOverviewInverted( true );

QgsCompositionChecker checker( "composermap_overview_invert", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
mComposition->removeComposerItem( overviewMapInvert );
QVERIFY( testResult );
}
Expand Down Expand Up @@ -222,11 +222,16 @@ void TestQgsComposerMap::zebraStyle()
mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver );

mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra );
mComposerMap->setGridFrameWidth( 10 );
mComposerMap->setGridFramePenSize( 1 );
mComposerMap->setGridFramePenColor( QColor( 255, 100, 0, 200 ) );
mComposerMap->setGridFrameFillColor1( QColor( 50, 90, 50, 100 ) );
mComposerMap->setGridFrameFillColor2( QColor( 200, 220, 100, 60 ) );
mComposerMap->setGridEnabled( true );

QgsCompositionChecker checker( "composermap_zebrastyle", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
QVERIFY( testResult );
}

Expand All @@ -242,8 +247,8 @@ void TestQgsComposerMap::overviewMapCenter()
overviewMapCenter->setOverviewCentered( true );

QgsCompositionChecker checker( "composermap_overview_center", mComposition );
bool testResult = checker.testComposition( mReport);

bool testResult = checker.testComposition( mReport );
mComposition->removeComposerItem( overviewMapCenter );
QVERIFY( testResult );
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.