Skip to content
Permalink
Browse files

UI tweaks + selectively enable line/cross width/marker picker

  • Loading branch information
etiennesky committed Jun 24, 2012
1 parent 46242e1 commit 498575e9235e8d2bc3ea02e324b766fc2587c897
Showing with 282 additions and 229 deletions.
  1. +10 −18 src/app/qgsdecorationgrid.h
  2. +40 −64 src/app/qgsdecorationgriddialog.cpp
  3. +2 −1 src/app/qgsdecorationgriddialog.h
  4. +230 −146 src/ui/qgsdecorationgriddialog.ui
@@ -58,40 +58,33 @@ class QgsDecorationGrid: public QgsDecorationItem
BoundaryDirection
};

/**Sets coordinate grid style to solid or cross
@note this function was added in version 1.4*/
/**Sets coordinate grid style.
@note this function (and all others) was added in version 2.0 */
void setGridStyle( GridStyle style ) {mGridStyle = style;}
GridStyle gridStyle() const { return mGridStyle; }

/**Sets coordinate interval in x-direction for composergrid.
@note this function was added in version 1.4*/
/**Sets coordinate interval in x-direction for composergrid. */
void setGridIntervalX( double interval ) { mGridIntervalX = interval;}
double gridIntervalX() const { return mGridIntervalX; }

/**Sets coordinate interval in y-direction for composergrid.
@note this function was added in version 1.4*/
/**Sets coordinate interval in y-direction for composergrid. */
void setGridIntervalY( double interval ) { mGridIntervalY = interval;}
double gridIntervalY() const { return mGridIntervalY; }

/**Sets x-coordinate offset for composer grid
@note this function was added in version 1.4*/
/**Sets x-coordinate offset for composer grid */
void setGridOffsetX( double offset ) { mGridOffsetX = offset; }
double gridOffsetX() const { return mGridOffsetX; }

/**Sets y-coordinate offset for composer grid
@note this function was added in version 1.4*/
/**Sets y-coordinate offset for composer grid */
void setGridOffsetY( double offset ) { mGridOffsetY = offset; }
double gridOffsetY() const { return mGridOffsetY; }

/**Sets the pen to draw composer grid
@note this function was added in version 1.4*/
/**Sets the pen to draw composer grid */
void setGridPen( const QPen& p ) { mGridPen = p; }
QPen gridPen() const { return mGridPen; }
/**Sets with of grid pen
@note this function was added in version 1.4*/
/**Sets with of grid pen */
void setGridPenWidth( double w ) { mGridPen.setWidthF( w ); }
/**Sets the color of the grid pen
@note this function was added in version 1.4*/
/**Sets the color of the grid pen */
void setGridPenColor( const QColor& c ) { mGridPen.setColor( c ); }

/**Sets font for grid annotations
@@ -217,8 +210,7 @@ class QgsDecorationGrid: public QgsDecorationItem
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignement = Qt::AlignLeft, Qt::AlignmentFlag valignement = Qt::AlignTop ) const;
/**Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double textWidthMillimeters( const QFont& font, const QString& text ) const;
/**Returns the font height of a character in millimeters
@note this method was added in version 1.7*/
/**Returns the font height of a character in millimeters. */
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const;
/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMillimeters( const QFont& font ) const;
@@ -31,28 +31,32 @@
#include <QSettings>

QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid& deco, QWidget* parent )
: QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
: QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );
// restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );

chkEnable->setChecked( mDeco.enabled() );

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

mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );
mGridTypeComboBox->insertItem( 2, tr( "Marker" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Solid, tr( "Lines" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Cross, tr( "Cross" ) );
mGridTypeComboBox->insertItem( QgsDecorationGrid::Marker, tr( "Marker" ) );

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

mAnnotationDirectionComboBox->insertItem( 0, tr( "Horizontal" ) );
mAnnotationDirectionComboBox->insertItem( 1, tr( "Vertical" ) );
mAnnotationDirectionComboBox->insertItem( 2, tr( "Horizontal and Vertical" ) );
mAnnotationDirectionComboBox->insertItem( 2, tr( "Boundary direction" ) );
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal,
tr( "Horizontal" ) );
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical,
tr( "Vertical" ) );
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical,
tr( "Horizontal and Vertical" ) );
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection,
tr( "Boundary direction" ) );

updateGuiElements();

@@ -71,52 +75,16 @@ void QgsDecorationGridDialog::updateGuiElements()
mOffsetXSpinBox->setValue( mDeco.gridOffsetX() );
mOffsetYSpinBox->setValue( mDeco.gridOffsetY() );

QgsDecorationGrid::GridStyle gridStyle = mDeco.gridStyle();
if ( gridStyle == QgsDecorationGrid::Cross )
{
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Cross" ) ) );
}
else if ( gridStyle == QgsDecorationGrid::Marker )
{
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Marker" ) ) );
}
else
{
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Solid" ) ) );
}

mGridTypeComboBox->setCurrentIndex(( int ) mDeco.gridStyle() );

mCrossWidthSpinBox->setValue( mDeco.crossLength() );

QgsDecorationGrid::GridAnnotationPosition annotationPos = mDeco.gridAnnotationPosition();
if ( annotationPos == QgsDecorationGrid::InsideMapFrame )
{
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Inside frame" ) ) );
}
else
{
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Outside frame" ) ) );
}

mAnnotationPositionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationPosition() );

mDrawAnnotationCheckBox->setChecked( mDeco.showGridAnnotation() );

QgsDecorationGrid::GridAnnotationDirection dir = mDeco.gridAnnotationDirection();
if ( dir == QgsDecorationGrid::Horizontal )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal" ) ) );
}
else if ( dir == QgsDecorationGrid::Vertical )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Vertical" ) ) );
}
else if ( dir == QgsDecorationGrid::HorizontalAndVertical )
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal and Vertical" ) ) );
}
else //BoundaryDirection
{
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Boundary direction" ) ) );
}


mAnnotationDirectionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationDirection() );

mCoordinatePrecisionSpinBox->setValue( mDeco.gridAnnotationPrecision() );

// QPen gridPen = mDeco.gridPen();
@@ -140,7 +108,7 @@ void QgsDecorationGridDialog::updateGuiElements()
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol, mMarkerSymbolButton->iconSize() );
mMarkerSymbolButton->setIcon( icon );
}

// blockAllSignals( false );
}

@@ -196,12 +164,12 @@ void QgsDecorationGridDialog::updateDecoFromGui()
mDeco.setGridAnnotationPrecision( mCoordinatePrecisionSpinBox->value() );
if ( mLineSymbol )
{
mDeco.setLineSymbol( mLineSymbol );
mDeco.setLineSymbol( mLineSymbol );
mLineSymbol = dynamic_cast<QgsLineSymbolV2*>( mDeco.lineSymbol()->clone() );
}
if ( mMarkerSymbol )
{
mDeco.setMarkerSymbol( mMarkerSymbol );
mDeco.setMarkerSymbol( mMarkerSymbol );
mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mDeco.markerSymbol()->clone() );
}
}
@@ -232,7 +200,7 @@ void QgsDecorationGridDialog::apply()
{
updateDecoFromGui();
mDeco.update();
//accept();
//accept();
}

void QgsDecorationGridDialog::on_buttonBox_rejected()
@@ -243,14 +211,22 @@ void QgsDecorationGridDialog::on_buttonBox_rejected()

// void QgsDecorationGridDialog::on_mLineColorButton_clicked()
// {
// QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
// if ( newColor.isValid() )
// {
// mLineColorButton->setColor( newColor );
// mDeco.setGridPenColor( newColor );
// }
// QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
// if ( newColor.isValid() )
// {
// mLineColorButton->setColor( newColor );
// mDeco.setGridPenColor( newColor );
// }
// }

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


void QgsDecorationGridDialog::on_mLineSymbolButton_clicked()
{
if ( ! mLineSymbol )
@@ -41,6 +41,7 @@ class QgsDecorationGridDialog : public QDialog, private Ui::QgsDecorationGridDia
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void on_mGridTypeComboBox_currentIndexChanged( int index );
void on_mLineSymbolButton_clicked();
void on_mMarkerSymbolButton_clicked();

@@ -49,7 +50,7 @@ class QgsDecorationGridDialog : public QDialog, private Ui::QgsDecorationGridDia
void on_mAnnotationFontButton_clicked();

private:
QgsDecorationGrid& mDeco;
QgsDecorationGrid& mDeco;
QgsLineSymbolV2* mLineSymbol;
QgsMarkerSymbolV2* mMarkerSymbol;

0 comments on commit 498575e

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