27 #include "../../../common/Exception.h"
28 #include "../../../serialization/qt/widgets/Symbol.h"
36 #include "ui_SymbolSelectorDialogForm.h"
39 #include <QtGui/QFileDialog>
40 #include <QtGui/QMessageBox>
47 m_ui(new Ui::SymbolSelectorDialogForm)
51 m_ui->m_symbolLibraryTreeWidget->setIconSize(QSize(32, 32));
57 QGridLayout* previewLayout =
new QGridLayout(
m_ui->m_previewGroupBox);
61 connect(
m_ui->m_symbolLibraryTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(
onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
78 dlg.setWindowTitle(title);
80 if(dlg.exec() == QDialog::Accepted)
88 Symbol* symbol = getSelectedSymbol();
93 return symbol->
clone();
98 Symbol* symbol = getSymbolFromItem(current);
103 m_preview->updatePreview(symbol);
108 Symbol* symbol = getSelectedSymbol();
122 QString path = QFileDialog::getOpenFileName(
this, tr(
"Select a TerraLib Symbol Library File"),
"",
"XML (.xml)");
133 QString message = tr(
"The selected symbol library could not be loaded.\n Details: )");
135 QMessageBox::critical(
this, tr(
"Error"), message);
141 QList<QTreeWidgetItem*> items = m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 0);
142 items.append(m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 1));
143 items.append(m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 2));
151 std::pair<std::map<std::string, SymbolLibrary*>::const_iterator,
154 std::map<std::string, SymbolLibrary*>::const_iterator itLibrary;
155 for(itLibrary = iteratorsLibrary.first; itLibrary != iteratorsLibrary.second; ++itLibrary)
157 QString libraryName = QString::fromStdString(itLibrary->second->getName());
159 QTreeWidgetItem* libraryItem =
new QTreeWidgetItem(m_ui->m_symbolLibraryTreeWidget, LIBRARY);
160 libraryItem->setText(0, libraryName);
161 libraryItem->setData(0, Qt::UserRole, libraryName);
163 std::pair<std::map<std::string, Symbol*>::const_iterator,
164 std::map<std::string, Symbol*>::const_iterator> iteratorsSymbol = itLibrary->second->getIterator();
166 std::map<std::string, Symbol*>::const_iterator itSymbol;
168 for(itSymbol = iteratorsSymbol.first; itSymbol != iteratorsSymbol.second; ++itSymbol)
171 Symbol* symbol = itSymbol->second;
174 QTreeWidgetItem* symbolItem =
new QTreeWidgetItem(libraryItem, SYMBOL);
177 symbolItem->setToolTip(0, formatSymbolInfo(symbol->
getInfo()));
178 symbolItem->setData(0, Qt::UserRole, QVariant(QString(symbol->
getInfo().
m_id.c_str())));
185 m_ui->m_symbolLibraryTreeWidget->sortItems(0, Qt::AscendingOrder);
186 m_ui->m_symbolLibraryTreeWidget->resizeColumnToContents(0);
187 m_ui->m_symbolLibraryTreeWidget->expandAll();
192 for(
int i = 0; i < m_ui->m_symbolLibraryTreeWidget->topLevelItemCount(); ++i)
194 QTreeWidgetItem* library = m_ui->m_symbolLibraryTreeWidget->topLevelItem(i);
195 assert(library && library->type() == LIBRARY);
197 for(
int j = 0; j < library->childCount(); ++j)
199 QTreeWidgetItem* symbol = library->child(j);
200 assert(symbol && symbol->type() == SYMBOL);
201 bool hide = items.indexOf(symbol) == -1;
202 symbol->setHidden(hide);
210 QList<QTreeWidgetItem*> selected = m_ui->m_symbolLibraryTreeWidget->selectedItems();
215 return getSymbolFromItem(selected.at(0));
222 if(item->type() != SYMBOL)
226 QTreeWidgetItem* parent = item->parent();
229 QString name = parent->data(0, Qt::UserRole).toString();
230 assert(!name.isEmpty());
233 assert(symbolLibrary);
236 QString
id = item->data(0, Qt::UserRole).toString();
237 assert(!
id.isEmpty());
239 Symbol* symbol = symbolLibrary->findById(
id.toStdString());
247 QString information(
"<h3>Symbol Information</h3><ul>");
248 information +=
"<li><b>Name: </b>" + QString(info.
m_name.c_str()) +
"</li>";
249 information +=
"<li><b>Author: </b>" + QString(info.
m_author.c_str()) +
"</li>";
250 information +=
"<li><b>Tags: </b>" + QString(info.
m_tags.c_str()) +
"</li>";
251 information +=
"<li><b>Description: </b>" + QString(info.
m_description.c_str()) +
"</li>";
252 information +=
"</ul>";
static QPixmap build(const te::se::Symbolizer *symb, const QSize &size)
Generates the preview of given symbolizer element.
Symbol * clone() const
It creates a new copy of this object.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
void setReadMode(bool enable=true)
SymbolPreviewWidget * m_preview
Preview Widget used to visualize the symbol.
void setSymbolInfo(const SymbolInfo &info)
Sets the symbol information to this dialog.
A widget used to preview symbol elements.
void onCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
void onSearchLineEditTextChanged(const QString &text)
std::string m_description
Symbol * getSymbolFromItem(QTreeWidgetItem *item) const
Auxiliary internal method that returns the symbol given a list widget item.
virtual const char * what() const
It outputs the exception message.
The SymbolLibraryManager is a singleton that can be used to manage all loaded symbol libraries in Ter...
void onShowSymbolInfoPushButtonPressed()
This class represents a symbol. TODO: More description!
~SymbolSelectorDialog()
Destructor.
std::pair< std::map< std::string, SymbolLibrary * >::const_iterator, std::map< std::string, SymbolLibrary * >::const_iterator > getIterator() const
It returns a pair of iterators over the symbol libraries of this manager.
A dialog used to select a specific symbol.
void filter(const QList< QTreeWidgetItem * > &items)
Auxiliary internal method to filter the symbols.
This class represents a library of symbols.
Symbol * getSymbol() const
Gets the selected symbol.
A dialog used to configure informations about a symbol.
const SymbolInfo & getInfo() const
It return the information associated to the symbol.
std::auto_ptr< Ui::SymbolSelectorDialogForm > m_ui
Dialog form.
Symbol * getSelectedSymbol() const
Auxiliary internal method that returns the selected symbol.
A dialog used to select a specific symbol.
void onLoadSymbolLibraryPushButtonPressed()
Static class used to generate preview of Symbology elements.
This class represents a symbol.
Information about a given Symbol.
SymbolLibrary * findByName(const std::string &name) const
It returns the symbol library identified by a given name or NULL if none is found.
QString formatSymbolInfo(const SymbolInfo &info) const
Auxiliary internal method to format a symbol info to be used on tool tips.
static Symbol * getSymbol(QWidget *parent, const QString &title="")
Pops up a modal symbol selector dialog with the given window title, lets the user select a symbol...
static SymbolLibraryManager & getInstance()
It returns a reference to the singleton instance.
This class represents a library of symbols.
A dialog used to configure informations about a symbol.
A widget used to preview symbol elements.
SymbolSelectorDialog(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a symbol selector dialog which is a child of parent, with widget flags set to f...
void initialize()
Initialize the dialog.
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It returns the list of Symbolizers that compose the symbol.