29 #include "../../../se/Config.h"
30 #include "../../../se/Stroke.h"
31 #include "../../../se/SvgParameter.h"
32 #include "../../../maptools/Utils.h"
33 #include "../../../maptools/Enums.h"
36 #include <QtGui/QPainter>
37 #include <QtGui/QIcon>
38 #include "../../../../../third-party/qt/propertybrowser/qtpropertybrowser.h"
45 m_stroke(new te::se::Stroke)
90 addProperty(basicStrokeProperty, tr(
"Basic Stroke"), QColor(175, 255, 175));
104 m_stroke = stroke->
clone();
111 return m_stroke->
clone();
119 m_color = QColor(rgba.
getRgba());
121 updateUiStrokeColor();
136 for(
size_t t = 0; t < m_dashes.size(); ++t)
138 if(str == m_dashes[t])
156 std::map<int, std::string>::iterator it = m_joinMap.begin();
158 while(it != m_joinMap.end())
160 if(it->second == joinStr)
179 std::map<int, std::string>::iterator it = m_capMap.begin();
181 while(it != m_capMap.end())
183 if(it->second == capStr)
204 if(p == m_opacityProperty)
206 double opacity = value / 100.0;
208 m_color.setAlpha(opacity * 255);
209 updateUiStrokeColor();
212 m_stroke->setOpacity(QString::number(opacity,
'g', 2).toStdString());
213 emit strokeChanged();
215 else if(p == m_dashProperty)
220 std::string pattern = m_dashes[value];
221 m_stroke->setDashArray(pattern);
222 emit strokeChanged();
224 else if(p == m_joinProperty)
226 m_stroke->setLineJoin(m_joinMap[value]);
228 emit strokeChanged();
230 else if(p == m_capProperty)
232 m_stroke->setLineCap(m_capMap[value]);
234 emit strokeChanged();
240 if(p == m_widthProperty)
245 m_stroke->setWidth(str.toStdString());
246 emit strokeChanged();
252 if(p == m_colorProperty)
255 m_color.setRgb(value.red(), value.green(), value.blue(), m_color.alpha());
257 updateUiStrokeColor();
260 m_stroke->setColor(m_color.name().toStdString());
261 emit strokeChanged();
267 QMap<int, QIcon> map;
273 QLine line(0, size.height() * 0.5, size.width(), size.height() * 0.5);
279 for(
size_t t = 0; t < m_dashes.size(); ++t)
281 QPixmap pixmap(size);
282 pixmap.fill(Qt::transparent);
284 QPainter painter(&pixmap);
286 std::string pattern = m_dashes[t];
287 std::vector<double> dasharray;
290 QVector<qreal> qdasharray = QVector<qreal>::fromStdVector(dasharray);
292 pen.setDashPattern(qdasharray);
294 painter.drawLine(line);
306 QMap<int, QIcon> map;
308 map[0] = QIcon::fromTheme(
"stroke-join-miter").pixmap(16,16);
309 map[1] = QIcon::fromTheme(
"stroke-join-round").pixmap(16,16);
310 map[2] = QIcon::fromTheme(
"stroke-join-bevel").pixmap(16,16);
317 QMap<int, QIcon> map;
319 map[0] = QIcon::fromTheme(
"stroke-cap-butt").pixmap(16,16);
320 map[1] = QIcon::fromTheme(
"stroke-cap-round").pixmap(16,16);
321 map[2] = QIcon::fromTheme(
"stroke-cap-square").pixmap(16,16);
328 m_dashes.push_back(
"");
329 m_dashes.push_back(
"1 2");
330 m_dashes.push_back(
"4 2");
331 m_dashes.push_back(
"4 2 1 2");
332 m_dashes.push_back(
"4 2 1 2 1 2");
336 for(
size_t t = 0; t < m_dashes.size(); ++t)
338 l << m_dashes[t].c_str();
346 m_joinMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_MITRE_JOIN));
347 m_joinMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_JOIN));
348 m_joinMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_BEVEL_JOIN));
352 l << m_joinMap[0].c_str();
353 l << m_joinMap[1].c_str();
354 l << m_joinMap[2].c_str();
361 m_capMap.insert(std::map<int, std::string>::value_type(0,
TE_SE_BUTT_CAP));
362 m_capMap.insert(std::map<int, std::string>::value_type(1,
TE_SE_ROUND_CAP));
363 m_capMap.insert(std::map<int, std::string>::value_type(2,
TE_SE_SQUARE_CAP));
367 l << m_capMap[0].c_str();
368 l << m_capMap[1].c_str();
369 l << m_capMap[2].c_str();
TEMAPEXPORT void GetColor(const te::se::Stroke *stroke, te::color::RGBAColor &color)
Gets the RGBA color from Stroke element.
~BasicStrokePropertyItem()
Destructor.
virtual void valueChanged(QtProperty *p, int value)
QMap< int, QIcon > getCapIcons()
QtProperty * m_colorProperty
QtIntPropertyManager * m_intSliderManager
#define TE_SE_ROUND_CAP
It specifies the value "round" for stroke-linecap parameter.
#define TE_SE_ROUND_JOIN
It specifies the value "round" for stroke-linejoin parameter.
QtProperty * m_dashProperty
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
QtColorPropertyManager * m_colorManager
QtProperty * m_joinProperty
QtProperty * m_opacityProperty
#define TE_SE_BUTT_CAP
It specifies the value "butt" for stroke-linecap parameter.
QStringList getCapNames()
QtProperty * m_capProperty
A Stroke specifies the appearance of a linear geometry.
TEMAPEXPORT double GetDouble(const te::se::ParameterValue *param)
Gets the parameter value as double.
Stroke * clone() const
It creates a new copy of this object.
void setStroke(const te::se::Stroke *stroke)
Sets a stroke element to this widget.
QtDoublePropertyManager * m_doubleManager
QtEnumPropertyManager * m_enumManager
QStringList getDashIconsNames()
TEMAPEXPORT void GetDashStyle(const std::string &dasharray, std::vector< double > &style)
Converts a dasharray pattern coded by a string to a vector of double.
void updateUiStrokeColor()
Updates the widget form element used to visualize the stroke color.
#define TE_SE_SQUARE_CAP
It specifies the value "square" for stroke-linecap parameter.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
TEMAPEXPORT std::string GetString(const te::se::ParameterValue *param)
Gets the parameter value as string.
#define TE_SE_DEFAULT_STROKE_BASIC_COLOR
It specifies the default color used by stroke basic (solid colors).
#define TE_SE_BEVEL_JOIN
It specifies the value "bevel" for stroke-linejoin parameter.
#define TE_SE_MITRE_JOIN
It specifies the value "mitre" for stroke-linejoin parameter.
A widget used to define the basic fill se object.
#define TE_SE_DEFAULT_FILL_BASIC_COLOR
It specifies the default color used by basic fill (solid colors).
void updateUi()
Updates the widget form based on internal stroke element.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
A widget used to define the main property items that can be used to describe a se object...
QtProperty * m_widthProperty
QMap< int, QIcon > getDashIcons()
te::se::Stroke * getStroke() const
Gets the configured stroke element.
void addProperty(QtProperty *property, const QString &id, QColor c)
static AbstractPropertyManager & getInstance()
It returns a reference to the singleton instance.
A SvgParameter refers to an SVG/CSS graphical-formatting parameter.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
BasicStrokePropertyItem(QtTreePropertyBrowser *pb, QColor c=QColor())
Constructor.
QStringList getJoinNames()
QMap< int, QIcon > getJoinIcons()