27 #include "../../common/STLUtils.h"
28 #include "../../maptools/MarkRendererManager.h"
29 #include "../../maptools/Canvas.h"
30 #include "../../se/Fill.h"
31 #include "../../se/Mark.h"
32 #include "../../se/Stroke.h"
33 #include "../../se/Utils.h"
37 #include <QtCore/QSettings>
38 #include <QtGui/QApplication>
39 #include <QtGui/QImage>
40 #include <QtGui/QMenu>
41 #include <QtGui/QMenuBar>
42 #include <QtGui/QMessageBox>
43 #include <QtGui/QPainter>
45 #include <QtGui/QTreeWidgetItem>
46 #include <QtGui/QTreeWidgetItemIterator>
50 if(item && item->child(0))
52 QTreeWidgetItemIterator it(item->child(0));
56 (*it)->setCheckState(column, state);
65 QImage* qimg =
new QImage(width, height, QImage::Format_ARGB32);
67 for(
int i = 0; i < height; ++i)
69 unsigned char* u = qimg->scanLine(i);
71 for(
int j = 0; j < width; ++j)
75 QRgb* v = (QRgb*)(u+j*4);
86 for(
int i = 0; i < img->height(); ++i)
90 for(
int j = 0; j < img->width(); ++j)
91 s[j] = img->pixel(j, i);
99 QStyle::StandardPixmap
toQStyle(
const QMessageBox::Icon& icon)
103 case QMessageBox::Question:
104 return QStyle::SP_MessageBoxQuestion;
107 case QMessageBox::Warning:
108 return QStyle::SP_MessageBoxWarning;
111 case QMessageBox::Critical:
112 return QStyle::SP_MessageBoxCritical;
116 return QStyle::SP_MediaVolumeMuted;
123 return mnu->findChild<QMenu*>(mnuText);
128 return bar->findChild<QMenu*>(mnuText);
133 return mnu->findChild<QAction*>(actText);
138 return mnuBar->findChild<QAction*>(actText);
143 QMenu* mnu = p->findChild<QMenu*>(mnuName);
147 QStringList ls = mnuName.split(
".");
148 mnu = p->addMenu(ls[ls.size()-1]);
150 mnu->setObjectName(mnuName);
162 QStringList ls = mnuName.split(
".");
163 mnu =
new QMenu(ls[ls.size()-1], p);
164 mnu->setObjectName(mnuName);
168 QAction* act = (helpMnu == 0) ? 0 : helpMnu->menuAction();
170 p->insertMenu(act, mnu);
178 QMenu* res =
FindMenu(mnuText, mnu);
180 QStringList mnus = mnuText.split(
'.');
182 for(
int i=1; i<mnus.size(); i++)
183 mnus[i] = mnus[i-1] +
"." + mnus[i];
185 for(
int i=0; i<mnus.size(); i++)
195 QMenu* res =
FindMenu(mnuText, bar);
197 QStringList mnus = mnuText.split(
'.');
199 for(
int i=1; i<mnus.size(); i++)
200 mnus[i] = mnus[i-1] +
"." + mnus[i];
202 for(
int i=0; i<mnus.size(); i++)
218 QColor qcolor(color.
getRgba());
219 qcolor.setAlpha(qAlpha(color.
getRgba()));
243 const QColor& fillColor,
const QColor& contourColor,
const std::size_t& contourWidth)
246 QString::number(contourWidth).toStdString(),
247 QString::number(contourColor.alphaF()).toStdString());
250 QString::number(fillColor.alphaF()).toStdString());
277 QColor fillColor = selectionColor;
278 fillColor.setAlpha(128);
293 QColor fillColor = selectionColor;
294 fillColor.setAlpha(128);
309 QColor fillColor = selectionColor;
310 fillColor.setAlpha(70);
312 QColor contourColor = selectionColor;
313 contourColor.setAlpha(150);
326 QPixmap pix(size, size);
327 pix.fill(Qt::transparent);
332 path.addRect(offset, offset, pix.width() - 2 * offset, pix.height() - 2 * offset);
335 pen.setColor(penColor);
336 pen.setWidth(contourSize);
339 brush.setColor(brushColor);
343 p.setBrush(brushColor);
345 p.fillPath(path, brush);
353 QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
355 QString key =
"Last used file path/" + typeFile;
357 sett.setValue(key, path);
362 QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
364 QString key =
"Last used file path/" + typeFile;
366 return sett.value(key).toString();
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.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
TEQTWIDGETSEXPORT te::color::RGBAColor Convert2TerraLib(const QColor &color)
It converts a Qt Color to TerraLib Color.
A Fill specifies the pattern for filling an area geometry.
virtual void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)=0
It sets the point pattern.
QMenu * CreateMenu(const QString &mnuName, QMenu *p)
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
A canvas is an abstraction of a drawing area.
TEQTWIDGETSEXPORT QString GetFilePathFromSettings(const QString &typeFile)
Returns the value of the last saved file path for the typeFile required.
virtual void setPolygonContourColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw the boundary of polygon geometries.
A Stroke specifies the appearance of a linear geometry.
TEQTWIDGETSEXPORT void AddFilePathToSettings(const QString &path, const QString &typeFile)
Save last used path in QSettings.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
TEQTWIDGETSEXPORT QAction * FindAction(const QString &actText, QMenu *mnu)
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).
virtual void setPolygonFillColor(const te::color::RGBAColor &color)=0
It sets the color used to fill the draw of polygon geometries.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
TEQTWIDGETSEXPORT void SetChildrenCheckState(QTreeWidgetItem *item, int column, Qt::CheckState state)
It sets the check state for the children of a item.
QStyle::StandardPixmap toQStyle(const QMessageBox::Icon &icon)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
virtual void setPolygonContourWidth(int w)=0
It sets the polygon contour width.
virtual void setPointColor(const te::color::RGBAColor &color)=0
It sets the point drawing color.
TEQTWIDGETSEXPORT QMenu * GetMenu(const QString &mnuText, QMenu *mnu)
Gets a menu or submenu contained in the mnu object.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
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.
TEQTWIDGETSEXPORT QColor Convert2Qt(const te::color::RGBAColor &color)
It converts a TerraLib Color to Qt Color.
virtual void setLineColor(const te::color::RGBAColor &color)=0
It sets the pen color used to draw line geometries.
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.
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
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.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
virtual void setLineWidth(int w)=0
It sets the line width.
int getRed() const
It returns the red component color value (a value from 0 to 255).
TEQTWIDGETSEXPORT QMenu * FindMenu(const QString &mnuText, QMenu *mnu)
Finds a menu item in the mnu object.
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
A Mark specifies a geometric shape and applies coloring to it.