27 #include "../../core/logger/Logger.h" 28 #include "../../edit/qt/Renderer.h" 29 #include "../../edit/qt/tools/CreateLineTool.h" 30 #include "../../edit/qt/tools/VertexTool.h" 31 #include "../../edit/Feature.h" 32 #include "../../edit/Repository.h" 33 #include "../../edit/RepositoryManager.h" 34 #include "../../qt/af/events/MapEvents.h" 35 #include "../../qt/widgets/Utils.h" 36 #include "../../dataaccess/datasource/DataSourceFactory.h" 37 #include "../../dataaccess/datasource/DataSourceInfoManager.h" 38 #include "../../dataaccess/datasource/DataSourceManager.h" 39 #include "../../dataaccess/utils/Utils.h" 40 #include "../../geometry/GeometryProperty.h" 41 #include "../../mnt/core/Profile.h" 42 #include "../../qt/af/ApplicationController.h" 43 #include "../../qt/af/BaseApplication.h" 44 #include "../../qt/af/connectors/MapDisplay.h" 45 #include "../../qt/widgets/canvas/Canvas.h" 46 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h" 47 #include "../../qt/widgets/layer/explorer/LayerItemView.h" 48 #include "../../qt/widgets/layer/utils/DataSet2Layer.h" 49 #include "../../qt/widgets/canvas/MapDisplay.h" 50 #include "../../raster.h" 51 #include "../../statistics/core/Utils.h" 53 #include "../core/Utils.h" 58 #include "ui_ProfileDialogForm.h" 61 #include <QFileDialog> 63 #include <QMessageBox> 70 #include <boost/filesystem.hpp> 74 te::mnt::ProfileDialog::ProfileDialog(
QWidget* parent, Qt::WindowFlags f)
76 m_ui(new
Ui::ProfileDialogForm),
85 m_ui->m_addPointMousePushButton->setIcon(QIcon::fromTheme(
"mnt-profile-line create"));
86 m_ui->m_changePointPushButton->setIcon(QIcon::fromTheme(
"mnt-profile-vertex move"));
87 m_ui->m_addPointPushButton->setIcon(QIcon::fromTheme(
"mnt-profile-vertex create"));
88 m_ui->m_deletePointPushButton->setIcon(QIcon::fromTheme(
"mnt-profile-vertex delete"));
89 m_ui->m_deletePathPushButton->setIcon(QIcon::fromTheme(
"mnt-profile-delete"));
90 m_ui->m_invertPushButton->setIcon(QIcon::fromTheme(
"mnt-profile-invert"));
93 connect(m_ui->m_layerSearchToolButton, SIGNAL(clicked()),
this, SLOT(onInputLayerToolButtonClicked()));
94 connect(m_ui->m_inputLayersComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(onInputComboBoxChanged(
int)));
96 connect(m_ui->m_dummycheckBox, SIGNAL(toggled(
bool)), m_ui->m_dummylineEdit, SLOT(setEnabled(
bool)));
98 connect(m_ui->m_editionradioButton, SIGNAL(toggled(
bool)),
this, SLOT(oneditionEnabled(
bool)));
99 connect(m_ui->m_selectionradioButton, SIGNAL(toggled(
bool)),
this, SLOT(onselectionEnabled(
bool)));
101 connect(m_ui->m_vectorlayersComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(onVectorInputComboBoxChanged(
int)));
103 connect(m_ui->m_okPushButton, SIGNAL(clicked()),
this, SLOT(onOkPushButtonClicked()));
105 connect(m_ui->m_addPointMousePushButton, SIGNAL(toggled(
bool)), SLOT(onaddPointMouseToggled(
bool)));
106 connect(m_ui->m_changePointPushButton, SIGNAL(toggled(
bool)), SLOT(onchangePointToggled(
bool)));
107 connect(m_ui->m_addPointPushButton, SIGNAL(toggled(
bool)), SLOT(onaddPointToggled(
bool)));
108 connect(m_ui->m_deletePointPushButton, SIGNAL(toggled(
bool)), SLOT(ondeletePointToggled(
bool)));
109 connect(m_ui->m_deletePathPushButton, SIGNAL(toggled(
bool)), SLOT(ondeletePathToggled(
bool)));
110 connect(m_ui->m_invertPushButton, SIGNAL(toggled(
bool)), SLOT(oninvertToggled(
bool)));
118 m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins");
119 m_ui->m_helpPushButton->setPageReference(
"plugins/mnt/DTM_Profile.html");
123 setDefaultInterface();
136 m_ui->m_vectorlayersComboBox->clear();
137 m_ui->m_inputLayersComboBox->clear();
139 m_ui->m_vectorlayersComboBox->addItem(QString(
""), QVariant(
""));
141 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
147 if (it->get()->isValid())
149 std::unique_ptr<te::da::DataSetType> dsType(it->get()->getSchema());
152 if (dsType->hasGeom())
165 m_ui->m_vectorlayersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
175 m_ui->m_inputLayersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
182 if (dsType->hasRaster())
183 m_ui->m_inputLayersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
195 m_ui->m_selectionradioButton->setChecked(
true);
196 m_ui->m_trajectorystackedWidget->setCurrentIndex(1);
218 connect(
m_app->
getMapDisplay(), SIGNAL(drawLayersFinished(
const QMap<QString, QString>&)), SLOT(onDrawLayersFinished(
const QMap<QString, QString>&)));
231 QList<mntType> types;
235 if (search.exec() != QDialog::Accepted)
240 int index =
m_ui->m_inputLayersComboBox->findText(search.
getLayer().get()->getTitle().c_str());
241 m_ui->m_inputLayersComboBox->setCurrentIndex(index);
247 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
248 std::string layerID =
m_ui->m_inputLayersComboBox->itemData(index, Qt::UserRole).toString().toUtf8().data();
251 if(layerID == it->get()->getId())
254 std::unique_ptr<te::da::DataSetType> dsType =
m_inputLayer->getSchema();
257 m_ui->m_ZcomboBox->clear();
263 m_ui->m_inputstackedWidget->setCurrentIndex(1);
270 if (!inDataSource.get())
273 std::unique_ptr<te::da::DataSet> inDset(inDataSource->getDataSet(inSetName));
276 std::unique_ptr<te::gm::Geometry> gin(inDset->getGeometry(geo_pos));
279 m_ui->m_ZcomboBox->hide();
280 m_ui->m_Zlabel->hide();
284 m_ui->m_ZcomboBox->show();
285 m_ui->m_Zlabel->show();
286 std::vector<te::dt::Property*> props = dsType->getProperties();
287 for (std::size_t i = 0; i < props.size(); ++i)
289 switch (props[i]->getType())
300 m_ui->m_ZcomboBox->addItem(QString(props[i]->getName().c_str()), QVariant(props[i]->getName().c_str()));
309 m_ui->m_ZcomboBox->hide();
310 m_ui->m_Zlabel->hide();
315 m_ui->m_inputstackedWidget->setCurrentIndex(0);
316 std::unique_ptr<te::da::DataSet> dsRaster = inDataSource->getDataSet(indsLayer->
getDataSetName());
319 std::unique_ptr<te::rst::Raster> in_raster = dsRaster->getRaster(rasterProp->
getName());
320 m_ui->m_dummylineEdit->setText(QString::number(in_raster->getBand(0)->getProperty()->m_noDataValue));
321 m_tol = in_raster->getResolutionX() * 3;
335 m_ui->m_trajectorystackedWidget->setCurrentIndex(0);
345 m_ui->m_addPointMousePushButton->setChecked(
true);
347 m_ui->m_vectorlayersComboBox->setCurrentIndex(0);
358 m_ui->m_trajectorystackedWidget->setCurrentIndex(1);
359 m_ui->m_vectorlayersComboBox->setCurrentIndex(0);
367 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
368 std::string layerID =
m_ui->m_vectorlayersComboBox->itemData(index, Qt::UserRole).toString().toUtf8().data();
371 if(layerID == it->get()->getId())
376 m_ui->m_vectorlayersComboBox->setCurrentIndex(0);
403 QMessageBox::information(
this, tr(
"Profile "), tr(
"SRID Input Layer different from SRID Display"));
418 m_ui->m_addPointMousePushButton->setChecked(
true);
419 m_ui->m_changePointPushButton->setChecked(
false);
420 m_ui->m_addPointPushButton->setChecked(
false);
421 m_ui->m_deletePointPushButton->setChecked(
false);
422 m_ui->m_deletePathPushButton->setChecked(
false);
423 m_ui->m_invertPushButton->setChecked(
false);
441 m_ui->m_changePointPushButton->setChecked(
true);
442 m_ui->m_addPointMousePushButton->setChecked(
false);
443 m_ui->m_addPointPushButton->setChecked(
false);
444 m_ui->m_deletePointPushButton->setChecked(
false);
445 m_ui->m_deletePathPushButton->setChecked(
false);
446 m_ui->m_invertPushButton->setChecked(
false);
464 m_ui->m_addPointPushButton->setChecked(
true);
465 m_ui->m_addPointMousePushButton->setChecked(
false);
466 m_ui->m_changePointPushButton->setChecked(
false);
467 m_ui->m_deletePointPushButton->setChecked(
false);
468 m_ui->m_deletePathPushButton->setChecked(
false);
469 m_ui->m_invertPushButton->setChecked(
false);
487 m_ui->m_deletePointPushButton->setChecked(
true);
488 m_ui->m_addPointMousePushButton->setChecked(
false);
489 m_ui->m_changePointPushButton->setChecked(
false);
490 m_ui->m_addPointPushButton->setChecked(
false);
491 m_ui->m_deletePathPushButton->setChecked(
false);
492 m_ui->m_invertPushButton->setChecked(
false);
513 m_ui->m_deletePathPushButton->setChecked(
true);
514 m_ui->m_addPointMousePushButton->setChecked(
false);
515 m_ui->m_changePointPushButton->setChecked(
false);
516 m_ui->m_addPointPushButton->setChecked(
false);
517 m_ui->m_deletePointPushButton->setChecked(
false);
518 m_ui->m_invertPushButton->setChecked(
false);
537 m_ui->m_invertPushButton->setChecked(
true);
538 m_ui->m_addPointMousePushButton->setChecked(
false);
539 m_ui->m_changePointPushButton->setChecked(
false);
540 m_ui->m_addPointPushButton->setChecked(
false);
541 m_ui->m_deletePointPushButton->setChecked(
false);
542 m_ui->m_deletePathPushButton->setChecked(
false);
554 m_ui->m_addPointMousePushButton->setChecked(
false);
555 m_ui->m_changePointPushButton->setChecked(
false);
556 m_ui->m_addPointPushButton->setChecked(
false);
557 m_ui->m_deletePointPushButton->setChecked(
false);
558 m_ui->m_deletePathPushButton->setChecked(
false);
559 m_ui->m_invertPushButton->setChecked(
false);
601 QApplication::setOverrideCursor(Qt::WaitCursor);
615 m_dummy =
m_ui->m_dummylineEdit->text().toDouble();
622 if (!inDataSource.get())
627 std::unique_ptr<te::da::DataSet> inDset = inDataSource->getDataSet(inDsetName);
630 std::unique_ptr<te::gm::Geometry> gin = inDset->getGeometry(geo_pos);
632 if (!gin.get()->is3D())
634 attrZ =
m_ui->m_ZcomboBox->currentText().toUtf8().data();
637 std::stringstream msg;
638 msg <<
"'" << inDsetName <<
"' " <<
TE_TR(
"Sets Quote Attribute!");
643 std::unique_ptr<te::da::DataSetType> inDsetType(inDataSource->getDataSetType(inDsetName));
645 std::unique_ptr<Profile> profile(
new Profile());
646 profile->setInput(inDataSource, inDsetName, std::move(inDsetType),
m_dummy, attrZ);
649 std::string geostype;
651 if (
m_ui->m_selectionradioButton->isChecked())
655 std::unique_ptr<te::da::DataSet> inDset;
657 if (
m_ui->m_selectCheckBox->isChecked())
667 inDset->moveBeforeFirst();
671 while (inDset->moveNext())
673 std::unique_ptr<te::gm::Geometry> gin = inDset->getGeometry(geo_pos);
675 geostype = gin.get()->getGeometryType();
677 if (geostype ==
"LineString")
682 if (geostype ==
"MultiLineString")
686 for (std::size_t i = 0; i < np; ++i)
703 std::string msg =
"Profile - Start.";
704 #ifdef TERRALIB_LOGGER_ENABLED 708 std::vector<te::gm::LineString*> profileSet;
709 std::unique_ptr<te::da::DataSetType> dsType =
m_inputLayer->getSchema();
710 if (dsType->hasRaster())
712 profile->runRasterProfile(
m_viewed, profileSet);
714 if (dsType->hasGeom())
723 profile->runIsolinesProfile(
m_viewed, profileSet);
729 profile->runTINProfile(
m_viewed, profileSet);
735 msg =
"Profile - End.";
736 #ifdef TERRALIB_LOGGER_ENABLED 743 if (!profileSet.size())
748 QApplication::restoreOverrideCursor();
749 if (result.exec() != QDialog::Accepted)
762 catch (
const std::exception& e)
764 QApplication::restoreOverrideCursor();
765 QMessageBox::information(
this, tr(
"Profile "), e.what());
778 QApplication::restoreOverrideCursor();
791 if (!canvas.getDevice())
795 canvas.setLineWidth(width);
799 for (
unsigned int v = 0; v < visadas.size(); ++v)
805 #ifdef TERRALIB_LOGGER_ENABLED 806 TE_CORE_LOG_DEBUG(
"mnt", tr(
"SRID InputLayer different from SRID Display").toUtf8().data());
809 canvas.draw(visadas[v]);
814 std::unique_ptr<te::gm::Point> point(visadas[v]->getPointN(
p));
815 canvas.draw(point.get());
828 bool changed =
false;
829 for (
size_t i = 0; i <
m_viewed.size(); i++)
846 QMessageBox::information(
this, tr(
"Profile "),
TE_TR(
"No trajectories!"));
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
te::qt::af::BaseApplication * m_app
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
std::list< te::map::AbstractLayerPtr > m_layers
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
void onZoomInToggled(bool checked)
void onPanToggled(bool checked)
boost::shared_ptr< DataSource > DataSourcePtr
void ondeletePointToggled(bool checked)
std::vector< te::gm::LineString * > m_viewed
void onOkPushButtonClicked()
#define TE_CORE_LOG_DEBUG(channel, message)
Use this tag in order to log a message to a specified logger with the DEBUG level.
void ondeletePathToggled(bool checked)
void onDrawTrajectories(const QMap< QString, QString > &)
double m_urx
Upper right corner x-coordinate.
void onchangePointToggled(bool checked)
te::qt::widgets::AbstractTool * m_tool
#define TE_TR(message)
It marks a string in order to get translated.
te::map::AbstractLayerPtr m_outputLayer
std::unique_ptr< Ui::ProfileDialogForm > m_ui
void onInputLayerToolButtonClicked()
void onGeometriesChanged()
void onaddPointMouseToggled(bool checked)
double m_llx
Lower left corner x-coordinate.
std::size_t getNPoints() const
it returns the number of points (vertexes) in the geometry.
LineString is a curve with linear interpolation between points.
static RepositoryManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
void setDefaultInterface()
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
This class represents a set of unique ids created in the same context. i.e. from the same data set...
te::map::AbstractLayerPtr getLayer()
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
void onSelectionToggled(bool checked)
te::map::AbstractLayerPtr getLayer()
void oneditionEnabled(bool)
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
te::qt::widgets::LayerItemView * getLayerExplorer()
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
virtual AbstractData * clone() const =0
It returns a clone of this object.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
double m_lly
Lower left corner y-coordinate.
void oninvertToggled(bool checked)
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
void onselectionEnabled(bool)
void DrawSelected(const std::vector< te::gm::LineString * > visadas, int width=1, bool vertex=true, bool draw=true)
MultiLineString is a MultiCurve whose elements are LineStrings.
const std::string & getDataSetName() const
te::map::AbstractLayerPtr m_inputLayer
double m_ury
Upper right corner y-coordinate.
te::qt::widgets::MapDisplay * getMapDisplay()
void onInputComboBoxChanged(int index)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void setActive(const QList< mntType > &types)
te::da::DataSet * getDataSet(te::da::DataSource *ds)
void onZoomOutToggled(bool checked)
std::vector< te::color::RGBAColor > m_color
This class represents a repository of geometries and features.
A layer with reference to a dataset.
A dialog Show Profile Graphic Result.
mntType m_inputType
Input type (TIN, GRID)
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void onVectorInputComboBoxChanged(int index)
TEMNTEXPORT te::mnt::mntType getMNTType(const te::da::DataSetType *dt)
te::map::AbstractLayerPtr m_trajectoryLayer
Visibility
Each layer can have three states of visibility.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
void onaddPointToggled(bool checked)
virtual const std::string & getDataSourceId() const
const std::string & getName() const
It returns the property name.