27 #include "../../../maptools/Utils.h"
28 #include "../../../maptools/Enums.h"
29 #include "../../../se/Stroke.h"
30 #include "../../../se/SvgParameter.h"
31 #include "../../../se/Utils.h"
32 #include "../utils/ColorPickerToolButton.h"
34 #include "ui_BasicStrokeWidgetForm.h"
44 m_ui(new Ui::BasicStrokeWidgetForm),
45 m_stroke(new te::se::Stroke)
54 QGridLayout* layout =
new QGridLayout(
m_ui->m_colorPickerFrame);
55 layout->setContentsMargins(0, 0, 0, 0);
56 layout->setSizeConstraint(QLayout::SetFixedSize);
81 m_stroke = stroke->
clone();
88 return m_stroke->
clone();
94 m_dashes.push_back(
"");
95 m_dashes.push_back(
"1 2");
96 m_dashes.push_back(
"4 2");
97 m_dashes.push_back(
"4 2 1 2");
98 m_dashes.push_back(
"4 2 1 2 1 2");
103 updateUiStrokeColor();
106 fillStrokeDashStyleComboBox();
109 m_strokeJoinStyleButtonGroup =
new QButtonGroup(
this);
110 m_strokeJoinStyleButtonGroup->addButton(m_ui->m_miterJoinPushButton,
te::map::MiterJoin);
111 m_strokeJoinStyleButtonGroup->addButton(m_ui->m_roundJoinPushButton,
te::map::RoundJoin);
112 m_strokeJoinStyleButtonGroup->addButton(m_ui->m_bevelJoinPushButton,
te::map::BevelJoin);
115 m_strokeCapStyleButtonGroup =
new QButtonGroup(
this);
116 m_strokeCapStyleButtonGroup->addButton(m_ui->m_buttCapPushButton,
te::map::ButtCap);
117 m_strokeCapStyleButtonGroup->addButton(m_ui->m_roundCapPushButton,
te::map::RoundCap);
118 m_strokeCapStyleButtonGroup->addButton(m_ui->m_squareCapPushButton,
te::map::SquareCap);
121 m_ui->m_miterJoinPushButton->setIcon(QIcon::fromTheme(
"stroke-join-miter"));
122 m_ui->m_roundJoinPushButton->setIcon(QIcon::fromTheme(
"stroke-join-round"));
123 m_ui->m_bevelJoinPushButton->setIcon(QIcon::fromTheme(
"stroke-join-bevel"));
125 m_ui->m_buttCapPushButton->setIcon(QIcon::fromTheme(
"stroke-cap-butt"));
126 m_ui->m_roundCapPushButton->setIcon(QIcon::fromTheme(
"stroke-cap-round"));
127 m_ui->m_squareCapPushButton->setIcon(QIcon::fromTheme(
"stroke-cap-square"));
135 m_color = QColor(rgba.
getRgba());
137 updateUiStrokeColor();
140 m_ui->m_strokeOpacitySlider->setValue(m_color.alphaF() * 100);
165 m_colorPicker->setColor(m_color);
171 std::vector<std::string>::iterator it;
172 for(it = m_dashes.begin(); it != m_dashes.end(); ++it)
176 m_ui->m_strokeDashComboBox->setCurrentIndex(i);
182 if(it == m_dashes.end())
184 m_dashes.push_back(pattern);
185 fillStrokeDashStyleComboBox();
186 m_ui->m_strokeDashComboBox->setCurrentIndex(i);
194 m_ui->m_roundJoinPushButton->setChecked(
true);
196 m_ui->m_bevelJoinPushButton->setChecked(
true);
203 m_ui->m_roundCapPushButton->setChecked(
true);
205 m_ui->m_squareCapPushButton->setChecked(
true);
211 m_ui->m_strokeDashComboBox->clear();
217 m_ui->m_strokeDashComboBox->setIconSize(size);
220 QLine line(0, size.height() * 0.5, size.width(), size.height() * 0.5);
227 std::vector<std::string>::iterator it = m_dashes.begin();
228 for(it = m_dashes.begin(); it != m_dashes.end(); ++it)
230 QPixmap pixmap(size);
231 pixmap.fill(Qt::transparent);
233 QPainter painter(&pixmap);
235 std::string pattern = *it;
236 std::vector<double> dasharray;
239 QVector<qreal> qdasharray = QVector<qreal>::fromStdVector(dasharray);
241 pen.setDashPattern(qdasharray);
243 painter.drawLine(line);
245 m_ui->m_strokeDashComboBox->addItem(pixmap,
"");
252 m_color.setRgb(color.red(), color.green(), color.blue(), m_color.alpha());
254 updateUiStrokeColor();
257 m_stroke->setColor(m_color.name().toStdString());
258 emit strokeChanged();
263 double opacity = value / 100.0;
265 m_color.setAlpha(opacity * 255);
266 updateUiStrokeColor();
269 m_stroke->setOpacity(QString::number(opacity,
'g', 2).toStdString());
270 emit strokeChanged();
275 m_stroke->setWidth(text.toStdString());
276 emit strokeChanged();
284 std::string pattern = m_dashes[index];
285 m_stroke->setDashArray(pattern);
286 emit strokeChanged();
306 emit strokeChanged();
326 emit strokeChanged();
Stroke * clone() const
It creates a new copy of this object.
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
TESEEXPORT void GetColor(const te::se::Stroke *stroke, te::color::RGBAColor &color)
It gets the RGBA color from the Stroke element.
#define TE_SE_MITRE_JOIN
It specifies the value "mitre" for stroke-linejoin parameter.
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
#define TE_SE_BUTT_CAP
It specifies the value "butt" for stroke-linecap parameter.
#define TE_SE_BEVEL_JOIN
It specifies the value "bevel" for stroke-linejoin parameter.
TEMAPEXPORT void GetDashStyle(const std::string &dasharray, std::vector< double > &style)
Converts a dasharray pattern coded by a string to a vector of double.
#define TE_SE_SQUARE_CAP
It specifies the value "square" for stroke-linecap parameter.
#define TE_SE_DEFAULT_STROKE_BASIC_COLOR
It specifies the default color used by stroke basic (solid colors).
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
#define TE_SE_ROUND_JOIN
It specifies the value "round" for stroke-linejoin parameter.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
#define TE_SE_ROUND_CAP
It specifies the value "round" for stroke-linecap parameter.
A Stroke specifies the appearance of a linear geometry.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
A SvgParameter refers to an SVG/CSS graphical-formatting parameter.
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.