DXF export improvements:

* tree view and attribute selection for layer assigment in dialog
* support fill polygons/HATCH
* represent texts as MTEXT instead of TEXT (including font, slant and weight)
* support for RGB colors when there's no exact color match
* use AutoCAD 2000 DXF (R15) instead of R12
* remove R18 test methods

Funded-By: City of Uster
Funded-By: Ville de Morges
Funded-By: SIGE
This commit is contained in:
Juergen E. Fischer 2014-09-08 15:24:33 +02:00
parent e47642bdf6
commit 67e077853e
34 changed files with 3753 additions and 1242 deletions

View File

@ -1355,6 +1355,66 @@ template<double, TYPE2>
%End
};
%MappedType QList < QPair< QgsVectorLayer *, int > >
{
%TypeHeaderCode
#include <QPair>
#include <QList>
%End
%ConvertFromTypeCode
//convert map to a python dictionary
PyObject *d;
if ((d = PyList_New( sipCpp->size() )) == NULL)
return NULL;
for ( int i = 0; i<sipCpp->size(); i++ )
{
PyObject *p;
if ((p = PyList_New(2) ) == NULL)
{
Py_DECREF(d);
return NULL;
}
PyObject *t1obj = sipConvertFromNewType(sipCpp->at(i).first, sipType_QgsVectorLayer, sipTransferObj);
PyObject *t2obj = PyInt_FromLong( (long) sipCpp->at(i).second );
PyList_SetItem( p, 0, t1obj );
PyList_SetItem( p, 1, t2obj );
PyList_SetItem( d, i, p );
}
return d;
%End
%ConvertToTypeCode
#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t i = 0;
#else
int i = 0;
#endif
QList < QPair< QgsVectorLayer *, int > > *qm = new QList< QPair< QgsVectorLayer *, int > >;
for ( i = 0; i < PyList_GET_SIZE(sipPy); i++ )
{
int state;
PyObject *sipPair = PyList_GetItem( sipPy, i );
PyObject *sipLayer = PyList_GetItem( sipPair, 0 );
PyObject *sipIdx = PyList_GetItem( sipPair, 1 );
QgsVectorLayer *t1 = reinterpret_cast<QgsVectorLayer *>(sipConvertToType(sipLayer, sipType_QgsVectorLayer, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
int idx = PyLong_AsLongLong(sipIdx);
qm->append( qMakePair<QgsVectorLayer *, int>( t1, idx ) );
sipReleaseType(t1, sipType_QgsVectorLayer, state);
}
*sipCppPtr = qm;
return sipGetState(sipTransferObj);
%End
};
template <TYPE>

View File

@ -31,8 +31,8 @@ class QgsDxfExport
QgsDxfExport();
~QgsDxfExport();
void addLayers( QList< QgsMapLayer* >& layers );
int writeToFile( QIODevice* d );
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
int writeToFile( QIODevice* d ); //maybe add progress dialog? //other parameters (e.g. scale, dpi)?
void setSymbologyScaleDenominator( double d );
double symbologyScaleDenominator() const;
@ -49,6 +49,8 @@ class QgsDxfExport
//get closest entry in dxf palette
static int closestColorMatch( QRgb pixel );
QString layerName( const QString &id, const QgsFeature &f ) const;
//! @note available in python bindings as writeGroupInt
void writeGroup( int code, int i ) /PyName=writeGroupInt/;
//! @note available in python bindings as writeGroupDouble
@ -58,21 +60,29 @@ class QgsDxfExport
void writeInt( int i );
void writeDouble( double d );
void writeString( const QString& s );
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false ) /PyName=writeGroupPoint/;
void writeGroup( QColor color, int exactMatch = 62, int rgb = 420 );
int writeHandle( int code = 5, int handle = 0 );
//draw dxf primitives
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, int color,
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
double width = -1, bool polygon = false );
void writeSolid( const QString& layer, int color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );
void writeSolid( const QString& layer, QColor color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
//write line (as a polyline)
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, int color, double width = -1 );
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, QColor color, double width = -1 );
void writePoint( const QString& layer, int color, const QgsPoint& pt );
void writePoint( const QString& layer, QColor color, const QgsPoint& pt );
void writeCircle( const QString& layer, int color, const QgsPoint& pt, double radius );
void writeCircle( const QString& layer, QColor color, const QgsPoint& pt, double radius );
void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, int color );
void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, QColor color );
void writeMText( const QString& layer, const QString& text, const QgsPoint& pt, double width, double angle, QColor color );
static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits );

View File

@ -95,7 +95,7 @@ class QgsLayerTreeModel : QAbstractItemModel
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes( QgsLayerTreeLayer* nodeLayer );
//! Return pointer to the root node of the layer tree. Always a non-null pointer.
QgsLayerTreeGroup* rootGroup();
QgsLayerTreeGroup* rootGroup() const;
//! Reset the model and use a new root group node
//! @note added in 2.6
void setRootGroup( QgsLayerTreeGroup* newRootGroup );

View File

@ -57,7 +57,7 @@ class QgsLabelingEngineInterface
//! adds a diagram layer to the labeling engine
virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings* s );
//! called for every feature
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0;
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null ) = 0;
//! called for every diagram feature
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
//! called when the map is drawn and labels should be placed

View File

@ -449,7 +449,7 @@ class QgsPalLayerSettings
void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 );
// implementation of register feature hook
void registerFeature( QgsFeature& f, const QgsRenderContext& context );
void registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer );
void readFromLayer( QgsVectorLayer* layer );
void writeToLayer( QgsVectorLayer* layer );
@ -696,7 +696,7 @@ class QgsPalLabeling : QgsLabelingEngineInterface
//! adds a diagram layer to the labeling engine
virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s );
//! hook called when drawing for every feature in a layer
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null );
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
//! called when the map is drawn and labels should be placed
virtual void drawLabeling( QgsRenderContext& context );

View File

@ -4013,8 +4013,7 @@ void QgisApp::dxfExport()
if ( d.exec() == QDialog::Accepted )
{
QgsDxfExport dxfExport;
QList<QgsMapLayer*> layerList = d.layers();
dxfExport.addLayers( layerList );
dxfExport.addLayers( d.layers() );
dxfExport.setSymbologyScaleDenominator( d.symbologyScale() );
dxfExport.setSymbologyExport( d.symbologyMode() );
if ( mapCanvas() )

View File

@ -17,22 +17,205 @@
#include "qgsdxfexportdialog.h"
#include "qgsmaplayer.h"
#include "qgsmaplayermodel.h"
#include "qgsmaplayerregistry.h"
#include "qgslayertree.h"
#include "qgslayertreegroup.h"
#include "qgsvectorlayer.h"
#include "qgsproject.h"
#include "qgis.h"
#include "qgsfieldcombobox.h"
#include <QFileDialog>
#include <QPushButton>
#include <QSettings>
#if 0
FieldSelectorDelegate::FieldSelectorDelegate( QObject *parent ) : QItemDelegate( parent )
{
}
QWidget *FieldSelectorDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
QgsDebugCall;
Q_UNUSED( option );
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return 0;
QgsFieldComboBox *w = new QgsFieldComboBox( parent );
w->setLayer( vl );
return w;
}
void FieldSelectorDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const
{
QgsDebugCall;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return;
const QgsVectorLayerAndAttributeModel *model = dynamic_cast< const QgsVectorLayerAndAttributeModel *>( index.model() );
if( !model )
return;
QgsFieldComboBox *fcb = qobject_cast<QgsFieldComboBox *>( editor );
if( !fcb )
return;
int idx = model->mAttributeIdx.value( vl, -1 );
if( vl->pendingFields().exists( idx ) )
fcb->setField( vl->pendingFields()[ idx ].name() );
}
void FieldSelectorDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
{
QgsDebugCall;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return;
QgsFieldComboBox *fcb = qobject_cast<QgsFieldComboBox *>( editor );
if( !fcb )
return;
model->setData( index, vl->fieldNameIndex( fcb->currentField() ) );
}
#endif
QgsVectorLayerAndAttributeModel::QgsVectorLayerAndAttributeModel( QgsLayerTreeGroup* rootNode, QObject *parent )
: QgsLayerTreeModel( rootNode, parent )
{
}
QgsVectorLayerAndAttributeModel::~QgsVectorLayerAndAttributeModel()
{
}
QModelIndex QgsVectorLayerAndAttributeModel::index( int row, int column, const QModelIndex &parent ) const
{
QgsLayerTreeNode *n = index2node( parent );
if( !QgsLayerTree::isLayer( n ) )
return QgsLayerTreeModel::index( row, column, parent );
if( row != 0 || column != 0 )
return QModelIndex();
return createIndex( 0, 0, QgsLayerTree::toLayer( n )->layer() );
}
QModelIndex QgsVectorLayerAndAttributeModel::parent( const QModelIndex &child ) const
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( child.internalPointer() ) );
if( !vl )
return QgsLayerTreeModel::parent( child );
QgsLayerTreeLayer *layer = rootGroup()->findLayer( vl->id() );
Q_ASSERT( layer );
QgsLayerTreeNode *parent = layer->parent();
if ( !parent )
return QModelIndex();
int row = parent->children().indexOf( layer );
Q_ASSERT( row >= 0 );
return createIndex( row, 0, layer );
}
int QgsVectorLayerAndAttributeModel::rowCount( const QModelIndex &index ) const
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( vl )
return 0;
QgsLayerTreeNode *n = index2node( index );
if( QgsLayerTree::isLayer( n ) )
return 1;
return QgsLayerTreeModel::rowCount( index );
}
Qt::ItemFlags QgsVectorLayerAndAttributeModel::flags( const QModelIndex &index ) const
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return QgsLayerTreeModel::flags( index );
return Qt::ItemIsEnabled /* | Qt::ItemIsEditable */;
}
QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex& index, int role ) const
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return QgsLayerTreeModel::data( index, role );
int idx = mAttributeIdx.value( vl, -1 );
if( role == Qt::EditRole )
return idx;
if( role != Qt::DisplayRole )
return QVariant();
if( vl->pendingFields().exists( idx ) )
return vl->pendingFields()[ idx ].name();
return vl->name();
}
bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
if( role != Qt::EditRole )
return false;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( index.internalPointer() ) );
if( !vl )
return QgsLayerTreeModel::setData( index, value, role );
mAttributeIdx[ vl ] = value.toInt();
return true;
}
QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers( const QModelIndexList &selectedIndexes ) const
{
QList< QPair<QgsVectorLayer *, int> > layers;
foreach( const QModelIndex &idx, selectedIndexes )
{
QgsLayerTreeNode *node = index2node( idx );
if( QgsLayerTree::isGroup( node ) )
{
foreach( QgsLayerTreeLayer *treeLayer, QgsLayerTree::toGroup( node )->findLayers() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( treeLayer->layer() );
Q_ASSERT( vl );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
}
}
else if( QgsLayerTree::isLayer( node ) )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() );
Q_ASSERT( vl );
layers << qMakePair<QgsVectorLayer *, int>( vl,mAttributeIdx.value( vl, -1 ) );
}
}
return layers;
}
QgsDxfExportDialog::QgsDxfExportDialog( QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
{
setupUi( this );
mModel = new QgsMapLayerProxyModel( this );
mModel->sourceLayerModel()->setItemsCheckable( true );
mModel->setFilters( QgsMapLayerProxyModel::HasGeometry );
mLayersListView->setModel( mModel );
mLayerTreeGroup = QgsLayerTree::toGroup( QgsProject::instance()->layerTreeRoot()->clone() );
cleanGroup( mLayerTreeGroup );
QgsLayerTreeModel *model = new QgsVectorLayerAndAttributeModel( mLayerTreeGroup, this );
model->setFlags( 0 );
mTreeView->setModel( model );
connect( mFileLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( setOkEnabled() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( saveSettings() ) );
@ -46,26 +229,88 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget* parent, Qt::WindowFlags f ): QD
mSymbologyScaleLineEdit->setText( s.value( "qgis/lastSymbologyExportScale", "50000" ).toString() );
mMapExtentCheckBox->setChecked( s.value( "qgis/lastDxfMapRectangle", "false" ).toBool() );
#if 0
mFieldSelectorDelegate = new FieldSelectorDelegate( this );
mTreeView->setItemDelegateForColumn( 0, mFieldSelectorDelegate );
#endif
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
}
QgsDxfExportDialog::~QgsDxfExportDialog()
{
delete mLayerTreeGroup;
#if 0
delete mFieldSelectorDelegate;
#endif
}
void QgsDxfExportDialog::on_mTreeView_clicked( const QModelIndex & current )
{
QgsDebugCall;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( reinterpret_cast<QObject*>( current.internalPointer() ) );
if( !vl )
{
QgsDebugMsg( "No vector layer" );
mLayerAttributeComboBox->setDisabled( true );
return;
}
mLayerAttributeComboBox->setEnabled( true );
int idx = mTreeView->model()->data( current, Qt::EditRole ).toInt();
mLayerAttributeComboBox->setLayer( vl );
if( vl->pendingFields().exists( idx ) )
mLayerAttributeComboBox->setField( vl->pendingFields()[ idx ].name() );
}
void QgsDxfExportDialog::on_mLayerAttributeComboBox_fieldChanged( QString fieldName )
{
QgsDebugCall;
mTreeView->model()->setData( mTreeView->currentIndex(), mLayerAttributeComboBox->layer()->fieldNameIndex( fieldName ) );
}
void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node )
{
QgsLayerTreeGroup *group = QgsLayerTree::toGroup( node );
if( !group )
return;
QList<QgsLayerTreeNode *> toRemove;
foreach( QgsLayerTreeNode *child, node->children() )
{
if( QgsLayerTree::isLayer( child ) && QgsLayerTree::toLayer( child )->layer()->type() != QgsMapLayer::VectorLayer )
{
toRemove << child;
continue;
}
cleanGroup( child );
if( QgsLayerTree::isGroup( child ) && child->children().isEmpty() )
toRemove << child;
}
foreach( QgsLayerTreeNode *child, toRemove )
group->removeChildNode( child );
}
void QgsDxfExportDialog::selectAll()
{
mModel->sourceLayerModel()->checkAll( Qt::Checked );
mTreeView->selectAll();
}
void QgsDxfExportDialog::unSelectAll()
{
mModel->sourceLayerModel()->checkAll( Qt::Unchecked );
mTreeView->clearSelection();
}
QList<QgsMapLayer*> QgsDxfExportDialog::layers() const
QList< QPair<QgsVectorLayer *, int> > QgsDxfExportDialog::layers() const
{
return mModel->sourceLayerModel()->layersChecked();
const QgsVectorLayerAndAttributeModel *model = dynamic_cast< const QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
Q_ASSERT( model );
return model->layers( mTreeView->selectionModel()->selectedIndexes() );
}
double QgsDxfExportDialog::symbologyScale() const
@ -103,6 +348,14 @@ void QgsDxfExportDialog::on_mFileSelectionButton_clicked()
void QgsDxfExportDialog::setOkEnabled()
{
QModelIndex idx = mTreeView->currentIndex();
QgsDebugMsg( QString( "current index:%1" ).arg( idx.isValid() ) );
while( idx.isValid() )
{
QgsDebugMsg( QString( " row=%1 column=%2" ).arg( idx.row() ).arg( idx.column() ) );
idx = idx.parent();
}
QPushButton* btn = buttonBox->button( QDialogButtonBox::Ok );
QString filePath = mFileLineEdit->text();

View File

@ -20,16 +20,62 @@
#include "ui_qgsdxfexportdialogbase.h"
#include "qgsdxfexport.h"
#include "qgsmaplayerproxymodel.h"
#include "qgslayertreemodel.h"
class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
#include <QList>
#include <QPair>
class QgsLayerTreeGroup;
class QgsLayerTreeNode;
#if 0
#include <QItemDelegate>
class FieldSelectorDelegate : public QItemDelegate
{
Q_OBJECT
public:
FieldSelectorDelegate( QObject *parent = 0 );
QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const;
void setEditorData( QWidget *editor, const QModelIndex &index ) const;
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const;
};
#endif
class QgsVectorLayerAndAttributeModel : public QgsLayerTreeModel
{
Q_OBJECT
public:
QgsVectorLayerAndAttributeModel( QgsLayerTreeGroup* rootNode, QObject *parent = 0 );
~QgsVectorLayerAndAttributeModel();
QModelIndex index( int row, int column, const QModelIndex &parent ) const;
QModelIndex parent( const QModelIndex &child ) const;
int rowCount( const QModelIndex &index ) const;
Qt::ItemFlags flags( const QModelIndex &index ) const;
QVariant data( const QModelIndex& index, int role ) const;
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
QList< QPair<QgsVectorLayer *, int> > layers( const QModelIndexList &selectedIndexes ) const;
private:
QHash<QgsVectorLayer *, int> mAttributeIdx;
#if 0
friend FieldSelectorDelegate;
#endif
};
class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
{
Q_OBJECT
public:
QgsDxfExportDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsDxfExportDialog();
QList<QgsMapLayer *> layers() const;
QList< QPair<QgsVectorLayer *, int> > layers() const;
double symbologyScale() const;
QgsDxfExport::SymbologyExport symbologyMode() const;
QString saveFile() const;
@ -40,13 +86,20 @@ class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
void selectAll();
void unSelectAll();
void on_mTreeView_clicked( const QModelIndex & current );
void on_mLayerAttributeComboBox_fieldChanged( QString );
private slots:
void on_mFileSelectionButton_clicked();
void setOkEnabled();
void saveSettings();
private:
QgsMapLayerProxyModel* mModel;
void cleanGroup( QgsLayerTreeNode *node );
QgsLayerTreeGroup *mLayerTreeGroup;
#if 0
FieldSelectorDelegate *mFieldSelectorDelegate;
#endif
};
#endif // QGSDXFEXPORTDIALOG_H

View File

@ -27,9 +27,10 @@
#include <QMessageBox>
#include <QSettings>
QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget * parent, const QString& projectFile, Qt::WindowFlags f ): QDialog( parent, f ),
mShowEmbeddedContent( false )
, mRootGroup( new QgsLayerTreeGroup )
QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget * parent, const QString& projectFile, Qt::WindowFlags f )
: QDialog( parent, f )
, mShowEmbeddedContent( false )
, mRootGroup( new QgsLayerTreeGroup )
{
setupUi( this );

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@ class CORE_EXPORT QgsDxfExport
~QgsDxfExport();
QgsDxfExport& operator=( const QgsDxfExport& dxfExport );
void addLayers( QList< QgsMapLayer* >& layers ) { mLayers = layers; }
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
int writeToFile( QIODevice* d ); //maybe add progress dialog? //other parameters (e.g. scale, dpi)?
void setSymbologyScaleDenominator( double d ) { mSymbologyScaleDenominator = d; }
@ -62,6 +62,8 @@ class CORE_EXPORT QgsDxfExport
//get closest entry in dxf palette
static int closestColorMatch( QRgb pixel );
QString layerName( const QString &id, const QgsFeature &f ) const;
//! @note available in python bindings as writeGroupInt
void writeGroup( int code, int i );
//! @note available in python bindings as writeGroupDouble
@ -71,30 +73,37 @@ class CORE_EXPORT QgsDxfExport
void writeInt( int i );
void writeDouble( double d );
void writeString( const QString& s );
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false );
void writeGroup( QColor color, int exactMatch = 62, int rgb = 420 );
int writeHandle( int code = 5, int handle = 0 );
//draw dxf primitives
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, int color,
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
double width = -1, bool polygon = false );
void writeSolid( const QString& layer, int color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );
void writeSolid( const QString& layer, QColor color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
//write line (as a polyline)
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, int color, double width = -1 );
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, QColor color, double width = -1 );
void writePoint( const QString& layer, int color, const QgsPoint& pt );
void writePoint( const QString& layer, QColor color, const QgsPoint& pt );
void writeCircle( const QString& layer, int color, const QgsPoint& pt, double radius );
void writeCircle( const QString& layer, QColor color, const QgsPoint& pt, double radius );
void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, int color );
void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, QColor color );
void writeMText( const QString& layer, const QString& text, const QgsPoint& pt, double width, double angle, QColor color );
static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits );
static QString dxfLayerName( const QString& name );
private:
QList< QPair<QgsVectorLayer*, int> > mLayers;
QList< QgsMapLayer* > mLayers;
/**Extent for export, only intersecting features are exported. If the extent is an empty rectangle, all features are exported*/
QgsRectangle mExtent;
/**Scale for symbology export (used if symbols units are mm)*/
@ -104,7 +113,7 @@ class CORE_EXPORT QgsDxfExport
QTextStream mTextStream;
static double mDxfColors[][3];
static int mDxfColors[][3];
int mSymbolLayerCounter; //internal counter
int mNextHandleId;
@ -124,30 +133,31 @@ class CORE_EXPORT QgsDxfExport
void startSection();
void endSection();
void writePoint( const QgsPoint& pt, const QString& layer, int color, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol );
void writePoint( const QgsPoint& pt, const QString& layer, QColor color, const QgsFeature* f, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol );
void writeVertex( const QgsPoint& pt, const QString& layer );
void writeDefaultLinestyles();
void writeSymbolLayerLinestyle( const QgsSymbolLayerV2* symbolLayer );
void writeLinestyle( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u );
void writeDefaultLinetypes();
void writeSymbolLayerLinetype( const QgsSymbolLayerV2* symbolLayer );
void writeLinetype( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u );
#if 0
//AC1018
void writeHeaderAC1018( QTextStream& stream );
void writeTablesAC1018( QTextStream& stream );
void writeEntitiesAC1018( QTextStream& stream );
void writeEntitiesSymbolLevelsAC1018( QTextStream& stream, QgsVectorLayer* layer );
void writeSymbolLayerLinestyleAC1018( QTextStream& stream, const QgsSymbolLayerV2* symbolLayer );
void writeLinestyleAC1018( QTextStream& stream, const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u );
void writeSymbolLayerLinetypeAC1018( QTextStream& stream, const QgsSymbolLayerV2* symbolLayer );
void writeLinetypeAC1018( QTextStream& stream, const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u );
void writeVertexAC1018( QTextStream& stream, const QgsPoint& pt );
void writePolylineAC1018( QTextStream& stream, const QgsPolyline& line, const QString& layer, const QString& lineStyleName, int color,
void writePolylineAC1018( QTextStream& stream, const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
double width = -1, bool polygon = false );
#endif
QgsRectangle dxfExtent() const;
void addFeature( const QgsSymbolV2RenderContext& ctx, const QString& layer, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol );
//returns dxf palette index from symbol layer color
static int colorFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2RenderContext& ctx );
static QColor colorFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2RenderContext& ctx );
QString lineStyleFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer );
//functions for dxf palette
@ -166,6 +176,8 @@ class CORE_EXPORT QgsDxfExport
double sizeToMapUnits( double s ) const;
static QString lineNameFromPenStyle( Qt::PenStyle style );
bool layerIsScaleBasedVisible( const QgsMapLayer* layer ) const;
int mModelSpaceBR;
};
#endif // QGSDXFEXPORT_H

View File

@ -221,11 +221,11 @@ QgsPoint QgsDxfPaintEngine::toDxfCoordinates( const QPointF& pt ) const
return QgsPoint( dxfPt.x(), dxfPt.y() );
}
int QgsDxfPaintEngine::currentColor() const
QColor QgsDxfPaintEngine::currentColor() const
{
if ( !mDxf )
{
return 0;
return QColor();
}
QColor c = mPen.color();
@ -233,7 +233,7 @@ int QgsDxfPaintEngine::currentColor() const
{
c = mBrush.color();
}
return mDxf->closestColorMatch( c.rgb() );
return c;
}
double QgsDxfPaintEngine::currentWidth() const

View File

@ -61,7 +61,7 @@ class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
QList<QPointF> mCurrentCurve;
QgsPoint toDxfCoordinates( const QPointF& pt ) const;
int currentColor() const;
QColor currentColor() const;
double currentWidth() const;
void moveTo( double dx, double dy );

View File

@ -17,7 +17,6 @@
#include "qgsdxfpallabeling.h"
#include "qgsdxfexport.h"
#include "qgsmaplayerregistry.h"
#include "qgspalgeometry.h"
#include "qgsmapsettings.h"
@ -75,44 +74,31 @@ void QgsDxfPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext&
//debug: print label infos
if ( mDxfExport )
{
//label text
QString text = (( QgsPalGeometry* )label->getFeaturePart()->getUserGeometry() )->text();
QgsPalGeometry *g = dynamic_cast< QgsPalGeometry* >( label->getFeaturePart()->getUserGeometry() );
//layer name
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( QString( label->getLayerName() ) );
if ( !layer )
{
return;
}
QString layerName = mDxfExport->dxfLayerName( layer->name() );
//label text
QString text = g->text();
//angle
double angle = label->getAlpha() * 180 / M_PI;
//debug: show label rectangle
/*QgsPolyline line;
for( int i = 0; i < 4; ++i )
#if 0
QgsPolyline line;
for ( int i = 0; i < 4; ++i )
{
line.append( QgsPoint( label->getX( i ), label->getY( i ) ) );
line.append( QgsPoint( label->getX( i ), label->getY( i ) ) );
}
mDxfExport->writePolyline( line, layerName, "CONTINUOUS", 1, 0.01, true );*/
mDxfExport->writePolyline( line, mLayerName, "CONTINUOUS", 1, 0.01, true );
#endif
text = text.replace( tmpLyr.wrapChar.isEmpty() ? "\n" : tmpLyr.wrapChar, "\\P" );
QStringList textList;
if ( !tmpLyr.wrapChar.isEmpty() )
{
textList = text.split( tmpLyr.wrapChar );
}
else
{
textList = text.split( "\n" );
}
double textHeight = label->getHeight() / textList.size();
QFontMetricsF fm( tmpLyr.textFont );
double textAscent = textHeight * fm.ascent() / fm.height();
text.prepend( QString( "\\f%1|i%2|b%3;\\H%4;" )
.arg( tmpLyr.textFont.family() )
.arg( tmpLyr.textFont.italic() ? 1 : 0 )
.arg( tmpLyr.textFont.bold() ? 1 : 0 )
.arg( label->getHeight() / ( 1 + text.count( "\\P" ) ) ) );
for ( int i = 0; i < textList.size(); ++i )
{
mDxfExport->writeText( layerName, textList.at( i ), QgsPoint( label->getX(), label->getY() + ( textList.size() - 1 - i ) * textHeight ), textAscent, angle, mDxfExport->closestColorMatch( tmpLyr.textColor.rgb() ) );
}
mDxfExport->writeMText( g->dxfLayer(), text, QgsPoint( label->getX(), label->getY() ), label->getWidth(), angle, tmpLyr.textColor );
}
}

View File

@ -24,7 +24,7 @@
class QgsDxfExport;
class CORE_EXPORT QgsDxfPalLabeling: public QgsPalLabeling
class CORE_EXPORT QgsDxfPalLabeling : public QgsPalLabeling
{
public:
QgsDxfPalLabeling( QgsDxfExport* dxf, const QgsRectangle& bbox, double scale, QGis::UnitType mapUnits );

View File

@ -140,7 +140,7 @@ void QgsLayerTreeGroup::removeAllChildren()
removeChildren( 0, mChildren.count() );
}
QgsLayerTreeLayer *QgsLayerTreeGroup::findLayer( const QString& layerId )
QgsLayerTreeLayer *QgsLayerTreeGroup::findLayer( const QString& layerId ) const
{
foreach ( QgsLayerTreeNode* child, mChildren )
{

View File

@ -68,7 +68,7 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode
void removeAllChildren();
//! Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
QgsLayerTreeLayer* findLayer( const QString& layerId );
QgsLayerTreeLayer* findLayer( const QString& layerId ) const;
//! Find all layer nodes. Searches recursively the whole sub-tree.
QList<QgsLayerTreeLayer*> findLayers() const;
//! Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.

View File

@ -41,6 +41,7 @@ QgsLayerTreeModel::QgsLayerTreeModel( QgsLayerTreeGroup* rootNode, QObject *pare
, mLegendMapViewDpi( 0 )
, mLegendMapViewScale( 0 )
{
QgsDebugCall;
connectToRootNode();
mFontLayer.setBold( true );
@ -87,14 +88,18 @@ int QgsLayerTreeModel::rowCount( const QModelIndex &parent ) const
}
QgsLayerTreeNode* n = index2node( parent );
if ( !n )
return 0;
if ( parent.isValid() && parent.column() != 0 )
return 0;
if ( QgsLayerTree::isLayer( n ) )
{
QgsLayerTreeLayer* nL = QgsLayerTree::toLayer( n );
if( !testFlag( ShowLegend ) )
return 0;
QgsLayerTreeLayer* nL = QgsLayerTree::toLayer( n );
if ( mLegendNodes[nL].count() == 1 && mLegendNodes[nL][0]->isEmbeddedInParent() )
return 0;
@ -106,6 +111,7 @@ int QgsLayerTreeModel::rowCount( const QModelIndex &parent ) const
int QgsLayerTreeModel::columnCount( const QModelIndex &parent ) const
{
QgsDebugCall;
Q_UNUSED( parent );
return 1;
}
@ -116,17 +122,11 @@ QModelIndex QgsLayerTreeModel::index( int row, int column, const QModelIndex &pa
return QModelIndex();
QgsLayerTreeNode* n = index2node( parent );
if ( !n )
{
QgsLayerTreeModelLegendNode* sym = index2legendNode( parent );
Q_ASSERT( sym );
return QModelIndex(); // have no children
}
if ( !n || column != 0 || row >= rowCount( parent ) )
return QModelIndex();
if ( testFlag( ShowLegend ) && QgsLayerTree::isLayer( n ) )
{
QgsLayerTreeLayer* nL = QgsLayerTree::toLayer( n );
@ -142,10 +142,8 @@ QModelIndex QgsLayerTreeModel::parent( const QModelIndex &child ) const
if ( !child.isValid() )
return QModelIndex();
QgsLayerTreeNode* n = index2node( child );
QgsLayerTreeNode* parentNode = 0;
QgsLayerTreeNode* n = index2node( child );
if ( !n )
{
QgsLayerTreeModelLegendNode* sym = index2legendNode( child );
@ -154,6 +152,7 @@ QModelIndex QgsLayerTreeModel::parent( const QModelIndex &child ) const
}
else
parentNode = n->parent(); // must not be null
Q_ASSERT( parentNode );
QgsLayerTreeNode* grandParentNode = parentNode->parent();
@ -162,6 +161,7 @@ QModelIndex QgsLayerTreeModel::parent( const QModelIndex &child ) const
int row = grandParentNode->children().indexOf( parentNode );
Q_ASSERT( row >= 0 );
return createIndex( row, 0, static_cast<QObject*>( parentNode ) );
}
@ -182,7 +182,8 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
{
if ( QgsLayerTree::isGroup( node ) )
return QgsLayerTree::toGroup( node )->name();
else if ( QgsLayerTree::isLayer( node ) )
if ( QgsLayerTree::isLayer( node ) )
{
QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node );
QString name = nodeLayer->layerName();
@ -199,7 +200,8 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
{
if ( QgsLayerTree::isGroup( node ) )
return iconGroup();
else if ( QgsLayerTree::isLayer( node ) )
if ( QgsLayerTree::isLayer( node ) )
{
QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node );
@ -337,6 +339,9 @@ Qt::ItemFlags QgsLayerTreeModel::flags( const QModelIndex& index ) const
bool QgsLayerTreeModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
QgsDebugCall;
QgsDebugMsg( QString( "setData( r=%1 c=%2 value=%3 role=%4 )" ).arg( index.row() ).arg( index.column() ).arg( value.toString() ).arg( role ) );
QgsLayerTreeModelLegendNode *sym = index2legendNode( index );
if ( sym )
{
@ -430,6 +435,7 @@ static bool _isChildOfNodes( QgsLayerTreeNode* child, QList<QgsLayerTreeNode*> n
QList<QgsLayerTreeNode*> QgsLayerTreeModel::indexes2nodes( const QModelIndexList& list, bool skipInternal ) const
{
QgsDebugCall;
QList<QgsLayerTreeNode*> nodes;
foreach ( QModelIndex index, list )
{
@ -470,13 +476,14 @@ QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::layerLegendNodes( QgsLaye
return mLegendNodes.value( nodeLayer );
}
QgsLayerTreeGroup*QgsLayerTreeModel::rootGroup()
QgsLayerTreeGroup*QgsLayerTreeModel::rootGroup() const
{
return mRootNode;
}
void QgsLayerTreeModel::setRootGroup( QgsLayerTreeGroup* newRootGroup )
{
QgsDebugCall;
beginResetModel();
disconnectFromRootNode();
@ -493,6 +500,7 @@ void QgsLayerTreeModel::setRootGroup( QgsLayerTreeGroup* newRootGroup )
void QgsLayerTreeModel::refreshLayerLegend( QgsLayerTreeLayer* nodeLayer )
{
QgsDebugCall;
// update title
QModelIndex idx = node2index( nodeLayer );
emit dataChanged( idx, idx );
@ -513,11 +521,13 @@ void QgsLayerTreeModel::refreshLayerLegend( QgsLayerTreeLayer* nodeLayer )
QModelIndex QgsLayerTreeModel::currentIndex() const
{
QgsDebugCall;
return mCurrentIndex;
}
void QgsLayerTreeModel::setCurrentIndex( const QModelIndex& currentIndex )
{
QgsDebugCall;
QModelIndex oldIndex = mCurrentIndex;
mCurrentIndex = currentIndex;
@ -530,6 +540,7 @@ void QgsLayerTreeModel::setCurrentIndex( const QModelIndex& currentIndex )
void QgsLayerTreeModel::setLayerTreeNodeFont( int nodeType, const QFont& font )
{
QgsDebugCall;
if ( nodeType == QgsLayerTreeNode::NodeGroup )
{
if ( mFontGroup != font )
@ -555,6 +566,7 @@ void QgsLayerTreeModel::setLayerTreeNodeFont( int nodeType, const QFont& font )
QFont QgsLayerTreeModel::layerTreeNodeFont( int nodeType ) const
{
QgsDebugCall;
if ( nodeType == QgsLayerTreeNode::NodeGroup )
return mFontGroup;
else if ( nodeType == QgsLayerTreeNode::NodeLayer )
@ -568,6 +580,7 @@ QFont QgsLayerTreeModel::layerTreeNodeFont( int nodeType ) const
void QgsLayerTreeModel::setLegendFilterByScale( double scaleDenominator )
{
QgsDebugCall;
mLegendFilterByScale = scaleDenominator;
// this could be later done in more efficient way

View File

@ -117,7 +117,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes( QgsLayerTreeLayer* nodeLayer );
//! Return pointer to the root node of the layer tree. Always a non-null pointer.
QgsLayerTreeGroup* rootGroup();
QgsLayerTreeGroup* rootGroup() const;
//! Reset the model and use a new root group node
//! @note added in 2.6
void setRootGroup( QgsLayerTreeGroup* newRootGroup );

View File

@ -206,14 +206,18 @@ class QgsConnectionPool
//! @return initialized connection or null on error
T acquireConnection( const QString& connInfo )
{
QgsDebugMsg( QString( "Lock mutex 0x%1" ).arg( (qint64) &mMutex, 0, 16 ) );
mMutex.lock();
QgsDebugMsg( QString( "Unlock mutex 0x%1" ).arg( (qint64) &mMutex, 0, 16 ) );
typename T_Groups::iterator it = mGroups.find( connInfo );
if ( it == mGroups.end() )
{
it = mGroups.insert( connInfo, new T_Group( connInfo ) );
}
T_Group* group = *it;
QgsDebugMsg( QString( "Unlock mutex 0x%1" ).arg( (qint64) &mMutex, 0, 16 ) );
mMutex.unlock();
QgsDebugMsg( QString( "Unlocked mutex 0x%1" ).arg( (qint64) &mMutex, 0, 16 ) );
return group->acquire();
}
@ -232,8 +236,9 @@ class QgsConnectionPool
protected:
T_Groups mGroups;
QMutex mMutex;
private:
QMutex mMutex;
};

View File

@ -95,7 +95,7 @@ class CORE_EXPORT QgsLabelingEngineInterface
virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings* s )
{ Q_UNUSED( layer ); Q_UNUSED( s ); return 0; }
//! called for every feature
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0;
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null ) = 0;
//! called for every diagram feature
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() )
{ Q_UNUSED( layerID ); Q_UNUSED( feat ); Q_UNUSED( context ); }

View File

@ -129,6 +129,9 @@ class QgsPalGeometry : public PalGeometry
feature.setValid( true );
}
void setDxfLayer( QString dxfLayer ) { mDxfLayer = dxfLayer; }
QString dxfLayer() const { return mDxfLayer; }
protected:
GEOSGeometry* mG;
QString mText;
@ -147,6 +150,8 @@ class QgsPalGeometry : public PalGeometry
/**Stores attribute values for diagram rendering*/
QgsAttributes mDiagramAttributes;
QString mDxfLayer;
};
#endif //QGSPALGEOMETRY_H

View File

@ -75,152 +75,6 @@ static void _fixQPictureDPI( QPainter* p )
using namespace pal;
#if 0
class QgsPalGeometry : public PalGeometry
{
public:
QgsPalGeometry( QgsFeatureId id, QString text, GEOSGeometry* g,
qreal ltrSpacing = 0.0, qreal wordSpacing = 0.0, bool curvedLabeling = false )
: mG( g )
, mText( text )
, mId( id )
, mInfo( NULL )
, mIsDiagram( false )
, mIsPinned( false )
, mFontMetrics( NULL )
, mLetterSpacing( ltrSpacing )
, mWordSpacing( wordSpacing )
, mCurvedLabeling( curvedLabeling )
{
mStrId = FID_TO_STRING( mId ).toAscii();
mDefinedFont = QFont();
}
~QgsPalGeometry()
{
if ( mG )
GEOSGeom_destroy( mG );
delete mInfo;
delete mFontMetrics;
}
// getGeosGeometry + releaseGeosGeometry is called twice: once when adding, second time when labeling
const GEOSGeometry* getGeosGeometry()
{
return mG;
}
void releaseGeosGeometry( const GEOSGeometry* /*geom*/ )
{
// nothing here - we'll delete the geometry in destructor
}
const char* strId() { return mStrId.data(); }
QString text() { return mText; }
pal::LabelInfo* info( QFontMetricsF* fm, const QgsMapToPixel* xform, double fontScale, double maxinangle, double maxoutangle )
{
if ( mInfo )
return mInfo;
mFontMetrics = new QFontMetricsF( *fm ); // duplicate metrics for when drawing label
// max angle between curved label characters (20.0/-20.0 was default in QGIS <= 1.8)
if ( maxinangle < 20.0 )
maxinangle = 20.0;
if ( 60.0 < maxinangle )
maxinangle = 60.0;
if ( maxoutangle > -20.0 )
maxoutangle = -20.0;
if ( -95.0 > maxoutangle )
maxoutangle = -95.0;
// create label info!
QgsPoint ptZero = xform->toMapCoordinates( 0, 0 );
QgsPoint ptSize = xform->toMapCoordinatesF( 0.0, -fm->height() / fontScale );
// mLetterSpacing/mWordSpacing = 0.0 is default for non-curved labels
// (non-curved spacings handled by Qt in QgsPalLayerSettings/QgsPalLabeling)
qreal charWidth;
qreal wordSpaceFix;
mInfo = new pal::LabelInfo( mText.count(), ptSize.y() - ptZero.y(), maxinangle, maxoutangle );
for ( int i = 0; i < mText.count(); i++ )
{
mInfo->char_info[i].chr = mText[i].unicode();
// reconstruct how Qt creates word spacing, then adjust per individual stored character
// this will allow PAL to create each candidate width = character width + correct spacing
charWidth = fm->width( mText[i] );
if ( mCurvedLabeling )
{
wordSpaceFix = qreal( 0.0 );
if ( mText[i] == QString( " " )[0] )
{
// word spacing only gets added once at end of consecutive run of spaces, see QTextEngine::shapeText()
int nxt = i + 1;
wordSpaceFix = ( nxt < mText.count() && mText[nxt] != QString( " " )[0] ) ? mWordSpacing : qreal( 0.0 );
}
if ( fm->width( QString( mText[i] ) ) - fm->width( mText[i] ) - mLetterSpacing != qreal( 0.0 ) )
{
// word spacing applied when it shouldn't be
wordSpaceFix -= mWordSpacing;
}
charWidth = fm->width( QString( mText[i] ) ) + wordSpaceFix;
}
ptSize = xform->toMapCoordinatesF((( double ) charWidth ) / fontScale , 0.0 );
mInfo->char_info[i].width = ptSize.x() - ptZero.x();
}
return mInfo;
}
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& dataDefinedValues() const { return mDataDefinedValues; }
void addDataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QVariant v ) { mDataDefinedValues.insert( p, v ); }
void setIsDiagram( bool d ) { mIsDiagram = d; }
bool isDiagram() const { return mIsDiagram; }
void setIsPinned( bool f ) { mIsPinned = f; }
bool isPinned() const { return mIsPinned; }
void setDefinedFont( QFont f ) { mDefinedFont = QFont( f ); }
QFont definedFont() { return mDefinedFont; }
QFontMetricsF* getLabelFontMetrics() { return mFontMetrics; }
void setDiagramAttributes( const QgsAttributes& attrs, const QgsFields* fields ) { mDiagramAttributes = attrs; mDiagramFields = fields; }
const QgsAttributes& diagramAttributes() { return mDiagramAttributes; }
void feature( QgsFeature& feature )
{
feature.setFeatureId( mId );
feature.setFields( mDiagramFields, false );
feature.setAttributes( mDiagramAttributes );
feature.setValid( true );
}
protected:
GEOSGeometry* mG;
QString mText;
QByteArray mStrId;
QgsFeatureId mId;
LabelInfo* mInfo;
bool mIsDiagram;
bool mIsPinned;
QFont mDefinedFont;
QFontMetricsF* mFontMetrics;
qreal mLetterSpacing; // for use with curved labels
qreal mWordSpacing; // for use with curved labels
bool mCurvedLabeling; // whether the geometry is to be used for curved labeling placement
/**Stores attribute values for data defined properties*/
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues;
/**Stores attribute values for diagram rendering*/
QgsAttributes mDiagramAttributes;
const QgsFields* mDiagramFields;
};
#endif //0
// -------------
QgsPalLayerSettings::QgsPalLayerSettings()
@ -1567,7 +1421,7 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
labelY = qAbs( ptSize.y() - ptZero.y() );
}
void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext& context )
void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer )
{
QVariant exprVal; // value() is repeatedly nulled on data defined evaluation and replaced when successful
mCurFeat = &f;
@ -1576,7 +1430,6 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
// store data defined-derived values for later adding to QgsPalGeometry for use during rendering
dataDefinedValues.clear();
// data defined show label? defaults to show label if not 0
if ( dataDefinedEvaluate( QgsPalLayerSettings::Show, exprVal ) )
{
@ -2240,6 +2093,8 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
labelFont.wordSpacing(),
placement == QgsPalLayerSettings::Curved );
lbl->setDxfLayer( dxfLayer );
// record the created geometry - it will be deleted at the end.
geometries.append( lbl );
@ -3502,10 +3357,10 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLaye
return 1;
}
void QgsPalLabeling::registerFeature( const QString& layerID, QgsFeature& f, const QgsRenderContext& context )
void QgsPalLabeling::registerFeature( const QString& layerID, QgsFeature& f, const QgsRenderContext& context, QString dxfLayer )
{
QgsPalLayerSettings& lyr = mActiveLayers[layerID];
lyr.registerFeature( f, context );
lyr.registerFeature( f, context, dxfLayer );
}
void QgsPalLabeling::registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context )

View File

@ -429,7 +429,7 @@ class CORE_EXPORT QgsPalLayerSettings
void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY, QgsFeature* f = 0 );
// implementation of register feature hook
void registerFeature( QgsFeature& f, const QgsRenderContext& context );
void registerFeature( QgsFeature& f, const QgsRenderContext& context, QString dxfLayer );
void readFromLayer( QgsVectorLayer* layer );
void writeToLayer( QgsVectorLayer* layer );
@ -770,7 +770,7 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
//! adds a diagram layer to the labeling engine
virtual int addDiagramLayer( QgsVectorLayer* layer, const QgsDiagramLayerSettings *s );
//! hook called when drawing for every feature in a layer
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
virtual void registerFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext(), QString dxfLayer = QString::null );
virtual void registerDiagramFeature( const QString& layerID, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() );
//! called when the map is drawn and labels should be placed
virtual void drawLabeling( QgsRenderContext& context );

View File

@ -643,7 +643,6 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
{
fc = QColor( fillColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
}
int fillColorIndex = e.closestColorMatch( fc.rgb() );
//outline color
QColor oc = mOutlineColor;
@ -652,8 +651,6 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
{
oc = QColor( outlineColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
}
int outlineColorIndex = e.closestColorMatch( oc.rgb() );
//symbol name
QString symbolName = mSymbolName;
@ -699,7 +696,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
if ( qgsDoubleNear( halfWidth, halfHeight ) )
{
QPointF pt( t.map( QPointF( 0, 0 ) ) );
e.writeCircle( layerName, outlineColorIndex, QgsPoint( pt.x(), pt.y() ), halfWidth );
e.writeCircle( layerName, oc, QgsPoint( pt.x(), pt.y() ), halfWidth );
}
else
{
@ -715,7 +712,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
}
//close ellipse with first point
line.push_back( line.at( 0 ) );
e.writePolyline( line, layerName, "solid", outlineColorIndex, outlineWidth, true );
e.writePolyline( line, layerName, "solid", oc, outlineWidth, true );
}
}
else if ( symbolName == "rectangle" )
@ -724,7 +721,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
QPointF pt3( t.map( QPointF( -halfWidth, halfHeight ) ) );
QPointF pt4( t.map( QPointF( halfWidth, halfHeight ) ) );
e.writeSolid( layerName, fillColorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
e.writeSolid( layerName, fc, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
return true;
}
else if ( symbolName == "cross" )
@ -734,13 +731,13 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
QPointF pt2( t.map( QPointF( halfWidth, 0 ) ) );
line1[0] = QgsPoint( pt1.x(), pt1.y() );
line1[1] = QgsPoint( pt2.x(), pt2.y() );
e.writePolyline( line1, layerName, "CONTINUOUS", outlineColorIndex, outlineWidth, false );
e.writePolyline( line1, layerName, "CONTINUOUS", oc, outlineWidth, false );
QgsPolyline line2( 2 );
QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
line2[0] = QgsPoint( pt3.x(), pt3.y() );
line2[1] = QgsPoint( pt4.x(), pt4.y() );
e.writePolyline( line2, layerName, "CONTINUOUS", outlineColorIndex, outlineWidth, false );
e.writePolyline( line2, layerName, "CONTINUOUS", oc, outlineWidth, false );
return true;
}
else if ( symbolName == "triangle" )
@ -749,7 +746,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
QPointF pt4( t.map( QPointF( 0, halfHeight ) ) );
e.writeSolid( layerName, fillColorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
e.writeSolid( layerName, fc, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
return true;
}

View File

@ -32,14 +32,14 @@
#include <QDomElement>
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2( QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth,
Qt::PenJoinStyle penJoinStyle ) :
mBrushStyle( style ),
mBorderColor( borderColor ),
mBorderStyle( borderStyle ),
mBorderWidth( borderWidth ),
mBorderWidthUnit( QgsSymbolV2::MM ),
mPenJoinStyle( penJoinStyle ),
mOffsetUnit( QgsSymbolV2::MM )
Qt::PenJoinStyle penJoinStyle )
: mBrushStyle( style )
, mBorderColor( borderColor )
, mBorderStyle( borderStyle )
, mBorderWidth( borderWidth )
, mBorderWidthUnit( QgsSymbolV2::MM )
, mPenJoinStyle( penJoinStyle )
, mOffsetUnit( QgsSymbolV2::MM )
{
mColor = color;
}
@ -383,10 +383,10 @@ double QgsSimpleFillSymbolLayerV2::dxfWidth( const QgsDxfExport& e, const QgsSym
QColor QgsSimpleFillSymbolLayerV2::dxfColor( const QgsSymbolV2RenderContext& context ) const
{
QgsExpression* colorBorderExpression = expression( "color_border" );
if ( colorBorderExpression )
QgsExpression* colorExpression = expression( "border_color" );
if ( colorExpression )
{
return QgsSymbolLayerV2Utils::decodeColor( colorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
return QgsSymbolLayerV2Utils::decodeColor( colorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}
return mBorderColor;
}
@ -396,22 +396,37 @@ Qt::PenStyle QgsSimpleFillSymbolLayerV2::dxfPenStyle() const
return mBorderStyle;
}
QColor QgsSimpleFillSymbolLayerV2::dxfBrushColor( const QgsSymbolV2RenderContext& context ) const
{
QgsExpression* colorExpression = expression( "color" );
if ( colorExpression )
{
return QgsSymbolLayerV2Utils::decodeColor( colorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() );
}
return mColor;
}
Qt::BrushStyle QgsSimpleFillSymbolLayerV2::dxfBrushStyle() const
{
return mBrushStyle;
}
//QgsGradientFillSymbolLayer
QgsGradientFillSymbolLayerV2::QgsGradientFillSymbolLayerV2( QColor color, QColor color2,
GradientColorType colorType, GradientType gradientType,
GradientCoordinateMode coordinateMode, GradientSpread spread )
: mGradientColorType( colorType ),
mGradientRamp( NULL ),
mGradientType( gradientType ),
mCoordinateMode( coordinateMode ),
mGradientSpread( spread ),
mReferencePoint1( QPointF( 0.5, 0 ) ),
mReferencePoint1IsCentroid( false ),
mReferencePoint2( QPointF( 0.5, 1 ) ),
mReferencePoint2IsCentroid( false ),
mAngle( 0 ),
mOffsetUnit( QgsSymbolV2::MM )
: mGradientColorType( colorType )
, mGradientRamp( NULL )
, mGradientType( gradientType )
, mCoordinateMode( coordinateMode )
, mGradientSpread( spread )
, mReferencePoint1( QPointF( 0.5, 0 ) )
, mReferencePoint1IsCentroid( false )
, mReferencePoint2( QPointF( 0.5, 1 ) )
, mReferencePoint2IsCentroid( false )
, mAngle( 0 )
, mOffsetUnit( QgsSymbolV2::MM )
{
mColor = color;
mColor2 = color2;

View File

@ -119,6 +119,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
Qt::PenStyle dxfPenStyle() const;
QColor dxfBrushColor( const QgsSymbolV2RenderContext& context ) const;
Qt::BrushStyle dxfBrushStyle() const;
protected:
QBrush mBrush;

View File

@ -849,7 +849,6 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
{
c = QgsSymbolLayerV2Utils::decodeColor( colorExpression->evaluate( *f ).toString() );
}
int colorIndex = QgsDxfExport::closestColorMatch( c.rgb() );
//offset
double offsetX = 0;
@ -883,14 +882,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
if ( mName == "circle" )
{
e.writeGroup( 0, "CIRCLE" );
e.writeGroup( 8, layerName );
e.writeGroup( 62, colorIndex );
e.writeGroup( 10, shift.x() );
e.writeGroup( 20, shift.y() );
e.writeGroup( 30, 0.0 );
e.writeGroup( 40, halfSize );
e.writeCircle( layerName, c, QgsPoint( shift.x(), shift.y() ), halfSize );
}
else if ( mName == "square" || mName == "rectangle" )
{
@ -898,7 +890,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
QPointF pt2 = t.map( QPointF( halfSize, -halfSize ) );
QPointF pt3 = t.map( QPointF( -halfSize, halfSize ) );
QPointF pt4 = t.map( QPointF( halfSize, halfSize ) );
e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
e.writeSolid( layerName, c, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
}
else if ( mName == "diamond" )
{
@ -906,14 +898,14 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
QPointF pt2 = t.map( QPointF( 0, -halfSize ) );
QPointF pt3 = t.map( QPointF( 0, halfSize ) );
QPointF pt4 = t.map( QPointF( halfSize, 0 ) );
e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
e.writeSolid( layerName, c, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
}
else if ( mName == "triangle" )
{
QPointF pt1 = t.map( QPointF( -halfSize, -halfSize ) );
QPointF pt2 = t.map( QPointF( halfSize, -halfSize ) );
QPointF pt3 = t.map( QPointF( 0, halfSize ) );
e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt3.x(), pt3.y() ) );
e.writeSolid( layerName, c, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt3.x(), pt3.y() ) );
}
/*else if( mName == "equilateral_triangle" )
{
@ -923,7 +915,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
{
QPointF pt1 = t.map( QPointF( 0, halfSize ) );
QPointF pt2 = t.map( QPointF( 0, -halfSize ) );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", c, outlineWidth );
}
else if ( mName == "coss" )
{
@ -931,8 +923,8 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
QPointF pt2 = t.map( QPointF( halfSize, 0 ) );
QPointF pt3 = t.map( QPointF( 0, -halfSize ) );
QPointF pt4 = t.map( QPointF( 0, halfSize ) );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", c, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ), layerName, "CONTINUOUS", c, outlineWidth );
}
else if ( mName == "x" || mName == "cross2" )
{
@ -940,23 +932,23 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
QPointF pt2 = t.map( QPointF( halfSize, halfSize ) );
QPointF pt3 = t.map( QPointF( -halfSize, halfSize ) );
QPointF pt4 = t.map( QPointF( halfSize, -halfSize ) );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", c, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ), layerName, "CONTINUOUS", c, outlineWidth );
}
else if ( mName == "arrowhead" )
{
QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
QPointF pt2 = t.map( QPointF( 0, 0 ) );
QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", colorIndex, outlineWidth );
e.writeLine( QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", c, outlineWidth );
e.writeLine( QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt2.x(), pt2.y() ), layerName, "CONTINUOUS", c, outlineWidth );
}
else if ( mName == "filled_arrowhead" )
{
QPointF pt1 = t.map( QPointF( -halfSize, halfSize ) );
QPointF pt2 = t.map( QPointF( 0, 0 ) );
QPointF pt3 = t.map( QPointF( -halfSize, -halfSize ) );
e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt3.x(), pt3.y() ) );
e.writeSolid( layerName, c, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt3.x(), pt3.y() ) );
}
else
{

View File

@ -118,6 +118,17 @@ Qt::PenStyle QgsSymbolLayerV2::dxfPenStyle() const
return Qt::SolidLine;
}
QColor QgsSymbolLayerV2::dxfBrushColor( const QgsSymbolV2RenderContext& context ) const
{
Q_UNUSED( context );
return color();
}
Qt::BrushStyle QgsSymbolLayerV2::dxfBrushStyle() const
{
return Qt::NoBrush;
}
void QgsSymbolLayerV2::prepareExpressions( const QgsFields* fields, double scale )
{
if ( !fields )

View File

@ -128,6 +128,8 @@ class CORE_EXPORT QgsSymbolLayerV2
virtual QVector<qreal> dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const;
virtual Qt::PenStyle dxfPenStyle() const;
virtual QColor dxfBrushColor( const QgsSymbolV2RenderContext& context ) const;
virtual Qt::BrushStyle dxfBrushStyle() const;
protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )

View File

@ -21,7 +21,7 @@
class QgsMapLayerModel;
/**
* @brief The QgsMapLayerProxModel class provides an easy to use model to display the list of layers in widgets.
* @brief The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets.
* @note added in 2.3
*/
class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel

View File

@ -23,3 +23,14 @@ QgsPostgresConnPool* QgsPostgresConnPool::instance()
static QgsPostgresConnPool sInstance;
return &sInstance;
}
QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool<QgsPostgresConn*, QgsPostgresConnPoolGroup>()
{
QgsDebugCall;
}
QgsPostgresConnPool::~QgsPostgresConnPool()
{
QgsDebugCall;
}

View File

@ -60,6 +60,12 @@ class QgsPostgresConnPool : public QgsConnectionPool<QgsPostgresConn*, QgsPostgr
public:
static QgsPostgresConnPool* instance();
protected:
Q_DISABLE_COPY( QgsPostgresConnPool );
private:
QgsPostgresConnPool();
~QgsPostgresConnPool();
};

View File

@ -26,21 +26,21 @@
</item>
<item row="0" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mSymbologyModeLabel">
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<property name="text">
<string>Symbology mode</string>
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>Symbology scale</string>
<item row="3" column="0" colspan="3">
<widget class="QgsLayerTreeView" name="mTreeView">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<attribute name="headerDefaultSectionSize">
<number>0</number>
</attribute>
</widget>
</item>
<item row="0" column="0">
@ -50,13 +50,16 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<item row="1" column="0">
<widget class="QLabel" name="mSymbologyModeLabel">
<property name="text">
<string>...</string>
<string>Symbology mode</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="mSymbologyModeComboBox">
<item>
@ -76,13 +79,33 @@
</item>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="mSymbologyScaleLineEdit"/>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>Symbology scale</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QListView" name="mLayersListView">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
<item row="0" column="1">
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Layerattribute</string>
</property>
<property name="buddy">
<cstring>mLayerAttributeComboBox</cstring>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QgsFieldComboBox" name="mLayerAttributeComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
@ -90,13 +113,6 @@
</item>
<item row="2" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="mSelectAllButton">
<property name="text">
<string>Select all</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="mUnSelectAllButton">
<property name="text">
@ -117,6 +133,13 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="mSelectAllButton">
<property name="text">
<string>Select all</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
@ -128,6 +151,18 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsFieldComboBox</class>
<extends>QComboBox</extends>
<header>qgsfieldcombobox.h</header>
</customwidget>
<customwidget>
<class>QgsLayerTreeView</class>
<extends>QTreeView</extends>
<header>qgslayertreeview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>