summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-25 18:36:10 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-25 18:36:10 +0000
commit17f09296aa0beff56222e2d9c24f92a8ce94eef2 (patch)
tree9eae706e5f1145ee3184e41432f6d4315a53dce5 /src/ui
parentUpdate perspective-envelope to be affected by the clip or mask on LPE patch (diff)
parentCleaned casts from sp-shape by fixing member type. (diff)
downloadinkscape-17f09296aa0beff56222e2d9c24f92a8ce94eef2.tar.gz
inkscape-17f09296aa0beff56222e2d9c24f92a8ce94eef2.zip
Update to trunk r13638
(bzr r13341.1.286)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/clipboard.cpp132
-rw-r--r--src/ui/dialog/aboutbox.cpp16
-rw-r--r--src/ui/object-edit.cpp213
-rw-r--r--src/ui/tools-switch.cpp27
-rw-r--r--src/ui/tools/select-tool.cpp78
-rw-r--r--src/ui/tools/spray-tool.cpp32
-rw-r--r--src/ui/tools/tweak-tool.cpp86
7 files changed, 354 insertions, 230 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 40500cf15..931a295d8 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -54,6 +54,7 @@
#include <2geom/transforms.h>
#include "box3d.h"
#include "gradient-drag.h"
+#include "sp-marker.h"
#include "sp-item.h"
#include "sp-item-transform.h" // for sp_item_scale_rel, used in _pasteSize
#include "sp-path.h"
@@ -505,12 +506,15 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
- SPItem *item = SP_ITEM(i->data);
- Geom::OptRect obj_size = item->desktopVisualBounds();
- if ( !obj_size ) {
- continue;
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ if (item) {
+ Geom::OptRect obj_size = item->desktopVisualBounds();
+ if ( obj_size ) {
+ sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y));
+ }
+ } else {
+ g_assert_not_reached();
}
- sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y));
}
}
// resize the selection as a whole
@@ -640,7 +644,12 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
GSList const *items = selection->itemList();
// copy the defs used by all items
for (GSList *i = const_cast<GSList *>(items) ; i != NULL ; i = i->next) {
- _copyUsedDefs(SP_ITEM (i->data));
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ if (item) {
+ _copyUsedDefs(item);
+ } else {
+ g_assert_not_reached();
+ }
}
// copy the representation of the items
@@ -648,36 +657,38 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
sorted_items = g_slist_sort(sorted_items, (GCompareFunc) sp_object_compare_position);
for (GSList *i = sorted_items ; i ; i = i->next) {
- if (!SP_IS_ITEM(i->data)) {
- continue;
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ if (item) {
+ Inkscape::XML::Node *obj = item->getRepr();
+ Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root);
+
+ // copy complete inherited style
+ SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style");
+ sp_repr_css_set(obj_copy, css, "style");
+ sp_repr_css_attr_unref(css);
+
+ // write the complete accumulated transform passed to us
+ // (we're dealing with unattached representations, so we write to their attributes
+ // instead of using sp_item_set_transform)
+ gchar *transform_str = sp_svg_transform_write(item->i2doc_affine());
+ obj_copy->setAttribute("transform", transform_str);
+ g_free(transform_str);
}
- Inkscape::XML::Node *obj = reinterpret_cast<SPObject *>(i->data)->getRepr();
- Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root);
-
- // copy complete inherited style
- SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style");
- sp_repr_css_set(obj_copy, css, "style");
- sp_repr_css_attr_unref(css);
-
- // write the complete accumulated transform passed to us
- // (we're dealing with unattached representations, so we write to their attributes
- // instead of using sp_item_set_transform)
- gchar *transform_str = sp_svg_transform_write(SP_ITEM(i->data)->i2doc_affine());
- obj_copy->setAttribute("transform", transform_str);
- g_free(transform_str);
}
// copy style for Paste Style action
if (sorted_items) {
- if (SP_IS_ITEM(sorted_items->data)) {
- SPCSSAttr *style = take_style_from_item((SPItem *) sorted_items->data);
+ SPObject *object = static_cast<SPObject *>(sorted_items->data);
+ SPItem *item = dynamic_cast<SPItem *>(object);
+ if (item) {
+ SPCSSAttr *style = take_style_from_item(item);
sp_repr_css_set(_clipnode, style, "style");
sp_repr_css_attr_unref(style);
}
// copy path effect from the first path
- if (SP_IS_OBJECT(sorted_items->data)) {
- gchar const *effect = reinterpret_cast<SPObject *>(sorted_items->data)->getRepr()->attribute("inkscape:path-effect");
+ if (object) {
+ gchar const *effect =object->getRepr()->attribute("inkscape:path-effect");
if (effect) {
_clipnode->setAttribute("inkscape:path-effect", effect);
}
@@ -704,35 +715,38 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
if (style && (style->fill.isPaintserver())) {
SPPaintServer *server = item->style->getFillPaintServer();
- if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) {
- _copyGradient(SP_GRADIENT(server));
+ if ( dynamic_cast<SPLinearGradient *>(server) || dynamic_cast<SPRadialGradient *>(server) ) {
+ _copyGradient(dynamic_cast<SPGradient *>(server));
}
- if ( SP_IS_PATTERN(server) ) {
- _copyPattern(SP_PATTERN(server));
+ SPPattern *pattern = dynamic_cast<SPPattern *>(server);
+ if ( pattern ) {
+ _copyPattern(pattern);
}
}
if (style && (style->stroke.isPaintserver())) {
SPPaintServer *server = item->style->getStrokePaintServer();
- if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) {
- _copyGradient(SP_GRADIENT(server));
+ if ( dynamic_cast<SPLinearGradient *>(server) || dynamic_cast<SPRadialGradient *>(server) ) {
+ _copyGradient(dynamic_cast<SPGradient *>(server));
}
- if ( SP_IS_PATTERN(server) ) {
- _copyPattern(SP_PATTERN(server));
+ SPPattern *pattern = dynamic_cast<SPPattern *>(server);
+ if ( pattern ) {
+ _copyPattern(pattern);
}
}
// For shapes, copy all of the shape's markers
- if (SP_IS_SHAPE(item)) {
- SPShape *shape = SP_SHAPE (item);
+ SPShape *shape = dynamic_cast<SPShape *>(item);
+ if (shape) {
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
if (shape->_marker[i]) {
_copyNode(shape->_marker[i]->getRepr(), _doc, _defs);
}
}
}
+
// For lpe items, copy lpe stack if applicable
- if (SP_IS_LPE_ITEM(item)) {
- SPLPEItem *lpeitem = SP_LPE_ITEM (item);
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (lpeitem) {
if (lpeitem->hasPathEffect()) {
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
{
@@ -743,14 +757,24 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
}
+
// For 3D boxes, copy perspectives
- if (SP_IS_BOX3D(item)) {
- _copyNode(box3d_get_perspective(SP_BOX3D(item))->getRepr(), _doc, _defs);
+ {
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ if (box) {
+ _copyNode(box3d_get_perspective(box)->getRepr(), _doc, _defs);
+ }
}
+
// Copy text paths
- if (SP_IS_TEXT_TEXTPATH(item)) {
- _copyTextPath(SP_TEXTPATH(item->firstChild()));
+ {
+ SPText *text = dynamic_cast<SPText *>(item);
+ SPTextPath *textpath = (text) ? dynamic_cast<SPTextPath *>(text->firstChild()) : NULL;
+ if (textpath) {
+ _copyTextPath(textpath);
+ }
}
+
// Copy clipping objects
if (item->clip_ref){
if (item->clip_ref->getObject()) {
@@ -764,8 +788,9 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
_copyNode(mask->getRepr(), _doc, _defs);
// recurse into the mask for its gradients etc.
for (SPObject *o = mask->children ; o != NULL ; o = o->next) {
- if (SP_IS_ITEM(o)) {
- _copyUsedDefs(SP_ITEM(o));
+ SPItem *childItem = dynamic_cast<SPItem *>(o);
+ if (childItem) {
+ _copyUsedDefs(childItem);
}
}
}
@@ -774,15 +799,16 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
// Copy filters
if (style->getFilter()) {
SPObject *filter = style->getFilter();
- if (SP_IS_FILTER(filter)) {
+ if (dynamic_cast<SPFilter *>(filter)) {
_copyNode(filter->getRepr(), _doc, _defs);
}
}
// recurse
for (SPObject *o = item->children ; o != NULL ; o = o->next) {
- if (SP_IS_ITEM(o)) {
- _copyUsedDefs(SP_ITEM(o));
+ SPItem *childItem = dynamic_cast<SPItem *>(o);
+ if (childItem) {
+ _copyUsedDefs(childItem);
}
}
}
@@ -817,10 +843,10 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
// items in the pattern may also use gradients and other patterns, so recurse
for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) {
- if (!SP_IS_ITEM (child)) {
- continue;
+ SPItem *childItem = dynamic_cast<SPItem *>(child);
+ if (childItem) {
+ _copyUsedDefs(childItem);
}
- _copyUsedDefs(SP_ITEM(child));
}
if (pattern->ref){
pattern = pattern->ref->getObject();
@@ -939,13 +965,13 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta
if ( item == NULL ) {
return;
}
- if ( SP_IS_RECT(item) ) {
+ if ( dynamic_cast<SPRect *>(item) ) {
return;
}
- if (SP_IS_LPE_ITEM(item))
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (lpeitem)
{
- SPLPEItem *lpeitem = SP_LPE_ITEM(item);
// for each effect in the stack, check if we need to fork it before adding it to the item
lpeitem->forkPathEffectsIfNecessary(1);
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 7212fa372..50b35ca2f 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -452,13 +452,13 @@ void AboutBox::initStrings() {
*/
gchar const *allTranslators =
"3ARRANO.com <3arrano@3arrano.com>, 2005.\n"
-"Adib Taraben <theadib@gmail.com>, 2004.\n"
+"Adib Taraben <theadib@gmail.com>, 2004-2014.\n"
"Alan Monfort <alan.monfort@free.fr>, 2009-2010.\n"
"Alastair McKinstry <mckinstry@computer.org>, 2000.\n"
"Aleksandar Urošević <urke@users.sourceforge.net>, 2004-2006.\n"
"Alessio Frusciante <algol@firenze.linux.it>, 2002, 2003.\n"
"Alexander Shopov <ash@contact.bg>, 2006.\n"
-"Alexandre Prokoudine <alexandre.prokoudine@gmail.com>, 2005, 2010-2013.\n"
+"Alexandre Prokoudine <alexandre.prokoudine@gmail.com>, 2005, 2010-2014.\n"
"Alexey Remizov <alexey@remizov.pp.ru>, 2004.\n"
"Ali Ghanavatian <ghanvatian.ali@gmail.com>, 2010.\n"
"Álvaro Lopes <alvieboy@alvie.com>, 2001, 2002.\n"
@@ -503,7 +503,7 @@ void AboutBox::initStrings() {
"Hleb Valoshka <375gnu@gmail.com>, 2008-2009.\n"
"Hizkuntza Politikarako Sailburuordetza <hizkpol@ej-gv.es>, 2005.\n"
"Ilia Penev <lichopicho@gmail.com>, 2006.\n"
-"Ivan Masár <helix84@centrum.sk>, 2006-2010. \n"
+"Ivan Masár <helix84@centrum.sk>, 2006-2014. \n"
"Ivan Řihošek <irihosek@seznam.cz>, 2014.\n"
"Iñaki Larrañaga <dooteo@euskalgnu.org>, 2006.\n"
"Jānis Eisaks <jancs@dv.lv>, 2012-2014.\n"
@@ -537,7 +537,7 @@ void AboutBox::initStrings() {
"Mahesh subedi <submanesh@hotmail.com>, 2006.\n"
"Martin Srebotnjak, <miles@filmsi.net>, 2005, 2010.\n"
"Masatake YAMATO <jet@gyve.org>, 2002.\n"
-"Masato Hashimoto <cabezon.hashimoto@gmail.com>, 2009-2012.\n"
+"Masato Hashimoto <cabezon.hashimoto@gmail.com>, 2009-2014.\n"
"Matiphas <matiphas _a_ free _point_ fr>, 2004-2006.\n"
"Mattias Hultgren <mattias_hultgren@tele2.se>, 2005, 2006.\n"
"Maxim Dziumanenko <mvd@mylinux.com.ua>, 2004.\n"
@@ -553,7 +553,7 @@ void AboutBox::initStrings() {
"Przemysław Loesch <p_loesch@poczta.onet.pl>, 2005.\n"
"Quico Llach <quico@softcatala.org>, 2000. Traducció sodipodi.\n"
"Raymond Ostertag <raymond@linuxgraphic.org>, 2002, 2003.\n"
-"Riku Leino <tsoots@gmail.com>, 2006.\n"
+"Riku Leino <tsoots@gmail.com>, 2006-2011.\n"
"Rune Rønde Laursen <runerl@skjoldhoej.dk>, 2006.\n"
"Ruud Steltenpool <svg@steltenpower.com>, 2006.\n"
"Serdar Soytetir <sendirom@gmail.com>, 2005.\n"
@@ -569,9 +569,11 @@ void AboutBox::initStrings() {
"Thiago Pimentel <thiago.merces@gmail.com>, 2006.\n"
"Toshifumi Sato <sato@centrosystem.com>, 2005.\n"
"Jon South <striker@lunar-linux.org>, 2006. \n"
-"Uwe Schöler <oss@oss-marketplace.com>, 2006-2013.\n"
+"Uwe Schöler <oss@oss-marketplace.com>, 2006-2014.\n"
"Valek Filippov <frob@df.ru>, 2000, 2003.\n"
"Victor Dachev <vdachev@gmail.com>, 2006.\n"
+"Victor Westmann <victor.westmann@gmail.com>, 2011, 2014.\n"
+"Ville Pätsi, 2013.\n"
"Vincent van Adrighem <V.vanAdrighem@dirck.mine.nu>, 2003.\n"
"Vital Khilko <dojlid@mova.org>, 2003.\n"
"Vitaly Lipatov <lav@altlinux.ru>, 2002, 2004.\n"
@@ -584,7 +586,7 @@ void AboutBox::initStrings() {
"Yaron Shahrabani <sh.yaron@gmail.com>, 2009.\n"
"Yukihiro Nakai <nakai@gnome.gr.jp>, 2000, 2003.\n"
"Yuri Beznos <zhiz0id@gmail.com>, 2006.\n"
-"Yuri Chornoivan <yurchor@ukr.net>, 2007-2013.\n"
+"Yuri Chornoivan <yurchor@ukr.net>, 2007-2014.\n"
"Yuri Syrota <rasta@renome.rovno.ua>, 2000.\n"
"Yves Guillou <yvesguillou@users.sourceforge.net>, 2004.\n"
"Zdenko Podobný <zdpo@mailbox.sk>, 2003, 2004."
diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp
index cc96727f8..ca550502d 100644
--- a/src/ui/object-edit.cpp
+++ b/src/ui/object-edit.cpp
@@ -6,6 +6,7 @@
* Mitsuru Oka
* Maximilian Albert <maximilian.albert@gmail.com>
* Abhishek Sharma
+ * Jon A. Cruz <jon@joncruz.org>
*
* Licensed under GNU GPL
*/
@@ -42,11 +43,11 @@
namespace {
-static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop)
+static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop)
{
KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL);
- Inkscape::LivePathEffect::Effect *effect = SP_LPE_ITEM(item)->getCurrentLPE();
+ Inkscape::LivePathEffect::Effect *effect = item->getCurrentLPE();
effect->addHandles(knot_holder, desktop, item);
return knot_holder;
@@ -61,29 +62,33 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop)
{
KnotHolder *knotholder = NULL;
- if (SP_IS_LPE_ITEM(item) &&
- SP_LPE_ITEM(item)->getCurrentLPE() &&
- SP_LPE_ITEM(item)->getCurrentLPE()->isVisible() &&
- SP_LPE_ITEM(item)->getCurrentLPE()->providesKnotholder()) {
- knotholder = sp_lpe_knot_holder(item, desktop);
- } else if (SP_IS_RECT(item)) {
+ SPLPEItem *lpe = dynamic_cast<SPLPEItem *>(item);
+ if (lpe &&
+ lpe->getCurrentLPE() &&
+ lpe->getCurrentLPE()->isVisible() &&
+ lpe->getCurrentLPE()->providesKnotholder()) {
+ knotholder = sp_lpe_knot_holder(lpe, desktop);
+ } else if (dynamic_cast<SPRect *>(item)) {
knotholder = new RectKnotHolder(desktop, item, NULL);
- } else if (SP_IS_BOX3D(item)) {
+ } else if (dynamic_cast<SPBox3D *>(item)) {
knotholder = new Box3DKnotHolder(desktop, item, NULL);
- } else if (SP_IS_GENERICELLIPSE(item)) {
+ } else if (dynamic_cast<SPGenericEllipse *>(item)) {
knotholder = new ArcKnotHolder(desktop, item, NULL);
- } else if (SP_IS_STAR(item)) {
+ } else if (dynamic_cast<SPStar *>(item)) {
knotholder = new StarKnotHolder(desktop, item, NULL);
- } else if (SP_IS_SPIRAL(item)) {
+ } else if (dynamic_cast<SPSpiral *>(item)) {
knotholder = new SpiralKnotHolder(desktop, item, NULL);
- } else if (SP_IS_OFFSET(item)) {
+ } else if (dynamic_cast<SPOffset *>(item)) {
knotholder = new OffsetKnotHolder(desktop, item, NULL);
- } else if (SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) {
- knotholder = new FlowtextKnotHolder(desktop, SP_FLOWTEXT(item)->get_frame(NULL), NULL);
- } else if ((item->style->fill.isPaintserver() && SP_IS_PATTERN(item->style->getFillPaintServer())) ||
- (item->style->stroke.isPaintserver() && SP_IS_PATTERN(item->style->getStrokePaintServer()))) {
- knotholder = new KnotHolder(desktop, item, NULL);
- knotholder->add_pattern_knotholder();
+ } else {
+ SPFlowtext *flowtext = dynamic_cast<SPFlowtext *>(item);
+ if (flowtext && flowtext->has_internal_frame()) {
+ knotholder = new FlowtextKnotHolder(desktop, flowtext->get_frame(NULL), NULL);
+ } else if ((item->style->fill.isPaintserver() && dynamic_cast<SPPattern *>(item->style->getFillPaintServer())) ||
+ (item->style->stroke.isPaintserver() && dynamic_cast<SPPattern *>(item->style->getStrokePaintServer()))) {
+ knotholder = new KnotHolder(desktop, item, NULL);
+ knotholder->add_pattern_knotholder();
+ }
}
return knotholder;
@@ -130,7 +135,8 @@ public:
Geom::Point
RectKnotHolderEntityRX::knot_get() const
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
return Geom::Point(rect->x.computed + rect->width.computed - rect->rx.computed, rect->y.computed);
}
@@ -138,7 +144,8 @@ RectKnotHolderEntityRX::knot_get() const
void
RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
@@ -157,13 +164,14 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig
update_knot();
- (static_cast<SPObject*>(rect))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void
RectKnotHolderEntityRX::knot_click(unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
if (state & GDK_SHIFT_MASK) {
/* remove rounding from rectangle */
@@ -179,7 +187,8 @@ RectKnotHolderEntityRX::knot_click(unsigned int state)
Geom::Point
RectKnotHolderEntityRY::knot_get() const
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->ry.computed);
}
@@ -187,7 +196,8 @@ RectKnotHolderEntityRY::knot_get() const
void
RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
@@ -215,13 +225,14 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig
update_knot();
- (static_cast<SPObject *>(rect))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void
RectKnotHolderEntityRY::knot_click(unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
if (state & GDK_SHIFT_MASK) {
/* remove rounding */
@@ -251,7 +262,8 @@ static void sp_rect_clamp_radii(SPRect *rect)
Geom::Point
RectKnotHolderEntityWH::knot_get() const
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
@@ -259,7 +271,8 @@ RectKnotHolderEntityWH::knot_get() const
void
RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
Geom::Point s = p;
@@ -325,7 +338,7 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
sp_rect_clamp_radii(rect);
- (static_cast<SPObject *>(rect))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void
@@ -338,7 +351,8 @@ RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin
Geom::Point
RectKnotHolderEntityXY::knot_get() const
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
return Geom::Point(rect->x.computed, rect->y.computed);
}
@@ -346,7 +360,8 @@ RectKnotHolderEntityXY::knot_get() const
void
RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
- SPRect *rect = SP_RECT(item);
+ SPRect *rect = dynamic_cast<SPRect *>(item);
+ g_assert(rect != NULL);
// opposite corner (unmoved)
gdouble opposite_x = (rect->x.computed + rect->width.computed);
@@ -426,7 +441,7 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
update_knot();
- (static_cast<SPObject *>(rect))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
@@ -479,7 +494,12 @@ public:
Geom::Point
Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id) const
{
- return box3d_get_corner_screen(SP_BOX3D(item), knot_id);
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ if (box) {
+ return box3d_get_corner_screen(box, knot_id);
+ } else {
+ return Geom::Point(); // TODO investigate proper fallback
+ }
}
void
@@ -488,7 +508,8 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom
Geom::Point const s = snap_knot_position(new_pos, state);
g_assert(item != NULL);
- SPBox3D *box = SP_BOX3D(item);
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ g_assert(box != NULL);
Geom::Affine const i2dt (item->i2dt_affine ());
Box3D::Axis movement;
@@ -608,7 +629,12 @@ Box3DKnotHolderEntity7::knot_get() const
Geom::Point
Box3DKnotHolderEntityCenter::knot_get() const
{
- return box3d_get_center_screen(SP_BOX3D(item));
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ if (box) {
+ return box3d_get_center_screen(box);
+ } else {
+ return Geom::Point(); // TODO investigate proper fallback
+ }
}
void
@@ -664,10 +690,11 @@ Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point co
{
Geom::Point const s = snap_knot_position(new_pos, state);
- SPBox3D *box = SP_BOX3D(item);
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ g_assert(box != NULL);
Geom::Affine const i2dt (item->i2dt_affine ());
- box3d_set_center (SP_BOX3D(item), s * i2dt, origin * i2dt, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z,
+ box3d_set_center(box, s * i2dt, origin * i2dt, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z,
state & GDK_CONTROL_MASK);
box3d_set_z_orders(box);
@@ -789,7 +816,8 @@ ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*or
{
int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12);
- SPGenericEllipse *arc = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(arc != NULL);
arc->setClosed(sp_genericellipse_side(arc, p) == -1);
@@ -809,7 +837,8 @@ ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*or
Geom::Point
ArcKnotHolderEntityStart::knot_get() const
{
- SPGenericEllipse const *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse const *>(item);
+ g_assert(ge != NULL);
return ge->getPointAtAngle(ge->start);
}
@@ -817,11 +846,12 @@ ArcKnotHolderEntityStart::knot_get() const
void
ArcKnotHolderEntityStart::knot_click(unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
if (state & GDK_SHIFT_MASK) {
ge->end = ge->start = 0;
- (static_cast<SPObject *>(ge))->updateRepr();
+ ge->updateRepr();
}
}
@@ -830,7 +860,8 @@ ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*orig
{
int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12);
- SPGenericEllipse *arc = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(arc != NULL);
arc->setClosed(sp_genericellipse_side(arc, p) == -1);
@@ -850,7 +881,8 @@ ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*orig
Geom::Point
ArcKnotHolderEntityEnd::knot_get() const
{
- SPGenericEllipse const *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse const *>(item);
+ g_assert(ge != NULL);
return ge->getPointAtAngle(ge->end);
}
@@ -859,11 +891,12 @@ ArcKnotHolderEntityEnd::knot_get() const
void
ArcKnotHolderEntityEnd::knot_click(unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
if (state & GDK_SHIFT_MASK) {
ge->end = ge->start = 0;
- (static_cast<SPObject *>(ge))->updateRepr();
+ ge->updateRepr();
}
}
@@ -871,7 +904,8 @@ ArcKnotHolderEntityEnd::knot_click(unsigned int state)
void
ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
Geom::Point const s = snap_knot_position(p, state);
@@ -881,13 +915,14 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi
ge->ry.computed = ge->rx.computed;
}
- (static_cast<SPObject *>(item))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
Geom::Point
ArcKnotHolderEntityRX::knot_get() const
{
- SPGenericEllipse const *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse const *>(item);
+ g_assert(ge != NULL);
return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(ge->rx.computed, 0));
}
@@ -895,18 +930,20 @@ ArcKnotHolderEntityRX::knot_get() const
void
ArcKnotHolderEntityRX::knot_click(unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
ge->ry.computed = ge->rx.computed;
- (static_cast<SPObject *>(ge))->updateRepr();
+ ge->updateRepr();
}
}
void
ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
Geom::Point const s = snap_knot_position(p, state);
@@ -916,13 +953,14 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi
ge->rx.computed = ge->ry.computed;
}
- (static_cast<SPObject *>(item))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
Geom::Point
ArcKnotHolderEntityRY::knot_get() const
{
- SPGenericEllipse const *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(0, ge->ry.computed));
}
@@ -930,11 +968,12 @@ ArcKnotHolderEntityRY::knot_get() const
void
ArcKnotHolderEntityRY::knot_click(unsigned int state)
{
- SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
ge->rx.computed = ge->ry.computed;
- (static_cast<SPObject *>(ge))->updateRepr();
+ ge->updateRepr();
}
}
@@ -991,7 +1030,8 @@ public:
void
StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPStar *star = SP_STAR(item);
+ SPStar *star = dynamic_cast<SPStar *>(item);
+ g_assert(star != NULL);
Geom::Point const s = snap_knot_position(p, state);
@@ -1011,13 +1051,14 @@ StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origi
star->arg[0] = arg1;
star->arg[1] += darg1;
}
- (static_cast<SPObject *>(star))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void
StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
- SPStar *star = SP_STAR(item);
+ SPStar *star = dynamic_cast<SPStar *>(item);
+ g_assert(star != NULL);
Geom::Point const s = snap_knot_position(p, state);
@@ -1039,7 +1080,7 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi
star->r[1] = L2(d);
star->arg[1] = atan2(d);
}
- (static_cast<SPObject *>(star))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
@@ -1048,7 +1089,8 @@ StarKnotHolderEntity1::knot_get() const
{
g_assert(item != NULL);
- SPStar const *star = SP_STAR(item);
+ SPStar const *star = dynamic_cast<SPStar const *>(item);
+ g_assert(star != NULL);
return sp_star_get_xy(star, SP_STAR_POINT_KNOT1, 0);
@@ -1059,7 +1101,8 @@ StarKnotHolderEntity2::knot_get() const
{
g_assert(item != NULL);
- SPStar const *star = SP_STAR(item);
+ SPStar const *star = dynamic_cast<SPStar const *>(item);
+ g_assert(star != NULL);
return sp_star_get_xy(star, SP_STAR_POINT_KNOT2, 0);
}
@@ -1067,17 +1110,18 @@ StarKnotHolderEntity2::knot_get() const
static void
sp_star_knot_click(SPItem *item, unsigned int state)
{
- SPStar *star = SP_STAR(item);
+ SPStar *star = dynamic_cast<SPStar *>(item);
+ g_assert(star != NULL);
if (state & GDK_MOD1_MASK) {
star->randomized = 0;
- (static_cast<SPObject *>(star))->updateRepr();
+ star->updateRepr();
} else if (state & GDK_SHIFT_MASK) {
star->rounded = 0;
- (static_cast<SPObject *>(star))->updateRepr();
+ star->updateRepr();
} else if (state & GDK_CONTROL_MASK) {
star->arg[1] = star->arg[0] + M_PI / star->sides;
- (static_cast<SPObject *>(star))->updateRepr();
+ star->updateRepr();
}
}
@@ -1096,7 +1140,8 @@ StarKnotHolderEntity2::knot_click(unsigned int state)
StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
KnotHolder(desktop, item, relhandler)
{
- SPStar *star = SP_STAR(item);
+ SPStar *star = dynamic_cast<SPStar *>(item);
+ g_assert(item != NULL);
StarKnotHolderEntity1 *entity1 = new StarKnotHolderEntity1();
entity1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER,
@@ -1144,7 +1189,8 @@ SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &o
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- SPSpiral *spiral = SP_SPIRAL(item);
+ SPSpiral *spiral = dynamic_cast<SPSpiral *>(item);
+ g_assert(spiral != NULL);
gdouble dx = p[Geom::X] - spiral->cx;
gdouble dy = p[Geom::Y] - spiral->cy;
@@ -1179,7 +1225,7 @@ SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &o
spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999);
}
- (static_cast<SPObject *>(spiral))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
/*
@@ -1193,7 +1239,8 @@ SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- SPSpiral *spiral = SP_SPIRAL(item);
+ SPSpiral *spiral = dynamic_cast<SPSpiral *>(item);
+ g_assert(spiral != NULL);
gdouble dx = p[Geom::X] - spiral->cx;
gdouble dy = p[Geom::Y] - spiral->cy;
@@ -1258,13 +1305,14 @@ SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/
spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999);
}
- (static_cast<SPObject *>(spiral))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
Geom::Point
SpiralKnotHolderEntityInner::knot_get() const
{
- SPSpiral const *spiral = SP_SPIRAL(item);
+ SPSpiral const *spiral = dynamic_cast<SPSpiral const *>(item);
+ g_assert(spiral != NULL);
return spiral->getXY(spiral->t0);
}
@@ -1272,7 +1320,8 @@ SpiralKnotHolderEntityInner::knot_get() const
Geom::Point
SpiralKnotHolderEntityOuter::knot_get() const
{
- SPSpiral const *spiral = SP_SPIRAL(item);
+ SPSpiral const *spiral = dynamic_cast<SPSpiral const *>(item);
+ g_assert(spiral != NULL);
return spiral->getXY(1.0);
}
@@ -1280,14 +1329,15 @@ SpiralKnotHolderEntityOuter::knot_get() const
void
SpiralKnotHolderEntityInner::knot_click(unsigned int state)
{
- SPSpiral *spiral = SP_SPIRAL(item);
+ SPSpiral *spiral = dynamic_cast<SPSpiral *>(item);
+ g_assert(spiral != NULL);
if (state & GDK_MOD1_MASK) {
spiral->exp = 1;
- (static_cast<SPObject *>(spiral))->updateRepr();
+ spiral->updateRepr();
} else if (state & GDK_SHIFT_MASK) {
spiral->t0 = 0;
- (static_cast<SPObject *>(spiral))->updateRepr();
+ spiral->updateRepr();
}
}
@@ -1322,20 +1372,22 @@ public:
void
OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int /*state*/)
{
- SPOffset *offset = SP_OFFSET(item);
+ SPOffset *offset = dynamic_cast<SPOffset *>(item);
+ g_assert(offset != NULL);
offset->rad = sp_offset_distance_to_original(offset, p);
offset->knot = p;
offset->knotSet = true;
- (static_cast<SPObject *>(offset))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ offset->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
Geom::Point
OffsetKnotHolderEntity::knot_get() const
{
- SPOffset const *offset = SP_OFFSET(item);
+ SPOffset const *offset = dynamic_cast<SPOffset const *>(item);
+ g_assert(offset != NULL);
Geom::Point np;
sp_offset_top_point(offset,&np);
@@ -1365,7 +1417,8 @@ public:
Geom::Point
FlowtextKnotHolderEntity::knot_get() const
{
- SPRect const *rect = SP_RECT(item);
+ SPRect const *rect = dynamic_cast<SPRect const *>(item);
+ g_assert(rect != NULL);
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
diff --git a/src/ui/tools-switch.cpp b/src/ui/tools-switch.cpp
index 048252788..47b9d2832 100644
--- a/src/ui/tools-switch.cpp
+++ b/src/ui/tools-switch.cpp
@@ -4,6 +4,7 @@
* Authors:
* bulia byak <buliabyak@users.sf.net>
* Josh Andler <scislac@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2003-2007 authors
*
@@ -59,6 +60,8 @@
#include "message-context.h"
+using Inkscape::UI::Tools::ToolBase;
+
static char const *const tool_names[] = {
NULL,
"/tools/select",
@@ -130,9 +133,11 @@ int
tools_isactive(SPDesktop *dt, unsigned num)
{
g_assert( num < G_N_ELEMENTS(tool_names) );
- if (SP_IS_EVENT_CONTEXT(dt->event_context))
+ if (dynamic_cast<ToolBase *>(dt->event_context)) {
return dt->event_context->pref_observer->observed_path == tool_names[num];
- else return FALSE;
+ } else {
+ return FALSE;
+ }
}
int
@@ -159,27 +164,27 @@ tools_switch(SPDesktop *dt, int num)
void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p)
{
- if (SP_IS_RECT(item)) {
+ if (dynamic_cast<SPRect *>(item)) {
tools_switch(dt, TOOLS_SHAPES_RECT);
- } else if (SP_IS_BOX3D(item)) {
+ } else if (dynamic_cast<SPBox3D *>(item)) {
tools_switch(dt, TOOLS_SHAPES_3DBOX);
- } else if (SP_IS_GENERICELLIPSE(item)) {
+ } else if (dynamic_cast<SPGenericEllipse *>(item)) {
tools_switch(dt, TOOLS_SHAPES_ARC);
- } else if (SP_IS_STAR(item)) {
+ } else if (dynamic_cast<SPStar *>(item)) {
tools_switch(dt, TOOLS_SHAPES_STAR);
- } else if (SP_IS_SPIRAL(item)) {
+ } else if (dynamic_cast<SPSpiral *>(item)) {
tools_switch(dt, TOOLS_SHAPES_SPIRAL);
- } else if (SP_IS_PATH(item)) {
+ } else if (dynamic_cast<SPPath *>(item)) {
if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
tools_switch(dt, TOOLS_CONNECTOR);
}
else {
tools_switch(dt, TOOLS_NODES);
}
- } else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ } else if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) {
tools_switch(dt, TOOLS_TEXT);
- sp_text_context_place_cursor_at (SP_TEXT_CONTEXT(dt->event_context), SP_OBJECT(item), p);
- } else if (SP_IS_OFFSET(item)) {
+ sp_text_context_place_cursor_at (SP_TEXT_CONTEXT(dt->event_context), item, p);
+ } else if (dynamic_cast<SPOffset *>(item)) {
tools_switch(dt, TOOLS_NODES);
}
}
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 394b0b369..21459e5d0 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -264,15 +264,16 @@ sp_select_context_up_one_layer(SPDesktop *desktop)
SPObject *const current_layer = desktop->currentLayer();
if (current_layer) {
SPObject *const parent = current_layer->parent;
+ SPGroup *current_group = dynamic_cast<SPGroup *>(current_layer);
if ( parent
&& ( parent->parent
- || !( SP_IS_GROUP(current_layer)
- && ( SPGroup::LAYER
- == SP_GROUP(current_layer)->layerMode() ) ) ) )
+ || !( current_group
+ && ( SPGroup::LAYER == current_group->layerMode() ) ) ) )
{
desktop->setCurrentLayer(parent);
- if (SP_IS_GROUP(current_layer) && SPGroup::LAYER != SP_GROUP(current_layer)->layerMode())
+ if (current_group && (SPGroup::LAYER != current_group->layerMode())) {
sp_desktop_selection(desktop)->set(current_layer);
+ }
}
}
}
@@ -403,7 +404,8 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele
}
Inkscape::DrawingItem *arenaitem;
- SPItem *item = SP_ITEM(this->cycling_cur_item->data);
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(cycling_cur_item->data));
+ g_assert(item != NULL);
// Deactivate current item
if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) {
@@ -427,7 +429,8 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele
if (next) {
this->cycling_cur_item = next;
- item = SP_ITEM(this->cycling_cur_item->data);
+ item = dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data));
+ g_assert(item != NULL);
}
arenaitem = item->get_arenaitem(desktop->dkey);
@@ -442,8 +445,13 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele
void SelectTool::sp_select_context_reset_opacities() {
for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) {
- Inkscape::DrawingItem *arenaitem = SP_ITEM(l->data)->get_arenaitem(this->desktop->dkey);
- arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value));
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data));
+ if (item) {
+ Inkscape::DrawingItem *arenaitem = item->get_arenaitem(desktop->dkey);
+ arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(item->style->opacity.value));
+ } else {
+ g_assert_not_reached();
+ }
}
g_list_free(this->cycling_items);
@@ -475,8 +483,8 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (!selection->isEmpty()) {
SPItem *clicked_item = static_cast<SPItem *>(selection->itemList()->data);
- if (SP_IS_GROUP(clicked_item) && !SP_IS_BOX3D(clicked_item)) { // enter group if it's not a 3D box
- desktop->setCurrentLayer(reinterpret_cast<SPObject *>(clicked_item));
+ if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
+ desktop->setCurrentLayer(clicked_item);
sp_desktop_selection(desktop)->clear();
this->dragging = false;
sp_event_context_discard_delayed_snap_event(this);
@@ -591,8 +599,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
item_in_group = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE);
group_at_point = desktop->getGroupAtPoint(Geom::Point(event->button.x, event->button.y));
- if (SP_IS_LAYER(selection->single())) {
- group_at_point = SP_GROUP(selection->single());
+ {
+ SPGroup *selGroup = dynamic_cast<SPGroup *>(selection->single());
+ if (selGroup && (selGroup->layerMode() == SPGroup::LAYER)) {
+ group_at_point = selGroup;
+ }
}
// group-at-point is meant to be topmost item if it's a group,
@@ -673,10 +684,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
selection->toggle(this->item);
} else {
SPObject* single = selection->single();
+ SPGroup *singleGroup = dynamic_cast<SPGroup *>(single);
// without shift, increase state (i.e. toggle scale/rotation handles)
if (selection->includes(this->item)) {
_seltrans->increaseState();
- } else if (SP_IS_LAYER(single) && single->isAncestorOf(this->item)) {
+ } else if (singleGroup && (singleGroup->layerMode() == SPGroup::LAYER) && single->isAncestorOf(this->item)) {
_seltrans->increaseState();
} else {
_seltrans->resetState();
@@ -818,7 +830,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
SPItem *item = desktop->getItemAtPoint(p, true, NULL);
// Save pointer to current cycle-item so that we can find it again later, in the freshly built list
- SPItem *tmp_cur_item = this->cycling_cur_item ? SP_ITEM(this->cycling_cur_item->data) : NULL;
+ SPItem *tmp_cur_item = this->cycling_cur_item ? dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data)) : NULL;
g_list_free(this->cycling_items);
this->cycling_items = NULL;
this->cycling_cur_item = NULL;
@@ -851,11 +863,14 @@ bool SelectTool::root_handler(GdkEvent* event) {
Inkscape::DrawingItem *arenaitem;
for(GList *l = this->cycling_items_cmp; l != NULL; l = l->next) {
- arenaitem = SP_ITEM(l->data)->get_arenaitem(desktop->dkey);
- arenaitem->setOpacity(1.0);
- //if (!shift_pressed && !g_list_find(this->cycling_items_selected_before, SP_ITEM(l->data)) && selection->includes(SP_ITEM(l->data)))
- if (!g_list_find(this->cycling_items_selected_before, SP_ITEM(l->data)) && selection->includes(SP_ITEM(l->data))) {
- selection->remove(SP_ITEM(l->data));
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data));
+ if (item) {
+ arenaitem = item->get_arenaitem(desktop->dkey);
+ arenaitem->setOpacity(1.0);
+ //if (!shift_pressed && !g_list_find(this->cycling_items_selected_before, item) && selection->includes(item))
+ if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) {
+ selection->remove(item);
+ }
}
}
@@ -869,16 +884,19 @@ bool SelectTool::root_handler(GdkEvent* event) {
// ... and rebuild them with the new items.
this->cycling_items_cmp = g_list_copy(this->cycling_items);
- SPItem *item;
for(GList *l = this->cycling_items; l != NULL; l = l->next) {
- item = SP_ITEM(l->data);
- arenaitem = item->get_arenaitem(desktop->dkey);
- arenaitem->setOpacity(0.3);
-
- if (selection->includes(item)) {
- // already selected items are stored separately, too
- this->cycling_items_selected_before = g_list_append(this->cycling_items_selected_before, item);
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data));
+ if (item) {
+ arenaitem = item->get_arenaitem(desktop->dkey);
+ arenaitem->setOpacity(0.3);
+
+ if (selection->includes(item)) {
+ // already selected items are stored separately, too
+ this->cycling_items_selected_before = g_list_append(this->cycling_items_selected_before, item);
+ }
+ } else {
+ g_assert_not_reached();
}
}
@@ -1134,9 +1152,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__CTRL_ONLY(event)) {
if (selection->singleItem()) {
SPItem *clicked_item = selection->singleItem();
-
- if ( SP_IS_GROUP(clicked_item) || SP_IS_BOX3D(clicked_item)) { // enter group or a 3D box
- desktop->setCurrentLayer(reinterpret_cast<SPObject *>(clicked_item));
+ SPGroup *clickedGroup = dynamic_cast<SPGroup *>(clicked_item);
+ if ( (clickedGroup && (clickedGroup->layerMode() == SPGroup::LAYER)) || dynamic_cast<SPBox3D *>(clicked_item)) { // enter group or a 3D box
+ desktop->setCurrentLayer(clicked_item);
sp_desktop_selection(desktop)->clear();
} else {
this->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selected object is not a group. Cannot enter."));
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 933da6fb1..cdc608558 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -384,11 +384,14 @@ static bool sp_spray_recursive(SPDesktop *desktop,
gint _distrib)
{
bool did = false;
-
- if (SP_IS_BOX3D(item) ) {
- // convert 3D boxes to ordinary groups before spraying their shapes
- item = box3d_convert_to_group(SP_BOX3D(item));
- selection->add(item);
+
+ {
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ if (box) {
+ // convert 3D boxes to ordinary groups before spraying their shapes
+ item = box3d_convert_to_group(box);
+ selection->add(item);
+ }
}
double _fid = g_random_double_range(0, 1);
@@ -413,7 +416,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
parent->appendChild(copy);
SPObject *new_obj = doc->getObjectByRepr(copy);
- item_copied = SP_ITEM(new_obj); // Convertion object->item
+ item_copied = dynamic_cast<SPItem *>(new_obj); // Convertion object->item
Geom::Point center=item->getCenter();
sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale));
sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale));
@@ -437,7 +440,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
items != NULL;
items = items->next) {
- SPItem *item1 = SP_ITEM(items->data);
+ SPItem *item1 = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
if (i == 1) {
parent_item = item1;
}
@@ -458,7 +461,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
parent->appendChild(copy);
SPObject *new_obj = doc->getObjectByRepr(copy);
- item_copied = SP_ITEM(new_obj);
+ item_copied = dynamic_cast<SPItem *>(new_obj);
// Move around the cursor
Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
@@ -503,7 +506,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
SPObject *clone_object = doc->getObjectByRepr(clone);
// Conversion object->item
- item_copied = SP_ITEM(clone_object);
+ item_copied = dynamic_cast<SPItem *>(clone_object);
Geom::Point center = item->getCenter();
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
@@ -554,13 +557,16 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
for (GSList *items = original_selection;
items != NULL;
items = items->next) {
- sp_object_ref(SP_ITEM(items->data));
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ g_assert(item != NULL);
+ sp_object_ref(item);
}
for (GSList *items = original_selection;
items != NULL;
items = items->next) {
- SPItem *item = SP_ITEM(items->data);
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ g_assert(item != NULL);
if (is_transform_modes(tc->mode)) {
if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) {
@@ -576,7 +582,9 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
for (GSList *items = original_selection;
items != NULL;
items = items->next) {
- sp_object_unref(SP_ITEM(items->data));
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
+ g_assert(item != NULL);
+ sp_object_unref(item);
}
}
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 340f64a0b..f56975de2 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -372,13 +372,16 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
{
bool did = false;
- if (SP_IS_BOX3D(item) && !is_transform_mode(mode) && !is_color_mode(mode)) {
- // convert 3D boxes to ordinary groups before tweaking their shapes
- item = box3d_convert_to_group(SP_BOX3D(item));
- selection->add(item);
+ {
+ SPBox3D *box = dynamic_cast<SPBox3D *>(item);
+ if (box && !is_transform_mode(mode) && !is_color_mode(mode)) {
+ // convert 3D boxes to ordinary groups before tweaking their shapes
+ item = box3d_convert_to_group(box);
+ selection->add(item);
+ }
}
- if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) {
GSList *items = g_slist_prepend (NULL, item);
GSList *selected = NULL;
GSList *to_select = NULL;
@@ -387,22 +390,25 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
g_slist_free (items);
SPObject* newObj = doc->getObjectByRepr(static_cast<Inkscape::XML::Node *>(to_select->data));
g_slist_free (to_select);
- item = SP_ITEM(newObj);
+ item = dynamic_cast<SPItem *>(newObj);
+ g_assert(item != NULL);
selection->add(item);
}
- if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item)) {
+ if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
GSList *children = NULL;
for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
+ if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) {
children = g_slist_prepend(children, child);
}
}
for (GSList *i = children; i; i = i->next) {
- SPItem *child = SP_ITEM(i->data);
- if (sp_tweak_dilate_recursive (selection, SP_ITEM(child), p, vector, mode, radius, force, fidelity, reverse))
+ SPItem *child = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ g_assert(child != NULL);
+ if (sp_tweak_dilate_recursive (selection, child, p, vector, mode, radius, force, fidelity, reverse)) {
did = true;
+ }
}
g_slist_free(children);
@@ -509,13 +515,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
}
}
- } else if (SP_IS_PATH(item) || SP_IS_SHAPE(item)) {
+ } else if (dynamic_cast<SPPath *>(item) || dynamic_cast<SPShape *>(item)) {
Inkscape::XML::Node *newrepr = NULL;
gint pos = 0;
Inkscape::XML::Node *parent = NULL;
char const *id = NULL;
- if (!SP_IS_PATH(item)) {
+ if (!dynamic_cast<SPPath *>(item)) {
newrepr = sp_selected_item_to_curved_repr(item, 0);
if (!newrepr) {
return false;
@@ -631,7 +637,8 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (newrepr) {
newrepr->setAttribute("d", str);
} else {
- if (SP_IS_LPE_ITEM(item) && SP_LPE_ITEM(item)->hasPathEffectRecursive()) {
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (lpeitem && lpeitem->hasPathEffectRecursive()) {
item->getRepr()->setAttribute("inkscape:original-d", str);
} else {
item->getRepr()->setAttribute("d", str);
@@ -769,7 +776,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
{
SPGradient *gradient = getGradient(item, fill_or_stroke);
- if (!gradient || !SP_IS_GRADIENT(gradient)) {
+ if (!gradient || !dynamic_cast<SPGradient *>(gradient)) {
return;
}
@@ -780,9 +787,9 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
double pos = 0;
double r = 0;
- if (SP_IS_LINEARGRADIENT(gradient)) {
- SPLinearGradient *lg = SP_LINEARGRADIENT(gradient);
+ SPLinearGradient *lg = dynamic_cast<SPLinearGradient *>(gradient);
+ if (lg) {
Geom::Point p1(lg->x1.computed, lg->y1.computed);
Geom::Point p2(lg->x2.computed, lg->y2.computed);
Geom::Point pdiff(p2 - p1);
@@ -800,11 +807,13 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
// Calculate radius in lenfth-of-gradient-line units
r = radius / vl;
- } else if (SP_IS_RADIALGRADIENT(gradient)) {
- SPRadialGradient *rg = SP_RADIALGRADIENT(gradient);
- Geom::Point c (rg->cx.computed, rg->cy.computed);
- pos = Geom::L2(p - c) / rg->r.computed;
- r = radius / rg->r.computed;
+ } else {
+ SPRadialGradient *rg = dynamic_cast<SPRadialGradient *>(gradient);
+ if (rg) {
+ Geom::Point c (rg->cx.computed, rg->cy.computed);
+ pos = Geom::L2(p - c) / rg->r.computed;
+ r = radius / rg->r.computed;
+ }
}
// Normalize pos to 0..1, taking into accound gradient spread:
@@ -836,14 +845,16 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
double offset_h = 0;
SPObject *child_prev = NULL;
for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- if (!SP_IS_STOP(child)) {
+ SPStop *stop = dynamic_cast<SPStop *>(child);
+ if (!stop) {
continue;
}
- SPStop *stop = SP_STOP (child);
offset_h = stop->offset;
if (child_prev) {
+ SPStop *prevStop = dynamic_cast<SPStop *>(child_prev);
+ g_assert(prevStop != NULL);
if (offset_h - offset_l > r && pos_e >= offset_l && pos_e <= offset_h) {
// the summit falls in this interstop, and the radius is small,
@@ -853,9 +864,9 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
tweak_color (mode, stop->specified_color.v.c, rgb_goal,
force * (pos_e - offset_l) / (offset_h - offset_l),
do_h, do_s, do_l);
- tweak_color (mode, SP_STOP(child_prev)->specified_color.v.c, rgb_goal,
- force * (offset_h - pos_e) / (offset_h - offset_l),
- do_h, do_s, do_l);
+ tweak_color(mode, prevStop->specified_color.v.c, rgb_goal,
+ force * (offset_h - pos_e) / (offset_h - offset_l),
+ do_h, do_s, do_l);
stop->updateRepr();
child_prev->updateRepr();
break;
@@ -863,9 +874,9 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
// wide brush, may affect more than 2 stops,
// paint each stop by the force from the profile curve
if (offset_l <= pos_e && offset_l > pos_e - r) {
- tweak_color (mode, SP_STOP(child_prev)->specified_color.v.c, rgb_goal,
- force * tweak_profile (fabs (pos_e - offset_l), r),
- do_h, do_s, do_l);
+ tweak_color(mode, prevStop->specified_color.v.c, rgb_goal,
+ force * tweak_profile (fabs (pos_e - offset_l), r),
+ do_h, do_s, do_l);
child_prev->updateRepr();
}
@@ -894,10 +905,11 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
{
bool did = false;
- if (SP_IS_GROUP(item)) {
+ if (dynamic_cast<SPGroup *>(item)) {
for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (SP_IS_ITEM(child)) {
- if (sp_tweak_color_recursive (mode, SP_ITEM(child), item_at_point,
+ SPItem *childItem = dynamic_cast<SPItem *>(child);
+ if (childItem) {
+ if (sp_tweak_color_recursive (mode, childItem, item_at_point,
fill_goal, do_fill,
stroke_goal, do_stroke,
opacity_goal, do_opacity,
@@ -953,11 +965,11 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
//cycle through filter primitives
SPObject *primitive_obj = style->getFilter()->children;
while (primitive_obj) {
- if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
- SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj);
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj);
+ if (primitive) {
//if primitive is gaussianblur
- if(SP_IS_GAUSSIANBLUR(primitive)) {
- SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
+ SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive);
+ if (spblur) {
float num = spblur->stdDeviation.getNumber();
blur_now += num * i2dt.descrim(); // sum all blurs in the filter
}
@@ -1080,7 +1092,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point
items != NULL;
items = items->next) {
- SPItem *item = SP_ITEM(items->data);
+ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
if (is_color_mode (tc->mode)) {
if (do_fill || do_stroke || do_opacity) {