27 #include "../../../../common/Config.h"
28 #include "../../../../common/Translator.h"
29 #include "../../../../common/Logger.h"
30 #include "../../../../dataaccess/dataset/DataSetType.h"
31 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
32 #include "../../../../dataaccess/datasource/DataSourceManager.h"
33 #include "../../../../maptools/AbstractLayer.h"
34 #include "../../../widgets/datasource/core/DataSourceTypeManager.h"
35 #include "../../../widgets/layer/utils/DataSet2Layer.h"
36 #include "../../../widgets/Utils.h"
38 #include "../../../af/ApplicationController.h"
39 #include "../../../af/Project.h"
40 #include "../../../af/Utils.h"
41 #include "../../../af/events/LayerEvents.h"
47 #include <boost/uuid/random_generator.hpp>
48 #include <boost/uuid/uuid_io.hpp>
49 #include <boost/filesystem.hpp>
52 #include <QtGui/QAction>
53 #include <QtGui/QFileDialog>
54 #include <QtGui/QMenu>
55 #include <QtCore/QFileInfo>
56 #include <QtGui/QMessageBox>
60 std::list<te::da::DataSetTypePtr> res;
64 std::vector<std::string> dsets = ds->getDataSetNames();
66 std::vector<std::string>::iterator it;
68 for(it = dsets.begin(); it != dsets.end(); ++it)
76 std::list<te::map::AbstractLayerPtr> res;
85 te::plugin::
Plugin(pluginInfo)
105 m_initialized =
true;
111 if(act != 0 && mnu != 0)
113 QWidget* parent = act->parentWidget();
114 m_openFile =
new QAction(QIcon::fromTheme(
"file-raster"), tr(
"Raster File..."), parent);
115 m_openFile->setObjectName(
"Project.Add Layer.Raster File");
116 mnu->insertAction(act, m_openFile);
121 connect (m_openFile, SIGNAL(triggered()), SLOT(openFileDialog()));
135 m_initialized =
false;
142 QString filter = tr(
"Image File (*.png *.jpg *.jpeg *.tif *.tiff *.geotif *.geotiff);; Web Map Service - WMS (*.xml *.wms);; Web Coverage Service - WCS (*.xml *.wcs);; All Files (*.*)");
146 if(fileNames.isEmpty())
149 QFileInfo info(fileNames.value(0));
153 std::list<te::map::AbstractLayerPtr> layers;
155 for(QStringList::iterator it = fileNames.begin(); it != fileNames.end(); ++it)
159 ds->setAccessDriver(
"GDAL");
161 std::map<std::string, std::string> dsinfo;
162 dsinfo[
"URI"] = it->toStdString();
164 ds->setConnInfo(dsinfo);
166 ds->setDescription(
"A single raster file");
168 boost::uuids::basic_random_generator<boost::mt19937> gen;
169 boost::uuids::uuid u = gen();
170 std::string
id = boost::uuids::to_string(u);
174 boost::filesystem::path mpath(it->toStdString());
176 std::string fileBaseName = mpath.stem().string();
178 ds->setTitle(fileBaseName);
193 if(selectedLayers.size() == 1 && selectedLayers.front()->getType() ==
"FOLDERLAYER")
194 parentLayer = selectedLayers.front();
196 std::list<te::map::AbstractLayerPtr>::iterator it;
197 for(it = layers.begin(); it != layers.end(); ++it)
The basic information about a plugin.
QMenu * findMenu(const QString &id) const
Returns the menu registered with key id.
#define TE_QT_PLUGIN_DATASOURCE_GDAL(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
void startup()
Do nothing! Just set plugin as started.
std::list< te::da::DataSetTypePtr > GetDataSetsInfo(const te::da::DataSourceInfoPtr &info)
TEQTWIDGETSEXPORT QString GetFilePathFromSettings(const QString &typeFile)
Returns the value of the last saved file path for the typeFile required.
A class that represents a data source component.
TEQTWIDGETSEXPORT void AddFilePathToSettings(const QString &path, const QString &typeFile)
Save last used path in QSettings.
static ApplicationController & getInstance()
It gives access to the controller singleton.
#define TE_LOG_TRACE(msg)
Use this tag in order to log a message to a specified logger with the TRACE level.
This event signals that a new layer was created.
#define PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
boost::shared_ptr< DataSource > DataSourcePtr
void GetLayers(const te::da::DataSourceInfoPtr &info, std::list< te::map::AbstractLayerPtr > &layers)
#define TE_ADD_TEXT_DOMAIN(domain, domaindir, codeset)
It adds the given text domain located at domain-dir with the given codeset to the multilingual system...
void shutdown()
Do nothing! Just set plugin as stopped.
Plugin implementation for the GDAL data source widget.
boost::shared_ptr< DataSetType > DataSetTypePtr
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
~Plugin()
Virtual destructor.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
#define TE_QT_PLUGIN_DATASOURCE_GDAL_TEXT_DOMAIN_DIR
It contains the translation catalog directory.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
#define TE_QT_PLUGIN_DATASOURCE_GDAL_TEXT_DOMAIN
It contains the name of the text domain used in the translation of messages in TerraLib GDAL driver i...
QAction * findAction(const QString &id) const
Returns the action identified by id or NULL if there's not an action identified by id...
te::qt::af::Project * getProject()
Get the current project.
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Plugin(const te::plugin::PluginInfo &pluginInfo)
const std::list< te::map::AbstractLayerPtr > getSelectedLayers() const
It gets all the layers that are selected.