Skip to content
Permalink
Browse files

remove cross grid type and set default marker to cross; remove annota…

…tion position option
  • Loading branch information
etiennesky committed Jun 25, 2012
1 parent 52d9f3a commit dce914d15f9eb7f004c33fcd3ff64524dd1e3635
Showing with 158 additions and 191 deletions.
  1. +21 −10 src/app/qgsdecorationgrid.cpp
  2. +7 −7 src/app/qgsdecorationgrid.h
  3. +25 −23 src/app/qgsdecorationgriddialog.cpp
  4. +105 −151 src/ui/qgsdecorationgriddialog.ui
@@ -28,6 +28,7 @@
#include "qgsproject.h"
#include "qgssymbollayerv2utils.h" //for pointOnLineWithDistance
#include "qgssymbolv2.h" //for symbology
#include "qgsmarkersymbollayerv2.h"
#include "qgsrendercontext.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
@@ -100,15 +101,16 @@ void QgsDecorationGrid::projectRead()
mMapUnits = ( QGis::UnitType ) QgsProject::instance()->readNumEntry( mNameConfig, "/MapUnits",
QGis::UnknownUnit );
mGridStyle = ( GridStyle ) QgsProject::instance()->readNumEntry( mNameConfig, "/Style",
QgsDecorationGrid::Solid );
QgsDecorationGrid::Line );
mGridIntervalX = QgsProject::instance()->readDoubleEntry( mNameConfig, "/IntervalX", 10 );
mGridIntervalY = QgsProject::instance()->readDoubleEntry( mNameConfig, "/IntervalY", 10 );
mGridOffsetX = QgsProject::instance()->readDoubleEntry( mNameConfig, "/OffsetX", 0 );
mGridOffsetY = QgsProject::instance()->readDoubleEntry( mNameConfig, "/OffsetY", 0 );
mCrossLength = QgsProject::instance()->readDoubleEntry( mNameConfig, "/CrossLength", 3 );
// mCrossLength = QgsProject::instance()->readDoubleEntry( mNameConfig, "/CrossLength", 3 );
mShowGridAnnotation = QgsProject::instance()->readBoolEntry( mNameConfig, "/ShowAnnotation", false );
mGridAnnotationPosition = ( GridAnnotationPosition ) QgsProject::instance()->readNumEntry( mNameConfig,
"/AnnotationPosition", 0 );
// mGridAnnotationPosition = ( GridAnnotationPosition ) QgsProject::instance()->readNumEntry( mNameConfig,
// "/AnnotationPosition", 0 );
mGridAnnotationPosition = InsideMapFrame; // don't allow outside frame, doesn't make sense
mGridAnnotationDirection = ( GridAnnotationDirection ) QgsProject::instance()->readNumEntry( mNameConfig,
"/AnnotationDirection", 0 );
QString fontStr = QgsProject::instance()->readEntry( mNameConfig, "/AnnotationFont", "" );
@@ -152,7 +154,14 @@ void QgsDecorationGrid::projectRead()
mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( QgsSymbolLayerV2Utils::loadSymbol( elem ) );
}
if ( ! mMarkerSymbol )
mMarkerSymbol = new QgsMarkerSymbolV2();
{
// set default symbol : cross with width=20
QgsSymbolLayerV2List symbolList;
symbolList << new QgsSimpleMarkerSymbolLayerV2( "cross", DEFAULT_SIMPLEMARKER_COLOR,
DEFAULT_SIMPLEMARKER_BORDERCOLOR, 20, 0 );
mMarkerSymbol = new QgsMarkerSymbolV2( symbolList );
// mMarkerSymbol = new QgsMarkerSymbolV2();
}
}

void QgsDecorationGrid::saveToProject()
@@ -165,10 +174,10 @@ void QgsDecorationGrid::saveToProject()
QgsProject::instance()->writeEntry( mNameConfig, "/IntervalY", mGridIntervalY );
QgsProject::instance()->writeEntry( mNameConfig, "/OffsetX", mGridOffsetX );
QgsProject::instance()->writeEntry( mNameConfig, "/OffsetX", mGridOffsetY );
QgsProject::instance()->writeEntry( mNameConfig, "/CrossLength", mCrossLength );
// QgsProject::instance()->writeEntry( mNameConfig, "/CrossLength", mCrossLength );
// missing mGridPen, but should use styles anyway
QgsProject::instance()->writeEntry( mNameConfig, "/ShowAnnotation", mShowGridAnnotation );
QgsProject::instance()->writeEntry( mNameConfig, "/AnnotationPosition", ( int ) mGridAnnotationPosition );
// QgsProject::instance()->writeEntry( mNameConfig, "/AnnotationPosition", ( int ) mGridAnnotationPosition );
QgsProject::instance()->writeEntry( mNameConfig, "/AnnotationDirection", ( int ) mGridAnnotationDirection );
QgsProject::instance()->writeEntry( mNameConfig, "/AnnotationFont", mGridAnnotationFont.toString() );
QgsProject::instance()->writeEntry( mNameConfig, "/AnnotationFrameDistance", mAnnotationFrameDistance );
@@ -184,7 +193,7 @@ void QgsDecorationGrid::saveToProject()
// FIXME this works, but XML will not be valid as < is replaced by &lt;
QgsProject::instance()->writeEntry( mNameConfig, "/LineSymbol", doc.toString() );
}
if ( mLineSymbol )
if ( mMarkerSymbol )
{
doc.setContent( QString( "" ) );
elem = QgsSymbolLayerV2Utils::saveSymbol( "marker symbol", mMarkerSymbol, doc );
@@ -223,7 +232,7 @@ void QgsDecorationGrid::render( QPainter * p )
// p->setClipRect( thisPaintRect );

//simpler approach: draw vertical lines first, then horizontal ones
if ( mGridStyle == QgsDecorationGrid::Solid )
if ( mGridStyle == QgsDecorationGrid::Line )
{
if ( ! mLineSymbol )
return;
@@ -252,6 +261,7 @@ void QgsDecorationGrid::render( QPainter * p )

mLineSymbol->stopRender( context );
}
#if 0
else if ( mGridStyle == QgsDecorationGrid::Cross )
{
QPointF intersectionPoint, crossEnd1, crossEnd2;
@@ -299,6 +309,7 @@ void QgsDecorationGrid::render( QPainter * p )
p->drawLine( hIt->second.p2(), crossEnd1 );
}
}
#endif
else //marker
{
if ( ! mMarkerSymbol )
@@ -308,7 +319,7 @@ void QgsDecorationGrid::render( QPainter * p )
context.setPainter( p );
mMarkerSymbol->startRender( context, 0 );

QPointF intersectionPoint, crossEnd1, crossEnd2;
QPointF intersectionPoint;
for ( ; vIt != verticalLines.constEnd(); ++vIt )
{
//test for intersection with every horizontal line
@@ -40,9 +40,9 @@ class QgsDecorationGrid: public QgsDecorationItem

enum GridStyle
{
Solid = 0, //solid lines
Cross = 1, //only draw line crossings
Marker = 2 //user-defined marker
Line = 0, //solid lines
// Cross = 1, //only draw line crossings
Marker = 1 //user-defined marker
};

enum GridAnnotationPosition
@@ -113,8 +113,8 @@ class QgsDecorationGrid: public QgsDecorationItem
GridAnnotationDirection gridAnnotationDirection() const {return mGridAnnotationDirection;}

/**Sets length of the cros segments (if grid style is cross) */
void setCrossLength( double l ) {mCrossLength = l;}
double crossLength() {return mCrossLength;}
/* void setCrossLength( double l ) {mCrossLength = l;} */
/* double crossLength() {return mCrossLength;} */

/**Set symbol that is used to draw grid lines. Takes ownership*/
void setLineSymbol( QgsLineSymbolV2* symbol );
@@ -164,7 +164,7 @@ class QgsDecorationGrid: public QgsDecorationItem
Top
};

/**Solid or crosses*/
/** Line or Symbol */
GridStyle mGridStyle;
/**Grid line interval in x-direction (map units)*/
double mGridIntervalX;
@@ -189,7 +189,7 @@ class QgsDecorationGrid: public QgsDecorationItem
/**Annotation can be horizontal / vertical or different for axes*/
GridAnnotationDirection mGridAnnotationDirection;
/**The length of the cross sides for mGridStyle Cross*/
double mCrossLength;
/* double mCrossLength; */

QgsLineSymbolV2* mLineSymbol;
QgsMarkerSymbolV2* mMarkerSymbol;
@@ -43,11 +43,11 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid& deco, QWidg

// mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) );

mGridTypeComboBox->insertItem( QgsDecorationGrid::Solid, tr( "Lines" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Cross, tr( "Cross" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Line, tr( "Line" ) );
// mGridTypeComboBox->insertItem( QgsDecorationGrid::Cross, tr( "Cross" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Marker, tr( "Marker" ) );

mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::InsideMapFrame, tr( "Inside frame" ) );
// mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::InsideMapFrame, tr( "Inside frame" ) );
// mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::OutsideMapFrame, tr( "Outside frame" ) );

mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal,
@@ -77,8 +77,8 @@ void QgsDecorationGridDialog::updateGuiElements()
mOffsetYSpinBox->setValue( mDeco.gridOffsetY() );

mGridTypeComboBox->setCurrentIndex(( int ) mDeco.gridStyle() );
mCrossWidthSpinBox->setValue( mDeco.crossLength() );
mAnnotationPositionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationPosition() );
// mCrossWidthSpinBox->setValue( mDeco.crossLength() );
// mAnnotationPositionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationPosition() );
mDrawAnnotationCheckBox->setChecked( mDeco.showGridAnnotation() );
mAnnotationDirectionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationDirection() );
mCoordinatePrecisionSpinBox->setValue( mDeco.gridAnnotationPrecision() );
@@ -118,28 +118,28 @@ void QgsDecorationGridDialog::updateDecoFromGui()
mDeco.setGridOffsetX( mOffsetXSpinBox->value() );
mDeco.setGridOffsetY( mOffsetYSpinBox->value() );
// mDeco.setGridPenWidth( mLineWidthSpinBox->value() );
if ( mGridTypeComboBox->currentText() == tr( "Cross" ) )
{
mDeco.setGridStyle( QgsDecorationGrid::Cross );
}
else if ( mGridTypeComboBox->currentText() == tr( "Marker" ) )
// if ( mGridTypeComboBox->currentText() == tr( "Cross" ) )
// {
// mDeco.setGridStyle( QgsDecorationGrid::Cross );
// }
if ( mGridTypeComboBox->currentText() == tr( "Marker" ) )
{
mDeco.setGridStyle( QgsDecorationGrid::Marker );
}
else
else if ( mGridTypeComboBox->currentText() == tr( "Line" ) )
{
mDeco.setGridStyle( QgsDecorationGrid::Solid );
mDeco.setGridStyle( QgsDecorationGrid::Line );
}
mDeco.setCrossLength( mCrossWidthSpinBox->value() );
// mDeco.setCrossLength( mCrossWidthSpinBox->value() );
mDeco.setAnnotationFrameDistance( mDistanceToMapFrameSpinBox->value() );
if ( mAnnotationPositionComboBox->currentText() == tr( "Inside frame" ) )
{
mDeco.setGridAnnotationPosition( QgsDecorationGrid::InsideMapFrame );
}
else
{
mDeco.setGridAnnotationPosition( QgsDecorationGrid::OutsideMapFrame );
}
// if ( mAnnotationPositionComboBox->currentText() == tr( "Inside frame" ) )
// {
// mDeco.setGridAnnotationPosition( QgsDecorationGrid::InsideMapFrame );
// }
// else
// {
// mDeco.setGridAnnotationPosition( QgsDecorationGrid::OutsideMapFrame );
// }
mDeco.setShowGridAnnotation( mDrawAnnotationCheckBox->isChecked() );
QString text = mAnnotationDirectionComboBox->currentText();
if ( text == tr( "Horizontal" ) )
@@ -218,8 +218,8 @@ void QgsDecorationGridDialog::on_buttonBox_rejected()

void QgsDecorationGridDialog::on_mGridTypeComboBox_currentIndexChanged( int index )
{
mLineSymbolButton->setEnabled( index == QgsDecorationGrid::Solid );
mCrossWidthSpinBox->setEnabled( index == QgsDecorationGrid::Cross );
mLineSymbolButton->setEnabled( index == QgsDecorationGrid::Line );
// mCrossWidthSpinBox->setEnabled( index == QgsDecorationGrid::Cross );
mMarkerSymbolButton->setEnabled( index == QgsDecorationGrid::Marker );
}

@@ -231,6 +231,7 @@ void QgsDecorationGridDialog::on_mLineSymbolButton_clicked()

QgsLineSymbolV2* lineSymbol = dynamic_cast<QgsLineSymbolV2*>( mLineSymbol->clone() );
QgsSymbolV2PropertiesDialog dlg( lineSymbol, 0, this );
// QgsSymbolV2SelectorDialog dlg( lineSymbol, 0, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete lineSymbol;
@@ -254,6 +255,7 @@ void QgsDecorationGridDialog::on_mMarkerSymbolButton_clicked()

QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mMarkerSymbol->clone() );
QgsSymbolV2PropertiesDialog dlg( markerSymbol, 0, this );
// QgsSymbolV2SelectorDialog dlg( markerSymbol, 0, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete markerSymbol;

0 comments on commit dce914d

Please sign in to comment.
You can’t perform that action at this time.