27 #include "../../../se/Config.h"
28 #include "../../../se/Stroke.h"
29 #include "../../../se/SvgParameter.h"
30 #include "../../../se/Utils.h"
31 #include "../../../maptools/Utils.h"
32 #include "../../../maptools/Enums.h"
33 #include "../propertybrowser/AbstractPropertyManager.h"
41 #include <QtPropertyBrowser/QtTreePropertyBrowser>
42 #include <QtPropertyBrowser/QtVariantPropertyManager>
49 m_stroke(new te::se::Stroke)
94 addProperty(basicStrokeProperty, tr(
"Basic Stroke"), QColor(175, 255, 175));
108 m_stroke = stroke->
clone();
115 return m_stroke->
clone();
123 m_color = QColor(rgba.
getRgba());
125 updateUiStrokeColor();
140 for(
size_t t = 0; t < m_dashes.size(); ++t)
142 if(str == m_dashes[t])
160 std::map<int, std::string>::iterator it = m_joinMap.begin();
162 while(it != m_joinMap.end())
164 if(it->second == joinStr)
183 std::map<int, std::string>::iterator it = m_capMap.begin();
185 while(it != m_capMap.end())
187 if(it->second == capStr)
208 if(p == m_opacityProperty)
210 double opacity = value / 100.0;
212 m_color.setAlpha(opacity * 255);
213 updateUiStrokeColor();
216 m_stroke->setOpacity(QString::number(opacity,
'g', 2).toStdString());
217 emit strokeChanged();
219 else if(p == m_dashProperty)
224 std::string pattern = m_dashes[value];
225 m_stroke->setDashArray(pattern);
226 emit strokeChanged();
228 else if(p == m_joinProperty)
230 m_stroke->setLineJoin(m_joinMap[value]);
232 emit strokeChanged();
234 else if(p == m_capProperty)
236 m_stroke->setLineCap(m_capMap[value]);
238 emit strokeChanged();
244 if(p == m_widthProperty)
249 m_stroke->setWidth(str.toStdString());
250 emit strokeChanged();
256 if(p == m_colorProperty)
259 m_color.setRgb(value.red(), value.green(), value.blue(), m_color.alpha());
261 updateUiStrokeColor();
264 m_stroke->setColor(m_color.name().toStdString());
265 emit strokeChanged();
271 QMap<int, QIcon> map;
277 QLine line(0, size.height() * 0.5, size.width(), size.height() * 0.5);
283 for(
size_t t = 0; t < m_dashes.size(); ++t)
285 QPixmap pixmap(size);
286 pixmap.fill(Qt::transparent);
288 QPainter painter(&pixmap);
290 std::string pattern = m_dashes[t];
291 std::vector<double> dasharray;
294 QVector<qreal> qdasharray = QVector<qreal>::fromStdVector(dasharray);
296 pen.setDashPattern(qdasharray);
298 painter.drawLine(line);
310 QMap<int, QIcon> map;
312 map[0] = QIcon::fromTheme(
"stroke-join-miter").pixmap(16,16);
313 map[1] = QIcon::fromTheme(
"stroke-join-round").pixmap(16,16);
314 map[2] = QIcon::fromTheme(
"stroke-join-bevel").pixmap(16,16);
321 QMap<int, QIcon> map;
323 map[0] = QIcon::fromTheme(
"stroke-cap-butt").pixmap(16,16);
324 map[1] = QIcon::fromTheme(
"stroke-cap-round").pixmap(16,16);
325 map[2] = QIcon::fromTheme(
"stroke-cap-square").pixmap(16,16);
332 m_dashes.push_back(
"");
333 m_dashes.push_back(
"1 2");
334 m_dashes.push_back(
"4 2");
335 m_dashes.push_back(
"4 2 1 2");
336 m_dashes.push_back(
"4 2 1 2 1 2");
340 for(
size_t t = 0; t < m_dashes.size(); ++t)
342 l << m_dashes[t].c_str();
350 m_joinMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_MITRE_JOIN));
351 m_joinMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_JOIN));
352 m_joinMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_BEVEL_JOIN));
356 l << m_joinMap[0].c_str();
357 l << m_joinMap[1].c_str();
358 l << m_joinMap[2].c_str();
365 m_capMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_BUTT_CAP));
366 m_capMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_CAP));
367 m_capMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_SQUARE_CAP));
371 l << m_capMap[0].c_str();
372 l << m_capMap[1].c_str();
373 l << m_capMap[2].c_str();
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.
static AbstractPropertyManager & getInstance()
It returns a reference to the singleton instance.
A widget used to define the basic fill se object.
#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.
#define TE_SE_DEFAULT_FILL_BASIC_COLOR
It specifies the default color used by basic fill (solid colors).
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.