Skip to content

Commit

Permalink
Modified projectio (serialisation and deserialisation of project file…
Browse files Browse the repository at this point in the history
…s) to use maplayerregistry and not mapcanvas.

Implemented state handling of 'showInOverview' property in project io.


git-svn-id: http://svn.osgeo.org/qgis/trunk@1554 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jun 10, 2004
1 parent 077dcef commit 3fb49d8
Show file tree
Hide file tree
Showing 10 changed files with 500 additions and 404 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
@@ -1,8 +1,11 @@
QGIS Change Log
ChangeLog,v 1.122 2004/06/10 15:38:53 sbr00pwb Exp
ChangeLog,v 1.123 2004/06/10 23:10:16 timlinux Exp
------------------------------------------------------------------------------
Version 0.3 'Madison' .... development version
2004-06-10 [ts] 0.3.0devel27
** Modified projectio (serialisation and deserialisation of project files) to use maplayerregistry and not mapcanvas.

** Implemented state handling of 'showInOverview' property in project io.
2004-06-10 [petebr] 0.3.0devel26
Tidied up the SPIT gui to match the plugin template.
Fixed bug in scale bar which displayed the bar the wrong size!
Expand Down
4 changes: 2 additions & 2 deletions configure.in
@@ -1,6 +1,6 @@

dnl Process this file with autoconf to produce a configure script.
dnl configure.in,v 1.125 2004/06/10 15:38:53 sbr00pwb Exp
dnl configure.in,v 1.126 2004/06/10 23:10:16 timlinux Exp

AC_INIT

Expand All @@ -24,7 +24,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=3
MICRO_VERSION=0
EXTRA_VERSION=26
EXTRA_VERSION=27
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
Expand Down
6 changes: 5 additions & 1 deletion qgis.dtd
Expand Up @@ -31,7 +31,11 @@
<!ELEMENT datasource (#PCDATA) >
<!ELEMENT zorder (#PCDATA) >
<!-- Attribute Lists -->
<!ATTLIST maplayer
<!--Raster : flag indicating whether the layer should be represented in overview or not -->
<!ELEMENT showInOverviewFlag>
<!-- Attribute lists -->
<!ATTLIST showInOverViewFlag boolean (1|0|true|false) "false">
<!ATTLIST maplayer
type (vector|raster|database) "vector"
visible (1|0) "0"
>
Expand Down
52 changes: 30 additions & 22 deletions qgis.kdevelop
Expand Up @@ -9,7 +9,7 @@
<ignoreparts/>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<description/>
<secondaryLanguages/>
</general>
<kdevautoproject>
Expand All @@ -21,7 +21,7 @@
<mainprogram>src/qgis</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs></programargs>
<programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
Expand Down Expand Up @@ -61,19 +61,19 @@
</debug>
<default>
<configargs>--prefix=$HOME --enable-debug</configargs>
<builddir></builddir>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ldflags></ldflags>
<builddir/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevpgf77options</f77compiler>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<cflags></cflags>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags>-O0 -g3</cxxflags>
<f77flags></f77flags>
<f77flags/>
</default>
</configurations>
<make>
Expand All @@ -84,17 +84,17 @@
<abortonerror>true</abortonerror>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin></makebin>
<makebin/>
</make>
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs></programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<programargs/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
Expand Down Expand Up @@ -142,16 +142,24 @@
<argumentsHintDelay>400</argumentsHintDelay>
<headerCompletionDelay>250</headerCompletionDelay>
</codecompletion>
<references>
<pcs>Qt</pcs>
<pcs>GDAL</pcs>
</references>
<references/>
</kdevcppsupport>
<kdevfileview>
<groups/>
<groups>
<hidenonprojectfiles>false</hidenonprojectfiles>
<hidenonlocation>false</hidenonlocation>
</groups>
<tree>
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
<hidenonprojectfiles>false</hidenonprojectfiles>
<showvcsfields>false</showvcsfields>
</tree>
</kdevfileview>
<kdevcvsservice>
<recursivewhenupdate>true</recursivewhenupdate>
<prunedirswhenupdate>true</prunedirswhenupdate>
<createdirswhenupdate>true</createdirswhenupdate>
<recursivewhencommitremove>true</recursivewhencommitremove>
<revertoptions>-C</revertoptions>
</kdevcvsservice>
</kdevelop>
64 changes: 58 additions & 6 deletions src/qgisapp.cpp
Expand Up @@ -1612,7 +1612,7 @@ void QgisApp::fileOpen()
if (answer != QMessageBox::Cancel)
{
mMapCanvas->freeze(true);
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::OPEN, this);

if (pio->read())
{
Expand All @@ -1630,9 +1630,9 @@ void QgisApp::fileOpen()

void QgisApp::fileSave()
{
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVE);
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVE);
pio->setFileName(mFullPathName);
if (pio->write())
if (pio->write(mMapCanvas->extent()))
{
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
Expand All @@ -1644,8 +1644,8 @@ void QgisApp::fileSave()

void QgisApp::fileSaveAs()
{
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVEAS);
if (pio->write())
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVEAS);
if (pio->write(mMapCanvas->extent()))
{
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
Expand Down Expand Up @@ -1782,7 +1782,7 @@ bool QgisApp::addProject(QString projectFile)
// adds a saved project to qgis, usually called on startup by
// specifying a project file on the command line
bool returnValue = false;
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
QgsProjectIo *pio = new QgsProjectIo(QgsProjectIo::OPEN, this);
#ifdef QGISDEBUG
std::cout << "Loading Project - about to call ProjectIO->read()" << std::endl;
#endif
Expand Down Expand Up @@ -2086,6 +2086,17 @@ void QgisApp::removeLayer()
mMapCanvas->clear();
mMapCanvas->render();
}
void QgisApp::removeAllLayers()
{
std::map<QString, QgsMapLayer *> myMapLayers = mMapLayerRegistry->mapLayers();
std::map<QString, QgsMapLayer *>::iterator myMapIterator;
for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
{
mMapLayerRegistry->removeMapLayer( myMapIterator->first );
}
mOverviewCanvas->clear();
mMapCanvas->clear();
} //remove all layers

void QgisApp::zoomToLayerExtent()
{
Expand Down Expand Up @@ -2789,6 +2800,47 @@ void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString

}

void QgisApp::addMapLayer(QgsMapLayer *theMapLayer)
{
mMapCanvas->freeze();
QApplication::setOverrideCursor(Qt::WaitCursor);
if(theMapLayer->isValid())
{
// Register this layer with the layers registry
mMapLayerRegistry->addMapLayer(theMapLayer);
// init the context menu so it can connect to slots in main app
theMapLayer->initContextMenu(this);
// add it to the mapcanvas collection
mMapCanvas->addLayer(theMapLayer);
//connect up a request from the raster layer to show in overview map
QObject::connect(theMapLayer,
SIGNAL(showInOverview(QString,bool)),
this,
SLOT(setLayerOverviewStatus(QString,bool)));

mProjectIsDirtyFlag = true;
statusBar()->message(mMapCanvas->extent().stringRep(2));

}else
{
QMessageBox::critical(this,"Layer is not valid",
"The layer is not a valid layer and can not be added to the map");
}
qApp->processEvents();
mMapCanvas->freeze(false);
mMapCanvas->render();
QApplication::restoreOverrideCursor();

}

void QgisApp::setExtent(QgsRect theRect)
{
mMapCanvas->setExtent(theRect);
}




int QgisApp::saveDirty()
{
int answer = 0;
Expand Down
8 changes: 8 additions & 0 deletions src/qgisapp.h
Expand Up @@ -115,6 +115,14 @@ Q_OBJECT public:
*/
bool addRasterLayer(QFileInfo const & rasterFile);

/** Add a 'pre-made' map layer to the project */
void addMapLayer(QgsMapLayer *theMapLayer);

/** Set the extents of the map canvas */
void setExtent(QgsRect theRect);

//! Remove all layers from the map and legend
void removeAllLayers();
/** opens a qgis project file
@returns false if unable to open the project
Expand Down
5 changes: 5 additions & 0 deletions src/qgsmaplayerregistry.cpp
Expand Up @@ -91,3 +91,8 @@ void QgsMapLayerRegistry::removeAllMapLayers()
//delete mMapLayers[theLayerId];
//mMapLayers.erase(theLayerId);
}

std::map<QString,QgsMapLayer*> QgsMapLayerRegistry::mapLayers()
{
return mMapLayers;
}
2 changes: 2 additions & 0 deletions src/qgsmaplayerregistry.h
Expand Up @@ -39,6 +39,8 @@ Q_OBJECT;
QStringList mapLayerList();
//! Retrieve a pointer to a loaded plugin by id
QgsMapLayer * mapLayer(QString theLayerId);
//! Retrieve the mapLayers collection (mainly intended for use by projectio)
std::map<QString,QgsMapLayer*> mapLayers();
//! Add a layer to the map of loaded layers
void addMapLayer(QgsMapLayer * theMapLayer);
//! Remove a layer from qgis - any canvases using that layer will need to remove it
Expand Down

0 comments on commit 3fb49d8

Please sign in to comment.