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));
110 m_stroke = stroke->
clone();
117 return m_stroke->
clone();
125 m_color = QColor(rgba.
getRgba());
127 updateUiStrokeColor();
142 for(
size_t t = 0; t < m_dashes.size(); ++t)
144 if(str == m_dashes[t])
162 std::map<int, std::string>::iterator it = m_joinMap.begin();
164 while(it != m_joinMap.end())
166 if(it->second == joinStr)
185 std::map<int, std::string>::iterator it = m_capMap.begin();
187 while(it != m_capMap.end())
189 if(it->second == capStr)
215 if(p == m_opacityProperty)
217 double opacity = value / 100.0;
219 m_color.setAlpha(opacity * 255);
220 updateUiStrokeColor();
223 m_stroke->setOpacity(QString::number(opacity,
'g', 2).toStdString());
224 emit strokeChanged();
226 else if(p == m_dashProperty)
231 std::string pattern = m_dashes[value];
232 m_stroke->setDashArray(pattern);
233 emit strokeChanged();
235 else if(p == m_joinProperty)
237 m_stroke->setLineJoin(m_joinMap[value]);
239 emit strokeChanged();
241 else if(p == m_capProperty)
243 m_stroke->setLineCap(m_capMap[value]);
245 emit strokeChanged();
258 if(p == m_widthProperty)
263 m_stroke->setWidth(str.toStdString());
264 emit strokeChanged();
277 if(p == m_colorProperty)
280 m_color.setRgb(value.red(), value.green(), value.blue(), value.alpha());
282 int opacity = (value.alpha() / 255.) * 100.;
286 updateUiStrokeColor();
289 m_stroke->setColor(m_color.name().toStdString());
290 m_stroke->setOpacity(QString::number(opacity,
'g', 2).toStdString());
291 emit strokeChanged();
299 QMap<int, QIcon> map;
305 QLine line(0, size.height() * 0.5, size.width(), size.height() * 0.5);
311 for(
size_t t = 0; t < m_dashes.size(); ++t)
313 QPixmap pixmap(size);
314 pixmap.fill(Qt::transparent);
316 QPainter painter(&pixmap);
318 std::string pattern = m_dashes[t];
319 std::vector<double> dasharray;
322 QVector<qreal> qdasharray = QVector<qreal>::fromStdVector(dasharray);
324 pen.setDashPattern(qdasharray);
326 painter.drawLine(line);
338 QMap<int, QIcon> map;
340 map[0] = QIcon::fromTheme(
"stroke-join-miter").pixmap(16,16);
341 map[1] = QIcon::fromTheme(
"stroke-join-round").pixmap(16,16);
342 map[2] = QIcon::fromTheme(
"stroke-join-bevel").pixmap(16,16);
349 QMap<int, QIcon> map;
351 map[0] = QIcon::fromTheme(
"stroke-cap-butt").pixmap(16,16);
352 map[1] = QIcon::fromTheme(
"stroke-cap-round").pixmap(16,16);
353 map[2] = QIcon::fromTheme(
"stroke-cap-square").pixmap(16,16);
360 m_dashes.push_back(
"");
361 m_dashes.push_back(
"1 2");
362 m_dashes.push_back(
"4 2");
363 m_dashes.push_back(
"4 2 1 2");
364 m_dashes.push_back(
"4 2 1 2 1 2");
368 for(
size_t t = 0; t < m_dashes.size(); ++t)
370 l << m_dashes[t].c_str();
378 m_joinMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_MITRE_JOIN));
379 m_joinMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_JOIN));
380 m_joinMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_BEVEL_JOIN));
384 l << m_joinMap[0].c_str();
385 l << m_joinMap[1].c_str();
386 l << m_joinMap[2].c_str();
393 m_capMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_BUTT_CAP));
394 m_capMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_CAP));
395 m_capMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_SQUARE_CAP));
399 l << m_capMap[0].c_str();
400 l << m_capMap[1].c_str();
401 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.