src/terralib/qt/widgets/Utils.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,
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 QtUtils.cpp
22 
23  \brief This file contains utility functions for dealing with Qt controls.
24  */
25 
26 // TerraLib
27 #include "../../common/STLUtils.h"
28 #include "../../common/StringUtils.h"
29 #include "../../maptools/MarkRendererManager.h"
30 #include "../../maptools/Canvas.h"
31 #include "../../se/Fill.h"
32 #include "../../se/Mark.h"
33 #include "../../se/Stroke.h"
34 #include "../../se/Utils.h"
35 #include "../../dataaccess/datasource/DataSourceCapabilities.h"
36 #include "../../dataaccess/datasource/DataSourceFactory.h"
37 #include "../../dataaccess/datasource/DataSource.h"
38 #include "../../common/StringUtils.h"
41 #include "Utils.h"
42 
43 // Qt
44 #include <QApplication>
45 #include <QActionGroup>
46 #include <QImage>
47 #include <QMenu>
48 #include <QMenuBar>
49 #include <QMessageBox>
50 #include <QPainter>
51 #include <QPen>
52 #include <QSettings>
53 #include <QTreeWidgetItem>
54 #include <QTreeWidgetItemIterator>
55 #include <QString>
56 
57 //Boost
58 #include <boost/lexical_cast.hpp>
59 
60 void te::qt::widgets::SetChildrenCheckState(QTreeWidgetItem* item, int column, Qt::CheckState state)
61 {
62  if(item && item->child(0))
63  {
64  QTreeWidgetItemIterator it(item->child(0));
65 
66  while(*it)
67  {
68  (*it)->setCheckState(column, state);
69 
70  ++it;
71  }
72  }
73 }
74 
75 QImage* te::qt::widgets::GetImage(te::color::RGBAColor** img, int width, int height)
76 {
77  QImage* qimg = new QImage(width, height, QImage::Format_ARGB32);
78 
79  for(int i = 0; i < height; ++i)
80  {
81  unsigned char* u = qimg->scanLine(i);
82 
83  for(int j = 0; j < width; ++j)
84  {
85  te::color::RGBAColor c = img[i][j];
86  QRgb val = qRgba(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
87  QRgb* v = (QRgb*)(u+j*4);
88  *v = val;
89  }
90  }
91 
92  return qimg;
93 }
94 
96 {
97  te::color::RGBAColor** rgba = new te::color::RGBAColor*[img->height()];
98  for(int i = 0; i < img->height(); ++i)
99  {
100  te::color::RGBAColor* s = new te::color::RGBAColor[img->width()];
101 
102  for(int j = 0; j < img->width(); ++j)
103  s[j] = img->pixel(j, i);
104 
105  rgba[i] = s;
106  }
107 
108  return rgba;
109 }
110 
111 QStyle::StandardPixmap toQStyle(const QMessageBox::Icon& icon)
112 {
113  switch(icon)
114  {
115  case QMessageBox::Question:
116  return QStyle::SP_MessageBoxQuestion;
117  break;
118 
119  case QMessageBox::Warning:
120  return QStyle::SP_MessageBoxWarning;
121  break;
122 
123  case QMessageBox::Critical:
124  return QStyle::SP_MessageBoxCritical;
125  break;
126 
127  default:
128  return QStyle::SP_MediaVolumeMuted;
129  break;
130  }
131 }
132 
133 QMenu* te::qt::widgets::FindMenu(const QString& mnuText, QMenu* mnu)
134 {
135  return mnu->findChild<QMenu*>(mnuText);
136 }
137 
138 QMenu* te::qt::widgets::FindMenu(const QString& mnuText, QMenuBar* bar)
139 {
140  return bar->findChild<QMenu*>(mnuText);
141 }
142 
143 QAction* te::qt::widgets::FindAction(const QString& actText, QMenu* mnu)
144 {
145  return mnu->findChild<QAction*>(actText);
146 }
147 
148 QAction* te::qt::widgets::FindAction(const QString& actText, QMenuBar* mnuBar)
149 {
150  return mnuBar->findChild<QAction*>(actText);
151 }
152 
153 QActionGroup* te::qt::widgets::FindActionGroup(const QString& actGroupText, QMenu* mnu)
154 {
155  return mnu->findChild<QActionGroup*>(actGroupText);
156 }
157 
158 QActionGroup* te::qt::widgets::FindActionGroup(const QString& actGroupText, QMenuBar* mnuBar)
159 {
160  return mnuBar->findChild<QActionGroup*>(actGroupText);
161 }
162 
163 QMenu* CreateMenu(const QString& mnuName, QMenu* p)
164 {
165  QMenu* mnu = p->findChild<QMenu*>(mnuName);
166 
167  if(mnu == nullptr)
168  {
169  QStringList ls = mnuName.split(".");
170  mnu = p->addMenu(ls[ls.size()-1]);
171 
172  mnu->setObjectName(mnuName);
173  }
174 
175  return mnu;
176 }
177 
178 QMenu* CreateMenu(const QString& mnuName, QMenuBar* p)
179 {
180  QMenu* mnu = te::qt::widgets::FindMenu(mnuName, p);
181 
182  if(mnu == nullptr)
183  {
184  QStringList ls = mnuName.split(".");
185  mnu = new QMenu(ls[ls.size()-1], p);
186  mnu->setObjectName(mnuName);
187 
188  QMenu* helpMnu = te::qt::widgets::FindMenu("Help", p);
189 
190  QAction* act = (helpMnu == nullptr) ? nullptr : helpMnu->menuAction();
191 
192  p->insertMenu(act, mnu);
193  }
194 
195  return mnu;
196 }
197 
198 QMenu* te::qt::widgets::GetMenu(const QString& mnuText, QMenu* mnu)
199 {
200  QMenu* res = FindMenu(mnuText, mnu);
201 
202  QStringList mnus = mnuText.split('.');
203 
204  for(int i=1; i<mnus.size(); i++)
205  mnus[i] = mnus[i-1] + "." + mnus[i];
206 
207  for(int i=0; i<mnus.size(); i++)
208  res = (i == 0) ?
209  CreateMenu(mnus[i], mnu) :
210  CreateMenu(mnus[i], res);
211 
212  return res;
213 }
214 
215 QMenu* te::qt::widgets::GetMenu(const QString& mnuText, QMenuBar* bar)
216 {
217  QMenu* res = FindMenu(mnuText, bar);
218 
219  QStringList mnus = mnuText.split('.');
220 
221  for(int i=1; i<mnus.size(); i++)
222  mnus[i] = mnus[i-1] + "." + mnus[i];
223 
224  for(int i=0; i<mnus.size(); i++)
225  {
226  res = (i == 0) ?
227  CreateMenu(mnus[i], bar) :
228  CreateMenu(mnus[i], res);
229  }
230  return res;
231 }
232 
234 {
235  return te::color::RGBAColor(color.red(), color.green(), color.blue(), color.alpha());
236 }
237 
239 {
240  QColor qcolor(color.getRgba());
241  qcolor.setAlpha(qAlpha(color.getRgba()));
242  return qcolor;
243 }
244 
245 void te::qt::widgets::Config2DrawPolygons(te::map::Canvas* canvas, const QColor& fillColor, const QColor& contourColor, const std::size_t& contourWidth)
246 {
247  canvas->setPolygonContourWidth((int)contourWidth);
248  canvas->setPolygonContourColor(Convert2TerraLib(contourColor));
249  canvas->setPolygonFillColor(Convert2TerraLib(fillColor));
250 }
251 
252 void te::qt::widgets::Config2DrawLines(te::map::Canvas* canvas, const QColor& color, const std::size_t& width)
253 {
254  canvas->setLineWidth((int)width);
255  canvas->setLineColor(Convert2TerraLib(color));
256 }
257 
258 void te::qt::widgets::Config2DrawPoints(te::map::Canvas* canvas, const QColor& color, const std::size_t& width)
259 {
260  canvas->setPointWidth((int)width);
261  canvas->setPointColor(Convert2TerraLib(color));
262 }
263 
264 void te::qt::widgets::Config2DrawPoints(te::map::Canvas* canvas, const QString& markName, const std::size_t& size,
265  const QColor& fillColor, const QColor& contourColor, const std::size_t& contourWidth)
266 {
267  te::se::Stroke* stroke = te::se::CreateStroke(contourColor.name().toUtf8().data(),
268  QString::number(contourWidth).toUtf8().data(),
269  QString::number(contourColor.alphaF()).toUtf8().data());
270 
271  te::se::Fill* fill = te::se::CreateFill(fillColor.name().toUtf8().data(),
272  QString::number(fillColor.alphaF()).toUtf8().data());
273 
274  te::se::Mark* mark = te::se::CreateMark(markName.toUtf8().data(), stroke, fill);
275 
277 
279  canvas->setPointPattern(rgba, (int)size, (int)size);
280 
281  te::common::Free(rgba, size);
282 
283  delete mark;
284 }
285 
286 void te::qt::widgets::Config2DrawLayerSelection(te::map::Canvas* canvas, const QColor& selectionColor, const te::gm::GeomType& type)
287 {
288  switch(type)
289  {
290  case te::gm::PolygonType:
298  {
299  QColor fillColor = selectionColor;
300 
301  Config2DrawPolygons(canvas, fillColor, Qt::black, 2);
302  }
303  break;
304 
313  {
314  QColor fillColor = selectionColor;
315 
316  Config2DrawLines(canvas, fillColor, 6);
317  }
318  break;
319 
320  case te::gm::PointType:
321  case te::gm::PointZType:
322  case te::gm::PointMType:
323  case te::gm::PointZMType:
328  {
329  QColor fillColor = selectionColor;
330 
331  QColor contourColor = selectionColor;
332  contourColor.setAlpha(150);
333 
334  Config2DrawPoints(canvas, "square", 24, fillColor, contourColor,2);
335  }
336  break;
337 
338  default:
339  return;
340  }
341 }
342 
343 QPixmap te::qt::widgets::CreatePixmapIcon(const int& size, const QColor& penColor, const QColor& brushColor, const int& contourSize)
344 {
345  QPixmap pix(size, size);
346  pix.fill(Qt::transparent);
347 
348  int offset = 2;
349 
350  QPainterPath path;
351  path.addRect(offset, offset, pix.width() - 2 * offset, pix.height() - 2 * offset);
352 
353  QPen pen;
354  pen.setColor(penColor);
355  pen.setWidth(contourSize);
356 
357  QBrush brush;
358  brush.setColor(brushColor);
359 
360  QPainter p(&pix);
361  p.setPen(pen);
362  p.setBrush(brushColor);
363 
364  p.fillPath(path, brush);
365  p.drawPath(path);
366 
367  return pix;
368 }
369 
370 void te::qt::widgets::AddFilePathToSettings(const QString& path, const QString& typeFile)
371 {
372  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
373 
374  QString key = "Last used file path/" + typeFile;
375 
376  sett.setValue(key, path);
377 }
378 
379 QString te::qt::widgets::GetFilePathFromSettings(const QString& typeFile)
380 {
381  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
382 
383  QString key = "Last used file path/" + typeFile;
384 
385  return sett.value(key).toString();
386 }
387 
388 QString te::qt::widgets::Convert2Qt(const std::string& text, te::core::EncodingType encoding)
389 {
390  std::string conv_text = text;
391 
392  if (encoding != te::core::EncodingType::UTF8)
393  conv_text = te::core::CharEncoding::toUTF8(text, encoding);
394 
395  return QString::fromUtf8(conv_text.c_str());
396 }
397 
398 QString te::qt::widgets::GetDiskRasterFileSelFilter( const bool creationSupport )
399 {
400  QString filter;
401 
402  if( te::da::DataSourceFactory::find( "GDAL" ) )
403  {
404  std::unique_ptr< te::da::DataSource > dsPtr = te::da::DataSourceFactory::make( "GDAL", "file://" );
405 
406  if( dsPtr.get() )
407  {
408  std::map< std::string, std::string > specCap = dsPtr->getCapabilities().getSpecificCapabilities();
409 
410  const std::string extensionName = creationSupport ?
411  std::string( "SUPPORTED_RASTER_CREATION_EXTENSIONS" ) :
412  std::string( "SUPPORTED_RASTER_EXTENSIONS" );
413 
414  if( specCap.find( extensionName ) != specCap.end() )
415  {
416  std::string fileExtensions = specCap[ extensionName ];
417  std::string extFilter;
418  std::string uCaseToken;
419  std::string lCaseToken;
420  std::vector< std::string > tokens;
421  te::common::Tokenize( fileExtensions, tokens, ";" );
422 
423  for( unsigned int tokensIdx = 0 ; tokensIdx < tokens.size() ; ++tokensIdx )
424  {
425  uCaseToken = te::common::Convert2UCase( tokens[ tokensIdx ] );
426  lCaseToken = te::common::Convert2LCase( tokens[ tokensIdx ] );
427  extFilter = uCaseToken + " Raster File (" + "*." + lCaseToken + " *." +
428  uCaseToken + ")";
429 
430  if( uCaseToken == "TIF" )
431  {
432  filter = QString( extFilter.c_str() ) + ( filter.isEmpty() ? "" : ";;" ) + filter;
433  }
434  else
435  {
436  filter += ( filter.isEmpty() ? "" : ";;" ) + QString( extFilter.c_str() );
437  }
438  }
439  }
440  }
441  }
442 
443  filter += QString( ( filter.isEmpty() ? "" : ";;" ) ) +
444  "Web Map Service - WMS (*.xml *.wms);;Web Coverage Service - WCS (*.xml *.wcs);;All Files (*.*)";
445 
446  return filter;
447 }
448 
450 {
451  QString filter;
452 
453  if( te::da::DataSourceFactory::find( "GDAL" ) )
454  {
455  std::unique_ptr< te::da::DataSource > dsPtr = te::da::DataSourceFactory::make( "GDAL", "file://" );
456 
457  if( dsPtr.get() )
458  {
459  std::map< std::string, std::string > specCap = dsPtr->getCapabilities().getSpecificCapabilities();
460 
461  const std::string extensionName = "SUPPORTED_VECTOR_EXTENSIONS";
462 
463  if( specCap.find( extensionName ) != specCap.end() )
464  {
465  std::string fileExtensions = specCap[ extensionName ];
466  std::string extFilter;
467  std::string uCaseToken;
468  std::string lCaseToken;
469  std::vector< std::string > tokens;
470  te::common::Tokenize( fileExtensions, tokens, ";" );
471 
472  for( unsigned int tokensIdx = 0 ; tokensIdx < tokens.size() ; ++tokensIdx )
473  {
474  uCaseToken = te::common::Convert2UCase( tokens[ tokensIdx ] );
475  lCaseToken = te::common::Convert2LCase( tokens[ tokensIdx ] );
476  extFilter = uCaseToken + " Vector File (" + "*." + lCaseToken + " *." +
477  uCaseToken + ")";
478 
479  if( uCaseToken == "SHP" )
480  {
481  filter = QString( extFilter.c_str() ) + ( filter.isEmpty() ? "" : ";;" ) + filter;
482  }
483  else
484  {
485  filter += ( filter.isEmpty() ? "" : ";;" ) + QString( extFilter.c_str() );
486  }
487  }
488  }
489  }
490  }
491 
492  filter += QString( ( filter.isEmpty() ? "" : ";;" ) ) + "All Files (*.*)";
493 
494  return filter;
495 }
496 
497 std::list<te::map::AbstractLayerPtr> te::qt::widgets::GetSelectedLayersOnly(te::qt::widgets::LayerItemView* view, const bool getFolder)
498 {
499  std::list<te::map::AbstractLayerPtr> res;
500  std::list<te::qt::widgets::TreeItem*> items = view->getSelectedItems();
501 
502  for(std::list<te::qt::widgets::TreeItem*>::iterator it = items.begin(); it != items.end(); ++it)
503  if((*it)->getType() == "LAYER")
504  res.push_back(((te::qt::widgets::LayerItem*)(*it))->getLayer());
505  else if(getFolder && (*it)->getType() == "FOLDER")
506  res.push_back(((te::qt::widgets::LayerItem*)(*it))->getLayer());
507 
508  return res;
509 }
510 
511 void te::qt::widgets::GetValidLayers(QAbstractItemModel* model, const QModelIndex& parent, std::vector<te::map::AbstractLayerPtr>& layers)
512 {
513  int cs = model->rowCount(parent);
514 
515  for(int i = 0; i < cs; i++)
516  {
517  QModelIndex idx = model->index(i, 0, parent);
518 
519  if(idx.isValid())
520  {
521  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(idx.internalPointer());
522 
523  if(item->getType() == "LAYER")
524  {
525  te::map::AbstractLayerPtr l = ((te::qt::widgets::LayerItem*)item)->getLayer();
526 
527  if(l->isValid())
528  layers.push_back(l);
529  }
530  else if(item->getType() == "FOLDER")
531  GetValidLayers(model, idx, layers);
532  }
533  }
534 }
535 
536 void te::qt::widgets::GetValidLayers(QAbstractItemModel* model, const QModelIndex& parent, std::list<te::map::AbstractLayerPtr>& layers)
537 {
538  int cs = model->rowCount(parent);
539 
540  for(int i = 0; i < cs; i++)
541  {
542  QModelIndex idx = model->index(i, 0, parent);
543 
544  if(idx.isValid())
545  {
546  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(idx.internalPointer());
547 
548  if(item->getType() == "LAYER")
549  {
550  te::map::AbstractLayerPtr l = ((te::qt::widgets::LayerItem*)item)->getLayer();
551 
552  if(l->isValid())
553  layers.push_back(l);
554  }
555  else if(item->getType() == "FOLDER")
556  GetValidLayers(model, idx, layers);
557  }
558  }
559 }
560 
561 void te::qt::widgets::GetChangedAndVisibleLayers(const QModelIndexList& idxs, std::list<te::map::AbstractLayerPtr>& layers)
562 {
563  for(QModelIndexList::const_iterator it = idxs.begin(); it != idxs.end(); ++it)
564  {
565  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>((*it).internalPointer());
566 
567  if(item->getType() == "CHART" || item->getType() == "GROUPING" || item->getType() == "COLORMAP")
568  {
569  QModelIndex parent = (*it).model()->parent(*it);
570 
571  if(!idxs.contains(parent))
572  {
573  te::qt::widgets::TreeItem* lI = static_cast<te::qt::widgets::TreeItem*>(parent.internalPointer());
574 
576  layers.push_back(((te::qt::widgets::LayerItem*)lI)->getLayer());
577  }
578  }
579  }
580 }
581 
582 bool te::qt::widgets::isValidSRIDs(const int& firstSRID, const int& secondSRID, std::string& msg)
583 {
584  if (firstSRID == 0 && secondSRID != 0)
585  {
586  msg = "The first SRID(0). It is not possible to convert the SRID to a valid Projection (";
587  msg += te::common::Convert2String(secondSRID);
588  msg += "). Please, inform the fisrt SRID!";
589 
590  return false;
591  }
592 
593  if (firstSRID != 0 && secondSRID == 0)
594  {
595  msg = "The second SRID(0). It is not possible to convert the SRID to a valid Projection (";
596  msg += te::common::Convert2String(firstSRID);
597  msg += "). Please, inform the second SRID!";
598 
599  return false;
600  }
601 
602  return true;
603 }
604 
605 int te::qt::widgets::MillimetersToPixels(const QPaintDevice* device, const double& mm, const bool& printer)
606 {
607  int h_dpi = (printer) ? device->physicalDpiX() : device->logicalDpiX(),
608  v_dpi = (printer) ? device->physicalDpiY() : device->logicalDpiY(),
609  dpi = (h_dpi > v_dpi) ? h_dpi : v_dpi;
610 
611  double dpMM = dpi / 25.4; // Dots per millimeter.
612 
613  int pixels = qRound(mm * dpMM); // Number of pixels.
614 
615  return pixels;
616 }
617 
618 QPixmap* te::qt::widgets::GetCleanImage(const QSize& s, const QColor& c)
619 {
620  QPixmap* pix = new QPixmap(s);
621 
622  pix->fill(c);
623 
624  return pix;
625 }
626 
627 
628 
629 
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
Definition: RGBAColor.h:327
TEQTWIDGETSEXPORT te::color::RGBAColor Convert2TerraLib(const QColor &color)
It converts a Qt Color to TerraLib Color.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
TEQTWIDGETSEXPORT void Config2DrawLayerSelection(te::map::Canvas *canvas, const QColor &selectionColor, const te::gm::GeomType &type)
It configs (i.e. prepares) the given canvas to draw a layer selection.
virtual void setPointWidth(int w)=0
It sets the point width. If point has a patterns, this pattern is scaled to width.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
TEQTWIDGETSEXPORT QString GetDiskRasterFileSelFilter(const bool creationSupport)
Returns a disk raster file selection filter base on current supported formats.
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:307
TEQTWIDGETSEXPORT QAction * FindAction(const QString &actText, QMenu *mnu)
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
Definition: StringUtils.h:202
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
virtual void setPolygonFillColor(const te::color::RGBAColor &color)=0
It sets the color used to fill the draw of polygon geometries.
TEQTWIDGETSEXPORT void AddFilePathToSettings(const QString &path, const QString &typeFile)
Save last used path in QSettings.
virtual void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the point pattern.
virtual void setLineWidth(int w)=0
It sets the line width.
TEQTWIDGETSEXPORT void Config2DrawLines(te::map::Canvas *canvas, const QColor &color, const std::size_t &width=1)
It configs (i.e. prepares) the given canvas to draw lines.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Definition: RGBAColor.h:317
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Definition: RGBAColor.h:312
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:168
QStyle::StandardPixmap toQStyle(const QMessageBox::Icon &icon)
Defines a hierarchical structure.
EncodingType
Supported character encodings.
Definition: CharEncoding.h:50
TEQTWIDGETSEXPORT void Config2DrawPolygons(te::map::Canvas *canvas, const QColor &fillColor, const QColor &contourColor, const std::size_t &contourWidth=1)
It configs (i.e. prepares) the given canvas to draw polygons.
TEQTWIDGETSEXPORT void GetValidLayers(QAbstractItemModel *model, const QModelIndex &parent, std::vector< te::map::AbstractLayerPtr > &layers)
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Definition: StringUtils.h:221
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
TEQTWIDGETSEXPORT QActionGroup * FindActionGroup(const QString &actGroupText, QMenu *mnu)
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
TEQTWIDGETSEXPORT void SetChildrenCheckState(QTreeWidgetItem *item, int column, Qt::CheckState state)
It sets the check state for the children of a item.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Definition: RGBAColor.h:322
TEQTWIDGETSEXPORT bool isValidSRIDs(const int &firstSRID, const int &secondSRID, std::string &msg)
Verify if the SRID from informed Layers are valids to execute the operation.
A specialization of QTreeView for manipulate layers.
Definition: LayerItemView.h:78
te::gm::Polygon * p
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
TEQTWIDGETSEXPORT void Config2DrawPoints(te::map::Canvas *canvas, const QColor &color, const std::size_t &width=1)
It configs (i.e. prepares) the given canvas to draw points.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
QMenu * CreateMenu(const QString &mnuName, QMenu *p)
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
Defines a layer item view for Qt5.
std::list< te::qt::widgets::TreeItem * > getSelectedItems() const
Returns a list of TreeItem that are selected.
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
A canvas is an abstraction of a drawing area.
virtual void setPointColor(const te::color::RGBAColor &color)=0
It sets the point drawing color.
TEQTWIDGETSEXPORT QString GetDiskVectorFileSelFilter()
Returns a disk vector file selection filter base on current supported formats.
QPixmap * GetCleanImage(const QSize &s, const QColor &c)
Returns a transparent pixmap of size s.
TEQTWIDGETSEXPORT std::list< te::map::AbstractLayerPtr > GetSelectedLayersOnly(te::qt::widgets::LayerItemView *view, const bool getFolder=false)
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
TEQTWIDGETSEXPORT QMenu * FindMenu(const QString &mnuText, QMenu *mnu)
Finds a menu item in the mnu object.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
virtual void setPolygonContourColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw the boundary of polygon geometries.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
static std::string toUTF8(const std::string &src)
Convert a string from a current locale encoding to UTF-8.
Defines a layer item.
TEQTWIDGETSEXPORT QColor Convert2Qt(const te::color::RGBAColor &color)
It converts a TerraLib Color to Qt Color.
TEQTWIDGETSEXPORT QString GetFilePathFromSettings(const QString &typeFile)
Returns the value of the last saved file path for the typeFile required.
virtual void setLineColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw line geometries.
TEQTWIDGETSEXPORT QMenu * GetMenu(const QString &mnuText, QMenu *mnu)
Gets a menu or submenu contained in the mnu object.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
Definition: StringUtils.h:56
te::da::DataSetType * Convert2TerraLib(sqlite3_stmt *pStmt)
TEQTWIDGETSEXPORT void GetChangedAndVisibleLayers(const QModelIndexList &idxs, std::list< te::map::AbstractLayerPtr > &layers)
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
TEQTWIDGETSEXPORT int MillimetersToPixels(const QPaintDevice *device, const double &mm, const bool &printer)
Returns the size in pixels.
TEQTWIDGETSEXPORT QPixmap CreatePixmapIcon(const int &size, const QColor &penColor, const QColor &brushColor, const int &contourSize)
It creates a pixmap to use as icon (to be used as legend icon).
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
std::string getType() const
Returns the type of the item.
virtual VISIBLE isVisible() const
Returns the visibilty state of the item.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.