27 #include "../../../../common/Config.h" 28 #include "../../../../core/translator/Translator.h" 29 #include "../../../../core/logger/Logger.h" 31 #include "../../../../dataaccess/dataset/DataSetType.h" 32 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h" 33 #include "../../../../dataaccess/datasource/DataSourceManager.h" 35 #include "../../../../dataaccess/datasource/DataSourceCapabilities.h" 36 #include "../../../../maptools/AbstractLayer.h" 37 #include "../../../widgets/canvas/MultiThreadMapDisplay.h" 38 #include "../../../widgets/datasource/core/DataSourceTypeManager.h" 39 #include "../../../widgets/layer/explorer/LayerItemView.h" 40 #include "../../../widgets/layer/utils/DataSet2Layer.h" 41 #include "../../../widgets/raster/RasterInfoDialog.h" 42 #include "../../../widgets/raster/RasterInfoWidget.h" 43 #include "../../../widgets/Utils.h" 45 #include "../../../af/ApplicationController.h" 46 #include "../../../af/BaseApplication.h" 47 #include "../../../af/Utils.h" 48 #include "../../../af/events/LayerEvents.h" 49 #include "../../../af/events/ApplicationEvents.h" 54 #include "../../../../cellspace/CellSpaceOperations.h" 57 #include <boost/uuid/random_generator.hpp> 58 #include <boost/uuid/uuid_io.hpp> 59 #include <boost/filesystem.hpp> 63 #include <QFileDialog> 66 #include <QMessageBox> 72 std::list<te::da::DataSetTypePtr> res;
76 std::vector<std::string> dsets = ds->getDataSetNames();
78 std::vector<std::string>::iterator it;
80 for(it = dsets.begin(); it != dsets.end(); ++it)
104 std::list<te::map::AbstractLayerPtr> res;
113 te::core::CppPlugin(pluginInfo),
115 m_openMultipleFiles(nullptr),
116 m_handlerLayerExplorer(nullptr),
117 m_handlerMapDisplay(nullptr)
136 m_openMultipleFiles =
new QAction(QIcon::fromTheme(
"file-raster"), tr(
"Raster File..."),
this);
139 m_openFile =
new QAction(QIcon::fromTheme(
"file-raster"), tr(
"RAW Raster File..."),
this);
140 m_openFile->setObjectName(
"Project.Add Layer.RAW Raster File");
193 std::unique_ptr< te::qt::widgets::RasterInfoDialog > diagPtr(
197 if( diagPtr->getWidget()->getShortName().empty() )
202 QFileInfo
info( diagPtr->getWidget()->getFullName().c_str() );
203 QStringList fileNames;
204 fileNames << diagPtr->getWidget()->getFullName().c_str();
208 std::list<te::map::AbstractLayerPtr> layers;
210 for(QStringList::iterator it = fileNames.begin(); it != fileNames.end(); ++it)
215 ds->setAccessDriver(
"GDAL");
216 std::string fpath = it->toUtf8().data();
217 ds->setConnInfo(
"file://" + fpath);
219 ds->setDescription(
"A single raster file");
221 boost::uuids::basic_random_generator<boost::mt19937> gen;
222 boost::uuids::uuid u = gen();
223 std::string
id = boost::uuids::to_string(u);
227 boost::filesystem::path mpath(it->toUtf8().data());
229 std::string fileBaseName = mpath.stem().string();
231 ds->setTitle(fileBaseName);
238 layer =
GetLayer(ds, mpath.leaf().string());
240 layers.push_back(layer);
247 std::list<te::map::AbstractLayerPtr>::iterator it;
248 for(it = layers.begin(); it != layers.end(); ++it)
257 QStringList fileNames = QFileDialog::getOpenFileNames(
262 if(fileNames.isEmpty())
265 QFileInfo
info(fileNames.value(0));
269 std::list<te::map::AbstractLayerPtr> layers;
This event signals that a new layer was created.
Plugin(const te::core::PluginInfo &pluginInfo)
void CreateLayers(QStringList fileNames, std::list< te::map::AbstractLayerPtr > &layers)
boost::shared_ptr< DataSetType > DataSetTypePtr
boost::shared_ptr< DataSource > DataSourcePtr
QList< QAction * > m_actions
Basic information about a plugin.
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
void openMultipleFilesDialog()
A class used to handle geofile drag and drop events.
void triggered(te::qt::af::evt::Event *e)
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
QAction * m_openMultipleFiles
te::map::AbstractLayerPtr GetLayer(const te::da::DataSourceInfoPtr &info, std::string fileName)
te::map::AbstractLayerPtr GetLayer(const te::da::DataSourceInfoPtr &info, std::string fileName)
te::qt::widgets::LayerItemView * getLayerExplorer()
std::list< te::da::DataSetTypePtr > GetDataSetsInfo(const te::da::DataSourceInfoPtr &info)
#define TERRALIB_PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
te::qt::plugins::gdal::GeoFileDragAndDropHandler * m_handlerMapDisplay
Utility routines for the TerraLib Application Framework module.
te::qt::plugins::gdal::GeoFileDragAndDropHandler * m_handlerLayerExplorer
const PluginInfo & info() const
It returns the PluginInfo of the CppPlugin.
void shutdown()
This method will be called by applicatons to shutdown plugin's functionality.
te::qt::widgets::MapDisplay * getMapDisplay()
#define TE_LOG_TRACE(message)
Use this tag in order to log a message to the TerraLib default logger with the TRACE level...
A class that represents a data source component.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
Plugin implementation for the GDAL data source widget.
void GetLayers(const te::da::DataSourceInfoPtr &info, std::list< te::map::AbstractLayerPtr > &layers)
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
void startup()
This method will be called by applications to startup some plugin's functionality.