All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SymbolPreviewWidget.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 terralib/qt/widgets/se/SymbolPreviewWidget.cpp
22 
23  \brief A widget used to preview symbol elements.
24 */
25 
26 // TerraLib
27 #include "../../../geometry/Line.h"
28 #include "../../../geometry/LinearRing.h"
29 #include "../../../geometry/Point.h"
30 #include "../../../geometry/Polygon.h"
31 #include "../../../maptools/CanvasConfigurer.h"
32 #include "../canvas/Canvas.h"
33 #include "Symbol.h"
34 #include "SymbologyPreview.h"
35 #include "SymbolPreviewWidget.h"
36 
37 // Qt
38 #include <QGridLayout>
39 #include <QLabel>
40 
41 // STL
42 #include <cassert>
43 
45  : QWidget(parent),
46  m_geom(0),
47  m_size(size)
48 {
49  // Label preview
50  m_previewLabel = new QLabel(this);
51  m_previewLabel->setFixedSize(m_size);
52 
53  // Adjusting...
54  QGridLayout* layout = new QGridLayout(this);
55  layout->setContentsMargins(0, 0, 0, 0);
56  layout->setSizeConstraint(QLayout::SetFixedSize);
57  layout->addWidget(m_previewLabel);
58 }
59 
61 {
62  delete m_geom;
63 }
64 
66 {
67  updatePreview(symbol->getSymbolizers());
68 }
69 
70 void te::qt::widgets::SymbolPreviewWidget::updatePreview(const std::vector<te::se::Symbolizer*>& symbolizers)
71 {
72  m_previewLabel->setPixmap(te::qt::widgets::SymbologyPreview::build(symbolizers, m_size));
73 }
74 
76 {
77  m_previewLabel->setPixmap(te::qt::widgets::SymbologyPreview::build(symbolizer, m_size));
78 }
A widget used to preview symbol elements.
This class represents a symbol.
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
Static class used to generate preview of Symbology elements.
This class represents a symbol. TODO: More description!
Definition: Symbol.h:54
QLabel * m_previewLabel
Qt element that will be used to visualize preview result.
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It returns the list of Symbolizers that compose the symbol.
Definition: Symbol.cpp:77
void updatePreview(Symbol *symbol)
Preview a symbol element.
SymbolPreviewWidget(const QSize &size, QWidget *parent=0)
Constructs a symbol preview widget with fixed size, which is a child of parent, with widget flags set...
static QPixmap build(const te::se::Symbolizer *symb, const QSize &size)
Generates the preview of given symbolizer element.