started to make a dialog class for unique renderer, added a bit of wkb code in the shapefileprovider

git-svn-id: http://svn.osgeo.org/qgis/trunk@1828 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2004-07-28 19:12:20 +00:00
parent 5551cb83e2
commit 50b1d79d38
5 changed files with 188 additions and 3 deletions

View File

@ -585,7 +585,7 @@ bool QgsShapeFileProvider::addFeature(QgsFeature* f)
{
OGRLineString* l=new OGRLineString();
int length;
memcpy(&length,f->getGeometry()+sizeof(int),sizeof(int));
memcpy(&length,f->getGeometry()+1+sizeof(int),sizeof(int));
#ifdef QGISDEBUG
qWarning("length: "+QString::number(length));
#endif
@ -615,11 +615,33 @@ bool QgsShapeFileProvider::addFeature(QgsFeature* f)
}
case QGis::WKBMultiPoint:
{
OGRMultiPoint* multip= new OGRMultiPoint();
int count;
//determine how many points
memcpy(&count,f->getGeometry()+1+sizeof(int),sizeof(int));
multip->importFromWkb(f->getGeometry(),1+2*sizeof(int)+count*2*sizeof(double));
feature->SetGeometry(multip);
break;
}
case QGis::WKBMultiLineString:
{
OGRMultiLineString* multil=new OGRMultiLineString();
int numlines=(int)f->getGeometry()[5];
int totalpoints=0;
unsigned char* ptr=f->getGeometry()+9;
for(int i=0;i<numlines;++i)
{
int numpoints=(int)ptr;
ptr+=4;
for(int j=0;j<numpoints;++j)
{
ptr+=16;
totalpoints+=2;
}
}
int size=1+2*sizeof(int)+numlines*sizeof(int)+totalpoints*2*sizeof(double);
multil->importFromWkb(f->getGeometry(),size);
feature->SetGeometry(multil);
}
case QGis::WKBMultiPolygon:
{

View File

@ -92,6 +92,7 @@ headers = qgis.h \
qgssymbol.h \
qgssymbologyutils.h \
qgsuniquevalrenderer.h \
qgsuvaldialog.h \
qgsvectorlayer.h \
qgsvectorlayerproperties.h \
splashscreen.h \
@ -124,6 +125,7 @@ qgis_UIC = qgisappbase.ui \
qgsrasterlayerpropertiesbase.ui \
qgssimadialogbase.ui \
qgssisydialogbase.ui \
qgsuvaldialogbase.ui \
qgsvectorlayerpropertiesbase.ui \
qgsprojectpropertiesbase.ui
@ -238,6 +240,7 @@ qgis_SOURCES = main.cpp \
qgssymbol.cpp \
qgssymbologyutils.cpp \
qgsuniquevalrenderer.cpp \
qgsuvaldialog.cpp \
qgsvectorlayer.cpp \
qgsvectorlayerproperties.cpp \
splashscreen.cpp \

62
src/qgsuvaldialog.cpp Normal file
View File

@ -0,0 +1,62 @@
/***************************************************************************
qgsuvaldialog.cpp - description
-------------------
begin : July 2004
copyright : (C) 2004 by Marco Hugentobler
email : marco.hugentobler@autoform.ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsuvaldialog.h"
#include "qgsdataprovider.h"
#include "qgsvectorlayer.h"
#include <qcombobox.h>
QgsUValDialog::QgsUValDialog(QgsVectorLayer* vl): QgsUValDialogBase(), ext(0), mVectorLayer(vl)
{
//find out the fields of mVectorLayer
QgsDataProvider *provider;
if (provider = mVectorLayer->getDataProvider())
{
std::vector < QgsField > &fields = provider->fields();
QString str;
for (std::vector < QgsField >::iterator it = fields.begin(); it != fields.end(); ++it)
{
str = (*it).name();
str = str.left(1).upper() + str.right(str.length() - 1); //make the first letter uppercase
mClassificationComboBox->insertItem(str);
}
}
else
{
qWarning("Warning, data provider is null in QgsUValDialog::QgsUValDialog");
return;
}
}
QgsUValDialog::~QgsUValDialog()
{
}
void QgsUValDialog::apply()
{
}
void QgsUValDialog::changeClassificationAttribute(int nr)
{
mValues.clear();
//go through all the features and insert their value into the set
//go through the set and insert entries to the extension widget
}

48
src/qgsuvaldialog.h Normal file
View File

@ -0,0 +1,48 @@
/***************************************************************************
qgsuvaldialog.h - description
-------------------
begin : July 2004
copyright : (C) 2004 by Marco Hugentobler
email : marco.hugentobler@autoform.ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSUVALDIALOG_H
#define QGSUVALDIALOG_H
#include "qgsuvaldialogbase.uic.h"
#include <set.h>
class QgsVectorLayer;
class QgsGraMaExtensionWidget;
class QgsUValDialog: public QgsUValDialogBase
{
public:
QgsUValDialog(QgsVectorLayer* vl);
~QgsUValDialog();
public slots:
void apply();
protected:
/**Pointer to the curret extension widget*/
QgsGraMaExtensionWidget* ext;
/**Pointer to the associated vector layer*/
QgsVectorLayer* mVectorLayer;
/**Set to store the already entered values*/
std::set<QString> mValues;
protected slots:
void changeClassificationAttribute(int nr);
};
#endif

50
src/qgsuvaldialogbase.ui Normal file
View File

@ -0,0 +1,50 @@
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>QgsUValDialogBase</class>
<widget class="QDialog">
<property name="name">
<cstring>QgsUValDialogBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>59</height>
</rect>
</property>
<property name="caption">
<string>unique Value</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox" row="0" column="2">
<property name="name">
<cstring>mClassificationComboBox</cstring>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</widget>
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>mClassVarLabel</cstring>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Classification Field:</string>
</property>
</widget>
</grid>
</widget>
<layoutdefaults spacing="6" margin="11"/>
</UI>