ToolBar.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,DataSource
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/plugins/edit/ToolBar.cpp
22 
23  \brief The main toolbar of TerraLib Edit Qt plugin.
24  */
25 
26 // Terralib
27 #include "../../../common/Exception.h"
28 #include "../../../core/translator/Translator.h"
29 #include "../../../dataaccess/dataset/ObjectId.h"
30 #include "../../../dataaccess/dataset/ObjectIdSet.h"
31 #include "../../../dataaccess/datasource/DataSourceInfoManager.h"
32 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
33 #include "../../../dataaccess/utils/Utils.h"
34 #include "../../../datatype/SimpleData.h"
35 #include "../../../edit/Feature.h"
36 #include "../../../edit/Repository.h"
37 #include "../../../edit/RepositoryManager.h"
38 #include "../../../edit/qt/core/UndoStackManager.h"
39 #include "../../../edit/qt/tools/AggregateAreaTool.h"
40 #include "../../../edit/qt/tools/CreateLineTool.h"
41 #include "../../../edit/qt/tools/CreatePointTool.h"
42 #include "../../../edit/qt/tools/CreatePolygonTool.h"
43 #include "../../../edit/qt/tools/DeleteGeometryByAreaTool.h"
44 #include "../../../edit/qt/tools/DeleteGeometryTool.h"
45 #include "../../../edit/qt/tools/DeletePartTool.h"
46 #include "../../../edit/qt/tools/EditInfoTool.h"
47 #include "../../../edit/qt/tools/MergeGeometriesTool.h"
48 #include "../../../edit/qt/tools/MoveGeometryTool.h"
49 #include "../../../edit/qt/tools/RotateGeometryTool.h"
50 #include "../../../edit/qt/tools/SplitPolygonTool.h"
51 #include "../../../edit/qt/tools/SubtractAreaTool.h"
52 #include "../../../edit/qt/tools/VertexTool.h"
53 #include "../../../edit/qt/SnapOptionsDialog.h"
54 #include "../../../edit/qt/Utils.h"
55 #include "../../../geometry/GeometryProperty.h"
56 #include "../../../maptools/DataSetLayer.h"
57 #include "../../../memory/DataSet.h"
58 #include "../../../memory/DataSetItem.h"
59 #include "../../widgets/Utils.h"
60 #include "../../widgets/canvas/MapDisplay.h"
61 #include "../../widgets/canvas/MultiThreadMapDisplay.h"
62 #include "../../widgets/layer/explorer/LayerItemView.h"
63 #include "../../widgets/layer/utils/CreateLayerDialog.h"
64 #include "../../af/ApplicationController.h"
65 #include "../../af/events/ApplicationEvents.h"
66 #include "../../af/events/LayerEvents.h"
67 #include "../../af/events/MapEvents.h"
68 
69 #include "ToolBar.h"
70 #include "Stasher.h"
71 
72 // Qt
73 #include <QActionGroup>
74 #include <QApplication>
75 #include <QMessageBox>
76 #include <QUndoCommand>
77 
78 // Boost
79 #include <boost/ptr_container/ptr_vector.hpp>
80 
81 // STL
82 #include <algorithm>
83 #include <cassert>
84 #include <list>
85 #include <memory>
86 #include <vector>
87 
89 QObject(parent),
90  m_toolBar(0),
91  m_editAction(0),
92  m_saveAction(0),
93  m_clearEditionAction(0),
94  m_vertexToolAction(0),
95  m_createPolygonToolAction(0),
96  m_createLineToolAction(0),
97  m_moveGeometryToolAction(0),
98  m_rotateGeometryToolAction(0),
99  m_snapOptionsAction(0),
100  m_deleteGeometryToolAction(0),
101  m_aggregateAreaToolAction(0),
102  m_subtractAreaToolAction(0),
103  m_featureAttributesAction(0),
104  m_splitPolygonToolAction(0),
105  m_mergeGeometriesToolAction(0),
106  m_createPointToolAction(0),
107  m_createLayerAction(0),
108  m_undoToolAction(0),
109  m_redoToolAction(0),
110  m_undoView(0),
111  m_currentAction(0),
112  m_currentTool(0),
113  m_usingStash(false),
114  m_layerIsStashed(true),
115  m_isEnabled(false),
116  m_toolChecked(false)
117 {
118  initialize();
119 }
120 
122 {
123  if(m_currentTool != 0)
124  {
125  if(m_currentTool->isInUse())
126  {
128  emit triggered(&e);
129 
131  }
132  else
133  delete m_currentTool;
134  }
135 
136  delete m_toolBar;
137  delete m_undoView;
138 }
139 
141 {
142  return m_toolBar;
143 }
144 
146 {
147  if (!m_editAction->isChecked())
148  return;
149 
150  if(layer == 0 || layer->getSRID() == 0)
151  {
152  for (int i = 0; i < m_tools.size(); ++i)
153  m_tools[i]->setEnabled(false);
154 
155  m_editAction->setChecked(false);
156 
157  if (layer->getSRID() == 0)
158  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("SRID invalid."));
159 
160  return;
161  }
162  else
163  {
164  m_toolBar->setEnabled(true);
166  }
167 
169 
170  if(m_currentTool != 0)
171  m_currentTool->setLayer(layer);
172 
173  if(stashed && te::edit::RepositoryManager::getInstance().getRepository(layer->getTitle()) == 0)
174  {
175  std::map<std::string, int> ops;
176  std::map<std::string, te::gm::Geometry*> gms;
177 
178  GetStashedGeometries(layer, gms, ops);
179 
180  for(std::map<std::string, te::gm::Geometry*>::iterator it = gms.begin(); it != gms.end(); ++it)
181  {
182  bool ok;
183  QString id = QString::fromUtf8(it->first.c_str());
185 
186  int v = id.toInt(&ok);
187 
188  if(!ok)
189  {
190  te::dt::String* data = new te::dt::String(it->first);
191  oid->addValue(data);
192  }
193  else
194  {
195  te::dt::Int32* data = new te::dt::Int32(v);
196  oid->addValue(data);
197  }
198 
199  te::edit::RepositoryManager::getInstance().addGeometry(layer->getId(), oid, it->second);
200  }
201  }
202 }
203 
205 {
207  emit triggered(&e);
208 
210 
211  return layer;
212 }
213 
215 {
217  emit triggered(&evt);
218 
219  std::list<te::map::AbstractLayerPtr>::iterator it;
220  for(it = evt.m_layers.begin(); it != evt.m_layers.end(); ++it)
221  {
222  if((*it)->getId() == id)
223  return *it;
224  }
225 
226  throw te::common::Exception(TE_TR("Could not retrieve the layer."));
227 }
228 
230 {
231  te::da::DataSourceInfoPtr info = te::da::DataSourceInfoManager::getInstance().get(layer->getDataSourceId());
232 
233  if (info->getType() != "POSTGIS" && info->getType() != "OGR")
234  {
235  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Under Development to this data source: ") + QString(info->getType().c_str()));
236  return false;
237  }
238 
239  if (info->getType() == "OGR")
240  return true;
241 
242  std::unique_ptr<te::da::DataSetType> toSchema = layer->getSchema();
243 
244  if (!toSchema->getPrimaryKey() || toSchema->getPrimaryKey()->getProperties().empty())
245  {
246  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Invalid Data Set Primary Key."));
247  return false;
248  }
249 
250  std::vector<te::dt::Property*> pkProps = toSchema->getPrimaryKey()->getProperties();
251 
252  bool hasAutoIncrement = false;
253  for (std::size_t j = 0; j < pkProps.size(); ++j)
254  {
255  te::dt::SimpleProperty* simpleProp = dynamic_cast<te::dt::SimpleProperty*>(pkProps[j]);
256 
257  if (simpleProp)
258  {
259  if (simpleProp->isAutoNumber())
260  {
261  hasAutoIncrement = true;
262  break;
263  }
264  }
265  }
266 
267  if (!hasAutoIncrement)
268  {
269  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), tr("The Primary Key has not auto-increment!"));
270  return false;
271  }
272 
273  return true;
274 }
275 
277 {
278  // Create the main toolbar
279  m_toolBar = new QToolBar("Edit Tool Bar");
280 
282 
283  m_saveAction->setEnabled(true);
284 
285  for (int i = 0; i < m_tools.size(); ++i)
286  m_tools[i]->setEnabled(true);
287 
288  m_snapOptionsAction->setEnabled(true);
289  m_createLayerAction->setEnabled(true);
290 
292 }
293 
295 {
296  // Enable Edition Mode
297  createAction(m_editAction, tr("Turn on/off edition mode"), QString("edit-enable"), true, true, "edit_enable", SLOT(onEditActivated(bool)));
298  m_toolBar->addAction(m_editAction);
299 
300  m_toolBar->addSeparator();
301 
302  // Save
303  createAction(m_saveAction, tr("Save edition"), "edit-save", false, false, "save_edition", SLOT(onSaveActivated()));
304  m_toolBar->addAction(m_saveAction);
305 
306  // Cancel all Edition
307  createAction(m_clearEditionAction, tr("Cancel all edition [ESC]"), "clearEdition", false, false, "cancel_edition", SLOT(onResetVisualizationToolActivated(bool)));
308  m_clearEditionAction->setShortcut(Qt::Key_Escape);
309  m_toolBar->addAction(m_clearEditionAction);
310 
311  // Undo/Redo
313  emit triggered(&e);
314  QUndoStack* undoStack = te::edit::UndoStackManager::getInstance().getUndoStack();
315 
316  if (undoStack)
317  {
318  m_undoToolAction = undoStack->createUndoAction(this, tr("&Undo"));
319  m_undoToolAction->setShortcuts(QKeySequence::Undo);
320  m_undoToolAction->setObjectName("redo");
321  m_undoToolAction->setIcon(QIcon::fromTheme("edit-undo"));
322  m_undoToolAction->setToolTip("Undo Action");
323 
324  m_redoToolAction = undoStack->createRedoAction(this, tr("&Redo"));
325  m_redoToolAction->setShortcuts(QKeySequence::Redo);
326  m_redoToolAction->setObjectName("undo");
327  m_redoToolAction->setIcon(QIcon::fromTheme("edit-redo"));
328  m_redoToolAction->setToolTip("Redo Action");
329  }
330 
331  m_digitStepComboBox = new QComboBox;
332 
333  //Insert items on m_digitStepComboBox
334  m_digitStepComboBox->addItem("0.00");
335  m_digitStepComboBox->addItem("0.01");
336  m_digitStepComboBox->addItem("0.02");
337  m_digitStepComboBox->addItem("0.03");
338  m_digitStepComboBox->addItem("0.04");
339  m_digitStepComboBox->addItem("0.05");
340  m_digitStepComboBox->addItem("0.06");
341  m_digitStepComboBox->addItem("0.07");
342  m_digitStepComboBox->addItem("0.08");
343  m_digitStepComboBox->addItem("0.09");
344  m_digitStepComboBox->addItem("0.10");
345  m_digitStepComboBox->setToolTip("Digitalization step (mm)");
346 
347  // Tools
348  createAction(m_createPolygonToolAction, tr("Create Polygon"), "edit-create-polygon", true, false, "create_polygon", SLOT(onCreatePolygonToolActivated(bool)));
349  createAction(m_createLineToolAction, tr("Create Line"), "layout-drawline", true, false,"create_line", SLOT(onCreateLineToolActivated(bool)));
350  createAction(m_createPointToolAction, tr("Create Point"), "edit-create-point", true, false, "create_point", SLOT(onCreatePointToolActivated(bool)));
351  createAction(m_moveGeometryToolAction, tr("Move Geometry"), "edit-move-geometry", true, false, "move_geometry", SLOT(onMoveGeometryToolActivated(bool)));
352  createAction(m_rotateGeometryToolAction, tr("Rotate Geometry"), "edit-rotate-geometry", true, false, "rotate_geometry", SLOT(onRotateGeometryToolActivated(bool)));
353  createAction(m_vertexToolAction, tr("Vertex Tool - Move, \nAdd [Double Click] and \nRemove [Shift+Click]"), "edit-vertex-tool", true, false, "vertex_tool", SLOT(onVertexToolActivated(bool)));
354  createAction(m_aggregateAreaToolAction, tr("Aggregate Area"), "edit-aggregateGeometry", true, false, "aggregate_area", SLOT(onAggregateAreaToolActivated(bool)));
355  createAction(m_subtractAreaToolAction, tr("Subtract Area"), "edit-subtractGeometry", true, false, "subtract_area", SLOT(onSubtractAreaToolActivated(bool)));
356  createAction(m_mergeGeometriesToolAction, tr("Merge Geometries"), "edition_mergeGeometries", true, true, "merge_geometries", SLOT(onMergeGeometriesToolActivated(bool)));
357  createAction(m_splitPolygonToolAction, tr("Split Polygon"), "edit-cut", true, true, "split_polygon", SLOT(onSplitPolygonToolActivated(bool)));
358  createAction(m_featureAttributesAction, tr("Feature Attributes"), "edit-Info", true, true, "feature_attributes", SLOT(onFeatureAttributesActivated(bool)));
359  createAction(m_deleteGeometryToolAction, tr("Delete Geometry\nDelete Geometry by Area"), "edit-deletetool", true, false, "delete_geometry", SLOT(onDeleteGeometryToolActivated(bool)));
360  createAction(m_snapOptionsAction, tr("Snap Options"), "edit_snap", false, false, "snap_option", SLOT(onSnapOptionsActivated()));
361  createAction(m_createLayerAction, tr("Create Layer..."), "layer-new", false, false, "create_layer", SLOT(onCreateLayerActivated()));
362 
363  m_toolBar->addAction(m_saveAction);
364  m_toolBar->addSeparator();
365  m_toolBar->addAction(m_undoToolAction);
366  m_toolBar->addAction(m_redoToolAction);
367  m_toolBar->addSeparator();
369  m_toolBar->addAction(m_createLineToolAction);
371  m_toolBar->addSeparator();
374  m_toolBar->addAction(m_vertexToolAction);
375  m_toolBar->addSeparator();
379  m_toolBar->addSeparator();
382  m_toolBar->addSeparator();
384  m_toolBar->addSeparator();
385  m_toolBar->addAction(m_snapOptionsAction);
386  m_toolBar->addSeparator();
387  m_toolBar->addAction(m_createLayerAction);
388  m_toolBar->addSeparator();
389  m_toolBar->addWidget(m_digitStepComboBox);
390 
391  // Get the action group of map tools.
392  QActionGroup* toolsGroup = te::qt::af::AppCtrlSingleton::getInstance().findActionGroup("Map.ToolsGroup");
393  assert(toolsGroup);
394 
395  // Adding the new tools
396  toolsGroup->addAction(m_vertexToolAction);
397  toolsGroup->addAction(m_createPolygonToolAction);
398  toolsGroup->addAction(m_createLineToolAction);
399  toolsGroup->addAction(m_createPointToolAction);
400  toolsGroup->addAction(m_moveGeometryToolAction);
401  toolsGroup->addAction(m_rotateGeometryToolAction);
402  toolsGroup->addAction(m_aggregateAreaToolAction);
403  toolsGroup->addAction(m_subtractAreaToolAction);
404  toolsGroup->addAction(m_deleteGeometryToolAction);
405  toolsGroup->addAction(m_featureAttributesAction);
406  toolsGroup->addAction(m_splitPolygonToolAction);
407  toolsGroup->addAction(m_mergeGeometriesToolAction);
408 
409  // Grouping...
410  m_tools.push_back(m_saveAction);
411  m_tools.push_back(m_clearEditionAction);
413  m_tools.push_back(m_createLineToolAction);
414  m_tools.push_back(m_createPointToolAction);
415  m_tools.push_back(m_vertexToolAction);
424 
425  connect(m_digitStepComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onDigitStepComboBoxChanged(int)));
426  connect(toolsGroup, SIGNAL(triggered(QAction*)), this, SLOT(onActionChanged(QAction*)));
427 }
428 
429 void te::qt::plugins::edit::ToolBar::createAction(QAction*& action, const QString& tooltip, const QString& icon, bool checkable, bool enabled, const QString& objName, const char* member)
430 {
431  action = new QAction(this);
432  action->setIcon(QIcon::fromTheme(icon));
433  action->setToolTip(tooltip);
434  action->setCheckable(checkable);
435  action->setEnabled(enabled);
436  action->setObjectName(objName);
437  connect(action, SIGNAL(triggered(bool)), this, member);
438 }
439 
441 {
442  m_isEnabled = checked;
443 
445 
447 
449 
451  emit triggered(&e);
452 
453  if (e.m_display == 0)
454  return;
455 
456  if (!m_isEnabled)
457  {
458  QPixmap* draft = e.m_display->getDisplay()->getDraftPixmap();
459  draft->fill(Qt::transparent);
460 
461  // Clear the repositories
462  std::map<std::string, te::edit::Repository*> repositories = te::edit::RepositoryManager::getInstance().getRepositories();
463 
464  std::map<std::string, te::edit::Repository*>::const_iterator it;
465  for (it = repositories.begin(); it != repositories.end(); ++it)
466  {
467  if (it->second)
468  it->second->clear();
469  }
470 
471  // Clear the undo stack
472  te::edit::UndoStackManager::getInstance().getUndoStack()->clear();
473 
474  m_toolChecked = false;
475  }
476 
477  e.m_display->getDisplay()->repaint();
478 }
479 
481 {
482  std::unique_ptr<te::da::DataSourceTransactor> t;
483 
485  if (layer.get() == 0)
486  return;
487 
488  // To clear and repaint
490  emit triggered(&e);
491 
493  {
494  std::map<std::string, te::edit::Repository*> repositories = te::edit::RepositoryManager::getInstance().getRepositories();
495 
496  std::map<std::string, te::edit::Repository*>::iterator it;
497 
498  std::map<std::string, int> ops;
499 
500  // Retrieve the layer associated with the current repository
501  layer = getSelectedLayer();
502  assert(layer.get());
503 
504  // The current repository
505  te::edit::Repository* repo = repositories[layer->getId()];
506  assert(repo);
507 
508  // Get the edited geometries
509  const std::vector<te::edit::Feature*>& features = repo->getAllFeatures();
510 
511  std::map<std::string, te::gm::Geometry*> gs;
512 
513  for(std::vector<te::edit::Feature*>::const_iterator fIt = features.begin(); fIt != features.end(); ++fIt)
514  {
515  te::da::ObjectId* oid = (*fIt)->getId();
516  assert(oid);
517 
518  // Get the edited geometry
519  te::gm::Geometry* geom = (*fIt)->getGeometry();
520  assert(geom);
521 
522  std::string sOid = oid->getValueAsString();
523 
524  gs[sOid] = geom;
525 
526  ops[sOid] = (int)(*fIt)->getOperationTypeId();
527  }
528 
529  StashGeometries(layer.get(), gs, ops);
530 
531  emit stashed(layer.get());
532 
533  m_layerIsStashed = true;
534 
535  return;
536  }
537 
538  try
539  {
540 
541  std::map<std::string, te::edit::Repository*> repositories = te::edit::RepositoryManager::getInstance().getRepositories();
542 
543  std::map<std::string, te::edit::Repository*>::iterator it = repositories.find(layer->getId());
544 
545  if(it != repositories.end())
546  {
547  // The current repository
548  te::edit::Repository* repo = it->second;
549  assert(repo);
550 
551  // Retrieve the layer associated with the current repository
552  layer = getLayer(it->first);
553  assert(layer.get());
554 
555  // The data source is it prepared?
556  if (!dataSrcIsPrepared(layer))
557  return;
558 
559  // Get the data souce info
560  te::da::DataSourceInfoPtr info = te::da::DataSourceInfoManager::getInstance().get(layer->getDataSourceId());
561  assert(info.get());
562 
563  te::da::DataSourcePtr dsource = te::da::GetDataSource(layer->getDataSourceId(), true);
564  assert(dsource.get());
565 
566  // Start the transactor
567  t = dsource->getTransactor();
568 
569  // Get the layer schema
570  std::unique_ptr<te::map::LayerSchema> schema(layer->getSchema());
571  assert(schema.get());
572 
573  // Get the property names that compose the object id
574  std::vector<std::string> oidPropertyNames;
575  te::da::GetOIDPropertyNames(schema.get(), oidPropertyNames);
576 
577  // Get the edited geometries
578  const std::vector<te::edit::Feature*>& features = repo->getAllFeatures();
579 
580  // Build the DataSet that will be used to add, update and remove.
581  std::map<te::edit::OperationType, te::mem::DataSet* > featuresTypeDs;
582 
583  //create dataset memory to insert into datasource.
584  featuresTypeDs[te::edit::INSERT] = new te::mem::DataSet(schema.get());
585  //create dataset memory to update into datasource.
586  featuresTypeDs[te::edit::UPDATE] = new te::mem::DataSet(schema.get());
587  //create dataset memory to deletes into datasource.
588  featuresTypeDs[te::edit::DELETE] = new te::mem::DataSet(schema.get());
589 
590  // Get the geometry property position
591  std::size_t gpos = te::da::GetFirstSpatialPropertyPos(featuresTypeDs[te::edit::INSERT]);
592  assert(gpos != std::string::npos);
593 
594  // Responsible to guarantee the data type of oid
595  std::unique_ptr<te::da::DataSet> ds = layer->getData();
596  assert(ds.get());
597 
598  for (std::size_t j = 0; j < oidPropertyNames.size(); ++j)
599  {
600  std::size_t pos = te::da::GetPropertyPos(featuresTypeDs[te::edit::INSERT], oidPropertyNames[j]);
601 
602  featuresTypeDs[te::edit::INSERT]->setPropertyDataType(ds->getPropertyDataType(pos), pos);
603  featuresTypeDs[te::edit::UPDATE]->setPropertyDataType(ds->getPropertyDataType(pos), pos);
604  }
605 
606  std::map<te::edit::OperationType, std::set<int> > propertiesPos;
607 
608  t->begin();
609 
610  for (std::size_t i = 0; i < features.size(); ++i) // for each edited feature
611  {
612  // Create the new item
613  te::mem::DataSetItem* item = new te::mem::DataSetItem(featuresTypeDs[te::edit::INSERT]);
614 
615  // Get the object id
616  te::da::ObjectId* oid = features[i]->getId();
617  if (oid == 0)
618  continue;
619 
620  const boost::ptr_vector<te::dt::AbstractData>& values = oid->getValue();
621  if (values.size() != oidPropertyNames.size())
622  continue;
623 
624  // Fill the new item
625  for (std::size_t j = 0; j < values.size(); ++j)
626  item->setValue(oidPropertyNames[j], values[j].clone());
627 
628  // Get the edited geometry
629  te::gm::Geometry* geom = te::edit::Convert2LayerGeomType(layer, te::gm::Validate(features[i]->getGeometry()), e.m_display->getDisplay()->getSRID());
630  if (geom == 0)
631  continue;
632 
633  // Set the geometry type
634  item->setGeometry(gpos, static_cast<te::gm::Geometry*>(geom->clone()));
635 
636  switch (features[i]->getOperationTypeId())
637  {
638  case te::edit::INSERT:
639  {
640  te::mem::DataSet* tempDs = new te::mem::DataSet(schema.get());
641 
642  std::vector<std::size_t> objIdIdx;
643  te::da::GetOIDPropertyPos(schema.get(), objIdIdx);
644  for (std::map<std::size_t, te::dt::AbstractData*>::const_iterator it = features[i]->getData().begin(); it != features[i]->getData().end(); ++it)
645  {
646  if (std::find(objIdIdx.begin(), objIdIdx.end(), (int)it->first) == objIdIdx.end())
647  item->setValue(it->first, it->second);
648  }
649 
650  tempDs->add(item);
651 
652  // used to not insert the pk
653  for (std::size_t j = 0; j < oidPropertyNames.size(); ++j)
654  {
655  std::size_t pos = te::da::GetPropertyPos(featuresTypeDs[te::edit::INSERT], oidPropertyNames[j]);
656  tempDs->drop(pos);
657  }
658 
659  t->add(layer->getDataSetName(), tempDs, std::map<std::string, std::string>());
660  }
661  break;
662 
663  case te::edit::UPDATE:
664  {
665  std::vector<std::size_t> objIdIdx;
666  te::da::GetOIDPropertyPos(schema.get(), objIdIdx);
667 
668  for (std::map<std::size_t, te::dt::AbstractData*>::const_iterator it = features[i]->getData().begin(); it != features[i]->getData().end(); ++it)
669  {
670  if (std::find(objIdIdx.begin(), objIdIdx.end(), (int)it->first) == objIdIdx.end())
671  {
672  item->setValue(it->first, it->second);
673  propertiesPos[te::edit::UPDATE].insert((int)it->first);
674  }
675  }
676 
677  propertiesPos[te::edit::UPDATE].insert((int)gpos);
678  featuresTypeDs[te::edit::UPDATE]->add(item);
679  }
680  break;
681 
682  case te::edit::DELETE:
683 
684  featuresTypeDs[te::edit::DELETE]->add(item);
685  break;
686 
687  default:
688  break;
689  }
690  }
691 
692  if (featuresTypeDs[te::edit::UPDATE]->size() > 0)
693  {
694  std::vector<std::set<int> > properties;
695  for (std::size_t i = 0; i < featuresTypeDs[te::edit::UPDATE]->size(); ++i)
696  properties.push_back(propertiesPos[te::edit::UPDATE]);
697 
698  std::vector<std::size_t> oidPropertyPosition;
699  for (std::size_t i = 0; i < oidPropertyNames.size(); ++i)
700  oidPropertyPosition.push_back(te::da::GetPropertyPos(featuresTypeDs[te::edit::UPDATE], oidPropertyNames[i]));
701 
702  featuresTypeDs[te::edit::UPDATE]->moveBeforeFirst();
703 
704  t->update(layer->getDataSetName(), featuresTypeDs[te::edit::UPDATE], properties, oidPropertyPosition);
705  }
706 
707  if (featuresTypeDs[te::edit::DELETE]->size() > 0)
708  {
709  std::map<te::edit::OperationType, te::da::ObjectIdSet* > currentOids;
710  currentOids[te::edit::DELETE] = te::da::GenerateOIDSet(featuresTypeDs[te::edit::DELETE], schema.get());
711 
712  featuresTypeDs[te::edit::DELETE]->moveBeforeFirst();
713 
714  t->remove(layer->getDataSetName(), currentOids[te::edit::DELETE]);
715  }
716 
717  // Commit the transaction
718  t->commit();
719 
720  // Clear the repository
721  repo->clear();
722 
723  // Reset the undo stack
725 
726  // Update Box
727  std::unique_ptr<te::da::DataSet> data = layer->getData();
728 
729  std::size_t pos = te::da::GetFirstSpatialPropertyPos(data.get());
730 
731  std::unique_ptr<te::gm::Envelope> env = data->getExtent(pos);
732 
733  layer->setExtent(*env.get());
734 
735  }
736 
737  layer->clearSelected();
738 
739  //update layer
741  if (mtmp)
742  mtmp->updateLayer(layer);
743  else
744  e.m_display->getDisplay()->refresh(true);
745 
746  m_layerIsStashed = false;
747 
748  if (m_currentTool)
750  }
751  catch(const te::common::Exception& ex)
752  {
753  t->rollBack();
754  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), ex.what());
755  return;
756  }
757  catch (const std::exception& e)
758  {
759  t->rollBack();
760  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), e.what());
761  return;
762  }
763  catch (...)
764  {
765  t->rollBack();
766  QMessageBox::critical(this->get(),
767  tr("TerraLib Edit Qt Plugin"),
768  tr("Unknown error while updating data source information!"));
769  return;
770  }
771 
772  emit stashed(layer.get());
773 }
774 
776 {
778  if(layer.get() == 0)
779  {
780  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
782  return;
783  }
784 
786  return;
787 
789  emit triggered(&e);
790 
791  assert(e.m_display);
792 
794 }
795 
797 {
799  return;
800 
802  if(layer.get() == 0)
803  {
804  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
806  return;
807  }
808 
810  emit triggered(&e);
811 
812  assert(e.m_display);
813 
814  setCurrentTool(new te::edit::CreatePolygonTool(e.m_display->getDisplay(), layer, Qt::ArrowCursor, this), e.m_display);
815 }
816 
818 {
820  return;
821 
823  if(layer.get() == 0)
824  {
825  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
827  return;
828  }
829 
831  emit triggered(&e);
832 
833  assert(e.m_display);
834 
835  setCurrentTool(new te::edit::CreateLineTool(e.m_display->getDisplay(), layer, Qt::ArrowCursor, this), e.m_display);
836 }
837 
839 {
841  return;
842 
844  if(layer.get() == 0)
845  {
846  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
848  return;
849  }
850 
852  emit triggered(&e);
853 
854  assert(e.m_display);
855 
857 }
858 
860 {
862 
864  emit triggered(&e);
865 
866  assert(e.m_display);
867 
869  emit triggered(&evt);
870 
871  options.setLayers(evt.m_layers);
872  options.setMapDisplay(e.m_display->getDisplay());
873 
874  options.exec();
875 }
876 
878 {
880  return;
881 
883  if (layer.get() == 0)
884  {
885  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
887  return;
888  }
889 
891  emit triggered(&e);
892 
893  assert(e.m_display);
894 
896 
897 }
898 
900 {
903 
905  if(layer.get() == 0)
906  {
907  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
909  return;
910  }
911 
913  emit triggered(&e);
914 
915  assert(e.m_display);
916 
918 }
919 
921 {
923  return;
924 
926  if(layer.get() == 0)
927  {
928  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
930  return;
931  }
932 
934  emit triggered(&e);
935 
936  assert(e.m_display);
937 
939 }
940 
942 {
943  try
944  {
946  return;
947 
949 
950  if(layer.get() == 0)
951  {
952  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
954  return;
955  }
956 
958  emit triggered(&e);
959 
960  assert(e.m_display);
961 
963  }
964  catch(te::common::Exception& e)
965  {
966  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), e.what());
967  return;
968  }
969 }
970 
972 {
974  return;
975 
977  if(layer.get() == 0)
978  {
979  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
981  return;
982  }
983 
984  if(layer->getSelected() == 0)
985  {
986  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a geometry first!"));
988  return;
989  }
990 
991  if(layer->getSelected()->size() < 2)
992  {
993  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("To use this tool, you must select at least two geometries!"));
995  return;
996  }
997 
999  emit triggered(&e);
1000 
1001  assert(e.m_display);
1002 
1003  setCurrentTool(new te::edit::MergeGeometriesTool(e.m_display->getDisplay(), layer, Qt::ArrowCursor, this), e.m_display);
1004 }
1005 
1007 {
1009  return;
1010 
1012  if (layer.get() == 0)
1013  {
1014  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1016  return;
1017  }
1018 
1019  if (layer->getSelected() == 0)
1020  {
1021  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a geometry first!"));
1023  return;
1024  }
1025 
1026  if (!layer->getSelected()->size())
1027  {
1028  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("To use this tool, you must select at least one geometry!"));
1030  return;
1031  }
1032 
1034  emit triggered(&e);
1035 
1036  assert(e.m_display);
1037 
1039 }
1040 
1042 {
1044  if (layer.get() == 0)
1045  {
1046  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1047  return;
1048  }
1049 
1050  // Clear the repository
1051  te::edit::Repository* repo = te::edit::RepositoryManager::getInstance().getRepository(layer->getId());
1052 
1053  if (repo)
1054  repo->clear();
1055 
1056  // Reset visualization tool
1057  if (m_currentTool)
1059 
1060  // Clear the undo stack
1062  stack.reset();
1063 
1064  // Repaint
1066  emit triggered(&e);
1067 
1068  if (e.m_display == 0)
1069  return;
1070 
1071  e.m_display->getDisplay()->getDraftPixmap()->fill(Qt::transparent);
1072  e.m_display->getDisplay()->repaint();
1073 
1074 }
1075 
1077 {
1079  return;
1080 
1082  if (layer.get() == 0)
1083  {
1084  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1086  return;
1087  }
1088 
1090  emit triggered(&e);
1091 
1092  assert(e.m_display);
1093 
1094  setCurrentTool(new te::edit::CreatePointTool(e.m_display->getDisplay(), layer, Qt::ArrowCursor, this), e.m_display);
1095 }
1096 
1098 {
1100  if (layer.get() == 0)
1101  {
1102  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1103  return;
1104  }
1105 
1107  emit triggered(&e);
1108 
1109  assert(e.m_display);
1110 
1112 }
1113 
1115 {
1116  //show interface
1117  te::qt::widgets::CreateLayerDialog dlg(this->get());
1118 
1119  if (dlg.exec() == QDialog::Accepted)
1120  {
1122  emit triggered(&e);
1123 
1124  std::list<te::map::AbstractLayerPtr> list;
1125  list.push_back(dlg.getLayer());
1126 
1127  //set the layer visibility
1128  list.begin()->get()->setVisibility(te::map::VISIBLE);
1129 
1130  //insert in tree
1131  e.m_layerExplorer->addLayers(list, QModelIndex());
1132 
1134  emit triggered(&d);
1135 
1136  std::list<te::map::AbstractLayerPtr> ls;
1137  te::qt::widgets::GetValidLayers(e.m_layerExplorer->model(), QModelIndex(), ls);
1138 
1139  //draw
1140  d.m_display->draw(ls);
1141  }
1142 }
1143 
1145 {
1146  try
1147  {
1149 
1150  if (layer.get() == 0)
1151  {
1152  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1153  return;
1154  }
1155 
1157  emit triggered(&e);
1158 
1159  assert(e.m_display);
1160 
1161  if (m_undoView == 0)
1162  {
1163  m_undoView = new QUndoView(te::edit::UndoStackManager::getInstance().getUndoStack(), this->get());
1164  m_undoView->setWindowTitle(tr("Edition List"));
1165  m_undoView->setFixedSize(QSize(300, 300));
1166  m_undoView->show();
1167  m_undoView->setAttribute(Qt::WA_QuitOnClose, true);
1168  }
1169 
1170  }
1171  catch (te::common::Exception& e)
1172  {
1173  QMessageBox::critical(this->get(), tr("TerraLib Edit Qt Plugin"), e.what());
1174  return;
1175  }
1176 }
1177 
1179 {
1180  m_currentTool = 0;
1181 }
1182 
1184 {
1185  if(m_currentTool == 0)
1186  return;
1187 
1189  emit triggered(&e);
1190 
1191  if(e.m_display == 0)
1192  return;
1193 
1194  m_currentTool->setInUse(enable);
1195 
1196  if(enable)
1198  else
1199  {
1200  e.m_display->getDisplay()->setCursor(Qt::ArrowCursor);
1201  e.m_display->getDisplay()->setCurrentTool(0, false);
1202  m_currentTool = 0;
1203 
1204  for (int i = 0; i < m_tools.size(); ++i)
1205  m_tools[i]->setChecked(false);
1206  }
1207 }
1208 
1210 {
1211  display->getDisplay()->setCurrentTool(tool);
1212 
1213  m_currentTool = tool;
1214 
1215  connect(m_currentTool, SIGNAL(geometriesEdited()), SIGNAL(geometriesEdited()));
1216  connect(m_currentTool, SIGNAL(toolDeleted()), SLOT(onToolDeleted()));
1217 
1218 }
1219 
1220 void te::qt::plugins::edit::ToolBar::enableActionsByGeomType(QList<QAction*> acts, const bool& enable)
1221 {
1222  std::size_t geomType = 0;
1224 
1225  for(QList<QAction*>::iterator it = acts.begin(); it != acts.end(); ++it)
1226  (*it)->setEnabled(enable);
1227 
1228  if (enable)
1229  {
1230  if (layer.get() == 0 || layer->getSRID() == 0)
1231  return;
1232 
1233  // Get the geometry type of layer
1234  std::unique_ptr<te::da::DataSetType> dt = layer->getSchema();
1236 
1237  if (geomProp == 0)
1238  {
1239  for (QList<QAction*>::iterator it = acts.begin(); it != acts.end(); ++it)
1240  (*it)->setEnabled(false);
1241 
1242  return;
1243  }
1244 
1245  switch (geomProp->getGeometryType())
1246  {
1248  case te::gm::PolygonType:
1249  geomType = 1;
1250  break;
1251 
1254  geomType = 2;
1255  break;
1256 
1258  case te::gm::PointType:
1259  geomType = 3;
1260  break;
1261 
1262  default:
1263  geomType = std::string::npos;
1264  }
1265 
1266  if (geomType == std::string::npos)
1267  {
1268  for (QList<QAction*>::iterator it = acts.begin(); it != acts.end(); ++it)
1269  (*it)->setEnabled(false);
1270 
1271  return;
1272  }
1273 
1274  m_createPolygonToolAction->setEnabled(geomType == 1 ? true : false);
1275  m_aggregateAreaToolAction->setEnabled(geomType == 1 ? true : false);
1276  m_subtractAreaToolAction->setEnabled(geomType == 1 ? true : false);
1277  m_mergeGeometriesToolAction->setEnabled(geomType == 1 ? true : false);
1278  m_splitPolygonToolAction->setEnabled(geomType == 1 ? true : false);
1279  m_createLineToolAction->setEnabled(geomType == 2 ? true : false);
1280  m_vertexToolAction->setEnabled(geomType == 1 || geomType == 2 ? true : false);
1281  m_moveGeometryToolAction->setEnabled(geomType >= 1 && geomType <= 3 ? true : false);
1282  m_deleteGeometryToolAction->setEnabled(geomType >= 1 && geomType <= 3 ? true : false);
1283  m_createPointToolAction->setEnabled(geomType == 3 ? true : false);
1284  m_rotateGeometryToolAction->setEnabled(geomType == 1 || geomType == 2 ? true : false);
1285  }
1286 
1287 }
1288 
1290 {
1291  onActionChanged(action);
1292 
1293  action->blockSignals(true);
1294 
1295  if(m_toolChecked)
1296  {
1297  resetTool(action);
1298  return false;
1299  }
1300 
1301  action->setChecked(true);
1302  action->blockSignals(false);
1303 
1304  m_toolChecked = true;
1305  m_currentAction = action;
1306 
1307  return true;
1308 }
1309 
1311 {
1312  action->blockSignals(true);
1313  action->setChecked(false);
1314  action->blockSignals(false);
1315  m_toolChecked = false;
1316  enableCurrentTool(false);
1317 }
1318 
1320 {
1321  return m_isEnabled;
1322 }
1323 
1325 {
1327  emit triggered(&e);
1328 
1329  if (e.m_display == 0)
1330  return;
1331 
1332  double digit = m_digitStepComboBox->itemText(index).toUtf8().toDouble();
1333  e.m_display->getDisplay()->setDigitalization(digit);
1334 }
1335 
1337 {
1338  if(!m_currentAction)
1339  return;
1340 
1341  if(m_currentAction->objectName() != action->objectName())
1342  m_toolChecked = false;
1343 }
1344 
1346 {
1348  return;
1349 
1351  if (layer.get() == 0)
1352  {
1353  QMessageBox::information(this->get(), tr("TerraLib Edit Qt Plugin"), tr("Select a layer first!"));
1355  return;
1356  }
1357 
1359  emit triggered(&e);
1360 
1361  assert(e.m_display);
1362 
1364 }
QAction * m_rotateGeometryToolAction
Definition: ToolBar.h:163
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
virtual void setCurrentTool(te::qt::widgets::AbstractTool *tool, const bool &delPrevious=true)
Updates the current tool being used on te::qt::widgets::MapDisplay.
virtual const std::string & getId() const
It returns the layer id.
std::size_t size() const
It returns the collection size, if it is known.
virtual void refresh(bool redraw=false)
It updates the contents in the map display.
QAction * m_subtractAreaToolAction
Definition: ToolBar.h:167
SimpleData< std::string, STRING_TYPE > String
Definition: SimpleData.h:229
Geometric property.
bool dataSrcIsPrepared(const te::map::AbstractLayerPtr &layer)
Definition: ToolBar.cpp:229
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
QAction * m_aggregateAreaToolAction
Definition: ToolBar.h:166
te::map::AbstractLayerPtr m_layer
Layer selected.
Definition: LayerEvents.h:336
This class implements a concrete tool to move geometries.
This event is used to get a single layer selected in layer tree.
Definition: LayerEvents.h:325
An atomic property like an integer or double.
QAction * m_mergeGeometriesToolAction
Definition: ToolBar.h:170
const std::vector< Feature * > & getAllFeatures() const
Definition: Repository.cpp:177
This is the base class for layers.
Definition: AbstractLayer.h:77
boost::shared_ptr< DataSource > DataSourcePtr
virtual const std::string & getTitle() const
It returns the layer title.
A dialog used to configure geometry snap options.
virtual const char * what() const
It outputs the exception message.
te::qt::widgets::LayerItemView * m_layerExplorer
void onMoveGeometryToolActivated(bool checked)
Definition: ToolBar.cpp:838
This class implements a concrete tool to create lines.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
void onCreatePointToolActivated(bool checked)
Definition: ToolBar.cpp:1076
SimpleData< boost::int32_t, INT32_TYPE > Int32
Definition: SimpleData.h:221
void onResetVisualizationToolActivated(bool checked)
Definition: ToolBar.cpp:1041
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
const boost::ptr_vector< te::dt::AbstractData > & getValue() const
It gets the properties values used to uniquely identify a data set element.
te::map::AbstractLayerPtr getSelectedLayer()
Definition: ToolBar.cpp:204
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
void setCurrentTool(te::edit::GeometriesUpdateTool *tool, te::qt::af::MapDisplay *display)
Definition: ToolBar.cpp:1209
TEEDITEXPORT te::gm::Geometry * Convert2LayerGeomType(const te::map::AbstractLayerPtr &layer, te::gm::Geometry *geom, int srid)
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
void onCreateLineToolActivated(bool checked)
Definition: ToolBar.cpp:817
void triggered(te::qt::af::evt::Event *e)
void setLayers(const std::list< te::map::AbstractLayerPtr > &layers)
void onActionChanged(QAction *action)
Definition: ToolBar.cpp:1336
This class implements a concrete tool to create polygons.
QComboBox * m_digitStepComboBox
Definition: ToolBar.h:176
void drop(std::size_t pos)
It drops a property from the dataset.
void setInUse(const bool &status)
This class implements a concrete tool for vertex operations (move, add, etc.).
Definition: VertexTool.h:74
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
void addLayers(const std::list< te::map::AbstractLayerPtr > &layers, const QModelIndex &idx, const std::string &idxPath="./")
Add the layers to the model.
void onRotateGeometryToolActivated(bool checked)
Definition: ToolBar.cpp:1345
This class implements a concrete tool to delete parts of multi features (deleting polygons of a multi...
TEQTWIDGETSEXPORT void GetValidLayers(QAbstractItemModel *model, const QModelIndex &parent, std::vector< te::map::AbstractLayerPtr > &layers)
void updateLayer(te::map::AbstractLayerPtr layer, bool redraw=true)
void setLayer(te::map::AbstractLayer *layer)
void onCreateUndoViewActivated(bool checked)
Definition: ToolBar.cpp:1144
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
This class implements a concrete tool to split polygons.
static RepositoryManager & getInstance()
It returns a reference to the singleton instance.
void ObjectId()
ObjectId example.
te::edit::GeometriesUpdateTool * m_currentTool
Definition: ToolBar.h:180
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
This class represents an unique id for a data set element.
This event can be used to retrieve the MapDisplat component.
Definition: MapEvents.h:96
void DataSet()
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
static te::dt::TimeDuration dt(20, 30, 50, 11)
The main toolbar of TerraLib Edit Qt plugin.
void onEditActivated(bool checked)
Definition: ToolBar.cpp:440
std::string getValueAsString() const
It gets the properties values used to uniquely identify a data set element as string.
void draw(const std::list< te::map::AbstractLayerPtr > &layers)
It draws the given layer list.
virtual AbstractData * clone() const =0
It returns a clone of this object.
void onDeletePartToolActivated(bool checked)
Definition: ToolBar.cpp:1097
void onSubtractAreaToolActivated(bool checked)
Definition: ToolBar.cpp:920
This interface is used to create new layer operation.
QAction * m_featureAttributesAction
Definition: ToolBar.h:168
TEDATAACCESSEXPORT ObjectIdSet * GenerateOIDSet(DataSet *dataset, const DataSetType *type)
QAction * m_createPolygonToolAction
Definition: ToolBar.h:160
void enableActionsByGeomType(QList< QAction * > acts, const bool &enable)
Definition: ToolBar.cpp:1220
void resetTool(QAction *action)
Definition: ToolBar.cpp:1310
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setMapDisplay(te::qt::widgets::MapDisplay *display)
void updateDelegate(const bool &add)
void updateLayer(te::map::AbstractLayer *layer, const bool &stashed)
Definition: ToolBar.cpp:145
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
QAction * m_splitPolygonToolAction
Definition: ToolBar.h:169
This class implements a concrete tool to create points.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
QToolBar * get() const
Definition: ToolBar.cpp:140
std::list< te::map::AbstractLayerPtr > m_layers
Definition: LayerEvents.h:345
void onFeatureAttributesActivated(bool checked)
Definition: ToolBar.cpp:877
void onDigitStepComboBoxChanged(int index)
Definition: ToolBar.cpp:1324
void onAggregateAreaToolActivated(bool checked)
Definition: ToolBar.cpp:899
TEDATAACCESSEXPORT void GetOIDPropertyPos(const DataSetType *type, std::vector< std::size_t > &ppos)
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
te::map::AbstractLayerPtr getLayer(const std::string &id)
Definition: ToolBar.cpp:214
void stashed(te::map::AbstractLayer *layer)
void onDeleteGeometryToolActivated(bool checked)
Definition: ToolBar.cpp:941
te::map::AbstractLayerPtr getLayer()
void StashGeometries(const te::map::AbstractLayer *layer, const std::map< std::string, te::gm::Geometry * > &geoms, const std::map< std::string, int > &ops)
Definition: Stasher.cpp:17
TEDATAACCESSEXPORT void GetOIDPropertyNames(const DataSetType *type, std::vector< std::string > &pnames)
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
This class represents a repository of geometries and features.
Definition: Repository.h:63
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
ToolBar(QObject *parent=0)
Definition: ToolBar.cpp:88
te::qt::af::MapDisplay * m_display
Definition: MapEvents.h:107
void onCreatePolygonToolActivated(bool checked)
Definition: ToolBar.cpp:796
bool isAutoNumber() const
It returns true if the attribute is an autonumber, otherwise it returns false.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void createAction(QAction *&action, const QString &tooltip, const QString &icon, bool checkable, bool enabled, const QString &objName, const char *member)
Definition: ToolBar.cpp:429
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TEGEOMEXPORT te::gm::Geometry * Validate(te::gm::Geometry *geom)
Get/create a valid version of the geometry given. If the geometry is a polygon or multi polygon...
void enableCurrentTool(const bool &enable)
Definition: ToolBar.cpp:1183
void onVertexToolActivated(bool checked)
Definition: ToolBar.cpp:775
A multi thread Qt4 widget to control the display of a set of layers.
QAction * m_deleteGeometryToolAction
Definition: ToolBar.h:165
bool isToolChanged(QAction *action)
Definition: ToolBar.cpp:1289
void GetStashedGeometries(const te::map::AbstractLayer *layer, std::map< std::string, te::gm::Geometry * > &geoms, std::map< std::string, int > &ops)
Definition: Stasher.cpp:67
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
virtual void setDigitalization(double digitalization)
Sets the digitalization factor.
void setPropertyDataType(int dt, std::size_t pos)
QAction * m_moveGeometryToolAction
Definition: ToolBar.h:162
void onSplitPolygonToolActivated(bool checked)
Definition: ToolBar.cpp:1006
void onMergeGeometriesToolActivated(bool checked)
Definition: ToolBar.cpp:971
QList< QAction * > m_tools
Definition: ToolBar.h:175