SymbologyWidgets.cpp
Go to the documentation of this file.
1 #include "SymbologyWidgets.h"
2 
3 // TerraLib
5 #include <terralib/common.h>
6 #include <terralib/se.h>
23 
24 
25 // Qt
26 #include <QApplication>
27 #include <QDialog>
28 #include <QGridLayout>
29 #include <QGroupBox>
30 #include <QMdiArea>
31 #include <QMdiSubWindow>
32 #include <QToolBox>
33 
34 // STL
35 #include <cassert>
36 #include <iostream>
37 
39 {
40  // Loads the Symbol Library from XML file
41 
42  //te::serialize::ReadSymbolLibrary("E:/TerraLib/terralib5_develop/schemas/terralib/qt/se/symbol.xml");
43 
44  std::string slib_path= te::core::FindInTerraLibPath("share/terralib/schemas/terralib/qt/se");
45 
46  te::qt::widgets::ReadSymbolLibrary(slib_path + "symbol.xml");
47 
48  // Select a symbol
50  if(symbol == 0)
51  return;
52 
53  // Shows the selected symbol information
54  te::qt::widgets::SymbolInfo info = symbol->getInfo();
55  std::cout << ":: Selected Symbol ::" << std::endl;
56  std::cout << "- ID: " << info.m_id << std::endl;
57  std::cout << "- Name: " << info.m_name << std::endl;
58  std::cout << "- Author: " << info.m_author << std::endl;
59  std::cout << "- Tags: " << info.m_tags << std::endl;
60  std::cout << "- Description: " << info.m_description << std::endl;
61  std::cout << "- Number of Symbolizers: " << symbol->getSymbolizersCount() << std::endl;
62 
63  delete symbol;
64 }
65 
67 {
68  // Widgets for symbol edition...
72 
73  // Symbol Information
75  info.m_id = "179C25E4-AABC-4F63-8C10-AAD00CCE74F9";
76  info.m_name = "Brazilian Highway";
77  info.m_author = "TerraLib Team";
78  info.m_tags = "highway; road; Brazil";
79  info.m_description = "This symbol is used to represent highways.";
81  symbolInfo->setSymbolInfo(info);
82 
83  // Grouping to show!
84  QMdiArea mainWidget;
85  mainWidget.setWindowTitle("Symbol Editors");
86  mainWidget.addSubWindow(editPointSymbol)->setWindowTitle("Point Symbol");
87  mainWidget.addSubWindow(editLineSymbol)->setWindowTitle("Line Symbol");
88  mainWidget.addSubWindow(editPolygonSymbol)->setWindowTitle("Polygon Symbol");
89  mainWidget.addSubWindow(symbolInfo);
90  mainWidget.show();
91 
92  qApp->exec();
93 }
94 
96 {
97  QDialog dlg;
98  dlg.setWindowTitle("Symbolizer Widgets Example");
99 
100  // Polygon Symbolizer Widget
102 
103  // Line Symbolizer Widget
105 
106  // Point Symbolizer Widget
108 
109  // Grouping...
110  QToolBox* box = new QToolBox(&dlg);
111  box->addItem(ps, "&Polygon Symbolyzer");
112  box->addItem(ls, "&Line Symbolyzer");
113  box->addItem(pts, "P&oint Symbolyzer");
114 
115  // Adjusting...
116  QGridLayout* layout = new QGridLayout(&dlg);
117  layout->setSizeConstraint(QLayout::SetFixedSize);
118  layout->addWidget(box);
119 
120  dlg.exec();
121 }
122 
124 {
125  QDialog dlg;
126  dlg.setWindowTitle("Symbolizer Preview Example");
127 
128  // Creates the symbol
132  symbol->addSymbolizer(te::se::CreateLineSymbolizer(te::se::CreateStroke("#FFFF00", "2.0", "1.0", "2 2")));
133 
134  // Preview
136  preview->updatePreview(symbol);
137 
138  // Table preview
140  table->updatePreview(symbol);
141  table->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
142 
143  // Adjusting...
144  QGridLayout* layout = new QGridLayout(&dlg);
145  layout->setSizeConstraint(QLayout::SetFixedSize);
146  layout->addWidget(preview, 0, 0);
147  layout->addWidget(table, 1, 0);
148 
149  dlg.exec();
150 
151  delete symbol;
152 }
153 
155 {
156  QString title("Testing Basic Symbology Widgets");
157 
158  // Creates a new stroke
160  delete stroke;
161 
162  // Creates a new stroke based on pre-existed
163  te::se::Stroke* initialStroke = te::se::CreateStroke("#FF0000", "2", "0.5", "5 5", "round", "round");
164  stroke = te::qt::widgets::BasicStrokeDialog::getStroke(initialStroke, 0, title);
165  delete stroke;
166  delete initialStroke;
167 
168  // Create a new Fill
170  delete fill;
171 
172  // Creates a new fill based on pre-existed
173  te::se::Fill* initialFill = te::se::CreateFill("#00FF00", "0.5");
174  fill = te::qt::widgets::BasicFillDialog::getFill(initialFill, 0, title);
175  delete fill;
176  delete initialFill;
177 
178  // Creates a new well known mark
180  delete mark;
181 
182  // Creates a new mark based on pre-existed
183  te::se::Stroke* markStroke = te::se::CreateStroke("#000000", "3", "0.5");
184  te::se::Fill* markFill = te::se::CreateFill("#FFFF00", "1.0");
185  te::se::Mark* initialMark = te::se::CreateMark("star", markStroke, markFill);
186  mark = te::qt::widgets::WellKnownMarkDialog::getMark(initialMark, 0, title);
187  delete mark;
188  delete initialMark;
189 
190  // Create a new glyph mark
192  delete glyphMark;
193 
194  // Creates a new graphic
196  delete graphic;
197  }
198 
200 {
201  int argc = 1;
202  QApplication app(argc, 0);
203 
204  // Adjusting icons theme
205  QStringList ithemes = QIcon::themeSearchPaths();
206  ithemes.push_back(te::core::FindInTerraLibPath("share/terralib/icons").c_str());
207  QIcon::setThemeName("terralib");
208  QIcon::setThemeSearchPaths(ithemes);
209 
210  SymbolSelector();
211 
212  SymbolEditor();
213 
215 
216  PreviewWidgets();
217 
218  BasicWidgets();
219 }
Several examples declarations.
A widget used to build a point symbolizer element.
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
A widget used to preview symbol elements.
This class represents a symbol.
std::size_t getSymbolizersCount() const
It returns the number of Symbolizers that compose of the symbol.
Definition: Symbol.cpp:58
A dialog used to configure informations about a symbol.
void SymbolizerWidgets()
This file is a wrapper around platform specific include files.
te::se::Mark * getMark() const
Gets the configured mark element.
void SymbologyWidgets()
It shows a set of widgets related with Symbology Encondig.
A widget used to build a line symbolizer element.
A dialog used to build a basic fill element.
This file contains include headers for TerraLib Symbology Encoding module.
void PreviewWidgets()
TESEEXPORT LineSymbolizer * CreateLineSymbolizer(Stroke *stroke)
Creates a line symbolizer.
A widget used to preview a symbol as separated layers.
te::se::Graphic * getGraphic() const
Gets the configured graphic element.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
A dialog used to build a basic stroke element.
const SymbolInfo & getInfo() const
It return the information associated to the symbol.
Definition: Symbol.cpp:48
A dialog used to select a specific symbol.
A widget used to edit symbols.
Symbol * getSymbol() const
Gets the selected symbol.
A widget used to edit symbols.
A widget used to build a line symbolizer element.
A dialog used to configure informations about a symbol.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
Information about a given Symbol.
Definition: SymbolInfo.h:60
This class represents a symbol. TODO: More description!
Definition: Symbol.h:54
A widget used to build a point symbolizer element.
A widget used to preview a symbol as separated layers.
This file contains utility functions for dealing with Symbology Enconding and Qt concepts.
A dialog used to build a graphic element.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
A dialog used to build a glyph mark element.
A widget used to build a polygon symbolizer element.
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
te::se::Stroke * getStroke() const
Gets the configured stroke element.
void updatePreview(Symbol *symbol)
Preview a symbol element.
A widget used to preview symbol elements.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
void SymbolSelector()
A dialog used to build a well known mark element.
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
void updatePreview(Symbol *symbol)
Preview a symbol element.
void BasicWidgets()
This file contains include headers for the TerraLib Common Runtime module.
te::se::Mark * getMark() const
Gets the configured mark element.
te::se::Fill * getFill() const
Gets the configured fill element.
TEQTWIDGETSEXPORT void ReadSymbolLibrary(const std::string &path)
It reads a symbol library file and put the result on SymbolLibraryManager.
A widget used to build a polygon symbolizer element.
void setSymbolInfo(const SymbolInfo &info)
Sets the symbol information to this dialog.
void SymbolEditor()
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
void addSymbolizer(te::se::Symbolizer *symb)
It adds the given Symbolizer to the list of Symbolizers of the symbol.
Definition: Symbol.cpp:80