removed msgs to std out / added line width to symbology settings

git-svn-id: http://svn.osgeo.org/qgis/trunk@110 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2002-08-21 04:30:37 +00:00
parent 3a1af8b438
commit 250cd83f8a
12 changed files with 92 additions and 27 deletions

View File

@ -390,7 +390,7 @@ void QgisApp::drawPoint(double x, double y)
void QgisApp::drawLayers() void QgisApp::drawLayers()
{ {
std::cout << "In QgisApp::drawLayers()" << std::endl; // std::cout << "In QgisApp::drawLayers()" << std::endl;
mapCanvas->render2(); mapCanvas->render2();
} }

View File

@ -17,6 +17,7 @@
#include <iostream> #include <iostream>
#include <qstring.h> #include <qstring.h>
#include <qpainter.h> #include <qpainter.h>
#include <qpen.h>
#include <qpointarray.h> #include <qpointarray.h>
#include <qbrush.h> #include <qbrush.h>
#include "qgis.h" #include "qgis.h"
@ -36,7 +37,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table)
if (pd->Status() == CONNECTION_OK) { if (pd->Status() == CONNECTION_OK) {
// get the geometry column // get the geometry column
QString sql = "select f_geometry_column,type from geometry_columns where f_table_name='" + tableName + "'"; QString sql = "select f_geometry_column,type from geometry_columns where f_table_name='" + tableName + "'";
qWarning("Getting geometry column: " + sql); // qWarning("Getting geometry column: " + sql);
int result = pd->ExecTuplesOk((const char *) sql); int result = pd->ExecTuplesOk((const char *) sql);
if (result) { if (result) {
// set the simple type for use with symbology operations // set the simple type for use with symbology operations
@ -52,7 +53,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table)
QString sql = "select xmax(extent(" + geometryColumn + ")) as xmax," QString sql = "select xmax(extent(" + geometryColumn + ")) as xmax,"
"xmin(extent(" + geometryColumn + ")) as xmin," "xmin(extent(" + geometryColumn + ")) as xmin,"
"ymax(extent(" + geometryColumn + ")) as ymax," "ymin(extent(" + geometryColumn + ")) as ymin" " from " + tableName; "ymax(extent(" + geometryColumn + ")) as ymax," "ymin(extent(" + geometryColumn + ")) as ymin" " from " + tableName;
qWarning("Getting extents: " + sql); // qWarning("Getting extents: " + sql);
result = pd->ExecTuplesOk((const char *) sql); result = pd->ExecTuplesOk((const char *) sql);
if (result) { if (result) {
@ -66,7 +67,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table)
QTextOStream(&xMsg).width(18); QTextOStream(&xMsg).width(18);
QTextOStream(&xMsg) << "Set extents to: " << layerExtent. QTextOStream(&xMsg) << "Set extents to: " << layerExtent.
xMin() << ", " << layerExtent.yMin() << " " << layerExtent.xMax() << ", " << layerExtent.yMax(); xMin() << ", " << layerExtent.yMin() << " " << layerExtent.xMax() << ", " << layerExtent.yMax();
qWarning(xMsg); // qWarning(xMsg);
} else { } else {
QString msg = "Unable to access " + tableName; QString msg = "Unable to access " + tableName;
@ -106,19 +107,19 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, int yTransform)
// set pen and fill // set pen and fill
QgsSymbol *sym = symbol(); QgsSymbol *sym = symbol();
p->setPen(sym->color()); p->setPen(sym->color());
std::cout << "Drawing layer using view extent " << viewExtent->stringRep() << " with a y transform of " << yTransform << std::endl; //std::cout << "Drawing layer using view extent " << viewExtent->stringRep() << " with a y transform of " << yTransform << std::endl;
PgCursor pgs(dataSource, "drawCursor"); PgCursor pgs(dataSource, "drawCursor");
QString sql = "select asbinary(" + geometryColumn + ",'" + endianString(); QString sql = "select asbinary(" + geometryColumn + ",'" + endianString();
sql += "') as features from " + tableName; sql += "') as features from " + tableName;
sql += " where " + geometryColumn; sql += " where " + geometryColumn;
sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep(); sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep();
sql += ")'::box3d,-1)"; sql += ")'::box3d,-1)";
qWarning(sql); // qWarning(sql);
pgs.Declare((const char *) sql, true); pgs.Declare((const char *) sql, true);
//! \todo Check return from Fecth(); //! \todo Check return from Fecth();
int res = pgs.Fetch(); int res = pgs.Fetch();
std::cout << "Number of matching records: " << pgs.Tuples() << std::endl; //std::cout << "Number of matching records: " << pgs.Tuples() << std::endl;
for (int idx = 0; idx < pgs.Tuples(); idx++) { for (int idx = 0; idx < pgs.Tuples(); idx++) {
// allocate memory for the item // allocate memory for the item
char *feature = new char[pgs.GetLength(idx, 0) + 1]; char *feature = new char[pgs.GetLength(idx, 0) + 1];
@ -256,20 +257,23 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTra
4. draw 4. draw
*/ */
QgsSymbol *sym = symbol(); QgsSymbol *sym = symbol();
p->setPen(sym->color()); QPen pen;
pen.setColor(sym->color());
pen.setWidth(sym->lineWidth());
p->setPen(pen);
PgCursor pgs(dataSource, "drawCursor"); PgCursor pgs(dataSource, "drawCursor");
QString sql = "select asbinary(" + geometryColumn + ",'" + endianString(); QString sql = "select asbinary(" + geometryColumn + ",'" + endianString();
sql += "') as features from " + tableName; sql += "') as features from " + tableName;
sql += " where " + geometryColumn; sql += " where " + geometryColumn;
sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep(); sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep();
sql += ")'::box3d,-1)"; sql += ")'::box3d,-1)";
qWarning(sql); // qWarning(sql);
pgs.Declare((const char *) sql, true); pgs.Declare((const char *) sql, true);
int res = pgs.Fetch(); int res = pgs.Fetch();
QString msg; QString msg;
QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl; QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl;
qWarning(msg); // qWarning(msg);
std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl; // std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl;
for (int idx = 0; idx < pgs.Tuples(); idx++) { for (int idx = 0; idx < pgs.Tuples(); idx++) {
// allocate memory for the item // allocate memory for the item
char *feature = new char[pgs.GetLength(idx, 0) + 1]; char *feature = new char[pgs.GetLength(idx, 0) + 1];

View File

@ -83,7 +83,7 @@ void QgsDbSourceSelect::dbConnect()
m_connInfo = host + " " + database + " " + username + " " + password; m_connInfo = host + " " + database + " " + username + " " + password;
qDebug(m_connInfo); qDebug(m_connInfo);
PgDatabase *pd = new PgDatabase((const char *) m_connInfo); PgDatabase *pd = new PgDatabase((const char *) m_connInfo);
std::cout << pd->ErrorMessage(); // std::cout << pd->ErrorMessage();
if (pd->Status() == CONNECTION_OK) { if (pd->Status() == CONNECTION_OK) {
// clear the existing entries // clear the existing entries
lstTables->clear(); lstTables->clear();

View File

@ -19,6 +19,7 @@
#include <qcolordialog.h> #include <qcolordialog.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qspinbox.h>
#include <qstring.h> #include <qstring.h>
#include <qlabel.h> #include <qlabel.h>
#include "qgsmaplayer.h" #include "qgsmaplayer.h"
@ -39,6 +40,7 @@ QgsLayerProperties::QgsLayerProperties(QgsMapLayer * lyr):layer(lyr)
btnSetColor->setPaletteBackgroundColor(sym->color()); btnSetColor->setPaletteBackgroundColor(sym->color());
btnSetFillColor->setPaletteBackgroundColor(sym->fillColor()); btnSetFillColor->setPaletteBackgroundColor(sym->fillColor());
spinLineWidth->setValue(sym->lineWidth());
setCaption("Layer Properties - " + lyr->name()); setCaption("Layer Properties - " + lyr->name());
} }
@ -68,3 +70,9 @@ void QgsLayerProperties::selectOutlineColor()
QString QgsLayerProperties::displayName(){ QString QgsLayerProperties::displayName(){
return txtDisplayName->text(); return txtDisplayName->text();
} }
void QgsLayerProperties::setLineWidth(int w){
sym->setLineWidth(w);
}

View File

@ -41,6 +41,7 @@ public:
void selectOutlineColor(); void selectOutlineColor();
//! Name to display in legend //! Name to display in legend
QString displayName(); QString displayName();
void setLineWidth(int w);
private: private:
QgsMapLayer *layer; QgsMapLayer *layer;
QgsSymbol *sym; QgsSymbol *sym;

View File

@ -114,6 +114,22 @@
<attribute name="title"> <attribute name="title">
<string>Symbology</string> <string>Symbology</string>
</attribute> </attribute>
<widget class="QLabel">
<property name="name">
<cstring>TextLabel1_4</cstring>
</property>
<property name="geometry">
<rect>
<x>156</x>
<y>18</y>
<width>51</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Line width</string>
</property>
</widget>
<widget class="QLabel"> <widget class="QLabel">
<property name="name"> <property name="name">
<cstring>TextLabel1_2</cstring> <cstring>TextLabel1_2</cstring>
@ -185,6 +201,22 @@
<string></string> <string></string>
</property> </property>
</widget> </widget>
<widget class="QSpinBox">
<property name="name">
<cstring>spinLineWidth</cstring>
</property>
<property name="geometry">
<rect>
<x>210</x>
<y>20</y>
<width>56</width>
<height>20</height>
</rect>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</widget> </widget>
<widget class="QWidget"> <widget class="QWidget">
<property name="name"> <property name="name">
@ -300,8 +332,15 @@
<receiver>QgsLayerPropertiesBase</receiver> <receiver>QgsLayerPropertiesBase</receiver>
<slot>selectFillColor()</slot> <slot>selectFillColor()</slot>
</connection> </connection>
<connection>
<sender>spinLineWidth</sender>
<signal>valueChanged(int)</signal>
<receiver>QgsLayerPropertiesBase</receiver>
<slot>setLineWidth(int)</slot>
</connection>
</connections> </connections>
<slots> <slots>
<slot>setLineWidth(int)</slot>
<slot>selectFillColor()</slot> <slot>selectFillColor()</slot>
<slot>selectOutlineColor()</slot> <slot>selectOutlineColor()</slot>
</slots> </slots>

View File

@ -78,6 +78,7 @@ void QgsMapCanvas::addLayer(QgsMapLayer * lyr)
blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0)); blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
sym->setColor(QColor(red, green, blue)); sym->setColor(QColor(red, green, blue));
sym->setLineWidth(1);
lyr->setSymbol(sym); lyr->setSymbol(sym);
layers[lyr->name()] = lyr; layers[lyr->name()] = lyr;
// update extent if warranted // update extent if warranted
@ -113,10 +114,10 @@ QgsMapLayer *QgsMapCanvas::getZpos(int index)
void QgsMapCanvas::render2() void QgsMapCanvas::render2()
{ {
QString msg = frozen?"frozen":"thawed"; QString msg = frozen?"frozen":"thawed";
std::cout << "Map canvas is " << msg << std::endl; //std::cout << "Map canvas is " << msg << std::endl;
if(!frozen){ if(!frozen){
if (!drawing) { if (!drawing) {
std::cout << "IN RENDER 2" << std::endl; // std::cout << "IN RENDER 2" << std::endl;
drawing = true; drawing = true;
QPainter *paint = new QPainter(); QPainter *paint = new QPainter();
paint->begin(this); paint->begin(this);
@ -125,7 +126,7 @@ if(!frozen){
double muppX, muppY; double muppX, muppY;
muppY = currentExtent.height() / height(); muppY = currentExtent.height() / height();
muppX = currentExtent.width() / width(); muppX = currentExtent.width() / width();
std::cout << "MuppX is: " << muppX << "\nMuppY is: " << muppY << std::endl; // std::cout << "MuppX is: " << muppX << "\nMuppY is: " << muppY << std::endl;
m_mupp = muppY > muppX ? muppY : muppX; m_mupp = muppY > muppX ? muppY : muppX;
// calculate the actual extent of the mapCanvas // calculate the actual extent of the mapCanvas
double dxmin, dxmax, dymin, dymax, whitespace; double dxmin, dxmax, dymin, dymax, whitespace;
@ -143,8 +144,8 @@ if(!frozen){
dymax = currentExtent.yMax() + whitespace; dymax = currentExtent.yMax() + whitespace;
} }
std::cout << "dxmin: " << dxmin << std::endl << "dymin: " << dymin << std:: // std::cout << "dxmin: " << dxmin << std::endl << "dymin: " << dymin << std::
endl << "dymax: " << dymax << std::endl << "whitespace: " << whitespace << std::endl; // endl << "dymax: " << dymax << std::endl << "whitespace: " << whitespace << std::endl;
coordXForm->setParameters(m_mupp, dxmin, dymin, height()); //currentExtent.xMin(), currentExtent.yMin(), currentExtent.yMax()); coordXForm->setParameters(m_mupp, dxmin, dymin, height()); //currentExtent.xMin(), currentExtent.yMin(), currentExtent.yMax());
// update the currentExtent to match the device coordinates // update the currentExtent to match the device coordinates
currentExtent.setXmin(dxmin); currentExtent.setXmin(dxmin);
@ -153,12 +154,12 @@ if(!frozen){
currentExtent.setYmax(dymax); currentExtent.setYmax(dymax);
// render all layers in the stack, starting at the base // render all layers in the stack, starting at the base
std::map < QString, QgsMapLayer * >::iterator mi = layers.begin(); std::map < QString, QgsMapLayer * >::iterator mi = layers.begin();
std::cout << "MAP LAYER COUNT: " << layers.size() << std::endl; // std::cout << "MAP LAYER COUNT: " << layers.size() << std::endl;
while (mi != layers.end()) { while (mi != layers.end()) {
QgsMapLayer *ml = (*mi).second; QgsMapLayer *ml = (*mi).second;
if(ml){ if(ml){
// QgsDatabaseLayer *dbl = (QgsDatabaseLayer *)&ml; // QgsDatabaseLayer *dbl = (QgsDatabaseLayer *)&ml;
std::cout << "Rendering " << ml->name() << std::endl; // std::cout << "Rendering " << ml->name() << std::endl;
if (ml->visible()) if (ml->visible())
ml->draw(paint, &currentExtent, coordXForm); ml->draw(paint, &currentExtent, coordXForm);
mi++; mi++;
@ -217,8 +218,8 @@ void QgsMapCanvas::paintEvent(QPaintEvent * pe)
{ {
if (!drawing) if (!drawing)
render2(); render2();
else // else
std::cout << "Can't paint in paint event -- drawing = true" << std::endl; // std::cout << "Can't paint in paint event -- drawing = true" << std::endl;
} }
QgsRect QgsMapCanvas::extent() QgsRect QgsMapCanvas::extent()

View File

@ -62,12 +62,12 @@ QgsRect QgsMapLayer::calculateExtent()
} }
void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform) void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform)
{ {
std::cout << "In QgsMapLayer::draw" << std::endl; // std::cout << "In QgsMapLayer::draw" << std::endl;
} }
void QgsMapLayer::draw(QPainter *, QgsRect *, QgsCoordinateTransform *) void QgsMapLayer::draw(QPainter *, QgsRect *, QgsCoordinateTransform *)
{ {
std::cout << "In QgsMapLayer::draw" << std::endl; // std::cout << "In QgsMapLayer::draw" << std::endl;
} }

View File

@ -50,7 +50,7 @@ void QgsNewConnection::testConnection()
"host=" + txtHost->text() + " dbname=" + txtDatabase->text() + "host=" + txtHost->text() + " dbname=" + txtDatabase->text() +
" user=" + txtUsername->text() + " password=" + txtPassword->text(); " user=" + txtUsername->text() + " password=" + txtPassword->text();
PgDatabase *pd = new PgDatabase((const char *) connInfo); PgDatabase *pd = new PgDatabase((const char *) connInfo);
std::cout << pd->ErrorMessage(); // std::cout << pd->ErrorMessage();
if (pd->Status() == CONNECTION_OK) { if (pd->Status() == CONNECTION_OK) {
// Database successfully opened; we can now issue SQL commands. // Database successfully opened; we can now issue SQL commands.
QMessageBox::information(this, "Test connection", "Connection to " + txtDatabase->text() + " was successfull"); QMessageBox::information(this, "Test connection", "Connection to " + txtDatabase->text() + " was successfull");

View File

@ -82,7 +82,7 @@ void QgsShapeFileLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTr
// reset the pointer to read from start of features // reset the pointer to read from start of features
// set the spatial filter // set the spatial filter
std::cout << "Drawing " << dataSource << std::endl; // std::cout << "Drawing " << dataSource << std::endl;
OGRGeometry *filter = 0; OGRGeometry *filter = 0;
filter = new OGRPolygon(); filter = new OGRPolygon();
std::ostrstream wktExtent; std::ostrstream wktExtent;
@ -238,7 +238,7 @@ void QgsShapeFileLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTr
delete[]feature; delete[]feature;
delete fet; delete fet;
} }
std::cout << featureCount << " features in ogr layer within the extent" << std::endl; // std::cout << featureCount << " features in ogr layer within the extent" << std::endl;
OGRGeometry *filt = ogrLayer->GetSpatialFilter(); OGRGeometry *filt = ogrLayer->GetSpatialFilter();
filt->dumpReadable(stdout); filt->dumpReadable(stdout);
ogrLayer->ResetReading(); ogrLayer->ResetReading();

View File

@ -45,3 +45,12 @@ void QgsSymbol::setFillColor(QColor c)
{ {
m_fillColor = c; m_fillColor = c;
} }
int QgsSymbol::lineWidth(){
return m_lineWidth;
}
void QgsSymbol::setLineWidth(int w){
m_lineWidth = w;
}

View File

@ -35,6 +35,8 @@ class QgsSymbol{
//! Get the fill color //! Get the fill color
QColor fillColor(); QColor fillColor();
void setFillColor(QColor c); void setFillColor(QColor c);
int lineWidth();
void setLineWidth(int w);
//! Destructor //! Destructor
~QgsSymbol(); ~QgsSymbol();
/*! Comparison operator /*! Comparison operator
@ -48,5 +50,6 @@ class QgsSymbol{
private: private:
QColor m_color; QColor m_color;
QColor m_fillColor; QColor m_fillColor;
int m_lineWidth;
}; };
#endif // QGSSYMBOL_H #endif // QGSSYMBOL_H