28 #include "../../../core/filesystem/FileSystem.h" 29 #include "../../../dataaccess/utils/Utils.h" 30 #include "../../../geometry/GeometryProperty.h" 31 #include "../../../fe.h" 32 #include "../../../se/FeatureTypeStyle.h" 33 #include "../../../se/Font.h" 34 #include "../../../se/Rule.h" 35 #include "../../../se/TextSymbolizer.h" 36 #include "../../../se/Utils.h" 37 #include "../../../se/Style.h" 38 #include "../../../se/Symbolizer.h" 39 #include "../../../se/serialization/xml/Style.h" 40 #include "../../../xml/AbstractWriter.h" 41 #include "../../../xml/AbstractWriterFactory.h" 42 #include "../../../xml/Reader.h" 43 #include "../../../xml/ReaderFactory.h" 44 #include "../../widgets/Utils.h" 51 #include "ui_StyleControllerWidgetForm.h" 54 #include <QMessageBox> 55 #include <QFileDialog> 65 #include <boost/filesystem/operations.hpp> 69 m_ui(new
Ui::StyleControllerWidgetForm),
70 m_currentStyle(nullptr),
71 m_currentLayer(nullptr)
77 connect(
m_ui->m_explorer_frame->m_addRuleToolButton, SIGNAL(clicked()),
this, SLOT(
onAddRuleClicked()));
85 connect(
m_ui->m_explorer_frame->m_exportStyleToolButton, SIGNAL(clicked()),
this, SLOT(
onExportClicked()));
86 connect(
m_ui->m_explorer_frame->m_importStyleToolButton, SIGNAL(clicked()),
this, SLOT(
onImportClicked()));
91 m_ui->m_explorer_frame->m_addRuleToolButton->setEnabled(
false);
92 m_ui->m_explorer_frame->m_removeRuleToolButton->setEnabled(
false);
102 m_ui->m_explorer->setStyle(style);
104 m_ui->m_visualStyleRadioButton->setEnabled(
false);
105 m_ui->m_selectionStyleRadioButton->setEnabled(
false);
107 m_ui->m_layerGroupBox->setVisible(
false);
116 std::unique_ptr<te::da::DataSetType> dsType = layer->
getSchema();
118 if (dsType->hasGeom())
126 if (symbolizer !=
nullptr)
134 m_ui->m_selectionStyleRadioButton->setEnabled(
true);
138 m_ui->m_visualStyleRadioButton->setChecked(
true);
139 m_ui->m_selectionStyleRadioButton->setEnabled(
false);
144 m_ui->m_selectionStyleRadioButton->setEnabled(
true);
147 if (
m_ui->m_visualStyleRadioButton->isChecked())
149 m_ui->m_explorer->setStyle(layer->
getStyle(), currentRule);
164 return m_ui->m_explorer;
171 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a layer first."));
177 QMessageBox::information(
this, tr(
"Style"), tr(
"Style not defined"));
209 m_ui->m_explorer->updateStyleTree();
218 QMessageBox::information(
this, tr(
"Style"), tr(
"Style not defined"));
224 QMessageBox::information(
this, tr(
"Style"), tr(
"It is not possible to leave a style without rules."));
232 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a rule first."));
245 m_ui->m_explorer->updateStyleTree();
256 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a rule first."));
267 m_ui->m_explorer->updateStyleTree();
276 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a rule first."));
294 m_ui->m_explorer->updateStyleTree();
303 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a symbol first."));
312 QMessageBox::information(
this, tr(
"Style"), tr(
"The rule must have at least one symbol."));
325 m_ui->m_explorer->updateStyleTree();
334 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a symbol first."));
338 m_ui->m_explorer->goUpSymbolizer();
347 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a symbol first."));
351 m_ui->m_explorer->goDownSymbolizer();
360 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a rule first."));
365 if(symbol ==
nullptr)
368 std::vector<te::se::Symbolizer*> symbolizers;
374 m_ui->m_explorer->updateStyleTree();
381 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a layer first."));
387 if (styleFile.isEmpty())
390 QFileInfo info(styleFile);
394 if (info.suffix().isEmpty())
395 styleFile.append(
".sld");
404 QMessageBox::information(
this, tr(
"Style"), tr(
"Select a layer first."));
410 QFileInfo info(styleFile);
414 if (!styleFile.isEmpty())
427 m_ui->m_explorer->setLegendIconSize(size);
455 writer->setURI(file.string());
456 writer->writeStartDocument(
"UTF-8",
"no");
458 writer->writeStartElement(
"StyledLayerDescriptor");
460 writer->writeAttribute(
"xmlns",
"http://www.opengis.net/sld");
461 writer->writeAttribute(
"xmlns:ogc",
"http://www.opengis.net/ogc");
462 writer->writeAttribute(
"xmlns:se",
"http://www.opengis.net/se");
463 writer->writeAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink");
464 writer->writeAttribute(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
465 writer->writeAttribute(
"xsi:schemaLocation",
"http://www.opengis.net/sld StyledLayerDescriptor.xsd");
467 writer->writeAttribute(
"version", style->
getVersion());
469 writer->writeStartElement(
"NamedLayer");
470 writer->writeStartElement(
"UserStyle");
474 writer->writeEndElement(
"UserStyle");
475 writer->writeEndElement(
"NamedLayer");
477 writer->writeEndElement(
"StyledLayerDescriptor");
478 writer->writeToFile();
484 std::unique_ptr<te::se::Style> style;
489 reader->setValidationScheme(
false);
491 reader->read(file.string());
496 QMessageBox::warning(
this, tr(
"Style Explorer"), tr(
"The selected theme is not compatible with the current data."));
501 (reader->getElementLocalName() ==
"StyledLayerDescriptor"))
505 (reader->getElementLocalName() ==
"NamedLayer"))
509 (reader->getElementLocalName() ==
"Name"))
521 (reader->getElementLocalName() ==
"UserStyle"))
525 (reader->getElementLocalName() ==
"Name"))
537 (reader->getElementLocalName() ==
"FeatureTypeStyle"))
542 m_ui->m_explorer->importStyle(style.release(),
m_ui->m_visualStyleRadioButton->isChecked());
546 QMessageBox::warning(
this, tr(
"Style Explorer"), tr(
"The style contained unrecognized elements and could not be read."));
557 m_ui->m_explorer->setStyle(
nullptr);
559 m_ui->m_visualStyleRadioButton->setEnabled(
false);
560 m_ui->m_selectionStyleRadioButton->setEnabled(
false);
562 m_ui->m_layerGroupBox->setVisible(
false);
568 std::ifstream t(file);
569 std::stringstream buffer;
572 sldFile = buffer.str();
574 std::size_t found = sldFile.find(
m_ui->m_explorer->getCurrentSymbolizer()->getType());
576 if (found != std::string::npos)
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
This is the base class for layers.
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
This class represents a symbol.
virtual te::se::Style * getSelectionStyle() const
It returns the selection Style associated to the layer.
A Symbolizer describes how a feature is to appear on a map.
static te::xml::AbstractWriter * make()
It creates a new XML writer using the dafault implementation.
void push_back(const std::string &semanticTypeIdentifier)
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
TESEEXPORT TextSymbolizer * CreateTextSymbolizer(const std::string &label, Fill *fill, Font *font)
Creates a text symbolizer.
void push_back(Symbolizer *s)
A dialog used to select a specific symbol.
Rule * getRule(std::size_t i) const
const std::vector< Rule * > & getRules() const
static std::string absolutePath(const std::string &path)
Retrives the absolute path for the given path in UTF-8.
static Style & getInstance()
It returns a reference to the singleton instance.
The FeatureTypeStyle defines the styling that is to be applied to a dataset that can be viewed as a f...
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
A Font specifies the text font to use in a text symbolizer.
A Fill specifies the pattern for filling an area geometry.
void removeRule(std::size_t i)
virtual void setSelectionStyle(te::se::Style *style)
It sets the selection Style associated to the layer.
void setSymbolizers(const std::vector< Symbolizer * > &symbs)
const std::vector< Symbolizer * > & getSymbolizers() const
void removeSymbolizer(std::size_t i)
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
TESEEXPORT Font * CreateFont(const std::string &family, const std::string &size, const te::se::Font::FontStyleType &style=te::se::Font::StyleNormal, const te::se::Font::FontWeightType &weight=te::se::Font::WeightNormal)
Creates a font.
virtual Symbolizer * clone() const =0
It creates a new copy of this object.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
const Symbolizer * getSymbolizer(std::size_t i) const
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
const std::string & getVersion() const