several things (because sf was down a while), e.g. work prior to save/ load symbology

git-svn-id: http://svn.osgeo.org/qgis/trunk@569 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2004-01-23 15:19:11 +00:00
parent 726c1deacf
commit efeeb353d1
11 changed files with 256 additions and 164 deletions

View File

@ -48,6 +48,24 @@ QgsContColDialog::QgsContColDialog(QgsVectorLayer* layer): QgsContColDialogBase(
qWarning("Warning, data provider is null in QgsContColDialog::QgsContColDialog(...)");
return;
}
//restore the correct colors for minimum and maximum values
QgsContinuousColRenderer* renderer=dynamic_cast<QgsContinuousColRenderer*>(m_vectorlayer->renderer());
if(renderer)
{
QgsRenderItem* minitem=renderer->minimumItem();
QgsRenderItem* maxitem=renderer->maximumItem();
if(m_vectorlayer->vectorType()==QGis::Line)
{
mincolorbutton->setPaletteBackgroundColor(minitem->getSymbol()->pen().color());
maxcolorbutton->setPaletteBackgroundColor(maxitem->getSymbol()->pen().color());
}
else
{
mincolorbutton->setPaletteBackgroundColor(minitem->getSymbol()->brush().color());
maxcolorbutton->setPaletteBackgroundColor(maxitem->getSymbol()->brush().color());
}
}
}
QgsContColDialog::QgsContColDialog()

View File

@ -193,9 +193,7 @@ void QgsContinuousColRenderer::renderFeature(QPainter* p, QgsFeature* f, QgsCoor
char lsb;
QgsPoint pt;
QPointArray *pa;
//OGRFieldDefn *fldDef;
QString fld;
QString val;
switch (wkbType) {
case QGis::WKBPoint:

View File

@ -44,6 +44,10 @@ class QgsContinuousColRenderer: public QgsRenderer
void setMinimumItem(QgsRenderItem* it);
/**Sets the item for the maximum value. The item has to be created using the new operator and is automatically deleted when inserting a new item or when the instance is destroyed*/
void setMaximumItem(QgsRenderItem* it);
/**Returns the item for the minimum value*/
QgsRenderItem* minimumItem();
/**Returns the item for the maximum value*/
QgsRenderItem* maximumItem();
/** Returns true*/
bool needsAttributes();
protected:
@ -65,6 +69,16 @@ inline void QgsContinuousColRenderer::setClassificationField(int id)
m_classificationField=id;
}
inline QgsRenderItem* QgsContinuousColRenderer::minimumItem()
{
return m_minimumItem;
}
inline QgsRenderItem* QgsContinuousColRenderer::maximumItem()
{
return m_maximumItem;
}
inline bool QgsContinuousColRenderer::needsAttributes()
{
return true;

View File

@ -92,9 +92,7 @@ void QgsGraduatedSymRenderer::renderFeature(QPainter* p, QgsFeature* f, QgsCoord
char lsb;
QgsPoint pt;
QPointArray *pa;
//OGRFieldDefn *fldDef;
QString fld;
QString val;
switch (wkbType) {
case QGis::WKBPoint:
@ -287,7 +285,7 @@ void QgsGraduatedSymRenderer::initializeSymbology(QgsVectorLayer* layer)
p.setFont( f );
p.drawText(35,pixmap->height()-10,name);
QgsRangeRenderItem* ri = new QgsRangeRenderItem(sy,QString::number(DBL_MIN,'f',6),QString::number(DBL_MAX,'f',6),"");
QgsRangeRenderItem* ri = new QgsRangeRenderItem(sy,QString::number(-DBL_MAX,'f',6),QString::number(DBL_MAX,'f',6),"");
addItem(ri);
QgsGraSyDialog* dialog=new QgsGraSyDialog(layer);

View File

@ -50,6 +50,8 @@ class QgsGraduatedSymRenderer: public QgsRenderer
\param field the number of the field to classify*/
void setClassificationField(int field);
void initializeSymbology(QgsVectorLayer* layer);
/**Returns the list with the render items*/
std::list<QgsRangeRenderItem*>& items();
/** Returns true*/
bool needsAttributes();
protected:
@ -80,6 +82,11 @@ inline void QgsGraduatedSymRenderer::setClassificationField(int field)
m_classificationField=field;
}
inline std::list<QgsRangeRenderItem*>& QgsGraduatedSymRenderer::items()
{
return m_items;
}
inline bool QgsGraduatedSymRenderer::needsAttributes()
{
return true;

View File

@ -34,11 +34,6 @@
QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext(0), scv(0), m_vectorlayer(layer)
{
QObject::connect(numberofclassesspinbox,SIGNAL(valueChanged(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(classificationComboBox,SIGNAL(activated(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(modeComboBox,SIGNAL(activated(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(closebutton,SIGNAL(clicked()),this,SLOT(hide()));
QObject::connect(applybutton,SIGNAL(clicked()),this,SLOT(apply()));
setOrientation(Qt::Vertical);
//Set the initial display name
@ -74,6 +69,61 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext
modeComboBox->insertItem("equal interval");
setSizeGripEnabled(true);
//restore the correct settings
QgsGraduatedSymRenderer* renderer=dynamic_cast<QgsGraduatedSymRenderer*>(m_vectorlayer->renderer());
if(renderer)
{
std::list<QgsRangeRenderItem*> list=renderer->items();
ext=new QgsGraSyExtensionWidget(this,renderer->classificationField(),QgsGraSyDialog::EMPTY,list.size(),m_vectorlayer);
//todo:find out the fieldname for the classification field
classificationComboBox->setCurrentItem(renderer->classificationField());
//set the right colors and texts to the widgets
int number=0;
for(std::list<QgsRangeRenderItem*>::iterator it=list.begin();it!=list.end();++it)
{
qWarning("inside loop");
((QLineEdit*)(ext->getWidget(0,number)))->setText((*it)->value());
((QLineEdit*)ext->getWidget(1,number))->setText((*it)->upper_value());
((QLineEdit*)ext->getWidget(2,number))->setText((*it)->label());
((QPushButton*)ext->getWidget(3,number))->setPaletteBackgroundColor((*it)->getSymbol()->pen().color());
((QPushButton*)ext->getWidget(4,number))->setText(QgsSymbologyUtils::penStyle2QString((*it)->getSymbol()->pen().style()));
((QSpinBox*)ext->getWidget(5,number))->setValue((*it)->getSymbol()->pen().width());
((QPushButton*)ext->getWidget(6,number))->setPaletteBackgroundColor((*it)->getSymbol()->brush().color());
((QPushButton*)ext->getWidget(7,number))->setText(QgsSymbologyUtils::brushStyle2QString((*it)->getSymbol()->brush().style()));
number++;
}
if(scv)
{
QgsGraSyDialogBaseLayout->remove(scv);
delete scv;
}
numberofclassesspinbox->setValue(list.size());
if(numberofclassesspinbox->value()==0)
{
scv=0;
return;
}
scv=new QScrollView(this);
scv->addChild(ext);
QgsGraSyDialogBaseLayout->addMultiCellWidget(scv,5,5,0,3);
scv->show();
//do the necessary signal/slot connections
QObject::connect(numberofclassesspinbox,SIGNAL(valueChanged(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(classificationComboBox,SIGNAL(activated(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(modeComboBox,SIGNAL(activated(int)),this,SLOT(adjustNumberOfClasses()));
QObject::connect(closebutton,SIGNAL(clicked()),this,SLOT(hide()));
QObject::connect(applybutton,SIGNAL(clicked()),this,SLOT(apply()));
}
}
QgsGraSyDialog::QgsGraSyDialog()
@ -257,6 +307,7 @@ void QgsGraSyDialog::apply() const
if(lbcontainsletter==false&&ubcontainsletter==false&&lower_bound.length()>0&&upper_bound.length()>0)//only add the item if the value bounds do not contain letters and are not null strings
{
qWarning("adde ein renderitem");
QgsRangeRenderItem* item = new QgsRangeRenderItem(sy, lower_bound, upper_bound, ((QLineEdit*)(ext->getWidget(2,i)))->text());
renderer->addItem(item);

View File

@ -384,10 +384,6 @@ private:
double minGrayDouble;
// maximum gray value - used in scaling procedure
double maxGrayDouble;
signals:
void repaintRequested();
};
#endif

View File

@ -63,9 +63,7 @@ void QgsSingleSymRenderer::renderFeature(QPainter* p, QgsFeature* f, QgsCoordina
char lsb;
QgsPoint pt;
QPointArray *pa;
//OGRFieldDefn *fldDef;
QString fld;
QString val;
switch (wkbType) {
case QGis::WKBPoint:

View File

@ -45,8 +45,12 @@ QgsSiSyDialog::QgsSiSyDialog(QgsVectorLayer* layer): QgsSiSyDialogBase(), m_vect
displaynamefield->setText(m_vectorlayer->name());
outlinecolorbutton->setPaletteBackgroundColor(((QgsSingleSymRenderer*)(layer->renderer()))->item()->getSymbol()->pen().color());
stylebutton->setText(tr("SolidLine"));
outlinewidthspinbox->setValue(((QgsSingleSymRenderer*)(layer->renderer()))->item()->getSymbol()->pen().width());
fillcolorbutton->setPaletteBackgroundColor(((QgsSingleSymRenderer*)(layer->renderer()))->item()->getSymbol()->brush().color());
QgsSingleSymRenderer* renderer=dynamic_cast<QgsSingleSymRenderer*>(layer->renderer());
if(renderer)
{
outlinewidthspinbox->setValue(renderer->item()->getSymbol()->pen().width());
fillcolorbutton->setPaletteBackgroundColor(renderer->item()->getSymbol()->brush().color());
}
patternbutton->setText(tr("SolidPattern"));
if(m_vectorlayer&&m_vectorlayer->vectorType()==QGis::Line)

View File

@ -238,6 +238,21 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
QgsFeature *fet;
unsigned char *feature;
bool attributesneeded = m_renderer->needsAttributes();
double *x;
double *y;
int *nPoints;
int *numRings;
int *numPolygons;
int numPoints;
int numLineStrings;
int idx, jdx, kdx;
unsigned char *ptr;
char lsb;
QgsPoint pt;
QPointArray *pa;
int wkbType;
while ((fet = dataProvider->getNextFeature(attributesneeded))) {//true is necessary for graduated symbol
if (fet == 0) {
@ -265,26 +280,13 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
// if (feature != 0) {
// std::cout << featureCount << "'the feature is null\n";
int wkbType = (int) feature[1];
wkbType = (int) feature[1];
// std::cout << "Feature type: " << wkbType << std::endl;
// read each feature based on its type
double *x;
double *y;
int *nPoints;
int *numRings;
int *numPolygons;
int numPoints;
int numLineStrings;
int idx, jdx, kdx;
unsigned char *ptr;
char lsb;
QgsPoint pt;
QPointArray *pa;
//OGRFieldDefn *fldDef;
QString fld;
QString val;
switch (wkbType) {
case WKBPoint:
p->setBrush(*brush);
// fldDef = fet->GetFieldDefnRef(1);
// fld = fldDef->GetNameRef();
@ -299,7 +301,9 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
p->drawRect(pt.xToInt(), pt.yToInt(), 5, 5);
//std::cout << "marker draw complete\n";
break;
case WKBLineString:
// get number of points in the line
ptr = feature + 5;
nPoints = (int *) ptr;
@ -317,6 +321,7 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
p->lineTo(pt.xToInt(), pt.yToInt());
}
break;
case WKBMultiLineString:
numLineStrings = (int) (feature[5]);
@ -338,10 +343,10 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
p->moveTo(pt.xToInt(), pt.yToInt());
else
p->lineTo(pt.xToInt(), pt.yToInt());
}
}
break;
case WKBPolygon:
p->setBrush(*brush);
@ -372,7 +377,9 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
}
break;
case WKBMultiPolygon:
p->setBrush(*brush);
// get the number of polygons
ptr = feature + 5;
@ -407,6 +414,7 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
}
}
break;
default:
std::cout << "UNKNOWN WKBTYPE ENCOUNTERED\n";
break;
@ -719,12 +727,6 @@ QgsRect QgsVectorLayer::bBoxOfSelected()
QgsFeature *fet;
unsigned char *feature;
while ((fet = dataProvider->getNextFeature(false)))
{
if(selected.find(fet->featureId())!=selected.end())
{
feature = fet->getGeometry();
int wkbType = (int) feature[1];
double *x;
double *y;
int *nPoints;
@ -737,8 +739,15 @@ QgsRect QgsVectorLayer::bBoxOfSelected()
char lsb;
QgsPoint pt;
QPointArray *pa;
QString fld;
QString val;
int wkbType;
while ((fet = dataProvider->getNextFeature(false)))
{
if(selected.find(fet->featureId())!=selected.end())
{
feature = fet->getGeometry();
wkbType = (int) feature[1];
switch (wkbType)
{

View File

@ -137,7 +137,6 @@ class QgsVectorLayer:public QgsMapLayer
};
private: // Private methods
int endian();
signals:void repaintRequested();
};