mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
icon for adding raster layer. save/restore raster layers in project files
git-svn-id: http://svn.osgeo.org/qgis/trunk@354 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
6d8b263412
commit
dbabd3a56c
@ -9,7 +9,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>470</height>
|
||||
<height>472</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
@ -106,8 +106,9 @@
|
||||
<property name="label">
|
||||
<string>Data Toolbar</string>
|
||||
</property>
|
||||
<action name="actionAddNonDbLayer"/>
|
||||
<action name="actionAddLayer"/>
|
||||
<action name="actionAddNonDbLayer"/>
|
||||
<action name="actionAddRasterLayer"/>
|
||||
<action name="drawAction"/>
|
||||
</toolbar>
|
||||
<toolbar dock="2">
|
||||
@ -168,7 +169,7 @@
|
||||
<iconset>image1</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add a PostGIS Layer to the map</string>
|
||||
<string>Add a PostGIS Layer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
@ -333,7 +334,7 @@
|
||||
<iconset>image11</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add a vector layer</string>
|
||||
<string>Add a Vector Layer</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add a vector layer (e.g. Shapefile)</string>
|
||||
@ -470,8 +471,11 @@
|
||||
<property name="name">
|
||||
<cstring>actionAddRasterLayer</cstring>
|
||||
</property>
|
||||
<property name="iconSet">
|
||||
<iconset>image18</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add a raster layer</string>
|
||||
<string>Add a Raster Layer</string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
@ -530,6 +534,9 @@
|
||||
<image name="image17">
|
||||
<data format="XPM.GZ" length="1904">789c5dd4c772db301006e0bb9e8223dc3c99357b994c0e72efdd96ec4c0e204855cbb68a8b9cc9bb07fb2fa889c3df3e7ce4120217203737bcdec5a9b7b1d95a2cf572643c33d4736fa37a9d4e573f7ffdf8dd6a07a967ff72df0bdbdf5a6d1a78c6533e1f39dc6b1cf8f0bc7114c0c3c6b1864338e7c02f8d13b9be60077ed08cf70ce71c38638741d0dc9fc0459067257c26e6c0113b0a38f0122ec2c0d577c41cf89d1d876191c8f3aec41cf8949d588532debed89e91f9a78dddfd1fb0e6c00fec34e2c07b709984ee792e1a17315ba17f5994681ffd5053761e5ba35ef5c5ebf146620eae97b0492357af1abbf9c46cb44be6bb03c759e99eef53cc81efe18c03dfc038e073b8e4c0016c38f0015c73e02db6f639f02b1c71e0198c0662fe8f709625ae5f4f620e8cfe681cb0d41b0ebc0b5745ecd6f3d2d9b8fd3081fb1c78cc2e030e7c08471cb880933c76fdda86530efc06e71c18eb55e2806bb8e2c015dce7c0866d420e8cf5343107fdc07a9b3437f27ea8a7c66eff9f8875e2dea75bb18df45fc31907c6fec072e1fe4bbc2f0607c6c77c4d5d18d7bf2bb1ae32f44361fe555a18b73e47625d391f8bcbc4bdcfd7620eeec7f356b576ebabc68d65fe0aeb5367ba72cfe38b39700ef7cbe67eedecea15894dedd6fb4eccc1757cdffa9949ddf85d3147fa418a349564a8a29afa34a0218d684c137aa4293d490fffab18d033bd34153493beff533147cdc2fe2fa5825e65add7156ff44e1fb4a24fead8df43056dc9fe58576cdb9a1ddaa53ddab723a2820e644fad2b0e6dcd111dd3099dd2991dcd56d0b9ecc375c58c2ee892aee8da9e5b4805ddc8de7515633bfe2dddd9746d3ad4e30aba97fdee2a86f4e0ae77c9a78042fb74f7f429ef082a4614b9eb4d3af6f7e624df9943f434b1555f6b528c349277133dcdece85f6b3e6c4dcfd54cecd519e554d8a76de6d35564bb14daff997c1329571a29ed1c9a51ae9451953d57cb77765d33b0bd918a400ddd392de3a8911aab09ce3cdad55ad9751fa8a9fdf55c3d51d0fef3bdf5178af1abfa</data>
|
||||
</image>
|
||||
<image name="image18">
|
||||
<data format="XPM.GZ" length="2221">789ccdd3c952dc301006e0fb3c850bdfa8d48fb7f152a91cd897b00d3ba47290658b7d1fd654de3d52770b8630241c3880b87cd26f59eed68c8d063bab4bc1e858e7baaffa873ad007ea2a186d6e4e4f1f7efcfcf6ab33922481fd2fa22019f9d219e9f5031d2c9f9fb50e082dc2c8fe9511799e1dc76d4e9e23c771620c7983dc6df388f3ebe4dc18f1ac73ac1225f935b23126aec833ce6996f9fd7ae4d29834254f3b674dd73fbfeadcb51b640d79ca392f8a58d657c8369df379279dcba8ac647d996cdf26df37e15c29e59f5f22d7c6547cbeda59456e90c79debb42e25bf48ce8ca9a9987874d64d13c9fa77b6315a93ef9ded7224f5cc9cdbf4a97ea7e4dc75c0396cd85521eb0fecd6bf7f815c1823fbdd399b3cf2df734b2e625fbf1b729966e23eb9ca1af13559e585f88a5c97fe7b2ed995dfef82aceb549cb26dff6372e21d2bf239b9d1fe7d31dbf63b2347ded2df3defbc209f91db3697e777d94ffddcf1aef87ddbde35dfa72d6fcdfb9f908daf378ed97125f7f3889da6721f0fd95923e73b60e7b9dcb77d76e97f3f865d557c9f42cd5625d727acd9752cf569c509dfa7508915d7270cd93ae1f78710d7529f46ace5be55ec2693f394622df529d86d57ea23e7b3378cbf2717b752af2edbf8f54db1bf7fca9bfbd3ebbf7f7c641ea11dea33e4293938d4c7e607cfc3e353d4e7c549fe9f1f3686e551bf3586e5edbc46831606fb38c0218e708c139cda79f53a6f67cf708e0b5ce20ad7e8e306b7b8c33da7ffcedbd9073c621c1398c414a6318359cc61dea75fe6edec02be63114b58c60a56d1c31ad6b1f19c1eccdbd94d6c611b3bd8c51e22c44890221b4c3fe7ed6c17390a94a86c9bc2508575a8c3e665dae7dfaee0f07ef95bf57abca75fffecefefaf9d3f6ae35eac</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -12,7 +12,7 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* qgsprojectio.cpp,v 1.11 2003/11/12 04:44:37 gsherman Exp */
|
||||
/* qgsprojectio.cpp,v 1.12 2003/12/26 15:56:30 stevehalasz Exp */
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <qfiledialog.h>
|
||||
@ -24,6 +24,7 @@
|
||||
#ifdef POSTGRESQL
|
||||
#include "qgsdatabaselayer.h"
|
||||
#endif
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsshapefilelayer.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsrect.h"
|
||||
@ -61,129 +62,131 @@ bool QgsProjectIo::write(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsProjectIo::read(){
|
||||
QString path = selectFileName();
|
||||
QDomDocument *doc;
|
||||
if(!path.isEmpty()){
|
||||
doc = new QDomDocument( "qgisdocument" );
|
||||
QFile file( path );
|
||||
if ( !file.open( IO_ReadOnly ) )
|
||||
return false;
|
||||
if ( !doc->setContent( &file ) ) {
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
// clear the map canvas
|
||||
map->removeAll();
|
||||
// get the extent
|
||||
QDomNodeList extents = doc->elementsByTagName("extent");
|
||||
QDomNode extentNode = extents.item(0);
|
||||
QDomNode xminNode = extentNode.namedItem("xmin");
|
||||
QDomNode yminNode = extentNode.namedItem("ymin");
|
||||
QDomNode xmaxNode = extentNode.namedItem("xmax");
|
||||
QDomNode ymaxNode = extentNode.namedItem("ymax");
|
||||
QDomElement exElement = xminNode.toElement();
|
||||
double xmin = exElement.text().toDouble();
|
||||
exElement = yminNode.toElement();
|
||||
double ymin = exElement.text().toDouble();
|
||||
exElement = xmaxNode.toElement();
|
||||
double xmax = exElement.text().toDouble();
|
||||
exElement = ymaxNode.toElement();
|
||||
double ymax = exElement.text().toDouble();
|
||||
QgsRect savedExtent(xmin,ymin,xmax,ymax);
|
||||
|
||||
|
||||
QDomNodeList nl = doc->elementsByTagName("maplayer");
|
||||
QString layerCount;
|
||||
layerCount = layerCount.setNum(nl.count());
|
||||
//QMessageBox::information(0, "Number of map layers", layerCount);
|
||||
QString wk;
|
||||
// process the map layer nodes
|
||||
for(int i = 0; i < nl.count(); i++){
|
||||
QDomNode node = nl.item(i);
|
||||
QDomElement element = node.toElement();
|
||||
QString type = element.attribute("type");
|
||||
QString visible = element.attribute("visible");
|
||||
|
||||
//QMessageBox::information(0,"Type of map layer", type);
|
||||
// process layer name
|
||||
QDomNode mnl = node.namedItem("layername");
|
||||
QTextStream ts( &wk, IO_WriteOnly );
|
||||
ts << mnl.nodeType();
|
||||
//QMessageBox::information(0,"Node Type", wk);
|
||||
QDomElement mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Layer Name", mne.text());
|
||||
QString layerName = mne.text();
|
||||
|
||||
//process data source
|
||||
mnl = node.namedItem("datasource");
|
||||
mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Datasource Name", mne.text());
|
||||
QString dataSource = mne.text();
|
||||
|
||||
//process zorder
|
||||
mnl = node.namedItem("zorder");
|
||||
mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Zorder", mne.text());
|
||||
|
||||
//process symbology
|
||||
mnl = node.namedItem("symbol");
|
||||
QDomNode snode = mnl.namedItem("linewidth");
|
||||
QDomElement lineElement = snode.toElement();
|
||||
int lineWidth = lineElement.text().toInt();
|
||||
doc = new QDomDocument( "qgisdocument" );
|
||||
QFile file( path );
|
||||
if ( !file.open( IO_ReadOnly ) )
|
||||
return false;
|
||||
if ( !doc->setContent( &file ) ) {
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
file.close();
|
||||
// clear the map canvas
|
||||
map->removeAll();
|
||||
// get the extent
|
||||
QDomNodeList extents = doc->elementsByTagName("extent");
|
||||
QDomNode extentNode = extents.item(0);
|
||||
QDomNode xminNode = extentNode.namedItem("xmin");
|
||||
QDomNode yminNode = extentNode.namedItem("ymin");
|
||||
QDomNode xmaxNode = extentNode.namedItem("xmax");
|
||||
QDomNode ymaxNode = extentNode.namedItem("ymax");
|
||||
QDomElement exElement = xminNode.toElement();
|
||||
double xmin = exElement.text().toDouble();
|
||||
exElement = yminNode.toElement();
|
||||
double ymin = exElement.text().toDouble();
|
||||
exElement = xmaxNode.toElement();
|
||||
double xmax = exElement.text().toDouble();
|
||||
exElement = ymaxNode.toElement();
|
||||
double ymax = exElement.text().toDouble();
|
||||
QgsRect savedExtent(xmin,ymin,xmax,ymax);
|
||||
|
||||
|
||||
snode = mnl.namedItem("outlinecolor");
|
||||
QDomElement colorElement = snode.toElement();
|
||||
int olRed = colorElement.attribute("red").toInt();
|
||||
int olGreen = colorElement.attribute("green").toInt();
|
||||
int olBlue = colorElement.attribute("blue").toInt();
|
||||
QDomNodeList nl = doc->elementsByTagName("maplayer");
|
||||
QString layerCount;
|
||||
layerCount = layerCount.setNum(nl.count());
|
||||
//QMessageBox::information(0, "Number of map layers", layerCount);
|
||||
QString wk;
|
||||
// process the map layer nodes
|
||||
for(int i = 0; i < nl.count(); i++){
|
||||
QDomNode node = nl.item(i);
|
||||
QDomElement element = node.toElement();
|
||||
QString type = element.attribute("type");
|
||||
QString visible = element.attribute("visible");
|
||||
|
||||
//QMessageBox::information(0,"Type of map layer", type);
|
||||
// process layer name
|
||||
QDomNode mnl = node.namedItem("layername");
|
||||
QTextStream ts( &wk, IO_WriteOnly );
|
||||
ts << mnl.nodeType();
|
||||
//QMessageBox::information(0,"Node Type", wk);
|
||||
QDomElement mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Layer Name", mne.text());
|
||||
QString layerName = mne.text();
|
||||
|
||||
snode = mnl.namedItem("fillcolor");
|
||||
colorElement = snode.toElement();
|
||||
int fillRed = colorElement.attribute("red").toInt();
|
||||
int fillGreen = colorElement.attribute("green").toInt();
|
||||
int fillBlue = colorElement.attribute("blue").toInt();
|
||||
|
||||
QgsSymbol *sym = new QgsSymbol();
|
||||
sym->setFillColor( QColor(fillRed, fillGreen, fillBlue));
|
||||
sym->setColor(QColor(olRed, olGreen, olBlue));
|
||||
sym->setLineWidth(lineWidth);
|
||||
// get the linewidth information
|
||||
|
||||
//QMessageBox::information(0,"Zorder", mne.text());
|
||||
|
||||
|
||||
// add the layer to the maplayer
|
||||
|
||||
if(type == "database"){
|
||||
#ifdef POSTGRESQL
|
||||
//process data source
|
||||
mnl = node.namedItem("datasource");
|
||||
mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Datasource Name", mne.text());
|
||||
QString dataSource = mne.text();
|
||||
|
||||
//process zorder
|
||||
mnl = node.namedItem("zorder");
|
||||
mne = mnl.toElement();
|
||||
//QMessageBox::information(0,"Zorder", mne.text());
|
||||
|
||||
//process symbology
|
||||
QgsSymbol *sym = new QgsSymbol();
|
||||
if ( type != "raster" ) {
|
||||
mnl = node.namedItem("symbol");
|
||||
QDomNode snode = mnl.namedItem("linewidth");
|
||||
QDomElement lineElement = snode.toElement();
|
||||
int lineWidth = lineElement.text().toInt();
|
||||
|
||||
|
||||
snode = mnl.namedItem("outlinecolor");
|
||||
QDomElement colorElement = snode.toElement();
|
||||
int olRed = colorElement.attribute("red").toInt();
|
||||
int olGreen = colorElement.attribute("green").toInt();
|
||||
int olBlue = colorElement.attribute("blue").toInt();
|
||||
|
||||
snode = mnl.namedItem("fillcolor");
|
||||
colorElement = snode.toElement();
|
||||
int fillRed = colorElement.attribute("red").toInt();
|
||||
int fillGreen = colorElement.attribute("green").toInt();
|
||||
int fillBlue = colorElement.attribute("blue").toInt();
|
||||
|
||||
sym->setFillColor( QColor(fillRed, fillGreen, fillBlue));
|
||||
sym->setColor(QColor(olRed, olGreen, olBlue));
|
||||
sym->setLineWidth(lineWidth);
|
||||
// get the linewidth information
|
||||
}
|
||||
|
||||
//QMessageBox::information(0,"Zorder", mne.text());
|
||||
|
||||
|
||||
// add the layer to the maplayer
|
||||
|
||||
if(type == "database"){
|
||||
#ifdef POSTGRESQL
|
||||
QgsDatabaseLayer *dbl = new QgsDatabaseLayer(dataSource, layerName);
|
||||
|
||||
map->addLayer(dbl);
|
||||
dbl->setSymbol(sym);
|
||||
dbl->setVisible(visible == "1");
|
||||
#endif
|
||||
}else{
|
||||
if(type == "vector"){
|
||||
#endif
|
||||
} else if ( type == "vector" ) {
|
||||
QgsShapeFileLayer *shpl = new QgsShapeFileLayer(dataSource, layerName);
|
||||
|
||||
map->addLayer(shpl);
|
||||
shpl->setSymbol(sym);
|
||||
shpl->setVisible(visible == "1");
|
||||
}else{
|
||||
if(type == "raster"){
|
||||
}
|
||||
}
|
||||
} else if ( type == "raster" ) {
|
||||
QgsRasterLayer *rastl = new QgsRasterLayer(dataSource, layerName);
|
||||
|
||||
map->addLayer(rastl);
|
||||
rastl->setVisible(visible == "1");
|
||||
}
|
||||
|
||||
|
||||
map->setExtent(savedExtent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
map->setExtent(savedExtent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QgsProjectIo::selectFileName(){
|
||||
if(action == SAVE && fullPath.isEmpty()){
|
||||
action = SAVEAS;
|
||||
@ -262,17 +265,19 @@ void QgsProjectIo::writeXML(){
|
||||
}
|
||||
xml << "\t\t<datasource>" + lyr->source() + "</datasource>\n";
|
||||
xml << "\t\t<zorder>" << i << "</zorder>\n";
|
||||
xml << "\t\t<symbol>\n";
|
||||
QgsSymbol *sym = lyr->symbol();
|
||||
xml << "\t\t\t<linewidth>" << sym->lineWidth() << "</linewidth>\n";
|
||||
QColor outlineColor = sym->color();
|
||||
xml << "\t\t\t<outlinecolor red=\"" << outlineColor.red() << "\" green=\""
|
||||
<< outlineColor.green() << "\" blue=\"" << outlineColor.blue() << "\" />\n";
|
||||
QColor fillColor = sym->fillColor();
|
||||
xml << "\t\t\t<fillcolor red=\"" << fillColor.red() << "\" green=\""
|
||||
<< fillColor.green() << "\" blue=\"" << fillColor.blue() << "\" />\n";
|
||||
|
||||
xml << "\t\t</symbol>\n";
|
||||
if ( lyr->type() != QgsMapLayer::RASTER ) {
|
||||
xml << "\t\t<symbol>\n";
|
||||
QgsSymbol *sym = lyr->symbol();
|
||||
xml << "\t\t\t<linewidth>" << sym->lineWidth() << "</linewidth>\n";
|
||||
QColor outlineColor = sym->color();
|
||||
xml << "\t\t\t<outlinecolor red=\"" << outlineColor.red() << "\" green=\""
|
||||
<< outlineColor.green() << "\" blue=\"" << outlineColor.blue() << "\" />\n";
|
||||
QColor fillColor = sym->fillColor();
|
||||
xml << "\t\t\t<fillcolor red=\"" << fillColor.red() << "\" green=\""
|
||||
<< fillColor.green() << "\" blue=\"" << fillColor.blue() << "\" />\n";
|
||||
|
||||
xml << "\t\t</symbol>\n";
|
||||
}
|
||||
xml << "\t</maplayer>\n";
|
||||
}
|
||||
xml << "</projectlayers>\n";
|
||||
|
95
src/xpm/add_raster.xpm
Normal file
95
src/xpm/add_raster.xpm
Normal file
@ -0,0 +1,95 @@
|
||||
/* XPM */
|
||||
static char * add_raster_xpm[] = {
|
||||
"22 22 70 1",
|
||||
" c None",
|
||||
". c #000080",
|
||||
"+ c #FFFFFF",
|
||||
"@ c #A0A0A0",
|
||||
"# c #FFE6E6",
|
||||
"$ c #FFCCCC",
|
||||
"% c #FFB2B2",
|
||||
"& c #FF9999",
|
||||
"* c #FF8080",
|
||||
"= c #FF6666",
|
||||
"- c #FF4D4D",
|
||||
"; c #FF3333",
|
||||
"> c #FF1919",
|
||||
", c #FF0000",
|
||||
"' c #E60000",
|
||||
") c #FEE6FF",
|
||||
"! c #FDCDFF",
|
||||
"~ c #FCB3FF",
|
||||
"{ c #FB9AFF",
|
||||
"] c #FB80FF",
|
||||
"^ c #FA67FF",
|
||||
"/ c #F94DFF",
|
||||
"( c #F834FF",
|
||||
"_ c #F71AFF",
|
||||
": c #F601FF",
|
||||
"< c #DD00E6",
|
||||
"[ c #E6E8FF",
|
||||
"} c #CDD0FF",
|
||||
"| c #B3B8FF",
|
||||
"1 c #9AA1FF",
|
||||
"2 c #8089FF",
|
||||
"3 c #6771FF",
|
||||
"4 c #4D5AFF",
|
||||
"5 c #3442FF",
|
||||
"6 c #1A2AFF",
|
||||
"7 c #0112FF",
|
||||
"8 c #0011E6",
|
||||
"9 c #E7FFE6",
|
||||
"0 c #CDFFCC",
|
||||
"a c #B4FFB2",
|
||||
"b c #9BFF99",
|
||||
"c c #82FF80",
|
||||
"d c #6AFF66",
|
||||
"e c #51FF4D",
|
||||
"f c #38FF33",
|
||||
"g c #1FFF19",
|
||||
"h c #06FF00",
|
||||
"i c #05E600",
|
||||
"j c #FFFFE6",
|
||||
"k c #FEFFCD",
|
||||
"l c #FEFFB3",
|
||||
"m c #FEFF9A",
|
||||
"n c #FEFF80",
|
||||
"o c #FDFF67",
|
||||
"p c #FDFF4D",
|
||||
"q c #FDFF34",
|
||||
"r c #FCFF1A",
|
||||
"s c #FCFF01",
|
||||
"t c #E3E600",
|
||||
"u c #FFF6E6",
|
||||
"v c #FFEECD",
|
||||
"w c #FFE5B3",
|
||||
"x c #FFDC9A",
|
||||
"y c #FFD480",
|
||||
"z c #FFCB67",
|
||||
"A c #FFC24D",
|
||||
"B c #FFBA34",
|
||||
"C c #FFB11A",
|
||||
"D c #FFA801",
|
||||
"E c #E69700",
|
||||
" ",
|
||||
" ",
|
||||
" ..+ ",
|
||||
" ..+ ",
|
||||
" ..+ ",
|
||||
" ........+ ",
|
||||
" ........+ ",
|
||||
" ..++++ ",
|
||||
" ..+ ",
|
||||
" ..+ ",
|
||||
" +++ ",
|
||||
" ",
|
||||
" @@@@@@@@@@@@@ ",
|
||||
" @#$%&*=-;>,'@+ ",
|
||||
" @)!~{]^/(_:<@+ ",
|
||||
" @[}|12345678@+ ",
|
||||
" @90abcdefghi@+ ",
|
||||
" @jklmnopqrst@+ ",
|
||||
" @uvwxyzABCDE@+ ",
|
||||
" @@@@@@@@@@@@@+ ",
|
||||
" +++++++++++++ ",
|
||||
" "};
|
Loading…
x
Reference in New Issue
Block a user