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" 44 #include <QApplication> 45 #include <QActionGroup> 49 #include <QMessageBox> 53 #include <QTreeWidgetItem> 54 #include <QTreeWidgetItemIterator> 58 #include <boost/lexical_cast.hpp> 62 if(item && item->child(0))
64 QTreeWidgetItemIterator it(item->child(0));
68 (*it)->setCheckState(column, state);
77 QImage* qimg =
new QImage(width, height, QImage::Format_ARGB32);
79 for(
int i = 0; i < height; ++i)
81 unsigned char* u = qimg->scanLine(i);
83 for(
int j = 0; j < width; ++j)
87 QRgb* v = (QRgb*)(u+j*4);
98 for(
int i = 0; i < img->height(); ++i)
102 for(
int j = 0; j < img->width(); ++j)
103 s[j] = img->pixel(j, i);
111 QStyle::StandardPixmap
toQStyle(
const QMessageBox::Icon& icon)
115 case QMessageBox::Question:
116 return QStyle::SP_MessageBoxQuestion;
119 case QMessageBox::Warning:
120 return QStyle::SP_MessageBoxWarning;
123 case QMessageBox::Critical:
124 return QStyle::SP_MessageBoxCritical;
128 return QStyle::SP_MediaVolumeMuted;
135 return mnu->findChild<QMenu*>(mnuText);
140 return bar->findChild<QMenu*>(mnuText);
145 return mnu->findChild<QAction*>(actText);
150 return mnuBar->findChild<QAction*>(actText);
155 return mnu->findChild<QActionGroup*>(actGroupText);
160 return mnuBar->findChild<QActionGroup*>(actGroupText);
165 QMenu* mnu = p->findChild<QMenu*>(mnuName);
169 QStringList ls = mnuName.split(
".");
170 mnu = p->addMenu(ls[ls.size()-1]);
172 mnu->setObjectName(mnuName);
184 QStringList ls = mnuName.split(
".");
185 mnu =
new QMenu(ls[ls.size()-1],
p);
186 mnu->setObjectName(mnuName);
190 QAction* act = (helpMnu ==
nullptr) ?
nullptr : helpMnu->menuAction();
192 p->insertMenu(act, mnu);
200 QMenu* res =
FindMenu(mnuText, mnu);
202 QStringList mnus = mnuText.split(
'.');
204 for(
int i=1; i<mnus.size(); i++)
205 mnus[i] = mnus[i-1] +
"." + mnus[i];
207 for(
int i=0; i<mnus.size(); i++)
217 QMenu* res =
FindMenu(mnuText, bar);
219 QStringList mnus = mnuText.split(
'.');
221 for(
int i=1; i<mnus.size(); i++)
222 mnus[i] = mnus[i-1] +
"." + mnus[i];
224 for(
int i=0; i<mnus.size(); i++)
240 QColor qcolor(color.
getRgba());
241 qcolor.setAlpha(qAlpha(color.
getRgba()));
265 const QColor& fillColor,
const QColor& contourColor,
const std::size_t& contourWidth)
268 QString::number(contourWidth).toUtf8().data(),
269 QString::number(contourColor.alphaF()).toUtf8().data());
272 QString::number(fillColor.alphaF()).toUtf8().data());
299 QColor fillColor = selectionColor;
314 QColor fillColor = selectionColor;
329 QColor fillColor = selectionColor;
331 QColor contourColor = selectionColor;
332 contourColor.setAlpha(150);
345 QPixmap pix(size, size);
346 pix.fill(Qt::transparent);
351 path.addRect(offset, offset, pix.width() - 2 * offset, pix.height() - 2 * offset);
354 pen.setColor(penColor);
355 pen.setWidth(contourSize);
358 brush.setColor(brushColor);
362 p.setBrush(brushColor);
364 p.fillPath(path, brush);
372 QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
374 QString key =
"Last used file path/" + typeFile;
376 sett.setValue(key, path);
381 QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
383 QString key =
"Last used file path/" + typeFile;
385 return sett.value(key).toString();
390 std::string conv_text = text;
395 return QString::fromUtf8(conv_text.c_str());
408 std::map< std::string, std::string > specCap = dsPtr->getCapabilities().getSpecificCapabilities();
410 const std::string extensionName = creationSupport ?
411 std::string(
"SUPPORTED_RASTER_CREATION_EXTENSIONS" ) :
412 std::string(
"SUPPORTED_RASTER_EXTENSIONS" );
414 if( specCap.find( extensionName ) != specCap.end() )
416 std::string fileExtensions = specCap[ extensionName ];
417 std::string extFilter;
418 std::string uCaseToken;
419 std::string lCaseToken;
420 std::vector< std::string > tokens;
423 for(
unsigned int tokensIdx = 0 ; tokensIdx < tokens.size() ; ++tokensIdx )
427 extFilter = uCaseToken +
" Raster File (" +
"*." + lCaseToken +
" *." +
430 if( uCaseToken ==
"TIF" )
432 filter = QString( extFilter.c_str() ) + ( filter.isEmpty() ?
"" :
";;" ) + filter;
436 filter += ( filter.isEmpty() ?
"" :
";;" ) + QString( extFilter.c_str() );
443 filter += QString( ( filter.isEmpty() ?
"" :
";;" ) ) +
444 "Web Map Service - WMS (*.xml *.wms);;Web Coverage Service - WCS (*.xml *.wcs);;All Files (*.*)";
459 std::map< std::string, std::string > specCap = dsPtr->getCapabilities().getSpecificCapabilities();
461 const std::string extensionName =
"SUPPORTED_VECTOR_EXTENSIONS";
463 if( specCap.find( extensionName ) != specCap.end() )
465 std::string fileExtensions = specCap[ extensionName ];
466 std::string extFilter;
467 std::string uCaseToken;
468 std::string lCaseToken;
469 std::vector< std::string > tokens;
472 for(
unsigned int tokensIdx = 0 ; tokensIdx < tokens.size() ; ++tokensIdx )
476 extFilter = uCaseToken +
" Vector File (" +
"*." + lCaseToken +
" *." +
479 if( uCaseToken ==
"SHP" )
481 filter = QString( extFilter.c_str() ) + ( filter.isEmpty() ?
"" :
";;" ) + filter;
485 filter += ( filter.isEmpty() ?
"" :
";;" ) + QString( extFilter.c_str() );
492 filter += QString( ( filter.isEmpty() ?
"" :
";;" ) ) +
"All Files (*.*)";
499 std::list<te::map::AbstractLayerPtr> res;
502 for(std::list<te::qt::widgets::TreeItem*>::iterator it = items.begin(); it != items.end(); ++it)
503 if((*it)->getType() ==
"LAYER")
505 else if(getFolder && (*it)->getType() ==
"FOLDER")
513 int cs = model->rowCount(parent);
515 for(
int i = 0; i < cs; i++)
517 QModelIndex idx = model->index(i, 0, parent);
530 else if(item->
getType() ==
"FOLDER")
538 int cs = model->rowCount(parent);
540 for(
int i = 0; i < cs; i++)
542 QModelIndex idx = model->index(i, 0, parent);
555 else if(item->
getType() ==
"FOLDER")
563 for(QModelIndexList::const_iterator it = idxs.begin(); it != idxs.end(); ++it)
569 QModelIndex parent = (*it).model()->parent(*it);
571 if(!idxs.contains(parent))
584 if (firstSRID == 0 && secondSRID != 0)
586 msg =
"The first SRID(0). It is not possible to convert the SRID to a valid Projection (";
588 msg +=
"). Please, inform the fisrt SRID!";
593 if (firstSRID != 0 && secondSRID == 0)
595 msg =
"The second SRID(0). It is not possible to convert the SRID to a valid Projection (";
597 msg +=
"). Please, inform the second SRID!";
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;
611 double dpMM = dpi / 25.4;
613 int pixels = qRound(mm * dpMM);
620 QPixmap* pix =
new QPixmap(s);
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
virtual void setPointWidth(int w)=0
It sets the point width. If point has a patterns, this pattern is scaled to width.
static bool find(const std::string &dsType)
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.
int getRed() const
It returns the red component color value (a value from 0 to 255).
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
virtual void setPolygonFillColor(const te::color::RGBAColor &color)=0
It sets the color used to fill the draw of polygon geometries.
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.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
EncodingType
Supported character encodings.
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.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
A Fill specifies the pattern for filling an area geometry.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
Defines a layer item view for Qt5.
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.
A Stroke specifies the appearance of a linear geometry.
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.
static std::string toUTF8(const std::string &src)
Convert a string from a current locale encoding to UTF-8.
virtual void setLineColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw line geometries.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
te::da::DataSetType * Convert2TerraLib(sqlite3_stmt *pStmt)
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.