sp-guide.cpp revision d2e42b9425ccd4c2d4c20c2217455da177035e48
/*
* Inkscape guideline implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Peter Moulder <pmoulder@mail.csse.monash.edu.au>
* Johan Engelen
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2000-2002 authors
* Copyright (C) 2004 Monash University
* Copyright (C) 2007 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <algorithm>
#include <cstring>
#include <string>
#include "desktop-handles.h"
#include "display/sp-canvas.h"
#include "display/guideline.h"
#include "svg/stringstream.h"
#include "attributes.h"
#include "sp-guide.h"
#include <sp-item-notify-moveto.h>
#include <sp-item.h>
#include <sp-guide-constraint.h>
#include <remove-last.h>
#include "inkscape.h"
#include "desktop.h"
#include "sp-namedview.h"
#include "document.h"
#include "document-undo.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
//enum {
// PROP_0,
// PROP_COLOR,
// PROP_HICOLOR
//};
//
//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
#include "sp-factory.h"
namespace {
SPObject* createGuide() {
return new SPGuide();
}
}
//static void sp_guide_class_init(SPGuideClass *gc)
//{
// GObjectClass *gobject_class = (GObjectClass *) gc;
//
// gobject_class->set_property = sp_guide_set_property;
// gobject_class->get_property = sp_guide_get_property;
//
// g_object_class_install_property(gobject_class,
// PROP_COLOR,
// g_param_spec_uint("color", "Color", "Color",
// 0,
// 0xffffffff,
// 0xff000000,
// (GParamFlags) G_PARAM_READWRITE));
//
// g_object_class_install_property(gobject_class,
// PROP_HICOLOR,
// g_param_spec_uint("hicolor", "HiColor", "HiColor",
// 0,
// 0xffffffff,
// 0xff000000,
// (GParamFlags) G_PARAM_READWRITE));
//}
// CPPIFY: properties!
this->color = 0x0000ff7f;
this->hicolor = 0xff00007f;
}
}
return color;
}
return hicolor;
}
color = c;
}
}
this->hicolor = h;
}
//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/)
//{
// SPGuide &guide = *SP_GUIDE(object);
//
// switch (prop_id) {
// case PROP_COLOR:
// guide.color = g_value_get_uint(value);
// for (GSList *l = guide.views; l != NULL; l = l->next) {
// sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color);
// }
// break;
//
// case PROP_HICOLOR:
// guide.hicolor = g_value_get_uint(value);
// break;
// }
//}
//
//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/)
//{
// SPGuide const &guide = *SP_GUIDE(object);
//
// switch (prop_id) {
// case PROP_COLOR:
// g_value_set_uint(value, guide.color);
// break;
// case PROP_HICOLOR:
// g_value_set_uint(value, guide.hicolor);
// break;
// }
//}
this->readAttr( "inkscape:label" );
this->readAttr( "orientation" );
this->readAttr( "position" );
/* Register */
}
while (this->views) {
}
if (this->document) {
// Unregister ourselves
}
}
switch (key) {
case SP_ATTR_INKSCAPE_LABEL:
if (value) {
} else {
}
sp_guide_set_label(*this, this->label, false);
break;
case SP_ATTR_ORIENTATION:
{
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
} else if (value) {
this->normal_to_line = direction;
} else {
// default to vertical line for bad arguments
}
} else {
// default to vertical line for bad arguments
}
sp_guide_set_normal(*this, this->normal_to_line, false);
}
break;
case SP_ATTR_POSITION:
{
if (value) {
if (success == 2) {
} else if (success == 1) {
// before 0.46 style guideline definition.
} else {
}
}
} else {
// default to (0,0) for bad arguments
}
// update position in non-committing way
// fixme: perhaps we need to add an update method instead, and request_update here
sp_guide_moveto(*this, this->point_on_line, false);
}
break;
default:
break;
}
}
{
if (namedview) {
}
return guide;
}
void
sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts) {
for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) {
}
}
void
}
void
}
}
{
}
{
return;
}
}
}
{
return;
}
}
}
{
return -(pt - point_on_line);
}
{
}
/**
* \arg commit False indicates temporary moveto in response to motion event while dragging,
* true indicates a "committing" version: in response to button release event after
* dragging a guideline, or clicking OK in guide editing dialog.
*/
{
}
/* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit
case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
if (commit) {
//XML Tree being used here directly while it shouldn't be.
}
/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
iEnd(guide.attached_items.end());
i != iEnd; ++i)
{
SPGuideAttachment const &att = *i;
sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
}
*/
}
/**
* \arg commit False indicates temporary moveto in response to motion event while dragging,
* true indicates a "committing" version: in response to button release event after
* dragging a guideline, or clicking OK in guide editing dialog.
*/
{
}
/* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
if (commit) {
//XML Tree being used directly while it shouldn't be
}
/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
iEnd(guide.attached_items.end());
i != iEnd; ++i)
{
SPGuideAttachment const &att = *i;
sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
}
*/
}
void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit)
{
}
if (commit){
//XML Tree being used directly while it shouldn't be
}
}
{
}
if (commit){
//XML Tree being used directly while it shouldn't be
}
}
/**
* Returns a human-readable description of the guideline for use in dialog boxes and status bar.
* If verbose is false, only positioning information is included (useful for dialogs).
*
* The caller is responsible for freeing the string.
*/
{
using Geom::X;
using Geom::Y;
char *descr = 0;
// Guide has probably been deleted and no longer has an attached namedview.
} else {
gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete"));
} else {
}
if (verbose) {
}
}
return descr;
}
{
i != iEnd; ++i)
{
SPGuideAttachment const &att = *i;
}
//XML Tree being used directly while it shouldn't be.
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :