/*
* 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 "display/sp-canvas.h"
#include "display/guideline.h"
#include "svg/svg-color.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-root.h"
#include "sp-namedview.h"
#include "document.h"
#include "document-undo.h"
#include "helper-fns.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
: SPObject()
, locked(0)
, color(0x0000ff7f)
, hicolor(0xff00007f)
{}
{
color = c;
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
}
}
{
this->readAttr( "inkscape:color" );
this->readAttr( "inkscape:label" );
this->readAttr( "inkscape:locked" );
this->readAttr( "orientation" );
this->readAttr( "position" );
/* Register */
}
{
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
}
if (this->document) {
// Unregister ourselves
}
}
switch (key) {
case SP_ATTR_INKSCAPE_COLOR:
if (value) {
}
break;
case SP_ATTR_INKSCAPE_LABEL:
// this->label already freed in sp_guideline_set_label (src/display/guideline.cpp)
// see bug #1498444, bug #1469514
if (value) {
} else {
}
break;
case SP_ATTR_INKSCAPE_LOCKED:
if (value) {
this->set_locked(this->locked, 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
}
this->set_normal(this->normal_to_line, false);
}
break;
case SP_ATTR_POSITION:
{
if (value) {
if (success == 2) {
// If root viewBox set, interpret guides in terms of viewBox (90/96)
if( root->viewBox_set ) {
if(Geom::are_near((root->width.computed * root->viewBox.height()) / (root->viewBox.width() * root->height.computed), 1.0, Geom::EPSILON)) {
// for uniform scaling, try to reduce numerical error
double vbunit2px = (root->width.computed / root->viewBox.width() + root->height.computed / root->viewBox.height())/2.0;
} else {
}
}
} 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
this->moveto(this->point_on_line, false);
}
break;
default:
break;
}
}
{
// If root viewBox set, interpret guides in terms of viewBox (90/96)
if( root->viewBox_set ) {
// check to see if scaling is uniform
if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
double px2vbunit = (root->viewBox.width()/root->width.computed + root->viewBox.height()/root->height.computed)/2.0;
} else {
}
}
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) {
}
}
{
}
{
}
}
{
}
{
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
} else {
//reposition to same place to show knots
}
}
}
{
return;
}
}
assert(false);
}
{
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
}
}
}
{
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
return;
}
}
assert(false);
}
{
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.
*/
{
if(this->locked) {
return;
}
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
}
/* 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) {
// If root viewBox set, interpret guides in terms of viewBox (90/96)
if( root->viewBox_set ) {
// check to see if scaling is uniform
if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
double px2vbunit = (root->viewBox.width()/root->width.computed + root->viewBox.height()/root->height.computed)/2.0;
} else {
}
}
//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(attached_items.begin()),
iEnd(attached_items.end());
i != iEnd; ++i)
{
SPGuideAttachment const &att = *i;
sp_item_notify_moveto(*att.item, this, 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.
*/
{
if(this->locked) {
return;
}
for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
}
/* 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(attached_items.begin()),
iEnd(attached_items.end());
i != iEnd; ++i)
{
SPGuideAttachment const &att = *i;
sp_item_notify_moveto(*att.item, this, att.snappoint_ix, position, commit);
}
*/
}
{
}
if (commit) {
//XML Tree being used directly while it shouldn't be
}
}
{
}
if (commit) {
}
}
{
}
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;
if ( !this->document ) {
// 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)
{
}
//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:fileencoding=utf-8:textwidth=99 :